/* ============================================================
   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: 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); }
/* A date/time box draws its own calendar indicator and picker: told the wrong
   scheme it paints them dark on the dark console. Scoped to these inputs —
   the rest of the app colours everything itself. */
.input[type='datetime-local'], .input[type='date'], .input[type='time'] { color-scheme: dark; }
[data-theme='light'] .input[type='datetime-local'],
[data-theme='light'] .input[type='date'],
[data-theme='light'] .input[type='time'] { color-scheme: light; }
.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); }
/* A text box of more than one line (dispatch_form.yaml: `rows`) — the
   Hinweise block. `rows` sets the height, so no min-height fights it; the
   drag handle is vertical only, because widening it would break the grid
   cell it sits in. */
textarea.input { resize: vertical; line-height: 1.5; }

/* 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); }
/* The dispatch record's own grid — the field cards, the 12 tracks, the
   "+N more fields" expander and the suggestion dropdown — belongs to the
   mask that draws it and lives in masks/standard/mask.css, scoped to
   [data-mask="standard"] like every mask's stylesheet (MASKS-DESIGN §5). */
.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); }
/* A folded chapter holding the case shown on the right. */
.case-group-h.has-sel .case-group-name { color: var(--accent); }
.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); }

/* One position, one map. A callback splits it: left where the caller is,
   right where the person being rung back is (CALLBACKS-DESIGN.md §4). */
.map-split { display: grid; grid-template-columns: 1fr; gap: 14px; }
.map-split.two { grid-template-columns: 1fr 1fr; }
.map-split.two .maploc { aspect-ratio: 4 / 3; }
.map-cap { margin-bottom: 6px; }
@media (max-width: 720px) { .map-split.two { grid-template-columns: 1fr; } }

/* one row of the callback list */
.line-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px 12px; }
.line-name { font-size: 13px; font-weight: 600; }
.line-num { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   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; }
}


/* ---- 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; }

/* The run list's filters: one wrapping row of labelled boxes above it. */
.runs-filters {
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end;
  padding: 12px 14px; margin-bottom: 14px;
}
.runs-filters label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 130px; max-width: 220px; }
.runs-filters label.wide { flex-basis: 200px; max-width: 320px; }
.runs-filters label.narrow { flex: 0 1 90px; }
.runs-filters label.period { flex: 0 0 auto; max-width: none; }
.runs-filters label > span:first-child {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.runs-filters .select, .runs-filters .input { padding-top: 6px; padding-bottom: 6px; }
.runs-filters .input[type='date'] { width: auto; }

/* --- 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);
}

/* --- releases (releases.jsx) ----------------------------------------------
   The dialog is tall — a catalogue and an account list — so it scrolls inside
   the viewport instead of pushing its buttons off-screen. */
.release-dialog { display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 130px); overflow: auto; padding-right: 2px; }
.release-dialog-lead { margin: 0; font-size: 13px; line-height: 1.5; }
.release-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
/* Rows of a picker are labels (the whole row ticks the box), but not the
   field captions `.field label` styles — they read as text, not as headings. */
.field .release-check, .field .release-case {
  font-family: var(--sans); font-size: 13px; letter-spacing: normal; text-transform: none; color: var(--text);
}
.release-check input, .release-case input, .release-chapter input, .release-case-row input,
.release-group-h input,
.release-switch input { accent-color: var(--accent); margin: 0; }
.release-picker { border: 1px solid var(--line); border-radius: 9px; background: var(--bg); overflow: hidden; }
.release-picker-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px; border-bottom: 1px solid var(--line-soft); }
.release-picker-list { max-height: 300px; overflow: auto; position: relative; }
.release-picker-list.short { max-height: 220px; }
.release-group-h {
  position: sticky; top: 0; z-index: 1; padding: 8px 12px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
}
.release-group-h .chev { display: grid; place-items: center; color: var(--muted); transition: transform .18s; }
.release-group-h .chev svg { width: 13px; height: 13px; }
.release-group-h.open .chev { transform: rotate(90deg); }
.release-group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.release-group-n { margin-left: auto; font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--muted); }
.release-group-n.some { color: var(--accent); }
.release-case {
  display: grid; grid-template-columns: 18px 56px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.release-targets .release-case { grid-template-columns: 18px 1fr auto; }
.release-case:hover { background: var(--panel-2); }
.release-case.on { background: color-mix(in oklch, var(--accent) 8%, transparent); }
.release-case .case-title, .release-case .case-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.release-targets { display: flex; flex-direction: column; gap: 10px; }
.release-fixed {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
}
.release-fixed .item {
  font-size: 12px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
/* What saving does, in sentences — the last thing read before the button. */
.release-summary { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; background: var(--panel-2); }
.release-summary p { margin: 6px 0 0; font-size: 13px; line-height: 1.5; }
.release-summary-warn { color: var(--warn); font-weight: 500; }

/* The page: two views, then the case list or the trainees. */
.release-page { display: flex; flex-direction: column; gap: 18px; }
.release-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.release-views { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--bg); }
.release-view {
  font: inherit; font-size: 12.5px; padding: 7px 13px; background: none; border: 0;
  color: var(--muted); cursor: pointer;
}
.release-view + .release-view { border-left: 1px solid var(--line); }
.release-view:hover { color: var(--text); }
.release-view.on { background: var(--panel-3); color: var(--text); font-weight: 600; }
.release-search { width: 280px; max-width: 100%; }
.release-section { display: flex; flex-direction: column; gap: 10px; }
.release-hint { font-size: 12px; color: var(--muted); }
.release-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.release-cases-bar { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; }
.release-person-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; }
.release-person-pick .select { width: auto; min-width: 180px; padding-top: 6px; padding-bottom: 6px; }
.release-selection {
  position: sticky; top: 0; z-index: 3; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; border-color: var(--accent);
  box-shadow: 0 6px 18px -12px color-mix(in oklch, var(--accent) 60%, transparent);
}
.release-selection b { font-size: 13px; font-weight: 600; margin-right: 4px; }

/* By case: the catalogue with its releases. A row is a grid so the columns
   line up across chapters without being a table the switches fight with. */
.release-cases { padding: 0; overflow: hidden; }
.release-chapter {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 12.5px; cursor: pointer;
  background: var(--panel-2); border-bottom: 1px solid var(--line-soft); user-select: none;
}
.release-chapter .chev { display: grid; place-items: center; color: var(--muted); transition: transform .18s; }
.release-chapter .chev svg { width: 13px; height: 13px; }
.release-chapter.open .chev { transform: rotate(90deg); }
.release-case-row {
  display: grid; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer;
  grid-template-columns: 16px 52px minmax(0, 1fr) 190px 120px 52px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.release-case-row:hover { background: var(--panel-2); }
.release-case-row.on { background: color-mix(in oklch, var(--accent) 7%, transparent); }
.release-case-row .chev { display: grid; place-items: center; color: var(--faint); transition: transform .18s; }
.release-case-row .chev svg { width: 12px; height: 12px; }
.release-case-row.open .chev { transform: rotate(90deg); }
/* The case the Trainer's release badge sent someone to: lit up twice as the
   scroll lands, then back to an ordinary row. */
.release-case-row.flash { animation: release-flash 2.2s ease-out .35s both; }
@keyframes release-flash {
  0%, 40% { background: color-mix(in oklch, var(--accent) 22%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
  20%     { background: color-mix(in oklch, var(--accent) 8%, transparent);  box-shadow: inset 3px 0 0 var(--accent); }
  100%    { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .release-case-row.flash { animation: none; background: color-mix(in oklch, var(--accent) 12%, transparent); } }
.release-case-main { min-width: 0; }
.release-case-main .case-title, .release-case-main .case-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.release-ref { color: var(--text-dim); }
.release-case-release { min-width: 0; overflow: hidden; }
.release-case-release .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.release-case-figs { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.release-case-mean { text-align: right; }
.release-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; }
.release-case-detail { background: var(--panel-2); border-bottom: 1px solid var(--line); }
.release-case-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px 10px 44px; border-bottom: 1px solid var(--line-soft); }
.release-case-detail .runs-table th:first-child, .release-case-detail .runs-table td:first-child { padding-left: 44px; }

/* By trainee: a row per person; a click shows the cases as they see them. */
.release-table-wrap { overflow-x: auto; }
.release-table th, .release-table td { white-space: nowrap; }
.release-table .num { text-align: right; }
.release-table td.right { text-align: right; }
.release-person-row { cursor: pointer; }
.release-people .chev-col { width: 1%; padding-right: 0; }
.release-people .chev { display: grid; place-items: center; color: var(--muted); transition: transform .18s; }
.release-people .chev svg { width: 13px; height: 13px; }
.release-person-row.open .chev { transform: rotate(90deg); }
.release-person-row.open td { background: var(--panel-2); }
.release-people tbody tr.release-person-detail:hover { background: none; }
.release-person-detail > td { padding: 0; background: var(--panel-2); white-space: normal; }
/* One trainee opened: their figures, then their released cases a row each. */
.release-person { padding: 4px 16px 14px 40px; display: flex; flex-direction: column; gap: 10px; }
.release-person-figures { display: flex; gap: 10px 28px; align-items: center; flex-wrap: wrap; padding-top: 8px; }
.release-person-figures > div { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.release-person-figures .l {
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.release-person-figures .release-person-actions { flex-direction: row; gap: 8px; margin-left: auto; }
.release-person-cases { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.release-person-cases tr.off td { opacity: .55; }
.release-person-case { display: flex; gap: 10px; align-items: baseline; max-width: 520px; }
.release-person-case .release-ref { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.release-person-case .case-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.release-mini-bar {
  display: inline-block; width: 56px; height: 5px; border-radius: 3px; margin-right: 8px;
  vertical-align: middle; background: var(--panel-3); overflow: hidden;
}
.release-mini-bar i { display: block; height: 100%; background: var(--ok); }

/* On the case setup: to whom the case is released, and a mark in the list. */
.case-mark { display: grid; place-items: center; color: var(--faint); }
.case-mark svg { width: 13px; height: 13px; }
/* Released or not, on the case in the Trainer — a click opens it on the
   release page. */
.release-state { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.release-state:not(.ok) { border-style: dashed; }
.release-state > svg:last-child { opacity: .45; margin-right: -3px; transition: opacity .12s, transform .12s; }
.release-state:hover { border-color: var(--accent); color: var(--text); }
.release-state.ok:hover { color: var(--ok); }
.release-state:hover > svg:last-child { opacity: 1; transform: translateX(1px); }

@media (max-width: 900px) {
  .release-case-row { grid-template-columns: 16px minmax(0, 1fr) auto auto 14px; }
  .release-case-row .case-id, .release-case-row .release-case-figs { display: none; }
}

/* --- my practice (practice.jsx) --------------------------------------------
   The trainee's starting page, the whole width: a table per release — a row
   per category that opens into its cases, a column per level — and a ▶ at
   the end of every row that starts what the row says. */
.practice { display: flex; flex-direction: column; gap: 14px; }
.practice-intro { margin: 0; font-size: 13px; line-height: 1.5; }
.practice-figures { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 0; }
.practice-card { overflow: hidden; }
.practice-card .card-h { gap: 12px; }
.practice-free { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.practice-scroll { overflow-x: auto; }
.practice-table th, .practice-table td { white-space: nowrap; }
.practice-table th.num, .practice-table td.num { text-align: right; }
.practice-table tbody tr.todo td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.practice-table .play-col { width: 1%; text-align: right; }
/* A category: its own figures, and the switch for its cases. */
.chapter-row { cursor: pointer; user-select: none; }
.chapter-row td { background: var(--panel-2); }
.practice-table tbody tr.chapter-row:hover td { background: var(--panel-3); }
.chapter-row .chev { display: inline-grid; place-items: center; width: 16px; margin-right: 6px; color: var(--muted); transition: transform .18s; vertical-align: -2px; }
.chapter-row .chev svg { width: 13px; height: 13px; }
.chapter-row.open .chev { transform: rotate(90deg); }
.case-row-p td:first-child { padding-left: 38px; }
.case-num { color: var(--text-dim); }
.case-num b { font-family: var(--mono); color: var(--text); margin-left: 2px; }
/* A level: how often, how well, and the ▶ for exactly that. */
.lvl-cell { border-left: 1px solid var(--line-soft); }
/* …and the column after the last level, where the level is drawn. */
.lvl-cell + .play-col { border-left: 1px solid var(--line-soft); padding-left: 18px; }
.practice-table th.lvl-cell { cursor: help; }
.lvl-head { border-bottom: 1px dotted var(--faint); }
.lvl-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 132px; }
.lvl-fig { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; }
/* Quiet until the row is looked at: a table of cases would otherwise be a
   wall of red circles. The big ones — a release's, an open task's — are the
   page's main actions and stay in the accent colour. */
.play-btn {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border-radius: 50%; cursor: pointer; color: var(--muted);
  border: 1px solid var(--line); background: var(--panel);
  transition: background .12s, color .12s, border-color .12s, transform .06s;
}
.practice-table tr:hover .play-btn:not(:disabled), .play-btn.big {
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.play-btn svg { width: 13px; height: 13px; margin-left: 2px; }
.play-btn:hover:not(:disabled), .practice-table tr:hover .play-btn:hover:not(:disabled) {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.play-btn:active:not(:disabled) { transform: scale(.94); }
.play-btn:disabled { opacity: .3; cursor: not-allowed; }
.play-btn.big { width: 34px; height: 34px; }
.play-btn.big svg { width: 15px; height: 15px; }
.practice-legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 11.5px; }
.practice-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.practice-legend i.ok { background: var(--ok); }
.practice-legend i.warn { background: var(--warn); }
.practice-legend i.miss { background: var(--live); }

/* The Disponent panel's one line about it: what is prepared, and the way
   back to choose another (trainee.jsx). */
.desk-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 18px; max-width: 1000px; }
.desk-bar-ico { display: grid; place-items: center; color: var(--accent); }
.desk-bar-ico svg { width: 16px; height: 16px; }
.desk-bar-text { flex: 1; min-width: 0; font-size: 13px; }

/* 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; }

/* The line under the panel's map when it carries no marker (trainee.jsx).
   Says whether the position is still to come with the call or whether this
   case has none — not an error, and not a reason to hide the area. */
.map-note { padding: 6px 2px 0; color: var(--muted); font-size: 12px; }
