/* zcmir app. One dark theme: neutral greys, one gold accent for "the next thing to do", green for
   done / inliers, red for stop / outliers. Images sit on near-black wells. */
:root {
  color-scheme: dark;
  --well: #0a0a0b;
  --bg: #0f0f11;
  --panel: #151517;
  --card: #19191c;
  --field: #111113;
  --raise: #232327;
  --line: #2b2b30;
  --line-soft: #222226;
  --text: #e6e6e8;
  --muted: #9d9da4;
  --faint: #67676e;
  --accent: #d6b064;
  --accent-hi: #e8c77e;
  --accent-ink: #f6eacd;
  --accent-bg: #2a2316;
  --accent-line: #6b5631;
  --good: #7fbf6e;
  --bad: #d4615f;
  --data: #6a9ec8;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --rail: 344px;
  --bar: 30px;
  --status: 26px;
  --rad: 6px;
  --rad-s: 4px;
  --split: 5px;
  --ctl: 28px;
}
* { box-sizing: border-box; margin: 0; padding: 0; scrollbar-width: thin; scrollbar-color: #34343a transparent; }
::selection { background: #4a3d22; }
html, body { height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
.pane-bar, .statusbar, .rail, .side-tabs { user-select: none; }
.hpanel, .log { user-select: text; }
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; flex: none; }

/* ── controls ─────────────────────────────────────────────────────────────── */
button, input, select {
  font: inherit; color: inherit; background: var(--field);
  border: 1px solid var(--line); border-radius: var(--rad-s);
}
button {
  cursor: pointer; padding: 0 10px; height: var(--ctl); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--raise); border-color: #34343a; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
button:hover { background: #2c2c31; border-color: #44444b; }
button:active { background: #1e1e22; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, .hint-i:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button.ghost, button.icon {
  background: transparent; border-color: transparent; color: var(--muted);
}
button.ghost:hover, button.icon:hover { color: var(--text); background: var(--raise); border-color: var(--line); }
button.ghost[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-bg); border-color: var(--accent-line); }
button.icon { width: var(--ctl); padding: 0; }
button.icon svg { width: 15px; height: 15px; }
button.tight { height: 20px; padding: 0 7px; font-size: 11.5px; }
button.stop, #btn-cancel { background: #2a1717; border-color: #6c3535; color: #f0c4c4; }
button.stop:hover, #btn-cancel:hover { background: #351c1c; border-color: #8a4242; }

input[type="number"], select {
  height: var(--ctl); width: 100%; padding: 0 8px; font-feature-settings: "tnum";
  background: var(--field); border-color: var(--line);
}
input[type="number"] { font: 12.5px var(--mono); padding-right: 2px; }
input[type="number"]:hover, select:hover { border-color: #3b3b41; }
input:disabled, select:disabled { opacity: .45; }
select { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 14px; height: 14px; flex: none; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); height: 16px; }
label { color: var(--muted); font-size: 11.5px; }

/* switch: a checkbox drawn as a pill */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 13px; white-space: nowrap; }
.toggle input {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 28px; height: 16px; border-radius: 8px; background: #3a3a40; position: relative;
  transition: background-color .15s;
}
.toggle input::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: #c9c9cf; transition: transform .15s, background-color .15s;
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::before { transform: translateX(12px); background: #1c1608; }
.toggle:hover input:not(:checked) { background: #46464d; }

/* segmented choice: radios drawn as one control */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
  padding: 2px; border-radius: var(--rad); background: var(--field); border: 1px solid var(--line);
}
.seg label { margin: 0; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 4px 6px; border-radius: var(--rad-s);
  color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.seg label:hover span { color: var(--text); }
.seg input:checked + span { color: var(--accent-ink); background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent-line); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.check {
  display: flex; align-items: center; gap: 8px; margin: 7px 0;
  color: var(--text); font-size: 13px; cursor: pointer; line-height: 1.25;
}
.check .note { color: var(--faint); font-size: 11.5px; margin-left: 2px; }
.check:has(input:disabled) { opacity: .45; cursor: default; }
.check.tight { margin: 0; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.check.tight:hover { color: var(--text); }
.hint { font-size: 11.5px; color: var(--faint); line-height: 1.45; margin: 6px 0 8px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.btns button { height: 26px; font-size: 12px; padding: 0 9px; }
.unit, .u { color: var(--faint); font-size: 11px; }
.grow { flex: 1; }
.hint-i {
  display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--muted); font: 600 10.5px var(--font); cursor: help; flex: none;
}
.hint-i:hover { color: var(--text); border-color: #45454c; }

/* fields: a two-column grid of label-over-input */
.fields, .detect { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin: 8px 0; }
.fields > div, .detect > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fields label, .detect label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fields .span2 { grid-column: 1 / -1; }
.fields .end { justify-content: flex-end; }
.fields .pair2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fields .pair2 > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fields.indent { margin-left: 22px; }
.field-dim { opacity: .4; }
label.stacked { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
label.inline { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: 12px; }
label.inline select { width: auto; height: 22px; padding: 0 4px; font-size: 12px; }
label.inline.range input { width: 64px; }
label.inline.range b { font: 11.5px var(--mono); color: var(--text); min-width: 3.4ch; font-feature-settings: "tnum"; }
details.fold { margin-top: 8px; }
details.fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px; padding: 4px 0;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: ""; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; margin: 0 3px 0 1px;
}
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > summary:hover { color: var(--text); }
h3.cap {
  font: 600 10.5px var(--font); letter-spacing: .09em; text-transform: uppercase; color: var(--faint);
  margin: 14px 0 4px;
}
h3.cap:first-child { margin-top: 4px; }

/* menus (details + popover) */
.more { position: relative; flex: none; }
.more > summary {
  list-style: none; cursor: pointer; height: var(--ctl); min-width: var(--ctl); padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--rad-s); color: var(--muted); font-size: 12px;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover, .more[open] > summary { color: var(--text); background: var(--raise); border-color: var(--line); }
.more > summary svg { width: 16px; height: 16px; }
.more-pop {
  position: fixed; z-index: 40; max-height: calc(100vh - 60px); overflow-y: auto;
  min-width: 190px; padding: 5px; border-radius: 8px;
  background: #1c1c1f; border: 1px solid #34343a; box-shadow: 0 14px 34px rgba(0, 0, 0, .55);
  display: flex; flex-direction: column; gap: 1px;
}
.more-pop > button { justify-content: flex-start; background: transparent; border-color: transparent; height: 30px; font-size: 12.5px; }
.more-pop > button:hover { background: var(--raise); }
.more-pop.form { padding: 10px 12px; gap: 4px; min-width: 230px; }
.more-group { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; padding: 8px 8px 4px; border-top: 1px solid var(--line-soft); }
.more-group .check { font-size: 12.5px; white-space: nowrap; }
.more-note { padding-left: 21px; font-size: 11.5px; color: var(--faint); }
.more-pop.form .check { margin: 4px 0; font-size: 12.5px; }
.menu-row { display: flex; align-items: center; gap: 10px; margin: 2px 0; }
.menu-group { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.menu-group label { display: flex; flex-direction: column; gap: 3px; }
.menu-cap { font: 600 10.5px var(--font); letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }

/* ── layout ───────────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--status) 0px;
  height: 100%; overflow: hidden;
}
.app.log-open { grid-template-rows: minmax(0, 1fr) var(--status) min(18vh, 180px); }
.stagewrap {
  --rail-w: var(--rail);
  display: grid; grid-template-columns: minmax(0, 1fr) var(--split) var(--rail-w);
  min-height: 0; overflow: hidden;
}
.app.rail-hidden .stagewrap { grid-template-columns: minmax(0, 1fr) 0 0; }
.app.rail-hidden .rail, .app.rail-hidden #split-rail { display: none; }
.rail-revive { display: none; position: absolute; z-index: 12; top: 6px; right: 8px; height: 24px; font-size: 12px; }
.app.rail-hidden .rail-revive { display: inline-flex; }
.work { position: relative; min-width: 0; min-height: 0; display: grid; container-type: size; }
.stage-view { display: grid; min-width: 0; min-height: 0; }

/* side views (left) | overlay (right)
 * Every side tab is as wide as the maps tab needs for a square shift map to fill its pane: the
 * stage's height less the tab bar, the map toolbar, two pane bars and the gaps, halved (plus the
 * scale bar when shown), at least 250 px so the tabs' names fit. The overlay keeps at least half
 * of the width and 280 px. Dragging the
 * splitter sets --split-align inline; a double-click removes it. */
#view-main {
  --map-tools-h: 56px;
  --cbar-w: 0px;
  --split-align: calc((100cqh - 3 * var(--bar) - var(--map-tools-h) - 2px) / 2 + var(--cbar-w));
  grid-template-columns: minmax(250px, min(var(--split-align), 100cqw - var(--split) - max(280px, 50cqw))) var(--split) minmax(240px, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
#view-main:has(#map-cbar:checked) { --cbar-w: 22px; }
.side { display: grid; grid-template-rows: var(--bar) minmax(0, 1fr); min-width: 0; min-height: 0; }
.side-tabs { display: flex; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; padding: 0 4px; gap: 2px; }
.dock-tab {
  flex: 1 1 auto; height: 100%; border: 0; border-radius: 0; background: transparent; padding: 0 6px; white-space: nowrap;
  color: var(--muted); font-size: 12.5px; font-weight: 500;
  box-shadow: inset 0 -2px 0 transparent;
}
.dock-tab:hover { background: transparent; color: var(--text); }
.dock-tab[aria-pressed="true"] { color: var(--accent-ink); box-shadow: inset 0 -2px 0 var(--accent); }
.dock { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); background: var(--well); }
.dock-pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); }
.dock-pane > .map-stack, .dock-pane > .flexpane, .dock-pane > .pair, .dock-pane > .pane { height: 100%; min-height: 0; }
#dock-kp { grid-template-rows: auto minmax(0, 1fr); }
#dock-score { grid-template-rows: minmax(150px, 42%) minmax(0, 1fr); gap: 1px; background: var(--line); }
#dock-pop { grid-template-rows: minmax(160px, 55%) minmax(0, 1fr); gap: 1px; background: var(--line); }

/* panes */
.pane {
  position: relative; min-height: 0; min-width: 0; overflow: hidden;
  background: var(--well); display: grid; grid-template-rows: var(--bar) minmax(0, 1fr);
}
.pane-bar {
  display: flex; align-items: center; gap: 10px; padding: 0 10px; min-width: 0;
  background: var(--panel); border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted); overflow: hidden; flex-wrap: nowrap;
}
.pane-bar .ttl { color: var(--text); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pane-bar .meta {
  font: 11.5px var(--mono); color: var(--faint); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.pane-bar select, .pane-bar input[type="number"] { height: 22px; width: auto; padding: 0 5px; font-size: 12px; }
.pane-bar input[type="number"] { width: 58px; }
.pane-bar #chk-px { width: 48px; }
.pane-bar .head-ctrls { display: inline-flex; align-items: center; gap: 4px; }
.pane-bar button.ghost { height: 22px; padding: 0 8px; font-size: 12px; }
.pane-bar .toggle { font-size: 12px; color: var(--muted); }
.pane-bar .toggle:hover, .pane-bar .toggle:has(input:checked) { color: var(--text); }
.pane-bar .more > summary { height: 22px; font-size: 12px; }
.pane-bar.tools { flex-wrap: wrap; height: auto; min-height: var(--bar); column-gap: 8px; row-gap: 4px; padding-top: 4px; padding-bottom: 4px; overflow: visible; position: relative; z-index: 9; }
.pane-body { position: relative; min-height: 0; min-width: 0; }
.pane-body canvas, .pane canvas { width: 100%; height: 100%; display: block; }
.slot { min-height: 0; min-width: 0; }
#slot-reg .pane { height: 100%; }
.drop.over { outline: 2px dashed var(--accent); outline-offset: -4px; }

/* keypoints */
.pair {
  --split-pair: 50%;
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(80px, var(--split-pair)) var(--split) minmax(80px, 1fr);
  min-height: 0; overflow: hidden;
}
.pane.source .pane-body canvas { cursor: crosshair; }
.pane.source .pane-body::after {
  position: absolute; inset: 10px; display: grid; place-items: center; pointer-events: none;
  border: 1.5px dashed #2f2f35; border-radius: 10px; color: var(--faint); font-size: 12.5px;
}
.app:not([data-left="1"]) #pane-left .pane-body::after { content: "drop the moving image here"; }
.app:not([data-right="1"]) #pane-right .pane-body::after { content: "drop the fixed image here"; }
.pane-bar.tools > select { width: auto; height: 22px; padding: 0 4px; font-size: 12px; }
#cv-matches { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.kp-patch {
  position: absolute; left: 8px; bottom: 8px; z-index: 6; pointer-events: none;
  display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-radius: var(--rad);
  background: rgba(14, 14, 16, .94); border: 1px solid var(--line);
}
.kp-patch-row { display: flex; gap: 8px; }
.kp-patch-col { display: flex; flex-direction: column; gap: 3px; }
.kp-patch-col .sub { font: 11px/1.35 var(--mono); color: var(--faint); white-space: pre; }
#cv-patch-l, #cv-patch-r { width: 88px; height: 88px; background: #000; display: block; border-radius: 2px; }
.kp-patch .meta { font: 11.5px var(--mono); color: var(--muted); }

/* maps */
.map-stack { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); }
.map-stack > .pane { height: 100%; min-height: 0; }
.map-stack.duo {
  grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--map-tools-h) minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px 0; background: var(--line);
}
/* two fixed rows at any width (the column's width rule counts on this height); a row too wide for
   a narrow column is clipped at its right end rather than wrapping */
.pane-bar.tools.map-tools { display: grid; grid-template-rows: 1fr 1fr; height: var(--map-tools-h); row-gap: 0; padding-top: 2px; padding-bottom: 2px; overflow: hidden; }
.map-tools .tools-row { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.map-body { display: grid; grid-template-columns: minmax(0, 1fr) 22px; min-height: 0; }
.map-body.no-cbar { grid-template-columns: minmax(0, 1fr); }
.map-plot { position: relative; min-width: 0; min-height: 0; }
.map-plot canvas { width: 100%; height: 100%; display: block; }
#cv-cbar { width: 22px; height: 100%; display: block; background: var(--well); border-left: 1px solid var(--line); }
#cv-map, #cv-rs { cursor: crosshair; touch-action: none; }
#cv-map.panning, #cv-rs.panning { cursor: grabbing; }

/* score history and lists */
.flexpane { display: grid; grid-template-rows: var(--bar) minmax(0, 1fr); min-height: 0; background: var(--bg); }
#cv-flex { width: 100%; height: 100%; display: block; cursor: grab; }
.side-list { display: grid; grid-template-rows: var(--bar) minmax(0, 1fr); min-height: 0; background: var(--well); }
.side-list .rows {
  list-style: none; padding: 2px 0; overflow-y: auto; min-height: 0;
  font: 12px/1.35 var(--mono); font-feature-settings: "tnum";
}
.side-list .rows li {
  display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; gap: 8px; align-items: baseline;
  padding: 4px 10px; cursor: pointer; color: var(--muted); border-left: 2px solid transparent;
}
.side-list .rows li:hover { background: #18181b; color: var(--text); }
.side-list .rows li.sel { background: var(--accent-bg); color: var(--accent-ink); border-left-color: var(--accent); }
.side-list .rows li .k { color: var(--faint); }
.side-list .rows li .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list .rows li .v { color: var(--text); }
.side-list .rows li.best .v::after { content: " ★"; color: var(--accent); }
.side-list .rows li.empty { cursor: default; color: var(--faint); display: block; font-family: var(--font); }
.side-list .rows li.empty:hover { background: none; }

/* overlay */
#cv-reg { outline: none; cursor: grab; }
#cv-reg:active { cursor: grabbing; }
#cv-reg.tweak-on { cursor: move; }
#cv-reg.rs-over { cursor: grab; }
.handle-tip {
  position: absolute; pointer-events: none; z-index: 4; white-space: nowrap;
  font: 11px var(--mono); color: #f0c8c8; padding: 3px 7px; border-radius: var(--rad-s);
  background: rgba(22, 10, 10, .92); border: 1px solid #6a3030; transform: translate(10px, -22px);
}
.hpanel {
  position: absolute; left: 8px; top: 8px; z-index: 6; margin: 0;
  background: rgba(16, 16, 18, .93); border: 1px solid var(--line); border-radius: var(--rad);
  padding: 7px 10px; font: 12px/1.5 var(--mono); color: #cfcfd4; font-feature-settings: "tnum"; white-space: pre;
}
.welcome {
  position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center; background: var(--well);
}
.app[data-images="2"] .welcome { display: none; }
.welcome-logo { width: 46px; height: 46px; color: var(--accent); opacity: .9; }
.welcome h1 { font-size: 18px; font-weight: 600; color: var(--text); }
.welcome p { max-width: 34em; color: var(--muted); font-size: 13px; line-height: 1.5; }
.welcome p b { color: var(--text); font-weight: 600; }
.welcome p.fine { color: var(--faint); font-size: 11.5px; }
.welcome-actions { display: flex; gap: 8px; margin: 4px 0; }
.welcome-actions button { height: 32px; padding: 0 14px; }
.welcome-actions svg { width: 15px; height: 15px; }

/* ── inspector (right rail) ───────────────────────────────────────────────── */
.rail {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--panel); border-left: 1px solid var(--line);
}
.rail-top { flex: none; display: flex; align-items: center; gap: 4px; padding: 8px 10px 6px 14px; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand .logo { width: 18px; height: 18px; color: var(--accent); }
.brand .name { font-weight: 650; font-size: 14px; letter-spacing: .02em; }
.rail-top button.ghost { height: 26px; font-size: 12px; padding: 0 8px; }
.rail-top #preset { width: 150px; height: 26px; font-size: 12px; }

.files { flex: none; margin: 2px 12px 0; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--card); }
.file { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; min-height: 34px; }
.file + .file { border-top: 1px solid var(--line-soft); }
.file .role { font: 600 10.5px var(--font); letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.file .fname { font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .fname.set { color: var(--text); }

.model { flex: none; padding: 10px 12px 0; display: flex; flex-direction: column; gap: 8px; }
.spline-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; padding: 0 2px; }
.spline-grid { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.spline-grid input[type="number"] { width: 50px; height: 24px; }
.app[data-ffd="off"] .spline-grid { visibility: hidden; }
.app[data-ffd="off"] .spline-only { display: none; }
.app[data-group="affine"] .homog-only { display: none; }

.run { flex: none; padding: 12px 12px 10px; }
#btn-auto, #btn-stack-run, #btn-stop { width: 100%; height: 46px; border-radius: 8px; }
#btn-auto, #btn-stack-run {
  flex-direction: column; gap: 1px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent)); border-color: #b8944b;
  color: #1c1505; box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 18px rgba(214, 176, 100, .12);
}
#btn-auto:hover, #btn-stack-run:hover { background: linear-gradient(180deg, #f0d38f, #dfba6c); }
#btn-auto:active, #btn-stack-run:active { background: var(--accent); }
#btn-auto:disabled, #btn-stack-run:disabled { opacity: 1; background: var(--raise); border-color: var(--line); color: var(--faint); box-shadow: none; }
#btn-auto b, #btn-stack-run b { font-size: 14px; font-weight: 700; letter-spacing: .03em; }
#auto-plan, #stack-plan { font: 11px var(--mono); opacity: .72; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-stop { font-weight: 600; gap: 8px; }
#btn-stop .busy-msg { font: 400 11.5px var(--mono); opacity: .8; }

.steps { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.card { border: 1px solid var(--line-soft); border-radius: 8px; background: var(--card); transition: border-color .15s; }
.card.open { border-color: var(--line); }
.card-head { display: flex; align-items: center; gap: 4px; padding-right: 5px; }
.card-toggle {
  flex: 1; min-width: 0; height: 40px; padding: 0 6px 0 10px; border: 0; background: transparent;
  display: grid; grid-template-columns: 22px auto minmax(0, 1fr) auto 12px; align-items: center; gap: 8px;
  text-align: left; border-radius: 8px;
}
.card-toggle:hover { background: transparent; }
.card-toggle:hover .name { color: var(--accent-ink); }
.card-toggle .name { font-weight: 600; font-size: 13px; color: var(--text); }
.card-toggle .sum { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-toggle .res { font: 11.5px var(--mono); color: var(--muted); white-space: nowrap; font-feature-settings: "tnum"; }
.card-toggle .res.opt { font: italic 11px var(--font); color: var(--faint); }
.card-toggle .res b { color: var(--good); font-weight: 500; }
.card-toggle .chev { width: 12px; height: 12px; color: var(--faint); transition: transform .15s; }
.card.open .chev { transform: rotate(90deg); }
.card-pose:empty { display: none; }
.card-pose { margin: -6px 12px 9px 40px; font: 11px/1.45 var(--mono); color: var(--faint); }
.card-body { padding: 2px 12px 12px; border-top: 1px solid var(--line-soft); }
.card-body > .seg { margin: 10px 0 2px; }

.badge {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid #3b3b42; color: var(--muted); font: 600 11px var(--font); position: relative;
}
.badge i { font-style: normal; }
.badge svg { display: none; width: 12px; height: 12px; }
.badge.dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #55555c; }
.card.is-done .badge { background: rgba(127, 191, 110, .14); border-color: rgba(127, 191, 110, .55); color: var(--good); }
.card.is-done .badge i { display: none; }
.card.is-done .badge svg { display: block; }
.card.is-next .badge { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-bg); }
.card.is-auto .badge { border-color: var(--accent); color: var(--accent-ink); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(214, 176, 100, .45); } 50% { box-shadow: 0 0 0 5px rgba(214, 176, 100, 0); } }

.go { width: 30px; height: 30px; padding: 0; border-radius: 50%; flex: none; color: var(--muted); background: transparent; border-color: var(--line); }
.go svg { width: 11px; height: 11px; margin-left: 2px; }
.go:hover:not(:disabled) { color: var(--accent-ink); border-color: var(--accent-line); background: var(--accent-bg); }
.card.is-next .go:not(:disabled) { color: #1c1505; background: var(--accent); border-color: var(--accent); }
.card.is-next .go:not(:disabled):hover { background: var(--accent-hi); }
#btn-rematch.ready:not(:disabled) { color: var(--accent-ink); border-color: var(--accent-line); }

/* ── status and log ───────────────────────────────────────────────────────── */
.statusbar {
  display: flex; align-items: center; gap: 10px; padding: 0 10px; min-width: 0;
  border-top: 1px solid var(--line); background: var(--panel);
  font: 11.5px var(--mono); color: var(--muted);
}
.statusbar .chip { padding: 1px 7px; border-radius: 10px; background: var(--raise); color: var(--muted); white-space: nowrap; }
.statusbar .live { color: var(--good); font-feature-settings: "tnum"; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar #busy { color: var(--accent); font-feature-settings: "tnum"; white-space: nowrap; }
.statusbar #btn-cancel { height: 20px; padding: 0 8px; font-size: 11.5px; }
.statusbar #status-extra { white-space: nowrap; color: var(--faint); }
.statusbar .compiling { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); white-space: nowrap; font-feature-settings: "tnum"; }
.compiling .bar { width: 72px; height: 4px; border-radius: 2px; background: var(--raise); overflow: hidden; }
.compiling .bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent); transition: width .12s linear; }
.log {
  border-top: 1px solid var(--line); background: var(--well);
  font: 12px/1.45 var(--mono); color: #9e9e96;
  overflow: hidden; padding: 6px 10px; white-space: pre-wrap; min-height: 0;
}
.app.log-open .log { overflow-y: auto; }

/* ── splitters ───────────────────────────────────────────────────────────── */
.split { position: relative; z-index: 8; background: var(--line); flex: none; touch-action: none; transition: background-color .12s; }
.split.v { cursor: col-resize; }
.split.h { cursor: row-resize; }
.split::after { content: ""; position: absolute; inset: 0; }
.split.v::after { left: -4px; right: -4px; }
.split.h::after { top: -4px; bottom: -4px; }
.split:hover, .split.dragging { background: var(--accent); }
body.split-drag-v { cursor: col-resize; user-select: none; }
body.split-drag-h { cursor: row-resize; user-select: none; }

@media (max-width: 1280px) { :root { --rail: 320px; } }

/* ── stack mode ──────────────────────────────────────────────────────────── */
.app[data-mode="pair"] .stack-only, .app[data-mode="stack"] .pair-only { display: none !important; }
.mode-row { flex: none; padding: 0 12px 8px; }
.work { grid-template-rows: minmax(0, 1fr) auto; }
.stack-bar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  height: 78px; padding: 6px 14px; background: var(--panel); border-top: 1px solid var(--line); overflow: hidden;
}
.stack-nav { display: flex; align-items: center; gap: 4px; min-width: 0; }
.stack-nav .icon { width: 30px; height: 30px; border-radius: 50%; }
.stack-nav .play { background: var(--accent-bg); border-color: var(--accent-line); color: var(--accent-ink); }
.stack-nav .play .i-pause, .stack-nav .play.on .i-play { display: none; }
.stack-nav .play.on .i-pause { display: block; }
.stack-where { display: flex; flex-direction: column; min-width: 150px; max-width: 240px; margin-left: 8px; }
.stack-where b { font: 600 13px var(--font); color: var(--text); font-feature-settings: "tnum"; }
.stack-where span { font: 11px var(--mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack-track { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; }
#cv-stack { width: 100%; height: 40px; min-width: 0; display: block; cursor: pointer; touch-action: none; }
.app[data-thumbs="on"] .stack-bar { height: 104px; }
.app[data-thumbs="on"] #cv-stack { height: 66px; }
#slice-slider { width: 100%; height: 18px; margin: 0; cursor: pointer; }
.stack-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.seg.mini span { padding: 2px 10px; font-size: 11.5px; }
.side-list .rows.slices li { grid-template-columns: 2.4em minmax(0, 1fr) auto 4.4em 4.4em 5.6em; }
.side-list .rows.slices li.head { cursor: default; color: var(--faint); font-family: var(--font); font-size: 11px; position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line-soft); }
.side-list .rows.slices li.head:hover { background: var(--panel); color: var(--faint); }
.side-list .rows.slices li.flag { box-shadow: inset 3px 0 0 var(--bad); }
.side-list .rows.slices li .t.bad { color: var(--bad); font-weight: 600; }
.side-list .rows.slices li .m { color: var(--faint); font-family: var(--font); font-size: 11.5px; }
.side-list .rows.slices li .d.bad { color: var(--bad); }
.side-list .rows.slices li .d.good { color: var(--good); }
