/* ============================================================
   PPTX://ANATOMY — design system
   Format forensics: x-ray plates, exploded layers, phosphor ink
   ============================================================ */

:root {
  --bg: #05080f;
  --bg-2: #080d17;
  --plate: rgba(13, 22, 38, 0.72);
  --plate-solid: #0b1424;
  --plate-edge: #1c2c46;
  --plate-edge-hi: #33507c;
  --ink: #d7e6f7;
  --ink-dim: #8ba1bd;
  --ink-faint: #556b88;
  --phos: #45e3c0;            /* phosphor teal — primary */
  --phos-dim: #1d8f78;
  --amber: #f2b749;
  --red: #ff6d6d;
  --violet: #9a8cff;
  --blue: #5aa9ff;
  --green: #8de08d;
  --slide-white: #fdfdfb;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --disp: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --rad: 10px;
  --rail-w: 236px;
  --topbar-h: 54px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(69, 227, 192, 0.055), transparent 60%),
    radial-gradient(900px 600px at 8% 110%, rgba(90, 169, 255, 0.05), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--disp);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

/* blueprint grid + scanline atmosphere */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(92, 140, 190, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 140, 190, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
}
.scanlines {
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 3px);
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: overlay;
}

#app { position: relative; z-index: 2; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------------- top instrument bar ---------------- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: rgba(6, 10, 18, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--plate-edge);
}
.tb-brand { display: flex; align-items: center; gap: 9px; }
.tb-mark { width: 22px; height: 22px; color: var(--phos); }
.tb-name {
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  letter-spacing: 0.14em; color: var(--ink);
}
.tb-dim { color: var(--phos); }
.tb-specimen {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.08em;
  color: var(--ink-faint);
}
.tb-specimen b { color: var(--ink-dim); font-weight: 500; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.tb-chapter {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em;
  color: var(--phos);
}
.tb-files {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--ink-dim); background: rgba(28, 44, 70, 0.35);
  border: 1px solid var(--plate-edge); border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.tb-files svg { width: 14px; height: 14px; }
.tb-files:hover { color: var(--phos); border-color: var(--phos-dim); background: rgba(69,227,192,0.08); }
.tb-files-count {
  background: var(--phos); color: #04231c;
  font-weight: 700; font-size: 10px;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.tb-progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: rgba(28, 44, 70, 0.5);
}
.tb-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--phos-dim), var(--phos));
  box-shadow: 0 0 8px rgba(69, 227, 192, 0.7);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* ---------------- layout ---------------- */
#bodyRow {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 0;
}

/* ---------------- chapter rail ---------------- */
#rail {
  border-right: 1px solid var(--plate-edge);
  padding: 22px 0 18px;
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  background: rgba(7, 11, 19, 0.5);
}
#railList { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.rail-item { position: relative; }
.rail-link {
  display: flex; gap: 12px; align-items: baseline;
  width: 100%; text-align: left;
  padding: 11px 18px 11px 22px;
  background: none; border: 0; cursor: pointer;
  color: var(--ink-faint);
  font-family: var(--disp);
  border-left: 2px solid transparent;
  transition: color .2s, background .2s, border-color .2s;
}
.rail-link:hover { color: var(--ink); background: rgba(28, 44, 70, 0.25); }
.rail-item.current .rail-link {
  color: var(--phos);
  border-left-color: var(--phos);
  background: linear-gradient(90deg, rgba(69,227,192,0.1), transparent 75%);
}
.rail-item.visited .rail-link { color: var(--ink-dim); }
.rail-num {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  color: inherit; opacity: 0.75; min-width: 20px;
}
.rail-texts { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rail-title { font-size: 13.5px; font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-sub { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-item.current .rail-sub { color: var(--phos-dim); }
.rail-hint {
  padding: 14px 22px 0;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
  display: flex; align-items: center; gap: 6px;
  border-top: 1px solid rgba(28,44,70,0.6);
}
.key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--plate-edge-hi); border-bottom-width: 2px; border-radius: 4px;
  font-family: var(--mono); font-size: 10px; color: var(--ink-dim);
  background: rgba(13, 22, 38, 0.8);
}

/* ---------------- stage ---------------- */
#stage {
  min-width: 0;
  padding: 34px clamp(20px, 4.5vw, 64px) 24px;
  display: flex; flex-direction: column;
  outline: none;
}
#chapterRoot { flex: 1; animation: chIn .55s cubic-bezier(.22,.8,.3,1) both; }
@keyframes chIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.ch-eyebrow {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em;
  color: var(--phos); margin-bottom: 10px;
}
.ch-eyebrow::before { content: ''; width: 26px; height: 1px; background: var(--phos); }
.ch-title {
  font-size: clamp(28px, 3.6vw, 44px); font-weight: 700;
  letter-spacing: -0.015em; line-height: 1.08;
  margin: 0 0 14px;
}
.ch-title .dim { color: var(--ink-faint); }
.ch-lede {
  max-width: 62ch; color: var(--ink-dim);
  font-size: clamp(15px, 1.35vw, 17.5px); line-height: 1.65;
  margin: 0 0 26px;
}
.ch-lede b, .ch-lede strong { color: var(--ink); font-weight: 600; }
.ch-lede code, .case-note code, .inlinecode {
  font-family: var(--mono); font-size: 0.86em;
  background: rgba(69, 227, 192, 0.1);
  border: 1px solid rgba(69, 227, 192, 0.18);
  padding: 1px 6px; border-radius: 5px; color: var(--phos);
  white-space: nowrap;
}
.case-note {
  border: 1px solid var(--plate-edge);
  border-left: 3px solid var(--amber);
  background: rgba(242, 183, 73, 0.05);
  border-radius: 0 var(--rad) var(--rad) 0;
  padding: 14px 18px;
  color: var(--ink-dim); font-size: 14.5px; line-height: 1.6;
  margin: 22px 0;
  max-width: 72ch;
}
.case-note b { color: var(--ink); }

/* ---------------- plates (x-ray cards) ---------------- */
.plate {
  position: relative;
  background: var(--plate);
  border: 1px solid var(--plate-edge);
  border-radius: var(--rad);
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.03);
}
.plate::before, .plate::after,
.plate > .tick::before, .plate > .tick::after {
  content: ''; position: absolute; width: 9px; height: 9px;
  border-color: var(--phos-dim); border-style: solid; opacity: .8;
  pointer-events: none;
}
.plate::before { top: -1px; left: -1px; border-width: 1.5px 0 0 1.5px; border-radius: 9px 0 0 0; }
.plate::after { top: -1px; right: -1px; border-width: 1.5px 1.5px 0 0; border-radius: 0 9px 0 0; }
.plate > .tick::before { bottom: -1px; left: -1px; border-width: 0 0 1.5px 1.5px; border-radius: 0 0 0 9px; }
.plate > .tick::after { bottom: -1px; right: -1px; border-width: 0 1.5px 1.5px 0; border-radius: 0 0 9px 0; }

.plate-tag {
  position: absolute; top: -9px; left: 16px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  color: var(--phos); background: var(--bg);
  border: 1px solid var(--plate-edge-hi);
  padding: 1px 9px; border-radius: 10px;
  text-transform: uppercase; z-index: 2;
}
.plate-tag.amber { color: var(--amber); border-color: rgba(242,183,73,.4); }
.plate-tag.red { color: var(--red); border-color: rgba(255,109,109,.4); }

.plate-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(28, 44, 70, 0.7);
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
}
.plate-head .fname { color: var(--ink); letter-spacing: 0.02em; }
.plate-head .fsize { margin-left: auto; color: var(--ink-faint); font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.teal { background: var(--phos); box-shadow: 0 0 7px var(--phos); }
.dot.amber { background: var(--amber); }
.dot.gray { background: var(--ink-faint); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--phos);
  background: linear-gradient(180deg, rgba(69,227,192,0.12), rgba(69,227,192,0.05));
  border: 1px solid var(--phos-dim);
  border-radius: 7px;
  padding: 10px 18px; cursor: pointer;
  box-shadow: 0 0 0 rgba(69,227,192,0), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: box-shadow .25s, background .25s, transform .1s, color .2s, border-color .2s;
}
.btn:hover { box-shadow: 0 0 22px rgba(69,227,192,0.25); background: linear-gradient(180deg, rgba(69,227,192,0.2), rgba(69,227,192,0.08)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.38; cursor: default; box-shadow: none; }
.btn.ghost {
  color: var(--ink-dim); border-color: var(--plate-edge-hi);
  background: rgba(28, 44, 70, 0.3);
}
.btn.ghost:hover { color: var(--ink); box-shadow: none; border-color: var(--ink-faint); }
.btn.amber {
  color: var(--amber); border-color: rgba(242,183,73,.5);
  background: linear-gradient(180deg, rgba(242,183,73,.14), rgba(242,183,73,.05));
}
.btn.amber:hover { box-shadow: 0 0 22px rgba(242,183,73,.22); }
.btn.big { padding: 14px 26px; font-size: 13px; }
.btn .arr { font-size: 14px; line-height: 1; }

.stepbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 20px 0 8px; }
.step-done {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 6px;
}
.step-done::before { content: '✓'; color: var(--phos); }

/* ---------------- two-pane lab layouts ---------------- */
.lab { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,1fr); gap: 26px; align-items: start; margin-top: 24px; }
.lab.wide-right { grid-template-columns: minmax(0,0.9fr) minmax(0,1.1fr); }
.lab-col { min-width: 0; }
.lab-cap {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em;
  color: var(--ink-faint); text-transform: uppercase;
  margin: 0 0 10px 2px; display: flex; align-items: center; gap: 8px;
}
.lab-cap .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--phos); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(69,227,192,.5);} 50% { opacity: .6; box-shadow: 0 0 0 5px rgba(69,227,192,0);} }

/* ---------------- slide canvas ---------------- */
.slideplate { padding: 14px; }
.slideframe {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--slide-white);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(90,140,190,.35), 0 0 34px rgba(69,227,192,.08), 0 10px 30px rgba(0,0,0,.5);
  overflow: hidden;
}
.slideframe svg { display: block; width: 100%; height: 100%; }
.slide-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
  padding: 9px 4px 0; letter-spacing: .06em;
}
.slide-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.slide-tab {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  color: var(--ink-faint); border: 1px solid var(--plate-edge);
  background: rgba(13,22,38,.6); border-radius: 6px;
  padding: 5px 12px; cursor: pointer;
  transition: all .2s;
}
.slide-tab:hover { color: var(--ink); border-color: var(--plate-edge-hi); }
.slide-tab.on { color: #04231c; background: var(--phos); border-color: var(--phos); font-weight: 700; }
.slide-obj { cursor: pointer; }
.slide-obj .selring { opacity: 0; transition: opacity .15s; }
.slide-obj.selected .selring, .slide-obj:hover .selring { opacity: 1; }

/* ---------------- file/code plates ---------------- */
.fileplate { overflow: hidden; }
.code {
  margin: 0; padding: 14px 0 16px;
  font-family: var(--mono); font-size: 12.4px; line-height: 1.7;
  overflow-x: auto;
  color: var(--ink);
}
.code .ln {
  display: flex; white-space: pre;
  padding: 0 16px 0 0;
  transition: background .25s, opacity .4s;
}
.code .ln-n {
  flex: 0 0 42px; text-align: right; padding-right: 14px;
  color: var(--ink-faint); opacity: .55; user-select: none;
  font-size: 10.5px; line-height: 1.95;
}
.code .ln-t { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: break-word; }
.ln.head .ln-t { color: var(--blue); font-weight: 700; }
.ln.objhead .ln-t { color: var(--violet); }
.ln.shared .ln-t { color: var(--amber); }
.ln.shared-dim { opacity: .42; }
.ln.hi-amber { background: rgba(242,183,73,.13); box-shadow: inset 2px 0 0 var(--amber); }
.ln.hi-teal { background: rgba(69,227,192,.1); box-shadow: inset 2px 0 0 var(--phos); }
.ln.ghosted .ln-t { color: var(--ink-faint); font-style: italic; }
.ln.new { animation: lnIn .4s ease both; }
@keyframes lnIn { from { opacity: 0; transform: translateX(-8px); background: rgba(69,227,192,.16);} to { opacity: 1; transform: none; } }
.ln.liftout { transition: opacity .35s, transform .35s; opacity: 0; transform: translateY(-14px); }

/* tokens */
.tk-tag { color: var(--phos); }
.tk-ns { color: var(--violet); }
.tk-attr { color: var(--blue); }
.tk-val { color: var(--amber); }
.tk-punc { color: var(--ink-faint); }
.tk-text { color: var(--ink); }
.tk-com { color: var(--ink-faint); font-style: italic; }
.tk-decl { color: var(--ink-faint); }
.tk-key { color: var(--blue); }

/* ---------------- tree view ---------------- */
.tree { font-family: var(--mono); font-size: 12.5px; padding: 14px 16px; line-height: 1.5; }
.tnode { position: relative; }
.trow {
  display: flex; align-items: center; gap: 8px;
  padding: 3.5px 8px; border-radius: 5px;
  cursor: default; position: relative;
  transition: background .18s;
}
.trow.file { cursor: pointer; }
.trow.file:hover { background: rgba(69,227,192,.09); }
.trow.file:hover .tname { color: var(--phos); }
.ticon { width: 15px; height: 15px; flex: 0 0 15px; color: var(--ink-faint); }
.trow.dir > .ticon { color: var(--amber); }
.tname { color: var(--ink-dim); white-space: nowrap; }
.trow.dir > .tname { color: var(--ink); font-weight: 500; }
.tnote {
  font-size: 9.5px; letter-spacing: .08em; color: var(--ink-faint);
  border: 1px solid var(--plate-edge-hi); border-radius: 8px;
  padding: 0 7px; margin-left: 6px; text-transform: uppercase;
}
.tnote.map { color: var(--phos); border-color: rgba(69,227,192,.35); }
.trow.ghost .tname, .trow.ghost .ticon { color: var(--ink-faint); opacity: .75; }
.trow.ghost .tname { font-style: italic; }
.tkids { margin-left: 21px; border-left: 1px solid rgba(92,140,190,.18); padding-left: 6px; }
.tnode.newdir > .trow { animation: lnIn .5s ease both; }
.tnode.newdir > .tkids { animation: kidsIn .55s ease both; }
@keyframes kidsIn { from { opacity: 0; transform: translateY(-6px);} to { opacity: 1; transform: none; } }
.tcount { font-size: 10px; color: var(--ink-faint); margin-left: 6px; }
.tarrow { width: 10px; color: var(--ink-faint); font-size: 9px; transition: transform .2s; flex: 0 0 10px; text-align: center; }
.tnode.closed > .tkids { display: none; }
.tnode.closed > .trow .tarrow { transform: rotate(-90deg); }
.tnode.newfile > .trow { animation: lnIn .45s ease both; }

/* ---------------- palette (chapter 0) ---------------- */
.palette { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.objcount {
  display: inline-flex; gap: 16px; align-items: center;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim);
  border: 1px dashed var(--plate-edge-hi); border-radius: 8px;
  padding: 8px 14px; margin-top: 6px;
}
.objcount b { color: var(--phos); font-weight: 700; font-size: 14px; }
.prop-probe { min-height: 120px; }
.probe-empty {
  color: var(--ink-faint); font-family: var(--mono); font-size: 12px;
  padding: 26px 16px; text-align: center; letter-spacing: .05em;
}
.probe-title { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--violet); padding: 10px 16px 0; text-transform: uppercase; }

/* ---------------- dedupe (chapter 2) ---------------- */
.dedupe-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 18px 0; }
.liftmeter {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim);
  display: flex; gap: 14px; align-items: center;
}
.liftmeter b { color: var(--amber); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0 0; font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .la i { background: var(--amber); }
.legend .lt i { background: var(--phos); }
.legend .lb i { background: var(--blue); }

/* ---------------- reveal (chapter 4) ---------------- */
.rename-zone { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 34px 10px 10px; }
.filecard {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 26px 34px;
  background: linear-gradient(180deg, rgba(19,32,54,.9), rgba(11,20,36,.9));
  border: 1px solid var(--plate-edge-hi); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55), 0 0 30px rgba(69,227,192,.06);
}
.filecard-icon { width: 64px; height: 76px; position: relative; }
.filecard-icon svg { width: 100%; height: 100%; }
.filename-edit {
  display: flex; align-items: baseline; gap: 0;
  font-family: var(--mono); font-size: 17px; color: var(--ink);
}
.filename-edit .stem { color: var(--ink); }
.filename-edit .ext {
  color: var(--phos); font-weight: 700;
  border: 1px dashed var(--phos-dim); border-radius: 6px;
  padding: 1px 7px; margin-left: 2px;
  background: rgba(69,227,192,.07);
  outline: none; min-width: 52px; text-align: center;
}
.filename-edit .ext:focus { border-style: solid; background: rgba(69,227,192,.15); }
.unzip-flash { animation: flash .9s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 rgba(69,227,192,0);} 30% { box-shadow: 0 0 80px rgba(69,227,192,.5);} 100% { box-shadow: 0 20px 60px rgba(0,0,0,.55);} }

.mapgrid { display: grid; grid-template-columns: minmax(0,1fr) 56px minmax(0,1.35fr); gap: 0; align-items: stretch; margin-top: 20px; }
.mapgrid .plate { min-width: 0; }
.map-mid { position: relative; }
.map-mid svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-mid path { stroke: var(--phos-dim); stroke-width: 1.4; fill: none; opacity: .85; stroke-dasharray: 3 4; animation: dashmove 1.6s linear infinite; }
@keyframes dashmove { to { stroke-dashoffset: -14; } }
.congrats {
  text-align: center; margin: 30px auto 6px; max-width: 640px;
}
.congrats .cg-title {
  font-family: var(--mono); font-size: clamp(17px,2vw,22px); font-weight: 700;
  color: var(--phos); letter-spacing: .06em;
}
.congrats p { color: var(--ink-dim); font-size: 14.5px; }

/* exploded layers */
.layers { display: flex; flex-direction: column; gap: 0; align-items: center; padding: 10px 0 4px; }
.layer {
  width: min(240px, 80%);
  padding: 8px 14px;
  margin-top: -6px;
  background: linear-gradient(180deg, rgba(26,42,68,.95), rgba(14,24,42,.95));
  border: 1px solid var(--plate-edge-hi);
  border-radius: 7px;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim);
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  position: relative;
  transform: perspective(600px) rotateX(12deg);
  transition: transform .5s cubic-bezier(.3,1,.4,1), margin .5s cubic-bezier(.3,1,.4,1), box-shadow .5s, border-color .3s, color .3s;
}
.layer:first-child { margin-top: 0; }
.layers.exploded .layer {
  transform: none;
  margin-top: 10px;
  border-color: var(--phos-dim);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(69,227,192,.12), 0 10px 26px rgba(0,0,0,.45);
}
.layers.exploded .layer::before {
  content: ''; position: absolute; left: 50%; top: -11px; height: 10px;
  border-left: 1px dashed var(--phos-dim);
}
.layers.exploded .layer:first-child::before { display: none; }

/* ---------------- xml morph (chapter 5) ---------------- */
.morphbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.seg {
  display: inline-flex; border: 1px solid var(--plate-edge-hi); border-radius: 8px; overflow: hidden;
}
.seg button {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  background: rgba(13,22,38,.7); color: var(--ink-faint);
  border: 0; padding: 9px 16px; cursor: pointer;
  transition: all .2s; text-transform: uppercase;
}
.seg button + button { border-left: 1px solid var(--plate-edge); }
.seg button.on { background: var(--phos); color: #04231c; font-weight: 700; }
.seg button:not(.on):hover { color: var(--ink); }

.morph-wrap { position: relative; }
.morph-pane { transition: opacity .45s, transform .45s; }
.morph-pane.out { opacity: 0; transform: translateY(10px) scale(.99); position: absolute; inset: 0; pointer-events: none; }
.tagchips { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 0; }
.tagchip {
  font-family: var(--mono); font-size: 10.5px;
  border: 1px solid var(--plate-edge-hi); border-radius: 12px;
  padding: 3px 10px; color: var(--violet); background: rgba(154,140,255,.07);
  cursor: default; transition: all .2s;
}
.tagchip:hover { border-color: var(--violet); color: #cfc7ff; box-shadow: 0 0 12px rgba(154,140,255,.25); }

/* emu lab */
.emu-lab { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); gap: 26px; margin-top: 26px; align-items: start; }
.emu-readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.emu-ro {
  border: 1px solid var(--plate-edge); border-radius: 8px;
  padding: 10px 14px; background: rgba(8,13,23,.6);
}
.emu-ro .k { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; color: var(--ink-faint); text-transform: uppercase; }
.emu-ro .v { font-family: var(--mono); font-size: 15px; color: var(--phos); margin-top: 3px; font-weight: 500; }
.emu-ro .v small { color: var(--ink-faint); font-size: 10px; }
.emu-conv { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.emu-row { display: flex; align-items: center; gap: 10px; }
.emu-row label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; color: var(--ink-faint); width: 64px; text-transform: uppercase; }
.emu-row input {
  flex: 1; font-family: var(--mono); font-size: 14px; color: var(--ink);
  background: rgba(5,8,15,.8); border: 1px solid var(--plate-edge-hi);
  border-radius: 6px; padding: 8px 12px; outline: none; min-width: 0;
}
.emu-row input:focus { border-color: var(--phos); box-shadow: 0 0 0 2px rgba(69,227,192,.15); }
.emu-eq { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); text-align: center; letter-spacing: .1em; }
.emu-eq b { color: var(--amber); }
.draggable-hint {
  position: absolute; font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint);
  bottom: 6px; right: 10px; letter-spacing: .1em; pointer-events: none;
}

/* ---------------- minefield (chapter 6) ---------------- */
.timeline { display: flex; align-items: flex-start; gap: 0; margin: 26px 0 8px; overflow-x: auto; padding-bottom: 6px; }
.tl-item { flex: 1 0 128px; position: relative; padding-top: 26px; min-width: 128px; }
.tl-item::before {
  content: ''; position: absolute; top: 9px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, var(--plate-edge-hi), var(--plate-edge));
}
.tl-item::after {
  content: ''; position: absolute; top: 5px; left: 0; width: 9px; height: 9px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--phos-dim);
}
.tl-item.hot::after { border-color: var(--amber); box-shadow: 0 0 10px rgba(242,183,73,.5); }
.tl-year { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--ink); }
.tl-item.hot .tl-year { color: var(--amber); }
.tl-cap { font-size: 12px; color: var(--ink-dim); margin-top: 3px; padding-right: 14px; line-height: 1.45; }

.stacklab { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); gap: 30px; margin-top: 24px; align-items: end; }
.stackstage {
  position: relative; height: 380px;
  display: flex; align-items: flex-end; justify-content: center; gap: 8%;
  border-bottom: 2px solid var(--plate-edge-hi);
  padding: 0 8%;
}
.paperstack { position: relative; width: 130px; }
.paperstack .sheet {
  position: absolute; left: 0; right: 0; height: 3px;
  background: #e9edf3; border-radius: 1px;
  opacity: 0; transform: translateY(6px);
  transition: opacity .12s, transform .12s;
}
.paperstack .sheet.on { opacity: 1; transform: none; }
.paperstack .stackbody {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #f4f6f9, #cfd6e0);
  border-radius: 3px 3px 0 0;
  box-shadow: 0 0 0 1px rgba(90,140,190,.4), 0 0 30px rgba(69,227,192,.06);
  transition: height .15s linear;
}
.paperstack .stacklabel {
  position: absolute; bottom: -30px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--phos); white-space: nowrap;
  text-align: center; line-height: 1.3;
}
.paperstack .heighttag {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--ink-faint); white-space: nowrap;
}
.bookrow { display: flex; align-items: flex-end; gap: 9px; }
.book {
  width: 44px; border-radius: 3px 3px 0 0;
  display: flex; align-items: flex-end; justify-content: center;
  font-family: var(--mono); font-size: 8.5px; color: rgba(255,255,255,.85);
  padding-bottom: 6px; letter-spacing: .04em;
  box-shadow: 0 0 0 1px rgba(90,140,190,.3);
  writing-mode: vertical-rl; text-orientation: mixed;
  transform: rotate(180deg);
  line-height: 1.2;
}
.b-lotr1 { background: linear-gradient(180deg, #7d3b3b, #5c2a2a); }
.b-lotr2 { background: linear-gradient(180deg, #3b5c7d, #2a425c); }
.b-lotr3 { background: linear-gradient(180deg, #3b7d4f, #2a5c3a); }
.b-lotr4 { background: linear-gradient(180deg, #6d5a9e, #4f3f78); }
.stackfig { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); text-align: center; margin-top: 10px; letter-spacing: .1em; }
.pageslider { margin-top: 20px; }
.pageslider input[type=range] {
  width: 100%; appearance: none; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--phos) var(--fill,0%), var(--plate-edge) var(--fill,0%));
  outline: none;
}
.pageslider input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--phos); border: 3px solid #062a22; cursor: pointer;
  box-shadow: 0 0 12px rgba(69,227,192,.6);
}
.pageslider input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--phos); border: 3px solid #062a22; cursor: pointer;
}
.pagescale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-top: 6px; }
.pagecount { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); margin-top: 10px; }
.pagecount b { color: var(--phos); font-size: 16px; }

.theories { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 30px; }
.theory {
  padding: 20px 22px; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .25s, transform .25s, box-shadow .25s;
}
.theory:hover { transform: translateY(-3px); }
.theory.picked { border-color: var(--amber); box-shadow: 0 0 30px rgba(242,183,73,.12); }
.theory .th-tag { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--amber); }
.theory .th-tag.kinder { color: var(--blue); }
.theory h3 { margin: 8px 0 10px; font-size: 17px; }
.theory p { font-size: 13.5px; color: var(--ink-dim); line-height: 1.6; margin: 0 0 10px; }
.theory blockquote {
  margin: 10px 0; padding: 10px 14px;
  border-left: 2px solid var(--amber);
  font-size: 12.5px; color: var(--ink-dim); font-style: italic;
  background: rgba(242,183,73,.05); border-radius: 0 6px 6px 0;
  line-height: 1.55;
}
.theory .th-src { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); letter-spacing: .1em; }
.theory .th-pick {
  position: absolute; top: 14px; right: 16px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em;
  color: var(--ink-faint);
}
.theory.picked .th-pick { color: var(--amber); }

.takeaway { margin-top: 34px; padding: 26px 30px; text-align: center; }
.takeaway .tk-big {
  font-size: clamp(18px, 2.1vw, 24px); font-weight: 700; line-height: 1.4;
  margin: 0 auto 12px; max-width: 56ch;
}
.takeaway .tk-big .hl { color: var(--phos); }
.takeaway p { color: var(--ink-dim); max-width: 64ch; margin: 0 auto 8px; font-size: 14.5px; }

/* receipt */
.receipt { margin: 26px auto 0; max-width: 560px; }
.receipt .code { font-size: 11.5px; text-align: left; }
.receipt .ln .ln-n { flex-basis: 8px; padding-right: 8px; }

/* ---------------- stage nav ---------------- */
.stage-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 44px; padding-top: 20px;
  border-top: 1px solid rgba(28,44,70,.7);
}
.snav {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em;
  color: var(--ink-dim); background: none;
  border: 1px solid var(--plate-edge); border-radius: 8px;
  padding: 10px 18px; cursor: pointer;
  transition: all .2s; text-transform: uppercase;
}
.snav:hover { color: var(--phos); border-color: var(--phos-dim); background: rgba(69,227,192,.06); }
.snav svg { width: 14px; height: 14px; }
.snav-next { color: var(--phos); border-color: var(--phos-dim); }
.snav-next:hover { background: rgba(69,227,192,.1); box-shadow: 0 0 18px rgba(69,227,192,.15); }
.snav:disabled { opacity: .3; cursor: default; box-shadow: none; }
.stage-dots { display: flex; gap: 8px; }
.sdot {
  width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--plate-edge-hi);
  background: transparent; cursor: pointer; padding: 0;
  transition: all .2s;
}
.sdot.done { background: var(--ink-faint); border-color: var(--ink-faint); }
.sdot.now { background: var(--phos); border-color: var(--phos); box-shadow: 0 0 8px var(--phos); transform: scale(1.25); }

/* ---------------- drawer + modal ---------------- */
#drawerScrim, #modalScrim {
  position: fixed; inset: 0; background: rgba(3,5,9,.66);
  backdrop-filter: blur(3px); z-index: 60;
  animation: scrimIn .25s ease;
}
@keyframes scrimIn { from { opacity: 0; } }
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(420px, 94vw);
  background: var(--bg-2); border-left: 1px solid var(--plate-edge-hi);
  box-shadow: -30px 0 80px rgba(0,0,0,.6);
  display: flex; flex-direction: column;
  animation: drawerIn .35s cubic-bezier(.3,1,.4,1);
}
@keyframes drawerIn { from { transform: translateX(60px); opacity: 0; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--plate-edge);
}
.drawer-title { font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .18em; color: var(--phos); }
.drawer-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px 8px 30px; }
.drawer-empty { padding: 30px 20px; color: var(--ink-faint); font-family: var(--mono); font-size: 12px; text-align: center; }

#modal {
  position: fixed; z-index: 80; inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(780px, 92vw); max-height: 82vh;
  background: var(--bg-2); border: 1px solid var(--plate-edge-hi);
  border-radius: 12px; box-shadow: 0 40px 120px rgba(0,0,0,.7), 0 0 40px rgba(69,227,192,.05);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn .3s cubic-bezier(.3,1,.4,1);
}
@keyframes modalIn { from { transform: translate(-50%,-48%) scale(.97); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--plate-edge);
  background: rgba(13,22,38,.6);
}
.modal-path { font-family: var(--mono); font-size: 12.5px; color: var(--phos); letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-meta { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-left: auto; white-space: nowrap; }
.modal-body { overflow: auto; }
.modal-body .code { font-size: 11.8px; }
.modal-preview { padding: 20px; display: flex; justify-content: center; }
.iconbtn {
  width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--plate-edge); background: none;
  color: var(--ink-dim); cursor: pointer; flex: 0 0 30px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.iconbtn:hover { color: var(--red); border-color: rgba(255,109,109,.4); }
.iconbtn svg { width: 13px; height: 13px; }

/* binary previews */
.logo-preview { width: 190px; }
.xlsx-preview { border-collapse: collapse; font-family: var(--mono); font-size: 11px; }
.xlsx-preview td, .xlsx-preview th {
  border: 1px solid var(--plate-edge-hi); padding: 5px 12px;
  color: var(--ink-dim); text-align: right; min-width: 58px;
}
.xlsx-preview th { color: var(--phos); background: rgba(69,227,192,.06); font-weight: 500; }
.xlsx-preview td.rowh { color: var(--ink-faint); min-width: 24px; text-align: center; background: rgba(28,44,70,.3); }
.thumb-preview { width: 220px; border-radius: 4px; }

/* ---------------- misc ---------------- */
.divider { border: 0; border-top: 1px solid rgba(28,44,70,.7); margin: 34px 0; }
.small { font-size: 12.5px; color: var(--ink-faint); }
.kbd-note { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); }
.flex { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt { margin-top: 22px; } .mt2 { margin-top: 34px; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible, .trow:focus-visible {
  outline: 2px solid var(--phos); outline-offset: 2px;
}
.hintline { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); margin-top: 10px; letter-spacing: .04em; }
.hintline b { color: var(--ink-dim); font-weight: 500; }

/* mini slide previews inside inspector / steps */
.minislide {
  width: 150px; aspect-ratio: 16/9; border-radius: 4px;
  background: var(--slide-white);
  box-shadow: 0 0 0 1px rgba(90,140,190,.35);
  overflow: hidden; position: relative; flex: 0 0 150px;
}
.minislide svg { width: 100%; height: 100%; display: block; }
.fileref { display: flex; gap: 16px; align-items: center; padding: 12px 16px; }
.fileref .fr-txt { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); line-height: 1.6; }
.fileref .fr-txt b { color: var(--ink-dim); font-weight: 500; }

/* ---------------- responsive ---------------- */
@media (max-width: 1080px) {
  :root { --rail-w: 200px; }
  .lab, .lab.wide-right, .emu-lab, .stacklab, .theories { grid-template-columns: 1fr; }
  .stacklab { align-items: stretch; }
  .mapgrid { grid-template-columns: 1fr; }
  .map-mid { display: none; }
}
@media (max-width: 860px) {
  #bodyRow { grid-template-columns: 1fr; }
  #rail {
    position: static; height: auto; border-right: 0;
    border-bottom: 1px solid var(--plate-edge);
    padding: 0; flex-direction: row; align-items: center;
    overflow-x: auto; background: rgba(6,10,18,.9);
    position: sticky; top: var(--topbar-h); z-index: 30;
  }
  #railList { display: flex; overflow: visible; }
  .rail-link { padding: 12px 14px; border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .rail-item.current .rail-link { border-left-color: transparent; border-bottom-color: var(--phos); background: rgba(69,227,192,.07); }
  .rail-sub, .rail-hint { display: none; }
  #stage { padding: 24px 16px 18px; }
  .tb-specimen { display: none; }
  .stage-nav { flex-wrap: wrap; }
  .stage-dots { order: -1; width: 100%; justify-content: center; margin-bottom: 12px; }
}
@media (max-width: 560px) {
  .ch-title { font-size: 27px; }
  .emu-readouts { grid-template-columns: 1fr 1fr; }
  .stackstage { padding: 0 4%; gap: 5%; }
  .paperstack { width: 100px; }
  .modal-meta { display: none; }
  .tb-chapter { font-size: 10px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
  html { scroll-behavior: auto; }
}
