/* =====================================================================
   learn2gether – Design System v3  (cute pastel, round, bouncy, accessible)
   ---------------------------------------------------------------------
   TOKENS
     colors   --bg --bg-2 --surface --surface-2 --line --text --text-dim
              --accent (strawberry) --accent-ink (text on accent) --accent-soft
              --accent-2 (lavender) --accent-2-soft --accent-2-ink
              --good (mint) --good-ink --good-soft  --warn --warn-ink --warn-soft
              --bad --bad-ink --bad-soft  --peach --butter --sky
     spacing  --s1 4 · --s2 8 · --s3 12 · --s4 16 · --s5 24 · --s6 32 · --s7 48 (px)
     type     --fs-xs 12 · --fs-sm 14 · --fs-md 16 · --fs-lg 20 · --fs-xl 26 · --fs-2xl 34
              --font --font-display --font-mono
     shape    --radius-sm --radius --radius-lg --radius-xl  · --shadow --shadow-sm --shadow-lg
     motion   --ease-bounce (alias --bounce) --ease-out
     layout   --nav-h (mobile bottom nav), --sidebar-w (desktop ≥ 900px)

   LAYOUT      .page (max 720px + gutters; .page.wide = 1040px; combine with .stack-lg for vertical rhythm)
               .page-header > .page-title + .page-subtitle + .page-actions
               .section + .section-title (+ .section-head wrapper for title + trailing)
               .stack (.stack-sm/.stack-lg) · .row (.row-between, .wrap) · .grid-2 · .grid-3
   SURFACES    .card (+ .card-pad-lg, .card-interactive, .card-flat)
               .list > .list-row  (avatar | .list-main [.list-title + .list-sub] | .list-trailing), ≥ 56px
                       .list-row.is-active / a.list-row / button.list-row are interactive
   BUTTONS     .btn  .primary .secondary .ghost .danger · sizes .sm .lg · .block · .icon-btn (44px round)
               .is-loading (shows spinner, blocks clicks)
   BITS        .badge (.good .warn .accent .muted .lavender) · .chip · .stat > .stat-value + .stat-label
   CONTROLS    .seg > button[aria-pressed=true]       (segmented, full width)
               .tabs > button[aria-selected=true]     (scrollable chips)
               .field > label + .input + .hint | .error   (.input also on select/textarea)
               label.switch > input[type=checkbox] + .switch-track  (+ text)
   OVERLAYS    .sheet-backdrop > .sheet[role=dialog] (+ .sheet-handle .sheet-title .sheet-actions)
               add .open to .sheet-backdrop to animate in. Bottom sheet on mobile, dialog ≥ 600px.
   STATES      .skeleton (+ .skeleton-text .skeleton-circle) · .empty > .empty-icon + .empty-title + .empty-text + action
               .spinner (.sm)
   PEOPLE      .avatar-pic (.sm 32 .md 44 .lg 72) > img | initials text; set --av-h (0–360) for fallback tint
               .status-dot (.online .studying .paused .offline) – place inside .avatar-wrap for overlay
   MISC        .muted .h1 .h2 .sr-only .icon (from icons.js) .truncate .tabular
   ===================================================================== */

:root {
  /* colors (v2 names kept) */
  --bg: #fff3f0;
  --bg-2: #fbeae6;
  --surface: #fffdfb;
  --surface-2: #fdeef3;
  --line: rgba(122, 80, 104, 0.14);
  --text: #4a3848;
  --text-dim: #765f7a;            /* 5:1 on --bg */
  --accent: #ff8fab;
  --accent-ink: #4a1426;          /* 7:1 on --accent */
  --accent-soft: #ffe1e9;
  --accent-strong: #d4507a;       /* accent as text on light bg (4.5:1) */
  --accent-2: #b9a6ff;
  --accent-2-soft: #ece6ff;
  --accent-2-ink: #4b36a8;
  --good: #5fd3a0;
  --good-ink: #1d6e4c;
  --good-soft: #dcf7ea;
  --warn: #ffc56b;
  --warn-ink: #7a4a00;
  --warn-soft: #fff1d6;
  --bad: #ef5b72;
  --bad-ink: #a82a42;
  --bad-soft: #ffe3e7;
  --peach: #ffd6a5;
  --butter: #fff3b8;
  --sky: #dff4ff;

  /* spacing */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* type */
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 26px; --fs-2xl: 34px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", "Varela Round", "M PLUS Rounded 1c", "Arial Rounded MT Bold", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Arial Rounded MT Bold", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* shape */
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --radius-xl: 34px;
  --shadow-sm: 0 3px 10px rgba(214, 120, 150, 0.14);
  --shadow: 0 10px 26px rgba(214, 120, 150, 0.18), 0 2px 0 rgba(214, 120, 150, 0.08);
  --shadow-lg: 0 18px 48px rgba(150, 90, 130, 0.25);
  --shadow-press: 0 1px 0 rgba(214, 120, 150, 0.18);
  /* motion */
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --bounce: var(--ease-bounce);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  /* layout */
  --nav-h: 72px;
  --topbar-h: 56px;
  --sidebar-w: 248px;
  color-scheme: light;
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }
/* The `hidden` attribute must always win over component display rules (e.g. .sheet-backdrop is display:flex). */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(circle at 10% 6%, #ffe1ea 0, transparent 36%),
    radial-gradient(circle at 94% 16%, #ebe4ff 0, transparent 34%),
    radial-gradient(circle at 50% 108%, #dff4ff 0, transparent 46%),
    radial-gradient(rgba(255, 143, 171, 0.12) 1.5px, transparent 1.7px) 0 0 / 22px 22px,
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent-strong); }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.icon svg { display: block; }

/* =====================================================================
   SHELL
   ===================================================================== */
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* offline banner */
#offline {
  position: fixed; z-index: 120; left: 50%; top: calc(env(safe-area-inset-top) + 8px);
  transform: translate(-50%, -140%); transition: transform .4s var(--ease-bounce);
  display: flex; align-items: center; gap: var(--s2);
  padding: 8px 16px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 800;
  background: var(--warn-soft); color: var(--warn-ink); border: 2px solid var(--warn); box-shadow: var(--shadow);
  max-width: calc(100% - 24px);
}
#offline.show { transform: translate(-50%, 0); }

/* top bar (mobile) */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  min-height: var(--topbar-h);
  padding: calc(env(safe-area-inset-top) + 8px) var(--s4) 8px;
  background: rgba(255, 250, 248, 0.82);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; /* comfortable touch target without changing the look */
  font-family: var(--font-display); font-weight: 900; font-size: 20px; letter-spacing: -0.01em;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand-2 {
  display: inline-grid; place-items: center;
  width: 1.3em; height: 1.3em; margin: 0 2px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: .82em;
  transform: rotate(-8deg); box-shadow: var(--shadow-sm);
}
/* v2 compat */
.brand > span:not(.brand-2) { color: var(--accent-strong); }
.top-stats { display: flex; gap: var(--s2); }
.top-stats .chip { background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 800; }
.top-stats b { font-variant-numeric: tabular-nums; }

#view {
  flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s5));
}
#view.view-enter { animation: view-in .38s var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }

/* bottom nav (mobile) */
#nav {
  position: fixed; z-index: 20;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  width: calc(100% - 16px); max-width: 520px;
  display: flex; gap: 2px; padding: 6px;
  background: rgba(255, 253, 251, 0.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow-lg);
}
.nav-links { display: contents; }
.nav-item {
  flex: 1 1 0; min-width: 0; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 4px 2px; border-radius: 20px;
  color: var(--text-dim); text-decoration: none; font-size: 11.5px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .2s, color .2s, transform .25s var(--ease-bounce);
}
.nav-item .icon { transition: transform .35s var(--ease-bounce); }
.nav-item:active { transform: scale(0.92); }
.nav-item.active { color: var(--accent-ink); background: var(--accent-soft); }
.nav-item.active .icon { transform: translateY(-1px) scale(1.12); }
.nav-label { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sidebar-only { display: none !important; }

#app.no-chrome #topbar, #app.no-chrome #nav { display: none; }
#app.no-chrome #view { max-width: none; padding-bottom: 0; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 24px) scale(.92); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: var(--s2);
  background: var(--surface); color: var(--text); padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow-lg); border: 2px solid var(--accent-soft);
  font-size: var(--fs-sm); font-weight: 800; z-index: 110;
  transition: opacity .2s, transform .38s var(--ease-bounce); max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* desktop sidebar ≥ 900px */
@media (min-width: 900px) {
  #app { padding-left: var(--sidebar-w); }
  #topbar { display: none; }
  #nav {
    left: 0; top: 0; bottom: 0; transform: none; width: var(--sidebar-w); max-width: none;
    flex-direction: column; gap: var(--s2); padding: var(--s5) var(--s4);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0; border: 0; border-right: 1px solid var(--line);
    background: rgba(255, 253, 251, 0.9); box-shadow: var(--shadow);
    overflow-y: auto;
  }
  .sidebar-only { display: flex !important; }
  .nav-links { display: flex; flex-direction: column; gap: var(--s1); }
  .nav-item {
    flex: none; flex-direction: row; justify-content: flex-start; gap: var(--s3);
    min-height: 48px; padding: 8px 14px; border-radius: var(--radius);
    font-size: var(--fs-md); font-weight: 800;
  }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.active { background: var(--accent-soft); }
  .nav-item.active .icon { transform: scale(1.1); }
  .sidebar-brand { padding: 0 6px var(--s3); font-size: 22px; }
  .sidebar-stats { display: grid !important; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s3); }
  .sidebar-stats .stat { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; }
  .sidebar-user {
    margin-top: auto; align-items: center; gap: var(--s3);
    padding: var(--s3); border-radius: var(--radius-lg); background: var(--surface-2);
  }
  .sidebar-user .list-main { flex: 1; min-width: 0; }
  #view { padding: var(--s4) var(--s4) var(--s6); }
  #toast { bottom: 28px; left: calc(50% + var(--sidebar-w) / 2); }
  #offline { left: calc(50% + var(--sidebar-w) / 2); }
  #app.no-chrome { padding-left: 0; }
}

/* =====================================================================
   LAYOUT
   ===================================================================== */
.page { width: 100%; max-width: 720px; margin: 0 auto; padding: var(--s4); }
.page.wide { max-width: 1040px; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s2) var(--s4); padding: var(--s2) 0 var(--s1); }
.page-header > :first-child { min-width: 0; }
.page-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 900; letter-spacing: -0.01em; line-height: 1.15; display: flex; align-items: center; gap: var(--s2); }
.page-subtitle { margin: 4px 0 0; color: var(--text-dim); font-size: var(--fs-md); }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.section { display: flex; flex-direction: column; gap: var(--s3); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 32px; }
.section-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 800; display: flex; align-items: center; gap: var(--s2); }
.section-title .icon-tile, .icon-tile {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.icon-tile.lavender { background: var(--accent-2-soft); }
.icon-tile.mint { background: var(--good-soft); }
.icon-tile.butter { background: var(--butter); }
.icon-tile.sky { background: var(--sky); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s5); }
.row { display: flex; align-items: center; gap: var(--s2); }
.row-between { justify-content: space-between; }
.row.wrap, .wrap { flex-wrap: wrap; }
.grid-2, .grid-3 { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 520px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 760px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* typography helpers */
.h1 { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 900; letter-spacing: -0.01em; margin: 0; }
.h2 { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 800; margin: 0; }
.muted { color: var(--text-dim); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tabular { font-variant-numeric: tabular-nums; }

/* =====================================================================
   SURFACES
   ===================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s4); box-shadow: var(--shadow);
}
.card-pad-lg { padding: var(--s5); }
.card-flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card-interactive { cursor: pointer; text-decoration: none; color: inherit; display: block; transition: transform .3s var(--ease-bounce), box-shadow .2s; }
.card-interactive:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-interactive:active { transform: scale(.98); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.list-row {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 56px; padding: var(--s2) var(--s3); width: 100%;
  border-radius: var(--radius); background: var(--surface-2);
  border: 2px solid transparent; color: var(--text); text-decoration: none; text-align: left;
}
a.list-row, button.list-row, .list-row.is-interactive {
  appearance: none; cursor: pointer; font: inherit;
  transition: transform .25s var(--ease-bounce), background .15s, border-color .15s;
}
a.list-row:hover, button.list-row:hover, .list-row.is-interactive:hover { background: var(--accent-soft); }
a.list-row:active, button.list-row:active, .list-row.is-interactive:active { transform: scale(.98); }
.list-row.is-active { background: var(--accent-soft); border-color: rgba(255, 143, 171, .5); }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-title { font-weight: 800; min-width: 0; display: flex; align-items: center; gap: 6px; }
.list-sub { color: var(--text-dim); font-size: var(--fs-sm); min-width: 0; }
.list-trailing { flex: none; display: flex; align-items: center; gap: var(--s2); color: var(--text-dim); }

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  appearance: none; position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 10px 20px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-weight: 800; font-size: var(--fs-md); line-height: 1.1; text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 rgba(122, 80, 104, 0.12);
  transition: transform .25s var(--ease-bounce), box-shadow .15s, background .2s, opacity .2s;
  -webkit-user-select: none; user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(3px) scale(0.97); box-shadow: var(--shadow-press); transition-duration: .08s; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 4px 0 #e66d8e, 0 8px 18px rgba(255, 143, 171, 0.32);
}
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 #e66d8e; }
.btn.secondary {
  background: var(--accent-2-soft); color: var(--accent-2-ink); border-color: transparent;
  box-shadow: 0 4px 0 rgba(123, 98, 214, .28);
}
.btn.secondary:active:not(:disabled) { box-shadow: 0 1px 0 rgba(123, 98, 214, .28); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.ghost:active:not(:disabled) { box-shadow: none; }
.btn.danger { background: var(--bad-soft); color: var(--bad-ink); border-color: transparent; box-shadow: 0 4px 0 rgba(239, 91, 114, .25); }
.btn.danger.solid, .btn.danger.is-confirm { background: #c93a53; color: #fff; box-shadow: 0 4px 0 #9c2a3f; }
.btn.sm { min-height: 36px; padding: 6px 14px; font-size: var(--fs-sm); }
.btn.lg { min-height: 54px; padding: 14px 28px; font-size: var(--fs-lg); }
.btn.block { display: flex; width: 100%; }
.icon-btn {
  appearance: none; flex: none; display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform .25s var(--ease-bounce), background .2s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.icon-btn { padding: 0; min-height: 44px; }
.btn.is-loading, .icon-btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > *, .icon-btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after, .icon-btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; border: 3px solid var(--text); border-right-color: transparent; opacity: .7;
  animation: spin .7s linear infinite;
}
.btn.primary.is-loading::after { border-color: var(--accent-ink); border-right-color: transparent; }

/* =====================================================================
   BITS
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 2px 9px; border-radius: 999px; min-height: 22px;
  font-size: var(--fs-xs); font-weight: 900; line-height: 1.2;
  background: var(--accent-2-soft); color: var(--accent-2-ink);
}
.badge.good { background: var(--good-soft); color: var(--good-ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.accent { background: var(--accent); color: var(--accent-ink); }
.badge.muted { background: var(--bg-2); color: var(--text-dim); }
.badge.bad { background: var(--bad-soft); color: var(--bad-ink); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; min-height: 30px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 700;
}
.stat { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.stat-value { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 900; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; line-height: 1.2; }
.stat-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-dim); text-transform: none; }

/* =====================================================================
   CONTROLS
   ===================================================================== */
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-2); border-radius: 999px;
}
.seg > button {
  appearance: none; flex: 1 1 0; min-width: 0; min-height: 40px;
  border: 0; background: transparent; cursor: pointer; border-radius: 999px;
  padding: 8px 10px; font-weight: 800; font-size: var(--fs-sm); color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .25s, color .2s, transform .3s var(--ease-bounce), box-shadow .2s;
}
.seg > button:hover { color: var(--text); }
.seg > button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #e66d8e; }
.seg > button[aria-pressed="true"]:active { transform: scale(.96); }

.tabs {
  display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none;
  padding: 2px 2px 6px; margin: 0 -2px; scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs > button {
  appearance: none; flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 2px solid transparent; background: var(--surface); box-shadow: var(--shadow-sm);
  font-weight: 800; font-size: var(--fs-sm); color: var(--text-dim);
  transition: background .2s, color .2s, transform .25s var(--ease-bounce);
}
.tabs > button:active { transform: scale(.95); }
.tabs > button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: 800; color: var(--text-dim); padding-left: 4px; }
.input, input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 14px; min-height: 46px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { width: 100%; }
.input:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-2-soft); }
.input[aria-invalid="true"], input[aria-invalid="true"] { border-color: var(--bad); }
input::placeholder, textarea::placeholder { color: #9d8a9f; }
.hint { font-size: var(--fs-sm); color: var(--text-dim); margin: 0; padding-left: 4px; }
.error {
  font-size: var(--fs-sm); font-weight: 700; color: var(--bad-ink); margin: 0;
  display: flex; align-items: center; gap: 6px;
}
.error[hidden], .hint[hidden] { display: none; }

.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; user-select: none; font-weight: 700; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  flex: none; position: relative; width: 52px; height: 32px; border-radius: 999px;
  background: var(--bg-2); border: 2px solid var(--line); transition: background .2s, border-color .2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 2px 4px rgba(122, 80, 104, .3);
  transition: transform .35s var(--ease-bounce);
}
.switch input:checked + .switch-track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.switch:has(input:disabled) { cursor: not-allowed; }

/* =====================================================================
   OVERLAYS
   ===================================================================== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(74, 56, 72, 0); transition: background .25s;
}
.sheet-backdrop.open { background: rgba(74, 56, 72, .38); }
.sheet {
  width: 100%; max-width: 540px; max-height: 92vh; max-height: 92dvh; overflow: auto;
  display: flex; flex-direction: column; gap: var(--s4);
  padding: var(--s2) var(--s5) calc(env(safe-area-inset-bottom) + var(--s5));
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .42s var(--ease-bounce);
  overscroll-behavior: contain;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-handle { width: 44px; height: 5px; border-radius: 999px; background: var(--accent-soft); margin: 4px auto 0; flex: none; }
.sheet-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 900; display: flex; align-items: center; gap: var(--s2); }
.sheet-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.sheet-actions .btn.primary { flex: 1 1 auto; }
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; padding: var(--s4); }
  .sheet { border-radius: var(--radius-xl); padding-bottom: var(--s5); transform: translateY(24px) scale(.95); opacity: 0; transition: transform .38s var(--ease-bounce), opacity .2s; }
  .sheet-backdrop.open .sheet { transform: none; opacity: 1; }
  .sheet-handle { display: none; }
}

/* =====================================================================
   STATES
   ===================================================================== */
.skeleton {
  display: block; min-height: 16px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-2) 20%, var(--surface-2) 40%, var(--bg-2) 60%);
  background-size: 250% 100%; animation: shimmer 1.4s linear infinite;
}
.skeleton-text { height: 14px; border-radius: 999px; }
.skeleton-circle { border-radius: 50%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: var(--s5) var(--s3); }
.empty-icon {
  display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%;
  background: var(--accent-2-soft); margin-bottom: var(--s1);
  animation: float 3.2s ease-in-out infinite;
}
.empty-title { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: var(--fs-lg); }
.empty-text { margin: 0 0 var(--s2); color: var(--text-dim); max-width: 34ch; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-5deg); } }

.spinner {
  display: inline-block; width: 28px; height: 28px; border-radius: 50%;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   PEOPLE
   ===================================================================== */
.avatar-wrap { position: relative; flex: none; display: inline-flex; }
.avatar-pic {
  --av-h: 340;
  flex: none; position: relative; display: inline-grid; place-items: center; overflow: hidden;
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(180deg, hsl(var(--av-h) 90% 93%), hsl(var(--av-h) 80% 85%));
  color: hsl(var(--av-h) 45% 28%);
  font-family: var(--font-display); font-weight: 900; font-size: 18px;
  border: 3px solid var(--surface); box-shadow: 0 3px 8px hsl(var(--av-h) 50% 70% / .45);
}
.avatar-pic img { width: 116%; height: 116%; max-width: none; object-fit: cover; object-position: 50% 28%; display: block; }
.avatar-pic.sm { width: 32px; height: 32px; font-size: 14px; border-width: 2px; }
.avatar-pic.md { width: 44px; height: 44px; }
.avatar-pic.lg { width: 72px; height: 72px; font-size: 28px; border-width: 4px; }
.avatar-pic.pop { animation: pop .45s var(--ease-bounce); }
@keyframes pop { from { transform: scale(.6); } }

.status-dot {
  display: inline-block; flex: none; position: relative;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-dim); border: 2px solid var(--surface); box-sizing: content-box;
}
.avatar-wrap > .status-dot { position: absolute; right: -1px; bottom: -1px; }
.status-dot.online { background: var(--accent-2); }
.status-dot.studying { background: var(--good); }
.status-dot.studying::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--good); animation: pulse 1.8s ease-out infinite;
}
.status-dot.paused { background: var(--warn); }
.status-dot.offline { background: #cbbfcc; }
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.3); opacity: 0; } }

/* =====================================================================
   MOTION PREFS
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media (max-width: 370px) {
  .brand { font-size: 18px; }
  .top-stats .chip { padding: 3px 9px; font-size: 13px; }
  .nav-item { font-size: 10.5px; }
}

/* sound settings */
.top-stats { align-items: center; }
.top-stats .snd-btn { margin-right: -6px; }
.sidebar-user:has(.snd-btn) { gap: var(--s2); padding-right: var(--s2); }
.sidebar-user .snd-btn, .sidebar-user .snd-btn + .icon-btn { margin: 0 -4px; }
.snd-label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.snd-val { font-weight: 800; color: var(--accent-strong); font-size: var(--fs-sm); }
.snd-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0;
  background: transparent; cursor: pointer; padding: 0; border: 0;
}
.snd-range:focus { outline: none; box-shadow: none; background: transparent; }
.snd-range::-webkit-slider-runnable-track { height: 12px; border-radius: 999px; background: var(--accent-soft); }
.snd-range::-moz-range-track { height: 12px; border-radius: 999px; background: var(--accent-soft); }
.snd-range::-moz-range-progress { height: 12px; border-radius: 999px; background: var(--accent); }
.snd-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -8px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease-bounce);
}
.snd-range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow-sm);
}
.snd-range:active::-webkit-slider-thumb { transform: scale(1.15); }
.snd-range:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.snd-range:focus-visible::-moz-range-thumb { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.snd-range:disabled { opacity: .45; cursor: not-allowed; }
.snd-switches { display: flex; flex-direction: column; gap: var(--s1); }
.snd-switches .switch { justify-content: space-between; flex-direction: row-reverse; }
.snd-sheet.is-muted .snd-field { opacity: .7; }
