/* ===== Variables ===== */
:root {
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --bg: #fafaf9;
  --card-bg: #fff;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --accent-dark: #3730a3;
  --green: #059669;
  --green-light: #ecfdf5;
  --green-border: #a7f3d0;
  --orange: #d97706;
  --orange-light: #fffbeb;
  --orange-border: #fde68a;
  --red: #dc2626;
  --red-light: #fef2f2;
  --red-border: #fecaca;
  --border: #e5e7eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --max-w: 680px;
  --font: 'Inter', 'Heebo', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  padding-bottom: 80px;
}
img { max-width: 100%; display: block; }

/* ===== Top Nav ===== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,250,249,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topnav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.topnav-progress {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ===== Home ===== */
.home {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 24px 40px;
}
.home-header {
  text-align: center;
  margin-bottom: 32px;
}
.home-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1.2;
}
.home-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 8px;
}
.home-intro {
  max-width: var(--max-w);
  margin: 0 auto 40px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}
.module-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-width: var(--max-w);
  margin: 0 auto;
}
.module-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text);
}
.module-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(79,70,229,0.08);
  transform: translateY(-1px);
}
.module-card .mc-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.module-card.mc-done .mc-num {
  background: var(--green-light);
  color: var(--green);
}
.module-card .mc-info { flex: 1; }
.module-card .mc-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.module-card .mc-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.module-card .mc-weight {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.mc-weight.high { background: #fef2f2; color: #b91c1c; }
.mc-weight.very-high { background: #fef2f2; color: #7f1d1d; border: 1px solid #fca5a5; }
.mc-weight.medium { background: #fffbeb; color: #92400e; }

/* ===== Article ===== */
.article {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 24px;
}
.article-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.article-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.3;
}
.article-header .ah-meta {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.article-header .ah-weight {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ===== Article Prose ===== */
.article-body h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 48px 0 16px;
  padding-top: 16px;
  letter-spacing: -0.3px;
}
.article-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 10px;
}
.article-body p {
  margin-bottom: 16px;
  font-size: 1rem;
}
.article-body ul, .article-body ol {
  margin-bottom: 16px;
  padding-left: 28px;
}
.article-body li {
  margin-bottom: 6px;
}
.article-body strong {
  font-weight: 600;
}

/* Formula */
.formula {
  font-family: var(--mono);
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 18px 0;
  direction: ltr;
  text-align: center;
  font-size: 0.9rem;
  overflow-x: auto;
  line-height: 1.6;
}

/* Callout boxes */
.callout {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 0.92rem;
  line-height: 1.7;
}
.callout-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.callout.info { background: var(--accent-light); border: 1px solid #c7d2fe; }
.callout.info .callout-title { color: var(--accent-dark); }
.callout.warn { background: var(--orange-light); border: 1px solid var(--orange-border); }
.callout.warn .callout-title { color: #92400e; }
.callout.danger { background: var(--red-light); border: 1px solid var(--red-border); }
.callout.danger .callout-title { color: #991b1b; }
.callout.tip { background: var(--green-light); border: 1px solid var(--green-border); }
.callout.tip .callout-title { color: #065f46; }
.slides-unavailable { margin-top: 0; }

/* Inline code */
code {
  font-family: var(--mono);
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  direction: ltr;
  display: inline-block;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.85rem;
  direction: ltr;
}
.data-table th, .data-table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: center;
}
.data-table th { background: #f3f4f6; font-weight: 600; }
.data-table .hl { background: var(--accent-light); font-weight: 600; }

/* ===== Inline Slide Figure ===== */
.slide-figure {
  margin: 28px 0;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.slide-figure-img {
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
}
.slide-figure-img:hover { opacity: 0.92; }
.slide-figure-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.slide-figure-nav button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.slide-figure-nav button:hover { border-color: var(--accent); color: var(--accent); }
.slide-figure-counter {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  direction: ltr;
  min-width: 60px;
  text-align: center;
}
.slide-figure-caption {
  padding: 8px 14px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: #fff;
}

/* ===== Review Cards (quantum.country style) ===== */
.review-set {
  margin: 40px 0;
  padding: 28px 0;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}
.review-set-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 20px;
  text-align: center;
}
.review-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  transition: border-color 0.3s;
}
.review-card.rc-correct { border-color: var(--green-border); }
.review-card.rc-wrong { border-color: var(--red-border); }
.rc-question {
  padding: 18px 22px;
  font-size: 0.95rem;
  line-height: 1.7;
  font-weight: 500;
}
.rc-options {
  padding: 0 22px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rc-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.9rem;
  line-height: 1.5;
}
.rc-option:hover { border-color: var(--accent); background: var(--accent-light); }
.rc-option.selected { border-color: var(--accent); background: var(--accent-light); }
.rc-option.correct { border-color: var(--green); background: var(--green-light); }
.rc-option.wrong { border-color: var(--red); background: var(--red-light); }
.rc-option.disabled { pointer-events: none; }
.rc-option .rc-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  margin-top: 2px;
}
.rc-option.selected .rc-marker { border-color: var(--accent); background: var(--accent); color: #fff; }
.rc-option.correct .rc-marker { border-color: var(--green); background: var(--green); color: #fff; }
.rc-option.wrong .rc-marker { border-color: var(--red); background: var(--red); color: #fff; }

.rc-actions {
  padding: 10px 22px 16px;
}
.rc-check-btn {
  padding: 8px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}
.rc-check-btn:hover { background: var(--accent-dark); }

.rc-feedback {
  padding: 14px 22px;
  font-size: 0.88rem;
  line-height: 1.7;
  display: none;
}
.rc-feedback.show { display: block; }
.rc-feedback.correct { background: var(--green-light); color: #065f46; border-top: 1px solid var(--green-border); }
.rc-feedback.incorrect { background: var(--red-light); color: #7f1d1d; border-top: 1px solid var(--red-border); }
.rc-source {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-style: italic;
}

/* ===== Article Navigation ===== */
.article-footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.article-nav a {
  padding: 14px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.15s;
  flex: 1;
  max-width: 280px;
}
.article-nav a:hover { border-color: var(--accent); }
.article-nav a .nav-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 2px;
}
.article-nav a .nav-title {
  font-weight: 600;
}
.article-nav a.nav-next { text-align: right; margin-left: auto; }

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.hidden { display: none; }
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}
.lightbox-img {
  max-width: 95%;
  max-height: 90vh;
  border-radius: var(--radius);
}

/* ===== Utilities ===== */
.hidden { display: none !important; }
.ltr { direction: ltr; text-align: left; }
.text-muted { color: var(--text-secondary); }

/* ===== Dark Mode Toggle ===== */
.topnav-dark-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card-bg);
  cursor: pointer; font-size: 1rem; display: flex;
  align-items: center; justify-content: center; transition: all 0.15s;
}
.topnav-dark-toggle::before { content: '\1F319'; }
[data-theme="dark"] .topnav-dark-toggle::before { content: '\2600\FE0F'; }
.topnav-dark-toggle:hover { border-color: var(--accent); }

/* ===== Dark Mode ===== */
[data-theme="dark"] {
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --accent: #818cf8;
  --accent-light: #1e1b4b;
  --accent-dark: #a5b4fc;
  --green: #34d399;
  --green-light: #064e3b;
  --green-border: #065f46;
  --orange: #fbbf24;
  --orange-light: #451a03;
  --orange-border: #78350f;
  --red: #f87171;
  --red-light: #450a0a;
  --red-border: #7f1d1d;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}
[data-theme="dark"] .topnav { background: rgba(15,23,42,0.92); }
[data-theme="dark"] .formula { background: #1e293b; }
[data-theme="dark"] .data-table th { background: #1e293b; }
[data-theme="dark"] .slide-figure { background: #1e293b; }
[data-theme="dark"] .slide-figure-nav { background: var(--card-bg); }
[data-theme="dark"] .slide-figure-caption { background: var(--card-bg); }
[data-theme="dark"] .slide-figure-nav button { background: var(--card-bg); }
[data-theme="dark"] code { background: #1e293b; }
[data-theme="dark"] .lightbox-close { background: rgba(255,255,255,0.2); }
[data-theme="dark"] .rc-feedback.correct { color: #a7f3d0; }
[data-theme="dark"] .rc-feedback.incorrect { color: #fecaca; }
[data-theme="dark"] .callout.info { color: #c7d2fe; }
[data-theme="dark"] .callout.warn { color: #fde68a; }
[data-theme="dark"] .callout.danger { color: #fecaca; }
[data-theme="dark"] .callout.tip { color: #a7f3d0; }

/* ===== Home Search ===== */
.home-search {
  max-width: var(--max-w); margin: 0 auto 20px; position: relative;
}
.home-search input {
  width: 100%; padding: 12px 18px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card-bg); color: var(--text);
  font-family: var(--font); font-size: 0.95rem; outline: none; transition: border-color 0.15s;
}
.home-search input:focus { border-color: var(--accent); }
.search-results {
  position: absolute; top: 100%; right: 0; left: 0; z-index: 50;
  background: var(--card-bg); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); max-height: 360px; overflow-y: auto;
  box-shadow: var(--shadow);
}
.search-results.hidden { display: none; }
.search-result-item {
  padding: 12px 18px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result-item:hover { background: var(--accent-light); }
.search-result-item:last-child { border-bottom: none; }
.search-result-module {
  font-size: 0.72rem; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.search-result-text { font-size: 0.88rem; margin-top: 2px; color: var(--text); }
.search-result-text mark { background: #fef08a; color: #000; border-radius: 2px; padding: 0 2px; }
[data-theme="dark"] .search-result-text mark { background: #854d0e; color: #fef3c7; }

/* ===== Home Action Buttons ===== */
.home-actions {
  max-width: var(--max-w); margin: 0 auto 32px;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.home-action-btn {
  padding: 10px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card-bg); color: var(--text); cursor: pointer; font-family: var(--font);
  font-size: 0.85rem; font-weight: 500; transition: all 0.15s; display: flex;
  align-items: center; gap: 6px;
}
.home-action-btn:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.home-action-exam::before { content: '\1F4DD'; }
.home-action-wrong::before { content: '\1F504'; }
.home-action-formula::before { content: '\1F4D0'; }
.home-action-export::before { content: '\1F5A8\FE0F'; }

/* ===== Module Card Progress Bar ===== */
.mc-progress { width: 100%; height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.mc-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }
.module-card.mc-done .mc-progress-fill { background: var(--green); }

/* ===== Keyboard Hint ===== */
.keyboard-hint {
  max-width: var(--max-w); margin: 24px auto 0; text-align: center;
  font-size: 0.72rem; color: var(--text-secondary); opacity: 0.6;
  font-family: var(--mono); letter-spacing: 0.3px;
}

/* ===== Article TOC ===== */
.article-toc {
  position: fixed; top: 70px; left: 24px; width: 200px; max-height: calc(100vh - 100px);
  overflow-y: auto; font-size: 0.78rem; z-index: 10; display: none;
}
@media (min-width: 1100px) { .article-toc { display: block; } }
.article-toc a {
  display: block; padding: 5px 10px; color: var(--text-secondary); text-decoration: none;
  border-left: 2px solid transparent; transition: all 0.15s; line-height: 1.4;
}
.article-toc a:hover { color: var(--accent); }
.article-toc a.toc-active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.article-toc a.toc-h3 { padding-left: 22px; font-size: 0.73rem; }

/* ===== Exam Simulation ===== */
.exam-sim {
  max-width: var(--max-w); margin: 0 auto; padding: 40px 24px;
}
.exam-sim-header {
  text-align: center; margin-bottom: 32px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.exam-sim-header h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 12px; }
.exam-sim-timer {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 1.1rem; color: var(--accent);
  background: var(--accent-light); padding: 6px 16px; border-radius: 20px;
}
.exam-sim-progress {
  font-size: 0.85rem; color: var(--text-secondary); margin-top: 8px;
}
.exam-sim-card { margin-bottom: 20px; }
.exam-sim-nav { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }
.exam-sim-nav button {
  padding: 10px 28px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card-bg); color: var(--text); cursor: pointer; font-family: var(--font);
  font-size: 0.9rem; font-weight: 500; transition: all 0.15s;
}
.exam-sim-nav button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.exam-sim-nav button.primary:hover { background: var(--accent-dark); }
.exam-sim-nav button:hover { border-color: var(--accent); }
/* Score screen */
.exam-score { text-align: center; padding: 40px 0; }
.exam-score-number { font-size: 3.5rem; font-weight: 800; color: var(--accent); }
.exam-score-label { font-size: 1rem; color: var(--text-secondary); margin-top: 4px; }
.exam-score-breakdown { margin-top: 24px; text-align: left; }
.exam-score-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
.exam-score-correct { color: var(--green); font-weight: 600; }
.exam-score-wrong { color: var(--red); font-weight: 600; }
.exam-back-btn {
  margin-top: 28px; padding: 12px 32px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); cursor: pointer; font-family: var(--font);
  font-size: 0.95rem; font-weight: 600; transition: background 0.15s;
}
.exam-back-btn:hover { background: var(--accent-dark); }

/* ===== Formula Sheet ===== */
.formula-sheet {
  max-width: 900px; margin: 0 auto; padding: 40px 24px;
}
.formula-sheet-inner h1 {
  font-size: 1.6rem; font-weight: 800; text-align: center; margin-bottom: 8px;
}
.formula-sheet-back {
  display: block; margin: 0 auto 32px; padding: 8px 24px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card-bg); color: var(--text); cursor: pointer; font-family: var(--font);
  font-size: 0.85rem; transition: all 0.15s;
}
.formula-sheet-back:hover { border-color: var(--accent); }
.formula-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.formula-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; transition: border-color 0.15s;
}
.formula-card:hover { border-color: var(--accent); }
.formula-card h3 {
  font-size: 0.85rem; font-weight: 700; color: var(--accent); margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.formula-card .formula { margin: 8px 0; padding: 10px 14px; font-size: 0.82rem; }
.formula-card p { font-size: 0.82rem; color: var(--text-secondary); margin: 4px 0; line-height: 1.5; }
/* Algorithm comparison table in formula sheet */
.formula-sheet .data-table { font-size: 0.78rem; margin-top: 24px; }

/* ===== Slide Annotations ===== */
.slide-annotation-btn {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card-bg); cursor: pointer;
  font-size: 0.75rem; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s; z-index: 5;
}
.slide-figure { position: relative; }
.slide-figure:hover .slide-annotation-btn { opacity: 1; }
.slide-annotation-btn.has-note { opacity: 1; background: var(--orange-light); border-color: var(--orange); }
.slide-annotation-area {
  padding: 8px 14px; border-top: 1px solid var(--border); background: var(--card-bg);
}
.slide-annotation-area textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 4px; padding: 8px;
  font-family: var(--font); font-size: 0.82rem; resize: vertical; min-height: 50px;
  background: var(--bg); color: var(--text); outline: none;
}
.slide-annotation-area textarea:focus { border-color: var(--accent); }

/* ===== Print Styles ===== */
@media print {
  .topnav, .home-actions, .home-search, .keyboard-hint, .ai-chat-panel,
  .ai-chat-backdrop, .ai-key-overlay, .article-toc, .lightbox,
  .slide-annotation-btn, .slide-annotation-area, .rc-actions,
  .ai-gen-btn, .ai-summary-btn, .ai-tutor-btn, .exam-sim-nav,
  .article-footer, .slide-figure-nav { display: none !important; }
  body { background: #fff; color: #000; padding: 0; font-size: 11pt; }
  .article, .exam-sim, .formula-sheet { max-width: 100%; padding: 10px; }
  .review-card { break-inside: avoid; page-break-inside: avoid; border: 1px solid #ccc; }
  .formula-grid { grid-template-columns: repeat(2, 1fr); }
  .formula { background: #f5f5f5 !important; }
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  html { font-size: 16px; }
  .home { padding: 40px 16px 30px; }
  .home-header h1 { font-size: 1.6rem; }
  .article { padding: 24px 16px; }
  .article-header h1 { font-size: 1.4rem; }
  .article-nav { flex-direction: column; }
  .article-nav a { max-width: 100%; }
  .home-actions { gap: 6px; }
  .home-action-btn { font-size: 0.78rem; padding: 8px 12px; }
  .keyboard-hint { display: none; }
  .formula-grid { grid-template-columns: 1fr; }
  .questions-index-table { font-size: 0.8rem; }
  .qi-question-cell { max-width: 180px; }
}

/* ===== Questions Index Table ===== */
.questions-table-wrapper { margin: 24px 0; }

.questions-index-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.questions-index-table th { background: var(--accent-light); color: var(--accent-dark); font-weight: 600; padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: 2px solid var(--accent); }
.questions-index-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.questions-index-table tr:hover { background: var(--accent-light); }
.questions-index-table tr.qi-correct { background: var(--green-light); }
.questions-index-table tr.qi-wrong { background: var(--red-light); }
.qi-question-cell { max-width: 300px; line-height: 1.4; }
.questions-index-table a { color: var(--accent); text-decoration: none; font-weight: 500; }
.questions-index-table a:hover { text-decoration: underline; }

.qi-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 500; white-space: nowrap; }
.qi-badge-correct { background: var(--green-light); color: var(--green); border: 1px solid var(--green-border); }
.qi-badge-wrong { background: var(--red-light); color: var(--red); border: 1px solid var(--red-border); }
.qi-badge-pending { background: var(--orange-light); color: var(--orange); border: 1px solid var(--orange-border); }

.qi-summary { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; padding: 12px 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); }
.qi-summary span:last-child { margin-left: auto; color: var(--text-secondary); font-size: 0.88rem; }

/* Dark mode */
[data-theme="dark"] .questions-index-table th { background: #2d2b55; color: #c4b5fd; border-color: #4f46e5; }
[data-theme="dark"] .questions-index-table tr:hover { background: rgba(79,70,229,0.1); }
[data-theme="dark"] .questions-index-table tr.qi-correct { background: rgba(5,150,105,0.1); }
[data-theme="dark"] .questions-index-table tr.qi-wrong { background: rgba(220,38,38,0.1); }
[data-theme="dark"] .qi-summary { background: #1e1b3a; border-color: #3b3770; }

/* ===== Course Switcher Tabs ===== */
.course-tabs {
  display: flex;
  gap: 0;
  justify-content: center;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}
.course-tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.course-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.course-tab:hover { color: var(--text); }
.course-group-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ===== Transcript Block ===== */
.transcript-block { margin: 2rem 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.transcript-toggle { width: 100%; padding: 1rem 1.25rem; border: none; background: var(--card-bg); cursor: pointer; font-size: 1rem; font-weight: 600; text-align: left; display: flex; justify-content: space-between; align-items: center; }
.transcript-toggle:hover { background: var(--highlight); }
.transcript-content { display: none; padding: 1rem 1.25rem; max-height: 500px; overflow-y: auto; }
.transcript-content.expanded { display: block; }
.transcript-search { width: 100%; padding: 0.5rem 0.75rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.transcript-speaker { font-weight: 600; color: var(--accent); }
.transcript-line { padding: 0.3rem 0; line-height: 1.7; border-bottom: 1px solid var(--border-light, rgba(0,0,0,0.05)); }
.transcript-line.highlight { background: rgba(var(--accent-rgb, 99,102,241), 0.1); }
.transcript-line.hidden { display: none; }

/* ===== Assignment Block ===== */
.assignment-block { margin: 2rem 0; }
.assignment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.assignment-due { font-size: 0.9rem; color: var(--text-secondary); }
.assignment-progress { height: 8px; background: var(--border); border-radius: 4px; margin-bottom: 1.5rem; overflow: hidden; }
.assignment-progress-fill { height: 100%; background: var(--success, #22c55e); border-radius: 4px; transition: width 0.3s; }
.assignment-points-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; text-align: right; }
.assignment-task { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.75rem; transition: border-color 0.2s; }
.assignment-task:hover { border-color: var(--accent); }
.assignment-task.completed { opacity: 0.7; }
.assignment-task input[type="checkbox"] { margin-top: 0.3rem; width: 18px; height: 18px; cursor: pointer; }
.assignment-task-info { flex: 1; }
.assignment-task-title { font-weight: 600; margin-bottom: 0.25rem; }
.assignment-task-points { display: inline-block; background: var(--accent); color: white; font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 10px; margin-left: 0.5rem; }
.assignment-task-desc { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; line-height: 1.5; }

/* ===== QA Log Block ===== */
.qa-log-block { margin: 2rem 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.qa-log-toggle { width: 100%; padding: 1rem 1.25rem; border: none; background: var(--card-bg); cursor: pointer; font-size: 1rem; font-weight: 600; text-align: left; display: flex; justify-content: space-between; align-items: center; }
.qa-log-toggle:hover { background: var(--highlight); }
.qa-log-content { display: none; padding: 1rem 1.25rem; max-height: 600px; overflow-y: auto; }
.qa-log-content.expanded { display: block; }
.qa-log-search { width: 100%; padding: 0.5rem 0.75rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.qa-entry { padding: 1rem; border-left: 3px solid var(--accent); margin-bottom: 0.75rem; background: var(--card-bg); border-radius: 0 8px 8px 0; }
.qa-question { font-weight: 600; margin-bottom: 0.5rem; }
.qa-answer { color: var(--text-secondary); line-height: 1.6; }
.qa-meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.5rem; font-style: italic; }

/* ===== Dataset Table ===== */
.dataset-table-wrap { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--border); border-radius: 8px; }
.dataset-search { width: 100%; padding: 0.5rem 0.75rem; margin-bottom: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.dataset-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dataset-table th { position: sticky; top: 0; background: var(--bg); padding: 0.6rem 0.5rem; text-align: left; border-bottom: 2px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none; }
.dataset-table th:hover { color: var(--accent); }
.dataset-table th .sort-arrow { margin-left: 0.25rem; font-size: 0.7rem; }
.dataset-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); }
.dataset-table tr:hover { background: var(--highlight); }

/* =========================================================================
   LESSON VISUAL COMPONENTS — "lecture-summary" style
   Reusable palette for the rewritten lesson prose (authored in module JSON).
   Goal: flowing lecturer voice + visual structure instead of bullet dumps.
   ========================================================================= */

/* Hero / lesson opener */
.lesson-hero { margin: 0 0 8px; }
.lesson-hero .eyebrow { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.lesson-hero h2 { margin: 4px 0 8px; line-height: 1.25; }
.lesson-hero .dek { font-size: 1.05rem; line-height: 1.7; color: var(--text-secondary); margin: 0; }

/* The spoken framing line that opens a section (lecturer's voice) */
.lead { font-size: 1.02rem; line-height: 1.78; margin: 0 0 14px; }

/* The lecturer's main point — pull box */
.key-idea { border-left: 4px solid var(--accent); background: var(--accent-light); padding: 13px 18px; border-radius: 0 var(--radius) var(--radius) 0; margin: 18px 0; line-height: 1.7; }
.key-idea .label { display: block; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 4px; }

/* Horizontal concept flow: boxes joined by arrows (pipelines / sequences) */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; margin: 20px 0; }
.flow-step { flex: 1 1 0; min-width: 130px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; position: relative; box-shadow: var(--shadow); }
.flow-step h5 { margin: 0 0 4px; font-size: .9rem; color: var(--accent-dark); }
.flow-step p { margin: 0; font-size: .82rem; color: var(--text-secondary); line-height: 1.5; }
.flow-step:not(:last-child) { margin-right: 28px; }
.flow-step:not(:last-child)::after { content: "\2192"; position: absolute; right: -23px; top: 50%; transform: translateY(-50%); color: var(--accent); font-size: 1.4rem; font-weight: 700; }

/* Two-column comparison */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.compare > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--card-bg); }
.compare h5 { margin: 0 0 8px; font-size: .92rem; }
.compare .c-a { border-top: 3px solid var(--accent); }
.compare .c-b { border-top: 3px solid var(--orange); }
.compare ul { margin: 0; padding-left: 18px; } .compare li { font-size: .85rem; margin: 5px 0; line-height: 1.5; }

/* Vertical numbered steps (process) */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 18px 0; }
ol.steps li { counter-increment: step; position: relative; padding: 0 0 16px 42px; line-height: 1.6; }
ol.steps li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 27px; height: 27px; background: var(--accent); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; }
ol.steps li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 27px; bottom: 2px; width: 2px; background: var(--border); }

/* Stat / number highlights */
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0; }
.stat { flex: 1 1 120px; text-align: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 10px; background: var(--card-bg); }
.stat .num { display: block; font-size: 1.45rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat .lbl { font-size: .76rem; color: var(--text-secondary); }

/* Inline SVG figure + caption */
.figure { margin: 20px 0; text-align: center; }
.figure svg { max-width: 100%; height: auto; }
.figure figcaption { font-size: .78rem; color: var(--text-secondary); margin-top: 6px; }

/* "Expansion" badge — content beyond the instructor's slides */
.expansion-tag { display: inline-block; font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; background: var(--orange-light); color: #92400e; border: 1px solid var(--orange-border); border-radius: 10px; padding: 1px 8px; font-weight: 700; margin-left: 6px; vertical-align: middle; }

/* Dark-mode surfaces */
[data-theme="dark"] .key-idea { background: #1e293b; }
[data-theme="dark"] .flow-step,
[data-theme="dark"] .compare > div,
[data-theme="dark"] .stat { background: #0f172a; }
[data-theme="dark"] .expansion-tag { background: #3b2f1a; color: #fde68a; }

/* Responsive: stack the multi-column components on narrow screens */
@media (max-width: 600px) {
  .flow { flex-direction: column; }
  .flow-step:not(:last-child) { margin-right: 0; margin-bottom: 28px; }
  .flow-step:not(:last-child)::after { content: "\2193"; right: 50%; top: auto; bottom: -24px; transform: translateX(50%); }
  .compare { grid-template-columns: 1fr; }
}

/* ============ Interactive demo widgets ============ */
.widget-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 20px 0;
}
.widget-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.widget-note { color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 14px; }
.widget-controls { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 14px; }
.widget-slider-row { flex: 1 1 200px; min-width: 180px; }
.widget-slider-label { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; }
.widget-slider-value { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }
.widget-slider-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.tp-chart { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.tp-bar-row { display: flex; align-items: center; gap: 10px; }
.tp-bar-token { width: 80px; text-align: right; font-size: 0.85rem; font-family: ui-monospace, monospace; }
.tp-bar-track { flex: 1; background: var(--accent-light); border-radius: 4px; height: 18px; overflow: hidden; }
.tp-bar-fill { background: var(--accent); height: 100%; border-radius: 0 4px 4px 0; transition: width 0.15s ease; }
.tp-bar-pct { width: 110px; font-size: 0.8rem; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.tp-bar-cut { opacity: 0.45; }
.tp-bar-cut .tp-bar-fill { background: var(--text-secondary); }
.tp-sample-row { display: flex; align-items: center; gap: 12px; }
.tp-sample-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 6px 14px; font-size: 0.85rem; cursor: pointer;
}
.tp-sample-btn:hover { background: var(--accent-dark); }
.tp-sample-out { font-family: ui-monospace, monospace; font-size: 0.85rem; color: var(--text); }
.widget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.widget-field-label { display: block; font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 3px; }
.widget-field input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 0.9rem;
}
.widget-formula {
  font-family: ui-monospace, monospace; font-size: 0.82rem; color: var(--text-secondary);
  background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px;
  overflow-x: auto;
}
.widget-result { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.widget-result-big { font-size: 1.4rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.widget-result-sub { font-size: 0.85rem; color: var(--text-secondary); }

/* Section-scoped slide carousels */
.slide-figure-title {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: 8px;
}

/* Slide carousel thumbnail strip (was unstyled — thumbs rendered full-size) */
.slide-thumb-strip {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 8px 4px 4px;
}
.slide-thumb {
  width: 88px;
  height: auto;
  flex: 0 0 auto;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.75;
}
.slide-thumb:hover { opacity: 1; }
.slide-thumb-active {
  border-color: var(--accent);
  opacity: 1;
}
