/* Layout: one operator screen. Top bar with layers; fleet and policy rail on the left, map in the centre with the route strip under it, inspector and decisions rail on the right. Below 900 px the rails become tabs in a bottom sheet. */
:root {
  color-scheme: light;
  --bg: #e7eae5;
  --surface: #f8f9f6;
  --surface-2: #eef1ec;
  --ink: #1b2320;
  --muted: #5a6661;
  --line: #d3d9d3;
  --accent: #155e63;
  --accent-ink: #ffffff;
  --accent-soft: #d6e8e6;
  --warn: #b35c00;
  --bad: #c42b35;

  --map-bg: #eceee8;
  --terrain-low: #f2f3ec;
  --terrain-high: #e3d6b8;
  --contour: #9b6f46;
  --building: #d9d3c8;
  --building-edge: #b5ab9c;
  --grad-flat: #71818a;
  --grad-mod: #d09016;
  --grad-steep: #c8323c;
  --stairs: #7b3fb5;
  --kerb-raised: #7b3fb5;
  --kerb-ok: #148a72;
  --crossing: #2b3a42;
  --no-rover: #98a39f;
  --label: #1b2320;
  --halo: #f8f9f6;
  --poi: #8a7f70;
  --pickup: #e08a00;
  --dropoff: #0aa2c4;
  --done: #22a06b;
  --block: #e5484d;
  --hub: #155e63;
  --rover-1: #2463c7;
  --rover-2: #b8326e;
  --rover-3: #4b8a1c;
  --rover-4: #c26a14;
  --rover-5: #6d4bd1;
  --rover-6: #0e8a86;
  --rover-7: #8a5a2b;
  --rover-8: #3d5a80;
  --ctx-building: #d8d9d4;
  --ctx-edge: #c6c8c2;
  --ctx-road: #f8f8f5;
  --ctx-path: #c4c8c2;
  --ctx-green: #dde3d5;
  --ctx-water: #ccd9df;
  --wash: #d3d7d2;
  --wash-a: 0.55;
  --edge-line: #6b7671;
  --think: #eef4f3;
  --cand-1: #4f5bd5;
  --cand-2: #e04f8a;
  --cand-3: #23a55a;
  --cand-4: #d9a000;
  --cand-5: #6f7d86;
  --power-1: #3b8bd9;
  --power-2: #2aa898;
  --power-3: #e0ad2f;
  --power-4: #e8702a;
  --power-5: #c9283e;
  --shake-1: #8fb8a8;
  --shake-2: #3f9a8c;
  --shake-3: #8a6cc0;
  --shake-4: #b8408f;
  --shake-5: #6e1846;
  --s-surface: #a0783c;
  --s-kerbs: #7b3fb5;
  --s-turns: #2aa898;
  --s-descents: #3b8bd9;
  --up: #e8702a;
  --down: #3b8bd9;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-data: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 11px;
  --fs-s: 12px;
  --fs-m: 13px;
  --fs-l: 15px;
  --radius: 6px;
  --beyond: #dcdfda;
  --focus-wash: #dfe2dd;
  --focus-a: 0.7;
  --grid: #5a666150;
  --hover: #3d8f95;
  --line-strong: #b7c0b9;
  --e-climb: #d9632b;
  --e-rolling: #a0783c;
  --e-stops: #5f7480;
  --e-kerbs: #7b3fb5;
  --e-turning: #2aa898;
  --e-hotel: #a9b3b8;
  --e-regen: #3b8bd9;
  --rail-l: 288px;
  --rail-r: 360px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1211; --surface: #141a19; --surface-2: #1b2321; --ink: #e3e9e6; --muted: #8d9a95; --line: #29332f;
    --accent: #4fb7ae; --accent-ink: #08201e; --accent-soft: #1d3634; --warn: #f0a14a; --bad: #ff6b72;
    --map-bg: #111716; --terrain-low: #1c2624; --terrain-high: #4a4636; --contour: #b48a62; --building: #2a3230; --building-edge: #3d4744;
    --grad-flat: #8597a0; --grad-mod: #e8b443; --grad-steep: #f2646e; --stairs: #b892f2; --kerb-raised: #b892f2; --kerb-ok: #3cc4a2;
    --crossing: #d5dde0; --no-rover: #56625e; --label: #e3e9e6; --halo: #111716; --poi: #8d8677;
    --pickup: #f5a524; --dropoff: #36c5e6; --done: #3ccf8a; --block: #ff5d62; --hub: #4fb7ae;
    --rover-1: #5b9cf5; --rover-2: #ec6aa6; --rover-3: #8cc84b; --rover-4: #f09a45;
    --rover-5: #a58bf5; --rover-6: #3fc7bf; --rover-7: #c99563; --rover-8: #8fb0d6;
    --ctx-building: #2a3230; --ctx-edge: #343d3a; --ctx-road: #323b39; --ctx-path: #3a4441; --ctx-green: #1f2925; --ctx-water: #1b2833;
    --wash: #2b3230; --wash-a: 0.55; --edge-line: #8d9a95; --think: #172322;
    --cand-1: #8a95ff; --cand-2: #ff7aa8; --cand-3: #4fd486; --cand-4: #f5c542; --cand-5: #9aa7b0;
    --power-1: #5aa6f0; --power-2: #47c9b8; --power-3: #f0c24f; --power-4: #f58a45; --power-5: #f2556a;
    --shake-1: #6f9c8c; --shake-2: #4fc0ae; --shake-3: #ae92ec; --shake-4: #f06ab8; --shake-5: #ffb3dc; --s-surface: #c79a5a; --s-kerbs: #b892f2; --s-turns: #47c9b8; --s-descents: #5aa6f0;
    --up: #f58a45; --down: #5aa6f0;
    --beyond: #171d1c; --focus-wash: #0d1211; --focus-a: 0.72; --grid: #8d9a9550; --hover: #7fd3cb; --line-strong: #3b4743; --e-climb: #f0844d; --e-rolling: #c79a5a; --e-stops: #8aa0ab; --e-kerbs: #b892f2; --e-turning: #47c9b8; --e-hotel: #5d6a70; --e-regen: #5aa6f0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1211; --surface: #141a19; --surface-2: #1b2321; --ink: #e3e9e6; --muted: #8d9a95; --line: #29332f;
  --accent: #4fb7ae; --accent-ink: #08201e; --accent-soft: #1d3634; --warn: #f0a14a; --bad: #ff6b72;
  --map-bg: #111716; --terrain-low: #1c2624; --terrain-high: #4a4636; --contour: #b48a62; --building: #2a3230; --building-edge: #3d4744;
  --grad-flat: #8597a0; --grad-mod: #e8b443; --grad-steep: #f2646e; --stairs: #b892f2; --kerb-raised: #b892f2; --kerb-ok: #3cc4a2;
  --crossing: #d5dde0; --no-rover: #56625e; --label: #e3e9e6; --halo: #111716; --poi: #8d8677;
  --pickup: #f5a524; --dropoff: #36c5e6; --done: #3ccf8a; --block: #ff5d62; --hub: #4fb7ae;
  --rover-1: #5b9cf5; --rover-2: #ec6aa6; --rover-3: #8cc84b; --rover-4: #f09a45;
    --rover-5: #a58bf5; --rover-6: #3fc7bf; --rover-7: #c99563; --rover-8: #8fb0d6;
    --ctx-building: #2a3230; --ctx-edge: #343d3a; --ctx-road: #323b39; --ctx-path: #3a4441; --ctx-green: #1f2925; --ctx-water: #1b2833;
    --wash: #2b3230; --wash-a: 0.55; --edge-line: #8d9a95; --think: #172322;
  --cand-1: #8a95ff; --cand-2: #ff7aa8; --cand-3: #4fd486; --cand-4: #f5c542; --cand-5: #9aa7b0;
  --power-1: #5aa6f0; --power-2: #47c9b8; --power-3: #f0c24f; --power-4: #f58a45; --power-5: #f2556a;
  --shake-1: #6f9c8c; --shake-2: #4fc0ae; --shake-3: #ae92ec; --shake-4: #f06ab8; --shake-5: #ffb3dc; --s-surface: #c79a5a; --s-kerbs: #b892f2; --s-turns: #47c9b8; --s-descents: #5aa6f0;
  --up: #f58a45; --down: #5aa6f0;
  --beyond: #171d1c; --focus-wash: #0d1211; --focus-a: 0.72; --grid: #8d9a9550; --hover: #7fd3cb; --line-strong: #3b4743; --e-climb: #f0844d; --e-rolling: #c79a5a; --e-stops: #8aa0ab; --e-kerbs: #b892f2; --e-turning: #47c9b8; --e-hotel: #5d6a70; --e-regen: #5aa6f0;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-m)/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
button, input, output { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); align-self: center; box-shadow: 4px 4px 0 -1px var(--pickup); }
.brand h1 { font-size: var(--fs-l); font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clock {
  display: flex; align-items: baseline; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line);
}
.clock-label { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
#clock { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: var(--fs-m); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 30px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-size: var(--fs-s); font-weight: 600; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.icon { width: 30px; padding: 0; }
.btn.icon svg { width: 14px; height: 14px; fill: currentColor; }
.btn.small { min-height: 24px; padding: 2px 8px; font-size: var(--fs-xs); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn[aria-pressed="true"].mode, .btn[aria-pressed="true"].toggle { background: var(--accent-soft); border-color: var(--accent); }
#play .i-play { display: none; }
#play[aria-pressed="true"] .i-play { display: inline; }
#play[aria-pressed="true"] .i-pause { display: none; }
.toggle .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--muted); }
.toggle[aria-pressed="true"] .dot { background: var(--accent); border-color: var(--accent); }
.toggle .auto { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg-btn { border: 0; background: var(--surface); padding: 4px 9px; min-height: 28px; font-size: var(--fs-s); font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); }


/* Shell: top bar, then a three-column grid. */
.layout {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: var(--rail-l) minmax(0, 1fr) var(--rail-r);
  grid-template-areas: "left center right";
}
.rail { min-height: 0; overflow-y: auto; background: var(--surface); scrollbar-width: thin; }
.rail-left { grid-area: left; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.rail-right { grid-area: right; border-left: 1px solid var(--line); }
.center { grid-area: center; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mapwrap { position: relative; flex: 1; min-height: 200px; overflow: hidden; background: var(--map-bg); touch-action: none; }
#map { position: absolute; inset: 0; display: block; cursor: grab; }
.mapwrap.hot #map { cursor: pointer; }
#map.dragging { cursor: grabbing; }
.sheet-tabs { display: none; }

.panel { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel.grow { flex: 1; }
.panel-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.panel-head h2 { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-right: auto; }
.panel-meta { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-head .btn { align-self: center; }
.empty { margin: 0; color: var(--muted); font-size: var(--fs-s); }
.about { padding: 10px 14px 14px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.count { display: inline-block; min-width: 18px; padding: 0 4px; margin-left: 4px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-family: var(--font-data); letter-spacing: 0; text-align: center; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn svg { width: 13px; height: 13px; fill: currentColor; flex: none; }

/* Map overlays */
.zoom { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 2; }
.north { width: 30px; display: grid; place-items: center; padding-top: 4px; }
.north svg { width: 20px; height: 26px; overflow: visible; }
.north .n-up { fill: var(--ink); }
.north .n-dn { fill: var(--muted); opacity: 0.6; }
.north text { font: 700 8px var(--font-ui); fill: var(--ink); paint-order: stroke; stroke: var(--halo); stroke-width: 3px; }
.scale { position: absolute; left: 12px; bottom: 12px; z-index: 2; display: grid; gap: 2px; pointer-events: none;
  font: 600 var(--fs-xs)/1 var(--font-data); color: var(--ink); text-shadow: 0 0 3px var(--halo), 0 0 3px var(--halo); }
.scale-bar { display: block; width: 100px; height: 6px; border: 2px solid var(--ink); border-top: 0; box-shadow: 0 1px 0 var(--halo); }
.coords {
  position: absolute; right: 12px; bottom: 12px; z-index: 2; pointer-events: none;
  display: grid; gap: 1px; min-width: 232px; padding: 6px 9px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: var(--radius);
  font: var(--fs-xs)/1.45 var(--font-data); font-variant-numeric: tabular-nums;
}
.c-row { display: flex; justify-content: space-between; gap: 12px; }
.c-row span { color: var(--muted); font-family: var(--font-ui); }
.c-row b { font-weight: 600; text-align: right; }

/* Layers dropdown */
.pop { position: relative; }
#layers-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.pop-panel {
  position: fixed; z-index: 30; width: min(440px, calc(100vw - 24px)); max-height: min(78vh, 640px); overflow-y: auto;
  display: grid; gap: 6px; padding: 10px 12px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 28px -12px rgb(0 0 0 / 0.35); font-size: var(--fs-xs);
}
.pop-title { margin: 0 0 2px; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.lg-row { display: grid; grid-template-columns: 16px 112px 1fr; align-items: start; gap: 6px; cursor: pointer; padding: 3px 0; }
.lg-row input { margin: 1px 0 0; accent-color: var(--accent); }
.lg-static { cursor: default; border-top: 1px solid var(--line); padding-top: 7px; }
.lg-static::before { content: ""; }
.sw.fill.ctx { background: var(--ctx-building); border-color: var(--ctx-edge); }
.k-note { color: var(--muted); white-space: normal !important; }
.pop-panel .lg-keys { min-width: 0; }
.pop-panel .lg-keys .k { white-space: normal; }
.lg-name { font-weight: 600; }
.lg-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; color: var(--muted); }
.lg-keys .k { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.lg-note { margin: 2px 0 0; color: var(--muted); line-height: 1.45; }
.sw { display: inline-block; flex: none; }
.sw.line { width: 16px; height: 3px; border-radius: 2px; background: var(--c); }
.sw.line.thin { height: 1.5px; }
.sw.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.sw.dot.open { background: none; box-shadow: inset 0 0 0 1.5px var(--c); }
.sw.dash { width: 16px; height: 2px; background: repeating-linear-gradient(90deg, var(--no-rover) 0 3px, transparent 3px 6px); }
.sw.ladder { width: 16px; height: 7px; background: repeating-linear-gradient(90deg, var(--stairs) 0 1.5px, transparent 1.5px 4px), linear-gradient(var(--stairs), var(--stairs)) center / 100% 2px no-repeat; }
.sw.bar { width: 3px; height: 10px; background: var(--kerb-raised); }
.sw.sq { width: 7px; height: 7px; background: var(--crossing); }
.sw.sq.open { background: none; border: 1.5px solid var(--crossing); }
.sw.dots { width: 16px; height: 4px; background: radial-gradient(circle, var(--label) 1px, transparent 1.4px) 0 0 / 4px 4px repeat-x; }
.sw.fill { width: 12px; height: 9px; background: var(--building); border: 1px solid var(--building-edge); }
.sw.cross { width: 10px; height: 10px; background: linear-gradient(45deg, transparent 40%, var(--block) 40% 60%, transparent 60%), linear-gradient(-45deg, transparent 40%, var(--block) 40% 60%, transparent 60%); }

.sw.blk { width: 12px; height: 8px; border-radius: 2px; background: color-mix(in srgb, var(--c) 55%, transparent); }
.sw.mk { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid var(--c); }
.sw.band { width: 14px; height: 8px; background: repeating-linear-gradient(90deg, var(--e-rolling) 0 2px, transparent 2px 4px); opacity: 0.7; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 4;
  padding: 5px 8px; border-radius: var(--radius); background: var(--ink); color: var(--surface);
  font: var(--fs-xs)/1.35 var(--font-ui); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tooltip b { font-weight: 700; }
.toast {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 4;
}
.toast-item {
  display: flex; align-items: center; gap: 10px; pointer-events: auto; max-width: min(560px, calc(100vw - 32px));
  padding: 6px 12px; border-radius: var(--radius); background: var(--ink); color: var(--surface);
  font-size: var(--fs-s); font-weight: 600; animation: toast-in 0.2s ease-out both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.loader {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: var(--map-bg);
  transition: opacity 0.5s ease, visibility 0.5s;
}
.loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader.done .loader-card { transform: translateY(-8px) scale(0.98); }
.loader-card {
  width: min(340px, calc(100% - 32px)); padding: 24px 24px 20px; display: grid; justify-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); animation: card-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.loader-spin { width: 44px; height: 44px; }
.loader-spin circle { fill: none; stroke-width: 3; }
.loader-spin .ring { stroke: var(--surface-2); }
.loader-spin .arc { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 30 120; transform-origin: 24px 24px; animation: spin 1.1s linear infinite, dash 1.6s ease-in-out infinite; }
.loader-spin .core { fill: var(--accent); stroke: none; transform-origin: 24px 24px; animation: beat 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dash { 0%, 100% { stroke-dasharray: 18 120; } 50% { stroke-dasharray: 70 120; } }
@keyframes beat { 0%, 100% { transform: scale(0.8); opacity: 0.7; } 50% { transform: scale(1.1); opacity: 1; } }
.loader.failed .loader-spin .arc, .loader.failed .loader-spin .core { animation: none; stroke: var(--bad); fill: var(--bad); }
.loader-title { font-size: var(--fs-l); font-weight: 700; color: var(--ink); }
.loader-step { min-height: 1.4em; font-size: var(--fs-s); color: var(--muted); animation: step-in 0.3s ease both; }
@keyframes step-in { from { opacity: 0; transform: translateY(4px); } }
.loader-bar { position: relative; width: 100%; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.loader-bar span {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(0); border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--dropoff)));
}
.loader-bar span::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.45), transparent); transform: translateX(-100%);
  animation: sheen 1.3s ease-in-out infinite;
}
@keyframes sheen { to { transform: translateX(100%); } }
.loader-meta { width: 100%; display: flex; justify-content: space-between; font: 600 var(--fs-xs)/1 var(--font-data); color: var(--muted); font-variant-numeric: tabular-nums; }
.loader-meta output { color: var(--ink); }
.loader-steps { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; display: grid; gap: 5px; font-size: var(--fs-s); color: var(--muted); }
.loader-steps li { position: relative; padding-left: 20px; transition: color 0.3s; }
.loader-steps li::before {
  content: ""; position: absolute; left: 2px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%;
  border: 1.5px solid var(--line); box-sizing: border-box; transition: background 0.3s, border-color 0.3s, transform 0.3s;
}
.loader-steps li.active { color: var(--ink); }
.loader-steps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.loader-steps li.ok { color: var(--ink); }
.loader-steps li.ok::before { background: var(--done); border-color: var(--done); animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.4); } }
.loader-error { width: 100%; display: grid; gap: 10px; justify-items: center; text-align: center; font-size: var(--fs-s); color: var(--bad); }
.loader-error p { margin: 0; }

.toast { left: 12px; bottom: 44px; transform: none; align-items: flex-start; max-width: calc(100% - 300px); }
.toast-item { max-width: 100%; }
.toast-item .btn { min-height: 22px; padding: 1px 8px; background: transparent; color: var(--surface); border-color: color-mix(in srgb, var(--surface) 45%, transparent); }
.toast-item .btn:hover { background: color-mix(in srgb, var(--surface) 14%, transparent); }

body.booting #map { opacity: 0; }
#map { transition: opacity 0.6s ease; }
body.booting .zoom, body.booting .scale { opacity: 0; translate: 0 6px; }
.zoom, .scale { transition: opacity 0.5s ease 0.35s, translate 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.35s; }
body.booting .rail .panel, body.booting .strip { opacity: 0; translate: 0 8px; }
.rail .panel, .strip { transition: opacity 0.45s ease, translate 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.rail .panel:nth-child(2) { transition-delay: 0.08s; }
.rail .panel:nth-child(3) { transition-delay: 0.16s; }

.fleet { display: grid; gap: 4px; }
.rover-card {
  display: grid; grid-template-columns: 30px 82px 1fr 44px; grid-template-rows: auto auto; align-items: center; gap: 2px 8px;
  width: 100%; padding: 6px 8px; text-align: left; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius); background: var(--surface-2);
}
.rover-card:hover { border-color: var(--line); }
.rover-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.rc-id { grid-row: 1 / 3; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: var(--halo); font-weight: 700; font-size: var(--fs-xs); }
.rc-bat { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.bar { position: relative; flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--done); border-radius: 3px; }
.bar.low > span { background: var(--bad); }
.bar.mid > span { background: var(--warn); }
.rc-cargo { font-size: var(--fs-xs); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rc-order { grid-column: 2 / 5; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: max-content;
  padding: 1px 7px; border-radius: 10px; font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
  background: var(--line); color: var(--ink);
}
.chip[data-s="TO_PICKUP"], .chip[data-s="LOADING"] { background: color-mix(in srgb, var(--pickup) 22%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px var(--pickup); }
.chip[data-s="DELIVERING"], .chip[data-s="DROP_OFF"] { background: color-mix(in srgb, var(--dropoff) 22%, transparent); box-shadow: inset 0 0 0 1px var(--dropoff); }
.chip[data-s="RETURNING"] { background: color-mix(in srgb, var(--grad-flat) 22%, transparent); box-shadow: inset 0 0 0 1px var(--grad-flat); }
.chip[data-s="CHARGING"] { background: color-mix(in srgb, var(--done) 22%, transparent); box-shadow: inset 0 0 0 1px var(--done); }
.chip.planning::after { content: "planning"; font-weight: 500; color: var(--muted); }
.rover-card .chip.planning::after { content: none; }
.rover-card .chip.planning { outline: 1.5px dashed var(--muted); outline-offset: 1px; }

.orders { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px;  }
.order {
  display: grid; grid-template-columns: 34px 1fr auto 30px; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: var(--radius); font-size: var(--fs-s);
}
.order:nth-child(odd) { background: var(--surface-2); }
.o-id { font-family: var(--font-data); font-size: var(--fs-xs); color: var(--muted); }
.o-route { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-route .pu::before, .o-route .dr::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }
.o-route .pu::before { background: var(--pickup); }
.o-route .dr::before { background: var(--dropoff); }
.o-route .arrow { color: var(--muted); padding: 0 4px; }
.o-sla { font-family: var(--font-data); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.o-sla.late { color: var(--bad); font-weight: 700; }
.o-sla.soon { color: var(--warn); font-weight: 700; }
.o-rover { justify-self: end; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.o-rover.on { color: var(--halo); background: var(--c); padding: 0 5px; border-radius: 8px; }
.order.done { opacity: 0.55; }
.order.done .o-sla { color: var(--done); }
.order.new { animation: row-in 0.6s ease-out both; }
@keyframes row-in { from { background: color-mix(in srgb, var(--pickup) 30%, transparent); } }


/* Routing policy */
.seg.wide { display: flex; width: 100%; margin-bottom: 8px; }
.seg.wide .seg-btn { flex: 1; padding: 4px 2px; font-size: var(--fs-xs); white-space: nowrap; }
.weights { display: grid; grid-template-columns: 76px minmax(0, 1fr) 40px; align-items: center; gap: 2px 8px; }
.weights label { font-size: var(--fs-s); }
.weights input { width: 100%; accent-color: var(--accent); margin: 0; }
.weights output { font-family: var(--font-data); font-size: var(--fs-xs); text-align: right; font-variant-numeric: tabular-nums; }
.w-note { margin: 6px 0 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.w-note.busy { color: var(--accent); }

/* Inspector */
.insp-title { display: grid; gap: 1px; margin-bottom: 8px; }
.insp-title b { font-size: var(--fs-l); line-height: 1.25; overflow-wrap: anywhere; }
.insp-title span { font-size: var(--fs-xs); color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(84px, auto) minmax(0, 1fr); gap: 3px 10px; margin: 0; font-size: var(--fs-s); }
.kv dt { color: var(--muted); font-size: var(--fs-xs); padding-top: 1px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv dd.ok { color: var(--done); font-weight: 600; }
.kv dd.bad { color: var(--bad); font-weight: 600; }
.kv dd.warn { color: var(--warn); font-weight: 600; }
.insp-parts { display: grid; gap: 6px; margin-top: 8px; }
.insp-part { padding: 6px 8px; border-radius: var(--radius); background: var(--surface-2); }
.insp-part h3 { font-size: var(--fs-xs); font-weight: 700; margin-bottom: 3px; }
.insp-part .kv { font-size: var(--fs-xs); }
.insp-hint { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.also { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; font-size: var(--fs-xs); color: var(--muted); }
.also .chipbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 1px 8px; font-size: var(--fs-xs); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.also .chipbtn:hover { border-color: var(--accent); }

/* Selected rover telemetry */
.sel-status { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.sel-task { min-width: 0; font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tel-cell { display: grid; gap: 1px; padding: 5px 7px; border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.tel-cell span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.tel-cell b { font: 600 var(--fs-s)/1.3 var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tel-cell.big b { font-size: var(--fs-l); }
.tel-cell.big { box-shadow: inset 3px 0 0 var(--pw, var(--line)); }
.tel-cell.wide { grid-column: span 2; }
.tel-cell b.up { color: var(--up); }
.tel-cell b.down { color: var(--down); }

/* Decision tree */
.tree { position: relative; }
@media (min-width: 900px) {
  .tree { max-height: max(240px, calc(100vh - 560px)); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
}
.tree-lines { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.tl { fill: none; stroke: var(--line-strong); stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 0.5s ease; }
.tl.in { stroke-dashoffset: 0; }
.tl.win { stroke: var(--accent); stroke-width: 2.5; }
.tree-nodes { position: relative; display: grid; gap: 6px; }
.tn { position: relative; min-width: 0; opacity: 0; transform: translateX(-6px); transition: opacity 0.35s ease, transform 0.35s ease, border-color 0.3s, box-shadow 0.3s; }
.tn.in { opacity: 1; transform: none; }
.tn.root { padding: 6px 9px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tn.br { margin-left: 22px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tn.chosen { margin-left: 44px; border-color: var(--c); box-shadow: inset 3px 0 0 var(--c); background: color-mix(in srgb, var(--c) 8%, var(--surface)); }
.tn.base, .tn.closed { border-style: dashed; background: var(--surface-2); }
.tn.base .tn-why, .tn.closed .tn-why { color: var(--bad); font-weight: 600; }
.tn.dup { padding: 3px 8px; }
.tn.dup.in { opacity: 0.7; }
.tn.cand.win { border-color: var(--c); box-shadow: inset 3px 0 0 var(--c); }
.tn.cand.lose.in { opacity: 0.5; }
.tn.now { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent); }
.tn-head { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; min-width: 0; }
.tn-head b { font-size: var(--fs-s); }
.tn-head small { font-size: var(--fs-xs); color: var(--muted); }
.tn-head .sw { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.tn-score { margin-left: auto; font: var(--fs-xs) var(--font-data); color: var(--muted); font-variant-numeric: tabular-nums; }
.tn.win .tn-score { color: var(--ink); font-weight: 700; }
.tn-nums { display: flex; flex-wrap: wrap; gap: 0 9px; margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.tn-nums b { color: var(--ink); font-weight: 600; }
.tn-why { margin: 3px 0 0; font-size: var(--fs-xs); line-height: 1.45; }
.tn.chosen .tn-why { font-size: var(--fs-s); color: var(--ink); }
.tn-calm { margin: 3px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.tn-dom { padding: 0 7px; border-radius: 9px; font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.leaves { list-style: none; margin: 5px 0 0; padding: 0 0 0 10px; border-left: 1.5px solid var(--line-strong); display: grid; gap: 2px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; }
.leaves li { position: relative; }
.leaves li::before { content: ""; position: absolute; left: -10px; top: 0.7em; width: 7px; border-top: 1.5px solid var(--line-strong); }
.leaves li.sev-2 { color: var(--ink); }
.tn .bars { margin-top: 6px; }
.tn .b-fill { transform: scaleX(0); transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s; }
.tn.in .b-fill { transform: scaleX(1); }
.tree.static .tn, .tree.static .tl, .tree.static .b-fill { transition: none !important; }
.ebar { display: flex; align-items: center; gap: 2px; height: 8px; margin-top: 5px; }
.ebar-pos { display: flex; height: 8px; border-radius: 2px; overflow: hidden; min-width: 2px; }
.ebar-neg { height: 8px; min-width: 2px; border-radius: 2px; background: repeating-linear-gradient(135deg, var(--e-regen) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px var(--e-regen); }
.eseg { display: block; height: 100%; min-width: 1px; }
.e-climb { background: var(--e-climb); } .e-rolling { background: var(--e-rolling); } .e-stops { background: var(--e-stops); }
.e-kerbs { background: var(--e-kerbs); } .e-turning { background: var(--e-turning); } .e-hotel { background: var(--e-hotel); }
.e-regen { background: var(--e-regen); }
.tn-dom.e-climb, .tn-dom.e-rolling, .tn-dom.e-stops, .tn-dom.e-kerbs, .tn-dom.e-turning, .tn-dom.e-hotel, .tn-dom.e-regen { background: var(--surface-2); }
.ekey { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: var(--fs-xs); color: var(--muted); }
.tree-key { margin: 4px 0 0 22px; }
.ek { display: inline-flex; align-items: center; gap: 4px; }
.ek .eseg { display: inline-block; width: 10px; height: 7px; border-radius: 1px; }
.ek .eseg.e-regen { background: repeating-linear-gradient(135deg, var(--e-regen) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px var(--e-regen); }
.think { margin-top: 10px; }

/* Bottom route strip */
.strip { flex: none; background: var(--surface); border-top: 1px solid var(--line); }
.strip-head { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; padding-block: 6px; padding-inline: 12px; min-width: 0; }
.strip-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 0; cursor: pointer;
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.strip-toggle::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform 0.2s; }
.strip-toggle[aria-expanded="false"]::before { transform: rotate(-135deg) translateY(-1px); }
.strip-title { font-size: var(--fs-s); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 120px; }
.strip-sum { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.strip-sum b { color: var(--ink); font: 600 var(--fs-s) var(--font-data); }
.strip-body { padding: 0 12px 8px; }
#profile { height: 158px; }
.chart { display: block; width: 100%; border-radius: var(--radius); background: var(--surface-2); }
.strip-key { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; margin-top: 5px; font-size: var(--fs-xs); color: var(--muted); }
.strip-key span { display: inline-flex; align-items: center; gap: 4px; }
.strip-key .sep { width: 1px; height: 10px; background: var(--line); }
.strip.collapsed .strip-body { display: none; }
.info { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--muted); background: none; color: var(--muted); font: 700 11px/1 Georgia, serif; font-style: italic; cursor: help; padding: 0; flex: none; }
.tip {
  position: absolute; right: 12px; bottom: calc(100% - 4px); z-index: 6; width: min(360px, calc(100% - 24px));
  padding: 8px 10px; border-radius: var(--radius); background: var(--ink); color: var(--surface);
  font-size: var(--fs-xs); line-height: 1.45; visibility: hidden; opacity: 0; transition: opacity 0.15s;
}
.info:hover + .tip, .info:focus-visible + .tip { visibility: visible; opacity: 1; }

.reroute { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.reroute-label { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-s); white-space: nowrap; cursor: pointer; }
.check input { margin: 0; accent-color: var(--accent); }
.walk {
  position: absolute; top: 52px; left: 12px; z-index: 3;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  width: min(540px, calc(100% - 70px)); padding: 8px 10px 8px 12px;
  background: color-mix(in srgb, var(--surface) 96%, transparent); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--accent);
  animation: walk-in 0.25s ease-out both;
}
@keyframes walk-in { from { opacity: 0; transform: translateY(-4px); } }
.walk-text { display: grid; gap: 1px; min-width: 0; }
.walk-text b { font-size: var(--fs-m); font-variant-numeric: tabular-nums; }
.walk-text span { font-size: var(--fs-s); line-height: 1.35; color: var(--muted); overflow-wrap: anywhere; }
.walk-btns { display: flex; gap: 6px; grid-row: 1 / 3; grid-column: 2; }
.walk-dots { grid-column: 1; display: flex; gap: 4px; list-style: none; margin: 2px 0 0; padding: 0; }
.walk-dots li { width: 18px; height: 4px; border-radius: 2px; background: var(--line); }
.walk-dots li.done { background: var(--accent); }
.walk-dots li.now { background: linear-gradient(90deg, var(--accent) var(--p, 0%), var(--line) var(--p, 0%)); }
.fleet-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: -2px 0 8px; }
.fleet-actions .btn svg { width: 11px; height: 11px; fill: currentColor; }
.rover-item.spawned .rover-card { animation: card-spawn 0.7s ease-out both; }
.rover-item { position: relative; }
.rover-item .rover-card { padding-right: 30px; }
.rc-remove {
  position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 22px; height: 22px; padding: 0;
  border: 1px solid transparent; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
  opacity: 0; transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.rc-remove svg { width: 10px; height: 10px; fill: currentColor; }
.rover-item:hover .rc-remove, .rover-item:focus-within .rc-remove, .rc-remove:focus-visible { opacity: 1; }
.rc-remove:hover, .rc-remove:focus-visible { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.rc-remove:disabled { display: none; }
@media (hover: none) { .rc-remove { opacity: 1; } }

.events { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.events-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-s); cursor: pointer; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 30px; height: 18px; margin: 0; cursor: pointer; }
.switch .sw-track { position: relative; width: 30px; height: 18px; border-radius: 9px; background: var(--line-strong); transition: background 0.15s ease; flex: none; }
.switch .sw-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: translate 0.15s ease; }
.switch input:checked + .sw-track { background: var(--accent); }
.switch input:checked + .sw-track::after { translate: 12px 0; }
.switch input:focus-visible + .sw-track { outline: 2px solid var(--accent); outline-offset: 2px; }
#events-note { margin-top: 6px; }

.shake-row { display: grid; grid-template-columns: auto minmax(40px, 1fr); align-items: center; gap: 2px 8px; margin-top: 5px; font-size: var(--fs-xs); color: var(--muted); }
.shake-row .s-label b { font-family: var(--font-data); color: var(--ink); font-weight: 600; }
.sbar { display: block; height: 6px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.sbar-fill { display: flex; height: 100%; min-width: 2px; }
.sseg { display: block; height: 100%; min-width: 1px; }
.s-surface { background: var(--s-surface); } .s-kerbs { background: var(--s-kerbs); } .s-turns { background: var(--s-turns); } .s-descents { background: var(--s-descents); }
.shake-row .s-parts { grid-column: 1 / -1; }
#t-sh small { font-weight: 500; color: var(--muted); }
#t-sh small.mj { display: block; overflow: hidden; text-overflow: ellipsis; }
#t-sh[data-level="rough"], #t-sh[data-level="harsh"] { color: var(--bad); }
#t-sh[data-level="high"] { color: var(--warn); }
@keyframes card-spawn { from { background: color-mix(in srgb, var(--c) 30%, var(--surface-2)); } }
.log-filter { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: var(--fs-xs); color: var(--muted); }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px;  }
.log-item {
  display: grid; grid-template-columns: 56px 26px minmax(0, 1fr); gap: 0 8px; align-items: start;
  width: 100%; padding: 5px 6px; border: 1px solid transparent; border-radius: var(--radius);
  background: none; text-align: left; cursor: pointer;
}
.log li:nth-child(odd) .log-item { background: var(--surface-2); }
.log-item:hover { border-color: var(--line); }
.log-item[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.log-time { font-family: var(--font-data); font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.log-rover { display: grid; place-items: center; height: 18px; border-radius: 9px; background: var(--c); color: var(--halo); font-size: var(--fs-xs); font-weight: 700; }
.log-main { min-width: 0; display: grid; gap: 1px; font-size: var(--fs-s); }
.log-line { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.log-trig { min-width: 0; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-win { font-weight: 700; white-space: nowrap; }
.log-delta { flex: none; margin-left: auto; font-family: var(--font-data); font-size: var(--fs-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-delta.up { color: var(--warn); }
.log-delta.down { color: var(--done); }
.log-why { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-item.fail .log-win { color: var(--bad); }
.log-scope { margin: -4px 0 6px; font-size: var(--fs-xs); color: var(--muted); }
.think { margin: 0 0 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--think); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); }
.think.live { border-color: var(--accent); }
.think-head { display: flex; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; }
.think-head .dec-meta { margin-right: auto; }
.think-more { margin-top: 4px; padding: 0; border: 0; background: none; color: var(--accent); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.think-head h3 { font-size: var(--fs-s); font-weight: 700; }
.think-why { margin: 4px 0 0; font-size: var(--fs-s); line-height: 1.45; }
.think-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; counter-reset: none; }
.ts { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 0 8px; padding: 5px 6px 6px; border-radius: 5px; overflow: hidden; }
.ts-n {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font: 700 var(--fs-xs)/1 var(--font-data); background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line);
}
.ts-body { min-width: 0; display: grid; gap: 1px; }
.ts-title { font-size: var(--fs-s); font-weight: 700; }
.ts-title small { font-weight: 500; color: var(--muted); margin-left: 4px; }
.ts-detail { margin: 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.ts.todo { opacity: 0.45; }
.ts.todo .ts-detail, .ts.todo .bars { display: none; }
.ts.done .ts-n { background: var(--sw, var(--accent)); color: var(--halo); box-shadow: none; }
.ts.now { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); }
.ts.now .ts-n { background: var(--sw, var(--accent)); color: var(--halo); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sw, var(--accent)) 30%, transparent); }
.ts.now .ts-detail { color: var(--ink); }
.ts-fill { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--accent); transform-origin: left; animation: ts-fill linear both; }
@keyframes ts-fill { from { transform: scaleX(0); } }
.ts.k-decide .ts-detail { color: var(--ink); font-size: var(--fs-s); font-weight: 600; }
.bars { display: grid; grid-template-columns: 74px minmax(0, 1fr) 40px; gap: 3px 6px; align-items: center; margin-top: 4px; font-size: var(--fs-xs); }
.bars .b-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars .b-track { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bars .b-fill { display: block; height: 100%; border-radius: 4px; background: var(--c); transform-origin: left; }
.think .bars .b-fill { animation: bar-grow 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes bar-grow { from { transform: scaleX(0); } }
.bars .b-val { font-family: var(--font-data); text-align: right; font-variant-numeric: tabular-nums; }
.bars .win { font-weight: 700; }
.cand.focus { border-color: var(--c); box-shadow: inset 3px 0 0 var(--c); opacity: 1; }
.sw.dot.ring { background: var(--dropoff); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c); }
.sw.heading { width: 16px; height: 2px; background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }

/* Responsive */
.check .short { display: none; }
@media (max-width: 1280px) {
  :root { --rail-l: 264px; --rail-r: 330px; }
  .reroute-label { display: none; }
}
@media (max-width: 1080px) {
  :root { --rail-l: 240px; --rail-r: 300px; }
  .brand-sub { display: none; }
  .rover-card { grid-template-columns: 26px 72px 1fr 40px; }
}
@media (min-width: 900px) and (max-height: 760px) {
  .panel { padding-top: 8px; padding-bottom: 8px; }
  #profile { height: 122px; }
}

@media (max-width: 899px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(220px, 1fr) auto minmax(0, 44%);
    grid-template-areas: "map" "tabs" "sheet";
  }
  .center, .rail-right { display: contents; }
  .mapwrap { grid-area: map; min-height: 0; }
  .rail-left, .rail-group, .strip { grid-area: sheet; min-height: 0; overflow-y: auto; border: 0; }
  .rail-left { display: block; }
  .rail-group { background: var(--surface); }
  .strip { border-top: 0; }
  .strip-toggle { pointer-events: none; }
  .strip-toggle::before { display: none; }
  .strip.collapsed .strip-body { display: block; }
  .sheet-tabs {
    grid-area: tabs; display: flex; gap: 2px; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px));
  }
  .sheet-tabs button {
    flex: 1; border: 0; background: none; padding: 9px 4px 7px; cursor: pointer; border-bottom: 2px solid transparent;
    font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  }
  .sheet-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
  body:not([data-tab="fleet"]) .rail-left,
  body:not([data-tab="route"]) .strip,
  body:not([data-tab="rover"]) .rail-group[data-tab="rover"],
  body:not([data-tab="decisions"]) .rail-group[data-tab="decisions"] { display: none; }
  .panel { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .check span { font-size: var(--fs-xs); }
  .walk { width: calc(100% - 64px); }
  .coords { min-width: 0; right: 8px; bottom: 8px; padding: 4px 7px; }
  .coords .c-row:nth-child(3) { display: none; }
  .scale { left: 8px; bottom: 8px; }
  .toast { bottom: 40px; max-width: calc(100% - 24px); }
}
@media (max-width: 560px) {
  .topbar { gap: 6px; }
  .clock-label { display: none; }
  .clock { padding: 4px 8px; }
  .controls { gap: 5px; width: 100%; }
  .check .long { display: none; }
  .check .short { display: inline; }
  .reroute .seg-btn, .seg-btn { padding: 4px 7px; }
  #lowpower { padding: 4px 8px; gap: 4px; }
  #lowpower .dot { display: none; }
  .walk { top: auto; bottom: 44px; padding: 6px 8px 6px 10px; }
  .coords { padding: 3px 6px; gap: 0; }
  .coords .c-row:nth-child(2), .coords .c-row:nth-child(3) { display: none; }
  .mapwrap.walking .coords { display: none; }
  .mapwrap.walking .toast { top: 10px; bottom: auto; max-width: calc(100% - 64px); }
  .tel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition: none !important; }
}

/* 3D map: WebGL canvas under the console canvas, which draws labels and bubbles on top. */
.mapwrap canvas.map3d { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
body[data-dim="3d"] #map { background: transparent; }
.mapwrap .zoom .btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.dim-seg .seg-btn.unavailable { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.m3-load {
  position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); z-index: 3;
  display: grid; grid-template-columns: auto minmax(90px, 160px) auto; align-items: center; gap: 10px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 1px 0 var(--line);
  font-size: var(--fs-s); color: var(--ink); max-width: calc(100% - 24px);
}
.m3-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.m3-bar { position: relative; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.m3-bar span { position: absolute; inset: 0; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform 0.2s ease; }
.m3-pct { font: 600 var(--fs-xs)/1 var(--font-data); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.m3-load.failed { grid-template-columns: 1fr; color: var(--bad); }
.m3-load.failed .m3-bar, .m3-load.failed .m3-pct { display: none; }
.tel.mj .tel-cell.big span::after { content: " MuJoCo"; color: var(--accent); letter-spacing: 0.06em; }
#north svg { transition: transform 0.12s linear; }
@media (max-width: 560px) {
  .m3-load { grid-template-columns: 1fr auto; bottom: 40px; }
  .m3-load .m3-bar { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) {
  .m3-bar span, #north svg { transition: none; }
}
