/* ============================================================================
   Genesis Graphics — interactive layer styles
   Visual identity: "VDP datasheet meets a Trinitron scanline."
   Near-black ground, the Genesis red stripe as the primary accent, Sega blue
   and 16-bit gold as the two signal traces. Monospace for every piece of
   hardware data, sans for prose. Everything here mirrors the sibling GameCube
   course's shell; only the palette and the raster/VDP widgets differ.
   ============================================================================ */

:root {
  /* ground + panels (cool near-black 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 — red primary, blue & gold 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 gold           */
  --amber:    #ff9d3c;  /* highlights, warnings                              */

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

  /* aliases so the shared shell rules read naturally                        */
  --violet:   var(--red);
  --violet-d: var(--red-d);
  --cyan:     var(--blue);
  --magenta:  var(--gold);
  --on:       #170a08;  /* dark ink for text on a bright accent fill         */

  --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;
  --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 as a fixed pseudo-element (avoids the iOS Safari
   background-attachment repaint bug). Genesis red + blue glows. */
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,.14), transparent 60%),
    radial-gradient(1000px 650px at 8% -4%, rgba(63,181,255,.08), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(255,196,77,.05), transparent 55%);
}

::selection { background: rgba(255,83,71,.30); 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 */
.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 40px;
  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% 26%, var(--red), var(--red-d) 58%, #7a1712);
  box-shadow: var(--glow-r), inset 0 0 0 1px rgba(255,255,255,.12);
  position: relative;
}
.brand .logo::after {
  /* horizontal cartridge-slot bar */
  content: "";
  position: absolute; left: 8px; right: 8px; top: 15px; height: 5px;
  border-radius: 2px;
  background: rgba(10,11,16,.82);
  box-shadow: 0 7px 0 -1px rgba(10,11,16,.35);
}
.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: 18px 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: 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: #fff; 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: #dfe6f5;
}
.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; }
.specs .spec .v.hi { color: var(--gold); }

/* memory map bar */
.memmap { margin: 26px 0; }
.memmap .bar { display: flex; height: 46px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-2); }
.memmap .seg {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 600 11px/1.2 var(--mono);
  color: var(--on);
  text-align: center;
  min-width: 0;
}
.memmap .seg small { font-size: 9.5px; opacity: .8; }

/* 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;
}
.pill.a { color: var(--blue); border-color: rgba(63,181,255,.4); }
.pill.b { color: var(--gold); border-color: rgba(255,196,77,.4); }
.pill.c { color: var(--red); border-color: rgba(255,83,71,.45); }
.pill.util { color: var(--muted); }

/* two-column compare cards */
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 28px 0; }
.vs .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.vs .card h4 { margin: 0 0 4px; display: flex; align-items: center; gap: 10px; font-size: 17px; }
.vs .card .tag { font: 600 10px/1 var(--mono); letter-spacing: .1em; padding: 4px 8px; border-radius: 6px; }
.vs .a .tag { background: rgba(63,181,255,.14); color: var(--blue); }
.vs .b .tag { background: rgba(255,83,71,.16); color: var(--red); }
.vs .card ul { margin: 14px 0 0; padding-left: 18px; font-size: 13.5px; }
.vs .card .verdict { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* pipeline diagram */
.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(--sans); }
.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; }

/* Every lab canvas gets a FIXED CSS height. Their draw() routines set
   canvas.height = rect.height * dpr; without a CSS height the element's
   displayed height derives from the bitmap, and each iOS scroll-resize would
   double it until the canvas blanks out. */
.gfx {
  width: 100%;
  height: 300px;
  border-radius: var(--radius-s);
  background: linear-gradient(180deg, #06070c, #0a0c12);
  border: 1px solid var(--line);
  display: block;
}
.gfx.short { height: 224px; }
.gfx.tall  { height: 340px; }
.gfx.grab  { cursor: grab; touch-action: none; }
.gfx.grab:active { cursor: grabbing; }
.gfx.cross { cursor: crosshair; touch-action: none; }
.gfx.paint { cursor: crosshair; touch-action: none; }
.gfx.strip { height: 200px; }

/* small monospace readout line under a lab canvas */
.lab-readout {
  font: 600 11px/1.7 var(--mono);
  color: var(--muted);
  letter-spacing: .04em;
}
.lab-readout b { color: var(--blue); font-weight: 700; }
.lab-readout .m { color: var(--gold); }
.lab-readout .v { color: var(--red); }

/* legend chips */
.legend { display: flex; flex-wrap: wrap; gap: 12px 16px; }
.legend .chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: 600 10.5px/1 var(--mono); color: var(--muted); letter-spacing: .05em;
}
.legend .chip i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none; }

/* controls */
.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 var(--ground);
  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 var(--ground);
}
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; flex-wrap: wrap; }
.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: var(--on); }

.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(--blue), #269adf);
  color: #04202f; border: 0;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn svg { width: 13px; height: 13px; }
.play-btn.alt { background: linear-gradient(180deg, var(--red), var(--red-d)); color: #fff; }

/* multi-state toggle buttons that may be ON together (RGB channel toggles) */
.chan-btns { display: inline-flex; padding: 3px; gap: 3px; background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 8px; }
.chan-btns button {
  font: 700 12px/1 var(--mono);
  border: 0; background: transparent; color: var(--ink-2);
  padding: 7px 12px; border-radius: 6px; cursor: pointer;
}
.chan-btns button.on[data-ch="r"] { background: #ff5f5a; color: #200; }
.chan-btns button.on[data-ch="g"] { background: #5fd18b; color: #032; }
.chan-btns button.on[data-ch="b"] { background: #5aa8ff; color: #013; }

/* native colour picker restyled */
input[type="color"] {
  width: 46px; height: 33px; padding: 3px;
  border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--panel-3); cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }

/* palette / swatch strip used by several VDP labs */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches .sw { text-align: center; }
.swatches .sw i {
  display: block; width: 30px; height: 26px; border-radius: 6px;
  border: 1px solid var(--line-2); cursor: pointer;
}
.swatches .sw span { display: block; margin-top: 5px; font: 600 9.5px/1.3 var(--mono); color: var(--muted); }
.swatches .sw.sel i { box-shadow: 0 0 0 2px var(--gold); }

/* two-canvas side-by-side (source + detail) */
.pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 640px) { .pair-grid { grid-template-columns: 1fr; } }
.pair-grid canvas { width: 100%; display: block; border-radius: var(--radius-s); border: 1px solid var(--line); background: #06070c; }

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

/* --------------------------------------------- architecture / concept diagrams */
.dsp-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;
}
.dsp-diagram svg, .figure svg { width: 100%; height: auto; display: block; }
.dsp-diagram .fig-cap, .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-amber { fill: #ff9d3c; } .d-amber-s { stroke: #ff9d3c; }
.d-gold { fill: #ffc44d; } .d-gold-s { stroke: #ffc44d; }
/* aliases matching the shared shell's helper names */
.d-cyan { fill: #3fb5ff; } .d-cyan-s { stroke: #3fb5ff; }
.d-violet { fill: #ff5347; } .d-violet-s { stroke: #ff5347; }
.d-magenta { fill: #ffc44d; } .d-magenta-s { stroke: #ffc44d; }
.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-grid { stroke: #262b3a; stroke-width: 1; }
.d-axis { stroke: #343a4d; stroke-width: 1.5; }
.d-dot-b { fill: #3fb5ff; stroke: #0e1017; stroke-width: 1.5; }
.d-dot-g { fill: #ffc44d; stroke: #0e1017; stroke-width: 1.5; }
.d-stem { stroke: #ff5347; stroke-width: 1.4; stroke-dasharray: 2 3; opacity: .8; }
.d-num { fill: #eef1f8; font: 600 12px/1 var(--mono); }
.d-val { fill: #b3b9cc; font: 600 13px/1 var(--mono); }

/* ------------------------------------------------------------- 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; }
  .vs { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .part .part-inner { padding: 22px 18px; }
}

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