/* N3 Assistant — dark UI. Colour means status/danger ONLY and always comes with words:
   green done/ok · yellow waiting on you · orange approval/caution · red failed/blocked/danger ·
   grey queued/cancelled/expired/unknown. Running is neutral with a spinner.
   Identity colours (Claude indigo, OpenAI sky) never borrow a status hue. */

:root {
  --bg: #0b0f17;
  --bg2: #0d1320;
  --card: #111827;
  --card2: #151d2e;
  --line: #1f2937;
  --line2: #2a3850;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --dim: #6b7280;
  --ok: #22c55e;
  --wait: #eab308;
  --attn: #f97316;
  --bad: #ef4444;
  --grey: #9ca3af;
  --claude: #818cf8;
  --openai: #38bdf8;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
p { margin: 0; }
img, svg, canvas { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
code { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.fine { font-size: 12.5px; color: var(--muted); }
.bad-text { color: #fca5a5; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; }

.sr-only, .visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid #f8fafc; outline-offset: 2px; }

/* ---------- icons, spinner ---------- */
.ic { width: 20px; height: 20px; flex: 0 0 auto; }
.ic-sm { width: 14px; height: 14px; }
.ic-lg { width: 32px; height: 32px; }
.spin {
  display: inline-block; width: 12px; height: 12px; flex: 0 0 auto;
  border: 2px solid rgba(229, 231, 235, .25); border-top-color: var(--text);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- boot / login ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(420px, 100%); display: grid; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.brand-block { display: grid; justify-items: center; gap: 6px; text-align: center; margin-bottom: 4px; }
.brand-block h1 { font-size: 24px; letter-spacing: .2px; }

/* ---------- form controls ---------- */
input, textarea, select {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px;
  padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--dim); }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--ok); }
input.num { width: 90px; }
select { appearance: auto; }
.field { display: grid; gap: 6px; }
label { font-weight: 600; font-size: 14px; }
.form-error {
  color: #fecaca; background: rgba(239, 68, 68, .10); border: 1px solid rgba(239, 68, 68, .45);
  padding: 8px 10px; border-radius: 10px; font-size: 14px;
}
.form-error.info { color: var(--text); background: rgba(234, 179, 8, .08); border-color: rgba(234, 179, 8, .45); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1 1 auto; min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line2); background: var(--card2); color: var(--text);
  font: inherit; font-weight: 650; font-size: 15px; line-height: 1.2; cursor: pointer;
  text-decoration: none; text-align: center; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: #3b4c6b; background: #1a2438; }
.btn.primary { background: var(--text); color: #0b0f17; border-color: var(--text); }
.btn.primary:hover:not(:disabled) { background: #fff; border-color: #fff; }
.btn.outline { background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(229, 231, 235, .06); border-color: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }
.btn.danger-outline { background: rgba(239, 68, 68, .08); color: #fca5a5; border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.big { min-height: 58px; font-size: 17px; }
.btn.wide { width: 100%; }
.btn.icon-only { padding: 8px; min-width: 44px; }
.btn.tool { font-weight: 600; font-size: 14px; padding: 8px 12px; min-height: 40px; }
.btn.tool.on-call { border-color: var(--text); background: rgba(229, 231, 235, .10); }

/* approve button: 1 s arming bar so a stray tap while the card appears can't approve */
.btn.approve { position: relative; overflow: hidden; white-space: normal; }
.btn.approve.arming::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: #0b0f17; opacity: .45; transform-origin: left; animation: arm 1s linear forwards;
}
@keyframes arm { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- chips (status words + colour) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; border: 1px solid currentColor;
  font-size: 12.5px; font-weight: 700; line-height: 1.4; white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.chip.small { font-size: 11.5px; padding: 1px 8px; }
.s-ok { color: var(--ok); background: rgba(34, 197, 94, .10); }
.s-wait { color: var(--wait); background: rgba(234, 179, 8, .10); }
.s-attn { color: var(--attn); background: rgba(249, 115, 22, .10); }
.s-bad { color: var(--bad); background: rgba(239, 68, 68, .12); }
.s-grey { color: var(--grey); background: rgba(156, 163, 175, .08); }
.s-run, .s-neutral { color: var(--text); background: rgba(229, 231, 235, .06); border-color: var(--line2); }
.mchip {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700; border: 1px solid; white-space: nowrap;
}
.m-claude { color: var(--claude); border-color: rgba(129, 140, 248, .5); }
.m-openai { color: var(--openai); border-color: rgba(56, 189, 248, .5); }
.m-other { color: var(--muted); border-color: var(--line2); }
.kind { font-size: 12.5px; color: var(--muted); }
.tag { font-size: 11.5px; padding: 1px 8px; border-radius: 6px; border: 1px dashed var(--line2); color: var(--muted); }

/* ---------- cards, banners ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.b-ok { border-color: rgba(34, 197, 94, .55); box-shadow: inset 4px 0 0 var(--ok); }
.b-wait { border-color: rgba(234, 179, 8, .55); box-shadow: inset 4px 0 0 var(--wait); }
.b-attn { border-color: rgba(249, 115, 22, .6); box-shadow: inset 4px 0 0 var(--attn); }
.b-bad { border-color: rgba(239, 68, 68, .6); box-shadow: inset 4px 0 0 var(--bad); }
.b-neutral { border-color: var(--line2); }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card h3 { font-size: 17px; margin-bottom: 8px; }
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: 8px 0;
  border-radius: 12px; border: 1px solid var(--line2); background: rgba(229, 231, 235, .04); font-size: 14.5px;
}
.banner .ic { margin-top: 1px; }
.banner.b-bad { background: rgba(239, 68, 68, .10); border-color: rgba(239, 68, 68, .55); box-shadow: none; }
.banner.b-bad .ic { color: var(--bad); }
.banner.b-attn { background: rgba(249, 115, 22, .10); border-color: rgba(249, 115, 22, .55); box-shadow: none; }
.banner.b-attn .ic { color: var(--attn); }
.banner.b-neutral .ic { color: var(--muted); }
.loading { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: grid; gap: 12px; }
.stack.tight { gap: 6px; }
.lbl { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
code.url {
  display: block; font-size: 13px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; word-break: break-all; white-space: pre-wrap; color: var(--text);
}
.plain-pre, pre.json {
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 6px 0 0; max-height: 320px; overflow: auto;
}
a.ext { color: var(--text); text-decoration: underline; text-decoration-color: rgba(229, 231, 235, .4); word-break: break-all; display: inline-flex; gap: 4px; align-items: baseline; }
a.ext .ic { align-self: center; }
dl.facts { display: grid; gap: 6px; margin: 8px 0 0; }
dl.facts > div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; }
dl.facts dt { color: var(--muted); font-size: 14px; }
dl.facts dd { margin: 0; word-break: break-word; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 15, 23, .88); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.top-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 1280px; margin: 0 auto; }
.top-row.second { margin-top: 6px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: .2px; }
.brand img { width: 28px; height: 28px; }
.top-id { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; }
.who { color: var(--muted); font-size: 14px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; background: none; border: 0; padding: 0; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.signout { display: none; }

.model-switch { display: inline-flex; border: 1px solid var(--line2); border-radius: 12px; overflow: hidden; }
.ms-opt {
  appearance: none; background: transparent; color: var(--muted); border: 0;
  padding: 6px 12px; min-height: 38px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  display: grid; justify-items: center; line-height: 1.15;
}
.ms-opt + .ms-opt { border-left: 1px solid var(--line2); }
.ms-opt small { font-size: 10px; font-weight: 600; color: var(--dim); }
.ms-opt.on.m-claude { background: var(--claude); color: #0b0f17; }
.ms-opt.on.m-openai { background: var(--openai); color: #0b0f17; }
.ms-opt:disabled { cursor: not-allowed; opacity: .7; }
.model-switch.big .ms-opt { min-height: 48px; padding: 8px 20px; font-size: 16px; }

.usage { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.usage.block { font-size: 15px; }
progress.meter {
  -webkit-appearance: none; appearance: none; width: 110px; height: 8px; border: 0;
  border-radius: 999px; background: var(--line); overflow: hidden; vertical-align: middle;
}
progress.meter::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress.meter::-webkit-progress-value { background: #cbd5e1; border-radius: 999px; }
progress.meter::-moz-progress-bar { background: #cbd5e1; border-radius: 999px; }
progress.meter.lv-attn::-webkit-progress-value { background: var(--attn); }
progress.meter.lv-attn::-moz-progress-bar { background: var(--attn); }
progress.meter.lv-bad::-webkit-progress-value { background: var(--bad); }
progress.meter.lv-bad::-moz-progress-bar { background: var(--bad); }

/* ---------- tabs ---------- */
.tabs { display: flex; }
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 650; min-height: 56px; padding: 6px 4px;
}
.tab.on { color: var(--text); }
.tab .badge {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; color: #0b0f17;
}
.badge.b-wait { background: var(--wait); box-shadow: none; }
.badge.b-attn { background: var(--attn); box-shadow: none; }
.top-tabs { display: none; }
.bottom-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(11, 15, 23, .96); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-tabs .tab.on::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--text); }

/* ---------- main layout ---------- */
.main { max-width: 1280px; margin: 0 auto; padding: 12px 12px calc(88px + env(safe-area-inset-bottom)); }
.view-home { display: block; }
.col-left { display: grid; gap: 12px; align-content: start; min-width: 0; }
.col-right { min-width: 0; }
.detail-empty { display: none; }
.page-title { font-size: 22px; margin: 4px 0 12px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .page-title { margin-bottom: 4px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 0 8px; }
.sec-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

/* needs-you strip */
.needs-clear { display: flex; align-items: center; gap: 10px; padding: 4px 2px; flex-wrap: wrap; }
.needs-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 6px; }
.needs-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.need {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 52px;
  background: var(--card); border: 1px solid var(--line2); border-radius: 12px;
  color: var(--text); text-decoration: none;
}
.need:hover { border-color: #3b4c6b; }
.need-text { flex: 1 1 auto; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 14.5px; }
.need .ic { color: var(--muted); }

/* composer */
.composer { display: grid; gap: 10px; }
.composer textarea { border-radius: 12px; field-sizing: content; max-height: 240px; }
.composer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; }
.send { min-width: 104px; margin-left: auto; }
.inline-form .btn { white-space: nowrap; }

/* task list */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task-card { display: grid; gap: 6px; color: var(--text); text-decoration: none; }
.task-card:hover { border-color: #3b4c6b; }
.task-card.selected { border-color: var(--text); }
.tc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tc-time { margin-left: auto; font-size: 12.5px; }
.tc-title { font-weight: 650; word-break: break-word; }
.tc-snippet { font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.empty { text-align: center; display: grid; gap: 6px; padding: 24px 14px; }

/* collapsibles */
details.collapsible { margin-top: 10px; }
details.collapsible > summary, details.panel > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-weight: 700; padding: 8px 2px; min-height: 40px;
}
details.collapsible > summary::-webkit-details-marker, details.panel > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before, details.panel > summary::after {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s; flex: 0 0 auto;
}
details.collapsible[open] > summary::before, details.panel[open] > summary::after { transform: rotate(45deg); }
details.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 14px; margin-bottom: 12px;
}
details.panel > summary { justify-content: space-between; padding: 14px 0; }
details.panel > summary h3 { font-size: 16px; }
details.panel[open] { padding-bottom: 14px; }

/* ---------- task detail ---------- */
.detail:not([hidden]) {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(8px + env(safe-area-inset-top)) 12px calc(28px + env(safe-area-inset-bottom));
}
body.detail-open { overflow: hidden; }
.detail-inner { display: grid; gap: 12px; max-width: 860px; margin: 0 auto; }
.detail-head { display: grid; gap: 8px; }
.dh-row { display: flex; align-items: center; gap: 8px; }
.dh-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.detail-title { font-size: 20px; word-break: break-word; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.waiting-other { display: flex; gap: 12px; align-items: flex-start; }
.waiting-other .ic-lg { color: var(--muted); }
.result .md { margin-top: 4px; }

/* receipt */
.receipt { margin-top: 12px; padding: 12px; border: 1px dashed var(--line2); border-radius: 12px; background: var(--bg2); }
.receipt-head { display: flex; align-items: center; gap: 8px; color: var(--ok); margin-bottom: 6px; }
.receipt-head strong { color: var(--text); }
.confirmation { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.confirmation .lbl { margin: 0; }
.conf-num { font-size: 20px; font-weight: 800; letter-spacing: 1px; word-break: break-all; }
.links { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ap-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14.5px; }

/* timeline */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 7px 0; }
.tl-icon {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line2); color: var(--muted); z-index: 1;
}
.tl-icon .ic { width: 15px; height: 15px; }
.tl-body { min-width: 0; display: grid; gap: 4px; }
.tl-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tl-title { font-weight: 650; font-size: 14.5px; word-break: break-word; }
.tl-top time { font-size: 12px; white-space: nowrap; }
.tl-text { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.tl-url code.url { font-size: 12px; padding: 4px 6px; }
.tl-ok .tl-icon { color: var(--ok); border-color: rgba(34, 197, 94, .6); }
.tl-wait .tl-icon { color: var(--wait); border-color: rgba(234, 179, 8, .6); }
.tl-attn .tl-icon { color: var(--attn); border-color: rgba(249, 115, 22, .6); }
.tl-attn .tl-title { color: #fdba74; }
.tl-bad .tl-icon { color: var(--bad); border-color: rgba(239, 68, 68, .6); }
.tl-bad .tl-title { color: #fca5a5; }
.tl-grey .tl-icon { color: var(--grey); }
ul.plain { margin: 0; padding-left: 18px; font-size: 14.5px; }
.shot { padding: 0; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; background: var(--bg2); cursor: zoom-in; width: min(320px, 100%); display: block; }
.shot-img { display: block; width: 100%; height: auto; min-height: 60px; }
.shot-full { display: block; width: 100%; height: auto; border-radius: 10px; }

/* markdown answers */
.md { display: grid; gap: 8px; word-break: break-word; }
.md ul, .md ol { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.md h4 { font-size: 16px; margin-top: 4px; }
.md code { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; font-size: 13.5px; }
.md pre.code { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; margin: 0; }
.md pre.code code { border: 0; padding: 0; background: none; }

/* ---------- approval card ---------- */
.approval { display: grid; gap: 12px; }
.ap-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-title { font-size: 19px; margin: 0; word-break: break-word; }
.ap-big { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; }
.ap-big > div { background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; }
.ap-big dt { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ap-big dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; line-height: 1.2; word-break: break-word; }
.ap-big dd.rec-yes { color: #fdba74; }
.ap-terms ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14.5px; }
.ap-fields table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.ap-fields th, .ap-fields td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; word-break: break-word; }
.ap-fields th { color: var(--muted); font-weight: 600; width: 40%; }
.ap-notes { font-size: 14.5px; white-space: pre-wrap; }
.ap-actions { display: grid; gap: 10px; }

/* ---------- link safety ---------- */
.urlcheck { display: grid; gap: 8px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 12px; }
.urlcheck.compact { padding: 8px 10px; gap: 6px; }
.uc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.uc-reasons { margin: 0; padding-left: 20px; font-size: 14px; display: grid; gap: 3px; }

/* ---------- QR ---------- */
.qr-status { display: flex; align-items: center; gap: 8px; min-height: 24px; color: var(--muted); }
.qr-status.bad-text { color: #fca5a5; }
.qr-preview { display: grid; justify-items: center; }
.qr-preview canvas { max-height: 220px; width: auto; height: auto; border-radius: 12px; border: 1px solid var(--line2); }
.qr-actions { display: grid; gap: 10px; }
.or { text-align: center; color: var(--dim); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* ---------- voice ---------- */
.voice { display: grid; gap: 10px; border-color: var(--line2); }
.voice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.voice-state { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.bars i { display: block; width: 4px; height: 6px; border-radius: 2px; background: var(--text); opacity: .7; }
.voice-state.speaking .bars i, .voice-state.hearing .bars i { animation: eq .9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: .15s; }
.bars i:nth-child(3) { animation-delay: .3s; }
.bars i:nth-child(4) { animation-delay: .45s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }
.captions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.cap { display: grid; grid-template-columns: 84px 1fr; gap: 8px; font-size: 15px; }
.cap-who { font-weight: 700; color: var(--muted); }
.cap-you .cap-who { color: var(--text); }
.cap.interim .cap-text { opacity: .65; }
.voice-audio-host { display: none; }

/* ---------- inbox ---------- */
.msg { display: grid; gap: 8px; }
.msg-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-top time { margin-left: auto; font-size: 12.5px; }
.msg-who { font-weight: 650; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.msg-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13.5px; }
.msg-result { border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- settings / admin ---------- */
.steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.mfa-qr { background: #fff; padding: 12px; border-radius: 12px; width: max-content; max-width: 100%; }
.mfa-qr svg { display: block; width: 200px; height: 200px; }
.mfa .row code.url { flex: 1 1 260px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.grid tbody th { font-weight: 650; }
.audit td code { font-size: 12.5px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.grid2 { display: grid; gap: 10px; grid-template-columns: 1fr; }
.add-user { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.add-user h4 { font-size: 15px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 100;
  bottom: calc(72px + env(safe-area-inset-bottom));
  display: grid; gap: 8px; width: min(520px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  pointer-events: auto; background: #1b2435; border: 1px solid var(--line2); color: var(--text);
  padding: 10px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font-size: 14.5px; transition: opacity .3s, transform .3s;
}
.toast.t-ok { border-color: rgba(34, 197, 94, .6); }
.toast.t-bad { border-color: rgba(239, 68, 68, .75); background: #2a1618; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- modal ---------- */
dialog.modal {
  padding: 0; border: 1px solid var(--line2); border-radius: 18px; background: var(--card); color: var(--text);
  width: min(560px, calc(100vw - 20px)); max-height: calc(100vh - 40px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
dialog.modal.wide { width: min(1000px, calc(100vw - 20px)); }
dialog::backdrop { background: rgba(3, 6, 12, .74); }
.modal-inner { padding: 16px; max-height: calc(100vh - 42px); overflow: auto; display: grid; gap: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h2 { font-size: 18px; }
.modal-body { display: grid; gap: 12px; }

/* ---------- wider screens ---------- */
@media (max-width: 379px) {
  .brand-name { display: none; }
}
@media (min-width: 600px) {
  .ap-big { grid-template-columns: repeat(3, 1fr); }
  .ap-actions { grid-template-columns: 1fr 1fr; }
  .qr-actions { grid-template-columns: 1fr 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 959px) {
  /* phones/tablets: the header scrolls away; the bottom tab bar stays */
  .top { position: static; }
}
@media (max-width: 599px) {
  .tools { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .tools .btn.tool { flex-direction: column; gap: 4px; min-height: 62px; padding: 6px 4px; font-size: 13px; }
  .send { width: 100%; margin-left: 0; }
  dialog.modal {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0;
    max-height: calc(100dvh - 24px);
  }
  .modal-inner { padding-bottom: calc(16px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 26px); }
  .ap-actions .btn { min-height: 52px; }
}
@media (min-width: 960px) {
  .top { padding-left: 20px; padding-right: 20px; }
  .signout { display: inline-flex; }
  .top-tabs { display: flex; gap: 4px; }
  .top-tabs .tab { flex-direction: row; gap: 6px; min-height: 40px; padding: 6px 12px; border-radius: 10px; font-size: 14px; }
  .top-tabs .tab.on { background: rgba(229, 231, 235, .08); }
  .top-tabs .tab .badge { position: static; margin-left: 2px; }
  .top-row.second { justify-content: space-between; }
  .bottom-tabs { display: none; }
  .main { padding: 18px 20px 32px; }
  .view-home:not([hidden]) { display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); gap: 20px; align-items: start; }
  .col-right { position: sticky; top: 112px; max-height: calc(100vh - 128px); overflow-y: auto; border-radius: var(--radius); }
  .detail-empty {
    display: grid; justify-items: center; align-content: center; gap: 10px; min-height: 320px; text-align: center;
    border: 1px dashed var(--line2); border-radius: var(--radius); color: var(--muted); padding: 24px;
  }
  .detail:not([hidden]) {
    position: static; inset: auto; z-index: auto; overflow: visible; padding: 16px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  }
  body.detail-open { overflow: auto; }
  .detail .back { display: none; }
  .toasts { bottom: 20px; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .spin { border-top-color: var(--muted); }
  .bars i { height: 10px; }
}

/* ---------- round 2: emergency stop, outcomes, passkeys, pilot scoreboard ---------- */
.pause-banner { margin: 0 0 12px; font-size: 15px; }
.pause-reason { color: #fecaca; word-break: break-word; }

/* "Did this do what you wanted?" — selection is not a status, so it gets no status hue */
.outcome { display: grid; gap: 10px; }
.outcome .card-head { margin-bottom: 0; }
.outcome .card-head h3 { margin: 0; }
.oc-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.oc-btn { min-height: 52px; font-size: 16px; }
.oc-btn.on { border-color: var(--text); background: rgba(229, 231, 235, .12); }
.oc-emoji { font-size: 20px; line-height: 1; filter: grayscale(1); } /* emoji colour would read as a status hue */

/* emergency stop */
.estop { display: grid; gap: 10px; margin-bottom: 12px; }
.estop-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.estop-head strong { font-size: 17px; }
.estop.on { background: rgba(239, 68, 68, .06); }
.estop-reason { white-space: pre-wrap; word-break: break-word; }

/* passkeys */
.pk-box { display: grid; gap: 10px; }
.pk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pk-item { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 8px 10px; }
.pk-text { display: grid; min-width: 0; flex: 1 1 auto; }
.pk-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-nudge a { color: var(--text); }

/* pilot scoreboard: stat tiles are label + value (+ sub-line); colour lives only on status chips */
.scoreboard { gap: 14px; }
.gng-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gng-count { font-size: 30px; font-weight: 750; line-height: 1.1; }
.gng { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gng-row { display: flex; align-items: flex-start; gap: 10px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; }
.gng-row .chip { margin-top: 1px; }
.gng-text { display: grid; gap: 2px; min-width: 0; }
.kpi-group h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.kpi-row { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.kpi { background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; align-content: start; }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 650; line-height: 1.2; color: var(--text); word-break: break-word; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi .chip { justify-self: start; margin-top: 4px; }
.breakdown { margin: -4px 0 0; }
.tests { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.test-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
