/* ==========================================================================
   PADHLE.WTF — structural design system

   This file owns layout, component structure, motion and interaction states.
   The active visual language is "Looseleaf" (paper desk, pencil ink, Kevin
   Sans, marker accents), defined in `src/styles/looseleaf.css`, which loads
   after this file and re-points every semantic token below at the paper
   palette. Both light and dark themes are Looseleaf; there is no classic
   fallback and no design toggle.

   Keep new UI on the semantic tokens (--surface, --ink, --line, --accent,
   --ok/--warn/--bad, --r, --shadow-*) so it inherits the Looseleaf look and
   works in both themes automatically.
   ========================================================================== */

/* ------------------------------------------------------------- 1. tokens -- */
:root {
  /* The one radius. Chips, cards, inputs, buttons: all square. Change `--r`
     and the entire system softens at once — that is the point of the token. */
  --r: 20px;
  --r-sm: 8px;
  --r-pill: 9999px;

  /* Stroke scale — 1.5px charcoal for cards, 1px dashed muted slate for separators */
  --border-w: 1.5px;
  --border-w-thin: 1px;
  --border-w-thick: 2px;
  --border-dash: 1px dashed #94A3B8;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 44px;

  --fs-xs: 11px; --fs-sm: 12.5px; --fs: 14.5px; --fs-lg: 17px;
  --fs-xl: 22px; --fs-2xl: 30px;

  /* Type roles — Plus Jakarta Sans / Outfit; cursive script for logo */
  --font-display: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-heading: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Plus Jakarta Sans", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system,
          "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --font-script: "Outfit", ui-sans-serif, "Segoe Script", cursive;

  --sidebar-w: 240px;
  --utility-w: 320px;
  --topbar-h: 64px;
  --speed: 150ms;
}

/* Light: pure white canvas, deep charcoal ink, warm ochre primary.
   Soft pastel backgrounds cycle across KPI cards and highlight blocks. */
:root, [data-theme="light"] {
  --ink: #1A1A1A;             /* borders, structural lines, deep charcoal text */
  --text: #1A1A1A;
  --text-strong: #1A1A1A;
  --text-muted: #52606D;

  --bg: #FFFFFF;              /* page — pure white canvas */
  --surface: #FFFFFF;         /* raised panels, cards, nav */
  --surface-2: #FDE68A;       /* butter yellow */
  --surface-3: #D8EEFE;       /* pastel sky blue */
  --surface-4: #F9B4AB;       /* soft coral pink */
  --surface-5: #FFEDD5;       /* warm peach */
  --surface-6: #FEF3C7;       /* warm cream — active route pill */

  --muted: #5B6675;           /* readable secondary text (≈5.8:1 on white) */
  --faint: #5C6878;           /* still readable on the butter pastel (≈4.6:1) */
  --line: #94A3B8;

  /* ---------------------------- the palette ---------------------------- */
  --black: #1A1A1A;
  --white: #FFFFFF;

  /* Primary brand — warm ochre-marigold. Text on it is dark ink: white on
     ochre only reaches ≈3.3:1, while charcoal clears 6:1. */
  --primary: #D97724;
  --primary-text: #1A1A1A;

  /* Accent highlight yellow (used for selection, highlights, hover bands) */
  --yellow: #FDE68A;
  --yellow-light: #FEF3C7;
  --red: #FF4444;

  /* Pastel accent cycle */
  --pastel-1: #FDE68A;
  --pastel-2: #D8EEFE;
  --pastel-3: #F9B4AB;
  --pastel-4: #FFEDD5;

  /* Semantic aliases */
  --accent: var(--primary);
  --accent-2: var(--pastel-2);
  --ok: var(--pastel-1);
  --warn: var(--pastel-3);
  --bad: var(--pastel-4);
  --info: var(--pastel-2);
  --extra: var(--pastel-3);
  --on-accent: var(--primary-text);

  --ok-text: #1A1A1A;
  --warn-text: #1A1A1A;
  --bad-text: #1A1A1A;
  --info-text: #0B4F6C;
  /* Coloured text on the paper surface — the pastel fills above are too pale
     to read as type, so these are the darker members of the same hues. */
  --ok-ink: #15803D;
  --warn-ink: #9A3412;
  --bad-ink: #B91C1C;

  /* Accent tints — light fills for badges, option states and result chips */
  --ok-light: #FEF3C7;
  --warn-light: #FCD5CE;
  --bad-light: #FECACA;
  --info-light: #DBEAFE;
  --extra-light: #FCD5CE;
  --accent-light: #FEF3C7;
  --accent-text: #7A4A00;
  --cyan: #67E8F9;

  /* Legacy colour names used across the app, aliased to the semantic palette so
     every component resolves in both themes. */
  --green: var(--ok);
  --blue: var(--info);
  --pink: var(--bad);
  --orange: var(--warn);
  --purple: var(--extra);
  --green-light: var(--ok-light);
  --blue-light: var(--info-light);
  --pink-light: var(--bad-light);
  --orange-light: var(--warn-light);
  --purple-light: var(--extra-light);
  --green-text: var(--ok-text);
  --blue-text: var(--ok-text);
  --pink-text: var(--ok-text);
  --orange-text: var(--ok-text);
  --purple-text: var(--ok-text);

  /* Premium poker card faces */
  --card-front: #FFFFFF;
  --card-back: #1A3A5C;
  --card-back-text: #FFFFFF;

  --chart-grid: rgba(26, 26, 26, 0.08);
  --scrim: rgba(26, 26, 26, 0.15);
  --grid: none;

  --focus: #D97724;
}

/* Dark: same soft palette on charcoal canvas. Bright fills stay bright. */
[data-theme="dark"] {
  --ink: #FFFFFF;
  --text: #FFFFFF;
  --text-strong: #FFFFFF;
  --text-muted: #A7B3C6;

  --bg: #121212;
  --surface: #1E1E1E;
  --surface-2: #2D2D2D;
  --surface-3: #3A3A3A;
  --surface-4: #4A4A4A;
  --surface-5: #5A5A5A;
  --surface-6: #FEF3C7;

  --muted: #A7B3C6;           /* lightened for ≥7:1 on charcoal */
  --faint: #9AA6B8;
  --line: #4A4A4A;

  /* ---------------------------- the palette ---------------------------- */
  --black: #FFFFFF;
  --white: #1A1A1A;

  /* Primary brand — warm ochre-marigold. Dark ink keeps every bright fill
     readable, including the primary button and hero cards. */
  --primary: #E8A33D;
  --primary-text: #1A1A1A;

  /* Accent highlight yellow (used for selection, highlights, hover bands) */
  --yellow: #FDE68A;
  --yellow-light: rgba(253, 230, 138, 0.14);
  --red: #FF6B6B;

  /* Pastel accent cycle */
  --pastel-1: #FFE5B4;
  --pastel-2: #B7E4FF;
  --pastel-3: #FFC7B4;
  --pastel-4: #FFE8B4;

  /* Semantic aliases */
  --accent: var(--primary);
  --accent-2: var(--pastel-2);
  --ok: var(--pastel-1);
  --warn: var(--pastel-3);
  --bad: var(--pastel-4);
  --info: var(--pastel-2);
  --extra: var(--pastel-3);
  --on-accent: var(--primary-text);

  --ok-text: #1A1A1A;
  --warn-text: #1A1A1A;
  --bad-text: #1A1A1A;
  --info-text: #A9E2FF;
  /* Coloured text on charcoal — the lighter members of the same hues. */
  --ok-ink: #86EFAC;
  --warn-ink: #FDBA74;
  --bad-ink: #FCA5A5;

  /* Accent tints — light fills for badges, option states and result chips */
  --ok-light: rgba(255, 229, 180, 0.25);
  --warn-light: rgba(255, 199, 180, 0.25);
  --bad-light: rgba(255, 202, 202, 0.25);
  --info-light: rgba(183, 228, 255, 0.25);
  --extra-light: rgba(255, 199, 180, 0.25);
  --accent-light: rgba(232, 163, 61, 0.2);
  --accent-text: #FFD98A;
  --cyan: #7DE3F4;

  /* Legacy colour names used across the app, aliased to the semantic palette so
     every component resolves in both themes. */
  --green: var(--ok);
  --blue: var(--info);
  --pink: var(--bad);
  --orange: var(--warn);
  --purple: var(--extra);
  --green-light: var(--ok-light);
  --blue-light: var(--info-light);
  --pink-light: var(--bad-light);
  --orange-light: var(--warn-light);
  --purple-light: var(--extra-light);
  --green-text: var(--ok-text);
  --blue-text: var(--ok-text);
  --pink-text: var(--ok-text);
  --orange-text: var(--ok-text);
  --purple-text: var(--ok-text);

  /* Premium poker card faces */
  --card-front: #252525;
  --card-back: #5B2A36;
  --card-back-text: #F5E6D4;

  --chart-grid: rgba(255, 255, 255, 0.08);
  --scrim: rgba(26, 26, 26, 0.4);
  --grid: none;

  --focus: #D97724;

  /* Dark-specific overrides */
  --yellow: #FDE68A;
}

/* Note on dark mode: every bright or tinted fill above carries `--on-accent`
   (black) or an explicit black type colour in its own rule, so a light fill
   never ends up with light ink. That is why there is no long list of
   `[data-theme="dark"] … { color: var(--black) }` patch rules here — the
   pairing is structural, not patched. */

/* Soft, low-opacity diffused drop shadows — no harsh offset block shadows */
:root {
  --shadow-sm: 0 1px 3px rgba(26, 26, 26, 0.08);
  --shadow: 0 2px 8px rgba(26, 26, 26, 0.10);
  --shadow-lg: 0 4px 16px rgba(26, 26, 26, 0.12);
  --shadow-xl: 0 8px 32px rgba(26, 26, 26, 0.14);
  --shadow-sm-hover: 0 2px 12px rgba(26, 26, 26, 0.12);
  --shadow-hover: 0 4px 20px rgba(26, 26, 26, 0.14);
  --shadow-none: none;
}

/* ============================== Sidebar collapse transitions ================== */
.sidebar {
  transition: width var(--speed), box-shadow var(--speed);
}
.app-shell.sidebar-collapsed {
  grid-template-columns: 72px minmax(0, 1fr) var(--utility-w);
}
.app-shell .sidebar.collapsed {
  width: 72px;
  overflow-x: hidden;
}.app-shell .sidebar.collapsed .nav a span:not(.ico):not(.count),
.app-shell .sidebar.collapsed .sidebar-foot > *:not(.dot) {
  display: none !important;
}
.app-shell .sidebar.collapsed .nav a {
  justify-content: center;
  padding: 10px 8px;
}
.app-shell .sidebar.collapsed .nav a .ico {
  margin: 0 auto;
}
.app-shell .sidebar.collapsed .brand-mark {
  margin: 0 auto;
}

/* Sidebar toggle button states */
.sidebar-toggle.collapsed {
  background: var(--surface-2);
}

/* Workspace expands when sidebar collapses */
.app-shell .workspace.collapsed-sidebar {
  flex: 1;
}.xp-bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.xp-bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-right: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-pill);
  transition: width var(--speed) ease;
}
.xp-bar > span::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.4) 25%,
    transparent 50%,
    rgba(255,255,255,0.4) 75%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: xp-shimmer 2s linear infinite;
}
@keyframes xp-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: var(--fs-lg);
  box-shadow: var(--shadow);
}

.gamified-card {
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform var(--speed), box-shadow var(--speed);
}
.gamified-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-lg);
}
.gamified-card h3 {
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-2);
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}/* Streak calendar mini */
.streak-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: var(--sp-3);
}
.streak-day {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
}
.streak-day.done {
  background: var(--ok);
  color: var(--on-accent);
  border-color: var(--ok);
}
.streak-day.current {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(217, 119, 36, 0.4);
}.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--pastel-1);
  top: 50%;
  left: 50%;
  animation: confetti-fall 1s ease-out forwards;
}
.confetti:nth-child(2) { background: var(--pastel-2); animation-delay: 0.1s; left: 60%; }
.confetti:nth-child(3) { background: var(--pastel-3); animation-delay: 0.2s; left: 40%; }
.confetti:nth-child(4) { background: var(--pastel-4); animation-delay: 0.3s; left: 70%; }
.confetti:nth-child(5) { background: var(--pastel-1); animation-delay: 0.1s; left: 30%; }
.confetti:nth-child(6) { background: var(--pastel-2); animation-delay: 0.2s; left: 80%; }
.confetti:nth-child(7) { background: var(--pastel-3); animation-delay: 0.3s; left: 20%; }
.confetti:nth-child(8) { background: var(--pastel-4); animation-delay: 0.1s; left: 50%; }
@keyframes confetti-fall {
  0% { transform: translate(-50%, -10%) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, 80vh) rotate(720deg); opacity: 0; }
}

/* Dark mode - ensure all key elements adapt */
[data-theme="dark"] .card {
  box-shadow: var(--shadow);
}
[data-theme="dark"] .btn {
  box-shadow: var(--shadow);
}
[data-theme="dark"] .bar {
  background: var(--surface-2);
}
[data-theme="dark"] .bar > span {
  background: var(--accent);
}

/* Empty states - more colorful */
.empty {
  display: grid;
  place-items: center;
  gap: var(--sp-3);
  padding: var(--sp-8);
  background: var(--surface-2);
  border: var(--border-w-thick) solid var(--ink);
  border-radius: var(--r);
  text-align: center;
  color: var(--ink);
}/* The single radius token, applied to every box in the system. */
.card, .btn, .input, .select, .textarea, .chip, .badge, .bar, .task-row,
.table-wrap, .tab, .list-item, .chart-tip, .tile, .tile-mark, .suggest-item,
.modal, .toast, .cal-cell, .timer-face, .check .box, .empty, .metric-link,
details.disclosure, .callout, .boot-card, .skip-link, .nav a, .sticker,
.tree .leaf, .reorder button, kbd,
input[type="date"], input[type="time"], input[type="number"], input[type="search"] {
  border-radius: var(--r);
}

/* --------------------------------------------------------------- 2. base -- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.55;
  color: var(--text);
  /* Flat paper + a hard-edged 28px grid. Zero blur, zero softness. */
  background-color: var(--bg);
  background-image: var(--grid);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--yellow); color: var(--on-accent); }
/* Inline highlight, exactly as the reference marks text. */
mark {
  background: var(--yellow); color: var(--on-accent);
  padding: 0.1em 0.3em; border-bottom: 2px solid var(--on-accent);
}

h1, h2, h3, h4 {
  margin: 0 0 var(--sp-3);
  color: var(--text-strong);
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.01em;
}
/* Display type is reserved for the two loudest levels. */
h1 { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-2xl); text-transform: uppercase; letter-spacing: -0.02em; line-height: 1.05; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs); }
p { margin: 0 0 var(--sp-3); }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--text-strong); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
/* The reference's signature link hover: a flat yellow highlight behind the
   text. Excluded on anything that is already a block-shaped control. */
a:not(.btn):not(.tile):not(.card):not(.metric-link):not(.suggest-item):not(.chip):hover {
  background: var(--yellow); color: var(--on-accent);
}
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
hr { border: 0; border-top: var(--border-w) solid var(--ink); margin: var(--sp-5) 0; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; }
kbd {
  border: var(--border-w-thin) solid var(--ink); border-bottom-width: var(--border-w);
  padding: 1px 6px; background: var(--surface); box-shadow: 2px 2px 0 0 var(--ink);
}
::placeholder { color: var(--faint); opacity: 1; }

/* Labels, eyebrows and meta are monospace — it makes structure feel exposed. */
.mono, .crumb, .metric .k, .badge, .chip, .count, .nav-label, .brand-sub,
.timer-state, .timer-clock, .stat-line b, th { font-family: var(--font-mono); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.strong { font-weight: 700; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; gap: var(--sp-3); align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }.mt-2{margin-top:var(--sp-2)}.mt-3{margin-top:var(--sp-3)}.mt-4{margin-top:var(--sp-4)}

.skip-link {
  position: fixed; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 12px 18px; border: var(--border-w) solid var(--ink);
  border-left: 0; border-top: 0; font-weight: 700;
  box-shadow: var(--shadow);
}
.skip-link:focus { left: 0; }
/* Focus is never swallowed by a decorative shadow. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.noscript {
  padding: var(--sp-6); border: var(--border-w-thick) solid var(--ink);
  border-left-width: 14px; border-left-color: var(--bad); background: var(--surface);
  box-shadow: var(--shadow); font-weight: 600;
}

/* ------------------------------------------------- 3. surfaces & accents -- */
.card {
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow);
  padding: var(--sp-5);
}
.card.tight { padding: var(--sp-4); }
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: var(--sp-4); }
/* Colourful card backgrounds — cycle through pastels */
.card.colorful-1 { background: var(--pastel-1); color: var(--on-accent); border-color: var(--ink); }
/* A card you can click lifts, like the canonical neubrutalist button. */
a.card, .metric-link, .tile, .suggest-item { transition: transform var(--speed), box-shadow var(--speed); }
a.card:hover, .metric-link:hover, .tile:hover, .suggest-item:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hover);
}

/* The one loud gesture: an accent-filled hero block. Use sparingly. */
.card.hero {
  background: var(--accent);
  color: var(--on-accent);
  border-width: var(--border-w-thick);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
}
.card.hero h1, .card.hero h2, .card.hero h3, .card.hero .metric .v { color: var(--on-accent); }
.card.hero .muted { color: rgba(0, 0, 0, 0.72); }

/* A thick colour stripe on the left edge — colour without a loud fill. */
.card.stripe { border-left-width: 14px; border-left-color: var(--stripe, var(--accent)); }

/* Inside the yellow hero the local palette inverts: black is the ink. */
.card.hero .bar { background: rgba(0, 0, 0, 0.16); }
.card.hero .bar > span { background: var(--black); }
.card.hero .btn { background: var(--surface); color: var(--text); }
/* The reference's primary CTA: solid black, white type. */
.card.hero .btn.primary { background: var(--black); color: var(--white); }
.card.hero .btn.ghost { background: transparent; color: var(--on-accent); box-shadow: none; }
.card.hero .btn.ghost:hover { background: var(--surface); color: var(--text); border-color: var(--ink); box-shadow: var(--shadow-sm-hover); }
.card.hero .stat-line { border-bottom-color: rgba(0, 0, 0, 0.3); }
.card.hero .eyebrow, .card.hero .faint { color: rgba(0, 0, 0, 0.68); }
.hero-num {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(40px, 9vw, 68px); line-height: 0.95; letter-spacing: -0.04em;
}

.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-title h2, .card-title h3 { margin: 0; }
.card-title h2::before, .card-title h3::before {
  content: ""; display: inline-block; width: 12px; height: 12px;
  background: var(--accent); border: var(--border-w-thin) solid var(--ink);
  margin-right: 10px; vertical-align: baseline;
}
/* Annotation strip inside a card — the reference's pull-quote pattern: a light
   tint with a heavy ink bar, not a faded grey footnote. */
.card-note {
  margin-top: var(--sp-4); padding: var(--sp-3);
  background: var(--yellow-light);
  border: var(--border-w-thin) solid var(--ink);
  border-left: 5px solid var(--ink);
  font-size: var(--fs-sm); color: var(--black);
}

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted);
}

/* ------------------------------------------------------------- 4. layout -- */
/* #app is the grid host for both shells. The app shell has two tracks
   (sidebar + main); public pages and the boot card are the only child and must
   span both, otherwise they are squeezed into the sidebar track at desktop
   widths. The :has() rule also collapses the unused sidebar track for public
   pages; the span above keeps the layout correct even without :has() support. */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.app > .public-shell, .app > .boot { grid-column: 1 / -1; }
.app:has(> .public-shell) { grid-template-columns: minmax(0, 1fr); }
.sidebar {
  grid-column: 1; position: sticky; top: 0; align-self: start; min-height: 100vh;
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-4);
  background: var(--surface);
  border-right: var(--border-w-thick) solid var(--ink);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding-bottom: var(--sp-2); }.brand-name {
  font-family: var(--font-display); font-weight: 800; font-size: 22px;
  text-transform: uppercase; letter-spacing: -0.03em; line-height: 1;
}.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px 11px;
  border: var(--border-w-thin) solid transparent;
  font-family: var(--font-heading); font-weight: 700; font-size: var(--fs-sm);
  text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--on-accent);
  transition: transform var(--speed), box-shadow var(--speed), background var(--speed);
}
.nav a .ico { width: 20px; text-align: center; font-size: 15px; flex: 0 0 auto; }
.nav a .count {
  margin-left: auto; font-size: var(--fs-xs); font-weight: 700; padding: 0 6px;
  border: var(--border-w-thin) solid var(--ink); background: var(--surface-2); color: var(--text);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink); box-shadow: var(--shadow-sm); text-decoration: none; }
/* Colourful nav items — each gets a different pastel background */
.nav a:nth-child(1) { background: var(--pastel-1); border-color: var(--ink); }
.nav a:nth-child(2) { background: var(--pastel-2); border-color: var(--ink); }
.nav a:nth-child(3) { background: var(--pastel-3); border-color: var(--ink); }
.nav a:nth-child(4) { background: var(--pastel-4); border-color: var(--ink); }
.nav a:nth-child(5) { background: var(--pastel-1); border-color: var(--ink); }
.nav a:nth-child(6) { background: var(--pastel-2); border-color: var(--ink); }
.nav a:nth-child(7) { background: var(--pastel-3); border-color: var(--ink); }
.nav a:nth-child(8) { background: var(--pastel-4); border-color: var(--ink); }
.nav a:nth-child(9) { background: var(--pastel-1); border-color: var(--ink); }
.nav a:nth-child(10) { background: var(--pastel-2); border-color: var(--ink); }
.nav a:nth-child(11) { background: var(--pastel-3); border-color: var(--ink); }
.nav a:nth-child(12) { background: var(--pastel-4); border-color: var(--ink); }
.nav a.active {
  background: var(--primary) !important; color: var(--primary-text) !important;
  border-color: var(--ink); box-shadow: var(--shadow-sm);
}
.nav a.active .count { background: var(--on-accent); color: var(--accent); border-color: var(--on-accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--muted); }

.main { grid-column: 2; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-6);
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: var(--border-w-thick) solid var(--ink);
}
.topbar h1 { margin: 0; font-size: var(--fs-xl); }
.topbar .crumb { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.view { padding: var(--sp-6); max-width: 1500px; width: 100%; margin-inline: auto; }
.view > * + * { margin-top: var(--sp-5); }

/* A colour band under the topbar, like the reference's divider bands: the six
   palette colours as one hard-stop stripe. Hard stops, no blend — the palette
   printed as a key, not a gradient. */
.band {
  flex: 0 0 auto;
  height: 7px;
  border-bottom: var(--border-w) solid var(--ink);
  background: linear-gradient(90deg,
    var(--yellow) 0 16.667%, var(--pink) 0 33.333%, var(--blue) 0 50%,
    var(--green) 0 66.667%, var(--orange) 0 83.333%, var(--purple) 0 100%);
}
/* Mobile navigation backdrop. Hidden on desktop; shown only while the drawer
   is open on narrow screens (see the responsive rules below). */
.nav-scrim { display: none; }

/* ------------------------------------------------------------ 5. buttons -- */
.btn {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px;
  background: var(--surface); color: var(--text);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow);
  font-family: var(--font-heading); font-weight: 700; font-size: var(--fs-sm);
  letter-spacing: 0.01em;
  transition: transform var(--speed), box-shadow var(--speed), background var(--speed), color var(--speed);
}
.btn:hover { background: var(--surface-2); transform: translate(-2px, -2px); box-shadow: var(--shadow-hover); }
.btn:active { transform: translate(5px, 5px); box-shadow: var(--shadow-none); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed; transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 0 var(--ink); background: var(--surface-2);
}
.btn[disabled]:hover, .btn[aria-disabled="true"]:hover { transform: translate(3px, 3px); box-shadow: 2px 2px 0 0 var(--ink); }

.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ok      { background: var(--ok); color: var(--on-accent); }
.btn.danger  { background: var(--bad); color: var(--on-accent); }
/* Reserved for the truly destructive action: the reference keeps --red out of
   the everyday palette, so the one nuclear button reads differently from a
   normal delete. Black type on #FF4444 is 6.2:1 (white would only be 3.4:1). */
.btn.red     { background: var(--red); color: var(--on-accent); }.btn.primary:hover,
.btn.ok:hover,
.btn.danger:hover { filter: brightness(1.05); }

/* Colourful pastel buttons */
.btn.pastel-1 { background: var(--pastel-1); color: var(--on-accent); border-color: var(--ink); }

.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text); }
.btn.ghost:hover { background: var(--surface); border-color: var(--ink); box-shadow: var(--shadow-sm-hover); transform: translate(-2px, -2px); }
.btn.ghost:active { transform: translate(3px, 3px); box-shadow: var(--shadow-none); }

.btn.sm { padding: 6px 10px; box-shadow: var(--shadow-sm); font-size: var(--fs-xs); }
.btn.sm:hover { box-shadow: var(--shadow-sm-hover); }
.btn.sm:active { transform: translate(3px, 3px); box-shadow: var(--shadow-none); }
.btn.icon { padding: 7px 10px; box-shadow: var(--shadow-sm); }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { box-shadow: none; border-right-width: 0; }

/* Colourful chip styles */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.btn-group .btn:last-child { border-right-width: var(--border-w); }
.btn-group .btn.active { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.btn-group .btn.active:hover { transform: none; }

/* -------------------------------------------------------------- 6. forms -- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field > label {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
}
.input, .select, .textarea, input[type="date"], input[type="time"], input[type="number"], input[type="search"] {
  width: 100%; padding: 10px 12px;
  background: var(--surface); color: var(--text);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--speed), transform var(--speed), background var(--speed);
}
.input:focus, .select:focus, .textarea:focus, input[type="date"]:focus, input[type="time"]:focus, input[type="number"]:focus, input[type="search"]:focus {
  outline: 3px solid var(--focus); outline-offset: 2px;
  box-shadow: var(--shadow-sm-hover); transform: translate(-1px, -1px);
  background: var(--surface);
}
.textarea { min-height: 96px; resize: vertical; }
.select { cursor: pointer; }
.field-hint { font-size: var(--fs-xs); color: var(--faint); }
.field-error { font-size: var(--fs-sm); color: var(--bad-ink); font-weight: 700; }
.field-error:empty { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }@media (max-width: 720px){.grid-2,
.grid-3 { grid-template-columns: 1fr; } }

.check { display: inline-flex; align-items: flex-start; gap: var(--sp-3); cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px;
  background: var(--surface); border: var(--border-w) solid var(--ink);
  display: grid; place-items: center;
  box-shadow: 2px 2px 0 0 var(--ink);
  transition: background var(--speed), box-shadow var(--speed), transform var(--speed);
}
.check .box::after {
  content: "✓"; font-size: 16px; font-weight: 700; color: var(--on-accent);
  opacity: 0; transform: scale(0.5); transition: opacity var(--speed), transform var(--speed);
}
.check:hover .box { background: var(--surface-2); }
.check input:checked + .box { background: var(--ok); box-shadow: 2px 2px 0 0 var(--ink); }
.check input:checked + .box::after { opacity: 1; transform: scale(1); }
.check input:focus-visible + .box { outline: 3px solid var(--focus); outline-offset: 2px; }
.check.done .label-text { color: var(--muted); }
.check.done .label-text .strong { text-decoration: line-through; text-decoration-thickness: 2px; }

/* ------------------------------------------------- 7. chips, tags, badges -- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; font-size: var(--fs-xs); font-weight: 700;
  border: var(--border-w-thin) solid var(--ink);
  background: var(--surface); color: var(--text); white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.chip.soft { background: var(--surface-2); color: var(--muted); }
.chip.plain { background: transparent; }
/* State chips are filled: colour carries the meaning, black text keeps it legible. */
.chip.ok   { background: var(--ok); color: var(--on-accent); }
.chip.warn { background: var(--warn); color: var(--on-accent); }
.chip.bad  { background: var(--bad); color: var(--on-accent); }
.chip.info { background: var(--info); color: var(--on-accent); }
.chip.acc  { background: var(--accent); color: var(--on-accent); }
.chip button { all: unset; cursor: pointer; font-weight: 700; opacity: 0.65; padding: 0 2px; }
.chip button:hover { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
  flex: 0 0 auto; border: var(--border-w-thin) solid var(--ink);
}

.badge {
  display: inline-grid; place-items: center; min-width: 22px; padding: 1px 6px;
  font-size: var(--fs-xs); font-weight: 700;
  border: var(--border-w-thin) solid var(--ink); background: var(--surface); color: var(--text);
  box-shadow: 2px 2px 0 0 var(--ink);
}
.badge.bad  { background: var(--bad); color: var(--on-accent); }
.badge.warn { background: var(--warn); color: var(--on-accent); }
.badge.ok   { background: var(--ok); color: var(--on-accent); }
/* The reference's six-colour badge set, available by palette name. */
.badge.yellow { background: var(--yellow); color: var(--on-accent); }
.badge.pink   { background: var(--pink);   color: var(--on-accent); }
.badge.blue   { background: var(--blue);   color: var(--on-accent); }
.badge.green  { background: var(--green);  color: var(--on-accent); }
.badge.orange { background: var(--orange); color: var(--on-accent); }

/* ----------------------------------------------------------- 8. progress -- */
.bar {
  position: relative; height: 14px; background: var(--surface-2);
  border: var(--border-w) solid var(--ink); overflow: hidden;
}
/* Light accents on a pale track sit at ~1.4:1, so the fill's leading edge is
   drawn in ink: the boundary — not the fill colour — carries the reading. */
.bar > span {
  display: block; height: 100%; background: var(--accent);
  border-right: var(--border-w) solid var(--ink);
  transition: width 200ms ease;
}
.bar > span[style*="width:0%"] { border-right: 0; }
.bar.thin { height: 9px; }
.bar.tall { height: 20px; }
.bar.ok > span   { background: var(--ok); }
.bar.warn > span { background: var(--warn); }
.bar.bad > span  { background: var(--bad); }
.bar.striped > span {
  background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.28) 0 7px, transparent 7px 14px);
}
.meter { display: flex; align-items: center; gap: var(--sp-3); }
.meter .bar { flex: 1 1 auto; }
.meter .pct {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: var(--fs-sm); min-width: 50px; text-align: right;
}

/* Stat card — box card with label above value, stacked vertically inside */
.metric {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  height: 100%;
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.metric .k {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 700;
}
.metric .v {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric .s {
  font-size: var(--fs-xs);
  color: var(--faint);
  margin-top: var(--sp-1);
}

/* Stat cards in a fixed, responsive grid — four columns on desktop. */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
  overflow: visible;
}

/* Each card in the grid */
.metrics > .card,
.metrics > .card.metric-link {
  display: block;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

.metrics > .card > .metric,
.metrics > .card.metric-link > .metric {
  height: 100%;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}@media (hover: none){ }

.tree { list-style: none; padding-left: 0; }
.tree ul { list-style: none; padding-left: 26px; border-left: var(--border-w-thin) dashed var(--line); margin-left: 10px; }
.tree li { position: relative; }
.tree .leaf { display: flex; align-items: flex-start; gap: var(--sp-2); padding: 6px 8px; }
.tree .leaf:hover { background: var(--yellow-light); color: var(--black); }
.reorder { display: flex; flex-direction: column; gap: 1px; }
.reorder button { all: unset; cursor: pointer; line-height: 0.8; font-size: 10px; color: var(--faint); padding: 1px 4px; }
.reorder button:hover { background: var(--accent); color: var(--on-accent); }

.empty {
  display: grid; place-items: center; gap: var(--sp-3); text-align: center;
  padding: var(--sp-8) var(--sp-5);
  background: var(--purple-light);
  border: var(--border-w-thick) dashed var(--ink);
  color: var(--black);
}
.empty .em-ico { font-size: 36px; line-height: 1; }
.empty h3 { margin: 0; }
.empty p { max-width: 46ch; margin: 0; }

/* ------------------------------------------------------------- 10. tables -- */
.table-wrap {
  overflow-x: auto; border: var(--border-w) solid var(--ink);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 10px 12px; border-bottom: var(--border-w-thin) solid var(--line); vertical-align: middle; }
th {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text); background: var(--surface-3); font-weight: 700;
  border-bottom: var(--border-w) solid var(--ink); position: sticky; top: 0; z-index: 1;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--yellow-light); color: var(--black); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------- 11. tabs, lists -- */
.tabs { display: flex; gap: 0; flex-wrap: wrap; border-bottom: var(--border-w) solid var(--ink); }
.tab {
  appearance: none; cursor: pointer; background: transparent;
  border: var(--border-w-thin) solid transparent; border-bottom: 0;
  padding: 8px 14px;
  font-family: var(--font-heading); font-weight: 700; font-size: var(--fs-sm);
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted);
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active {
  color: var(--on-accent); background: var(--accent);
  border-color: var(--ink); border-bottom: 0;
  margin-bottom: -3px; padding-bottom: 11px;
}

.list { display: flex; flex-direction: column; gap: var(--sp-3); }
.list-item {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4); background: var(--surface);
  border: var(--border-w) solid var(--ink); box-shadow: var(--shadow-sm);
}
.list-item.flat { box-shadow: none; }
.list-item.overdue { border-color: var(--bad); box-shadow: 4px 4px 0 0 var(--bad); }
.list-item.soon { border-color: var(--warn); box-shadow: 4px 4px 0 0 var(--warn); }
.list-item.pinned { border-left-width: 14px; border-left-color: var(--accent); }
.list-item.item { padding: var(--sp-3); }

/* ------------------------------------------------------------- 12. charts -- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 10.5px; font-family: var(--font-mono); }
.chart .axis-text.strong { fill: var(--text); font-weight: 700; }
.chart .bar { fill: var(--accent); }
.chart .bar-ok { fill: var(--ok); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: 0.28; stroke: none; }
.chart .donut-track { fill: none; stroke: var(--surface-3); }
.chart .donut-seg { fill: none; stroke-linecap: butt; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar:hover { filter: brightness(1.12); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--muted); margin-top: var(--sp-3); }
.chart-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 12px; height: 12px; border: var(--border-w-thin) solid var(--ink); }
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, -124%);
  background: var(--surface); color: var(--text);
  border: var(--border-w) solid var(--ink); box-shadow: var(--shadow-sm);
  padding: 6px 10px; font-family: var(--font-mono); font-size: var(--fs-xs);
  font-weight: 700; white-space: nowrap; opacity: 0; transition: opacity 100ms;
}
.chart-tip.on { opacity: 1; }

/* Chart pairs inside analytics sit side by side without the usual inter-card gap. */
.card-pair > .card + .card { margin-top: 0; }

/* ---------------------------------------------------------- 13. dashboard -- */
.tiles { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4); border: var(--border-w) solid var(--ink);
  background: var(--surface); box-shadow: var(--shadow);
}
.tile.today { background: var(--accent); color: var(--on-accent); }
.tile.today .muted { color: rgba(0, 0, 0, 0.72); }
/* The reference cycles colour across a card grid — 1st = surface, 2nd = pink,
   3rd = cyan — so a grid of cards reads as a colour sequence, not a grey list.
   Scoped to grids that opt in with `.tinted`. */
.tiles.tinted > .tile:nth-child(3n+2) { background: var(--pink); color: var(--on-accent); }
.tiles.tinted > .tile:nth-child(3n+3) { background: var(--cyan); color: var(--on-accent); }
.tiles.tinted > .tile:nth-child(3n+2) .muted,
.tiles.tinted > .tile:nth-child(3n+3) .muted { color: rgba(0, 0, 0, 0.72); }
.tiles.tinted > .tile:nth-child(3n+2) .stats b,
.tiles.tinted > .tile:nth-child(3n+3) .stats b { color: var(--on-accent); }
.tile .tile-top { display: flex; align-items: center; gap: var(--sp-3); }
.tile .tile-mark {
  width: 36px; height: 36px; border: var(--border-w-thin) solid var(--ink);
  display: grid; place-items: center; flex: 0 0 auto;
  font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-sm);
  color: var(--on-accent); box-shadow: 2px 2px 0 0 var(--ink);
}
.tile h3 { margin: 0; font-size: var(--fs); }
.tile .stats { display: flex; gap: var(--sp-4); font-size: var(--fs-xs); color: var(--muted); }
.tile .stats b { display: block; font-family: var(--font-mono); font-size: var(--fs); color: var(--text-strong); font-variant-numeric: tabular-nums; }

.suggest { display: flex; flex-direction: column; gap: var(--sp-3); }
.suggest-item {
  padding: var(--sp-3) var(--sp-4); border: var(--border-w) solid var(--ink);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.suggest-item .why { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.suggest-rank {
  font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg);
  width: 30px; color: var(--text); line-height: 1;
}

/* -------------------------------------------------------------- 14. modal -- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--sp-4);
  background-color: var(--scrim);
  /* Hard-edged diagonal stripes — a printed screen, not a frosted pane. */
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0 10px, transparent 10px 20px);
  animation: fade 100ms ease;
}
.modal {
  width: min(680px, 100%); max-height: min(88vh, 900px); overflow: auto;
  background: var(--surface); color: var(--text);
  border: var(--border-w-thick) solid var(--ink); box-shadow: var(--shadow-xl);
  animation: pop 120ms ease;
}
.modal-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: var(--border-w) solid var(--ink);
  position: sticky; top: 0; background: var(--surface-3); z-index: 2;
}
.modal-head h2 { margin: 0; font-size: var(--fs-lg); text-transform: uppercase; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: var(--sp-5); }
.modal-foot {
  display: flex; gap: var(--sp-3); justify-content: flex-end;
  padding: var(--sp-4) var(--sp-5);
  border-top: var(--border-w) solid var(--ink);
  position: sticky; bottom: 0; background: var(--surface-3);
}
.modal.wide { width: min(980px, 100%); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translate(6px, 6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- 15. toasts -- */
.toasts { position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 80; display: flex; flex-direction: column; gap: var(--sp-3); max-width: min(400px, 92vw); }
/* Full-colour toasts with black type — the reference fills the whole toast. */
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: var(--border-w) solid var(--ink);
  background: var(--blue); box-shadow: var(--shadow);
  color: var(--on-accent);
  font-weight: 600; font-size: var(--fs-sm);
  animation: pop 120ms ease;
}
.toast.ok   { background: var(--green); }
.toast.err  { background: var(--pink); }
.toast.info { background: var(--blue); }
.toast.warn { background: var(--yellow); }

/* ----------------------------------------------------------- 16. calendar -- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-head {
  font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--muted); text-align: center; padding: 4px 0; font-weight: 700;
}
.cal-cell {
  min-height: 90px; padding: 6px;
  border: var(--border-w-thin) solid var(--ink);
  background: var(--surface);
  display: flex; flex-direction: column; gap: 3px; font-size: var(--fs-xs);
  cursor: pointer; text-align: left; color: inherit;
  transition: transform var(--speed), box-shadow var(--speed);
}
.cal-cell:hover { box-shadow: var(--shadow-sm); transform: translate(-1px, -1px); }
.cal-cell.out { opacity: 0.4; background: transparent; box-shadow: none; }
.cal-cell.today { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.cal-cell.sel { border-width: var(--border-w); box-shadow: var(--shadow-sm); }
.cal-cell .dnum { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-cell .ev { display: flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-cell .ev .dot { width: 7px; height: 7px; }
.cal-cell .more { color: var(--muted); font-size: 10px; }

/* -------------------------------------------------------------- 17. timer -- */
.timer-face {
  display: grid; place-items: center; gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-5);
  border: var(--border-w-thick) solid var(--ink);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.timer-clock {
  font-size: clamp(46px, 12vw, 104px); font-weight: 700;
  letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1;
}
.timer-state { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.24em; font-weight: 700; color: var(--muted); }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Topbar streak chip animations */
@keyframes streakPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.03); }
}
@keyframes streakBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-3px) rotate(-3deg); }
  50% { transform: translateY(0) rotate(2deg); }
  75% { transform: translateY(-2px) rotate(-1deg); }
}
.ring {
  --p: 0; width: 184px; height: 184px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
  border: var(--border-w-thick) solid var(--ink); box-shadow: var(--shadow-sm);
}
.ring > div {
  width: 78%; height: 78%; border-radius: 50%; background: var(--surface);
  border: var(--border-w) solid var(--ink); display: grid; place-items: center; text-align: center;
}

/* ------------------------------------------------------------- 18. misc --- */
.stat-line {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 8px 0; border-bottom: var(--border-w-thin) dashed var(--line); font-size: var(--fs-sm);
}
.stat-line:last-child { border-bottom: 0; }
.stat-line b { font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px var(--sp-4); font-size: var(--fs-sm); }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; }
details.disclosure {
  border: var(--border-w) solid var(--ink); padding: var(--sp-3) var(--sp-4);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
details.disclosure summary { cursor: pointer; font-family: var(--font-heading); font-weight: 700; }
details.disclosure summary::marker { color: var(--accent-text); }
details.disclosure[open] summary { margin-bottom: var(--sp-3); }
/* Tinted panel + coloured hard shadow, exactly the reference's do/don't box. */
.callout {
  border: var(--border-w) solid var(--ink);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--black);
}
.callout.ok   { background: var(--green-light);  box-shadow: 5px 5px 0 0 var(--green); }
.callout.warn { background: var(--orange-light); box-shadow: 5px 5px 0 0 var(--orange); }
.callout.bad  { background: var(--pink-light);   box-shadow: 5px 5px 0 0 var(--pink); }
.callout.info { background: var(--blue-light);   box-shadow: 5px 5px 0 0 var(--blue); }

/* The first paint. A branded, self-contained card with one quiet animation, so
   a cold start never shows a blank page or an unstyled flash. */
.boot { display: grid; place-items: center; min-height: 100vh; padding: var(--sp-6); background: var(--bg); }
.boot-card {
  position: relative; overflow: hidden;
  padding: clamp(28px, 6vw, 48px) clamp(28px, 7vw, 64px); text-align: center;
  background: var(--surface); border: var(--border-w-thick) solid var(--ink);
  box-shadow: var(--shadow-xl);
  animation: pop 180ms ease-out both;
}
.boot-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--accent);
}.boot-progress {
  width: min(220px, 62vw); height: 6px; margin: var(--sp-5) auto var(--sp-3);
  background: var(--surface-2); border: var(--border-w-thin) solid var(--ink); overflow: hidden;
}
.boot-progress span {
  display: block; width: 42%; height: 100%; background: var(--accent);
  animation: boot-bar 1.35s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.boot-status { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
@keyframes boot-bar { 0% { transform: translateX(-105%); } 100% { transform: translateX(360%); } }
@keyframes boot-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}
@keyframes app-in { from { opacity: 0; } to { opacity: 1; } }
.main, .public-shell { animation: app-in 240ms ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .boot-mark, .boot-progress span, .boot-card, .main, .public-shell { animation: none; }
}
[data-reduce-motion="true"] .boot-mark,
[data-reduce-motion="true"] .boot-progress span,
[data-reduce-motion="true"] .boot-card,
[data-reduce-motion="true"] .main,
[data-reduce-motion="true"] .public-shell { animation: none; }

/* The boot card is static HTML, so it names both products and CSS picks one.
   `data-brand` is set by the inline script in index.html when the Android shell
   is present, which happens before the first paint. */
.brand-native { display: none; }

/* ------------------------------------------------------- 19. responsive --- */
@media (max-width: 1080px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  /* The sidebar leaves the grid flow (position: fixed), so main must return to
     the first track instead of creating an implicit second column. */
  .main { grid-column: 1; }
  /* The shell's sidebar width is driven by --sidebar-w (0px at this breakpoint
     for the old grid layout); the drawer still needs its real width. `aside`
     raises specificity above the later base `.app-shell > .sidebar` rules. */
  .app-shell > aside.sidebar {
    width: min(290px, 86vw);
    min-height: 0;
    z-index: 50;
    overflow-y: auto;
  }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-104%);
    transition: transform 160ms ease; border-right: var(--border-w-thick) solid var(--ink);
    box-shadow: 12px 0 0 0 var(--ink);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  /* A desktop-collapsed sidebar must still be fully usable as a mobile drawer. */
  .app-shell .sidebar.collapsed { width: min(290px, 86vw); }
  .app-shell .sidebar.collapsed .nav-label,
  .app-shell .sidebar.collapsed .nav a span:not(.ico):not(.count),
  .app-shell .sidebar.collapsed .brand-name-cursive { display: revert !important; }
  .app-shell .sidebar.collapsed .nav a { justify-content: flex-start; padding: 9px 11px; }
  .hamburger { display: inline-flex; }
  /* Backdrop/overlay behind the drawer. Clicking it closes the menu. */
  body.nav-open .nav-scrim {
    display: block;
    position: fixed; inset: 0;
    z-index: 45;
    width: 100%; height: 100%;
    border: 0; padding: 0; margin: 0;
    background: rgb(0 0 0 / 0.45);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  /* Keep the page behind the open drawer from scrolling. */
  body.nav-open { overflow: hidden; }
  .view { padding: var(--sp-4); }
  .topbar { padding: var(--sp-3) var(--sp-4); }
  .topbar h1 { font-size: var(--fs-lg); }
  .scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 25; }
}
@media (max-width: 720px) {
  :root { --fs: 14px; --fs-2xl: 26px; --fs-xl: 20px; }
  body { background-image: none; }     /* the grid would fight a narrow viewport */
  .metrics { grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: var(--sp-3); }
  .card { padding: var(--sp-4); box-shadow: var(--shadow); }
  .card.hero { padding: var(--sp-4); }
  .cal-cell { min-height: 64px; }
  .cal { gap: 4px; }
  .toasts { left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3); max-width: none; }
  th, td { padding: 8px 10px; }
}

/* -------------------------------------------------- 20. motion & print --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .pulse { animation: none; }
}
[data-reduce-motion="true"] *, [data-reduce-motion="true"] *::before, [data-reduce-motion="true"] *::after {
  animation-duration: 0.001ms !important; transition-duration: 0.001ms !important;
}
[data-reduce-motion="true"] .btn:hover, [data-reduce-motion="true"] a.card:hover,
[data-reduce-motion="true"] .tile:hover, [data-reduce-motion="true"] .suggest-item:hover,
[data-reduce-motion="true"] .metric-link:hover { transform: none; }
@media print {
  .sidebar, .topbar, .toasts, .actions, .skip-link { display: none !important; }
  body { background: #fff; background-image: none; color: #000; }
  .card, .tile, .list-item, .modal, .empty { box-shadow: none; border-color: #000; break-inside: avoid; }
  .chip, .badge { box-shadow: none; }
}.tile-mark.big { width: 64px; height: 64px; font-size: 2rem; }/* ----------------------------------------------------------------- heatmap -- */
/* One column per week, seven cells tall; the month label sits above its column so
   the labels line up with the grid without absolute positioning. */
.hm { display: flex; gap: 3px; overflow-x: auto; padding-bottom: var(--sp-2); }
.hm-week { display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto; }
.hm-month {
  height: 14px; font-size: 10px; line-height: 14px; color: var(--muted);
  font-family: var(--font-mono); white-space: nowrap;
}
.hm-cell {
  width: 14px; height: 14px; display: block; border: 1px solid var(--ink);
  background: var(--surface);
}
.hm-cell.lvl0 { background: #e9e5da; }
.hm-cell.lvl1 { background: var(--yellow-light); }
.hm-cell.lvl2 { background: var(--yellow); }
.hm-cell.lvl3 { background: var(--orange); }
.hm-cell.lvl4 { background: var(--green); }
[data-theme="dark"] .hm-cell.lvl0 { background: #34323f; }
.hm-cell:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }/* ------------------------------------------------------------ form helpers -- */
/* Field hint text (used under inputs) and a code/command block. */
.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }

/* ------------------------------------------------------------ onboarding -- */
/* A full-screen welcome tour for a brand-new install. Built from the same tokens
   as the rest of the app: square edges, hard shadows, flat accent fills. */
body.onb-open { overflow: hidden; }
.onb {
  position: fixed; inset: 0; z-index: 200; overflow-y: auto;
  display: grid; place-items: center; padding: var(--sp-5);
  background: var(--bg);
}
.onb-card {
  position: relative; width: min(880px, 100%); background: var(--surface);
  border: var(--border-w-thick) solid var(--ink); box-shadow: var(--shadow-xl);
  padding: clamp(var(--sp-5), 4vw, var(--sp-8));
  animation: pop 140ms ease-out both;
}
.onb-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--accent);
}
.onb-stage { position: relative; }
.onb-logo {
  display: inline-block; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.4rem, 7vw, 4rem); line-height: 0.95; letter-spacing: -0.02em;
  background: var(--accent); border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow); padding: 6px 18px; transform: rotate(-2deg); color: var(--on-accent);
  animation: onb-wobble 3.4s ease-in-out infinite;
}
.onb-title {
  font-size: clamp(1.5rem, 3.6vw, 2.2rem); line-height: 1.1;
  margin: var(--sp-5) 0 var(--sp-3);
}
.onb-accent { color: var(--text); box-shadow: inset 0 -0.35em 0 var(--yellow); }
/* White type sits over this highlight in dark mode, so the fill must stay a
   quiet translucent wash rather than the bright ochre. */
[data-theme="dark"] .onb-accent { box-shadow: inset 0 -0.35em 0 rgba(253, 230, 138, 0.22); }
.onb-lead { color: var(--muted); max-width: 56ch; }
.onb-step {
  display: inline-block; font-family: var(--font-mono); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  border: var(--border-w-thin) solid var(--ink); padding: 3px 8px; background: var(--surface-2);
}
.onb-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3); margin: var(--sp-5) 0;
}
.onb-feature {
  display: flex; flex-direction: column; gap: 2px;
  border: var(--border-w-thin) solid var(--ink); background: var(--surface-2);
  padding: var(--sp-3); box-shadow: var(--shadow-sm);
}
.onb-feature-ico { font-size: 1.2rem; }
.onb-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-top: var(--sp-5); }
.onb-big { font-size: var(--fs-lg); padding: 12px 22px; }
.onb-form { margin-top: var(--sp-4); }
.onb-avatars { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.onb-avatar {
  cursor: pointer; border: var(--border-w-thin) solid var(--ink);
  background: var(--surface); width: 46px; height: 46px; display: grid; place-items: center;
  font-size: 1.4rem; box-shadow: var(--shadow-sm); transition: transform var(--speed), box-shadow var(--speed);
}
.onb-avatar input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.onb-avatar:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.onb-avatar.on { background: var(--accent); box-shadow: var(--shadow); transform: translate(-1px, -1px); }
.onb-avatar:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Step rail: a labelled progress bar replaces the bare dots on wide screens. */
.onb-rail { display: flex; gap: 6px; margin-bottom: var(--sp-5); }
.onb-rail-step {
  flex: 1; display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border: var(--border-w-thin) solid var(--ink);
  background: var(--surface-2); color: var(--muted);
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.onb-rail-step i {
  width: 19px; height: 19px; flex: 0 0 auto; display: grid; place-items: center;
  border: var(--border-w-thin) solid var(--ink); background: var(--surface);
  color: var(--text); font-style: normal;
}
.onb-rail-step.on { background: var(--accent); color: var(--on-accent); }
.onb-rail-step.on i { background: var(--surface); color: var(--text); }
.onb-rail-step.done i { background: var(--ok); color: var(--on-accent); }

.onb-subject-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-3); margin: var(--sp-4) 0 var(--sp-2); flex-wrap: wrap;
}
.onb-subject-head b { font-family: var(--font-heading); font-size: var(--fs-lg); }
.onb-subject-head p { margin: 2px 0 0; }
.onb-count-pill, .setup-count-pill {
  display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap;
  padding: 5px 10px; border: var(--border-w-thin) solid var(--ink);
  background: var(--surface-2); font-family: var(--font-mono);
  font-size: var(--fs-xs); font-weight: 700;
}
.onb-count-pill b, .setup-count-pill b { font-size: var(--fs-lg); color: var(--text); }
.onb-subject-grid { max-height: min(46vh, 440px); overflow-y: auto; padding-right: 4px; }
@media (max-width: 680px) {
  .onb-rail-step { font-size: 0; gap: 0; justify-content: center; padding: 6px; }
  .onb-rail-step i { font-size: 10px; }
  .onb-subject-head, .setup-subject-head { align-items: flex-start; }
  .landing-pill, .landing-orb.o2 { display: none; }
}
/* Funky stage furniture: flat orbs and drifting glyphs, no blur, no gradients. */
.onb-orb {
  position: absolute; border: var(--border-w) solid var(--ink); z-index: -1; pointer-events: none;
}
.onb-orb.o1 {
  width: 120px; height: 120px; background: var(--info); right: -28px; top: -46px;
  animation: onb-drift 6s ease-in-out infinite;
}
.onb-orb.o2 {
  width: 74px; height: 74px; background: var(--warn); left: -26px; bottom: -30px;
  animation: onb-drift 7.5s ease-in-out infinite reverse;
}
.onb-float { position: absolute; font-size: 1.6rem; color: var(--accent); z-index: -1; animation: onb-drift 5s ease-in-out infinite; }
.onb-float { right: 10%; top: 12%; }
.onb-float.f2 { left: 8%; top: 30%; animation-duration: 6.5s; color: var(--info); }
.onb-float.f3 { right: 18%; bottom: 8%; animation-duration: 8s; color: var(--bad); }
@keyframes onb-drift { 0%, 100% { transform: translate(0, 0) rotate(0deg); } 50% { transform: translate(4px, -8px) rotate(6deg); } }
@keyframes onb-wobble { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(1.5deg); } }
[data-reduce-motion="true"] .onb-orb, [data-reduce-motion="true"] .onb-float,
/* ---------------------------------------------------- onboarding unlock --- */
/* The final onboarding stage: the ₹199 unlock, in the same hand-drawn card. */
.onb-upgrade .buy-card { margin-top: var(--sp-5); }
.onb-upgrade .buy-title { font-size: clamp(1.5rem, 4.4vw, 2.1rem); }
.onb-unlock-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 20px;
  margin: 0 auto var(--sp-5);
  padding: 0;
  max-width: 54ch;
  text-align: left;
}
.onb-unlock-list li {
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--ll-ink);
}
.onb-unlock-list li > span:first-child { flex: none; width: 1.3em; text-align: center; }
.onb-unlock-list b { font-weight: 800; }
@media (max-width: 560px) {
  .onb-unlock-list { grid-template-columns: 1fr; }
  .onb-upgrade .buy-actions { flex-direction: column; }
  .onb-upgrade .buy-actions .btn { width: 100%; }
}

[data-reduce-motion="true"] .onb-logo, [data-reduce-motion="true"] .onb-card { animation: none; }

/* --------------------------------------------------------------- quests --- */
.quest-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); }
.quest {
  border: var(--border-w-thin) solid var(--ink); background: var(--surface-2);
  padding: var(--sp-3); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: var(--sp-2);
}
.quest.done { background: var(--green-light); }
.quest-top { display: flex; align-items: flex-start; gap: var(--sp-2); }
.quest-ico { font-size: 1.3rem; }
.quest-xp { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-xs); border: var(--border-w-thin) solid var(--ink); padding: 2px 6px; background: var(--accent); color: var(--on-accent); }
.quest.done .quest-xp { background: var(--ok); }
[data-theme="dark"] .quest.done { background: var(--surface-2); }

/* ------------------------------------------------------------ curriculum -- */
.cur-subject { border: var(--border-w-thin) solid var(--ink); background: var(--surface); padding: var(--sp-3); box-shadow: var(--shadow-sm); }
.cur-subject > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); align-items: baseline; list-style: none; }
.cur-subject > summary::-webkit-details-marker { display: none; }
.cur-subject > summary::before { content: "▸"; color: var(--muted); margin-right: 2px; }
.cur-subject[open] > summary::before { content: "▾"; }
.cur-sub-name { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); }
.cur-unit { border-top: var(--border-w-thin) dashed var(--surface-3); margin-top: var(--sp-4); padding-top: var(--sp-3); }
.cur-chapter { border-left: var(--border-w-thin) solid var(--surface-3); padding-left: var(--sp-3); }
.cur-topics { margin: var(--sp-2) 0 0; padding-left: 18px; display: grid; gap: 4px; }
.cur-topic-name { font-weight: 600; }

/* ==========================================================================
   PUBLIC PRODUCT SURFACE

   The landing, auth and setup screens use the same grammar as the app: one
   radius (0), 3–4px ink borders, hard offset shadows, flat saturated fills.
   They are full-width pages rather than app views, but nothing new is
   introduced — the type scale, buttons, cards and chips are the existing ones.
   ========================================================================== */

.public-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.public-top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: var(--border-w-thick) solid var(--ink);
}
.public-brand { display: flex; align-items: center; gap: var(--sp-3); color: var(--text); text-decoration: none; }
.public-brand:hover { text-decoration: none; }.public-top-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; }
.public-identity { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.public-main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) var(--sp-8); overflow-x: clip; }
.public-foot {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-4) clamp(16px, 4vw, 40px);
  border-top: var(--border-w-thin) solid var(--ink);
  background: var(--surface);
  font-size: var(--fs-sm); color: var(--muted);
}
.account-gate { min-height: 62vh; display: grid; place-items: center; }

/* ------------------------------------------------------------------ landing */
.landing { display: flex; flex-direction: column; gap: clamp(40px, 7vw, 88px); padding-top: clamp(32px, 6vw, 64px); }
.landing-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(36px, 6vw, 80px); align-items: center; }
.landing-copy { min-width: 0; max-width: 48ch; }
.landing-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.25rem, 5.2vw, 4.3rem); line-height: 1.02; letter-spacing: -0.045em;
  margin: 14px 0 18px;
}
.landing-hl { box-shadow: inset 0 -0.32em 0 var(--yellow); }
[data-theme="dark"] .landing-hl { box-shadow: inset 0 -0.32em 0 rgba(253, 230, 138, 0.22); }
.landing-lead { font-size: var(--fs-lg); line-height: 1.6; color: var(--muted); max-width: 54ch; margin: 0; }
.landing-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-top: var(--sp-5); }
.landing-points { list-style: none; padding: 0; margin: var(--sp-4) 0 0; display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }.landing-visual { position: relative; min-width: 0; }
.landing-sticker {
  position: absolute; right: -14px; top: -18px;
  width: 56px; height: 56px; display: grid; place-items: center;
  background: var(--accent-2); color: var(--on-accent);
  border: var(--border-w) solid var(--ink); box-shadow: var(--shadow-sm);
  font-size: 26px; transform: rotate(8deg);
}
.landing-preview {
  background: var(--surface);
  border: var(--border-w-thick) solid var(--ink);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-4);
  transform: rotate(-1.2deg);
}
.lp-head { display: flex; align-items: center; gap: var(--sp-4); margin-top: var(--sp-4); }
.lp-ring {
  width: 86px; height: 86px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--ok) 0 62%, var(--surface-3) 62% 100%);
  border: var(--border-w) solid var(--ink);
}
.lp-ring span { width: 62px; height: 62px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 21px; }
.lp-ring i { font-style: normal; font-size: 11px; }
.lp-big { display: block; font-family: var(--font-heading); font-size: var(--fs-lg); margin: 2px 0; }
.lp-list { list-style: none; margin: var(--sp-4) 0 0; padding: 0; display: grid; gap: 6px; }
.lp-row { display: flex; align-items: center; gap: var(--sp-2); border: var(--border-w-thin) solid var(--ink); padding: 7px 9px; font-size: var(--fs-sm); background: var(--surface-2); }
.lp-check { width: 18px; height: 18px; flex: 0 0 auto; display: grid; place-items: center; border: var(--border-w-thin) solid var(--ink); background: var(--surface); font-size: 10px; font-weight: 700; }
.lp-check.on { background: var(--ok); color: var(--on-accent); }
.lp-row .chip { margin-left: auto; }
.lp-foot { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: var(--border-w-thin) dashed var(--line); font-size: var(--fs-sm); color: var(--muted); }
.lp-foot b { color: var(--text); }

.landing-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow);
}
.landing-stat { padding: var(--sp-5) var(--sp-4); border-right: var(--border-w-thin) solid var(--ink); position: relative; }
.landing-stat:last-child { border-right: 0; }
.landing-stat::before {
  content: ""; position: absolute; left: var(--sp-4); top: var(--sp-5); bottom: var(--sp-5); width: 4px;
}
.landing-stat:nth-child(1)::before { background: var(--accent); }
.landing-stat:nth-child(2)::before { background: var(--accent-2); }
.landing-stat:nth-child(3)::before { background: var(--ok); }
.landing-stat:nth-child(4)::before { background: var(--extra); }
.landing-stat span { display: block; margin-top: 5px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; color: var(--muted); }
.landing-stat b { display: block; font-family: var(--font-display); font-weight: 800; font-size: clamp(24px, 4vw, 36px); line-height: 1; letter-spacing: -0.03em; }
.landing-stat span { display: block; margin-top: 5px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; color: var(--muted); }

.landing-section-head { max-width: 62ch; margin-bottom: var(--sp-5); }
.landing-section-head h2 { font-family: var(--font-display); font-size: clamp(1.55rem, 3.2vw, 2.35rem); line-height: 1.08; letter-spacing: -0.035em; margin: 8px 0 10px; }
.landing-section-head p { margin: 0; }
.landing-features { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.landing-feature {
  background: var(--surface); border: var(--border-w) solid var(--ink); border-left-width: var(--border-w-thick);
  box-shadow: var(--shadow-sm); padding: var(--sp-4); transition: transform var(--speed), box-shadow var(--speed);
}
.landing-feature:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.landing-feature-ico {
  width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: var(--sp-3);
  background: var(--accent); color: var(--on-accent); border: var(--border-w) solid var(--ink);
  font-size: 19px; font-weight: 700;
}
.landing-feature:nth-child(1) { border-left-color: var(--accent); }
.landing-feature:nth-child(2) { border-left-color: var(--accent-2); }
.landing-feature:nth-child(3) { border-left-color: var(--ok); }
.landing-feature:nth-child(4) { border-left-color: var(--warn); }
.landing-feature:nth-child(5) { border-left-color: var(--bad); }
.landing-feature:nth-child(6) { border-left-color: var(--extra); }
.landing-feature:nth-child(1) .landing-feature-ico { background: var(--accent); }
.landing-feature:nth-child(2) .landing-feature-ico { background: var(--accent-2); }
.landing-feature:nth-child(3) .landing-feature-ico { background: var(--ok); }
.landing-feature:nth-child(4) .landing-feature-ico { background: var(--warn); }
.landing-feature:nth-child(5) .landing-feature-ico { background: var(--bad); }
.landing-feature:nth-child(6) .landing-feature-ico { background: var(--extra); }
.landing-feature h3 { margin: 0 0 6px; font-family: var(--font-heading); font-size: var(--fs-lg); }
.landing-feature p { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.6; }

.landing-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.landing-step { border-top: var(--border-w-thick) solid var(--ink); padding-top: var(--sp-4); position: relative; }
.landing-step-n { font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-lg); background: var(--accent); border: var(--border-w-thin) solid var(--ink); padding: 4px 10px; display: inline-block; }
.landing-step:nth-child(1) .landing-step-n { background: var(--accent); }
.landing-step:nth-child(2) .landing-step-n { background: var(--accent-2); }
.landing-step:nth-child(3) .landing-step-n { background: var(--ok); }
.landing-step h3 { margin: var(--sp-3) 0 6px; font-family: var(--font-heading); font-size: var(--fs-lg); }
.landing-step p { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.6; }
.landing-subject .xs { font-weight: 400; }

.landing-cta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-5);
  background: var(--accent); color: var(--on-accent);
  border: var(--border-w-thick) solid var(--ink); box-shadow: var(--shadow-lg);
  padding: clamp(22px, 4vw, 36px);
}
.landing-cta h2 { font-family: var(--font-display); font-size: clamp(1.5rem, 3vw, 2.2rem); margin: 8px 0 6px; letter-spacing: -0.03em; }
.landing-cta .muted { color: rgba(0, 0, 0, 0.7); }
.landing-cta .eyebrow { color: rgba(0, 0, 0, 0.66); }
.landing-cta .btn { background: var(--surface); }
.landing-cta .btn.primary { background: var(--black); color: var(--white); }
.landing-cta .landing-actions { margin-top: 0; }


/* ------------------------------------------------------------ buy panel --- */
/* Gen Z hand-drawn looseleaf pricing card — free users only, at the bottom of
   the welcome page. Matches the app's ink-on-paper aesthetic. */
.welcome-buy { margin: var(--sp-8) 0 var(--sp-6); }
.buy-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--r);
  padding: var(--sp-7) var(--sp-6);
  background: var(--ll-paper);
  border: 2px solid var(--ll-pencil-mark);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.buy-card::before {
  content: "";
  position: absolute;
  top: -14px; left: -14px; right: -14px; height: 18px;
  background: repeating-linear-gradient(90deg,
    var(--ll-rule-blue) 0 10px,
    var(--ll-rule-red) 10px 20px,
    var(--ll-rule-green) 20px 30px);
  opacity: 0.9;
}
.buy-ribbon {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent-2);
  padding: 4px 12px;
  border: 1.4px solid var(--accent-2);
  border-radius: var(--r);
  margin-bottom: var(--sp-4);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent);
}
.buy-title { margin: 0 0 var(--sp-3); font-family: var(--font-display); font-size: clamp(1.9rem, 6vw, 2.8rem); line-height: 1.05; letter-spacing: -0.03em; color: var(--ll-ink); }
.buy-note { margin: 0 0 var(--sp-5); color: var(--muted); font-size: var(--fs-base); line-height: 1.7; }
.buy-actions { display: flex; gap: var(--sp-3); justify-content: center; margin-bottom: var(--sp-3); }
.buy-buy {
  padding: var(--sp-4) var(--sp-7);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-base);
  letter-spacing: -0.02em;
  background: var(--accent);
  color: #fff9ef;
  border: 1.4px solid var(--ink);
  border-radius: var(--r);
  box-shadow: 4px 4px 0 var(--ink);
}
.buy-buy:hover { background: var(--accent-2); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.buy-buy:active { transform: translate(0, 0); box-shadow: 2px 2px 0 var(--ink); }
.buy-buy[disabled] { opacity: 0.55; cursor: not-allowed; box-shadow: 2px 2px 0 var(--ink-muted); }
.buy-warn { margin: 0; color: var(--bad); font-size: var(--fs-sm); font-weight: 700; }

[data-theme="dark"] .buy-card { background: var(--ll-slate); border-color: var(--ll-pencil-mark); }
[data-theme="dark"] .buy-ribbon { background: color-mix(in srgb, var(--accent-2) 20%, transparent); }

/* -------------------------------------------------------- feature previews -- */
/* Free users see feature cards but they are visually locked / non-interactive. */
.welcome-preview { margin: var(--sp-8) 0 var(--sp-6); }
.preview-head { font-family: var(--font-display); font-size: clamp(1.6rem, 5vw, 2.4rem); margin: 0 0 var(--sp-5); color: var(--ll-ink); letter-spacing: -0.02em; text-align: center; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-5); }
.preview-card {
  position: relative;
  border-radius: var(--r);
  padding: var(--sp-5) var(--sp-4);
  background: var(--ll-paper);
  border: 1.6px solid var(--ll-pencil-mark);
  box-shadow: 3px 3px 0 var(--ink);
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.preview-card.locked { opacity: 0.62; filter: grayscale(0.35); pointer-events: none; }
.preview-card:not(.locked):hover { transform: translate(-3px, -3px); box-shadow: 5px 5px 0 var(--ink); border-color: var(--accent); }
.preview-ico { font-size: 2.2rem; display: block; margin-bottom: var(--sp-3); }
.preview-card h3 { margin: 0 0 var(--sp-3); font-family: var(--font-heading); font-size: var(--fs-lg); color: var(--ll-ink); }
.preview-text { margin: 0 0 var(--sp-4); color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }
.preview-lock {
  position: absolute;
  top: var(--sp-3); right: var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 15%, transparent);
  border: 1px solid var(--bad);
  border-radius: var(--r);
  padding: 2px 8px;
}
.preview-note { margin: var(--sp-4) 0 0; text-align: center; color: var(--muted); font-size: var(--fs-xs); font-style: italic; }

[data-theme="dark"] .preview-card { background: var(--ll-slate); border-color: var(--ll-pencil-mark); }




/* ------------------------------------------------------------ modal buy --- */
/* Beautiful Gen Z hand-drawn upgrade modal — matches the looseleaf theme. */
.modal-buy-card {
  text-align: center;
  max-width: 360px;
}
.buy-ribbon {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent-2);
  padding: 4px 12px;
  border: 1.4px solid var(--accent-2);
  border-radius: var(--r);
  margin-bottom: var(--sp-4);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent);
}
.buy-title { margin: 0 0 var(--sp-3); font-family: var(--font-display); font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.05; letter-spacing: -0.03em; color: var(--ll-ink); }
.buy-note { margin: 0 0 var(--sp-5); color: var(--muted); font-size: var(--fs-base); line-height: 1.7; }
.buy-actions { display: flex; gap: var(--sp-3); justify-content: center; margin-bottom: var(--sp-3); }
.buy-buy {
  padding: var(--sp-4) var(--sp-7);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-base);
  letter-spacing: -0.02em;
  background: var(--accent);
  color: #fff9ef;
  border: 1.4px solid var(--ink);
  border-radius: var(--r);
  box-shadow: 4px 4px 0 var(--ink);
}
.buy-buy:hover { background: var(--accent-2); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.buy-buy:active { transform: translate(0, 0); box-shadow: 2px 2px 0 var(--ink); }
.buy-buy[disabled] { opacity: 0.55; cursor: not-allowed; box-shadow: 2px 2px 0 var(--ink-muted); }
.buy-warn { margin: 0; color: var(--bad); font-size: var(--fs-sm); font-weight: 700; }

[data-theme="dark"] .buy-buy { background: var(--accent-2); }

/* ------------------------------------------------------------ buy panel --- */
/* Gen Z hand-drawn looseleaf pricing card — free users only, at the bottom of
   the welcome page. Matches the app's ink-on-paper aesthetic. */
.welcome-buy { margin: var(--sp-8) 0 var(--sp-6); }
.buy-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--r);
  padding: var(--sp-7) var(--sp-6);
  background: var(--ll-paper);
  border: 2px solid var(--ll-pencil-mark);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.buy-card::before {
  content: "";
  position: absolute;
  top: -14px; left: -14px; right: -14px; height: 18px;
  background: repeating-linear-gradient(90deg,
    var(--ll-rule-blue) 0 10px,
    var(--ll-rule-red) 10px 20px,
    var(--ll-rule-green) 20px 30px);
  opacity: 0.9;
}
[data-theme="dark"] .buy-card { background: var(--ll-slate); border-color: var(--ll-pencil-mark); }

/* -------------------------------------------------------- feature previews -- */
/* Free users see feature cards but they are visually locked / non-interactive. */
.welcome-preview { margin: var(--sp-8) 0 var(--sp-6); }
.preview-head { font-family: var(--font-display); font-size: clamp(1.6rem, 5vw, 2.4rem); margin: 0 0 var(--sp-5); color: var(--ll-ink); letter-spacing: -0.02em; text-align: center; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-5); }
.preview-card {
  position: relative;
  border-radius: var(--r);
  padding: var(--sp-5) var(--sp-4);
  background: var(--ll-paper);
  border: 1.6px solid var(--ll-pencil-mark);
  box-shadow: 3px 3px 0 var(--ink);
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.preview-card.locked { opacity: 0.62; filter: grayscale(0.35); pointer-events: none; }
.preview-card:not(.locked):hover { transform: translate(-3px, -3px); box-shadow: 5px 5px 0 var(--ink); border-color: var(--accent); }
.preview-ico { font-size: 2.2rem; display: block; margin-bottom: var(--sp-3); }
.preview-card h3 { margin: 0 0 var(--sp-3); font-family: var(--font-heading); font-size: var(--fs-lg); color: var(--ll-ink); }
.preview-text { margin: 0 0 var(--sp-4); color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }
.preview-lock {
  position: absolute;
  top: var(--sp-3); right: var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 15%, transparent);
  border: 1px solid var(--bad);
  border-radius: var(--r);
  padding: 2px 8px;
}
.preview-lock.ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 15%, transparent);
  border-color: var(--ok);
}
.preview-note { margin: var(--sp-4) 0 0; text-align: center; color: var(--muted); font-size: var(--fs-xs); font-style: italic; }

/* Paid landing: the same page without any buy prompt. */
.landing-paid-note {
  margin: var(--sp-3) 0 0;
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--ok);
}

[data-theme="dark"] .preview-card { background: var(--ll-slate); border-color: var(--ll-pencil-mark); }




/* ------------------------------------------------------------ locked view -- */
/* Looseleaf lock over the main content area only. It lives inside #main
   (position: relative), so it covers the tab content but not the sidebar
   navbar, the topbar header, or the footer. Paper desk, ink borders, marker
   accents — same grammar as the rest of the app. */
.locked-view {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.locked-backdrop {
  position: absolute;
  inset: 0;
  /* Frosted "matt glass" over the whole locked tab: enough blur to erase the
     underlying study content, with a faint paper tint so it still belongs to
     the looseleaf theme in both light and dark mode. */
  background: rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(40px) saturate(1.2);
  backdrop-filter: blur(40px) saturate(1.2);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.locked-glass {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  text-align: center;
  color: var(--ll-ink);
  max-width: 420px;
  width: 90%;
  padding: var(--sp-12) var(--sp-10) var(--sp-10);
  border-radius: 20px;
  background: color-mix(in srgb, var(--ll-card) 78%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
  border: 1.4px solid var(--ll-pencil-mark);
  box-shadow: 0 18px 40px -24px rgb(58 44 30 / 0.55);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  /* Without glass support the tint must be opaque enough to hide content. */
  .locked-backdrop { background: color-mix(in srgb, var(--ll-paper) 92%, transparent); }
  [data-theme="dark"] .locked-backdrop { background: color-mix(in srgb, var(--ll-paper) 94%, transparent); }
  .locked-glass { background: var(--ll-card); }
}
.lock-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--sp-7);
  display: block;
  color: var(--ll-pencil-mark);
}
.lock-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.locked-title { margin: 0 0 var(--sp-3); font-family: var(--font-display); font-size: clamp(1.75rem, 6vw, 2.25rem); line-height: 1.1; letter-spacing: -0.02em; }
.locked-route { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ll-pencil-text); }
.locked-note { margin: 0 0 var(--sp-10); color: var(--ll-ink-muted); font-size: var(--fs-sm); line-height: 1.7; }
.locked-btn {
  padding: var(--sp-6) var(--sp-10);
  font-family: var(--font);
  font-weight: 700;
  font-size: var(--fs-base);
  letter-spacing: 0;
  background: var(--ll-slip);
  color: var(--ll-ink);
  border: 1.4px solid var(--ll-pencil-mark);
  border-radius: var(--r-sm);
  box-shadow: 0 1px 0 var(--ll-pencil-mark), 0 2px 0 rgb(58 44 30 / 0.08);
  cursor: pointer;
  width: 100%;
}
.locked-btn:hover {
  background: color-mix(in srgb, var(--ll-hi) 32%, var(--ll-slip));
  transform: translateY(-1px);
  box-shadow: 0 1px 0 var(--ll-pencil-mark), 0 4px 8px -4px rgb(58 44 30 / 0.4);
}
.locked-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ll-pencil-mark);
}
.locked-hint { margin: var(--sp-7) 0 0; color: var(--ll-ink-muted); font-size: var(--fs-xs); }

[data-theme="dark"] .locked-backdrop {
  background: rgba(18, 20, 18, 0.38);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .locked-glass {
  background: color-mix(in srgb, var(--ll-card) 78%, transparent);
  border-color: var(--ll-pencil-mark);
  color: var(--ll-ink);
}
[data-theme="dark"] .locked-note { color: var(--ll-ink-muted); }
[data-theme="dark"] .locked-hint { color: var(--ll-ink-muted); }
[data-theme="dark"] .locked-btn {
  background: var(--ll-slip);
  color: var(--ll-ink);
}


.landing-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding-top: var(--sp-5); border-top: var(--border-w-thin) solid var(--ink); color: var(--muted); }
.landing-foot-brand { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg); text-transform: uppercase; letter-spacing: -0.02em; color: var(--text); }
.landing-foot .row { margin-left: auto; }

/* Landing atmosphere: flat pastel shapes (no blur, no gradients) drifting very
   slowly behind the hero. They are purely decorative and never interactive. */
.landing { position: relative; isolation: isolate; }
.landing-orb {
  position: absolute; z-index: -1; pointer-events: none;
  border: var(--border-w) solid var(--ink); border-radius: 50%; opacity: 0.55;
}
.landing-orb.o1 { width: 260px; height: 260px; background: var(--pastel-1); top: -60px; right: 1%; animation: landing-drift 16s ease-in-out infinite; }
.landing-orb.o2 { width: 170px; height: 170px; background: var(--pastel-2); top: 310px; left: -54px; animation: landing-drift 21s ease-in-out infinite reverse; }
.landing-orb.o3 { width: 120px; height: 120px; background: var(--pastel-3); top: 120px; left: 47%; opacity: 0.35; animation: landing-drift 18s ease-in-out infinite 2s; }
@keyframes landing-drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(6px, -14px) rotate(8deg); }
}

.landing-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; background: var(--surface);
  border: var(--border-w-thin) solid var(--ink); box-shadow: var(--shadow-sm);
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
}
.landing-badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); border: 1px solid var(--ink);
  box-shadow: 0 0 0 3px rgba(232, 163, 61, 0.25);
  animation: landing-pulse 2.6s ease-in-out infinite;
}
@keyframes landing-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.landing-visual { isolation: isolate; }
.landing-visual-glow {
  position: absolute; inset: 16px -14px -14px 16px; z-index: -1;
  background: var(--accent-2); border: var(--border-w) solid var(--ink);
  transform: rotate(1.4deg);
}
.landing-pill {
  position: absolute; left: -18px; bottom: 24px;
  padding: 6px 10px; background: var(--surface);
  border: var(--border-w) solid var(--ink); box-shadow: var(--shadow-sm);
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700;
  transform: rotate(-3deg);
}

.landing-marquee {
  overflow: hidden; padding: 10px 0;
  border-top: var(--border-w-thin) solid var(--ink);
  border-bottom: var(--border-w-thin) solid var(--ink);
  background: var(--surface);
}
.landing-marquee-track { display: flex; gap: var(--sp-5); width: max-content; animation: landing-marquee 42s linear infinite; }
.landing-marquee-item {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.landing-marquee-item .dot { width: 8px; height: 8px; }
@keyframes landing-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.landing-feature { animation: landing-rise 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes landing-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.landing-step-n { color: var(--on-accent); }
.lp-check.on { color: var(--on-accent); }

.landing-subject-panel {
  background: var(--surface); border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow); padding: clamp(18px, 3vw, 28px);
}
.landing-subject-panel h3 { font-family: var(--font-heading); }
.landing-subject-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-2); margin-top: var(--sp-4);
}
.landing-subject {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; background: var(--surface-2); color: var(--text);
  border: var(--border-w-thin) solid var(--ink);
  font-size: var(--fs-sm); font-weight: 600;
}
.landing-subject .xs { margin-left: auto; }
.landing-subjects-section .landing-section-head { max-width: 70ch; }

@media (prefers-reduced-motion: reduce) {
  .landing-orb, .landing-badge-dot, .landing-marquee-track, .landing-feature { animation: none; }
}
[data-reduce-motion="true"] .landing-orb,
[data-reduce-motion="true"] .landing-badge-dot,
[data-reduce-motion="true"] .landing-marquee-track,
[data-reduce-motion="true"] .landing-feature { animation: none; }

/* --------------------------------------------------------------------- auth */
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: var(--sp-5); max-width: 1000px; margin: clamp(28px, 6vw, 64px) auto; align-items: start; }
.auth-card { padding: clamp(22px, 4vw, 34px); }
.auth-head { display: flex; gap: var(--sp-4); align-items: flex-start; }
.auth-ico { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; background: var(--accent); border: var(--border-w) solid var(--ink); box-shadow: var(--shadow-sm); font-size: 22px; font-weight: 700; }
.auth-card h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 3.6vw, 2.3rem); letter-spacing: -0.035em; line-height: 1.06; margin: 8px 0 8px; }
.auth-card > .muted { margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-5); }
.auth-actions { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }
.auth-swap { margin: var(--sp-4) 0 0; }
.auth-back { margin: var(--sp-4) 0 0; }
.auth-side { position: sticky; top: 96px; }
.auth-side-card { background: var(--surface-2); border: var(--border-w) solid var(--ink); box-shadow: var(--shadow); padding: clamp(20px, 3vw, 28px); }
.auth-side-card h2 { font-family: var(--font-display); font-size: var(--fs-xl); letter-spacing: -0.03em; margin: 8px 0 var(--sp-4); }
.auth-benefits { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; font-size: var(--fs-sm); }
.auth-benefits li { display: flex; gap: 8px; align-items: flex-start; }
.auth-benefits li span { color: var(--muted); }
.auth-quote { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: var(--border-w-thin) dashed var(--ink); }
.auth-quote p { margin: 6px 0 0; font-family: var(--font-heading); font-size: var(--fs-lg); line-height: 1.45; }

.btn.wide { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
.link-btn:hover { background: var(--accent); color: var(--on-accent); text-decoration: none; }
.ok-text { color: var(--ok-ink); }
.bad-text { color: var(--bad-ink); }

/* -------------------------------------------------------------------- setup */
.setup-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-5); max-width: 1060px; margin: clamp(24px, 5vw, 56px) auto; align-items: start; }
.setup-wrap.setup-wide { max-width: 1220px; }
.setup-card { padding: clamp(22px, 4vw, 34px); }
.setup-head h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 3.4vw, 2.25rem); letter-spacing: -0.035em; line-height: 1.06; margin: 8px 0; }
.setup-head p { margin: 0; max-width: 62ch; }
.setup-account { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-3) 0; margin-top: var(--sp-4); border-top: var(--border-w-thin) dashed var(--line); border-bottom: var(--border-w-thin) dashed var(--line); }
.setup-account .link-btn { margin-left: auto; }
.setup-form { margin-top: var(--sp-4); }
.setup-avatars { border: 0; padding: 0; margin: 0 0 var(--sp-4); }
.setup-avatars legend, .field legend { font-size: var(--fs-sm); font-weight: 700; margin-bottom: 6px; }
.setup-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.subject-pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-3); }
.subject-pick {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  background: var(--surface); border: var(--border-w) solid var(--ink);
  padding: 11px 12px; cursor: pointer;
  transition: transform var(--speed), box-shadow var(--speed), background var(--speed);
}
label.subject-pick:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-sm); }
.subject-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.subject-pick:has(input:checked) { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.subject-pick:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.subject-pick:has(input:checked) .muted,
.subject-pick:has(input:checked) .faint { color: rgba(26, 26, 26, 0.72); }
.subject-pick.core { background: var(--surface-2); cursor: default; }
.subject-pick:has(input:disabled:not(:checked)) { opacity: 0.5; cursor: not-allowed; }
.subject-pick-mark .tile-mark { width: 36px; height: 36px; font-size: 12px; }
.subject-pick-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.subject-pick-body b { font-family: var(--font-heading); font-size: var(--fs); }
.subject-pick-body .small { line-height: 1.25; }
.subject-pick-check { margin-left: auto; width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; border: var(--border-w-thin) solid var(--ink); background: var(--surface); color: var(--text); font-size: 12px; font-weight: 700; visibility: hidden; }
.subject-pick:has(input:checked) .subject-pick-check { visibility: visible; background: var(--ok); color: var(--on-accent); }
.subject-pick.core .chip { margin-left: auto; }
.setup-side { display: flex; flex-direction: column; gap: var(--sp-3); position: sticky; top: 96px; }
.setup-progress, .setup-note { background: var(--surface-2); border: var(--border-w) solid var(--ink); box-shadow: var(--shadow-sm); padding: var(--sp-4); }
.setup-progress-head { display: flex; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.setup-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.setup-steps li { display: flex; gap: var(--sp-3); align-items: flex-start; opacity: 0.55; }
.setup-steps li.on { opacity: 1; }
.setup-step-dot { width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; border: var(--border-w-thin) solid var(--ink); background: var(--surface); font-weight: 700; font-size: var(--fs-sm); }
.setup-steps li.on .setup-step-dot { background: var(--accent); color: var(--on-accent); }
.setup-steps li.done .setup-step-dot { background: var(--ok); color: var(--on-accent); }
.setup-steps b { display: block; font-family: var(--font-heading); font-size: var(--fs-sm); }
.setup-note b { display: block; margin: 6px 0 4px; font-size: var(--fs-sm); line-height: 1.45; }
.setup-subject-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-2); flex-wrap: wrap;
}
.setup-subject-head h2 { margin: 0; font-family: var(--font-heading); font-size: var(--fs-lg); }
.setup-subject-head p { margin: 3px 0 0; }

/* Destructive settings block: clearly separated, still on-brand. */
.settings-danger {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-4); background: var(--bad-light);
  border: var(--border-w-thin) dashed var(--bad);
}
.settings-danger-copy { max-width: 58ch; }
.settings-danger-copy b { font-family: var(--font-heading); font-size: var(--fs-lg); }
.settings-danger-copy p { margin: 4px 0 0; }
.settings-danger .muted { color: var(--text); opacity: 0.78; }

/* ------------------------------------------------------- dashboard extras -- */
.dash-subjects { padding: 12px var(--sp-4); }
.dash-subjects .chip .dot { margin-right: 2px; }
.dash-note-list { display: grid; gap: 6px; }
.dash-note { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 10px; border: var(--border-w-thin) solid var(--ink); background: var(--surface); color: var(--text); }
.dash-note:hover { background: var(--surface-2); text-decoration: none; }
.dash-note .dot { flex: 0 0 auto; }
.account-avatar { width: 62px; height: 62px; flex: 0 0 auto; display: grid; place-items: center; background: var(--accent); border: var(--border-w) solid var(--ink); box-shadow: var(--shadow-sm); font-size: 30px; }

/* ------------------------------------------------------------- responsive -- */
/* 13-inch laptop (1366×768): keep two columns but compress vertical spacing
   so the page fits a short screen without excessive scrolling. */
@media (max-width: 1366px) {
  .landing { gap: clamp(24px, 4vw, 52px); padding-top: clamp(20px, 4vw, 44px); }
  .landing-hero { gap: clamp(24px, 4vw, 52px); align-items: start; }
  .landing-copy { max-width: 44ch; }
  .landing-title { font-size: clamp(1.9rem, 4.5vw, 3.1rem); line-height: 1.05; margin: 10px 0 14px; }
  .landing-lead { font-size: var(--fs-sm); line-height: 1.55; max-width: 44ch; margin: 0; }
  .landing-actions { margin-top: var(--sp-4); gap: var(--sp-2); }
  .landing-points { margin: var(--sp-3) 0 0; gap: 5px; font-size: var(--fs-xs); }
  .landing-stat { padding: var(--sp-4); }
  .landing-stat b { font-size: clamp(20px, 3.5vw, 28px); line-height: 1; }
  .landing-stat span { margin-top: 3px; }
  .landing-section-head { max-width: 52ch; margin-bottom: var(--sp-4); }
  .landing-section-head h2 { font-size: clamp(1.35rem, 2.8vw, 1.95rem); line-height: 1.08; margin: 6px 0 8px; }
  .landing-features { gap: var(--sp-4); }
  .landing-feature { padding: var(--sp-3); }
  .landing-feature-ico { width: 36px; height: 36px; margin-bottom: var(--sp-2); font-size: 17px; }
  .landing-feature h3 { margin: 0 0 5px; font-size: var(--fs-sm); }
  .landing-feature p { font-size: var(--fs-xs); line-height: 1.5; }
  .landing-steps { gap: var(--sp-3); }
  .landing-step { padding-top: var(--sp-3); }
  .landing-step-n { font-size: var(--fs-sm); padding: 3px 8px; }
  .landing-step h3 { margin: var(--sp-2) 0 5px; font-size: var(--fs-sm); }
  .landing-step p { font-size: var(--fs-xs); line-height: 1.5; }
  .landing-preview { padding: var(--sp-3); transform: rotate(-0.6deg); }
  .lp-head { gap: var(--sp-3); margin-top: var(--sp-3); }
  .lp-ring { width: 72px; height: 72px; }
  .lp-ring span { width: 50px; height: 50px; font-size: 17px; }
  .lp-ring i { font-size: 10px; }
  .lp-big { font-size: var(--fs-sm); margin: 2px 0; }
  .lp-list { margin: var(--sp-3) 0 0; gap: 5px; }
  .lp-row { padding: 6px 8px; font-size: var(--fs-xs); gap: var(--sp-1); }
  .lp-foot { margin-top: var(--sp-3); font-size: var(--fs-xs); gap: var(--sp-2); }
  .landing-subject-group { padding: var(--sp-3); }
  .landing-subject-list { gap: var(--sp-1); margin-top: var(--sp-2); }
  .landing-subject { padding: 6px 9px; font-size: var(--fs-xs); gap: 6px; }
  .landing-subject .xs { font-size: var(--fs-xs); }
  .landing-cta { padding: clamp(18px, 3vw, 28px); gap: var(--sp-4); }
  .landing-cta h2 { font-size: clamp(1.3rem, 2.6vw, 1.8rem); margin: 6px 0 5px; letter-spacing: -0.03em; }
  .landing-cta .muted, .landing-cta .eyebrow { font-size: var(--fs-xs); }
  .landing-foot { padding-top: var(--sp-4); font-size: var(--fs-xs); gap: var(--sp-2); }
}
@media (max-width: 980px) {
  .landing-hero { grid-template-columns: 1fr; gap: var(--sp-6); }
  .landing-visual { max-width: 560px; }
  .landing-sticker { right: 6px; }
  .landing-features { grid-template-columns: 1fr; }
  .landing-steps { grid-template-columns: 1fr; gap: var(--sp-5); }
  .auth-wrap, .setup-wrap { grid-template-columns: 1fr; max-width: 620px; }
  .auth-side, .setup-side { position: static; order: 2; }
  .setup-wrap.setup-wide { max-width: 780px; }
}
@media (max-width: 720px) {
  .public-identity { display: none; }
  .public-top { padding: 10px 14px; }
  .public-brand-text .brand-sub { display: none; }
  .public-brand-text b { font-size: 19px; }
  .landing-stats { grid-template-columns: 1fr 1fr; }
  .landing-stat:nth-child(2) { border-right: 0; }
  .landing-stat:nth-child(1), .landing-stat:nth-child(2) { border-bottom: var(--border-w-thin) solid var(--ink); }
  .landing-title { font-size: clamp(2rem, 9vw, 2.8rem); }
  .landing-preview { transform: none; }
  .landing-sticker { display: none; }
  .subject-pick-grid { grid-template-columns: 1fr; }
  .landing-cta { flex-direction: column; align-items: flex-start; }
  .auth-head { flex-direction: column; }
  .auth-card h1 { font-size: 1.7rem; }
  .public-main { padding-left: 14px; padding-right: 14px; }
}

/* Signed-in confirmation inside the one-time tour. */
.onb-account-card {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--surface); border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-sm); padding: var(--sp-4); margin-bottom: var(--sp-4);
}
.onb-account-avatar {
  width: 54px; height: 54px; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--accent); border: var(--border-w) solid var(--ink); font-size: 26px;
}
.onb-account-card b { display: block; font-family: var(--font-heading); font-size: var(--fs-lg); }
.onb-account-card .small { display: block; margin-top: 2px; }

/* ==========================================================================
   FLASHCARD FLIP ANIMATION & QUIZ INTERFACE
   ========================================================================== */

/* Flashcard Flip Animation */
.flashcard {
  perspective: 1000px;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4/3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}.correct-answer {
  padding: var(--sp-3);
  background: var(--surface);
  border: var(--border-w-thin) solid var(--ink);
  margin-top: var(--sp-3);
}

.correct-answer strong {
  color: var(--ok-ink);
}

.explanation {
  padding: var(--sp-3);
  background: var(--info-light);
  border: var(--border-w-thin) solid var(--info);
  margin-top: var(--sp-3);
  color: var(--info-text);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}.stat {
  flex: 1;
  min-width: 80px;
  padding: var(--sp-3);
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  text-align: center;
}

.review-detail {
  padding: var(--sp-4);
  display: none;
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}.correct-answer {
  padding: var(--sp-3);
  border: var(--border-w) solid var(--ink);
  border-radius: 0;
}

.correct-answer {
  background: var(--ok-light);
  border-color: var(--ok);
}

.correct-answer strong {
  color: var(--ok-ink);
}

.explanation {
  padding: var(--sp-3);
  background: var(--info-light);
  border: var(--border-w-thin) solid var(--info);
  color: var(--info-text);
  font-size: var(--fs-sm);
  line-height: 1.5;
}@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  padding: var(--sp-3);
  background: var(--surface-2);
  border: var(--border-w) solid var(--ink);
}

.filters .input,
.filters .select {
  min-width: 180px;
}

/* Responsive */
@media (max-width: 720px) {
  .flashcard {
    aspect-ratio: 3/4;
    max-width: 100%;
  }
  
  .flashcard-inner {
    padding: var(--sp-3);
  }
  
  .topic-title {
    font-size: var(--fs);
  }
  
  .quiz-question {
    padding: var(--sp-4);
  }
  
  .question-text {
    font-size: var(--fs);
  }
  
  .score-circle {
    width: 120px;
    height: 120px;
  }
  
  .score-value {
    font-size: clamp(28px, 10vw, 44px);
  }
  
  .score-circle {
    width: 100px;
    height: 100px;
  }
}.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.card-front { z-index: 2; }
.card-back { transform: rotateY(180deg); z-index: 1; }

.card-meta {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.card-source {
  border-top: var(--border-w-thin) solid var(--line);
  padding-top: var(--sp-2);
  font-style: italic;
}/* -------------------------------------------------------------- analytics -- */

/* .metrics grid is defined earlier in the stylesheet (compact stat cards) */

.chart-wrap { margin: var(--sp-4) 0; }

/* --------------------------------------------------------------- lists ---- */
.list-item { display: flex; gap: var(--sp-3); align-items: flex-start; }/* ----------------------------------------------------------------- scrollbars ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

.sidebar::-webkit-scrollbar-thumb { background: var(--faint); }
.main::-webkit-scrollbar-thumb { background: var(--line); }

/* Soft neo-brutalist bento grid + playful gamified flat UI */

/* Pin the app shell to the viewport. #app is a flex column holding the shell
   plus the footer, so the shell owns the remaining height and #main is the one
   and only scroll container. Without a definite height here the legacy
   `.sidebar { min-height: 100vh }` rule made the document grow instead, which
   left trailing blank space and clipped the bottom of long views. */
#app.is-app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.app-shell > .sidebar {
  width: var(--sidebar-w);
  border-right: var(--border-dash);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  z-index: 30;
  overflow-x: hidden;
  padding: var(--sp-4);
  flex-shrink: 0;
  min-height: 0;
}

/* Reset the legacy sticky/100vh sidebar rules inside the flex shell. On narrow
   screens the responsive block below turns it back into a fixed drawer. */
@media (min-width: 1081px) {
  .app-shell > .sidebar {
    position: relative;
    top: auto;
    align-self: stretch;
    min-height: 0;
  }
}

.app-shell > .workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#main.view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  display: block;
  width: 100%;
  position: relative;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.app-shell > .utility {
  width: var(--utility-w);
  border-left: var(--border-dash);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  z-index: 20;
  overflow-y: auto;
  padding: var(--sp-4);
  flex-shrink: 0;
}

/* Topbar — dashed bottom border */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: var(--border-dash);
  background: var(--surface);
  z-index: 40;
}

.topbar .grow {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-strong);
  font-size: var(--fs-lg);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}/* Bento cards — soft neo-brutalist */
.card {
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: var(--sp-5);
  transition: transform var(--speed), box-shadow var(--speed);
}

.card.tight { padding: var(--sp-4); }
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: var(--sp-4); }

.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hover);
}

/* KPI cards — pastel background cycle */
.card.kpi {
  background: var(--surface-2);
  border-color: var(--ink);
} /* butter yellow */
.card.kpi:nth-child(4n+2) { background: var(--pastel-2); color: var(--on-accent); } /* pastel sky blue */
.card.kpi:nth-child(4n+3) { background: var(--pastel-3); color: var(--on-accent); } /* soft coral pink */
.card.kpi:nth-child(4n+4) { background: var(--pastel-4); color: var(--on-accent); } /* warm peach */
.card.kpi:nth-child(4n+1) .muted,
.card.kpi:nth-child(4n+2) .muted,
.card.kpi:nth-child(4n+3) .muted,
.card.kpi:nth-child(4n+4) .muted { color: rgba(0, 0, 0, 0.72); }

/* Pill shapes — 9999px border radius with solid charcoal outline */
.btn.pill, .input.pill, .chip.pill, .badge.pill, .nav a.pill {
  border-radius: var(--r-pill) !important;
  border: var(--border-w) solid var(--ink);
}

.btn.pill { background: var(--surface); }
.btn.pill:hover { background: var(--surface-2); }

/* Primary CTA — warm ochre-marigold + white text */
.btn.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--ink);
}

.btn.primary:hover {
  /* Dark ink on the ochre fill needs a bright hover; the old #B45309 was 3.5:1. */
  background: #E08A2E;
  box-shadow: var(--shadow-hover);
}/* Sidebar brand header — PADHLE.WTF logo style */
.brand-header {
  text-align: center;
  padding: var(--sp-4) 0 var(--sp-3);
}
.sidebar-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 4vw, 2rem);
  text-transform: uppercase;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}
.brand-dot {
  color: var(--accent);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  margin-top: 2px;
}
.brand-wtf {
  color: var(--accent);
}
.brand-tagline {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-top: var(--sp-2);
}

/* Active nav route — warm cream pill fill */
.nav a.active {
  background: var(--primary);
  color: var(--primary-text);
  border-radius: var(--r-pill);
  border: var(--border-w) solid var(--ink);
}

/* Pill nav items */
.nav a {
  border-radius: var(--r-pill);
  border: var(--border-w) solid transparent;
  padding: var(--sp-2) var(--sp-3);
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}/* App footer */
.app-footer {
  flex: 0 0 auto;
  padding: var(--sp-4) var(--sp-6);
  border-top: var(--border-dash);
  background: var(--surface);
  text-align: center;
}/* Progress bars / donut charts — 1.5px solid charcoal borders */
.bar {
  border: 1.5px solid var(--ink);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  height: 8px;
  overflow: hidden;
}

.bar span {
  background: var(--accent);
  height: 100%;
  border-radius: var(--r-pill);
}

/* Donut chart */
.donut {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: conic-gradient(var(--accent) var(--pct), var(--surface-2) 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut::after {
  content: var(--pct-text, "0%");
  font-weight: 700;
  color: var(--ink);
  font-family: var(--font-heading);
}/* Heading typography — bold charcoal, Plus Jakarta Sans */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs); }

/* Subtitles — medium slate gray */
.subtitle, .xs.muted, .text-muted {
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--fs-sm);
}

/* Search input — pill shape */
.input.pill {
  border-radius: var(--r-pill);
  padding: var(--sp-2) var(--sp-4);
}

/* Sidebar navigation — pill items */
.nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-pill);
  border: var(--border-w) solid transparent;
  /* Every nav item sits on a bright pastel fill in both themes, so the label
     must always be the dark ink — never the theme's white text. */
  color: var(--on-accent);
  font-weight: 500;
  font-size: var(--fs-sm);
  transition: background var(--speed), color var(--speed);
}

.nav a.active {
  background: var(--primary) !important;
  color: var(--primary-text) !important;
  border-color: var(--ink);
}

.nav a:hover:not(.active) {
  background: var(--surface-2);
  color: var(--ink);
}

/* Sidebar footer */
.sidebar-foot {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: var(--border-dash);
}

/* Remove old neubrutalism hover lift on cards — use soft shadow instead */
.card:hover {
  box-shadow: var(--shadow-hover);
  transform: none;
}
/* Responsive */
@media (max-width: 720px) {
  .revision-card { max-width: 100%; min-height: 280px; }
  .card-body { font-size: var(--fs); }
  .metrics { grid-template-columns: 1fr; }
  .chart-bars { height: 120px; overflow-x: auto; }
  .chart-bar { flex: none; width: 56px; }
  .filter-group { flex-direction: column; }
}

/* ==========================================================================
   Revision Centre — playful flashcards & gamified practice questions
   ========================================================================== */

/* ---- shared game surfaces ---- */
.card-table, .game-table { background: var(--bg); }

/* Study card — 3D flip like a study flashcard, playful proportions. */
.card-deck {
  display: flex;
  justify-content: center;
  margin: var(--sp-5) 0;
  perspective: 1200px;
}
.study-card {
  position: relative;
  width: min(460px, 94vw);
  aspect-ratio: 4 / 3;
  transform-style: preserve-3d;
  perspective: 1200px;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), box-shadow var(--speed);
  cursor: pointer;
  touch-action: manipulation;
  will-change: transform;
}
.study-card.flipped { transform: rotateY(180deg); }
.study-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.study-card:hover { box-shadow: var(--shadow-hover); transform: translate(-2px, -2px); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--r);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding: var(--sp-6);
  box-sizing: border-box;
  overflow: hidden;
}
.card-front {
  z-index: 2;
  background: var(--card-front);
  color: var(--text);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.card-back {
  z-index: 1;
  transform: rotateY(180deg);
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--accent);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* Some engines ignore backface-visibility inside a 3D card, which used to
   show a mirrored question through the answer "See answer". Hiding the
   inactive face explicitly makes the flip correct everywhere. */
.card-back { visibility: hidden; }
.study-card.flipped .card-front { visibility: hidden; }
.study-card.flipped .card-back { visibility: visible; }
.card-back::after {
  content: "💡";
  position: absolute;
  inset: 10px;
  border: 2px dashed rgba(0,0,0,0.15);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 48px; line-height: 1;
  pointer-events: none;
  opacity: 0.3;
}
[data-theme="dark"] .card-back::after { border-color: rgba(255,255,255,0.15); }
[data-theme="dark"] .card-back { background: var(--surface-3); border-color: var(--accent-2); }

.card-meta { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.card-prompt, .card-answer {
  flex: 1 1 auto;
  min-height: 0;
  font-size: var(--fs-lg);
  line-height: 1.7;
  color: inherit;
  white-space: pre-wrap;
  overflow-y: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
}
.card-prompt { display: flex; align-items: safe center; justify-content: center; text-align: center; }
.card-answer {
  display: flex;
  align-items: safe center;
  justify-content: center;
  text-align: center;
  padding-top: var(--sp-2);
}
.card-answer strong { color: var(--ink); }
.card-hint {
  margin-top: auto;
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs); color: inherit; opacity: 0.8;
}
.card-hint-bar {
  margin-top: var(--sp-2);
  font-size: var(--fs-xs); color: var(--muted);
  text-align: center;
}

/* Answer label on the back of flashcards — clear, non-confusing. */
.answer-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: var(--sp-1);
}

/* Verdict buttons for practice questions (I knew it / I did not know / Skip). */
.verdict-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.verdict-row .btn { flex: 1; min-width: 120px; }
.verdict-hint { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--muted); text-align: center; }

/* Study progress bar. */
.card-progress { margin: var(--sp-3) 0; }
.card-progress .row { font-size: var(--fs-sm); }
.card-bar {
  height: 10px;
  background: var(--surface-2);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: var(--sp-1);
}
.card-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-right: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-pill);
  transition: width 0.4s ease;
}

/* Study action cards. */
.card-actions, .game-actions {
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow);
  border-radius: var(--r);
  padding: var(--sp-4);
}
.card-verdict { display: flex; gap: var(--sp-2); }
.card-verdict .btn { flex: 1; }

/* ---- Practice Questions — "magic reveal" card -------------------------
   Deliberately distinct from the flashcard 3D flip. The panel glows, the
   answer blooms into place (blur → clear) and long answers wrap/scroll
   instead of spilling out of a fixed-ratio card. */
.pq-deck {
  display: flex;
  justify-content: center;
  margin: var(--sp-5) 0;
}

.pq-card {
  position: relative;
  isolation: isolate;
  width: min(720px, 96vw);
  max-height: 72vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-6);
  box-sizing: border-box;
  border-radius: var(--r);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-lg);
  background:
    radial-gradient(140% 120% at 0% 0%, rgba(217, 119, 36, 0.10), transparent 52%),
    radial-gradient(140% 120% at 100% 0%, rgba(216, 238, 254, 0.55), transparent 55%),
    var(--card-front);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.4s ease, transform 0.3s ease, border-color 0.4s ease;
  scrollbar-width: thin;
}
[data-theme="dark"] .pq-card {
  background:
    radial-gradient(140% 120% at 0% 0%, rgba(217, 119, 36, 0.22), transparent 55%),
    radial-gradient(140% 120% at 100% 0%, rgba(96, 165, 250, 0.18), transparent 55%),
    var(--card-front);
}
.pq-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.pq-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.pq-card.is-revealed {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg), 0 0 0 3px rgba(217, 119, 36, 0.18), 0 0 34px rgba(217, 119, 36, 0.16);
}

/* Magical aura that bursts once the answer appears. */
.pq-spark {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 30%, rgba(217, 119, 36, 0.35), transparent 55%),
    radial-gradient(circle at 72% 72%, rgba(216, 238, 254, 0.55), transparent 50%);
  transition: opacity 0.6s ease;
}
.pq-card.is-revealed .pq-spark { opacity: 1; animation: pq-burst 0.9s ease both; }
.pq-card > *:not(.pq-spark) { position: relative; z-index: 1; }

@keyframes pq-burst {
  0%   { transform: scale(0.82); opacity: 0; }
  45%  { opacity: 0.95; }
  100% { transform: scale(1); opacity: 0.55; }
}

/* Prompt + answer wrap aggressively so nothing escapes the panel. */
.pq-prompt,
.pq-answer-body,
.pq-explanation {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.pq-prompt {
  font-size: var(--fs-lg);
  line-height: 1.7;
}
/* Wide display equations scroll inside the panel instead of clipping out. */
.pq-prompt .katex-display,
.pq-answer-body .katex-display,
.pq-explanation .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding-bottom: 2px;
}
.pq-prompt .katex,
.pq-answer-body .katex,
.pq-explanation .katex { max-width: 100%; }

/* Reveal affordance pill with a travelling shimmer. */
.pq-reveal-hint { display: flex; justify-content: center; margin-top: var(--sp-4); }
.pq-reveal-pill {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5em 1em;
  border-radius: var(--r-pill);
  border: var(--border-w-thin) solid var(--ink);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pq-reveal-pill::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -45%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  transform: skewX(-18deg);
  animation: pq-shimmer 2.8s ease-in-out infinite;
}
.pq-card.is-revealed .pq-reveal-pill {
  background: var(--ok-light);
  border-color: var(--accent);
}
.pq-card.is-revealed .pq-reveal-pill::after { animation: none; opacity: 0; }

@keyframes pq-shimmer {
  0%   { left: -45%; }
  60%  { left: 110%; }
  100% { left: 110%; }
}

/* The answer blooms open: grid 0fr → 1fr gives a smooth auto-height reveal.
   This app re-renders by replacing innerHTML, so the reveal runs as a keyframe
   animation (which plays on element creation) rather than a class transition. */
.pq-answer {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  filter: blur(8px);
  transform: translateY(-6px);
}
.pq-card.is-revealed .pq-answer {
  grid-template-rows: 1fr;
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
  margin-top: var(--sp-4);
  animation: pq-bloom 0.55s cubic-bezier(0.22, 0.8, 0.24, 1) both;
}
@keyframes pq-bloom {
  from {
    grid-template-rows: 0fr;
    opacity: 0;
    filter: blur(8px);
    transform: translateY(-6px);
    margin-top: 0;
  }
  to {
    grid-template-rows: 1fr;
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
    margin-top: var(--sp-4);
  }
}
.pq-answer-clip { overflow: hidden; min-height: 0; }
.pq-answer-body {
  display: block;
  font-size: var(--fs-lg);
  line-height: 1.7;
  padding-top: var(--sp-1);
}
.pq-explanation {
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--accent);
  background: rgba(217, 119, 36, 0.08);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
[data-theme="dark"] .pq-explanation { background: rgba(217, 119, 36, 0.16); }

@media (max-width: 560px) {
  .pq-card { width: 96vw; padding: var(--sp-4); max-height: 78vh; }
  .pq-prompt, .pq-answer-body { font-size: var(--fs); }
}

@media (prefers-reduced-motion: reduce) {
  .pq-card,
  .pq-spark,
  .pq-answer,
  .pq-reveal-pill::after {
    transition: none;
    animation: none;
  }
  .pq-answer { filter: none; transform: none; }
}.explain-box {
  background: var(--info-light);
  border: var(--border-w-thin) solid var(--info);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  margin-top: var(--sp-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text);
}.stat { display: flex; flex-direction: column; gap: 2px; }
.streak-emoji { margin-right: 4px; }
.pill { padding: var(--sp-2) var(--sp-4); background: var(--surface-2); border: var(--border-w-thin) solid var(--ink); border-radius: var(--r-pill); }

.pq-progress { margin: var(--sp-3) 0; }
.pq-progress .row { font-size: var(--fs-sm); }
.pq-bar {
  height: 10px;
  background: var(--surface-2);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: var(--sp-1);
}
.pq-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-right: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-pill);
  transition: width 0.4s ease;
}

/* ---- Common result / gamification UI ---- */

.streak-card, .level-card {
  background: var(--surface-2);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-sm);
  border-radius: var(--r);
  padding: var(--sp-4);
}
.streak-val { font-family: var(--font-mono); font-weight: 800; font-size: var(--fs-xl); color: var(--text-strong); }
.level-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  background: var(--accent); color: var(--on-accent);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-sm);
  font-family: var(--font-heading); font-weight: 800; font-size: var(--fs-lg);
  box-shadow: var(--shadow);
}

.achievement {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface-2);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.achievement-icon { font-size: 26px; flex: 0 0 auto; }
.achievement-title { color: var(--text-strong); }
.achievement-text { color: var(--muted); }

.chapter-row { margin-bottom: 2px; }
.review-detail {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-top: var(--border-w-thin) solid var(--line);
  font-size: var(--fs-sm);
}
.explain-box .xs { margin-bottom: 6px; }

/* Responsive tweaks for the revision centre games. */
@media (max-width: 720px) {
  .study-card { width: min(340px, 92vw); }
  .option-btn { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
  .metrics { grid-template-columns: 1fr; }
  .card-verdict, .mastery-row { flex-direction: column; }
  .card-verdict .btn, .mastery-row .btn { width: 100%; }
}

/* ------------------------------------------------ board exam countdown (gen-z horror) --- */
.board-countdown {
  position: relative;
  overflow: hidden;
  background: var(--bad) !important;
  color: var(--white) !important;
  border: var(--border-w) solid var(--ink) !important;
  box-shadow: 0 0 20px rgba(0,0,0,0.35);
}
.board-countdown * { color: var(--white) !important; }
.board-countdown .eyebrow { color: var(--white) !important; opacity: 0.9; }
.board-countdown .small, .board-countdown .muted { color: var(--white) !important; opacity: 0.85; }
.board-countdown .btn.danger { background: var(--ink) !important; color: var(--white) !important; }
.board-countdown .btn.ghost { background: transparent !important; color: var(--white) !important; border: 1px solid var(--white) !important; }
.board-countdown .btn.ghost:hover { background: var(--white) !important; color: var(--ink) !important; }

.countdown-big {
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(0,0,0,0.5);
}
.countdown-big::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.15) 3px);
  pointer-events: none;
}

.countdown-rumour {
  font-style: italic;
  font-weight: 600;
  animation: rumourWobble 3s ease-in-out infinite;
}

@keyframes rumourWobble {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Glitch flicker when exam is imminent. */
@keyframes countdownGlitch {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}
.board-countdown[data-glitch] .countdown-big {
  animation: countdownGlitch 0.15s infinite;
}

/* ==========================================================================
   Profile, streaks, analytics & share-card refresh
   ========================================================================== */

/* ---- Metrics: 4 × 2 on desktop, 2 columns on tablet, 1–2 on phones ---- */
@media (max-width: 860px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 430px) {
  .metrics { grid-template-columns: 1fr; }
}
.metrics .metric .v { overflow-wrap: anywhere; }

/* ---- Profile hero ---- */
.profile-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: var(--sp-5);
  align-items: center;
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-light) 100%);
}
.profile-hero-main {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}
.profile-avatar {
  width: 84px;
  height: 84px;
  font-size: 2.6rem;
  flex: 0 0 auto;
}
.profile-hero h1 {
  margin: 2px 0 0;
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
}
.profile-hero-side {
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
@media (max-width: 820px) {
  .profile-hero { grid-template-columns: 1fr; }
}

/* ---- Streak spotlight ---- */
.streak-spotlight {
  position: relative;
  overflow: hidden;
  padding-top: calc(var(--sp-5) + 6px);
}
.streak-spotlight::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 8px;
  background: linear-gradient(90deg, var(--warn), var(--accent), var(--ok));
}
.streak-spotlight-head {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: var(--sp-4);
  align-items: start;
}
.streak-big {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.8rem, 7vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: var(--text-strong);
}
.streak-big .streak-unit {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
}
.streak-flame { font-size: 0.8em; }
.streak-spotlight-copy p { max-width: 62ch; margin: var(--sp-2) 0 0; }
.streak-spotlight-side {
  display: grid;
  gap: 0;
  background: var(--accent-light);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r);
  padding: var(--sp-2) var(--sp-4);
}
.streak-side-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: var(--fs-sm);
}
.streak-side-row:last-child { border-bottom: none; }
.streak-side-row b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.streak-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.streak-week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: var(--sp-3) var(--sp-1);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.streak-week-day.on { background: var(--ok-light); }
.streak-week-day.today { box-shadow: 0 0 0 3px var(--accent); }
.swd-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
}
.swd-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 0;
}
.streak-week-day.on .swd-dot {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--ink);
}
.swd-min {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.streak-next {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: var(--border-dash);
}
.streak-milestones {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.milestone {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 4px 10px;
  border: var(--border-w-thin) solid var(--ink);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}
.milestone.reached {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
@media (max-width: 820px) {
  .streak-spotlight-head { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .streak-week { gap: 4px; }
  .streak-week-day { padding: var(--sp-2) 2px; }
  .swd-label { font-size: 9px; }
  .streak-big { font-size: clamp(2.4rem, 14vw, 3.4rem); }
}

/* ---- Achievements ---- */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-3);
}
.achievement-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: transform var(--speed), box-shadow var(--speed);
}
.achievement-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.achievement-card.locked { opacity: 0.68; }
.achievement-card.unlocked {
  border-color: var(--ok);
  background: linear-gradient(180deg, var(--surface), var(--ok-light));
}
.achievement-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
}
.achievement-icon { font-size: 1.8rem; line-height: 1; }
.achievement-card h3 { margin: 0; font-size: var(--fs); }
.achievement-card p { margin: 0; }

/* ---- XP & rewards ---- */
.xp-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-3);
}
.xp-summary > div {
  padding: var(--sp-3);
  background: var(--accent-light);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r-sm);
}
.xp-summary .k {
  display: block;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}
.xp-summary b {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
}
.award-list { display: grid; gap: 0; }
.award-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: var(--fs-sm);
}
.award-row:last-child { border-bottom: none; }
.disclosure { border-top: var(--border-dash); padding-top: var(--sp-3); }
.disclosure summary { cursor: pointer; font-weight: 700; font-size: var(--fs-sm); }
@media (max-width: 620px) {
  .xp-summary { grid-template-columns: 1fr; }
}

/* ---- Share studio ---- */
.share-studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: var(--sp-5);
  align-items: start;
}
.share-preview-col { position: sticky; top: var(--sp-4); }
.share-preview-frame {
  display: flex;
  justify-content: center;
  padding: var(--sp-4);
  background: var(--accent-light);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
#share-canvas {
  width: 100%;
  max-width: 340px;
  height: auto;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.share-controls { display: grid; gap: var(--sp-3); }
.share-stat-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r);
}
.share-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.share-stat span {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.share-stat b {
  font-family: var(--font-mono);
  font-size: var(--fs);
  font-variant-numeric: tabular-nums;
}
.share-intents { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
/* The card design is fixed (Looseleaf, like the app), so it is shown as a
   note rather than a picker. */
.share-theme-note {
  display: grid;
  gap: 2px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: var(--border-w-thin) solid var(--ink);
  border-radius: var(--r);
}
.share-theme-note b { font-family: var(--font-display); }
@media (max-width: 900px) {
  .share-studio-grid { grid-template-columns: 1fr; }
  .share-preview-col { position: static; }
}