:root {
  /* lab instrument theme: deep blue-black, cyan signal, amber caution */
  --bg: #0a0d12; --fg: #e3e8ef; --muted: #8a94a3; --card: #10151c; --card2: #0d1218; --line: #1f2833; --line2: #2b3644;
  --accent: #3fb6ff; --accent2: #7fe3ff; --ok: #3ddc97; --mid: #ffb547; --bad: #ff5d5d; --err: #ff5d5d; --stage: #000;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* #login/#lab set display, which would override the hidden attribute */
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 12.5px; }
.fine { font-size: 11px; margin: 6px 0 0; }
.error { color: var(--err); min-height: 1.2em; }
a { color: var(--accent); }
button { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent); background: linear-gradient(180deg, #2d9ff0, #1f7fd0); color: #fff; cursor: pointer; }
button:hover { filter: brightness(1.12); }
button.ghost { background: transparent; color: var(--fg); border-color: var(--line2); }
button.ghost:hover { border-color: var(--accent); color: var(--accent2); }
button.icon { padding: 0 7px; font-size: 13px; line-height: 22px; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line2); border-radius: 6px; background: var(--card2); color: var(--fg); }

#login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(63,182,255,.08), transparent 60%), var(--bg); }
.card { width: min(360px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px; display: grid; gap: 12px; }
.card h1 { margin: 0 0 4px; font-size: 20px; }
.card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

#lab { height: 100%; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #121922, #0d1218); }
header strong { letter-spacing: .5px; }
header strong::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; background: var(--accent); box-shadow: 0 0 8px var(--accent); vertical-align: 1px; }
.spacer { flex: 1; }
.badge:empty { display: none; }
.badge { font: 11px var(--mono); padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line2); color: var(--accent2); text-transform: uppercase; letter-spacing: 1px; }

.split { flex: 1; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 640px); min-height: 0; }
.stage { background: var(--stage); color: #fff; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.stage-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid #1a1f26; font-size: 13px; }
.stage-bar button.ghost { color: #ddd; border-color: #333b46; }
.stage-bar button:disabled { opacity: 0.4; cursor: default; }
.stage .muted { color: #8a8f98; }
.stage:fullscreen .stage-bar { position: absolute; top: 0; right: 0; opacity: 0.25; border: 0; }
.stage:fullscreen .stage-bar:hover { opacity: 1; }

/* ---- console: instrument panels on a faint lab grid ---- */
.console { display: flex; flex-direction: column; gap: 10px; padding: 12px; overflow: auto; border-left: 1px solid var(--line);
  background:
    linear-gradient(rgba(63,182,255,.035) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(63,182,255,.035) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg); }
.panel { position: relative; background: linear-gradient(180deg, var(--card), var(--card2)); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; }
/* corner brackets: instrument bezel */
.panel::before, .panel::after { content: ""; position: absolute; width: 10px; height: 10px; border: 1px solid var(--accent); opacity: .55; pointer-events: none; }
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.panel.grow { flex: 1; min-height: 180px; display: flex; flex-direction: column; }
.p-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.panel h2 { margin: 0; font: 600 11px var(--mono); letter-spacing: 2px; text-transform: uppercase; color: var(--accent2); }
.cap { display: block; font: 10.5px var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 6px 0 3px; }
.cap .mono { text-transform: none; letter-spacing: 0; color: var(--fg); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.small { padding: 0 9px; font-size: 12px; line-height: 22px; }

/* experiment picker + card */
.exp-select { font-size: 14px; padding: 8px 10px; border-color: var(--line2); background: #0b1016; }
.exp-select:focus { outline: 1px solid var(--accent); }
.exp-select optgroup { color: var(--accent2); font-style: normal; }
.exp-select option { color: var(--fg); }
.exp-card { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.exp-desc { margin: 0; color: #c3cad4; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font: 11px var(--mono); padding: 2px 8px; border-radius: 4px; border: 1px solid var(--line2); color: var(--fg); background: #0b1016; }
.chip.gen { border-color: rgba(63,182,255,.5); color: var(--accent2); }
.chip.dsp { border-color: rgba(61,220,151,.45); color: var(--ok); }
.chip.atk { border-color: rgba(255,93,93,.5); color: var(--bad); }
.chip.meta { color: var(--muted); }
.exp-meta { font-size: 12px; }
.exp-meta button { vertical-align: 1px; }
.exp-actions { display: flex; align-items: center; gap: 6px; }
.exp-actions button.small { margin: 0; }
.pill { font: 600 11px var(--mono); letter-spacing: 1px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line2); text-decoration: none; color: var(--accent2); }
.pill:hover { border-color: var(--accent); background: rgba(63,182,255,.08); }

/* instrument grid: compact panels, never stretched across the console */
.instruments { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.inst.wide { grid-column: 1 / -1; }
.disp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 16px; align-items: start; }
.inst-row { display: flex; gap: 12px; align-items: center; }
.inst-col { flex: 1; min-width: 0; }
.kv { font-size: 12px; flex: 1; min-width: 0; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 4px; border: 1px solid var(--line2); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.tag[data-state="created"], .tag[data-state="displayed"], .tag[data-state="captured"], .tag[data-state="submitted"] { color: var(--accent2); border-color: rgba(63,182,255,.5); }
.tag[data-state="verified"] { color: var(--ok); border-color: var(--ok); }
.tag[data-state="rejected"], .tag[data-state="expired"], .tag[data-state="aborted"] { color: var(--bad); border-color: var(--bad); }
.led-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.led { width: 9px; height: 9px; border-radius: 50%; background: #39424e; display: inline-block; }
.led[data-tone="ok"] { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.led[data-tone="mid"] { background: var(--mid); box-shadow: 0 0 8px var(--mid); animation: blink 1.2s infinite; }
.led[data-tone="bad"] { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
@keyframes blink { 50% { opacity: .35; } }
.readouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.readouts > div { background: #0a0f15; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px 6px; }
.readouts .cap { margin: 0 0 2px; }
.readouts b { font-size: 20px; font-weight: 600; color: var(--accent2); }
.readouts small { margin-left: 4px; color: var(--muted); font-size: 11px; }
[data-tone="ok"] { --tone: var(--ok); } [data-tone="mid"] { --tone: var(--mid); } [data-tone="bad"] { --tone: var(--bad); }
.readouts b[data-tone], #d-std[data-tone], #d-cal[data-tone] { color: var(--tone, inherit); }

/* gauges (gauges.js) */
.g-ring { display: block; flex: none; }
.g-ring .g-track { stroke: #19222d; }
.g-ring .g-ticks line { stroke: #2b3644; stroke-width: 1; }
.g-ring .g-arc { stroke: var(--accent); transition: stroke-dashoffset .1s linear, stroke .3s; filter: drop-shadow(0 0 4px rgba(63,182,255,.6)); }
.g-ring[data-tone="ok"] .g-arc { stroke: var(--ok); filter: drop-shadow(0 0 4px rgba(61,220,151,.6)); }
.g-ring[data-tone="mid"] .g-arc { stroke: var(--mid); filter: drop-shadow(0 0 4px rgba(255,181,71,.6)); }
.g-ring[data-tone="bad"] .g-arc { stroke: var(--bad); filter: drop-shadow(0 0 4px rgba(255,93,93,.6)); }
.g-big { fill: var(--fg); font: 600 22px var(--mono); }
.g-small { fill: var(--muted); font: 10px var(--mono); letter-spacing: .5px; }
.g-arcg { display: block; flex: none; }
.g-z { stroke-width: 7; opacity: .75; }
.g-z.ok { stroke: var(--ok); } .g-z.mid { stroke: var(--mid); } .g-z.bad { stroke: var(--bad); }
.g-tick { stroke: #4a5664; stroke-width: 1; }
.g-needle { stroke: var(--fg); stroke-width: 2; stroke-linecap: round; transition: transform .35s cubic-bezier(.3,1.4,.6,1); }
.g-hub { fill: var(--accent); }
.g-arcg .g-big { font-size: 18px; }
.g-spark { width: 100%; height: 34px; display: block; background: #0a0f15; border: 1px solid var(--line); border-radius: 4px; }
.g-spark-line { stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.g-spark-area { fill: rgba(63,182,255,.12); }
.g-spark-dot { fill: var(--accent2); }
.g-bar { position: relative; height: 10px; background: #0a0f15; border: 1px solid var(--line); border-radius: 5px; overflow: visible; }
.g-bar-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: 5px; background: var(--tone, var(--accent)); box-shadow: 0 0 8px var(--tone, var(--accent)); transition: width .3s, left .3s; }
.g-bar-thr { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--fg); }
.g-bar-thr::after { content: "std"; position: absolute; top: 15px; left: -7px; font: 9px var(--mono); color: var(--muted); }
#g-module { margin-bottom: 12px; }
.g-bar-zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.g-lights { display: flex; gap: 4px; margin-top: 10px; }
.g-light { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font: 9.5px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.g-light i { width: 100%; height: 5px; border-radius: 3px; background: #19222d; }
.g-light[data-state="done"] i { background: rgba(63,182,255,.55); }
.g-light[data-state="on"] i { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1.2s infinite; }
.g-light[data-state="on"], .g-light[data-state="done"] { color: var(--accent2); }
.g-light[data-state="ok"] i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.g-light[data-state="ok"] { color: var(--ok); }
.g-light[data-state="bad"] i { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.g-light[data-state="bad"] { color: var(--bad); }

/* event stream: terminal */
.log-panel { background: #070a0e; }
#events { list-style: none; margin: 0; padding: 0; font-size: 11.5px; overflow: auto; flex: 1; }
#events li { display: grid; grid-template-columns: 88px 34px 1fr; gap: 8px; padding: 2px 0; border-bottom: 1px solid #10161d; }
#events time { color: #56606d; }
#events b { font-weight: 600; text-transform: uppercase; font-size: 10px; padding-top: 1px; }
#events span { word-break: break-word; color: #c3cad4; }
.t-err { color: var(--bad); } .t-ses { color: var(--accent2); } .t-run { color: var(--ok); } .t-dsp { color: #c59bff; } .t-net { color: var(--mid); } .t-sys { color: var(--muted); }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; grid-template-rows: 70vh auto; }
  .console { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---- experiment builder (drawer over the console) ---- */
.builder { position: fixed; top: 53px; right: 0; bottom: 0; width: min(1100px, 100%); background: var(--bg); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0,0,0,.35); display: flex; flex-direction: column; z-index: 20; }
.b-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.b-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 500px; }
.b-form { overflow: auto; padding: 12px 16px 0; display: flex; flex-direction: column; gap: 12px; }
.b-preview { border-left: 1px solid var(--line); padding: 12px 14px; overflow: auto; }
.b-preview canvas { width: 472px; max-width: 100%; aspect-ratio: 1; background: #000; border-radius: 6px; display: block; }
.b-group { display: flex; flex-direction: column; gap: 10px; }
.b-group h3, .b-card h3, .b-preview h3 { margin: 0; font-size: 14px; }
.b-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.b-card > p.muted { margin: 0; }
.b-card-head { display: flex; align-items: center; gap: 8px; }
.b-card-head select { width: auto; padding: 2px 6px; }
.b-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
.b-fields > .b-fields, .b-fields > .b-adv { grid-column: 1 / -1; }
.b-adv { justify-self: start; }
.b-row { display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 13px; }
.b-row > span { color: var(--muted); }
.b-row small { margin-left: 4px; }
.b-row input, .b-row select, .b-row textarea { padding: 4px 8px; font-size: 13px; }
.b-row input[type=checkbox] { width: auto; justify-self: start; }
.b-checks { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.b-checks input { width: auto; }
.b-note { display: grid; grid-template-columns: 160px 1fr auto; gap: 6px; }
.b-note input { padding: 4px 8px; font-size: 13px; }
.b-status { font-size: 12px; }
.b-status .ok { color: var(--ok); }
.b-status ul { margin: 0; padding-left: 18px; }
.b-foot { position: sticky; bottom: 0; z-index: 2; margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 0; background: var(--bg); border-top: 1px solid var(--line); }
.b-foot button:disabled { opacity: .45; cursor: default; }
.b-foot button { white-space: nowrap; }
@media (max-width: 1000px) { .b-body { grid-template-columns: 1fr; } .b-preview { border-left: 0; border-top: 1px solid var(--line); } }

/* builder: add buttons keep their natural width */
.b-group > button.small, .b-card > button.small { align-self: flex-start; margin-left: 0; }

/* ---- test page (layout.js): challenge at physical size inside a page ---- */
.stage-view { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.test-status { font-size: 12px; padding: 4px 10px; color: #9aa1ab; border-top: 1px solid #222; min-height: 22px; }
.test-status.warn, .ts-badge.warn { color: #ffb74d; }
.tp { position: absolute; inset: 0; overflow: hidden; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.tp-light { background: #f4f6f8; color: #1d2733; --tp-card: #fff; --tp-line: #dde3ea; --tp-muted: #6b7684; --tp-accent: #24507a; }
.tp-dark { background: #0d1014; color: #e6e9ee; --tp-card: #171b21; --tp-line: #2a3039; --tp-muted: #8d96a3; --tp-accent: #6aa4dc; }
.tp-blank.tp-light { background: #ffffff; }
.tp-blank.tp-dark { background: #000; }
.tp-page { position: absolute; inset: 0; display: flex; flex-direction: column; }
.tp-header { display: flex; align-items: center; gap: 24px; padding: 14px 28px; border-bottom: 1px solid var(--tp-line); background: var(--tp-card); }
.tp-logo { font-weight: 700; color: var(--tp-accent); letter-spacing: .2px; }
.tp-nav { color: var(--tp-muted); font-size: 14px; }
.tp-main { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6vw; padding: 24px; flex-wrap: wrap; }
.tp-hero h1 { font-size: clamp(22px, 3vw, 40px); margin: 0 0 8px; font-weight: 600; }
.tp-card { background: var(--tp-card); border: 1px solid var(--tp-line); border-radius: 14px; padding: 26px 30px; width: max-content; min-width: 300px; max-width: 92vw; display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.tp-card-title { font-size: 22px; font-weight: 600; align-self: flex-start; }
.tp-card-gap { height: 8px; }
.tp-muted { color: var(--tp-muted); margin: 0; font-size: 14px; }
.tp-small { font-size: 12px; }
.tp-or { color: var(--tp-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 2px; }
.tp-field { align-self: stretch; border: 1px solid var(--tp-line); border-radius: 8px; padding: 10px 12px; color: var(--tp-muted); font-size: 14px; }
.tp-btn { align-self: stretch; text-align: center; background: var(--tp-accent); color: #fff; border-radius: 8px; padding: 10px; font-size: 14px; }
.tp-footer { padding: 10px 28px; font-size: 12px; color: var(--tp-muted); border-top: 1px solid var(--tp-line); }
.tp-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tp-challenge { display: block; border-radius: 4px; }
.tp-tc { display: block; height: auto; }
.tp-place-center > .tp-slot, .tp-blank > .tp-slot { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tp-place-top_right > .tp-slot { position: absolute; right: 5%; top: 12%; }
.tp-place-bottom_left > .tp-slot { position: absolute; left: 5%; bottom: 10%; }
.tp-blank.tp-place-top_right > .tp-slot, .tp-blank.tp-place-bottom_left > .tp-slot { transform: none; }
.tp-tc-corner { position: absolute; right: 8px; bottom: 8px; opacity: .9; }
.tp-tc-corner .tp-tc { width: 280px; }

/* ---- calibration ---- */
.cal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 50; }
.cal-panel { background: #fff; color: #1d2733; border-radius: 12px; padding: 22px 26px; max-width: min(900px, 94vw); display: flex; flex-direction: column; gap: 12px; }
.cal-panel h2 { margin: 0; }
.cal-card { background: #c9ced6; border: 2px solid #1d2733; border-radius: 3.2mm; box-sizing: border-box; }
.cal-panel input[type=range] { width: 100%; }
.cal-label { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.cal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.cal-panel button.ghost { color: #1d2733; }

/* ---- pop-out test screen ---- */
body.test-screen { background: #000; overflow: hidden; }
.test-view { position: fixed; inset: 0; }
.ts-bar { position: fixed; top: 6px; right: 6px; display: flex; gap: 6px; align-items: center; opacity: .15; transition: opacity .2s; z-index: 40; background: rgba(20,22,26,.85); padding: 4px 6px; border-radius: 8px; }
.ts-bar:hover { opacity: 1; }
.ts-badge { font: 12px ui-monospace, Consolas, monospace; color: #c9ced6; }
.ts-bar button.ghost { color: #ddd; border-color: #444; }
.b-pinfo { white-space: pre-line; }
.tp-root { position: relative; }
.test-view.tp-root { position: fixed; inset: 0; }

/* display standard readout (builder) */
.b-std { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.b-std-verdict { margin: 6px 0; font-size: 13px; }
.b-std-verdict.warn { color: #ffb74d; }
.b-std-verdict.ok, .b-std .ok { color: #66bb6a; }
.b-std-table { border-collapse: collapse; font-size: 12px; width: 100%; }
.b-std-table td { padding: 2px 6px 2px 0; vertical-align: top; }
.b-std .error { min-height: 0; }

/* Phase 1 trigger */
.stage-bar button.lock-btn:not(:disabled) { color: #ffd27a; border-color: #b8862b; animation: blink 1.4s infinite; }
.tl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.tl > div { background: #0a0f15; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px 5px; }
.tl .cap { margin: 0; }
.tl b { font-size: 14px; color: var(--accent2); font-weight: 600; }

/* run setup panel + dialog */
.setup-grid { grid-template-columns: max-content 1fr max-content 1fr; font-size: 12px; }
@media (max-width: 1300px) { .setup-grid { grid-template-columns: max-content 1fr; } }
.dlg-overlay { position: fixed; inset: 0; background: rgba(2,4,8,.72); display: grid; place-items: center; z-index: 60; padding: 16px; }
.dlg { width: min(720px, 100%); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.dlg fieldset { border: 1px solid var(--line2); border-radius: 6px; padding: 6px 10px 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; }
.dlg legend { font: 600 10.5px var(--mono); letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent2); padding: 0 6px; }
.dlg label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.dlg input, .dlg select, .dlg textarea { padding: 5px 8px; font-size: 13px; }
.dlg .dlg-preset { width: auto; }
.dlg-foot { display: flex; gap: 6px; align-items: center; }
.dlg-foot button { margin: 0; }

/* recording */
.stage-bar .rec-btn.on { color: #fff; background: #b3261e; border-color: #ff5d5d; box-shadow: 0 0 10px rgba(255,93,93,.5); }
.rec-status { font-size: 11px; color: var(--muted); }
.rec-status[data-state="on"] { color: #ff6b6b; animation: blink 1.2s infinite; }
.rec-status[data-state="saved"] { color: var(--ok); }
.rec-status[data-state="failed"] { color: var(--bad); }

/* runs list (experiment card) */
.runs-head { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.runs-head .cap { margin: 0; }
.runs { list-style: none; margin: 0; padding: 0; font-size: 11.5px; max-height: 240px; overflow: auto; border-top: 1px solid var(--line); }
.runs li { border-bottom: 1px solid var(--line); padding: 3px 0; }
.runs li.active .run-info { color: var(--accent2); }
.run-head { display: flex; align-items: center; gap: 5px; }
.run-info { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c3cad4; }
.pill.sm { font-size: 9.5px; padding: 1px 7px; }
.pill.zip { color: var(--ok); border-color: rgba(61,220,151,.45); }
.run-body { padding: 4px 0 4px 26px; display: flex; flex-direction: column; gap: 3px; color: var(--muted); }
.rec-row, .ses-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* compact stage bar: one line where possible, wraps cleanly when narrow */
.stage-bar { flex-wrap: wrap; row-gap: 4px; }
.stage-bar button { white-space: nowrap; margin-left: 0; }
.stage-bar #stage-exp { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 120px; flex: 1 1 160px; }
.stage-bar .spacer { display: none; }
.g-light { font-size: 8.5px; letter-spacing: 0; }

/* ---- v0.9.1: stage control deck (grouped tool tiles with icons) ---- */
.split { grid-template-columns: minmax(440px, 46%) 1fr; }
.stage-bar.deck { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px 14px; padding: 10px 12px; border-bottom: 1px solid #1a2230;
  background: linear-gradient(180deg, #0f1620, #0a0f15); }
.deck-id { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.deck-id #stage-exp { font-size: 14px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-cap { font: 600 9.5px var(--mono); letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent2); opacity: .8; }
.deck-groups { display: flex; flex-wrap: wrap; gap: 10px; }
.deck-group { display: flex; flex-direction: column; gap: 4px; padding: 4px 6px 6px; border: 1px solid #1c2633; border-radius: 8px; background: rgba(63,182,255,.03); }
.deck-row { display: flex; gap: 6px; }
.stage-bar .tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; height: 54px; padding: 6px 10px;
  margin: 0; border-radius: 7px; border: 1px solid #2b3644; background: #0d131b; color: #d6dde6; font: 600 11.5px system-ui, sans-serif; letter-spacing: .2px; transition: border-color .15s, box-shadow .15s, background .15s; }
.stage-bar .tool .ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stage-bar .tool:hover:not(:disabled) { border-color: var(--accent); color: #fff; box-shadow: 0 0 0 1px rgba(63,182,255,.25), 0 0 14px rgba(63,182,255,.18); filter: none; }
.stage-bar .tool:disabled { opacity: .35; cursor: default; }
.stage-bar .tool.primary:not(:disabled) { background: linear-gradient(180deg, #2d9ff0, #1f7fd0); border-color: #4cb8ff; color: #fff; box-shadow: 0 0 14px rgba(63,182,255,.35); }
.stage-bar .tool.lock-btn:not(:disabled) { color: #ffd27a; border-color: #b8862b; background: rgba(255,181,71,.08); animation: blink 1.4s infinite; }
.stage-bar .tool.rec-btn.on { color: #fff; background: linear-gradient(180deg, #d4352b, #a5221b); border-color: #ff6b6b; box-shadow: 0 0 14px rgba(255,93,93,.45); }
.stage-bar .tool.rec-btn.on .ico { animation: blink 1.2s infinite; }
.stage-bar .tool.on-ok { color: var(--ok); border-color: rgba(61,220,151,.6); }
.deck .rec-status { font-size: 11px; min-height: 14px; }
.stage:fullscreen .stage-bar.deck { position: absolute; top: 0; right: 0; left: auto; opacity: .2; border: 0; background: rgba(10,15,21,.9); }
.stage:fullscreen .stage-bar.deck:hover { opacity: 1; }

/* ---- compact test page in the operator stage (the pop-out test screen keeps its full layout) ---- */
#stage-view .tp-header { padding: 8px 16px; gap: 14px; }
#stage-view .tp-logo { font-size: 13px; }
#stage-view .tp-nav { font-size: 12px; }
#stage-view .tp-main { gap: 2.5vw; padding: 10px; }
#stage-view .tp-hero h1 { font-size: clamp(16px, 1.7vw, 24px); margin-bottom: 4px; }
#stage-view .tp-hero .tp-muted { font-size: 12px; }
#stage-view .tp-card { padding: 14px 16px; gap: 7px; min-width: 0; border-radius: 10px; }
#stage-view .tp-card-title { font-size: 16px; }
#stage-view .tp-muted { font-size: 12px; }
#stage-view .tp-field { padding: 6px 10px; font-size: 12px; }
#stage-view .tp-btn { padding: 7px; font-size: 12px; }
#stage-view .tp-footer { padding: 5px 16px; font-size: 10.5px; }
#stage-view .tp-card-gap { height: 2px; }
#stage-view .tp-card > .tp-muted { max-width: 30ch; text-align: center; }
/* deck header line: caption · experiment · recording status on one row above the tool groups */
.deck-id { flex: 1 1 100%; flex-direction: row; align-items: baseline; gap: 10px; }
.deck-id #stage-exp { flex: 0 1 auto; min-width: 0; }
.deck-id .rec-status { margin-left: auto; white-space: nowrap; }
.stage-bar.deck { row-gap: 8px; padding: 8px 12px 10px; }

/* deck status readouts */
.deck-status .dro { min-width: 76px; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #1c2633; border-radius: 7px; background: #0a0f15; }
.deck-status .dro b { font-size: 15px; color: var(--accent2); text-transform: uppercase; letter-spacing: .5px; }
.deck-status .dro small { font: 9.5px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
#dk-state[data-state="verified"] { color: var(--ok); }
#dk-state[data-state="rejected"], #dk-state[data-state="expired"], #dk-state[data-state="aborted"] { color: var(--bad); }
#dk-state[data-state="locked"] { color: #ffd27a; }
.stage-bar .tool { min-width: 54px; padding: 6px 8px; }
.deck-status .dro { min-width: 62px; }
.deck-groups { gap: 8px; }
.deck-group { padding: 4px 5px 5px; }

/* ---- guide page ---- */
.help-link { font-size: 12px; padding: 4px 12px; }
body.guide-page { min-height: 100%; }
.guide { display: grid; grid-template-columns: 330px 1fr; gap: 0; min-height: calc(100vh - 53px); }
.guide-nav { border-right: 1px solid var(--line); padding: 14px; overflow: auto; background: var(--card2); }
.guide-nav .muted { margin: 4px 0 10px; }
.guide-all { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.guide-all input { width: auto; }
.guide-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.guide-list a { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--fg); padding: 6px; border: 1px solid transparent; border-radius: 8px; }
.guide-list a:hover { border-color: var(--line2); background: rgba(63,182,255,.05); }
.guide-list li.active a { border-color: var(--accent); background: rgba(63,182,255,.09); box-shadow: 0 0 12px rgba(63,182,255,.15); }
.guide-list img { width: 104px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 5px; border: 1px solid var(--line2); background: #000; flex: none; }
.gl-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gl-text b { font-size: 13px; font-weight: 600; }
.gl-n { font-size: 10.5px; color: var(--accent2); letter-spacing: 1px; }
.gl-text small { font-size: 10.5px; color: var(--muted); }
.guide-main { padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
  background: linear-gradient(rgba(63,182,255,.03) 1px, transparent 1px) 0 0 / 24px 24px, linear-gradient(90deg, rgba(63,182,255,.03) 1px, transparent 1px) 0 0 / 24px 24px, var(--bg); }
.guide-player { padding: 6px; max-width: 1200px; }
.guide-player video { width: 100%; aspect-ratio: 16 / 10; display: block; background: #000; border-radius: 6px; }
.guide-info { max-width: 1200px; display: flex; flex-direction: column; gap: 12px; }
.guide-title-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.guide-title-row h1 { margin: 0; font-size: 22px; }
.guide-title-row p { margin: 2px 0 0; }
.guide-n { font-size: 28px; font-weight: 600; color: var(--accent2); line-height: 1; padding-top: 2px; }
.guide-ctrl { display: flex; gap: 6px; align-items: center; }
.guide-ctrl select { width: auto; padding: 3px 6px; font-size: 12px; }
.guide-ctrl button { margin: 0; }
.guide-ctrl button:disabled { opacity: .35; cursor: default; }
.guide-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #c3cad4; }
.guide-steps li::marker { color: var(--accent2); font-family: var(--mono); font-size: 12px; }
@media (max-width: 900px) { .guide { grid-template-columns: 1fr; } .guide-nav { border-right: 0; border-bottom: 1px solid var(--line); } }

/* ---- brand ---- */
header .brand { height: 32px; width: auto; opacity: .92; display: block; }
header strong.brand-name { font-weight: 500; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; font-size: 12px; padding-left: 10px; border-left: 1px solid var(--line2); }
header strong.brand-name::before { content: none; }
.login-logo { height: 64px; width: auto; justify-self: center; opacity: .95; margin: 4px 0 2px; }
#login .card h1 { text-align: center; font-size: 15px; font-weight: 500; letter-spacing: 3px; text-transform: uppercase; color: var(--accent2); margin: 0; }
.login-sub { text-align: center; margin: -6px 0 6px; }

/* ---- Step 4: virtual phone + results ---- */
.ph-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.ph-profile { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-ctrl button { margin: 0; }
.ph-ctrl button.on { color: #fff; background: linear-gradient(180deg, #2d9ff0, #1f7fd0); border-color: #4cb8ff; }
.ph-n { width: 64px; padding: 3px 6px; font-size: 12px; }
.ph-last { font-size: 11.5px; margin: 6px 0 0; color: var(--muted); word-break: break-word; }
.ph-last[data-tone="ok"] { color: var(--ok); } .ph-last[data-tone="bad"] { color: var(--bad); } .ph-last[data-tone="mid"] { color: var(--mid); }
#ph-mode[data-tone="bad"] { color: var(--bad); border-color: var(--bad); } #ph-mode[data-tone="ok"] { color: var(--ok); border-color: rgba(61,220,151,.5); }
.rs-grid { display: grid; grid-template-columns: auto auto 1fr; gap: 16px; align-items: center; }
@media (max-width: 1300px) { .rs-grid { grid-template-columns: auto 1fr; } .rs-times { grid-column: 1 / -1; } }
.rs-matrix { border-collapse: separate; border-spacing: 4px; font-size: 12px; }
.rs-matrix th { color: var(--muted); font-weight: 500; text-align: left; padding: 0 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; }
.rs-matrix td { min-width: 74px; height: 46px; text-align: center; font-size: 22px; font-weight: 600; border-radius: 6px; border: 1px solid var(--line); background: #0a0f15; }
.rs-matrix td.ok { color: var(--ok); border-color: rgba(61,220,151,.35); }
.rs-matrix td.mid { color: var(--mid); border-color: rgba(255,181,71,.35); }
.rs-matrix td.bad { color: var(--bad); border-color: rgba(255,93,93,.4); }
.rs-rates { display: flex; flex-direction: column; gap: 6px; }
.rs-rates > div { background: #0a0f15; border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px 5px; min-width: 96px; }
.rs-rates .cap { margin: 0; }
.rs-rates b { font-size: 22px; color: var(--accent2); }
.rs-rates b[data-tone="ok"] { color: var(--ok); } .rs-rates b[data-tone="mid"] { color: var(--mid); } .rs-rates b[data-tone="bad"] { color: var(--bad); }
.rs-rates small { color: var(--muted); margin-left: 3px; }
.rs-times { font-size: 11.5px; }
.rs-scope { width: auto; padding: 2px 6px; font-size: 12px; }
.rs-labels { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-top: 10px; }
.rs-labels th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 3px 6px 3px 0; }
.rs-labels td { padding: 3px 6px 3px 0; border-bottom: 1px solid #10161d; }
.rs-labels td.ok { color: var(--ok); } .rs-labels td.mid { color: var(--mid); } .rs-labels td.bad { color: var(--bad); } .rs-labels td.atk { color: #ff9d9d; }

/* Step 5: T0–T5 phase bar */
.rs-phases { margin-top: 10px; display: grid; gap: 6px; }
.phasebar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--card2); border: 1px solid var(--line); position: relative; }
.phasebar span { min-width: 2px; }
.phasebar:empty::after { content: attr(data-empty); position: absolute; inset: 0; font-size: 9.5px; color: var(--muted); display: grid; place-items: center; }
.rs-ph { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; font-size: 11.5px; margin: 0; }
.rs-ph dt i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.rs-ph dd { margin: 0; text-align: right; }

/* account: change password, invites */
.who-btn { border-color: transparent; }
.dlg-narrow { width: min(560px, 100%); }
.dlg-narrow > label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.inv-form { display: grid; grid-template-columns: 1fr 1.4fr; gap: 6px 10px; }
.inv-link { display: flex; gap: 6px; }
.inv-list { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.inv-list th, .inv-list td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); }
.inv-list .st-accepted { color: var(--ok); } .inv-list .st-open { color: var(--accent2); } .inv-list .st-expired, .inv-list .st-revoked { color: var(--muted); }

/* login: promo film beside the card (stacked on narrow screens) */
.login-wrap { display: flex; align-items: center; justify-content: center; gap: 28px; width: min(1180px, 100%); flex-wrap: wrap; }
.login-film { position: relative; margin: 0; flex: 1 1 560px; max-width: 760px; display: grid; gap: 6px; }
.login-film video { width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; border: 1px solid var(--line2); background: #000; box-shadow: 0 18px 50px rgba(0,0,0,.45), 0 0 40px rgba(63,182,255,.08); }
.login-film #login-sound { position: absolute; right: 10px; top: 10px; background: rgba(10,13,18,.65); backdrop-filter: blur(4px); }
.login-film figcaption { text-align: center; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; }
.login-wrap .card { flex: 0 0 auto; }
@media (max-width: 720px) { .login-wrap { gap: 16px; } .login-film { flex-basis: 100%; } }
.inv-mail { display: flex !important; grid-template-columns: none; gap: 8px; align-items: center; font-size: 12.5px; color: var(--fg); }
.inv-mail input { width: auto; }

/* record labels (v0.13): account class + evidence level */
.lchip { display: inline-block; font: 600 9.5px/1 var(--mono); letter-spacing: .06em; padding: 3px 5px; border-radius: 3px; border: 1px solid; margin-left: 4px; vertical-align: middle; }
.lchip.demo { color: var(--mid); border-color: var(--mid); background: rgba(255,181,71,.08); }
.lchip.proj { color: var(--ok); border-color: var(--ok); background: rgba(61,220,151,.08); }
.lchip.real { color: var(--accent2); border-color: var(--accent2); }
.lchip.sim { color: var(--muted); border-color: var(--line2); }
.lchip.mixed { color: #b38cff; border-color: #b38cff; }
.chip.warnc { color: var(--mid); border-color: rgba(255,181,71,.5); }
.rs-demo { display: flex; gap: 4px; align-items: center; font-size: 11.5px; color: var(--muted); }
.rs-demo input { width: auto; }
.rs-ci { display: block; font-size: 10.5px; margin-top: 2px; }
.exp-protocol { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.dlg-narrow textarea { font-size: 13px; }
.people-head { margin-top: 12px; }
.ppl-list select { padding: 2px 6px; font-size: 12px; width: auto; }

/* study room */
.study-page { min-height: 100%; }
.study { display: grid; grid-template-columns: 340px 1fr; gap: 12px; padding: 12px; align-items: start; }
.study-nav { position: sticky; top: 12px; max-height: calc(100vh - 80px); overflow: auto; }
.study-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.study-filters select { font-size: 12px; padding: 5px 6px; }
.study-filters #f-exp { grid-column: 1 / -1; }
.study-runs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 11.5px; }
.study-runs li { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer; background: var(--card2); }
.study-runs li:hover { border-color: var(--accent); }
.study-runs li.active { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2) inset; }
.sr-name { color: var(--fg); margin: 2px 0; }
.study-main { display: grid; gap: 12px; min-width: 0; }
.study-main > #detail { display: grid; gap: 12px; }
.study-empty { color: var(--muted); padding: 40px; text-align: center; }
.study-stamp { font-weight: 600; margin: 4px 0 0; }
.study-stamp.demo { color: var(--mid); }
.study-stamp.proj { color: var(--ok); }
.study-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 12px; }
.study-player video { width: 100%; background: #000; border-radius: 6px; max-height: 62vh; }
.study-replay { position: relative; height: 56vh; border-radius: 6px; overflow: hidden; background: #000; }
.study-replay .tp-header { padding: 8px 16px; }
.study-tl .tl-row { display: grid; grid-template-columns: 34px 1fr auto 52px; gap: 6px; font-size: 12px; padding: 2px 0; border-bottom: 1px solid var(--line); }
.study-events { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow: auto; font-size: 11px; }
.study-events li { padding: 2px 4px; border-left: 2px solid transparent; opacity: .55; display: grid; grid-template-columns: 84px 54px 1fr; gap: 4px; align-items: baseline; }
.ev-type { overflow-wrap: anywhere; }
.study-events li.past { opacity: 1; }
.study-events li.now { border-left-color: var(--accent2); background: rgba(63,182,255,.08); }
.ev-t { color: var(--muted); }
.ev-src { color: var(--accent2); }
.study-notes { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.study-note-form { display: flex; gap: 8px; align-items: flex-end; }
@media (max-width: 1000px) { .study, .study-grid { grid-template-columns: 1fr; } .study-nav { position: static; max-height: none; } }
