@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

html { scroll-behavior: smooth; }

/* ── DARK theme (default) ────────────────────────────────────────────────── */
:root {
  --bg: #060b18; --bg2: #0b1225; --panel: #0d1530; --panel2: #111d3a;
  --border: #1a2540; --border2: #243058; --text: #e8eef8; --muted: #7a8fba;
  --accent: #4f7cff; --accent2: #1ef5aa; --accent3: #ff6b6b;
  --gold: #f5b731; --purple: #9d6aff;
  --art: #ff7b54; --science: #54d4ff; --social: #ff6b9d;
  --header-bg: rgba(6,11,24,.9);
  --shadow: 0 8px 32px rgba(0,0,0,.4);
  --grad1: rgba(79,124,255,.12); --grad2: rgba(30,245,170,.07);
  --accent-glass: rgba(79,124,255,.1);
  --accent-glass2: rgba(79,124,255,.15);
  --accent-border: rgba(79,124,255,.3);
  --accent-glow: rgba(79,124,255,.35);

  /* ── Stacking scale — use these instead of arbitrary z-index values ──── */
  --z-base: 0;
  --z-header: 40;
  --z-sidebar: 100;
  --z-modal-backdrop: 200;
  --z-modal: 210;
  --z-toast: 300;
  --z-overlay: 400;
  --z-copy-protect: 9999;

  /* ── Border-radius scale — semantic tokens for consistency across pages.
     Older pages use raw 4px / 6px / 12px; new components should use these. */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-pill: 999px;
}

/* ── Shared page-level utilities ──────────────────────────────────────────
   Pulled out of per-page <style> blocks where they were duplicated 9+ times.
   Pages that already define these locally still work (locally scoped wins). */
.eyebrow {
  display: block;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px; font-weight: 700;
  letter-spacing: .28em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
/* Stat numbers — Rajdhani + tabular-nums for consistent column-aligned digits */
.hud-number, .stat-val {
  font-family: 'Rajdhani', sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--text);
}
.stat-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted);
}

/* ── Empty + Loading state patterns ───────────────────────────────────────
   Canonical "no data here yet" + "loading" UI. Reusable across pages.
   Use as: <div class="empty-state"><div class="empty-state__icon">📅</div>
   <h3>Nothing scheduled</h3><p>...</p><a class="btn">CTA</a></div> */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--muted);
}
.empty-state__icon {
  font-size: 36px; line-height: 1;
  margin-bottom: 10px;
}
.empty-state h3 {
  color: var(--text);
  font-size: 16px; font-weight: 700;
  margin: 0 0 6px;
}
.empty-state p {
  font-size: 13px; line-height: 1.5;
  margin: 0 auto 14px;
  max-width: 460px;
}
.empty-state .btn {
  margin-top: 4px;
}
.loading-state {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
}
.loading-state::before {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin .8s linear infinite;
}
@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

/* ── Global focus ring ───────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.btn:focus-visible,
.menu-card:focus-visible,
.subject-btn:focus-visible,
.choice-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ── LIGHT theme ─────────────────────────────────────────────────────────── */
html[data-theme="light"] {
  --bg: #ffffff; --bg2: #f0f4ff; --panel: #ffffff; --panel2: #f0f4ff;
  --border: #d0d8f0; --border2: #b0bcd8; --text: #0a1128; --muted: #556080;
  --accent: #1a4ed8; --accent2: #0a9e6a; --accent3: #cc2020;
  --gold: #b87800; --purple: #6030cc;
  --art: #c84010; --science: #0077aa; --social: #aa2060;
  --header-bg: rgba(255,255,255,.95);
  --shadow: 0 4px 24px rgba(0,0,60,.1);
  --grad1: rgba(26,78,216,.06); --grad2: rgba(10,158,106,.04);
  --accent-glass: rgba(26,78,216,.1);
  --accent-glass2: rgba(26,78,216,.15);
  --accent-border: rgba(26,78,216,.3);
  --accent-glow: rgba(26,78,216,.35);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* Remove 300ms tap delay and tap flash on all interactive elements */
a, button, [role="button"], .btn, .nd-item, .choice-btn, .menu-card, label {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html {
  height: 100%;
  background-color: var(--bg);
  transition: background-color .25s;
}

body {
  margin: 0;
  /* Use dvh (dynamic viewport height) for mobile so browser chrome is excluded.
     Falls back gracefully to 100vh in browsers without dvh support. */
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  transition: color .3s;
  /* Remove iOS tap flash on interactive elements */
  -webkit-tap-highlight-color: transparent;
}

/* Smooth theme transitions on key structural elements */
header, main, .card, .panel, footer, .footer,
.btn, .input, .choice-btn, .stat-badge, .daily-hud, .progress-wrap {
  transition: background-color .3s, border-color .3s, color .3s, box-shadow .3s;
}

/* ── Sidebar offset — push header + content right of the 44px icon strip ─── */
body { padding-left: 44px; transition: padding-left .22s cubic-bezier(.4,0,.2,1); }
/* When sidebar is pinned expanded, shift content to accommodate full width */
body.nd-body-pinned { padding-left: 244px; }
@media (max-width: 700px) {
  body, body.nd-body-pinned { padding-left: 0; }
  /* Safe-area padding for notched iPhones on mobile (no sidebar) */
  body { padding-left: env(safe-area-inset-left, 0); padding-right: env(safe-area-inset-right, 0); }
  .footer { padding-bottom: max(20px, env(safe-area-inset-bottom, 20px)); }
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: var(--z-header);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background .25s, border-color .25s;
}
header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent2), transparent);
  opacity: .5;
}
.container { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.nav {
  display: flex; align-items: center; gap: 12px;
  height: 66px; min-height: 56px;
  /* Let it grow taller if content needs it */
  flex-wrap: nowrap; overflow: visible;
}
/* gap fallback for Safari <14 — children get margin-right instead */
@supports not (gap: 1px) {
  .nav > * + * { margin-left: 12px; }
  .row > * + * { margin-left: 10px; }
  .stack > * + * { margin-top: 10px; }
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand img { height: 42px; border-radius: 10px; flex-shrink: 0; }

/* Brand text container — allow it to truncate */
.brand > div { min-width: 0; overflow: hidden; }

.site-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 18px; font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-sub {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── DECAfy co-brand tag in header (injected by branding.js) ─────────────
   Sits between the school brand block and the nav-right buttons.
   Read-only attribution — not clickable, no border, no pill chrome. */
.decafy-host-tag {
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: auto;     /* push to the right of available space */
  margin-right: 14px;
  padding: 4px 0;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
  opacity: .85;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.decafy-host-tag img { width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0; }
.decafy-host-tag .decafy-host-text strong { font-weight: 700; color: var(--text); letter-spacing: .14em; }
/* Coexist with .nav-right which also has margin-left:auto — clear the auto
   on nav-right when the tag is its preceding sibling so they sit together. */
.decafy-host-tag + .nav-right { margin-left: 0; }
@media (max-width: 720px) {
  .decafy-host-tag .decafy-host-text { display: none; }   /* icon only */
  .decafy-host-tag { margin-right: 8px; gap: 0; }
}

/* ── Mobile header ───────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .nav { height: 56px; gap: 8px; padding: 0 12px; }
  .container { padding: 0 12px; }
  .brand img { height: 32px; border-radius: 8px; }
  .site-name { font-size: 16px; }
  /* Hide subtitle on small screens — too cramped */
  .site-sub { display: none; }
  /* Compact nav-right buttons */
  .nav-right { gap: 6px; }
  .nav-right .btn { padding: 7px 10px; font-size: 12px; border-radius: 9px; }
  /* Update sidebar top offset to match shorter header */
  .nd-sidebar { top: 56px; }
}
/* On very small screens, hide btn text and show only emoji icon */
@media (max-width: 420px) {
  .btn-label-hide { display: none; }
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
main { padding: 28px 0 60px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px 24px; position: relative; overflow: hidden;
  transition: background .25s, border-color .25s;
}
html[data-theme="light"] .card { box-shadow: 0 2px 16px rgba(0,0,60,.07); }
.card-glow { border-color: var(--accent-border); box-shadow: 0 0 0 1px var(--accent-border), 0 8px 32px var(--accent-glow); }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1 { font-family: 'Rajdhani', sans-serif; font-size: 28px; font-weight: 700; margin: .1em 0; letter-spacing: .02em; }
h2 { font-size: 20px; font-weight: 700; margin: .2em 0; }
h3 { font-size: 15px; font-weight: 600; color: var(--muted); margin: .2em 0; }
.muted { color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border2); background: var(--panel2);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px;
  font-family: inherit;
  transition: border-color 150ms ease, background 150ms ease, transform 180ms cubic-bezier(0.23, 1, 0.32, 1), box-shadow 200ms ease, color 150ms ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); background: var(--accent-glass); transform: translateY(-1px); }
html[data-theme="light"] .btn:hover { background: var(--accent-glass); }
.btn:active { transform: translateY(0) scale(0.97); transition-duration: 100ms; }
.btn.primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%); border-color: transparent; color: #fff; box-shadow: 0 4px 20px var(--accent-glow); }
html[data-theme="light"] .btn.primary { box-shadow: 0 4px 20px var(--accent-glow); }
.btn.primary:hover { box-shadow: 0 6px 28px var(--accent-glow); }
.btn.success { background: linear-gradient(135deg, #1ef5aa, #0db87e); border-color: transparent; color: #050c1a; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: default; transform: none !important; pointer-events: none; }
.btn-sm { padding: 7px 12px; min-height: 32px; font-size: 13px; border-radius: 9px; }

/* ── Ghost button — transparent HUD chip with hairline border ─────────── */
.btn-ghost {
  background: transparent;
  border-color: var(--border2);
  color: var(--muted);
  position: relative;
}
.btn-ghost::before {
  content: '';
  position: absolute; inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--text) 18%, transparent), transparent);
  border-radius: inherit;
  pointer-events: none;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent-border); background: var(--accent-glass); }
.btn-ghost[aria-current="page"] {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-glass);
}
.btn-ghost[aria-current="page"]::after {
  content: '';
  position: absolute; left: 50%; bottom: -1px;
  width: 16px; height: 2px; transform: translateX(-50%);
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Icon-only square button — used in nav-right at small breakpoints */
.btn-icon-only {
  padding: 0;
  width: 34px; height: 34px;
  min-height: 34px;
  border-radius: 10px;
  font-size: 15px;
}
.btn-icon-only svg { width: 16px; height: 16px; }

/* Sign-out accent variant — subtly danger-tinted without being alarming */
.btn-signout {
  color: color-mix(in oklab, var(--accent3) 75%, var(--muted));
}
.btn-signout:hover {
  color: var(--accent3);
  border-color: color-mix(in oklab, var(--accent3) 35%, var(--border2));
  background: color-mix(in oklab, var(--accent3) 7%, transparent);
}

/* ── HUD utilities — shared type treatments and meters ────────────────── */
/* Eyebrow label with trailing hairline rule */
.hud-eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .22em;
  margin: 0 0 12px;
}
.hud-eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
.hud-eyebrow .hud-eyebrow-count {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Numeric display with Rajdhani + tabular-nums */
.hud-number {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  line-height: 1;
}

/* Ladder meter — 10 notches, filled ones glow. HUD replacement for a plain bar. */
.ladder {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  height: 6px;
  margin-top: 10px;
}
.ladder-notch {
  border-radius: 2px;
  background: color-mix(in oklab, var(--text) 8%, transparent);
  transition: background .18s;
}
.ladder-notch.on {
  background: var(--ladder-fill, var(--accent));
  box-shadow: 0 0 6px color-mix(in oklab, var(--ladder-fill, var(--accent)) 40%, transparent);
}

/* Tier ring — three concentric stroke rings around avatars / medals */
.tier-ring {
  position: relative;
  border-radius: 50%;
  padding: 3px;
  background:
    conic-gradient(from 210deg,
      color-mix(in oklab, var(--tier-color, var(--accent)) 95%, transparent) 0 72%,
      color-mix(in oklab, var(--tier-color, var(--accent)) 15%, transparent) 72% 100%);
}
.tier-ring::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: 50%;
  border: 1px solid color-mix(in oklab, var(--tier-color, var(--accent)) 25%, transparent);
  pointer-events: none;
}
.tier-honors     { --tier-color: var(--gold); }
.tier-scholastic { --tier-color: var(--accent); }
.tier-varsity    { --tier-color: var(--accent2); }

/* Pulsing LED dot — used for status on cards (earned delight only) */
.led-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--led-color, var(--accent));
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--led-color, var(--accent)) 22%, transparent),
              0 0 10px color-mix(in oklab, var(--led-color, var(--accent)) 55%, transparent);
  flex-shrink: 0;
}
.led-active  { --led-color: var(--accent2); animation: led-pulse 2400ms ease-in-out infinite; }
.led-expired { --led-color: var(--accent3); }
.led-pending { --led-color: var(--gold); }
@keyframes led-pulse {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in oklab, var(--led-color) 22%, transparent),
                        0 0 8px color-mix(in oklab, var(--led-color) 45%, transparent); }
  50%      { box-shadow: 0 0 0 4px color-mix(in oklab, var(--led-color) 14%, transparent),
                        0 0 14px color-mix(in oklab, var(--led-color) 65%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .led-active { animation: none; }
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--border2); background: var(--panel2);
  color: var(--text); font-family: inherit; font-size: 15px;
  transition: border-color .15s, background .25s, color .25s;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glass); }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }
code { font-family: 'JetBrains Mono', monospace; font-size: .85em; background: var(--panel2); padding: 2px 6px; border-radius: 4px; }

/* ── Subject pills ───────────────────────────────────────────────────────── */
.subject-pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; min-height: 26px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.pill-art     { background: color-mix(in srgb, var(--art) 15%, transparent);     color: var(--art);     border: 1px solid color-mix(in srgb, var(--art) 30%, transparent); }
.pill-econ    { background: var(--accent-glass2);                                color: var(--accent);  border: 1px solid var(--accent-border); }
.pill-lit     { background: color-mix(in srgb, var(--purple) 15%, transparent);  color: var(--purple);  border: 1px solid color-mix(in srgb, var(--purple) 30%, transparent); }
.pill-math    { background: color-mix(in srgb, var(--accent2) 15%, transparent); color: var(--accent2); border: 1px solid color-mix(in srgb, var(--accent2) 30%, transparent); }
.pill-music   { background: color-mix(in srgb, var(--gold) 15%, transparent);    color: var(--gold);    border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); }
.pill-science { background: color-mix(in srgb, var(--science) 15%, transparent); color: var(--science); border: 1px solid color-mix(in srgb, var(--science) 30%, transparent); }
.pill-social_science { background: color-mix(in srgb, var(--social) 15%, transparent); color: var(--social); border: 1px solid color-mix(in srgb, var(--social) 30%, transparent); }
.pill-misc    { background: color-mix(in srgb, var(--muted) 15%, transparent);   color: var(--muted);   border: 1px solid color-mix(in srgb, var(--muted) 30%, transparent); }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-wrap { width: 100%; height: 5px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s; box-shadow: 0 0 8px var(--accent-glow); }

/* ── Stat badge ──────────────────────────────────────────────────────────── */
.stat-badge { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; min-height: 28px; border: 1px solid var(--border2); border-radius: 10px; background: var(--panel2); font-size: 13px; color: var(--muted); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
/* Spinner: border-based for universal compat (conic-gradient unsupported in Safari <12.1) */
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--border2); border-top-color: var(--accent); border-right-color: var(--accent2); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border2); color: var(--text); font-size: 14px; font-weight: 500; box-shadow: var(--shadow); animation: slideUp .25s ease; }
.toast.correct { border-color: var(--accent2); color: var(--accent2); }
.toast.wrong   { border-color: var(--accent3); color: var(--accent3); }
@keyframes slideUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; background: var(--panel2); }
tr:last-child td { border-bottom: none; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer { text-align: center; padding: 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 20px; }

/* ── Choice buttons ──────────────────────────────────────────────────────── */
.choice-btn {
  display: flex; align-items: baseline; gap: 10px;
  width: 100%; text-align: left; padding: 13px 16px;
  border-radius: 13px; border: 1px solid var(--border2); background: var(--panel2);
  color: var(--text); font-family: inherit; font-size: 15px; cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 180ms cubic-bezier(0.23, 1, 0.32, 1), color 150ms ease;
  font-weight: 500;
}
.choice-letter { flex-shrink: 0; font-weight: 700; color: var(--muted); }
.choice-btn.selected .choice-letter,
.choice-btn.correct .choice-letter,
.choice-btn.correct-ans .choice-letter  { color: inherit; }
.choice-btn.wrong .choice-letter,
.choice-btn.wrong-ans .choice-letter    { color: inherit; }
.choice-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-glass); }
html[data-theme="light"] .choice-btn:hover:not(:disabled) { background: var(--accent-glass); }
.choice-btn.selected  { border-color: var(--accent);  background: var(--accent-glass2); color: var(--accent); box-shadow: 0 0 0 1px var(--accent-border), inset 0 1px 0 var(--accent-glass); }
.choice-btn.correct   { border-color: var(--accent2); background: rgba(30,245,170,.1);  color: var(--accent2); font-weight: 700; }
.choice-btn.wrong     { border-color: var(--accent3); background: rgba(255,107,107,.1); color: var(--accent3); }
.choice-btn.reveal    { border-color: var(--accent2); background: rgba(30,245,170,.07); color: var(--accent2); }
.choice-btn:disabled  { cursor: default; }

/* ── Explanation box ─────────────────────────────────────────────────────── */
.explanation-box { padding: 14px 16px; border-radius: 4px; border: 1px solid var(--accent-border); background: var(--accent-glass); font-size: 14px; line-height: 1.6; margin-top: 12px; }

/* ── Celebrate overlay ───────────────────────────────────────────────────── */
.celebrate-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); z-index: var(--z-overlay); display: flex; align-items: center; justify-content: center; }
.celebrate-card { background: var(--panel); border: 1px solid var(--border2); border-radius: 20px; padding: 36px; text-align: center; max-width: 340px; box-shadow: var(--shadow); }

/* ── Daily HUD ───────────────────────────────────────────────────────────── */
.daily-hud { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border2); background: var(--panel2); margin-bottom: 16px; flex-wrap: wrap; }

/* ── Left Sidebar Navigation (nav.js) ────────────────────────────────────── */

/* The sidebar sits fixed on the left, below the header.
   Collapsed = 44px icon strip. Expanded on hover = 244px. */
.nd-sidebar {
  position: fixed;
  top: 66px; /* matches .nav height */
  /* Account for notch/home-bar on iPhones */
  left: env(safe-area-inset-left, 0);
  bottom: env(safe-area-inset-bottom, 0);
  width: 44px;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width .22s cubic-bezier(.4,0,.2,1),
              box-shadow .22s,
              border-color .22s;
  /* Subtle right-edge glow so it's always discoverable */
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
}
.nd-sidebar.nd-open,
.nd-sidebar.nd-pinned {
  width: 244px;
  border-right-color: var(--accent-border);
  box-shadow: 4px 0 28px rgba(0,0,0,.28), 2px 0 0 var(--accent-border);
}

/* Scrollable nav list */
.nd-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 4px;
  scrollbar-width: none;
}
.nd-list::-webkit-scrollbar { display: none; }

/* Group dividers — only separator line when collapsed, label when expanded */
.nd-group {
  height: 1px;
  background: var(--border);
  margin: 6px 8px;
  overflow: hidden;
  transition: height .15s, margin .15s;
  position: relative;
}
.nd-group-label {
  position: absolute; left: 0; right: 0; top: 0;
  font-size: 9px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .12em;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .15s .05s, transform .15s .05s;
  padding: 0 12px;
  line-height: 1;
}
.nd-sidebar.nd-open .nd-group,
.nd-sidebar.nd-pinned .nd-group {
  height: 24px;
  margin: 4px 0 2px;
  background: transparent;
  border-top: 1px solid var(--border);
}
.nd-sidebar.nd-open .nd-group:first-child,
.nd-sidebar.nd-pinned .nd-group:first-child { border-top: none; margin-top: 4px; }
.nd-sidebar.nd-open .nd-group-label,
.nd-sidebar.nd-pinned .nd-group-label {
  opacity: .65;
  transform: translateX(0);
  top: 6px;
}

/* Nav items — min-height 44px for WCAG AAA touch targets */
.nd-item {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 0 10px 12px;
  min-height: 44px;
  box-sizing: border-box;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  position: relative;
  cursor: pointer;
  transition: background .1s, color .1s;
}
.nd-item:hover { background: var(--panel2); color: var(--accent); }
.nd-item:hover .nd-icon { transform: scale(1.18); }

.nd-active {
  background: var(--accent-glass);
  color: var(--accent);
}
.nd-active::before {
  content: '';
  position: absolute; left: 0; top: 5px; bottom: 5px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Icon: always visible, fixed 20px, centered in the 44px strip */
.nd-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  transition: transform .12s;
  margin-right: 12px; /* gap to label */
}

/* Label: hidden (opacity+transform) when collapsed */
.nd-label {
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .14s .03s, transform .14s .03s;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.nd-sidebar.nd-open .nd-label,
.nd-sidebar.nd-pinned .nd-label {
  opacity: 1;
  transform: translateX(0);
}

/* Footer (user name) */
.nd-foot {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--panel2);
  display: flex;
  align-items: center;
  padding: 11px 0 11px 12px;
  gap: 0;
  overflow: hidden;
}
.nd-user-name {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .14s .03s, transform .14s .03s;
}
.nd-sidebar.nd-open .nd-user-name,
.nd-sidebar.nd-pinned .nd-user-name { opacity: 1; transform: translateX(0); }
.nd-foot .nd-icon { margin-right: 12px; }

/* Brand link injected by nav.js */
.nd-brand-link {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit; flex-shrink: 0;
  border-radius: 10px; padding: 4px 6px; margin: -4px -6px;
  transition: background .15s;
}
.nd-brand-link:hover { background: var(--accent-glass); }

/* ── Pin-toggle (desktop, at the top of the sidebar) ──────────────────── */
/* Standard side-panel icon (rectangle with vertical divider) — same visual
   affordance as VS Code / Claude / most modern apps. Collapsed state: the
   line sits toward the left (open panel icon). Pinned state: the line
   stays, making it recognizably the "toggle sidebar" icon. */
.nd-pin-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 10px 0 10px 12px;
  min-height: 44px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.nd-pin-toggle:hover { background: var(--panel2); color: var(--accent); }
.nd-pin-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* SVG icon wrapper — matches the other nav icons in size and alignment */
.nd-pin-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 12px;
  flex-shrink: 0;
  color: var(--text);
}
.nd-pin-icon svg {
  width: 18px;
  height: 18px;
  transition: transform .22s;
}
/* When pinned, flip the icon horizontally so the divider moves to the right —
   a visual cue that the panel is currently open. */
.nd-sidebar.nd-pinned .nd-pin-icon svg { transform: scaleX(-1); }

/* Label hidden when collapsed; shown when hovered or pinned */
.nd-pin-label {
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .14s .03s, transform .14s .03s;
  white-space: nowrap;
}
.nd-sidebar.nd-open .nd-pin-label,
.nd-sidebar.nd-pinned .nd-pin-label {
  opacity: 1;
  transform: translateX(0);
}
/* Label text swaps via CSS depending on pinned state */
.nd-sidebar.nd-pinned .nd-pin-label::before { content: 'Collapse'; }
.nd-sidebar:not(.nd-pinned) .nd-pin-label::before { content: 'Expand'; }
.nd-pin-label::before { font-size: 12px; }

/* Hide pin toggle on mobile (mobile uses hamburger) */
@media (max-width: 700px) {
  .nd-pin-toggle { display: none !important; }
}

/* ── Hamburger button (mobile only) ───────────────────────────────────── */
/* Desktop uses the in-sidebar pin-toggle (.nd-pin-toggle) instead. */
.nd-hamburger {
  display: none; /* overridden on mobile below */
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  margin-right: 10px;
  width: 44px;
  height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  border-radius: 8px;
  transition: background .15s;
}
.nd-hamburger:hover { background: var(--panel2); }
.nd-hamburger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nd-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nd-hamburger:hover span { background: var(--accent); }
.nd-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nd-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nd-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Backdrop scrim (shown when sidebar is explicitly open) ─────────────── */
.nd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-sidebar, 50) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.nd-backdrop.nd-backdrop-open {
  opacity: 1;
  pointer-events: auto;
}
/* On desktop (wider viewports) the sidebar is non-modal — no backdrop needed */
@media (min-width: 701px) {
  .nd-backdrop { display: none; }
}

/* ── Mobile sidebar — hidden by default, slides in when .nd-open ──────── */
@media (max-width: 700px) {
  .nd-sidebar {
    display: flex; /* overrides previous display:none */
    width: min(85vw, 300px);
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 28px rgba(0,0,0,.4);
  }
  .nd-sidebar.nd-open {
    transform: translateX(0);
  }
  /* Ensure labels and group headers are always visible on mobile when open */
  .nd-sidebar .nd-label,
  .nd-sidebar .nd-group-label,
  .nd-sidebar .nd-user-name {
    opacity: 1;
    transform: translateX(0);
  }
  .nd-sidebar .nd-group {
    height: 24px;
    margin: 4px 0 2px;
    background: transparent;
    border-top: 1px solid var(--border);
  }
  .nd-sidebar .nd-group:first-child { border-top: none; }
  .nd-sidebar .nd-group-label { top: 6px; }
  /* Show hamburger on mobile; hide the desktop pin toggle */
  .nd-hamburger { display: flex; }
  .nd-pin-toggle { display: none; }
}

/* ── Mobile responsiveness ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .menu-grid {
    grid-template-columns: 1fr !important;
  }
  .coach-tabs {
    gap: 2px;
  }
  .coach-tab {
    font-size: 11px !important;
    padding: 8px 10px !important;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .pending-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .pending-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .jump-grid {
    gap: 3px;
  }
  .jump-btn {
    width: 24px !important;
    height: 24px !important;
    font-size: 10px !important;
  }
}
@media (max-width: 360px) {
  main { padding: 16px 12px 48px !important; }
  .card { padding: 16px 14px !important; }
}

/* ── Shared entrance animations ──────────────────────────────────────────── */
/* One vocabulary used across every polished page (login, menu, practice,
   testing, random, assigned-test). Easing is cubic-bezier(0.23,1,0.32,1) —
   a natural ease-out-quart. All animations are one-shot on page load. */
@keyframes hero-in {
  from { opacity: 0; transform: translateY(24px); filter: blur(6px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0);   }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes alert-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0);     }
}
@keyframes rule-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes rule-draw {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(22px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
@keyframes featured-pulse {
  0%, 100% { box-shadow: 0 0 0 0  color-mix(in srgb, var(--accent) 35%, transparent); }
  60%      { box-shadow: 0 0 0 14px transparent; }
}

/* ── Ambient/continuous motion (decorative accents only) ────────────────── */
/* Slow, infinite — draws the eye to CTAs and brand marks without distracting
   from content. Durations >2s so motion reads as "alive" rather than "busy". */
@keyframes cta-breathe {
  0%, 100% { box-shadow: 0 4px 20px var(--accent-glow); }
  50%      { box-shadow: 0 8px 34px var(--accent-glow), 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
}
.btn.primary {
  animation: cta-breathe 3200ms ease-in-out infinite;
}
.btn.primary:hover,
.btn.primary:active,
.btn.primary:disabled {
  animation-play-state: paused;
}

@keyframes brand-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
header .brand img,
header .nd-brand-link img {
  animation: brand-float 4400ms ease-in-out infinite;
}

@keyframes gold-shimmer {
  0%, 100% { filter: drop-shadow(0 0 0 color-mix(in srgb, var(--gold) 0%, transparent)); }
  50%      { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--gold) 45%, transparent)); }
}
/* Applied opt-in via .ambient-shimmer — pages can tag trophies/awards */
.ambient-shimmer {
  animation: gold-shimmer 3600ms ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  @keyframes hero-in    { from { opacity: 0; } to { opacity: 1; } }
  @keyframes fade-up    { from { opacity: 0; } to { opacity: 1; } }
  @keyframes alert-in   { from { opacity: 0; } to { opacity: 1; } }
  @keyframes card-in    { from { opacity: 0; } to { opacity: 1; } }
  @keyframes rule-draw  { from { opacity: 0; } to { opacity: 1; } }
  @keyframes featured-pulse { 0%, 100% { box-shadow: none; } }
  /* Kill all ambient/continuous motion */
  .btn.primary,
  header .brand img,
  header .nd-brand-link img,
  .ambient-shimmer { animation: none; }
}

/* Default page entrance for any page using .card as a main surface.
   Opacity-only so it doesn't stack translation with child fade-up animations
   on the polished pages. Page-scoped animations (e.g. #quizCard:not(.hidden),
   .auth-card, .waiting-card) declared later in per-page <style> override this
   baseline. */
main > .card,
main > .container > .card,
main.container > .card {
  animation: fade-in 360ms ease-out 80ms both;
}
