:root {
  color-scheme: light;
  --page: #f4f4f4;
  --panel: #fff;
  --line: #d5d5d5;
  --ink: #181818;
  --muted: #555;
  --action: #222;
  --surface: #ededed;
  font: 16px/1.45 "Segoe UI", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
h1, h2, p, dl, dd, ul { margin: 0; }
h1 { font-size: clamp(1.4rem, 3.4vw, 2.45rem); line-height: 1.12; letter-spacing: -.035em; }
h2 { font-size: 1rem; line-height: 1.25; }
label, dt { color: var(--muted); font-size: .82rem; font-weight: 500; }
input, select, button { font: inherit; }
button, select, input[type="file"] { min-height: 2.5rem; border: 1px solid var(--line); border-radius: .55rem; }
button, select { padding: .48rem .7rem; }
button { cursor: pointer; color: white; background: var(--action); font-size: .875rem; font-weight: 650; }
button:hover:enabled { background: #414141; }
button:disabled, select:disabled, input:disabled { opacity: .5; cursor: default; }
.secondary { color: var(--action); background: white; }
.secondary:hover:enabled { background: #ededed; }
:focus-visible { outline: 3px solid #666; outline-offset: 3px; }
[hidden] { display: none !important; }

.shell { max-width: 1720px; margin: auto; padding: 1.25rem clamp(.8rem, 2.4vw, 2.2rem) 2rem; }
.masthead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; padding: .4rem 0 1.15rem; }
.processor { display: inline-flex; gap: .32rem; justify-content: center; padding: .35rem .7rem; background: #e7e7e7; color: var(--ink); border-radius: .55rem; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: .85rem; min-width: 0; overflow: hidden; }
.setup, .timeline, .metadata, .workspace { margin-bottom: .85rem; }
.setup, .timeline { padding: .85rem 1rem; }
.setup form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(11rem, auto) minmax(7rem, auto) auto; align-items: end; gap: .7rem; margin-top: .55rem; }
.setup label { display: grid; gap: .25rem; min-width: 0; }
.scenario-fields { display: grid; gap: .45rem; min-width: 0; }
.download-links { display: flex; flex-wrap: wrap; gap: .35rem 1.15rem; margin-top: .75rem; }
.download-links a { color: var(--action); font-size: .875rem; text-underline-offset: .15em; }
#scenario-file { display: block; width: 100%; padding: 0 .45rem 0 0; background: #fafafa; color: var(--ink); font-size: .875rem; }
input::file-selector-button { cursor: pointer; background: #ededed; color: var(--action); border: 0; border-right: 1px solid var(--line); min-height: 2.45rem; padding: .4rem .65rem; margin-right: .55rem; font: inherit; font-weight: 650; }
select { max-width: 100%; color: var(--ink); background: #fafafa; font-size: .875rem; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.icon-button { display: grid; place-items: center; width: 2.5rem; padding: 0; }
.icon-button::before { content: ""; }
.play-icon::before { margin-left: .13rem; border-block: .42rem solid transparent; border-left: .66rem solid currentColor; }
.stop-icon::before { border: .37rem solid currentColor; border-radius: .07rem; }
.notice { margin-top: .55rem; color: var(--ink); font-size: .85rem; font-weight: 650; overflow-wrap: anywhere; }
.timeline-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.timeline-head > div { min-width: 0; }
.trial-profile-note { margin-top: .2rem; color: var(--ink); font-size: .8rem; font-weight: 650; overflow-wrap: anywhere; }
#run-status, .timing-note, .section-head p { color: var(--muted); font-size: .8rem; }
#run-status { margin-top: .25rem; }
#run-status[data-status="complete"], #run-status[data-status="error"] { color: var(--ink); font-weight: 650; }
.readout, dd, input[type="range"] + button { font-variant-numeric: tabular-nums; }
.readout { color: var(--action); font-size: .85rem; font-weight: 650; white-space: nowrap; }
progress { display: block; width: 100%; height: .42rem; margin: .55rem 0 .6rem; overflow: hidden; appearance: none; border: 0; border-radius: .5rem; background: #e7e7e7; accent-color: var(--action); }
progress::-webkit-progress-bar { background: #e7e7e7; }
progress::-webkit-progress-value { background: var(--action); }
progress::-moz-progress-bar { background: var(--action); }
.scrub { display: grid; align-items: center; gap: .7rem; grid-template-columns: 7rem minmax(0, 1fr) auto; }
.scrub button { min-height: 2.15rem; font-size: .78rem; padding-block: .32rem; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--action); }

.section-head { min-height: 2.85rem; display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .66rem .9rem; }
.section-head p { margin-top: .2rem; }
.heading-copy { min-width: 0; }
#frame-name { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.metric-heading { flex: 0 0 auto; display: grid; text-align: right; color: var(--muted); font-size: .75rem; }
.metric-heading strong { color: var(--ink); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; border-top: 1px solid var(--line); background: var(--line); }
.facts div { min-width: 0; min-height: 3.65rem; padding: .52rem .9rem; background: var(--panel); }
dd { color: var(--ink); font-size: .875rem; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.facts dd { margin-top: .18rem; }

.workspace { display: grid; grid-template-columns: minmax(0, .87fr) minmax(0, 1.42fr) minmax(0, 1fr); gap: .85rem; }
.camera, .map { display: grid; grid-template-rows: auto 1fr auto; }
.comparisons { display: grid; grid-template-rows: repeat(2, 1fr); gap: .85rem; min-width: 0; }
.match-panel { display: grid; grid-template-rows: auto 1fr auto; }
.surface { position: relative; overflow: hidden; background: var(--surface); min-width: 0; }
canvas { display: block; width: 100%; height: 100%; }
.surface canvas { position: absolute; inset: 0; }
.frame-surface, .map-surface { min-height: clamp(290px, 33vw, 565px); }
.match-surface { min-height: 126px; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: .75rem; text-align: center; color: var(--muted); font-size: .82rem; pointer-events: none; }
.north { position: absolute; top: .55rem; right: .55rem; background: #202020df; color: #fff; padding: .15rem .4rem; border-radius: .25rem; font-weight: 650; font-size: .75rem; }
.map-foot { padding: .45rem .65rem; }
.legend { list-style: none; display: flex; align-items: center; flex-wrap: wrap; gap: .15rem .65rem; padding: 0; color: var(--muted); font-size: .73rem; }
.legend li { display: flex; gap: .25rem; align-items: center; }
.swatch { display: inline-block; width: .9rem; height: .12rem; border-top: 2px solid; }
.route { border-color: #181818; }
.reference { border-color: #181818; border-top-style: dashed; }
.search { height: .65rem; border: 1px dotted #555; border-radius: .4rem; background: #ededed; }
.fix { width: .52rem; height: .52rem; border: 1px solid #181818; background: #fff; transform: rotate(45deg); }
.match-copy { color: var(--muted); padding: .45rem .65rem; min-height: 3rem; display: flex; align-items: center; font-size: .72rem; }
.errors .section-head { flex-wrap: wrap; }
.error-stats { display: flex; flex-wrap: wrap; gap: .55rem 1rem; }
.error-stats dt { font-size: .72rem; }
.error-stats dd { margin-top: .13rem; }
.chart-surface { background: #fafafa; border-top: 1px solid var(--line); min-height: clamp(205px, 20vw, 300px); }
.chart-surface .empty { color: var(--muted); }

@media (max-width: 1000px) {
  .setup form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
  .comparisons { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; }
  .match-surface { min-height: 170px; }
}
@media (max-width: 670px) {
  .setup form { grid-template-columns: minmax(0, 1fr); }
  .setup, .timeline { padding: .65rem .75rem; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts div { min-height: 3.4rem; padding-inline: .55rem; }
  .section-head { padding-inline: .55rem; }
  .scrub { grid-template-columns: auto minmax(0, 1fr); gap: .3rem .6rem; }
  .scrub button { grid-column: 2; justify-self: end; }
  .workspace, .comparisons { grid-template-columns: minmax(0, 1fr); }
  .frame-surface { min-height: min(60vw, 360px); }
  .map-surface { min-height: min(82vw, 460px); }
}
