/* ============================================================
   AI-102 STUDY HUB — main.css
   Design: Glassmorphism · Depth Layers · Monochrome + Emerald
   Font: Sora (headings) + IBM Plex Sans (body) + IBM Plex Mono (code)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;600;700;800&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Monochrome dark base */
  --mono-950:  #1a1f2e; /* Softer Dark Background */
  --mono-900:  #252b3d; /* Lighter Surface */
  --mono-800:  #2d334a; 
  --mono-750:  #343b57;
  --mono-700:  #3d4566;
  --mono-600:  #4f5982;
  --mono-500:  #6e7681;
  --mono-400:  #8b949e;
  --mono-300:  #cbd5e0;
  --mono-200:  #e2e8f0;

  /* Emerald accent — single vibrant colour */
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-400: #34d399;
  --emerald-300: #6ee7b7;
  --emerald-200: #a7f3d0;
  --emerald-100: #d1fae5;

  /* Glass surfaces */
  --glass-0:    rgba(255,255,255,0.015);
  --glass-1:    rgba(255,255,255,0.03);
  --glass-2:    rgba(255,255,255,0.055);
  --glass-3:    rgba(255,255,255,0.08);
  --glass-4:    rgba(255,255,255,0.11);
  --glass-em:   rgba(16,185,129,0.07);
  --glass-em-h: rgba(16,185,129,0.13);

  /* Glass borders */
  --gb-white:   rgba(255,255,255,0.08);
  --gb-white-h: rgba(255,255,255,0.14);
  --gb-em:      rgba(16,185,129,0.22);
  --gb-em-h:    rgba(16,185,129,0.45);
  --gb-em-glow: rgba(16,185,129,0.55);

  /* Semantic tokens — remapped to monochrome + emerald */
  --bg-primary:      var(--mono-950);
  --bg-secondary:    var(--mono-900);
  --bg-card:         var(--glass-2);
  --bg-card-hover:   var(--glass-3);
  --bg-elevated:     var(--glass-1);
  --bg-deep:         #0d0d1a;
  --surface-2:       rgba(255,255,255,0.04);

  --text-primary:    #ffffff;
  --text-secondary:  #c9d1d9;
  --text-muted:      var(--mono-300);
  --text-accent:     var(--emerald-400);

  --border-subtle:   var(--gb-white);
  --border-default:  rgba(255,255,255,0.11);
  --border-strong:   var(--gb-em);

  --accent:          var(--emerald-400);
  --accent-primary:  var(--emerald-500);
  --accent-light:    var(--emerald-300);
  --accent-subtle:   rgba(16,185,129,0.15);
  --accent-glow:     rgba(16,185,129,0.25);
  --accent-amber:    #fbbf24;
  --accent-green:    var(--emerald-400);

  /* Semantic state colours (muted/desaturated for monochrome feel) */
  --blue-400:   #60a5fa;
  --blue-300:   #93c5fd;
  --blue-200:   #bfdbfe;
  --cyan-400:   #22d3ee;
  --cyan-300:   #67e8f9;
  --cyan-200:   #a5f3fc;
  --amber-500:  #d97706;
  --amber-400:  #f59e0b;
  --amber-300:  #fbbf24;
  --amber-200:  #fde68a;
  --amber-100:  #fef3c7;
  --green-600:  var(--emerald-600);
  --green-500:  var(--emerald-500);
  --green-400:  var(--emerald-400);
  --green-100:  var(--emerald-100);
  --red-500:    #dc2626;
  --red-400:    #f87171;
  --red-100:    #fee2e2;
  --purple-500: #7c3aed;
  --purple-400: #a78bfa;
  --purple-300: #c4b5fd;
  --purple-100: #ede9fe;
  --slate-300:  #cbd5e1;
  --slate-400:  #94a3b8;
  --slate-500:  var(--mono-300);
  --slate-600:  var(--mono-400);

  /* Legacy navy aliases — kept so inline HTML colour refs still resolve */
  --navy-950:   var(--mono-950);
  --navy-900:   var(--mono-900);
  --navy-800:   var(--mono-800);
  --navy-700:   var(--mono-700);
  --navy-600:   var(--mono-600);
  --navy-500:   var(--mono-500);

  /* Part domain colours — emerald family + muted variants */
  --part1-color: #38bdf8;
  --part2-color: #a78bfa;
  --part3-color: #fbbf24;
  --part4-color: var(--emerald-400);
  --part5-color: #f87171;
  --part6-color: #67e8f9;

  /* Typography */
  --font-heading: 'Sora', sans-serif;
  --font-body:    'IBM Plex Sans', sans-serif;
  --font-sans:    var(--font-body);
  --font-mono:    'IBM Plex Mono', monospace;

  /* Spacing scale */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-7:  1.75rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius:     8px;
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 24px;

  /* Glass shadows — depth layers */
  --shadow-card:  0 4px 24px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.4),
                  inset 0 1px 0 rgba(255,255,255,0.06);
  --shadow-glass: 0 8px 40px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.45),
                  inset 0 1px 0 rgba(255,255,255,0.07);
  --shadow-glow:  0 0 24px var(--accent-glow);
  --shadow-blue:  0 0 24px rgba(59,130,246,0.25), 0 4px 24px rgba(0,0,0,0.5);
  --shadow-em:    0 0 28px rgba(16,185,129,0.18), 0 4px 24px rgba(0,0,0,0.5);
  --shadow-btn:   0 4px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  --shadow-btn-em:0 0 20px rgba(16,185,129,0.3), 0 4px 16px rgba(0,0,0,0.4),
                  inset 0 1px 0 rgba(255,255,255,0.12);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;

  /* Layout */
  --sidebar-width-expanded: 280px;
  --sidebar-collapsed-width: 76px;
  --sidebar-width:   var(--sidebar-width-expanded);
  --content-max:     860px;
  --topbar-height:   60px;

  /* Blur values */
  --blur-sm:  8px;
  --blur-md:  16px;
  --blur-lg:  24px;
  --blur-xl:  40px;

  /* Button adaptive tokens — override in body.light-mode */
  --btn-primary-bg:        rgba(16,185,129,0.15);
  --btn-primary-border:    rgba(16,185,129,0.35);
  --btn-primary-color:     var(--emerald-300);
  --btn-primary-bg-h:      rgba(16,185,129,0.22);
  --btn-primary-border-h:  rgba(16,185,129,0.55);
  --btn-primary-color-h:   var(--emerald-200);
  --btn-success-bg:        rgba(16,185,129,0.2);
  --btn-success-border:    rgba(16,185,129,0.4);
  --btn-success-color:     var(--emerald-300);
  --btn-success-bg-h:      rgba(16,185,129,0.3);
  --btn-success-border-h:  rgba(16,185,129,0.6);
  --btn-success-color-h:   var(--emerald-200);
  /* Hero component tokens — dark defaults; theme pages override :root values for theme-specific gradients */
  --hero-bg:     linear-gradient(135deg, var(--navy-800) 0%, var(--navy-900) 60%, #0a0f1e 100%);
  --hero-border: var(--border-subtle);
  --hero-shadow: none;
}

/* ── Light Mode Override ── */
body.light-mode {
  --mono-950:      #f8fafc;
  --bg-primary:    #f8fafc;
  --bg-secondary:  #f1f5f9;
  --bg-card:       rgba(255,255,255,0.92);
  --bg-card-hover: rgba(255,255,255,1);
  --bg-deep:       #e2e8f0;
  --surface-2:     rgba(0,0,0,0.04);
  --text-primary:  #0f172a;
  --text-secondary: #334155;
  --text-muted:    #64748b;
  --border-subtle: rgba(0,0,0,0.08);
  --border-default: rgba(0,0,0,0.13);
  --border-strong: rgba(16,185,129,0.4);
  --navy-950: #f8fafc;
  --navy-900: #f1f5f9;
  --navy-800: #e2e8f0;
  --navy-700: #cbd5e1;
  --navy-600: #94a3b8;
  --navy-500: #64748b;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.05);
  --shadow-glass: 0 4px 24px rgba(0,0,0,0.1), 0 1px 8px rgba(0,0,0,0.06);

  /* Mono scale: dark-mode has navy-ish darks; light-mode inverts to slate grays */
  --mono-900: #f1f5f9;
  --mono-800: #e2e8f0;
  --mono-750: #cbd5e1;
  --mono-700: #94a3b8;
  --mono-600: #64748b;
  --mono-500: #475569;
  --mono-400: #334155;
  --mono-300: #1e293b;
  --mono-200: #0f172a;

  /* Glass surfaces → subtle light grays (dark-mode uses white-transparent which vanishes on light bg) */
  --glass-0:    rgba(0,0,0,0.01);
  --glass-1:    rgba(0,0,0,0.025);
  --glass-2:    rgba(0,0,0,0.045);
  --glass-3:    rgba(0,0,0,0.07);
  --glass-4:    rgba(0,0,0,0.10);
  --glass-em:   rgba(16,185,129,0.07);
  --glass-em-h: rgba(16,185,129,0.13);
  /* Glass borders → dark-transparent (dark-mode uses white-transparent = invisible on light bg) */
  --gb-white:   rgba(0,0,0,0.10);
  --gb-white-h: rgba(0,0,0,0.16);
  /* Elevated surface */
  --bg-elevated: rgba(0,0,0,0.03);
  --surface-2:   rgba(0,0,0,0.04);

  /* Button tokens: solid emerald replaces invisible glass on white bg */
  --btn-primary-bg:        #059669;
  --btn-primary-border:    #047857;
  --btn-primary-color:     #ffffff;
  --btn-primary-bg-h:      #047857;
  --btn-primary-border-h:  #065f46;
  --btn-primary-color-h:   #ffffff;
  --btn-success-bg:        #059669;
  --btn-success-border:    #047857;
  --btn-success-color:     #ffffff;
  --btn-success-bg-h:      #047857;
  --btn-success-border-h:  #065f46;
  --btn-success-color-h:   #ffffff;

  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(16,185,129,0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(16,185,129,0.03) 0%, transparent 60%);
  --hero-bg:     linear-gradient(135deg, rgba(255,255,255,0.97) 0%, #f1f5f9 100%);
  --hero-border: rgba(0,0,0,0.1);
  --hero-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

body.light-mode .sidebar {
  background: #fff;
  border-right: 1px solid rgba(0,0,0,0.1);
}

body.light-mode .sidebar-logo {
  background: rgba(255,255,255,0.95);
  border-bottom-color: rgba(0,0,0,0.08);
}

body.light-mode .sidebar-logo-text { color: #0f172a; }
body.light-mode .sidebar-logo-sub  { color: #64748b; }

body.light-mode .topbar {
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

body.light-mode .sidebar-item { color: #334155; }
body.light-mode .sidebar-item:hover { background: rgba(0,0,0,0.04); color: #0f172a; }
body.light-mode .sidebar-item.active { background: rgba(16,185,129,0.1); color: var(--emerald-600); }

body.light-mode .progress-bar {
  background: rgba(0,0,0,0.1);
  border-color: rgba(0,0,0,0.08);
}


/* Code blocks in light mode */
body.light-mode pre {
  background: #f1f5f9;
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

body.light-mode code {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.1);
  color: #059669;
}

/* Cards in light mode */
body.light-mode .card,
body.light-mode .bg-card {
  background: var(--bg-card);
  border-color: var(--border-subtle);
}

/* ── Light mode element fixes ── */


/* Selector card button: glass bg + white text = invisible in light mode */
body.light-mode .selector-card-btn {
  color: var(--text-primary) !important;
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
}

/* Back-to-hub button: glass bg looks wrong; hover white text invisible */
body.light-mode .back-to-hub-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
}
body.light-mode .back-to-hub-btn:hover {
  color: var(--text-primary) !important;
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.14);
}

/* wh-footer divider: white-transparent invisible on white bg */
body.light-mode .wh-footer { border-top-color: rgba(0,0,0,0.08); }

/* em / strong inherit correctly via --text-* but amber-300 em is too pale */
body.light-mode em { color: #92400e; }

/* Links: emerald-400 (#34d399) is too pale on white; use darker emerald */
body.light-mode a { color: #059669; }
body.light-mode a:hover { color: #047857; }

/* Topbar breadcrumb separator */
body.light-mode .topbar-breadcrumb .sep { color: rgba(0,0,0,0.3); }

/* Scrollbar */
body.light-mode ::-webkit-scrollbar-track { background: #e2e8f0; }
body.light-mode ::-webkit-scrollbar-thumb { background: #94a3b8; }

/* Term cards — solid white so they stand out on the light bg */
body.light-mode .term-card {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}
body.light-mode .term-card::before { display: none; }
body.light-mode .term-card:hover {
  background: #fff;
  border-color: rgba(16,185,129,0.35);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 0 0 2px rgba(16,185,129,0.1);
}

/* Section blocks */
body.light-mode .section-block {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.09);
}

/* Callout boxes: invisible borders & too-pale text in light mode */
body.light-mode .callout,
body.light-mode [class^="callout-"],
body.light-mode [class*=" callout-"] {
  border-top-color: rgba(0,0,0,0.06);
  border-right-color: rgba(0,0,0,0.05);
  border-bottom-color: rgba(0,0,0,0.06);
}

body.light-mode .callout-concept { background: rgba(59,130,246,0.07); color: #1e3a8a; }
body.light-mode .callout-concept .callout-title,
body.light-mode .callout-concept .callout-body strong { color: #1d4ed8; }

body.light-mode .callout-exam { background: rgba(245,158,11,0.08); color: #78350f; }
body.light-mode .callout-exam .callout-title,
body.light-mode .callout-exam .callout-body strong { color: #92400e; }

body.light-mode .callout-tip { background: rgba(16,185,129,0.08); color: #064e3b; }
body.light-mode .callout-tip .callout-title,
body.light-mode .callout-tip .callout-body strong { color: #065f46; }

body.light-mode .callout-warning,
body.light-mode .callout-warn { background: rgba(220,38,38,0.07); color: #7f1d1d; }
body.light-mode .callout-warning .callout-title,
body.light-mode .callout-warn .callout-title,
body.light-mode .callout-warning .callout-body strong,
body.light-mode .callout-warn .callout-body strong { color: #991b1b; }

body.light-mode .callout-analogy { background: rgba(124,58,237,0.07); color: #3b0764; }
body.light-mode .callout-analogy .callout-title,
body.light-mode .callout-analogy .callout-body strong { color: #5b21b6; }

body.light-mode .callout-info { background: rgba(14,165,233,0.07); color: #0c4a6e; }
body.light-mode .callout-info .callout-title,
body.light-mode .callout-info .callout-body strong { color: #0369a1; }

/* Headings — gradient text (#fff → pastel) invisible on light bg */
body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode h4 {
  -webkit-text-fill-color: var(--text-primary);
  background: none;
}

/* Part-hero and topic-header — page-specific dark gradient backgrounds */
body.light-mode .part-hero {
  background: linear-gradient(135deg, rgba(16,185,129,0.10) 0%, rgba(16,185,129,0.04) 100%) !important;
  border-color: var(--accent-glow) !important;
}
body.light-mode .part-hero::before {
  background: radial-gradient(circle, rgba(16,185,129,0.12) 0%, transparent 70%);
}
body.light-mode .topic-header {
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(99,102,241,0.04) 100%) !important;
  border-color: rgba(99,102,241,0.2) !important;
}
body.light-mode .topic-header::before {
  background: radial-gradient(circle, rgba(99,102,241,0.10) 0%, transparent 70%);
}

/* Part-hero text — gradient text needs solid color in light mode */
body.light-mode .part-hero-title,
body.light-mode .part-hero-desc,
body.light-mode .topic-title {
  -webkit-text-fill-color: var(--text-primary);
  background: none;
  color: var(--text-primary);
}

/* Part-hero eyebrow & meta readable in light mode */
body.light-mode .part-hero-eyebrow { color: #065f46; background: rgba(16,185,129,0.1); }
body.light-mode .meta-value { color: #047857; }
body.light-mode .meta-label { color: var(--text-muted); }

/* Dashboard hero — decorative glows reduced in light mode; bg/border/shadow handled via --hero-* tokens */
body.light-mode .hero::before,
body.light-mode .hero::after { opacity: 0.4; }

/* Accent text: violet/blue light variants unreadable on white */
/* CSA violet theme */
body.light-mode.theme-csa .hero-eyebrow {
  color: #5b21b6;
  background: rgba(124,58,237,0.08);
  border-color: rgba(124,58,237,0.22);
}
body.light-mode.theme-csa .op-pct        { color: #5b21b6; }
body.light-mode.theme-csa .next-up-title { color: #5b21b6; }
body.light-mode.theme-csa .part-mini-link:hover { color: #5b21b6; }

/* AI-102 blue theme */
body.light-mode.theme-ai102 .hero-eyebrow {
  color: #1d4ed8;
  background: rgba(59,130,246,0.08);
  border-color: rgba(59,130,246,0.22);
}
body.light-mode.theme-ai102 .op-pct { color: #1d4ed8; }

/* Weight chart track: rgba(255,255,255,0.05) vanishes on white */
body.light-mode .weight-bar-wrap { background: rgba(0,0,0,0.08); }

/* Part card hover: heavy dark shadow looks wrong on light bg */
body.light-mode .part-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06) !important;
}

/* Hero title gradient text — h1.hero-title uses -webkit-text-fill-color */
body.light-mode .hero-title {
  -webkit-text-fill-color: var(--text-primary);
  background: none;
}
body.light-mode .hero-sub  { color: var(--text-secondary); }
body.light-mode .hero-stat-label { color: var(--text-muted); }
body.light-mode .hero-stat-value { color: var(--text-primary); }

/* Revision center: specific overrides that vars alone don't cover */
body.light-mode .fc-front { background: linear-gradient(145deg, #e8edf5, #f0f4fb); }
body.light-mode .fc-back  { background: linear-gradient(145deg, #dde4f0, #e8edf5); }
body.light-mode .part-btn-icon { background: rgba(0,0,0,0.05); }
body.light-mode .recap-item { border-bottom-color: rgba(0,0,0,0.06); }
body.light-mode .recap-item.recap-trap { color: #92400e; }
body.light-mode .recap-trap-label { color: #92400e; background: rgba(245,158,11,0.12); }
body.light-mode .topic-btn.active { color: #065f46; }
body.light-mode .rating-btn.need-review:not(:disabled):hover { color: #991b1b; }
body.light-mode .rating-btn.got-it:not(:disabled):hover { color: #065f46; }

/* Quiz: correct/incorrect feedback colors too pale on white */
body.light-mode .quiz-option.correct  .quiz-option-text { color: #065f46; }
body.light-mode .quiz-option.incorrect .quiz-option-text { color: #991b1b; }
body.light-mode .quiz-option.selected .quiz-option-letter,
body.light-mode .quiz-option.correct  .quiz-option-letter { color: #065f46; }
body.light-mode .quiz-option.incorrect .quiz-option-letter { color: #991b1b; }

/* Quiz sub-sections: rgba(255,255,255,*) bg invisible on white */
body.light-mode .quiz-header { background: rgba(0,0,0,0.02); }
body.light-mode .quiz-footer { background: rgba(0,0,0,0.02); }
body.light-mode .quiz-explanation { background: rgba(0,0,0,0.03); }

/* Tab active: emerald-300 (#6ee7b7) too pale on white */
body.light-mode .tab-btn.active { color: #047857; }
body.light-mode .tab-btn:hover  { color: var(--text-primary); }

/* Copy button: emerald-300 too pale on white */
body.light-mode .copy-btn:hover { color: #047857; }
body.light-mode .copy-btn.copied { color: #047857; }

/* Badges: pale tints invisible on white bg */
body.light-mode .badge-blue   { color: #1d4ed8; background: rgba(59,130,246,0.08);  border-color: rgba(59,130,246,0.25); }
body.light-mode .badge-amber  { color: #92400e; background: rgba(245,158,11,0.1);   border-color: rgba(245,158,11,0.3); }
body.light-mode .badge-green  { color: #065f46; background: rgba(16,185,129,0.1);   border-color: rgba(16,185,129,0.3); }
body.light-mode .badge-red    { color: #991b1b; background: rgba(220,38,38,0.08);   border-color: rgba(220,38,38,0.25); }
body.light-mode .badge-purple { color: #5b21b6; background: rgba(124,58,237,0.08);  border-color: rgba(124,58,237,0.25); }
body.light-mode .badge-cyan   { color: #0e7490; background: rgba(6,182,212,0.08);   border-color: rgba(6,182,212,0.25); }
body.light-mode .badge-slate  { color: #334155; background: rgba(100,116,139,0.08); border-color: rgba(100,116,139,0.2); }

/* Sidebar groups: hardcoded rgba(255,255,255,0.02) bg + border = invisible on white */
body.light-mode .sidebar-group {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.07);
}
body.light-mode .sidebar-group-body { background: rgba(0,0,0,0.015); }
body.light-mode .sidebar-item.sidebar-nav-tab {
  background: rgba(0,0,0,0.025);
  border-color: rgba(0,0,0,0.07);
}
body.light-mode .sidebar-item.sidebar-nav-tab:hover { border-color: rgba(0,0,0,0.12); }
body.light-mode .sidebar-back-sep { background: rgba(0,0,0,0.06); }
body.light-mode .sidebar-group-header { color: #475569; }
body.light-mode .sidebar-group-header:hover { color: #065f46; background: var(--glass-em); }
body.light-mode .sidebar-item.sidebar-nav-tab { color: #475569; }
body.light-mode .sidebar-item.sidebar-nav-tab:hover { color: #047857; background: var(--glass-em); }
body.light-mode .sidebar-item.sidebar-nav-tab.active { color: #065f46; }

/* Settings panel: dark rgba(5,6,10,0.88) bg not adapting */
body.light-mode .sidebar-settings-panel {
  background: rgba(255,255,255,0.97);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Dividers and topic-nav-footer: rgba(255,255,255,0.05-0.06) invisible */
body.light-mode .divider { background: rgba(0,0,0,0.08); }
body.light-mode .topic-nav-footer { border-top-color: rgba(0,0,0,0.08); }

/* Comparison table: invisible borders and bg on white */
body.light-mode .comparison-table table th,
body.light-mode table.comparison-table th {
  background: rgba(0,0,0,0.03);
  border-bottom-color: rgba(0,0,0,0.08);
}
body.light-mode .comparison-table table td,
body.light-mode table.comparison-table td {
  background: transparent;
  border-bottom-color: rgba(0,0,0,0.05);
}
body.light-mode .comparison-table table tr:hover td,
body.light-mode table.comparison-table tr:hover td { background: rgba(16,185,129,0.04); }

/* Selector portal: hardcoded #ffffff text + invisible glass surfaces */
body.light-mode .selector-title {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
body.light-mode .selector-eyebrow {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}
body.light-mode .selector-card {
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.08);
}
body.light-mode .selector-card:hover {
  background: #ffffff;
  border-color: var(--accent-color);
}
body.light-mode .selector-card-title { color: #0f172a; }
body.light-mode .selector-card-icon {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}
body.light-mode .selector-card-progress {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.07);
}
body.light-mode .selector-prog-bar { background: rgba(0,0,0,0.08); }
body.light-mode .selector-prog-pct { color: #0f172a; }

/* Tryit spinner: white-transparent track invisible on white */
body.light-mode .tryit-spinner { border-color: rgba(0,0,0,0.1); }

/* Sidebar collapsed hover: rgba(255,255,255,0.03) invisible */
body.light-mode.sidebar-collapsed .sidebar-item:hover,
body.light-mode.sidebar-collapsed .sidebar-group-header:hover {
  background: rgba(0,0,0,0.05);
}

/* Quiz result score: gradient end (#6ee7b7 or #bfdbfe) too pale on white; use themed accent vars */
body.light-mode .quiz-result-score {
  background: linear-gradient(135deg, var(--emerald-600), var(--emerald-700));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Retirement warning banner */
.retirement-banner {
  background: linear-gradient(90deg, rgba(239,68,68,0.12), rgba(245,158,11,0.08));
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-6);
  font-size: 0.85rem;
}
.retirement-banner strong { color: var(--red-400); }
.retirement-banner a { color: var(--amber-400); }

/* Theme toggle button */
.theme-toggle-btn {
  background: none; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); width: 36px; height: 36px;
  cursor: pointer; font-size: 1rem; display: flex;
  align-items: center; justify-content: center;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}
.theme-toggle-btn:hover { background: var(--bg-card); border-color: var(--border-default); }

/* Progress export/import buttons */
.progress-actions {
  display: flex; gap: var(--space-3); flex-wrap: wrap;
  margin-top: var(--space-4);
}

/* ── Global Contrast Fixes ── */
.part-btn, .topic-btn, .rating-btn, .part-btn-title, .topic-btn-title {
  color: var(--text-primary);
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }

body.sidebar-collapsed {
  --sidebar-width: var(--sidebar-collapsed-width);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--mono-950);
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, var(--glass-em) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(16,185,129,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 100% 80% at 50% 50%, rgba(255,255,255,0.012) 0%, transparent 100%);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--mono-900); }
::-webkit-scrollbar-thumb { background: var(--mono-600); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--emerald-600); }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 3vw, 1.85rem); font-weight: 700; }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.35rem); font-weight: 600; }
h4 { font-size: 1.05rem; font-weight: 600; }

p { color: var(--text-secondary); margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--emerald-400);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--emerald-300); }

strong { color: var(--text-primary); font-weight: 600; }
em { color: var(--amber-300); font-style: italic; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(16,185,129,0.08);
  color: var(--emerald-300);
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16,185,129,0.18);
}

pre {
  font-family: var(--font-mono);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)),
    var(--mono-950);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  overflow-x: auto;
  position: relative;
  margin: var(--space-6) 0;
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Code syntax highlight */
.token-keyword  { color: #c084fc; }
.token-string   { color: var(--emerald-300); }
.token-comment  { color: var(--mono-300); font-style: italic; }
.token-function { color: #7dd3fc; }
.token-number   { color: #fb923c; }
.token-operator { color: #67e8f9; }
.token-class    { color: #fde68a; }

/* ── Layout Shells ────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  overflow-x: clip;
}

/* ── Sidebar — deep glass panel ──────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background:
    linear-gradient(180deg, rgba(16,185,129,0.04) 0%, transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,0.025) 0%, rgba(255,255,255,0.01) 100%),
    var(--mono-900);
  border-right: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 1px 0 0 rgba(255,255,255,0.04), 20px 0 60px rgba(0,0,0,0.6);
  transition: width var(--transition-normal), min-width var(--transition-normal),
              transform var(--transition-normal), box-shadow var(--transition-normal);
  /* Subtle noise texture via pseudo */
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 40% at 50% 0%, rgba(16,185,129,0.06) 0%, transparent 70%);
}

.sidebar-logo {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(5,6,10,0.85);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.22), transparent 50%),
    linear-gradient(135deg, var(--emerald-500), var(--emerald-700) 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(16,185,129,0.35), 0 4px 12px rgba(0,0,0,0.5),
              inset 0 1px 0 rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.12);
}

.theme-ai102 .sidebar-logo-icon::before {
  content: 'AI';
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #fff;
}

.theme-csa .sidebar-logo-icon {
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.22), transparent 50%),
    linear-gradient(135deg, #7c3aed, #a855f7) !important;
  box-shadow: 0 0 20px rgba(168,85,247,0.35), 0 4px 12px rgba(0,0,0,0.5),
              inset 0 1px 0 rgba(255,255,255,0.2) !important;
}

.theme-csa .sidebar-logo-icon::before {
  content: 'SN';
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #fff;
}

.theme-cis-df .sidebar-logo-icon {
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.22), transparent 50%),
    linear-gradient(135deg, #0891b2, #22d3ee) !important;
  box-shadow: 0 0 20px rgba(8,145,178,0.35), 0 4px 12px rgba(0,0,0,0.5),
              inset 0 1px 0 rgba(255,255,255,0.2) !important;
}

.theme-cis-df .sidebar-logo-icon::before {
  content: 'DF';
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #fff;
}

.sidebar-logo-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: 0.7rem;
  color: rgba(139,146,168,0.7);
  font-weight: 400;
}

.sidebar-nav {
  padding: var(--space-4) 0 var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.sidebar-logo > *,
.sidebar-item,
.sidebar-group-header,
.sidebar-progress {
  transition: opacity var(--transition-fast), transform var(--transition-normal),
              background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.sidebar-desktop-toggle {
  margin-right: var(--space-2);
  width: 36px;
  height: 36px;
  border: 1px solid var(--gb-white);
  border-radius: 12px;
  background: var(--glass-1);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-desktop-toggle:hover {
  background: var(--glass-em);
  border-color: var(--gb-em);
  box-shadow: 0 0 12px var(--accent-subtle);
  color: var(--emerald-400);
}

.sidebar-desktop-toggle::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='11 17 6 12 11 7'/%3E%3Cpolyline points='18 17 13 12 18 7'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='11 17 6 12 11 7'/%3E%3Cpolyline points='18 17 13 12 18 7'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

body.sidebar-collapsed .sidebar-desktop-toggle::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='13 17 18 12 13 7'/%3E%3Cpolyline points='6 17 11 12 6 7'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='13 17 18 12 13 7'/%3E%3Cpolyline points='6 17 11 12 6 7'/%3E%3C/svg%3E");
}

/* ── Sidebar accordion groups ───────────────────────────────── */
.sidebar-group {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  margin: 0 var(--space-3) var(--space-2);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
}

.sidebar-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(180,188,210,0.95);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-group-header:hover {
  background: var(--glass-em);
  color: var(--emerald-300);
}

.sidebar-group.all-done .sidebar-group-header {
  color: var(--emerald-400);
}

.sidebar-group-title { flex: 1; }

.sidebar-chevron {
  width: 12px; height: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}
.sidebar-chevron::before {
  content: '';
  display: block;
  width: 5px; height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
  transition: transform var(--transition-fast);
}
.sidebar-group.open .sidebar-chevron::before {
  transform: rotate(45deg) translateY(-2px);
}

.sidebar-group-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
  background: rgba(255,255,255,0.01);
}
.sidebar-group.open .sidebar-group-body { max-height: 900px; }

/* ── Standalone nav tabs (Dashboard, Revision) — match group-header look ── */
.sidebar-item.sidebar-nav-tab {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 14px;
  margin: 0 var(--space-3) var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(180,188,210,0.95);
}
.sidebar-item.sidebar-nav-tab:hover {
  background: var(--glass-em);
  border-color: rgba(255,255,255,0.12);
  color: var(--emerald-300);
  transform: none;
}
.sidebar-item.sidebar-nav-tab.active {
  background: rgba(16,185,129,0.08);
  border-color: rgba(16,185,129,0.3);
  color: var(--emerald-300);
  font-weight: 700;
  box-shadow: none;
}

.topic-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--gb-white);
  background: transparent;
  flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.topic-dot.done {
  background: var(--emerald-500);
  border-color: var(--emerald-500);
  box-shadow: 0 0 6px rgba(16,185,129,0.5);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.8rem 1rem;
  margin: 0 var(--space-3) 0.15rem;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none;
  position: relative;
  border-top: none;
  border-right: none;
  border-bottom: none;
}

.sidebar-item:hover {
  background: var(--glass-em);
  color: var(--emerald-300);
  transform: translateX(2px);
  border-left-color: rgba(16,185,129,0.3);
}

.sidebar-item.active {
  background: rgba(16,185,129,0.08);
  color: var(--emerald-300);
  border-left-color: var(--emerald-400);
  font-weight: 600;
  box-shadow: inset 0 0 20px rgba(16,185,129,0.04);
}

.sidebar-back-item {
  color: var(--text-muted) !important;
  font-size: 0.8rem !important;
  font-weight: 500 !important;
  margin-bottom: 0 !important;
  border-left-color: transparent !important;
}
.sidebar-back-item:hover {
  color: var(--text-secondary) !important;
  background: rgba(255,255,255,0.04) !important;
  border-left-color: transparent !important;
  transform: translateX(0) !important;
}
.sidebar-back-item + * {
  /* Separator line after back item */
  position: relative;
}
.sidebar-back-sep {
  height: 1px;
  background: rgba(255,255,255,0.05);
  margin: var(--space-1) var(--space-4) var(--space-2);
}

.sidebar-settings-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.8;
  cursor: pointer;
}

.sidebar-item .item-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item .item-badge {
  margin-left: auto;
  font-size: 0.65rem;
  background: var(--glass-em);
  color: var(--emerald-400);
  padding: 2px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  border: 1px solid var(--gb-em);
}

.sidebar-item.active .item-badge {
  background: rgba(16,185,129,0.18);
  color: var(--emerald-300);
}

button.sidebar-item {
  appearance: none;
  -webkit-appearance: none;
  width: calc(100% - (var(--space-3) * 2));
  background: transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
}

button.sidebar-group-header {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
}

.sidebar-item.sidebar-utility { display: none; }

.sidebar-settings-toggle {
  margin-top: auto;
  margin-bottom: var(--space-3);
}

.sidebar-settings-toggle::before {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.sidebar-settings-panel {
  display: none;
  margin: 0 var(--space-3) var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--gb-white);
  border-radius: 16px;
  background: rgba(5,6,10,0.88);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  box-shadow: var(--shadow-glass);
}

.sidebar-settings-panel.open {
  display: block;
  animation: fadeIn 0.22s ease forwards;
}

.sidebar-settings-title {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.sidebar-settings-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-settings-input {
  width: 100%;
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: 12px;
  border: 1px solid var(--gb-white);
  background: var(--glass-1);
  color: var(--text-primary);
  font-family: var(--font-body);
}

.sidebar-settings-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sidebar-sub-item {
  padding-left: 1.35rem;
  font-size: 0.8rem;
  margin-left: calc(var(--space-3) + 0.35rem);
  margin-right: var(--space-3);
}

.sidebar-progress {
  padding: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.05);
  margin: auto var(--space-3) var(--space-3);
  border-radius: 16px;
  background: var(--glass-1);
  border: 1px solid var(--gb-white);
}

.sidebar-progress-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  display: flex;
  justify-content: space-between;
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  width: calc(100vw - var(--sidebar-width));
  max-width: calc(100vw - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-normal);
}

/* ── Topbar — sticky glass ────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: rgba(5,6,10,0.72);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 8px 32px rgba(0,0,0,0.35);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-breadcrumb .sep { color: rgba(255,255,255,0.15); }
.topbar-breadcrumb .current { color: var(--text-primary); font-weight: 500; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Page containers ──────────────────────────────────────── */
.page-content {
  padding: var(--space-10) var(--space-8);
  max-width: calc(var(--content-max) + var(--space-16));
  margin: 0 auto;
  width: 100%;
}

.page-full {
  padding: var(--space-10) var(--space-8);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Buttons — glass morphism ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  letter-spacing: 0.01em;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.07) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::before { opacity: 1; }

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Primary — adaptive (glass in dark, solid in light) */
.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: var(--btn-primary-color);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-bg-h);
  border-color: var(--btn-primary-border-h);
  color: var(--btn-primary-color-h);
  box-shadow: var(--shadow-btn-em);
}

/* Secondary — neutral glass */
.btn-secondary {
  background: var(--glass-2);
  border-color: var(--gb-white);
  color: var(--text-secondary);
  box-shadow: var(--shadow-btn);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--glass-3);
  border-color: var(--gb-white-h);
  color: var(--text-primary);
  box-shadow: 0 6px 20px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.12);
}

/* Ghost — minimal glass */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--glass-1);
  border-color: var(--gb-white);
  color: var(--text-primary);
}

/* Success — adaptive (glass in dark, solid in light) */
.btn-success {
  background: var(--btn-success-bg);
  border-color: var(--btn-success-border);
  color: var(--btn-success-color);
  box-shadow: var(--shadow-btn-em);
}
.btn-success:hover:not(:disabled) {
  background: var(--btn-success-bg-h);
  border-color: var(--btn-success-border-h);
  color: var(--btn-success-color-h);
  box-shadow: 0 0 30px rgba(16,185,129,0.3), var(--shadow-btn);
}

.btn-sm  { padding: var(--space-2) var(--space-4); font-size: 0.8rem; }
.btn-lg  { padding: var(--space-4) var(--space-8); font-size: 1rem; }
.btn-icon { padding: var(--space-2); width: 36px; height: 36px; justify-content: center; }

/* Copy button */
.copy-btn {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: var(--glass-2);
  color: var(--text-muted);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}
.copy-btn:hover {
  background: var(--glass-em);
  color: var(--emerald-300);
  border-color: var(--gb-em);
  box-shadow: 0 0 10px var(--accent-subtle);
}
.copy-btn.copied {
  background: rgba(16,185,129,0.2);
  color: var(--emerald-300);
  border-color: var(--gb-em);
}

/* ── Cards — glass panels ─────────────────────────────────── */
.card {
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-card);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 50%);
  pointer-events: none;
}

.card:hover {
  border-color: var(--gb-em);
  box-shadow: var(--shadow-em);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-4);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.card-link {
  cursor: pointer;
  text-decoration: none;
  display: block;
}
.card-link:hover {
  border-color: var(--gb-em-h);
  transform: translateY(-2px);
  box-shadow: var(--shadow-em);
}

/* ── Topic Page Layout ────────────────────────────────────── */
.topic-header {
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topic-part-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-heading);
  letter-spacing: 0.05em;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
}

.topic-title { margin-bottom: var(--space-3); }

.topic-meta {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

.topic-meta-item,
.topic-meta > span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.section-block { margin-bottom: var(--space-10); }

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  padding: var(--space-1) var(--space-3);
  background: var(--glass-1);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border-radius: var(--radius-sm);
  border: 1px solid var(--gb-white);
}

/* ── Callout Boxes — glass variants ───────────────────────── */
/* Shared appearance — works with direct text content OR icon+content children */
.callout,
.callout-concept,
.callout-exam,
.callout-warning,
.callout-warn,
.callout-tip,
.callout-analogy,
.callout-info {
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-lg);
  border-left: 3px solid;
  margin: var(--space-6) 0;
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border-top: 1px solid rgba(255,255,255,0.06);
  border-right: 1px solid rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(0,0,0,0.2);
}
/* Flex layout only when icon+content structure is used (.callout base class) */
.callout {
  display: flex;
  gap: var(--space-4);
}

.callout-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.callout-content > *:last-child { margin-bottom: 0; }
.callout-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.callout-concept {
  background: rgba(96,165,250,0.06);
  border-left-color: #3b82f6;
}
.callout-concept .callout-title { color: #93c5fd; }

.callout-exam {
  background: rgba(245,158,11,0.06);
  border-left-color: var(--amber-500);
}
.callout-exam .callout-title { color: var(--amber-400); }

.callout-warning {
  background: rgba(220,38,38,0.06);
  border-left-color: var(--red-500);
}
.callout-warning .callout-title { color: var(--red-400); }

.callout-tip {
  background: var(--glass-em);
  border-left-color: var(--emerald-500);
}
.callout-tip .callout-title { color: var(--emerald-400); }

.callout-analogy {
  background: rgba(124,58,237,0.07);
  border-left-color: var(--purple-500);
}
.callout-analogy .callout-title { color: var(--purple-400); }

.callout-info {
  background: rgba(14,165,233,0.06);
  border-left-color: #0ea5e9;
}
.callout-info .callout-title { color: #7dd3fc; }

.callout-warn {
  background: rgba(220,38,38,0.06);
  border-left-color: var(--red-500);
}
.callout-warn .callout-title { color: var(--red-400); }

.callout-body,
.callout-content { flex: 1; }
.callout-body > *:last-child,
.callout-content > *:last-child { margin-bottom: 0; }

/* ── Term Grid / Cards ────────────────────────────────────── */
.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.term-card {
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-card);
  position: relative;
}

.term-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.term-card:hover {
  border-color: var(--gb-em);
  background: var(--glass-3);
  box-shadow: var(--shadow-em);
}

.term-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--emerald-400);
  margin-bottom: var(--space-2);
  display: block;
}

.term-definition {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ── Step Walkthrough ─────────────────────────────────────── */
.step-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.step-item {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
}

.step-number {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: var(--accent-subtle);
  border: 1px solid var(--gb-em);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--emerald-400);
  margin-top: 2px;
  box-shadow: 0 0 10px var(--accent-subtle);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

.step-content { flex: 1; }

.step-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.step-desc { font-size: 0.875rem; color: var(--text-secondary); margin: 0; }

.step-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--glass-1);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

/* ── Comparison Table — glass ─────────────────────────────── */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-6) 0;
  font-size: 0.875rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gb-white);
  box-shadow: var(--shadow-card);
}

.compare-table th {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.8rem;
  text-align: left;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--gb-white);
  letter-spacing: 0.03em;
}

.compare-table td {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-secondary);
  vertical-align: top;
  line-height: 1.5;
  background: rgba(255,255,255,0.01);
}

.compare-table tr:last-child td { border-bottom: none; }

.compare-table tr:hover td {
  background: rgba(16,185,129,0.04);
}

.compare-table .highlight-col {
  color: var(--emerald-400);
  font-weight: 500;
}

/* ── Comparison Table — alias for compare-table ───────────── */
/* Supports both: <div class="comparison-table"><table> and <table class="comparison-table"> */
.comparison-table {
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin: var(--space-6) 0;
}
.comparison-table table,
table.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gb-white);
  box-shadow: var(--shadow-card);
}
.comparison-table table th,
table.comparison-table th {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.8rem;
  text-align: left;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--gb-white);
  letter-spacing: 0.03em;
}
.comparison-table table td,
table.comparison-table td {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-secondary);
  vertical-align: top;
  line-height: 1.5;
  background: rgba(255,255,255,0.01);
}
.comparison-table table tr:last-child td,
table.comparison-table tr:last-child td { border-bottom: none; }
.comparison-table table tr:hover td,
table.comparison-table tr:hover td { background: rgba(16,185,129,0.04); }

/* ── Term Card — h4/p fallbacks for content using heading tags ─ */
.term-card h4 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--emerald-400);
  margin: 0 0 var(--space-2) 0;
}
.term-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
  background: linear-gradient(90deg, var(--emerald-600), var(--emerald-400));
  box-shadow: 0 0 8px rgba(16,185,129,0.4);
}

.progress-labeled {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.progress-labeled .progress-bar { flex: 1; }

.progress-pct {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--emerald-400);
  min-width: 35px;
  text-align: right;
}

/* ── Badges / Tags ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
  white-space: nowrap;
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

.badge-blue   { background: rgba(96,165,250,0.1);  color: #93c5fd;           border: 1px solid rgba(96,165,250,0.25); }
.badge-amber  { background: rgba(245,158,11,0.1);  color: var(--amber-400);  border: 1px solid rgba(245,158,11,0.25); }
.badge-green  { background: rgba(16,185,129,0.1);  color: var(--emerald-400);border: 1px solid var(--gb-em); }
.badge-red    { background: rgba(220,38,38,0.1);   color: var(--red-400);    border: 1px solid rgba(220,38,38,0.25); }
.badge-purple { background: rgba(124,58,237,0.1);  color: var(--purple-400); border: 1px solid rgba(124,58,237,0.25); }
.badge-cyan   { background: rgba(6,182,212,0.1);   color: #67e8f9;           border: 1px solid rgba(6,182,212,0.25); }
.badge-slate  { background: rgba(100,116,139,0.1); color: var(--slate-300);  border: 1px solid rgba(100,116,139,0.25);}

/* ── Quiz Component — glass container ─────────────────────── */
.quiz-container {
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-glass);
  position: relative;
}

.quiz-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  pointer-events: none;
}

.quiz-header {
  background: rgba(255,255,255,0.025);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gb-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quiz-question-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.quiz-body { padding: var(--space-8); }

.quiz-question {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: var(--space-6);
}

.quiz-scenario {
  background: var(--glass-1);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  font-style: italic;
  border-left: 3px solid var(--amber-500);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--glass-1);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
  font-family: var(--font-body);
  position: relative;
}

.quiz-option::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.quiz-option:hover:not(:disabled)::before { opacity: 1; }

.quiz-option:hover:not(:disabled) {
  border-color: var(--gb-em);
  background: var(--glass-em);
  box-shadow: 0 0 12px rgba(16,185,129,0.08);
}

.quiz-option.selected {
  border-color: var(--gb-em);
  background: var(--glass-em);
}

.quiz-option.correct {
  border-color: rgba(16,185,129,0.5);
  background: rgba(16,185,129,0.08);
  box-shadow: 0 0 16px rgba(16,185,129,0.12);
}

.quiz-option.incorrect {
  border-color: rgba(220,38,38,0.4);
  background: rgba(220,38,38,0.06);
}

.quiz-option-letter {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--glass-2);
  border: 1px solid var(--gb-white);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.quiz-option.selected .quiz-option-letter {
  background: rgba(16,185,129,0.2);
  border-color: var(--gb-em);
  color: var(--emerald-300);
  box-shadow: 0 0 8px rgba(16,185,129,0.2);
}
.quiz-option.correct .quiz-option-letter {
  background: var(--accent-glow);
  border-color: rgba(16,185,129,0.6);
  color: var(--emerald-300);
  box-shadow: 0 0 12px rgba(16,185,129,0.3);
}
.quiz-option.incorrect .quiz-option-letter {
  background: rgba(220,38,38,0.2);
  border-color: rgba(220,38,38,0.5);
  color: var(--red-400);
}

.quiz-option-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-top: 3px;
}

.quiz-option.correct  .quiz-option-text { color: var(--emerald-300); }
.quiz-option.incorrect .quiz-option-text { color: var(--red-400); }

.quiz-explanation {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: var(--space-4);
  display: none;
}
.quiz-explanation.show { display: block; }

.quiz-explanation-title {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--emerald-400);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.quiz-footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--gb-white);
  background: rgba(255,255,255,0.015);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.quiz-score-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quiz-result { text-align: center; padding: var(--space-12) var(--space-8); }

.quiz-result-score {
  font-family: var(--font-heading);
  font-size: 4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: var(--space-2);
}

/* ── Flashcard Component ──────────────────────────────────── */
.flashcard-container {
  perspective: 1200px;
  margin: var(--space-8) auto;
  max-width: 600px;
}

.flashcard {
  position: relative;
  width: 100%;
  height: 220px;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
  border: 1px solid var(--gb-white);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  box-shadow: var(--shadow-glass);
}

.flashcard-front { background: var(--glass-2); }

.flashcard-back {
  background: rgba(16,185,129,0.06);
  border-color: var(--gb-em);
  transform: rotateY(180deg);
}

.flashcard-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  font-family: var(--font-heading);
}

.flashcard-term {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.flashcard-definition {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.flashcard-hint {
  position: absolute;
  bottom: var(--space-4);
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.flashcard-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.flashcard-counter {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 60px;
  text-align: center;
}

/* ── Live API Try-It Panel ────────────────────────────────── */
.tryit-panel {
  background: var(--glass-1);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin: var(--space-6) 0;
  box-shadow: var(--shadow-glass);
}

.tryit-header {
  background: var(--glass-2);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--gb-white);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.tryit-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--emerald-400);
  box-shadow: 0 0 8px var(--emerald-400);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--emerald-400); }
  50%       { opacity: 0.5; box-shadow: 0 0 16px var(--emerald-400); }
}

.tryit-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tryit-body { padding: var(--space-6); }

.tryit-field { margin-bottom: var(--space-4); }

.tryit-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-heading);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tryit-input {
  width: 100%;
  background: var(--glass-2);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: var(--space-3) var(--space-4);
  transition: all var(--transition-fast);
  outline: none;
}

.tryit-input:focus-visible {
  border-color: var(--gb-em);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

.tryit-textarea { min-height: 80px; resize: vertical; }

.tryit-response {
  background: var(--glass-1);
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  min-height: 80px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: var(--space-4);
  display: none;
  line-height: 1.6;
}

.tryit-response.show { display: block; }

.tryit-loading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.tryit-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.08);
  border-top-color: var(--emerald-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--glass-1);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  padding: 3px;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1;
  min-width: 100px;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); background: var(--glass-2); }

.tab-btn.active {
  background: var(--glass-2);
  color: var(--emerald-300);
  border: 1px solid var(--gb-em);
  box-shadow: 0 0 12px rgba(16,185,129,0.1), 0 1px 4px rgba(0,0,0,0.3);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Accordion ────────────────────────────────────────────── */
.accordion {
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: var(--space-4) 0;
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  box-shadow: var(--shadow-card);
}

.accordion-item { border-bottom: 1px solid var(--gb-white); }
.accordion-item:last-child { border-bottom: none; }

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--glass-2);
  border: none;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  gap: var(--space-4);
  transition: background var(--transition-fast);
}

.accordion-trigger:hover { background: var(--glass-3); }

.accordion-chevron {
  transition: transform var(--transition-fast);
  color: var(--text-muted);
  flex-shrink: 0;
}

.accordion-item.open .accordion-chevron { transform: rotate(180deg); }

.accordion-body {
  display: none;
  padding: var(--space-5) var(--space-6);
  background: var(--glass-1);
  border-top: 1px solid var(--gb-white);
}

.accordion-item.open .accordion-body { display: block; }

/* ── Completion Checkbox ──────────────────────────────────── */
.completion-bar {
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-8) 0;
  box-shadow: var(--shadow-card);
}

.completion-checkbox {
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--gb-em);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--glass-1);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

.completion-checkbox.checked {
  background: rgba(16,185,129,0.2);
  border-color: var(--emerald-400);
  box-shadow: 0 0 12px var(--accent-glow);
}

.completion-checkbox .check-icon { display: none; color: var(--emerald-300); font-size: 0.9rem; }
.completion-checkbox.checked .check-icon { display: block; }

.completion-label {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.completion-label.checked { color: var(--emerald-400); text-decoration: line-through; }

/* ── Domain Colours ───────────────────────────────────────── */
.domain-p1 { --domain-color: var(--part1-color); }
.domain-p2 { --domain-color: var(--part2-color); }
.domain-p3 { --domain-color: var(--part3-color); }
.domain-p4 { --domain-color: var(--part4-color); }
.domain-p5 { --domain-color: var(--part5-color); }
.domain-p6 { --domain-color: var(--part6-color); }

.domain-accent { color: var(--domain-color); }

.domain-badge {
  background: color-mix(in srgb, var(--domain-color) 10%, transparent);
  color: var(--domain-color);
  border: 1px solid color-mix(in srgb, var(--domain-color) 30%, transparent);
}

.domain-border-left { border-left: 3px solid var(--domain-color); }

/* ── Dashboard helpers ────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-5);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--gb-em);
  box-shadow: var(--shadow-em);
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Topic nav footer ─────────────────────────────────────── */
.topic-nav-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-8) 0;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin-top: var(--space-10);
  gap: var(--space-4);
}

.topic-nav-prev,
.topic-nav-next {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--gb-white);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: all var(--transition-fast);
  max-width: 48%;
  box-shadow: var(--shadow-card);
}

.topic-nav-prev:hover,
.topic-nav-next:hover {
  border-color: var(--gb-em);
  background: var(--glass-em);
  box-shadow: var(--shadow-em);
}

.topic-nav-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }
.topic-nav-title { font-size: 0.875rem; color: var(--text-primary); font-weight: 600; font-family: var(--font-heading); }
.topic-nav-next { text-align: right; margin-left: auto; flex-direction: row-reverse; }

/* ── Utilities ────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.flex-wrap  { flex-wrap: wrap; }
.flex-1     { flex: 1; }
.ml-auto    { margin-left: auto; }
.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary   { color: var(--text-primary); }
.text-center    { text-align: center; }
.font-mono    { font-family: var(--font-mono); }
.font-heading { font-family: var(--font-heading); }
.font-bold    { font-weight: 700; }
.hidden  { display: none; }
.w-full  { width: 100%; }
.rounded-lg { border-radius: var(--radius-lg); }
.border  { border: 1px solid var(--gb-white); }
.overflow-hidden { overflow: hidden; }

/* Glass utility classes */
.glass {
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border: 1px solid var(--gb-white);
  box-shadow: var(--shadow-card);
}

.glass-em {
  background: var(--glass-em);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border: 1px solid var(--gb-em);
  box-shadow: var(--shadow-em);
}

.glow-em { box-shadow: 0 0 20px rgba(16,185,129,0.2); }
.border-em { border-color: var(--gb-em) !important; }

/* Divider */
.divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: var(--space-8) 0;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 20px var(--accent-subtle); }
  50%       { box-shadow: 0 0 40px rgba(16,185,129,0.3); }
}

.animate-fade-in     { animation: fadeIn 0.4s ease forwards; }
.animate-slide-left  { animation: slideInLeft 0.35s ease forwards; }
.animate-scale-in    { animation: scaleIn 0.3s ease forwards; }
.animate-glow        { animation: glowPulse 3s ease-in-out infinite; }

.stagger > * { opacity: 0; animation: fadeIn 0.4s ease forwards; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* ── Responsive ───────────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--gb-white);
  border-radius: 12px;
  color: var(--text-secondary);
  padding: var(--space-2);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
  min-width: 44px;
  min-height: 44px;
}

.menu-toggle:hover {
  background: var(--glass-em);
  border-color: var(--gb-em);
  color: var(--emerald-300);
}

body.sidebar-collapsed .sidebar-logo > :not(.sidebar-logo-icon):not(.sidebar-desktop-toggle) {
  opacity: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

body.sidebar-collapsed .sidebar-logo {
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  width: 100%;
  border-bottom: none;
}

body.sidebar-collapsed .sidebar-logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
}

body.sidebar-collapsed .sidebar-logo-icon::before {
  font-size: 0.62rem;
}

body.sidebar-collapsed .sidebar-nav {
  padding: 10px 6px 8px;
  gap: 8px;
  align-items: center;
  width: 100%;
}

body.sidebar-collapsed #sidebar-search-container,
body.sidebar-collapsed .sidebar-progress,
body.sidebar-collapsed .sidebar-group-title,
body.sidebar-collapsed .sidebar-chevron {
  display: none;
}

body.sidebar-collapsed .sidebar-group {
  margin: 0 0 8px;
  background: transparent;
  border-bottom: none;
  border-radius: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  border: none;
}

body.sidebar-collapsed .sidebar-group-body {
  max-height: 0 !important;
  background: transparent;
}

body.sidebar-collapsed .sidebar-group-header,
body.sidebar-collapsed .sidebar-item {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 46px;
  font-size: 0;
  line-height: 0;
  color: transparent;
  overflow: hidden;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  transition: all var(--transition-fast);
}

body.sidebar-collapsed .sidebar-group-header::before,
body.sidebar-collapsed .sidebar-item::before {
  content: attr(data-short-label);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  pointer-events: none;
  transition: all var(--transition-fast);
}

body.sidebar-collapsed .sidebar-item[data-short-label="⌂"]::before { font-size: 1.25rem; }
body.sidebar-collapsed .sidebar-item[data-short-label="←"]::before { font-size: 1.1rem; }
body.sidebar-collapsed .sidebar-back-sep { display: none; }

body.sidebar-collapsed .sidebar-group.all-done:not(.open) .sidebar-group-header::before {
  color: var(--emerald-400);
  text-shadow: 0 0 8px rgba(16,185,129,0.5);
}

body.sidebar-collapsed .sidebar-settings-toggle::before {
  width: 18px;
  height: 18px;
}

body.sidebar-collapsed .sidebar-item:hover,
body.sidebar-collapsed .sidebar-group-header:hover {
  transform: none;
  background: rgba(255,255,255,0.03);
}

body.sidebar-collapsed .sidebar-item > *,
body.sidebar-collapsed .sidebar-group-header > * {
  opacity: 0;
  width: 0 !important;
  max-width: 0 !important;
  overflow: hidden;
  pointer-events: none;
  flex-shrink: 0;
}

body.sidebar-collapsed .sidebar-item.active::before,
body.sidebar-collapsed .sidebar-group.open .sidebar-group-header::before {
  color: var(--emerald-400);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  text-shadow: 0 0 12px rgba(16,185,129,0.6);
  transform: translate(-50%, -50%) scale(1.15);
}

body.sidebar-collapsed .sidebar-item,
body.sidebar-collapsed .sidebar-group-header {
  border-left-color: transparent;
  transform: none;
}

body.sidebar-collapsed .sidebar-item.active,
body.sidebar-collapsed .sidebar-group.open .sidebar-group-header {
  background: transparent;
  box-shadow: none;
}

body.sidebar-collapsed .sidebar-item:hover::before,
body.sidebar-collapsed .sidebar-group-header:hover::before {
  color: var(--text-primary);
  transform: translate(-50%, -50%) scale(1.05);
}

body.sidebar-collapsed .sidebar-item.sidebar-utility { display: none; }
body.sidebar-collapsed .sidebar-settings-panel { display: none !important; }
body.sidebar-collapsed .sidebar-settings-toggle { margin: auto 0 0; width: 100%; }
body.sidebar-collapsed .sidebar { box-shadow: 8px 0 18px rgba(0,0,0,0.5); }

@media (max-width: 900px) {
  body.sidebar-collapsed { --sidebar-width: var(--sidebar-width-expanded); }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width-expanded);
    min-width: var(--sidebar-width-expanded);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }

  .main-content { margin-left: 0; width: 100%; max-width: 100%; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .sidebar-desktop-toggle { display: none; }
  .page-content { padding: var(--space-6) var(--space-5); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .term-grid { grid-template-columns: 1fr; }
  .topic-nav-footer { flex-direction: column; align-items: stretch; }
  .topic-nav-prev, .topic-nav-next { max-width: 100%; }
  .topic-nav-next { margin-left: 0; }
  .compare-table { display: block; overflow-x: auto; }
  .tabs { gap: 0; }
  .tab-btn { min-width: unset; font-size: 0.75rem; }
}

@media (max-width: 600px) {
  .quiz-body { padding: var(--space-5); }
  .quiz-footer { flex-direction: column; align-items: stretch; }
  .topbar { padding: 0 var(--space-4); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .tryit-panel, .quiz-container, .flashcard-container,
  .topic-nav-footer, .copy-btn, .menu-toggle { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; }
  pre { border: 1px solid #ccc; background: #f5f5f5; color: #000; }
}

/* ============================================================
   DYNAMIC MULTI-COURSE COLOR THEMES (Azure Blue vs ServiceNow Green)
   ============================================================ */

/* 1. Microsoft Azure AI-102 Theme (Azure Blue / Purple) */
body.theme-ai102 {
  --emerald-700: #1d4ed8; /* Blue-700 */
  --emerald-600: #2563eb; /* Blue-600 */
  --emerald-500: #3b82f6; /* Blue-500 */
  --emerald-400: #60a5fa; /* Blue-400 */
  --emerald-300: #93c5fd; /* Blue-300 */
  --emerald-200: #bfdbfe; /* Blue-200 */
  --emerald-100: #dbeafe; /* Blue-100 */

  --glass-em:   rgba(59,130,246,0.07);
  --glass-em-h: rgba(59,130,246,0.13);

  --gb-em:      rgba(59,130,246,0.22);
  --gb-em-h:    rgba(59,130,246,0.45);
  --gb-em-glow: rgba(59,130,246,0.55);

  --text-accent:     var(--emerald-400);
  --border-strong:   var(--gb-em);
  --accent-primary:  var(--emerald-500);
  --accent-glow:     rgba(59,130,246,0.25);
  --accent-green:    var(--emerald-400);

  --shadow-em:    0 0 28px rgba(59,130,246,0.18), 0 4px 24px rgba(0,0,0,0.5);
  --shadow-btn-em:0 0 20px rgba(59,130,246,0.3), 0 4px 16px rgba(0,0,0,0.4),
                  inset 0 1px 0 rgba(255,255,255,0.12);
}

body.theme-ai102 ::-webkit-scrollbar-thumb:hover { background: var(--emerald-600); }

/* 2. ServiceNow CSA Theme (ServiceNow Green / Teal) */
body.theme-csa {
  --emerald-700: #047857; /* Emerald-700 */
  --emerald-600: #059669; /* Emerald-600 */
  --emerald-500: #10b981; /* Emerald-500 */
  --emerald-400: #34d399; /* Emerald-400 */
  --emerald-300: #6ee7b7; /* Emerald-300 */
  --emerald-200: #a7f3d0; /* Emerald-200 */
  --emerald-100: #d1fae5; /* Emerald-100 */

  --glass-em:   rgba(16,185,129,0.07);
  --glass-em-h: rgba(16,185,129,0.13);

  --gb-em:      rgba(16,185,129,0.22);
  --gb-em-h:    rgba(16,185,129,0.45);
  --gb-em-glow: rgba(16,185,129,0.55);

  --text-accent:     var(--emerald-400);
  --border-strong:   var(--gb-em);
  --accent-primary:  var(--emerald-500);
  --accent-glow:     rgba(16,185,129,0.25);
  --accent-green:    var(--emerald-400);

  --shadow-em:    0 0 28px rgba(16,185,129,0.18), 0 4px 24px rgba(0,0,0,0.5);
  --shadow-btn-em:0 0 20px rgba(16,185,129,0.3), 0 4px 16px rgba(0,0,0,0.4),
                  inset 0 1px 0 rgba(255,255,255,0.12);
}

body.theme-csa ::-webkit-scrollbar-thumb:hover { background: var(--emerald-600); }

/* 3. ServiceNow CIS-DF Theme (Cyan/Teal) */
body.theme-cis-df {
  --part1-color: #0e7490;
  --part2-color: #0891b2;
  --part3-color: #06b6d4;
  --part4-color: #22d3ee;
  --part5-color: #67e8f9;
  --part6-color: #a5f3fc;

  --cisdf-700: #0e7490;
  --cisdf-600: #0891b2;
  --cisdf-500: #06b6d4;
  --cisdf-400: #22d3ee;
  --cisdf-300: #67e8f9;
  --cisdf-200: #a5f3fc;

  --glass-cy:   rgba(8,145,178,0.07);
  --glass-cy-h: rgba(8,145,178,0.13);

  --text-accent:     var(--cisdf-400);
  --accent-primary:  var(--cisdf-500);
  --accent-glow:     rgba(8,145,178,0.25);
}

body.theme-cis-df ::-webkit-scrollbar-thumb:hover { background: var(--cisdf-700); }

body.light-mode.theme-cis-df .hero-eyebrow {
  color: #0e7490;
  background: rgba(8,145,178,0.08);
  border-color: rgba(8,145,178,0.22);
}
body.light-mode.theme-cis-df .op-pct        { color: #0e7490; }
body.light-mode.theme-cis-df .next-up-title { color: #0e7490; }
body.light-mode.theme-cis-df .part-mini-link:hover { color: #0e7490; }

/* Body override class for selector portal page state */
body.selector-active {
  background-image:
    radial-gradient(ellipse 80% 50% at 30% -10%, rgba(59,130,246,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 80% 50% at 70% 110%, rgba(16,185,129,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 100% 80% at 50% 50%, rgba(255,255,255,0.01) 0%, transparent 100%);
}

/* ============================================================
   WELCOME SELECTOR GATEWAY PORTAL STYLES
   ============================================================ */

.selector-portal-wrap {
  min-height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  box-sizing: border-box;
}

.selector-container {
  max-width: 960px;
  width: 100%;
  text-align: center;
  animation: slideInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.selector-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
}

.selector-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: var(--space-3);
  background: linear-gradient(135deg, #ffffff 0%, var(--mono-300) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.selector-sub {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 580px;
  margin: 0 auto var(--space-12);
  line-height: 1.6;
}

.selector-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}

.selector-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-2xl);
  padding: var(--space-8) var(--space-8) var(--space-10);
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  transition: all var(--transition-normal);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Custom 3D tilt micro-interactions */
.selector-card:hover {
  transform: translateY(-8px) scale(1.015);
  background: rgba(255,255,255,0.04);
  border-color: var(--accent-color);
  box-shadow: 0 16px 48px rgba(0,0,0,0.65), 0 0 32px var(--shadow-color);
}

.selector-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--accent-gradient);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  opacity: 0.8;
}

/* Define local color contexts for hover highlights */
.selector-card.card-ai102 {
  --accent-color: #3b82f6;
  --accent-gradient: linear-gradient(90deg, #3b82f6, #8b5cf6);
  --shadow-color: rgba(59, 130, 246, 0.15);
}

.selector-card.card-csa {
  --accent-color: #10b981;
  --accent-gradient: linear-gradient(90deg, #10b981, #06b6d4);
  --shadow-color: rgba(16, 185, 129, 0.15);
}

.selector-card-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin-bottom: var(--space-6);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  transition: all var(--transition-normal);
  box-shadow: inset 0 2px 8px rgba(255,255,255,0.03);
}

.selector-card:hover .selector-card-icon {
  background: color-mix(in srgb, var(--accent-color) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent-color) 35%, transparent);
  transform: scale(1.1) rotate(2deg);
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent-color) 20%, transparent);
}

.selector-card-badge {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-color);
  background: color-mix(in srgb, var(--accent-color) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-color) 25%, transparent);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: var(--space-3);
}

.selector-card-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: var(--space-3);
  line-height: 1.25;
}

.selector-card-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-6);
  flex: 1;
  max-width: 320px;
}

/* Selector Card Progress bar container */
.selector-card-progress {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  box-sizing: border-box;
  text-align: left;
}

.selector-prog-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.selector-prog-pct {
  font-weight: 700;
  font-family: var(--font-mono);
  color: #ffffff;
}

.selector-prog-bar {
  height: 6px;
  width: 100%;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.selector-prog-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Action button inside selectors */
.selector-card-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff !important;
  text-decoration: none;
  transition: all var(--transition-fast);
  width: 100%;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.selector-card:hover .selector-card-btn {
  background: var(--accent-color);
  border-color: var(--accent-color);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent-color) 35%, transparent);
}

@media (max-width: 800px) {
  .selector-cards {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
  .selector-card {
    padding: var(--space-6) var(--space-6) var(--space-8);
  }
}

/* ============================================================
   WELCOME HUB v2 — Production Landing Page
   ============================================================ */

/* Violet scale (ServiceNow CSA theme) */
:root {
  --violet-700: #5b21b6;
  --violet-600: #7c3aed;
  --violet-500: #8b5cf6;
  --violet-400: #a78bfa;
  --violet-300: #c4b5fd;
  --violet-200: #ddd6fe;
  --violet-100: #ede9fe;
  --glass-vio:   rgba(124,58,237,0.07);
  --glass-vio-h: rgba(124,58,237,0.13);
  --gb-vio:      rgba(124,58,237,0.25);
  --gb-vio-h:    rgba(124,58,237,0.50);
  --shadow-vio:  0 0 28px rgba(124,58,237,0.20), 0 4px 24px rgba(0,0,0,0.5);
}

/* Full-screen portal container */
#course-selector-portal {
  min-height: 100vh;
  width: 100vw;
  position: relative;
  overflow-x: hidden;
}

/* Animated background layers */
.wh-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.wh-bg-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 85% 85% at 50% 50%, black 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 85% 85% at 50% 50%, black 30%, transparent 100%);
}

.wh-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
}

.wh-orb-1 {
  width: 700px; height: 700px;
  top: -250px; left: -200px;
  background: radial-gradient(circle, rgba(59,130,246,0.14) 0%, transparent 70%);
  animation: whOrbFloat 22s ease-in-out infinite;
}

.wh-orb-2 {
  width: 600px; height: 600px;
  bottom: -200px; right: -150px;
  background: radial-gradient(circle, rgba(124,58,237,0.12) 0%, transparent 70%);
  animation: whOrbFloat 28s ease-in-out infinite reverse;
}

.wh-orb-3 {
  width: 450px; height: 450px;
  top: 45%; left: 55%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(16,185,129,0.06) 0%, transparent 70%);
  animation: whOrbFloat 35s ease-in-out infinite 5s;
}

@keyframes whOrbFloat {
  0%, 100% { transform: translate(0, 0); }
  33%       { transform: translate(40px, -25px); }
  66%       { transform: translate(-25px, 35px); }
}

/* Content wrapper */
.wh-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-8) var(--space-16);
  display: flex;
  flex-direction: column;
}

/* Header bar */
.wh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0 var(--space-10);
}

.wh-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.wh-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--emerald-500) 0%, #3b82f6 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 18px rgba(16,185,129,0.35), 0 2px 8px rgba(0,0,0,0.4);
}

.wh-logo-name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.wh-header-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

/* Hero */
.wh-hero {
  text-align: center;
  padding-bottom: var(--space-12);
  animation: slideInUp 0.55s cubic-bezier(0.16,1,0.3,1) both;
}

.wh-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-7);
}

.wh-eyebrow-dot {
  width: 6px; height: 6px;
  background: var(--emerald-400);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--emerald-400);
  animation: whDotPulse 2.2s ease-in-out infinite;
}

@keyframes whDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(0.8); }
}

.wh-title {
  font-size: clamp(3rem, 7vw, 5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: #fff;
  margin-bottom: var(--space-5);
}

.wh-title-accent {
  background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 55%, var(--emerald-400) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.wh-sub {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto var(--space-10);
  line-height: 1.65;
}

/* Stats pill */
.wh-stats {
  display: inline-flex;
  align-items: center;
  gap: var(--space-6);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 999px;
  padding: var(--space-4) var(--space-8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.wh-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.wh-stat-val {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.wh-stat-lbl {
  font-size: 0.63rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.wh-stat-sep {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,0.08);
  flex-shrink: 0;
}

/* Section divider label */
.wh-section-label {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  animation: slideInUp 0.55s cubic-bezier(0.16,1,0.3,1) 0.12s both;
}

.wh-section-label span {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.wh-section-line {
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.06);
}

/* Course cards stack */
.wh-courses {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-10);
  animation: slideInUp 0.55s cubic-bezier(0.16,1,0.3,1) 0.2s both;
}

/* Individual course card */
.wh-card {
  position: relative;
  background: linear-gradient(145deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.015) 100%);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  box-shadow: var(--shadow-glass);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
}

.wh-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255,255,255,0.025) 0%, transparent 55%);
  border-radius: var(--radius-2xl);
  pointer-events: none;
}

.wh-card:hover {
  transform: translateY(-3px);
  border-color: var(--card-accent-border);
  box-shadow: 0 16px 48px rgba(0,0,0,0.65),
              0 0 0 1px var(--card-accent-border),
              0 0 50px var(--card-glow);
}

.wh-card-ai102 {
  --card-accent-border: rgba(59,130,246,0.45);
  --card-glow: rgba(59,130,246,0.07);
  --card-gradient: linear-gradient(90deg, #3b82f6, #8b5cf6);
  --ring-stroke: #60a5fa;
  --ring-glow: rgba(96,165,250,0.55);
  --vendor-bg: rgba(59,130,246,0.10);
  --vendor-border: rgba(59,130,246,0.22);
  --vendor-clr: #93c5fd;
  --cta-from: #3b82f6;
  --cta-to: #8b5cf6;
  --cta-glow: rgba(59,130,246,0.4);
}

.wh-card-csa {
  --card-accent-border: rgba(124,58,237,0.45);
  --card-glow: rgba(124,58,237,0.07);
  --card-gradient: linear-gradient(90deg, #7c3aed, #a855f7);
  --ring-stroke: #a78bfa;
  --ring-glow: rgba(167,139,250,0.55);
  --vendor-bg: rgba(124,58,237,0.10);
  --vendor-border: rgba(124,58,237,0.22);
  --vendor-clr: #c4b5fd;
  --cta-from: #7c3aed;
  --cta-to: #a855f7;
  --cta-glow: rgba(124,58,237,0.4);
}

.wh-card-cisdf {
  --card-accent-border: rgba(8,145,178,0.45);
  --card-glow: rgba(8,145,178,0.07);
  --card-gradient: linear-gradient(90deg, #0891b2, #22d3ee);
  --ring-stroke: #22d3ee;
  --ring-glow: rgba(34,211,238,0.55);
  --vendor-bg: rgba(8,145,178,0.10);
  --vendor-border: rgba(8,145,178,0.22);
  --vendor-clr: #67e8f9;
  --cta-from: #0891b2;
  --cta-to: #22d3ee;
  --cta-glow: rgba(8,145,178,0.4);
}

/* Top accent stripe */
.wh-card-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-gradient);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

/* NEW badge */
.wh-new-badge {
  position: absolute;
  top: var(--space-4);
  right: var(--space-5);
  font-family: var(--font-heading);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  padding: 3px 9px;
  border-radius: 999px;
  animation: whNewPulse 2.8s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(124,58,237,0.5);
}

@keyframes whNewPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(124,58,237,0.5); }
  50%       { box-shadow: 0 0 22px rgba(124,58,237,0.85), 0 0 42px rgba(124,58,237,0.28); }
}

/* Card inner — horizontal layout */
.wh-card-inner {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
  margin-bottom: var(--space-5);
}

/* Left: progress ring */
.wh-card-left {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.wh-ring-wrap {
  position: relative;
  width: 88px;
  height: 88px;
}

.wh-ring-svg {
  width: 88px;
  height: 88px;
  transform: rotate(-90deg);
}

.wh-ring-track {
  fill: none;
  stroke: rgba(255,255,255,0.07);
  stroke-width: 2.8;
}

.wh-ring-fill {
  fill: none;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke: var(--ring-stroke);
  filter: drop-shadow(0 0 5px var(--ring-glow));
  transition: stroke-dasharray 1.4s cubic-bezier(0.16,1,0.3,1);
}

.wh-ring-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
}

.wh-pct-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ring-stroke);
}

/* Right: course info */
.wh-card-right {
  flex: 1;
  min-width: 0;
}

.wh-vendor-row {
  margin-bottom: var(--space-2);
}

.wh-vendor-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--vendor-bg);
  border: 1px solid var(--vendor-border);
  color: var(--vendor-clr);
}

.wh-exam-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  letter-spacing: 0.04em;
}

.wh-exam-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: var(--space-2);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.wh-exam-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: var(--space-4);
  max-width: 560px;
}

/* 4-column meta grid */
.wh-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.wh-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}

.wh-meta-lbl {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: var(--font-heading);
  font-weight: 700;
}

.wh-meta-val {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

/* Card footer: progress + CTA */
.wh-card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.wh-prog-wrap { flex: 1; }

.wh-prog-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.wh-prog-lbl {
  font-size: 0.67rem;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.wh-prog-pct {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
}

.wh-prog-bar {
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.wh-prog-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1.4s cubic-bezier(0.16,1,0.3,1);
}

.wh-card-ai102  .wh-prog-fill { background: linear-gradient(90deg, #3b82f6, #8b5cf6); }
.wh-card-csa    .wh-prog-fill { background: linear-gradient(90deg, #7c3aed, #a855f7); }
.wh-card-cisdf  .wh-prog-fill { background: linear-gradient(90deg, #0891b2, #22d3ee); }

/* CTA button */
.wh-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff !important;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  background: linear-gradient(135deg, var(--cta-from), var(--cta-to));
  box-shadow: 0 4px 16px var(--cta-glow);
}

.wh-cta:hover {
  box-shadow: 0 6px 26px var(--cta-glow);
  transform: translateY(-1px);
}

.wh-cta-arrow {
  display: inline-block;
  transition: transform var(--transition-fast);
}

.wh-card:hover .wh-cta-arrow { transform: translateX(3px); }

/* Welcome footer */
.wh-footer {
  text-align: center;
  padding: var(--space-6) 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255,255,255,0.05);
}

/* Back to hub button (in topbar) */
.back-to-hub-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted) !important;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.back-to-hub-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #fff !important;
  border-color: rgba(255,255,255,0.16);
}

/* Responsive */
@media (max-width: 700px) {
  .wh-wrap { padding: var(--space-5) var(--space-5) var(--space-12); }
  .wh-hero { padding-bottom: var(--space-8); }
  .wh-title { font-size: clamp(2.4rem,9vw,3.2rem); }
  .wh-stats { gap: var(--space-3); padding: var(--space-3) var(--space-5); flex-wrap: wrap; justify-content: center; }
  .wh-stat-sep { display: none; }
  .wh-card-inner { flex-direction: column; gap: var(--space-4); }
  .wh-ring-wrap, .wh-ring-svg { width: 72px; height: 72px; }
  .wh-meta-grid { grid-template-columns: repeat(2,1fr); }
  .wh-card-footer { flex-direction: column; align-items: stretch; gap: var(--space-4); }
  .wh-cta { justify-content: center; }
}

/* ── Screen-reader only utility ────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Skip Link ─────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  z-index: 9999;
  padding: var(--space-3) var(--space-5);
  background: var(--emerald-500);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.875rem;
}
.skip-link:focus {
  left: var(--space-4);
}

/* ── Focus Visible ─────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--emerald-400);
  outline-offset: 3px;
  border-radius: 3px;
}
/* emerald-400 (#34d399) fails 3:1 on light bg — use emerald-700 instead */
body.light-mode :focus-visible {
  outline-color: #047857;
}

/* ── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Dynamic Viewport Height ───────────────────────────────────────────── */
/* 100vh = static on iOS Safari (ignores URL bar); 100dvh = actual viewport */
@supports (min-height: 100dvh) {
  body,
  .app-shell,
  .main-content,
  .selector-portal-wrap,
  #course-selector-portal,
  body.selector-active .wh-wrap {
    min-height: 100dvh;
  }
  .sidebar {
    height: 100dvh;
  }
}

/* ── Sidebar Overlay ───────────────────────────────────────────────────── */
/* CIS-DF pages define #sidebar-overlay in a per-page <style> block that
   loads AFTER main.css, so !important is required to override their
   backdrop-filter and opaque background. Reduced to 0.4 opacity so the
   dim is softer and doesn't appear as a solid black bar on mobile. */
#sidebar-overlay {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(0,0,0,0.4) !important;
}

/* ── Sidebar responsive width at intermediate viewports ────────────────── */
/* At 901-1280px the 280px sidebar is proportionally too wide.
   Reducing to 240px gives content more room without collapsing to icon mode. */
@media (min-width: 901px) and (max-width: 1280px) {
  :root { --sidebar-width-expanded: 240px; }
}

/* ── Visual Flow Diagrams ──────────────────────────────────────────────── */
/* .vflow  = vertical step-by-step flow with spine, numbered badges, branches
   .hflow  = horizontal pipeline (short sequential steps)
   Used in CIS-DF topic pages to replace text-arrow .flow-diagram layouts. */

/* Vertical flow container */
.vflow { margin: var(--space-6) 0; }

.vflow-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0 var(--space-4);
}

.vflow-spine {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Circular step badge */
.vflow-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800; font-size: 0.82rem;
  flex-shrink: 0; position: relative; z-index: 1;
}
.vflow-num.n-in  { background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.15); color: var(--text-muted); font-size: 1rem; }
.vflow-num.n-1   { background: rgba(59,130,246,0.14);  border: 2px solid rgba(59,130,246,0.45);  color: #93c5fd; }
.vflow-num.n-2   { background: rgba(8,145,178,0.14);   border: 2px solid rgba(8,145,178,0.45);   color: #22d3ee; }
.vflow-num.n-3   { background: rgba(245,158,11,0.12);  border: 2px solid rgba(245,158,11,0.4);   color: #fcd34d; }
.vflow-num.n-ok  { background: rgba(16,185,129,0.12);  border: 2px solid rgba(16,185,129,0.4);   color: #6ee7b7; }
.vflow-num.n-err { background: rgba(239,68,68,0.12);   border: 2px solid rgba(239,68,68,0.35);   color: #fca5a5; }

/* Connector spine line */
.vflow-line {
  width: 2px; flex: 1; min-height: 16px; margin: 2px 0;
}
.vflow-line.l-in  { background: linear-gradient(to bottom, rgba(255,255,255,0.1), rgba(59,130,246,0.3)); }
.vflow-line.l-1   { background: linear-gradient(to bottom, rgba(59,130,246,0.4), rgba(8,145,178,0.3)); }
.vflow-line.l-2   { background: linear-gradient(to bottom, rgba(8,145,178,0.4), rgba(245,158,11,0.3)); }
.vflow-line.l-3   { background: linear-gradient(to bottom, rgba(245,158,11,0.35), rgba(16,185,129,0.3)); }
.vflow-line.l-def { background: linear-gradient(to bottom, rgba(255,255,255,0.15), rgba(255,255,255,0.04)); }

/* Step content area */
.vflow-body { padding-bottom: var(--space-5); padding-top: 4px; }

.vflow-phase {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; margin-bottom: 3px;
}
.vflow-phase.c-in  { color: var(--text-muted); }
.vflow-phase.c-1   { color: #93c5fd; }
.vflow-phase.c-2   { color: #22d3ee; }
.vflow-phase.c-3   { color: #fcd34d; }
.vflow-phase.c-ok  { color: #6ee7b7; }
.vflow-phase.c-def { color: var(--text-muted); }

.vflow-title {
  font-family: var(--font-heading);
  font-size: 1rem; font-weight: 700; line-height: 1.3;
  margin-bottom: var(--space-2);
}
.vflow-title.c-in  { color: var(--text-primary); }
.vflow-title.c-1   { color: #93c5fd; }
.vflow-title.c-2   { color: #22d3ee; }
.vflow-title.c-3   { color: #fcd34d; }
.vflow-title.c-ok  { color: #6ee7b7; }
.vflow-title.c-def { color: var(--text-primary); }

.vflow-desc {
  font-size: 0.85rem; color: var(--text-secondary);
  line-height: 1.65; margin-bottom: var(--space-3);
}

/* Source/step pills */
.vflow-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-1); }
.vflow-tag {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,0.05); border: 1px dashed rgba(255,255,255,0.14);
  border-radius: var(--radius-sm); padding: 2px 10px;
  font-size: 0.72rem; color: var(--text-muted);
  font-family: var(--font-heading); font-weight: 600; letter-spacing: 0.04em;
}

/* Decision branches */
.vflow-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-3); margin-top: var(--space-3);
}
.vflow-branch {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border: 1px solid; position: relative;
}
.vflow-branch-tag {
  position: absolute; top: -9px; left: 12px;
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 1px 7px; border-radius: 20px;
}
.vflow-branch.br-yes   { background: rgba(8,145,178,0.07);   border-color: rgba(8,145,178,0.28); }
.vflow-branch.br-no    { background: rgba(245,158,11,0.06);  border-color: rgba(245,158,11,0.25); }
.vflow-branch.br-multi { background: rgba(239,68,68,0.06);   border-color: rgba(239,68,68,0.22); }
.vflow-branch.br-ok    { background: rgba(16,185,129,0.07);  border-color: rgba(16,185,129,0.25); }
.vflow-branch.br-yes   .vflow-branch-tag { background: rgba(8,145,178,0.18);  color: #22d3ee; border: 1px solid rgba(8,145,178,0.35); }
.vflow-branch.br-no    .vflow-branch-tag { background: rgba(245,158,11,0.15); color: #fcd34d; border: 1px solid rgba(245,158,11,0.3); }
.vflow-branch.br-multi .vflow-branch-tag { background: rgba(239,68,68,0.14);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.28); }
.vflow-branch.br-ok    .vflow-branch-tag { background: rgba(16,185,129,0.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.vflow-branch-name {
  font-family: var(--font-heading); font-weight: 700;
  font-size: 0.84rem; margin: 6px 0 4px;
}
.vflow-branch.br-yes   .vflow-branch-name { color: #a5f3fc; }
.vflow-branch.br-no    .vflow-branch-name { color: #fde68a; }
.vflow-branch.br-multi .vflow-branch-name { color: #fecaca; }
.vflow-branch.br-ok    .vflow-branch-name { color: #a7f3d0; }
.vflow-branch-body { font-size: 0.78rem; line-height: 1.55; }
.vflow-branch.br-yes   .vflow-branch-body { color: #a5f3fc; opacity: 0.88; }
.vflow-branch.br-no    .vflow-branch-body { color: #fde68a; opacity: 0.88; }
.vflow-branch.br-multi .vflow-branch-body { color: #fecaca; opacity: 0.88; }
.vflow-branch.br-ok    .vflow-branch-body { color: #a7f3d0; opacity: 0.88; }

/* Horizontal pipeline flow */
.hflow {
  display: flex; align-items: flex-start; gap: 0; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: thin;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-xl); padding: var(--space-6) var(--space-5);
  margin: var(--space-5) 0;
}
.hflow-phase-group { display: flex; align-items: flex-start; gap: 0; flex-shrink: 0; }
.hflow-phase-label {
  writing-mode: vertical-rl; text-orientation: mixed;
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; align-self: center;
  padding: var(--space-2) 4px; border-radius: var(--radius-sm);
  margin-right: var(--space-3); flex-shrink: 0;
}
.hflow-phase-label.ph-1  { color: #93c5fd; background: rgba(59,130,246,0.1);  border: 1px solid rgba(59,130,246,0.22); }
.hflow-phase-label.ph-2  { color: #22d3ee; background: rgba(8,145,178,0.1);   border: 1px solid rgba(8,145,178,0.22); }
.hflow-phase-label.ph-3  { color: #fcd34d; background: rgba(245,158,11,0.1);  border: 1px solid rgba(245,158,11,0.22); }
.hflow-phase-label.ph-ok { color: #6ee7b7; background: rgba(16,185,129,0.1);  border: 1px solid rgba(16,185,129,0.22); }
.hflow-steps { display: flex; align-items: center; gap: 0; }
.hflow-node  { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }
.hflow-box {
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3);
  font-family: var(--font-heading); font-size: 0.74rem; font-weight: 700;
  border: 1px solid; text-align: center; line-height: 1.3; max-width: 150px;
}
.hflow-num   { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-muted); font-weight: 600; }
.hflow-arrow { color: rgba(255,255,255,0.22); font-size: 1rem; flex-shrink: 0; padding: 0 4px; align-self: center; margin-top: -14px; }
.hflow-phase-sep { width: 1px; align-self: stretch; background: rgba(255,255,255,0.08); margin: 0 var(--space-3); flex-shrink: 0; }
.hflow-box.h-1  { background: rgba(59,130,246,0.1);  border-color: rgba(59,130,246,0.28);  color: #93c5fd; }
.hflow-box.h-2  { background: rgba(8,145,178,0.1);   border-color: rgba(8,145,178,0.28);   color: #22d3ee; }
.hflow-box.h-3  { background: rgba(245,158,11,0.1);  border-color: rgba(245,158,11,0.28);  color: #fcd34d; }
.hflow-box.h-ok { background: rgba(16,185,129,0.1);  border-color: rgba(16,185,129,0.28);  color: #6ee7b7; }

@media (max-width: 600px) {
  .vflow-branches { grid-template-columns: 1fr; }
  .hflow { flex-direction: column; align-items: stretch; overflow-x: unset; }
  .hflow-phase-group { flex-direction: column; }
  .hflow-phase-label { writing-mode: horizontal-tb; margin-right: 0; margin-bottom: var(--space-2); }
  .hflow-steps { flex-direction: column; }
  .hflow-arrow { transform: rotate(90deg); }
  .hflow-phase-sep { width: 100%; height: 1px; margin: var(--space-3) 0; align-self: unset; }
}
