/* ═══════════════════════════════════════════════════════════════
   Diffusion From Scratch — Shared Styles (Dark Ocean Theme)
   Based on CS234 RL structure, remapped to dark mode ocean palette
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Dark ocean palette */
  --bg-deep: #0a0e17;
  --bg-surface: #111827;
  --bg-elevated: #1a2332;
  --bg-hover: #1f2937;

  /* Text — soft beige-white, not pure white */
  --text-primary: #e8dcc8;
  --text-secondary: #b8ad98;
  --text-muted: #6b7280;

  /* Accents */
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-light: rgba(249, 115, 22, 0.08);
  --accent-border: rgba(249, 115, 22, 0.25);
  --teal: #2dd4bf;
  --teal-light: rgba(45, 212, 191, 0.08);
  --teal-border: rgba(45, 212, 191, 0.25);

  /* Rules */
  --rule: rgba(255, 255, 255, 0.06);
  --rule-strong: rgba(255, 255, 255, 0.12);

  /* Layout */
  --sidebar-w: 280px;

  /* Typography */
  --serif: 'Instrument Serif', 'Georgia', serif;
  --sans: 'Source Sans 3', 'Helvetica Neue', sans-serif;
  --mono: 'IBM Plex Mono', 'Menlo', monospace;

  /* Callout colors (bright enough for dark bg) */
  --blue: #60a5fa;
  --green: #4ade80;
  --purple: #a78bfa;
  --amber: #fbbf24;
  --rose: #f472b6;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Subtle noise texture ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.015'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--rule);
}

.sidebar-header {
  padding: 32px 24px 24px;
  border-bottom: 1px solid var(--rule);
}

.sidebar-header .course-code {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 6px;
  font-weight: 500;
}

.sidebar-header h1 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-primary);
}

.sidebar-header h1 a {
  color: inherit;
  text-decoration: none;
}

.sidebar-header h1 a:hover {
  color: var(--accent);
}

.sidebar-header .term {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section {
  padding: 0 16px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.4;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--text-primary);
}

.nav-item .nav-num {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  min-width: 20px;
  padding-top: 2px;
  opacity: 0.8;
}

.nav-item.active .nav-num { opacity: 1; }

/* ToC sub-items (lecture pages) */
.nav-sub-item {
  display: block;
  padding: 6px 12px 6px 44px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
}

.nav-sub-item:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
}

.nav-sub-item.active {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.sidebar-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.sidebar-footer a:hover { color: var(--accent); }

/* ── Mobile menu toggle ── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.3s;
  position: relative;
}

.menu-toggle span::before,
.menu-toggle span::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.3s;
}

.menu-toggle span::before { top: -6px; }
.menu-toggle span::after { top: 6px; }

.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s;
}

/* ── Main content ── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* ── Scroll progress ── */
.progress-bar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 50;
}

.progress-bar .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  width: 0%;
  transition: width 0.1s linear;
}

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

/* ═══════════════════════════════════════════════════════════════
   INDEX PAGE — Hero, modules, lecture cards, readings, prereqs
   ═══════════════════════════════════════════════════════════════ */
.hero {
  padding: 80px 60px 60px;
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
  max-width: 1200px;
  margin: 0 auto;
}

.hero::after {
  content: '';
  position: absolute;
  top: -120px;
  right: -80px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 16px;
  font-weight: 500;
}

.hero h2 {
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 400;
  line-height: 1.15;
  color: var(--text-primary);
  max-width: 600px;
  margin-bottom: 16px;
}

.hero-hook {
  font-size: 22px;
  font-weight: 600;
  color: var(--teal);
  max-width: 560px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.hero p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  gap: 40px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
}

.hero-stat .stat-num {
  font-family: var(--serif);
  font-size: 32px;
  color: var(--text-primary);
}

.hero-stat .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.content {
  padding: 0 60px 80px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Module card ── */
.module {
  padding-top: 56px;
  scroll-margin-top: 24px;
}

.module-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--rule-strong);
}

.module-number {
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1;
  color: var(--accent);
  opacity: 0.2;
  min-width: 60px;
}

.module-title-block { padding-top: 8px; }

.module-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--text-primary);
}

.module-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 4px;
}

.module-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 40px;
  max-width: 1200px;
}

.module-description {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-secondary);
}

.module-description p + p { margin-top: 12px; }

.module-description ul {
  margin-top: 10px;
  padding-left: 20px;
}

.module-description li {
  margin-bottom: 6px;
  color: var(--text-secondary);
}

/* ── Lecture cards ── */
.lectures-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lectures-panel h4 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.lecture-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.lecture-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.lecture-card:hover {
  border-color: var(--accent-border);
  background: var(--bg-elevated);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.lecture-card:hover::before { transform: scaleY(1); }

.lecture-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lecture-icon svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.lecture-info {
  flex: 1;
  min-width: 0;
}

.lecture-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.lecture-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.lecture-arrow {
  color: var(--text-muted);
  transition: all 0.25s;
  flex-shrink: 0;
}

.lecture-card:hover .lecture-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ── Reading pills ── */
.readings { margin-top: 8px; }

.readings h4 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.reading-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reading-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  text-decoration: none;
  transition: all 0.2s;
}

.reading-pill:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

.reading-pill.is-link { cursor: pointer; }

.reading-pill svg {
  width: 12px;
  height: 12px;
  opacity: 0.5;
}

/* ── Prerequisites ── */
.prereqs {
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 28px 32px;
  margin-top: 40px;
  max-width: 1200px;
}

.prereqs h4 {
  font-family: var(--serif);
  font-size: 20px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.prereqs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.prereq-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
}

.prereq-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.prereq-card .prereq-icon { font-size: 20px; }
.prereq-card .prereq-label { font-size: 13px; font-weight: 600; }
.prereq-card .prereq-sub { font-size: 11px; color: var(--text-muted); }

/* Index page animations */
.page-index .module {
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.page-index .module:nth-child(1) { animation-delay: 0.05s; }
.page-index .module:nth-child(2) { animation-delay: 0.1s; }
.page-index .module:nth-child(3) { animation-delay: 0.15s; }
.page-index .module:nth-child(4) { animation-delay: 0.2s; }
.page-index .module:nth-child(5) { animation-delay: 0.25s; }
.page-index .module:nth-child(6) { animation-delay: 0.3s; }
.page-index .module:nth-child(7) { animation-delay: 0.35s; }

.page-index .hero { animation: fadeUp 0.6s ease forwards; }

/* ── Assessment section (distinct from numbered modules) ── */
.assessment-section {
  padding-top: 56px;
  scroll-margin-top: 24px;
}

.assessment-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--teal-border);
}

.assessment-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.assessment-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  color: var(--text-primary);
}

.assessment-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   LECTURE PAGES — Article content, callouts, algorithms, proofs
   ═══════════════════════════════════════════════════════════════ */

/* ── Lecture header ── */
.lecture-header {
  padding: 80px 60px 48px;
  border-bottom: 1px solid var(--rule);
  max-width: 1200px;
  margin: 0 auto;
}

.lecture-header .lecture-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 12px;
  font-weight: 500;
}

.lecture-header h2 {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.lecture-header .lecture-desc {
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 640px;
}

.lecture-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.lecture-tag {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

/* Teal variant for optional/advanced tags */
.lecture-tag.optional {
  background: var(--teal-light);
  color: var(--teal);
  border-color: var(--teal-border);
}

/* ── Article ── */
.lecture-article {
  padding: 48px 60px 80px;
  max-width: 1200px;
  margin: 0 auto;
}

.lecture-roadmap {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.lecture-article h2 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 400;
  color: var(--text-primary);
  margin-top: 56px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--rule-strong);
  scroll-margin-top: 24px;
}

.section-number {
  color: var(--accent);
  margin-right: 10px;
  font-family: var(--mono);
  font-size: 0.75em;
  font-weight: 500;
  vertical-align: baseline;
  opacity: 0.7;
}

.lecture-article h3 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
  margin-top: 40px;
  margin-bottom: 16px;
  scroll-margin-top: 24px;
}

.lecture-article h4 {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 28px;
  margin-bottom: 12px;
}

.lecture-article p {
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.lecture-article ul,
.lecture-article ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.lecture-article li {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.lecture-article strong {
  color: var(--text-primary);
  font-weight: 600;
}

.lecture-article a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-border);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s;
}

.lecture-article a:hover {
  text-decoration-color: var(--accent);
}

/* ── Callout boxes ── */
.callout {
  border-radius: 12px;
  padding: 24px 28px;
  margin: 24px 0;
  border-left: 4px solid;
}

.callout-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.callout p { margin-bottom: 8px; }
.callout p:last-child { margin-bottom: 0; }

.callout.definition {
  background: rgba(96, 165, 250, 0.06);
  border-color: var(--blue);
}
.callout.definition .callout-label { color: var(--blue); }

.callout.theorem {
  background: rgba(167, 139, 250, 0.06);
  border-color: var(--purple);
}
.callout.theorem .callout-label { color: var(--purple); }

.callout.example {
  background: rgba(251, 191, 36, 0.06);
  border-color: var(--amber);
}
.callout.example .callout-label { color: var(--amber); }

.callout.insight {
  background: rgba(74, 222, 128, 0.06);
  border-color: var(--green);
}
.callout.insight .callout-label { color: var(--green); }

.callout.note {
  background: rgba(107, 114, 128, 0.06);
  border-color: var(--text-muted);
}
.callout.note .callout-label { color: var(--text-muted); }

.callout.prereq {
  background: rgba(244, 114, 182, 0.06);
  border-color: var(--rose);
}
.callout.prereq .callout-label { color: var(--rose); }

/* ── Algorithm blocks ── */
.algorithm {
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 24px 28px;
  margin: 24px 0;
  overflow-x: auto;
}

.algorithm-title {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.algorithm ol,
.algorithm ul {
  padding-left: 20px;
  margin-bottom: 0;
}

.algorithm li {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.algorithm .keyword {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--teal);
  font-size: 14px;
}

.algorithm .comment {
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}

/* ── Collapsible sections (ELBO derivation, proofs, etc.) ── */
.collapsible {
  margin: 20px 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
}

.collapsible summary {
  padding: 14px 20px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--bg-elevated);
  transition: all 0.2s;
  list-style: none;
}

.collapsible summary::-webkit-details-marker { display: none; }

.collapsible summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s;
  color: var(--accent);
}

.collapsible[open] summary::before {
  transform: rotate(90deg);
}

.collapsible summary:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.collapsible .collapsible-content {
  padding: 20px 24px;
  border-top: 1px solid var(--rule);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-secondary);
}

.collapsible .collapsible-content p {
  font-size: 16px;
  margin-bottom: 12px;
}

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

/* ── Code blocks ── */
.code-block {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 20px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre-wrap;
  position: relative;
}

.code-block-label {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.6;
}

.code-block .comment { color: var(--text-muted); font-style: italic; }
.code-block .keyword { color: var(--teal); }
.code-block .string { color: var(--green); }
.code-block .number { color: var(--amber); }
.code-block .function { color: var(--blue); }
.code-block .type { color: var(--purple); }

/* Pseudocode syntax highlighting — same tokens, slightly muted */
.pseudocode .comment { color: var(--text-muted); font-style: italic; }
.pseudocode .keyword { color: var(--teal); }
.pseudocode .string { color: var(--green); }
.pseudocode .number { color: var(--amber); }
.pseudocode .function { color: var(--blue); }
.pseudocode .type { color: var(--purple); }

/* Pseudocode block (distinct from real code) */
.pseudocode {
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--teal);
  border-radius: 0 10px 10px 0;
  padding: 20px 24px;
  margin: 20px 0;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-x: auto;
}

.pseudocode-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  opacity: 0.8;
}

/* ── Math hover tooltips ── */
[data-tip] {
  cursor: help;
  border-bottom: 1px dotted var(--teal);
  padding-bottom: 1px;
}

.math-tooltip {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 320px;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
}

.math-tooltip.visible {
  opacity: 1;
}

/* ── Display math overflow ── */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

/* ── Prev/Next footer nav ── */
.lecture-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 60px;
  border-top: 1px solid var(--rule);
  max-width: 1200px;
  margin: 0 auto;
}

.lecture-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 24px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  text-decoration: none;
  transition: all 0.25s;
  min-width: 180px;
}

.lecture-nav a:hover {
  border-color: var(--accent-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.lecture-nav a .nav-dir {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.lecture-nav a .nav-title {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--text-primary);
}

.lecture-nav .next {
  text-align: right;
  margin-left: auto;
}

/* Top navigation — compact prev/next links */
.lecture-nav-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 60px;
  max-width: 1200px;
  margin: 0 auto 8px auto;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.5px;
}

.lecture-nav-top a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.lecture-nav-top a:hover {
  color: var(--accent);
}

.lecture-nav-top .next {
  margin-left: auto;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
  .module-body {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .prereqs-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: flex; }
  .menu-overlay.open { display: block; opacity: 1; }

  .main { margin-left: 0; }
  .progress-bar { left: 0; }

  .hero { padding: 80px 24px 40px; }
  .hero h2 { font-size: 32px; }
  .content { padding: 0 24px 60px; }

  .hero-stats { gap: 24px; }
  .prereqs-grid { grid-template-columns: 1fr; }

  .lecture-header { padding: 80px 24px 36px; }
  .lecture-header h2 { font-size: 28px; }
  .lecture-article { padding: 32px 24px 60px; }
  .lecture-article h2 { font-size: 26px; }
  .lecture-article h3 { font-size: 20px; }
  .lecture-nav { padding: 24px; flex-direction: column; }
  .lecture-nav a { min-width: unset; }
  .lecture-nav .next { text-align: left; }
  .lecture-nav-top { padding: 12px 24px; font-size: 12px; }

  .callout { padding: 18px 20px; }
  .algorithm { padding: 18px 20px; }
}
