/* ============================================================================
   Genesis Homebrew — interactive documentation
   Visual identity: "cartridge silkscreen meets logic-analyser screen."
   Near-black blue-biased ground, red primary (the Genesis stripe), blue & gold
   signal traces, monospace for every piece of hardware data, sans for prose.
   Shares the design language of the sibling "Inside the Sega Genesis" courses.
   ============================================================================ */

:root {
  /* ground + panels (blue-biased neutrals, never a flat grey) */
  --ground:   #0a0b10;
  --ground-2: #0e1017;
  --panel:    #14161f;
  --panel-2:  #1b1e2a;
  --panel-3:  #232736;
  --line:     #262b3a;
  --line-2:   #343a4d;

  /* ink */
  --ink:      #eef1f8;
  --ink-2:    #b3b9cc;
  --muted:    #7e8599;

  /* signal palette — the accent is spent on the traces */
  --red:      #ff5347;  /* PRIMARY accent — the Genesis stripe               */
  --red-d:    #e23b30;
  --blue:     #3fb5ff;  /* secondary / scope trace A (Sega blue)            */
  --gold:     #ffc44d;  /* highlight / scope trace B (16-BIT)               */
  --amber:    #ff9d3c;

  /* aliases — the shared stylesheet was authored with these names; here they
     resolve to the Genesis palette so class names stay identical across courses */
  --violet:   var(--red);
  --violet-d: var(--red-d);
  --cyan:     var(--blue);
  --magenta:  var(--gold);

  /* semantic */
  --good:     #4fd08a;
  --warn:     #ffb14e;
  --bad:      #ff5f5f;

  --radius:   14px;
  --radius-s: 9px;
  --shadow:   0 18px 50px -22px rgba(0,0,0,.85);
  --glow-r:   0 0 24px -4px rgba(255,83,71,.55);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --sidebar-w: 288px;
  --player-h: 0px;   /* this course has no player bar */
  --measure: 74ch;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--ground);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Viewport-anchored vignette — red + blue glows (Genesis). Done as a fixed
   pseudo-element rather than `background-attachment: fixed`, which triggers a
   repaint bug on iOS Safari where sections vanish while scrolling. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 78% -8%, rgba(255,83,71,.15), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(63,181,255,.07), transparent 55%);
}

::selection { background: rgba(255,83,71,.32); color: #fff; }

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

/* ------------------------------------------------------------------ layout */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* reading-progress bar (course feel) */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 70;
  background: transparent;
}
.progress .fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--red) 55%, var(--gold));
  box-shadow: 0 0 10px rgba(255,83,71,.6);
  transition: width .08s linear;
}

/* ------------------------------------------------------------------ sidebar */

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--ground-2), var(--ground));
  padding: 22px 18px calc(var(--player-h) + 28px);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.brand .logo {
  width: 38px; height: 38px; flex: none;
  border-radius: 9px;
  background:
    radial-gradient(circle at 30% 30%, var(--red), var(--red-d) 55%, #7a1410);
  box-shadow: var(--glow-r), inset 0 0 0 1px rgba(255,255,255,.12);
  position: relative;
}
.brand .logo::after {
  /* cartridge-slot bar motif */
  content: "";
  position: absolute; left: 8px; right: 8px; top: 15px; height: 5px;
  border-radius: 2px;
  background: rgba(10,11,16,.82);
}
.brand h1 {
  font: 700 15px/1.2 var(--sans);
  margin: 0; letter-spacing: .2px;
}
.brand .sub {
  display: block;
  font: 500 10.5px/1.3 var(--mono);
  color: var(--muted);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 2px;
}

.toc {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toc .toc-group {
  font: 600 10px/1 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 10px 8px;
}
.toc a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.toc a .n {
  font: 600 10.5px/1 var(--mono);
  color: var(--muted);
  min-width: 20px;
}
.toc a:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.toc a.active {
  background: linear-gradient(90deg, rgba(255,83,71,.16), transparent);
  color: #fff;
  border-left-color: var(--red);
}
.toc a.active .n { color: var(--red); }
.toc a.done .n { color: var(--good); }
.toc a.done .n::after { content: " ✓"; }

.progress-note {
  margin: 14px 10px 0;
  font: 600 10px/1.5 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.progress-note b { color: var(--blue); }

/* ------------------------------------------------------------------ main */

.main {
  min-width: 0;
  padding-bottom: calc(var(--player-h) + 40px);
}

.wrap {
  max-width: 940px;
  margin: 0 auto;
  padding: 0 34px;
}

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  padding: 74px 0 46px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: .5;
  pointer-events: none;
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}
.hero .inner { position: relative; z-index: 1; max-width: var(--measure); }
.eyebrow {
  font: 600 11px/1 var(--mono);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.eyebrow::before {
  content: ""; width: 26px; height: 1px; background: var(--blue); opacity: .7;
}
.hero h2 {
  font: 800 clamp(34px, 6vw, 62px)/1.02 var(--sans);
  letter-spacing: -.02em;
  margin: 20px 0 0;
  text-wrap: balance;
}
.hero h2 .grad {
  background: linear-gradient(100deg, var(--blue), var(--red) 55%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lede {
  font-size: 18.5px;
  color: var(--ink-2);
  margin: 22px 0 0;
  max-width: 60ch;
}
.hero .cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.btn {
  font: 600 13.5px/1 var(--sans);
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--panel-3); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--red), var(--red-d));
  border-color: transparent; color: #260709; box-shadow: var(--glow-r);
}
.btn.primary:hover { box-shadow: 0 0 30px -4px rgba(255,83,71,.7); }
.btn svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ course scaffolding */

.part {
  scroll-margin-top: 20px;
  padding: 62px 0 8px;
}
.part .part-inner {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  padding: 26px 28px;
  overflow: hidden;
}
.part .part-inner::before {
  content: "";
  position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,83,71,.22), transparent 60%);
  pointer-events: none;
}
.part .kicker {
  font: 700 11px/1 var(--mono); letter-spacing: .24em; text-transform: uppercase;
  color: var(--blue);
}
.part h3 { font: 800 clamp(22px,3.4vw,30px)/1.1 var(--sans); margin: 12px 0 0; letter-spacing: -.015em; }
.part p { margin: 12px 0 0; color: var(--ink-2); max-width: 62ch; font-size: 15px; }
.part .part-meta { margin-top: 16px; display: flex; gap: 18px; flex-wrap: wrap; font: 600 11px/1 var(--mono); color: var(--muted); letter-spacing: .06em; }
.part .part-meta b { color: var(--ink); }

/* course landing cards */
.arc-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 34px 0 0; }
.arc-cards .arc {
  display: block;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; transition: transform .14s, border-color .14s, background .14s;
}
.arc-cards .arc:hover { transform: translateY(-3px); border-color: var(--line-2); background: var(--panel-2); text-decoration: none; }
.arc-cards .arc .an { font: 700 11px/1 var(--mono); letter-spacing: .16em; color: var(--red); }
.arc-cards .arc h4 { font: 700 16px/1.25 var(--sans); margin: 12px 0 6px; color: var(--ink); }
.arc-cards .arc p { font-size: 13px; color: var(--muted); margin: 0; }
.arc-cards .arc .cnt { margin-top: 12px; font: 600 10.5px/1 var(--mono); color: var(--blue); letter-spacing: .08em; }
@media (max-width: 720px){ .arc-cards { grid-template-columns: 1fr; } }

/* module header */
.mod-head { margin-bottom: 10px; }
.mod-head .eye {
  display: inline-flex; align-items: center; gap: 10px;
  font: 700 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--red);
}
.mod-head .eye .part-tag { color: var(--muted); }
.mod-head h3 {
  font: 800 clamp(23px, 3.4vw, 33px)/1.1 var(--sans);
  letter-spacing: -.015em; margin: 12px 0 0; text-wrap: balance;
}
.mod-head .objective {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: baseline;
  margin: 14px 0 0; padding: 12px 15px;
  background: rgba(63,181,255,.06); border: 1px solid rgba(63,181,255,.18);
  border-radius: var(--radius-s);
}
.mod-head .objective .lbl { font: 700 9.5px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--blue); }
.mod-head .objective span.txt { font-size: 13.5px; color: var(--ink-2); }

/* key takeaways */
.takeaway {
  margin: 30px 0 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  padding: 18px 20px;
}
.takeaway .th { font: 700 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--red); display: flex; align-items: center; gap: 9px; }
.takeaway .th::before { content: "✦"; color: var(--blue); }
.takeaway ul { margin: 14px 0 0; padding-left: 20px; }
.takeaway li { margin: 7px 0; font-size: 14px; color: var(--ink-2); }
.takeaway li::marker { color: var(--blue); }

/* module footer nav */
.mod-nav {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 26px;
}
.mod-nav a {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); transition: border-color .14s, background .14s;
}
.mod-nav a:hover { border-color: var(--red); background: var(--panel-2); text-decoration: none; }
.mod-nav a .dir { font: 600 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.mod-nav a .ttl { font: 700 14px/1.2 var(--sans); }
.mod-nav a.next { text-align: right; align-items: flex-end; }
.mod-nav a.disabled { opacity: .4; pointer-events: none; }

/* ------------------------------------------------------------------ sections / prose */

section.doc { padding: 40px 0 46px; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }

.prose { max-width: var(--measure); }
.prose p { margin: 16px 0; color: var(--ink-2); }
.prose p strong { color: var(--ink); font-weight: 650; }
.prose h4 {
  font: 700 16px/1.3 var(--sans);
  margin: 34px 0 4px;
  color: var(--ink);
}
.prose ul, .prose ol { color: var(--ink-2); padding-left: 22px; margin: 14px 0; }
.prose li { margin: 8px 0; }
.prose li::marker { color: var(--red); }

code, .kbd {
  font: 500 .88em/1.4 var(--mono);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: .12em .42em;
  border-radius: 5px;
  color: #d7deef;
}
.prose a code { color: var(--red); }

/* callouts */
.note {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  margin: 24px 0;
  padding: 16px 18px;
  border-radius: var(--radius-s);
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
}
.note .ico { font: 600 18px/1 var(--mono); color: var(--red); }
.note.hw { border-left-color: var(--blue); }
.note.hw .ico { color: var(--blue); }
.note.warn { border-left-color: var(--amber); }
.note.warn .ico { color: var(--amber); }
.note p { margin: 0; font-size: 14px; color: var(--ink-2); }
.note p + p { margin-top: 8px; }

/* spec grid */
.specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 28px 0;
}
.spec {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 15px 16px;
}
.spec .k { font: 600 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.spec .v { font: 700 22px/1.1 var(--mono); color: var(--ink); margin-top: 9px; font-variant-numeric: tabular-nums; }
.spec .d { font-size: 12px; color: var(--muted); margin-top: 5px; }
.spec .v small { font-size: 12px; color: var(--ink-2); font-weight: 500; }

/* tables */
.tbl-wrap { overflow-x: auto; margin: 24px 0; border: 1px solid var(--line); border-radius: var(--radius-s); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  text-align: left;
  font: 600 10.5px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,83,71,.05); }
td .crc { font: 600 12.5px/1 var(--mono); color: var(--blue); }
.pill {
  display: inline-block;
  font: 600 10px/1 var(--mono);
  letter-spacing: .06em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--ink);
  white-space: nowrap;
}

/* pipeline diagram (static) */
.pipe {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px;
  margin: 28px 0; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.pipe .stage {
  flex: 1 1 120px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  padding: 14px;
  position: relative;
}
.pipe .stage .t { font: 700 13px/1.2 var(--mono); color: var(--ink); }
.pipe .stage .d { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.pipe .arrow { align-self: center; color: var(--red); font-family: var(--mono); }

/* ------------------------------------------------------- interactive labs */
.lab {
  margin: 30px 0;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.lab .lab-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.2);
}
.lab .lab-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 10px var(--blue); flex: none; }
.lab .lab-head .title { font: 700 13.5px/1 var(--sans); }
.lab .lab-head .badge { margin-left: auto; font: 600 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lab .lab-body { padding: 18px; display: grid; gap: 16px; }

/* All lab canvases MUST have a fixed CSS height (see note in labCanvas). */
.scope {
  width: 100%;
  height: 150px;
  border-radius: var(--radius-s);
  background: linear-gradient(180deg, #06070c, #0a0b12);
  border: 1px solid var(--line);
  display: block;
}
.scope.lab-mid  { height: 240px; }
.scope.lab-tall { height: 300px; }
.scope.lab-pad  { height: 320px; }

.controls { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-end; }
.ctrl { display: flex; flex-direction: column; gap: 7px; min-width: 120px; }
.ctrl label { font: 600 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ctrl .val { font: 600 11px/1 var(--mono); color: var(--blue); }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 4px;
  background: var(--line-2);
  outline-offset: 4px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); cursor: pointer; border: 2px solid #0a0b10;
  box-shadow: var(--glow-r);
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); cursor: pointer; border: 2px solid #0a0b10;
}
select, .seg-btns {
  font: 500 13px/1 var(--sans);
  background: var(--panel-3);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 9px 11px;
}
.seg-btns { display: inline-flex; padding: 3px; gap: 3px; }
.seg-btns button {
  font: 600 12px/1 var(--mono);
  border: 0; background: transparent; color: var(--ink-2);
  padding: 7px 11px; border-radius: 6px; cursor: pointer;
}
.seg-btns button.on { background: var(--red); color: #260709; }

.play-btn {
  font: 600 13px/1 var(--sans);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 9px; cursor: pointer;
  background: linear-gradient(180deg, var(--red), var(--red-d));
  color: #260709; border: 0;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn svg { width: 13px; height: 13px; }

/* live readout chips */
.readouts { display: flex; flex-wrap: wrap; gap: 10px; }
.readout {
  font: 600 11.5px/1.5 var(--mono);
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  letter-spacing: .02em;
}
.readout b { color: var(--blue); font-weight: 700; font-variant-numeric: tabular-nums; }
.readout.warn b { color: var(--amber); }
.readout.bad b { color: var(--bad); }
.readout.good b { color: var(--good); }

.seg-btns.wrap { flex-wrap: wrap; }

/* small utility button used by lab resets */
.reset-btn {
  font: 600 10.5px/1 var(--mono);
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--ink-2);
  cursor: pointer;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.reset-btn:hover { color: var(--ink); border-color: var(--red); }

/* "this is a simulation" fine print under labs */
.sim-note { font-size: 12.5px; color: var(--muted); margin: 0; }

/* ------------------------------------------------------------ code blocks */
.code {
  margin: 22px 0;
  background: #08090f;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  overflow: hidden;
}
.code .code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font: 600 10.5px/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.code .code-head::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }
.code .code-head .copy {
  margin-left: auto;
  font: 600 10px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
}
.code .code-head .copy:hover { color: var(--ink); border-color: var(--red); }
.code .code-head .copy.ok { color: var(--good); border-color: rgba(79,208,138,.5); }
.code pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font: 500 12.5px/1.7 var(--mono);
  color: var(--ink-2);
  tab-size: 4;
}
.code pre .c  { color: var(--muted); font-style: italic; }
.code pre .k  { color: var(--red); }
.code pre .s  { color: var(--amber); }
.code pre .fn { color: var(--blue); }
.code pre .n  { color: var(--gold); }
.code pre .p  { color: var(--muted); }
.code pre .hl { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------ OS tab set */
.os-tabs { margin: 24px 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.os-tabs .tab-row {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--ground-2);
}
.os-tabs .tab-row button {
  flex: 1;
  padding: 13px 10px;
  font: 700 12.5px/1 var(--sans);
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.os-tabs .tab-row button .os-ico { font-family: var(--mono); font-size: 14px; }
.os-tabs .tab-row button:hover { color: var(--ink-2); background: var(--panel); }
.os-tabs .tab-row button.on { color: var(--ink); border-bottom-color: var(--red); background: var(--panel); }
.os-tabs .tab-panel { display: none; padding: 6px 18px 18px; }
.os-tabs .tab-panel.on { display: block; }
.os-tabs .tab-panel .code { margin: 16px 0; }
.os-tabs .tab-panel p { font-size: 14px; color: var(--ink-2); margin: 14px 0 0; }
.os-tabs .tab-panel ul { font-size: 14px; color: var(--ink-2); padding-left: 20px; margin: 12px 0 0; }
.os-tabs .tab-panel li { margin: 7px 0; }
.os-tabs .tab-panel li::marker { color: var(--red); }

/* verification checklist */
.checklist { margin: 22px 0; display: grid; gap: 8px; }
.checklist label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-2);
}
.checklist label:hover { border-color: var(--line-2); }
.checklist input { accent-color: var(--red); margin-top: 2px; flex: none; }
.checklist label.done { color: var(--muted); }
.checklist label.done b { color: var(--muted); }
.checklist label b { color: var(--ink); }
.checklist code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12px; }

/* ------------------------------------------------- ROM header inspector */
.dol-lab { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
@media (max-width: 760px) { .dol-lab { grid-template-columns: 1fr; } }
.dol-hex {
  background: #08090f;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 12px;
  overflow-x: auto;
}
.dol-hex .row { display: flex; gap: 9px; font: 500 11px/1.9 var(--mono); white-space: nowrap; }
.dol-hex .off { color: var(--muted); flex: none; width: 46px; }
.dol-hex .b {
  color: var(--ink-2);
  padding: 0 2px;
  border-radius: 3px;
  cursor: default;
}
.dol-hex .b.hi { background: rgba(255,83,71,.22); color: var(--red); font-weight: 700; }
.dol-hex .b.dim { color: #3a4055; }
.dol-hex .asc { color: var(--muted); flex: none; margin-left: 8px; letter-spacing: 1px; }
.dol-hex .asc .ac.hi { color: var(--red); font-weight: 700; }
.dol-fields { display: grid; gap: 6px; align-content: start; }
.dol-fields button {
  text-align: left;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-2);
  font: 500 12.5px/1.45 var(--sans);
  cursor: pointer;
}
.dol-fields button .rng { font: 600 10.5px/1.4 var(--mono); color: var(--muted); }
.dol-fields button:hover { border-color: var(--line-2); }
.dol-fields button.on { border-color: rgba(255,83,71,.55); background: var(--panel-2); color: var(--ink); }
.dol-fields button.on .rng { color: var(--red); }
.dol-decode {
  grid-column: 1 / -1;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-s);
  font-size: 13.5px;
  color: var(--ink-2);
  min-height: 58px;
}
.dol-decode b { color: var(--ink); }
.dol-decode code { color: var(--red); font-size: 12.5px; }

/* -------------------------------------------------- controller tester */
.pad-wrap { display: grid; gap: 14px; }
.pad-keys { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pad-keys .kbd {
  font: 600 11px/1 var(--mono);
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 6px 8px;
}
.pad-keys .lbl { font: 600 11px/1.9 var(--mono); color: var(--muted); margin-right: 2px; }

/* ------------------------------------------------------ route/flashcart cards */
.routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 24px 0; }
.route {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.route .tag {
  align-self: flex-start;
  font: 700 9.5px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255,83,71,.14);
  color: var(--red);
}
.route .tag.hw { background: rgba(63,181,255,.12); color: var(--blue); }
.route .tag.old { background: rgba(255,157,60,.12); color: var(--amber); }
.route h5 { font: 700 15px/1.25 var(--sans); color: var(--ink); margin: 11px 0 6px; }
.route p { font-size: 13px; color: var(--muted); margin: 0; flex: 1; }
.route .need { margin-top: 12px; font: 600 10.5px/1.5 var(--mono); color: var(--ink-2); }
.route .need span { color: var(--muted); }

/* ------------------------------------------------------------- footer */
.foot { padding: 40px 0 60px; color: var(--muted); font-size: 13px; max-width: var(--measure); }
.foot a { color: var(--ink-2); }
.foot .src { font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------- glossary tooltips */
.term {
  border-bottom: 1.5px dotted var(--red);
  color: var(--ink);
  font-weight: 600;
  cursor: help;
}
.term:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }

.tip-bubble {
  position: fixed;
  z-index: 90;
  max-width: min(320px, calc(100vw - 20px));
  background: var(--panel-3);
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  padding: 11px 13px;
  font: 500 13px/1.55 var(--sans);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(5px);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}
.tip-bubble .tt { color: var(--blue); font-weight: 700; }
.tip-bubble.show { opacity: 1; transform: translateY(0); }
.tip-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--panel-3);
}
.tip-bubble.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--panel-3);
}

/* ------------------------------------------------- worked examples */
.example {
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-s);
  background: linear-gradient(180deg, rgba(255,157,60,.05), transparent);
}
.example .lbl {
  font: 700 10px/1 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--amber);
}
.example p { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.example p + p { margin-top: 9px; }

/* Analogy callout */
.analogy {
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius-s);
  background: linear-gradient(180deg, rgba(63,181,255,.05), transparent);
}
.analogy .lbl {
  font: 700 10px/1 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--blue);
}
.analogy p { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }

/* Glossary-style definition list */
.defs { margin: 22px 0; display: grid; gap: 1px; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--line); }
.defs .row { display: grid; grid-template-columns: 178px 1fr; gap: 14px; padding: 12px 15px; background: var(--panel); }
.defs .row dt { font: 600 13px/1.4 var(--sans); color: var(--ink); margin: 0; }
.defs .row dd { margin: 0; font-size: 13.5px; color: var(--ink-2); }
@media (max-width: 560px) { .defs .row { grid-template-columns: 1fr; gap: 4px; } }

/* --------------------------------------------- figure / diagram */
.figure {
  margin: 26px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255,83,71,.06), transparent 60%),
    var(--ground-2);
  padding: 20px 18px 14px;
}
.figure svg { width: 100%; height: auto; display: block; }
.figure .fig-cap { font-size: 12.5px; color: var(--muted); margin: 12px 4px 2px; line-height: 1.55; }
.figure .fig-cap strong { color: var(--ink); font-weight: 650; }
/* SVG element theming — kept in CSS so it tracks the palette */
.d-fill-panel { fill: #1b1e2a; }
.d-fill-panel2 { fill: #232736; }
.d-fill-ground { fill: #0e1017; }
.d-stroke-line { stroke: #343a4d; }
.d-blue { fill: #3fb5ff; } .d-blue-s { stroke: #3fb5ff; }
.d-red { fill: #ff5347; } .d-red-s { stroke: #ff5347; }
.d-gold { fill: #ffc44d; } .d-gold-s { stroke: #ffc44d; }
.d-amber { fill: #ff9d3c; } .d-amber-s { stroke: #ff9d3c; }
.d-good { fill: #4fd08a; } .d-good-s { stroke: #4fd08a; }
.d-label { fill: #eef1f8; font: 600 15px/1 var(--sans); }
.d-sub { fill: #7e8599; font: 500 11px/1 var(--mono); }
.d-tag { fill: #b3b9cc; font: 600 12px/1 var(--sans); }
.d-flow { fill: #7e8599; font: 600 10.5px/1 var(--mono); letter-spacing: .04em; }
.d-axis { stroke: #343a4d; stroke-width: 1.5; }
.d-num { fill: #eef1f8; font: 600 12px/1 var(--mono); }

/* --------------------------------------------- palette swatch strip (module 06) */
.palstrip { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0; }
.palstrip .sw {
  width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line-2);
  position: relative;
}
.palstrip .sw span {
  position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
  font: 600 8.5px/1 var(--mono); color: var(--muted);
}

/* ------------------------------------------------------------- mobile */
.menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 60;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink);
  cursor: pointer;
}
.scrim { display: none; }

@media (max-width: 940px) {
  .app { grid-template-columns: 1fr; }
  .menu-btn { display: grid; place-items: center; }
  .sidebar {
    position: fixed; z-index: 55; width: 300px; left: 0; top: 0;
    transform: translateX(-104%); transition: transform .24s ease;
  }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); }
  .wrap { padding: 0 20px; }
  .hero { padding-top: 66px; }
}

@media (max-width: 560px) {
  .dol-fields button { grid-template-columns: 1fr; gap: 3px; }
}

/* ---- Back-link to the oldmachines hub site (sidebar) ---- */
.collection-link{
  display:inline-flex; align-items:center; gap:7px; margin:0 0 16px;
  font:600 11px/1 var(--mono); letter-spacing:.14em; text-transform:uppercase;
  color:var(--muted);
}
.collection-link:hover{ color:var(--ink); text-decoration:none; }
