/* CCA-F Exam Prep — Professional SaaS UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800&display=swap');

:root {
  --sidebar-bg: #0c1222;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f8fafc;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(99, 102, 241, 0.15);
  --bg: #f4f6fa;
  --bg-subtle: #eef1f6;
  --surface: #ffffff;
  --surface-hover: #fafbfc;
  --border: #e4e8ef;
  --border-strong: #d1d8e3;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: #eef2ff;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent: #0ea5e9;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --green-border: #a7f3d0;
  --orange: #f59e0b;
  --orange-soft: #fffbeb;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --red-border: #fecaca;
  --d1: #3b82f6; --d2: #f97316; --d3: #8b5cf6; --d4: #10b981; --d5: #ec4899;
  --s1: #3b82f6; --s2: #8b5cf6; --s3: #06b6d4; --s4: #eab308; --s5: #f97316; --s6: #10b981;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.1);
  --sidebar-w: 252px;
  --topbar-h: 56px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'SF Mono', ui-monospace, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.ambient { display: none; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.main-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 20px 12px;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 10px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 16px;
}
.brand-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}
.brand-text { font-size: 14px; font-weight: 700; color: #f1f5f9; line-height: 1.25; }
.brand-sub { font-size: 11px; color: #64748b; font-weight: 500; margin-top: 2px; }

.nav-section { flex: 1; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: #475569;
  padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--sidebar-text);
  cursor: pointer; transition: all 0.15s;
  border: none; margin-bottom: 2px;
  background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.nav-item.active {
  background: var(--sidebar-active);
  color: #e0e7ff;
}
.nav-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: inherit;
}
.nav-icon svg { width: 18px; height: 18px; }
.nav-item.active .nav-icon { color: #a5b4fc; }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 100px;
  background: rgba(255,255,255,0.06); color: #64748b;
}
.nav-item.active .nav-badge { background: rgba(99,102,241,0.25); color: #c7d2fe; }

.sidebar-progress {
  margin-top: auto; padding: 14px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  border: 1px solid var(--sidebar-border);
}
.progress-ring-label { font-size: 11px; color: #94a3b8; margin-bottom: 8px; font-weight: 500; line-height: 1.4; }
.progress-bar-track { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
.progress-bar-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  transition: width 0.5s ease;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); }
.topbar-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Main ── */
.main {
  flex: 1;
  padding: 28px 28px 80px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}
.main.wide { max-width: 1280px; }
.view { display: none; animation: fadeUp 0.25s ease; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Hero ── */
.hero {
  position: relative;
  border-radius: var(--radius-xl);
  padding: 36px 36px 32px;
  margin-bottom: 24px;
  overflow: hidden;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #4338ca 100%);
  color: white;
  box-shadow: var(--shadow-lg);
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 85% 15%, rgba(129, 140, 248, 0.4), transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(14, 165, 233, 0.2), transparent 40%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; max-width: 560px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 5px 11px; border-radius: 100px;
  margin-bottom: 16px;
  color: #e0e7ff;
}
.hero-title {
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 800; letter-spacing: -0.03em;
  line-height: 1.1; margin-bottom: 12px;
}
.hero-desc {
  font-size: 15px; line-height: 1.65;
  color: rgba(255,255,255,0.78); margin-bottom: 22px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-hero {
  padding: 11px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: var(--font);
  cursor: pointer; border: none;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.15s;
}
.btn-hero-primary {
  background: white; color: #312e81;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.btn-hero-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.btn-hero-secondary {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}
.btn-hero-secondary:hover { background: rgba(255,255,255,0.16); }
.btn-hero svg { width: 16px; height: 16px; }

.trust-row { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 22px; }
.trust-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.65);
}
.trust-item svg { color: #6ee7b7; flex-shrink: 0; }

.page-header { margin-bottom: 24px; }
.page-title {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.2; margin-bottom: 6px;
}
.page-desc { font-size: 14px; color: var(--text-secondary); max-width: 540px; line-height: 1.6; }

.section-heading {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

/* ── Dashboard insights (replaces generic stat cards) ── */
.insight-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
.insight-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}
.insight-featured {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.insight-featured:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow);
}
.insight-featured-top {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.insight-step-badge {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.insight-step-badge svg { width: 26px; height: 26px; }
.insight-eyebrow {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--primary); margin-bottom: 4px;
}
.insight-title {
  font-size: 17px; font-weight: 700;
  color: var(--text); line-height: 1.3;
  letter-spacing: -0.02em; margin-bottom: 6px;
}
.insight-desc {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.55; margin: 0 0 8px;
}
.insight-meta-row {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.insight-path-bar {
  height: 5px; background: var(--bg-subtle);
  border-radius: 3px; overflow: hidden;
}
.insight-path-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 3px; transition: width 0.4s ease;
}
.insight-cta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--primary);
}
.insight-cta svg { width: 14px; height: 14px; }
.insight-panel-head {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 14px;
}
.insight-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.insight-icon svg { width: 20px; height: 20px; }
.insight-panel-title { font-size: 14px; font-weight: 600; color: var(--text); }
.insight-panel-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.insight-stat-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.insight-big { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.insight-unit { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.insight-pct-ring {
  width: 48px; height: 48px; border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--bg-subtle) 0);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.insight-pct-ring::before {
  content: ''; position: absolute; inset: 5px;
  background: var(--surface); border-radius: 50%;
}
.insight-pct-ring span {
  position: relative; font-size: 11px; font-weight: 700; color: var(--green);
}
.insight-foot { font-size: 12px; color: var(--text-secondary); margin: 0 0 12px; line-height: 1.5; }
.insight-actions { display: flex; gap: 8px; }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.insight-facts {
  list-style: none; margin: 0 0 12px; padding: 0;
  font-size: 13px; color: var(--text-secondary); line-height: 1.8;
}
.insight-facts li::before {
  content: '→'; color: var(--primary); margin-right: 8px; font-weight: 600;
}
.insight-link {
  background: none; border: none; padding: 0;
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--primary); cursor: pointer;
}

/* ── Stats (legacy) ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; gap: 12px;
}
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ── Action cards ── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-bottom: 28px;
}
.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column;
  min-height: 160px;
}
.mode-card:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.mode-card-featured {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #fafafe 0%, var(--surface) 100%);
}
.mode-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.mode-icon svg { width: 20px; height: 20px; }
.mode-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.mode-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.55; flex: 1; }
.mode-cta {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 14px; font-size: 12px; font-weight: 600; color: var(--primary);
}
.mode-cta svg { width: 14px; height: 14px; }

/* ── Study path ── */
.path-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.path-intro {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 520px;
}
.path-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
.hero-secondary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
}
.hero-secondary button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.hero-secondary button:hover { color: #fff; }
.hero-sep { color: rgba(255,255,255,0.45); }

.curriculum-path {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}
.path-step {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--step-accent, var(--border));
  border-radius: var(--radius);
  cursor: pointer; text-align: left;
  transition: all 0.15s;
  font-family: var(--font);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  width: 100%;
}
.path-step:hover { border-color: #c7d2fe; box-shadow: var(--shadow-sm); }
.path-step.current {
  border-left-color: var(--step-accent, var(--primary));
  background: linear-gradient(90deg, color-mix(in srgb, var(--step-accent, var(--primary)) 6%, var(--surface)) 0%, var(--surface) 40%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--step-accent, var(--primary)) 25%, transparent);
}
.path-step.done { opacity: 0.82; }
.path-step.done .path-icon {
  background: #ecfdf5 !important;
  color: var(--green) !important;
}
.path-icon {
  width: 44px; height: 44px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-weight: 700; font-size: 14px;
}
.path-icon svg { width: 22px; height: 22px; }
.path-body { flex: 1; min-width: 0; }
.path-title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.path-step-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--step-accent, var(--primary));
}
.path-title { font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--text); }
.path-meta {
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.45; margin-bottom: 2px;
}
.path-time { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.path-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Filters ── */
.filter-panel {
  padding: 16px 18px;
  margin-bottom: 20px;
}
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 7px;
  align-items: center;
}
.filter-label { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-right: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.chip {
  padding: 5px 11px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-subtle); color: var(--text-secondary);
  cursor: pointer; transition: all 0.12s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.chip.active { color: white; border-color: transparent; }
.chip-all.active { background: var(--primary); }
.chip-s1.active { background: var(--s1); }
.chip-s2.active { background: var(--s2); }
.chip-s3.active { background: var(--s3); }
.chip-s4.active { background: var(--s4); }
.chip-s5.active { background: var(--s5); }
.chip-s6.active { background: var(--s6); }
.chip-d1.active { background: var(--d1); }
.chip-d2.active { background: var(--d2); }
.chip-d3.active { background: var(--d3); }
.chip-d4.active { background: var(--d4); }
.chip-d5.active { background: var(--d5); }

/* ── Quiz ── */
.quiz-shell { max-width: 720px; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.quiz-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 500;
  padding: 3px 9px; border-radius: 5px;
  border: 1px solid; background: var(--surface);
}
.quiz-progress { height: 3px; background: var(--border); border-radius: 2px; margin-bottom: 20px; overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.4s ease; }

.stem-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.stem-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.stem-text { font-size: 14px; line-height: 1.7; color: var(--text); }
.question-prompt { font-size: 15px; font-weight: 600; margin-bottom: 14px; line-height: 1.5; }

.kill-hint {
  background: #fff5f5;
  border: 1px solid var(--red-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 14px;
  font-size: 13px; display: none;
  color: var(--text-secondary); line-height: 1.55;
}
.kill-hint.show { display: block; }
.kill-hint strong { color: var(--red); display: block; margin-bottom: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

.options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.option {
  display: grid; grid-template-columns: 32px 1fr;
  gap: 12px; align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  cursor: pointer; text-align: left;
  font-size: 13px; line-height: 1.55; color: var(--text);
  transition: all 0.12s;
}
.option:hover:not(:disabled) { border-color: #c7d2fe; background: var(--primary-soft); }
.option:disabled { cursor: default; }
.option-letter {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
}
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.correct .option-letter { background: var(--green); border-color: var(--green); color: white; }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option.wrong .option-letter { background: var(--red); border-color: var(--red); color: white; }
.option.dimmed { opacity: 0.45; }

.feedback-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
  animation: fadeUp 0.25s ease;
}
.feedback-panel.show { display: block; }
.feedback-correct { font-size: 13px; font-weight: 600; color: var(--green); margin-bottom: 8px; }
.feedback-wrong { font-size: 13px; font-weight: 600; color: var(--red); margin-bottom: 8px; }
.feedback-body { font-size: 13px; line-height: 1.65; margin-bottom: 12px; color: var(--text-secondary); }
.distractor-list { display: flex; flex-direction: column; gap: 6px; }
.distractor-row {
  font-size: 12px; color: var(--text-secondary);
  padding: 9px 11px 9px 28px; position: relative; line-height: 1.5;
  background: var(--bg-subtle); border-radius: var(--radius-sm);
}
.distractor-row::before { content: '✗'; position: absolute; left: 10px; top: 9px; color: var(--red); font-weight: 700; font-size: 11px; }
.anchor-pill {
  margin-top: 12px; padding: 11px 13px;
  background: var(--primary-soft);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; color: var(--primary-hover);
}

/* ── Buttons ── */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; border: none;
  transition: all 0.12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 3px var(--primary-glow); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 8px 13px; font-size: 12px; }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }

.toggle-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-secondary);
  margin-bottom: 14px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--border-strong); position: relative;
  cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.toggle.on::after { transform: translateX(18px); }

/* ── Flashcards ── */
.flashcard-wrap { perspective: 1200px; margin: 20px auto; max-width: 520px; }
.flashcard {
  min-height: 260px; position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute; width: 100%; min-height: 260px;
  backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  box-shadow: var(--shadow);
}
.card-back { transform: rotateY(180deg); }
.card-tag { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 14px; }
.card-front-text { font-size: 17px; font-weight: 600; line-height: 1.45; color: var(--text); }
.card-back-text { font-size: 13px; line-height: 1.65; color: var(--text-secondary); white-space: pre-line; text-align: left; width: 100%; }
.card-hint { font-size: 11px; color: var(--text-muted); margin-top: 18px; }

/* ── Reference / Dashboard panels ── */
.ref-grid { display: flex; flex-direction: column; gap: 10px; }
.ref-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.ref-header {
  padding: 14px 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  transition: background 0.12s;
}
.ref-header:hover { background: var(--surface-hover); }
.ref-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ref-chevron { color: var(--text-muted); transition: transform 0.2s; font-size: 11px; }
.ref-card.open .ref-chevron { transform: rotate(180deg); }
.ref-body { display: none; padding: 0 18px 16px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.ref-card.open .ref-body { display: block; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ref-table th, .ref-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.ref-table th { color: var(--text-muted); font-weight: 600; font-size: 10px; text-transform: uppercase; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.domain-row {
  display: grid; grid-template-columns: 110px 1fr 40px;
  align-items: center; gap: 10px;
  padding: 7px 0; font-size: 12px;
}
.domain-bar { height: 6px; background: var(--bg-subtle); border-radius: 3px; overflow: hidden; }
.domain-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

.result-hero {
  text-align: center; padding: 40px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  max-width: 480px; margin-left: auto; margin-right: auto;
}
.result-pct { font-size: 56px; font-weight: 800; line-height: 1; margin-bottom: 8px; letter-spacing: -0.03em; }
.result-msg { font-size: 15px; font-weight: 500; color: var(--text-secondary); }

/* ── Help tooltips ── */
.help-wrap { display: inline-flex; align-items: center; gap: 3px; vertical-align: baseline; }
.help-trigger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: 50%; flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.help-trigger:hover, .help-trigger:focus-visible { color: var(--primary); background: var(--primary-soft); outline: none; }
.help-balloon {
  position: fixed; z-index: 10000;
  max-width: min(300px, calc(100vw - 24px));
  padding: 10px 12px;
  background: #1e293b; color: #f1f5f9;
  font-size: 12px; line-height: 1.55; font-weight: 400;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: none; opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}
.help-balloon.visible { opacity: 1; transform: translateY(0); }
.help-balloon::after {
  content: ''; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #1e293b;
}
.pattern-chip { display: inline; white-space: normal; }
.file-ref { font-size: 11px; color: var(--text-muted); background: var(--bg-subtle); padding: 2px 7px; border-radius: 4px; }

/* ── Learn ── */
.learn-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}
.learn-nav {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 0;
  box-shadow: var(--shadow-xs);
}
.learn-nav-group { margin-bottom: 4px; }
.learn-nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 8px 14px 4px;
}
.learn-nav-item {
  display: block; width: 100%; text-align: left;
  padding: 7px 14px; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); background: none; border: none;
  cursor: pointer; font-family: var(--font);
  border-left: 2px solid transparent;
  transition: all 0.12s; line-height: 1.4;
}
.learn-nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.learn-nav-item.active { background: var(--primary-soft); color: var(--primary); border-left-color: var(--primary); }
.learn-nav-item .step-num {
  display: inline-block; width: 16px; height: 16px;
  border-radius: 4px; background: var(--bg-subtle);
  font-size: 9px; line-height: 16px; text-align: center;
  margin-right: 5px; font-weight: 700; vertical-align: middle;
}
.learn-nav-item.active .step-num { background: var(--primary); color: white; }
.learn-nav-item.done .step-num { background: #ecfdf5; color: var(--green); }
.learn-nav-more {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 4px;
}
.learn-nav-more summary {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 14px;
  cursor: pointer;
  list-style: none;
}
.learn-nav-more summary::-webkit-details-marker { display: none; }
.learn-nav-more summary::after {
  content: '▸';
  float: right;
  font-size: 10px;
  transition: transform 0.15s;
}
.learn-nav-more[open] summary::after { transform: rotate(90deg); }
.learn-nav-subgroup { margin-bottom: 4px; }
.learn-nav-sublabel {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 14px 2px 18px;
  opacity: 0.85;
}
.learn-nav-extra-item { padding-left: 18px; font-size: 11px; }

.learn-main { min-width: 0; }
.learn-header-panel {
  padding: 22px 24px;
  margin-bottom: 16px;
}
.learn-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 0; align-items: center; }
.learn-footer {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: space-between; align-items: center;
  margin-top: 20px; padding: 16px 20px;
}

.path-arrow { flex-shrink: 0; opacity: 0.35; }
.path-arrow svg { width: 16px; height: 16px; }
.path-step:hover .path-arrow { opacity: 0.7; }

.content-panel {
  padding: 24px 28px 32px;
}

/* ── Lesson visuals ── */
.lesson-banner {
  margin: -8px -4px 24px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.lesson-banner-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: 120px;
}
.lesson-banner-caption {
  margin: 0;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

.lesson-lead {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 20px !important;
  margin-bottom: 24px !important;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-lg);
  font-size: 14px !important;
  color: var(--text) !important;
  line-height: 1.6 !important;
}
.lesson-lead-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-xs);
}
.lesson-lead-icon svg { width: 20px; height: 20px; }

.lesson-section-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 32px 0 16px;
  padding: 16px 18px;
  background: var(--section-bg, #f8fafc);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--section-accent, var(--primary));
}
.lesson-section-header:first-child { margin-top: 0; }
.lesson-section-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #fff;
  color: var(--section-accent, var(--primary));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.lesson-section-icon svg { width: 20px; height: 20px; }
.lesson-section-meta { flex: 1; min-width: 0; }
.lesson-h2 {
  font-size: 16px !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  letter-spacing: -0.02em;
}

.lesson-h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 20px 0 10px !important;
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px !important;
}
.lesson-h3-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.prose .verdict-table { border: none; }
.prose .verdict-table th {
  background: #1e293b;
  color: #94a3b8;
}
.prose .verdict-table td { vertical-align: middle; }
.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.verdict-badge svg { width: 12px; height: 12px; flex-shrink: 0; }
.verdict-bad-badge { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.verdict-good-badge { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.verdict-cell.verdict-bad { background: #fffbfb; }
.verdict-cell.verdict-good { background: #fafffb; }

.prose pre.decision-tree, .prose .decision-tree {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border: 1px solid #334155;
  position: relative;
  padding-top: 36px;
}
.prose pre.decision-tree::before, .prose .decision-tree::before {
  content: 'Decision tree';
  position: absolute;
  top: 10px; left: 16px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}
.tree-glyph { color: #6366f1; font-weight: 700; }
.tree-elim { color: #f87171; font-weight: 600; }
.tree-keep { color: #4ade80; font-weight: 600; }
.tree-root { color: #818cf8; font-weight: 700; display: block; margin-bottom: 6px; }

.prose pre.flow-diagram {
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  color: #5b21b6;
}
.prose pre.flow-diagram code { color: #5b21b6; font-weight: 500; }

.exam-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 16px;
}
.exam-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.exam-option-letter {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.verdict-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px !important;
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 12px !important;
}
.inline-verdict {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
}
.inline-verdict-kill { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.inline-verdict-pick { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.iv-icon { font-weight: 800; }

.prose .lesson-list li {
  margin-bottom: 8px;
  padding-left: 4px;
  line-height: 1.55;
}
.prose .lesson-callout {
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-xs);
}

/* Prose — app content, not notebook */
.prose { font-size: 14px; line-height: 1.65; color: var(--text-secondary); }
.prose > h1:first-child { display: none; }
.prose h2 {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin: 28px 0 12px; padding: 0;
  border: none; letter-spacing: -0.01em;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 14px; font-weight: 600; color: var(--text); margin: 20px 0 8px; }
.prose p { margin: 0 0 12px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--primary); text-decoration: none; font-weight: 500; }
.prose a:hover { text-decoration: underline; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.prose li::marker { color: var(--primary); }
.prose hr { display: none; }

.prose code {
  font-family: var(--mono); font-size: 0.85em;
  background: #f1f5f9; padding: 2px 6px;
  border-radius: 4px; color: #4338ca;
}
.prose pre, .code-block {
  background: #0f172a;
  border-radius: var(--radius);
  padding: 16px 18px; overflow-x: auto;
  margin: 0 0 16px;
  font-size: 12px; line-height: 1.6;
}
.prose pre code, .code-block code {
  background: none; border: none; padding: 0;
  color: #e2e8f0; font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.prose table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; margin: 0;
  display: table;
}
.prose th, .prose td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.prose th {
  background: #f8fafc;
  color: var(--text-muted); font-weight: 600;
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prose tr:last-child td { border-bottom: none; }
.prose tr:hover td { background: #fafbfc; }

.prose blockquote, .callout {
  border: 1px solid #c7d2fe;
  border-left: 3px solid var(--primary);
  padding: 14px 16px; margin: 0 0 14px;
  background: var(--primary-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text); font-size: 13px;
}
.prose input[type="checkbox"] { margin-right: 6px; accent-color: var(--primary); }

.learn-mobile-select {
  display: none; width: 100%;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 13px;
  margin-bottom: 12px;
}

/* ── Mobile ── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 100; justify-content: space-around;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}
.mobile-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; background: none; border: none;
  font-size: 9px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; font-family: var(--font);
}
.mobile-nav button.active { color: var(--primary); }
.mobile-nav .m-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.mobile-nav .m-icon svg { width: 18px; height: 18px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar, .topbar { display: none; }
  .main { padding: 16px 16px 88px; }
  .insight-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .exam-options-grid { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .mobile-nav { display: flex; }
  .hero { padding: 24px 20px; border-radius: var(--radius-lg); }
  .content-panel { padding: 20px 18px; }
  .domain-row { grid-template-columns: 90px 1fr 36px; }
  .learn-layout { grid-template-columns: 1fr; }
  .learn-nav { display: none; }
  .learn-mobile-select { display: block; }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

code, .mono { font-family: var(--mono); font-size: 0.88em; }
.loading { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.spinner {
  width: 32px; height: 32px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.confetti { position: fixed; pointer-events: none; z-index: 9999; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
