/* codriver — ALL-127 feedback prototype.
   Tokens lifted from public/styles/tokens.css (Concrete & Cobalt) so the
   dialog reads as the shipping app, not as a demo page. */

:root {
  --cd-font-ui: 'Geist', system-ui, -apple-system, sans-serif;
  --cd-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --cd-bg: #0E1218;
  --cd-bg-alt: #161B23;
  --cd-surface: #181E27;
  --cd-surface-2: #222A36;
  --cd-surface-3: #2C3543;
  --cd-text: #F2F4F7;
  --cd-text-dim: rgba(242,244,247,0.62);
  --cd-text-mute: rgba(242,244,247,0.38);
  --cd-line: rgba(255,255,255,0.07);
  --cd-line-strong: rgba(255,255,255,0.14);
  --cd-accent: #3D8BFF;
  --cd-accent-hov: #5FA0FF;
  --cd-accent-soft: rgba(61,139,255,0.16);
  --cd-glass: rgba(14,18,24,0.90);
  --cd-ok: #3DAD6E;
  --cd-warn: #FF8C00;
  --cd-danger: #FF4B3E;
  --cd-ease: cubic-bezier(.4,0,.2,1);
  color-scheme: dark;
}

* , *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--cd-bg); color: var(--cd-text);
  font-family: var(--cd-font-ui); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4,p { margin: 0; }
a { color: var(--cd-accent); }

/* ── prototype chrome (never ships) ─────────────────────────────────────── */
.pbar {
  height: 52px; display: flex; align-items: center; gap: 18px;
  padding: 0 16px; background: var(--cd-bg-alt);
  border-bottom: 1px solid var(--cd-line-strong); position: relative; z-index: 40;
}
.pbar__brand { display: flex; align-items: baseline; gap: 10px; font-weight: 600; letter-spacing: -0.02em; }
.pbar__brand span { color: var(--cd-text-mute); font-weight: 400; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.pbar__tabs { display: flex; gap: 2px; margin-left: auto; }
.ptab {
  appearance: none; background: transparent; border: 1px solid transparent;
  padding: 7px 14px; cursor: pointer; color: var(--cd-text-dim); font-size: 13px;
}
.ptab[aria-selected="true"] { color: var(--cd-text); border-color: var(--cd-line-strong); background: var(--cd-surface); }
.pbar__right { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--cd-text-mute); }
.pbar select {
  background: var(--cd-surface); border: 1px solid var(--cd-line-strong);
  padding: 6px 8px; font-size: 12px;
}

main { position: absolute; inset: 52px 0 0 0; }
.view { position: absolute; inset: 0; display: none; }
.view.is-active { display: block; }
.view--doc { overflow-y: auto; }

/* ── the car view ───────────────────────────────────────────────────────── */
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }

.plate {
  position: absolute; background: var(--cd-glass); border: 1px solid var(--cd-line-strong);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.plate::before, .plate::after,
.plate .bk-bl, .plate .bk-br { content: ''; position: absolute; width: 5px; height: 5px; pointer-events: none; }
.plate::before { top: 0; left: 0; border-top: 1px solid var(--cd-text-mute); border-left: 1px solid var(--cd-text-mute); }
.plate::after { top: 0; right: 0; border-top: 1px solid var(--cd-text-mute); border-right: 1px solid var(--cd-text-mute); }
.plate .bk-bl { bottom: 0; left: 0; border-bottom: 1px solid var(--cd-text-mute); border-left: 1px solid var(--cd-text-mute); }
.plate .bk-br { bottom: 0; right: 0; border-bottom: 1px solid var(--cd-text-mute); border-right: 1px solid var(--cd-text-mute); }

.maneuver { top: 20px; left: 20px; padding: 12px 16px; min-width: 260px; }
.maneuver__d { color: var(--cd-accent); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.maneuver__t { color: var(--cd-text-dim); font-size: 14px; }
.speed { left: 20px; bottom: 20px; padding: 8px 16px; display: flex; align-items: baseline; gap: 6px; }
.speed b { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.speed span { color: var(--cd-text-mute); font-size: 12px; }
.eta { left: 168px; bottom: 20px; padding: 8px 16px; }
.eta b { font-size: 17px; font-weight: 600; }
.eta div { color: var(--cd-text-mute); font-size: 12px; }
.rail { position: absolute; right: 20px; top: 20px; display: flex; flex-direction: column; gap: 10px; }
.hud-btn {
  appearance: none; width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--cd-glass); color: var(--cd-text); border: 1px solid var(--cd-line-strong);
  cursor: pointer; position: relative; backdrop-filter: blur(10px);
  transition: background 120ms var(--cd-ease), border-color 120ms var(--cd-ease), color 120ms var(--cd-ease);
}
.hud-btn:hover { background: var(--cd-surface-2); }
.hud-btn:active { transform: translateY(1px); }
.hud-btn--wide { width: auto; gap: 10px; padding: 0 16px; font-size: 14px; font-weight: 600; }
.hud-btn.is-accent { color: var(--cd-accent); border-color: var(--cd-accent); }
.report-strip { position: absolute; right: 20px; bottom: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 22px;
  color: var(--cd-text-mute); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
}

/* ── feedback dialog ────────────────────────────────────────────────────── */
.fb-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(6,9,13,0.66);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(3px);
}
.fb-overlay[hidden] { display: none; }
.fb-sheet {
  width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column;
  background: var(--cd-surface); border: 1px solid var(--cd-line-strong);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6); position: relative;
}
.fb-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--cd-line); }
.fb-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.fb-sub { color: var(--cd-text-mute); font-size: 12px; }
.fb-close {
  margin-left: auto; appearance: none; background: transparent; border: 1px solid var(--cd-line-strong);
  width: 36px; height: 36px; cursor: pointer; color: var(--cd-text-dim);
}
.fb-close:hover { color: var(--cd-text); background: var(--cd-surface-2); }
.fb-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mic {
  position: relative; width: 148px; height: 148px; appearance: none; cursor: pointer;
  background: var(--cd-surface-2); border: 1px solid var(--cd-line-strong); color: var(--cd-text);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 120ms var(--cd-ease), background 120ms var(--cd-ease);
}
.mic::before, .mic::after { content: ''; position: absolute; width: 8px; height: 8px; }
.mic::before { top: 0; left: 0; border-top: 1px solid var(--cd-text-mute); border-left: 1px solid var(--cd-text-mute); }
.mic::after { bottom: 0; right: 0; border-bottom: 1px solid var(--cd-text-mute); border-right: 1px solid var(--cd-text-mute); }
.mic.is-live { border-color: var(--cd-accent); color: var(--cd-accent); background: var(--cd-accent-soft); }
.mic.is-disabled { opacity: 0.4; cursor: not-allowed; }
.mic__level {
  position: absolute; inset: -1px; border: 2px solid var(--cd-accent);
  opacity: 0; transform: scale(1); pointer-events: none;
}
.mic svg { width: 56px; height: 56px; }
.mic__label { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.mic__state { font-size: 12px; color: var(--cd-text-mute); text-align: center; min-height: 32px; max-width: 380px; }
.path-badge {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--cd-font-mono);
  font-size: 11px; letter-spacing: 0.04em; padding: 3px 8px; border: 1px solid var(--cd-line-strong);
  color: var(--cd-text-dim);
}
.path-badge.is-live { color: var(--cd-ok); border-color: rgba(61,173,110,0.5); }
.path-badge.is-upload { color: var(--cd-warn); border-color: rgba(255,140,0,0.5); }
.path-badge.is-text { color: var(--cd-text-mute); }

.transcript {
  min-height: 92px; width: 100%; background: var(--cd-bg-alt); border: 1px solid var(--cd-line);
  padding: 12px 14px; font-size: 15px; line-height: 1.55; resize: vertical;
  font-family: inherit;
}
.transcript:focus { outline: 2px solid var(--cd-accent); outline-offset: -1px; }
.transcript .interim { color: var(--cd-text-mute); }
.transcript-live { min-height: 92px; }
.transcript-live:empty::before { content: attr(data-placeholder); color: var(--cd-text-mute); }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cd-text-mute); }
.chip {
  appearance: none; background: var(--cd-surface-2); border: 1px solid var(--cd-line-strong);
  color: var(--cd-text-dim); padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--cd-accent); color: var(--cd-accent); background: var(--cd-accent-soft); }
.linkish {
  appearance: none; background: none; border: 0; padding: 0; color: var(--cd-accent);
  font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

.attach { border: 1px solid var(--cd-line); background: var(--cd-bg-alt); }
.attach__head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.attach__body { padding: 0 12px 12px; display: flex; gap: 12px; }
.shot {
  width: 190px; flex: 0 0 auto; border: 1px solid var(--cd-line-strong); background: #000;
  aspect-ratio: 16 / 10; object-fit: cover; display: block;
}
.attach__facts { font-size: 12px; color: var(--cd-text-dim); display: grid; gap: 4px; align-content: start; }
.attach__facts code { font-family: var(--cd-font-mono); font-size: 11px; color: var(--cd-text-mute); }
.seg { display: inline-flex; border: 1px solid var(--cd-line-strong); }
.seg button {
  appearance: none; background: transparent; border: 0; padding: 6px 12px; font-size: 12px;
  color: var(--cd-text-dim); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--cd-line-strong); }
.seg button[aria-pressed="true"] { background: var(--cd-accent-soft); color: var(--cd-accent); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cd-text-dim); cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--cd-accent); }

details.review { border: 1px solid var(--cd-line); background: var(--cd-bg-alt); }
details.review > summary { cursor: pointer; padding: 10px 12px; font-size: 13px; color: var(--cd-text-dim); list-style: none; }
details.review > summary::-webkit-details-marker { display: none; }
details.review > summary::before { content: '▸ '; color: var(--cd-text-mute); }
details.review[open] > summary::before { content: '▾ '; }
pre.json {
  margin: 0; padding: 12px; max-height: 260px; overflow: auto; background: #0b0f14;
  border-top: 1px solid var(--cd-line); font-family: var(--cd-font-mono); font-size: 11px;
  line-height: 1.55; color: var(--cd-text-dim); white-space: pre-wrap; word-break: break-word;
}
.fb-foot {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-top: 1px solid var(--cd-line); background: var(--cd-bg-alt);
}
.fb-foot .meta { font-size: 12px; color: var(--cd-text-mute); font-family: var(--cd-font-mono); }
.btn {
  appearance: none; background: var(--cd-surface-2); border: 1px solid var(--cd-line-strong);
  color: var(--cd-text); padding: 12px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 120ms var(--cd-ease);
}
.btn:hover { background: var(--cd-surface-3); }
.btn--primary { background: var(--cd-accent); border-color: var(--cd-accent); color: #06121f; margin-left: auto; }
.btn--primary:hover { background: var(--cd-accent-hov); }
.btn--primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--sm { padding: 8px 14px; font-size: 13px; font-weight: 500; }

.sent { padding: 32px 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.sent h3 { font-size: 19px; font-weight: 600; }
.sent p { color: var(--cd-text-dim); font-size: 14px; max-width: 380px; }
.sent code { font-family: var(--cd-font-mono); font-size: 12px; color: var(--cd-accent); }

/* ── lab ────────────────────────────────────────────────────────────────── */
.lab { position: absolute; inset: 0; overflow-y: auto; padding: 24px; }
.lab__grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); max-width: 1360px; margin: 0 auto; }
.card { border: 1px solid var(--cd-line-strong); background: var(--cd-surface); }
.card__head { padding: 14px 16px; border-bottom: 1px solid var(--cd-line); display: flex; align-items: center; gap: 10px; }
.card__head h3 { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.card__head .btn { margin-left: auto; }
.card__body { padding: 14px 16px; font-size: 13px; color: var(--cd-text-dim); display: grid; gap: 10px; }
.card__note { color: var(--cd-text-mute); font-size: 12px; line-height: 1.5; }
table.kv { width: 100%; border-collapse: collapse; font-size: 12px; }
table.kv td { padding: 5px 0; border-bottom: 1px solid var(--cd-line); vertical-align: top; }
table.kv td:first-child { color: var(--cd-text-mute); width: 45%; }
table.kv td:last-child { font-family: var(--cd-font-mono); color: var(--cd-text); word-break: break-word; }
.ok { color: var(--cd-ok); }
.warn { color: var(--cd-warn); }
.bad { color: var(--cd-danger); }
.muted { color: var(--cd-text-mute); }
.big { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--cd-text); font-family: var(--cd-font-mono); }

/* ── findings doc ───────────────────────────────────────────────────────── */
.doc { max-width: 820px; margin: 0 auto; padding: 40px 24px 96px; }
.doc h2 { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--cd-text-mute); margin: 40px 0 14px; }
.doc h2:first-child { margin-top: 0; }
.doc h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 24px 0 8px; }
.doc p, .doc li { color: var(--cd-text-dim); font-size: 15px; line-height: 1.65; }
.doc p { margin: 10px 0; }
.doc ul, .doc ol { margin: 10px 0; padding-left: 20px; }
.doc li { margin: 6px 0; }
.doc strong { color: var(--cd-text); font-weight: 600; }
.doc code { font-family: var(--cd-font-mono); font-size: 12.5px; color: var(--cd-accent); background: var(--cd-accent-soft); padding: 1px 5px; }
.doc .lede { font-size: 17px; color: var(--cd-text); line-height: 1.6; }
.callout { border-left: 2px solid var(--cd-accent); background: var(--cd-surface); padding: 14px 18px; margin: 18px 0; }
.callout p { margin: 0; }
.callout--warn { border-left-color: var(--cd-warn); }
.doc table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13.5px; }
.doc th, .doc td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--cd-line); vertical-align: top; }
.doc th { color: var(--cd-text-mute); font-weight: 500; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.doc td { color: var(--cd-text-dim); }
.doc td:first-child { color: var(--cd-text); }
.rule { height: 1px; background: var(--cd-line-strong); margin: 32px 0; }

@media (max-width: 720px) {
  .pbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  main { top: 96px; }
  .fb-overlay { padding: 0; }
  .fb-sheet { width: 100%; height: 100%; max-height: none; }
  .eta { display: none; }
}

/* Download progress. The on-device install exposes no byte count on most
   builds, so the bar is indeterminate by default and only becomes a real
   percentage if a downloadprogress event actually arrives. Never fake a
   percentage — a bar that invents progress is worse than one that admits
   it is only telling you the thing is alive. */
.dlbar {
  height: 6px; background: var(--cd-surface-3); border: 1px solid var(--cd-line);
  position: relative; overflow: hidden;
}
.dlbar__fill { height: 100%; width: 0; background: var(--cd-accent); transition: width 200ms var(--cd-ease); }
.dlbar.is-indeterminate .dlbar__fill {
  width: 34%; animation: dlslide 1.4s var(--cd-ease) infinite;
}
@keyframes dlslide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(330%); }
}
.dlbar.is-done .dlbar__fill { width: 100%; background: var(--cd-ok); }
.dlbar.is-failed .dlbar__fill { width: 100%; background: var(--cd-danger); }

/* Build stamp. Every screenshot from a car should say which build it came
   from — otherwise a stale tab silently reports yesterday's behaviour as
   today's finding, which already happened once. */
.pbar__build {
  font-family: var(--cd-font-mono); font-size: 10px; color: var(--cd-text-mute);
  border: 1px solid var(--cd-line); padding: 1px 5px; letter-spacing: 0.02em;
}
.pbar__reload {
  appearance: none; background: var(--cd-accent-soft); border: 1px solid var(--cd-accent);
  color: var(--cd-accent); font-size: 12px; padding: 5px 10px; cursor: pointer;
}
.pbar__reload:hover { background: var(--cd-accent); color: #06121f; }
