/* ============================================================
   How the Web Works — a cross-section
   Palette shifts with altitude: abyss → slate → amber → daylight → rails red
   ============================================================ */

:root {
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;

  --bg: #f4efe4;
  --bg-2: #ebe4d6;
  --ink: #1b1a17;
  --ink-2: #5a564d;
  --ink-3: #8f8a7e;
  --line: rgba(27,26,23,.18);
  --accent: #d0642a;
  --accent-2: #2b6cb0;
  --door: #b8431a;
  --panel: rgba(255,255,255,.55);
  --panel-ink: var(--ink);
  --shadow: 0 1px 0 rgba(0,0,0,.05), 0 12px 40px -20px rgba(0,0,0,.35);
  --radius: 14px;

  /* packet stripe colours — constant across all floors */
  --c-phy: #0b1c33;
  --c-link: #1f8a7a;
  --c-ip: #2a6fd6;
  --c-tcp: #e3a028;
  --c-udp: #8e6bd6;
  --c-tls: #c9a227;
  --c-http: #f1e6c8;
  --c-app: #cc2a1a;

  --altitude-w: 64px;

  /* Fraunces as an altitude instrument: cold and sharp in the abyss, warm and soft at the top */
  --opsz: 96; --soft: 30; --wght: 500;
}

/* ---- floors -------------------------------------------------- */
body[data-floor="hub"]     { --bg:#f4efe4; --bg-2:#e9e2d3; --ink:#1b1a17; --ink-2:#5a564d; --ink-3:#8f8a7e; --accent:#d0642a; --door:#b8431a; --panel:rgba(255,255,255,.6); --line:rgba(27,26,23,.18);  --opsz:80; --soft:60; --wght:520; }
body[data-floor="wires"]   { --bg:#07111f; --bg-2:#0d1b30; --ink:#e6edf7; --ink-2:#a9b7cc; --ink-3:#929db1; --accent:#5fd3ff; --door:#ffd166; --panel:rgba(255,255,255,.06); --line:rgba(230,237,247,.18);  --opsz:144; --soft:0; --wght:400; }
body[data-floor="links"]   { --bg:#0b1e2c; --bg-2:#12293a; --ink:#e4f0f0; --ink-2:#a8c2c2; --ink-3:#91a6a6; --accent:#4fe0c0; --door:#ffd166; --panel:rgba(255,255,255,.06); --line:rgba(228,240,240,.18);  --opsz:130; --soft:10; --wght:400; }
body[data-floor="ip"]      { --bg:#10293a; --bg-2:#183548; --ink:#e6eff5; --ink-2:#adc3d2; --ink-3:#94abb9; --accent:#7fb8ff; --door:#ffd166; --panel:rgba(255,255,255,.07); --line:rgba(230,239,245,.18);  --opsz:120; --soft:20; --wght:420; }
body[data-floor="tcp"]     { --bg:#1f2f36; --bg-2:#2a3c44; --ink:#f0ece2; --ink-2:#c2bcaa; --ink-3:#a7a397; --accent:#f2b34c; --door:#ffd166; --panel:rgba(255,255,255,.07); --line:rgba(240,236,226,.18);  --opsz:110; --soft:30; --wght:440; }
body[data-floor="dns"]     { --bg:#2f3129; --bg-2:#3b3d33; --ink:#f3eedf; --ink-2:#c9c2ad; --ink-3:#aca898; --accent:#f2c14e; --door:#ffd166; --panel:rgba(255,255,255,.07); --line:rgba(243,238,223,.18);  --opsz:100; --soft:40; --wght:460; }
body[data-floor="tls"]     { --bg:#3d3520; --bg-2:#4a4128; --ink:#f7f0dc; --ink-2:#d2c7a6; --ink-3:#b4ac94; --accent:#ffd166; --door:#ffe9a8; --panel:rgba(255,255,255,.07); --line:rgba(247,240,220,.18);  --opsz:90; --soft:50; --wght:480; }
body[data-floor="http"]    { --bg:#f3ead7; --bg-2:#e9dec6; --ink:#211d16; --ink-2:#5f5847; --ink-3:#958c76; --accent:#d9812b; --door:#b8431a; --panel:rgba(255,255,255,.55); --line:rgba(33,29,22,.18);  --opsz:80; --soft:60; --wght:500; }
body[data-floor="browser"] { --bg:#f8f5ee; --bg-2:#ece7dc; --ink:#1c1c1a; --ink-2:#585650; --ink-3:#8d8a80; --accent:#2b6cb0; --door:#b8431a; --panel:rgba(255,255,255,.7); --line:rgba(28,28,26,.16);  --opsz:70; --soft:70; --wght:520; }
body[data-floor="server"]  { --bg:#f5ebe4; --bg-2:#ecdcd2; --ink:#231b18; --ink-2:#6a564f; --ink-3:#9f8b83; --accent:#b8431a; --door:#8f2a10; --panel:rgba(255,255,255,.6); --line:rgba(35,27,24,.18);  --opsz:60; --soft:80; --wght:540; }
body[data-floor="rails"]   { --bg:#fbf0ec; --bg-2:#f3dfd8; --ink:#241412; --ink-2:#6d4a44; --ink-3:#a4837c; --accent:#cc2a1a; --door:#8f2a10; --panel:rgba(255,255,255,.65); --line:rgba(36,20,18,.18);  --opsz:50; --soft:90; --wght:560; }
body[data-floor="sandbox"] { --bg:#f4efe4; --bg-2:#e9e2d3; --ink:#1b1a17; --ink-2:#5a564d; --ink-3:#8f8a7e; --accent:#d0642a; --door:#b8431a; --panel:rgba(255,255,255,.6); --line:rgba(27,26,23,.18);  --opsz:40; --soft:100; --wght:560; }

/* ---- base ---------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.55;
  overflow: hidden;
  transition: background-color .6s ease, color .6s ease;
  -webkit-font-smoothing: antialiased;
}
body.diving { transition: background-color .09s linear, color .09s linear; }
body.diving h1, body.diving h2, body.diving h3 { transition: none; }
#depth {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; width: 100%; height: 100%; display: block;
}
body.has-depth::before { display: none; }
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 80% -10%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, color-mix(in oklab, var(--accent) 8%, transparent), transparent 60%);
  transition: opacity .6s;
}
#grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
body[data-floor="wires"] #grain, body[data-floor="links"] #grain, body[data-floor="ip"] #grain,
body[data-floor="tcp"] #grain, body[data-floor="dns"] #grain, body[data-floor="tls"] #grain { mix-blend-mode: screen; opacity: .35; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; line-height: 1.1; margin: 0 0 .4em; font-variation-settings: "opsz" var(--opsz), "SOFT" var(--soft), "wght" var(--wght); transition: font-variation-settings .6s ease; }
h1 { font-size: clamp(2.2rem, 4.4vw, 3.6rem); }
h2 { font-size: clamp(1.85rem, 3.2vw, 2.6rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
em { font-style: italic; }
strong { font-weight: 600; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .9em; }
code { background: color-mix(in oklab, var(--ink) 8%, transparent); padding: .08em .35em; border-radius: 5px; }
kbd { border: 1px solid var(--line); border-radius: 5px; padding: 0 .35em; font-size: .75em; margin-left: .35em; opacity: .8; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
small, .small { font-size: .9em; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.tiny { font-size: .84em; color: var(--ink-3); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }

/* ---- chrome -------------------------------------------------- */
#topbar {
  position: fixed; top: 0; left: var(--altitude-w); right: 0; height: 52px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  font-size: .85rem; color: var(--ink-2);
}
.tb-floor { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; margin-right: 12px; color: var(--accent); }
.tb-title { font-family: var(--font-display); font-size: 1.05rem; color: var(--ink); }
.tb-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  font-size: .8rem; color: var(--ink); transition: all .2s;
}
.tb-btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tb-btn:hover kbd { border-color: var(--bg); }

#navbar {
  position: fixed; bottom: 0; left: var(--altitude-w); right: 0; height: 64px; z-index: 20;
  display: flex; align-items: center; justify-content: center; gap: 18px;
}
.nav-arrow {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent;
  font-size: 1.2rem; display: grid; place-items: center; transition: all .18s;
}
.nav-arrow:hover:not(:disabled) { background: var(--ink); color: var(--bg); transform: translateY(-1px); }
.nav-arrow:disabled { opacity: .18; cursor: default; }
.nav-arrow.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 60%, transparent); } 50% { box-shadow: 0 0 0 9px transparent; } }
#dots { display: flex; gap: 8px; align-items: center; }
#dots button {
  width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent; padding: 0;
  transition: transform .15s, background .15s; position: relative;
}
#dots button.seen { background: color-mix(in oklab, var(--ink) 35%, transparent); }
#dots button.here { background: var(--ink); transform: scale(1.25); }
#dots button:disabled { opacity: .25; cursor: default; }
#dots button:not(:disabled):hover { transform: scale(1.35); }
#dots button.gate::after { content: ""; position: absolute; right: -6px; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
#dots button[data-title]:hover::before {
  content: attr(data-title); position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: .7rem; white-space: nowrap; font-family: var(--font-body);
}

/* ---- altitude strip ----------------------------------------- */
/* the core sample: strata drawn per floor (app.js STRATA), a drawn glyph, a depth readout, and a marker that rides the elevator */
#altitude {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--altitude-w); z-index: 25;
  border-right: 1px solid var(--line); box-shadow: 1px 0 0 rgba(0,0,0,.08), 6px 0 24px -12px rgba(0,0,0,.45);
}
.alt-track { position: absolute; inset: 0; display: flex; flex-direction: column-reverse; }
.alt-floor {
  flex: 1; position: relative; cursor: pointer; border-top: 1px solid rgba(128,128,128,.22);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background-size: 100% 100%; background-repeat: no-repeat; overflow: hidden;
}
.alt-floor::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,0); transition: background .2s; pointer-events: none; }
.alt-floor.dark:hover::after { background: rgba(255,255,255,.12); }
.alt-floor.light:hover::after { background: rgba(0,0,0,.06); }
.alt-floor .glyph { width: 20px; height: 20px; opacity: .55; transition: opacity .25s, transform .25s; position: relative; z-index: 1; }
.alt-floor .glyph svg { display: block; }
.alt-floor.here .glyph { opacity: 1; transform: scale(1.2); filter: drop-shadow(0 0 5px currentColor); }
.alt-floor.seen .glyph { opacity: .8; }
.alt-floor .depth {
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .04em; opacity: 0; transition: opacity .25s; position: relative; z-index: 1; white-space: nowrap;
}
.alt-floor.here .depth { opacity: .9; }
.alt-floor .lbl {
  position: absolute; left: 60px; top: 50%; transform: translateY(-50%); z-index: 2;
  background: var(--ink); color: var(--bg); padding: 4px 10px; border-radius: 6px; font-size: .72rem; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s; font-family: var(--font-mono); letter-spacing: .04em;
}
.alt-floor:hover .lbl { opacity: 1; }
.alt-floor.dark { color: #e8f1ff; }
.alt-floor.light { color: #1b1a17; }
.alt-marker {
  position: absolute; right: 0; width: 3px; background: var(--accent); border-radius: 2px 0 0 2px; z-index: 3; pointer-events: none;
  transition: top .5s cubic-bezier(.2,.7,.2,1), height .5s, background-color .6s; box-shadow: 0 0 10px color-mix(in oklab, var(--accent) 70%, transparent);
}
body.diving .alt-marker { transition: top .08s linear, height .08s linear; }
@media (max-height: 640px) { .alt-floor .depth { display: none; } }

/* ---- stage & slides ----------------------------------------- */
#stage {
  position: fixed; top: 52px; bottom: 64px; left: var(--altitude-w); right: 0; z-index: 10;
  overflow: auto; -webkit-overflow-scrolling: touch;
}
.slide {
  min-height: 100%; width: 100%; padding: clamp(24px, 5vh, 56px) 56px 14px; margin: 0 auto;
  animation: slide-in .45s cubic-bezier(.2,.7,.2,1) both;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.slide > * { animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }
.slide > *:nth-child(2) { animation-delay: .06s; }
.slide > *:nth-child(3) { animation-delay: .12s; }
.slide > *:nth-child(4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* layouts */
.prose { max-width: 660px; font-size: 1.18rem; }
.prose.wide { max-width: 820px; }
.prose p { margin-bottom: 1.05em; }
.center { text-align: center; }
.center .prose { margin: 0 auto; }
.lede { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.35; font-variation-settings: "opsz" 40, "SOFT" 50; }
.split { display: grid; grid-template-columns: minmax(340px, 460px) minmax(520px, 1fr); gap: 48px; align-items: center; width: 100%; max-width: 1360px; }
.split.rev { grid-template-columns: minmax(520px, 1fr) minmax(340px, 460px); }
.split .prose { font-size: 1.18rem; line-height: 1.6; }
.stack { display: flex; flex-direction: column; gap: 22px; width: 100%; max-width: 1180px; align-items: center; }
.eyebrow { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; color: var(--accent); margin-bottom: 10px; }
.big-num { font-family: var(--font-display); font-size: clamp(3rem, 9vw, 7rem); line-height: 1; font-variation-settings: "opsz" 144, "wght" 300; letter-spacing: -.03em; }

/* demo stage: fixed size, never reflows with content. two materials, keyed off the floor's theme:
   below ground it is a lit instrument panel; above ground it is paper. */
.demo {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; width: 100%;
}
body[data-theme="dark"] .demo {
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.025));
  border-color: rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), inset 0 0 0 1px rgba(0,0,0,.35), 0 18px 40px -22px rgba(0,0,0,.9);
}
body[data-theme="dark"] .demo-label { color: color-mix(in oklab, var(--accent) 70%, var(--ink-3)); text-shadow: 0 0 8px color-mix(in oklab, var(--accent) 40%, transparent); }
body[data-theme="light"] .demo {
  background: rgba(255,255,255,.72);
  border-color: rgba(0,0,0,.1);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 1px 2px rgba(0,0,0,.05), 0 24px 44px -28px rgba(60,40,20,.4);
}
body[data-theme="light"] .fork { background: rgba(255,255,255,.72); }
.demo.h-260 { height: 260px; } .demo.h-300 { height: 300px; } .demo.h-320 { height: 320px; } .demo.h-340 { height: 340px; } .demo.h-360 { height: 360px; } .demo.h-380 { height: 380px; } .demo.h-400 { height: 400px; } .demo.h-440 { height: 440px; } .demo.h-500 { height: 500px; } .demo.h-560 { height: 560px; }
.demo svg { display: block; width: 100%; height: 100%; }
.demo svg.ico { width: 16px; height: 16px; display: inline-block; }
.demo-label { position: absolute; top: 10px; left: 14px; font-family: var(--font-mono); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.demo-note { position: absolute; bottom: 10px; left: 14px; right: 14px; font-size: .9rem; color: var(--ink-2); }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 12px; font-size: .95rem; color: var(--ink-2); }
.controls label { display: inline-flex; align-items: center; gap: 8px; }
.controls input[type=range] { width: 130px; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
.controls .val { font-family: var(--font-mono); color: var(--ink); min-width: 3.5ch; }
.btn {
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink); border-radius: 999px; padding: 8px 18px;
  font-size: .9rem; transition: all .18s; font-weight: 500;
}
.btn:hover:not(:disabled) { background: var(--ink); color: var(--bg); transform: translateY(-1px); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: color-mix(in oklab, var(--accent) 85%, black); border-color: transparent; }
.btn.sm { padding: 4px 12px; font-size: .8rem; }
.btn.active { background: var(--ink); color: var(--bg); }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 14px; font-size: .85rem; }
.seg button.active { background: var(--ink); color: var(--bg); }

/* doors & forks */
.door {
  color: var(--door); text-decoration: none; border-bottom: 1.5px dashed var(--door); cursor: pointer;
  transition: all .15s; padding-bottom: 1px; font-weight: 500;
}
.door:hover { background: color-mix(in oklab, var(--door) 14%, transparent); border-bottom-style: solid; }
.door::after { content: "\00a0↗"; font-size: .8em; opacity: .7; white-space: nowrap; }
.door.down::after { content: "\00a0↓"; }
.forks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; width: 100%; max-width: 860px; }
.fork {
  display: block; text-align: left; padding: 16px 18px; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--panel); text-decoration: none; color: var(--ink); transition: all .18s; cursor: pointer; font: inherit;
}
.fork:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.fork b { display: block; font-family: var(--font-display); font-size: 1.15rem; margin-bottom: 4px; font-weight: 500; }
.fork span { font-size: .88rem; color: var(--ink-2); }
.fork .arrow { float: right; color: var(--accent); }
.next-line { margin-top: 26px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.go-next { font-family: var(--font-display); font-size: 1.25rem; border: 1.5px solid var(--ink); border-radius: 999px; padding: 10px 24px; background: transparent; transition: all .18s; }
.go-next:hover { background: var(--ink); color: var(--bg); transform: translateX(3px); }

/* gates */
.gated { opacity: 0; transform: translateY(8px); pointer-events: none; transition: all .5s cubic-bezier(.2,.7,.2,1); max-height: 0; overflow: hidden; }
.gated.open { opacity: 1; transform: none; pointer-events: auto; max-height: 600px; }
.gate-hint { font-size: .85rem; color: var(--accent); font-family: var(--font-mono); letter-spacing: .04em; }

/* ---- tables & misc content ---------------------------------- */
table.t { border-collapse: collapse; width: 100%; font-size: .98rem; }
table.t th, table.t td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t.compact th, table.t.compact td { padding: 3px 8px; }
table.t th { font-family: var(--font-mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 500; }
table.t td.mono { font-family: var(--font-mono); font-size: .85rem; }
pre.code {
  font-family: var(--font-mono); font-size: .88rem; line-height: 1.5; background: color-mix(in oklab, var(--ink) 7%, transparent);
  padding: 14px 18px; border-radius: 10px; overflow: auto; margin: 0; border: 1px solid var(--line); white-space: pre;
}
pre.code .k { color: var(--accent); } pre.code .c { color: var(--ink-3); font-style: italic; } pre.code .s { color: #2f8f5b; }
body[data-floor="wires"] pre.code .s, body[data-floor="links"] pre.code .s, body[data-floor="ip"] pre.code .s, body[data-floor="tcp"] pre.code .s, body[data-floor="dns"] pre.code .s, body[data-floor="tls"] pre.code .s { color: #7fe0a0; }
textarea.code, input.code {
  font-family: var(--font-mono); font-size: .85rem; background: color-mix(in oklab, var(--ink) 6%, transparent); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; resize: none; outline: none;
}
textarea.code:focus, input.code:focus { border-color: var(--accent); }
.callout { border-left: 3px solid var(--accent); padding: 6px 16px; background: color-mix(in oklab, var(--accent) 7%, transparent); border-radius: 0 10px 10px 0; font-size: .95rem; }
.pill { display: inline-block; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 14px; font-size: .85rem; }
.tabs button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.layer-stripe { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.recap-list { list-style: none; padding: 0; margin: 0; }
.recap-list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 14px; align-items: baseline; }
.recap-list li b { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); min-width: 110px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .9rem; }
.kv dt { font-family: var(--font-mono); color: var(--ink-3); font-size: .8rem; }
.kv dd { margin: 0; }
.hl { background: color-mix(in oklab, var(--accent) 22%, transparent); border-radius: 3px; padding: 0 .2em; }
.flash { animation: flash .6s ease-out; }
@keyframes flash { 0% { background: color-mix(in oklab, var(--accent) 45%, transparent); } 100% { background: transparent; } }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

/* ---- map ----------------------------------------------------- */
#map[hidden] { display: none; }
#map { position: fixed; inset: 0; z-index: 50; background: rgba(10,12,18,.72); backdrop-filter: blur(8px); display: grid; place-items: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0 } }
.map-inner { position: relative; width: min(1180px, 94vw); height: auto; max-height: 92vh; background: #f4efe4; color: #1b1a17; border-radius: 20px; box-shadow: 0 40px 100px -30px rgba(0,0,0,.7); display: flex; flex-direction: column; overflow: hidden; }
.map-head { display: flex; align-items: center; gap: 18px; padding: 16px 26px; border-bottom: 1px solid rgba(0,0,0,.1); }
.map-head h2 { margin: 0; font-size: 1.4rem; }
.map-head p { margin: 0; font-size: .85rem; color: #5a564d; flex: 1; }
.map-head .tb-btn { color: #1b1a17; border-color: rgba(0,0,0,.25); }
.map-head .tb-btn:hover { background: #1b1a17; color: #f4efe4; }
.map-legend { margin-left: 14px; }
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #1b1a17; margin: 0 4px 0 10px; vertical-align: -1px; }
.map-legend i.seen { background: rgba(27,26,23,.4); }
.map-legend i.here { background: #d0642a; border-color: #d0642a; }
#map-body { flex: 1; overflow: auto; padding: 10px 10px 20px; }
.map-inner::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34px; pointer-events: none;
  background: linear-gradient(to top, #f4efe4, rgba(244,239,228,0));
  border-radius: 0 0 20px 20px;
}
#map-body svg { width: 100%; height: auto; display: block; }
.map-floor-bg { transition: opacity .2s; }
.map-dot { cursor: pointer; }
.map-dot:hover circle { r: 8; }
.map-room { cursor: pointer; }
.map-room:hover rect { stroke-width: 2.2; }
.map-title { font-family: var(--font-display); font-size: 15px; }
.map-sub { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; }

/* ---- scroll cue: a slide taller than the stage fades at the bottom edge instead of looking cut ---- */
#stage-fade { position: fixed; left: var(--altitude-w); right: 0; bottom: 64px; height: 56px; z-index: 15; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: linear-gradient(to top, var(--bg), transparent); }
#stage-fade.on { opacity: 1; }

/* ---- toast --------------------------------------------------- */
#toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: .85rem; z-index: 60; animation: toast 2.4s forwards; pointer-events: none; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px) } 10%, 80% { opacity: 1; transform: translate(-50%, 0) } 100% { opacity: 0 } }

/* ---- responsive ---------------------------------------------- */
@media (max-width: 980px) {
  .split, .split.rev { grid-template-columns: 1fr; gap: 24px; }
  .slide { padding: 20px 22px 40px; justify-content: flex-start; }
  body { font-size: 16px; }
}

/* stack layouts: keep header + demo inside one viewport at 1440×900 */
.stack .prose.wide { max-width: 820px; font-size: 1.08rem; }
.stack .prose.wide h2 { font-size: clamp(1.7rem, 2.8vw, 2.2rem); }
.stack .prose.wide p { margin-bottom: .7em; }
.stack .demo { max-width: 1200px !important; }
.stack { gap: 16px; }

/* ---- laptops (1440×776, 1280×720): the demo scales to leave room for the words; the words keep their size ---- */
@media (max-height: 840px) {
  :root, body { --demo-max-h: 50vh; }
  .slide { padding: 12px 44px 12px; }
  .stack { gap: 10px; }
  .stack .prose.wide { font-size: 1.04rem; }
  .stack .prose.wide p { margin-bottom: .5em; }
  .stack .prose.wide h2 { font-size: clamp(1.6rem, 2.6vw, 2rem); margin-bottom: .25em; }
  .stack .demo.fit { max-height: 50vh; }
  .stack .prose.wide p { margin-bottom: .6em; }
  .stack .prose.wide h2 { margin-bottom: .3em; }
  .demo.fit { max-height: 50vh; }
  .demo.fit { display: flex; align-items: center; justify-content: center; }
  .demo.fit > svg { height: 100%; width: auto; margin: 0 auto; max-width: 100%; }
  .forks { margin-top: 12px; }
  .next-line { margin-top: 16px; }
  .controls { margin-top: 8px; }
}
/* genuinely small screens */
@media (max-height: 700px) {
  :root, body { --demo-max-h: 46vh; }
  .demo.fit { max-height: 46vh; }
  body { font-size: 17px; }
  h2 { font-size: 1.6rem; }
  .prose, .split .prose, .stack .prose.wide { font-size: 1.02rem; }
  .prose p { margin-bottom: .6em; }
}
