/* Excelerate — HSC study platform
   Type: Instrument Serif (display) / Inter (UI) / JetBrains Mono (data)
   Palette: ink + warm bone + deep blue accent
*/

:root {
  --ink: #0a0e1a;
  --ink-2: #1a1f2e;
  --ink-3: #3a4054;
  --ink-4: #6b7280;
  --ink-5: #9ca3af;
  --line: rgba(10, 14, 26, 0.08);
  --line-2: rgba(10, 14, 26, 0.14);
  --bone: #f7f5f0;
  --bone-2: #efece4;
  --paper: #fdfcf9;
  --white: #ffffff;
  --accent: #1e40af;
  --accent-2: #2c52cc;
  --accent-soft: #e8edfa;
  --accent-ink: #0d1f4d;
  --warn: #b45309;
  --good: #047857;
  --rose: #be123c;

  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --serif-reading: 'Source Serif 4', 'Charter', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --handwriting: 'Caveat', 'Bradley Hand', 'Segoe Script', cursive;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
}

[data-theme="dark"] {
  --ink: #f5f3ee;
  --ink-2: #d8d5cc;
  --ink-3: #b0aea4;
  --ink-4: #7d7c74;
  --ink-5: #56554f;
  --line: rgba(245, 243, 238, 0.08);
  --line-2: rgba(245, 243, 238, 0.16);
  --bone: #14161c;
  --bone-2: #1c1f28;
  --paper: #0d0f14;
  --white: #181b23;
  --accent: #6e8aff;
  --accent-2: #8aa1ff;
  --accent-soft: #1a2347;
  --accent-ink: #cbd5fc;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }

::selection { background: var(--accent); color: white; }

.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* ── Layout primitives ───────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--paper);
}
.app[data-route="landing"] { grid-template-columns: 1fr; }

/* ── Top route switch (prototype only) ───────────────────────── */
.route-switch {
  position: fixed; top: 76px; right: 16px;
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--white); border: 1px solid var(--line);
  border-radius: 999px; z-index: 100;
  box-shadow: 0 6px 24px rgba(10, 14, 26, 0.08), 0 1px 0 rgba(255,255,255,.6) inset;
  font-size: 11.5px;
}
.route-switch button {
  appearance: none; border: 0; background: transparent;
  padding: 6px 12px; border-radius: 999px;
  color: var(--ink-4); letter-spacing: 0.02em;
  font-weight: 500; transition: all 0.15s;
}
.route-switch button[data-on="true"] {
  background: var(--ink); color: var(--paper);
}
.route-switch button:hover:not([data-on="true"]) { color: var(--ink); }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--bone);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 14px 14px;
}
.sidebar-brand { padding: 4px 8px 22px; }
.sidebar-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-4); padding: 12px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r);
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  cursor: default; transition: background 0.12s;
}
.nav-item:hover { background: var(--bone-2); }
.nav-item[data-active="true"] {
  background: var(--ink); color: var(--paper);
}
.nav-item[data-active="true"] .nav-ico { color: var(--paper); }
.nav-ico {
  width: 16px; height: 16px; display: inline-flex; flex-shrink: 0;
  color: var(--ink-3);
}
.nav-badge {
  margin-left: auto;
  font-family: var(--mono); font-size: 10px;
  background: var(--accent-soft); color: var(--accent-ink);
  padding: 1px 6px; border-radius: 999px; font-weight: 500;
}
.nav-item[data-active="true"] .nav-badge { background: rgba(255,255,255,.18); color: var(--paper); }

.sidebar-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r);
}
.user-chip:hover { background: var(--bone-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: white;
  font-weight: 600; font-size: 11px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.user-meta { line-height: 1.2; min-width: 0; }
.user-meta b { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.user-meta span { font-size: 11px; color: var(--ink-4); }

/* ── Main area ───────────────────────────────────────────────── */
.main { min-width: 0; padding: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px;
  background: rgba(253, 252, 249, 0.78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
[data-theme="dark"] .topbar { background: rgba(13, 15, 20, 0.78); }
.crumb { font-size: 12px; color: var(--ink-4); }
.crumb b { color: var(--ink); font-weight: 600; }
.search-bar {
  flex: 1; max-width: 420px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bone); border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px; color: var(--ink-4);
}
.search-bar:focus-within { border-color: var(--ink-3); background: var(--white); }
.search-bar input {
  border: 0; background: transparent; outline: none;
  flex: 1; color: var(--ink); font-size: 12.5px;
}
.kbd {
  font-family: var(--mono); font-size: 10px;
  padding: 1px 5px; border-radius: 4px;
  background: var(--white); border: 1px solid var(--line-2);
  color: var(--ink-4);
}
.icon-btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--white); color: var(--ink-2);
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bone); }

.page { padding: 28px 28px 80px; max-width: 1280px; margin: 0 auto; }

/* ── Type ────────────────────────────────────────────────────── */
.h-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-4); font-weight: 600; margin: 0 0 8px;
}
.h-display {
  font-family: var(--serif); font-weight: 400;
  font-size: 56px; line-height: 1.1; letter-spacing: -0.02em;
  margin: 0 0 20px; color: var(--ink); text-wrap: balance;
  padding-bottom: 0.22em;
}
.h-display em { font-style: italic; color: var(--accent); }
.h-page {
  font-family: var(--serif); font-weight: 400;
  font-size: 36px; line-height: 1.05; letter-spacing: -0.015em;
  margin: 0 0 6px; color: var(--ink);
}
.h-section {
  font-family: var(--serif); font-weight: 400;
  font-size: 28px; line-height: 1.1; letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.lede {
  font-size: 16px; line-height: 1.5; color: var(--ink-3);
  margin: 0 0 24px; max-width: 56ch; text-wrap: pretty;
}
.muted { color: var(--ink-4); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  appearance: none; border: 0;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  transition: transform 0.06s, background 0.15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ink-2); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-2); }
.btn-ghost {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover { background: var(--bone); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 22px; font-size: 14px; }

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-flat {
  background: var(--bone);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-tight { padding: 14px; border-radius: var(--r); }

/* ── Tag / pill ──────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bone-2); color: var(--ink-3);
  font-family: var(--mono);
}
.tag-accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag-good { background: #d1fae5; color: #065f46; }
.tag-warn { background: #fef3c7; color: #92400e; }
.tag-rose { background: #fce7f3; color: #9f1239; }
[data-theme="dark"] .tag-good { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .tag-warn { background: #4a3010; color: #fcd34d; }
[data-theme="dark"] .tag-rose { background: #4a1027; color: #fbcfe8; }

/* ── Subject color dots ──────────────────────────────────────── */
.dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ── Misc utility ────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; gap: 16px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.scroll-area { overflow-y: auto; }
.scroll-area::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

/* ── Placeholder image ───────────────────────────────────────── */
.ph {
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(10,14,26,0.04) 8px 9px),
    var(--bone-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-4); letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Progress bar ────────────────────────────────────────────── */
.bar {
  height: 4px; background: var(--bone-2); border-radius: 999px; overflow: hidden;
}
.bar > span {
  display: block; height: 100%; background: var(--accent);
  border-radius: 999px;
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.3s ease-out both; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* ── Form ────────────────────────────────────────────────────── */
.input {
  display: block; width: 100%;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font-size: 13.5px; outline: none;
}
.input:focus { border-color: var(--ink); }
.label {
  display: block; font-size: 12px; font-weight: 600;
  margin-bottom: 6px; color: var(--ink-2);
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bone); border-radius: 10px;
}
.tabs button {
  appearance: none; border: 0; background: transparent;
  padding: 6px 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-3);
}
.tabs button[data-on="true"] {
  background: var(--white); color: var(--ink);
  box-shadow: 0 1px 2px rgba(10,14,26,0.06);
}

/* ── Landing-specific ────────────────────────────────────────── */
.land {
  max-width: 1280px; margin: 0 auto; padding: 24px 32px 80px;
}
.land-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 32px;
}
.land-nav-links { display: flex; gap: 28px; font-size: 13px; color: var(--ink-3); }
.land-nav-links a:hover { color: var(--ink); }

.hero-grid {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px;
  align-items: center; padding: 32px 0 64px;
}

.feat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}
.feat-cell {
  background: var(--paper); padding: 28px 24px; min-height: 200px;
  display: flex; flex-direction: column; gap: 8px;
}
.feat-cell .feat-num {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  font-weight: 500;
}
.feat-cell h4 {
  font-family: var(--serif); font-size: 22px; font-weight: 400;
  margin: 6px 0 4px; letter-spacing: -0.01em;
}
.feat-cell p { font-size: 13px; line-height: 1.5; color: var(--ink-3); margin: 0; }

/* Hero — variation B (focused/minimal) */
.hero-b {
  padding: 80px 0;
  text-align: center;
}
.hero-b .h-display { font-size: 88px; max-width: 14ch; margin-inline: auto; }
.hero-b .lede { margin-inline: auto; }
.hero-b-stats {
  display: flex; justify-content: center; gap: 48px;
  margin-top: 56px; padding-top: 32px;
  border-top: 1px solid var(--line);
}
.hero-b-stats .stat-num {
  font-family: var(--serif); font-size: 40px; line-height: 1; color: var(--ink);
}
.hero-b-stats .stat-lbl {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-4); margin-top: 6px;
}

/* ── Countdown ──────────────────────────────────────────────── */
.countdown-wrap {
  background: var(--ink); color: var(--paper);
  border-radius: var(--r-lg);
  padding: 28px;
  position: relative; overflow: hidden;
}
.countdown-wrap.alt {
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line);
}
.countdown-num {
  font-family: var(--serif); font-size: 96px; line-height: 0.9;
  letter-spacing: -0.03em;
}
.countdown-lbl {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-5); margin-top: 8px;
}
[data-theme="dark"] .countdown-wrap { background: #1c1f28; color: var(--ink); border: 1px solid var(--line); }

/* ── Variation B dashboard ──────────────────────────────────── */
.dash-b-hero {
  background: linear-gradient(135deg, var(--accent) 0%, #0d2877 100%);
  color: white; border-radius: var(--r-xl);
  padding: 36px; position: relative; overflow: hidden;
}
.dash-b-hero::after {
  content: ''; position: absolute; right: -80px; top: -80px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Mobile menu button ────────────────────────────────────────── */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(10,14,26,0.08);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,14,26,0.4);
  z-index: 90;
}

/* ── Responsive breakpoints ────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid.three-col { grid-template-columns: repeat(2, 1fr) !important; }
  .grid.dash-top { grid-template-columns: 1fr 1fr !important; }
  .grid.dash-mid { grid-template-columns: 1fr !important; }
  .grid.subject-detail-grid { grid-template-columns: 1fr !important; }
  .grid.tutor-grid { grid-template-columns: 1fr !important; }
  .grid.lookup-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .land-about { grid-template-columns: 1fr !important; gap: 32px !important; }
}

@media (max-width: 768px) {
  body { font-size: 14px; }

  /* Hide the legacy floating button — topbar has the menu now */
  .mobile-menu-btn { display: none; }
  .topbar-back-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.topbar-back-btn:hover {
  background: var(--bone-2);
  color: var(--ink);
}
.topbar-back-btn svg {
  transform: rotate(180deg);
}
.topbar-menu-btn { display: flex !important; }

  .app { grid-template-columns: 1fr !important; }

  /* Sidebar becomes drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 84vw;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    background: var(--white);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .app[data-mobile-open="true"] .sidebar { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.12); }
  .app[data-mobile-open="true"] .mobile-overlay { display: block; }

  /* Drawer items get bigger touch targets */
  .sidebar .nav-item {
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 8px;
  }
  .sidebar .nav-item .nav-ico svg { width: 18px; height: 18px; }

  /* Sticky topbar */
  .main {
    padding-top: 0;
    padding-bottom: calc(60px + env(safe-area-inset-bottom)); /* room for bottom nav */
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--paper);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(253, 252, 249, 0.92);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px !important;
    padding-top: max(12px, env(safe-area-inset-top)) !important;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
  }
  .topbar-search { display: none; }
  .crumb { font-size: 16px; font-weight: 600; }

  /* Page padding tightens but not too much */
  .page { padding: 18px 16px 28px !important; }
  .page-calm { padding: 18px 16px 28px !important; max-width: 100%; }

  /* Headings — readable but not absurdly big on a 360px screen */
  .h-page { font-size: 26px !important; line-height: 1.15; letter-spacing: -0.01em; }
  .h-display { font-size: 36px !important; line-height: 1.05 !important; }
  .h-section { font-size: 17px !important; }
  .countdown-num { font-size: 56px !important; }
  .calm-countdown .serif { font-size: 56px !important; }

  /* Grids collapse */
  .grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .grid.dash-top, .grid.dash-mid,
  .grid.three-col, .grid.two-col,
  .grid.lookup-grid, .grid.stat-grid,
  .grid.tutor-grid, .grid.planner-grid {
    grid-template-columns: 1fr !important;
  }

  /* Cards: less internal padding so content has more room */
  .card { padding: 16px; }

  /* Form/touch targets */
  button, .btn, .input, input, select, textarea {
    min-height: 44px;
  }
  .btn-sm, button.btn-sm, .a11y-choice {
    min-height: 36px;
  }
  .icon-btn {
    min-width: 40px;
    min-height: 40px;
  }
  /* Tasks/list rows — easier to tap */
  .calm-row {
    padding: 14px 0;
    min-height: 52px;
  }
  .check-box {
    width: 22px;
    height: 22px;
  }

  /* Hero/landing tweaks (in case anyone hits #landing) */
  .hero-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
  .land-nav { padding: 14px 16px !important; }
  .land-nav-links { display: none !important; }
  .feat-grid { grid-template-columns: 1fr !important; }

  /* Tables get horizontal scroll */
  .card[style*="overflow"] { overflow-x: auto !important; }

  /* Stack header rows that put the title and action buttons on one line */
  .row.spread.dash-header,
  .row.spread.tutor-header,
  .row.spread.auth-card-row {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  .route-switch { display: none !important; }

  /* Planner: 7-day grid is unreadable on phones — already hidden via grid
     collapse, but force it to actually re-stack as days */
  .planner-grid > .card:first-child > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Hide the day-header row on mobile (numbers without context) */
  .planner-grid > .card:first-child > div:first-child {
    display: none !important;
  }

  /* Forum thread row — make the whole row tappable, larger title */
  .calm-row, [data-row] { cursor: pointer; }

  /* AI tutor: chat scrolls inside available space; input bar sticks above
     the bottom nav */
  .tutor-grid > .card { min-height: auto !important; }
}

/* ── Bottom navigation (mobile only) ────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(253, 252, 249, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(60px + env(safe-area-inset-bottom));
}
@media (max-width: 768px) {
  .bottom-nav { display: flex; }
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  color: var(--ink-4);
  min-height: 60px;
  font-family: inherit;
  transition: color 0.12s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item:active { transform: scale(0.94); }
.bottom-nav-item[data-active="true"] {
  color: var(--ink);
}
/* Each bottom nav item picks up its route color when active */
.bottom-nav-item[data-active="true"][data-id="dashboard"] { color: #4F6BCC; }
.bottom-nav-item[data-active="true"][data-id="subjects"]  { color: #B8623F; }
.bottom-nav-item[data-active="true"][data-id="papers"]    { color: #4A8C5E; }
.bottom-nav-item[data-active="true"][data-id="planner"]   { color: #C68A2E; }
.bottom-nav-item[data-active="true"][data-id="tutor"]     { color: #8358B8; }
.bottom-nav-item[data-active="true"][data-id="forum"]     { color: #2F8F8C; }
.bottom-nav-item[data-active="true"][data-id="links"]     { color: #4684C2; }
.bottom-nav-item[data-active="true"][data-id="admin"]     { color: #1A1A1A; }
.bottom-nav-ico {
  display: flex;
  align-items: center;
  justify-content: center;
}
.bottom-nav-label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.bottom-nav-item[data-active="true"] .bottom-nav-label {
  font-weight: 600;
}

/* High-contrast mode for bottom nav */
html[data-a11y-contrast="high"] .bottom-nav {
  background: #fff;
  border-top: 2px solid #000;
}
html[data-a11y-contrast="high"] .bottom-nav-item[data-active="true"] {
  color: #000 !important;
}
html[data-a11y-contrast="high"] .bottom-nav-item[data-active="true"]::after {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: #000;
}

/* The topbar menu button — only visible on mobile */
.topbar-back-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.topbar-back-btn:hover {
  background: var(--bone-2);
  color: var(--ink);
}
.topbar-back-btn svg {
  transform: rotate(180deg);
}
.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  margin-left: -8px;
}
.topbar-menu-btn:active { background: rgba(0,0,0,0.05); }

/* On mobile, hide the desktop "Velocity / page" crumb prefix lookalikes
   that some pages include — kept page name only */

@media (max-width: 480px) {
  .h-page { font-size: 24px !important; }
  .h-display { font-size: 30px !important; }
  .countdown-num, .calm-countdown .serif { font-size: 48px !important; }
  .btn-lg { font-size: 14px !important; padding: 12px 16px !important; min-height: 48px; }
  .land-nav .row { flex-direction: column; gap: 6px; }
  .page { padding: 16px 14px 24px !important; }

  /* Smaller bottom-nav labels on tiny screens but keep icons readable */
  .bottom-nav-label { font-size: 10px; }
}

/* ── Pulse animation for tutor typing ─────────────────────────── */
.dot.pulse {
  animation: pulse 1.2s infinite ease-in-out;
}

/* ── Subject card hover effect ────────────────────────────────── */
.subj-card {
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.subj-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10,14,26,0.06);
}

/* ── Note rows hover ──────────────────────────────────────────── */
.note-row:hover, .search-row:hover {
  background: var(--bone);
}

/* ── Print: hide nav ──────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .mobile-menu-btn, .route-switch { display: none !important; }
  .main { padding: 0 !important; }
  .app { grid-template-columns: 1fr !important; }
}

/* ── Exam Timer (distraction-free fullscreen page) ───────────── */
.exam-timer {
  position: fixed;
  inset: 0;
  background: #0a0e1a;
  color: #e7eaf3;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  overflow: auto;
  padding: 24px;
}
.exam-exit {
  position: absolute;
  top: 16px; right: 16px;
  background: transparent;
  color: #9ca3af;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--sans);
}
.exam-exit:hover { color: #fff; border-color: rgba(255,255,255,0.3); }

.exam-timer-inner {
  width: 100%;
  max-width: 880px;
  text-align: center;
}
.exam-title {
  font-size: 32px;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}
.exam-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.exam-controls .btn {
  font-size: 13px;
  padding: 8px 14px;
}
.exam-controls .btn-primary {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.exam-controls .btn-primary:hover { background: #15803d; border-color: #15803d; }
.exam-controls .btn-accent {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.exam-controls .btn-ghost {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #e7eaf3;
}
.exam-controls .btn-ghost:hover { background: rgba(255,255,255,0.14); }
.exam-controls .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.exam-setup {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-bottom: 24px;
  padding: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.exam-setup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.exam-setup-field label {
  font-size: 11px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.exam-setup-field input {
  width: 80px;
  padding: 8px 10px;
  background: #1a1f2e;
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 6px;
  font-size: 18px;
  font-family: var(--mono);
  text-align: center;
}
.exam-setup-field input:disabled { opacity: 0.4; }
.exam-setup-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-self: flex-end;
  border-left: 1px solid rgba(255,255,255,0.1);
  padding-left: 18px;
  margin-left: 0;
}
.exam-setup-presets .btn-sm {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: #cbd5e1;
  font-size: 11px;
}
.exam-setup-presets .btn-sm:hover { background: rgba(255,255,255,0.08); }

.exam-times {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 36px;
  text-align: left;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.exam-time-block { min-height: 64px; }
.exam-time-label {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}
.exam-time-value {
  font-size: 40px;
  font-weight: 300;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  min-height: 48px;
}

.exam-countdown-label {
  font-size: 22px;
  font-weight: 600;
  text-align: left;
  margin-bottom: 16px;
}

.exam-countdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.exam-countdown.done .exam-num { color: #ef4444; }
.exam-countdown.running .exam-num { color: #fff; }
.exam-cell {
  background: #11151f;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 30px 16px 22px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
.exam-num {
  font-size: 116px;
  line-height: 1;
  color: #cbd5e1;
  letter-spacing: -0.04em;
}
.exam-unit {
  font-size: 28px;
  color: #9ca3af;
  font-weight: 300;
  align-self: flex-end;
  margin-bottom: 8px;
}

.exam-done-banner {
  margin-top: 24px;
  padding: 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: #fca5a5;
  font-size: 16px;
}

.exam-hint {
  margin-top: 24px;
  font-size: 12px;
  color: #6b7280;
}
.exam-hint .kbd {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: #cbd5e1;
}

@media (max-width: 768px) {
  .exam-num { font-size: 64px; }
  .exam-cell { padding: 18px 8px 14px; }
  .exam-unit { font-size: 18px; margin-bottom: 4px; }
  .exam-time-value { font-size: 24px; }
  .exam-time-label { font-size: 14px; }
  .exam-countdown-label { font-size: 16px; }
  .exam-times { gap: 12px; }
}

/* ── Paper session view (PDF + timer + scratchpad) ─────────────── */
.paper-session {
  position: fixed;
  inset: 0;
  background: var(--bone);
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.paper-session-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.paper-session-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.paper-session-title > span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.paper-session-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}
.paper-session-pdf {
  background: #f3f4f6;
  border-right: 1px solid var(--line);
  min-height: 0;
}
.paper-session-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  overflow-y: auto;
  background: var(--bone);
}
.paper-timer-card {
  padding: 14px;
}
.paper-timer-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin: 12px 0 8px;
  color: var(--ink);
  font-feature-settings: 'tnum';
}
.paper-timer-display.running { color: var(--ink); }
.paper-timer-display.done    { color: var(--rose); }
.paper-timer-display > span:not(.paper-timer-sep) {
  font-size: 44px;
  line-height: 1;
}
.paper-timer-sep {
  font-size: 38px;
  color: var(--ink-4);
  margin: 0 2px;
}
.paper-timer-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.paper-timer-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s linear;
}
.paper-timer-presets {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}
.paper-timer-done {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  color: var(--rose);
  font-size: 12px;
  text-align: center;
}
.paper-scratch-card {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}
.paper-scratch-input {
  width: 100%;
  flex: 1;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
  resize: none;
}
.paper-scratch-input:focus {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 900px) {
  .paper-session-body {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh 1fr;
  }
  .paper-session-pdf {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

/* ── Onboarding overlay & subject chips ────────────────────────── */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 500;
  overflow-y: auto;
}
.onboarding-card {
  background: var(--paper);
  border-radius: 16px;
  padding: 32px;
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(10, 14, 26, 0.25);
}
.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 18px;
}
@media (max-width: 540px) {
  .onboarding-grid { grid-template-columns: 1fr; }
  .onboarding-card { padding: 22px; }
}
.onboarding-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.onboarding-chip:hover {
  border-color: var(--ink-4);
}
.onboarding-chip[data-on="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.onboarding-chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: white;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.onboarding-chip-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.onboarding-chip-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.onboarding-chip-meta {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 2px;
}
.onboarding-chip-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: white;
}
.onboarding-chip[data-on="true"] .onboarding-chip-check {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Login page ─────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(ellipse at top, rgba(30, 64, 175, 0.06), transparent 60%),
    var(--paper);
}
.login-card-wrap {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 8px 30px rgba(10, 14, 26, 0.04);
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
}
.login-tagline {
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  color: var(--ink-4);
  margin: 0;
}
.login-countdown {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  margin-bottom: 28px;
  background: var(--accent-soft);
  border-radius: 10px;
  color: var(--accent-ink);
}
.login-countdown .mono {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
}
.login-countdown .serif {
  font-size: 28px;
  line-height: 1;
}
.login-actions {
  display: flex;
  flex-direction: column;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--ink-4);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.login-hint {
  font-size: 12px;
  text-align: center;
  margin-top: 18px;
  line-height: 1.5;
  color: var(--ink-4);
}
.login-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  font-size: 11px;
  color: var(--ink-4);
}
.login-footer a:hover {
  color: var(--ink-2);
}
.login-footer .btn-link:hover {
  color: var(--ink-2);
}
@media (max-width: 480px) {
  .login-card-wrap { padding: 28px 22px; }
}

/* ── Simplification pass — calmer global look ───────────────────── */

/* Softer cards across the app — less visual weight */
.card {
  border-radius: 8px;
}
.card-flat {
  border-radius: 8px;
}

/* Lighter sidebar — drop heavy section labels */
.sidebar-section {
  font-size: 9.5px !important;
  letter-spacing: 0.12em !important;
  color: var(--ink-5) !important;
  margin-top: 22px !important;
  margin-bottom: 6px !important;
  font-weight: 500 !important;
  opacity: 0.7;
}

/* Quieter nav items */
.nav-item {
  border-radius: 6px;
  padding: 7px 10px;
}

/* Topbar: thinner, no heavy border */
.topbar {
  padding-top: 14px;
  padding-bottom: 14px;
}
.crumb {
  font-size: 13.5px;
  color: var(--ink-3);
}
.crumb b {
  color: var(--ink);
  font-weight: 600;
}

/* Borderless inline link button — used everywhere we'd otherwise use a tiny btn-ghost */
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-2);
  transition: text-decoration-color 0.15s;
}
.btn-link:hover {
  text-decoration-color: var(--accent);
}

/* ── Calm dashboard ─────────────────────────────────────────────── */
.page-calm {
  max-width: 640px;
  padding-top: 24px;
}

.calm-countdown {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 28px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.calm-countdown .serif {
  font-size: 72px;
  line-height: 0.9;
  color: var(--ink);
}
.calm-countdown-label {
  font-size: 14px;
  color: var(--ink-4);
  line-height: 1.4;
}

.calm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: opacity 0.12s;
}
.calm-row:hover { opacity: 0.85; }

.check-box {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--line-2);
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
}
.check-box.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.calm-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

/* ── Login page redo (replaces earlier rules) ───────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--paper);
}
.login-card-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-countdown {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 18px 0 36px;
  padding: 0;
  background: none;
  border-radius: 0;
  display: block;
  text-align: center;
}
.login-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Type weight — confident but not loud ───────────────────────── */

/* Body baseline lifts from default 400 to 450 — reads as "well-set" rather than "bold" */
body, .page, .card, .card-flat, p, span, div, button, a, label, td, th, li {
  font-weight: 450;
}
/* Restore explicit-weight elements that should stay distinct */
.muted, .h-eyebrow {
  font-weight: 450;
}
strong, b, .nav-item[data-active="true"] span:not(.nav-ico):not(.nav-badge),
.serif, h1, h2, h3, h4, h5, h6, .h-page, .h-section {
  font-weight: 600;
}
/* Mono stays at its native weight — looks wrong if heavy */
.mono, code {
  font-weight: 450;
}
/* Inputs need to be readable, not loud */
.input, input, select, textarea {
  font-weight: 450;
}
/* Tags should stay tight */
.tag {
  font-weight: 500;
}

/* Slightly heavier serif for big page titles — gives the calm dashboard
   countdown a bit more anchor weight */
.h-page, h1.h-page {
  font-weight: 600;
}
.serif.tnum {
  font-weight: 500;
}

/* ── Per-route accent colors ────────────────────────────────────── */
/* Each route owns a CSS variable --route-accent that the page header,
   active nav item, and tag-accent inherit. Calm desaturated palette so
   it differentiates without competing with subject pills. */
.app[data-route="dashboard"] { --route-accent: #4F6BCC; --route-accent-soft: #4F6BCC18; }
.app[data-route="subjects"]  { --route-accent: #B8623F; --route-accent-soft: #B8623F18; }
.app[data-route="papers"]    { --route-accent: #4A8C5E; --route-accent-soft: #4A8C5E18; }
.app[data-route="planner"]   { --route-accent: #C68A2E; --route-accent-soft: #C68A2E18; }
.app[data-route="tutor"]     { --route-accent: #8358B8; --route-accent-soft: #8358B818; }
.app[data-route="forum"]     { --route-accent: #2F8F8C; --route-accent-soft: #2F8F8C18; }
.app[data-route="links"]     { --route-accent: #4684C2; --route-accent-soft: #4684C218; }
.app[data-route="mistakes"]  { --route-accent: #B85454; --route-accent-soft: #B8545418; }
.app[data-route="samples"]   { --route-accent: #C68A2E; --route-accent-soft: #C68A2E18; }
.app[data-route="auth"]      { --route-accent: #555; --route-accent-soft: #5555550e; }
.app[data-route="accessibility"] { --route-accent: #2F8F8C; --route-accent-soft: #2F8F8C18; }
.app[data-route="groups"]       { --route-accent: #7C3AED; --route-accent-soft: #7C3AED18; }
.app[data-route="group-manager"]{ --route-accent: #7C3AED; --route-accent-soft: #7C3AED18; }
.app[data-route="search"]    { --route-accent: #555; --route-accent-soft: #5555550e; }
.app[data-route="about"]     { --route-accent: #555; --route-accent-soft: #5555550e; }
.app[data-route="admin"]     { --route-accent: #1A1A1A; --route-accent-soft: #1A1A1A0e; }
.app[data-route="timer"]     { --route-accent: #B85454; --route-accent-soft: #B8545418; }
/* Fallback */
.app                         { --route-accent: var(--accent, #4F6BCC); --route-accent-soft: rgba(0,0,0,0.04); }

/* Apply the accent to the current page's eyebrow and page-title underline */
.page .h-eyebrow {
  color: var(--route-accent);
  opacity: 0.85;
}
/* Subtle accent stripe under page titles */
.page > h1.h-page {
  position: relative;
  padding-bottom: 6px;
}
.page > h1.h-page::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 36px;
  height: 2px;
  background: var(--route-accent);
  border-radius: 1px;
  opacity: 0.85;
}

/* Active sidebar nav item — paint with its own color, not just the global accent */
.nav-item[data-active="true"] {
  background: transparent;
  position: relative;
}
.nav-item[data-active="true"][data-id="dashboard"] { color: #4F6BCC; background: #4F6BCC12; }
.nav-item[data-active="true"][data-id="subjects"]  { color: #B8623F; background: #B8623F12; }
.nav-item[data-active="true"][data-id="papers"]    { color: #4A8C5E; background: #4A8C5E12; }
.nav-item[data-active="true"][data-id="planner"]   { color: #C68A2E; background: #C68A2E12; }
.nav-item[data-active="true"][data-id="tutor"]     { color: #8358B8; background: #8358B812; }
.nav-item[data-active="true"][data-id="forum"]     { color: #2F8F8C; background: #2F8F8C12; }
.nav-item[data-active="true"][data-id="links"]     { color: #4684C2; background: #4684C212; }
.nav-item[data-active="true"][data-id="mistakes"]  { color: #B85454; background: #B8545412; }
.nav-item[data-active="true"][data-id="samples"]   { color: #C68A2E; background: #C68A2E12; }
.nav-item[data-active="true"][data-id="auth"]      { color: #1A1A1A; background: #00000008; }
.nav-item[data-active="true"][data-id="accessibility"] { color: #2F8F8C; background: #2F8F8C12; }
.nav-item[data-active="true"][data-id="admin"]     { color: #1A1A1A; background: #00000008; }
.nav-item[data-active="true"] span                 { font-weight: 600; }

/* Left edge bar to make the active item unmistakable */
.nav-item[data-active="true"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.8;
}

/* ── Heading weight pass — proper hierarchy ─────────────────────── */
/* The earlier rules made body 450 and "strong" 600, but small headings
   (h3.h-section, h4) were inheriting 450 — making subheadings look LIGHTER
   than body text in some browsers. Lock them to 600/700 explicitly. */
.h-page,
h1.h-page,
.page > h1,
.page > h2 {
  font-weight: 700 !important;
  letter-spacing: -0.01em;
}
.h-section,
h2, h3, h4, h5, h6,
.serif {
  font-weight: 600 !important;
}
/* Eyebrow text — quiet but still firm */
.h-eyebrow {
  font-weight: 600 !important;
}
/* Big serif numbers (countdowns, stats) — anchor weight */
.serif.tnum,
.countdown-num,
.calm-countdown .serif {
  font-weight: 600 !important;
}
/* Login-page wordmark needs to feel set, not whispery */
.login-page .login-card-wrap > svg + *,
.login-page .login-card-wrap > * {
  font-weight: 500;
}

/* ── Accessibility — applied via data-* on <html> ───────────────── */

/* Choice buttons used inside the accessibility panel */
.a11y-choice {
  background: var(--white);
  border: 1px solid var(--line-2);
  color: var(--ink-3);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.a11y-choice:hover {
  border-color: var(--ink-4);
  color: var(--ink);
}
.a11y-choice[data-on="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* ─── Text size: bumps the root font-size, everything scales ─── */
html[data-a11y-text="large"]  { font-size: 18px; }
html[data-a11y-text="xlarge"] { font-size: 20px; }

/* ─── High contrast: pure black/white, thicker borders ─── */
html[data-a11y-contrast="high"] {
  --ink:   #000000;
  --ink-2: #000000;
  --ink-3: #1a1a1a;
  --ink-4: #333333;
  --ink-5: #444444;
  --paper: #ffffff;
  --bone:  #ffffff;
  --bone-2:#f0f0f0;
  --line:  #000000;
  --line-2:#000000;
  --white: #ffffff;
}
html[data-a11y-contrast="high"] .card,
html[data-a11y-contrast="high"] .card-flat,
html[data-a11y-contrast="high"] .input,
html[data-a11y-contrast="high"] input,
html[data-a11y-contrast="high"] select,
html[data-a11y-contrast="high"] textarea,
html[data-a11y-contrast="high"] .a11y-choice,
html[data-a11y-contrast="high"] .nav-item[data-active="true"] {
  border-width: 2px !important;
}
html[data-a11y-contrast="high"] .muted,
html[data-a11y-contrast="high"] .h-eyebrow,
html[data-a11y-contrast="high"] .mono {
  color: #000 !important;
}
html[data-a11y-contrast="high"] .btn {
  border-width: 2px !important;
}
/* Active nav: in HC mode the colored tints disappear, replaced by a solid
   black left bar and underline — color shouldn't be the only signal. */
html[data-a11y-contrast="high"] .nav-item[data-active="true"] {
  background: #000 !important;
  color: #fff !important;
}
html[data-a11y-contrast="high"] .nav-item[data-active="true"] * {
  color: #fff !important;
}
/* Page eyebrow + title underline: become black instead of route-accent */
html[data-a11y-contrast="high"] .page .h-eyebrow {
  color: #000 !important;
  opacity: 1;
}
html[data-a11y-contrast="high"] .page > h1.h-page::after {
  background: #000 !important;
  height: 3px;
  opacity: 1;
}

/* ─── Reduce motion: kill transitions and animations ─── */
html[data-a11y-motion="reduce"] *,
html[data-a11y-motion="reduce"] *::before,
html[data-a11y-motion="reduce"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* ─── Always-underline links ─── */
html[data-a11y-underline="all"] a,
html[data-a11y-underline="all"] .btn-link {
  text-decoration: underline !important;
  text-decoration-thickness: 1.5px !important;
  text-underline-offset: 2px !important;
}

/* ─── Dyslexia-friendly font ─── */
/* Atkinson Hyperlegible is a free, public-domain face designed for low
   vision. It has unambiguous letterforms (l vs I vs 1, 0 vs O) and
   generous spacing. Falls back to safe sans-serifs if the CDN can't load. */
html[data-a11y-font="dyslexic"] {
  --sans: "Atkinson Hyperlegible", "Verdana", "Tahoma", system-ui, sans-serif;
}
html[data-a11y-font="dyslexic"] body,
html[data-a11y-font="dyslexic"] .page,
html[data-a11y-font="dyslexic"] p,
html[data-a11y-font="dyslexic"] span:not(.mono):not(.serif),
html[data-a11y-font="dyslexic"] div,
html[data-a11y-font="dyslexic"] button,
html[data-a11y-font="dyslexic"] input,
html[data-a11y-font="dyslexic"] textarea,
html[data-a11y-font="dyslexic"] select,
html[data-a11y-font="dyslexic"] label,
html[data-a11y-font="dyslexic"] .h-section,
html[data-a11y-font="dyslexic"] h1, html[data-a11y-font="dyslexic"] h2,
html[data-a11y-font="dyslexic"] h3, html[data-a11y-font="dyslexic"] h4,
html[data-a11y-font="dyslexic"] h5, html[data-a11y-font="dyslexic"] h6 {
  font-family: var(--sans) !important;
  letter-spacing: 0.01em;
  word-spacing: 0.04em;
}

/* ── Font diversification ──────────────────────────────────────── */
/* Each font has a job. Handwriting earns its place ONLY in light
   garnish contexts where it adds personality (dashboard greeting
   subtitle, dashboard quick-link row). Reading serif handles long-
   form prose (note bodies, AI tutor responses). Display serif
   stays where it is (page titles, big numbers). */

/* Reading serif — for body prose where lines are long. Used in:
   - Note body text in subject pages
   - AI tutor responses (when user is reading paragraphs)
   - The "lede" intro paragraph on each page */
.lede,
.note-body,
.ai-message-text {
  font-family: var(--serif-reading);
  font-size: 16px;
  line-height: 1.65;
  font-weight: 450;
  color: var(--ink-2);
}

/* Handwriting accent — sparingly. Personal moments only. */
.handwriting,
.dash-greeting-sub,
.calm-countdown-label {
  font-family: var(--handwriting);
  font-weight: 500;
  letter-spacing: 0.005em;
}

/* The dashboard greeting subtitle ("X of Y done today") gets a touch
   of handwriting to feel personal — like a note from a study buddy.
   But only sized up — Caveat reads small if you keep it at 14px. */
.dash-greeting-sub {
  font-size: 18px;
  color: var(--ink-3);
}

/* Calm countdown label — "days until HSC 2026" reads warmly when
   set in handwriting next to the giant serif number. */
.calm-countdown-label {
  font-size: 18px;
  color: var(--ink-3);
  line-height: 1.3;
}

/* Quick link row at the bottom of the calm dashboard — handwriting
   makes them feel like inline notes rather than nav buttons. */
.calm-links .btn-link {
  font-family: var(--handwriting);
  font-size: 17px;
  font-weight: 500;
}

/* Big page titles — keep Instrument Serif but tighten kerning at
   the now-heavier 700 weight so they don't feel chunky */
h1.h-page,
.page > h1.h-page {
  font-family: var(--serif);
  letter-spacing: -0.015em;
  line-height: 1.1;
}

/* Section headings (h2/h3) keep the sans — they need to feel like
   information architecture, not editorial. Bumped weight already
   handles their authority. */

/* "Plain fonts" accessibility opt-out — strips decorative fonts back
   to safe sans/serif for users who find handwriting or display
   typography hard to read. */
html[data-a11y-font="plain"] .lede,
html[data-a11y-font="plain"] .note-body,
html[data-a11y-font="plain"] .ai-message-text {
  font-family: var(--sans) !important;
  line-height: 1.5;
}
html[data-a11y-font="plain"] .handwriting,
html[data-a11y-font="plain"] .dash-greeting-sub,
html[data-a11y-font="plain"] .calm-countdown-label,
html[data-a11y-font="plain"] .calm-links .btn-link,
html[data-a11y-font="plain"] h1.h-page,
html[data-a11y-font="plain"] .serif,
html[data-a11y-font="plain"] .page > h1.h-page {
  font-family: var(--sans) !important;
  letter-spacing: normal;
}

/* Dyslexia mode also overrides handwriting — it's the wrong choice
   for that user. */
html[data-a11y-font="dyslexic"] .handwriting,
html[data-a11y-font="dyslexic"] .dash-greeting-sub,
html[data-a11y-font="dyslexic"] .calm-countdown-label,
html[data-a11y-font="dyslexic"] .calm-links .btn-link {
  font-family: var(--sans) !important;
}

/* ── Mobile login tweaks ────────────────────────────────────────── */
@media (max-width: 480px) {
  .login-page {
    padding: 24px 20px;
    align-items: stretch;
    justify-content: flex-start;
    padding-top: max(60px, env(safe-area-inset-top));
  }
  .login-card-wrap {
    max-width: 100%;
  }
  .login-actions .btn-lg {
    padding: 14px 20px;
    font-size: 15px;
    min-height: 50px;
  }
  /* No bottom nav on the login screen */
  .login-page ~ .bottom-nav,
  body:has(.login-page) .bottom-nav {
    display: none !important;
  }
}

/* Hide bottom nav on the login route specifically (covers desktop+mobile) */
.app[data-route="login"] .bottom-nav,
.app[data-route="landing"] .bottom-nav {
  display: none !important;
}

/* ── Universal topbar search ────────────────────────────────────── */
.topbar-search-wrap {
  position: relative;
  flex: 0 1 360px;
  max-width: 360px;
}

.topbar-search-trigger {
  display: none;
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-3);
}
.topbar-search-trigger:hover { background: var(--bone-2); color: var(--ink); }

.topbar-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  height: 36px;
  background: var(--bone);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-4);
  transition: border-color 0.12s, background 0.12s;
}
.topbar-search-bar:focus-within {
  border-color: var(--ink-3);
  background: var(--white);
  color: var(--ink);
}
.topbar-search-input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 450;
  color: var(--ink);
  min-width: 0;
}
.topbar-search-input::placeholder {
  color: var(--ink-4);
}

.topbar-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: min(70vh, 480px);
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  z-index: 200;
  padding: 6px;
}

.topbar-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 7px;
  text-align: left;
  font-family: inherit;
  color: var(--ink);
  transition: background 0.08s;
}
.topbar-search-row:hover,
.topbar-search-row:focus-visible {
  background: var(--bone);
  outline: none;
}
.topbar-search-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 8px;
}
.topbar-search-empty {
  padding: 18px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-4);
}

/* Mobile: bar collapses to icon, taps to expand into a full-width search */
@media (max-width: 768px) {
  .topbar-search-wrap {
    flex: 0 0 auto;
  }
  .topbar-search-trigger {
    display: inline-flex;
  }
  .topbar-search-bar {
    display: none;
  }
  .topbar-search-wrap[data-expanded="true"] {
    position: absolute;
    top: 6px;
    left: 12px;
    right: 12px;
    z-index: 60;
    max-width: none;
    flex: 1;
  }
  .topbar-search-wrap[data-expanded="true"] .topbar-search-trigger {
    display: none;
  }
  .topbar-search-wrap[data-expanded="true"] .topbar-search-bar {
    display: flex;
    height: 40px;
    background: var(--white);
    border: 1px solid var(--ink-3);
  }
  .topbar-search-results {
    right: 0;
    left: 0;
    width: auto;
  }
}

/* High contrast adjustments */
html[data-a11y-contrast="high"] .topbar-search-bar {
  border-width: 2px;
  border-color: #000;
  background: #fff;
}
html[data-a11y-contrast="high"] .topbar-search-results {
  border-width: 2px;
  border-color: #000;
  box-shadow: none;
}
html[data-a11y-contrast="high"] .topbar-search-row:hover {
  background: #000;
  color: #fff;
}
html[data-a11y-contrast="high"] .topbar-search-row:hover * {
  color: #fff !important;
}

.paper-row-highlight {
  background: var(--accent-soft) !important;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 4px;
}