/* Route simulation lab · the acoustic bench.
   A calm paper workbench around one measuring scope (the map): dark in the dark theme, light in the light theme (see the end of
   this file). Routes are the only saturated colour;
   the signal green marks live state and the single next action. Every size is rem; type never follows the viewport. */

:root {
  --paper: #ecebe6; --plate: #f7f6f2; --plate-2: #e3e2db; --field: #fff;
  --ink: #121412; --ink-2: #3a3d37; --ink-3: #5c5f58;
  --rule: rgb(18 20 18 / .12); --rule-2: rgb(18 20 18 / .28);
  --slab: #121412; --on-slab: #edece5; --signal: #c4ee2c; --on-signal: #121412;
  --alert: #b33a0c; --ok: #12704f; --warn: #845200;
  --veil: rgb(10 12 10 / .48); --lift: 0 1.25rem 3rem -1rem rgb(10 12 10 / .38), 0 .25rem .75rem -.25rem rgb(10 12 10 / .18);
  --ring: #121412; --grid: rgb(18 20 18 / .05);
  --scope: #0f120f; --scope-2: #171b17; --scope-3: #252a25; --on-scope: #ebeae3; --on-scope-2: #aeb0a6;
  --scope-rule: rgb(235 234 227 / .14); --scope-signal: #d4f347;
  --cost-distance: #1ea7ff; --cost-continuous: #18e079; --cost-threshold: #ff3f64; --cost-exposure: #c56cff;
  --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, "Hiragino Sans", "Yu Gothic UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --f-num: "Cascadia Mono", "SF Mono", ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(.23, 1, .32, 1); --ease-move: cubic-bezier(.77, 0, .175, 1);
  --hit: 2.5rem; --ctl: 2.25rem; --r: .375rem;
  --pad-l: max(.75rem, env(safe-area-inset-left)); --pad-r: max(.75rem, env(safe-area-inset-right)); --pad-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (pointer: coarse) { :root { --ctl: 2.75rem; --hit: 2.75rem; } }
:root[data-theme="dark"] {
  --paper: #0c0d0c; --plate: #141614; --plate-2: #1e211e; --field: #101210;
  --ink: #edece5; --ink-2: #c8c7bf; --ink-3: #979890;
  --rule: rgb(237 236 229 / .1); --rule-2: rgb(237 236 229 / .24);
  --slab: #2b2f2b; --on-slab: #edece5; --signal: #d4f347; --on-signal: #121412;
  --alert: #ff7a2e; --ok: #4ade9a; --warn: #ffc23d;
  --veil: rgb(0 0 0 / .62); --lift: 0 1.25rem 3rem -1rem rgb(0 0 0 / .7), 0 0 0 1px rgb(237 236 229 / .06);
  --ring: #edece5; --grid: rgb(237 236 229 / .035);
  --scope: #080a08; --scope-2: #121512; --scope-3: #222622;
  color-scheme: dark;
}
@media (prefers-contrast: more) {
  :root { --ink-3: var(--ink-2); --rule: rgb(18 20 18 / .3); --rule-2: rgb(18 20 18 / .55); --on-scope-2: #d6d7cf; }
  :root[data-theme="dark"] { --rule: rgb(237 236 229 / .3); --rule-2: rgb(237 236 229 / .55); }
}

/* ---- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* the root never scrolls: when a task lets the page scroll (phone results), the body is the one scroller */
html { height: 100dvh; overflow: hidden; container: sm-viewport / size; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.sm {
  --sm-task-layout: 0;
  position: relative; margin: 0; min-height: 100dvh; display: grid;
  grid-template: "top" auto "main" minmax(0, 1fr) "foot" auto / minmax(0, 1fr);
  background: var(--paper); color: var(--ink); font: 400 .9375rem/1.5 var(--f-ui); letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}
/* isophones: faint concentric rings behind the bench, centred on the scope */
body.sm::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: repeating-radial-gradient(circle at 62% 46%, transparent 0 3.375rem, var(--grid) 3.375rem 3.4375rem);
}
:where(.sm) :is(h1, h2, h3, p, ol, ul, dl, dd, figure, fieldset) { margin: 0; }
:where(.sm) :is(ol, ul) { padding: 0; list-style: none; }
:where(.sm) fieldset { min-width: 0; padding: 0; border: 0; }
:where(.sm) legend { padding: 0; }
:where(.sm) :is(button, input, select, textarea) { font: inherit; color: inherit; letter-spacing: 0; }
:where(.sm) button { cursor: pointer; }
:where(.sm) button:disabled { cursor: not-allowed; }
:where(.sm) a { color: inherit; }
:where(.sm) sub, :where(.sm) sup { line-height: 0; }
:where(.sm) :focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.ui-icon { flex: none; width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sm-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.sm-skip { position: absolute; z-index: 50; left: .75rem; top: -4rem; padding: .5rem .875rem; border-radius: var(--r); background: var(--slab); color: var(--on-slab); font-weight: 600; text-decoration: none; }
.sm-skip:focus { top: .75rem; }

/* text fields and selects on paper (zero specificity so every module can restyle them) */
:where(.sm) :where(select, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"]), textarea) {
  width: 100%; min-width: 0; min-height: var(--ctl); padding: .375rem .625rem; border: 1px solid var(--rule-2); border-radius: var(--r);
  background: var(--field); color: var(--ink); font-size: .9375rem; line-height: 1.3;
  transition: border-color .16s ease, box-shadow .16s ease;
}
:where(.sm) :where(select) { padding-right: 1.75rem; text-overflow: ellipsis; }
:where(.sm) :where(input[type="number"]) { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
:where(.sm) :where(select, input, textarea):hover:not(:disabled) { border-color: var(--ink-3); }
:where(.sm) :where(select, input, textarea):focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
:where(.sm) :where(input, select)[aria-invalid="true"] { border-color: var(--alert); box-shadow: 0 0 0 1px var(--alert); }
:where(.sm) :where(select, input):disabled { opacity: .55; }
:where(.sm) input[type="checkbox"], :where(.sm) input[type="radio"] { accent-color: var(--ink); }
:root[data-theme="dark"] :where(.sm) input[type="checkbox"] { accent-color: var(--signal); }

/* ---- buttons: four distinct families
   .sm-tool  square tool / labelled tool (outline)    .sm-btn  form action (outline, .sm-btn-strong = slab)
   .sm-command  borderless text command                .sm-switch  on/off with a track
   Each has disabled, focus and busy states. */
.sm-tool {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .4375rem;
  min-width: var(--ctl); min-height: var(--ctl); padding: .25rem .625rem; border: 1px solid var(--rule-2); border-radius: var(--r);
  background: var(--plate); color: var(--ink); font: 600 .875rem/1.2 var(--f-ui); text-decoration: none; white-space: nowrap;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .12s var(--ease);
}
.sm-tool:has(> .ui-icon:only-child) { padding: 0; }
.sm-tool:active:not(:disabled) { transform: scale(.97); }
.sm-tool:disabled { opacity: .45; }
.sm-tool[aria-busy="true"] { cursor: progress; }
@media (hover: hover) and (pointer: fine) { .sm-tool:hover:not(:disabled) { background: var(--plate-2); border-color: var(--ink-3); } }
.sm-tool-strong { border-color: var(--slab); background: var(--slab); color: var(--on-slab); }
.sm-tool-strong .ui-icon { color: var(--signal); }
@media (hover: hover) and (pointer: fine) { .sm-tool-strong:hover:not(:disabled) { background: color-mix(in oklab, var(--slab) 86%, var(--signal)); border-color: var(--slab); } }
.sm-tool-quiet { border-color: transparent; background: transparent; }
.sm-quiet {
  display: inline-flex; align-items: center; gap: .375rem; min-height: var(--ctl); padding: .25rem .5rem; border: 1px solid transparent; border-radius: var(--r);
  background: transparent; color: var(--ink-2); font: 600 .8125rem/1.2 var(--f-ui); text-decoration: none;
}
@media (hover: hover) and (pointer: fine) { .sm-quiet:hover { background: var(--plate-2); color: var(--ink); } }
.sm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--hit); padding: .375rem .875rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--plate); color: var(--ink); font: 600 .875rem/1.25 var(--f-ui);
  transition: background-color .16s ease, border-color .16s ease, transform .12s var(--ease);
}
.sm-btn:active:not(:disabled) { transform: scale(.98); }
.sm-btn:disabled { opacity: .45; }
.sm-btn[aria-busy="true"], .sm-btn.is-busy { cursor: progress; opacity: .75; }
@media (hover: hover) and (pointer: fine) { .sm-btn:hover:not(:disabled) { border-color: var(--ink-3); background: var(--plate-2); } }
.sm-btn-strong { border-color: var(--slab); background: var(--slab); color: var(--on-slab); }
.sm-btn-strong .ui-icon { color: var(--signal); }
@media (hover: hover) and (pointer: fine) { .sm-btn-strong:hover:not(:disabled) { background: color-mix(in oklab, var(--slab) 86%, var(--signal)); border-color: var(--slab); } }
.sm-btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.sm-count {
  display: inline-grid; place-items: center; min-width: 1.5rem; padding: .0625rem .375rem; border-radius: 999px;
  background: var(--plate-2); color: var(--ink-2); font: 600 .75rem/1.4 var(--f-num); font-variant-numeric: tabular-nums;
}
.sm-count:empty { display: none; }
.sm-gap { flex: 1 1 0; min-width: 0; }

/* ==== station head ====
   Geometry, zones and the display menu belong to the shared chrome (/static/workspace-chrome.css + .js); this page
   only places it in the body grid and gives it the lab's voice: the lime escape, the station number struck through
   with signal, and the project's resolved assets as a quiet second channel. */
body.sm > .wc-head { grid-area: top; --wc-bg: var(--plate); --wc-ring: var(--ring); }
.sm-eyebrow { font: 600 .75rem/1.3 var(--f-ui); color: var(--ink-3); }
.wc-head .wc-escape { background: var(--signal); color: var(--on-signal); }
@media (hover: hover) and (pointer: fine) { .wc-head .wc-escape:hover { background: color-mix(in oklab, var(--signal) 82%, var(--ink)); } }
.wc-head .wc-no { min-inline-size: 0; block-size: auto; padding: 0 .625rem 0 0; border: 0; border-inline-end: 2px solid var(--signal); border-radius: 0; font: 600 1.375rem/1 var(--f-display); }
.wc-head .wc-name h1 { font-size: 1.125rem; }
.wc-head .wc-project { background: var(--field); }
.wc-head .wc-menu-btn .wc-val .ui-icon { width: 1rem; height: 1rem; color: var(--ink-3); }
.sm-prefs-theme { font-weight: 500; color: var(--ink-3); }
.sm-prefs-theme::before { content: "·"; margin-inline-end: .375rem; }
.sm-meta { gap: .125rem; }
.sm-meta-line { min-width: 0; overflow: hidden; font: 500 .75rem/1.3 var(--f-ui); color: var(--ink-3); text-overflow: ellipsis; white-space: nowrap; }
.sm-asset { display: flex; gap: .875rem; min-width: 0; overflow: hidden; font: 600 .8125rem/1.35 var(--f-ui); color: var(--ink); }
.sm-asset[hidden] { display: none; }
.sm-asset-item { display: inline-flex; align-items: center; gap: .3125rem; min-width: 0; max-width: 100%; }
.sm-asset-item > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-asset-item .ui-icon { flex: none; width: .9375rem; height: .9375rem; color: var(--ink-3); }
.sm-asset-item:empty, .sm-asset-item:has(> span:last-child:empty) { display: none; }

/* ==== layout ==== */
.sm-layout { grid-area: main; position: relative; display: flex; gap: .625rem; min-width: 0; min-height: 0; padding: .625rem var(--pad-r) .625rem var(--pad-l); }
.sm-scrim { display: none; }
.sm-task { display: none; }

/* ==== setup rail ==== */
.sm-rail {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  border: 1px solid var(--rule); border-radius: .5rem; background: var(--plate);
}
.sm-rail-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .625rem .75rem .375rem 1rem; }
.sm-rail-head h2 { font: 600 1.0625rem/1.25 var(--f-display); }
.sm-tabs { flex: none; display: flex; gap: .125rem; margin: 0 .5rem; border-bottom: 1px solid var(--rule); }
.sm-tabs button {
  position: relative; flex: 1 1 0; display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .3125rem;
  min-width: 0; min-height: var(--hit); padding: .375rem .375rem .5rem; border: 0; background: transparent; color: var(--ink-3);
  font: 600 .8125rem/1.2 var(--f-ui); text-align: center; overflow-wrap: anywhere;
}
.sm-tabs button::after { content: ""; position: absolute; left: .5rem; right: .5rem; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); transform: scaleX(0); transition: transform .2s var(--ease); }
.sm-tabs button:is(.active, [aria-pressed="true"]) { color: var(--ink); }
.sm-tabs button:is(.active, [aria-pressed="true"])::after { transform: scaleX(1); }
@media (hover: hover) and (pointer: fine) { .sm-tabs button:hover { color: var(--ink); } }
.sm-tabs .sm-count { min-width: 1.25rem; padding: 0 .3125rem; }
.sm-panel { display: none; flex: 1 1 auto; min-height: 0; }
.sm-panel.active:not([hidden]), .sm-panel:not([hidden]) { display: flex; flex-direction: column; }
.sm-panel[data-sidebar-panel="layers"], .sm-panel[data-sidebar-panel="runs"] { overflow-y: auto; overscroll-behavior: contain; }

/* steps: a wire with numbered stations */
.sm-steps { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .75rem .875rem 1rem 1rem; display: grid; align-content: start; gap: 1.125rem; }
.sm-step { position: relative; display: grid; gap: .625rem; min-width: 0; padding-left: 2.25rem; }
.sm-step::before { content: ""; position: absolute; left: .8125rem; top: 1.875rem; bottom: -1.125rem; width: 1px; background: var(--rule-2); }
.sm-step:last-child::before { display: none; }
.sm-step-title { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .5rem; margin-left: -2.25rem; min-height: 1.75rem; font: 600 1rem/1.3 var(--f-display); }
.sm-step-no {
  flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; margin-right: .5rem; border-radius: 50%;
  border: 1px solid var(--rule-2); background: var(--plate); color: var(--ink-3); font: 600 .8125rem/1 var(--f-num);
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.sm-step[data-state="current"] .sm-step-no { border-color: var(--slab); background: var(--slab); color: var(--signal); box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 45%, transparent); }
.sm-step[data-state="done"] .sm-step-no { border-color: var(--ok); background: color-mix(in oklab, var(--ok) 14%, var(--plate)); color: var(--ok); }
.sm-chip {
  display: inline-flex; align-items: center; gap: .3125rem; padding: .0625rem .5rem; border: 1px solid var(--rule-2); border-radius: 999px;
  color: var(--ink-2); font: 600 .75rem/1.5 var(--f-ui); overflow-wrap: anywhere;
}
.sm-chip::before { content: ""; width: .4375rem; height: .4375rem; border-radius: 50%; background: currentColor; opacity: .7; }
.sm-step[data-state="done"] .sm-chip { border-color: color-mix(in oklab, var(--ok) 45%, transparent); color: var(--ok); }
.sm-field { display: grid; gap: .3125rem; min-width: 0; font: 600 .8125rem/1.3 var(--f-ui); color: var(--ink-2); }
.sm-field > span { overflow-wrap: anywhere; }
.sm-pickrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .375rem; }
.sm-pickrow .sm-tool { min-height: var(--ctl); }
.sm-help { font-size: .8125rem; line-height: 1.45; color: var(--ink-3); overflow-wrap: anywhere; }
.sm-links { display: flex; flex-wrap: wrap; gap: .25rem .875rem; }
.sm-link { display: inline-flex; align-items: center; gap: .375rem; min-height: 2rem; color: var(--ink-2); font: 600 .8125rem/1.3 var(--f-ui); text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: .2em; }
.sm-link .ui-icon { width: 1rem; height: 1rem; }
@media (hover: hover) and (pointer: fine) { .sm-link:hover { color: var(--ink); text-decoration-color: currentColor; } }
.sm-pins { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); gap: .375rem; }
.sm-pin {
  display: inline-flex; align-items: center; justify-content: center; gap: .4375rem; min-height: var(--hit); padding: .375rem .625rem;
  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;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.sm-pin:disabled { opacity: .45; }
@media (hover: hover) and (pointer: fine) { .sm-pin:hover:not(:disabled) { border-color: var(--ink-3); background: var(--plate-2); } }
.sm-pin.primary { border-color: var(--slab); background: var(--slab); color: var(--on-slab); box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 40%, transparent); }
.sm-pin.primary .ui-icon { color: var(--signal); }
.sm-coords { padding: .375rem .625rem; border-radius: var(--r); background: var(--plate-2); font: .8125rem/1.45 var(--f-num); color: var(--ink-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* method options */
.sm-opts { display: grid; gap: .25rem; }
.sm-opts legend { margin-bottom: .3125rem; font: 600 .8125rem/1.3 var(--f-ui); color: var(--ink-2); }
.sm-opt { display: grid; gap: .25rem; min-width: 0; }
.sm-opt-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .25rem; min-height: var(--ctl);
  padding-left: .5rem; border: 1px solid var(--rule); border-radius: var(--r); background: var(--field);
}
.sm-opt-row:has(input:checked) { border-color: var(--rule-2); }
.sm-opt-row label { display: flex; align-items: center; gap: .5rem; min-width: 0; min-height: var(--ctl); font-size: .875rem; line-height: 1.3; cursor: pointer; overflow-wrap: anywhere; }
.sm-opt-row input { flex: none; width: 1rem; height: 1rem; margin: 0; }
.sm-trace { flex: none; display: inline-block; width: 1.5rem; height: .1875rem; border-radius: 2px; background: var(--tint, var(--ink-3)); }
[data-tint="distance"] { --tint: var(--cost-distance); }
[data-tint="continuous"] { --tint: var(--cost-continuous); }
[data-tint="threshold"] { --tint: var(--cost-threshold); }
[data-tint="exposure"] { --tint: var(--cost-exposure); }
/* the presenter copies the engine's live colour and pattern onto each cost choice, so a trace matches its route line */
label[data-pattern] .sm-trace { width: 1.75rem; height: .25rem; background: var(--route-color, var(--tint, var(--ink-3))); }
label[data-pattern="dashed"] .sm-trace { background: repeating-linear-gradient(90deg, var(--route-color) 0 .375rem, transparent .375rem .5625rem); }
label[data-pattern="dotted"] .sm-trace { background: repeating-linear-gradient(90deg, var(--route-color) 0 .1875rem, transparent .1875rem .375rem); }
label[data-pattern="dashdot"] .sm-trace { background: repeating-linear-gradient(90deg, var(--route-color) 0 .375rem, transparent .375rem .5rem, var(--route-color) .5rem .5625rem, transparent .5625rem .6875rem); }
:is(.sm-opt-row, .sm-checks) label:has(input:not(:checked)) .sm-trace { opacity: .35; }
.sm-info { display: grid; place-items: center; width: var(--ctl); height: var(--ctl); border: 0; border-radius: var(--r); background: transparent; color: var(--ink-3); }
.sm-info[aria-expanded="true"] { color: var(--ink); background: var(--plate-2); }
@media (hover: hover) and (pointer: fine) { .sm-info:hover { color: var(--ink); background: var(--plate-2); } }
.sm-note-box { display: grid; gap: .5rem; margin: 0 0 .25rem; padding: .625rem .75rem; border-radius: var(--r); background: var(--plate-2); font-size: .8125rem; line-height: 1.5; color: var(--ink-2); animation: sm-in .18s var(--ease); }
.sm-note-box b { color: var(--ink); font-weight: 600; }
.sm-formula { padding: .5rem .625rem; border-radius: .25rem; background: var(--scope); color: var(--on-scope); font: .8125rem/1.6 var(--f-num); overflow-wrap: anywhere; }

/* cost parameters */
.sm-params { border: 1px solid var(--rule); border-radius: var(--r); background: var(--field); }
.sm-params > summary {
  display: flex; align-items: center; gap: .5rem; min-height: var(--hit); padding: .25rem .75rem; list-style: none; cursor: pointer;
  font: 600 .875rem/1.3 var(--f-ui); color: var(--ink);
}
.sm-params > summary::-webkit-details-marker { display: none; }
.sm-params > summary::after { content: ""; margin-left: auto; width: .5rem; height: .5rem; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg) translate(-.125rem, -.125rem); transition: transform .2s var(--ease); }
.sm-params[open] > summary::after { transform: rotate(-135deg) translate(-.125rem, -.125rem); }
.sm-param-groups { display: grid; gap: .5rem; padding: 0 .5rem .5rem; }
.parameter-group { display: grid; gap: .375rem; padding: .5rem .625rem .625rem; border-left: 3px solid var(--tint, var(--rule-2)); border-radius: .25rem; background: var(--plate); }
.parameter-group > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font: 600 .875rem/1.3 var(--f-ui); }
.parameter-group .cost-dot { display: none; }
.parameter-group > p, .linked-parameter-note { font-size: .8125rem; line-height: 1.45; color: var(--ink-3); }
.linked-parameter-note b { color: var(--ink-2); font-weight: 600; }
.sm-param-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 6.5rem), 1fr)); gap: .375rem; }
.sm-param-grid label { display: grid; align-content: end; gap: .1875rem; min-width: 0; }
.sm-sym { font: 600 .875rem/1.3 var(--f-ui); color: var(--ink); overflow-wrap: anywhere; }
.sm-unit { font: 500 .75rem/1 var(--f-num); color: var(--ink-3); }
.parameter-scope { font-size: .75rem; line-height: 1.3; color: var(--ink-3); }

/* commit: requirements chain and the emitter */
.sm-commit {
  flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "emit chain" "emit feed"; align-items: center; gap: .25rem .75rem;
  padding: .75rem .875rem .875rem 1rem; border-top: 1px solid var(--rule); background: var(--plate);
}
.sm-chain { grid-area: chain; display: flex; flex-wrap: wrap; gap: .25rem .75rem; font: 600 .8125rem/1.35 var(--f-ui); color: var(--ink-2); }
.sm-chain > span { display: inline-flex; align-items: center; gap: .375rem; min-width: 0; }
.sm-chain > span > i { flex: none; width: .5rem; height: .5rem; border-radius: 50%; border: 1.5px solid var(--warn); background: transparent; transition: background-color .2s ease, border-color .2s ease; }
.sm-chain > span[data-ready="true"] > i { border-color: var(--ok); background: var(--ok); }
.sm-chain > span[data-ready="true"] { color: var(--ink-3); }
.sm-emit {
  grid-area: emit; display: grid; justify-items: center; gap: .3125rem; min-width: 5.5rem; padding: .25rem; border: 0; background: transparent; color: var(--ink);
  font: 700 .875rem/1.2 var(--f-ui); text-align: center;
}
.sm-emit-disc {
  position: relative; display: grid; place-items: center; width: 3.5rem; height: 3.5rem; border-radius: 50%;
  background: var(--slab); color: var(--signal); box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--signal) 55%, transparent);
  transition: transform .14s var(--ease), background-color .2s ease;
}
.sm-emit-disc .ui-icon { width: 1.375rem; height: 1.375rem; fill: currentColor; }
.sm-emit-ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--signal); opacity: 0; pointer-events: none; }
.sm-emit:not(:disabled) .sm-emit-ring:first-child { animation: sm-breathe 2.8s ease-in-out infinite; transform: scale(1.14); }
.sm-emit.is-running .sm-emit-ring { animation: sm-emit 1.4s var(--ease) infinite; }
.sm-emit.is-running .sm-emit-ring + .sm-emit-ring { animation-delay: .7s; }
.sm-emit:active:not(:disabled) .sm-emit-disc { transform: scale(.95); }
.sm-emit:disabled { color: var(--ink-3); }
.sm-emit:disabled .sm-emit-disc { background: var(--plate-2); color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--rule-2); }
.sm-emit.is-running { cursor: progress; }
.sm-emit-copy strong { font-weight: 700; overflow-wrap: anywhere; }
.run-feedback { grid-area: feed; font-size: .8125rem; line-height: 1.4; color: var(--ink-3); overflow-wrap: anywhere; }
.run-feedback.ready { color: var(--ok); font-weight: 600; }
.run-feedback.error { color: var(--alert); font-weight: 600; }

/* layers and saved runs */
.sm-sec { display: grid; gap: .625rem; padding: .875rem 1rem; }
.sm-sec + .sm-sec { border-top: 1px solid var(--rule); }
.sm-sec-title { font: 600 1rem/1.3 var(--f-display); }
.sm-grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr)); gap: .5rem; }
.sm-row { display: flex; flex-wrap: wrap; gap: .375rem; }
.sm-row .sm-btn { flex: 1 1 8rem; }
.sm-btn.primary { border-color: var(--slab); background: var(--slab); color: var(--on-slab); box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 40%, transparent); }
.sm-save { width: 100%; }
.sm-list { display: grid; gap: .375rem; }
.sm-list:empty::before { content: "—"; color: var(--ink-3); }
.list-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; min-width: 0; padding: .5rem .625rem;
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--field); font-size: .8125rem; line-height: 1.4;
}
.list-item > b, .list-item > strong { flex: 1 1 100%; font-size: .875rem; font-weight: 600; overflow-wrap: anywhere; }
.list-item > small, .list-item > span { flex: 1 1 100%; color: var(--ink-3); overflow-wrap: anywhere; }
.list-item br { display: none; }
.list-item button {
  display: inline-flex; align-items: center; gap: .3125rem; min-height: 2rem; padding: .125rem .625rem; border: 1px solid var(--rule-2); border-radius: 999px;
  background: transparent; color: var(--ink); font: 600 .8125rem/1.2 var(--f-ui);
}
.list-item button:disabled { opacity: .45; }
@media (hover: hover) and (pointer: fine) { .list-item button:hover:not(:disabled) { background: var(--plate-2); } }
.list-item button:is(.danger, [data-delete], .delete) { color: var(--alert); border-color: color-mix(in oklab, var(--alert) 40%, transparent); }
.list-item.active, .list-item[aria-current="true"] { border-color: var(--ink-3); box-shadow: inset 3px 0 var(--signal); }
.sim-quality-warning { padding: .5rem .625rem; border-left: 3px solid var(--warn); border-radius: .25rem; background: color-mix(in oklab, var(--warn) 10%, var(--plate)); font-size: .8125rem; line-height: 1.45; color: var(--ink); }

/* ==== work surface: scope + results ==== */
.sm-work { position: relative; flex: 1 1 auto; display: grid; gap: .625rem; min-width: 0; min-height: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.sm-mapzone {
  position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; overflow: hidden;
  container: mapzone / inline-size; border-radius: .5rem; background: var(--scope); color: var(--on-scope);
  box-shadow: 0 0 0 1px var(--scope-rule) inset;
}
.sm-mapzone:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* map tool bar: one row; captions fold away before the tools wrap */
.sm-mapbar {
  display: flex; align-items: center; gap: .375rem; min-width: 0; padding: .375rem .5rem; background: var(--scope-2);
  border-bottom: 1px solid var(--scope-rule);
}
.sm-tools { display: inline-flex; align-items: center; gap: .125rem; padding: .125rem; border-radius: calc(var(--r) + .125rem); background: rgb(255 255 255 / .04); }
.sm-mapbar .sm-tool { border-color: transparent; background: transparent; color: var(--on-scope); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .sm-mapbar .sm-tool:hover:not(:disabled) { background: var(--scope-3); border-color: transparent; } }
.sm-mapbar .sm-tool:focus-visible { outline-color: var(--scope-signal); }
/* layer toggles carry a lamp: lit while the layer is drawn */
.sm-layer { padding-right: 1.25rem !important; }
.sm-layer::after {
  content: ""; position: absolute; right: .5rem; top: 50%; width: .375rem; height: .375rem; margin-top: -.1875rem; border-radius: 50%;
  background: transparent; box-shadow: inset 0 0 0 1.5px var(--on-scope-2); transition: background-color .16s ease, box-shadow .16s ease;
}
.sm-layer[aria-pressed="true"]::after { background: var(--scope-signal); box-shadow: 0 0 .375rem color-mix(in oklab, var(--scope-signal) 70%, transparent); }
.sm-layer[aria-pressed="false"] { color: var(--on-scope-2); }
.sm-zoomread { min-width: 3.25rem; padding: 0 .25rem; text-align: center; font: 600 .8125rem/1 var(--f-num); color: var(--on-scope-2); font-variant-numeric: tabular-nums; }
.sm-open { display: none !important; }
.sm-lamp { width: .5rem; height: .5rem; border-radius: 50%; background: var(--warn); }
body[data-next="run"] .sm-lamp { background: var(--ok); }
body[data-next="running"] .sm-lamp { background: var(--scope-signal); animation: sm-blink 1.2s ease-in-out infinite; }
.sm-cap-hidden, .sm-mapbar .sm-cap.is-folded { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@container mapzone (max-width: 46rem) {
  #toggleMapSummary .sm-cap, #fitMap .sm-cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #toggleMapSummary, #fitMap { padding-inline: .5rem; }
  #toggleMapSummary { padding-right: 1.25rem; }
}
@container mapzone (max-width: 34rem) {
  .sm-mapbar .sm-cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .sm-mapbar .sm-tool { padding-left: .5rem; }
  .sm-mapbar { gap: .25rem; padding-inline: .375rem; }
}
@container mapzone (max-width: 25rem) {
  .sm-zoomread { display: none; }
  .sm-mapbar { flex-wrap: wrap; }
}

/* the frame: the canvas alone, engine-sized */
.sm-frame { position: relative; min-width: 0; min-height: 12rem; overflow: hidden; background: var(--scope); }
.sm-frame > canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.sm-frame:not([data-mode="browse"])::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: 0;
  box-shadow: inset 0 0 0 2px var(--scope-signal), inset 0 0 2.5rem -1rem var(--scope-signal);
  animation: sm-fade .2s ease;
}
.sm-frame[data-mode="start"], .sm-frame[data-mode="goal"], .sm-frame[data-mode="draw"] { cursor: crosshair; }
.sm-corner { position: absolute; z-index: 1; width: .875rem; height: .875rem; pointer-events: none; border-color: var(--on-scope-2); opacity: .6; }
.sm-corner.tl { left: .5rem; top: .5rem; border-left: 1.5px solid; border-top: 1.5px solid; }
.sm-corner.br { right: .5rem; bottom: .5rem; border-right: 1.5px solid; border-bottom: 1.5px solid; }
.route-overlap-button{position:absolute;z-index:2;left:.75rem;bottom:.75rem;display:flex;align-items:center;gap:.5rem;max-width:calc(100% - 1.5rem);min-height:44px;padding:.5rem .75rem;border:1px solid #63818d;border-radius:.375rem;background:#15252e;color:#eef7fa;font:600 .75rem/1.4 var(--f-ui,system-ui);text-align:left;box-shadow:0 2px 8px #0005;cursor:pointer}
.route-overlap-button[hidden]{display:none}.route-overlap-button i{flex:none;width:2rem;height:.375rem;border:1px solid #05090c}.route-overlap-button:focus-visible{outline:2px solid #7ce5d4;outline-offset:2px}
#routeStyleControls .route-style-header strong>button[data-route-details]{display:inline;border:0;padding:0;margin:0;min-height:0;background:none;box-shadow:none;color:inherit;font:inherit;line-height:inherit;white-space:inherit;overflow-wrap:inherit;text-align:inherit;cursor:pointer}
#routeStyleControls [data-route-details]:is(:hover,:focus-visible){text-decoration:underline;text-underline-offset:.2em}#routeStyleControls [data-route-details]:focus-visible{outline:2px solid currentColor;outline-offset:3px}
.sm-plate-empty { position: absolute; inset: 0; z-index: 1; display: none; place-content: center; justify-items: center; gap: 1rem; padding: 1.5rem; text-align: center; color: var(--on-scope-2); pointer-events: none; }
.sm-frame:is([data-map="loading"], [data-map="stalled"]) .sm-plate-empty { display: grid; }
.sm-plate-empty p { display: none; max-width: 32ch; font-size: .875rem; line-height: 1.5; }
.sm-frame[data-map="loading"] .sm-plate-empty p[data-show="loading"], .sm-frame[data-map="stalled"] .sm-plate-empty p[data-show="error"] { display: block; }
.sm-plate-wave { position: relative; width: 4.5rem; height: 4.5rem; border-radius: 50%; border: 1.5px solid var(--scope-rule); }
.sm-plate-wave::before, .sm-plate-wave::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--scope-signal); opacity: 0; animation: sm-emit 2.2s var(--ease) infinite; }
.sm-plate-wave::after { animation-delay: 1.1s; }
.sm-frame[data-map="stalled"] .sm-plate-wave::before, .sm-frame[data-map="stalled"] .sm-plate-wave::after { border-color: var(--warn); animation-iteration-count: 1; }

/* armed-tool pill (browse stays silent but keeps its live region) */
.sm-mode {
  position: absolute; z-index: 6; left: .75rem; top: .75rem; display: flex; align-items: center; gap: .5rem; max-width: calc(100% - 1.5rem);
  padding: .3125rem .3125rem .3125rem .375rem; border-radius: 999px; background: rgb(10 12 10 / .9); color: var(--on-scope);
  box-shadow: 0 0 0 1px var(--scope-rule), 0 .5rem 1.5rem rgb(0 0 0 / .4); font: 600 .875rem/1.3 var(--f-ui);
  animation: sm-drop .18s var(--ease);
}
.sm-mode[data-mode="browse"] { position: absolute !important; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; animation: none; }
.sm-mode-glyph { flex: none; display: grid; place-items: center; width: 1.875rem; height: 1.875rem; border-radius: 50%; background: var(--scope-signal); color: #121412; }
.sm-mode-glyph .ui-icon { display: none; width: 1rem; height: 1rem; }
.sm-mode[data-mode="browse"] .sm-mode-glyph [data-for="browse"], .sm-mode[data-mode="start"] .sm-mode-glyph [data-for="start"],
.sm-mode[data-mode="goal"] .sm-mode-glyph [data-for="goal"], .sm-mode[data-mode="draw"] .sm-mode-glyph [data-for="draw"] { display: block; }
.sm-mode-text { min-width: 0; overflow-wrap: anywhere; }
.sm-mode-exit {
  flex: none; display: inline-flex; align-items: center; gap: .3125rem; min-height: 2rem; padding: .125rem .75rem .125rem .5rem;
  border: 1px solid var(--scope-rule); border-radius: 999px; background: transparent; color: var(--on-scope); font: 600 .8125rem/1.2 var(--f-ui);
}
.sm-mode-exit .ui-icon { width: .9375rem; height: .9375rem; }
@media (hover: hover) and (pointer: fine) { .sm-mode-exit:hover { background: var(--scope-3); } }
.sm-mode-exit:focus-visible { outline: 2px solid var(--scope-signal); outline-offset: 2px; }

/* ---- map comparison overlay
   The engine sizes and places this box; it is the outer limit. The visible card hugs its content inside it,
   so an empty or short comparison never blankets the map, and the clear part lets the map receive pointers. */
.sm-cmp {
  position: absolute; z-index: 3; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  /* a readout, not a second results panel: the dock below carries the full cards, so the scope keeps most of its field */
  max-width: min(calc(100% - 1.5rem), max(21rem, 348px, 24%), max(23rem, 348px)); max-height: calc(100% - 1rem);
  pointer-events: none; color: var(--on-scope); filter: drop-shadow(0 .5rem 1rem rgb(0 0 0 / .4));
}
.sm-cmp > * { pointer-events: auto; background: rgb(15 18 15 / .97); border-inline: 1px solid var(--scope-rule); }
.sm-cmp[data-surface="transparent"] > * { background: rgb(15 18 15 / .66); -webkit-backdrop-filter: blur(.625rem) saturate(1.2); backdrop-filter: blur(.625rem) saturate(1.2); }
.sm-cmp[data-dock="right"]:not(.window-dragging) { left: auto !important; right: .75rem !important; }
.sm-cmp[data-dock="top"]:not(.window-dragging) { left: 50% !important; right: auto !important; translate: -50% 0; max-width: min(40rem, calc(100% - 1.5rem)); max-height: 46%; }
.sm-cmp[data-dock="bottom"] { justify-content: flex-end; max-width: none; }
.sm-cmp.window-snapping { transition: left .22s var(--ease-move), top .22s var(--ease-move), width .22s var(--ease-move), height .22s var(--ease-move); }
.sm-cmp.window-dragging, .sm-cmp.window-resizing { filter: drop-shadow(0 1rem 1.75rem rgb(0 0 0 / .55)); }
.sm-cmp-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .375rem .375rem .375rem .625rem;
  border-top: 1px solid var(--scope-rule); border-radius: .5rem .5rem 0 0; cursor: grab; touch-action: none;
}
.sm-cmp.window-dragging .sm-cmp-head { cursor: grabbing; }
.sm-cmp-title { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.sm-cmp-title > span { display: grid; min-width: 0; }
.sm-cmp-title small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sm-cmp-title strong { font: 600 .8125rem/1.25 var(--f-display); overflow-wrap: anywhere; }
.sm-cmp .sm-grip { color: var(--on-scope-2); }
.sm-cmp-actions { flex: none; display: flex; gap: .125rem; }
.sm-tool-s { min-width: 2rem; min-height: 2rem; border-color: transparent; background: transparent; color: var(--on-scope-2); }
@media (hover: hover) and (pointer: fine) { .sm-cmp .sm-tool-s:hover { background: var(--scope-3); color: var(--on-scope); border-color: transparent; } }
.sm-tool-s[aria-pressed="true"] { color: var(--scope-signal); }
.sm-cmp-empty { flex: none; padding: .625rem .75rem .75rem; font-size: .8125rem; line-height: 1.45; color: var(--on-scope-2); }
.sm-cmp:has(.sm-cmp-body:not(:empty)) .sm-cmp-empty { display: none; }
.sm-cmp-body { flex: 0 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; border-top: 1px solid var(--scope-rule); }
.sm-cmp-body:empty { display: none; }
.sm-cmp-resize { flex: none; position: relative; height: .875rem; border-bottom: 1px solid var(--scope-rule); border-radius: 0 0 .5rem .5rem; cursor: nwse-resize; touch-action: none; }
.sm-cmp-resize::after {
  content: ""; position: absolute; right: .25rem; bottom: .1875rem; width: .625rem; height: .625rem;
  background: linear-gradient(135deg, transparent 0 45%, var(--on-scope-2) 45% 52%, transparent 52% 68%, var(--on-scope-2) 68% 75%, transparent 75%);
  opacity: .7;
}
.sm-cmp[data-dock="bottom"] .sm-cmp-resize { cursor: ns-resize; }
.sm-snap { position: absolute; z-index: 2; border: 2px dashed var(--scope-signal); border-radius: .5rem; background: color-mix(in oklab, var(--scope-signal) 12%, transparent); pointer-events: none; }

/* comparison content (engine markup) */
.map-summary-route-list { display: grid; }
.map-summary-route { display: grid; gap: .1875rem; padding: .4375rem .625rem .5rem; border-bottom: 1px solid var(--scope-rule); }
.map-summary-route:last-child { border-bottom: 0; }
.map-summary-route > header { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.map-summary-route > header strong { flex: 1 1 auto; min-width: 0; font-size: .8125rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.map-summary-route > header small { flex: none; font: 600 .75rem/1 var(--f-num); color: var(--on-scope-2); }
/* values read as one line of label-value pairs under the route name, wrapping only when the readout is narrow */
.map-summary-route-metrics { display: flex; flex-wrap: wrap; gap: .125rem .875rem; padding-left: 2.25rem; }
.map-summary-value { display: inline-grid; grid-template-columns: auto auto; align-items: baseline; column-gap: .375rem; min-width: 0; }
.map-summary-value small { font-size: .75rem; line-height: 1.3; color: var(--on-scope-2); overflow-wrap: anywhere; }
.map-summary-value b { font: 600 .8125rem/1.3 var(--f-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-summary-value.with-bar::after {
  content: ""; grid-column: 1 / -1; height: 2px; margin-top: .125rem; border-radius: 1px; background: var(--route-color);
  transform: scaleX(var(--metric-ratio, 0)); transform-origin: left; transition: transform .3s var(--ease);
}
.map-summary-value.with-bar { background: linear-gradient(var(--scope-3), var(--scope-3)) left bottom / 100% 2px no-repeat; }
@container mapzone (max-width: 34rem) { .map-summary-route-metrics { padding-left: 0; } }
.map-summary-metric-list { display: grid; }
.map-summary-metric { display: grid; gap: .3125rem; padding: .5rem .75rem; border-bottom: 1px solid var(--scope-rule); }
.map-summary-metric:last-child { border-bottom: 0; }
.map-summary-metric > header { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.map-summary-metric > header strong { font-size: .875rem; font-weight: 600; overflow-wrap: anywhere; }
.map-summary-metric > header small { font: .75rem/1 var(--f-num); color: var(--on-scope-2); }
.map-summary-metric-row { display: grid; grid-template-columns: minmax(4.5rem, 7.5rem) minmax(0, 1fr) auto; align-items: center; gap: .5rem; }
.map-summary-metric-row > span { display: flex; align-items: center; gap: .375rem; min-width: 0; font-size: .75rem; color: var(--on-scope-2); overflow-wrap: anywhere; }
.map-summary-metric-row > span::before { content: ""; flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: var(--route-color); }
.map-summary-metric-row > i { height: .375rem; border-radius: 3px; background: var(--scope-3); }
.map-summary-metric-row > i.with-bar { background: linear-gradient(90deg, var(--route-color) calc(var(--metric-ratio, 0) * 100%), var(--scope-3) 0); }
.map-summary-metric-row > b { font: 600 .8125rem/1.2 var(--f-num); font-variant-numeric: tabular-nums; text-align: end; }

/* route hover readout */
.sm-hover {
  position: absolute; z-index: 7; display: grid; gap: .375rem; max-width: min(18rem, calc(100% - 1rem)); padding: .5rem .625rem;
  border: 1px solid var(--scope-rule); border-radius: .375rem; background: rgb(12 14 12 / .96); color: var(--on-scope);
  box-shadow: 0 .5rem 1.5rem rgb(0 0 0 / .45); font-size: .8125rem; line-height: 1.35; pointer-events: none;
}
.route-hover-heading { display: grid; gap: .125rem; }
.route-hover-heading small, .route-hover-row small { color: var(--on-scope-2); }
.route-hover-row { display: flex; align-items: flex-start; gap: .5rem; }
.route-hover-row > span:last-child { display: grid; min-width: 0; }
.route-hover-row small { font-family: var(--f-num); }

/* route patterns: one vocabulary for every swatch the engine renders */
:is(.route-legend-line, .route-style-preview, .route-hover-swatch, .map-summary-route-line) {
  --w: 3px; flex: none; display: inline-block; width: 1.75rem; height: max(var(--w), 3px); border-radius: 2px;
  background: var(--route-color); vertical-align: middle;
}
:is(.route-legend-line, .route-style-preview, .route-hover-swatch, .map-summary-route-line).dashed { background: repeating-linear-gradient(90deg, var(--route-color) 0 .375rem, transparent .375rem .5625rem); }
:is(.route-legend-line, .route-style-preview, .route-hover-swatch, .map-summary-route-line).dotted { background: repeating-linear-gradient(90deg, var(--route-color) 0 .1875rem, transparent .1875rem .375rem); }
:is(.route-legend-line, .route-style-preview, .route-hover-swatch, .map-summary-route-line).dashdot { background: repeating-linear-gradient(90deg, var(--route-color) 0 .375rem, transparent .375rem .5rem, var(--route-color) .5rem .5625rem, transparent .5625rem .6875rem); }
.route-hover-swatch { margin-top: .4375rem; }
.route-legend-line { --w: min(var(--route-width, 3px), 6px); }

/* keys and the browse hint under the scope */
.sm-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: .375rem 1rem; padding: .4375rem .75rem; background: var(--scope-2); color: var(--on-scope-2);
  border-top: 1px solid var(--scope-rule); font-size: .8125rem; line-height: 1.3;
}
.sm-routelegend { display: flex; flex-wrap: wrap; gap: .375rem .875rem; color: var(--on-scope); }
.sm-routelegend:empty { display: none; }
.sm-routelegend:not(:empty) + .sm-keys { padding-left: 1rem; border-left: 1px solid var(--scope-rule); }
.route-legend-item { display: inline-flex; align-items: center; gap: .4375rem; font-weight: 600; }
.sm-keys { display: flex; flex-wrap: wrap; gap: .375rem .875rem; }
.sm-keys li { display: inline-flex; align-items: center; gap: .375rem; }
.sm-keys i { flex: none; width: .6875rem; height: .6875rem; border-radius: .125rem; }
.k-start { background: #19c7de; border-radius: 50% !important; }
.k-goal { background: #ffe064; border-radius: 50% !important; box-shadow: inset 0 0 0 2px #14252d; }
.k-open { background: #84d8e8; }
.k-closed { background: #df8d9b; }
.k-current { background: #fff; box-shadow: inset 0 0 0 2px #14252d; }
.k-layer { background: rgba(184, 60, 60, .55); }
.k-walkable { background: #22c887; }
.k-blocked { background: #ef5265; }
.k-discouraged { background: #f0ad49; }
.k-unknown { background: #89919a; }
.k-annotation { background: #a88cde; }
.sm-legend[data-access="version"] .sm-keys li[data-key="legacy"], .sm-legend:not([data-access="version"]) .sm-keys li[data-key="version"] { display: none; }
.sm-legend-hint { display: inline-flex; align-items: center; gap: .375rem; margin-left: auto; color: var(--on-scope-2); }
.sm-legend-hint .ui-icon { width: 1rem; height: 1rem; }
@container mapzone (max-width: 40rem) { .sm-legend-hint { display: none; } }

/* ==== results dock ==== */
.sm-dock {
  position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0;
  container: dock / inline-size; border: 1px solid var(--rule); border-radius: .5rem; background: var(--plate);
}
.sm-dock-resize { position: absolute; z-index: 3; touch-action: none; }
.sm-dock[data-dock-position="bottom"] .sm-dock-resize { left: 0; right: 0; top: -.5rem; height: .75rem; cursor: ns-resize; }
.sm-dock[data-dock-position="right"] .sm-dock-resize { top: 0; bottom: 0; left: -.5rem; width: .75rem; cursor: ew-resize; }
.sm-dock-resize::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 2.5rem; height: .25rem; border-radius: 999px; background: var(--rule-2);
  transform: translate(-50%, -50%); transition: background-color .16s ease;
}
.sm-dock[data-dock-position="right"] .sm-dock-resize::after { width: .25rem; height: 2.5rem; }
@media (hover: hover) and (pointer: fine) { .sm-dock-resize:hover::after { background: var(--ink-3); } }

.sm-dock-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .625rem; min-width: 0; padding: .5rem .75rem;
  border-bottom: 1px solid var(--rule); cursor: grab; touch-action: none;
}
.sm-work.dock-dragging .sm-dock-head { cursor: grabbing; }
.sm-dock-head .sm-grip { color: var(--ink-3); }
.sm-dock-title { display: grid; min-width: 0; font: 600 1.0625rem/1.2 var(--f-display); }
.sm-dock-title small { font: 600 .75rem/1.3 var(--f-ui); color: var(--ink-3); }
.sm-count-wide { padding-inline: .5rem; }
.sm-dock-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; cursor: auto; }
/* route set commands beside the count: show all is outlined only while a route is hidden; clear stays quiet */
.sm-dock-tools #showAllCosts { border-color: transparent; background: transparent; color: var(--ink); padding-inline: .5rem .625rem; }
.sm-dock-tools #showAllCosts:not(:disabled, [data-complete="true"]) { border-color: var(--rule-2); background: var(--plate); }
.sm-dock-tools #showAllCosts:is(:disabled, [data-complete="true"]) { color: var(--ink-3); opacity: .6; }
body:not([data-shown="yes"]) .sm-dock-tools #showAllCosts { display: none; }
@media (hover: hover) and (pointer: fine) { .sm-dock-tools #showAllCosts:hover:not(:disabled) { background: var(--plate-2); border-color: var(--ink-3); } }
/* results layout: where the dock sits is a command; how much it takes is a choice of two sizes */
.sm-dock-layout { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; padding-left: .625rem; border-left: 1px solid var(--rule); }
.sm-dock-move { padding-inline: .5rem .625rem; }
.sm-dock-size { display: inline-flex; gap: .125rem; padding: .125rem; border-radius: calc(var(--r) + .125rem); background: var(--plate-2); }
.sm-dock-size .sm-tool { min-height: calc(var(--ctl) - .25rem); border-color: transparent; background: transparent; color: var(--ink-2); padding-inline: .5rem .625rem; }
.sm-dock-size .sm-tool[aria-pressed="true"] { background: var(--plate); color: var(--ink); box-shadow: 0 0 0 1px var(--rule-2), 0 1px 2px rgb(0 0 0 / .12); }
@media (hover: hover) and (pointer: fine) { .sm-dock-size .sm-tool:not([aria-pressed="true"]):hover:not(:disabled) { background: var(--plate); border-color: transparent; color: var(--ink); } }
/* size glyph: a frame filled to the share of the bench it takes */
.sm-size::before {
  content: ""; flex: none; width: 1.0625rem; height: 1.0625rem; border: 2px solid currentColor; border-radius: .1875rem;
  background: linear-gradient(currentColor, currentColor) left bottom / 100% var(--fill, 35%) no-repeat;
}
.sm-size[data-size="expanded"] { --fill: 75%; }
.sm-dock[data-dock-position="right"] .sm-size::before { background-position: right top; background-size: var(--fill, 35%) 100%; }
/* a narrower dock: title and route set commands on the first line, the results layout on its own aligned line */
@container dock (max-width: 51.99rem) {
  .sm-dock-tools { display: contents; }
  .sm-dock-layout { order: 1; flex: 1 1 100%; justify-content: space-between; padding-left: 0; border-left: 0; }
}
@container dock (max-width: 40rem) {
  #clearRoute .sm-cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #clearRoute { padding-inline: 0; }
}
@container dock (max-width: 22rem) {
  .sm-dock-head .sm-grip { display: none; }
  .sm-dock-tools #showAllCosts .i18n-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .sm-dock-tools #showAllCosts { padding-inline: 0; }
}

.sm-dock-body { position: relative; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; scrollbar-gutter: stable; }
.sm-traces { flex: 1 0 auto; display: flex; flex-direction: column; gap: .75rem; min-width: 0; padding: .75rem; }

/* ---- result state (engine markup inside #routeResults) */
#routeResults:empty { display: none; }
#routeResults[data-variant="panel"] {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .875rem; padding: 1rem 1.125rem 1.125rem 1rem;
  border: 1px solid var(--rule); border-radius: .5rem; background: var(--field); animation: sm-in .24s var(--ease);
}
.sm-state-mark {
  position: relative; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  background: var(--scope); color: var(--scope-signal);
}
.sm-state-mark .ui-icon, .sm-state-mark svg { width: 1.25rem; height: 1.25rem; }
.sm-state-mark::before, .sm-state-mark::after { content: ""; position: absolute; inset: -.3125rem; border-radius: 50%; border: 1px solid var(--rule-2); pointer-events: none; }
.sm-state-mark::after { inset: -.6875rem; opacity: .5; }
#routeResults[data-state="running"] .sm-state-mark::before, #routeResults[data-state="running"] .sm-state-mark::after { border-color: var(--signal); animation: sm-emit 1.6s var(--ease) infinite; }
#routeResults[data-state="running"] .sm-state-mark::after { animation-delay: .8s; }
#routeResults[data-state="error"] .sm-state-mark { background: color-mix(in oklab, var(--alert) 16%, var(--field)); color: var(--alert); }
#routeResults[data-state="error"] .sm-state-mark::before, #routeResults[data-state="error"] .sm-state-mark::after { border-color: color-mix(in oklab, var(--alert) 40%, transparent); }
#routeResults[data-state="error"] { border-color: color-mix(in oklab, var(--alert) 45%, transparent); }
.sm-state-copy { display: grid; gap: .5rem; min-width: 0; }
.sm-state-copy > strong { font: 600 1.0625rem/1.3 var(--f-display); overflow-wrap: anywhere; }
.sm-state-copy > p { max-width: 52ch; font-size: .875rem; line-height: 1.5; color: var(--ink-2); overflow-wrap: anywhere; }
.sm-state-traces { display: grid; gap: .375rem; padding-top: .625rem; border-top: 1px solid var(--rule); }
.sm-state-traces > small { font: 600 .75rem/1.3 var(--f-ui); color: var(--ink-3); }
.sm-state-traces ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr)); gap: .25rem .75rem; }
.sm-state-traces li { display: flex; align-items: center; gap: .5rem; min-width: 0; font-size: .875rem; line-height: 1.35; overflow-wrap: anywhere; }
.sm-state-traces .route-style-preview { width: 1.75rem; height: .75rem; border-radius: .1875rem; box-shadow: none; background-size: 100% 3px; background-repeat: repeat-x; background-position: center; background-color: var(--scope); }
.sm-state-traces .route-style-preview:not(.dashed, .dotted, .dashdot) { background: linear-gradient(var(--route-color), var(--route-color)) center / 100% 3px no-repeat, var(--scope); }
.sm-state-traces .route-style-preview.dashed { background: repeating-linear-gradient(90deg, var(--route-color) 0 .375rem, transparent .375rem .5625rem) center / 100% 3px no-repeat, var(--scope); }
.sm-state-traces .route-style-preview.dotted { background: repeating-linear-gradient(90deg, var(--route-color) 0 .1875rem, transparent .1875rem .375rem) center / 100% 3px no-repeat, var(--scope); }
.sm-state-traces .route-style-preview.dashdot { background: repeating-linear-gradient(90deg, var(--route-color) 0 .375rem, transparent .375rem .5rem, var(--route-color) .5rem .5625rem, transparent .5625rem .6875rem) center / 100% 3px no-repeat, var(--scope); }
#routeResults[data-state="running"] .sm-state-traces li { animation: sm-breathe 1.8s ease-in-out infinite; }
#routeResults[data-state="running"] .sm-state-traces li:nth-child(2) { animation-delay: .2s; }
#routeResults[data-state="running"] .sm-state-traces li:nth-child(3) { animation-delay: .4s; }
#routeResults[data-state="running"] .sm-state-traces li:nth-child(4) { animation-delay: .6s; }
.sm-state-action {
  justify-self: start; display: inline-flex; align-items: center; gap: .4375rem; min-height: var(--ctl); padding: .25rem .875rem .25rem .75rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--plate); color: var(--ink); font: 600 .875rem/1.2 var(--f-ui);
  transition: background-color .16s ease, border-color .16s ease;
}
.sm-state-action:disabled { opacity: .45; }
@media (hover: hover) and (pointer: fine) { .sm-state-action:hover:not(:disabled) { background: var(--plate-2); border-color: var(--ink-3); } }
#routeResults[data-variant="line"] { display: block; padding: .5rem .75rem; border-radius: var(--r); background: var(--plate-2); animation: sm-in .2s var(--ease); }
.sm-state-line { display: flex; align-items: center; gap: .5rem; font-size: .875rem; line-height: 1.4; color: var(--ink-2); overflow-wrap: anywhere; }
.sm-state-line .ui-icon, .sm-state-line svg { flex: none; width: 1rem; height: 1rem; }
.sm-state-pulse { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ink); animation: sm-blink 1.2s ease-in-out infinite; }
:root[data-theme="dark"] .sm-state-pulse { background: var(--signal); }
#routeResults[data-variant="line"][data-state="error"] { border: 1px solid color-mix(in oklab, var(--alert) 45%, transparent); background: color-mix(in oklab, var(--alert) 8%, var(--plate)); }
#routeResults[data-variant="line"][data-state="error"] .sm-state-line { color: var(--alert); }
#routeResults table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
#routeResults :is(th, td) { padding: .375rem .5rem; border-bottom: 1px solid var(--rule); text-align: start; }
@container dock (max-width: 22rem) {
  #routeResults[data-variant="panel"] { grid-template-columns: minmax(0, 1fr); }
}

/* ---- cards panel, in document order: the styles switch and the analysis commands share one line,
   the card order choice takes the next (or the return bar while inspecting), then the list */
.sm-cards-panel { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .375rem; min-width: 0; }
.sm-cards-tools { display: flex; align-items: center; gap: .25rem; min-width: 0; }
.sm-cards-out { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .375rem; margin-left: auto; min-width: 0; }
.sm-cards-panel > .route-comparison-tools { flex: 1 1 100%; min-width: 0; margin: 0; }
.sm-cards-panel > .route-inspector { flex: 1 1 100%; min-width: 0; }
.sm-cards-panel > #routeStyleControls { flex: 1 1 100%; }
@container dock (max-width: 25rem) { .sm-cards-panel #smStyles > .ui-icon { display: none; } }

/* line styles: an on/off switch */
.sm-cards-panel #smStyles { gap: .5rem; border-color: transparent; background: transparent; padding-inline: .5rem; }
.sm-cards-panel #smStyles .style-switch-track {
  position: relative; flex: none; display: inline-block; width: 2.125rem; height: 1.25rem; border-radius: 999px;
  border: 0; background: var(--rule-2); transition: background-color .18s ease;
}
.sm-cards-panel #smStyles .style-switch-track::after {
  content: ""; position: absolute; left: .1875rem; top: .1875rem; width: .875rem; height: .875rem; border-radius: 50%;
  background: var(--plate); box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .2s var(--ease);
}
.sm-cards-panel #smStyles[aria-checked="true"] { color: var(--ink); background: transparent; }
.sm-cards-panel #smStyles[aria-checked="true"] .style-switch-track { background: var(--slab); }
.sm-cards-panel #smStyles[aria-checked="true"] .style-switch-track::after { transform: translateX(.875rem); background: var(--signal); }
@media (hover: hover) and (pointer: fine) { .sm-cards-panel #smStyles:hover { background: var(--plate-2); } }
.sm-cards-panel #smStylesClose { min-width: 2rem; min-height: 2rem; border-color: transparent; background: transparent; }
/* analysis: budget (outline) and chart (slab) */
.sm-cards-out #routeChoiceBudget { border: 1px solid var(--rule-2); background: var(--plate); color: var(--ink); }
.sm-cards-out #openChartBuilder { border-color: var(--slab); background: var(--slab); color: var(--on-slab); }
.sm-cards-out #openChartBuilder .ui-icon { color: var(--signal); }
.sm-cards-out #openChartBuilder:disabled { border-color: var(--rule-2); background: var(--plate-2); color: var(--ink-3); opacity: .7; }
.sm-cards-out #openChartBuilder:disabled .ui-icon { color: inherit; }

/* inspector tools: order modes as a segmented pill, reset as a quiet tool, return as a full-width bar */
.sm-cards-panel .route-comparison-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; }
.sm-cards-panel .route-comparison-tools button { min-height: var(--ctl); font: 600 .875rem/1.2 var(--f-ui); }
.sm-cards-panel .route-layout-modes { display: inline-flex; gap: .125rem; padding: .125rem; border-radius: calc(var(--r) + .125rem); background: var(--plate-2); }
.sm-cards-panel .route-layout-modes button {
  display: inline-flex; align-items: center; gap: .375rem; min-height: calc(var(--ctl) - .25rem); padding: .125rem .625rem; border: 0; border-radius: var(--r);
  background: transparent; color: var(--ink-2);
}
.sm-cards-panel .route-layout-modes button:is([aria-pressed="true"], [aria-checked="true"], .active) { background: var(--plate); color: var(--ink); box-shadow: 0 0 0 1px var(--rule-2), 0 1px 2px rgb(0 0 0 / .12); }
.sm-cards-panel #resetRouteCardOrder { min-width: var(--ctl); border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--ink-2); }
@media (hover: hover) and (pointer: fine) { .sm-cards-panel #resetRouteCardOrder:hover:not(:disabled) { background: var(--plate-2); } }
.sm-cards-panel #returnRouteComparison {
  flex-basis: 100%; display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--hit);
  border: 0; border-radius: var(--r); background: var(--slab); color: var(--on-slab); font: 600 .9375rem/1.2 var(--f-ui);
}
.sm-cards-panel #returnRouteComparison .ui-icon { color: var(--signal); }
.sm-cards-panel .route-layout-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- the card list: one column by default; auto layout is the user's choice */
#routeStyleControls { display: grid; grid-template-columns: minmax(0, 1fr); gap: .625rem; min-width: 0; container: cards / inline-size; }
#routeStyleControls[data-card-layout="auto"] { grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); }
#routeStyleControls:empty { display: none; }

#routeStyleControls .route-style-card {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: .625rem; min-width: 0;
  padding: .75rem .875rem .875rem 1.125rem; border: 1px solid var(--rule); border-radius: .5rem; background: var(--field);
  box-shadow: none; transition: border-color .18s ease, box-shadow .18s ease, opacity .18s ease, transform .18s var(--ease);
}
#routeStyleControls .route-style-card::before { content: ""; position: absolute; left: .375rem; top: .75rem; bottom: .75rem; width: .1875rem; border-radius: 2px; background: var(--route-color); }
#routeStyleControls .route-style-card.hidden-cost { opacity: .62; }
#routeStyleControls .route-style-card.hidden-cost::before { background: var(--rule-2); }
#routeStyleControls .route-style-card:is(.selected-route, .active-route, .active-cost) { border-color: var(--route-color); box-shadow: 0 0 0 1px var(--route-color); }
#routeStyleControls .route-style-card.is-dragging { opacity: .55; transform: scale(.985); }
#routeStyleControls .route-style-card.is-drop-target { box-shadow: 0 -3px 0 0 var(--ink); }
#routeStyleControls .route-style-card:is([data-result="no-path"], [data-result="excluded"]) { border-style: dashed; border-color: var(--rule-2); background: transparent; }
#routeStyleControls .route-style-card:is([data-result="no-path"], [data-result="excluded"])::before { opacity: .45; }

/* header: handle · trace · name/algorithm · visibility */
#routeStyleControls .route-style-header {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "handle trace name eye" "handle trace algo eye";
  align-items: center; column-gap: .625rem; row-gap: 0; min-width: 0;
}
#routeStyleControls .route-style-header > .route-card-handle { grid-area: handle; }
#routeStyleControls .route-style-header > .route-style-preview { grid-area: trace; }
#routeStyleControls .route-style-header > strong { grid-area: name; min-width: 0; font: 600 1rem/1.3 var(--f-display); overflow-wrap: anywhere; }
#routeStyleControls .route-style-header > em { grid-area: algo; min-width: 0; font: 500 .75rem/1.3 var(--f-num); font-style: normal; text-transform: uppercase; color: var(--ink-3); overflow-wrap: anywhere; }
#routeStyleControls .route-style-header > .visibility-toggle { grid-area: eye; }
#routeStyleControls .route-style-header:not(:has(> em)) { grid-template-areas: "handle trace name eye"; }
#routeStyleControls .route-style-header:not(:has(> .route-card-handle)) { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "trace name eye" "trace algo eye"; }
#routeStyleControls .route-style-header:not(:has(> .route-card-handle)):not(:has(> em)) { grid-template-areas: "trace name eye"; }
#routeStyleControls .route-style-preview { --w: min(var(--route-width, 4px), 8px); width: 2.75rem; height: max(var(--w), 3px); margin: 0; box-shadow: 0 0 0 .375rem var(--scope); border-radius: 1px; }
#routeStyleControls .route-style-header > .route-style-preview { margin-inline: .375rem; }
#routeStyleControls .route-card-handle {
  display: grid; place-items: center; width: 1.75rem; min-height: 2.25rem; padding: 0; border: 0; border-radius: .25rem; background: transparent; color: var(--ink-3); cursor: grab; touch-action: none;
}
@media (hover: hover) and (pointer: fine) { #routeStyleControls .route-card-handle:hover { background: var(--plate-2); color: var(--ink); } }

/* visibility: one real eye, one state word */
#routeStyleControls .visibility-toggle {
  position: relative; display: inline-flex; align-items: center; gap: .375rem; width: auto; height: auto; min-height: 2rem; padding: .1875rem .625rem .1875rem .5rem;
  border: 1px solid var(--rule-2); border-radius: 999px; background: transparent; color: var(--ink); font: 600 .8125rem/1.2 var(--f-ui); cursor: pointer; white-space: nowrap;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}
#routeStyleControls .visibility-toggle::before, #routeStyleControls .visibility-toggle::after,
#routeStyleControls .visibility-toggle span::before { content: none !important; display: none !important; }
#routeStyleControls .visibility-toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
#routeStyleControls .visibility-toggle span { width: auto; height: auto; background: none; -webkit-mask: none; mask: none; }
#routeStyleControls .visibility-mark { position: relative; display: inline-grid; place-items: center; width: 1rem; height: 1rem; color: inherit; }
#routeStyleControls .visibility-mark svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#routeStyleControls .visibility-mark::after { content: "" !important; display: block !important; position: absolute; left: -.0625rem; right: -.0625rem; top: 50%; height: 2px; border-radius: 1px; background: currentColor; transform: rotate(-38deg) scaleX(0); transition: transform .18s var(--ease); }
#routeStyleControls .visibility-toggle input:not(:checked) ~ .visibility-mark::after { transform: rotate(-38deg) scaleX(1); }
#routeStyleControls .visibility-text { display: inline-flex; }
#routeStyleControls .visibility-toggle input:checked ~ .visibility-text .v-off,
#routeStyleControls .visibility-toggle input:not(:checked) ~ .visibility-text .v-on { display: none; }
#routeStyleControls .visibility-toggle:has(input:not(:checked)) { border-style: dashed; color: var(--ink-3); }
#routeStyleControls .visibility-toggle:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { #routeStyleControls .visibility-toggle:hover { background: var(--plate-2); } }

/* metrics: four readable tiles, then the rest on request */
#routeStyleControls .quick-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.25rem), 1fr)); gap: .3125rem; padding: 0; overflow: visible; border-radius: 0; background: none; }
#routeStyleControls :is(.quick-metrics, .metric-grid) > div { display: grid; align-content: start; gap: .125rem; min-width: 0; padding: .4375rem .625rem .5rem; border-radius: var(--r); background: var(--plate); }
#routeStyleControls :is(.quick-metrics, .metric-grid) small { font-size: .75rem; line-height: 1.3; color: var(--ink-3); overflow-wrap: anywhere; }
#routeStyleControls .quick-metrics b { font: 600 1.0625rem/1.25 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); overflow-wrap: anywhere; }
#routeStyleControls .metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: .3125rem; padding: .375rem 0 0; overflow: visible; background: none; }
#routeStyleControls .metric-grid b { font: 600 .9375rem/1.25 var(--f-num); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#routeStyleControls .route-metrics-details > summary {
  display: inline-flex; align-items: center; gap: .4375rem; min-height: 2rem; padding: 0 .375rem 0 .125rem; border-radius: .25rem; list-style: none; cursor: pointer;
  font: 600 .8125rem/1.2 var(--f-ui); color: var(--ink-2);
}
#routeStyleControls .route-metrics-details > summary::-webkit-details-marker { display: none; }
#routeStyleControls .route-metrics-details > summary::before {
  content: ""; width: .4375rem; height: .4375rem; margin: 0 .25rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s var(--ease);
}
#routeStyleControls .route-metrics-details[open] > summary::before { transform: rotate(45deg); }
@media (hover: hover) and (pointer: fine) { #routeStyleControls .route-metrics-details > summary:hover { color: var(--ink); background: var(--plate-2); } }

/* replay membership: a checkbox-like toggle in the route's colour */
#routeStyleControls .route-card-actions { display: flex; flex-wrap: wrap; gap: .375rem; min-width: 0; }
#routeStyleControls .focus-replay-button {
  flex: 0 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--ctl); padding: .25rem .875rem .25rem .625rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: transparent; color: var(--ink); font: 600 .875rem/1.2 var(--f-ui); text-align: start; overflow-wrap: anywhere;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}
#routeStyleControls .focus-state-dot {
  position: relative; flex: none; width: 1rem; height: 1rem; border: 2px solid var(--route-color); border-radius: .25rem; background: transparent; box-shadow: none;
  transition: background-color .16s ease;
}
#routeStyleControls .focus-replay-button.is-active { border-color: var(--slab); background: var(--slab); color: var(--on-slab); }
#routeStyleControls .focus-replay-button.is-active .focus-state-dot { background: var(--route-color); }
#routeStyleControls .focus-replay-button.is-active .focus-state-dot::after { content: ""; position: absolute; left: .25rem; top: .0625rem; width: .25rem; height: .5rem; border-right: 2px solid var(--scope); border-bottom: 2px solid var(--scope); transform: rotate(45deg); }
#routeStyleControls .focus-replay-button:disabled { opacity: .45; }
@media (hover: hover) and (pointer: fine) { #routeStyleControls .focus-replay-button:not(.is-active):hover:not(:disabled) { background: var(--plate-2); border-color: var(--ink-3); } }

#routeStyleControls .route-no-result { display: flex; align-items: flex-start; gap: .5rem; padding: .5rem .625rem; border: 0; border-radius: var(--r); background: var(--plate-2); font-size: .875rem; line-height: 1.45; color: var(--ink-2); overflow-wrap: anywhere; }
#routeStyleControls .route-no-result::before { content: ""; flex: none; width: .5rem; height: .5rem; margin-top: .4375rem; border-radius: 50%; border: 1.5px solid var(--warn); }
#routeStyleControls .route-no-result[data-reason="excluded"]::before { border-color: var(--ink-3); }

/* style editor: only while Line styles is on */
#routeStyleControls .route-style-fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: .5rem .75rem; padding: .625rem; border-radius: var(--r); background: var(--plate-2); font-size: .8125rem; color: var(--ink-2);
}
#routeStyleControls .route-style-fields label { display: grid; align-content: start; gap: .25rem; min-width: 0; font-weight: 600; }
#routeStyleControls .route-style-fields input[type="color"] { width: 3rem; height: var(--ctl); padding: .125rem; border: 1px solid var(--rule-2); border-radius: .25rem; background: var(--field); cursor: pointer; }
#routeStyleControls .route-style-fields select { width: 100%; min-height: var(--ctl); padding: .25rem 1.75rem .25rem .5rem; border: 1px solid var(--rule-2); border-radius: .25rem; background: var(--field); color: var(--ink); font-size: .875rem; }
#routeStyleControls .route-style-fields input[type="range"] { width: 100%; min-height: 1.5rem; accent-color: var(--route-color); }
#routeStyleControls .route-style-fields output { font: 600 .8125rem/1 var(--f-num); color: var(--ink); }
#routeStyleControls[data-styles="closed"] .route-style-fields { display: none; }
#routeStyleControls[data-styles="open"] .route-style-fields { animation: sm-in .18s var(--ease); }

@container route-card (max-width: 20rem) {
  #routeStyleControls .route-style-header, #routeStyleControls .route-style-header:not(:has(> .route-card-handle)), #routeStyleControls .route-style-header:not(:has(> em)) {
    grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: "handle trace eye" "name name name" "algo algo algo"; row-gap: .25rem;
  }
  #routeStyleControls .route-style-header > .visibility-toggle { justify-self: end; }
  #routeStyleControls .route-style-header:not(:has(> .route-card-handle)) { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "trace eye" "name name" "algo algo"; }
}
@container route-card (max-width: 14rem) {
  #routeStyleControls .route-style-header, #routeStyleControls .route-style-header:not(:has(> em)) {
    grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "handle trace" "name name" "algo algo" "eye eye";
  }
  #routeStyleControls .route-style-header:not(:has(> .route-card-handle)) {
    grid-template-columns: minmax(0, 1fr); grid-template-areas: "trace" "name" "algo" "eye";
  }
  #routeStyleControls .route-style-header > .visibility-toggle { justify-self: start; }
}
/* a wide single column becomes rows: identity | metrics | replay */
@container cards (min-width: 58rem) {
  #routeStyleControls:not([data-card-layout="auto"]) .route-style-card { grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr) minmax(9rem, auto); align-items: center; column-gap: 1rem; }
  #routeStyleControls:not([data-card-layout="auto"]) .route-style-header { grid-column: 1; }
  #routeStyleControls:not([data-card-layout="auto"]) .quick-metrics { grid-column: 2; }
  #routeStyleControls:not([data-card-layout="auto"]) .route-card-actions { grid-column: 3; justify-content: flex-end; }
  #routeStyleControls:not([data-card-layout="auto"]) .route-no-result { grid-column: 2 / -1; }
  #routeStyleControls:not([data-card-layout="auto"]) :is(.route-metrics-details, .route-style-fields) { grid-column: 1 / -1; }
}

.sm-policy { padding: .375rem .625rem; border-left: 2px solid var(--rule-2); font-size: .8125rem; line-height: 1.45; color: var(--ink-3); overflow-wrap: anywhere; }
.sm-policy:empty { display: none; }
.route-inspector { min-width: 0; border: 1px solid var(--rule); border-radius: .5rem; background: var(--field); }
.route-inspector header { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .625rem; }
.route-inspector dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: .3125rem; }
.route-inspector dl > div { min-width: 0; padding: .375rem .5rem; border-radius: var(--r); background: var(--plate); }
.route-inspector dt { font-size: .75rem; color: var(--ink-3); }
.route-inspector dd { margin: 0; font: 600 .9375rem/1.3 var(--f-num); overflow-wrap: anywhere; }

/* ---- replay transport: the player bar under the list */
.sm-transport {
  position: static; z-index: 2; flex: none; display: grid; gap: .5rem; min-width: 0; margin-top: auto;
  container: transport / inline-size; padding: .625rem .75rem .75rem; background: var(--scope); color: var(--on-scope);
  border-top: 1px solid var(--scope-rule); border-radius: 0 0 .4375rem .4375rem;
  box-shadow: 0 -.75rem 1.25rem -.75rem rgb(0 0 0 / .35);
}
.sm-transport-head { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; min-width: 0; }
.sm-transport-title { font: 600 .8125rem/1.3 var(--f-ui); color: var(--on-scope-2); }
.sm-focus { flex: 1 1 12rem; min-width: 0; }
.sm-chips { display: flex; flex-wrap: wrap; gap: .25rem; font-size: .8125rem; line-height: 1.35; color: var(--on-scope-2); }
.replay-selection-chip { display: inline-flex; align-items: center; gap: .375rem; padding: .125rem .5rem; border: 1px solid var(--scope-rule); border-radius: 999px; color: var(--on-scope); font-size: .8125rem; font-weight: 600; }
.replay-selection-chip > i { width: .5rem; height: .5rem; border-radius: 50%; background: var(--route-color); }
.sm-deck { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.sm-transport .sm-tool { border-color: var(--scope-rule); background: transparent; color: var(--on-scope); }
@media (hover: hover) and (pointer: fine) { .sm-transport .sm-tool:hover:not(:disabled) { background: var(--scope-3); border-color: var(--scope-rule); } }
.sm-transport .sm-tool:focus-visible, .sm-transport :focus-visible { outline-color: var(--scope-signal); }
.sm-play {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-width: 6rem; min-height: var(--hit); padding: 0 1.125rem 0 .875rem;
  border: 0; border-radius: 999px; background: var(--scope-signal); color: #121412; font: 700 .9375rem/1.1 var(--f-ui);
  transition: transform .12s var(--ease), opacity .16s ease, box-shadow .2s ease;
}
.sm-play::before {
  content: ""; flex: none; width: 1.125rem; height: 1.125rem; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5.2v13.6c0 .8.9 1.3 1.6.8l9.2-6.8c.5-.4.5-1.2 0-1.6L4.6 4.4C3.9 3.9 3 4.4 3 5.2z'/%3E%3Crect x='15.5' y='5' width='2.4' height='14' rx='1'/%3E%3Crect x='19.6' y='5' width='2.4' height='14' rx='1'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5.2v13.6c0 .8.9 1.3 1.6.8l9.2-6.8c.5-.4.5-1.2 0-1.6L4.6 4.4C3.9 3.9 3 4.4 3 5.2z'/%3E%3Crect x='15.5' y='5' width='2.4' height='14' rx='1'/%3E%3Crect x='19.6' y='5' width='2.4' height='14' rx='1'/%3E%3C/svg%3E") center / contain no-repeat;
}
.sm-play:active:not(:disabled) { transform: scale(.97); }
.sm-play:not(:disabled) { box-shadow: 0 0 0 .25rem color-mix(in oklab, var(--scope-signal) 18%, transparent); }
.sm-play:disabled { opacity: .38; }
.sm-play:focus-visible { outline: 2px solid var(--on-scope); outline-offset: 2px; }
.sm-track { position: relative; flex: 1 1 8rem; min-width: 6rem; padding-top: .875rem; }
.sm-track input[type="range"] { display: block; width: 100%; min-height: 1.75rem; margin: 0; accent-color: var(--scope-signal); background: transparent; }
.sm-track input[type="range"]:disabled { opacity: .45; }
.sm-milestones { position: absolute; left: .5rem; right: .5rem; top: 0; height: 1rem; pointer-events: none; }
.replay-milestone {
  position: absolute; left: var(--marker-position); top: calc(.25rem + var(--marker-row, 0) * .25rem); width: .5rem; height: .5rem;
  border-radius: 50%; background: var(--marker-color); box-shadow: 0 0 0 2px var(--scope); transform: translateX(-50%); pointer-events: auto;
}
.sm-speed { flex: none; display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--on-scope-2); }
.sm-speed select { width: auto; min-height: var(--ctl); padding: 0 1.5rem 0 .5rem; border: 1px solid var(--scope-rule); background: var(--scope-2); color: var(--on-scope); font: 600 .875rem/1 var(--f-num); }
.sm-speed select option { background: var(--scope-2); color: var(--on-scope); }
.sm-transport-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .75rem; min-width: 0; }
.sm-readout { flex: 1 1 14rem; min-width: 0; font: 600 .8125rem/1.4 var(--f-num); font-variant-numeric: tabular-nums; color: var(--on-scope); overflow-wrap: anywhere; }
.sm-seg { flex: 0 1 auto; display: flex; flex-wrap: wrap; gap: .125rem; padding: .125rem; border-radius: 999px; background: var(--scope-2); }
.sm-seg label { position: relative; flex: 1 1 auto; display: flex; min-width: 0; }
.sm-seg input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.sm-seg input:disabled { cursor: not-allowed; }
.sm-seg span {
  flex: 1 1 auto; display: grid; place-items: center; min-height: 2rem; padding: .25rem .75rem; border-radius: 999px;
  font: 600 .8125rem/1.25 var(--f-ui); color: var(--on-scope-2); text-align: center; transition: background-color .16s ease, color .16s ease;
}
.sm-seg input:checked + span { background: var(--on-scope); color: var(--scope); }
.sm-seg input:disabled + span { opacity: .45; }
.sm-seg input:focus-visible + span { outline: 2px solid var(--scope-signal); outline-offset: 1px; }
.sm-hint { font-size: .8125rem; line-height: 1.4; color: var(--on-scope-2); overflow-wrap: anywhere; }
.sm-hint:empty { display: none; }
@container transport (max-width: 30rem) {
  .sm-deck { flex-wrap: wrap; }
  .sm-track { order: 9; flex-basis: 100%; }
  .sm-speed { margin-left: auto; }
  .sm-seg { flex: 1 1 100%; }
}

/* ---- dialogs */
.sm-dialog {
  width: min(64rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 0; overflow: hidden;
  border: 1px solid var(--rule-2); border-radius: .5rem; background: var(--plate); color: var(--ink); box-shadow: var(--lift);
}
.sm-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: sm-rise .22s var(--ease); }
.sm-dialog::backdrop { background: var(--veil); }
.sm-dialog[open]::backdrop { animation: sm-fade .2s ease; }
.sm-summary-dialog { width: min(44rem, calc(100vw - 1.5rem)); }
.sm-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; padding: .875rem 1rem .75rem; border-bottom: 1px solid var(--rule); }
.sm-dialog-head > div { display: grid; gap: .1875rem; min-width: 0; }
.sm-dialog-head h2 { font: 600 1.25rem/1.2 var(--f-display); overflow-wrap: anywhere; }
/* chart: choices on the plate, the drawing on the scope, the same dark field the routes are drawn on in both themes.
   The engine reads the preview's colours and width when it draws, so the SVG and its PNG match what is on screen. */
.sm-chart-dialog { width: min(72rem, calc(100vw - 1.5rem)); }
.sm-chart-body { display: grid; grid-template-columns: minmax(15rem, 17rem) minmax(0, 1fr); min-height: 0; overflow: auto; }
.sm-chart-dialog .sm-chart-body { grid-row: 2 / -1; }
.sm-chart-options { display: grid; align-content: start; gap: 1rem; padding: 1rem; border-right: 1px solid var(--rule); }
.sm-chart-actions { display: grid; gap: .375rem; padding-top: .25rem; }
.sm-chart-preview { display: grid; align-content: safe center; min-height: 16rem; padding: 1rem 1.25rem; overflow: auto; background: var(--scope); color: var(--on-scope); }
.sm-chart-empty { display: grid; place-items: center; min-height: 10rem; padding: 1rem; color: var(--on-scope-2); text-align: center; }
#comparisonChart:empty { display: none; }
#comparisonChart svg, #comparisonChart img, #comparisonChart canvas { display: block; width: 100%; max-width: 100%; height: auto; }
.sm-checks { display: grid; gap: .125rem; }
.sm-checks legend { margin-bottom: .375rem; font: 600 .875rem/1.3 var(--f-ui); color: var(--ink); }
.sm-chart-options .sm-checks label { font-size: .9375rem; }
.sm-checks label { display: flex; align-items: center; gap: .5rem; min-height: var(--ctl); padding: .25rem .375rem; border-radius: var(--r); font-size: .875rem; line-height: 1.3; cursor: pointer; overflow-wrap: anywhere; }
@media (hover: hover) and (pointer: fine) { .sm-checks label:hover { background: var(--plate-2); } }
.sm-checks-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); column-gap: .5rem; }
.sm-checks-2 legend { grid-column: 1 / -1; }
.sm-choice { flex: none; width: 1.75rem; height: .875rem; border-radius: .1875rem; background: linear-gradient(var(--choice-color), var(--choice-color)) center / 100% 3px no-repeat, var(--scope); }
.sm-summary-body { display: grid; align-content: start; gap: 1rem; padding: .875rem 1rem; min-height: 0; overflow: auto; }
.sm-layouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .5rem; }
.sm-layouts legend { margin-bottom: .375rem; font: 600 .8125rem/1.3 var(--f-ui); color: var(--ink-2); }
.sm-layout-choice { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .625rem; padding: .625rem; border: 1px solid var(--rule-2); border-radius: .5rem; background: var(--field); cursor: pointer; }
.sm-layout-choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sm-layout-choice:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.sm-layout-choice:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
.sm-layout-choice > span:last-child { display: grid; gap: .125rem; font-size: .875rem; }
.sm-layout-choice small, .sm-switchrow small { font-size: .8125rem; line-height: 1.4; color: var(--ink-3); }
.sm-layout-preview { display: grid; gap: .1875rem; width: 3.5rem; padding: .375rem; border-radius: .25rem; background: var(--scope); }
.sm-layout-preview i { height: .3125rem; border-radius: 1px; }
.sm-layout-preview[data-preview="routes"] i:nth-child(1) { background: var(--cost-distance); }
.sm-layout-preview[data-preview="routes"] i:nth-child(2) { background: var(--cost-continuous); }
.sm-layout-preview[data-preview="routes"] i:nth-child(3) { background: var(--cost-threshold); }
.sm-layout-preview[data-preview="routes"] i:nth-child(4) { background: var(--cost-exposure); }
.sm-layout-preview[data-preview="metrics"] i { height: .5rem; background: linear-gradient(90deg, var(--cost-distance) 0 30%, var(--cost-continuous) 0 55%, var(--cost-threshold) 0 80%, var(--cost-exposure) 0); }
.sm-switchrow { display: flex; align-items: flex-start; gap: .625rem; padding: .625rem; border: 1px solid var(--rule); border-radius: .5rem; background: var(--field); cursor: pointer; }
.sm-switchrow input { margin-top: .1875rem; }
.sm-switchrow > span { display: grid; gap: .125rem; font-size: .875rem; }
.sm-dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; padding: .75rem 1rem calc(.75rem + var(--pad-b)); border-top: 1px solid var(--rule); }

/* ---- status line */
.sm-foot { grid-area: foot; padding: .25rem var(--pad-r) calc(.25rem + var(--pad-b)) var(--pad-l); border-top: 1px solid var(--rule); background: var(--plate); }
#status { min-height: 1.5rem; font: .8125rem/1.5 var(--f-ui); color: var(--ink-3); overflow-wrap: anywhere; }
.sm-foot:has(#status[data-kind="ready"]) { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }
.sm-noscript { padding: 1rem var(--pad-l); }

/* ---- channel strips: every cost carries its own parameters right under its row, on view before Run & Save */
.sm-costs .sm-opt > .parameter-group {
  margin-inline-start: 1.625rem; gap: .3125rem; padding: .375rem .5rem .5rem .625rem; border-left-width: 2px; border-radius: 0 .25rem .25rem 0;
  transition: opacity .16s ease;
}
/* the cost row above already names the channel: its repeated title and per-field cost tags stay for assistive tech only */
.sm-costs .parameter-group > header, .sm-costs .parameter-scope:not(.shared-scope) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sm-costs .shared-scope { color: var(--ink-2); font-weight: 600; }
.sm-costs .sm-param-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 5.25rem), 1fr)); }
.sm-baseline { margin: 0 0 .125rem 1.625rem; padding-left: .625rem; border-left: 2px solid var(--tint, var(--rule-2)); font-size: .8125rem; line-height: 1.4; color: var(--ink-3); }
/* an unticked cost keeps its values editable and only steps back; L max (read by Threshold) and walking speed (read by every
   route's time and exposure) stay lit while something else still uses them */
.sm-costs .sm-opt:has(> .sm-opt-row input[data-cost]:not(:checked)) > :is(.parameter-group, .sm-baseline) { border-left-style: dashed; }
.sm-costs .sm-opt:has(> .sm-opt-row input[data-cost]:not(:checked)) :is(.sm-baseline, .parameter-group > p, .linked-parameter-note, .sm-param-grid > label) { opacity: .62; }
.sm-costs:has(input[data-cost][value="threshold"]:checked) .sm-param-grid > label:has(#lMax), .sm-costs .sm-param-grid > label:has(#speed) { opacity: 1; }
/* settings read by every route: no cost row names this group, so it carries its own title and sits flush with the rows */
.sm-costs .sm-shared-params { margin-block-start: .375rem; }
.sm-costs .sm-shared-params > .parameter-group { margin-inline-start: 0; border-left-color: var(--rule-2); }
.sm-costs .sm-shared-params .sm-shared-title { font: 600 .8125rem/1.3 var(--f-ui); color: var(--ink-2); }

/* ---- the way back from results to the inputs */
.sm-edit-setup { flex: none; }
body:is([data-result="error"], [data-run="error"]) .sm-edit-setup { border-color: color-mix(in oklab, var(--alert) 55%, transparent); }

/* ==== bench: tablet and desktop with height to spare. A fixed working surface; panels scroll inside. ==== */
@container sm-viewport (min-width: 52rem) and (min-height: 48rem) {
  body.sm { height: 100dvh; overflow: hidden; }
  /* the recipe now shows every parameter, so the rail gains a little width for the channel strips */
  .sm-rail { flex: 0 0 auto; width: clamp(20rem, 24vw, 24rem); }
  .sim-layout.sidebar-collapsed .sm-rail { display: none; }
  .sim-layout.sidebar-collapsed .sm-open { display: inline-flex !important; }
  /* a hidden recipe is never a dead end: the way back reads as a lit channel on the scope bar */
  .sim-layout.sidebar-collapsed .sm-open { border-color: var(--scope-signal); color: var(--on-scope); }
  .sim-layout.sidebar-collapsed .sm-open .ui-icon { color: var(--scope-signal); }
  .sm-work[data-dock-position="bottom"], .sm-work:not([data-dock-position]) {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(min-content, 1fr) minmax(0, min(var(--results-height, 18.75rem), 58%));
  }
  .sm-work[data-dock-position="right"] { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(18rem, 1fr) min(var(--results-width, 27rem), max(25rem, 38%)); }
  .sm-work[data-dock-position="right"]:has(> .sm-dock[data-dock-size="expanded"]) { grid-template-columns: minmax(18rem, 1fr) min(var(--results-width, 40rem), 62%); }
  .sm-work[data-dock-position="right"]:has(> .sm-dock[data-dock-size="compact"]) { grid-template-columns: minmax(18rem, 1fr) min(var(--results-width, 24rem), 40%); }
  /* nothing to compare yet: whatever side the dock prefers, results shrink to one strip under the scope, which keeps
     the whole width. The preferred side and size return with the first shown route; nothing here writes them. */
  body[data-shown="no"] #simWorkspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(15rem, 1fr) auto; }
  body[data-shown="no"] #smPlate { grid-row: 1; grid-column: 1; }
  body[data-shown="no"] #resultsDock {
    grid-row: 2; grid-column: 1; grid-template-rows: auto; grid-template-columns: fit-content(min(24rem, 40%)) minmax(0, 1fr);
    box-shadow: inset 3px 0 0 var(--sm-edge, var(--rule-2)); transition: box-shadow .2s ease;
  }
  body[data-shown="no"] #resultsDock :is(.sm-dock-resize, .sm-dock-layout, .sm-grip) { display: none; }
  /* the head stands at the start of the strip and wraps its tools under the title instead of pushing the state away */
  body[data-shown="no"] #resultsDockDragHandle { align-self: stretch; align-content: center; padding-inline: 1rem .75rem; border-bottom: 0; border-inline-end: 1px solid var(--rule); cursor: default; touch-action: auto; }
  body[data-shown="no"] #resultsDockDragHandle > .sm-gap { display: none; }
  body[data-shown="no"] #resultsDock .sm-dock-body { max-height: min(16rem, 34cqh); scrollbar-gutter: auto; }
  body[data-shown="no"] #resultsDock .sm-traces { flex: none; gap: .25rem; padding: .5rem .875rem; }
  body[data-shown="no"] #routeResults[data-variant="panel"] {
    grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .375rem .875rem; padding: .25rem 0; border: 0; background: transparent;
  }
  body[data-shown="no"] #routeResults[data-variant="panel"] > .sm-state-action { grid-column: 3; grid-row: 1; }
  body[data-shown="no"] .sm-state-mark { width: 2.25rem; height: 2.25rem; }
  body[data-shown="no"] .sm-state-copy { grid-template-columns: minmax(0, 1fr) auto; gap: .1875rem 1.25rem; align-items: center; }
  body[data-shown="no"] .sm-state-copy > * { grid-column: 1; }
  body[data-shown="no"] .sm-state-copy > .sm-state-action { grid-column: 2; grid-row: 1 / span 4; }
  body[data-shown="no"] .sm-state-copy > strong { font-size: 1rem; }
  body[data-shown="no"] .sm-state-copy > p { max-width: 84ch; font-size: .8125rem; line-height: 1.45; }
  body[data-shown="no"] .sm-state-traces { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .875rem; padding-top: .125rem; border-top: 0; }
  body[data-shown="no"] .sm-state-traces ul { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
  /* the strip's edge names the state at a glance: neutral idle, signal while computing, alert on failure, dim while the map loads */
  body[data-result="running"] #resultsDock, body[data-run="running"] #resultsDock { --sm-edge: var(--signal); }
  body[data-result="error"] #resultsDock, body[data-run="error"] #resultsDock { --sm-edge: var(--alert); }
  body[data-shown="no"][data-result="error"] #resultsDock { background: color-mix(in oklab, var(--alert) 5%, var(--plate)); }
  body[data-shown="no"]:is([data-map="loading"], [data-map="stalled"]) #resultsDock .sm-traces { opacity: .62; }
  .sm-work.dock-transitioning { transition: grid-template-rows .26s var(--ease-move), grid-template-columns .26s var(--ease-move); }
  .sm-work.dock-dragging .sm-dock { box-shadow: 0 0 0 2px var(--ink-3); opacity: .9; }
  .sm-work[data-dock-target="right"]::after, .sm-work[data-dock-target="bottom"]::after {
    content: ""; position: absolute; z-index: 5; border: 2px dashed var(--ink-2); border-radius: .5rem; background: color-mix(in oklab, var(--signal) 14%, transparent); pointer-events: none;
  }
  .sm-work[data-dock-target="right"]::after { top: 0; right: 0; bottom: 0; width: min(27rem, 40%); }
  .sm-work[data-dock-target="bottom"]::after { left: 0; right: 0; bottom: 0; height: min(18.75rem, 45%); }

  body[data-routes="no"] .sm-transport { display: none; }
  body[data-shown="no"] .sm-cards-panel { display: none; }

  /* a wide dock reads list and transport side by side */
  @container dock (min-width: 56rem) {
    body[data-routes="yes"] .sm-dock-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, 21rem); align-items: start; }
    body[data-routes="yes"] .sm-traces { grid-column: 1; grid-row: 1; }
    body[data-routes="yes"] .sm-transport { grid-column: 2; grid-row: 1; position: sticky; top: .75rem; bottom: auto; margin: .75rem .75rem .75rem 0; border: 1px solid var(--scope-rule); border-radius: .5rem; box-shadow: none; }
    body[data-routes="yes"] .sm-transport .sm-deck { flex-wrap: wrap; }
    body[data-routes="yes"] .sm-transport .sm-track { order: 9; flex-basis: 100%; }
    body[data-routes="yes"] .sm-transport .sm-speed { margin-left: auto; }
    body[data-routes="yes"] .sm-transport .sm-seg { flex-basis: 100%; }
  }

  /* compact results: the user's choice only; the deck stays, the extras fold */
  .sm-dock[data-dock-size="compact"] :is(.route-metrics-details, .sm-policy, .sm-hint, .sm-transport-head, .sm-seg) { display: none; }
  .sm-dock[data-dock-size="compact"] .sm-traces { gap: .5rem; padding: .5rem; }
  .sm-dock[data-dock-size="compact"] #routeStyleControls .route-style-card { gap: .4375rem; padding: .5rem .75rem .625rem 1rem; }
  .sm-dock[data-dock-size="compact"] .sm-transport { padding: .5rem .625rem; gap: .375rem; }
}
@container sm-viewport (min-width: 52rem) and (min-height: 48rem) and (max-width: 74.99rem) {
  .sm-rail { width: 19.5rem; }
}
@container sm-viewport (min-width: 100rem) and (min-height: 48rem) {
  .sm-rail { width: clamp(23rem, 19vw, 27rem); }
  .sm-layout { gap: .75rem; padding: .75rem var(--pad-r) .75rem var(--pad-l); }
  .sm-work { gap: .75rem; }
}

/* ==== tasks: phones, short landscape, very large text. One task fills the screen; the switch stays in reach. ==== */
@container sm-viewport (max-width: 51.99rem) or (max-height: 47.99rem) {
  body.sm { --sm-task-layout: 1; height: 100dvh; overflow: hidden; grid-template: "top" auto "task" auto "main" minmax(0, 1fr) "foot" auto / minmax(0, 1fr); }
  /* the head keeps the shared chrome's per-viewport rows here too; only the station number steps back */
  .wc-head .wc-no { display: none; }

  .sm-task {
    grid-area: task; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem; padding: .375rem var(--pad-r) .375rem var(--pad-l);
    background: var(--plate); border-bottom: 1px solid var(--rule);
  }
  .sm-task-btn {
    position: relative; display: flex; align-items: center; justify-content: center; gap: .4375rem; min-width: 0; min-height: 2.75rem; padding: .25rem .5rem;
    border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--plate); color: var(--ink);
    font: 600 .875rem/1.2 var(--f-ui); text-align: center; overflow-wrap: anywhere;
    transition: background-color .16s ease, color .16s ease, border-color .16s ease;
  }
  .sm-task-btn > span { min-width: 0; }
  .sm-task-btn[aria-pressed="true"] { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }
  .sm-task-btn[aria-pressed="true"] .ui-icon { color: var(--signal); }
  .sm-task-lamp { position: absolute; top: .3125rem; right: .3125rem; width: .5rem; height: .5rem; border-radius: 50%; box-shadow: 0 0 0 2px var(--plate); }
  .sm-task-btn[aria-pressed="true"] .sm-task-lamp { box-shadow: 0 0 0 2px var(--slab); }
  .sm-task-lamp[data-lamp="todo"] { background: var(--warn); }
  .sm-task-lamp[data-lamp="ready"] { background: var(--ok); }
  .sm-task-lamp[data-lamp="running"] { background: var(--signal); animation: sm-blink 1.2s ease-in-out infinite; }
  .sm-task-lamp[data-lamp="fresh"] { background: var(--signal); box-shadow: 0 0 0 2px var(--plate), 0 0 0 4px color-mix(in oklab, var(--signal) 45%, transparent); }
  .sm-task-lamp:not([data-lamp]) { display: none; }

  .sm-layout { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); gap: 0; padding: .5rem var(--pad-r) .5rem var(--pad-l); }
  .sm-layout > .sm-rail, .sm-layout > .sm-work { grid-area: 1 / 1; }
  .sim-layout.sidebar-collapsed .sm-rail { display: flex; }
  #closeSidebar, .sm-open, .sm-dock-layout, .sm-dock-resize, .sm-dock-head .sm-grip { display: none !important; }
  .sm-dock-head { cursor: default; touch-action: auto; }
  /* hidden tasks keep their boxes, so the canvas never collapses */
  body:is([data-task="map"], [data-task="results"]) .sm-rail, body:not([data-task="map"]):not([data-task="results"]) .sm-work { visibility: hidden; pointer-events: none; opacity: 0; }
  body[data-task] :is(.sm-rail, .sm-work) { transition: opacity .18s ease, visibility 0s linear .18s; }
  body[data-task="setup"] .sm-rail, body:is([data-task="map"], [data-task="results"]) .sm-work { transition: opacity .18s ease, visibility 0s; }

  .sm-work { grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .sm-mapzone { grid-row: 1; grid-column: 1; }
  .sm-dock { grid-row: 2; grid-column: 1; }
  /* map task: only the transport rides under the scope, once there are routes to watch */
  body:not([data-task="results"]):not([data-routes="yes"]) .sm-dock { display: none; }
  body:not([data-task="results"]) .sm-dock :is(.sm-dock-head, .sm-traces, .sm-transport-head, .sm-transport-meta .sm-seg, .sm-hint, .sm-speed) { display: none; }
  body:not([data-task="results"]) .sm-dock { border: 0; background: transparent; }
  body:not([data-task="results"]) .sm-dock-body { overflow: visible; }
  body:not([data-task="results"]) .sm-transport { position: static; border-radius: .5rem; padding: .375rem .5rem .5rem; gap: .25rem; box-shadow: none; }
  body:not([data-task="results"]) .sm-deck { flex-wrap: nowrap; }
  body:not([data-task="results"]) .sm-track { order: 0; flex-basis: auto; padding-top: .75rem; }
  body:not([data-task="results"]) .sm-readout { font-size: .8125rem; }
  /* results task: the dock takes the whole surface over the kept, hidden scope */
  body[data-task="results"] .sm-dock { grid-row: 1 / -1; z-index: 2; }
  body[data-task="results"] .sm-mapzone { visibility: hidden; }
  body[data-task="results"][data-routes="no"] .sm-transport { display: none; }
  body[data-task="results"][data-shown="no"] .sm-cards-panel { display: none; }

  .sm-mapbar { padding: .3125rem; gap: .25rem; }
  .sm-mapbar .sm-cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .sm-mapbar .sm-tool { padding-left: .5rem; }
  .sm-zoomread { min-width: 2.75rem; }
  .sm-frame { min-height: 10rem; }
  .sm-legend { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .sm-legend > *, .sm-routelegend, .sm-keys { flex-wrap: nowrap; flex: none; }
  .sm-keys li, .route-legend-item { white-space: nowrap; }
  .sm-legend-hint { display: none; }
  .sm-dock-title small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  .sm-chart-body { grid-template-columns: minmax(0, 1fr); }
  .sm-chart-options { border-right: 0; border-bottom: 1px solid var(--rule); }
  .sm-chart-preview { min-height: 10rem; padding: .75rem; }
  .sm-chart-preview:has(svg) { min-height: 100dvh; align-content: start; }
  .sm-dialog { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
  .sm-dialog-head { padding: .625rem .75rem; }
  .sm-dialog-head .sm-help { display: none; }
}
/* phone portrait: the task switch moves to the thumb */
@container sm-viewport (max-width: 51.99rem) and (orientation: portrait) {
  body.sm { grid-template: "top" auto "main" minmax(0, 1fr) "foot" auto "task" auto / minmax(0, 1fr); }
  .sm-task { border-bottom: 0; border-top: 1px solid var(--rule); padding-bottom: calc(.375rem + var(--pad-b)); box-shadow: 0 -.5rem 1.5rem -1rem rgb(0 0 0 / .25); }
  .sm-foot { padding-bottom: .25rem; max-height: min(8rem, 22dvh); overflow-y: auto; }
}

@container sm-viewport ((max-width: 51.99rem) and (orientation: portrait)) or ((max-height: 32rem) and (orientation: landscape)) {
  /* results: reading, not operating. The page is the single scroller: the head and status scroll away, the cards
     follow in document order, and only the task switch stays under the thumb. Large text simply makes the page longer.
     The rail and the hidden scope leave the flow but keep their boxes, so the canvas never collapses. */
  body.sm[data-task="results"] {
    overflow: hidden auto; overscroll-behavior-y: contain;
    grid-template: "top" auto "foot" auto "main" minmax(max-content, 1fr) "task" auto / minmax(0, 1fr);
    scroll-padding-block: .5rem calc(var(--sm-task-h, 4.5rem) + .5rem);
  }
  body[data-task="results"] .sm-context { display: none; }
  body[data-task="results"] .sm-foot { max-height: none; overflow: visible; border-top: 0; border-bottom: 1px solid var(--rule); }
  body[data-task="results"] .sm-task {
    position: sticky; bottom: 0; z-index: 5; width: auto;
    min-height: min-content; overflow: visible;
    grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(min-content, auto); border-right: 0;
  }
  body.sm[data-task="results"] .sm-layout { display: block; min-height: auto; padding-bottom: 1rem; }
  body[data-task="results"] .sm-layout > .sm-rail { position: absolute; inset: 0; overflow: hidden; }
  body.sm[data-task="results"] .sm-work { display: block; min-height: auto; }
  body[data-task="results"] .sm-work > .sm-mapzone { position: absolute; top: 0; left: 0; right: 0; height: max(12rem, calc(100dvh - 14rem)); }
  /* the dock becomes the page section itself: no outer frame around the cards, no inner scroller */
  body[data-task="results"] .sm-dock { position: relative; border: 0; border-radius: 0; background: transparent; }
  body[data-task="results"] .sm-dock-head { padding: .25rem 0 .5rem; }
  body[data-task="results"] .sm-dock-body { overflow: visible; scrollbar-gutter: auto; }
  body[data-task="results"] .sm-traces { padding: .75rem 0 1rem; }
  body[data-task="results"] .sm-transport { border-radius: .5rem; box-shadow: none; }
}
/* narrow phones: the whole recipe scrolls, so enlarged text cannot trap its inputs */
@container sm-viewport (max-width: 39.99rem) {
  .sm-rail { overflow-y: auto; overscroll-behavior: contain; }
  .sm-rail-head { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
  .sm-tabs { margin: .25rem .375rem 0; }
  .sm-tabs button { min-height: 2.75rem; }
  .sm-panel, .sm-panel.active:not([hidden]) { flex: none; overflow: visible; }
  .sm-steps { flex: none; overflow: visible; padding: .75rem .75rem 1rem; }
  .sm-step { padding-left: 0; }
  .sm-step::before { display: none; }
  .sm-step-title { margin-left: 0; }
  .sm-commit { position: static; box-shadow: none; }
  .sm-task { padding-inline: .5rem; }
  .sm-task-btn { flex-direction: column; gap: .25rem; padding: .375rem; }
  .sm-task-btn .ui-icon { width: 1.375rem; height: 1.375rem; }
  .sm-dock-head { padding-inline: .625rem .375rem; }
  .sm-traces { padding: .625rem; }
}
/* short landscape: the switch becomes a slim column at the start edge, and the head becomes one row */
@container sm-viewport (max-height: 47.99rem) and (orientation: landscape) {
  body.sm { grid-template: "top top" auto "task main" minmax(0, 1fr) "foot foot" auto / auto minmax(0, 1fr); }
  .sm-top { flex-wrap: nowrap; }
  .sm-ident { display: none; }
  .sm-context { flex: 1 1 12rem; order: 3; }
  .sm-context > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .sm-title { flex: 0 1 auto; }
  .sm-top > .workspace-flow { order: 4; margin-left: 0; }
  .sm-task {
    grid-template-columns: none; grid-auto-rows: minmax(2.75rem, auto); align-content: start; width: 5rem; overflow-y: auto;
    padding: .5rem .25rem .5rem var(--pad-l); border-bottom: 0; border-right: 1px solid var(--rule);
  }
  .sm-task-btn { flex-direction: column; gap: .125rem; padding: .375rem .125rem; font-size: .75rem; }
  .sm-layout { padding-left: .5rem; padding-block: .375rem; }
  .sm-foot { max-height: min(4.5rem, 20dvh); overflow-y: auto; }
  .sm-commit { position: static; }
  .sm-frame { min-height: 8rem; }
  body[data-task="map"] .sm-work { grid-template-rows: minmax(min-content, 1fr) auto; overflow-y: auto; }
  .sm-rail { overflow-y: auto; }
  .sm-panel, .sm-panel.active:not([hidden]) { flex: none; }
  .sm-steps { flex: none; overflow: visible; }
}

/* The room supplies Home; language and display settings remain on this page. */
/* Keep the result reading header in one row despite the shared legacy compact grid. */
@container sm-viewport (min-width: 40rem) and (max-width: 63.99rem) and (max-height: 32rem) and (orientation: landscape) {
  :root body.sm[data-task="results"] > header.sm-top { display: flex; flex-wrap: nowrap; gap: .375rem; padding-block: .25rem; }
  :root body.sm[data-task="results"] > header.sm-top > .sm-title { flex: none; white-space: nowrap; }
  :root body.sm[data-task="results"] > header.sm-top > .workspace-flow { flex: 1 1 auto; width: auto; gap: .5rem; padding: 0; border: 0; }
  body.sm[data-task="results"] .sm-foot, body.sm[data-task="results"] .sm-dock-head { padding-block: 0; }
  body.sm[data-task="results"] .sm-traces { padding-block: .5rem; }
  body.sm[data-task="results"] .sm-cards-panel > .route-comparison-tools { flex: 0 1 auto; margin-inline-start: auto; }
  body.sm[data-task="results"] .sm-cards-out { margin-inline-start: 0; }
}
/* Reuse the wide single-column card's internal tracks on an ordinary short screen. */
@media (max-height: 32rem) and (orientation: landscape) {
  @container cards (min-width: 40rem) {
    #routeStyleControls:not([data-card-layout="auto"]) .route-style-card { grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr); align-items: start; column-gap: 1rem; }
    #routeStyleControls:not([data-card-layout="auto"]) .route-style-header { grid-column: 1; }
    #routeStyleControls:not([data-card-layout="auto"]) .quick-metrics { grid-column: 2; }
    #routeStyleControls:not([data-card-layout="auto"]) .route-card-actions { grid-column: 1 / -1; justify-content: flex-end; }
    #routeStyleControls:not([data-card-layout="auto"]) .route-no-result { grid-column: 2 / -1; }
    #routeStyleControls:not([data-card-layout="auto"]) :is(.route-metrics-details, .route-style-fields) { grid-column: 1 / -1; }
  }
}
:root[data-lab-host] .sm-home { display: none !important; }
:root[data-lab-host] .sm-top { padding-block: .375rem; }
:root[data-lab-host] body.sm::before { opacity: .6; }
:root[data-lab-host][data-lab-task="sim"] .sim-layout.sm-layout { grid-template-columns: none; }
@container sm-viewport (max-width: 51.99rem) or (max-height: 47.99rem) {
  :root[data-lab-host][data-lab-task="sim"] .sim-layout.sm-layout { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
}
:root[data-lab-host][data-lab-task="sim"] .sm-params .parameter-group { border-radius: .25rem; }

/* Personal large-text recovery. The ordinary workbench keeps its viewport rows;
   this mode is a scrolling document with one active task and a valid kept map. */
html:has(body.sm > .wc-head[data-wc-reading]) { overflow: auto; scroll-padding-block: .5rem; }
body.sm:has(> .wc-head[data-wc-reading]) {
  --sm-task-layout: 1;
  display: block;
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}
body.sm:has(> .wc-head[data-wc-reading]) > .sm-task {
  position: relative; inset: auto; z-index: 5;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: auto;
  width: auto; height: auto; overflow: visible; border-right: 0;
}
body.sm:has(> .wc-head[data-wc-reading]) .sm-layout { display: block; min-height: 0; isolation: isolate; }
body.sm:has(> .wc-head[data-wc-reading]) :is(.sm-rail, .sm-work) {
  position: relative; inset: auto; width: auto; height: auto; max-height: none;
}
body.sm:has(> .wc-head[data-wc-reading]) :is(.sm-rail, .sm-panel, .sm-steps, .sm-dock-body) { overflow: visible; }
body.sm:has(> .wc-head[data-wc-reading]) :is(.sm-panel, .sm-steps) { flex: none; }
body.sm:has(> .wc-head[data-wc-reading]) .sm-commit {
  position: static; grid-template-columns: minmax(0, 1fr); grid-template-areas: "chain" "emit" "feed";
}
body.sm:has(> .wc-head[data-wc-reading]) .sm-emit { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; }
body.sm:has(> .wc-head[data-wc-reading]) .sm-work { display: block; }
body.sm:has(> .wc-head[data-wc-reading]) .sm-mapzone {
  position: relative; inset: auto; width: auto; height: auto; min-height: 20rem;
  grid-template-rows: auto auto auto;
}
body.sm:has(> .wc-head[data-wc-reading]) .sm-frame { height: max(12rem, 60dvh); min-height: 12rem; }
body.sm:has(> .wc-head[data-wc-reading]) .sm-dock { position: relative; display: block; height: auto; max-height: none; }
body.sm:has(> .wc-head[data-wc-reading]) .sm-transport { position: static; }
body.sm:has(> .wc-head[data-wc-reading]) .sm-foot { max-height: none; overflow: visible; }
/* Inactive panes leave the document flow without display:none. Their explicit
   map track keeps the canvas bitmap/camera box valid and adds no empty page. */
body.sm:has(> .wc-head[data-wc-reading])[data-task="setup"] .sm-work,
body.sm:has(> .wc-head[data-wc-reading]):is([data-task="map"], [data-task="results"]) .sm-rail {
  position: fixed; inset: 0 var(--pad-r) auto var(--pad-l);
  width: auto; height: max(20rem, 80dvh); overflow: hidden;
  visibility: hidden; opacity: 0; pointer-events: none;
}
body.sm:has(> .wc-head[data-wc-reading])[data-task="results"] .sm-mapzone {
  position: fixed; inset: 0 var(--pad-r) auto var(--pad-l);
  width: auto; height: max(20rem, 80dvh); visibility: hidden; pointer-events: none;
}

/* ==== motion: short, interruptible transitions; continuous motion only for live sound (running, armed, loading) ==== */
@keyframes sm-in { from { opacity: 0; transform: translateY(.25rem); } to { opacity: 1; transform: none; } }
@keyframes sm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sm-rise { from { opacity: 0; transform: translateY(.5rem) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sm-drop { from { opacity: 0; transform: translateY(-.25rem) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sm-emit { 0% { opacity: .75; transform: scale(.94); } 100% { opacity: 0; transform: scale(1.55); } }
@keyframes sm-breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes sm-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes sm-landed { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--signal) 70%, transparent); } 100% { box-shadow: 0 0 0 .75rem transparent; } }
/* a fresh result arrives as a short wave down the list */
body[data-run="success"] #routeStyleControls .route-style-card { animation: sm-in .28s var(--ease) both; }
body[data-run="success"] #routeStyleControls .route-style-card:nth-child(2) { animation-delay: .05s; }
body[data-run="success"] #routeStyleControls .route-style-card:nth-child(3) { animation-delay: .1s; }
body[data-run="success"] #routeStyleControls .route-style-card:nth-child(4) { animation-delay: .15s; }
body[data-run="success"] #routeStyleControls .route-style-card:nth-child(n+5) { animation-delay: .2s; }
body[data-run="success"] .sm-task-btn[data-task="results"] { animation: sm-landed .9s var(--ease) 1; }
body[data-run="success"] #resultsDock { animation: sm-landed .9s var(--ease) 1; }
body[data-run="error"] .run-feedback { animation: sm-in .2s var(--ease); }

:root:is([data-motion="reduced"], [data-lab-motion="reduced"]) *, :root:is([data-motion="reduced"], [data-lab-motion="reduced"]) *::before, :root:is([data-motion="reduced"], [data-lab-motion="reduced"]) *::after {
  animation: none !important; transition-duration: 0s !important; scroll-behavior: auto !important;
}
:root:is([data-motion="reduced"], [data-lab-motion="reduced"]) .sm-emit.is-running .sm-emit-ring:first-child { opacity: .6; transform: scale(1.18); }
:root:is([data-motion="reduced"], [data-lab-motion="reduced"]) .sm-emit:not(:disabled) .sm-emit-ring:first-child { opacity: .35; transform: scale(1.12); }
:root:is([data-motion="reduced"], [data-lab-motion="reduced"]) #routeResults[data-state="running"] .sm-state-mark::before { opacity: .7; transform: scale(1.1); }
:root:is([data-motion="reduced"], [data-lab-motion="reduced"]) .sm-plate-wave::before { opacity: .8; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; }
}
:root[data-sm-hidden] *, :root[data-sm-hidden] *::before, :root[data-sm-hidden] *::after { animation-play-state: paused !important; }

/* forced colours: keep borders and state readable */
@media (forced-colors: active) {
  .sm-emit-disc, .sm-tool, .sm-btn, .sm-pin, .sm-task-btn, .sm-play, #routeStyleControls .visibility-toggle, #routeStyleControls .focus-replay-button { border: 1px solid ButtonText; }
  .sm-chain > span > i, .sm-lamp, .sm-task-lamp, .sm-layer::after, .focus-state-dot { forced-color-adjust: none; }
  .sm-cmp > * { border: 1px solid CanvasText; }
  .sm-dock-size .sm-tool[aria-pressed="true"], .sm-cards-panel .route-layout-modes button:is([aria-pressed="true"], [aria-checked="true"], .active) { outline: 2px solid Highlight; outline-offset: -2px; }
}

/* ==== the saved-runs list: its refresh button ==== */
.sm-list > [data-history-refresh] {
  justify-self: start; display: inline-flex; align-items: center; justify-content: center; min-height: var(--ctl); padding: .25rem .875rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--plate); color: var(--ink); font: 600 .8125rem/1.2 var(--f-ui);
  cursor: pointer; transition: background-color .16s ease, border-color .16s ease;
}
@media (hover: hover) and (pointer: fine) { .sm-list > [data-history-refresh]:hover:not(:disabled) { background: var(--plate-2); border-color: var(--ink-3); } }
.sm-list > [data-history-refresh]:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.sm-list > [data-history-refresh]:disabled { opacity: .5; cursor: default; }

/* ==== light theme: a light scope ====
   The dark theme keeps the dark measuring scope. In the light theme the scope, its tool bar, the key under it, the readouts laid
   over the map and the replay transport are one light instrument with the bench (the user, 2026-11-16: the light theme's colours
   on this page were not adapted). Route colours, the map image and the heat field are unchanged. */
:root:not([data-theme="dark"]) {
  --scope: #e2e1da; --scope-2: #f5f4ef; --scope-3: #d4d3cb; --on-scope: #121412; --on-scope-2: #4f524a;
  --scope-rule: rgb(18 20 18 / .14); --scope-signal: #6f9a00;
}
:root:not([data-theme="dark"]) .sm-tools { background: rgb(18 20 18 / .04); }
/* fills take the bench's accent (the reader's chosen accent where the display settings set one) with its own ink; the olive
   scope signal is for marks on the light scope (lamps, rings, outlines) */
:root:not([data-theme="dark"]) :is(.sm-mode-glyph, .sm-play) { background: var(--signal); color: var(--on-signal); }
:root:not([data-theme="dark"]) .sm-mode { background: rgb(250 249 245 / .96); box-shadow: 0 0 0 1px var(--scope-rule), 0 .5rem 1.5rem rgb(18 20 18 / .16); }
:root:not([data-theme="dark"]) .sm-cmp { filter: drop-shadow(0 .5rem 1rem rgb(18 20 18 / .14)); }
:root:not([data-theme="dark"]) :is(.sm-cmp.window-dragging, .sm-cmp.window-resizing) { filter: drop-shadow(0 1rem 1.75rem rgb(18 20 18 / .22)); }
:root:not([data-theme="dark"]) .sm-cmp > * { background: rgb(250 249 245 / .97); }
:root:not([data-theme="dark"]) .sm-cmp[data-surface="transparent"] > * { background: rgb(250 249 245 / .72); }
:root:not([data-theme="dark"]) .sm-hover { background: rgb(250 249 245 / .97); box-shadow: 0 .5rem 1.5rem rgb(18 20 18 / .18); }
:root:not([data-theme="dark"]) .route-overlap-button { border-color: #8fa7b1; background: #f3f7f8; color: #14252d; box-shadow: 0 2px 8px rgb(18 20 18 / .14); }
:root:not([data-theme="dark"]) .route-overlap-button:focus-visible { outline-color: #0e7490; }
