/* The Lab's stylesheet, and the only file in lab/ with a raw colour value.
   Every value is the product's own (docs/design-system.md): the instrument
   that tunes the product reads like the product it tunes. Three tokens are
   the Lab's alone, recorded in design-system.md §7.3: the score bands, and
   the pulse that travels an edge when a pass runs. */

@font-face { font-family: "Ubuntu"; src: url("./fonts/Ubuntu-300.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Ubuntu"; src: url("./fonts/Ubuntu-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Ubuntu"; src: url("./fonts/Ubuntu-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Ubuntu"; src: url("./fonts/Ubuntu-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Inconsolata"; src: url("./fonts/Inconsolata-300_700.woff2") format("woff2"); font-weight: 300 700; font-style: normal; font-display: swap; }

:root {
  --surface-0: #000000;
  --surface-1: #0c0e12;
  --surface-2: #15181d;
  --surface-3: #1f2329;
  --surface-invert: #ffffff;
  --border-subtle: #2b2e33;
  --border-strong: #3a3d44;
  --ink-muted: #a8acb3;
  --ink-secondary: #d0d3d8;
  --ink-primary: #e6e8ec;
  --ink-on-invert: #151515;

  /* Brand, not data (design-system.md §4.1b-2): the mark, and nothing else. */
  --brand-blue: #004fbc;
  --brand-red: #a90000;

  --accent-kept: #00a189;      /* the answered teal: a kept generation */
  --accent-reverted: #c28000;  /* the dropped amber: a reverted one */
  --focus: #64a1bd;            /* side-left blue: the focus ring, the one sanctioned reuse (§3.4a) */
  --danger: #db4241;
  --ink-danger: #e35b5a;
  --rec: #db4241;

  /* The Lab's own four (design-system.md §7.3). A score under 5, 5 to 7,
     7 and above: the same values as reverted, kept and danger, so no new hue
     enters, named for what they mean here. And the pulse: SOMETHING IS
     RUNNING RIGHT NOW, the dot on a wire, the ring on a step, a generation
     being measured, a shot filling, a download in progress. One meaning. */
  --score-low: #db4241;
  --score-mid: #c28000;
  --score-high: #00a189;
  --pulse: #64a1bd;

  --font-sans: "Ubuntu", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "Inconsolata", ui-monospace, SFMono-Regular, Menlo, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --r-sm: 2px; --r-md: 4px; --r-lg: 6px; --r-full: 9999px;
  --t-fast: 120ms cubic-bezier(0.2, 0, 0, 1);
  --t-base: 180ms cubic-bezier(0.2, 0, 0, 1);
  --shadow-overlay: 0 8px 24px -8px rgb(0 0 0 / 0.55);
  --shadow-lift: 0 6px 16px -6px rgb(0 0 0 / 0.5);
}

/* ------------------------------------------------------------------ reset */
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  background: var(--surface-0); color: var(--ink-primary);
  font: 13px/18px var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1 { font: 600 28px/32px var(--font-sans); letter-spacing: -0.01em; text-wrap: balance; }
h2 { font: 600 15px/20px var(--font-sans); color: var(--ink-primary); }
h3 { font: 600 13px/18px var(--font-sans); color: var(--ink-primary); }
p { font-size: 13px; line-height: 18px; color: var(--ink-secondary); max-width: 62ch; }
a { color: var(--ink-primary); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--ink-primary); }
code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); padding: 1px var(--s1); border-radius: var(--r-sm); }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.hint { color: var(--ink-muted); font-size: 13px; }
.err { color: var(--ink-danger); font-size: 13px; }
.err:empty, .hint:empty { display: none; }
.empty { color: var(--ink-muted); font-size: 13px; padding: var(--s3) 0; }
.eyebrow { font: 500 11px/16px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ----------------------------------------------------------------- shell */
.console { display: flex; min-height: 100dvh; }
.rail {
  position: sticky; top: 0; align-self: flex-start;
  display: flex; flex-direction: column; gap: var(--s6);
  width: 224px; flex-shrink: 0; height: 100dvh;
  padding: var(--s5) var(--s3);
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-0);
}
.rail .brand { padding: 0 var(--s4); }
.rail .brand img { display: block; width: 175px; height: 20px; max-width: none; }
.rail nav { display: flex; flex-direction: column; gap: var(--s1); }
.nav-item {
  display: flex; align-items: center; justify-content: flex-start; gap: var(--s3);
  width: 100%; height: auto; padding: var(--s3) var(--s4);
  border: 0; border-radius: var(--r-lg);
  background: none; color: var(--ink-muted);
  font: 400 15px/20px var(--font-sans); text-align: left; white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.nav-item svg { flex: none; }
.nav-item:hover { background: var(--surface-1); color: var(--ink-primary); }
.nav-item[aria-current="page"] { background: var(--surface-1); font-weight: 500; color: var(--ink-primary); }
.nav-item:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.nav-item .badge { margin-left: auto; }
.rail-foot { margin-top: auto; }
/* The app's sign-out control (app-header.tsx): a nav row in muted ink that comes up on hover, then a dialog. */
.signout {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; height: auto; padding: var(--s3) var(--s4);
  border: 0; border-radius: var(--r-lg); background: none; color: var(--ink-muted);
  font: 400 14px/20px var(--font-sans); text-align: left; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.signout svg { flex: none; }
.signout:hover { background: var(--surface-1); color: var(--ink-primary); }
.signout:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.content { min-width: 0; flex: 1; display: flex; flex-direction: column; }
main.panel { width: 100%; padding: var(--s6) var(--s8) 64px; }
main.panel.canvas-page { padding: 0; flex: 1; display: flex; flex-direction: column; min-height: 100dvh; }

@media (max-width: 860px) {
  .console { display: block; }
  .rail { flex-direction: row; align-items: center; width: auto; height: auto; gap: var(--s3);
          border-right: 0; border-bottom: 1px solid var(--border-subtle); padding: var(--s3); }
  .rail nav { flex-direction: row; }
  .nav-item { width: auto; padding: var(--s2) var(--s3); font-size: 13px; }
  .nav-item .label { display: none; }
  .rail-foot { display: none; }
  main.panel { padding: var(--s5) var(--s4) 48px; }
  main.panel.canvas-page { min-height: calc(100dvh - 57px); }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; column-gap: var(--s8); row-gap: var(--s4); flex-wrap: wrap; }
.page-head > div { min-width: 0; }
.page-head p { padding-top: var(--s2); }
.page-head .actions { display: flex; align-items: center; gap: var(--s3); flex-shrink: 0; flex-wrap: wrap; }
.page-head .state { display: flex; align-items: center; gap: var(--s2); font-size: 13px; }

/* ----------------------------------------------------------------- cards */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-top: var(--s8); align-items: start; }
.cards .wide { grid-column: 1 / -1; }
.cards > section { min-width: 0; }
@media (max-width: 1100px) { .cards { grid-template-columns: 1fr; } }
section.card, .cards > section {
  border: 1px solid var(--border-subtle); border-radius: var(--r-lg);
  background: var(--surface-1);
  padding: var(--s5);
  display: flex; flex-direction: column; gap: var(--s4);
}
.card-head { display: flex; align-items: center; gap: var(--s2); min-height: 20px; }
.card-head .aside { color: var(--ink-muted); font-size: 13px; font-weight: 400; }
.card-head .spacer { flex: 1; }
.unit-id {
  border: 1px solid var(--border-subtle); border-radius: var(--r-sm);
  padding: 0 var(--s1); margin-right: var(--s2);
  color: var(--ink-muted); font: 400 10px/16px var(--font-mono);
}
.unit-id:empty { display: none; }
.facts { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--s2) var(--s4); }
.facts dt { color: var(--ink-muted); font-size: 13px; }
.facts dd { color: var(--ink-secondary); font-size: 13px; margin: 0; }

/* ------------------------------------------------------------ help + tips */
.help, .tip {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border: 1px solid var(--border-strong); border-radius: var(--r-full);
  color: var(--ink-muted); font: 500 11px/1 var(--font-sans);
  cursor: default;
}
.help { width: 18px; height: 18px; }
.tip { width: 16px; height: 16px; font-size: 10px; }
.help:hover, .help:focus-visible, .tip:hover, .tip:focus-visible { border-color: var(--ink-muted); color: var(--ink-primary); }
.help:focus-visible, .tip:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.tip-source { display: none; }
.tipbox {
  position: fixed; z-index: 50;
  max-width: 280px;
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--ink-secondary);
  padding: var(--s3);
  font: 400 12px/1.5 var(--font-sans);
  box-shadow: var(--shadow-overlay);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  pointer-events: none;
}
.tipbox.wide { pointer-events: auto; max-width: 420px; padding: var(--s4); font-size: 13px; line-height: 1.6; }
.tipbox h3 { margin-bottom: var(--s2); font-size: 13px; }
.tipbox p + p { margin-top: var(--s3); }
.tipbox[hidden] { display: none !important; }

/* ---------------------------------------------------------------- inputs */
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.with-button { display: flex; align-items: stretch; gap: var(--s2); }
.with-button input { flex: 1 1 auto; min-width: 0; }
.with-button button { flex: none; }
label { color: var(--ink-secondary); font-size: 13px; }
input[type="text"], input[type="number"], input[type="password"], input[type="search"], select, textarea {
  background: var(--surface-3); color: var(--ink-primary);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  padding: 0 var(--s3); height: 36px;
  font: 13px/1 var(--font-sans);
  transition: border-color var(--t-fast);
}
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--ink-muted); }
input.num, select.fixture { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
input.num { width: 80px; text-align: center; }
textarea { height: auto; padding: var(--s3); font: 12px/1.6 var(--font-mono); width: 100%; min-height: 200px; resize: vertical; }
select { padding-right: var(--s6); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%23a8acb3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 12px center; background-repeat: no-repeat;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; margin: 0; flex: none;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: transparent;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
input[type="radio"] { border-radius: var(--r-full); }
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--ink-muted); }
input[type="checkbox"]:checked {
  border-color: var(--surface-invert);
  background: var(--surface-invert)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='8' fill='none' stroke='%23151515' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 4l2.5 2.5L9 1'/%3E%3C/svg%3E")
    center / 9px 7px no-repeat;
}
input[type="radio"]:checked { border-color: var(--surface-invert); background: var(--surface-invert); box-shadow: inset 0 0 0 3px var(--surface-1); }
input:disabled, select:disabled, textarea:disabled, button:disabled { opacity: 0.45; cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; }
.check input { cursor: pointer; }

/* Buttons, from app/src/components/primitives/button.tsx, property for
   property. A bare <button> is the app's ghost; .primary and .danger are its
   other two variants; .quiet is a text button. */
button {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 36px; padding: 0 var(--s4);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: transparent; color: var(--ink-primary);
  font: 600 13px/1 var(--font-sans); cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast), box-shadow var(--t-fast);
}
button:hover:not(:disabled) { border-color: var(--ink-muted); }
button:active:not(:disabled) { opacity: 0.75; }
button:disabled { cursor: default; opacity: 0.45; }
button.primary { background: var(--surface-invert); border-color: var(--surface-invert); color: var(--ink-on-invert); }
button.primary:hover:not(:disabled) { opacity: 0.9; border-color: var(--surface-invert); }
button.danger { border-color: var(--danger); color: var(--ink-danger); background: transparent; }
button.danger:hover:not(:disabled) { border-color: var(--danger); background: color-mix(in oklab, var(--danger) 14%, transparent); box-shadow: 0 0 0 2px color-mix(in oklab, var(--danger) 25%, transparent); }
button.small { height: 28px; padding: 0 var(--s3); font-size: 12px; }
button.quiet {
  height: auto; padding: 0; border: 0; background: none;
  color: var(--ink-muted); font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
button.quiet:hover:not(:disabled) { color: var(--ink-primary); }
button.quiet:disabled { text-decoration: none; }
button.icon { width: 28px; height: 28px; padding: 0; border-color: transparent; color: var(--ink-muted); }
button.icon:hover:not(:disabled) { color: var(--ink-primary); border-color: var(--border-strong); background: var(--surface-2); }
button.icon svg { width: 16px; height: 16px; }
button .spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: var(--r-full); animation: turn 0.8s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ status pill */
.pill {
  display: inline-flex; align-items: center; gap: var(--s2);
  height: 24px; padding: 0 var(--s3);
  border-radius: var(--r-full);
  background: color-mix(in oklab, var(--ink-muted) 12%, transparent);
  color: var(--ink-secondary);
  font: 500 11px/1 var(--font-mono); letter-spacing: 0.02em;
}
.pill .status-dot { background: var(--ink-muted); }
.pill.running { background: color-mix(in oklab, var(--rec) 12%, transparent); color: var(--rec); }
.pill.running .status-dot { background: var(--rec); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.pill.stopping { background: color-mix(in oklab, var(--accent-reverted) 12%, transparent); color: var(--accent-reverted); }
.pill.stopping .status-dot { background: var(--accent-reverted); }
.status-dot { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--ink-muted); display: inline-block; flex: none; }
@keyframes pulse { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .pill.running .status-dot { animation: none; } }

.badge {
  display: inline-flex; align-items: center; gap: var(--s1);
  height: 20px; padding: 0 6px;
  border: 1px solid var(--border-subtle); border-radius: var(--r-sm);
  color: var(--ink-muted); font: 500 11px/1 var(--font-mono);
}
.badge.count { background: var(--surface-2); }

/* Score chips: the one place the Lab colours a number. Under 5, 5 to 7, 7 up. */
.score {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 22px; padding: 0 6px;
  border-radius: var(--r-sm);
  font: 700 12px/1 var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--ink-primary); background: color-mix(in oklab, var(--ink-muted) 14%, transparent);
}
.score.low { color: var(--score-low); background: color-mix(in oklab, var(--score-low) 14%, transparent); }
.score.mid { color: var(--score-mid); background: color-mix(in oklab, var(--score-mid) 14%, transparent); }
.score.high { color: var(--score-high); background: color-mix(in oklab, var(--score-high) 14%, transparent); }
.score.none { color: var(--ink-muted); font-weight: 400; }
td.score-cell { padding: var(--s1) var(--s2); }

/* ------------------------------------------------------------ the banner */
.banner {
  display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s4) var(--s5);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface-2);
  margin-bottom: var(--s6);
  animation: rise 420ms ease-out both;
}
.banner .what { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 2px; }
.banner .what b { font-weight: 600; color: var(--ink-primary); }
.banner .what span { color: var(--ink-secondary); font-size: 13px; }
.banner .acts { display: flex; gap: var(--s2); }

/* ----------------------------------------------------------------- login */
.door { min-height: 100dvh; display: grid; place-items: center; padding: var(--s6); }
.door form {
  display: flex; flex-direction: column; gap: var(--s3);
  width: min(360px, 100%); padding: var(--s8);
  border: 1px solid var(--border-subtle); border-radius: var(--r-lg); background: var(--surface-1);
}
.door img { display: block; width: 175px; height: 20px; margin-bottom: var(--s3); }
.door input { width: 100%; }
.door button { width: 100%; }
/* Turnstile's box, reserved before Cloudflare paints into it: 68px is the
   4px step above the widget's own 65px, so the card never jumps. */
.door .captcha { min-height: 68px; }

/* ------------------------------------------------------------------ rows */
.source {
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center; gap: var(--s3);
  padding: var(--s3) 0; border-top: 1px solid var(--border-subtle);
}
.source:first-of-type { border-top: 0; padding-top: 0; }
.source .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.source .name { font-size: 13px; font-weight: 500; color: var(--ink-primary); }
.source .meta { color: var(--ink-muted); font-size: 12px; }
.source .when { display: flex; align-items: center; gap: var(--s2); }
.source .when span { color: var(--ink-muted); font: 12px var(--font-mono); }

.pick { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center;
        gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--border-subtle); cursor: pointer; }
.pick:first-of-type { border-top: 0; padding-top: 0; }
.pick:last-of-type { padding-bottom: 0; }
.pick .name { font-size: 13px; font-weight: 500; color: var(--ink-primary); }
.pick .meta { color: var(--ink-muted); font-size: 12px; }
.pick .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick .len { font: 400 12px var(--font-mono); color: var(--ink-muted); white-space: nowrap; }

.fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.fields label { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); font-size: 13px; color: var(--ink-secondary); }
.fields label > .tip { position: absolute; right: 0; top: 0; }
.fields input, .fields select { width: 100%; }
.fields .unit { font-size: 11px; color: var(--ink-muted); font-family: var(--font-mono); }
@media (max-width: 700px) { .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.setup > label.full { grid-column: 1 / -1; }
.fields.setup textarea { min-height: 72px; }
@media (max-width: 700px) { .fields.two { grid-template-columns: minmax(0, 1fr); } }
.model-row { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: var(--s3); align-items: start; }
.model-row > label { padding-top: var(--s2); }
.model-claude, .model-pick { width: 100%; }
@media (max-width: 700px) { .model-row { grid-template-columns: minmax(0, 1fr); } .model-row > label { padding-top: 0; } }
.estimate { border-left: 2px solid var(--border-strong); padding-left: var(--s3); color: var(--ink-secondary); }
.estimate.over { border-left-color: var(--score-low); color: var(--ink-primary); font-weight: 500; }

.weights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.weights label { display: flex; flex-direction: column; gap: var(--s1); font-size: 12px; color: var(--ink-secondary); }
.weights label .why { color: var(--ink-muted); font-size: 11px; line-height: 14px; min-height: 28px; }
.weights input { width: 100%; }
@media (max-width: 700px) { .weights { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ------------------------------------------------------------ model picker */
.picker { display: flex; flex-direction: column; gap: var(--s2); }
.picked { display: flex; align-items: center; gap: var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); padding: var(--s2) var(--s3); }
.picked .id { min-width: 0; flex: 1; font-family: var(--font-mono); font-size: 13px; color: var(--ink-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked .cost { flex: none; font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
.search { position: relative; }
.search svg { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-muted); pointer-events: none; }
.search input { width: 100%; height: 36px; padding-left: 34px; }
.options { overflow: hidden; border: 1px solid var(--border-subtle); border-radius: var(--r-lg); }
.options ul { list-style: none; margin: 0; padding: 0; max-height: 256px; overflow-y: auto; }
.option { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); cursor: pointer; transition: background-color var(--t-fast); }
.option.active { background: var(--surface-2); }
.option.chosen .label { font-weight: 600; }
.option .what { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.option .label { font-size: 13px; color: var(--ink-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option .id { font-family: var(--font-mono); font-size: 10px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option .cost { flex: none; font-family: var(--font-mono); font-size: 10px; color: var(--ink-muted); text-align: right; }
.options-note { padding: var(--s4) var(--s3); text-align: center; font-size: 13px; color: var(--ink-muted); }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--ink-muted); font-weight: 500; font-size: 12px; padding: var(--s2); white-space: nowrap; }
td { padding: var(--s2); vertical-align: top; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.record-scroll { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.record-scroll::-webkit-scrollbar { height: 10px; }
.record-scroll::-webkit-scrollbar-track { background: transparent; }
.record-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid var(--surface-1); }
.record-scroll table { min-width: max-content; }
.record-scroll th:first-child, .record-scroll td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface-1); }
.record-scroll tr > th:first-child { text-align: left; white-space: nowrap; padding-right: var(--s4); }
.record-scroll td { min-width: 104px; padding-right: var(--s4); }
.record-scroll td.wrap { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-sans); }
.record-scroll tr.rule td, .record-scroll tr.rule th { border-top: 1px solid var(--border-subtle); }
.run + .run { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--border-subtle); }
.run-head { display: flex; align-items: center; gap: var(--s2); font: 500 12px var(--font-mono); color: var(--ink-secondary); margin-bottom: var(--s2); }
.run-head span { color: var(--ink-muted); font-weight: 400; }
.del { width: 20px; height: 20px; padding: 0; flex: none; border: 1px solid transparent; border-radius: var(--r-sm); background: none; color: var(--ink-muted); font: 400 13px/1 var(--font-sans); }
.del:hover:not(:disabled) { border-color: var(--danger); color: var(--ink-danger); background: none; }
th .del { margin-left: var(--s2); vertical-align: middle; }
.verdict { font-weight: 600; font-size: 12px; }
.verdict.kept { color: var(--accent-kept); }
.verdict.reverted { color: var(--accent-reverted); }
.verdict.running { color: var(--pulse); }
.verdict.overfit { color: var(--ink-danger); }
.verdict.stopped, .verdict.interrupted, .verdict.tie, .verdict.inconclusive { color: var(--ink-muted); }
.replays td, .replays th { padding: var(--s2); }
.replays td.title { font-family: var(--font-sans); white-space: normal; min-width: 18ch; }
.replays td.num, .replays th.num { text-align: right; }
.replays td.go { width: 1%; text-align: right; }
.replays .golink { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--r-sm); color: var(--ink-muted); border: 1px solid transparent; }
.replays .golink:hover { color: var(--ink-primary); border-color: var(--border-strong); background: var(--surface-2); }
.replays tr.mine td { background: var(--surface-2); }

/* ------------------------------------------------------------- live log */
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s2); }
details.fold .fold-body { margin-top: var(--s2); }
input.wide { width: 100%; }
.canvas-err { padding: var(--s2) var(--s5); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { transition: transform var(--t-fast); }
details.fold[open] > summary .chev { transform: rotate(90deg); }
#log { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; font: 12px/18px var(--font-mono); margin-top: var(--s3); }
.log-line { display: flex; gap: var(--s2); align-items: baseline; }
.log-line .t { color: var(--ink-muted); flex-shrink: 0; }
.log-line .tag { flex-shrink: 0; padding: 0 var(--s1); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); color: var(--ink-secondary); font-size: 11px; }
.log-line .msg { color: var(--ink-secondary); white-space: pre-wrap; word-break: break-word; }
.log-line.warn .msg { color: var(--ink-primary); font-weight: 600; }

/* --------------------------------------------------------------- bones */
.bone { position: relative; overflow: hidden; background-color: var(--surface-2); border-radius: var(--r-md); }
.bone::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(100deg, transparent 25%, color-mix(in oklab, var(--ink-primary) 8%, transparent) 50%, transparent 75%); transform: translateX(-100%); animation: bone-sweep 1.6s ease-in-out infinite; }
@keyframes bone-sweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .bone::after { animation: none; content: none; } }
.bones { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s2) 0; }
.bone-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s3); }
.bone-row .lines { display: flex; flex-direction: column; gap: var(--s2); }
.bone-line { height: 13px; }
.bone-line.short { width: 40%; }
.bone-line.medium { width: 65%; }
.bone-btn { width: 84px; height: 36px; border-radius: var(--r-lg); }
.bone-poster { width: 200px; aspect-ratio: 16 / 9; border-radius: var(--r-md); flex: none; }

/* ---------------------------------------------------------------- dialogs */
dialog { color: inherit; }
dialog.confirm, dialog.sheet {
  margin: auto; padding: var(--s6);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface-1); color: var(--ink-secondary);
  box-shadow: var(--shadow-overlay);
  opacity: 0; transform: scale(0.97) translateY(4px);
  transition: opacity 140ms ease-out, transform 140ms ease-out, overlay 140ms ease-out allow-discrete, display 140ms ease-out allow-discrete;
}
dialog.confirm { max-width: 460px; }
dialog.sheet { width: min(640px, 94vw); max-height: 88dvh; overflow-y: auto; }
dialog.confirm[open], dialog.sheet[open] { opacity: 1; transform: none; }
@starting-style { dialog.confirm[open], dialog.sheet[open] { opacity: 0; transform: scale(0.97) translateY(4px); } }
dialog::backdrop { background: rgb(0 0 0 / 0); transition: background-color 140ms ease-out, overlay 140ms ease-out allow-discrete, display 140ms ease-out allow-discrete; }
dialog[open]::backdrop { background: rgb(0 0 0 / 0.55); }
@starting-style { dialog[open]::backdrop { background: rgb(0 0 0 / 0); } }
@media (prefers-reduced-motion: reduce) { dialog, dialog::backdrop { transition-duration: 1ms; } dialog.confirm, dialog.sheet { transform: none; } }
dialog.confirm h2, dialog.sheet h2 { margin-bottom: var(--s3); font-size: 15px; }
dialog.confirm .body p { max-width: none; }
dialog.confirm .body p + p { margin-top: var(--s3); }
.confirm-acts, .sheet-acts { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s6); }
dialog.confirm.danger .confirm-acts { justify-content: space-between; }
dialog.sheet .field { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); }
dialog.sheet .field input, dialog.sheet .field textarea { width: 100%; }
dialog.sheet .field textarea { min-height: 96px; font: 13px/18px var(--font-sans); }

/* ------------------------------------------------------------------ watch */
dialog.watch {
  margin: auto; width: min(1100px, 94vw); max-height: 90dvh;
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); background: var(--surface-1); color: var(--ink-primary);
  box-shadow: var(--shadow-overlay);
}
dialog.watch:not([open]) { display: none; }
.watch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.watch-title { font-size: 15px; margin: 0; }
.watch-sub { margin: var(--s1) 0 0; font-size: 12px; color: var(--ink-muted); }
.watch-tabs { display: flex; flex-wrap: wrap; gap: var(--s1); }
.watch-tab { font: 11px var(--font-mono); height: auto; padding: var(--s1) var(--s2); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-secondary); display: flex; gap: var(--s2); align-items: baseline; }
.watch-tab.on { border-color: var(--border-strong); background: var(--surface-3); color: var(--ink-primary); font-weight: 500; }
.watch-tab-phase { color: var(--ink-muted); }
.watch-body { overflow: auto; min-height: 0; overflow-wrap: anywhere; }
.wflags { list-style: none; margin: 0 0 var(--s3); padding: var(--s2) var(--s3); border-left: 2px solid var(--border-strong); background: var(--surface-2); border-radius: var(--r-sm); display: flex; flex-direction: column; gap: var(--s1); }
.wflags li { font: 11px var(--font-mono); color: var(--ink-secondary); }
.weye { border-left-style: dotted; }
.weye-h { color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; }
.watch-stats { display: flex; flex-wrap: wrap; gap: var(--s4); padding-bottom: var(--s3); }
.watch-stats div { display: flex; flex-direction: column; }
.watch-stats b { font: 15px var(--font-mono); font-variant-numeric: tabular-nums; }
.watch-stats span { font-size: 11px; color: var(--ink-muted); }
.watch-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s4); }
.watch-board, .watch-tx { min-width: 0; }
@media (max-width: 800px) { .watch-cols { grid-template-columns: minmax(0, 1fr); } }
.wq { font-size: 14px; margin: 0 0 var(--s3); }
.wlink { margin: 0 0 var(--s3); font-size: 12px; color: var(--ink-muted); }
.wthread { border-top: 1px solid var(--border-subtle); padding-top: var(--s3); margin-top: var(--s3); }
.wthread h3 { font-size: 12px; margin: 0 0 var(--s2); color: var(--ink-secondary); }
.wpos { margin-bottom: var(--s3); padding-left: var(--s3); border-left: 2px solid var(--border-subtle); }
.wpos.unfiled { border-left-style: dashed; }
.wpos-who { font: 11px var(--font-mono); color: var(--ink-secondary); display: flex; gap: var(--s2); }
.wpos-standing { color: var(--ink-muted); }
.wpos-text { margin: var(--s1) 0; font-size: 13px; }
.wclaims { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.wclaim { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2); font-size: 12px; align-items: baseline; }
.wclaim-t { font: 10px var(--font-mono); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.wclaim-meta { grid-column: 2; font: 10px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.wev { grid-column: 2; font-size: 11px; color: var(--ink-secondary); padding-left: var(--s2); border-left: 1px solid var(--border-subtle); }
.watch-tx h3 { font-size: 12px; margin: 0 0 var(--s2); color: var(--ink-secondary); }
.wlines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.wlines li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: var(--s2); font-size: 12px; align-items: baseline; }
.wline-t { font: 10px var(--font-mono); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.wline-who { font: 10px var(--font-mono); color: var(--ink-secondary); }

/* --------------------------------------------------------------- lineage */
.lineage { display: flex; gap: var(--s4); overflow-x: auto; padding-bottom: var(--s2); align-items: stretch; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.gen {
  flex: 0 0 auto; min-width: 248px; max-width: 320px; display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3); border: 1px solid var(--border-subtle); border-radius: var(--r-lg);
  background: var(--surface-2); position: relative;
  animation: rise 420ms ease-out both;
}
.gen + .gen::before { content: ""; position: absolute; left: calc(var(--s4) * -1); top: var(--s10); width: var(--s4); height: 1px; background: var(--border-strong); }
.gen.measuring { border-color: var(--pulse); }
.gen.kept { border-color: color-mix(in oklab, var(--accent-kept) 55%, var(--border-subtle)); }
.gen.reverted { border-color: color-mix(in oklab, var(--accent-reverted) 55%, var(--border-subtle)); }
.gen.tie, .gen.stopped, .gen.interrupted { border-color: var(--border-strong); }
.gen.overfit { border-color: color-mix(in oklab, var(--danger) 45%, var(--border-subtle)); }
.gen.overfit .gen-stage { color: var(--ink-danger); }
.gen.tie .gen-stage, .gen.stopped .gen-stage, .gen.interrupted .gen-stage { color: var(--ink-muted); }
.gen-head { display: flex; justify-content: space-between; align-items: baseline; }
.gen-n { font: 700 13px var(--font-mono); color: var(--ink-primary); }
.gen-of { color: var(--ink-muted); font-weight: 400; }
.gen-stage { font: 11px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: .06em; }
.gen.measuring .gen-stage, .gen.proposing .gen-stage { color: var(--pulse); }
.gen.kept .gen-stage { color: var(--accent-kept); }
.gen.reverted .gen-stage { color: var(--accent-reverted); }
.gen-parent { font: 11px var(--font-mono); color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cands { display: flex; flex-direction: column; gap: var(--s2); }
.gen-foot { margin-top: auto; display: flex; align-items: baseline; gap: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--border-subtle); }
.gen-agg { font: 700 18px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-primary); }
.gen-agg.pending { color: var(--ink-muted); font-size: 13px; font-weight: 400; }
.gen-delta { font: 12px var(--font-mono); }
.gen-delta.up { color: var(--accent-kept); }
.gen-delta.down { color: var(--accent-reverted); }
.cand { border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: var(--s2); background: var(--surface-1); transition: opacity 300ms ease, border-color 300ms ease, background 300ms ease; animation: rise 360ms ease-out both; }
.cand header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.cand-title { font-size: 12px; font-weight: 600; color: var(--ink-primary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand-file { font: 10px var(--font-mono); color: var(--ink-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font: 9px var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 0 4px; flex: none; }
.cand.measuring { border-color: color-mix(in oklab, var(--pulse) 45%, var(--border-subtle)); }
.cand.won { border-color: var(--accent-kept); background: color-mix(in oklab, var(--accent-kept) 8%, var(--surface-1)); }
.cand.lost { opacity: .42; }
.cand footer { display: flex; justify-content: space-between; align-items: baseline; margin-top: var(--s2); }
.cand-stage { font: 10px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: .05em; }
.cand.won .cand-stage { color: var(--accent-kept); }
.cand-agg { font: 700 14px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-primary); }
.shots { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s2); }
.shot { position: relative; height: 16px; border-radius: var(--r-sm); background: var(--surface-3); overflow: hidden; border: 0; padding: 0; font: inherit; cursor: pointer; width: 100%; display: block; }
.shot:hover { outline: 1px solid var(--border-strong); }
.shot-fill { position: absolute; inset: 0 auto 0 0; background: var(--pulse); transition: width 1.1s linear; }
.shot.judging .shot-fill { background: color-mix(in oklab, var(--pulse) 70%, var(--ink-primary)); animation: pulse 1.4s ease-in-out infinite; }
.shot.done .shot-fill { background: color-mix(in oklab, var(--accent-kept) 70%, var(--surface-3)); }
.shot.failed .shot-fill, .shot.cut .shot-fill { background: color-mix(in oklab, var(--danger) 60%, var(--surface-3)); }
.shot-n { position: absolute; left: 5px; top: 0; line-height: 16px; font: 10px var(--font-mono); color: var(--ink-secondary); }
.shot-score { position: absolute; right: 5px; top: 0; line-height: 16px; font: 10px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-primary); }
/* The pass strip under a candidate: the tick's seven passes as ticks that light. */
.passes { display: flex; gap: 2px; margin-top: var(--s2); }
.passes span { flex: 1; height: 4px; border-radius: var(--r-sm); background: var(--surface-3); transition: background-color var(--t-fast); }
.passes span.lit { background: var(--pulse); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .gen, .cand, .banner { animation: none; } .shot-fill { transition: none; } .shot.judging .shot-fill { animation: none; } }

/* ----------------------------------------------------------------- ingest */
#ingest-view .card { background: transparent; border: 0; border-radius: 0; padding: 0; }
#ingest-view .card + .card { margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--border-subtle); }
.card h2 { margin-bottom: var(--s3); }
.meta-title { margin: 0 0 var(--s1); font-size: 15px; font-weight: 500; }
.phase { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: var(--s3); }
.phase strong { font-weight: 500; }
.phase .pct { font: 500 12px var(--font-mono); color: var(--ink-muted); margin-left: auto; }
.bar { height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--pulse); transition: width 0.3s ease; }
.bar.is-indeterminate span { width: 30%; animation: slide 1.4s ease-in-out infinite; }
.meter { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s3); }
.meter span { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--ink-muted); }
.meter button { margin-left: auto; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.speaker { display: grid; gap: var(--s3); border-top: 1px solid var(--border-subtle); padding: var(--s5) 0; }
.speaker:first-of-type { border-top: 0; padding-top: var(--s2); }
.speaker.is-dropped { opacity: 0.5; }
.speaker .who { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s1); }
.speaker .stats { font: 400 12px var(--font-mono); color: var(--ink-muted); }
.speaker .opens { margin: 0; color: var(--ink-secondary); font-size: 13px; line-height: 20px; font-style: italic; max-width: 70ch; }
.sample { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.sample audio { flex: 1 1 240px; min-width: 0; height: 32px; }
.sample .at { flex: none; height: 32px; padding: 0 var(--s3); font: 500 12px var(--font-mono); white-space: nowrap; }
.sample .at svg { width: 16px; height: 11px; flex: none; }
.card.video .video-body { display: flex; gap: var(--s4); align-items: flex-start; }
.card.video .poster { width: 200px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-md); flex: none; }
.card.video .video-meta { min-width: 0; display: flex; flex-direction: column; gap: var(--s1); }
@media (max-width: 760px) { .card.video .video-body { flex-direction: column; } .card.video .poster { width: 100%; max-width: 320px; } }
.field { display: flex; flex-direction: column; gap: var(--s2); max-width: 520px; }
.field input { width: 100%; }
.form-acts { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--border-subtle); }
.form-acts .hint { margin-right: auto; }
.speaker-fields { display: flex; flex-direction: column; gap: var(--s2); align-items: stretch; }
.speaker-fields input:not([type="checkbox"]), .speaker-fields select { width: 100%; }
.speaker-fields label { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--ink-secondary); }
@media (min-width: 700px) {
  .speaker { grid-template-columns: minmax(0, 1fr) 240px; align-items: start; column-gap: var(--s6); }
  .speaker .who, .speaker .opens, .speaker .sample { grid-column: 1; }
  .speaker .speaker-fields { grid-column: 2; grid-row: 1 / span 3; }
}
.chip.is-weak { color: var(--accent-reverted); border-color: var(--accent-reverted); }
.chip.is-merge { color: var(--accent-kept); border-color: var(--accent-kept); }
.actions { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.error { color: var(--ink-danger); }
.done .path, .path { font: 400 12px var(--font-mono); color: var(--accent-kept); }
.stored { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--border-subtle); }
.stored:first-of-type { border-top: 0; padding-top: 0; }
.stored .acts { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.stored .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stored .name { font-size: 13px; font-weight: 500; color: var(--ink-primary); }
.stored .meta { color: var(--ink-muted); font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .bar span { transition: none; } .bar.is-indeterminate span { animation: none; width: 100%; opacity: 0.4; margin-left: 0; } }

/* ------------------------------------------------------------- replay env */
.envpick { display: flex; flex-direction: column; gap: var(--s2); }
.envpick label { display: flex; align-items: baseline; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border-subtle); border-radius: var(--r-lg); cursor: pointer; }
.envpick label:hover { border-color: var(--ink-muted); }
.envpick label:has(:checked) { border-color: var(--border-strong); background: var(--surface-2); }
.envpick label:has(:disabled) { cursor: default; opacity: .5; }
.envpick .what { display: flex; flex-direction: column; gap: 2px; }
.envpick .name { font-weight: 500; color: var(--ink-primary); }
.envpick .meta { font: 11px var(--font-mono); color: var(--ink-muted); }
.toggle svg { width: 16px; height: 16px; flex: none; }
.toggle .off { display: none; }
.toggle[aria-pressed="true"] { background: var(--surface-invert); border-color: var(--surface-invert); color: var(--ink-on-invert); }
.toggle[aria-pressed="true"] .on { display: none; }
.toggle[aria-pressed="true"] .off { display: block; }
.laptop-only { display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; padding: var(--s6) 0; }
.folder-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.folder-row .hint { min-width: 0; }
.replay-now { margin-top: var(--s4); }
.replay-now a { color: var(--ink-primary); text-decoration: underline; text-underline-offset: 2px; }

/* ================================================================ canvas */
.topbar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--border-subtle); background: var(--surface-0);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font: 600 15px/20px var(--font-sans); letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.topbar .prod { display: flex; align-items: center; gap: var(--s2); min-width: 0; max-width: 40vw; color: var(--ink-muted); font: 12px var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .prod b { color: var(--ink-secondary); font-weight: 500; }
.topbar .sep { width: 1px; height: 20px; background: var(--border-subtle); }
.menu { position: relative; }
.menu-list {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20;
  width: min(480px, 92vw); max-height: min(560px, 70dvh); overflow-y: auto;
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface-1); box-shadow: var(--shadow-overlay);
  padding: var(--s2);
}
.menu-list[hidden] { display: none; }
.version-row {
  display: grid; grid-template-columns: 44px 48px minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  width: 100%; height: auto; padding: var(--s2) var(--s3);
  border: 1px solid transparent; border-radius: var(--r-md); background: none;
  text-align: left; font: inherit; font-weight: 400; color: var(--ink-primary);
}
.version-row:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-subtle); }
.version-row .v { font: 600 12px var(--font-mono); color: var(--ink-primary); }
.version-row .t { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.version-row .t b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-row .t span { font: 11px var(--font-mono); color: var(--ink-muted); }
.version-row .marks { display: flex; gap: var(--s1); }
.version-row.current { background: var(--surface-2); }

.canvas-wrap { position: relative; flex: 1; min-height: 560px; overflow: hidden; background: var(--surface-0);
  background-image: radial-gradient(circle, var(--border-subtle) 1px, transparent 1px); background-size: 24px 24px;
  cursor: grab; user-select: none; }
.canvas-wrap.dragging { cursor: grabbing; }
.canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.wires { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.wires path.wire { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.wires path.wire.dashed { stroke-dasharray: 4 5; opacity: 0.8; }
.wires path.wire.lit { stroke: var(--pulse); }
.wires .dot { fill: var(--pulse); }
.flane { position: absolute; font: 500 10px/14px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.08em; pointer-events: none; }
.fnode {
  position: absolute; width: 208px; height: 84px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg); color: var(--ink-primary);
  transition: border-color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast);
}
.fnode:hover { background: var(--surface-2); border-color: var(--ink-muted); box-shadow: var(--shadow-lift); }
.fnode:has(.fopen:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.fnode.pressed { border-color: var(--ink-primary); background: var(--surface-2); }
.fnode.active { box-shadow: 0 0 0 1px var(--pulse), var(--shadow-lift); border-color: var(--pulse); }
/* The card is a button that opens the step; the padlock beside its eyebrow is a second button that locks it. */
.fnode .fopen {
  display: flex; flex-direction: column; gap: 2px; width: 100%; height: 100%;
  padding: var(--s2) var(--s3); text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: none; border: 0; border-radius: inherit; white-space: normal;
}
.fnode .fopen:focus-visible { outline: none; }
.fnode .fhead { display: flex; align-items: center; gap: var(--s2); padding-right: 24px; }
.fnode .fkind { font: 500 9px/12px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; flex: 1; }
.fnode .flock {
  position: absolute; top: 6px; right: 8px; display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-muted);
  transition: color var(--t-fast), background-color var(--t-fast);
}
.fnode button.flock { cursor: pointer; }
.fnode button.flock:hover { color: var(--ink-primary); background: var(--surface-2); }
.fnode button.flock:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.fnode button.flock:disabled { opacity: 0.45; cursor: default; }
.fnode .flock.closed { color: var(--ink-primary); }
.fnode .lock { width: 14px; height: 14px; flex: none; }
.fnode .live { display: none; min-width: 18px; height: 16px; padding: 0 4px; border-radius: var(--r-sm); background: var(--pulse); color: var(--ink-on-invert); font: 700 10px/16px var(--font-mono); text-align: center; }
.fnode.active .live { display: inline-block; }
.fnode .ftitle { font: 500 13px/16px var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fnode .fwhat { font: 11px/14px var(--font-sans); color: var(--ink-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.fnode .ffoot { display: flex; align-items: center; gap: var(--s2); margin-top: auto; font: 10px/14px var(--font-mono); color: var(--ink-muted); white-space: nowrap; }
.fnode .ffoot .changed { color: var(--ink-primary); }
.fnode .ffoot .changed::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: var(--r-full); background: var(--ink-primary); margin-right: 4px; vertical-align: 1px; }
.fnode.off { opacity: 0.55; }
.fnode.off .ftitle::after { content: " · off"; color: var(--ink-muted); font-weight: 400; }
.fnode.code, .fnode.gate { border-style: dashed; }
.fnode.locked-step { opacity: 0.7; }
.fnode.locked-step .fopen { cursor: default; }
.fnode.sink { background: var(--surface-2); }
.fnode.config { border-color: var(--border-subtle); }
.canvas-tools { position: absolute; right: var(--s4); bottom: var(--s4); display: flex; gap: var(--s1); z-index: 4; }
.canvas-tools button { width: 32px; height: 32px; padding: 0; background: var(--surface-1); }
.canvas-tools button.fit { width: auto; padding: 0 var(--s3); font: 500 12px var(--font-mono); }
.canvas-hint { position: absolute; left: var(--s4); bottom: var(--s4); font: 11px var(--font-mono); color: var(--ink-muted); z-index: 4; pointer-events: none; }

/* The list: every setting on one screen, over the canvas and under the step panel. */
.listview { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--surface-0); cursor: default; user-select: text; }
.listview-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border-subtle); }
.listview-head input { width: min(320px, 100%); }
.listview-head .hint { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listview-body { flex: 1; overflow: auto; padding: 0 var(--s4) var(--s8); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.listview-none { padding: var(--s4); }
table.settings { width: 100%; border-collapse: collapse; }
table.settings th { position: sticky; top: 0; z-index: 1; background: var(--surface-0); text-align: left; padding: var(--s3) var(--s2); font: 500 10px/14px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border-subtle); }
table.settings td { padding: var(--s2); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
table.settings tr.grp td { padding: var(--s5) var(--s2) var(--s1); border-bottom: 0; font: 500 10px/14px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
table.settings tr.grp .gname { color: var(--ink-primary); }
table.settings tr.grp .gwhat { text-transform: none; letter-spacing: 0; font: 12px/14px var(--font-sans); }
table.settings tr.setting:hover td { background: var(--surface-1); }
table.settings td.name { width: 30%; cursor: pointer; }
table.settings td.name b { display: block; font-weight: 500; font-size: 13px; line-height: 16px; }
table.settings td.name .key { font: 10px/14px var(--font-mono); color: var(--ink-muted); word-break: break-all; }
table.settings td.name:hover b { text-decoration: underline; text-underline-offset: 2px; }
table.settings td.name:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
table.settings td.stage { width: 28%; }
table.settings td.stage input:not([type="checkbox"]), table.settings td.stage select { height: 28px; width: 100%; max-width: 240px; font-size: 12px; }
table.settings td.stage button.quiet { font: 12px/16px var(--font-mono); text-decoration: none; }
table.settings td.stage button.quiet:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 2px; }
table.settings td.prod { width: 24%; max-width: 32ch; font: 12px/16px var(--font-mono); color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.settings td.marks { text-align: right; }
table.settings .mark { display: inline-block; margin-left: var(--s2); font: 10px/16px var(--font-mono); color: var(--ink-muted); }
table.settings .mark.changed { color: var(--ink-primary); }
table.settings .mark.unsaved { color: var(--ink-primary); font-weight: 700; }
table.settings .ai { display: inline-block; margin-left: var(--s2); font: 500 9px/14px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 0 4px; }
table.settings tr.dirty td.stage { box-shadow: inset 2px 0 var(--ink-primary); }

/* The node panel: slides in from the right, over the canvas. */
.fpanel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100%); z-index: 6;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border-strong); background: var(--surface-1); box-shadow: var(--shadow-overlay);
  transform: translateX(100%); transition: transform var(--t-base);
}
.fpanel.open { transform: none; }
.fpanel-head { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border-subtle); }
.fpanel-head .titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fpanel-head h2 { font-size: 15px; }
.fpanel-head .fwhat { color: var(--ink-secondary); }
.fpanel-body { flex: 1; overflow-y: auto; padding: var(--s4) var(--s5) var(--s8); display: flex; flex-direction: column; gap: var(--s5); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.fpanel .fdetail { color: var(--ink-secondary); }
.fpanel .freads { font: 11px var(--font-mono); color: var(--ink-muted); }
.fpanel .lockbox { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border-subtle); border-radius: var(--r-lg); background: var(--surface-2); }
.fpanel .lockbox .lock { width: 16px; height: 16px; flex: none; color: var(--ink-primary); }
.fpanel .lockbox .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fpanel .lockbox .what b { font-weight: 500; }
.fpanel .lockbox .what span { color: var(--ink-muted); font-size: 12px; }
.fpanel .keys { font: 10px var(--font-mono); color: var(--ink-muted); word-break: break-all; padding-top: var(--s4); border-top: 1px solid var(--border-subtle); }
.cfgfield { display: flex; flex-direction: column; gap: var(--s2); }
.cfghead { display: flex; align-items: baseline; gap: var(--s2); }
.cfghead label { font-weight: 500; color: var(--ink-primary); flex: 1; }
.cfghead .ai { font: 500 9px/14px var(--font-mono); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 0 4px; }
.cfgfield .help { display: block; width: auto; height: auto; border: 0; border-radius: 0; font: 12px/16px var(--font-sans); color: var(--ink-muted); justify-content: flex-start; cursor: default; }
.cfgfield .moves { font: 12px/16px var(--font-sans); color: var(--ink-muted); }
.cfgfield textarea { min-height: 200px; }
.cfgfield input[type="text"], .cfgfield input[type="number"], .cfgfield select { width: 100%; }
.cfgfield input[type="number"] { max-width: 160px; }
.cfgfield .toggle-row { display: flex; align-items: center; gap: var(--s2); }
.cfgfoot { display: flex; align-items: center; gap: var(--s3); }
.cfgdiff { margin: 0; font: 11px/16px var(--font-mono); white-space: pre-wrap; max-height: 200px; overflow-y: auto; border-left: 2px solid var(--border-subtle); padding-left: var(--s2); }
.cfgdiff .add { display: block; color: var(--ink-primary); }
.cfgdiff .del { display: block; color: var(--ink-muted); text-decoration: line-through; }
.cfgdiff:empty { display: none; }
details.shipped > summary { cursor: pointer; color: var(--ink-muted); font-size: 12px; }
details.shipped pre { margin-top: var(--s2); max-height: 220px; overflow: auto; font: 11px/16px var(--font-mono); white-space: pre-wrap; color: var(--ink-secondary); border-left: 2px solid var(--border-subtle); padding-left: var(--s2); }
.cfgplan { display: flex; flex-direction: column; gap: var(--s2); }
.cfgplanrow { display: grid; grid-template-columns: minmax(0, 1fr) 120px; align-items: center; gap: var(--s3); font-size: 12px; color: var(--ink-secondary); }
.cfgplanrow input[type="checkbox"] { justify-self: start; }

/* The promote sheet's rows. */
.cfgrow { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--s3); align-items: start; padding: var(--s2) 0; border-top: 1px solid var(--border-subtle); }
.cfgrow:first-of-type { border-top: 0; }
.cfgrow .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cfgrow .what b { font-weight: 500; }
.cfgrow .what span { font: 11px var(--font-mono); color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Version detail sheet. */
.vhead { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.vhead .v { font: 600 15px var(--font-mono); }
.vdesc { white-space: pre-wrap; color: var(--ink-secondary); margin-top: var(--s3); max-width: none; }
.vscores { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s2); margin-top: var(--s4); }
.vscores div { display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3); border: 1px solid var(--border-subtle); border-radius: var(--r-md); }
.vscores b { font: 600 14px var(--font-mono); font-variant-numeric: tabular-nums; }
.vscores span { font-size: 11px; color: var(--ink-muted); }
.vchanges { margin-top: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.vchange { display: flex; flex-direction: column; gap: 2px; padding: var(--s2) 0; border-top: 1px solid var(--border-subtle); }
.vchange b { font-weight: 500; }
.vchange .diff { font: 11px/16px var(--font-mono); color: var(--ink-muted); }
.vchange .diff .del { text-decoration: line-through; margin-right: var(--s2); }
.vchange .diff .add { color: var(--ink-primary); }
