/* ==========================================================================
   Moon Desk — design system
   Tokens → base → app shell → shared components → views → study room
   ========================================================================== */

/* ---------- fonts (self-hosted, SIL OFL; see fonts/OFL-*.txt) ---------- */
@font-face { font-family: 'DM Sans'; src: url(fonts/dmsans.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url(fonts/fraunces.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url(fonts/fraunces-italic.woff2) format('woff2'); font-weight: 300 700; font-style: italic; font-display: swap; }
/* Brand = Instrument Serif (SIL OFL, loaded from Google Fonts in index.html).
   Note = Pangolin, a stand-in for PaperNotes until its webfont license is in hand. */
@font-face { font-family: 'Moon Note'; src: url(fonts/pangolin.woff2) format('woff2'); font-display: swap; }

/* ---------- tokens ---------- */
:root {
  --font-ui: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-brand: 'Instrument Serif', 'Fraunces', Georgia, serif;
  --night: #1D2850;
  --night-2: #151D3C;
  --moon: #F4C552;
  --moon-text: #F6EBD9;
  --font-note: 'Moon Note', 'Segoe Print', 'Comic Sans MS', cursive;

  --fs-xs: .8125rem;
  --fs-sm: .9rem;
  --fs-base: 1rem;
  --fs-lg: clamp(1.1rem, 1rem + .35vw, 1.25rem);
  --fs-xl: clamp(1.35rem, 1.1rem + .9vw, 1.75rem);
  --fs-2xl: clamp(1.75rem, 1.3rem + 1.8vw, 2.5rem);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-pill: 999px;
  --gap: clamp(16px, 2.4vw, 28px);
  --side-w: 236px;
  --side-w-collapsed: 76px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --theme-ms: 500ms;
}

:root, :root[data-theme="dark"] {
  /* Night (default): the deep cobalt sky and moon gold of the Moon Desk painting */
  color-scheme: dark;
  --bg: #071537;
  --surface: #102352;
  --surface-2: #1A3168;
  --sunk: #0C1C46;
  --text: #F6ECD8;
  --text-2: #B6C0E0;
  --accent: #F2C23C;
  --accent-strong: #F7CB4D;
  --on-accent: #0A1940;
  --border: #2A4283;
  --focus: #FDD66A;
  --danger: #FF8A73;
  --ember: #FF9A4D;
  --shadow: 0 1px 2px rgba(0, 4, 20, .4), 0 14px 32px -16px rgba(0, 4, 20, .8);
  --shadow-lg: 0 2px 8px rgba(0, 4, 20, .45), 0 28px 64px -24px rgba(0, 4, 20, .9);
  --tint-mix: 20%;
  --photo-frame: #F4EAD6;
  --card-sheen: linear-gradient(180deg, rgba(255, 236, 190, .05), rgba(255, 236, 190, 0) 45%);
  --card-edge: rgba(242, 194, 60, .12);
  --stars: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cdefs%3E%3Cpath id='s' d='M0-6L1.53-2.1L5.71-1.85L2.47.8L3.53 4.85L0 2.6L-3.53 4.85L-2.47.8L-5.71-1.85L-1.53-2.1Z'/%3E%3C/defs%3E%3Cg fill='%23F7CB4D'%3E%3Cuse href='%23s' transform='translate(38 52) rotate(12) scale(1.0)' opacity='0.85'/%3E%3Cuse href='%23s' transform='translate(212 34) rotate(-8) scale(0.7)' opacity='0.85'/%3E%3Cuse href='%23s' transform='translate(318 148) rotate(20) scale(1.15)' opacity='0.85'/%3E%3Cuse href='%23s' transform='translate(96 236) rotate(-15) scale(0.8)' opacity='0.85'/%3E%3Cuse href='%23s' transform='translate(262 300) rotate(6) scale(0.9)' opacity='0.85'/%3E%3Cuse href='%23s' transform='translate(370 368) rotate(-22) scale(0.65)' opacity='0.85'/%3E%3Cuse href='%23s' transform='translate(150 388) rotate(30) scale(0.7)' opacity='0.85'/%3E%3Ccircle cx='120' cy='90' r='2' opacity='0.7'/%3E%3Ccircle cx='182' cy='160' r='1.4' opacity='0.7'/%3E%3Ccircle cx='30' cy='170' r='1.6' opacity='0.7'/%3E%3Ccircle cx='350' cy='60' r='1.8' opacity='0.7'/%3E%3Ccircle cx='260' cy='210' r='1.2' opacity='0.7'/%3E%3Ccircle cx='70' cy='330' r='1.8' opacity='0.7'/%3E%3Ccircle cx='330' cy='250' r='1.3' opacity='0.7'/%3E%3Ccircle cx='200' cy='330' r='1.6' opacity='0.7'/%3E%3Ccircle cx='395' cy='200' r='1.2' opacity='0.7'/%3E%3Ccircle cx='16' cy='400' r='1.4' opacity='0.7'/%3E%3Ccircle cx='240' cy='110' r='1' opacity='0.7'/%3E%3Ccircle cx='130' cy='300' r='1' opacity='0.7'/%3E%3C/g%3E%3C/svg%3E");
  --grain-op: .07;
  --sky:
    radial-gradient(900px 520px at 88% -8%, rgba(242, 194, 60, .13), transparent 62%),
    radial-gradient(1000px 700px at -10% 110%, rgba(40, 90, 200, .28), transparent 60%);
}
:root[data-theme="light"] {
  /* Moonlit paper: cream pages, midnight ink, gold leaf */
  color-scheme: light;
  --bg: #EFE5D2;
  --surface: #FAF4E8;
  --surface-2: #E9DEC8;
  --sunk: #E4D8C0;
  --text: #15224D;
  --text-2: #475584;
  --accent: #C8951C;
  --accent-strong: #1C2D6B;
  --on-accent: #FBF4E4;
  --border: #D9CBB0;
  --focus: #1C2D6B;
  --danger: #B0412F;
  --ember: #C2611F;
  --shadow: 0 1px 2px rgba(21, 34, 77, .07), 0 12px 30px -16px rgba(21, 34, 77, .32);
  --shadow-lg: 0 2px 6px rgba(21, 34, 77, .09), 0 26px 60px -22px rgba(21, 34, 77, .45);
  --tint-mix: 30%;
  --photo-frame: #FFFDF7;
  --card-sheen: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 45%);
  --card-edge: rgba(28, 45, 107, .07);
  --stars: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cdefs%3E%3Cpath id='s' d='M0-6L1.53-2.1L5.71-1.85L2.47.8L3.53 4.85L0 2.6L-3.53 4.85L-2.47.8L-5.71-1.85L-1.53-2.1Z'/%3E%3C/defs%3E%3Cg fill='%231C2D6B'%3E%3Cuse href='%23s' transform='translate(38 52) rotate(12) scale(1.0)' opacity='0.22'/%3E%3Cuse href='%23s' transform='translate(212 34) rotate(-8) scale(0.7)' opacity='0.22'/%3E%3Cuse href='%23s' transform='translate(318 148) rotate(20) scale(1.15)' opacity='0.22'/%3E%3Cuse href='%23s' transform='translate(96 236) rotate(-15) scale(0.8)' opacity='0.22'/%3E%3Cuse href='%23s' transform='translate(262 300) rotate(6) scale(0.9)' opacity='0.22'/%3E%3Cuse href='%23s' transform='translate(370 368) rotate(-22) scale(0.65)' opacity='0.22'/%3E%3Cuse href='%23s' transform='translate(150 388) rotate(30) scale(0.7)' opacity='0.22'/%3E%3Ccircle cx='120' cy='90' r='2' opacity='0.2'/%3E%3Ccircle cx='182' cy='160' r='1.4' opacity='0.2'/%3E%3Ccircle cx='30' cy='170' r='1.6' opacity='0.2'/%3E%3Ccircle cx='350' cy='60' r='1.8' opacity='0.2'/%3E%3Ccircle cx='260' cy='210' r='1.2' opacity='0.2'/%3E%3Ccircle cx='70' cy='330' r='1.8' opacity='0.2'/%3E%3Ccircle cx='330' cy='250' r='1.3' opacity='0.2'/%3E%3Ccircle cx='200' cy='330' r='1.6' opacity='0.2'/%3E%3Ccircle cx='395' cy='200' r='1.2' opacity='0.2'/%3E%3Ccircle cx='16' cy='400' r='1.4' opacity='0.2'/%3E%3Ccircle cx='240' cy='110' r='1' opacity='0.2'/%3E%3Ccircle cx='130' cy='300' r='1' opacity='0.2'/%3E%3C/g%3E%3C/svg%3E");
  --grain-op: .09;
  --sky: radial-gradient(1000px 560px at 90% -10%, rgba(242, 194, 60, .22), transparent 62%);
}
/* tile tints: night blues, moon gold and ember, mixed into the surface */
:root { --latte: #F2C23C; --clay: #FF8A5C; --sage: #4FB3A9; --dusk: #4F7BF0; --honey: #F7CB4D; --logo-sky: #02275F; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--sky), var(--stars), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 400; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E"); opacity: var(--grain-op); mix-blend-mode: soft-light;
}
body.in-room { overflow: hidden; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 .75em; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; }
a { color: var(--accent-strong); }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 300; padding: 8px 14px; background: var(--surface); border-radius: var(--r-sm); box-shadow: var(--shadow); }
.skip:focus { top: 12px; }
.hint { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.center { text-align: center; }
.note { font-family: var(--font-note); }
.hl { font-family: var(--font-display); font-weight: 600; }

/* theme switch: soft cross-fade fallback + circular reveal via View Transitions */
.theme-fading, .theme-fading * {
  transition: background-color var(--theme-ms) var(--ease), color var(--theme-ms) var(--ease),
    border-color var(--theme-ms) var(--ease), fill var(--theme-ms) var(--ease) !important;
}
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-reveal var(--theme-ms) var(--ease); }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0)); }
  to { clip-path: circle(150vmax at var(--vt-x, 100%) var(--vt-y, 0)); }
}

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; width: var(--side-w); flex: none; z-index: 40;
  display: flex; flex-direction: column; gap: 6px; padding: 22px 14px 16px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  transition: width .3s var(--ease);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; }
.brand-mark { width: 44px; height: 44px; flex: none; border-radius: 12px; object-fit: cover; box-shadow: 0 6px 16px -6px rgba(0, 10, 40, .7), 0 0 0 1px rgba(253, 198, 7, .25); }
.wordmark { font-family: var(--font-brand); font-style: normal; font-weight: 400; font-size: 1.7rem; line-height: 1; letter-spacing: -.005em; }
.wordmark em { font-style: italic; color: var(--accent-strong); }
.topbar-brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; white-space: nowrap; }
.wordmark, .streak-chip { white-space: nowrap; }
.topbar-brand .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 46px; padding: 0 14px;
  border: none; border-radius: var(--r-md); background: transparent; color: var(--text-2);
  font-weight: 500; text-align: left; white-space: nowrap; overflow: hidden;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.nav-item:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active .icon { color: var(--accent-strong); }
.nav-label { transition: opacity .2s var(--ease); }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.nav-quote { margin: 0 8px; padding: 12px 14px; border-radius: var(--r-md); background: var(--sunk); color: var(--text-2); font-family: var(--font-note); font-size: var(--fs-sm); line-height: 1.4; }
.collapse-btn .icon { transition: transform .3s var(--ease); }

/* desktop: collapsed rail of icons */
@media (min-width: 861px) {
  .nav-collapsed .sidebar { width: var(--side-w-collapsed); }
  .nav-collapsed .nav-label, .nav-collapsed .wordmark, .nav-collapsed .nav-quote { opacity: 0; pointer-events: none; }
  .nav-collapsed .nav-quote { display: none; }
  .nav-collapsed .collapse-btn .icon { transform: rotate(180deg); }
  .topbar .menu-btn, .topbar .topbar-brand { display: none; }
  .scrim { display: none !important; }
}

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 10px var(--gap);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.page-title { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: none; border-radius: var(--r-pill); background: transparent; color: var(--text);
  transition: background-color .2s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.streak-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  border: none; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow);
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.streak-chip.cold { color: var(--text-2); box-shadow: none; background: var(--surface-2); }
.avatar-btn { font-size: 22px; background: var(--surface); box-shadow: var(--shadow); }
[hidden] { display: none !important; }

/* sun ⇄ moon toggle */
.theme-toggle { color: var(--text); }
.theme-toggle svg { width: 24px; height: 24px; overflow: visible; }
.theme-toggle .sun-core, .theme-toggle .moon-bite { transition: r .5s var(--ease), cx .5s var(--ease), cy .5s var(--ease); }
.theme-toggle .rays { transform-origin: 12px 12px; transition: transform .5s var(--ease), opacity .35s var(--ease); }
[data-theme="dark"] .theme-toggle .sun-core { r: 8px; }
[data-theme="dark"] .theme-toggle .moon-bite { cx: 17px; cy: 8px; }
[data-theme="dark"] .theme-toggle .rays { transform: rotate(-60deg) scale(.4); opacity: 0; }
.theme-toggle.glow { animation: toggle-glow .7s var(--ease); }
@keyframes toggle-glow { 40% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 25%, transparent), 0 0 24px 6px color-mix(in srgb, var(--accent) 35%, transparent); } }

main { width: 100%; max-width: 1020px; margin: 0 auto; padding: 8px var(--gap) 96px; }
.topbar { max-width: 100%; }
@media (min-width: 861px) { .page-title { padding-left: max(0px, calc((100% - 1020px) / 2)); } }
.view { display: none; }
.view.active { display: block; animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* phones + small tablets: off-canvas drawer */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 84vw);
    background: var(--surface); box-shadow: var(--shadow-lg); border-right: none;
    transform: translateX(-105%); visibility: hidden;
    transition: transform .3s var(--ease), visibility 0s linear .3s;
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform .3s var(--ease); }
  .collapse-btn { display: none; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(33, 29, 27, .35); opacity: 0; transition: opacity .3s var(--ease); }
  .nav-open .scrim { opacity: 1; }
  .page-title { display: none; }
  .topbar { padding: 8px 12px; min-height: 60px; }
  .topbar-brand .wordmark { font-size: 1.4rem; }
  .topbar-right { gap: 6px; }
  main { padding: 4px 16px 88px; }
}

/* ---------- shared components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-sm); line-height: 1.2;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease);
}
.btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.off { background: var(--surface-2); color: var(--text-2); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.btn-row.center { justify-content: center; }
.link { background: none; border: none; padding: 0; color: var(--accent-strong); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.line-input {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--sunk); color: var(--text); font: inherit; outline: none;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.line-input::placeholder { color: color-mix(in srgb, var(--text-2) 75%, transparent); }
.line-input:focus { border-color: var(--accent); background: var(--surface); }
textarea.line-input { min-height: 104px; resize: vertical; line-height: 1.5; }
select.line-input { cursor: pointer; }
.field { display: block; margin: 16px 0; font-weight: 600; font-size: var(--fs-sm); }
.field > .line-input, .field > select, .field > textarea { margin-top: 6px; font-weight: 400; font-size: var(--fs-base); }
.field small { font-weight: 400; }

/* surfaces: .sketch is the legacy class name used across the views */
.sketch { position: relative; background: var(--card-sheen), var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow), inset 0 0 0 1px var(--card-edge); }
.sticky {
  position: relative; display: block; text-align: left; border: none; border-radius: var(--r-lg); padding: 18px 20px;
  background: color-mix(in srgb, var(--c, var(--latte)) var(--tint-mix), var(--surface)); color: var(--text);
}
.sticky b { display: block; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-2xl); line-height: 1.1; font-variant-numeric: lining-nums; }
.sticky small { display: block; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.4; margin-top: 2px; }
.yellow { --c: var(--honey); } .pink { --c: var(--clay); } .green { --c: var(--sage); } .blue { --c: var(--dusk); } .peach { --c: var(--latte); }
/* legacy inline names used by older templates */
:root { --yellow: var(--honey); --pink: var(--clay); --green: var(--sage); --blue: var(--dusk); --peach: var(--latte); }

.avatar { width: 46px; height: 46px; flex: none; display: grid; place-items: center; font-size: 24px; border: none; border-radius: 50%; background: var(--surface-2); }
.avatar.big { width: 84px; height: 84px; font-size: 46px; }
/* picture avatars (illustrated or photo) fill whatever round frame they're in */
.av-img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar, .avatar-btn { overflow: hidden; padding: 0; }
.av-inline { display: inline-block; width: 1.45em; height: 1.45em; border-radius: 50%; object-fit: cover; vertical-align: -.38em; }
.avatar.big { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--accent) 60%, transparent); }
/* avatar picker */
.av-tabs { margin: 8px 0 12px; }
.pick-art span { width: 60px; height: 60px; padding: 0; overflow: hidden; border-width: 3px; }
.pick-art img { width: 100%; height: 100%; display: block; }
.pick-art input:checked + span { transform: scale(1.1); box-shadow: 0 0 16px -2px color-mix(in srgb, var(--accent) 70%, transparent); }
.photo-pane { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.photo-pane[hidden] { display: none; }
#avCanvas { width: 150px; height: 150px; border-radius: 50%; cursor: grab; touch-action: none; box-shadow: 0 0 0 3px var(--accent); background: var(--sunk); }
#avCanvas:active { cursor: grabbing; }
.photo-tools { flex: 1; min-width: 180px; font-weight: 400; }
.photo-tools .zoom { margin: 12px 0 4px; }
.photo-tools input[type=range] { width: 100%; accent-color: var(--accent); }
.pick { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span {
  width: 48px; height: 48px; display: grid; place-items: center; font-size: 24px; cursor: pointer;
  border-radius: 50%; background: var(--sunk); border: 2px solid transparent; transition: transform .15s var(--ease), border-color .15s;
}
.pick input:checked + span { border-color: var(--accent-strong); background: var(--surface); transform: scale(1.08); }
.pick input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }

.empty { padding: clamp(28px, 5vw, 48px) 24px; text-align: center; }
.empty .doodle { font-family: var(--font-brand); font-size: 2.4rem; line-height: 1; color: var(--accent); margin-bottom: 10px; }
.empty h3 { font-size: var(--fs-xl); }
.empty p { color: var(--text-2); max-width: 46ch; margin: 0 auto 4px; }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(33, 29, 27, .45); animation: fade .2s var(--ease); }
.modal.hidden { display: none; }
.modal-card { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: clamp(20px, 4vw, 30px); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: pop-in .28s var(--ease); }
.modal-card h2 { font-size: var(--fs-xl); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; max-width: calc(100vw - 32px);
  padding: 12px 20px; border-radius: var(--r-pill); background: var(--text); color: var(--bg);
  font-weight: 500; box-shadow: var(--shadow-lg); pointer-events: none;
  transform: translate(-50%, calc(100% + 48px)); transition: transform .3s var(--ease);
}
.toast.show { transform: translate(-50%, 0); }
.toast.big { font-family: var(--font-display); font-size: var(--fs-lg); padding: 14px 26px; }

/* ---------- feed ---------- */
.feed-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin: 4px 0 28px; }
.start-cta { cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-lg); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.start-cta small { font-family: var(--font-ui); font-weight: 400; }
.start-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.card { padding: 20px 22px 16px; margin: 0 0 20px; animation: rise .35s var(--ease) both; }
.card header { display: flex; gap: 12px; align-items: center; line-height: 1.3; }
.card header small { display: block; color: var(--text-2); font-size: var(--fs-xs); }
.card .title { font-size: var(--fs-lg); margin: 14px 0 4px; }
.card .note { font-family: var(--font-ui); color: var(--text); margin: 4px 0; white-space: pre-wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; padding: 12px 0 0; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.stats small { display: block; color: var(--text-2); font-size: var(--fs-xs); }
.stats b { display: block; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.kudos { min-height: 38px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--r-pill); background: transparent; font-size: var(--fs-sm); font-weight: 500; transition: background-color .2s var(--ease); }
.kudos.on { background: color-mix(in srgb, var(--ember) 16%, transparent); border-color: color-mix(in srgb, var(--ember) 55%, transparent); color: var(--text); }
.kudos-count { color: var(--text-2); font-size: var(--fs-sm); }
.name-link { background: none; border: none; padding: 0; font-weight: 600; text-align: left; }
.name-link:hover { text-decoration: underline; text-underline-offset: 3px; }
button.avatar { padding: 0; cursor: pointer; }

.dump { display: flex; flex-wrap: wrap; gap: 16px; padding: 14px 2px 6px; }
.polaroid {
  position: relative; margin: 0; width: 150px; padding: 7px 7px 22px; background: var(--photo-frame);
  border-radius: 3px; box-shadow: 0 8px 16px -8px rgba(40, 28, 20, .45);
  transform: rotate(calc(var(--r, 0deg) * .6)); transition: transform .2s var(--ease);
}
.polaroid:hover { transform: rotate(0) scale(1.03); z-index: 2; }
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; border-radius: 1px; }
.polaroid .ph { aspect-ratio: 1; display: grid; place-items: center; color: var(--text-2); background: var(--sunk); }
.polaroid.small { width: 104px; padding: 5px 5px 16px; }
.polaroid .x, .goals .x {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; padding: 0; line-height: 1;
  border: none; border-radius: 50%; background: var(--text); color: var(--bg);
}
.lightbox { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border: 8px solid var(--photo-frame); border-radius: 4px; }

/* ---------- timer ---------- */
.timer-page { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding-top: 8px; }
.mode-row { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); }
.mode { min-height: 40px; padding: 0 16px; border: none; border-radius: var(--r-pill); background: transparent; color: var(--text-2); font-weight: 500; font-size: var(--fs-sm); }
.mode.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.clock-wrap { position: relative; width: min(320px, 78vw); aspect-ratio: 1; margin: 10px 0; }
.clock-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--accent-strong); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .4s linear; }
.clock-face { position: absolute; inset: 0; display: grid; place-content: center; }
.clock { font-family: var(--font-ui); font-weight: 500; font-size: clamp(3rem, 13vw, 4.6rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.clock-sub { font-family: var(--font-note); color: var(--text-2); margin-top: 10px; }
.timer-page .line-input { max-width: 440px; text-align: center; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tag { display: inline-block; padding: 0 8px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-xs); line-height: 1.6; }

/* ---------- timer pill (top bar, while the sheet is closed) ---------- */
.timer-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: none; border-radius: var(--r-pill);
  background: var(--accent-strong); color: var(--on-accent); font-weight: 600; font-variant-numeric: tabular-nums; box-shadow: var(--shadow);
  animation: pop-in .25s var(--ease);
}
.timer-pill span { font-weight: 500; opacity: .85; }
.timer-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.timer-pill .dot.live { opacity: 1; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; transform: scale(.8); } }
@media (max-width: 480px) { .timer-pill span { display: none; } }

/* ---------- focus view: the timer takes the whole screen ---------- */
/* Always night here, in the painting's own sky, whatever the app theme is. */
.sheet-wrap {
  --bg: var(--logo-sky); --surface: #0D2E6E; --surface-2: #163C86; --sunk: #0A2865;
  --text: #F7EEDB; --text-2: #BCC8EA; --accent: #FDC607; --accent-strong: #F9CD3A; --on-accent: #071A46;
  --border: #2D4E99; --focus: #FFE07A;
  position: fixed; inset: 0; z-index: 90; color: var(--text); overflow: auto;
  background:
    radial-gradient(800px 520px at 50% 38%, rgba(253, 198, 7, .10), transparent 65%),
    var(--stars), linear-gradient(180deg, #03204F, var(--logo-sky) 40%, #021E4C);
  animation: focus-in .35s var(--ease);
}
.sheet-wrap.hidden { display: none; }
body.sheet-open { overflow: hidden; }
@keyframes focus-in { from { opacity: 0; transform: scale(1.015); } }
/* the logo painting rests in the corner, fading into the same sky */
.sheet-wrap::before {
  content: ""; position: fixed; right: -2vw; bottom: -4vh; width: min(46vh, 40vw); aspect-ratio: 1; pointer-events: none;
  background: url(assets/logo.webp) center / cover;
  -webkit-mask-image: radial-gradient(closest-side, #000 62%, transparent 100%); mask-image: radial-gradient(closest-side, #000 62%, transparent 100%);
  opacity: .95;
}
.sheet {
  position: relative; min-height: 100%; width: min(760px, 100%); margin: 0 auto;
  display: flex; flex-direction: column; padding: max(18px, env(safe-area-inset-top)) clamp(16px, 4vw, 32px) max(24px, env(safe-area-inset-bottom));
}
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head .icon-btn { color: var(--text); background: rgba(255, 255, 255, .06); }
.sheet-head .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: rgba(0, 10, 40, .35); box-shadow: inset 0 0 0 1px rgba(253, 198, 7, .12); }
.phase { min-height: 38px; padding: 0 16px; border: none; border-radius: var(--r-pill); background: transparent; color: var(--text-2); font-weight: 500; font-size: var(--fs-sm); white-space: nowrap; }
.phase.active { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 18px -4px rgba(253, 198, 7, .6); }
.sw-label { margin: 0; font-weight: 600; color: var(--text-2); }
.ts-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8px 0; }
.ts-main .clock-wrap { width: min(54vh, 78vw, 460px); margin: 8px 0 18px; }
.ts-main .ring-bg { stroke: rgba(255, 255, 255, .08); stroke-width: 6; }
.ts-main .ring-fg { stroke: var(--accent); stroke-width: 7; filter: drop-shadow(0 0 6px rgba(253, 198, 7, .55)); }
.ts-main .clock { font-size: clamp(3.4rem, 11vh, 6.5rem); font-weight: 400; letter-spacing: -.03em; }
.ts-main .clock-sub { font-size: 1.1rem; }
.ts-main .line-input { max-width: 380px; text-align: center; background: rgba(0, 10, 40, .35); border-color: rgba(253, 198, 7, .14); }
.ts-main .btn-row { margin-top: 18px; }
.ts-main .btn-row .btn { min-width: 132px; min-height: 50px; font-size: var(--fs-base); }
.ts-main .btn { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: var(--text); }
.ts-main .btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 0 28px -8px rgba(253, 198, 7, .7); }
.finish { margin-top: 12px; min-width: 276px; }
#focusTally { margin: 14px 0 0; }
#focusTally b { color: var(--text); }
.kbd-hint { font-size: var(--fs-xs); margin: 8px 0 0; }
@media (hover: none) { .kbd-hint { display: none; } }
.ts-settings { width: min(460px, 100%); margin: 24px auto; padding: 22px 24px; border-radius: var(--r-lg); background: rgba(6, 24, 66, .82); box-shadow: inset 0 0 0 1px rgba(253, 198, 7, .14); }
.ts-settings fieldset { border: none; padding: 0; margin: 12px 0; }
.ts-settings legend { padding: 0; margin-bottom: 8px; }
.seg-full { display: flex; width: 100%; }
.seg-full label { flex: 1; }
.seg-full input { position: absolute; opacity: 0; pointer-events: none; }
.seg-full span { display: grid; place-items: center; min-height: 40px; border-radius: var(--r-pill); color: var(--text-2); font-weight: 500; cursor: pointer; }
.seg-full input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg-full input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.ts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.ts-grid .field { margin: 8px 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: var(--fs-sm); line-height: 1.4; cursor: pointer; }
.check input { accent-color: var(--accent-strong); width: 18px; height: 18px; margin: 1px 0 0; flex: none; }
.timed-min { margin: 6px 0 2px; font-weight: 400; font-size: var(--fs-base); }
.timed-min b { font-family: var(--font-display); font-size: var(--fs-xl); margin-right: 6px; }
@media (max-width: 640px) {
  .phase { padding: 0 11px; font-size: var(--fs-xs); }
  .sheet-wrap::before { width: 46vw; opacity: .55; }
  .ts-main .btn-row .btn { min-width: 112px; }
  .finish { min-width: 236px; }
}

/* ---------- home ---------- */
.greet { margin: 4px 0 6px; color: var(--text-2); font-size: var(--fs-lg); }
/* the night-sky card: the Moon Desk painting itself, its sky running into the card */
.quote {
  position: relative; overflow: hidden; isolation: isolate; margin: 0 0 var(--gap);
  min-height: clamp(220px, 30vw, 320px); display: flex; flex-direction: column; justify-content: center;
  padding: clamp(24px, 4vw, 44px); padding-right: clamp(150px, 38%, 380px);
  border-radius: var(--r-lg); color: #F7EEDB; background: var(--logo-sky);
  box-shadow: 0 2px 6px rgba(0, 10, 40, .25), 0 28px 60px -26px rgba(0, 10, 40, .8), inset 0 0 0 1px rgba(253, 198, 7, .15);
}
.quote-scene {
  position: absolute; z-index: -1; right: 0; top: 50%; height: 118%; width: auto; max-width: none; transform: translateY(-50%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 30%); mask-image: linear-gradient(90deg, transparent 0, #000 30%);
}
.quote blockquote {
  margin: 0; max-width: 20ch; font-family: var(--font-brand); font-style: normal; font-weight: 400;
  font-size: clamp(1.75rem, 1.15rem + 2.4vw, 2.75rem); line-height: 1.15; letter-spacing: -.005em; text-wrap: balance;
  text-shadow: 0 2px 18px rgba(2, 20, 60, .6); animation: rise .6s var(--ease) both;
}
.quote blockquote::before { content: '“'; display: block; height: .45em; color: #FDC607; font-size: 1.6em; line-height: 1; }
.quote figcaption { margin-top: 14px; color: rgba(247, 238, 219, .78); font-size: var(--fs-sm); }
@media (max-width: 560px) {
  .quote { padding: 22px 20px; padding-top: 170px; min-height: 0; justify-content: flex-end; }
  .quote-scene { top: -24px; right: -20px; height: 230px; transform: none;
    -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent); mask-image: linear-gradient(180deg, #000 60%, transparent); }
}
.week { padding: clamp(18px, 3vw, 26px); }
.week-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.week-head h2 { margin: 0; font-size: var(--fs-lg); }
.week-nums { margin: 10px 0 12px; color: var(--text-2); }
.week-nums b { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-2xl); color: var(--text); margin-right: 4px; font-variant-numeric: lining-nums; }
.bar { position: relative; height: 18px; border-radius: var(--r-pill); background: var(--sunk); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: var(--p); border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); animation: fill 1s var(--ease) both; }
@keyframes fill { from { width: 0; } }
.week-under { display: flex; justify-content: space-between; margin-top: 8px; font-size: var(--fs-sm); }
.week-msg { margin: 12px 0 0; font-family: var(--font-note); color: var(--text-2); }
.week-strip { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 18px 0 0; padding: 0; }
.week-strip li { display: grid; justify-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-2); }
.week-strip .col { position: relative; width: 100%; max-width: 34px; height: 54px; border-radius: 9px; background: var(--sunk); overflow: hidden; }
.week-strip i { position: absolute; left: 0; right: 0; bottom: 0; height: var(--h); background: var(--accent); border-radius: 9px; animation: grow .8s var(--ease) both; }
@keyframes grow { from { height: 0; } }
.week-strip .today { color: var(--text); font-weight: 600; }
.week-strip .today .col { box-shadow: inset 0 0 0 1.5px var(--accent-strong); }
.week-strip .future .col { opacity: .5; }
.start-timer {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 12px; width: 100%; min-height: 72px; margin: var(--gap) 0 12px; padding: 12px 24px;
  border: none; border-radius: var(--r-lg); background: var(--accent-strong); color: var(--on-accent); box-shadow: var(--shadow);
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-xl);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.start-timer:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.start-timer:active { transform: translateY(0); }
.start-timer .icon { width: 28px; height: 28px; }
.start-timer small { font-family: var(--font-ui); font-weight: 500; font-size: var(--fs-sm); opacity: .85; }
.home-foot { text-align: center; font-size: var(--fs-sm); }
.home-foot b { color: var(--text); }

/* ---------- groups ---------- */
.groups { display: grid; grid-template-columns: 72px minmax(0, 1020px); gap: var(--gap); }
/* on wide screens the group rail sits at the far left, next to the sidebar, like Discord */
@media (min-width: 861px) { main:has(#view-groups.active) { max-width: none; margin: 0; } .rail { position: sticky; top: 84px; align-self: start; } }
.rail { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 4px 0; }
.rail-btn {
  width: 54px; height: 54px; flex: none; display: grid; place-items: center; font-size: 1.5rem;
  border: none; border-radius: 50%; background: color-mix(in srgb, var(--c, var(--latte)) var(--tint-mix), var(--surface));
  box-shadow: var(--shadow); transition: border-radius .25s var(--ease), transform .2s var(--ease);
}
.rail-btn:hover, .rail-btn.active { border-radius: 18px; }
.rail-btn.active { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent-strong); }
.rail-btn.add { background: transparent; box-shadow: inset 0 0 0 1.5px var(--border); font-size: 1.2rem; color: var(--text-2); }
.group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 20px 22px; }
.g-emoji { width: 64px; height: 64px; display: grid; place-items: center; font-size: 2rem; border-radius: 20px; background: color-mix(in srgb, var(--c, var(--latte)) var(--tint-mix), var(--surface-2)); }
.g-info { flex: 1; min-width: 160px; line-height: 1.35; }
.g-info h2 { margin: 0; }
.g-info small { color: var(--text-2); }
.g-info code { font-family: var(--font-ui); font-weight: 600; letter-spacing: .12em; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); }
.group-head .btn-row { margin-top: 0; }
.group-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: var(--gap); margin: var(--gap) 0; align-items: start; }
.gchat { padding: 18px 20px; display: flex; flex-direction: column; }
.gchat h3, .gside h3, .wall-title { font-size: var(--fs-lg); margin: 0 0 8px; }
.gchat .chat { height: 340px; flex: none; }
.gside { display: grid; gap: var(--gap); }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 6px 0; }
.board li + li { border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.board li.me .name-link { color: var(--accent-strong); }
.board .rank { font-family: var(--font-display); font-weight: 600; color: var(--text-2); width: 18px; }
.board small { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; }
.goals { list-style: none; padding: 0; margin: 0 0 10px; }
.goals li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.goals .x { position: static; width: 26px; height: 26px; flex: none; font-size: .8rem; opacity: .55; }
.goals input { accent-color: var(--accent-strong); width: 18px; height: 18px; vertical-align: -3px; margin-right: 8px; }
.goals input:checked + span { text-decoration: line-through; color: var(--text-2); }
.wall-title { margin-top: 8px; }
.wall-title small { font-family: var(--font-ui); font-weight: 400; font-size: var(--fs-sm); color: var(--text-2); margin-left: 6px; }
.chat { flex: 1; min-height: 120px; overflow: auto; font-size: var(--fs-sm); line-height: 1.5; padding-right: 4px; }
.msg { margin: 6px 0; overflow-wrap: anywhere; }
.msg b { font-weight: 600; margin-right: 6px; }
.msg time { color: var(--text-2); font-size: var(--fs-xs); margin-left: 4px; }
.msg.sys { color: var(--text-2); font-style: italic; }
.setup ol { text-align: left; max-width: 520px; margin: 14px auto; padding-left: 22px; }
.setup li { margin: 6px 0; }
.setup code { font-family: var(--font-ui); font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); overflow-wrap: anywhere; }
.setup-mode .nav, .setup-mode .topbar-right > :not(.theme-toggle) { display: none; }

/* top performers: podium with the winner in the middle */
.top { padding: clamp(18px, 3vw, 28px); margin: var(--gap) 0; overflow: hidden;
  background: radial-gradient(520px 220px at 50% 0, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--card-sheen), var(--surface); }
.top-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.top-head h3 { font-size: var(--fs-xl); margin: 0; }
.top-head h3::before { content: "✦"; color: var(--accent); margin-right: 10px; font-size: .7em; }
.top-total { color: var(--text-2); font-size: var(--fs-sm); }
.top-total b { color: var(--text); font-variant-numeric: tabular-nums; }
.podium { list-style: none; margin: 22px auto 6px; padding: 0; max-width: 560px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 12px; }
.podium-spot { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; min-width: 0; animation: rise .5s var(--ease) both; }
.podium-spot.gold { order: 2; animation-delay: .05s; }
.podium-spot.silver { order: 1; animation-delay: .15s; }
.podium-spot.bronze { order: 3; animation-delay: .25s; }
.podium-spot .name-link { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-spot.me .name-link { color: var(--accent-strong); }
.podium-av { position: relative; width: 64px; height: 64px; display: grid; place-items: center; margin-bottom: 6px; font-size: 32px; padding: 0;
  border: none; border-radius: 50%; background: var(--surface-2); box-shadow: 0 0 0 3px var(--medal), 0 0 26px -6px var(--medal); }
.gold .podium-av { width: 78px; height: 78px; font-size: 40px; }
.medal { position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: var(--medal); color: #0A1940; font: 700 .8rem var(--font-ui); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.gold { --medal: #FDC607; } .silver { --medal: #C9D4F0; } .bronze { --medal: #E69B5C; }
.podium-hrs { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: lining-nums; }
.gold .podium-hrs { font-size: 2rem; color: var(--accent-strong); }
.podium-hrs small { font: 500 var(--fs-sm) var(--font-ui); color: var(--text-2); }
.pedestal { display: block; width: 100%; margin-top: 10px; border-radius: 14px 14px 4px 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--medal) 34%, var(--surface-2)), var(--surface-2)); }
.gold .pedestal { height: 72px; } .silver .pedestal { height: 48px; } .bronze .pedestal { height: 32px; }
.top .board { margin-top: 14px; }
.top-note { margin: 14px 0 0; font-size: var(--fs-sm); }
.group-goals { margin: 0; }
.room-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; text-align: left; border: none; border-radius: var(--r-lg);
  color: #F7EEDB; background: var(--logo-sky); box-shadow: var(--shadow), inset 0 0 0 1px rgba(253, 198, 7, .2); transition: transform .2s var(--ease); }
.room-card:hover { transform: translateY(-2px); }
.room-card img { width: 64px; height: 64px; border-radius: 14px; flex: none; }
.room-card b { display: block; font-family: var(--font-display); font-size: var(--fs-lg); }
.room-card small { color: rgba(247, 238, 219, .78); }
.rail-btn .icon { width: 22px; height: 22px; }
.rail-btn.add:hover { color: var(--accent-strong); box-shadow: inset 0 0 0 1.5px var(--accent); }
@media (max-width: 480px) {
  .podium { gap: 8px; }
  .podium-av { width: 52px; height: 52px; font-size: 26px; }
  .gold .podium-av { width: 64px; height: 64px; font-size: 32px; }
  .podium-hrs { font-size: 1.25rem; } .gold .podium-hrs { font-size: 1.5rem; }
}

/* weekly award cards */
.cats { margin: var(--gap) 0; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cat { display: flex; gap: 12px; align-items: flex-start; padding: 16px; animation: rise .4s var(--ease) both; }
.cat-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-size: 22px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); }
.cat b { display: block; font-family: var(--font-display); font-weight: 600; }
.cat-who { margin: 2px 0; }
.cat small { display: block; color: var(--text-2); font-size: var(--fs-xs); line-height: 1.4; }
.cat .cat-rule { margin-top: 4px; opacity: .8; font-style: italic; }

/* group target: one bar, coloured by who contributed */
.target-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.target .week-nums { margin: 4px 0 8px; }
.stack { display: flex; height: 14px; border-radius: var(--r-pill); overflow: hidden; background: var(--sunk); }
.stack i { display: block; width: var(--w); background: var(--c); transition: width .6s var(--ease); }
.stack i + i { box-shadow: -1px 0 0 var(--surface); }
.contrib { list-style: none; margin: 12px 0 0; padding: 0; font-size: var(--fs-sm); }
.contrib li { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; padding: 3px 0; }
.contrib li i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.contrib b { font-variant-numeric: tabular-nums; }

/* Constellations: a small night sky that fills in over time */
.sky-box { padding: 20px 22px; margin-bottom: var(--gap); border-radius: var(--r-lg); color: #F7EEDB;
  background: radial-gradient(600px 240px at 50% 110%, rgba(253, 198, 7, .14), transparent 70%), var(--stars), linear-gradient(180deg, #04225A, var(--logo-sky));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(253, 198, 7, .15); }
.sky-box h3 { color: #F7EEDB; }
.sky-box .hint { color: rgba(247, 238, 219, .75); }
.sky-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sky { display: block; width: 100%; height: auto; margin: 4px 0; overflow: visible; }
.sky line { stroke: rgba(247, 238, 219, .14); stroke-width: 1.2; stroke-dasharray: 3 5; }
.sky line.lit { stroke: rgba(253, 198, 7, .6); stroke-dasharray: none; stroke-width: 1.6; }
.sky .star { cursor: pointer; outline: none; }
.sky .star .hit { fill: transparent; }
.sky .star circle:not(.hit):not(.halo) { fill: rgba(247, 238, 219, .35); }
.sky .star.lit path { fill: #FDC607; filter: drop-shadow(0 0 6px rgba(253, 198, 7, .8)); animation: star-in .6s var(--ease) both; animation-delay: var(--d); }
.sky .star .halo { fill: rgba(253, 198, 7, .12); }
.sky .star.picked .halo, .sky .star:focus-visible .halo { fill: rgba(253, 198, 7, .3); }
.sky .star:not(.lit).picked circle:not(.hit), .sky .star:not(.lit):focus-visible circle:not(.hit) { fill: #F7EEDB; }
@keyframes star-in { from { opacity: 0; transform: scale(.3); } }
.sky-detail { min-height: 2.6em; margin: 4px 0 0; font-size: var(--fs-sm); }
.sky-detail b { color: #FDC607; }

/* privacy switches in the profile editor */
.privacy { border: none; padding: 0; margin: 18px 0 6px; }
.privacy legend { padding: 0; margin-bottom: 6px; }
.privacy .check span { display: block; }
.privacy .check small { display: block; font-weight: 400; margin-top: 2px; }

/* ---------- profile ---------- */
.me-head { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.me-head > div { flex: 1; line-height: 1.4; }
.me-head h2 { font-size: var(--fs-2xl); margin: 0; }
.me-head small { color: var(--text-2); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin: var(--gap) 0; }
.box { padding: 20px 22px; margin-bottom: var(--gap); }
.box > h3::before, .week h2::before, .gchat h3::before, .gside h3::before, .wall-title::before { content: "✦"; color: var(--accent); margin-right: 8px; font-size: .8em; }
.box h3 small { font-family: var(--font-ui); font-weight: 400; color: var(--text-2); font-size: var(--fs-sm); margin-left: 6px; }
.heat-wrap { display: flex; gap: 8px; }
.heat-days { display: grid; grid-template-rows: 18px repeat(7, 16px); row-gap: 4px; font-size: var(--fs-xs); color: var(--text-2); line-height: 16px; }
.heat-days::before { content: ""; }
.heat-scroll { overflow-x: auto; padding-bottom: 4px; }
.heat-months { display: grid; grid-auto-flow: column; grid-auto-columns: 16px; column-gap: 4px; height: 18px; margin-bottom: 4px; font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; }
.heat { display: flex; gap: 4px; }
.cell[data-day] { cursor: pointer; }
.cell.is-today { box-shadow: inset 0 0 0 1.5px var(--accent-strong); }
.cell.picked { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 10px; }
.cal-foot .legend { margin: 0; }
.cal-detail { margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.cal-detail b { color: var(--text); }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.month .big-num { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-2xl); margin: 4px 0 10px; }
.mini-stats { list-style: none; padding: 0; margin: 0; font-size: var(--fs-sm); }
.mini-stats li { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.mini-stats span { color: var(--text-2); }
.mini-stats b { font-variant-numeric: tabular-nums; }
@media (max-width: 960px) { .three { grid-template-columns: 1fr 1fr; } .three > :last-child { grid-column: 1 / -1; } }
@media (max-width: 640px) { .three { grid-template-columns: 1fr; } }
.heat .col { display: grid; gap: 4px; }
.cell { display: block; width: 16px; height: 16px; border-radius: 4px; background: var(--sunk); }
.cell.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--sunk)); }
.cell.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--sunk)); }
.cell.l3 { background: color-mix(in srgb, var(--accent-strong) 80%, var(--sunk)); }
.cell.l4 { background: var(--accent-strong); }
.cell.future { background: transparent; }
.legend { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-2); margin-top: 10px; }
.legend .cell { width: 12px; height: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.goal { text-align: center; }
.ring-wrap { position: relative; width: 168px; margin: 0 auto; }
.ring-wrap svg { display: block; width: 100%; }
.goal-num { position: absolute; inset: 0; display: grid; place-content: center; line-height: 1.15; }
.goal-num b { font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; }
.goal-num small { color: var(--text-2); }
.goal-edit { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: var(--fs-sm); }
.goal-edit input { width: 76px; min-height: 40px; text-align: center; }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: minmax(70px, 110px) 1fr auto; gap: 12px; align-items: center; padding: 4px 0; font-size: var(--fs-sm); }
.bars span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars i { display: block; height: 10px; width: var(--w); min-width: 6px; border-radius: var(--r-pill); background: var(--accent); }
.bars b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- study room: the corkboard (kept, retinted) ---------- */
.room {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  --cork: #B88E64;
  background-color: var(--cork);
  background-image: radial-gradient(rgba(70, 45, 25, .3) 1px, transparent 1.6px), radial-gradient(rgba(255, 240, 220, .14) 1px, transparent 1.6px);
  background-size: 9px 9px, 13px 13px; background-position: 0 0, 4px 6px;
}
[data-theme="dark"] .room { --cork: #5A4433; }
.room.hidden { display: none; }
.room-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; padding: 10px 20px; background: var(--surface); box-shadow: var(--shadow); line-height: 1.3; }
.room-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.room-top h2 { font-size: var(--fs-lg); margin: 0; }
.room-status { font-size: var(--fs-sm); }
.pill { padding: 2px 12px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--sage) 35%, var(--surface)); font-size: var(--fs-xs); font-weight: 600; }
/* group pomodoro lives in the top bar so it never hides behind the chat */
.room-timer { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 14px; border-radius: var(--r-pill); background: var(--sunk); }
.room-timer[hidden] { display: none; }
.room-timer small { font-family: var(--font-note); color: var(--text-2); }
.room-timer .btn { min-height: 36px; padding: 0 14px; }
#rClock { font-weight: 600; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.r-len { min-height: 36px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); }
.r-len:disabled { opacity: .5; }
.room-timer.running #rClock { color: var(--accent-strong); }

/* pre-join */
.prejoin { flex: 1; overflow: auto; display: grid; place-items: center; padding: 24px 16px; }
.prejoin[hidden] { display: none; }
.prejoin-card { display: grid; grid-template-columns: minmax(260px, 420px) minmax(240px, 320px); gap: 28px; align-items: center; padding: 28px; }
.prejoin-tile { transform: rotate(-1.5deg); }
.prejoin-side h3 { font-size: var(--fs-xl); }
#pjMsg { min-height: 3em; }
#pjMsg.warn { color: var(--danger); }
.prejoin-side .field { margin: 12px 0; }
@media (max-width: 720px) { .prejoin-card { grid-template-columns: 1fr; padding: 20px; } }

/* call layout: videos + collapsible people/chat panel */
.room-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 0; transition: grid-template-columns .3s var(--ease); }
.room-body[hidden] { display: none; }
.room.chat-open .room-body { grid-template-columns: 1fr 340px; }
.tiles { --cols: 1; padding: clamp(18px, 3vw, 34px); display: grid; gap: clamp(18px, 2.5vw, 30px); grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-content: center; justify-content: center; overflow: auto; }
.tiles[data-count="1"] { --cols: 1; max-width: 860px; width: 100%; margin: 0 auto; }
.tiles[data-count="2"] { --cols: 2; }
.tiles[data-count="3"], .tiles[data-count="4"] { --cols: 2; max-width: 1100px; width: 100%; margin: 0 auto; }
.tiles[data-count="5"], .tiles[data-count="6"] { --cols: 3; }
.tiles[data-count="7"], .tiles[data-count="8"], .tiles[data-count="9"] { --cols: 3; }
.tile { position: relative; margin: 0; padding: 10px 10px 40px; background: var(--photo-frame); border-radius: 3px; box-shadow: 0 18px 24px -12px rgba(30, 18, 10, .6); transform: rotate(var(--r)); transition: box-shadow .25s var(--ease); }
.tile video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #0D2E6E; border-radius: 1px; }
.tile.mirror video { transform: scaleX(-1); }
.tile.screen { grid-column: 1 / -1; transform: none; }
.tile.screen video { object-fit: contain; background: #061A44; }
/* who's talking: a soft moon-gold glow around their polaroid */
.tile.speaking { box-shadow: 0 0 0 3px #FDC607, 0 0 28px 4px rgba(253, 198, 7, .55), 0 18px 24px -12px rgba(30, 18, 10, .6); }
.tile figcaption { position: absolute; left: 12px; right: 12px; bottom: 8px; display: flex; justify-content: space-between; gap: 8px;
  font-family: var(--font-note); font-size: 1.1rem; color: #15224D; white-space: nowrap; }
.tile-name { overflow: hidden; text-overflow: ellipsis; }
.tile-icons { flex: none; font-family: var(--font-ui); font-size: .95rem; }
.tile-net { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); padding: 6px 14px; border-radius: var(--r-pill);
  background: rgba(6, 26, 68, .78); color: #F7EEDB; font-size: var(--fs-sm); font-weight: 600; }
.tape { position: absolute; top: -12px; left: 50%; width: 90px; height: 24px; transform: translateX(-50%) rotate(-4deg); background: rgba(240, 222, 180, .8); z-index: 1; }
.room-side { display: flex; flex-direction: column; gap: 4px; min-height: 0; min-width: 0; overflow: hidden; padding: 18px; background: var(--surface); box-shadow: var(--shadow); }
.room:not(.chat-open) .room-side { visibility: hidden; padding: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h3 { margin: 0; }
.room-side h3 { font-size: var(--fs-base); margin: 14px 0 4px; }
#roster { list-style: none; padding: 0; margin: 0; font-size: var(--fs-sm); }
#roster li { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; padding: 4px 0; }
#roster small { color: var(--text-2); margin-left: auto; }
.small-btn { min-height: 36px; margin-top: 8px; align-self: flex-start; }
.room-side .chat { flex: 1; min-height: 80px; }
#chatForm { margin-top: 8px; }
.room-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(8px); }
.room-controls[hidden] { display: none; }
.room-controls .btn { margin: 0; }
.room-controls .btn.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
#chatBtn { position: relative; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: var(--r-pill);
  background: var(--ember); color: #0A1940; font-size: .75rem; font-weight: 700; }
.badge[hidden] { display: none; }
.flash { animation: flash .35s ease-out; }
@keyframes flash { from { filter: brightness(2.2); } }

/* ---------- responsive layout of views ---------- */
/* the paper page the polaroids are scattered on (overrides the old grid layout) */
.tiles, .tiles[data-count] { display: block; position: relative; overflow: hidden; max-width: none; width: auto; margin: clamp(12px, 2vw, 24px);
  padding: 0; border-radius: 4px; background-color: #F4EAD6;
  background-image: linear-gradient(90deg, transparent 52px, rgba(201, 72, 59, .35) 52px 54px, transparent 54px), repeating-linear-gradient(transparent 0 31px, rgba(28, 45, 107, .12) 31px 32px);
  box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .6); }
.tiles .tile { position: absolute; transition: left .5s var(--ease), top .5s var(--ease), width .5s var(--ease), transform .5s var(--ease), box-shadow .25s var(--ease); }
.tiles .tile.screen { transform: none; z-index: 2; }
@media (max-width: 860px) {
  .room-body, .room.chat-open .room-body { display: flex !important; flex-direction: column; }
  .tiles, .tiles[data-count] { flex: 1; min-height: 60dvh; margin: 10px; }
}
@media (max-width: 860px) {
  /* phones: videos fill the screen, people + chat slide up as a sheet */
  .room-body, .room.chat-open .room-body { display: block; position: relative; overflow: auto; }
  .room-body[hidden] { display: none; }
  .tiles { padding: 20px 14px; gap: 18px; }
  .tiles[data-count="2"], .tiles[data-count="3"], .tiles[data-count="4"] { --cols: 1; }
  .tiles[data-count="3"], .tiles[data-count="4"], .tiles[data-count="5"], .tiles[data-count="6"],
  .tiles[data-count="7"], .tiles[data-count="8"], .tiles[data-count="9"] { --cols: 2; }
  .tile { padding: 6px 6px 30px; }
  .tile figcaption { font-size: .95rem; bottom: 5px; }
  .room-side { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; height: min(70dvh, 560px); padding: 16px;
    border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); transform: translateY(105%); visibility: hidden;
    transition: transform .3s var(--ease), visibility 0s linear .3s; }
  .room.chat-open .room-side { transform: none; visibility: visible; padding: 16px; transition: transform .3s var(--ease); }
  .room-top { padding: 8px 12px; }
  .room-timer small { display: none; }
  .room-controls { gap: 6px; padding: 8px; }
  .room-controls .btn { min-height: 44px; padding: 0 12px; font-size: var(--fs-xs); }
}
@media (max-width: 640px) {
  .groups { grid-template-columns: 1fr; gap: 16px; }
  .rail { flex-direction: row; overflow-x: auto; padding: 6px 4px 10px; }
  .group-layout, .two { grid-template-columns: 1fr; }
  .gchat .chat { height: 280px; }
  .mode-row { flex-wrap: nowrap; }
  .mode { padding: 0 11px; font-size: var(--fs-xs); }
  .polaroid { width: calc(50% - 8px); }
  .card { padding: 16px 16px 12px; }
  .stats b { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  ::view-transition-new(root) { animation: none; }
}
