@font-face{font-family:"Roboto";font-weight:300;font-display:swap;src:url("../../assets/fonts/roboto-300.woff2") format("woff2"),url("../../assets/fonts/roboto-300.woff") format("woff")}
@font-face{font-family:"Roboto";font-weight:400;font-display:swap;src:url("../../assets/fonts/roboto-400.woff2") format("woff2"),url("../../assets/fonts/roboto-400.woff") format("woff")}
@font-face{font-family:"Roboto";font-weight:700;font-display:swap;src:url("../../assets/fonts/roboto-700.woff2") format("woff2"),url("../../assets/fonts/roboto-700.woff") format("woff")}
/* MAESTRO simulated demo: styles. System fonts only; light and dark themes from tokens. */

:root {
  --navy: #071D49;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F1F3FF;
  --surface-3: #E5E9FB;
  --ink: #071D49;
  --text: #1B2850;
  --muted: #4E5A79;
  --border: #D8DDF1;
  --border-strong: #B4BEDF;
  --primary: #0066F5;
  --primary-ink: #FFFFFF;
  --primary-soft: #F0F5FF;
  --ai: #8A2ECC;
  --ai-soft: #F4EBFC;
  --ok: #338700;
  --ok-soft: #EBF6E3;
  --warn: #BB5A00;
  --warn-soft: #FFF2E4;
  --err: #CF451C;
  --err-soft: #FDEDE8;
  --code-bg: #0E1630;
  --code-ink: #E7EAF6;
  --code-key: #F08BD1;
  --code-str: #F3D27A;
  --code-num: #8FD3FF;
  --banner-bg: #071D49;
  --banner-ink: #FFFFFF;
  --pill-bg: #1D2440;
  --pill-ink: #EEF1FF;
  --scrim: rgba(7, 29, 73, .45);
  --shadow: 0 1px 2px rgba(7, 29, 73, .06), 0 8px 24px rgba(7, 29, 73, .10);
  --radius: 12px;
  --font: "Roboto",system-ui,-apple-system,"Segoe UI","Helvetica Neue",Arial,sans-serif;
  --mono: "Roboto",system-ui,-apple-system,"Segoe UI","Helvetica Neue",Arial,sans-serif;
  --sb-w: 268px;
  --tasks-w: 300px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1430; --surface: #0F1B3D; --surface-2: #15234D; --surface-3: #1C2C5C;
    --ink: #EFF2FF; --text: #D5DCF1; --muted: #A6B1CE; --border: #263868; --border-strong: #3B5090;
    --primary: #5C9DFF; --primary-ink: #071D49; --primary-soft: #16305F;
    --ai: #BB86F2; --ai-soft: #2A1E4E;
    --ok: #7DC657; --ok-soft: #18321F; --warn: #F2A55E; --warn-soft: #3A2815; --err: #FF8867; --err-soft: #3E1F19;
    --code-bg: #060C20; --banner-bg: #18285A; --pill-bg: #E7EBFA; --pill-ink: #071D49;
    --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1430; --surface: #0F1B3D; --surface-2: #15234D; --surface-3: #1C2C5C;
  --ink: #EFF2FF; --text: #D5DCF1; --muted: #A6B1CE; --border: #263868; --border-strong: #3B5090;
  --primary: #5C9DFF; --primary-ink: #071D49; --primary-soft: #16305F;
  --ai: #BB86F2; --ai-soft: #2A1E4E;
  --ok: #7DC657; --ok-soft: #18321F; --warn: #F2A55E; --warn-soft: #3A2815; --err: #FF8867; --err-soft: #3E1F19;
  --code-bg: #060C20; --banner-bg: #18285A; --pill-bg: #E7EBFA; --pill-ink: #071D49;
  --scrim: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ── Base ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50; padding: 8px 12px;
  background: var(--primary); color: var(--primary-ink); border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 8px; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }
.noscript { padding: 16px; text-align: center; }

/* Icons drawn as strokes */
.icon-btn svg, .sb-new svg, .send-btn svg, .jump svg, .mini svg, .chip-ico svg, .mode svg, .starter svg {
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Banner ─────────────────────────────────────────────────────────── */

.banner {
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px;
  padding: 6px 16px;
  background: var(--banner-bg); color: var(--banner-ink);
  font-size: 12.5px; line-height: 1.4; text-align: center;
}
.banner-link { color: var(--banner-ink); font-weight: 600; text-underline-offset: 2px; }
.banner-link:focus-visible { outline-color: #fff; }

/* ── Top bar ────────────────────────────────────────────────────────── */

.topbar {
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; margin-left: 6px; }
.logo { width: 28px; height: 28px; flex: none; }
.logo-bg { fill: var(--navy); }
:root[data-theme="dark"] .logo-bg { fill: #24357A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-bg { fill: #24357A; } }
.logo-m { fill: none; stroke: #FFFFFF; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.logo-n { fill: #8FB8FF; }
.logo-c { fill: #C79BF5; }
.brand-name { font-weight: 700; letter-spacing: .08em; color: var(--ink); font-size: 15px; }
.brand-tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ai); background: var(--ai-soft); border-radius: 999px; padding: 2px 8px;
}
.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.sm svg { width: 17px; height: 17px; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

.modes { min-width: 0; display: flex; justify-content: center; }
.modes-scroll {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin;
  padding: 2px; max-width: 100%;
}
.mode {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13.5px; white-space: nowrap;
}
.mode svg { width: 16px; height: 16px; }
.mode:hover { border-color: var(--border-strong); background: var(--surface-2); }
.mode[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--ink); font-weight: 600; }
.mode[aria-pressed="true"] svg { color: var(--primary); }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 420px; padding: 6px 12px;
  border: 0; border-radius: 16px;
  background: var(--pill-bg); color: var(--pill-ink);
  font: 11px/1.35 var(--mono); text-align: left;
}
.sp-dot { width: 8px; height: 8px; border-radius: 50%; background: #4CC26A; flex: none; box-shadow: 0 0 0 2px rgba(76, 194, 106, .25); }
.status-pill[data-state="probing"] .sp-dot { background: #F2A55E; box-shadow: 0 0 0 2px rgba(242, 165, 94, .3); animation: blink 1s ease-in-out infinite; }
.sp-short { display: none; }
.graph-btn { position: relative; }
.graph-pct {
  position: absolute; right: -4px; top: -2px; min-width: 22px; padding: 0 4px;
  border-radius: 999px; background: var(--ai); color: var(--primary-ink);
  font: 600 10px/16px var(--mono); text-align: center;
}

/* ── Shell ──────────────────────────────────────────────────────────── */

.shell {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 0 minmax(0, 1fr) var(--tasks-w);
  grid-template-rows: minmax(0, 1fr);
  position: relative;
}
.shell.sb-open { grid-template-columns: var(--sb-w) minmax(0, 1fr) var(--tasks-w); }
/* Explicit placement: a fixed-position sidebar or task panel must not shift the chat column */
.sidebar { grid-column: 1; grid-row: 1; }
.chat { grid-column: 2; grid-row: 1; }
.tasks { grid-column: 3; grid-row: 1; }

/* Sidebar */
.sidebar {
  min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border-right: 1px solid var(--border);
  padding: 12px 10px; visibility: hidden;
}
.shell.sb-open .sidebar { visibility: visible; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.sb-title { font-size: 14px; margin: 0; }
.sb-new {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-weight: 600;
}
.sb-new svg { width: 18px; height: 18px; }
.sb-new:hover { border-color: var(--primary); }
.history { list-style: none; margin: 4px 0 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.history li { display: flex; align-items: stretch; gap: 2px; border-radius: 10px; }
.history li:hover, .history li.active { background: var(--surface-3); }
.h-open {
  flex: 1; min-width: 0; text-align: left; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 10px; color: var(--text);
}
.h-title { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.h-meta { display: block; font-size: 11.5px; color: var(--muted); }
.h-del { opacity: .55; }
.history li:hover .h-del, .h-del:focus-visible { opacity: 1; }
.sb-empty { font-size: 13px; color: var(--muted); padding: 4px 6px; margin: 0; }
.sb-foot { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.sb-note { margin: 0; font-size: 12px; color: var(--muted); }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 19; }

/* ── Chat column ────────────────────────────────────────────────────── */

.chat { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 16px 10px; }
.thread-inner { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.jump {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 132px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.jump svg { width: 18px; height: 18px; }

.composer {
  flex: none; width: calc(100% - 32px); max-width: 860px; margin: 0 auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px;
  padding: 10px 10px 8px 14px;
}
.composer:focus-within { border-color: var(--primary); }
.composer textarea {
  display: block; width: 100%; resize: none; border: 0; outline: none; background: transparent;
  padding: 4px 2px; max-height: 180px; min-height: 26px; line-height: 1.5; color: var(--ink);
}
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: nowrap; min-width: 0; }
.bar-spacer { flex: 1; }
.mode-chip {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 auto;
  padding: 3px 4px 3px 10px; border-radius: 999px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--ink);
}
.mode-chip > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-chip > span:first-child, .mode-chip .chip-x { flex: none; }
.mode-chip.auto { padding-right: 10px; color: var(--muted); }
.mode-chip svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mode-chip .chip-x { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.mode-chip .chip-x:hover { background: var(--surface-3); color: var(--ink); }
.mode-chip .chip-x svg { width: 13px; height: 13px; }
.tasks-toggle {
  display: none; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
}
.tt-count { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; flex: none;
  display: grid; place-items: center; background: var(--primary); color: var(--primary-ink);
}
.send-btn svg { width: 19px; height: 19px; }
.send-btn:disabled { opacity: .45; cursor: default; }
.send-btn .i-stop { display: none; fill: currentColor; stroke: none; }
.send-btn.is-stop { background: var(--err); color: var(--primary-ink); }
.send-btn.is-stop .i-send { display: none; }
.send-btn.is-stop .i-stop { display: block; }
.composer-hint { margin: 6px auto 8px; font-size: 11.5px; color: var(--muted); text-align: center; padding: 0 16px; }

/* ── Welcome ────────────────────────────────────────────────────────── */

.welcome { text-align: center; padding: 6vh 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.welcome .logo { width: 64px; height: 64px; }
.welcome h2 { margin: 4px 0 0; font-size: 26px; letter-spacing: .08em; }
.welcome-sub { margin: 0; color: var(--muted); max-width: 560px; }
.welcome-mode { margin: 10px 0 0; max-width: 620px; font-size: 14px; }
.welcome-mode strong { color: var(--ink); }
.starters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; max-width: 760px; }
.starter {
  display: inline-flex; align-items: center; gap: 8px; text-align: left;
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-size: 14px;
}
.starter svg { width: 16px; height: 16px; color: var(--ai); flex: none; }
.starter:hover { border-color: var(--ai); background: var(--ai-soft); }
.welcome-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); max-width: 560px; }
.welcome-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }

/* ── Messages ───────────────────────────────────────────────────────── */

.msg { display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: min(640px, 88%); background: var(--surface-2); border-radius: 18px;
  padding: 10px 16px; color: var(--ink); overflow-wrap: anywhere;
}
.bubble .cmd { display: block; font-weight: 700; color: var(--primary); font-size: 14px; margin-bottom: 2px; }
.bubble p { margin: 0; white-space: pre-wrap; }
.avatar { flex: none; width: 30px; height: 30px; margin-top: 2px; }
.avatar .logo { width: 30px; height: 30px; }
.msg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.msg.notice .msg-main { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 12px; padding: 10px 14px; }
.msg.notice p { margin: 0; }

/* Steps (agent trace) */
.steps { display: flex; flex-direction: column; gap: 2px; }
.hide-steps .steps { display: none; }
.steps-note { display: none; font-size: 12.5px; color: var(--muted); margin: 0; }
.hide-steps .steps-note { display: block; }
.step > summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 4px 6px; border-radius: 8px; color: var(--muted); font-size: 14px; width: fit-content; max-width: 100%;
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { background: var(--surface-2); color: var(--ink); }
.st-title { overflow-wrap: anywhere; }
.st-chev { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.step[open] > summary .st-chev { transform: rotate(180deg); }
.st-ico { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.st-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.step[data-status="running"] > summary .st-ico { color: var(--ai); }
.step[data-status="running"] > summary .st-ico svg { animation: spin 1s linear infinite; }
.step[data-status="complete"] > summary .st-ico { color: var(--ok); }
.step[data-status="error"] > summary, .step[data-status="error"] > summary .st-ico { color: var(--err); }
.step[data-status="stopped"] > summary .st-ico { color: var(--warn); }
.step[data-status="running"] > summary .st-title { color: var(--ink); }
.st-meta { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.st-children { margin: 2px 0 6px 13px; padding-left: 14px; border-left: 2px solid var(--ai); display: flex; flex-direction: column; gap: 2px; }
.st-body { margin: 2px 0 8px 13px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; color: var(--text); }
.st-body p { margin: 0; }
.st-foot { margin-top: 4px; font-size: 12px; font-style: italic; color: var(--muted); }
.st-content { margin: 4px 0 8px 22px; display: flex; flex-direction: column; gap: 8px; }
.st-note { margin: 2px 0 2px 4px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; }
.st-note::before { content: "↳"; color: var(--ai); }
.st-note.tone-warn { color: var(--warn); }
.st-note.tone-warn::before { color: var(--warn); }
.st-note.tone-ok::before { content: "✓"; color: var(--ok); }
.st-note.tone-reflect::before { content: "⟲"; color: var(--ai); }

.route-card dl { margin: 4px 0 8px 22px; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.route-card dt { color: var(--muted); }
.route-card dd { margin: 0; color: var(--text); }
.route-card > summary .st-ico { color: var(--ai); }

.code { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--muted); }
.code pre {
  margin: 0; padding: 10px 12px; overflow-x: auto; background: var(--code-bg); color: var(--code-ink);
  font: 12.5px/1.5 var(--mono); white-space: pre;
}
.j-key { color: var(--code-key); }
.j-str { color: var(--code-str); }
.j-num, .j-bool { color: var(--code-num); }
.tool-out {
  margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--surface-2);
  font: 12.5px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
}
.tool-out.is-error { background: var(--err-soft); color: var(--ink); border: 1px solid var(--err); border-left-width: 4px; }
.mini {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12px;
}
.mini:hover { color: var(--ink); border-color: var(--border-strong); }
.mini svg { width: 14px; height: 14px; }
.mini[aria-pressed="true"] { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

/* Gate and judge cards */
.gate-card, .judge-card { margin: 4px 0 6px 4px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); font-size: 13.5px; }
.card-title { margin: 0 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.gate-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.gate-mark { width: 18px; text-align: center; font-weight: 700; }
.gate-row[data-s="present"] .gate-mark { color: var(--ok); }
.gate-row[data-s="missing"] .gate-mark { color: var(--err); }
.gate-row[data-s="optional"] .gate-mark { color: var(--muted); }
.gate-req { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
.verdict { display: inline-block; margin-top: 6px; font-weight: 700; font-family: var(--mono); font-size: 12.5px; padding: 1px 8px; border-radius: 6px; border: 1px solid currentColor; background: transparent; }
.verdict.pass { color: var(--ok); }
.verdict.fail { color: var(--err); }
.verdict-text { margin: 6px 0 0; color: var(--text); }
.score-row { display: grid; grid-template-columns: minmax(120px, 210px) 1fr 34px; align-items: center; gap: 8px; padding: 2px 0; }
.score-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.score-bar span { display: block; height: 100%; border-radius: 4px; background: var(--ai); }
.score-row[data-low="1"] .score-bar span { background: var(--warn); }
.score-val { font-family: var(--mono); font-size: 12px; text-align: right; }
.defects { margin: 6px 0 0; padding-left: 20px; color: var(--err); }

/* ── Answer (report) ───────────────────────────────────────────────── */

.answer { color: var(--text); overflow-wrap: break-word; }
.answer:empty { display: none; }
.rep-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }
.rep-title { margin: 0; font-size: 19px; }
.tag { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag.t-success { color: var(--ok); background: transparent; border-color: var(--ok); }
.tag.t-error { color: var(--err); background: transparent; border-color: var(--err); }
.tag.t-sample { color: var(--ai); background: var(--ai-soft); border-color: transparent; }
.answer h3 { font-size: 16.5px; margin: 20px 0 6px; }
.answer h4 { font-size: 14.5px; margin: 14px 0 4px; }
.answer p { margin: 6px 0; }
.answer ul, .answer ol { margin: 6px 0; padding-left: 22px; }
.answer li { margin: 3px 0; }
.answer strong { color: var(--ink); }
.rep-meta { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; }
.cite {
  display: inline-block; min-width: 20px; padding: 0 5px; margin: 0 1px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--primary-soft); color: var(--primary);
  font: 600 11px/17px var(--mono); vertical-align: 1px; text-align: center;
}
.cite:hover { border-color: var(--primary); }
.callout { margin: 8px 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; }
.callout.c-error { border-color: var(--err); background: var(--err-soft); color: var(--text); }
.callout.c-warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.c-info { border-color: var(--ai); background: var(--ai-soft); }
.quote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--ai); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.quote p { margin: 0; font-style: italic; color: var(--ink); }
.quote .by { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); font-style: normal; }
.tbl-wrap { overflow-x: auto; margin: 8px 0; border: 1px solid var(--border); border-radius: 10px; }
.answer table { border-collapse: collapse; width: 100%; font-size: 13px; }
.answer th, .answer td { padding: 6px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.answer th { background: var(--surface-2); color: var(--ink); font-weight: 600; white-space: nowrap; }
.answer td.r, .answer th.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.answer tfoot td { font-weight: 700; color: var(--ink); background: var(--surface-2); border-bottom: 0; }
.answer tbody tr:last-child td { border-bottom: 0; }
.tbl-note { margin: -2px 0 8px; font-size: 12px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 8px 0; }
.kpi { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.kpi b { display: block; font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi[data-tone="warning"] b { color: var(--warn); }
.kpi[data-tone="success"] b { color: var(--ok); }
.cites { margin: 6px 0; padding-left: 0; list-style: none; font-size: 12.5px; }
.cites li { display: flex; gap: 8px; padding: 3px 0; align-items: baseline; }
.cites button { flex: none; }
.cites span { color: var(--muted); }

/* Charts */
.chart { margin: 10px 0; }
.chart figcaption { font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.chart-scroll { overflow-x: auto; }
.chart svg { width: 100%; height: auto; }
.chart-scroll svg { min-width: 560px; }
.ch-lbl { fill: var(--text); font-size: 12px; font-family: var(--font); }
.ch-val { fill: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.ch-axis { stroke: var(--border); stroke-width: 1; }
.ch-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.ch-track { fill: var(--surface-2); }
.t-primary { fill: var(--primary); stroke: var(--primary); }
.t-ai { fill: var(--ai); stroke: var(--ai); }
.t-success { fill: var(--ok); stroke: var(--ok); }
.t-warning { fill: var(--warn); stroke: var(--warn); }
.t-error { fill: var(--err); stroke: var(--err); }
.t-muted { fill: var(--border-strong); stroke: var(--border-strong); }
rect.t-primary, rect.t-ai, rect.t-success, rect.t-warning, rect.t-error, rect.t-muted { stroke: none; }
.ch-line { fill: none; stroke-width: 2.4; }
.ch-line.dashed { stroke-dasharray: 6 4; }
.ch-dot { stroke: var(--surface); stroke-width: 1.5; }
.ch-today { stroke: var(--err); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ch-lane { fill: var(--surface-2); }
.tl-done { stroke: none; }
.tl-exp { fill: var(--surface); stroke-width: 2.2; }
.tl-spec { fill: var(--surface); stroke-width: 2; stroke-dasharray: 2 2; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.t-primary { background: var(--primary); } .sw.t-ai { background: var(--ai); } .sw.t-success { background: var(--ok); }
.sw.t-warning { background: var(--warn); } .sw.t-error { background: var(--err); } .sw.t-muted { background: var(--border-strong); }
.sw.dash { background: transparent; border: 2px dashed var(--warn); }

/* Exports and actions */
.exports { font-size: 13.5px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.exports:empty { display: none; }
.exports p { margin: 0; flex: 1 1 260px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions:empty { display: none; }
.suggests { display: flex; flex-wrap: wrap; gap: 6px; }
.suggests:empty { display: none; }
.suggest { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--ai); background: var(--ai-soft); color: var(--ink); font-size: 13px; }
.suggest:hover { background: var(--surface); }
.stopped-note { margin: 0; font-size: 13px; color: var(--warn); }
.caret::after { content: ""; display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px; background: var(--ai); animation: blink 1s steps(2) infinite; }

/* ── Tasks panel ───────────────────────────────────────────────────── */

.tasks {
  min-width: 0; border-left: 1px solid var(--border); background: var(--surface);
  padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
}
.tasks-head { display: flex; align-items: center; gap: 8px; }
.tasks-head h2 { margin: 0; font-size: 15px; flex: 1; }
.tasks-close { display: none; }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge[data-tone="running"] { color: var(--ai); background: var(--ai-soft); border-color: transparent; }
.badge[data-tone="done"] { color: var(--ok); background: transparent; border-color: var(--ok); }
.badge[data-tone="failed"], .badge[data-tone="stopped"] { color: var(--warn); background: transparent; border-color: var(--warn); }
.tasks-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; counter-reset: task; }
.tasks-list li { display: flex; align-items: center; gap: 8px; padding: 5px 4px; font-size: 13.5px; color: var(--muted); counter-increment: task; }
.tasks-list li::before { content: counter(task); width: 16px; text-align: right; font: 11px var(--mono); color: var(--muted); }
.tk-ico { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.tk-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tasks-list li[data-s="running"] { color: var(--ink); font-weight: 600; }
.tasks-list li[data-s="running"] .tk-ico { color: var(--ai); }
.tasks-list li[data-s="running"] .tk-ico svg { animation: spin 1s linear infinite; }
.tasks-list li[data-s="done"] { color: var(--ink); }
.tasks-list li[data-s="done"] .tk-ico { color: var(--ok); }
.tasks-list li[data-s="failed"] .tk-ico, .tasks-list li[data-s="failed"] { color: var(--err); }
.tasks-list li[data-s="stopped"] .tk-ico { color: var(--warn); }
.tasks-empty { margin: 0; font-size: 13px; color: var(--muted); }
.tasks-graph { align-self: flex-start; }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger[data-armed="1"] { background: var(--err); color: var(--primary-ink); }

/* ── Dialogs ───────────────────────────────────────────────────────── */

.dlg {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dlg::backdrop { background: var(--scrim); }
.dlg[open] { display: flex; flex-direction: column; }
.dlg-form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px 20px; }
.dlg-head h2 { margin: 0; font-size: 17px; flex: 1; }
.dlg-body { padding: 4px 20px 12px; overflow-y: auto; min-height: 0; flex: 1; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.field { margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field label:not(.check), .field legend, .field-label { display: block; font-weight: 600; font-size: 14px; color: var(--ink); margin-bottom: 6px; padding: 0; }
.field select { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.dlg-wide { width: min(1180px, calc(100vw - 24px)); height: min(820px, calc(100dvh - 24px)); }
.graph-head { flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.graph-head h2 { flex: 0 1 auto; }
.graph-progress { flex: 1 1 120px; min-width: 80px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.graph-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--ai)); transition: width .4s ease; }
.graph-count, .graph-time { font-size: 12px; color: var(--muted); }
.graph-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 280px; }
.graph-canvas { overflow: auto; padding: 10px; background: var(--bg); }
.graph-canvas svg { width: 100%; min-width: 760px; height: auto; }
.graph-side { border-left: 1px solid var(--border); padding: 10px 14px; overflow-y: auto; font-size: 13px; }
.graph-side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 6px; }
.graph-steps, .graph-log { list-style: none; margin: 0 0 8px; padding: 0; }
.graph-steps li { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--muted); }
.graph-steps li .gs-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; }
.graph-steps li[data-s="running"] { color: var(--ai); font-weight: 600; }
.graph-steps li[data-s="running"] .gs-dot { border-color: var(--ai); background: var(--ai); animation: blink 1s ease-in-out infinite; }
.graph-steps li[data-s="complete"] { color: var(--ok); }
.graph-steps li[data-s="complete"] .gs-dot { border-color: var(--ok); background: var(--ok); }
.graph-steps li[data-s="error"], .graph-steps li[data-s="stopped"] { color: var(--err); }
.graph-steps li[data-s="error"] .gs-dot, .graph-steps li[data-s="stopped"] .gs-dot { border-color: var(--err); background: var(--err); }
.graph-steps li[data-s="skipped"] { opacity: .5; text-decoration: line-through; }
.graph-log li { font: 11.5px/1.45 var(--mono); color: var(--muted); padding: 2px 0; display: flex; gap: 8px; }
.graph-log li b { font-weight: 400; color: var(--border-strong); flex: none; }
.graph-log li[data-tone="error"] { color: var(--err); }
.graph-log li[data-tone="warn"] { color: var(--warn); }
.graph-log li[data-tone="tier"] { color: var(--ai); }
.graph-foot { margin: 0; padding: 8px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }

/* Graph SVG */
.gn rect { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.3; }
.gn[data-kind="llm"] rect { fill: var(--ai-soft); }
.gn[data-kind="det"] rect { fill: var(--primary-soft); }
.gn[data-kind="out"] rect { fill: var(--ok-soft); }
.gn[data-kind="tool"] rect { fill: var(--surface); }
.gn[data-kind="retry"] rect { stroke-dasharray: 5 4; }
.gn text { fill: var(--ink); font-family: var(--font); }
.gn .g-lbl { font-size: 12.5px; font-weight: 600; }
.gn .g-sub { font-size: 10px; fill: var(--muted); font-family: var(--mono); }
.gn[data-kind="tool"] .g-lbl { font-size: 10.5px; font-weight: 500; }
.gn .g-st { font-size: 12px; font-weight: 700; }
.gn[data-status="running"] rect { stroke: var(--ai); stroke-width: 2.6; animation: pulse 1.2s ease-in-out infinite; }
.gn[data-status="running"] .g-st { fill: var(--ai); }
.gn[data-status="complete"] rect { stroke: var(--ok); stroke-width: 2; }
.gn[data-status="complete"] .g-st { fill: var(--ok); }
.gn[data-status="error"] rect, .gn[data-status="stopped"] rect { stroke: var(--err); stroke-width: 2; fill: var(--err-soft); }
.gn[data-status="error"] .g-st, .gn[data-status="stopped"] .g-st { fill: var(--err); }
.gn[data-status="skipped"] { opacity: .32; }
.gn[data-status="skipped"] rect { stroke-dasharray: 4 3; }
.gn[data-status="pending"] rect { stroke: var(--muted); }
.ge { fill: none; stroke: var(--border-strong); stroke-width: 1.4; }
.ge.dot { stroke-dasharray: 2 3; }
.ge.dash { stroke-dasharray: 6 5; }
.ge[data-status="active"] { stroke: var(--ai); stroke-width: 2; stroke-dasharray: 6 6; animation: dash 1s linear infinite; }
.ge[data-status="done"] { stroke: var(--ok); stroke-width: 1.8; }
.ge[data-status="skipped"] { opacity: .3; }
.g-tier { font: 600 10.5px var(--mono); fill: var(--muted); letter-spacing: .06em; }
.g-edge-lbl { font: 600 10px var(--mono); fill: var(--muted); }
.g-legend text { font-size: 11px; fill: var(--text); font-family: var(--font); }

/* ── Toast ─────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 60;
  padding: 9px 16px; border-radius: 10px; background: var(--ink); color: var(--bg);
  font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Motion ────────────────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes pulse { 50% { stroke-opacity: .45; } }
@keyframes dash { to { stroke-dashoffset: -24; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (min-width: 1101px) {
  .shell:not(.sb-open) .sidebar { padding: 0; border: 0; }
}
@media (max-width: 1600px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .modes { grid-column: 1 / -1; grid-row: 2; }
  .tb-right { justify-content: flex-end; }
}
@media (max-width: 1100px) {
  .shell, .shell.sb-open { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .shell.sb-open .sidebar, .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 20;
    transform: translateX(-102%); transition: transform .2s ease; visibility: hidden; box-shadow: var(--shadow);
  }
  .shell.sb-open .sidebar { transform: none; visibility: visible; }
  .tasks {
    position: fixed; right: 12px; bottom: 150px; width: min(320px, calc(100vw - 24px)); max-height: 50vh; z-index: 15;
    border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); display: none;
  }
  .tasks.open { display: flex; }
  .tasks-close { display: inline-grid; }
  .tasks-toggle { display: inline-flex; }
  .status-pill { max-width: 280px; }
  .sp-long { display: none; }
  .sp-short { display: inline; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .topbar { padding: 6px 8px; gap: 6px; }
  .brand { margin-left: 2px; }
  .brand-tag { display: none; }
  .thread { padding: 14px 12px 8px; }
  .composer { width: calc(100% - 20px); border-radius: 16px; }
  .msg { gap: 8px; }
  .avatar { display: none; }
  .bubble { max-width: 92%; }
  .st-children { margin-left: 6px; padding-left: 10px; }
  .st-body, .st-content { margin-left: 6px; }
  .route-card dl { grid-template-columns: 1fr; margin-left: 6px; }
  .route-card dt { margin-top: 4px; }
  .graph-body { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) auto; }
  .graph-side { border-left: 0; border-top: 1px solid var(--border); max-height: 34vh; }
  .composer-hint { display: none; }
  .jump { bottom: 104px; }
  .tasks { bottom: 120px; }
  .score-row { grid-template-columns: minmax(100px, 1fr) 70px 30px; }
}
@media (max-width: 480px) {
  .brand-name { display: none; }
  .sp-short { display: none; }
  .status-pill { padding: 8px; }
  .icon-btn { width: 34px; height: 34px; }
  .mode { padding: 5px 10px; font-size: 13px; }
  .tasks-toggle { padding: 3px 8px; }
}
@media print {
  .banner, .topbar, .sidebar, .tasks, .composer, .composer-hint, .jump, .actions, .exports, .steps { display: none !important; }
  body { height: auto; overflow: visible; display: block; }
  .shell { display: block; }
  .thread { overflow: visible; }
}
