/* Batch experiments · the bench where cases are built, frozen, run and read back.
   Same tokens as the route simulation lab. Cases are numbered channels divided by dimension rules, not
   cards; the run's progress is a segmented level meter on the fixed dark scope, so it reads the same in
   both themes. Type is fixed rem; layouts reflow by media/container width, never by viewport font scaling.
   The view owns every value and label; this sheet only places and dresses them. */

:root {
  color-scheme: light;
  --paper: #ecebe6; --plate: #f7f6f2; --plate-2: #e4e3dc; --field: #fff;
  --ink: #121412; --ink-2: #3d403a; --ink-3: #5f625b;
  --rule: rgb(18 20 18 / .11); --rule-2: rgb(18 20 18 / .26);
  --slab: #121412; --on-slab: #edece5; --signal: #c4ee2c; --signal-edge: #8db31a; --on-signal: #121412;
  --mark: var(--ink); --focus: var(--ink);
  --alert: #b93a0b; --ok: #12704f; --warn: #855300;
  --veil: rgb(18 20 18 / .46); --lift: 0 .75rem 2rem rgb(18 20 18 / .16);
  /* the meter: identical in both themes */
  --scope: #0f120f; --scope-seg: #262b26; --scope-signal: #d4f347;
  --f-display: Bahnschrift, "DIN Alternate", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --f-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-num: "Cascadia Mono", "JetBrains Mono", ui-monospace, Consolas, monospace;
  --hit: 2.5rem; --r: .375rem;
  --pad-l: max(.75rem, env(safe-area-inset-left)); --pad-r: max(.75rem, env(safe-area-inset-right));
  /* motion: the reduced block below swaps these, so every rule stays single-sourced */
  --ease-out: cubic-bezier(.23, 1, .32, 1); --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --bx-shift: .375rem; --bx-press: .97; --bx-pop: .97; --bx-turn: .2s; --bx-fill: .4s;
  --bx-pulse: bx-pulse; --bx-arm: bx-arm; --bx-spin: bx-spin; --bx-halo: 0 0 0 0 transparent;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d0e0d; --plate: #151715; --plate-2: #1f221f; --field: #0f110f;
  --ink: #edece5; --ink-2: #c6c5bd; --ink-3: #93948c;
  --rule: rgb(237 236 229 / .1); --rule-2: rgb(237 236 229 / .24);
  --slab: #2a2e2a; --on-slab: #edece5; --signal: #d4f347; --signal-edge: #d4f347; --on-signal: #121412;
  --mark: var(--signal); --focus: var(--signal);
  --alert: #ff7a2e; --ok: #4ade9a; --warn: #ffc23d;
  --veil: rgb(0 0 0 / .62); --lift: 0 .75rem 2rem rgb(0 0 0 / .5);
  --scope: #090b09; --scope-seg: #1f241f;
}
/* Han glyph forms follow the page language instead of whichever CJK face the OS reaches first. */
:root:lang(ja) { --f-ui: "Segoe UI Variable Text", "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo UI", "Noto Sans CJK JP", system-ui, sans-serif; }
:root:lang(zh) { --f-ui: "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", system-ui, sans-serif; }
@media (pointer: coarse) { :root { --hit: 2.75rem; } }

:root[data-motion="reduced"] {
  --bx-shift: 0rem; --bx-press: 1; --bx-pop: 1; --bx-turn: 0s; --bx-fill: 0s;
  --bx-pulse: none; --bx-arm: none; --bx-spin: none; --bx-halo: 0 0 0 .1875rem rgb(212 243 71 / .35);
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) {
    --bx-shift: 0rem; --bx-press: 1; --bx-pop: 1; --bx-turn: 0s; --bx-fill: 0s;
    --bx-pulse: none; --bx-arm: none; --bx-spin: none; --bx-halo: 0 0 0 .1875rem rgb(212 243 71 / .35);
  }
}
/* Hidden tab. Browsers already stop painting background tabs; this makes the pause explicit.
   Hook for Codex (batch-host.js): on `visibilitychange`, set
   `document.documentElement.dataset.pageHidden = String(document.hidden)`. */
:root[data-page-hidden="true"] .bx *,
:root[data-page-hidden="true"] .bx *::before,
:root[data-page-hidden="true"] .bx *::after { animation-play-state: paused !important; }

/* ---- base. Resets sit at zero specificity so every component rule below wins without escalation. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font: 400 .9375rem/1.5 var(--f-ui); }
body:is(:lang(ja), :lang(zh)) { line-height: 1.65; }
:where(.bx) :where(h1, h2, p, dl, dd, fieldset, legend) { margin: 0; }
:where(.bx) :where(a) { color: inherit; }
:where(.bx) :where(button, input, select) { font: inherit; color: inherit; letter-spacing: 0; }
.bx :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.bx-icon {
  width: 1.125rem; height: 1.125rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; transform-origin: center;
}

.bx {
  width: 100%; max-width: 100rem; margin-inline: auto;
  padding: 0 var(--pad-r) max(3rem, env(safe-area-inset-bottom)) var(--pad-l);
}
.bx[data-busy="true"] { cursor: progress; }
@media (min-width: 48rem) {
  .bx { --pad-l: max(1.5rem, env(safe-area-inset-left)); --pad-r: max(1.5rem, env(safe-area-inset-right)); }
}
@media (min-width: 100rem) { .bx { --pad-l: 2.5rem; --pad-r: 2.5rem; } }

/* section labels: mono caps in Latin scripts, plain UI type for Japanese and Chinese */
.bx-history > h2, .bx-deltas > dt:first-child, .bx-coordinates > legend, .bx-sensitivity > legend {
  font: 600 .75rem/1.35 var(--f-num); letter-spacing: 0; text-transform: uppercase; color: var(--ink-3);
}
:is(.bx-history > h2, .bx-deltas > dt:first-child, .bx-coordinates > legend, .bx-sensitivity > legend):is(:lang(ja), :lang(zh)) {
  font: 600 .8125rem/1.4 var(--f-ui); letter-spacing: 0; text-transform: none;
}

/* ---- header: brand, page links, preferences. A graduated scale fades out along its base. */
.bx-header {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
  padding-block: .75rem 1rem; border-bottom: 1px solid var(--rule);
}
.bx-header::after {
  content: ""; position: absolute; inset-inline: 0; bottom: 0; height: .375rem; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, var(--rule-2) 0 1px, transparent 1px 2.5rem) left bottom / 100% .375rem no-repeat,
    repeating-linear-gradient(90deg, var(--rule-2) 0 1px, transparent 1px .5rem) left bottom / 100% .1875rem no-repeat;
  -webkit-mask-image: linear-gradient(90deg, #000 0 30%, transparent 85%);
          mask-image: linear-gradient(90deg, #000 0 30%, transparent 85%);
}
.bx-brand {
  display: inline-flex; align-items: center; gap: .625rem; min-height: var(--hit); padding-inline-end: .5rem;
  border-radius: var(--r); color: var(--ink); text-decoration: none;
}
.bx-brand .bx-icon {
  box-sizing: content-box; padding: .375rem; border-radius: var(--r); background: var(--slab); color: var(--signal);
}
.bx-brand strong { font: 700 1rem/1 var(--f-display); letter-spacing: 0; }
.bx-nav { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: .25rem; min-width: 0; }
.bx-navlink {
  display: inline-flex; align-items: center; gap: .4375rem; min-height: var(--hit); padding: .25rem .625rem;
  border-radius: var(--r); color: var(--ink-2); font: 600 .875rem/1.2 var(--f-ui); text-decoration: none;
  transition: background-color .16s ease, color .16s ease;
}
.bx-navlink .bx-icon { width: 1rem; height: 1rem; color: var(--ink-3); }
.bx > .bx-header > select { flex: 0 1 auto; width: auto; max-width: 12rem; background-color: transparent; font-weight: 500; }
.bx > .bx-header > [data-control="language"] { margin-inline-start: auto; }
/* phones: brand and preferences share the first row, page links take the second */
@media (max-width: 40rem) { .bx-nav { order: 1; flex-basis: 100%; } }

/* ---- page heading */
.bx-heading { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-block: 1.5rem 1.25rem; }
.bx-heading h1 {
  flex: 1 1 auto; margin-inline-end: auto; min-width: 0;
  font: 600 1.5rem/1.2 var(--f-display); letter-spacing: 0; overflow-wrap: anywhere;
}
@media (min-width: 48rem) { .bx-heading h1 { font-size: 1.75rem; } }
.bx[data-busy="true"]:not([data-running="true"]) .bx-heading [data-action="refresh"] .bx-icon {
  animation: var(--bx-spin) .9s linear infinite;
}

/* ---- page-level alert */
.bx > .bx-error {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .875rem; margin-bottom: 1.25rem; padding: .625rem .75rem .625rem .875rem;
  border: 1px solid color-mix(in srgb, var(--alert) 40%, transparent); border-inline-start-width: 3px; border-radius: var(--r);
  background: color-mix(in srgb, var(--alert) 8%, var(--plate)); color: var(--ink);
}
.bx > .bx-error::before {
  content: "!"; content: "!" / ""; flex: none; display: grid; place-items: center; width: 1.375rem; height: 1.375rem;
  border: 1.5px solid var(--alert); border-radius: 50%; color: var(--alert); font: 700 .8125rem/1 var(--f-num);
}
.bx > .bx-error > p { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.bx > .bx-error > .bx-button { margin-inline-start: auto; }

/* ---- empty states: concentric isophones, nothing measured yet */
.bx > .bx-empty {
  display: grid; justify-items: center; gap: 1rem; padding: 3.5rem 1rem; margin-top: .5rem;
  border: 1px dashed var(--rule-2); border-radius: .5rem; text-align: center;
}
.bx > .bx-empty::before, .bx-draft > .bx-empty::before {
  content: ""; flex: none; width: 3rem; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--ink-3) 0 .1875rem, transparent .1875rem), repeating-radial-gradient(circle, transparent 0 .4375rem, var(--rule-2) .4375rem .5rem);
}
.bx > .bx-empty h2 { font: 600 1.0625rem/1.4 var(--f-ui); color: var(--ink-2); }
.bx-draft > .bx-empty {
  display: flex; align-items: center; gap: .875rem; padding: .875rem 1rem;
  border: 1px dashed var(--rule-2); border-radius: var(--r); color: var(--ink-2);
}
.bx-draft > .bx-empty::before { width: 2rem; }
.bx-history-list > .bx-empty { padding: .5rem .625rem; color: var(--ink-3); font-size: .875rem; }

/* ---- workspace: saved experiments beside the active panel */
.bx-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.bx-main { container: bx-main / inline-size; min-width: 0; display: grid; gap: 1.25rem; }
@media (min-width: 60rem) {
  .bx-workspace { grid-template-columns: minmax(13rem, 17rem) minmax(0, 1fr); gap: 1.5rem; }
  .bx-history { padding-inline-end: 1rem; border-inline-end: 1px solid var(--rule); min-height: 12rem; }
}
@media (max-width: 59.99rem) {
  .bx-history { padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
  /* a long archive stays bounded on phones so the setup below it remains one short scroll away */
  .bx-history-list { max-block-size: min(15rem, 45dvh); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
}

.bx-history { min-width: 0; }
.bx-history > h2 { padding: .25rem .625rem .625rem; }
.bx-history-list { display: grid; gap: .125rem; align-content: start; }
.bx-history-item {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .625rem;
  width: 100%; min-height: var(--hit); padding: .5rem .625rem; border: 0; border-radius: var(--r);
  background: transparent; color: var(--ink-2); text-align: start; cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.bx-history-item .bx-icon { width: 1rem; height: 1rem; color: var(--ink-3); }
.bx-history-item strong { min-width: 0; color: var(--ink); font-size: .875rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.bx-history-item span { font: 500 .75rem/1.2 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-3); white-space: nowrap; }
.bx-history-item[aria-current="true"] { background: var(--plate); }
.bx-history-item[aria-current="true"]::before {
  content: ""; position: absolute; inset-block: .5rem; inset-inline-start: 0; width: 2px; border-radius: 1px; background: var(--mark);
}
.bx-history-item[aria-current="true"] .bx-icon { color: var(--mark); }
.bx-history-item:disabled { cursor: not-allowed; opacity: .55; }
.bx-history-item:focus-visible { outline-offset: -2px; }

/* ---- panels: one plate per task, nothing nested inside it is boxed again */
.bx-draft, .bx-results { padding: 1rem; border: 1px solid var(--rule); border-radius: .5rem; background: var(--plate); }
@media (min-width: 48rem) { .bx-draft, .bx-results { padding: 1.5rem; } }
.bx-draft > h2, .bx-run-head > h2 { font: 600 1.25rem/1.3 var(--f-display); letter-spacing: 0; overflow-wrap: anywhere; }

/* ---- controls */
.bx-field { display: grid; gap: .3125rem; min-width: 0; }
.bx-field-label { font: 600 .75rem/1.35 var(--f-ui); color: var(--ink-2); }
.bx-field-label:is(:lang(ja), :lang(zh)) { font-size: .8125rem; }
.bx :is(input, select) {
  width: 100%; min-width: 0; min-height: var(--hit); margin: 0; padding: .4375rem .625rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background-color: var(--field); color: var(--ink);
  font-size: 1rem; line-height: 1.35; transition: border-color .16s ease, background-color .16s ease;
}
.bx select {
  -webkit-appearance: none; appearance: none; padding-inline-end: 2rem; text-overflow: ellipsis; cursor: pointer;
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) right 1rem center / .3125rem .3125rem no-repeat,
    linear-gradient(135deg, currentColor 50%, transparent 50%) right .6875rem center / .3125rem .3125rem no-repeat,
    var(--field);
}
.bx select option { background: var(--plate); color: var(--ink); }
.bx input[type="number"] { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.bx input::placeholder { color: var(--ink-3); opacity: 1; font-family: var(--f-ui); font-size: .875rem; }
.bx :is(input, select):focus-visible { outline-offset: 1px; border-color: var(--ink); }
.bx :is(input, select):disabled { opacity: .55; cursor: not-allowed; }
/* fine pointers get a denser preference row; touch keeps 1rem so iOS never zooms on focus */
@media (pointer: fine) { .bx > .bx-header > select { font-size: .875rem; } }

/* ---- buttons */
.bx-button {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-width: var(--hit); min-height: var(--hit); padding: .4375rem .875rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); color: var(--ink);
  font: 600 .875rem/1.2 var(--f-ui); text-align: center; text-decoration: none; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .12s var(--ease-out);
}
.bx-button > span { min-width: 0; overflow-wrap: anywhere; }
.bx-button:active:not(:disabled) { transform: scale(var(--bx-press)); }
.bx-button:disabled { cursor: not-allowed; opacity: .45; }
.bx-icon-button { flex: none; width: var(--hit); padding: 0; }
.bx-icon-button > span {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.bx-primary, .bx-login > button[type="submit"] { background: var(--signal); border-color: var(--signal-edge); color: var(--on-signal); }
.bx-primary:disabled, .bx-login > button[type="submit"]:disabled {
  background: var(--plate-2); border-color: var(--rule-2); color: var(--ink-3); opacity: 1;
}

/* ---- draft: the setup that gets frozen */
.bx-draft { display: grid; gap: 1.25rem; align-content: start; }
.bx-draft > .bx-field { max-width: 40rem; }
.bx-case-list { display: grid; gap: 1.75rem; align-items: start; }
.bx-case-list:empty { display: none; }
@container bx-main (min-width: 76rem) { .bx-case-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; } }
.bx-draft > .bx-actions { justify-content: space-between; padding-top: 1rem; border-top: 1px solid var(--rule); }
.bx-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* a case is a channel: its number, a dimension rule with an end tick, then its own tools */
.bx-case { container: bx-case / inline-size; display: grid; gap: .875rem; min-width: 0; animation: bx-reveal .24s var(--ease-out); }
.bx-case-head { display: flex; align-items: center; gap: .125rem; }
.bx-case-number {
  flex: 1; display: flex; align-items: center; gap: .75rem; min-width: 0;
  font: 600 1.125rem/1 var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: 0; color: var(--mark);
}
.bx-case-number::after {
  content: ""; flex: 1; height: .5rem; margin-inline-end: .375rem;
  background:
    linear-gradient(var(--rule-2), var(--rule-2)) left center / 100% 1px no-repeat,
    linear-gradient(var(--rule-2), var(--rule-2)) right center / 1px 100% no-repeat;
}
.bx-case-head .bx-icon-button { border-color: transparent; background: transparent; color: var(--ink-2); }
.bx-case-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
@container bx-case (min-width: 28rem) {
  .bx-case-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bx-case-fields > :first-child { grid-column: 1 / -1; }
}
@container bx-case (min-width: 46rem) {
  .bx-case-fields { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1.2fr); }
  .bx-case-fields > :first-child { grid-column: auto; }
}

/* disclosure carets: drawn, so they share stroke weight with the rules around them */
.bx-advanced > summary, .bx-result > summary { list-style: none; cursor: pointer; }
.bx-advanced > summary::-webkit-details-marker, .bx-result > summary::-webkit-details-marker { display: none; }
.bx-advanced > summary::before, .bx-result > summary::before {
  content: ""; flex: none; width: .4375rem; height: .4375rem; margin-inline: .125rem;
  border-inline-end: 1.5px solid var(--ink-3); border-block-end: 1.5px solid var(--ink-3);
  transform: rotate(-45deg); transition: transform var(--bx-turn) var(--ease-out);
}
.bx-advanced[open] > summary::before, .bx-result[open] > summary::before { transform: translateY(-.125rem) rotate(45deg); }

.bx-advanced > summary {
  display: inline-flex; align-items: center; gap: .625rem; min-height: var(--hit); padding-inline: .25rem .625rem;
  border-radius: var(--r); color: var(--ink-2); font: 600 .8125rem/1.2 var(--f-ui);
  transition: background-color .16s ease, color .16s ease;
}
.bx-advanced[open] > summary { color: var(--ink); }
/* parameters hang off the caret on a single guide line; defaults stay in the placeholders */
.bx-parameter-grid {
  --cols: 1; --span: 1;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 1rem .75rem;
  margin: .25rem 0 0 .5625rem; padding: .875rem 0 .25rem 1rem; border-inline-start: 1px solid var(--rule-2);
}
.bx-advanced[open] > .bx-parameter-grid { animation: bx-reveal .22s var(--ease-out); }
@container bx-case (min-width: 24rem) { .bx-parameter-grid { --cols: 2; --span: 2; } }
@container bx-case (min-width: 42rem) { .bx-parameter-grid { --cols: 4; } }
@container bx-case (min-width: 62rem) { .bx-parameter-grid { --cols: 6; } }

/* start, goal and the sensitivity scenario read as dimensioned groups: label, rule, end tick — the same
   mark as a case header. The float takes the legend out of the border so it becomes an ordinary grid row. */
.bx-coordinates, .bx-sensitivity {
  grid-column: span var(--span); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .75rem;
  min-width: 0; margin: 0; padding: 0; border: 0;
}
.bx-coordinates > legend, .bx-sensitivity > legend {
  float: left; grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; width: 100%; padding: 0;
}
.bx-coordinates > legend::after, .bx-sensitivity > legend::after {
  content: ""; flex: 1; min-width: 1rem; height: .375rem;
  background:
    linear-gradient(var(--rule-2), var(--rule-2)) left center / 100% 1px no-repeat,
    linear-gradient(var(--rule-2), var(--rule-2)) right center / 1px 100% no-repeat;
}
.bx-coordinates > .bx-field { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .5rem; }
.bx-coordinates .bx-field-label { min-width: .75rem; font: 600 .875rem/1 var(--f-num); color: var(--ink-3); }

/* ---- results: run head, level meter + readout, run controls, exports, the case log */
.bx-results { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem; align-items: center; }
.bx-results > * { grid-column: 1 / -1; min-width: 0; }
.bx-results > .bx-progress { grid-column: 1; margin-top: 1.25rem; }
.bx-results > .bx-count { grid-column: 2; margin-top: 1.25rem; }
.bx-results > .bx-actions { grid-column: 1; margin-top: 1rem; }
.bx-results > .bx-exports { grid-column: 2; margin-top: 1rem; justify-self: end; }
.bx-results > .bx-notice { margin-top: 1rem; }
.bx-results > .bx-result-list { margin-top: 1.5rem; }
@container bx-main (max-width: 34rem) {
  .bx-results > :is(.bx-actions, .bx-exports) { grid-column: 1 / -1; justify-self: start; }
}

.bx-run-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.bx-run-head > h2 { flex: 1 1 14rem; min-width: 0; }
.bx-run-head > .bx-icon-button { margin-inline-start: auto; }

/* segmented level meter. Track and value share one pattern origin, so lit segments sit exactly over dark ones. */
.bx-progress {
  --seg: repeating-linear-gradient(90deg, var(--scope-seg) 0 .3125rem, transparent .3125rem .4375rem);
  --lit: repeating-linear-gradient(90deg, var(--scope-signal) 0 .3125rem, transparent .3125rem .4375rem);
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 1rem; margin: 0;
  border: 2px solid var(--scope); border-radius: 3px; background: var(--seg), var(--scope); color: var(--scope-signal);
}
.bx-progress::-webkit-progress-bar { background: var(--seg), var(--scope); }
.bx-progress::-webkit-progress-value { background: var(--lit); transition: width var(--bx-fill) var(--ease-out); }
.bx-progress::-moz-progress-bar { background: var(--lit); }
/* one short arming flash when a run starts; the status LED carries the live state after that */
.bx[data-running="true"] .bx-progress { animation: var(--bx-arm) .7s var(--ease-out) 1; }
.bx-count {
  font: 600 1rem/1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
}
.bx-exports { display: flex; flex-wrap: wrap; gap: .375rem; }
.bx-exports .bx-button { padding-inline: .75rem; font: 600 .8125rem/1.2 var(--f-num); letter-spacing: 0; }
.bx-exports .bx-icon { width: 1rem; height: 1rem; }

/* ---- status: a mono label with an LED. Hollow = waiting, half = paused, solid = settled, slab = live. */
.bx-status {
  --led: var(--ink-3);
  position: relative; display: inline-flex; align-items: center; gap: .4375rem; min-height: 1.625rem; padding: .1875rem .5rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); color: var(--ink-2);
  font: 600 .75rem/1.2 var(--f-num); letter-spacing: 0; text-transform: uppercase;
}
.bx-status:is(:lang(ja), :lang(zh)) { font: 600 .8125rem/1.3 var(--f-ui); letter-spacing: 0; text-transform: none; }
.bx-status::before {
  content: ""; flex: none; width: .5rem; height: .5rem; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--led);
}
.bx-status:is([data-status="running"], [data-status="complete"], [data-status="completed"], [data-status="failed"])::before { background: var(--led); }
.bx-status[data-status="paused"]::before { background: linear-gradient(90deg, var(--led) 50%, transparent 50%); }
.bx-status[data-status="running"] { --led: var(--scope-signal); border-color: var(--slab); background: var(--slab); color: var(--on-slab); }
.bx-status[data-status="running"]::before { box-shadow: var(--bx-halo); }
.bx-status[data-status="running"]::after {
  content: ""; position: absolute; inset-inline-start: .5rem; top: 50%; width: .5rem; height: .5rem; margin-top: -.25rem;
  border: 1px solid var(--scope-signal); border-radius: 50%; opacity: 0; pointer-events: none;
  animation: var(--bx-pulse) 1.8s var(--ease-out) infinite;
}
.bx-status:is([data-status="complete"], [data-status="completed"]) { --led: var(--ok); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.bx-status[data-status="paused"] { --led: var(--warn); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.bx-status:is([data-status="failed"], [data-status="unreachable"]) { --led: var(--alert); color: var(--alert); border-color: color-mix(in srgb, var(--alert) 45%, transparent); }
/* Result rows carry no data-status yet, so they are read from their content. Calculated rows stay neutral
   because "No route" also has metrics; errors and quality flags are the only states colour can prove.
   If the view later adds data-status to these spans, the rules above win (these are zero-specificity wrappers). */
:where(.bx-result:has(> .bx-metrics)) > summary > .bx-status::before { background: var(--led); }
:where(.bx-result:has(> .bx-notice)) > summary > .bx-status { --led: var(--warn); }
:where(.bx-result:has(> .bx-error)) > summary > .bx-status { --led: var(--alert); color: var(--alert); border-color: color-mix(in srgb, var(--alert) 45%, transparent); }

/* ---- the case log: rows, not a table. Values carry their own units, so no column headers. */
.bx-result-list { container: bx-results / inline-size; border-bottom: 1px solid var(--rule); }
.bx-result-list:empty { display: none; }
.bx-result { border-top: 1px solid var(--rule); transition: background-color .16s ease; }
.bx-result[open] { background: color-mix(in srgb, var(--plate-2) 45%, var(--plate)); }
.bx-result > summary {
  display: grid; grid-template-columns: .75rem minmax(0, 1fr) auto; grid-template-areas: "caret id status" ". dist laeq";
  align-items: center; gap: .375rem .75rem; min-height: var(--hit); padding: .625rem .75rem;
  transition: background-color .16s ease;
}
.bx-result > summary::before { grid-area: caret; justify-self: center; margin: 0; }
.bx-result > summary:focus-visible { outline-offset: -2px; }
.bx-result > summary > strong { grid-area: id; min-width: 0; font: 600 .875rem/1.35 var(--f-num); overflow-wrap: anywhere; }
.bx-result > summary > .bx-status { grid-area: status; justify-self: end; }
.bx-result > summary > :nth-child(3), .bx-result > summary > :nth-child(4) {
  font: 500 .875rem/1.3 var(--f-num); font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.bx-result > summary > :nth-child(3) { grid-area: dist; color: var(--ink-2); }
.bx-result > summary > :nth-child(4) { grid-area: laeq; justify-self: end; text-align: end; color: var(--ink); }
@container bx-results (min-width: 38rem) {
  .bx-result > summary {
    grid-template-columns: .75rem minmax(0, 1fr) 8.5rem 7rem 7.5rem; grid-template-areas: "caret id status dist laeq"; column-gap: 1rem;
  }
  .bx-result > summary > .bx-status { justify-self: start; }
  .bx-result > summary > :nth-child(3) { justify-self: end; text-align: end; }
}

.bx-result > :not(summary) { margin-inline: 2.25rem .75rem; }
/* The view rebuilds the log on every poll, re-inserting open rows; reveal only when nothing is updating. */
.bx:not([data-running="true"]):not([data-busy="true"]) .bx-result[open] > :not(summary) { animation: bx-reveal .22s var(--ease-out); }
.bx-result > :last-child:not(summary) { margin-bottom: 1.125rem; }
@container bx-results (max-width: 24rem) { .bx-result > :not(summary) { margin-inline: .75rem; } }
.bx-source { font: 400 .75rem/1.45 var(--f-num); color: var(--ink-3); overflow-wrap: anywhere; }
.bx-result > .bx-error {
  margin-top: .625rem; padding-inline-start: .75rem; border-inline-start: 2px solid var(--alert);
  color: var(--alert); font-size: .875rem; overflow-wrap: anywhere;
}

/* readouts: a hairline per value, like the scale marks on an instrument face */
.bx-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); gap: 1rem; margin-top: .875rem; }
.bx-metric { min-width: 0; padding-inline-start: .625rem; border-inline-start: 1px solid var(--rule-2); }
.bx-metric dt { font: 500 .75rem/1.35 var(--f-ui); color: var(--ink-3); }
.bx-metric dt:is(:lang(ja), :lang(zh)) { font-size: .8125rem; }
.bx-metric dd { margin-top: .1875rem; font: 500 .9375rem/1.3 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); overflow-wrap: anywhere; }
.bx-metric:nth-child(-n + 3) dd { font-size: 1.0625rem; font-weight: 600; }
/* predicted LAeq: the quantity the cost functions turn into route cost */
.bx-metric:nth-child(3) { border-inline-start: 2px solid var(--signal-edge); }

.bx-deltas {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3125rem 1rem;
  margin-top: 1.125rem; padding-top: .875rem; border-top: 1px dashed var(--rule-2);
}
.bx-deltas > dt:first-child { grid-column: 1 / -1; margin-bottom: .25rem; }
.bx-deltas > dt:first-child::before { content: "Δ"; content: "Δ" / ""; margin-inline-end: .4375rem; color: var(--ink); font-family: var(--f-num); }
.bx-deltas > dt:not(:first-child) { min-width: 0; font-size: .8125rem; color: var(--ink-2); }
.bx-deltas > dd { font: 500 .875rem/1.4 var(--f-num); font-variant-numeric: tabular-nums; text-align: end; overflow-wrap: anywhere; }
@container bx-results (min-width: 38rem) {
  .bx-deltas { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: .1875rem; }
  .bx-deltas > dt:not(:first-child) { grid-row: 2; }
  .bx-deltas > dd { grid-row: 3; text-align: start; font-size: .9375rem; }
}

.bx-notice {
  padding: .5rem .75rem; border-inline-start: 2px solid var(--warn); border-radius: 0 var(--r) var(--r) 0;
  background: color-mix(in srgb, var(--warn) 9%, transparent); color: var(--ink-2);
  font-size: .8125rem; line-height: 1.5; overflow-wrap: anywhere;
}
.bx-result > .bx-notice { margin-top: .875rem; }

/* ---- dialogs: sign-in and confirmation. Buttons pair up when there is room and stack when there is not. */
.bx-dialog {
  width: min(26rem, calc(100% - 2rem)); max-width: calc(100% - 1rem); max-height: calc(100dvh - 1rem);
  overflow: auto; padding: 1.25rem; border: 1px solid var(--rule-2); border-radius: .5rem;
  background: var(--plate); color: var(--ink); box-shadow: var(--lift); overscroll-behavior: contain;
}
.bx-dialog[open] {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: 1rem .5rem;
  animation: bx-pop .2s var(--ease-out);
}
.bx-dialog::backdrop { background: var(--veil); }
.bx-dialog > :is(h2, p, form) { grid-column: 1 / -1; }
.bx-dialog > h2 { font: 600 1.125rem/1.3 var(--f-display); }
.bx-dialog > p { font-size: 1rem; line-height: 1.55; overflow-wrap: anywhere; }
.bx-dialog .bx-button { width: 100%; }
.bx-dialog > [data-action="confirm"] { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }
.bx-login { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: .875rem .5rem; }
.bx-login > :is(.bx-field, .bx-error) { grid-column: 1 / -1; }
.bx-login > .bx-error { color: var(--alert); font-size: .875rem; overflow-wrap: anywhere; }
.bx-login > .bx-error:empty { display: none; }
@media (max-height: 26rem) {
  .bx-dialog { padding: .875rem 1rem; }
  .bx-dialog[open], .bx-login { row-gap: .625rem; }
}

/* ---- hover, only where a real pointer can hover */
@media (hover: hover) and (pointer: fine) {
  .bx-navlink:hover { background: var(--plate-2); color: var(--ink); }
  .bx-button:hover:not(:disabled) { background: var(--plate-2); border-color: var(--ink-3); }
  .bx-primary:hover:not(:disabled), .bx-login > button[type="submit"]:hover:not(:disabled) {
    background: color-mix(in srgb, var(--signal) 88%, var(--ink)); border-color: var(--signal-edge);
  }
  .bx-dialog > [data-action="confirm"]:hover:not(:disabled) { background: color-mix(in srgb, var(--slab) 85%, var(--ink)); border-color: var(--slab); }
  .bx-case-head [data-action="remove"]:hover:not(:disabled) { color: var(--alert); background: color-mix(in srgb, var(--alert) 9%, transparent); }
  .bx-history-item:hover:not(:disabled) { background: var(--plate-2); color: var(--ink); }
  .bx-advanced > summary:hover, .bx-result > summary:hover { background: var(--plate-2); }
  .bx :is(input, select):hover:not(:disabled):not(:focus) { border-color: var(--ink-3); }
}

/* ---- motion. Only transform and opacity move; operations never wait for any of it. */
@keyframes bx-reveal { from { opacity: 0; transform: translateY(calc(var(--bx-shift) * -1)); } to { opacity: 1; transform: none; } }
@keyframes bx-pop { from { opacity: 0; transform: scale(var(--bx-pop)); } to { opacity: 1; transform: none; } }
@keyframes bx-pulse { 0% { opacity: .9; transform: scale(1); } 70%, 100% { opacity: 0; transform: scale(2.75); } }
@keyframes bx-spin { to { transform: rotate(-1turn); } }
@keyframes bx-arm {
  0% { box-shadow: 0 0 0 0 rgb(212 243 71 / .55); }
  100% { box-shadow: 0 0 0 .4375rem rgb(212 243 71 / 0); }
}

/* ---- forced colours: keep the meter, LEDs and selection legible without the palette */
@media (forced-colors: active) {
  .bx-progress { -webkit-appearance: auto; appearance: auto; border: 1px solid CanvasText; }
  .bx-status::before { forced-color-adjust: none; box-shadow: inset 0 0 0 1.5px CanvasText; }
  .bx-history-item[aria-current="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .bx-case-number::after, .bx-header::after { background: CanvasText; height: 1px; }
}
