:root {
  color-scheme: light;
  --page: #fdfdfd;
  --panel: #fff;
  --line: #dedede;
  --text: #111;
  --muted: #57575d;
  --accent: #5856d6;
  --accent-dark: #4442a9;
  --amber: #936009;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: var(--ui);
  background: var(--page);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, select, input { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.workspace { width: min(1100px, calc(100% - 60px)); margin: auto; padding: 31px 0 34px; }
.masthead { margin-bottom: 20px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.case { color: var(--muted); font: 500 11px var(--mono); letter-spacing: .12em; display: flex; align-items: center; gap: 10px; }
.case span { width: 3px; height: 3px; border-radius: 100%; background: #828282; }
.mast-row { display: flex; justify-content: space-between; align-items: end; gap: 18px; }
h1 { font-family: var(--serif); font-size: clamp(28px, 3.4vw, 42px); letter-spacing: -.035em; line-height: 1.1; margin: 0 0 5px; font-weight: 400; }
h1 span { color: var(--accent); font-weight: 400; margin: 0 .035em; }
.location { color: #3f3f43; font: 17px/1.4 var(--serif); margin: 0; }
.location b { color: var(--muted); font-weight: 500; margin: 0 3px; }
.status { white-space: nowrap; align-self: end; margin-bottom: 1px; border-left: 2px solid var(--accent); padding: 5px 0 5px 10px; color: var(--muted); font: 11px var(--mono); }

.views { display: grid; grid-template-columns: minmax(320px, 4fr) minmax(0, 7fr); gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 10px; min-width: 0; overflow: hidden; background: var(--panel);  }
.panel-header { min-height: 53px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
h2 { font: 400 22px/1.12 var(--serif); letter-spacing: -.025em; margin: 0; }
.subtle { color: var(--muted); font-size: 11px; }
.mono { font-family: var(--mono); }
.panel-header .mono { letter-spacing: .065em; font-size: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.stage, .map-stage { height: clamp(280px, 39vh, 430px); position: relative; overflow: hidden; }
.stage { display: grid; place-items: center; background: #f1f1f1; }
.portrait { position: absolute; height: 100%; max-width: 100%; aspect-ratio: var(--video-ratio, 9 / 16); }
video, #overlay { position: absolute; width: 100%; height: 100%; inset: 0; object-fit: contain; }
video { background: #0e1114; }
#overlay { pointer-events: none; }
.overlay-label { position: absolute; top: 8px; right: 8px; color: #dceeff; font: 9px var(--mono); border-radius: 3px; background: #0d1723ef; padding: 4px 5px; pointer-events: none; }
.media-status { position: relative; max-width: 85%; padding: 9px 13px; border-radius: 7px; background: #fff; color: var(--text); border: 1px solid var(--line); font-size: 12px; text-align: center; }
.overlay-bar, .map-footer { min-height: 77px; border-top: 1px solid var(--line); padding: 11px 14px 9px; }
.modes { display: flex; flex-wrap: wrap; gap: 4px; }
.modes button { white-space: nowrap; border: 1px solid transparent; border-radius: 6px; padding: 6px 7px; background: transparent; color: #3f3f48; font-size: 11px; }
.modes button:hover { background: #f4f3f8; }
.modes button[aria-pressed=true] { color: var(--accent-dark); border-color: #d5d2f1; background: #eeedfa; }
.overlay-bar p { margin: 6px 2px 0; font-size: 11px; color: var(--muted); }
.map-stage { background: #eeece9; display: grid; place-items: center; }
#map { width: 100%; height: 100%; display: block; }
.route-outline, .route-halo, #trail { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.route-halo { stroke: #17132c; opacity: .6; stroke-width: 10; }
.route-outline { stroke: #e4dfff; stroke-width: 5; stroke-dasharray: 8 12; }
#trail { stroke: #a39aff; stroke-width: 7; }
.map-point { fill: #f1edff; stroke: #4a439f; stroke-width: 3; }
.car { filter: drop-shadow(0 6px 3px #000a); }
.map-attribution { position: absolute; right: 9px; bottom: 9px; padding: 4px 6px; border-radius: 4px; color: #25242c; background: #fffe; font: 10px var(--ui); }
.map-stage .media-status { position: absolute; }
.map-footer { display: flex; gap: 7px 16px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 11px; color: #45454e; }
.legend i { width: 13px; display: inline-block; vertical-align: 3px; margin-right: 4px; border-top: 2px solid; }
.legend .amber { color: var(--amber); }
.legend .blue { color: #1972a6; }
.legend .dashed { color: var(--accent); border-top-style: dashed; }
.telemetry { margin-top: 14px; }
.telemetry .panel-header { min-height: 43px; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; }
.metric { min-width: 0; border: 0; border-right: 1px solid var(--line); background: #fafafa; padding: 10px 14px; text-align: left; }
.metric:last-child { border-right: 0; }
.metric:hover { background: #f4f3f8; }
.metric:focus-visible { outline-offset: -3px; }
.metric strong { display: block; margin-bottom: 4px; color: #36363d; font-size: 11px; font-weight: 550; }
.metric strong::after { content: " ↗"; color: var(--accent); }
.metric-value { color: var(--text); font: 19px var(--mono); }
.metric[data-kind=scenario] .metric-value { color: var(--accent-dark); }
.metric-state { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.timeline { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 17px; padding: 10px 15px; border-top: 1px solid var(--line); }
.transport { display: flex; align-items: center; gap: 5px; }
.transport button, select { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); font-size: 11px; }
.transport button:hover, select:hover { background: #f4f3f8; }
.transport .play { color: #fff; background: var(--accent); border-color: var(--accent); width: 39px; font-size: 14px; }
.transport .play:hover { background: var(--accent-dark); }
.scrub input { display: block; width: 100%; margin: 0; accent-color: var(--accent); cursor: pointer; }
.ticks { display: flex; justify-content: space-between; gap: 4px; color: var(--muted); font: 9px var(--mono); margin: 2px 3px 0; }
.time { display: grid; text-align: right; gap: 2px; min-width: 92px; }
.time output { color: var(--text); font-size: 15px; }
.time span { color: var(--muted); font-size: 10px; }
dialog { color: var(--text); width: min(510px, calc(100% - 28px)); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 23px; }
dialog::backdrop { background: #16152363; }
dialog .close { float: right; background: #fff; border: 1px solid var(--line); border-radius: 5px; font-size: 21px; line-height: 1; width: 30px; height: 30px; }
.dialog-kicker { color: var(--accent); font-size: 10px; letter-spacing: .09em; margin-top: 0; }
dialog h2 { font-size: 27px; }
.inspector-kind { color: var(--amber); font-size: 12px; margin-top: 6px; }
dialog dl { margin: 18px 0 0; }
dialog dt { color: var(--muted); font: 11px var(--mono); text-transform: uppercase; }
dialog dd { color: var(--text); font-size: 13px; line-height: 1.5; margin: 3px 0 12px; }
@media (max-width: 960px) {
  .workspace { width: calc(100% - 40px); }
  .views { grid-template-columns: minmax(300px, 4fr) minmax(0, 6fr); }
}
@media (max-width: 730px) {
  .workspace { width: calc(100% - 28px); padding: 22px 0; }
  .mast-row { align-items: start; flex-direction: column; gap: 10px; }
  .status { align-self: start; }
  .views { grid-template-columns: minmax(0, 1fr); }
  .stage { height: clamp(300px, 55svh, 480px); }
  .map-stage { height: auto; aspect-ratio: 4 / 3; }
  .map-footer { min-height: 52px; }
  .metrics { grid-template-columns: repeat(6, minmax(112px, 1fr)); overflow-x: auto; }
  .timeline { grid-template-columns: 1fr auto; gap: 7px 12px; }
  .scrub { grid-column: 1 / -1; grid-row: 2; }
  .time { grid-column: 2; }
}

.view-switch { display:flex; align-items:center; flex-wrap:wrap; gap:10px 18px; margin:0 0 10px; }
.reconstruction-modes { padding:3px; border:1px solid var(--line); border-radius:7px; }
.reconstruction-modes button { font-size:12px; padding:7px 11px; }
.solution-picker { display:flex; align-items:center; gap:8px; font-size:11px; color:var(--muted); }
.solution-picker select { max-width:240px; }
.diagnostic-link { margin-left:auto; font:11px var(--mono); color:var(--accent-dark); }
.model-context { font-size:12px; line-height:1.6; margin:0 0 16px; max-width:950px; color:#4a4857; }
.model-summary { padding:10px 15px; font:11px/1.7 var(--mono); border-top:1px solid var(--line); color:#4a4857; }
.metrics { grid-template-columns:repeat(8,minmax(0,1fr)); }
.metric { padding:10px 11px; }
.metric-value { font-size:17px; }
.metric-range { display:block; font:9px var(--mono); color:var(--muted); margin-top:4px; min-height:12px; }
.metric-state { color:var(--accent-dark); }
.metric[data-kind="Simulated"] { background:#fff8ed; }
.metric[data-kind="Observed"] .metric-state { color:#1b6c69; }
.trace-grid { display:grid; grid-template-columns:1fr 1fr; border-top:1px solid var(--line); }
.trace-grid figure { margin:0; padding:13px 15px; min-width:0; }
.trace-grid figure+figure { border-left:1px solid var(--line); }
.trace-grid figcaption { font:20px var(--serif); }
.trace-grid figcaption span { display:block; font:10px/1.6 var(--ui); color:var(--muted); }
.trace-grid svg { width:100%; display:block; overflow:visible; }
.trace-line { fill:none; stroke:var(--accent); stroke-width:2; }
.trace-band { fill:#5856d61e; }
.trace-gridline { stroke:#dedde5; stroke-width:1; }
.trace-tick { font:9px var(--mono); fill:#5a5864; }
.trace-cursor { stroke:#161521; stroke-width:1; stroke-dasharray:3 3; }
.trace-bridge { fill:#d69a3e17; }
.bridge-route { fill:none; stroke:#f2b258; stroke-width:8; stroke-dasharray:8 7; }
.uncertainty-envelope { fill:#aaa0ff30; stroke:#e8e2ff; stroke-width:1.5; stroke-dasharray:4 6; }
.road-envelope { fill:#d0ecb010; stroke:#e0ffc5; stroke-width:2; stroke-dasharray:8 8; }
.anchor-handle { cursor:grab; touch-action:none; }
.anchor-handle circle { fill:#fff; stroke:#5856d6; stroke-width:4; }
.anchor-handle text { fill:#252035; font:22px var(--ui); paint-order:stroke; stroke:#fff; stroke-width:5px; }
.assumptions-panel { margin-top:14px; }
.assumption-controls { padding:15px; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px 18px; }
.assumption-controls label { font-size:11px; color:#41404a; display:grid; gap:6px; }
.assumption-controls label span { display:flex; justify-content:space-between; gap:5px; }
.assumption-controls output { font:10px var(--mono); color:var(--accent-dark); }
.assumption-controls input { width:100%; accent-color:var(--accent); }
.assumption-actions { padding:0 15px 15px; display:flex; flex-wrap:wrap; align-items:center; gap:9px; }
.assumption-actions button { font-size:11px; padding:7px 10px; border:1px solid var(--line); background:white; border-radius:5px; }
.assumption-actions #refit { background:var(--accent); color:white; border-color:var(--accent); }
.assumption-actions button:disabled { opacity:.5; cursor:wait; }
.factory-reference { font:10px/1.7 var(--ui); color:var(--muted); margin:0; padding:10px 15px; border-top:1px solid var(--line); }
.factory-reference a { color:var(--accent-dark); }
.status[data-warning="true"] { border-color:#b0782e; color:#83520d; }
@media(max-width:960px) { .metrics { grid-template-columns:repeat(8,minmax(105px,1fr)); overflow-x:auto; } }
@media(max-width:730px) { .trace-grid { grid-template-columns:1fr; } .trace-grid figure+figure { border-left:0; border-top:1px solid var(--line); } .assumption-controls { grid-template-columns:1fr 1fr; } .diagnostic-link { margin-left:0; } .model-context { font-size:11px; } }

#media-retry { padding: 7px 10px; margin: 4px; color: var(--accent-dark); background: #f0effa; border: 1px solid var(--line); border-radius: 5px; }
