/* ============================================================
   PSAP Training Simulator — design tokens + components
   Technical / modern dispatch console. Dark by default,
   light theme + accent swaps driven by [data-theme]/[data-accent].
   ============================================================ */

@import url('/static/vendor/fonts/fonts.css');

:root {
  /* dark (default) */
  --bg:        oklch(0.165 0.006 260);
  --bg-grid:   oklch(0.205 0.008 260);
  --panel:     oklch(0.196 0.007 260);
  --panel-2:   oklch(0.232 0.008 260);
  --panel-3:   oklch(0.265 0.009 260);
  --line:      oklch(0.30 0.010 260);
  --line-soft: oklch(0.255 0.009 260);
  --text:      oklch(0.945 0.004 260);
  --text-dim:  oklch(0.74 0.008 260);
  --muted:     oklch(0.60 0.010 260);
  --faint:     oklch(0.46 0.010 260);

  /* status */
  --accent:    oklch(0.79 0.135 70);   /* amber */
  --accent-ink: oklch(0.22 0.05 70);
  --live:      oklch(0.635 0.205 25);  /* red — recording / live */
  --ok:        oklch(0.74 0.14 152);   /* green — passed */
  --warn:      oklch(0.80 0.14 85);    /* partial */
  --info:      oklch(0.70 0.12 235);
  --sel:       oklch(0.74 0.13 245);   /* blue — the selection: a turn, a question, a node. No verdict uses it */

  --shadow: 0 1px 0 oklch(1 0 0 / 0.03) inset, 0 8px 30px oklch(0 0 0 / 0.35);
  --radius: 9px;
  --rail-w: 232px;

  --sans: 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
}

[data-theme='light'] {
  --bg:        oklch(0.965 0.004 260);
  --bg-grid:   oklch(0.925 0.006 260);
  --panel:     oklch(0.995 0.002 260);
  --panel-2:   oklch(0.975 0.004 260);
  --panel-3:   oklch(0.945 0.006 260);
  --line:      oklch(0.875 0.008 260);
  --line-soft: oklch(0.915 0.006 260);
  --text:      oklch(0.235 0.012 260);
  --text-dim:  oklch(0.42 0.012 260);
  --muted:     oklch(0.55 0.012 260);
  --faint:     oklch(0.66 0.010 260);
  --sel:       oklch(0.56 0.17 250);
  --accent-ink: oklch(0.30 0.06 70);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.04), 0 10px 24px oklch(0 0 0 / 0.06);
}

[data-accent='red']   { --accent: oklch(0.635 0.205 25); --accent-ink: oklch(0.98 0.01 25); }
[data-accent='blue']  { --accent: oklch(0.65 0.16 248);  --accent-ink: oklch(0.98 0.01 248); }
[data-accent='green'] { --accent: oklch(0.72 0.15 152);  --accent-ink: oklch(0.20 0.05 152); }

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#root { height: 100%; }

::selection { background: color-mix(in oklch, var(--accent) 35%, transparent); }

/* scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 8px;
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100%;
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0 / 100% 64px,
    var(--bg);
}

/* ---- side rail ---- */
.rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-logo { width: 30px; height: 30px; border-radius: 7px; object-fit: contain; flex: none; }
.brand-text { line-height: 1.1; }
.brand-text b { font-size: 13.5px; letter-spacing: 0.02em; display: block; }
.brand-text span { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.14em; }

.rail-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em;
  color: var(--faint); text-transform: uppercase;
  padding: 14px 10px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 11px; border-radius: 8px;
  color: var(--text-dim); cursor: pointer;
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500;
  transition: background .14s, color .14s, border-color .14s;
  position: relative;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  background: var(--panel-2); color: var(--text);
  border-color: var(--line);
}
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-glyph {
  width: 26px; height: 26px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  background: var(--panel-3); border: 1px solid var(--line-soft);
  color: var(--muted);
}
.nav-item.active .nav-glyph { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 40%, var(--line)); }
.nav-glyph svg { width: 15px; height: 15px; }
.nav-meta { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.nav-sub { font-size: 11px; color: var(--faint); font-weight: 400; }
.nav-item .nav-stack { display: flex; flex-direction: column; gap: 1px; }

.rail-foot { margin-top: auto; padding: 12px 8px 2px; border-top: 1px solid var(--line-soft); }
.rail-stat { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); padding: 4px 2px; }

/* ---- main column ---- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; overflow: hidden; }
.topbar {
  height: 56px; flex: none;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--panel) 55%, transparent);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 16px; padding: 0 22px;
  /* Keep the topbar (and the settings popover it hosts) above the scrolling
     panel content — otherwise the map iframe paints over the popover. */
  position: relative; z-index: 30;
}
.crumb { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; white-space: nowrap; }
.crumb b { color: var(--text); font-weight: 600; }
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.topbar .spacer { flex: 1; }

.scroll { overflow: auto; flex: 1; min-height: 0; }
.pad { padding: 24px; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-h .t { font-size: 13px; font-weight: 600; }
.sec-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  color: var(--muted); text-transform: uppercase;
}

.btn {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 9px 15px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .14s, border-color .14s, transform .06s;
}
.btn:hover { background: var(--panel-3); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.accent:hover { background: color-mix(in oklch, var(--accent) 88%, white); }
.btn.live { background: var(--live); color: white; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.lg { padding: 13px 20px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* The trainer's protocol page: the chart scaled to the column, the page
   scrolls its height (a protocol is a tall top-down chart). */
.protocol-page svg { width: 100% !important; height: auto !important; max-width: 100% !important; display: block; }

/* The dispatch decision: a radio group drawn as choice chips. Real radio
   inputs (one-of-N, arrow keys and screen readers for free), visually the
   buttons of the rest of the console; the checked one keeps its fill, so the
   decision stays visible after it was made. "No dispatch" fills neutral
   rather than accent — it is a decision, not a dispatch. */
fieldset.choice { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 0; min-width: 0; }
fieldset.choice legend { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); padding: 0 6px; }
.choice-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.choice-opt { position: relative; }
.choice-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.choice-opt .btn { user-select: none; }
.choice-opt input:checked + .btn { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.choice-opt.none input:checked + .btn { background: var(--text); color: var(--panel); border-color: transparent; font-weight: 600; }
.choice-opt input:focus-visible + .btn { outline: 2px solid var(--sel); outline-offset: 2px; }
.choice-opt input:disabled + .btn { opacity: .5; cursor: not-allowed; }
.choice-opt input:disabled:not(:checked) + .btn:hover { background: var(--panel-2); border-color: var(--line); }

.badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  padding: 3px 8px; border-radius: 5px; letter-spacing: 0.02em;
  border: 1px solid var(--line); color: var(--text-dim); background: var(--panel-2);
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.badge.ok  { color: var(--ok);  border-color: color-mix(in oklch, var(--ok) 35%, var(--line));  background: color-mix(in oklch, var(--ok) 10%, transparent); }
.badge.warn{ color: var(--warn);border-color: color-mix(in oklch, var(--warn) 35%, var(--line));background: color-mix(in oklch, var(--warn) 10%, transparent); }
.badge.miss{ color: var(--live);border-color: color-mix(in oklch, var(--live) 35%, var(--line));background: color-mix(in oklch, var(--live) 10%, transparent); }
.badge.accent { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 40%, var(--line)); background: color-mix(in oklch, var(--accent) 12%, transparent); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.input, .select {
  font-family: var(--sans); font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 9px 11px; width: 100%; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
[data-theme='light'] .input, [data-theme='light'] .select { background: var(--panel-2); }
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
}
.input.mono { font-family: var(--mono); }

/* code / yaml */
.code {
  font-family: var(--mono); font-size: 12px; line-height: 1.65;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 14px 16px; overflow: auto; white-space: pre; color: var(--text-dim);
  tab-size: 2;
}
.code .k { color: var(--accent); }
.code .s { color: var(--ok); }
.code .n { color: var(--info); }
.code .c { color: var(--faint); font-style: italic; }
.code .d { color: var(--live); }

/* collapsible */
.collapse-h {
  display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
  padding: 13px 16px;
}
.collapse-h .chev { transition: transform .18s; color: var(--muted); display: grid; place-items: center; }
.collapse-h .chev svg { width: 14px; height: 14px; }
.collapse-h.open .chev { transform: rotate(90deg); }
.collapse-body { padding: 0 16px 16px; }

.divider { height: 1px; background: var(--line-soft); }
/* Dispatch-record field grid: 12 tracks. dispatch_form.yaml gives each field
   a fraction width (1/12 … full) which /api/fields serves as a span (w-1 …
   w-12); rows wrap when full, a `new_row` marker (.rb) forces the break
   explicitly. The .rb variants need the full "start / span" form: overriding
   only grid-column-start would drop the span from the shorthand. */
.fgrid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.fgrid .field { grid-column: span 4; min-width: 0; }
/* Bottom-align the controls of a row: neighbors' label/description wrap
   differently, and ragged inputs read worse than ragged descriptions. */
.fgrid .field > :last-child { margin-top: auto; }
/* Dispatch-record labels keep the field name's original casing (the generic
   .field label style uppercases) — long words may still break mid-word
   rather than overflow a narrow 1/12 cell. */
.fgrid .field label { overflow-wrap: anywhere; text-transform: none; letter-spacing: 0.04em; font-size: 10.5px; }
.fgrid .field.w-1 { grid-column: span 1; }
.fgrid .field.w-2 { grid-column: span 2; }
.fgrid .field.w-3 { grid-column: span 3; }
.fgrid .field.w-4 { grid-column: span 4; }
.fgrid .field.w-6 { grid-column: span 6; }
.fgrid .field.w-8 { grid-column: span 8; }
.fgrid .field.w-12 { grid-column: 1 / -1; }
.fgrid .field.rb { grid-column: 1 / span 4; }
.fgrid .field.rb.w-1 { grid-column: 1 / span 1; }
.fgrid .field.rb.w-2 { grid-column: 1 / span 2; }
.fgrid .field.rb.w-3 { grid-column: 1 / span 3; }
.fgrid .field.rb.w-4 { grid-column: 1 / span 4; }
.fgrid .field.rb.w-6 { grid-column: 1 / span 6; }
.fgrid .field.rb.w-8 { grid-column: 1 / span 8; }
.fgrid .field.rb.w-12 { grid-column: 1 / -1; }
@media (max-width: 900px) {
  /* 8 tracks: 1/3 fields become half rows; 1/2 and wider go full row. */
  .fgrid { grid-template-columns: repeat(8, 1fr); }
  .fgrid .field.w-6, .fgrid .field.w-8, .fgrid .field.w-12,
  .fgrid .field.rb.w-6, .fgrid .field.rb.w-8 { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  /* 4 tracks: the smallest fields share a row in pairs, the rest stack. */
  .fgrid { grid-template-columns: repeat(4, 1fr); }
  .fgrid .field.w-3, .fgrid .field.w-4, .fgrid .field.w-6,
  .fgrid .field.w-8, .fgrid .field.w-12,
  .fgrid .field.rb.w-3, .fgrid .field.rb.w-4, .fgrid .field.rb.w-6,
  .fgrid .field.rb.w-8 { grid-column: 1 / -1; }
  .fgrid .field.w-1, .fgrid .field.w-2 { grid-column: span 2; }
  .fgrid .field.rb.w-1, .fgrid .field.rb.w-2 { grid-column: 1 / span 2; }
}
/* "+N more fields" expander under a category's primary fields. */
.fields-toggle {
  margin-top: 12px; padding: 0; border: 0; background: none; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--muted);
}
.fields-toggle:hover { color: var(--accent); }
.row { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ============================================================
   TRAINER
   ============================================================ */
.trainer { display: grid; grid-template-columns: 380px 1fr; gap: 0; height: 100%; min-height: 0; }
.case-col { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.case-toolbar { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 10px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--faint); }
.search .input { padding-left: 33px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 10.5px; padding: 4px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg); transition: all .12s;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--panel-3); color: var(--text); border-color: var(--faint); }

.case-list { overflow: auto; flex: 1; min-height: 0; }
.case-row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px;
  padding: 11px 16px; cursor: pointer; border-bottom: 1px solid var(--line-soft);
  border-left: 2px solid transparent;
}
.case-row:hover { background: var(--panel-2); }
.case-row.sel { background: var(--panel-2); border-left-color: var(--accent); }
.case-id { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.case-row.sel .case-id { color: var(--accent); }
.case-title { font-size: 13px; font-weight: 500; line-height: 1.25; }
.case-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Catalogue chapters. The header sticks while its cases scroll past, so a long
   list never leaves the trainer wondering which chapter they are looking at.
   The count is the plain number of cases in the chapter — while a search is
   running it reads matches/total. */
.case-group-h {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; cursor: pointer; user-select: none;
  background: var(--panel-2); border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.case-group-h:hover { color: var(--text); }
.case-group-h .chev { transition: transform .18s; display: grid; place-items: center; }
.case-group-h .chev svg { width: 13px; height: 13px; }
.case-group-h.open .chev { transform: rotate(90deg); }
.case-group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-group-n {
  margin-left: auto; flex: none; padding: 1px 7px; border-radius: 999px;
  background: var(--panel-3); border: 1px solid var(--line-soft); color: var(--faint);
}
.case-group-empty {
  padding: 10px 16px 10px 37px; font-size: 12px; color: var(--faint);
  border-bottom: 1px solid var(--line-soft);
}

.detail-col { overflow: auto; min-height: 0; padding: 22px; }
.detail-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.detail-head h2 { font-size: 20px; margin: 0 0 7px; letter-spacing: -0.01em; }
.detail-head .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.diff { display: inline-flex; gap: 3px; align-items: center; }
.diff i { width: 6px; height: 12px; border-radius: 2px; background: var(--line); display: inline-block; }
.diff i.on { background: var(--accent); }

/* Run row: one line for everything that changes THIS instance (difficulty,
   seed, regenerate), separated from the case identity above it. The case says
   what is trained; the run row says how it is played. */
.run-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 16px; margin-bottom: 14px; }
.run-bar .sec-label { flex: none; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline label { text-transform: uppercase; }
.field.inline .select { padding-top: 5px; padding-bottom: 5px; }
.run-seed { font-family: var(--mono); font-size: 11px; color: var(--muted); cursor: help; }

.stat-strip {
  display: grid; gap: 1px; background: var(--line-soft); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; margin-bottom: 18px;
  /* Width follows content, not the column count: a dispatch keyword is three
     characters, the course of events is a sentence. */
  /* Every minimum is what the cell's own uppercase label needs (a narrower
     column clipped "STICHWORT"), plus enough for "16 Monate · male" to stay on
     one line. The fractions then hand the remaining width to the two cells that
     hold prose rather than a keyword. */
  grid-template-columns:
    minmax(150px, .6fr) minmax(100px, .5fr) minmax(120px, .95fr) minmax(150px, 2.55fr);
}
.stat-cell { background: var(--panel); padding: 13px 15px; }
.stat-cell .l { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.stat-cell .v { font-size: 14.5px; font-weight: 600; margin-top: 5px; }
/* Keep the strip two or three lines tall whatever the case writes; the full
   text stays available as a tooltip. */
.stat-cell .v.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ============================================================
   TRAINEE
   ============================================================ */
/* Wide enough for the three-per-row dispatch-record grid; the map keeps a
   sane height via .maploc's max-height instead of its square aspect. */
.trainee-grid { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; max-width: 1000px; }
.call-stage {
  border-radius: var(--radius); border: 1px solid var(--line);
  background:
     radial-gradient(120% 90% at 50% 0%, color-mix(in oklch, var(--live) 9%, transparent), transparent 60%),
     var(--panel);
  padding: 24px; overflow: hidden; position: relative;
}
.call-stage.idle { background: var(--panel); }
.live-tag { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--live); font-weight: 600; }
.live-tag .rec { width: 9px; height: 9px; border-radius: 50%; background: var(--live); animation: pulse2 1.3s infinite; }
@keyframes pulse2 { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.call-timer { font-family: var(--mono); font-size: 46px; font-weight: 500; letter-spacing: 0.02em; margin: 14px 0 4px; }

/* start methods */
.start-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.start-card { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 16px; display: flex; flex-direction: column; gap: 11px; }
.start-head { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.start-ico { width: 30px; height: 30px; border-radius: 8px; background: var(--panel-3); border: 1px solid var(--line-soft); display: grid; place-items: center; color: var(--accent); flex: none; }
.start-ico svg { width: 16px; height: 16px; }
.start-desc { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 0; }
.call-stage.live-min { background: radial-gradient(120% 90% at 50% 0%, color-mix(in oklch, var(--live) 10%, transparent), transparent 62%), var(--panel); }
@media (max-width: 720px) { .start-grid { grid-template-columns: 1fr; } }
.maploc { width: 100%; aspect-ratio: 1 / 1; max-height: 440px; border-radius: 8px; border: 1px solid var(--line); position: relative; overflow: hidden; display: block;
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0/100% 22px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0/22px 100%,
    var(--bg);
}
.maploc .ph { position: absolute; left: 12px; bottom: 10px; font-family: var(--mono); font-size: 10px; color: var(--faint); }

/* ============================================================
   ANALYSIS
   ============================================================ */
.analysis-grid { display: grid; grid-template-columns: 1fr 0.95fr; gap: 22px; align-items: start; }

.run-state { display: grid; place-items: center; padding: 70px 24px; text-align: center; }
.scanner { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin-bottom: 22px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Audio echo test (BACKEND-DESIGN §6): live meters and the verdict line. */
.audiotest-meters { display: flex; flex-direction: column; gap: 8px; }
.audiotest-row { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.audiotest-row .mono { text-align: right; font-size: 11.5px; }
.meter { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ok); transition: width 150ms linear; }
.meter.bad > span { background: var(--live); }
.audiotest-verdict { font-size: 13px; color: var(--muted); }
.audiotest-verdict.ok { color: var(--ok); }
.audiotest-verdict.bad { color: var(--live); }
.run-steps { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 18px; display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.run-steps .s { display: flex; align-items: center; gap: 9px; opacity: .4; transition: opacity .3s; }
.run-steps .s.done { opacity: 1; color: var(--text-dim); }
.run-steps .s.act { opacity: 1; color: var(--accent); }
.run-steps .tick { width: 14px; height: 14px; }

.score-ring { display: flex; align-items: center; gap: 18px; }
.ring { width: 76px; height: 76px; flex: none; }
.score-meta .big { font-size: 26px; font-weight: 700; }
.score-meta .lbl { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }

.check-group { padding: 6px 0; }
.check-group .gh { display: flex; align-items: center; gap: 9px; padding: 12px 16px 8px; }
.check-group .gh .sec-label { color: var(--text-dim); }
.check-row { display: grid; grid-template-columns: 22px 1fr auto auto; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--line-soft); }
.check-icon { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; flex: none; }
.check-icon.ok { background: color-mix(in oklch, var(--ok) 18%, transparent); color: var(--ok); }
.check-icon.warn { background: color-mix(in oklch, var(--warn) 18%, transparent); color: var(--warn); }
.check-icon.miss { background: color-mix(in oklch, var(--live) 16%, transparent); color: var(--live); }
/* not_applicable: the protocol did not require this criterion here, so it is
   neither a pass nor a failure and must not read as either. */
.check-icon.na { background: color-mix(in oklch, var(--muted) 14%, transparent); color: var(--muted); }
.badge.na { color: var(--muted); }
.check-icon svg { width: 13px; height: 13px; }
.check-name { font-size: 13px; font-weight: 500; }
.check-name .de { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-left: 7px; }
.check-time { font-family: var(--mono); font-size: 11px; color: var(--faint); }

.transcript { display: flex; flex-direction: column; gap: 2px; padding: 6px; max-height: 520px; overflow: auto; }
/* One selection, three places (runs.jsx / analysis.jsx): the turn in the
   transcript, the question in the result and the node in the chart are marked
   in the same colour — one no verdict uses, so a selected question never reads
   as a failed one. An inset shadow rather than a border, so nothing shifts. */
.run-turn { padding: 7px 8px; border-radius: 8px; margin: 2px -8px; cursor: pointer; }
.run-turn:hover { background: var(--panel-2); }
.run-turn.selected { background: color-mix(in oklch, var(--sel) 12%, transparent); box-shadow: inset 3px 0 0 var(--sel); }
.run-turn.selected .seq { color: var(--sel); }
.result-item { display: flex; gap: 10px; padding: 9px 8px; margin: 0 -8px; border-top: 1px solid var(--line); cursor: pointer; }
.result-item:hover { background: var(--panel-2); }
.result-item.selected { background: color-mix(in oklch, var(--sel) 12%, transparent); box-shadow: inset 3px 0 0 var(--sel); }
.turn { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 9px 12px; border-radius: 7px; }
.turn:hover { background: var(--panel-2); }
.turn .ts { font-family: var(--mono); font-size: 10.5px; color: var(--faint); padding-top: 2px; }
.turn .who { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 3px; }
.turn.disp .who { color: var(--accent); }
.turn.call .who { color: var(--info); }
.turn .tx { font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.turn .tx mark { background: color-mix(in oklch, var(--accent) 22%, transparent); color: var(--text); border-radius: 3px; padding: 0 2px; }

@media (max-width: 1180px) {
  .trainee-grid, .analysis-grid { grid-template-columns: 1fr; }
}

/* ---- address autocomplete (Einsatzstraße) -------------------------------- */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto;
}
.ac-item { padding: 7px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.ac-item.hi { background: var(--panel-3); }
.ac-item .ac-name { font-size: 13px; color: var(--text); }
.ac-item .ac-sub { font-size: 11px; color: var(--muted); }

/* ---- runs table ----------------------------------------------------------- */
/* The run page's right column: the player and the transcript stay in view
   while the result scrolls, because an evidence chip drives both. */
.run-aside { position: sticky; top: 0; max-height: calc(100vh - 96px); overflow-y: auto; }
@media (max-width: 1180px) { .run-aside { position: static; max-height: none; } }

.runs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.runs-table th {
  text-align: left; padding: 10px 14px; font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.runs-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); }
.runs-table tbody tr:hover { background: var(--panel-3); }
.runs-table tbody tr:last-child td { border-bottom: 0; }

/* --- sign-in and settings (BACKEND-DESIGN §9, §10) ------------------------ */

/* The one screen that runs without a signed-in user: centred, no rail, no
   topbar — there is nothing to navigate to yet. */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 360px; padding: 26px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h2 { font-size: 17px; font-weight: 600; }

/* A short outcome line under a form: what was saved, or why it was refused. */
.notice {
  font-size: 12.5px; line-height: 1.45; padding: 9px 12px; border-radius: 7px;
  border: 1px solid var(--line); margin-top: 10px;
}
.notice.bad {
  color: var(--live);
  border-color: color-mix(in oklch, var(--live) 35%, var(--line));
  background: color-mix(in oklch, var(--live) 8%, transparent);
}
.notice.good {
  color: var(--ok);
  border-color: color-mix(in oklch, var(--ok) 35%, var(--line));
  background: color-mix(in oklch, var(--ok) 8%, transparent);
}

/* --- dialogs -------------------------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in oklch, var(--bg) 72%, transparent);
  backdrop-filter: blur(2px);
}
.modal-card {
  width: 100%; padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 18px 48px -12px rgb(0 0 0 / 0.35);
}
/* The one-time password: large, monospaced and selectable in one gesture,
   because it is read out or copied once and never shown again. */
.once-only {
  font-family: var(--mono); font-size: 17px; letter-spacing: 0.02em;
  user-select: all; word-break: break-all;
  padding: 11px 13px; border-radius: 8px;
  border: 1px solid color-mix(in oklch, var(--ok) 35%, var(--line));
  background: color-mix(in oklch, var(--ok) 9%, transparent);
}

/* The protocol flowchart on the run page (analysis.jsx): wide charts scroll
   inside their own box, and a node is a button for its evidence. */
.protocol-chart svg { max-width: none; }
.protocol-chart .node { cursor: pointer; }
/* The selected node keeps its verdict fill and gets the selection outline.
   `!important` because Mermaid writes its classDefs into the SVG as
   `#<render id> .ok>*` rules, which outrank any class selector of ours. */
.protocol-chart .node.selected > * { stroke: var(--sel) !important; stroke-width: 4px !important; }
.protocol-chart .node.selected { filter: drop-shadow(0 0 3px var(--sel)); }
/* The chart box: fixed height, the drawing pans and zooms inside it. */
.chart-viewport { position: relative; height: 70vh; min-height: 560px; overflow: hidden; border-top: 1px solid var(--line-soft); background: var(--panel-2); cursor: grab; user-select: none; }
.chart-viewport.dragging { cursor: grabbing; }
.chart-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; display: inline-block; }
