/* =========================================================
   MedMCQ — Editorial-clinical design system
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Dark theme (default) */
  --bg:           #0a0e0e;
  --bg-elev:     #101414;
  --surface:     #131818;
  --surface-2:   #1a2020;
  --border:      #1f2626;
  --border-strong:#2a3434;
  --text:        #e8edec;
  --text-soft:   #a8b3b2;
  --text-mute:   #6a7674;
  --accent:      #fbbf24;
  --accent-deep: #f59e0b;
  --accent-glow: rgba(251, 191, 36, 0.18);
  --warn:        #f59e0b;
  --danger:      #f87171;
  --info:        #60a5fa;
  --highlight:   #fde68a;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.02) inset, 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 10px 30px -10px rgba(0,0,0,0.6), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 0 1px var(--accent-glow), 0 8px 30px -8px var(--accent-glow);

  --font-display: 'Fraunces', 'Iowan Old Style', 'Georgia', serif;
  --font-body:    'Manrope', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --maxw: 1240px;
  --gutter: clamp(16px, 3vw, 32px);

  --t-fast: 140ms cubic-bezier(.2,.7,.3,1);
  --t-med:  240ms cubic-bezier(.2,.7,.3,1);
  --t-slow: 420ms cubic-bezier(.2,.7,.3,1);
}

[data-theme="light"] {
  --bg:           #faf8f4;
  --bg-elev:     #ffffff;
  --surface:     #ffffff;
  --surface-2:   #f4f1ea;
  --border:      #e8e2d6;
  --border-strong:#d6cebc;
  --text:        #14181a;
  --text-soft:   #4a534f;
  --text-mute:   #7a847f;
  --accent:      #d97706;
  --accent-deep: #b45309;
  --accent-glow: rgba(217, 119, 6, 0.12);
  --warn:        #b45309;
  --danger:      #b91c1c;
  --info:        #1d4ed8;
  --shadow-1: 0 1px 0 rgba(255,255,255,0.6) inset, 0 1px 2px rgba(20,24,26,0.06);
  --shadow-2: 0 12px 30px -14px rgba(20,24,26,0.18), 0 2px 6px rgba(20,24,26,0.06);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  /* Atmospheric background — subtle gradient mesh */
  background-image:
    radial-gradient(at 8% -5%, rgba(251,191,36,0.07) 0px, transparent 45%),
    radial-gradient(at 100% 0%, rgba(96,165,250,0.04) 0px, transparent 50%),
    radial-gradient(at 50% 110%, rgba(245,158,11,0.04) 0px, transparent 45%);
  background-attachment: fixed;
}
[data-theme="light"] body {
  background-image:
    radial-gradient(at 8% -5%, rgba(217,119,6,0.06) 0px, transparent 45%),
    radial-gradient(at 100% 0%, rgba(29,78,216,0.03) 0px, transparent 50%);
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 400; }
h1 em { font-style: italic; font-weight: 300; color: var(--text-soft); }
h2 { font-size: clamp(1.4rem, 2.4vw, 2rem); font-weight: 500; }
h3 { font-size: 1.2rem; font-weight: 500; }
p  { margin: 0 0 1rem; }
a  { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-deep); }

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

kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(14px);
  -webkit-backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 16px;
  max-width: var(--maxw); margin: 0 auto;
  padding: 14px var(--gutter);
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--text); text-decoration: none;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #0a0e0e;
  box-shadow: 0 6px 18px -6px var(--accent-glow);
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: -0.02em; }
.brand-sub  { font-size: 11px; color: var(--text-mute); margin-top: 3px; letter-spacing: 0.04em; text-transform: uppercase; }

.nav-primary { display: flex; gap: 4px; margin-left: 16px; }
.nav-link {
  color: var(--text-soft);
  padding: 8px 14px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 500;
  transition: all var(--t-fast);
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.is-active {
  color: var(--text); background: var(--surface);
  box-shadow: var(--shadow-1);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-mini {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: var(--radius-pill);
  min-width: 240px;
  transition: all var(--t-fast);
}
.search-mini:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.search-mini svg { color: var(--text-mute); flex: none; }
.search-mini input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 13.5px; }
.search-mini input::placeholder { color: var(--text-mute); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--t-fast);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-sun, .icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
.nav-toggle { display: none; }

.meta-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--gutter) 12px;
}
.meta-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: var(--radius-pill);
  font-size: 12px; color: var(--text-soft);
}
.meta-pill svg { color: var(--accent); }

/* ---------- Page wrapper ---------- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px) var(--gutter) 80px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px;
  align-items: end;
  padding-bottom: 36px; margin-bottom: 36px;
  border-bottom: 1px solid var(--border);
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 16px;
}
.hero-eyebrow::before {
  content: ''; width: 22px; height: 1px; background: var(--text-mute);
}
.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.hero-stat .num {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 400;
  line-height: 1;
  color: var(--text);
}
.hero-stat .num.accent { color: var(--accent); }
.hero-stat .lbl {
  font-size: 11.5px; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-top: 8px;
}

/* ---------- Section header ---------- */
.section-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 16px; margin: 40px 0 20px;
}
.section-head h2 { display: flex; align-items: baseline; gap: 12px; }
.section-head .count {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-mute);
  font-weight: 400; letter-spacing: 0;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: all var(--t-med);
}
.card:hover { border-color: var(--border-strong); }

/* Subject card */
.subjects-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.subj-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  transition: all var(--t-med);
  text-decoration: none; color: inherit;
}
.subj-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 100% 0%, var(--c, var(--accent)) 0, transparent 60%);
  opacity: 0.07; transition: opacity var(--t-med);
  pointer-events: none;
}
.subj-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.subj-card:hover::before { opacity: 0.14; }
.subj-card-top { display: flex; align-items: center; justify-content: space-between; }
.subj-badge {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 500; font-size: 16px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.subj-count {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-mute);
}
.subj-name {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 500;
  letter-spacing: -0.015em; line-height: 1.15;
}
.subj-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: auto; padding-top: 10px;
  font-size: 12px; color: var(--text-mute);
}
.subj-meta .dot { color: var(--border-strong); }
.subj-go {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500; color: var(--accent);
}
.subj-card:hover .subj-go svg { transform: translateX(3px); }
.subj-go svg { transition: transform var(--t-fast); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  padding: 11px 20px; border-radius: var(--radius-pill);
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: #06120e;
  box-shadow: 0 8px 20px -8px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-deep); transform: translateY(-1px); color: #fff; }
.btn-ghost {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-danger {
  background: transparent; color: var(--danger); border-color: var(--border);
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-lg { padding: 14px 26px; font-size: 15px; }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field-label {
  display: block; font-size: 12px;
  color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.input, .select, .textarea {
  width: 100%; font: inherit; font-size: 14.5px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px; border-radius: var(--radius-sm);
  transition: all var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

/* Chips group */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-soft); user-select: none;
  transition: all var(--t-fast);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip:has(input:checked) {
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Mode tiles */
.mode-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.mode-tile {
  position: relative; cursor: pointer; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.mode-tile input { position: absolute; opacity: 0; pointer-events: none; }
.mode-tile:hover { border-color: var(--border-strong); }
.mode-tile:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px -10px var(--accent-glow);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.mode-tile h4 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 6px; }
.mode-tile p { font-size: 13px; color: var(--text-soft); margin: 0; }

/* ---------- Quiz UI ---------- */
/* When page contains quiz-shell, remove extra vertical padding to prevent double-scroll */
.page:has(.quiz-shell) {
  padding-top: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0));
}

.quiz-shell {
  max-width: 820px; margin: 0 auto;
  display: flex;
  flex-direction: column;
}
@media (max-width: 768px) {
  .quiz-shell {
    /* Height adjusts for topbar (~60px), bottom-nav (~70px), and paddings (~40px) */
    height: calc(100dvh - 180px);
  }
}
.q-header {
  flex-shrink: 0;
}
.q-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px; /* Some breathing room */
}
.q-footer {
  flex-shrink: 0;
  padding-top: 14px;
  background: var(--bg); /* To cover scrolling content if it bleeds */
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.quiz-topline {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.qprog {
  font-family: var(--font-mono); font-size: 13px; color: var(--text-mute);
}
.qprog strong { color: var(--text); font-weight: 600; }
.q-tools { display: flex; gap: 8px; }

.qbar {
  position: relative; height: 4px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; margin-bottom: 22px;
}
.qbar-fill {
  position: absolute; inset: 0 100% 0 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transition: right var(--t-med);
}

.q-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border);
}
.tag.past { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.tag.subject-tag { color: var(--c, var(--accent)); border-color: color-mix(in srgb, var(--c, var(--accent)) 30%, transparent); }

.q-stem {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  font-weight: 400; line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 26px;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  position: relative; cursor: pointer;
  display: grid; grid-template-columns: 32px 1fr auto; gap: 14px; align-items: center;
  padding: 14px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.opt:hover { border-color: var(--border-strong); transform: translateX(2px); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt-letter {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-soft);
  transition: all var(--t-fast);
}
.opt-text { font-size: 15px; color: var(--text); }
.opt-mark { color: var(--text-mute); opacity: 0; transition: opacity var(--t-fast); }
.opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.opt:has(input:checked) .opt-letter { background: var(--accent); color: #06120e; border-color: var(--accent); }

/* States after submitting (tutor mode) */
.opt.is-correct { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.opt.is-correct .opt-letter { background: var(--accent); color: #06120e; border-color: var(--accent); }
.opt.is-correct .opt-mark { opacity: 1; color: var(--accent); }
.opt.is-wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.opt.is-wrong .opt-letter { background: var(--danger); color: #fff; border-color: var(--danger); }
.opt.is-wrong .opt-mark { opacity: 1; color: var(--danger); }
.opt.is-locked { cursor: default; }
.opt.is-locked:hover { transform: none; }

.q-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; flex-wrap: wrap; }
.q-actions .spacer { flex: 1; }

.explain {
  margin-top: 22px; padding: 18px 20px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2);
  animation: slideDown var(--t-slow);
}
.explain-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 14px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-mute); margin-bottom: 10px;
}
.explain-head::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.explain-body { font-size: 14.5px; color: var(--text-soft); line-height: 1.6; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Confidence selector ---------- */
.conf-bar {
  display: flex; gap: 6px; font-size: 12px;
  color: var(--text-mute);
}
.conf-btn {
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 12px; cursor: pointer;
  transition: all var(--t-fast);
}
.conf-btn:hover { color: var(--text); }
.conf-btn.is-active { color: var(--accent); border-color: var(--accent); }

/* ---------- Results page ---------- */
.results-hero {
  text-align: center; padding: 48px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 32px;
}
.score-ring {
  position: relative; width: 200px; height: 200px; margin: 0 auto 24px;
}
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--surface-2); }
.score-ring .ring-fg {
  stroke: var(--accent);
  stroke-dasharray: 565.48;
  stroke-dashoffset: 565.48;
  transition: stroke-dashoffset 1.2s cubic-bezier(.2,.7,.3,1);
}
.score-ring .ring-pct {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 3rem; font-weight: 400;
}

.result-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px;
  margin-bottom: 32px;
}
.result-stat .num { font-family: var(--font-display); font-size: 2rem; font-weight: 500; }
.result-stat .lbl { color: var(--text-mute); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }

.result-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: 0; }
.result-row .idx {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-mute);
}
.result-row.ok .idx { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); color: var(--accent); }
.result-row.bad .idx { background: color-mix(in srgb, var(--danger) 15%, transparent); border-color: var(--danger); color: var(--danger); }
.result-row .qtxt { font-size: 14px; color: var(--text); }
.result-row .qmeta { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* ---------- Analytics charts ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-card { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat-card .lbl { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.1em; }
.stat-card .num { font-family: var(--font-display); font-size: 2.4rem; font-weight: 400; margin: 8px 0 4px; }
.stat-card .delta { font-size: 12px; color: var(--text-soft); }
.stat-card .delta.up { color: var(--accent); }
.stat-card .delta.down { color: var(--danger); }

.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 70px; gap: 12px; align-items: center; }
.bar-row .name { font-size: 13.5px; }
.bar-row .num  { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-mute); text-align: right; }
.bar-track {
  height: 8px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; position: relative;
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  border-radius: 999px; transition: width var(--t-slow);
}

/* ---------- Heatmap ---------- */
.heatmap { display: flex; gap: 3px; flex-wrap: wrap; }
.hm-cell {
  width: 14px; height: 14px; border-radius: 3px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.hm-cell[data-lvl="1"] { background: color-mix(in srgb, var(--accent) 20%, var(--surface-2)); }
.hm-cell[data-lvl="2"] { background: color-mix(in srgb, var(--accent) 40%, var(--surface-2)); }
.hm-cell[data-lvl="3"] { background: color-mix(in srgb, var(--accent) 65%, var(--surface-2)); }
.hm-cell[data-lvl="4"] { background: var(--accent); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 60px 20px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--text-soft);
}
.empty h3 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 8px; color: var(--text); }
.empty p  { color: var(--text-mute); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 18px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 13.5px;
  box-shadow: var(--shadow-2);
  animation: toastIn var(--t-med);
  pointer-events: auto;
}
.toast.ok { border-color: var(--accent); }
.toast.err { border-color: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 80px; padding: 32px 0;
  color: var(--text-mute); font-size: 12.5px;
}
.footer-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.footer-brand { display: flex; align-items: baseline; gap: 12px; }
.footer-tag { font-style: italic; }
.footer-meta { display: flex; gap: 10px; }
.footer-meta .dot { opacity: 0.5; }

/* ---------- Utility ---------- */
.muted { color: var(--text-mute); }
.soft  { color: var(--text-soft); }
.center-text { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.gap-sm { gap: 8px; } .gap-md { gap: 14px; } .gap-lg { gap: 22px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 22px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 14px; } .mb-3 { margin-bottom: 22px; } .mb-4 { margin-bottom: 32px; }
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .nav-primary { display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    background: var(--bg-elev); border-bottom: 1px solid var(--border);
    padding: 12px var(--gutter); gap: 4px; }
  .nav-primary.is-open { display: flex; }
  .nav-toggle { display: grid; }
  .search-mini { min-width: 0; flex: 1; }
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .brand-sub { display: none; }
}

@media (max-width: 600px) {
  .topbar-actions kbd { display: none; }
  .search-mini { display: none; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .hero-stat .num { font-size: 1.5rem; }
  .result-row { grid-template-columns: auto 1fr; }
  .result-row .right { grid-column: 1 / -1; }
}

/* Reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(8px); transition: opacity 600ms, transform 600ms; }
.reveal.in { opacity: 1; transform: none; }

/* ============================================================
   NEW FEATURES — v2 upgrade
   ============================================================ */

/* ---- Page transition ---- */
.page-enter { animation: pageFadeIn 0.35s ease both; }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Glassmorphism cards ---- */
.glass-card {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid color-mix(in srgb, var(--border-strong) 60%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--t-med), box-shadow var(--t-med);
}
.glass-card:hover {
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow-2);
}

/* ---- Mobile bottom nav ---- */
.has-bottom-nav { padding-bottom: 68px; }
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  padding: 6px 4px env(safe-area-inset-bottom, 0);
  justify-content: space-around; align-items: stretch;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: 1; padding: 6px 4px; color: var(--text-mute);
  text-decoration: none; font-size: 10px; font-weight: 500;
  transition: color var(--t-fast), transform var(--t-fast);
  border-radius: var(--radius-sm); min-height: 48px;
}
.bottom-nav-item.is-active { color: var(--accent); }
.bottom-nav-item.is-active svg { filter: drop-shadow(0 0 6px var(--accent-glow)); }
.bottom-nav-item:active { transform: scale(0.92); }
@media (max-width: 768px) {
  .bottom-nav { display: flex; }
  .has-bottom-nav { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0)); }
}

/* ---- XP Strip in topbar ---- */
.xp-strip { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter) 6px; }
.xp-bar {
  display: flex; align-items: center; gap: 10px;
}
.xp-bar-track {
  flex: 1; height: 5px; border-radius: var(--radius-pill);
  background: var(--surface-2); overflow: hidden;
}
.xp-bar-fill {
  height: 100%; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transition: width 0.7s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.xp-bar-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: shimmer 2s infinite; border-radius: inherit;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(200%); } }
.xp-bar-label { font-size: 11px; color: var(--text-mute); white-space: nowrap; }
.xp-level-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: var(--radius-pill); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  white-space: nowrap;
}
.xp-card { display: flex; flex-direction: column; gap: 10px; }
.xp-card-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-soft); font-size: 13px; }
.xp-level-display { display: flex; align-items: baseline; gap: 8px; }
.xp-level-num { font-family: var(--font-display); font-size: 3rem; font-weight: 600; color: var(--accent); line-height: 1; }
.xp-level-label { color: var(--text-soft); font-size: 14px; }

/* ---- Badge system ---- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 32px; }
.badge-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 10px; text-align: center;
  transition: transform var(--t-fast), box-shadow var(--t-med), border-color var(--t-med);
  cursor: default;
}
.badge-chip:not(.badge-locked) {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.badge-chip:not(.badge-locked):hover {
  transform: translateY(-3px); box-shadow: var(--shadow-glow);
}
.badge-chip.badge-locked { opacity: 0.45; filter: grayscale(0.6); }
.badge-chip-icon { font-size: 2rem; margin-bottom: 6px; }
.badge-chip-label { font-size: 12px; font-weight: 600; line-height: 1.2; }
.badge-chip-xp { font-size: 11px; color: var(--accent); margin-top: 4px; }
.badge-chip.badge-locked .badge-chip-xp { color: var(--text-mute); }

/* Badge unlock overlay */
.badge-unlock-overlay, .levelup-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: overlayIn 0.25s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.badge-unlock-modal, .levelup-modal {
  max-width: 360px; width: 100%; text-align: center;
  padding: 40px 28px; animation: modalPop 0.35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalPop { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }
.badge-unlock-icon { font-size: 4rem; margin-bottom: 14px; animation: badgeSpin 0.5s cubic-bezier(.34,1.56,.64,1); }
@keyframes badgeSpin { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1) rotate(0); } }
.badge-unlock-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.badge-unlock-name { font-family: var(--font-display); font-size: 1.6rem; font-weight: 500; margin-bottom: 6px; }
.badge-unlock-desc { color: var(--text-soft); font-size: 14px; margin-bottom: 10px; }
.badge-unlock-xp { color: var(--accent); font-weight: 700; font-size: 18px; margin-bottom: 20px; }
.levelup-icon { font-size: 4rem; margin-bottom: 12px; }
.levelup-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 700; }
.levelup-level { font-family: var(--font-display); font-size: 2.5rem; font-weight: 600; color: var(--accent); }
.levelup-desc { color: var(--text-soft); font-size: 14px; margin: 10px 0 20px; }

/* ---- Confetti ---- */
.confetti-piece {
  position: fixed; top: -10px; width: 10px; height: 10px;
  border-radius: 2px; z-index: 99999; pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotateZ(0) rotateX(0); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(100vh) rotateZ(720deg) rotateX(360deg); opacity: 0; }
}

/* ---- Skeleton loaders ---- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: skel 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes skel { to { background-position: -200% 0; } }
.skeleton-text  { height: 14px; border-radius: 4px; }
.skeleton-card  { height: 100px; border-radius: var(--radius); }
.skeleton-option{ height: 52px; border-radius: 10px; }

/* ---- Shortcut overlay ---- */
.shortcut-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.shortcut-overlay[hidden] { display: none; }
.shortcut-modal {
  max-width: 540px; width: 100%; max-height: 80vh; overflow-y: auto;
}
.shortcut-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; }
.shortcut-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; margin-bottom: 10px; }
.shortcut-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 13px; flex-wrap: wrap; }
.shortcut-row span { color: var(--text-soft); }

/* ---- Dashboard top row ---- */
.dashboard-top-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 32px; }

/* ---- Exam Countdown ---- */
.exam-countdown { display: flex; flex-direction: column; gap: 14px; }
.exam-countdown-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-soft); font-size: 13px; }
.countdown-numbers { text-align: center; }
.countdown-big { font-family: var(--font-display); font-size: 3.5rem; font-weight: 600; line-height: 1; color: var(--accent); }
.countdown-label { color: var(--text-soft); font-size: 13px; margin-top: 4px; }
.countdown-bar-wrap { margin-top: 10px; }
.countdown-bar { height: 6px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: 8px; }
.countdown-bar-fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.8s ease; }
.countdown-bar-labels { display: flex; justify-content: space-between; align-items: center; }

/* ---- Daily Challenge Card ---- */
.daily-challenge {
  position: relative; overflow: hidden;
  border-top: 2px solid var(--warn);
}
.daily-challenge-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.daily-fire { font-size: 20px; animation: fireFloat 2s ease-in-out infinite; }
@keyframes fireFloat { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* ---- Weak Topics Alert ---- */
.weak-alert {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 6%, var(--surface));
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 28px;
}
.weak-alert-head { display: flex; align-items: center; gap: 10px; color: var(--warn); margin-bottom: 14px; }
.weak-topics-list { display: flex; flex-direction: column; gap: 8px; }
.weak-topic-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; }
.weak-topic-info { min-width: 0; }
.weak-topic-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weak-topic-sub  { font-size: 11.5px; color: var(--text-mute); }
.weak-topic-bar  { width: 80px; height: 5px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.weak-bar-fill   { height: 100%; border-radius: inherit; transition: width 0.5s ease; }
.weak-topic-pct  { font-size: 12px; font-weight: 700; min-width: 36px; text-align: right; }
.weak-drill-btn  { white-space: nowrap; }
.weak-topics-block .weak-topic-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.weak-topics-block .weak-topic-row:last-child { border-bottom: none; }

/* ---- Mode tiles ---- */
.mode-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; }
.mode-tile {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer; transition: all var(--t-med);
  display: block;
}
.mode-tile:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--accent-glow), var(--shadow-2);
}
.mode-tile:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  box-shadow: 0 0 0 1px var(--accent-glow);
}
.mode-tile input[type="radio"], .mode-tile input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.mode-tile-icon { font-size: 1.6rem; margin-bottom: 10px; }
.mode-tile h4 { font-size: 15px; margin-bottom: 6px; }
.mode-tile p { font-size: 13px; color: var(--text-soft); margin: 0; line-height: 1.5; }

/* ---- Subject cards (enhanced) ---- */
.subjects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 40px; }
.subj-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; text-decoration: none; color: inherit; display: block;
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med);
  position: relative; overflow: hidden;
}
.subj-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--c, var(--accent)); opacity: 0; transition: opacity var(--t-med);
}
.subj-card:hover { transform: translateY(-3px); border-color: var(--c, var(--accent)); box-shadow: var(--shadow-2); }
.subj-card:hover::before { opacity: 1; }
.subj-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.subj-badge {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c, var(--accent)) 15%, transparent);
  color: var(--c, var(--accent)); font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.subj-count { font-size: 12px; color: var(--text-mute); font-family: var(--font-mono); }
.subj-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.subj-meta { font-size: 11.5px; color: var(--text-mute); display: flex; gap: 4px; margin-bottom: 10px; }
.subj-accuracy-bar { height: 3px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: 10px; }
.subj-accuracy-fill { height: 100%; background: var(--c, var(--accent)); border-radius: inherit; transition: width 0.8s ease; }
.subj-go { font-size: 12.5px; color: var(--c, var(--accent)); display: flex; align-items: center; gap: 4px; font-weight: 600; opacity: 0; transition: opacity var(--t-fast); }
.subj-card:hover .subj-go { opacity: 1; }

/* ---- Mock Exam ---- */
.mock-header {
  position: sticky; top: 0; z-index: 500; background: var(--bg-elev);
  border-bottom: 1px solid var(--border); padding: 0;
}
.mock-header-inner {
  display: flex; align-items: center; gap: 16px; padding: 12px var(--gutter); flex-wrap: wrap;
}
.mock-header-left { display: flex; align-items: center; gap: 10px; }
.mock-timer-wrap { display: flex; align-items: center; gap: 6px; background: var(--surface); border-radius: var(--radius-pill); padding: 6px 14px; }
.mock-timer { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 600; color: var(--accent); transition: color 0.3s; }
.mock-timer.warn { color: var(--warn); }
.mock-timer.danger { color: var(--danger); animation: timerPulse 0.5s ease infinite alternate; }
@keyframes timerPulse { from { opacity: 1; } to { opacity: 0.6; } }
.mock-header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.mock-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; min-height: 50vh; }
.mock-sidebar {
  position: sticky; top: 70px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; max-height: calc(100vh - 100px); overflow-y: auto;
}
.mock-sidebar-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); margin-bottom: 12px; }
.qnum-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 14px; }
.qnum-btn {
  aspect-ratio: 1; border: none; border-radius: 6px; background: var(--surface-2);
  color: var(--text-soft); font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast); display: flex; align-items: center; justify-content: center;
}
.qnum-btn.is-answered { background: color-mix(in srgb, var(--accent) 20%, var(--surface-2)); color: var(--accent); }
.qnum-btn.is-flagged  { background: color-mix(in srgb, var(--warn) 20%, var(--surface-2)); color: var(--warn); }
.qnum-btn.is-current  { outline: 2px solid var(--accent); outline-offset: 1px; }
.qnum-btn:hover       { transform: scale(1.08); }
.mock-sidebar-legend  { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.legend-item  { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-mute); }
.legend-dot   { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.mock-main    { min-width: 0; padding: 24px 0; }
.mock-sidebar-toggle {
  display: none; position: fixed; bottom: 76px; right: 16px; z-index: 400;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-pill);
  padding: 10px 16px; cursor: pointer; gap: 8px; align-items: center; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.q-number-badge {
  display: inline-flex; background: var(--surface-2); border-radius: var(--radius-pill);
  padding: 4px 12px; font-size: 12px; color: var(--text-mute); margin-bottom: 12px;
}
.opt-picked { border-color: var(--accent) !important; background: color-mix(in srgb, var(--accent) 8%, var(--surface)) !important; }
@media (max-width: 768px) {
  .mock-layout { grid-template-columns: 1fr; }
  .mock-sidebar { position: fixed; left: 0; bottom: 68px; right: 0; top: auto; border-radius: var(--radius) var(--radius) 0 0; max-height: 60vh; transform: translateY(100%); transition: transform 0.35s ease; z-index: 700; }
  .mock-sidebar.is-open { transform: none; }
  .mock-sidebar-toggle { display: flex; }
}

/* ---- Flashcards ---- */
.fc-wrapper { max-width: 600px; margin: 0 auto; }
.fc-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 10px; }
.fc-counter { font-family: var(--font-mono); font-size: 14px; color: var(--text-mute); }
.fc-known-count { font-size: 13px; }
.flashcard-scene {
  perspective: 1200px; cursor: pointer; margin-bottom: 20px;
  min-height: 320px; position: relative;
}
.flashcard {
  width: 100%; min-height: 320px; position: relative;
  transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(.4,0,.2,1);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
}
.flashcard.is-flipped { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg); padding: 32px 28px;
  display: flex; flex-direction: column; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
}
.flashcard-back { transform: rotateY(180deg); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.fc-subject-tag { font-size: 12px; color: var(--text-mute); margin-bottom: 18px; font-weight: 600; }
.fc-question { font-size: 1.1rem; font-family: var(--font-display); line-height: 1.5; font-weight: 400; }
.fc-tap-hint { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-mute); margin-top: auto; padding-top: 20px; }
.fc-answer-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; margin-bottom: 10px; }
.fc-answer { font-size: 1.15rem; font-weight: 600; color: var(--accent); margin-bottom: 12px; }
.fc-explanation { font-size: 13px; color: var(--text-soft); line-height: 1.6; }
.fc-diagram { max-width: 100%; border-radius: var(--radius-sm); margin-top: 12px; }
.fc-swipe-hints { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-mute); margin-bottom: 16px; }
.fc-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; margin-bottom: 20px; }
.fc-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: all var(--t-fast); font-family: var(--font-body); color: var(--text);
}
.fc-btn:hover { transform: translateY(-2px); }
.fc-known   { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.fc-known:hover { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); box-shadow: 0 4px 14px -2px var(--accent-glow); }
.fc-unknown { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.fc-unknown:hover { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.fc-flip-btn { background: var(--surface-2); border-color: var(--border); font-size: 13px; }
.fc-progress-wrap { }
.fc-progress-bar { height: 4px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: 6px; }
.fc-progress-fill { height: 100%; background: var(--accent); transition: width 0.5s ease; border-radius: inherit; }
.fc-progress-text { font-size: 12px; color: var(--text-mute); text-align: center; }
.fc-summary { max-width: 380px; margin: 40px auto; text-align: center; padding: 40px 28px; }
.fc-summary-icon { font-size: 3.5rem; margin-bottom: 14px; }
.fc-summary-title { font-family: var(--font-display); font-size: 1.8rem; margin-bottom: 20px; }
.fc-summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.fc-stat-num { font-family: var(--font-display); font-size: 2rem; font-weight: 600; }
.fc-stat-lbl { font-size: 12px; color: var(--text-mute); }

/* ---- Search Page ---- */
.search-hero { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; margin: 20px 0; border: 1px solid var(--border); }
.search-hero-form { display: flex; flex-direction: column; gap: 14px; }
.search-hero-input-wrap { position: relative; display: flex; align-items: center; }
.search-hero-icon { position: absolute; left: 16px; color: var(--text-mute); pointer-events: none; }
.search-hero-input {
  width: 100%; padding: 14px 50px; font-size: 1.1rem; font-family: var(--font-body);
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius);
  color: var(--text); outline: none; transition: border-color var(--t-med), box-shadow var(--t-med);
}
.search-hero-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-clear-btn {
  position: absolute; right: 14px; background: none; border: none; cursor: pointer;
  color: var(--text-mute); display: flex; align-items: center; padding: 4px;
  border-radius: 50%; transition: color var(--t-fast);
}
.search-clear-btn:hover { color: var(--text); }
.search-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.filter-pill {
  flex-shrink: 0; padding: 6px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-mute);
  font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all var(--t-fast);
  font-family: var(--font-body);
}
.filter-pill:hover, .filter-pill.is-active {
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.search-result-item { margin-bottom: 12px; }
.search-result-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.search-result-question { font-size: 15px; font-weight: 500; margin-bottom: 6px; line-height: 1.5; }
.search-result-answer { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.search-result-explain { font-size: 12.5px; color: var(--text-mute); line-height: 1.6; margin-bottom: 10px; }
.search-result-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); }
.highlight { background: color-mix(in srgb, var(--highlight) 50%, transparent); color: var(--text); border-radius: 3px; padding: 0 2px; }
[data-theme="light"] .highlight { background: color-mix(in srgb, var(--warn) 25%, transparent); }

/* ---- Enhanced Quiz ---- */
.confidence-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conf-label { font-size: 13px; color: var(--text-mute); }
.conf-btn {
  padding: 7px 14px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-soft); cursor: pointer; font-size: 13px;
  font-family: var(--font-body); transition: all var(--t-fast); font-weight: 500;
}
.conf-btn:hover { border-color: var(--accent); color: var(--text); }
.conf-btn.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); }
.note-panel { background: var(--surface-2); border-radius: var(--radius); padding: 14px; margin-top: 16px; }
.note-panel-head { font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.note-textarea {
  width: 100%; min-height: 80px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; color: var(--text); font-family: var(--font-body);
  font-size: 13.5px; line-height: 1.6; resize: vertical; outline: none; transition: border-color var(--t-med);
}
.note-textarea:focus { border-color: var(--accent); }
.wrong-option-note {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface));
  font-size: 13.5px; color: var(--text-soft); line-height: 1.6;
}
.skip-badge { font-size: 11px; color: var(--text-mute); padding: 2px 8px; border-radius: var(--radius-pill); background: var(--surface-2); margin-left: 8px; }
.timer-tag { font-family: var(--font-mono); font-size: 13px; padding: 4px 12px; }
.kbd-hints { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }

/* Option animations */
.options.animate-in .opt { animation: optSlideIn 0.25s ease both; }
@keyframes optSlideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.opt.pulse-correct { animation: pulseCorrect 0.6s ease; }
@keyframes pulseCorrect { 0% { box-shadow: 0 0 0 0 var(--accent-glow); } 50% { box-shadow: 0 0 0 8px var(--accent-glow); transform: scale(1.01); } 100% { box-shadow: 0 0 0 0 transparent; } }
.opt.shake { animation: shake 0.55s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 0%,100% { transform: none; } 10%,50%,90% { transform: translateX(-6px); } 30%,70% { transform: translateX(6px); } }

/* ---- Results enhancements ---- */
.xp-earned-banner {
  display: inline-flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius-pill); padding: 7px 18px; margin-top: 12px;
  font-weight: 700; color: var(--accent); font-size: 15px;
}
.result-row.expandable { cursor: pointer; }
.result-row.expandable .qtxt { cursor: pointer; }
.is-correct-opt { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.is-wrong-opt   { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---- Topbar brand sub on mobile ---- */
.brand-sub { font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); line-height: 1; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark { color: var(--accent); }

/* ---- Footer links ---- */
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-link { color: var(--text-mute); font-size: 12px; transition: color var(--t-fast); }
.footer-link:hover { color: var(--accent); }

/* ---- Analytics chart ---- */
.chart-container { width: 100%; overflow: hidden; }
.chart-container canvas { display: block; }

/* ---- Stat card highlight (predicted score) ---- */
.stat-card .num.accent { color: var(--accent); }

/* ---- Quiz result: option tags in expand ---- */
.explain .mt-2 .tag { margin: 3px; display: inline-flex; }
.tag.is-correct-opt { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); }
.tag.is-wrong-opt   { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger); }

/* ---- Scrollbar (Chrome/Edge) ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ---- Toast improvements ---- */
.toast { font-size: 14px; font-weight: 500; }

/* ---- Meta strip level pill ---- */
#levelPill { cursor: default; }
#levelNum { color: var(--warn); font-weight: 700; }

/* ---- Hero stats ---- */
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.hero-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 12px; text-align: center; }
.hero-stat .num { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; margin-bottom: 2px; }
.hero-stat .lbl { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.07em; }
@media (max-width: 600px) { .hero-stats { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   LANDING PAGE & REVIEWS
   ============================================================ */
.landing-page {
  padding-bottom: 0 !important;
  background-image: 
    radial-gradient(at 0% 0%, rgba(251,191,36,0.12) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(96,165,250,0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(245,158,11,0.08) 0px, transparent 50%);
}
[data-theme="light"] .landing-page {
  background-image: 
    radial-gradient(at 0% 0%, rgba(217,119,6,0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(29,78,216,0.05) 0px, transparent 50%);
}

.landing-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 100px var(--gutter) 40px;
}

.hero-content {
  text-align: center;
  max-width: 800px;
  margin: 0 auto 80px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  line-height: 1.1;
  font-weight: 500;
  margin-bottom: 24px;
}
.hero-title span {
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 600;
  font-style: italic;
}

.hero-subtitle {
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  color: var(--text-soft);
  max-width: 650px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

.hero-cta {
  justify-content: center;
  flex-wrap: wrap;
}

.section-container {
  padding: 80px 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.feature-card {
  padding: 32px 28px;
  text-align: center;
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  display: inline-block;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.3);
}

.feature-card h3 {
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.review-card {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
}

.review-stars {
  color: #f59e0b;
  font-size: 1.2rem;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.review-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  font-style: italic;
  flex-grow: 1;
  margin-bottom: 24px;
}

.review-author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  display: grid;
  place-items: center;
  color: #000;
  font-weight: 700;
  font-size: 14px;
}

.author-info {
  display: flex;
  flex-direction: column;
}

.author-info strong {
  font-size: 14px;
}

.author-info span {
  font-size: 12px;
  color: var(--text-mute);
}

/* ============================================================
   SUBJECT CARDS WITH AI IMAGES
   ============================================================ */
.subj-card {
  background-size: cover;
  background-position: center;
  background-repeat: no-resize;
  position: relative;
  z-index: 1;
}

.subj-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--surface) 30%, color-mix(in srgb, var(--surface) 70%, transparent) 100%);
  z-index: -1;
  transition: opacity var(--t-med);
  border-radius: inherit;
}
.subj-card:hover::before {
  background: linear-gradient(to top, var(--surface) 10%, color-mix(in srgb, var(--surface) 50%, transparent) 100%);
}

.subj-name, .subj-count, .subj-meta, .subj-badge {
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* ============================================================
   MOBILE POLISH
   ============================================================ */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

@media (max-width: 600px) {
  .hero-title {
    font-size: 2.2rem;
  }
  .hero-subtitle {
    font-size: 1.05rem;
  }
  .feature-grid, .review-grid {
    grid-template-columns: 1fr;
  }
  .glass-card {
    padding: 24px 20px;
  }
  .bottom-nav-item {
    padding: 8px 4px;
  }
  .q-stem {
    font-size: 1.25rem;
  }
  .badge-unlock-modal, .levelup-modal {
    padding: 30px 20px;
    width: 95%;
  }
}

/* ============================================================
   IMAGE CAROUSEL (LANDING)
   ============================================================ */
.ad-carousel-section {
  padding: 40px 0 80px;
  overflow: hidden;
}
.ad-carousel-wrap {
  display: flex;
  gap: 24px;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.ad-carousel-wrap::-webkit-scrollbar {
  display: none;
}
.ad-banner {
  flex: 0 0 85%;
  max-width: 900px;
  height: 400px;
  border-radius: var(--radius-lg);
  background-size: cover;
  background-position: center;
  position: relative;
  scroll-snap-align: center;
  box-shadow: var(--shadow-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.ad-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10,14,14,0.8) 0%, transparent 60%);
}
.ad-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px;
  z-index: 2;
}
.ad-tag {
  display: inline-block;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #000;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}
.ad-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 500;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
@media (max-width: 600px) {
  .ad-banner {
    flex: 0 0 92%;
    height: 300px;
  }
  .ad-content {
    padding: 24px;
  }
}
