/* ============================================
   StudyVault v2 — Warm & Friendly Study Theme
   ============================================ */

/* --- Google Fonts loaded via <link> in HTML <head> for performance --- */

/* --- OpenDyslexic (local) --- */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Regular.woff2') format('woff2'),
       url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Bold.woff2') format('woff2'),
       url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Italic.woff2') format('woff2'),
       url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Italic.woff') format('woff');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Bold-Italic.woff2') format('woff2'),
       url('../fonts/opendyslexic-0.91.12/compiled/OpenDyslexic-Bold-Italic.woff') format('woff');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* --- Page Transitions --- */
body {
  opacity: 0;
  animation: page-enter 0.3s ease-out forwards;
}

body.page-exit {
  animation: page-leave 0.2s ease-in forwards;
}

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

@keyframes page-leave {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-4px); }
}

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

:root {
  /* Base palette */
  --bg-body: #faf8f5;
  --bg-card: #ffffff;
  --text-primary: #2d2a26;
  --text-secondary: #6b6560;
  --text-muted: #9b9590;
  --border-light: #e8e4df;
  --border-lighter: #f0ece7;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(45, 42, 38, 0.06);
  --shadow-md: 0 4px 12px rgba(45, 42, 38, 0.08);
  --shadow-lg: 0 8px 24px rgba(45, 42, 38, 0.1);

  /* Exam tip (always amber) */
  --exam-tip-bg: #fffbeb;
  --exam-tip-border: #f59e0b;
  --exam-tip-text: #92400e;

  /* Unit accent — overridden by body class */
  --accent: #2d2a26;
  --accent-light: #f0ece7;
  --accent-badge: #e8e4df;

  /* Layout */
  --content-max: 760px;
  --sidebar-width: 260px;
  --page-max: 1160px;
  --radius: 16px;
  --radius-sm: 10px;
}

/* --- Unit colour themes --- */
body.unit-conflict {
  --accent: #c44536;
  --accent-light: #fdf2f0;
  --accent-badge: #fce8e5;
}

body.unit-health {
  --accent: #0d9488;
  --accent-light: #f0fdfa;
  --accent-badge: #ccfbf1;
}

body.unit-elizabethan {
  --accent: #b45309;
  --accent-light: #fffbeb;
  --accent-badge: #fef3c7;
}

body.unit-america {
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --accent-badge: #dbeafe;
}

body.unit-business-1 {
  --accent: #0891b2;
  --accent-light: #ecfeff;
  --accent-badge: #cffafe;
}

body.unit-business-2 {
  --accent: #059669;
  --accent-light: #ecfdf5;
  --accent-badge: #d1fae5;
}

body.unit-geography-1 {
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --accent-badge: #e0e7ff;
}

body.unit-geography-2 {
  --accent: #dc2626;
  --accent-light: #fef2f2;
  --accent-badge: #fee2e2;
}

body.unit-sport-science {
  --accent: #ea580c;
  --accent-light: #fff7ed;
  --accent-badge: #ffedd5;
}

body.unit-drama-1 {
  --accent: #7c3aed;
  --accent-light: #f5f3ff;
  --accent-badge: #ede9fe;
}

body.unit-drama-2 {
  --accent: #7c3aed;
  --accent-light: #f5f3ff;
  --accent-badge: #ede9fe;
}
body.unit-food-technology-1 {
  --accent: #0d9488;
  --accent-light: #f0fdfa;
  --accent-badge: #ccfbf1;
}

body.unit-christianity-beliefs {
  --accent: #1e40af;
  --accent-light: #eef0fb;
  --accent-badge: #d4daf4;
}

body.unit-christianity-practices {
  --accent: #0284c7;
  --accent-light: #ecf7fe;
  --accent-badge: #cdedf9;
}

body.unit-islam-beliefs {
  --accent: #047857;
  --accent-light: #ecfdf5;
  --accent-badge: #d1fae5;
}

body.unit-islam-practices {
  --accent: #15803d;
  --accent-light: #f0fdf4;
  --accent-badge: #dcfce7;
}

body.unit-theme-a-relationships {
  --accent: #be185d;
  --accent-light: #fdf2f8;
  --accent-badge: #fce7f3;
}

body.unit-theme-b-religion-life {
  --accent: #65a30d;
  --accent-light: #f7fee7;
  --accent-badge: #ecfccb;
}

body.unit-theme-d-peace-conflict {
  --accent: #92400e;
  --accent-light: #fdf8f0;
  --accent-badge: #fcefd4;
}

body.unit-theme-e-crime-punishment {
  --accent: #6d28d9;
  --accent-light: #f5f3ff;
  --accent-badge: #ede9fe;
}

/* --- Typography --- */
html, body {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--text-primary);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  line-height: 1.3;
  font-weight: 700;
  color: var(--text-primary);
}

h1 { font-size: 2.15rem; font-weight: 800; margin-bottom: 0.5em; }
h2 { font-size: 1.55rem; margin-bottom: 0.4em; }
h3 { font-size: 1.2rem; margin-bottom: 0.3em; }
h4 { font-size: 1.05rem; margin-bottom: 0.25em; font-weight: 600; }

p {
  margin-bottom: 1em;
}

strong {
  font-weight: 600;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

ul, ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.35em;
}

/* --- Scroll Progress Bar --- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 4px;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* --- Page Header (Lesson) --- */
.page-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 900;
}

.page-header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.header-brand:hover {
  text-decoration: none;
  opacity: 1;
}

.header-logo {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
}

.logo-lock {
  width: 0.3em;
  height: 0.3em;
  vertical-align: -0.06em;
  margin-left: 0.04em;
  fill: currentColor;
}

.logo-lock-keyhole {
  fill: #fff;
}

.header-unit-label,
.header-lesson-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-badge);
  padding: 0.2em 0.7em;
  border-radius: 999px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-nav a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.35em 0.75em;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease, color 0.2s ease;
  text-align: center;
}

.header-nav a:hover {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
  opacity: 1;
}

.header-nav a .nav-icon {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
  margin-right: 0.2em;
}

.header-nav a .nav-icon svg {
  width: 100%;
  height: 100%;
}

.header-nav a.nav-exam-technique .nav-icon {
  color: #7c3aed;
}

.header-nav a.nav-revision-techniques .nav-icon {
  color: #16a34a;
}

.header-nav a.nav-exam-technique:hover .nav-icon {
  color: #6d28d9;
}

.header-nav a.nav-revision-techniques:hover .nav-icon {
  color: #15803d;
}

body.dark-mode .header-nav a.nav-exam-technique .nav-icon {
  color: #a78bfa;
}

body.dark-mode .header-nav a.nav-revision-techniques .nav-icon {
  color: #4ade80;
}

.header-nav a.nav-lesson-pill {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.3em 0.85em;
  border-radius: 999px;
  white-space: nowrap;
}

.header-nav a.nav-lesson-pill:hover {
  background: var(--accent);
  color: #fff;
  opacity: 0.88;
  text-decoration: none;
}

/* Mobile hamburger */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text-primary);
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

/* ============================
   Lesson Page — Two-Column Layout
   ============================ */
.lesson-page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 3rem;
  align-items: start;
}

/* Main content column */
.lesson-content {
  min-width: 0; /* prevent grid blowout */
}

/* Legacy single-column fallback */
.lesson-container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* Lesson title area */
.lesson-header {
  margin-bottom: 2.5rem;
}

.lesson-number {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-badge);
  padding: 0.3em 0.85em;
  border-radius: 999px;
  margin-bottom: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.lesson-header h1 {
  font-size: 2.15rem;
  line-height: 1.2;
  margin-bottom: 0;
}

/* --- Sidebar --- */
.lesson-sidebar {
  position: sticky;
  top: 5rem; /* below sticky header */
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.3s;
}
.lesson-sidebar:hover {
  scrollbar-color: var(--accent) transparent;
}
.lesson-sidebar::-webkit-scrollbar { width: 4px; }
.lesson-sidebar::-webkit-scrollbar-track { background: transparent; }
.lesson-sidebar::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 2px;
  transition: background 0.3s;
}
.lesson-sidebar:hover::-webkit-scrollbar-thumb { background: var(--accent); }

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow: hidden;
  box-sizing: border-box;
  max-width: 100%;
  flex-shrink: 0;
}

.sidebar-section-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}



/* --- Lesson Hero Image --- */
.lesson-hero-image {
  position: relative;
  margin: 0 0 2.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.lesson-hero-image img {
  display: block;
  width: 100%;
  height: 280px;
  object-fit: cover;
  object-position: center top;
  cursor: pointer;
}

.lesson-hero-image::after {
  content: '\2197  Click to expand';
  font-family: system-ui, sans-serif;
  font-weight: 600;
  position: absolute;
  bottom: calc(1.8rem + 1px);
  right: 0.75rem;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.45);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lesson-hero-image:hover::after {
  opacity: 1;
}

.lesson-hero-image figcaption {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border-lighter);
}

@media (max-width: 768px) {
  .lesson-hero-image img {
    height: 200px;
  }
}

/* --- Accessibility Toolbar --- */
.a11y-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 0.6rem 1rem;
  margin: 0 0 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-lighter);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.a11y-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border-lighter);
  border-radius: 6px;
  background: var(--bg-body);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  transition: background 0.2s, border-color 0.2s;
}

.a11y-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.a11y-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.a11y-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.a11y-overlay-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.a11y-overlay-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 0.15rem;
}

.a11y-overlay {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border-lighter);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-overlay svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.a11y-overlay:hover {
  transform: scale(1.15);
}

.a11y-overlay.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-body), 0 0 0 3.5px var(--text-primary);
}

/* Dyslexia-friendly mode — OpenDyslexic, weighted bottoms to reduce letter-swapping */
body.dyslexia-font,
body.dyslexia-font .study-notes,
body.dyslexia-font .study-notes p,
body.dyslexia-font .study-notes li,
body.dyslexia-font .key-fact,
body.dyslexia-font .exam-tip,
body.dyslexia-font .conclusion,
body.dyslexia-font .collapsible-inner,
body.dyslexia-font .timeline-event p,
body.dyslexia-font .practice-question-text,
body.dyslexia-font .practice-answer-input {
  font-family: 'OpenDyslexic', sans-serif;
  letter-spacing: 0.02em;
  word-spacing: 0.08em;
  line-height: 1.85;
}

body.dyslexia-font h1,
body.dyslexia-font h2,
body.dyslexia-font h3,
body.dyslexia-font h4 {
  font-family: 'OpenDyslexic', sans-serif;
}

/* Irlen overlay colours */
body.overlay-yellow { background-color: #fef9c3; }
body.overlay-blue   { background-color: #dbeafe; }
body.overlay-pink   { background-color: #fce7f3; }
body.overlay-green  { background-color: #dcfce7; }
body.overlay-peach  { background-color: #fed7aa; }
body.overlay-aqua   { background-color: #cffafe; }

/* --- Dark Mode --- */
body.dark-mode {
  --bg-body: #1c1b19;
  --bg-card: #2a2826;
  --text-primary: #e8e4df;
  --text-secondary: #a39e98;
  --text-muted: #7a756f;
  --border-light: #3a3836;
  --border-lighter: #2f2d2b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
  --exam-tip-bg: #332d1f;
  --exam-tip-border: #d97706;
  --exam-tip-text: #fbbf24;
  background-color: var(--bg-body);
}

body.dark-mode.unit-conflict {
  --accent-light: #2e2220;
  --accent-badge: #3a2a27;
}

body.dark-mode.unit-health {
  --accent-light: #1a2e2c;
  --accent-badge: #203a37;
}

body.dark-mode.unit-elizabethan {
  --accent-light: #2e2618;
  --accent-badge: #3a3020;
}

body.dark-mode.unit-america {
  --accent-light: #1a2240;
  --accent-badge: #202a4a;
}

body.dark-mode.unit-business-1 {
  --accent-light: #164e63;
  --accent-badge: #1e3a5f;
}

body.dark-mode.unit-business-2 {
  --accent-light: #14332a;
  --accent-badge: #1a3d34;
}

body.dark-mode.unit-geography-1 {
  --accent-light: #1e1b4b;
  --accent-badge: #272463;
}

body.dark-mode.unit-geography-2 {
  --accent-light: #2e1a1a;
  --accent-badge: #3a2020;
}

body.dark-mode.unit-sport-science {
  --accent-light: #431407;
  --accent-badge: #7c2d12;
}

body.dark-mode.unit-drama-1 {
  --accent-light: #2e1065;
  --accent-badge: #3b0764;
}

body.dark-mode.unit-drama-2 {
  --accent-light: #2e1065;
  --accent-badge: #3b0764;
}
body.dark-mode.unit-food-technology-1 {
  --accent-light: #1a2e2c;
  --accent-badge: #203a37;
}

body.dark-mode.unit-christianity-beliefs {
  --accent-light: #1a2040;
  --accent-badge: #20284a;
}

body.dark-mode.unit-christianity-practices {
  --accent-light: #0c2a3e;
  --accent-badge: #12344a;
}

body.dark-mode.unit-islam-beliefs {
  --accent-light: #14332a;
  --accent-badge: #1a3d34;
}

body.dark-mode.unit-islam-practices {
  --accent-light: #14532d;
  --accent-badge: #166534;
}

body.dark-mode.unit-theme-a-relationships {
  --accent-light: #3b0a2a;
  --accent-badge: #4a1035;
}

body.dark-mode.unit-theme-b-religion-life {
  --accent-light: #263b10;
  --accent-badge: #304a16;
}

body.dark-mode.unit-theme-d-peace-conflict {
  --accent-light: #3a2010;
  --accent-badge: #4a2a16;
}

body.dark-mode.unit-theme-e-crime-punishment {
  --accent-light: #2e1065;
  --accent-badge: #3b0764;
}

body.dark-mode img {
  opacity: 0.9;
}

body.dark-mode .term-popup {
  background: #e8e4df;
  color: #1c1b19;
}

body.dark-mode .term-popup::after {
  border-top-color: #e8e4df;
}

body.dark-mode .term.term-flip .term-popup::after {
  border-top-color: transparent;
  border-bottom-color: #e8e4df;
}

/* Dark mode + Irlen overlays: muted versions */
body.dark-mode.overlay-yellow { background-color: #2e2b1a; }
body.dark-mode.overlay-blue   { background-color: #1a2030; }
body.dark-mode.overlay-pink   { background-color: #2e1a26; }
body.dark-mode.overlay-green  { background-color: #1a2e1f; }
body.dark-mode.overlay-peach  { background-color: #2e241a; }
body.dark-mode.overlay-aqua   { background-color: #1a2a2e; }

/* Ensure cards still look okay in dark mode */
body.dark-mode .key-fact,
body.dark-mode .exam-tip,
body.dark-mode .conclusion,
body.dark-mode .narration-player,
body.dark-mode .a11y-toolbar,
body.dark-mode .sidebar-section,
body.dark-mode .practice-question-card {
  border-color: var(--border-light);
}

body.dark-mode .narration-highlight,
body.dark-mode [data-narration-id].narration-active {
  background-color: #332d1a;
}

body.dark-mode .collapsible.narration-reading > .collapsible-toggle {
  background: linear-gradient(90deg, transparent 25%, #3a3520 45%, #4a4225 50%, #3a3520 55%, transparent 75%);
  background-size: 200% 100%;
  background-color: #2e2b1f;
}

body.dark-mode .practice-mark-scheme {
  background: #2a2826;
  color: var(--text-primary);
}

body.dark-mode .practice-mark-scheme .ms-level-desc,
body.dark-mode .practice-mark-scheme .ms-example,
body.dark-mode .practice-mark-scheme .ms-spag {
  color: var(--text-primary);
}

body.dark-mode .practice-mark-scheme .ms-example {
  background: #353331;
}

/* --- Font Size --- */
body.font-size-down-1 { font-size: 15px; }
body.font-size-up-1   { font-size: 18px; }
body.font-size-up-2   { font-size: 20px; }

/* A11y toolbar separator */
.a11y-separator {
  width: 1px;
  height: 20px;
  background: var(--border-light);
  flex-shrink: 0;
}

/* Font size button group */
.a11y-font-size-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.a11y-font-size-group .a11y-btn {
  min-width: 30px;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

/* --- Glossary Terms --- */
.term {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  cursor: help;
  position: relative;
  font-style: normal;
}

@media (hover: hover) {
  .term:hover {
    text-decoration-color: var(--text-primary);
  }
}

.term-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 280px;
  padding: 0.6rem 0.8rem;
  background: var(--text-primary);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Arrow pointing down */
.term-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text-primary);
}

.term.term-visible .term-popup {
  opacity: 1;
  pointer-events: auto;
}

/* Flip popup below if near top of viewport (added via JS) */
.term.term-flip .term-popup {
  bottom: auto;
  top: calc(100% + 8px);
}

.term.term-flip .term-popup::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--text-primary);
}

/* Dyslexia mode: use OpenDyslexic in popups too */
body.dyslexia-font .term-popup {
  font-family: 'OpenDyslexic', sans-serif;
}

/* Ensure cards still look okay on coloured backgrounds */
body[class*="overlay-"] .key-fact,
body[class*="overlay-"] .exam-tip,
body[class*="overlay-"] .conclusion,
body[class*="overlay-"] .narration-player,
body[class*="overlay-"] .a11y-toolbar,
body[class*="overlay-"] .sidebar-section {
  background: rgba(255, 255, 255, 0.7);
}

/* --- Narration Player --- */
.sidebar-video {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.sidebar-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.sidebar-section:has(.sidebar-video) {
  overflow: hidden;
}

/* --- Sidebar Collapsible Media --- */
.sidebar-collapsible {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.sidebar-collapsible:last-child {
  margin-bottom: 0;
}

.sidebar-collapsible-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg-card);
  border: none;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  transition: background 0.2s ease;
}

.sidebar-collapsible-toggle:hover {
  background: var(--accent-light);
}

.sidebar-collapsible-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.sidebar-collapsible.open .sidebar-collapsible-icon {
  transform: rotate(180deg);
}

.sidebar-collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.sidebar-collapsible.open .sidebar-collapsible-content {
  max-height: none;
  overflow: visible;
}

.sidebar-media-item {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  border-top: 1px solid var(--border-light);
  transition: background 0.2s ease;
}

.sidebar-media-item:hover {
  background: var(--accent-light);
  text-decoration: none;
  opacity: 1;
}

.sidebar-media-item strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.sidebar-media-item span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 0.15rem;
}

/* --- Knowledge Check --- */
.sidebar-knowledge-check {
  padding: 0.75rem !important;
}

.knowledge-check-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  font-family: inherit;
  color: var(--accent);
}

.knowledge-check-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
}

.knowledge-check-btn:hover svg {
  color: white;
}

.knowledge-check-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}

.knowledge-check-label {
  font-size: 0.82rem;
  font-weight: 600;
  flex: 1;
  text-align: left;
}

.knowledge-check-score {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent);
  color: white;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  line-height: 1.3;
}

.knowledge-check-score:empty {
  display: none;
}

.knowledge-check-btn:hover .knowledge-check-score {
  background: white;
  color: var(--accent);
}

/* Knowledge Check Modal */
.kc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: kc-fade-in 0.2s ease;
}

@keyframes kc-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.kc-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  animation: kc-slide-up 0.25s ease;
}

@keyframes kc-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.kc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-lighter);
}

.kc-title {
  font-family: 'Source Serif 4', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.kc-step {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kc-body {
  padding: 1.5rem 1.25rem;
}

.kc-question {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.45;
}

/* MCQ options */
.kc-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.kc-option {
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--border-lighter);
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-align: left;
}

.kc-option:hover:not(.locked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.kc-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.kc-option.correct {
  border-color: #059669;
  background: #d1fae5;
  color: #065f46;
}

.kc-option.incorrect {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
}

.kc-option.locked {
  cursor: default;
}

/* Fill in the blank */
.kc-fill-sentence {
  font-size: 0.92rem;
  line-height: 1.6;
}

.kc-blank {
  display: inline-block;
  min-width: 80px;
  padding: 0.15rem 0.5rem;
  border-bottom: 2px dashed var(--border-lighter);
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.kc-blank.filled {
  border-color: var(--accent);
  color: var(--accent);
}

.kc-blank.correct {
  border-color: #059669;
  color: #065f46;
  border-style: solid;
}

.kc-blank.incorrect {
  border-color: #dc2626;
  color: #991b1b;
  border-style: solid;
}

.kc-fill-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}

.kc-fill-btn {
  padding: 0.45rem 0.85rem;
  border: 2px solid var(--border-lighter);
  border-radius: 20px;
  background: var(--bg-main);
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kc-fill-btn:hover:not(.locked) {
  border-color: var(--accent);
}

.kc-fill-btn.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.kc-fill-btn.correct {
  border-color: #059669;
  background: #d1fae5;
  color: #065f46;
}

.kc-fill-btn.incorrect {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
}

.kc-fill-btn.locked {
  cursor: default;
}

/* Match up */
.kc-match {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kc-match-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kc-match-row.correct {
  border-color: #059669;
  background: #d1fae5;
}

.kc-match-row.incorrect {
  border-color: #dc2626;
  background: #fee2e2;
}

.kc-match-left {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 80px;
  max-width: 55%;
  flex-shrink: 1;
  word-break: break-word;
}

.kc-match-select {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  border: 2px solid var(--border-lighter);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text-primary);
  background: var(--bg-main);
  cursor: pointer;
}

.kc-match-select:focus {
  outline: none;
  border-color: var(--accent);
}

.kc-match-select:disabled {
  opacity: 0.7;
  cursor: default;
}

.kc-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-lighter);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.kc-btn {
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.kc-btn:hover {
  transform: translateY(-1px);
}

.kc-btn-primary {
  background: var(--accent);
  color: white;
}

.kc-btn-primary:hover {
  filter: brightness(1.1);
}

.kc-btn-secondary {
  background: var(--border-lighter);
  color: var(--text-secondary);
}

.kc-btn-secondary:hover {
  background: var(--border-light);
}

/* Results screen */
.kc-result {
  text-align: center;
  padding: 1.5rem 1.25rem 1rem;
}

.kc-result-score {
  font-family: 'Source Serif 4', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.kc-result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.kc-result-msg {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Dark mode overrides */
body.dark-mode .kc-option.correct,
body.dark-mode .kc-fill-btn.correct,
body.dark-mode .kc-match-row.correct,
body.dark-mode .kc-blank.correct {
  background: #064e3b;
  color: #6ee7b7;
  border-color: #065f46;
}

body.dark-mode .kc-option.incorrect,
body.dark-mode .kc-fill-btn.incorrect,
body.dark-mode .kc-match-row.incorrect,
body.dark-mode .kc-blank.incorrect {
  background: #7f1d1d;
  color: #fca5a5;
  border-color: #991b1b;
}

.narration-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  margin: 0 0 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-lighter);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.narration-play {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

.narration-play:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

.narration-play svg {
  width: 16px;
  height: 16px;
}

.narration-play .narration-icon-pause { display: none; }
.narration-play.playing .narration-icon-play { display: none; }
.narration-play.playing .narration-icon-pause { display: block; }

.narration-progress {
  flex: 1;
  height: 6px;
  background: var(--border-lighter);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.narration-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.15s linear;
}

.narration-time {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 5.5rem;
  text-align: center;
}

.narration-speed {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border-lighter);
  border: none;
  border-radius: 4px;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  transition: background 0.2s;
}

.narration-speed:hover {
  background: var(--accent);
  color: #fff;
}

.narration-audio {
  display: none;
}

/* Narration highlight — active paragraph */
[data-narration-id] {
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  [data-narration-id] {
    cursor: pointer;
  }
  [data-narration-id]:hover {
    background-color: rgba(0, 0, 0, 0.02);
  }
}

[data-narration-id].narration-active {
  background-color: #fef9e7;
  box-shadow: -4px 0 0 #e6b800;
  padding-left: 0.75rem;
}

/* Headings need slightly different treatment */
h2[data-narration-id].narration-active,
h3[data-narration-id].narration-active {
  padding-left: 0.75rem;
}

/* Key facts and other boxed elements */
.key-fact[data-narration-id].narration-active,
.exam-tip[data-narration-id].narration-active,
.conclusion[data-narration-id].narration-active,
.timeline[data-narration-id].narration-active {
  box-shadow: -4px 0 0 #e6b800, var(--shadow-sm);
}

/* When a list inside a key-fact is narrated, highlight the whole box */
.key-fact:has([data-narration-id].narration-active) {
  box-shadow: -4px 0 0 #e6b800, var(--shadow-sm);
  background-color: #fef9e7;
}

/* Lists have their own indentation — don't add extra padding-left */
ul[data-narration-id].narration-active,
ol[data-narration-id].narration-active {
  padding-left: revert;
}

/* Collapsible shimmer when narration is reading collapsed content */
@keyframes narration-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.collapsible.narration-reading > .collapsible-toggle {
  background: linear-gradient(90deg, transparent 25%, #fef3c7 45%, #fde68a 50%, #fef3c7 55%, transparent 75%);
  background-size: 200% 100%;
  background-color: #fefce8;
  border-color: #e6b800;
  box-shadow: -4px 0 0 #e6b800;
  animation: narration-shimmer 2.5s ease-in-out infinite;
}

/* Floating mini-player — appears when main player scrolls out of view */
.narration-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: calc(var(--sidebar-width) + 3rem);
  max-width: calc(100vw - 1.5rem);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-lighter);
  border-radius: 2rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.narration-fab.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.narration-fab-play {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

.narration-fab-play:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

.narration-fab-play svg {
  width: 14px;
  height: 14px;
}

.narration-fab-play .narration-icon-pause { display: none; }
.narration-fab-play.playing .narration-icon-play { display: none; }
.narration-fab-play.playing .narration-icon-pause { display: block; }

.narration-fab-progress {
  flex: 1;
  min-width: 80px;
  height: 4px;
  background: var(--border-lighter);
  border-radius: 2px;
  overflow: hidden;
}

.narration-fab-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s linear;
}

.narration-fab-time {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Responsive: mini-player and narration on mobile */
@media (max-width: 768px) {
  .narration-fab {
    right: 0.75rem;
    bottom: 0.75rem;
    width: calc(100vw - 1.5rem);
    max-width: none;
    padding: 0.85rem 1.15rem;
    gap: 0.85rem;
  }
  .narration-fab-play {
    width: 44px;
    height: 44px;
  }
  .narration-fab-play svg {
    width: 18px;
    height: 18px;
  }
  .narration-fab-progress {
    height: 6px;
    border-radius: 3px;
  }
  .narration-fab-progress-fill {
    border-radius: 3px;
  }
  .narration-fab-time {
    font-size: 0.8rem;
  }
  .narration-player {
    flex-wrap: wrap;
  }
  .narration-progress {
    order: 5;
    flex-basis: 100%;
    margin-top: 0.25rem;
  }
}

/* --- Diagrams --- */
.diagram {
  margin: 1.5rem auto 2rem;
  max-width: 720px;
  text-align: center;
}

.diagram img {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  cursor: zoom-in;
  transition: opacity 0.2s ease;
}
.diagram img:hover { opacity: 0.9; }

/* Concept images (Gemini editorial photos) — smaller, more illustrative */
.diagram--concept img {
  max-width: 400px;
}

.diagram figcaption {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.55rem;
  text-align: left;
  line-height: 1.4;
}

/* --- Image Lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.92);
  transition: transform 0.25s ease;
}
.lightbox-overlay.active img {
  transform: scale(1);
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.lightbox-close:hover { opacity: 1; }

/* --- Study Notes --- */
.study-notes {
  margin-bottom: 2.5rem;
}

.study-notes h2 {
  margin-top: 2.25rem;
  padding-bottom: 0.4em;
  border-bottom: 2px solid var(--border-lighter);
}

.study-notes h3 {
  margin-top: 1.75rem;
  color: var(--text-primary);
}

.study-notes h4 {
  margin-top: 1.25rem;
  color: var(--text-secondary);
}

/* --- Key Fact Box --- */
.key-fact {
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1.15rem 1.35rem;
  margin: 1.5rem 0;
}

.key-fact-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.key-fact p:last-child,
.key-fact ul:last-child {
  margin-bottom: 0;
}

/* --- Exam Tip Box --- */
.exam-tip {
  background: var(--exam-tip-bg);
  border-left: 4px solid var(--exam-tip-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1.15rem 1.35rem;
  margin: 1.5rem 0;
}

.exam-tip-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--exam-tip-text);
  margin-bottom: 0.4rem;
}

.exam-tip p:last-child {
  margin-bottom: 0;
}

/* --- Collapsible Sections --- */
.collapsible {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin: 1.25rem 0;
  overflow: hidden;
}

.collapsible.open {
  overflow: visible;
}

.collapsible-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg-card);
  border: none;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  transition: background 0.2s ease;
}

.collapsible-toggle:hover {
  background: var(--accent-light);
}

.collapsible-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.collapsible.open .collapsible-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible.open .collapsible-content {
  max-height: none;
  overflow: visible;
}

.collapsible-inner {
  padding: 1rem 1.25rem 1.15rem;
}

.collapsible-inner > *:first-child {
  margin-top: 0;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  margin: 2rem 0;
  padding-left: 2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-badge);
  border-radius: 2px;
}

.timeline-event {
  position: relative;
  margin-bottom: 1.75rem;
  padding-left: 1rem;
}

.timeline-event:last-child {
  margin-bottom: 0;
}

.timeline-event::before {
  content: "";
  position: absolute;
  left: -2rem;
  top: 0.45em;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 3px solid var(--bg-body);
  border-radius: 50%;
  z-index: 1;
}

.timeline-date {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.timeline-event h4 {
  margin-top: 0;
  margin-bottom: 0.25em;
  color: var(--text-primary);
}

.timeline-event p {
  margin-bottom: 0;
  color: var(--text-secondary);
  font-size: 0.93rem;
}

/* --- Conclusion Section --- */
.conclusion {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin: 2.5rem 0;
}

.conclusion h2 {
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
  font-size: 1.25rem;
}

.conclusion p:last-child {
  margin-bottom: 0;
}

/* --- Resources (inline fallback, also used in old layout) --- */
.resources {
  margin: 2rem 0;
}

.resources h2 {
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.resource-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.resource-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45em 1em;
  border-radius: 999px;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease;
}

.resource-tag:hover {
  transform: translateY(-1px);
  text-decoration: none;
  opacity: 1;
}

.resource-tag svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.resource-tag.podcast {
  background: #eff6ff;
  color: #3b82f6;
}
.resource-tag.podcast:hover {
  background: #dbeafe;
}

.resource-tag.video {
  background: #fef2f2;
  color: #ef4444;
}
.resource-tag.video:hover {
  background: #fee2e2;
}

.resource-tag.notebook {
  background: #f0fdf4;
  color: #10b981;
}
.resource-tag.notebook:hover {
  background: #dcfce7;
}

/* --- Practice Questions Section --- */
.practice-section {
  margin: 3rem 0 2rem;
  padding-top: 2.5rem;
  border-top: 2px solid var(--border-lighter);
}

.practice-section h2 {
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.practice-intro {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.practice-question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}

.practice-question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.practice-question-type {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-badge);
  padding: 0.25em 0.75em;
  border-radius: 999px;
}

.practice-past-paper-tag {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.practice-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3em 0.5em;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease, background 0.2s ease;
}

.practice-new-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.practice-new-btn svg {
  width: 16px;
  height: 16px;
}

.practice-question-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
  margin-bottom: 0;
}

.practice-mark-scheme {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  margin-top: 1rem;
  display: none;
}

.practice-show-marks {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.5em 0;
  transition: opacity 0.2s ease;
}

.practice-show-marks:hover {
  opacity: 0.7;
}

/* --- Formatted Mark Scheme --- */
.practice-mark-scheme .ms-preamble {
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.82rem;
}

.practice-mark-scheme .ms-level {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 0 6px 6px 0;
}

.practice-mark-scheme .ms-level-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.practice-mark-scheme .ms-level-num {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
}

.practice-mark-scheme .ms-level-marks {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border-lighter);
  padding: 0.15em 0.55em;
  border-radius: 999px;
}

.practice-mark-scheme .ms-level-desc {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.practice-mark-scheme .ms-level-desc:last-child {
  margin-bottom: 0;
}

.practice-mark-scheme .ms-example {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  margin-top: 0.4rem;
  background: var(--border-lighter);
  border-radius: 6px;
}

.practice-mark-scheme .ms-example-label {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.78rem;
}

.practice-mark-scheme .ms-zero {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.4rem 0;
  margin-bottom: 0.75rem;
}

.practice-mark-scheme .ms-spag {
  border-top: 1px solid var(--border-light);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.practice-answer-area {
  margin-bottom: 1rem;
}

.practice-answer-label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.practice-answer-input {
  width: 100%;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-card);
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.practice-answer-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-badge);
}

.practice-answer-input::placeholder {
  color: var(--text-muted);
}

.practice-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.practice-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7em 1.25em;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.practice-btn:hover {
  transform: translateY(-1px);
}

.practice-btn svg {
  width: 18px;
  height: 18px;
}

.practice-btn--ai {
  background: var(--accent);
  color: white;
}

.practice-btn--ai:hover {
  opacity: 0.9;
}

.practice-btn--send {
  background: var(--accent-badge);
  color: var(--accent);
}

.practice-btn--send:hover {
  background: var(--accent-light);
}

/* Toast notification */
.practice-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--text-primary);
  color: var(--bg-body);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.75em 1.5em;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  z-index: 999;
}

.practice-toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* --- Prev / Next Navigation --- */
.lesson-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-light);
}

.lesson-nav-link {
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lesson-nav-link:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  opacity: 1;
}

.lesson-nav-link--next {
  text-align: right;
  grid-column: 2;
}

.lesson-nav-direction {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.lesson-nav-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}

/* --- Back link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--accent-badge);
  padding: 0.5em 1.1em;
  border-radius: 999px;
  margin-top: 1.5rem;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.back-link:hover {
  background: var(--accent-badge);
  border-color: var(--accent);
  text-decoration: none;
  opacity: 1;
}

/* ============================
   Homepage
   ============================ */
.hero {
  text-align: center;
  padding: 4.5rem 1.5rem 1rem;
  max-width: var(--page-max);
  margin: 0 auto;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.2em;
  letter-spacing: -0.02em;
}

.hero .tagline,
.hero .hero-tagline {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---- Login ---- */
.login-section {
  max-width: 400px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.login-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

.login-box h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  text-align: center;
}

.login-field {
  margin-bottom: 1rem;
}

.login-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.login-field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--border-lighter);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-body);
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.login-field input:focus {
  outline: none;
  border-color: var(--text-primary);
}

.login-error {
  color: #dc2626;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.login-btn {
  width: 100%;
  padding: 0.7rem;
  border-radius: 999px;
  border: none;
  background: var(--text-primary);
  color: var(--bg-body);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-btn:hover {
  opacity: 0.85;
}

/* ---- Microsoft SSO button ---- */
.login-sso-btn + .login-sso-btn {
  margin-top: 0.5rem;
}
.login-sso-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.7rem;
  border-radius: 999px;
  border: 2px solid var(--border-light);
  background: #fff;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-sso-btn:hover {
  border-color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.login-sso-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--border-light);
  box-shadow: none;
}
.login-sso-btn:disabled:hover {
  border-color: var(--border-light);
  box-shadow: none;
}
.login-sso-soon {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-subtle, #f0eee9);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.2rem;
}

.login-sso-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

/* ---- Login separator ---- */
.login-separator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.login-separator::before,
.login-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-lighter);
}

.login-separator span {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Demo section (when SSO is present) ---- */
.login-demo--sso {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.login-demo {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-lighter);
}

.login-demo-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.login-demo-accounts {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.login-demo-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 1.5px solid var(--border-lighter);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  color: var(--text-primary);
}

.login-demo-account:hover {
  border-color: var(--text-muted);
  background: var(--bg-body);
}

.login-demo-account strong {
  font-size: 0.88rem;
  font-weight: 600;
}

.login-demo-account span {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Consolas', monospace;
}

.login-demo-account--admin {
  border-color: #ede9fe;
  background: #faf5ff;
}
.login-demo-account--admin:hover {
  border-color: #7c3aed;
  background: #f5f3ff;
}
.login-demo-account--admin strong { color: #7c3aed; }

.login-demo-account--teacher {
  border-color: #d1fae5;
  background: #f0fdf4;
}
.login-demo-account--teacher:hover {
  border-color: #16a34a;
  background: #dcfce7;
}
.login-demo-account--teacher strong { color: #16a34a; }

/* ---- Subject picker (first visit) ---- */
.subject-picker {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.picker-intro {
  text-align: center;
  margin-bottom: 2rem;
}

.picker-intro h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.3em;
}

.picker-intro p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.picker-group {
  margin-bottom: 1.5rem;
}

.picker-group-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.picker-group-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}

.picker-card {
  display: flex;
  flex-direction: column;
  height: 148px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 2px solid var(--border-lighter);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  overflow: hidden;
  position: relative;
}

.picker-card:hover {
  border-color: var(--picker-accent);
}

.picker-card.selected {
  border-color: var(--picker-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--picker-accent) 18%, transparent);
}

.picker-card-image {
  width: 100%;
  height: 80px;
  overflow: hidden;
}

.picker-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.picker-card-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
  padding: 0.45rem 0.6rem 0.1rem;
  line-height: 1.2;
}

.picker-card-board {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 0.6rem 0.45rem;
}

.picker-card-check {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid rgba(255,255,255,0.7);
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.25);
  transition: background 0.15s, border-color 0.15s;
}

.picker-card.selected .picker-card-check {
  background: var(--picker-accent);
  border-color: var(--picker-accent);
}

.picker-card.selected .picker-card-check::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.picker-footer {
  text-align: center;
  margin-top: 2rem;
}

.picker-continue-btn {
  padding: 0.75rem 2.5rem;
  border-radius: 999px;
  border: none;
  background: var(--text-primary);
  color: var(--bg-body);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.picker-continue-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.picker-continue-btn:not(:disabled):hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

/* ---- Dashboard (after subject selection) ---- */

.dashboard-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dashboard-action-btn:hover {
  color: var(--text-primary);
}

.dashboard-signout-btn {
  color: #dc2626;
}

.dashboard-signout-btn:hover {
  color: #b91c1c;
}

/* ---- Dashboard: Greeting + Countdown ---- */
.dashboard-greeting-row {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.5rem 0.5rem;
}

.dashboard-greeting {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.greeting-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.dashboard-countdown {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border-radius: 999px;
}

body.dark-mode .dashboard-countdown {
  color: #fbbf24;
  background: #332d1f;
}

/* ---- Dashboard: Today's Revision ---- */
.dashboard-today {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.dashboard-today-inner {
  margin-bottom: 1.25rem;
}

.dashboard-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.today-cards {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.today-card {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.15rem;
  background: var(--bg-card);
  border-radius: 12px;
  border-left: 4px solid var(--today-accent, var(--accent));
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.today-card:not(.today-card--disabled):hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.today-card--disabled {
  opacity: 0.55;
  cursor: default;
}

.today-card-subject {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--today-accent, var(--text-muted));
}

.today-card-lesson {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.today-tag {
  display: inline-block;
  align-self: flex-start;
  margin-top: auto;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
}

.today-tag--new {
  color: #065f46;
  background: #d1fae5;
}

.today-tag--revisit {
  color: #92400e;
  background: #fef3c7;
}

body.dark-mode .today-tag--new {
  color: #6ee7b7;
  background: #14332a;
}

body.dark-mode .today-tag--revisit {
  color: #fbbf24;
  background: #332d1f;
}

.dashboard-empty {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- Dashboard: Stats Row ---- */
.dashboard-stats {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.dashboard-stats-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.stat-value {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

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

.stat-good { color: #059669; }
.stat-ok { color: #d97706; }
.stat-low { color: #dc2626; }

body.dark-mode .stat-good { color: #34d399; }
body.dark-mode .stat-ok { color: #fbbf24; }
body.dark-mode .stat-low { color: #f87171; }

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stat-bar {
  margin-top: 0.6rem;
  height: 6px;
  background: var(--border-lighter);
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: #059669;
  border-radius: 999px;
  transition: width 0.6s ease;
}

body.dark-mode .stat-bar-fill {
  background: #34d399;
}

/* ---- Dashboard: Actions row ---- */
.dashboard-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.25rem 1.5rem 1rem;
}

/* ---- Subject card: progress bar ---- */
.subject-progress {
  margin-top: 0.5rem;
}

.subject-progress-bar {
  height: 5px;
  background: var(--border-lighter);
  border-radius: 999px;
  overflow: hidden;
}

.subject-progress-fill {
  height: 100%;
  background: var(--card-accent, var(--accent));
  border-radius: 999px;
}

.subject-progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  display: block;
}

/* ---- Subject cards (dashboard grid) ---- */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.subject-card {
  display: flex;
  flex-direction: row;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
  border-left: 4px solid var(--card-accent, var(--accent));
  height: 160px;
}

.subject-card:not(.subject-card--coming-soon):hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}

.subject-card .unit-card-image {
  position: relative;
  width: 42%;
  overflow: hidden;
  flex-shrink: 0;
}

.subject-card .unit-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.subject-card:not(.subject-card--coming-soon):hover .unit-card-image img {
  transform: scale(1.05);
}

.subject-card--coming-soon .unit-card-image {
  filter: grayscale(40%);
}

.subject-card .unit-card-body {
  padding: 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.subject-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.2em;
  color: var(--text-primary);
}

.subject-card .unit-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.subject-card--coming-soon {
  opacity: 0.55;
  cursor: default;
}

.coming-soon-badge {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--border-lighter);
  border-radius: 999px;
}

/* Unit cards grid */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}
.unit-grid.single-unit {
  grid-template-columns: 1fr;
  max-width: 540px;
}

.unit-card {
  display: flex;
  flex-direction: row;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
  border-left: 4px solid var(--card-accent, var(--accent));
  height: 210px;
}

.unit-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  opacity: 1;
}

.unit-card-image {
  position: relative;
  width: 42%;
  overflow: hidden;
  flex-shrink: 0;
}

.unit-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.unit-card:hover .unit-card-image img {
  transform: scale(1.05);
}

.unit-card-body {
  padding: 1.35rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
}

.unit-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.2em;
  color: var(--text-primary);
}

.unit-card .unit-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.unit-card .unit-meta {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
  margin-bottom: 0.5rem;
}

/* Progress bar (unit card + unit contents page) */
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border-lighter);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--card-accent, var(--accent));
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

/* Quote ticker */
.quote-ticker {
  overflow: hidden;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border-lighter);
  margin-top: 0;
}

.quote-ticker-track {
  display: flex;
  width: max-content;
  white-space: nowrap;
  animation: ticker-scroll 120s linear infinite;
}

.quote-ticker:hover .quote-ticker-track {
  animation-play-state: paused;
}

.quote-item {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-style: italic;
  color: #1a1816;
  font-weight: 600;
  flex-shrink: 0;
  border-left: 3px solid var(--q-color);
  padding-left: 0.75rem;
  margin-right: 3rem;
}

.quote-item em {
  font-style: normal;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--q-color);
  font-weight: 600;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============================
   Unit Contents Page
   ============================ */
.unit-page-header {
  padding: 3.5rem 1.5rem 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--bg-body) 100%);
  border-bottom: 3px solid var(--accent);
}

.unit-page-header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
}

.unit-page-header h1 {
  font-size: 2.25rem;
  color: var(--accent);
  margin-bottom: 0.3em;
}

.unit-page-header p {
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 0;
  line-height: 1.6;
}

.unit-progress {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.unit-progress-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

/* Lesson card grid */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.5rem 1.5rem 4rem;
}

.lesson-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  padding: 1.25rem 1.35rem;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.lesson-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  opacity: 1;
}

.lesson-card.visited::after {
  content: "";
  position: absolute;
  top: 1.35rem;
  right: 1.25rem;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.lesson-card.coming-soon {
  opacity: 0.5;
  pointer-events: none;
}

.lesson-card-number {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.lesson-card h3 {
  font-size: 1rem;
  margin-bottom: 0.4em;
  margin-top: 0;
  color: var(--text-primary);
}

.lesson-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.55;
}

.lesson-card .coming-soon-label {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
}

/* ============================
   Mobile Responsive
   ============================ */
@media (max-width: 960px) {
  /* Sidebar collapses below content */
  .lesson-page {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .lesson-sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
  }
}

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

  .page-header {
    padding: 0.65rem 1rem;
  }

  .header-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-card);
    flex-direction: column;
    align-items: flex-start;
    padding: 4.5rem 1.5rem 2rem;
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 950;
  }

  .header-nav.open {
    transform: translateX(0);
  }

  .header-nav a {
    font-size: 1rem;
    width: 100%;
    padding: 0.65em 0.75em;
  }

  .header-nav a.nav-lesson-pill {
    width: auto;
    align-self: flex-start;
    font-size: 0.9rem;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 960;
  }

  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 42, 38, 0.3);
    z-index: 940;
  }

  .mobile-overlay.open {
    display: block;
  }

  .lesson-page {
    padding: 1.75rem 1.15rem 3rem;
  }

  .lesson-container {
    padding: 1.75rem 1.15rem 3rem;
  }

  .lesson-header h1 {
    font-size: 1.6rem;
  }

  .lesson-nav {
    grid-template-columns: 1fr;
  }

  .lesson-nav-link--next {
    grid-column: 1;
    text-align: left;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .subject-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .greeting-text {
    font-size: 1.35rem;
  }

  .dashboard-stats-inner {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stat-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
    padding: 0.85rem 1rem;
  }

  .stat-card .stat-bar {
    flex: 1;
    margin-top: 0;
  }

  .today-card {
    flex: 0 0 190px;
  }

  .picker-group-cards {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .unit-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .unit-card {
    height: 180px;
  }

  .unit-card-image {
    width: 35%;
  }

  .unit-page-header {
    padding: 3rem 1.5rem 2rem;
  }

  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .lesson-sidebar {
    grid-template-columns: 1fr;
  }

  .timeline {
    padding-left: 1.5rem;
  }

  .timeline-event {
    padding-left: 0.75rem;
  }
}

@media (max-width: 480px) {
  .header-unit-label,
  .header-lesson-label {
    display: none;
  }

  .lesson-header h1 {
    font-size: 1.35rem;
  }
}

/* ============================
   Exam Technique — Purple Theme
   ============================ */
body.unit-exam-technique {
  --accent: #7c3aed;
  --accent-light: #f5f3ff;
  --accent-badge: #ede9fe;
}

body.dark-mode.unit-exam-technique {
  --accent-light: #1f1a2e;
  --accent-badge: #2a2040;
}

body.unit-revision-technique {
  --accent: #16a34a;
  --accent-light: #f0fdf4;
  --accent-badge: #dcfce7;
}

body.dark-mode.unit-revision-technique {
  --accent-light: #0a2618;
  --accent-badge: #14532d;
}

/* --- Exam Technique Banner (Homepage) --- */
.exam-technique-banner {
  display: block;
  max-width: 820px;
  margin: 1.5rem auto 0;
  padding: 1.25rem 1.75rem;
  background: #f5f3ff;
  border: 1px solid #ede9fe;
  border-radius: var(--radius);
  text-decoration: none;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.exam-technique-banner:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
  opacity: 1;
}

.exam-technique-banner-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.exam-technique-banner-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.exam-technique-banner-text h2 {
  font-size: 1.05rem;
  margin-bottom: 0.15em;
  color: #7c3aed;
}

.exam-technique-banner-text p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

body.dark-mode .exam-technique-banner {
  background: #1f1a2e;
  border-color: #2a2040;
}

body.dark-mode .exam-technique-banner-text h2 {
  color: #a78bfa;
}

/* --- Guide Hub — grouped by paper --- */
.guide-hub {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

.guide-paper {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border-left: 5px solid var(--paper-accent);
  overflow: hidden;
}

.guide-paper-header {
  padding: 1.25rem 1.5rem 1rem;
  background: var(--paper-light);
}

.guide-paper-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--paper-accent);
  margin-bottom: 0.15em;
}

.guide-paper-ref {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.guide-paper-questions {
  display: flex;
  flex-direction: column;
}

.guide-question-card {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-lighter);
  text-decoration: none;
  transition: background 0.15s ease;
}

.guide-question-card:hover {
  background: var(--paper-light);
  text-decoration: none;
}

.guide-question-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--paper-accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  min-width: 2rem;
}

.guide-question-marks {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border-lighter);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.guide-question-card h3 {
  width: 100%;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.35;
}

.guide-question-card p {
  width: 100%;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.15rem 0 0;
  line-height: 1.45;
}

.guide-question-card--soon {
  opacity: 0.6;
  cursor: default;
}

.guide-question-card--soon:hover {
  background: transparent;
}

.guide-soon-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--border-lighter);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* Dark mode for guide hub */
body.dark-mode .guide-paper-header {
  background: color-mix(in srgb, var(--paper-accent) 12%, var(--bg-card));
}

body.dark-mode .guide-question-card:hover {
  background: color-mix(in srgb, var(--paper-accent) 8%, var(--bg-card));
}

@media (max-width: 768px) {
  .guide-hub {
    grid-template-columns: 1fr;
  }

  .guide-question-card {
    padding: 0.85rem 1.15rem;
  }

  .guide-paper-header {
    padding: 1rem 1.15rem 0.85rem;
  }
}

/* --- Guide Page Header (centred on guide pages) --- */
body.unit-exam-technique .unit-page-header,
body.unit-revision-technique .unit-page-header {
  text-align: center;
}

body.unit-exam-technique .unit-page-header p,
body.unit-revision-technique .unit-page-header p {
  margin-left: auto;
  margin-right: auto;
}

/* --- Guide Page Layout --- */
.guide-content {
  max-width: 960px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
}

.guide-section {
  margin-bottom: 2.5rem;
}

.guide-section h2 {
  font-size: 1.35rem;
  border-bottom: 2px solid var(--border-lighter);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}

.guide-section h3 {
  border-bottom: 2px solid var(--border-lighter);
  padding-bottom: 0.4rem;
  margin-top: 1.25rem;
}

/* --- Guide Steps --- */
.guide-steps {
  list-style: none;
  padding-left: 0;
  counter-reset: guide-step;
}

.guide-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}

.guide-step-number {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.guide-step-body strong {
  display: block;
  margin-bottom: 0.2em;
}

/* --- Timing Bar --- */
.guide-timing-bar {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 2rem;
  font-size: 0.72rem;
  font-weight: 600;
  margin: 0.75rem 0 1rem;
}

.guide-timing-bar span {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  white-space: nowrap;
  padding: 0 0.5rem;
}

/* --- Paragraph Templates --- */
.guide-template {
  background: var(--accent-light);
  border: 1px solid var(--accent-badge);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.guide-template-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.guide-starter {
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 0.3em;
}

.guide-starter:last-child {
  margin-bottom: 0;
}

/* --- Annotated Model Answer --- */
.guide-model-question {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  font-style: italic;
  color: var(--text-secondary);
}

.guide-model-paragraph {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.guide-annotation {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-badge);
  padding: 0.15em 0.6em;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.guide-model-mark {
  text-align: right;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* --- Common Mistakes --- */
.guide-mistakes {
  list-style: none;
  padding-left: 0;
}

.guide-mistake {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: flex-start;
}

.guide-mistake-icon {
  flex-shrink: 0;
  font-size: 1.15rem;
  margin-top: 0.1rem;
}

/* --- Marks Badge (Guide Header) --- */
.guide-marks-badge {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-badge);
  padding: 0.3em 0.9em;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

/* --- Guide Nav (Prev/Next) --- */
.guide-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border-lighter);
}

.guide-nav-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--accent-badge);
  padding: 0.5em 1.1em;
  border-radius: 999px;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.guide-nav-link:hover {
  background: var(--accent-badge);
  border-color: var(--accent);
  text-decoration: none;
  opacity: 1;
}

/* --- Practice Guide Link (in lesson practice sections) --- */
.practice-guide-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: #7c3aed;
  margin-left: 0.5rem;
  vertical-align: middle;
  text-decoration: none;
}

.practice-guide-link:hover {
  text-decoration: underline;
  opacity: 1;
}

.practice-guide-link svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

body.dark-mode .practice-guide-link {
  color: #a78bfa;
}

@media (max-width: 640px) {
  .practice-question-header {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .practice-guide-link {
    width: 100%;
    margin-left: 0;
    margin-top: 0.25rem;
  }
  .exam-technique-banner {
    margin-left: 1rem;
    margin-right: 1rem;
  }
}

/* --- Weak vs Strong Comparison --- */
.guide-weak-answer {
  border-left-color: #ef4444;
}

.guide-annotation-weak {
  color: #dc2626;
  background: #fef2f2;
}

body.dark-mode .guide-weak-answer {
  border-left-color: #f87171;
}

body.dark-mode .guide-annotation-weak {
  color: #fca5a5;
  background: #451a1a;
}

/* --- Guide Level Descriptors Table --- */
.guide-levels {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1.25rem;
  font-size: 0.88rem;
}

.guide-levels thead th {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 0.6rem 0.85rem;
}

.guide-levels thead th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.guide-levels thead th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.guide-levels tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-lighter);
  vertical-align: top;
}

.guide-levels tbody tr:hover {
  background: var(--accent-light);
}

.guide-levels tbody tr:last-child td {
  border-bottom: none;
}

/* --- Guide Quick Reference Card (Sidebar) --- */
.guide-quick-ref {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.guide-quick-ref .sidebar-section-title {
  margin-bottom: 0.6rem;
}

.guide-quick-ref-bar {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  height: 0.6rem;
  margin-bottom: 0.3rem;
}

.guide-quick-ref-bar span {
  display: block;
}

.guide-quick-ref-total {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.guide-quick-ref h4 {
  font-size: 0.85rem;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

.guide-quick-ref-steps {
  font-size: 0.8rem;
  padding-left: 1.25rem;
  margin-bottom: 0;
  color: var(--text-secondary);
}

.guide-quick-ref-steps li {
  margin-bottom: 0.2rem;
}

/* --- Guide Video Placeholder --- */
.guide-video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent-light);
  border: 1px dashed var(--accent-badge);
  border-radius: var(--radius-sm);
  padding: 1.5rem 1rem;
}

.guide-video-placeholder svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
  opacity: 0.5;
}

.guide-video-placeholder span {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* --- Guide "Used in" subtitle --- */
.guide-used-in {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* --- Dark mode for guide additions --- */
body.dark-mode .guide-levels thead th {
  background: color-mix(in srgb, var(--accent) 80%, #000);
}

body.dark-mode .guide-levels tbody tr:hover {
  background: var(--accent-light);
}

body.dark-mode .guide-quick-ref {
  background: var(--bg-card);
  border-color: var(--border-light);
}

body.dark-mode .guide-video-placeholder {
  background: var(--accent-light);
  border-color: var(--accent-badge);
}

/* ============================
   Revision Technique Tips
   ============================ */
.revision-tip-anchor {
  position: relative;
}

.revision-tip-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 1.65rem;
  height: 1.65rem;
  border: none;
  border-radius: 50%;
  background: #f0fdf4;
  color: #16a34a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, transform 0.15s ease;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.revision-tip-btn:hover {
  background: #dcfce7;
  transform: scale(1.1);
}

.revision-tip-btn svg {
  width: 0.95rem;
  height: 0.95rem;
}

.revision-tip-popup {
  display: none;
  position: absolute;
  top: 2.6rem;
  right: 0.3rem;
  width: 15rem;
  background: #fff;
  border: 1px solid #d1fae5;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 10;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-color, #2d2a26);
}

.revision-tip-popup.is-open {
  display: block;
}

.revision-tip-popup p {
  margin: 0 0 0.45rem;
}

.revision-tip-popup a {
  color: #16a34a;
  font-weight: 600;
  text-decoration: none;
}

.revision-tip-popup a:hover {
  text-decoration: underline;
}

body.dark-mode .revision-tip-btn {
  background: #0a2618;
  color: #4ade80;
}

body.dark-mode .revision-tip-btn:hover {
  background: #14532d;
}

body.dark-mode .revision-tip-popup {
  background: #0a1f17;
  border-color: #14532d;
  color: #e8f0ec;
}

body.dark-mode .revision-tip-popup a {
  color: #4ade80;
}

/* ============================
   Print Styles
   ============================ */
@media print {
  .scroll-progress,
  .page-header,
  .lesson-nav,
  .back-link,
  .mobile-menu-btn,
  .mobile-overlay,
  .lesson-sidebar,
  .practice-section {
    display: none !important;
  }

  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .lesson-page {
    display: block;
    max-width: 100%;
    padding: 0;
  }

  .lesson-container {
    max-width: 100%;
    padding: 0;
  }

  .collapsible-content {
    max-height: none !important;
  }

  .key-fact,
  .exam-tip {
    break-inside: avoid;
    border-left-width: 3px;
  }

  .timeline-event {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: underline;
  }
}
