/* ─────────────────────────────────────────────────────────────────────────
   AI Concierge — operations console
   Direction: tech-utility (Datadog / GitHub). Tokens are the only place
   colour is declared. Everything else references a var().
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* base six — from the tech-utility direction, verbatim */
  --bg:      oklch(98% 0.005 250);
  --surface: oklch(100% 0 0);
  --fg:      oklch(22% 0.02 240);
  --muted:   oklch(50% 0.018 240);
  --border:  oklch(90% 0.008 240);
  --accent:  oklch(58% 0.16 145);

  --font-display: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  /* derived */
  --accent-soft: color-mix(in oklch, var(--accent) 14%, transparent);
  --accent-text: oklch(44% 0.12 148);
  --fg-soft:     color-mix(in oklch, var(--fg) 5%, transparent);
  --sunken:      oklch(96.5% 0.006 250);

  /* operational status — functional, not decorative */
  --ok:        oklch(58% 0.16 145);
  --ok-text:   oklch(44% 0.12 148);
  --warn:      oklch(52% 0.13 72);
  --warn-fill: oklch(72% 0.15 75);
  --danger:    oklch(52% 0.20 27);
  --info:      oklch(50% 0.13 255);

  /* route identity — consistent across queue, flow map, ticket, analytics */
  --r-appointment: oklch(52% 0.14 255);
  --r-medication:  oklch(52% 0.15 310);
  --r-financial:   oklch(48% 0.10 195);
  --r-other:       oklch(50% 0.02 250);
  --route: var(--r-other);

  /* scale */
  --fs-meta: 12px;
  --fs-body: 14px;
  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 40px;
  --rail: 236px;
  --radius: 8px;
  --radius-lg: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; font-family: var(--font-display); }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ─── type helpers ─────────────────────────────────────────────────────── */
.h-page  { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.h-sec   { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.h-card  { font-size: 14px; font-weight: 600; }
.meta    { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); letter-spacing: -0.01em; }
.num     { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.dim     { color: var(--muted); }
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ─── app shell ────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rail-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; border-bottom: 1px solid var(--border);
}
.rail-mark {
  width: 26px; height: 26px; flex: none; border-radius: 7px;
  background: var(--fg); color: var(--surface);
  display: grid; place-items: center;
}
.rail-mark svg { width: 15px; height: 15px; }
.rail-brand b { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; display: block; }
.rail-brand span { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; }

.nav-group { padding: 14px 10px 4px; }
.nav-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); padding: 0 8px 7px;
}
.nav-a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 6px; font-size: 13.5px; color: var(--fg);
  transition: background 0.12s ease;
}
.nav-a svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.nav-a:hover { background: var(--fg-soft); }
.nav-a:hover svg { color: var(--fg); }
.nav-a.is-active { background: var(--fg); color: var(--surface); font-weight: 500; }
.nav-a.is-active svg { color: var(--surface); }
.nav-a .count {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  font-variant-numeric: tabular-nums; color: var(--muted);
}
.nav-a.is-active .count { color: var(--surface); opacity: 0.75; }
.nav-a .count.is-alert { color: var(--danger); font-weight: 600; }
.nav-a.is-active .count.is-alert { color: var(--surface); opacity: 1; }

.rail-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: 9px; padding: 4px 6px; }
.who-av {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--sunken); border: 1px solid var(--border);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--fg);
}
.who b { display: block; font-size: 13px; font-weight: 500; }
.who span { display: block; font-size: 11.5px; color: var(--muted); }

/* ─── work area ────────────────────────────────────────────────────────── */
.work { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--gap-md);
  padding: 13px var(--gap-lg);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--gap-sm); }
.page { padding: var(--gap-lg); display: flex; flex-direction: column; gap: var(--gap-lg); }
.page-narrow { max-width: 1240px; }

.demo-note {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 999px; padding: 3px 9px;
}

/* live clock / pulse */
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none;
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ─── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; min-height: 36px;
  border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; color: var(--fg); background: transparent;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: oklch(100% 0 0); border-color: color-mix(in oklch, var(--accent) 80%, black); }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 86%, black); border-color: color-mix(in oklch, var(--accent) 66%, black); }
.btn-solid { background: var(--fg); color: var(--surface); border-color: var(--fg); }
.btn-solid:hover { background: color-mix(in oklch, var(--fg) 86%, var(--surface)); border-color: color-mix(in oklch, var(--fg) 86%, var(--surface)); }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { background: var(--sunken); border-color: color-mix(in oklch, var(--fg) 30%, var(--border)); }
.btn-ghost { padding-inline: 9px; }
.btn-ghost:hover { background: var(--fg-soft); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in oklch, var(--danger) 34%, var(--border)); }
.btn-danger:hover { background: color-mix(in oklch, var(--danger) 8%, var(--surface)); border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--gap-sm); }

/* ─── surfaces ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.card-pad { padding: var(--gap-md) var(--gap-lg) var(--gap-lg); }
.card-head {
  display: flex; align-items: center; gap: var(--gap-sm);
  padding: 13px var(--gap-lg); border-bottom: 1px solid var(--border);
}
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: var(--gap-lg); }
.card-body-tight { padding: var(--gap-md) var(--gap-lg); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--gap-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--gap-md); }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: var(--gap-md); }
.grid-main { display: grid; grid-template-columns: minmax(0,1fr) 344px; gap: var(--gap-lg); align-items: start; }
.grid-side { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: var(--gap-lg); align-items: start; }
.stack { display: flex; flex-direction: column; gap: var(--gap-md); }
.stack-sm { display: flex; flex-direction: column; gap: var(--gap-sm); }
.row { display: flex; align-items: center; gap: var(--gap-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-md); }
.wrap { flex-wrap: wrap; }
.rule { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ─── KPI tiles ────────────────────────────────────────────────────────── */
.kpi { padding: 14px 16px 15px; display: flex; flex-direction: column; gap: 3px; }
.kpi .kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi .kpi-val { font-family: var(--font-mono); font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; line-height: 1.1; }
.kpi .kpi-sub { font-size: 11.5px; color: var(--muted); }
.kpi.is-danger { border-color: color-mix(in oklch, var(--danger) 40%, var(--border)); }
.kpi.is-danger .kpi-val { color: var(--danger); }
.kpi.is-warn { border-color: color-mix(in oklch, var(--warn) 40%, var(--border)); }
.kpi.is-warn .kpi-val { color: var(--warn); }

/* ─── pills / chips ────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 5px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.05em;
  text-transform: uppercase; white-space: nowrap;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface);
}
.pill-ok     { color: var(--ok-text);  border-color: color-mix(in oklch, var(--ok) 32%, var(--border));     background: color-mix(in oklch, var(--ok) 8%, var(--surface)); }
.pill-warn   { color: var(--warn);     border-color: color-mix(in oklch, var(--warn) 34%, var(--border));   background: color-mix(in oklch, var(--warn) 9%, var(--surface)); }
.pill-danger { color: var(--danger);   border-color: color-mix(in oklch, var(--danger) 36%, var(--border)); background: color-mix(in oklch, var(--danger) 8%, var(--surface)); }
.pill-info   { color: var(--info);     border-color: color-mix(in oklch, var(--info) 30%, var(--border));   background: color-mix(in oklch, var(--info) 8%, var(--surface)); }
.pill-solid  { color: var(--surface);  background: var(--fg); border-color: var(--fg); }

.route-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--fg); white-space: nowrap;
}
.route-chip::before {
  content: ''; width: 8px; height: 8px; border-radius: 2px;
  background: var(--route); flex: none;
}
.r-appointment { --route: var(--r-appointment); }
.r-medication  { --route: var(--r-medication); }
.r-financial   { --route: var(--r-financial); }
.r-other       { --route: var(--r-other); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 12px; color: var(--muted); background: var(--surface);
}
.kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 1px 5px;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  background: var(--sunken); color: var(--muted);
}

/* ─── call cards ───────────────────────────────────────────────────────── */
.call-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  border-left: 3px solid var(--route);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.call-card:hover { box-shadow: 0 1px 3px color-mix(in oklch, var(--fg) 10%, transparent); }
.call-card .row-between { flex-wrap: wrap; row-gap: 4px; }
.call-card.is-risk { border-color: color-mix(in oklch, var(--warn) 45%, var(--border)); border-left-color: var(--route); }
.call-card.is-fail { border-color: color-mix(in oklch, var(--danger) 45%, var(--border)); border-left-color: var(--route); }
.call-id { font-family: var(--font-mono); font-size: 12px; letter-spacing: -0.02em; }
.call-timer { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.snippet {
  font-size: 12.5px; color: var(--muted); background: var(--sunken);
  border-radius: 6px; padding: 7px 9px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.snippet b { color: var(--fg); font-weight: 500; }

/* stage track — 8 dots */
.track { display: flex; align-items: center; gap: 3px; }
.track i {
  height: 4px; flex: 1; border-radius: 2px; background: var(--border); display: block;
}
.track i.done { background: color-mix(in oklch, var(--ok) 55%, var(--border)); }
.track i.now  { background: var(--fg); }
.track i.fail { background: var(--danger); }
.track i.risk { background: var(--warn-fill); }

/* ─── tables ───────────────────────────────────────────────────────────── */
.ds-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ds-table th, .ds-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ds-table thead th {
  color: var(--muted); font-weight: 500; font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase;
  background: var(--sunken); border-bottom-color: var(--border); position: sticky; top: 0;
}
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table tbody tr.clickable { cursor: pointer; }
.ds-table tbody tr.clickable:hover { background: var(--fg-soft); }
.ds-table tbody tr.is-selected { background: color-mix(in oklch, var(--info) 7%, var(--surface)); }
.num-col { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; letter-spacing: -0.02em; white-space: nowrap; }

/* ─── alerts ───────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
}
.alert:last-child { border-bottom: 0; }
.alert-mark { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--muted); }
.alert.sev-danger .alert-mark { color: var(--danger); }
.alert.sev-warn .alert-mark { color: var(--warn); }
.alert b { font-size: 13px; font-weight: 600; display: block; }
.alert p { font-size: 12.5px; color: var(--muted); }
.alert .alert-act { margin-left: auto; flex: none; }

/* ─── journey flow ─────────────────────────────────────────────────────── */
.flow { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 4px 0 10px; }
.flow-node {
  flex: 1 1 0; min-width: 128px; text-align: left;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 10px; padding: 11px 12px; display: flex; flex-direction: column; gap: 5px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.flow-node .fn-name { font-size: 13px; font-weight: 600; }
.flow-node .fn-time { font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-node .fn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.flow-node.done { border-color: color-mix(in oklch, var(--ok) 34%, var(--border)); background: color-mix(in oklch, var(--ok) 5%, var(--surface)); }
.flow-node.done .fn-dot { background: var(--ok); }
.flow-node.now { border-color: var(--fg); border-width: 1.5px; }
.flow-node.now .fn-dot { background: var(--fg); animation: breathe 2s ease-in-out infinite; }
.flow-node.risk { border-color: color-mix(in oklch, var(--warn) 45%, var(--border)); background: color-mix(in oklch, var(--warn) 7%, var(--surface)); }
.flow-node.risk .fn-dot { background: var(--warn-fill); }
.flow-node.fail { border-color: color-mix(in oklch, var(--danger) 45%, var(--border)); background: color-mix(in oklch, var(--danger) 6%, var(--surface)); }
.flow-node.fail .fn-dot { background: var(--danger); }
.flow-node.future { border-style: dashed; background: transparent; }
.flow-node.future .fn-name, .flow-node.future .fn-time { color: var(--muted); }
button.flow-node { cursor: pointer; }
button.flow-node:hover { background: var(--fg-soft); border-color: color-mix(in oklch, var(--fg) 35%, var(--border)); }
button.flow-node.done:hover { background: color-mix(in oklch, var(--ok) 11%, var(--surface)); }
.flow-node[aria-expanded="true"] { border-color: var(--fg); border-width: 1.5px; }
.flow-link { flex: 0 0 26px; display: grid; place-items: center; color: var(--border); }
.flow-link svg { width: 26px; height: 12px; }
.flow-link.provisional svg { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .flow-node.now .fn-dot { animation: none; } }

/* ─── evidence / reason blocks ─────────────────────────────────────────── */
.evidence {
  border: 1px solid var(--border); border-radius: 8px; background: var(--sunken);
  padding: 10px 12px; font-size: 13px;
}
.quote-line {
  border-left: 2px solid var(--route); padding-left: 10px;
  font-size: 13px; color: var(--fg); font-style: normal;
}
.kv { display: grid; grid-template-columns: 148px minmax(0,1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv-mono dd { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: -0.02em; }

.ai-note {
  border-left: 2px dashed color-mix(in oklch, var(--info) 50%, var(--border));
  padding-left: 10px;
}
.ai-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--info);
}

/* ─── checklist ────────────────────────────────────────────────────────── */
.check { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; font-size: 13px; }
.check + .check { border-top: 1px solid var(--border); }
.check input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.check label { cursor: pointer; }
.check.is-done label { color: var(--muted); text-decoration: line-through; }

/* ─── transcript ───────────────────────────────────────────────────────── */
.tx { display: flex; flex-direction: column; gap: 2px; }
.tx-line { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 11px 0; align-items: start; }
.tx-line + .tx-line { border-top: 1px solid var(--border); }
.tx-at { font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tx-who { display: block; margin-bottom: 6px; font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tx-line.caller .tx-who { color: var(--fg); }
.tx-text { display: block; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.tx-line.caller .tx-text { font-weight: 500; }
.tx-flag { display: block; margin-top: 6px; color: var(--warn); font-size: 12px; }

/* ─── drawer ───────────────────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: color-mix(in oklch, var(--fg) 32%, transparent);
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(560px, 94vw); background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 28px color-mix(in oklch, var(--fg) 12%, transparent);
  transform: translateX(100%); transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: flex-start; gap: var(--gap-sm);
  padding: 16px var(--gap-lg); border-bottom: 1px solid var(--border);
}
.drawer-body { overflow-y: auto; padding: var(--gap-lg); display: flex; flex-direction: column; gap: var(--gap-lg); }
.drawer-foot {
  margin-top: auto; padding: 14px var(--gap-lg);
  border-top: 1px solid var(--border); background: var(--sunken);
  display: flex; gap: var(--gap-sm); flex-wrap: wrap;
}
.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--muted); display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--fg-soft); color: var(--fg); }
.icon-btn svg { width: 16px; height: 16px; }

/* ─── tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 12px; font-size: 13px; color: var(--muted); background: transparent;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--fg); background: var(--fg-soft); }
.tab.is-active { color: var(--fg); font-weight: 600; border-bottom-color: var(--fg); }
.tabpanel[hidden] { display: none; }

/* ─── forms ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; padding: 8px 11px; min-height: 36px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); font: inherit; font-size: 13.5px;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:hover, .textarea:hover, .select:hover { border-color: color-mix(in oklch, var(--fg) 30%, var(--border)); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px color-mix(in oklch, var(--info) 15%, transparent); }
.input[readonly] { background: var(--sunken); color: var(--muted); }
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track-sw {
  width: 34px; height: 20px; border-radius: 999px; background: var(--border);
  position: relative; transition: background 0.15s ease; flex: none;
}
.switch .track-sw::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--surface); transition: transform 0.15s ease;
  box-shadow: 0 1px 2px color-mix(in oklch, var(--fg) 25%, transparent);
}
.switch input:checked + .track-sw { background: var(--accent); }
.switch input:checked + .track-sw::after { transform: translateX(14px); }
.switch input:focus-visible + .track-sw { outline: 2px solid var(--info); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg button {
  padding: 6px 12px; font-size: 12.5px; border: 0; background: transparent; color: var(--muted);
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--fg-soft); color: var(--fg); }
.seg button.is-active { background: var(--fg); color: var(--surface); font-weight: 500; }

/* ─── diff ─────────────────────────────────────────────────────────────── */
.diff { font-family: var(--font-mono); font-size: 12px; line-height: 1.65; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.diff div { padding: 2px 12px; white-space: pre-wrap; }
.diff .add { background: color-mix(in oklch, var(--ok) 11%, var(--surface)); color: var(--ok-text); }
.diff .del { background: color-mix(in oklch, var(--danger) 9%, var(--surface)); color: var(--danger); }
.diff .ctx { color: var(--muted); background: var(--surface); }

/* ─── charts ───────────────────────────────────────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 132px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; height: 100%; }
.bars .bar i { display: block; background: var(--route); border-radius: 3px 3px 0 0; }
.bars .bar span { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-align: center; }
.hbar { display: grid; grid-template-columns: 132px minmax(0,1fr) 48px; gap: 12px; align-items: center; font-size: 13px; padding: 5px 0; }
.hbar .rail-bg { height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.hbar .rail-bg i { display: block; height: 100%; background: var(--route); border-radius: 4px; }
.hbar .val { font-family: var(--font-mono); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
/* charts whose series are not routes must not borrow route colour */
.chart-neutral { --route: color-mix(in oklch, var(--fg) 52%, var(--bg)); }

/* ─── screen pop ───────────────────────────────────────────────────────── */
.pop {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 372px;
  background: var(--surface); border: 1px solid var(--fg); border-radius: var(--radius-lg);
  box-shadow: 0 10px 34px color-mix(in oklch, var(--fg) 20%, transparent);
  transform: translateY(16px); opacity: 0; pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.pop.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.pop-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.pop-body { padding: 13px 14px; display: flex; flex-direction: column; gap: 9px; }
.pop-foot { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--sunken); border-radius: 0 0 11px 11px; }

/* ─── toast ────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--fg); color: var(--surface); border-radius: 8px;
  padding: 9px 15px; font-size: 13px; display: flex; align-items: center; gap: 9px;
  box-shadow: 0 6px 20px color-mix(in oklch, var(--fg) 26%, transparent);
  animation: rise 0.2s ease;
}
.toast .meta { color: color-mix(in oklch, var(--surface) 72%, var(--fg)); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .grid-main, .grid-side { grid-template-columns: minmax(0,1fr); }
  .grid-5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 920px) {
  /* The rail stays on the left at every width. It narrows to an icon rail
     rather than stacking on top, so the console never stops reading as a
     dashboard in a narrow preview pane. */
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .rail-brand { padding: 16px 0; justify-content: center; }
  .rail-brand > span:last-child { display: none; }
  .nav-group { padding: 10px 8px 4px; }
  .nav-group + .nav-group { border-top: 1px solid var(--border); padding-top: 10px; }
  .nav-label { display: none; }
  .nav-a { position: relative; justify-content: center; gap: 0; padding: 9px 0; font-size: 0; }
  .nav-a svg { width: 17px; height: 17px; }
  .nav-a .count { display: none; }
  .nav-a .count.is-alert {
    display: block; position: absolute; top: 5px; right: 10px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--danger); overflow: hidden;
  }
  .nav-a.is-active .count.is-alert { background: var(--surface); opacity: 1; }
  .rail-foot { padding: 10px 8px; }
  .who { justify-content: center; padding: 0; }
  .who > span:not(.who-av) { display: none; }
  .role-pick { display: none; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0,1fr); }
  .page { padding: var(--gap-md); }
  .topbar { padding: 12px var(--gap-md); flex-wrap: wrap; }
  .kv { grid-template-columns: minmax(0,1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .drawer { width: 100%; }
  .pop { right: 12px; left: 12px; width: auto; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Progressive disclosure, zoomable canvas, and user-created routes.
   Added for the "show only what matters, reveal the rest on demand" pass.
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── first-run starter ────────────────────────────────────────────────── */
.starter { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 18px 20px; }
.starter-head { display: flex; align-items: baseline; gap: 12px; }
.starter-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.starter-head p { font-size: 13px; color: var(--muted); margin: 0; }
.starter-head .icon-btn { margin-left: auto; }
.starter-steps { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 14px; }
.starter-step {
  display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface);
}
.starter-step:hover { background: var(--sunken); border-color: color-mix(in oklch, var(--fg) 30%, var(--border)); }
.starter-step .n { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.starter-step b { font-size: 13.5px; font-weight: 600; }
.starter-step span:last-child { font-size: 12.5px; color: var(--muted); }

/* ─── compact live-call rows (one line, expand for detail) ─────────────── */
.crows { display: flex; flex-direction: column; }
.crow { border-bottom: 1px solid var(--border); }
.crow:last-child { border-bottom: 0; }
.crow > summary {
  display: grid; grid-template-columns: 3px 128px minmax(0,1fr) 132px 58px 18px;
  align-items: center; gap: 14px; padding: 11px 18px 11px 0; cursor: pointer; list-style: none;
}
.crow > summary::-webkit-details-marker { display: none; }
.crow > summary:hover { background: var(--fg-soft); }
.crow > summary:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.crow-bar { align-self: stretch; background: var(--route); border-radius: 0 2px 2px 0; min-height: 34px; }
.crow-id { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: -0.02em; }
.crow-what { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow-what b { font-weight: 600; }
.crow-what .sep { color: var(--border); margin: 0 7px; }
.crow-what .dim { color: var(--muted); }
.crow-state { justify-self: start; }
.crow-time { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
.crow-chev { color: var(--muted); transition: transform 0.15s ease; }
.crow-chev svg { width: 14px; height: 14px; display: block; }
.crow[open] > summary { background: var(--sunken); }
.crow[open] .crow-chev { transform: rotate(90deg); }
.crow-body { padding: 4px 18px 18px 20px; display: flex; flex-direction: column; gap: 12px; background: var(--sunken); }
.crow-body .snippet { margin: 0; }

/* ─── inline section disclosure ────────────────────────────────────────── */
.disclose > summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  font-size: 12.5px; color: var(--muted); padding: 10px 18px; border-top: 1px solid var(--border);
}
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary:hover { color: var(--fg); background: var(--fg-soft); }
.disclose > summary:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.disclose > summary .chev { transition: transform 0.15s ease; }
.disclose > summary .chev svg { width: 13px; height: 13px; display: block; }
.disclose[open] > summary .chev { transform: rotate(90deg); }
.disclose[open] > summary { color: var(--fg); }

/* ─── zoomable canvas ──────────────────────────────────────────────────── */
.page-fixed { flex: 1; min-height: 0; overflow: hidden; padding-bottom: var(--gap-lg); }
.stage { display: grid; grid-template-columns: minmax(0,1fr) 372px; gap: var(--gap-lg); align-items: start; }
.viewport {
  position: relative; overflow: hidden; height: 520px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--sunken);
  background-image: radial-gradient(circle, color-mix(in oklch, var(--fg) 10%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab; touch-action: none;
}
.viewport.is-panning { cursor: grabbing; }
.viewport:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.canvas { position: absolute; left: 50%; top: 50%; width: 980px; height: 452px; transform-origin: center center; }
.gnode {
  position: absolute; width: 190px; min-height: 68px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.gnode .gn-top { display: flex; align-items: center; gap: 7px; }
.gnode .gn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.gnode .gn-name { font-size: 13px; font-weight: 600; }
.gnode .gn-sub { font-size: 12px; color: var(--muted); }
.gnode .gn-time { font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gnode.done { border-color: color-mix(in oklch, var(--ok) 34%, var(--border)); background: color-mix(in oklch, var(--ok) 5%, var(--surface)); }
.gnode.done .gn-dot { background: var(--ok); }
.gnode.now { border-color: var(--fg); border-width: 1.5px; }
.gnode.now .gn-dot { background: var(--fg); animation: breathe 2s ease-in-out infinite; }
.gnode.future { border-style: dashed; background: transparent; }
.gnode.future .gn-name, .gnode.future .gn-sub { color: var(--muted); }
.gnode.warnish { border-color: color-mix(in oklch, var(--warn) 45%, var(--border)); background: color-mix(in oklch, var(--warn) 7%, var(--surface)); }
.gnode.warnish .gn-dot { background: var(--warn-fill); }
.gnode:hover { box-shadow: 0 1px 4px color-mix(in oklch, var(--fg) 14%, transparent); }
.gnode.is-selected { border-color: var(--fg); border-width: 1.5px; box-shadow: 0 0 0 3px color-mix(in oklch, var(--fg) 12%, transparent); }
.gnode:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.gbranch {
  position: absolute; width: 190px; padding: 8px 11px; border: 1px dashed var(--border); border-radius: 9px;
  background: var(--surface); display: flex; flex-direction: column; gap: 2px;
}
.gbranch b { font-size: 12px; font-weight: 600; color: var(--muted); }
.gbranch span { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.gwires { position: absolute; inset: 0; width: 980px; height: 452px; pointer-events: none; color: var(--border); }
@media (prefers-reduced-motion: reduce) { .gnode.now .gn-dot { animation: none; } }

.zoombar {
  position: absolute; right: 14px; bottom: 14px; display: flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px;
  box-shadow: 0 2px 10px color-mix(in oklch, var(--fg) 12%, transparent);
}
.zbtn {
  min-width: 30px; height: 28px; border: 0; background: transparent; border-radius: 6px; color: var(--muted);
  font-size: 12.5px; display: grid; place-items: center; cursor: pointer;
}
.zbtn:hover { background: var(--fg-soft); color: var(--fg); }
.zbtn:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.zbtn svg { width: 14px; height: 14px; }
.zlevel { font-family: var(--font-mono); font-size: 12px; color: var(--fg); min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.zhint { position: absolute; left: 14px; bottom: 16px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ─── inspector ────────────────────────────────────────────────────────── */
.inspector { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.insp-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 9px; }
.insp-body { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.insp-body [data-panel][hidden] { display: none; }
.insp-foot { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--sunken); border-radius: 0 0 11px 11px; }

/* ─── route colour picker ──────────────────────────────────────────────── */
.swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--sw); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--fg); }
.swatch:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.route-added { animation: flashin 1.4s ease; }
@keyframes flashin { 0%, 55% { background: color-mix(in oklch, var(--ok) 13%, var(--surface)); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .route-added { animation: none; } }

@media (max-width: 1180px) {
  .stage { grid-template-columns: minmax(0,1fr); }
  .starter-steps { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 920px) {
  .crow > summary { grid-template-columns: 3px minmax(0,1fr) 18px; row-gap: 4px; padding-right: 12px; }
  .crow-what, .crow-state, .crow-time { grid-column: 2; }
}

/* full-height pages (call journey) — the work area never scrolls */
.app-fixed { height: 100vh; overflow: hidden; }
.app-fixed .work { min-height: 0; }
.gwires { color: color-mix(in oklch, var(--fg) 25%, var(--bg)); }


/* ─── routing strip — one card per route, all equal, no hierarchy ──────── */
.rstrip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.rcard {
  border: 1px solid var(--border); border-top: 3px solid var(--route); border-radius: var(--radius);
  padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 2px;
}
.rcard-name { font-size: 13.5px; font-weight: 600; }
.rcard-desk { font-size: 12.5px; color: var(--muted); }
.rcard-n { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.rcard-n em { font-style: normal; color: var(--danger); }

/* ─── prompt preview — the words the assistant is actually given ───────── */
.prompt-box {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7; border: 1px solid var(--border);
  border-radius: 8px; background: var(--sunken); padding: 12px 14px; white-space: pre-wrap;
  color: var(--muted); overflow-wrap: anywhere;
}
.prompt-box b { color: var(--fg); font-weight: 500; }
.qlines { display: flex; flex-direction: column; gap: 8px; }
.qline { display: grid; grid-template-columns: 20px minmax(0,1fr) 30px; gap: 10px; align-items: start; }
.qline .n { font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-align: right; padding-top: 10px; }
.qline > .icon-btn { margin-top: 4px; }

/* ─── two-stage grouping — the prompt is swapped, not appended ─────────── */
.stage-group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stage-head {
  display: flex; align-items: baseline; gap: 10px; padding: 11px 14px;
  border-bottom: 1px solid var(--border); background: var(--sunken); border-radius: 7px 7px 0 0;
}
.stage-head .stage-n {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); flex: none;
}
.stage-head b { font-size: 13px; font-weight: 600; }
.stage-body { padding: 14px; display: flex; flex-direction: column; gap: 16px; }
.stage-body > p { font-size: 12.5px; color: var(--muted); margin: 0; }
.stage-swap { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 12.5px; color: var(--muted); }
.stage-swap svg { width: 14px; height: 14px; flex: none; }
.stage-swap b { color: var(--fg); font-weight: 500; }
.stage-note {
  display: flex; gap: 9px; align-items: baseline; padding: 10px 12px; border-radius: 8px;
  background: var(--sunken); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted);
}
.stage-note .stage-n {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg); flex: none;
}

/* ─── unsaved-changes bar ──────────────────────────────────────────────── */
.save-bar {
  display: flex; align-items: center; gap: 10px; padding: 11px 24px;
  border-top: 1px solid var(--border); background: var(--sunken); border-radius: 0 0 11px 11px;
}
.save-bar[hidden] { display: none; }
.save-bar .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn-fill); flex: none; }
.save-bar .msg { font-size: 12.5px; color: var(--fg); }
.save-bar .btn-row { margin-left: auto; }

/* ─── role preview in the rail ─────────────────────────────────────────── */
.role-pick { display: flex; flex-direction: column; gap: 6px; padding: 10px 6px 4px; }
.role-pick > .meta { padding-left: 2px; }
.role-pick .seg { width: 100%; }
.role-pick .seg button { flex: 1; padding: 5px 4px; font-size: 11.5px; }
.role-hint { line-height: 1.45; padding-left: 2px; }

/* Accent-outline action — used where a list gives every row its own fix, so
   the page is not three solid green blocks competing for the same attention. */
.btn-accent { background: var(--surface); color: var(--accent-text); border-color: color-mix(in oklch, var(--accent) 40%, var(--border)); font-weight: 500; }
.btn-accent:hover { background: color-mix(in oklch, var(--accent) 10%, var(--surface)); border-color: var(--accent); color: var(--accent-text); }

/* ── route cards + the route pop-up (Routes page) ─────────────────────── */
.route-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 16px var(--gap-lg) var(--gap-lg); }
.route-card {
  border: 1px solid var(--border); border-top: 3px solid var(--route); border-radius: var(--radius);
  background: var(--surface); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px;
  cursor: pointer; transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.route-card:hover { border-color: color-mix(in oklch, var(--fg) 35%, var(--border)); border-top-color: var(--route); box-shadow: 0 1px 3px color-mix(in oklch, var(--fg) 10%, transparent); }
.route-card.is-nodesk { border-color: color-mix(in oklch, var(--danger) 45%, var(--border)); border-top-color: var(--route); }
.route-card-head { display: flex; align-items: center; gap: 8px; }
.route-card-head b { font-size: 14px; }
.route-card-head .icon-btn.edit { margin-left: auto; border-color: var(--border); color: var(--fg); background: var(--surface); }
.route-card-head .icon-btn.edit:hover { background: var(--fg-soft); border-color: var(--fg); }
.route-card-meaning { font-size: 13px; color: var(--muted); margin: 0; }
.route-card-foot { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.route-card-foot .num { font-size: 11.5px; }
.route-card-foot .sep { color: var(--border); }

.modal {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  padding: var(--gap-lg); background: color-mix(in oklch, var(--fg) 32%, transparent);
}
.modal.open { display: flex; }
.modal-box {
  width: min(780px, 100%); max-height: calc(100vh - 2 * var(--gap-lg));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px color-mix(in oklch, var(--fg) 18%, transparent);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-box .drawer-body { flex: 1; min-height: 0; }
.modal-box .drawer-foot { margin-top: 0; align-items: center; }
@media (max-width: 920px) {
  .modal { padding: 12px; }
  .modal-box { max-height: calc(100vh - 24px); }
  .modal-box .grid-2 { grid-template-columns: minmax(0,1fr); }
}

/* ── operator-facing states ───────────────────────────────────────────── */
.btn.is-arming { border-color: var(--warn); color: var(--warn); background: color-mix(in oklch, var(--warn) 8%, var(--surface)); }
.btn.is-disabled, a.btn.is-disabled { opacity: 0.5; pointer-events: none; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.track-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-left: 8px; }
.role-pick .seg button { padding: 5px 2px; }
.ask-sup { font-size: 12px; color: var(--muted); margin-left: auto; flex: none; }
.provenance { font-size: 12.5px; color: var(--muted); padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* a card's contents (wide tables, long filter rows) never widen the page */
.card { min-width: 0; contain: inline-size; }

/* a call row is a link */
a.crow-link {
  display: grid; grid-template-columns: 3px 128px minmax(0,1fr) 132px 58px 18px;
  align-items: center; gap: 14px; padding: 11px 18px 11px 0; color: inherit; text-decoration: none;
}
a.crow-link:hover { background: var(--fg-soft); }
a.crow-link:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
a.crow-link[hidden] { display: none; }
a.crow-link .crow-what { white-space: normal; line-height: 1.35; }
.tx-stage { margin: 16px 0 6px; }
.tx-stage:first-child { margin-top: 0; }
.tx-note { margin-top: 12px; }
.row-link { text-decoration: underline; color: var(--muted); white-space: nowrap; }
.row-link:hover { color: var(--fg); }

/* live transcript */
.tx-livebar { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg); padding: 8px 10px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--sunken); }
.tx-livebar .num { margin-left: auto; }
.tx-listen { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 12px 0 0; font-style: italic; }
.tx-line.is-new { animation: tx-in 0.6s ease-out; }
.tx-line.is-new .tx-text { background: color-mix(in oklch, var(--info) 10%, transparent); }
@keyframes tx-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tx-line.is-new { animation: none; } }

/* things that happened on the line, as opposed to things that were said */
.tx-event { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 7px 0; align-items: center; }
.tx-event + .tx-line, .tx-line + .tx-event, .tx-event + .tx-event { border-top: 1px solid var(--border); }
.tx-ev {
  display: inline-flex; align-items: center; gap: 9px; justify-self: start;
  font-family: var(--font-mono); font-size: 12px; color: var(--fg);
  background: var(--sunken); border: 1px dashed color-mix(in oklch, var(--fg) 30%, var(--border)); border-radius: 6px; padding: 5px 10px;
}
.tx-ev .tag { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tx-event.route .tx-ev, .tx-event.transfer .tx-ev { border-style: solid; background: var(--surface); }
.tx-event.route .tx-ev { border-color: var(--route); }
.route-tag {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px;
  background: color-mix(in oklch, var(--route) 12%, var(--surface)); color: var(--route);
  border: 1px solid color-mix(in oklch, var(--route) 45%, var(--border)); font-weight: 600;
}

.tx-event.end .tx-ev { border-style: solid; border-color: color-mix(in oklch, var(--danger) 45%, var(--border)); color: var(--danger); }
.tx-event.end .tx-ev .tag { color: var(--danger); }
.tx-event.is-new { animation: tx-in 0.6s ease-out; }

/* how it got here — inside the drawer */
.how-wrap { border: 1px solid var(--border); border-radius: var(--radius); }
.how-wrap > summary { border-top: 0; }
.how { display: flex; flex-direction: column; gap: 12px; }
.how .track i { width: 22px; height: 6px; border-radius: 3px; }
.how-kv { grid-template-columns: 78px minmax(0,1fr); font-size: 12.5px; }
.crow-link.is-selected { background: var(--sunken); }

.drawer { overflow-x: hidden; }
.drawer-body > * { min-width: 0; max-width: 100%; }

/* the eight steps, stacked — fits a drawer and reads like the transcript */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps li {
  position: relative; display: grid; grid-template-columns: 18px minmax(0,1fr) auto; column-gap: 10px; align-items: baseline;
  padding: 0 0 14px;
}
.steps li::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: -2px; width: 2px; background: var(--border); }
.steps li:last-child::before { display: none; }
.steps .st-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); box-sizing: border-box; align-self: center; position: relative; z-index: 1; }
.steps .st-name { font-size: 13px; font-weight: 600; }
.steps .st-time { font-size: 11.5px; color: var(--muted); }
.steps .st-sub { grid-column: 2 / 4; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.steps li.done .st-dot { background: var(--ok); border-color: var(--ok); }
.steps li.done::before { background: color-mix(in oklch, var(--ok) 55%, var(--border)); }
.steps li.now .st-dot { background: var(--fg); border-color: var(--fg); box-shadow: 0 0 0 3px color-mix(in oklch, var(--fg) 12%, transparent); }
.steps li.risk .st-dot { background: var(--warn-fill); border-color: var(--warn-fill); box-shadow: 0 0 0 3px color-mix(in oklch, var(--warn) 18%, transparent); }
.steps li.fail .st-dot { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 16%, transparent); }
.steps li.fail .st-sub { color: var(--danger); }
.steps li.future .st-name { color: var(--muted); font-weight: 500; }
.steps li.future .st-dot { border-style: dashed; }

/* progress bar on a call row */
.crow-track { display: flex; width: 104px; margin-top: 6px; }
.crow-track i { height: 4px; }
a.crow-link .crow-what { display: block; }

.tx-ev { max-width: 100%; flex-wrap: wrap; }
.drawer-body { overflow-x: hidden; }
.tx, .tx-event, .tx-line { min-width: 0; }
