:root {
  /* Tones are set from the THEMES table in viewer.js (one place); these are fallbacks. */
  --bg: #0b0e13; --panel: rgba(17, 21, 28, 0.78); --text: #e8ecf2; --muted: #8a94a3; --line: rgba(255, 255, 255, 0.08);
  --accent: #ff3b30; --pass: #34d399; --retry: #a78bfa; --scrap: #ef4444;   /* retry is violet: amber sat too close to the twin gold */
  --radius: 14px; --shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  --font: "Inter", -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}
:root[data-ui="light"] { --shadow: 0 8px 30px rgba(20, 20, 30, 0.12); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
#scene { position: fixed; inset: 0; }
.glass { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); }

/* ---- layout: a top bar (what this is), a run card (how it went), one tabbed inspector (detail), a
   playback bar. Gold is the twin and the main action; red only ever means a unit failed. */
:root { --gold: #f2b24b; --gold-mid: #c47f22; --fail: #ef4444; --ink: #0e1013; --gap: 14px; --bar: 56px; }
kbd { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 4px; }

#topbar { position: fixed; top: var(--gap); left: var(--gap); right: var(--gap); height: 52px; display: flex; align-items: center;
  gap: 14px; padding: 0 12px 0 16px; z-index: 3; }
.brand { display: flex; align-items: center; }
.mark { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; line-height: 1; }
.mark .plus { color: var(--gold); }
.tb-sep { width: 1px; height: 22px; background: var(--line); flex: none; }
.tb-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#line-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.tb-sub { margin-left: 8px; font-size: 12px; color: var(--muted); }
.tb-layout { flex: 0 1 auto; min-width: 150px; max-width: 340px; font-size: 12.5px; font-weight: 600; padding: 4px 26px 4px 10px; border-radius: 8px;
  appearance: none; cursor: pointer; text-overflow: ellipsis;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") right 10px center no-repeat; }
.tb-layout:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
@media (max-width: 1100px) { .tb-name:has(+ .tb-layout:not([hidden])) .tb-sub { display: none; } }   /* the picker keeps its room */
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.chip b { font-weight: 600; color: var(--text); }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--retry); }
.chip-i { width: 15px; height: 15px; border-radius: 50%; border: 1px solid currentColor; font: 600 10px/13px var(--font);
  text-align: center; font-style: normal; }
.tb-grow { flex: 1; }
.view-switch { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.view-switch button { border: none; border-radius: 7px; padding: 5px 12px; font-size: 12.5px; color: var(--muted); }
.view-switch button[aria-pressed="true"] { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); font-weight: 600; }
.view-switch #twin-btn[aria-pressed="true"] { background: var(--gold); color: var(--ink); }
.tb-key { flex: none; }
.twin-note { position: absolute; right: 12px; top: calc(100% + 6px); font-size: 11.5px; color: var(--gold); white-space: nowrap;
  text-shadow: 0 1px 6px var(--bg); }

#runcard { position: fixed; top: calc(var(--gap) + 52px + 12px); left: var(--gap); width: 300px; padding: 12px 16px 14px; z-index: 2;
  max-height: calc(100vh - 52px - var(--bar) - 4 * var(--gap)); overflow-y: auto; }
#runcard > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; justify-content: space-between; }
#runcard > summary::-webkit-details-marker { display: none; }
.rc-h { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.rc-brief { display: none; font: 12px var(--mono); color: var(--text); }
#runcard:not([open]) .rc-brief { display: inline; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 10px 0 14px; }
.stat b { display: block; font: 600 20px/1.15 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }
.rc-rule { height: 1px; background: var(--line); margin: 0 -16px 12px; }
.rc-losses-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.rc-total { font: 600 12px var(--mono); letter-spacing: 0; text-transform: none; color: var(--fail); }
.loss { display: grid; grid-template-columns: 26px 1fr auto 10px; align-items: center; gap: 0 8px; width: calc(100% + 16px);
  margin: 0 -8px; padding: 6px 8px; border: none; border-radius: 8px; text-align: left; font-size: 12.5px; }
.loss:hover, .loss.on { background: color-mix(in srgb, var(--text) 6%, transparent); }
.loss.on { box-shadow: inset 2px 0 0 var(--text); }
.loss .id { font: 600 12px var(--mono); }
.loss .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loss .n { font: 600 12.5px var(--mono); color: var(--fail); text-align: right; }
.loss .go { color: var(--muted); }
.loss .bar { grid-column: 2 / 4; height: 3px; border-radius: 2px; background: var(--fail); margin-top: 5px; }
.rc-none { font-size: 12.5px; color: var(--muted); margin: 4px 0; }
.rc-recovered { display: block; border: none; padding: 6px 0 0; font-size: 12px; color: var(--muted); text-align: left; }
.rc-recovered b { color: var(--retry); font-family: var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot.pass { background: var(--pass); } .dot.retry { background: var(--retry); } .dot.scrap { background: var(--scrap); }
.rc-link { display: block; margin-top: 12px; border: none; padding: 0; color: var(--gold); font-weight: 600; font-size: 12.5px; }
#warnings:empty { display: none; }
#warnings { margin-top: 10px; }
.badge.bad { display: block; margin-top: 6px; padding: 4px 8px; border-radius: 8px; font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); }
.muted { color: var(--muted); font-size: 12px; }

/* ---- playback */
#controls { position: fixed; left: var(--gap); right: var(--gap); bottom: var(--gap); min-height: var(--bar); display: flex;
  flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 12px; z-index: 3; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button, select { font: inherit; font-size: 13px; color: var(--text); background: transparent; border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 11px; cursor: pointer; }
button:hover, select:hover { border-color: var(--muted); }
button.ghost { border-color: transparent; color: var(--muted); }
button.ghost:hover, button.ghost[aria-pressed="true"] { color: var(--text); border-color: var(--line); }
select option { color: #111; }
.play { flex: none; width: 34px; height: 34px; padding: 0; border: none; border-radius: 50%; background: var(--text);
  display: grid; place-items: center; }
.play::before { content: ""; width: 10px; height: 12px; box-sizing: border-box; border-left: 3.5px solid var(--bg); border-right: 3.5px solid var(--bg); }
.play[data-state="paused"]::before { width: 0; height: 0; margin-left: 3px; border-style: solid; border-width: 7px 0 7px 11px;
  border-color: transparent transparent transparent var(--bg); }
#clock, .lot { font: 12.5px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lot { color: var(--muted); }
.track { position: relative; flex: 1; min-width: 160px; height: 22px; }
#ticks { position: absolute; left: 6px; right: 6px; top: 0; width: calc(100% - 12px); height: 6px; }
#ticks line { stroke: var(--fail); stroke-width: 1.6; vector-effect: non-scaling-stroke; opacity: 0.8; }
#scrub { position: absolute; left: 0; right: 0; top: 6px; width: 100%; margin: 0; height: 16px; background: transparent;
  -webkit-appearance: none; appearance: none; cursor: pointer; --p: 0%; }
#scrub::-webkit-slider-runnable-track { height: 3px; border-radius: 2px;
  background: linear-gradient(to right, var(--text) var(--p), color-mix(in srgb, var(--text) 18%, transparent) var(--p)); }
#scrub::-moz-range-track { height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--text) 18%, transparent); }
#scrub::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--text); }
#scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; margin-top: -5px; border-radius: 50%; background: var(--text); border: none; }
#scrub::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--text); border: none; }
.ct-sep { width: 1px; height: 24px; background: var(--line); }
.ct-more { display: flex; gap: 2px; }
.credit { position: fixed; right: calc(var(--gap) + 4px); bottom: calc(var(--gap) + var(--bar) + 8px); font-size: 11px; color: var(--muted); }
.credit a { color: inherit; }

.twin-blend-wrap { display: inline-flex; align-items: center; gap: 6px; flex: none; }
#twin-blend { width: 64px; accent-color: var(--gold); cursor: pointer; }
#twin-pct { font-family: var(--mono); font-size: 11.5px; min-width: 34px; text-align: right; color: var(--gold); }
@media (max-width: 760px) { .twin-blend-wrap { display: none; } }

/* ---- one inspector, tabbed: the unit, the station, the what-ifs and the SOP take turns in it */
#inspector { position: fixed; top: calc(var(--gap) + 52px + 12px); right: var(--gap); bottom: calc(var(--gap) + var(--dock-h, var(--bar)) + 12px);
  width: min(400px, calc(100vw - 2 * var(--gap))); display: flex; flex-direction: column; z-index: 2; }
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -1px; padding: 7px 10px 9px;
  font-size: 12.5px; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.tabs .tab-close { margin-left: auto; font-size: 18px; padding: 2px 8px; }
.panes { flex: 1; overflow-y: auto; padding: 14px 16px 16px; }
.pane h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.pane h3 { margin: 16px 0 6px; font-size: 10.5px; color: var(--muted); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
#closeup { width: 100%; height: 200px; border: 1px solid var(--line); border-radius: 10px;
  background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--text) 8%, transparent), transparent 70%); }
#next-same { margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
td, th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.outcome { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink); }
.outcome.pass { background: var(--pass); } .outcome.retry { background: var(--retry); } .outcome.scrap { background: var(--scrap); color: #fff; }
.curve { width: 100%; height: 170px; }
.curve .axis { stroke: var(--muted); stroke-width: 0.5; }
.curve .trace { fill: none; stroke: var(--text); stroke-width: 1.6; }
.curve .trace.first { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.curve .win { fill: none; stroke: var(--muted); stroke-dasharray: 4 3; }
.curve text { fill: var(--muted); font-size: 10px; font-family: var(--mono); }

/* ---- FDE correlation box & multi-unit spaghetti envelope */
.fde-corr-box { margin: 10px 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  background: color-mix(in srgb, var(--gold) 7%, transparent); }
.fde-corr-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 4px; }
.fde-kicker { font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.fde-pill { font-family: var(--mono); font-size: 10px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); color: var(--gold); }
.fde-corr-body { font-size: 12px; color: var(--text); line-height: 1.45; }

/* the station pane: the counts first, then what failed, then every unit */
.st-title .id { font-family: var(--mono); color: var(--muted); font-weight: 600; margin-right: 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.pill { font-size: 12px; border-radius: 6px; padding: 3px 8px; background: color-mix(in srgb, var(--text) 7%, transparent); }
.pill b { font-family: var(--mono); font-weight: 600; margin-right: 4px; }
.pill.f { background: color-mix(in srgb, var(--fail) 15%, transparent); } .pill.f b { color: var(--fail); }
.pill.r { background: color-mix(in srgb, var(--retry) 15%, transparent); } .pill.r b { color: var(--retry); }
.why { display: grid; grid-template-columns: 1fr 96px 34px; align-items: center; gap: 10px; width: 100%; padding: 6px 0; border: none;
  border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; font-size: 12.5px; }
.why:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.why .b { height: 6px; border-radius: 3px; background: var(--fail); }
.why .b.r { background: var(--retry); }
.why .n { font: 600 12.5px var(--mono); text-align: right; }
.why-none { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 0; }
.links button, button.link { border: none; padding: 0; color: var(--gold); font-weight: 600; font-size: 12.5px; text-decoration: none; }
.xray-count { float: right; font: 12px var(--mono); letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 400; }

/* ---- the about dialog */
.dialog { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dialog-card { position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 20px 22px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.dialog-card h2 { margin: 0 0 8px; font-size: 18px; }
.dialog-card h3 { margin: 16px 0 6px; font-size: 10.5px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.dialog-card p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.5; }
.dialog-close { position: absolute; top: 10px; right: 10px; border: none; font-size: 18px; color: var(--muted); }
.about-list { display: grid; grid-template-columns: 70px 1fr; gap: 6px 12px; margin: 12px 0 0; font-size: 12.5px; }
.about-list dt { color: var(--muted); }
.about-list dd { margin: 0; }
.keys kbd { margin: 0 1px; }

/* ---- guided tour */
#tour { position: fixed; left: var(--gap); bottom: calc(var(--gap) + var(--dock-h, var(--bar)) + 12px); width: min(380px, calc(100vw - 2 * var(--gap)));
  padding: 12px 16px 14px; z-index: 4; }
.tour-head { display: flex; align-items: center; gap: 10px; }
.tour-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.tour-count { font-family: var(--mono); font-size: 11px; color: var(--muted); }
#tour-exit { margin-left: auto; border: none; padding: 0 4px; font-size: 18px; color: var(--muted); }
#tour h2 { margin: 6px 0 4px; font-size: 17px; letter-spacing: -0.01em; }
#tour p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.5; }
.tour-nav { display: flex; justify-content: flex-end; gap: 8px; }
button.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
button:disabled { opacity: 0.4; cursor: default; }
body.touring #runcard { display: none; }

/* ---- labels in the scene */
.label { font-size: 12px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; white-space: nowrap; pointer-events: auto; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.label b { color: var(--text); font-weight: 700; margin-right: 2px; }   /* station ids stay neutral: red marks failures only */
.label .lost { display: none; color: var(--fail); font-weight: 600; }
body.twin .label .lost { display: inline; }
body.twin .label.has-loss { border-color: color-mix(in srgb, var(--fail) 60%, transparent); }
.label.inactive { color: var(--muted); }
.label.inactive b { color: var(--muted); }
.label.robot, .label.equipment { font-size: 11px; max-width: 220px; white-space: normal; border-radius: 10px; }
.label.station.bay { max-width: 170px; white-space: normal; border-radius: 10px; text-align: center; line-height: 1.3; }   /* a MadeCell bay is 2.5 m: wrap to it */
.mc-flow { margin: 8px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }   /* a MadeCell run's WIP and outfeed counts */
.label.floor-note { font-size: 11px; background: transparent; border-color: transparent; color: var(--muted); pointer-events: none; }
/* ?bay=B2: the recorded handoff card (after Codex #19) */
.handoff-card { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 3;
  width: min(600px, calc(100vw - 28px)); padding: 14px 18px; box-sizing: border-box; }
.handoff-card strong { font-size: 15px; }
.handoff-card p { margin: 8px 0; min-height: 2.6em; }
.handoff-card small { color: var(--muted); }
.handoff-card > div:last-child { margin-top: 10px; display: flex; gap: 14px; align-items: center; }
.handoff-card a { color: var(--text); }
.handoff-legend { display: flex; gap: 20px; margin-top: 6px; font-size: 12px; }
.handoff-legend .first { color: #38bdf8; }
.handoff-legend .next { color: #fb923c; }

/* ---- modals (MuJoCo 3D Contact Solver & FDE Architecture) */
.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(6, 8, 11, 0.76); backdrop-filter: blur(8px); }
.modal-backdrop[hidden] { display: none; }
.modal-card { position: relative; width: min(920px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px 24px; }
.modal-close { position: absolute; top: 14px; right: 14px; border: none; font-size: 22px; color: var(--muted); }
.modal-kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.modal-card h2 { margin: 4px 0 8px; font-size: 21px; letter-spacing: -0.01em; }
.arch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 12px; }
.arch-col { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.02); }
.arch-col h3 { margin: 0 0 6px; font-size: 13px; color: var(--gold); }
.arch-col p, .arch-col li { font-size: 12.5px; color: var(--text); line-height: 1.48; }
.arch-col ul { margin: 6px 0 0; padding-left: 16px; }

.mujoco-card { width: min(960px, 100%); }
.mujoco-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.mujoco-stage-wrap { position: relative; width: 100%; height: min(460px, 56vh); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: #080a0d; }
#mujoco-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#mujoco-canvas:active { cursor: grabbing; }
.mujoco-overlay { position: absolute; left: 12px; bottom: 10px; padding: 4px 10px; border-radius: 8px;
  background: rgba(14, 16, 19, 0.84); border: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; color: var(--gold); }
.mujoco-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
#mj-scrub { flex: 1; accent-color: var(--gold); }
#mj-hide-cover[aria-pressed="true"], #mj-hide-press[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }

/* ---- the MadeCell arrival: one caption at a time, the run's panels away until the line runs */
#arrive { position: fixed; left: 50%; bottom: calc(var(--gap) + 28px); transform: translateX(-50%); z-index: 4; display: grid;
  grid-template-columns: 1fr auto; column-gap: 18px; align-items: center; padding: 12px 14px 12px 20px; width: max-content;
  max-width: min(640px, calc(100vw - 2 * var(--gap))); }
#arrive b { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
#arrive span { grid-column: 1; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
#arrive button { grid-column: 2; grid-row: 1 / span 2; }
body.arriving #runcard, body.arriving #controls, body.arriving #inspector, body.arriving #tour { display: none; }

/* ---- phones: the run card folds to one line, the inspector becomes a sheet above the playback bar */
@media (max-width: 760px) {
  :root { --gap: 10px; }
  #topbar { height: 46px; gap: 10px; padding: 0 8px 0 12px; }
  .tb-name, .chip-more, .tb-key, .tb-sep { display: none; }
  .tb-layout { position: absolute; left: 0; top: calc(100% + 6px); max-width: 100%; min-width: 0; padding: 7px 28px 7px 12px;
    background-color: var(--panel); border-color: var(--line); backdrop-filter: blur(14px); }   /* its own row under the bar */
  .chip b, .chip-dot { display: none; }
  .chip::after { content: "Simulated"; color: var(--text); font-weight: 600; }
  .view-switch button { padding: 5px 7px; font-size: 12px; }
  .twin-note { display: none; }
  #runcard { top: calc(var(--gap) + 46px + 8px); width: auto; right: var(--gap); padding: 10px 14px; }
  body:has(.tb-layout:not([hidden])) #runcard { top: calc(var(--gap) + 46px + 50px); }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .stat b { font-size: 15px; }
  .stat span { font-size: 10.5px; }
  #inspector { top: auto; left: var(--gap); width: auto; height: 46vh; }
  #controls { gap: 8px; }
  .track { min-width: 80px; }
  .lot, .ct-sep { display: none; }
  #speed { padding: 4px 6px; }
  .ct-more { order: 9; width: 100%; justify-content: space-between; }
  #tour { left: var(--gap); }
  .credit { display: none; }
}

/* ---- golden twin view (G): twin gold for the twin (the site's brighter gold), red only for failures */
:root { --gold: #f4cc64; --gold-mid: #c3963b; }
body.twin { --accent: #f4cc64; }

/* ---- X-ray panel and what-if charts */
#station-body h4, #whatif-body h4 { margin: 12px 0 4px; font-size: 12px; font-weight: 600; }
#station-body .xray-h, #whatif-body h3, #rerun h3 { margin: 18px 0 8px; font-size: 10.5px; color: var(--muted); font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; }
#rerun select { width: 100%; margin: 2px 0 6px; }
#rerun code { font-family: var(--mono); font-size: 11.5px; }
.rerun-row { display: flex; gap: 6px; }
.rerun-row input { flex: 1; min-width: 0; font: 12px var(--mono); color: var(--text); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.rerun-note { margin: 6px 0 0; font-size: 12px; line-height: 1.45; }
table.cmp th { overflow-wrap: anywhere; }   /* a rerun's change path has no spaces to break at */
.hist { width: 100%; height: auto; display: block; }
.hist .hb.ok { fill: color-mix(in srgb, var(--pass) 55%, transparent); }
body.twin .hist .hb.ok { fill: var(--gold); }
.hist .hb.retry { fill: var(--retry); }
.hist .hb.scrap { fill: var(--scrap); }
.hist .lim { stroke: var(--scrap); stroke-width: 1.2; stroke-dasharray: 4 3; }
.hist .axis { stroke: var(--muted); stroke-width: 0.5; }
.hist text { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.hist-note { margin: 2px 0 0; }
/* the X-ray chart: every unit at a station, in the line's colours */
.xray-sum { margin: 0 0 6px; }
.t-scrap { color: var(--scrap); } .t-retry { color: var(--retry); }
.xray-chart { position: relative; }
.xray-chart canvas { display: block; width: 100%; }
.xray-tip { position: absolute; pointer-events: none; max-width: 260px; padding: 6px 8px; border-radius: 8px; font-size: 12px;
  line-height: 1.35; background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow); }
details.more { margin: 12px 0 0; border-top: 1px solid var(--line); padding-top: 8px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; }
details.more h4 { margin: 10px 0 2px; font-size: 12px; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: -1px; }
.sw.scrap { background: var(--scrap); } .sw.retry { background: var(--retry); } .sw.ok { background: var(--pass); }
body.twin .sw.ok { background: var(--gold); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.seg button.on { border-color: var(--gold); color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.wi-yield { margin: 4px 0 6px; }
.wi-yield .big { font-family: var(--mono); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.delta.up { color: #7ee2b8; background: rgba(52, 211, 153, 0.12); }
.delta.down { color: #ffb3ad; background: rgba(229, 53, 43, 0.14); }
table.cmp th { font-size: 11px; }

/* the assembly SOP: steps from the spec, a schematic per step */
#sop h2 { margin: 6px 0 8px; font-size: 18px; letter-spacing: -0.01em; }
#sop h3 { margin: 14px 0 6px; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
#sop-diagram { width: 100%; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#sop-diagram canvas { display: block; }
#sop-diagram-note { margin: 4px 0 0; }
.sop-do, .sop-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.sop-do li, .sop-list li { margin: 2px 0; }
#sop .tour-nav { margin-top: 12px; }
button.link { border: none; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.label.station.sop-on { border-color: var(--text); color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.wi-frame { margin: 8px 0 12px; }
.wi-frame img { display: block; width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.wi-frame figcaption { margin-top: 4px; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
.sw.ring { background: transparent; border: 1.5px solid; border-radius: 50%; }
.sw.ring.retry { background: transparent; border-color: var(--retry); } .sw.ring.scrap { background: transparent; border-color: var(--scrap); }

/* ---- a line proposal: stations drawn, nothing run, so no playback, twin, tour or what-ifs */
body.proposal:not(.flow) #controls, body.proposal .view-switch, body.proposal .tb-key, body.proposal #twin-badge, body.proposal .legend,
body.proposal:not(.assembly) [data-tab="sop"], body.proposal [data-tab="panel"], body.proposal [data-tab="whatif-panel"], body.proposal .credit,
body.flow #tour-btn, body.flow #ticks { display: none !important; }
body.proposal:not(.flow) { --dock-h: 0px; }   /* a manual line plays its target flow, so it keeps the controls */
body.proposal .chip-dot { background: var(--gold); }
.pp-lead p { margin: 8px 0 12px; font-size: 13px; line-height: 1.45; }
.pp-lead p.muted { font-size: 12px; }
.pp-new, .loss .n.pp-new { color: var(--gold); font: 600 11px var(--mono); letter-spacing: 0.04em; }
.pp-key { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.rc-coming { margin-top: 14px; }
.pp-ed { margin-top: 8px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.pp-ed b { display: block; color: var(--text); font-weight: 600; }
a.rc-link { text-decoration: none; }
.pp-op { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.pp-state { font: 600 11.5px var(--mono); white-space: nowrap; color: var(--muted); }
.pp-state.yes { color: var(--pass); } .pp-state.new { color: var(--gold); }
.pp-op-note { margin: 4px 0 6px; font-size: 12px; line-height: 1.45; color: var(--muted); }
.pp-t, .loss .n.pp-t { font: 12px var(--mono); color: var(--muted); }
.loss .n.pp-t.slow { color: var(--text); font-weight: 600; }
.loss .nm .pp-new { font-style: normal; margin-left: 4px; }
.pp-rec { font-style: normal; font: 600 10.5px var(--mono); color: var(--gold); margin-left: 6px; letter-spacing: 0.04em; }
body.proposal .rc-total { color: var(--muted); }   /* a target, not a loss */
body.proposal .twin-blend-wrap { display: none !important; }   /* site: no blend without a twin */
#sop-tabs button[title] { min-width: 30px; padding: 3px 6px; font: 11.5px var(--mono); }   /* a proposal's numbered steps */
