/* ===== 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: 'Heebo', 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-right: 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; }

/* 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: left; margin-right: 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;
  left: 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-right: 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-right-color: var(--accent); font-weight: 500; }
.article-toc a.toc-h3 { padding-right: 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: right; }
.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; left: 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: right; 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-right: auto; color: var(--text-secondary); font-size: 0.88rem; }

/* ===== Exercise Navigator ===== */
.exercise-nav { margin: 16px 0; }
.exercise-nav:focus { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }

.exercise-nav-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.exercise-nav-counter {
  font-size: 0.88rem; color: var(--text-secondary); font-weight: 500;
  text-align: center; flex: 1;
}
.exercise-nav-arrow {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--card-bg);
  color: var(--text); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.exercise-nav-arrow:hover:not(:disabled) { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.exercise-nav-arrow:disabled { opacity: 0.3; cursor: default; }

.exercise-nav-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px;
  font-size: 1rem; line-height: 1.7;
  min-height: 60px;
}
.exercise-nav-num {
  display: inline-block; font-weight: 700; color: var(--accent);
  margin-left: 8px; min-width: 1.5em;
}

/* Exercise interaction: answer, check, reveal */
.exercise-answer-input {
  display: block; width: 100%; margin-top: 16px;
  padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--card-bg);
  color: var(--text); font-family: inherit; font-size: 0.95rem;
  line-height: 1.6; direction: rtl; resize: vertical;
  min-height: 72px;
}
.exercise-answer-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.exercise-btn-row {
  display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap;
}
.exercise-check-btn, .exercise-reveal-btn {
  padding: 8px 18px; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--card-bg);
  color: var(--text); transition: background 0.15s, border-color 0.15s;
}
.exercise-check-btn:hover:not(:disabled) {
  background: #eef2ff; border-color: var(--accent); color: var(--accent);
}
.exercise-reveal-btn:hover:not(:disabled) {
  background: #fef3c7; border-color: #d97706; color: #92400e;
}
.exercise-check-btn:disabled, .exercise-reveal-btn:disabled {
  opacity: 0.4; cursor: default;
}
.exercise-feedback {
  margin-top: 14px; padding: 14px 16px;
  border-radius: var(--radius); font-size: 0.93rem; line-height: 1.7;
  background: #eef2ff; border: 1px solid #c7d2fe; color: #312e81;
  direction: rtl;
}
.exercise-feedback.hidden { display: none; }
.exercise-streaming { position: relative; }
.exercise-streaming::after {
  content: ''; display: inline-block; width: 6px; height: 14px;
  background: var(--accent); margin-right: 2px;
  animation: blink 0.7s infinite;
  vertical-align: text-bottom;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.exercise-solution {
  margin-top: 14px; padding: 14px 16px;
  border-radius: var(--radius); font-size: 0.93rem; line-height: 1.7;
  background: #ecfdf5; border: 1px solid #a7f3d0; color: #064e3b;
  direction: rtl; white-space: pre-wrap;
}
.exercise-solution.hidden { display: none; }
.exercise-solution strong { display: block; margin-bottom: 6px; }
.exercise-solution-text { white-space: pre-wrap; }
/* Floating answer panel */
.exercise-float-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 900;
}
.exercise-float-backdrop.hidden { display: none; }
.exercise-float-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 901;
  background: var(--card-bg); border-top: 2px solid var(--accent);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  max-height: 55vh; overflow-y: auto;
  padding: 0 20px 16px;
  direction: rtl;
}
.exercise-float-panel.hidden { display: none; }
.exercise-float-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; position: sticky; top: 0;
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  margin-bottom: 8px; z-index: 1;
}
.exercise-float-title {
  font-size: 0.88rem; color: var(--text-secondary); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.exercise-float-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--card-bg);
  color: var(--text); font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px; flex-shrink: 0;
}
.exercise-float-close:hover { background: #fee2e2; border-color: #ef4444; color: #ef4444; }

/* PDF inline iframe */
.exercise-pdf-toggle-wrap { display: inline; }
.exercise-pdf-toggle-btn {
  display: inline-block; margin-right: 10px; padding: 4px 14px;
  border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--card-bg); color: var(--accent);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.exercise-pdf-toggle-btn:hover { background: var(--accent-light); border-color: var(--accent); }
.exercise-pdf-iframe-wrap { margin: 12px 0; }
.exercise-pdf-iframe-wrap.hidden { display: none; }
.exercise-pdf-iframe {
  width: 100%; height: 70vh; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: #f9fafb;
}

/* Dark mode overrides */
[data-theme="dark"] .exercise-answer-input { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .exercise-check-btn:hover:not(:disabled) { background: #1e1b4b; border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .exercise-reveal-btn:hover:not(:disabled) { background: #422006; border-color: #d97706; color: #fbbf24; }
[data-theme="dark"] .exercise-feedback { background: #1e1b4b; border-color: #3730a3; color: #c7d2fe; }
[data-theme="dark"] .exercise-solution { background: #064e3b; border-color: #059669; color: #a7f3d0; }
[data-theme="dark"] .exercise-float-panel { border-color: var(--accent); box-shadow: 0 -4px 24px rgba(0,0,0,0.4); }
[data-theme="dark"] .exercise-float-close:hover { background: #7f1d1d; border-color: #ef4444; color: #fca5a5; }
[data-theme="dark"] .exercise-pdf-iframe { background: #1e293b; border-color: #334155; }

/* 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; }
