:root {
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --surface-alt: #F3EFE7;
  --border: #E2DBD0;
  --ink: #16202A;
  --muted: #596573;
  --navy: #1E3A5F;
  --navy-soft: #EBF1F8;
  --terra: #C44D2B;
  --terra-soft: #FDF0EC;
  --gold: #C89B3C;
  --gold-soft: #FBF5E6;
  --sage: #2C6E58;
  --sage-soft: #EAF4F0;
  --shadow-sm: 0 2px 8px rgba(22, 32, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(22, 32, 42, 0.08);
  --radius: 14px;
  --font-sans: 'Be Vietnam Pro', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --reader-font-size: 17px;
}

[data-theme="dark"] {
  --bg: #12171E;
  --surface: #1A212B;
  --surface-alt: #222B37;
  --border: #2E3947;
  --ink: #EDE8DF;
  --muted: #9BA7B4;
  --navy: #7CB2F5;
  --navy-soft: #1E2D3F;
  --terra: #E87453;
  --terra-soft: #31201C;
  --gold: #E4B858;
  --gold-soft: #2D2619;
  --sage: #5AC49E;
  --sage-soft: #182C25;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

.hidden { display: none !important; }
.muted-text { color: var(--muted); font-size: 0.92rem; }

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 68px;
  flex-wrap: nowrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--navy);
  color: #FAF8F4;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}
[data-theme="dark"] .brand-mark { background: var(--terra); color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 700; font-size: 0.98rem; color: var(--ink); white-space: nowrap; }
.brand-sub { font-size: 0.74rem; color: var(--muted); white-space: nowrap; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}
.nav-tab:hover { color: var(--ink); background: var(--surface-alt); }
.nav-tab.is-active {
  color: var(--navy);
  background: var(--navy-soft);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  transition: border-color 0.18s;
}
.icon-btn:hover { border-color: var(--navy); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.94rem;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--terra);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(196, 77, 43, 0.25);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary {
  background: var(--surface);
  color: var(--navy);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--navy); background: var(--navy-soft); }
.btn-sm { padding: 7px 14px; font-size: 0.84rem; border-radius: 8px; }

/* HERO */
.hero {
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 28px;
  align-items: center;
}
.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--terra);
  margin-bottom: 10px;
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 3.2vw, 2.7rem);
  line-height: 1.18;
  margin: 0 0 14px;
  color: var(--ink);
}
.hero h1 em { color: var(--navy); font-style: italic; }
.hero-lead {
  font-size: 1.02rem;
  color: var(--muted);
  margin: 0 0 22px;
  max-width: 620px;
}
.hero-cta-row { display: flex; flex-wrap: wrap; gap: 12px; }

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.progress-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--navy-soft);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.progress-bar-track {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--terra));
  transition: width 0.35s ease;
}
.stats-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.stat-val { display: block; font-weight: 700; font-size: 1.02rem; color: var(--navy); }
.stat-lbl { display: block; font-size: 0.75rem; color: var(--muted); }
.progress-tip { margin: 0; font-size: 0.82rem; color: var(--muted); }

/* VIEWS */
.view-section { display: none; padding: 34px 0 60px; }
.view-section.is-active { display: block; animation: fadeIn 0.22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-header { margin-bottom: 26px; max-width: 780px; }
.section-header h2 {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  margin: 0 0 8px;
  line-height: 1.22;
}
.section-header p { margin: 0; color: var(--muted); }

/* MODULES LAYOUT */
.modules-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 26px;
  align-items: start;
}
.modules-sidebar {
  position: sticky;
  top: 86px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.sidebar-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.sidebar-head h3 { margin: 0 0 2px; font-size: 1rem; }
.module-nav-list { display: flex; flex-direction: column; gap: 6px; }
.mod-nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.mod-nav-item:hover { background: var(--surface-alt); }
.mod-nav-item.is-active { background: var(--navy-soft); border-color: color-mix(in srgb, var(--navy) 35%, transparent); }
.mod-num {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface-alt);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.mod-nav-item.is-done .mod-num { background: var(--sage); color: #fff; }
.mod-nav-item.is-active .mod-num { background: var(--navy); color: #fff; }
.mod-nav-title { font-size: 0.87rem; font-weight: 600; line-height: 1.35; }

.module-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 34px;
  box-shadow: var(--shadow-sm);
}
.stage-top-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.module-stage h2 {
  font-family: var(--font-serif);
  font-size: 1.95rem;
  line-height: 1.22;
  margin: 0 0 8px;
}
.stage-subtitle { font-size: 1.05rem; color: var(--muted); margin: 0 0 22px; }

.callout-box {
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  border-left: 4px solid var(--navy);
  background: var(--navy-soft);
}
.callout-box.is-gold { border-left-color: var(--gold); background: var(--gold-soft); }
.callout-box.is-terra { border-left-color: var(--terra); background: var(--terra-soft); }
.callout-box.is-sage { border-left-color: var(--sage); background: var(--sage-soft); }
.callout-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  color: var(--navy);
}
.callout-box.is-terra .callout-label { color: var(--terra); }
.callout-box.is-sage .callout-label { color: var(--sage); }

.distinction-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.94rem;
}
.distinction-table th, .distinction-table td {
  border: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  width: 50%;
}
.distinction-table th { background: var(--surface-alt); font-weight: 700; }
.distinction-table th:last-child { color: var(--navy); }

.figures-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 22px 0;
}
.figure-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.figure-card img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  cursor: zoom-in;
  display: block;
}
.figure-card figcaption {
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--muted);
}
.zoomable-img { cursor: zoom-in; }

.book-quote {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  border-left: 3px solid var(--gold);
  padding: 10px 18px;
  margin: 22px 0;
  color: var(--ink);
  background: var(--surface-alt);
  border-radius: 0 10px 10px 0;
}

.mini-quiz-box {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.mini-quiz-box h4 { margin: 0 0 14px; font-size: 1rem; color: var(--navy); }
.mq-item { margin-bottom: 16px; }
.mq-q { font-weight: 600; margin-bottom: 8px; font-size: 0.95rem; }
.mq-opts { display: flex; flex-direction: column; gap: 6px; }
.mq-opt {
  text-align: left;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.mq-opt:hover { border-color: var(--navy); }
.mq-opt.is-correct { background: var(--sage-soft); border-color: var(--sage); color: var(--sage); font-weight: 600; }
.mq-opt.is-wrong { background: var(--terra-soft); border-color: var(--terra); color: var(--terra); }
.mq-explain { margin-top: 6px; font-size: 0.86rem; color: var(--muted); }

.stage-footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* LABS */
.lab-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.subtab-btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
}
.subtab-btn.is-active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.lab-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}
.sim-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 22px;
}
.sim-context-btn {
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-sans);
}
.sim-context-btn.is-active {
  border-color: var(--terra);
  background: var(--terra-soft);
}
.sim-result-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.sim-card {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.sim-card h4 { margin: 0 0 6px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy); }
.sim-card p { margin: 0; font-size: 0.95rem; }

.bricks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.brick-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-alt);
  cursor: pointer;
  transition: all 0.2s;
}
.brick-card.is-broken {
  background: var(--sage-soft);
  border-color: var(--sage);
}
.brick-title { font-weight: 700; margin-bottom: 8px; color: var(--ink); }
.brick-stages { font-size: 0.9rem; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

/* READER */
.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
}
.book-switcher { display: flex; flex-wrap: wrap; gap: 8px; }
.book-switch-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
}
.book-switch-btn.is-active { background: var(--navy); color: #fff; border-color: var(--navy); }
.reader-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box input, .glossary-filter-bar input, .form-group input, .form-group textarea, .select-control {
  padding: 9px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.92rem;
}
.search-box input { width: 310px; max-width: 100%; }
.font-controls { display: flex; gap: 4px; }
.ctrl-btn {
  padding: 7px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.search-results-panel {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  max-height: 280px;
  overflow-y: auto;
}
.search-hit {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-hit:hover { background: var(--surface-alt); }

.reader-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  align-items: start;
}
.reader-toc {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.toc-btn {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.toc-btn:hover { background: var(--surface-alt); color: var(--ink); }
.toc-btn.is-active { background: var(--navy-soft); color: var(--navy); font-weight: 700; }
.toc-btn.is-read::after { content: "✓"; color: var(--sage); font-weight: 700; }

.reader-paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 42px;
  font-size: var(--reader-font-size);
  line-height: 1.78;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.reader-paper h1, .reader-paper h2, .reader-paper h3, .reader-paper h4 {
  font-family: var(--font-serif);
  color: var(--navy);
  line-height: 1.28;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
}
.reader-paper h1:first-child, .reader-paper h2:first-child { margin-top: 0; }
.reader-paper blockquote {
  margin: 18px 0;
  padding: 12px 18px;
  background: var(--surface-alt);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  font-size: 0.94em;
}
.reader-paper table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.84rem;
  line-height: 1.45;
}
.reader-paper th, .reader-paper td {
  border: 1px solid var(--border);
  padding: 7px 9px;
}
.reader-paper th { background: var(--surface-alt); font-weight: 700; }
.reader-paper figure.book-fig {
  margin: 24px 0;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.reader-paper figure.book-fig img { max-width: 100%; height: auto; border-radius: 8px; cursor: zoom-in; }
.reader-paper figure.book-fig figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 8px; font-style: italic; }

.term-highlight {
  border-bottom: 1.5px dotted var(--terra);
  color: inherit;
  cursor: pointer;
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  padding: 0 2px;
  border-radius: 3px;
}
.term-highlight:hover { background: color-mix(in srgb, var(--gold) 28%, transparent); }

/* GLOSSARY & FLASHCARDS */
.flashcard-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.flashcard-box {
  max-width: 680px;
  margin: 0 auto 16px;
  min-height: 210px;
  border-radius: 14px;
  border: 1.5px solid var(--navy);
  background: var(--bg);
  padding: 28px 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s;
}
.flashcard-box:hover { transform: translateY(-2px); }
.glossary-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.glossary-filter-bar input { min-width: 260px; flex: 1; }
.category-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.cat-pill.is-active { background: var(--navy); color: #fff; border-color: var(--navy); }
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.glossary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.glossary-card h4 { margin: 6px 0 4px; color: var(--navy); font-size: 1.05rem; }
.glossary-en { font-size: 0.84rem; color: var(--terra); font-style: italic; margin-bottom: 8px; }

/* QUIZ */
.quiz-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 860px;
}
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

/* PROJECT */
.project-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 24px;
  align-items: start;
}
.project-form, .empirical-aside {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; color: var(--navy); }
.form-group input, .form-group textarea { width: 100%; }
.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.save-indicator { font-size: 0.84rem; color: var(--sage); font-weight: 600; }
.aside-chart { width: 100%; border-radius: 10px; border: 1px solid var(--border); margin: 12px 0; }
.empirical-list { display: flex; flex-direction: column; gap: 8px; }
.emp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.85rem;
}

/* POPOVER & LIGHTBOX */
.term-popover {
  position: fixed;
  z-index: 90;
  bottom: 24px;
  right: 24px;
  width: min(390px, calc(100vw - 32px));
  background: var(--surface);
  border: 1.5px solid var(--navy);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-md);
}
.term-popover-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.term-popover-head strong { color: var(--navy); font-size: 1.02rem; }
.pop-close { border: none; background: transparent; font-size: 1.4rem; cursor: pointer; color: var(--muted); }
.term-popover-en { font-size: 0.84rem; color: var(--terra); font-style: italic; margin-bottom: 8px; }
.term-popover-def { margin: 0 0 8px; font-size: 0.9rem; }
.term-popover-ex { margin: 0; font-size: 0.84rem; color: var(--muted); background: var(--surface-alt); padding: 8px 10px; border-radius: 8px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 16, 22, 0.88);
  display: grid;
  place-items: center;
  padding: 24px;
}
.lightbox-inner { max-width: 92vw; max-height: 90vh; text-align: center; }
.lightbox-inner img { max-width: 100%; max-height: 80vh; border-radius: 10px; background: #fff; }
.lightbox-inner p { color: #EDE8DF; margin: 10px 0 0; font-size: 0.95rem; }
.lightbox-close {
  position: fixed;
  top: 18px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
}

/* FOOTER */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  background: var(--surface);
  font-size: 0.86rem;
  color: var(--muted);
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: var(--navy); font-weight: 600; text-decoration: none; }

@media (max-width: 980px) {
  .hero-grid, .modules-layout, .reader-layout, .project-grid { grid-template-columns: 1fr; }
  .modules-sidebar, .reader-toc { position: static; max-height: none; }
  .sim-grid, .sim-result-cards { grid-template-columns: 1fr; }
  .reader-paper { padding: 22px 18px; }
  .brand-sub { display: none; }
}
