/* ==========================================================================
   Serpent Canyon Workshop - "workshop at midnight"
   ========================================================================== */
:root {
  --bg: #05070a;
  --bg-2: #0a0f14;
  --panel: rgba(10, 16, 21, 0.9);
  --panel-solid: #0b1117;
  --line: rgba(120, 255, 214, 0.13);
  --line-2: rgba(120, 255, 214, 0.26);
  --ink: #d8e4de;
  --ink-2: #a3b4ad;
  --muted: #6f8079;
  --serpent: #19ffb0;
  --venom: #ff2fae;
  --amber: #ffb347;
  --danger: #ff5a5a;
  --ok: #43f59a;
  --sim: #b98cff;
  --meas: #ffc857;
  --radius: 14px;
  --font-d: 'Chakra Petch', 'Avenir Next Condensed', 'Segoe UI', system-ui, sans-serif;
  --font-b: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-m: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --hud-h: 58px;
  --glow: 0 0 18px color-mix(in srgb, var(--serpent) 55%, transparent);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* `hidden` must always win over component display rules (.field, .card, .row…) */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--font-b);
  overflow-x: hidden;
  background-image:
    radial-gradient(1200px 700px at 80% -10%, rgba(40, 90, 255, 0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 30%, rgba(255, 47, 174, 0.06), transparent 60%);
}
a { color: var(--serpent); text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-d); font-weight: 600; letter-spacing: 0.01em; line-height: 1.12; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.1rem, 4.6vw, 3.6rem); }
h1 em { font-style: normal; color: var(--serpent); text-shadow: var(--glow); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
small { color: var(--muted); }
code, kbd, .mono { font-family: var(--font-m); font-size: 0.88em; }
kbd { border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 0.35em; background: #0f171d; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--serpent); color: #000; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--serpent); outline-offset: 2px; }
.noscript { padding: 2rem; text-align: center; }

/* ------------------------------------------------------------------ loader */
.loader { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; gap: 12px; justify-items: center;
  background: var(--bg); transition: opacity 0.8s ease, visibility 0.8s; }
.loader.done { opacity: 0; visibility: hidden; }
.loader-coil svg { width: 96px; height: 96px; fill: none; stroke: var(--serpent); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 60 300; animation: coil 1.6s linear infinite; filter: drop-shadow(0 0 8px var(--serpent)); }
@keyframes coil { to { stroke-dashoffset: -360; } }
.loader-text { font-family: var(--font-m); color: var(--ink-2); letter-spacing: 0.08em; font-size: 0.85rem; text-transform: uppercase; }

/* ------------------------------------------------------------------ HUD */
.hud { position: fixed; top: 0; left: 0; right: 0; height: var(--hud-h); z-index: 50; display: flex; align-items: center; gap: 14px;
  padding: 0 14px 0 16px; background: linear-gradient(180deg, rgba(5, 7, 10, 0.92), rgba(5, 7, 10, 0.55));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand svg { width: 30px; height: 30px; flex: none; fill: #05070a; stroke: var(--serpent); stroke-width: 4; filter: drop-shadow(0 0 6px var(--serpent)); }
.brand .brand-s { fill: none; stroke-linecap: round; }
.brand span { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand b { font-family: var(--font-d); letter-spacing: 0.14em; font-size: 0.92rem; }
.brand i { font-style: normal; font-family: var(--font-m); font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.hud-chapter { flex: 1; text-align: center; font-family: var(--font-m); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-chapter b { color: var(--serpent); font-weight: 600; }
.hud-controls { display: flex; gap: 4px; }
.hud-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink-2); }
.hud-btn:hover { border-color: var(--line-2); color: var(--ink); }
.hud-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hud-btn[aria-pressed="true"] { color: var(--serpent); }
.hud-btn[aria-pressed="false"] { color: var(--muted); }
#btn-voice .slash { display: none; }
#btn-voice[aria-pressed="false"] .slash { display: inline; }
#btn-voice[aria-pressed="false"] .wave { display: none; }
.hud-menu { display: none; }

/* ------------------------------------------------------------------ spine nav */
.spine { position: fixed; left: 0; top: var(--hud-h); bottom: 0; width: 64px; z-index: 40; display: flex; flex-direction: column; justify-content: center; }
.spine-body { position: absolute; left: 12px; top: 4%; height: 92%; width: 40px; overflow: visible; }
.spine-body path { fill: none; stroke: color-mix(in srgb, var(--serpent) 35%, transparent); stroke-width: 2; stroke-dasharray: 3 7; }
.spine ol { list-style: none; margin: 0; padding: 0; position: relative; display: flex; flex-direction: column; justify-content: space-between; height: 86%; }
.spine li a { display: flex; align-items: center; gap: 12px; padding: 4px 0 4px 22px; text-decoration: none; color: var(--muted); font-family: var(--font-m); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.spine li a i { width: 12px; height: 12px; flex: none; transform: rotate(45deg); border: 1.5px solid currentColor; background: var(--bg); transition: all 0.3s; }
.spine li a span { opacity: 0; transform: translateX(-6px); transition: all 0.25s; background: rgba(5, 7, 10, 0.85); padding: 2px 8px; border-radius: 6px; pointer-events: none; }
.spine:hover li a span, .spine li a:focus-visible span { opacity: 1; transform: none; }
.spine li.seen a { color: var(--ink-2); }
.spine li.now a { color: var(--serpent); }
.spine li.now a i { background: var(--serpent); box-shadow: var(--glow); transform: rotate(45deg) scale(1.25); }

/* ------------------------------------------------------------------ chapters */
main { padding-left: 64px; }
.chapter { position: relative; min-height: 100vh; min-height: 100svh; border-top: 1px solid var(--line); }
.stage-chapter { display: grid; grid-template-columns: minmax(360px, 40%) 1fr; }
.stage-chapter .panel { grid-column: 1; grid-row: 1; padding: calc(var(--hud-h) + 40px) clamp(20px, 3vw, 44px) 120px; }
.stage-slot { grid-column: 2; grid-row: 1; position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  background: radial-gradient(ellipse at 50% 60%, #0d1418, #05070a 70%); }
.stage-slot::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, var(--bg) 0, transparent 8%), linear-gradient(0deg, rgba(5,7,10,0.6), transparent 18%); }
.stage-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; touch-action: none; outline: none; }
.flat-chapter .panel.wide { max-width: 1240px; margin: 0 auto; padding: calc(var(--hud-h) + 40px) clamp(16px, 3vw, 40px) 120px; }
.hero .panel { display: flex; flex-direction: column; justify-content: center; }
.kicker { font-family: var(--font-m); font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--serpent); margin-bottom: 1.2em; }
.lede { font-size: 1.1rem; color: var(--ink-2); max-width: 36em; }
.fineprint { font-size: 0.8rem; color: var(--muted); max-width: 38em; margin-top: 1.4em; }
.chapter-num { font-family: var(--font-m); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.2em; text-transform: uppercase; display: flex; align-items: center; gap: 10px; margin-bottom: 0.8em; }
.chapter-num::after { content: ''; height: 1px; flex: 1; background: linear-gradient(90deg, var(--line-2), transparent); }
.intro { color: var(--ink-2); }

/* ------------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(14, 22, 28, 0.9);
  cursor: pointer; font-family: var(--font-d); font-weight: 500; letter-spacing: 0.03em; transition: border-color 0.2s, background 0.2s, transform 0.1s, box-shadow 0.2s; text-align: left; }
.btn:hover { border-color: var(--serpent); }
.btn:active { transform: translateY(1px); }
.btn small { display: block; font-family: var(--font-b); font-weight: 400; font-size: 0.72rem; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: color-mix(in srgb, var(--serpent) 16%, #081014); border-color: var(--serpent); box-shadow: var(--glow); }
.btn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--serpent); box-shadow: var(--glow); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.86rem; border-radius: 10px; }
.btn.done { border-color: var(--ok); color: var(--ok); }
.cta-row, .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 1rem 0; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
.seg button { min-height: 38px; padding: 6px 12px; border: 0; background: transparent; cursor: pointer; font-family: var(--font-d); font-size: 0.86rem; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--serpent) 20%, transparent); color: var(--ink); }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.92rem; min-height: 38px; }
.toggle input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 12px; background: #1a252c; border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background 0.2s; margin: 0; flex: none; }
.toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-2); transition: transform 0.2s, background 0.2s; }
.toggle input:checked { background: color-mix(in srgb, var(--serpent) 35%, #0a1410); }
.toggle input:checked::after { transform: translateX(18px); background: var(--serpent); }
.field { display: grid; gap: 4px; margin: 0.6rem 0; }
.field label, .field .lbl { display: flex; justify-content: space-between; font-size: 0.84rem; color: var(--ink-2); }
.field output, .field .val { font-family: var(--font-m); color: var(--ink); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--serpent), #1b2a31); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: #1b2a31; }
input[type="range"]::-moz-range-progress { height: 4px; background: var(--serpent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 6px; transform: rotate(45deg); background: var(--bg); border: 2px solid var(--serpent); box-shadow: var(--glow); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 6px; background: var(--bg); border: 2px solid var(--serpent); }
select { font: inherit; color: var(--ink); background: #0e161c; border: 1px solid var(--line-2); border-radius: 10px; min-height: 38px; padding: 4px 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 1rem 0; }
.card h3 { margin-bottom: 0.4em; }
.card.warn { border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.card.warn h4, .card.warn h3 { color: var(--amber); }
.note { font-size: 0.84rem; color: var(--ink-2); border-left: 2px solid var(--line-2); padding-left: 12px; margin: 0.8rem 0; }
.note.conflict { border-left-color: var(--amber); }
.note.unconfirmed { border-left-color: var(--venom); }
.badge { display: inline-block; font-family: var(--font-m); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; border: 1px solid currentColor; vertical-align: middle; }
.badge.official, .tag-off { color: #7fd1ff; }
.badge.beyond { color: var(--venom); }
.tag-sim, .tag-meas { font-family: var(--font-m); font-size: 0.68rem; letter-spacing: 0.12em; padding: 1px 6px; border-radius: 5px; border: 1px solid currentColor; white-space: nowrap; }
.tag-sim { color: var(--sim); }
.tag-meas { color: var(--meas); }
.cite { display: inline-block; font-family: var(--font-m); font-size: 0.66rem; line-height: 1.5; padding: 0 5px; margin: 0 1px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--ink-2); text-decoration: none; vertical-align: 1px; white-space: nowrap; }
.cite:hover { color: var(--serpent); border-color: var(--serpent); }
.cite-measured { border-color: color-mix(in srgb, var(--meas) 45%, transparent); }
.cite-official { border-color: rgba(127, 209, 255, 0.4); }
.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 1rem 0; }
.spec { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(8, 13, 17, 0.8); }
.spec b { display: block; font-family: var(--font-d); font-size: 1.25rem; color: var(--ink); font-weight: 600; }
.spec span { font-size: 0.76rem; color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 0.8rem 0; }
.checklist li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 0.93rem; }
.checklist li::before { content: ''; width: 10px; height: 10px; margin-top: 0.5em; flex: none; transform: rotate(45deg); border: 1.5px solid var(--muted); }
.checklist li.done::before { background: var(--serpent); border-color: var(--serpent); box-shadow: var(--glow); }
.checklist li.add::before { border-color: var(--amber); }

/* steps */
.steps { list-style: none; padding: 0; margin: 1rem 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 10px 12px 10px 48px; border: 1px solid var(--line); border-radius: 12px; margin: 6px 0; background: rgba(8, 13, 17, 0.7); transition: border-color 0.3s, background 0.3s; }
.steps li::before { content: counter(s); position: absolute; left: 12px; top: 10px; width: 24px; height: 24px; display: grid; place-items: center; font-family: var(--font-m); font-size: 0.8rem; border: 1px solid var(--line-2); border-radius: 7px; }
.steps li.now { border-color: var(--serpent); background: color-mix(in srgb, var(--serpent) 8%, #081014); }
.steps li.now::before { background: var(--serpent); color: #000; border-color: var(--serpent); }
.steps li.done { opacity: 0.6; }
.steps li.done::before { content: '\2713'; color: var(--ok); border-color: var(--ok); }
.steps li b { font-family: var(--font-d); }
.steps li p { margin: 2px 0 0; font-size: 0.86rem; color: var(--ink-2); }
.progress { height: 4px; background: #16222a; border-radius: 2px; overflow: hidden; margin: 0.6rem 0; }
.progress i { display: block; height: 100%; width: 0; background: var(--serpent); box-shadow: var(--glow); transition: width 0.4s; }

/* ------------------------------------------------------------------ labels on the stage */
.label-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.tag { position: absolute; left: 0; top: 0; pointer-events: auto; display: none; align-items: center; gap: 6px; padding: 0; border: 0; background: none; cursor: pointer; will-change: transform; }
.tag.on { display: flex; }
.tag i { width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--serpent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--serpent) 25%, transparent), var(--glow); animation: pulse 2.2s infinite; flex: none; }
.tag span { margin-top: -6px; font-family: var(--font-m); font-size: 0.68rem; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 7px; background: rgba(5, 8, 11, 0.86); border: 1px solid var(--line-2); color: var(--ink); white-space: nowrap; }
.tag.flip { flex-direction: row-reverse; }
.tag.flip i { margin: -6px -6px 0 0; }
.tag.flip span { transform: translateX(calc(-100% - 18px)); position: absolute; left: 0; }
.tag.sel span { border-color: var(--serpent); color: var(--serpent); }
.label-card { position: absolute; left: 16px; right: 16px; bottom: 18px; max-width: 420px; margin-left: auto; pointer-events: auto; background: rgba(8, 12, 16, 0.94); border: 1px solid var(--serpent); border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.6), var(--glow); transform: translateY(12px); opacity: 0; visibility: hidden; transition: all 0.25s; font-size: 0.9rem; }
.label-card.open { transform: none; opacity: 1; visibility: visible; }
.label-card h4 { color: var(--serpent); margin-right: 30px; }
.label-card p { margin: 0; color: var(--ink-2); }
.card-x { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: transparent; cursor: pointer; font-size: 1.1rem; }
.stage-hint { position: absolute; left: 50%; top: calc(var(--hud-h) + 14px); transform: translateX(-50%); z-index: 3; font-family: var(--font-m); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); background: rgba(5,7,10,0.7); border: 1px solid var(--line); padding: 5px 12px; border-radius: 20px; pointer-events: none; white-space: nowrap; }
.stage-actions { position: absolute; z-index: 4; right: 16px; bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; max-width: 70%; }

/* ------------------------------------------------------------------ still mode (no WebGL) */
.still { position: absolute; inset: 0; margin: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 60%, #0d1418, #05070a 70%); }
.still-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 0; transition: opacity 0.7s ease; }
.still-img.on { opacity: 1; animation: still-breathe 9s ease-in-out infinite; }
@keyframes still-breathe { 50% { filter: brightness(1.08) saturate(1.05); } } /* no transform: labels stay pinned */
.still::before { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(3, 5, 7, 0.55)), repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px); }
.still::after { content: ''; position: absolute; left: -20%; right: -20%; bottom: 0; height: 40%; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 100%, color-mix(in srgb, var(--serpent) 10%, transparent), transparent 70%); animation: pulse 6s ease-in-out infinite; }
.still .label-layer { z-index: 3; }
.still-tint { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: var(--tint, #2255ff); mix-blend-mode: color; opacity: 0.9; }
.still-tint[data-style="Breathing"] { animation: tint-breathe var(--period, 3s) ease-in-out infinite; }
.still-tint[data-style="Strobing"] { animation: tint-strobe calc(var(--period, 3s) / 4) steps(1) infinite; }
.still-tint[data-style="Pulsing"] { animation: tint-pulse var(--period, 3s) ease-out infinite; }
.still-tint[data-style="Beyond"] { animation: tint-hue calc(var(--period, 3s) * 2) linear infinite; }
.still-tint[data-style="Off"] { background: #020304; mix-blend-mode: multiply; opacity: 0.94; }
@keyframes tint-breathe { 50% { opacity: 0.25; } }
@keyframes tint-strobe { 50% { opacity: 0; } }
@keyframes tint-pulse { 0% { opacity: 0.95; } 25%, 100% { opacity: 0.15; } }
@keyframes tint-hue { to { filter: hue-rotate(360deg); } }
.still-chip { position: absolute; z-index: 4; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: calc(100% - 32px);
  font-family: var(--font-m); font-size: 0.64rem; letter-spacing: 0.08em; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 5px 12px 5px 22px; border-radius: 20px; background: rgba(5, 8, 11, 0.72); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.still-chip::before { content: ''; position: absolute; left: 10px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--serpent); opacity: 0.7; }
.still ~ .label-card, .still .label-card { bottom: 50px; }
@media (max-width: 820px) { .still-chip { bottom: 10px; font-size: 0.58rem; } }

/* lab at rest (no WebAssembly) */
.lab-rest { display: flex; gap: 16px; align-items: center; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line);
  background: radial-gradient(ellipse at 0% 50%, color-mix(in srgb, var(--sim) 10%, transparent), transparent 60%), var(--panel); }
.lab-rest h3 { margin: 0 0 0.3em; color: var(--ink); }
.lab-rest p { margin: 0; color: var(--ink-2); font-size: 0.9rem; }
.rest-coil svg { width: 96px; height: 48px; fill: none; stroke: var(--sim); stroke-width: 3; stroke-linecap: round; opacity: 0.8; filter: drop-shadow(0 0 6px var(--sim)); animation: pulse 4.5s ease-in-out infinite; }
.lab-grid.resting .lab-col:first-child .card:last-child { opacity: 0.45; pointer-events: none; }
.lab-grid.resting .wl-list { opacity: 0.45; pointer-events: none; }
.lab-grid.resting .cores { opacity: 0.55; filter: saturate(0.4); }
.lab-grid.resting .chart { opacity: 0.35; }

/* ------------------------------------------------------------------ captions */
.captions { position: fixed; z-index: 60; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); width: min(760px, calc(100% - 32px)); transform: translate(-50%, 20px);
  background: rgba(4, 7, 9, 0.92); border: 1px solid var(--line-2); border-radius: 16px; padding: 12px 18px 14px; opacity: 0; visibility: hidden; transition: all 0.35s; box-shadow: 0 20px 60px rgba(0,0,0,0.6); pointer-events: none; }
.captions.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.cap-speaker { font-family: var(--font-m); font-size: 0.62rem; letter-spacing: 0.22em; color: var(--serpent); }
.cap-text { margin: 4px 0 0; font-size: 1.02rem; line-height: 1.5; color: var(--muted); }
.cap-text span.lit { color: var(--ink); }

/* ------------------------------------------------------------------ port map */
.portmap { display: grid; gap: 16px; }
.panel-view { background: linear-gradient(180deg, #0c1318, #070b0e); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel-view h3 { display: flex; justify-content: space-between; align-items: baseline; font-size: 1rem; }
.panel-view svg { width: 100%; height: auto; display: block; }
.pm-face { fill: #11181e; stroke: #2a363d; stroke-width: 0.6; }
.pm-grille { fill: url(#perf); }
.pm-port { cursor: pointer; }
.pm-port rect, .pm-port circle, .pm-port polygon { transition: all 0.2s; }
.pm-port .hit { fill: transparent; stroke: transparent; }
.pm-port:hover .shape, .pm-port:focus-visible .shape { stroke: var(--serpent); stroke-width: 0.8; filter: drop-shadow(0 0 2px var(--serpent)); }
.pm-port.sel .shape { stroke: var(--serpent); stroke-width: 1; }
.pm-port.lvl-best .shape { stroke: var(--ok); stroke-width: 1.2; }
.pm-port.lvl-ok .shape { stroke: #7fd1ff; stroke-width: 1.2; }
.pm-port.lvl-limited .shape, .pm-port.lvl-maybe .shape { stroke: var(--amber); stroke-width: 1.2; }
.pm-port.lvl-no .shape { opacity: 0.35; }
.pm-label { font-family: var(--font-m); font-size: 3px; fill: var(--muted); pointer-events: none; }
.pm-gpu-arc { fill: #7fd1ff; }
.pm-gpu-iris { fill: var(--venom); }
.pm-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.devices { display: flex; flex-wrap: wrap; gap: 8px; }
.device { display: inline-flex; gap: 8px; align-items: center; min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #0d151a; cursor: pointer; font-size: 0.86rem; }
.device[aria-pressed="true"] { border-color: var(--serpent); background: color-mix(in srgb, var(--serpent) 12%, #0d151a); box-shadow: var(--glow); }
.device b { font-family: var(--font-m); color: var(--serpent); }
.verdict { border-radius: 12px; padding: 12px 14px; margin: 10px 0; border: 1px solid var(--line-2); font-size: 0.92rem; }
.verdict.best { border-color: var(--ok); } .verdict.ok { border-color: #7fd1ff; } .verdict.limited, .verdict.maybe { border-color: var(--amber); } .verdict.no { border-color: var(--danger); }
.verdict strong { font-family: var(--font-d); text-transform: uppercase; letter-spacing: 0.06em; }
.plan { list-style: none; padding: 0; margin: 0; font-size: 0.88rem; }
.plan li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.gpu-chip { font-family: var(--font-m); font-size: 0.68rem; padding: 1px 6px; border-radius: 5px; }
.gpu-chip.arc { color: #7fd1ff; border: 1px solid #7fd1ff; } .gpu-chip.iris { color: var(--venom); border: 1px solid var(--venom); }

/* ------------------------------------------------------------------ lab */
.lab-grid { display: grid; grid-template-columns: 300px 1fr 330px; gap: 16px; align-items: start; }
.lab-col { display: grid; gap: 12px; }
.wl-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wl { text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #0b1216; padding: 8px 10px; cursor: pointer; min-height: 52px; }
.wl b { display: block; font-family: var(--font-d); font-size: 0.9rem; }
.wl small { font-size: 0.7rem; line-height: 1.3; display: block; }
.wl[aria-pressed="true"] { border-color: var(--serpent); background: color-mix(in srgb, var(--serpent) 10%, #0b1216); }
.cores { display: grid; gap: 10px; }
.cores h4 { font-size: 0.78rem; font-family: var(--font-m); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0; display: flex; justify-content: space-between; }
.pgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.egrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.core { border: 1px solid var(--line-2); border-radius: 10px; padding: 6px; background: #081014; position: relative; }
.core.e { border-color: rgba(185, 140, 255, 0.28); }
.core header { display: flex; justify-content: space-between; font-family: var(--font-m); font-size: 0.6rem; color: var(--muted); margin-bottom: 4px; }
.lanes { display: grid; gap: 3px; }
.lane { height: 26px; border-radius: 5px; background: #111b21; position: relative; overflow: hidden; }
.core.e .lane { height: 55px; }
.lane i { position: absolute; left: 0; bottom: 0; top: 0; width: 0; transition: width 0.25s, background 0.25s; }
.lane.foreground i { background: var(--serpent); } .lane.throughput i { background: #3ba4ff; } .lane.burst i { background: var(--amber); } .lane.background i { background: var(--sim); }
.lane b { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-family: var(--font-m); font-size: 0.56rem; color: rgba(255,255,255,0.8); font-weight: 400; }
.core .ghz { font-family: var(--font-m); font-size: 0.62rem; text-align: center; margin-top: 4px; color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.72rem; color: var(--ink-2); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.meter { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: #081014; }
.meter span { display: block; font-size: 0.66rem; color: var(--muted); font-family: var(--font-m); letter-spacing: 0.06em; text-transform: uppercase; }
.meter b { font-family: var(--font-d); font-size: 1.3rem; font-weight: 600; }
.meter b small { font-size: 0.7rem; margin-left: 2px; }
.meter.hot b { color: var(--danger); }
.meter .bar { height: 3px; background: #16222a; border-radius: 2px; margin-top: 4px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--serpent); transition: width 0.3s; }
.chart { width: 100%; height: 150px; display: block; border: 1px solid var(--line); border-radius: 12px; background: #070c0f; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.7rem; color: var(--ink-2); font-family: var(--font-m); margin: 4px 2px 10px; }
.chart-legend span::before { content: ''; display: inline-block; width: 14px; height: 2px; margin-right: 5px; vertical-align: 3px; background: var(--c); }
.headline-metric { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.headline-metric b { font-family: var(--font-d); font-size: 2.4rem; color: var(--sim); text-shadow: 0 0 20px rgba(185,140,255,0.4); line-height: 1; }
.event-log { font-family: var(--font-m); font-size: 0.72rem; color: var(--ink-2); max-height: 120px; overflow: auto; border-top: 1px dashed var(--line); padding-top: 6px; }
.event-log p { margin: 0 0 3px; }
.event-log p::before { content: '> '; color: var(--serpent); }
.measured h3 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.bars { display: grid; gap: 10px; }
.bench h5 { margin: 0 0 4px; font-size: 0.8rem; font-family: var(--font-b); font-weight: 600; color: var(--ink); }
.bench .brow { display: grid; grid-template-columns: 112px 1fr 58px; gap: 6px; align-items: center; font-size: 0.7rem; color: var(--ink-2); margin: 2px 0; }
.bench .brow .track { height: 9px; background: #121c22; border-radius: 3px; overflow: hidden; }
.bench .brow .track i { display: block; height: 100%; background: #3a4a52; border-radius: 3px; transition: width 0.8s cubic-bezier(.2,.8,.2,1); }
.bench .brow.me { color: var(--meas); font-weight: 600; }
.bench .brow.me .track i { background: var(--meas); box-shadow: 0 0 10px rgba(255,200,87,0.4); }
.bench .brow .v { font-family: var(--font-m); text-align: right; }
.bench .bnote { font-size: 0.7rem; color: var(--muted); margin: 2px 0 0; }

/* ------------------------------------------------------------------ BIOS */
.boot-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 20px; align-items: start; }
.monitor { background: #020304; border: 10px solid #151b20; border-bottom-width: 22px; border-radius: 14px; aspect-ratio: 16 / 10; position: relative; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.7), inset 0 0 60px rgba(0,0,0,0.9); }
.monitor::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px); }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; font-family: var(--font-m); font-size: clamp(0.62rem, 1.2vw, 0.82rem); color: #cfe; }
.screen.off { background: #000; }
.splash { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; background: #000; }
.splash svg { width: 28%; min-width: 90px; fill: none; stroke: var(--serpent); stroke-width: 3; filter: drop-shadow(0 0 10px var(--serpent)); }
.splash .hint { color: #8aa; font-size: 0.9em; }
.bios { flex: 1; display: grid; grid-template-rows: auto auto 1fr auto; background: linear-gradient(180deg, #06121a, #030a0f); }
.bios-top { display: flex; justify-content: space-between; padding: 6px 10px; background: #0a2230; color: #9fe; font-size: 0.9em; }
.bios-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid #16404f; scrollbar-width: none; }
.bios-tabs button { flex: none; background: transparent; border: 0; color: #7ab; padding: 6px 10px; font: inherit; cursor: pointer; }
.bios-tabs button[aria-selected="true"] { background: #16404f; color: #fff; }
.bios-body { display: grid; grid-template-columns: 1.3fr 1fr; min-height: 0; }
.bios-items { overflow: auto; padding: 4px 0; }
.bios-item { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 4px 10px; border: 0; background: transparent; color: #bdd; font: inherit; text-align: left; cursor: pointer; }
.bios-item .v { color: #5fe; white-space: nowrap; }
.bios-item[aria-current="true"] { background: #1a5266; color: #fff; }
.bios-item.ro { color: #789; cursor: default; }
.bios-help { border-left: 1px solid #16404f; padding: 8px 10px; color: #9bb; overflow: auto; font-size: 0.92em; line-height: 1.45; }
.bios-help .src { color: #5a8; font-size: 0.9em; margin-top: 6px; display: block; }
.bios-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 5px 10px; background: #0a2230; color: #8bc; font-size: 0.85em; }
.pbm { flex: 1; background: #000; padding: 6% 8%; color: #cde; }
.pbm p { margin: 0 0 0.4em; }
.pbm button { background: none; border: 0; color: #5fe; font: inherit; cursor: pointer; padding: 1px 0; text-align: left; display: block; }
.keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.keys button { min-width: 48px; min-height: 40px; border-radius: 8px; border: 1px solid var(--line-2); border-bottom-width: 3px; background: #0e161c; font-family: var(--font-m); cursor: pointer; }
.keys button:active { transform: translateY(2px); border-bottom-width: 1px; }
.hold { position: relative; width: 84px; height: 84px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; touch-action: none; }
.hold svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.hold circle { fill: none; stroke-width: 4; }
.hold .bgc { stroke: #1a252c; } .hold .fgc { stroke: var(--serpent); stroke-dasharray: 251; stroke-dashoffset: 251; }
.hold .hex { position: absolute; inset: 18px; clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); background: #10181d; display: grid; place-items: center; border: 0; }
.hold .hex::after { content: ''; width: 18px; height: 18px; border: 2px solid var(--amber); border-top-color: transparent; border-radius: 50%; }
.hold.blink .hex { animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { background: #3a2c08; } }

/* ------------------------------------------------------------------ everyday + ledger */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cards .card { margin: 0; }
.quiz .q { margin: 12px 0; }
.quiz .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.quiz .opts button { min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #0d151a; cursor: pointer; text-align: left; }
.quiz .opts button.right { border-color: var(--ok); color: var(--ok); }
.quiz .opts button.wrong { border-color: var(--danger); color: var(--danger); }
.quiz .why { font-size: 0.84rem; color: var(--ink-2); margin-top: 4px; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.ledger th, table.ledger td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ledger th { font-family: var(--font-m); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.srclist { list-style: none; padding: 0; columns: 2 320px; column-gap: 24px; }
.srclist li { break-inside: avoid; margin: 0 0 10px; font-size: 0.86rem; }
.pixel-grid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; width: min(100%, 300px); aspect-ratio: 1; touch-action: none; user-select: none; background: #0a1115; padding: 4px; border-radius: 10px; border: 1px solid var(--line-2); }
.pixel-grid i { background: #141d23; border-radius: 2px; }
.pixel-grid i.on { background: var(--serpent); box-shadow: 0 0 6px var(--serpent); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 38px; height: 38px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; background: var(--c); box-shadow: inset 0 0 0 2px rgba(0,0,0,0.4); }
.swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 14px var(--c); }
.zone-tabs { margin-bottom: 8px; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 40px 16px 120px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .lab-grid { grid-template-columns: 1fr 1fr; }
  .lab-grid .lab-mid { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 980px) {
  .pm-layout, .boot-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  :root { --hud-h: 54px; }
  main { padding-left: 0; }
  .brand i { display: none; }
  .hud { gap: 8px; padding: 0 8px 0 12px; }
  .hud-chapter { display: none; }
  .hud-btn { width: 38px; height: 38px; }
  .hud-menu { display: grid; }
  .spine { top: var(--hud-h); left: auto; right: 0; bottom: auto; width: min(300px, 86vw); height: calc(100svh - var(--hud-h)); background: rgba(5, 8, 11, 0.97); border-left: 1px solid var(--line); transform: translateX(105%); transition: transform 0.3s; padding: 20px 10px; }
  .spine.open { transform: none; }
  .spine ol { height: auto; gap: 4px; }
  .spine li a { padding: 10px 12px; font-size: 0.8rem; }
  .spine li a span { opacity: 1; transform: none; background: none; }
  .spine-body { display: none; }
  .stage-chapter { display: block; }
  .stage-slot { position: sticky; top: var(--hud-h); height: 48svh; z-index: 2; border-bottom: 1px solid var(--line); }
  .stage-slot::after { background: linear-gradient(0deg, rgba(5,7,10,0.8), transparent 20%); }
  .stage-chapter .panel { padding: 22px 16px 110px; position: relative; z-index: 1; }
  .hero .stage-slot { height: 44svh; }
  .flat-chapter .panel.wide { padding: calc(var(--hud-h) + 24px) 16px 110px; }
  .lab-grid { grid-template-columns: 1fr; }
  .meters { grid-template-columns: repeat(3, 1fr); }
  .pgrid { grid-template-columns: repeat(3, 1fr); }
  .egrid { grid-template-columns: repeat(4, 1fr); }
  .core.e .lane { height: 30px; }
  .label-card { left: 10px; right: 10px; bottom: 10px; font-size: 0.84rem; }
  .stage-actions { right: 10px; bottom: 10px; max-width: 94%; }
  .bios-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .bios-help { border-left: 0; border-top: 1px solid #16404f; max-height: 5.5em; }
  .captions { bottom: max(10px, env(safe-area-inset-bottom)); padding: 10px 14px; }
  .cap-text { font-size: 0.92rem; }
  .bench .brow { grid-template-columns: 90px 1fr 50px; }
  .tag span { font-size: 0.62rem; }
}
@media (max-width: 420px) {
  .wl-list { grid-template-columns: 1fr; }
  .meters { grid-template-columns: repeat(2, 1fr); }
}
