/* ==========================================================================
   6SENG006C Concurrent Programming — Interactive Visual Study Guide
   Shared Editorial Design System (extracted & extended from reference-style.html)
   100% offline-ready · Warm Paper Light & Dark Ink themes · Zero dependencies
   ========================================================================== */

:root {
  --bg: #faf7f2;
  --bg-elevated: #f3eee5;
  --bg-diagram: #ffffff;
  --bg-code: #f1ece2;
  --ink: #1a1816;
  --ink-secondary: #534d45;
  --ink-muted: #787065;
  --hairline: #dfd8cc;
  --hairline-strong: #c5bcad;

  /* Semantic concurrency palette */
  --forest: #245740;
  --forest-soft: #e6f0eb;
  --forest-mid: #3a7a5c;

  --terracotta: #a63d26;
  --terracotta-soft: #f7e7e2;
  --terracotta-mid: #c4563d;

  --indigo: #294973;
  --indigo-soft: #e6edf5;
  --indigo-mid: #41689b;

  --ochre: #8c621c;
  --ochre-soft: #f5ecd9;
  --ochre-mid: #b3802a;

  /* Diagram solids */
  --pyr-1: #245740;
  --pyr-2: #346b51;
  --pyr-3: #294973;
  --pyr-4: #875c18;
  --pyr-text: #ffffff;
  --pyr-sub: rgba(255, 255, 255, 0.85);
  --trellis-fill: #4a453e;
  --trellis-text: #faf7f2;

  --shadow-soft: 0 8px 28px rgba(26, 24, 22, 0.06), 0 1px 3px rgba(26, 24, 22, 0.04);
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  --measure: 68ch;
  --sidebar-w: 256px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg: #131216;
  --bg-elevated: #1c1b21;
  --bg-diagram: #18171d;
  --bg-code: #1d1c23;
  --ink: #eae6de;
  --ink-secondary: #b7b1a6;
  --ink-muted: #8b857b;
  --hairline: #2c2a33;
  --hairline-strong: #43404d;

  --forest: #7cc4a0;
  --forest-soft: #1a2d24;
  --forest-mid: #5ba480;

  --terracotta: #e6866e;
  --terracotta-soft: #2e1d19;
  --terracotta-mid: #c96952;

  --indigo: #88b0e2;
  --indigo-soft: #1a2433;
  --indigo-mid: #638ec4;

  --ochre: #dfb365;
  --ochre-soft: #2c2519;
  --ochre-mid: #c29648;

  --pyr-1: #23533d;
  --pyr-2: #2e634a;
  --pyr-3: #28466e;
  --pyr-4: #785217;
  --pyr-text: #f5f2eb;
  --pyr-sub: rgba(245, 242, 235, 0.82);
  --trellis-fill: #393642;
  --trellis-text: #eae6de;

  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Base reset & typography */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  line-height: 1.72;
  transition: background-color 240ms var(--ease-out), color 240ms var(--ease-out);
  overflow-x: clip;
}

::selection { background: var(--forest-soft); color: var(--forest); }

:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 3px;
  border-radius: 2px;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border: 2px solid var(--bg);
  border-radius: 99px;
}

/* Top reading progress bar */
.progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  z-index: 60;
  pointer-events: none;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--forest);
  transition: width 80ms linear;
}

/* Sticky top utility bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-title {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title .icon-btn { flex-shrink: 0; }
.topbar-title .topbar-sub { color: var(--ink-muted); font-weight: 400; }
.topbar-title .topbar-name { overflow: hidden; text-overflow: ellipsis; }
.topbar-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  font-family: var(--font-sans);
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.segmented button[aria-pressed="true"] {
  background: var(--bg-diagram);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.icon-btn:hover { border-color: var(--hairline-strong); color: var(--ink); }
.icon-btn.is-complete {
  background: var(--forest-soft);
  border-color: var(--forest);
  color: var(--forest);
}
.toc-toggle { display: none; }

/* Main two-column editorial shell (module pages) */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 96px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 64px;
  align-items: start;
}

/* Landing page centered shell (index.html) */
.shell-landing {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* Sticky sidebar TOC */
.sidebar {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  padding-right: 12px;
  font-family: var(--font-sans);
}
.sidebar-label {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 0 0 12px;
  padding-left: 12px;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--hairline);
}
.toc-list li { margin: 0; }
.toc-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px 7px 13px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  line-height: 1.35;
  transition: color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}
.toc-link:hover { color: var(--ink); }
.toc-link.active {
  color: var(--forest);
  font-weight: 600;
  border-left-color: var(--forest);
}
.toc-ts {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.sidebar-meta {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-size: 0.76rem;
  color: var(--ink-muted);
  line-height: 1.55;
  padding-left: 12px;
}
.sidebar-meta a { color: var(--ink-secondary); text-underline-offset: 3px; }
.sidebar-progress {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
}
.sidebar-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}
.mini-bar { height: 5px; background: var(--hairline); border-radius: 99px; overflow: hidden; }
.mini-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--forest);
  border-radius: 99px;
  transition: width 240ms var(--ease-out);
}

/* Article column */
.article {
  width: 100%;
  min-width: 0;
  max-width: var(--measure);
  padding-top: 48px;
}
.article-header {
  padding-bottom: 34px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 36px;
}
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--forest);
  background: var(--forest-soft);
  padding: 4px 10px;
  border-radius: 5px;
  margin-bottom: 14px;
}
h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 4.3vw, 3.15rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  text-wrap: balance;
}
.subtitle {
  font-size: 1.16rem;
  line-height: 1.54;
  color: var(--ink-secondary);
  margin: 0 0 22px;
  font-weight: 400;
  text-wrap: pretty;
}
.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.byline strong { color: var(--ink); font-weight: 600; }

/* Thesis / at-a-glance box */
.thesis-banner {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 0 0 38px;
}
.thesis-banner p { margin: 0; font-size: 1.05rem; line-height: 1.62; color: var(--ink); }
.thesis-banner p + p {
  margin-top: 10px;
  font-size: 0.89rem;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
}

/* Exam Cram Mode rules (substantial reduction + dedicated recap strips) */
.cram-notice {
  display: none;
  margin: 0 0 26px;
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--ochre-soft);
  border: 1px solid color-mix(in srgb, var(--ochre) 35%, transparent);
  color: var(--ochre);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  line-height: 1.48;
}
.cram-only {
  display: none;
  margin: 0 0 18px;
  padding: 11px 14px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline-strong);
  border-left: 3px solid var(--ochre);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink);
}
.cram-only strong { color: var(--ochre); }
[data-density="cram"] .cram-notice { display: block; }
[data-density="cram"] .cram-only { display: block; }
[data-density="cram"] .narrative-detail,
[data-density="cram"] .cram-hide { display: none !important; }
[data-density="cram"] section { margin-top: 38px; }

/* Sections & headings */
section { margin-top: 60px; }
section:first-of-type { margin-top: 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 2.5vw, 1.92rem);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}
.ts-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--hairline);
  background: var(--bg-elevated);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}
h3 {
  font-family: var(--font-sans);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 28px 0 10px;
  color: var(--ink);
}
p { margin: 0 0 18px; font-size: 1.05rem; color: var(--ink); }
p strong { font-weight: 600; }
code {
  font-family: var(--font-mono);
  font-size: 0.83em;
  background: var(--bg-code);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--hairline);
}
a { color: var(--forest); text-underline-offset: 3px; }

/* Callout strips */
.takeaway-strip {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-secondary);
  padding: 13px 16px;
  background: var(--forest-soft);
  border: 1px solid color-mix(in srgb, var(--forest) 25%, transparent);
  border-radius: 8px;
  margin: 0 0 22px;
}
.takeaway-strip strong { color: var(--forest); }

.exam-trap {
  font-family: var(--font-sans);
  font-size: 0.89rem;
  line-height: 1.55;
  color: var(--ink-secondary);
  padding: 14px 16px;
  background: var(--terracotta-soft);
  border: 1px solid color-mix(in srgb, var(--terracotta) 32%, transparent);
  border-left: 3px solid var(--terracotta);
  border-radius: 8px;
  margin: 22px 0;
}
.exam-trap strong { color: var(--terracotta); }

/* Lecture Shorthand vs Actual JVM Behavior callout (reusable across M3, M4, etc.) */
.lecture-vs-jvm {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-secondary);
  padding: 14px 16px;
  background: var(--indigo-soft);
  border: 1px solid color-mix(in srgb, var(--indigo) 32%, transparent);
  border-left: 3px solid var(--indigo);
  border-radius: 8px;
  margin: 20px 0;
}
.lecture-vs-jvm-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--indigo);
  margin-bottom: 5px;
}
.lecture-vs-jvm strong { color: var(--ink); }

/* Everyday intuition / analogy card */
.analogy-card {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.56;
  color: var(--ink-secondary);
  padding: 15px 18px;
  background: var(--ochre-soft);
  border: 1px solid color-mix(in srgb, var(--ochre) 30%, transparent);
  border-radius: 10px;
  margin: 0 0 22px;
}
.analogy-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ochre);
  margin-bottom: 6px;
}
.analogy-card p { font-family: var(--font-sans); font-size: 0.9rem; line-height: 1.56; margin: 0; color: var(--ink); }

/* Glossary strip */
.glossary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
  font-family: var(--font-sans);
}
.glossary-pill {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  color: var(--ink-secondary);
}
.glossary-pill strong { color: var(--ink); font-family: var(--font-mono); font-size: 0.75rem; }

/* Clickable Jargon Decoder */
.jargon-term {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1.5px dotted var(--indigo);
  padding: 0 2px;
  margin: 0;
  font: inherit;
  color: var(--indigo);
  font-weight: 500;
  cursor: pointer;
  border-radius: 2px;
  transition: background-color 140ms;
}
.jargon-term:hover,
.jargon-term[aria-expanded="true"] { background: var(--indigo-soft); }
.jargon-popover {
  position: fixed;
  z-index: 90;
  max-width: 310px;
  padding: 12px 14px;
  background: var(--bg-diagram);
  border: 1px solid var(--indigo);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink);
}
.jargon-popover-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}
.jargon-popover-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--indigo);
}
.jargon-popover-close {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.jargon-popover-body { color: var(--ink-secondary); }

/* Visual figures & interactive containers */
figure.visual {
  margin: 26px 0 32px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-soft);
}
figure.visual figcaption {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.52;
  color: var(--ink-muted);
}
figure.visual figcaption strong { color: var(--ink-secondary); font-weight: 600; }
.visual-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin-bottom: 16px;
  font-family: var(--font-sans);
}
.visual-title { font-size: 0.94rem; font-weight: 600; color: var(--ink); margin: 0; }
.visual-hint { font-size: 0.75rem; color: var(--ink-muted); }

/* SVG scroll wrapper so SVG labels never shrink below legible sizes on phones */
.svg-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.svg-interactive { width: 100%; height: auto; display: block; }

/* State inspector (full-width diagram above horizontal detail card) */
.state-inspector-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.state-detail-card {
  font-family: var(--font-sans);
  padding: 16px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}
.state-detail-card h4 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--ink); }
.state-detail-card p { font-family: var(--font-sans); font-size: 0.85rem; line-height: 1.54; color: var(--ink-secondary); margin: 0; }
.state-meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.state-meta-row span {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  padding: 3px 8px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  color: var(--ink);
}
.state-node { cursor: pointer; transition: opacity 150ms var(--ease-out); }
.state-node:hover { opacity: 0.92; }
.state-node.dimmed { opacity: 0.56; }
.state-node.active rect { stroke-width: 2.6; }

/* Thread state pills */
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.st-new { background: var(--bg-elevated); border-color: var(--hairline-strong); color: var(--ink-secondary); }
.st-runnable { background: var(--forest-soft); border-color: color-mix(in srgb, var(--forest) 40%, transparent); color: var(--forest); }
.st-blocked, .st-deadlock { background: var(--terracotta-soft); border-color: color-mix(in srgb, var(--terracotta) 42%, transparent); color: var(--terracotta); }
.st-waiting { background: var(--indigo-soft); border-color: color-mix(in srgb, var(--indigo) 42%, transparent); color: var(--indigo); }
.st-timed { background: var(--ochre-soft); border-color: color-mix(in srgb, var(--ochre) 42%, transparent); color: var(--ochre); }
.st-terminated { background: var(--bg-code); border-color: var(--hairline); color: var(--ink-muted); }

/* Simulator Controls, Buttons & Panels */
.sim-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  margin-bottom: 14px;
  font-family: var(--font-sans);
}
.sim-btn-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.sim-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--bg-diagram);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms var(--ease-out);
}
.sim-btn:hover:not(:disabled) { border-color: var(--forest); color: var(--forest); }
.sim-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.sim-btn-primary { background: var(--forest); border-color: var(--forest); color: #ffffff; }
[data-theme="dark"] .sim-btn-primary { color: #0e1712; }
.sim-btn-primary:hover:not(:disabled) { background: var(--forest-mid); border-color: var(--forest-mid); color: #ffffff; }
[data-theme="dark"] .sim-btn-primary:hover:not(:disabled) { color: #0e1712; }
.sim-btn-danger { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); }
.sim-btn-danger:hover:not(:disabled) { background: var(--terracotta); color: #ffffff; }
.sim-btn-indigo { background: var(--indigo-soft); border-color: var(--indigo); color: var(--indigo); }
.sim-btn-indigo:hover:not(:disabled) { background: var(--indigo); color: #ffffff; }

.mode-switch-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.mode-pill-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--bg-diagram);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 140ms;
}
.mode-pill-btn.safe-on { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); font-weight: 600; }
.mode-pill-btn.bug-on { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); font-weight: 600; }

.scene-btn-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.scene-btn {
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--hairline-strong);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms var(--ease-out);
}
.scene-btn:hover { border-color: var(--forest); color: var(--ink); }
.scene-btn.active { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); font-weight: 600; }
.scene-btn.active-danger { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); font-weight: 600; }

.sim-split {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 16px;
  align-items: start;
}
.dual-code-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 12px;
  margin-bottom: 14px;
}

.code-trace {
  background: var(--bg-code);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.62;
}
.code-trace-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--bg-elevated);
}
.code-trace-body { padding: 8px 0; overflow-x: auto; }
.code-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 11px;
  white-space: pre;
  color: var(--ink-secondary);
  transition: background-color 140ms;
}
.code-line .ln {
  color: var(--ink-muted);
  user-select: none;
  min-width: 16px;
  text-align: right;
  opacity: 0.65;
}
.code-line.active-line {
  background: var(--forest-soft);
  color: var(--ink);
  font-weight: 500;
  border-left: 3px solid var(--forest);
  padding-left: 8px;
}
.code-line.error-line {
  background: var(--terracotta-soft);
  color: var(--terracotta);
  font-weight: 500;
  border-left: 3px solid var(--terracotta);
  padding-left: 8px;
}
.line-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
  padding-left: 8px;
}
.pin-chip {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  line-height: 1.4;
}
.pin-chip.producer { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); }
.pin-chip.consumer { background: var(--indigo-soft); border-color: var(--indigo); color: var(--indigo); }
.pin-chip.dead { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); }

.sim-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 15px;
  font-family: var(--font-sans);
}
.sim-panel-title {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 0 0 10px;
}
.worker-pill-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  margin-bottom: 10px;
}
.worker-meta { display: flex; flex-direction: column; gap: 2px; }
.worker-meta strong { font-size: 0.85rem; color: var(--ink); }
.worker-meta span { font-size: 0.75rem; color: var(--ink-muted); }

/* Predict-before-step row inside tracers */
.predict-bar {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--indigo-soft);
  border: 1px solid color-mix(in srgb, var(--indigo) 32%, transparent);
  border-radius: 9px;
  font-family: var(--font-sans);
}
.predict-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.predict-score {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-diagram);
  color: var(--indigo);
  border: 1px solid color-mix(in srgb, var(--indigo) 35%, transparent);
}
.predict-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.predict-controls label {
  font-size: 0.78rem;
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.predict-controls select {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--bg-diagram);
  color: var(--ink);
}

/* Guided Story Narrator Strip & "You Are the JVM" Picker */
.story-sticky-wrap {
  position: relative;
}
.story-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px;
  background: var(--indigo-soft);
  border: 1px solid color-mix(in srgb, var(--indigo) 35%, transparent);
  border-radius: 9px;
  margin-bottom: 14px;
  font-family: var(--font-sans);
}
.story-beat-text { font-size: 0.86rem; line-height: 1.5; color: var(--ink); flex: 1 1 260px; }
.story-beat-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--indigo);
  background: var(--bg-diagram);
  border: 1px solid color-mix(in srgb, var(--indigo) 35%, transparent);
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 7px;
}

.jvm-picker {
  margin-bottom: 14px;
  padding: 13px 15px;
  background: var(--ochre-soft);
  border: 1px solid color-mix(in srgb, var(--ochre) 40%, transparent);
  border-radius: 9px;
  font-family: var(--font-sans);
}
.jvm-picker p {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  margin: 0 0 10px;
  color: var(--ink);
}

.sim-alert {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  line-height: 1.5;
  border: 1px solid var(--hairline);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
}
.sim-alert.ok { background: var(--forest-soft); border-color: color-mix(in srgb, var(--forest) 35%, transparent); color: var(--forest); }
.sim-alert.warn { background: var(--ochre-soft); border-color: color-mix(in srgb, var(--ochre) 38%, transparent); color: var(--ochre); }
.sim-alert.danger { background: var(--terracotta-soft); border-color: color-mix(in srgb, var(--terracotta) 42%, transparent); color: var(--terracotta); }

/* Collapsible execution log */
.log-details {
  margin-top: 12px;
  font-family: var(--font-sans);
}
.log-details summary {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
.sim-log {
  margin-top: 8px;
  background: var(--bg-code);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 150px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}
.sim-log-entry { padding: 2px 0; border-bottom: 1px dashed color-mix(in srgb, var(--hairline) 70%, transparent); }
.sim-log-entry:last-child { border-bottom: 0; }
.sim-log-entry.err { color: var(--terracotta); font-weight: 500; }
.sim-log-entry.ok { color: var(--forest); }
.sim-log-entry.info { color: var(--indigo); }
.sim-log-entry.warn { color: var(--ochre); }

/* Monitor & Buffer Visual Grids (Unified order: Hallway -> Counter -> Bench) */
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  font-family: var(--font-sans);
}
.monitor-box {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 12px;
  min-height: 96px;
}
.monitor-box h4 {
  margin: 0 0 8px;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.monitor-box.entry-box { border-color: color-mix(in srgb, var(--terracotta) 42%, var(--hairline)); }
.monitor-box.owner-box { border-color: color-mix(in srgb, var(--forest) 48%, var(--hairline)); }
.monitor-box.wait-box { border-color: color-mix(in srgb, var(--indigo) 45%, var(--hairline)); }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.thread-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
}
.thread-chip.producer { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); }
.thread-chip.consumer { background: var(--indigo-soft); border-color: var(--indigo); color: var(--indigo); }
.thread-chip.dead { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); }
.thread-chip.key-badge { background: var(--ochre-soft); border-color: var(--ochre); color: var(--ochre); font-weight: 600; }
.empty-hint { font-size: 0.76rem; color: var(--ink-muted); font-style: italic; }

.buffer-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  margin-bottom: 14px;
  font-family: var(--font-sans);
}
.buffer-label { font-size: 0.78rem; font-weight: 600; color: var(--ink-secondary); margin-right: 4px; }
.buffer-slot {
  min-width: 78px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1.5px dashed var(--hairline-strong);
  background: var(--bg-diagram);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.buffer-slot.filled {
  border-style: solid;
  border-color: var(--forest);
  background: var(--forest-soft);
  color: var(--forest);
  font-weight: 600;
}
.buffer-slot.overflow-slot {
  border-style: solid;
  border-color: var(--terracotta);
  background: var(--terracotta-soft);
  color: var(--terracotta);
  font-weight: 600;
}

/* Low-stakes Quick Guess micro-prompt */
.quick-guess {
  margin: 22px 0;
  padding: 16px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline-strong);
  border-left: 3px solid var(--indigo);
  border-radius: 9px;
  font-family: var(--font-sans);
}
.quick-guess-tag {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--indigo);
  margin-bottom: 6px;
  display: block;
}
.quick-guess-prompt { font-size: 0.92rem; font-weight: 600; color: var(--ink); margin: 0 0 11px; line-height: 1.46; }
.quick-guess-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.guess-btn {
  padding: 7px 13px;
  border-radius: 7px;
  border: 1px solid var(--hairline-strong);
  background: var(--bg-diagram);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms var(--ease-out);
}
.guess-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.guess-btn.is-right { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); font-weight: 600; }
.guess-btn.is-wrong { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); }
.guess-reply {
  display: none;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-secondary);
}
.guess-reply.visible { display: block; }
.guess-reply strong { color: var(--ink); }

/* Broken vs Fixed Diff Tabs & Plain-English Line Translator */
.diff-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.diff-tabs { display: inline-flex; flex-wrap: wrap; gap: 6px; font-family: var(--font-sans); }
.diff-tab {
  border: 1px solid var(--hairline);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms var(--ease-out);
}
.diff-tab.active-bad { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); }
.diff-tab.active-good { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); }

.gloss-toggle-btn {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--forest);
  background: var(--forest-soft);
  color: var(--forest);
  cursor: pointer;
  transition: all 140ms;
}
.gloss-toggle-btn[aria-pressed="false"] {
  border-color: var(--hairline-strong);
  background: var(--bg-elevated);
  color: var(--ink-muted);
}
.code-gloss {
  display: inline-block;
  margin-left: 10px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-weight: 400;
  color: var(--ink-secondary);
  white-space: normal;
}
.hide-gloss .code-gloss { display: none; }

.code-panel {
  margin-top: 14px;
  background: var(--bg-code);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.62;
}
.code-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  color: var(--ink-muted);
}
.code-panel pre { margin: 0; padding: 14px 16px; overflow-x: auto; white-space: pre; }
.code-bad-line {
  display: block;
  background: color-mix(in srgb, var(--terracotta-soft) 78%, transparent);
  margin: 0 -16px;
  padding: 0 16px;
  color: var(--terracotta);
}
.code-good-line {
  display: block;
  background: color-mix(in srgb, var(--forest-soft) 78%, transparent);
  margin: 0 -16px;
  padding: 0 16px;
  color: var(--forest);
}
.code-outcome {
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  line-height: 1.5;
}
.code-outcome.bad { background: var(--terracotta-soft); color: var(--terracotta); }
.code-outcome.good { background: var(--forest-soft); color: var(--forest); }

/* Interactive Exam Trace Quizzes */
.quiz-score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--ink-secondary);
}
.quiz-score-pill {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--forest);
  background: var(--forest-soft);
  padding: 3px 9px;
  border-radius: 99px;
}
.trace-quiz {
  margin: 22px 0;
  padding: 20px 22px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  font-family: var(--font-sans);
}
.quiz-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.quiz-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--indigo);
  background: var(--indigo-soft);
  padding: 3px 8px;
  border-radius: 4px;
}
.quiz-reset-btn {
  display: none;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--hairline-strong);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  cursor: pointer;
}
.quiz-reset-btn.visible { display: inline-flex; }
.quiz-reset-btn:hover { border-color: var(--forest); color: var(--forest); }
.quiz-question { font-size: 0.95rem; font-weight: 600; color: var(--ink); margin: 0 0 12px; line-height: 1.48; }
.quiz-code {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--bg-code);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}
.quiz-options { display: grid; gap: 8px; }
.quiz-opt {
  text-align: left;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--bg-elevated);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 140ms, background-color 140ms;
}
.quiz-opt:hover { border-color: var(--hairline-strong); }
.quiz-opt.is-correct { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); font-weight: 600; }
.quiz-opt.is-wrong { background: var(--terracotta-soft); border-color: var(--terracotta); color: var(--terracotta); }
.quiz-explain {
  display: none;
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}
.quiz-explain.visible { display: block; }
.quiz-explain strong { color: var(--ink); }

/* Editorial Ledger Table */
.ledger-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ledger { width: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: 0.85rem; }
.ledger th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 0 12px 10px 0;
  border-bottom: 1px solid var(--hairline-strong);
}
.ledger td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
  color: var(--ink-secondary);
  line-height: 1.48;
}
.ledger tr:last-child td { border-bottom: 0; }
.ledger-val { font-family: var(--font-mono); font-size: 0.84rem; font-weight: 500; color: var(--ink); white-space: nowrap; }
.ledger-val.highlight { color: var(--forest); }
.ledger-val.warn { color: var(--terracotta); }

/* Persistent Mastery Checklist */
.checklist { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 10px; font-family: var(--font-sans); }
.checklist li { margin: 0; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms;
}
.check-item:hover { border-color: var(--hairline-strong); }
.check-item input { margin-top: 3px; accent-color: var(--forest); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.check-item.done { background: var(--bg-elevated); opacity: 0.76; }
.check-item.done .check-title { text-decoration: line-through; }
.check-title { font-weight: 600; font-size: 0.9rem; color: var(--ink); display: block; }
.check-desc { font-size: 0.82rem; color: var(--ink-secondary); display: block; margin-top: 2px; line-height: 1.45; }

/* Module Prev / Next Footer */
.module-nav-cards {
  margin-top: 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  font-family: var(--font-sans);
}
.nav-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 150ms, transform 150ms;
}
a.nav-card:hover { border-color: var(--forest); transform: translateY(-1px); }
.nav-card.next { text-align: right; }
.nav-card.is-disabled { border-style: dashed; opacity: 0.68; cursor: default; }
.nav-card-dir { font-family: var(--font-mono); font-size: 0.71rem; color: var(--ink-muted); }
.nav-card-title { font-weight: 600; font-size: 0.9rem; color: var(--ink); }

.article-footer {
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 0.83rem;
  color: var(--ink-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-links a { color: var(--ink-secondary); text-decoration: none; border-bottom: 1px solid var(--hairline-strong); }
.footer-links a:hover { color: var(--forest); border-bottom-color: var(--forest); }

/* ==========================================================================
   Landing Page (index.html) Course Map & Module Cards
   ========================================================================== */
.hero-landing { padding-bottom: 36px; border-bottom: 1px solid var(--hairline); margin-bottom: 40px; }
.hero-landing h1 { max-width: 22ch; }
.hero-landing .subtitle { max-width: 62ch; }

.progress-summary {
  margin-top: 24px;
  padding: 18px 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 11px;
  font-family: var(--font-sans);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 24px;
  align-items: center;
}
.progress-summary-title { font-size: 0.86rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 12px; }
.progress-summary-bar { height: 8px; background: var(--hairline); border-radius: 99px; overflow: hidden; }
.progress-summary-fill { height: 100%; width: 0%; background: var(--forest); border-radius: 99px; transition: width 300ms var(--ease-out); }
.progress-summary-stat {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--forest);
  background: var(--forest-soft);
  padding: 7px 12px;
  border-radius: 7px;
  white-space: nowrap;
}

.map-grid-wrap { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr); gap: 22px; align-items: center; }
.map-inspector {
  font-family: var(--font-sans);
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  min-height: 245px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}
.map-inspector h4 { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 500; margin: 6px 0 6px; color: var(--ink); line-height: 1.25; }
.map-inspector p { font-family: var(--font-sans); font-size: 0.84rem; line-height: 1.52; color: var(--ink-secondary); margin: 0 0 10px; }
.map-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.map-chips span { font-family: var(--font-mono); font-size: 0.71rem; padding: 3px 8px; background: var(--bg-diagram); border: 1px solid var(--hairline); border-radius: 4px; color: var(--ink); }
.map-node { cursor: pointer; transition: opacity 160ms var(--ease-out); }
.map-node:hover { opacity: 0.92; }
.map-node.dimmed { opacity: 0.52; }
.map-node.active rect { stroke-width: 2.5; }

.section-label-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; margin: 46px 0 18px; }
.section-label-row h2 { margin: 0; }
.section-label-meta { font-family: var(--font-sans); font-size: 0.82rem; color: var(--ink-muted); }

.course-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; font-family: var(--font-sans); }
.module-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
  background: var(--bg-diagram);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
a.module-card:hover { border-color: var(--forest); transform: translateY(-2px); }
.module-card.is-featured { border-color: color-mix(in srgb, var(--forest) 55%, var(--hairline)); }
.module-card.is-planned { background: var(--bg-elevated); border-style: dashed; opacity: 0.88; }
.module-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.module-week { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; color: var(--ink-muted); }
.module-status { font-family: var(--font-mono); font-size: 0.69rem; font-weight: 500; padding: 3px 8px; border-radius: 99px; }
.module-status.ready { background: var(--forest-soft); color: var(--forest); }
.module-status.done { background: var(--forest); color: #ffffff; }
[data-theme="dark"] .module-status.done { color: #0e1712; }
.module-status.next { background: var(--indigo-soft); color: var(--indigo); }
.module-card h3 { font-family: var(--font-serif); font-size: 1.26rem; font-weight: 500; margin: 0 0 8px; line-height: 1.25; color: var(--ink); }
.module-card p { font-family: var(--font-sans); font-size: 0.86rem; line-height: 1.54; color: var(--ink-secondary); margin: 0 0 14px; }
.module-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.module-tags span { font-family: var(--font-mono); font-size: 0.7rem; padding: 2px 7px; border-radius: 4px; background: var(--bg-elevated); border: 1px solid var(--hairline); color: var(--ink-secondary); }
.module-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--hairline); font-size: 0.78rem; color: var(--ink-muted); }
.module-card-cta { font-weight: 600; color: var(--forest); }

.upcoming-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; font-family: var(--font-sans); }
.upcoming-card { padding: 16px 18px; background: var(--bg-elevated); border: 1px dashed var(--hairline-strong); border-radius: 10px; }
.upcoming-card .module-week { display: block; margin-bottom: 6px; }
.upcoming-card h4 { font-family: var(--font-serif); font-size: 1.04rem; font-weight: 500; margin: 0 0 6px; color: var(--ink); }
.upcoming-card p { font-family: var(--font-sans); font-size: 0.8rem; line-height: 1.48; color: var(--ink-muted); margin: 0; }

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 20px 80px; }
  .toc-toggle { display: inline-flex; }
  .sidebar {
    display: none;
    position: fixed;
    top: 57px; left: 0; right: 0;
    max-height: calc(100vh - 57px);
    background: var(--bg);
    border-bottom: 1px solid var(--hairline);
    padding: 20px 24px 28px;
    z-index: 45;
    box-shadow: var(--shadow-soft);
  }
  .sidebar.open { display: block; }
  .article { padding-top: 32px; margin: 0 auto; }
  .upcoming-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .map-grid-wrap,
  .state-inspector-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sim-split,
  .dual-code-grid,
  .monitor-grid,
  .course-grid,
  .module-nav-cards { grid-template-columns: 1fr; }
  .progress-summary { grid-template-columns: 1fr; }
  .nav-card.next { text-align: left; }
  .story-sticky-bar {
    position: sticky;
    top: 56px;
    z-index: 20;
    box-shadow: var(--shadow-soft);
  }
}

@media (max-width: 680px) {
  .svg-interactive.min-w-svg { min-width: 500px; }
  .topbar-inner { padding: 10px 14px; gap: 8px; }
  .topbar-title .topbar-sub,
  .topbar-title .topbar-name { display: none; }
  .segmented button { padding: 5px 8px; font-size: 0.74rem; }
  .icon-btn { padding: 0 8px; font-size: 0.74rem; }
  .shell, .shell-landing { padding-left: 16px; padding-right: 16px; }
  figure.visual { padding: 16px; }
  .section-head { flex-direction: column; gap: 8px; }
  .upcoming-grid { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .hide-xs { display: none; }
  .topbar-inner { padding: 9px 10px; gap: 6px; }
  .topbar-title { gap: 6px; }
  .topbar-controls { gap: 5px; }
  .segmented button { padding: 5px 7px; font-size: 0.72rem; }
  .icon-btn { padding: 0 7px; }
}
