:root {
  --bg: #08090a;
  --bg-panel: #0d0e10;
  --bg-raised: #131417;
  --bg-hover: #1a1c20;
  --bg-active: #1f2227;
  --border: #23252a;
  --border-soft: #1a1c1f;
  --text: #e8e9ea;
  --text-dim: #8b8d92;
  --text-faint: #5c5f66;
  --accent: #5e6ad2;
  --accent-hover: #6e79dd;
  --critical: #f2555a;
  --high: #f28b46;
  --medium: #e2c541;
  --low: #5b9cf5;
  --info: #6b7280;
  --ok: #4cb782;
  --run: #5e6ad2;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: 320px; padding: 28px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 10px; display: flex; flex-direction: column; gap: 14px;
}
.login-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 16px;
}
.login-card h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.login-card .muted { color: var(--text-dim); font-size: 12px; margin-top: -10px; }
.login-error {
  color: var(--critical); font-size: 12px;
  background: rgba(242,85,90,.08); border: 1px solid rgba(242,85,90,.25);
  padding: 6px 9px; border-radius: var(--radius);
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 11px; color: var(--text-dim); font-weight: 500; }

input, select, textarea, button { font-family: inherit; font-size: 13px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 9px; outline: none; width: 100%;
  transition: border-color .12s, background .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); background: var(--bg-panel);
}
textarea { resize: vertical; min-height: 80px; font-family: var(--mono); font-size: 12px; line-height: 1.55; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-raised); color: var(--text);
  cursor: pointer; font-weight: 500; transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: #2c2f35; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--critical); border-color: rgba(242,85,90,.3); background: transparent; }
.btn-danger:hover { background: rgba(242,85,90,.1); }
.btn-sm { padding: 4px 8px; font-size: 12px; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 290px 1fr; height: 100vh; overflow: hidden; }

.sidebar {
  background: var(--bg-panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.side-head {
  padding: 14px 14px 10px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.side-head .login-mark { width: 24px; height: 24px; font-size: 12px; border-radius: 6px; }
.side-head h1 { font-size: 13px; font-weight: 600; flex: 1; letter-spacing: -0.01em; }
.side-head .count {
  font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}

.side-actions { padding: 10px 10px 6px; display: flex; gap: 6px; }
.side-actions .btn { flex: 1; }

.search-wrap { padding: 4px 10px 8px; }
.search-wrap input { font-size: 12px; padding: 6px 9px; }

.run-list { flex: 1; overflow-y: auto; padding: 0 6px 12px; }

/* Runs are filed under a status folder. The header is a button so the folder
   can be folded away; its counts follow the live stream. */
.run-group { margin-top: 6px; }
.run-group:first-child { margin-top: 2px; }
.run-group-head {
  width: 100%; display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; background: transparent; border: 0; border-radius: var(--radius);
  color: var(--text-faint); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; cursor: pointer; text-align: left;
}
.run-group-head:hover { color: var(--text-dim); background: var(--bg-hover); }
.run-group-head .chev { width: 10px; flex: none; font-size: 9px; }
.run-group-head .run-group-label { flex: 1; min-width: 0; }
.run-group-head .run-group-count {
  flex: none; font-size: 10px; font-weight: 500; letter-spacing: 0;
  color: var(--text-faint); background: var(--bg-raised);
  border: 1px solid var(--border-soft); border-radius: 999px; padding: 0 6px;
}
.run-group.collapsed .run-group-body { display: none; }

.run-item {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 8px 9px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid transparent; transition: background .1s;
}
/* A row appears only when the stream adds one, so it can animate in freely;
   existing rows are patched in place and never re-enter. */
.run-item.enter { animation: rowin .24s cubic-bezier(.22, .8, .3, 1) both; }
@keyframes rowin {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}
.run-item:hover { background: var(--bg-hover); }
.run-item.active { background: var(--bg-active); border-color: var(--border); }
.run-item .dot { margin-top: 5px; flex-shrink: 0; }
.run-body { min-width: 0; flex: 1; }
.run-name {
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.005em;
}
.run-meta {
  font-size: 11px; color: var(--text-faint); display: flex;
  gap: 7px; align-items: center; margin-top: 2px; font-variant-numeric: tabular-nums;
}
/* Severity numbers keep the inline colour the renderer gives them. */
.run-meta .sev { display: flex; gap: 5px; }
.run-meta .sev span { color: inherit; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--info); flex-shrink: 0; }
.dot.completed { background: var(--ok); }
.dot.running   { background: var(--run); animation: pulse 1.8s ease-in-out infinite; }
.dot.failed    { background: var(--critical); }
.dot.stopped   { background: var(--medium); }
.dot.interrupted { background: var(--text-faint); }
.dot.stalled   { background: var(--medium); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.sys {
  padding: 10px 14px 11px; border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 7px;
}
.sys-row {
  display: grid; grid-template-columns: 34px 1fr 40px; align-items: center;
  gap: 8px; font-size: 11px; color: var(--text-dim);
}
.sys-row .v {
  text-align: right; color: var(--text); font-variant-numeric: tabular-nums;
}
.sys .bar { height: 4px; border-radius: 2px; background: var(--bg-active); overflow: hidden; }
.sys .bar > i {
  display: block; height: 100%; width: 0; border-radius: 2px;
  background: var(--ok); transition: width .45s ease, background .45s ease;
}
.sys-net {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.sys-net b { color: var(--text-dim); font-weight: 500; }

.side-foot {
  padding: 9px 14px; border-top: 1px solid var(--border-soft);
  font-size: 11px; color: var(--text-faint);
  display: flex; justify-content: space-between; align-items: center;
}

/* ------------------------------------------------------------------- main */
.main {
  display: flex; flex-direction: column; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
}
.main > .head, .main > .tabs { flex: 0 0 auto; }
.main > .pane { flex: 1 1 auto; min-height: 0; }
.empty {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: var(--text-faint);
}
.empty h2 { font-size: 15px; font-weight: 500; color: var(--text-dim); }

.head { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.head-top { display: flex; align-items: flex-start; gap: 12px; }
.head h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.head .sub { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.head-actions { margin-left: auto; display: flex; gap: 6px; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px; background: var(--border-soft);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  margin-top: 16px;
}
.stat { background: var(--bg-panel); padding: 10px 13px; }
.stat .k { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .v { font-size: 15px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.tabs {
  display: flex; gap: 2px; padding: 0 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.tab {
  padding: 10px 12px; font-size: 12.5px; color: var(--text-dim); cursor: pointer;
  border-bottom: 1.5px solid transparent; margin-bottom: -1px; font-weight: 500;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .badge {
  display: inline-block; margin-left: 5px; padding: 0 5px; border-radius: 8px;
  background: var(--bg-active); font-size: 10.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.pane { padding: 18px 24px 60px; }
.pane[hidden] { display: none; }

/* ---------------------------------------------------------------- timeline */
/* ChatGPT-style transcript. The pane owns the scroll so the follow logic has
   exactly one scroll container to reason about. */
.pane-timeline {
  padding: 0; display: flex; flex-direction: column;
  height: 100%; min-height: 0; position: relative;
}
.events {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 16px 24px 28px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain; scroll-behavior: auto;
  /* The pane pins itself to the bottom as nodes arrive. Anchor adjustment
     animates that pin into a visible crawl; Chrome still picks an anchor among
     the children when only the container opts out, so they opt out too. */
  overflow-anchor: none;
}
.events > * { overflow-anchor: none; }

/* One turn: the agent's prose, with the tool calls it issued nested below.
   The nesting is what makes a tool read as an action of that turn rather
   than as a message of its own. */
.turn { flex: 0 0 auto; max-width: 900px; }
/* Entrance runs only for nodes the stream actually inserts, never for a node
   the diff left in place: a permanently-animating class would make the pane
   twitch on every tick. */
.enter { animation: slidein .26s cubic-bezier(.22, .8, .3, 1) both; }
@keyframes slidein {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.turn-meta {
  display: flex; align-items: center; gap: 7px;
  margin: 0 0 5px 2px; font-size: 11px; color: var(--text-faint);
}
.bubble-avatar {
  width: 15px; height: 15px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 8px;
  background: rgba(94,106,210,.18); color: var(--accent);
}
.turn-agent { color: var(--text-dim); font-weight: 500; }
.turn-time { font-family: var(--mono); font-size: 10px; margin-left: auto; }

.turn-text {
  font-size: 13px; line-height: 1.62; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  padding: 9px 14px 11px; border-radius: 10px;
  border: 1px solid var(--border-soft); background: var(--bg-panel);
}
.turn-text p { margin: 0 0 8px; }
.turn-text p:last-child { margin-bottom: 0; }
.turn-text code {
  font-family: var(--mono); font-size: 11.5px;
  background: rgba(255,255,255,.05); padding: 1px 5px; border-radius: 4px;
}
.turn-text pre {
  font-family: var(--mono); font-size: 11.5px; overflow-x: auto;
  background: rgba(0,0,0,.35); padding: 8px 11px; border-radius: 6px; margin: 6px 0;
}
.turn-text pre code { background: none; padding: 0; }
.turn-text ul, .turn-text ol { margin: 6px 0; padding-left: 20px; }
.turn-text li { margin: 2px 0; }
.turn-input .turn-text {
  background: var(--bg-raised); border-color: var(--border);
  color: var(--text-dim); font-size: 12px; font-family: var(--mono);
}

/* Tool calls belonging to the turn above: indented, compact, secondary. */
.turn-tools {
  margin: 6px 0 0 18px; padding-left: 10px;
  border-left: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.tool-line {
  border-radius: 6px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border-soft);
}
.tool-head {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; cursor: pointer; user-select: none;
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
}
.tool-head:hover { background: var(--bg-hover); }
.tool-icon { color: var(--accent); font-size: 11px; width: 13px; text-align: center; flex: 0 0 auto; }
.tool-name { color: var(--text); font-weight: 500; flex: 0 0 auto; }
.tool-brief {
  color: var(--text-faint); font-size: 10.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1 1 auto; min-width: 0;
}
.tool-ok {
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 1px 5px; border-radius: 3px;
  margin-left: auto; flex: 0 0 auto;
}
.tool-ok.good { color: var(--ok); background: rgba(76,183,130,.12); }
.tool-ok.bad  { color: var(--critical); background: rgba(242,85,90,.12); }
.tool-pending { font-size: 10px; color: var(--accent); opacity: .8; margin-left: auto; }
.tool-time { font-size: 10px; color: var(--text-faint); flex: 0 0 auto; }
.tool-chev { color: var(--text-faint); font-size: 9px; transition: transform .14s; flex: 0 0 auto; }
.tool-line.open .tool-chev { transform: rotate(90deg); }
.tool-body { display: none; border-top: 1px solid var(--border-soft); }
.tool-line.open .tool-body { display: block; }
.tool-args, .tool-res {
  font-family: var(--mono); font-size: 11px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  padding: 8px 11px; max-height: 320px; overflow: auto;
}
.tool-args { color: var(--text-dim); background: rgba(255,255,255,.012); }
.tool-res-label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); padding: 7px 11px 0;
}
.tool-res { color: var(--text-dim); }

.virt-more {
  text-align: center; font-size: 11px; color: var(--text-faint);
  padding: 6px 0 10px; cursor: pointer; user-select: none;
}
.virt-more:hover { color: var(--text-dim); text-decoration: underline; }

.jump-bottom {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  font-size: 11.5px; font-weight: 500; padding: 6px 14px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); font-family: var(--sans);
}
.jump-bottom:hover { background: var(--accent-hover); }

.pulse {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint); margin-right: 5px; vertical-align: middle;
}
#liveInfo[data-on="1"] .pulse { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------------------------------------------------------------- findings */
.findings-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.findings-count { font-size: 11.5px; color: var(--text-faint); }
.findings-sort {
  display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 8px; padding: 2px 6px 2px 9px;
  background: var(--bg-panel);
}
.findings-sort > span {
  text-transform: uppercase; letter-spacing: .06em; font-size: 10px;
}
.findings-sort select {
  width: auto; padding: 3px 4px; font-size: 12px; color: var(--text);
  border: 0; background: transparent;
}
.findings-sort select:focus { background: var(--bg-raised); }
.findings-sort select:disabled { opacity: .55; }

.findings { display: flex; flex-direction: column; gap: 8px; }
.finding-group { display: flex; flex-direction: column; gap: 8px; }
.finding-group + .finding-group { margin-top: 8px; }
.finding-group-head { display: flex; align-items: center; gap: 8px; padding: 5px 2px 1px; }
.finding-type {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-dim);
}
.finding-group-count {
  margin-left: auto; font-size: 10.5px; color: var(--text-faint);
  background: var(--bg-raised); border: 1px solid var(--border-soft);
  border-radius: 999px; padding: 1px 7px;
}

.finding {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-panel); padding: 12px 14px;
}
.finding-head { display: flex; align-items: flex-start; gap: 10px; }
.finding h4 { font-size: 13.5px; font-weight: 600; flex: 1; letter-spacing: -0.01em; }
.finding .desc { color: var(--text-dim); font-size: 12.5px; margin-top: 6px; line-height: 1.6; }
.finding .tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.sev {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.sev-critical { color: var(--critical); background: rgba(242,85,90,.13); }
.sev-high     { color: var(--high); background: rgba(242,139,70,.13); }
.sev-medium   { color: var(--medium); background: rgba(226,197,65,.12); }
.sev-low      { color: var(--low); background: rgba(91,156,245,.13); }
.sev-info     { color: var(--info); background: rgba(107,114,128,.15); }

.tag {
  font-size: 11px; color: var(--text-faint); font-family: var(--mono);
  background: var(--bg-raised); padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border-soft);
}

/* ------------------------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint); font-weight: 600;
  padding: 7px 10px; border-bottom: 1px solid var(--border);
}
td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tr:hover td { background: var(--bg-panel); }

.outcome { font-family: var(--mono); font-size: 11.5px; }
.outcome-reported       { color: var(--critical); }
.outcome-no_issue_found { color: var(--ok); }
.outcome-ruled_out      { color: var(--text-faint); }
.outcome-needs_follow_up{ color: var(--medium); }
.outcome-not_applicable { color: var(--text-faint); }

/* ------------------------------------------------------------------- markdown */
.md {
  font-size: 13.5px; line-height: 1.75; max-width: 82ch;
  color: #d8d9db;
}
.md h1 { font-size: 21px; font-weight: 600; margin: 26px 0 12px; letter-spacing: -0.02em; color: var(--text); }
.md h2 { font-size: 16px; font-weight: 600; margin: 26px 0 10px; letter-spacing: -0.015em; color: var(--text);
         padding-bottom: 6px; border-bottom: 1px solid var(--border-soft); }
.md h3 { font-size: 14px; font-weight: 600; margin: 20px 0 8px; color: var(--text); }
.md h4 { font-size: 13px; font-weight: 600; margin: 16px 0 6px; color: var(--text-dim); }
.md p  { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0 10px 22px; }
.md li { margin: 4px 0; }
.md a { color: var(--low); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md code {
  font-family: var(--mono); font-size: 12px; background: var(--bg-raised);
  padding: 1.5px 5px; border-radius: 4px; border: 1px solid var(--border-soft);
  color: #d4a27f;
}
.md pre {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 12px 0;
}
.md pre code { background: none; border: none; padding: 0; color: #c9cacc; font-size: 12px; line-height: 1.6; }
.md blockquote {
  border-left: 2px solid var(--border); padding-left: 14px;
  color: var(--text-dim); margin: 12px 0;
}
.md table { margin: 14px 0; font-size 12.5px; }
.md th { background: var(--bg-panel); }
.md strong { font-weight: 600; color: var(--text); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* ------------------------------------------------------------------- misc */
.log-line {
  font-family: var(--mono); font-size: 11.5px; padding: 2px 0;
  display: grid; grid-template-columns: 78px 58px 1fr; gap: 10px;
}
.log-line .lvl { font-weight: 600; font-size: 10.5px; }
.lvl-DEBUG { color: var(--text-faint); }
.lvl-INFO { color: var(--ok); }
.lvl-WARNING { color: var(--medium); }
.lvl-ERROR { color: var(--critical); }
.lvl-CRITICAL { color: var(--critical); font-weight: 700; }
.log-line .ts { color: var(--text-faint); }
.log-line .ms { color: var(--text-dim); word-break: break-word; }

.spinner {
  width: 12px; height: 12px; border: 1.5px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: grid; place-items: center; z-index: 100; backdrop-filter: blur(2px);
}
.modal {
  width: 560px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.modal h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.instr-pick { display: flex; gap: 8px; align-items: center; }
.instr-pick select { flex: 1; min-width: 0; }
.instr-view {
  margin: 8px 0 0; padding: 10px 12px; max-height: 260px; overflow: auto;
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
}
.hint { font-size: 11.5px; color: var(--text-faint); }

/* The multi-target field: how many runs one press will start. The count turns
   red past the server's ceiling before the request is even sent. */
.target-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.target-meta .hint { flex: 1; min-width: 0; }
.target-count {
  flex: none; font-size: 11.5px; color: var(--text-faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.target-count.over { color: var(--critical); font-weight: 600; }
/* A line that already has a run: shown while typing, refused on submit. */
.target-dups { font-size: 11.5px; line-height: 1.5; margin-top: 1px; color: var(--medium); }
.target-dups b { font-weight: 600; color: var(--text); }

/* --- settings: API keys ------------------------------------------------ */
/* Wide enough for the eight columns the key table now carries: the switch, the
   masked key, the balance with its bar, and the two row buttons. */
.modal-wide { width: 860px; }
.key-add { border-top: 1px solid var(--border-soft); padding-top: 14px; }
.key-add h4 { font-size: 12.5px; font-weight: 600; margin-bottom: 10px; color: var(--text-dim); }
.key-add .field { margin-bottom: 10px; }

.kv-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kv-table th {
  text-align: left; font-weight: 500; font-size: 11px; color: var(--text-faint);
  padding: 0 8px 7px 0; border-bottom: 1px solid var(--border-soft);
}
.kv-table td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.kv-table tr:last-child td { border-bottom: none; }
.kv-table .key-actions { display: flex; gap: 6px; justify-content: flex-end; padding-right: 0; }
/* The detail column is the one that may wrap: a state line can be long, and
   letting it push the buttons off the edge is worse than a second line. */
.kv-table .key-detail { max-width: 210px; white-space: normal; }
.kv-table .key-masked { word-break: break-all; max-width: 96px; }
.kv-table .key-state { white-space: nowrap; }

.kv-table .key-balance { font-size: 11.5px; white-space: nowrap; }
.balance-head { display: flex; align-items: baseline; gap: 2px; }
.kv-table .key-balance .balance-left { font-weight: 500; font-variant-numeric: tabular-nums; }
.kv-table .key-balance .balance-left.good { color: var(--ok); }
.kv-table .key-balance .balance-left.warn { color: var(--medium); }
.kv-table .key-balance .balance-left.bad  { color: var(--critical); }
.balance-bar {
  width: 86px; height: 3px; margin-top: 5px; border-radius: 2px;
  background: var(--border-soft); overflow: hidden;
}
.balance-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.balance-bar i.fill-good { background: var(--ok); }
.balance-bar i.fill-warn { background: var(--medium); }
.balance-bar i.fill-bad  { background: var(--critical); }
.kv-table .key-load { font-size: 11px; white-space: nowrap; }
.key-busy { color: var(--medium); }
.key-full { color: var(--critical); }

/* The switch parks a key instead of deleting it, so a row that is off stays
   readable - dimmed, not hidden, because its balance is the reason it is off. */
.kv-table .key-toggle { width: 34px; padding-right: 4px; }
.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  width: 30px; height: 17px; border-radius: 9px; background: var(--border);
  position: relative; transition: background .15s; flex: none;
}
.switch i::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--text-faint); transition: transform .15s, background .15s;
}
.switch input:checked + i { background: var(--accent-soft, rgba(94,106,210,.35)); }
.switch input:checked + i::after { transform: translateX(13px); background: var(--accent); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + i { opacity: .5; }
.key-row-off > td { opacity: .5; }
.kv-table .key-row-off .key-toggle { opacity: 1; }
.tool-ok.off { color: var(--text-dim); background: rgba(120,124,134,.12); }
.tiny { font-size: 10.5px; }
.key-add .err { margin-bottom: 10px; }
.err { color: var(--critical); font-size: 12px; background: rgba(242,85,90,.08);
       border: 1px solid rgba(242,85,90,.25); padding: 7px 10px; border-radius: var(--radius);
       white-space: pre-wrap; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26282d; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #33363c; }

.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.mt { margin-top: 14px; }

/* ------------------------------------------------------------------- chat */
.chat-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 24px 0;
}
.chat-bar .grow { flex: 1; }
.chat-picker {
  max-width: 320px; padding: 4px 8px; font-size: 12px;
  background: var(--bg-raised); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.chat-picker:hover:not(:disabled) { color: var(--text); border-color: #2c2f35; }
.chat-picker:disabled { opacity: .5; cursor: default; }
.chat-picker:focus { outline: none; border-color: var(--accent); }
.switch {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-dim); cursor: pointer; user-select: none;
}
.switch input { accent-color: var(--accent); cursor: pointer; }
.switch:hover { color: var(--text); }
.pane-chat { padding: 0; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px 24px 8px; min-height: 0; }
.chat-empty { color: var(--text-dim); text-align: center; padding: 60px 20px; }
.chat-empty .hint { margin-top: 6px; font-size: 12px; color: var(--text-faint); }

.msg { margin-bottom: 16px; max-width: 860px; }
.msg-user { margin-left: auto; }
.msg-user .msg-body {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 13px; white-space: pre-wrap;
}
.msg-ai .msg-body { padding: 2px 0; }
.msg-error {
  color: var(--critical); border: 1px solid rgba(242,85,90,.25);
  border-radius: var(--radius); padding: 9px 13px; background: rgba(242,85,90,.06);
}
.msg-pending { opacity: .55; }

/* The transcript reuses the report's markdown styles; only the spacing inside
   a bubble differs, so it stays compact next to the tool output below it. */
.msg-body.md > :first-child { margin-top: 0; }
.msg-body.md > :last-child { margin-bottom: 0; }

.cmd-card {
  margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-panel); overflow: hidden;
}
.cmd-card.dismissed { opacity: .5; }
.cmd-code {
  font-family: var(--mono); font-size: 12px; padding: 11px 13px; margin: 0;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word; color: var(--text);
}
.cmd-actions {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-top: 1px solid var(--border-soft); background: var(--bg-raised);
}
.cmd-state { font-size: 12px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
.cmd-card.dismissed .cmd-actions { display: none; }
/* Under auto-run the row holds the status, not buttons, so it stays: hiding
   it would take away the only sign of what the command did. */
.cmd-card.auto.dismissed .cmd-actions { display: flex; }
.cmd-card.stalled { border-color: rgba(226,197,65,.35); }
.cmd-card.running { border-color: rgba(94,106,210,.5); }

.msg-exec {
  border-left: 2px solid var(--border); padding: 4px 0 4px 12px; margin-left: 2px;
}
.exec-head { display: flex; align-items: flex-start; gap: 8px; }
.exec-cmd { font-size: 12px; color: var(--text-dim); word-break: break-all; }
.exec-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none; margin-top: 5px;
  background: var(--text-faint);
}
.exec-dot.ok { background: var(--ok); }
.exec-dot.bad { background: var(--critical); }
.exec-dot.warn { background: var(--medium); }
.msg-stalled { border-left-color: var(--medium); }
.msg-stalled .exec-meta { color: var(--medium); }
.exec-out {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 10px 12px; margin-top: 8px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow-y: auto;
}

/* Long output is folded by default and says so: the size is in the meta line
   and the control is right there, so a cut-off tail never reads as the whole
   answer. */
.exec-out.is-long.collapsed { max-height: 180px; overflow-y: hidden; position: relative; }
.exec-out.is-long.collapsed::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 40px;
  background: linear-gradient(transparent, var(--bg-panel));
  pointer-events: none;
}
.exec-more { margin-top: 8px; }
.exec-err { color: var(--critical); }
.exec-meta { font-size: 11px; color: var(--text-faint); margin-top: 6px; }

.chat-sandbox {
  display: flex; align-items: center; gap: 8px;
  padding: 0 24px 8px; min-height: 18px;
}
.chat-input {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 24px 18px; border-top: 1px solid var(--border);
}
.chat-input textarea {
  flex: 1; resize: none; background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; font-family: var(--sans); font-size: 13px; line-height: 1.5;
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); }

/* ----------------------------------------------------------------- motion */
/* Messages land rather than appear: a short rise reads as "new thing" without
   asking the eye to track anything. */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg { animation: msg-in .18s ease-out; }

.stream-cursor {
  display: inline-block; width: 7px; height: 15px; margin-left: 2px;
  vertical-align: -2px; background: var(--accent); border-radius: 1px;
  animation: caret 1s steps(2, start) infinite;
}
@keyframes caret { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* "Thinking" while the first fragment is still on its way. Three dots that
   breathe out of phase; the text carries the meaning, so it is readable with
   the animation off. */
.thinking { display: inline-flex; align-items: center; gap: 9px; color: var(--text-dim); }
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint);
  animation: breathe 1.3s ease-in-out infinite;
}
.thinking-dots i:nth-child(2) { animation-delay: .18s; }
.thinking-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes breathe {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1); }
}

/* A command the operator just approved: the row settles into a working state
   so the click has an answer even before the sandbox does. */
.cmd-card { transition: opacity .2s ease, border-color .2s ease; }
.cmd-state .spinner { margin-right: 2px; }

.exec-dot.ok { animation: dot-in .25s ease-out; }
@keyframes dot-in { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

.exec-hint {
  margin-top: 8px; padding: 8px 11px; border-radius: var(--radius);
  border: 1px solid rgba(226,197,65,.28); background: rgba(226,197,65,.07);
  color: var(--medium); font-size: 12px; line-height: 1.45;
}

.finding-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Honour the OS setting: an entrance that cannot be turned off is a bug for
   anyone who gets motion sick from it. */
@media (prefers-reduced-motion: reduce) {
  .enter { animation: none; }
  .dot.running, #liveInfo[data-on="1"] .pulse { animation: none; }
  /* The caret and the thinking dots become static marks: both still say what
     they mean, they just stop moving. */
  .msg { animation: none; }
  .exec-dot.ok { animation: none; }
  .stream-cursor { animation: none; }
  .thinking-dots i { animation: none; opacity: .7; transform: none; }
  .toast { animation: none; }
}

/* --- notices ------------------------------------------------------------ */
/* The batch launcher closes the modal before the runs exist in the sidebar,
   so a short notice is what tells the operator how many were accepted, and
   keeps per-target failures from disappearing with the modal. */
.toast-host {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(560px, calc(100vw - 36px));
}
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 8px;
  background: var(--bg-panel); box-shadow: 0 10px 30px rgba(0,0,0,.45);
  color: var(--text-dim); font-size: 12.5px; line-height: 1.5;
  animation: toast-in .18s ease-out;
}
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--medium); }
.toast-err { border-left-color: var(--critical); }
.toast-body { min-width: 0; }
.toast-body b { color: var(--text); font-weight: 600; }
.toast-list { margin-top: 4px; color: var(--text-faint); }
.toast-x {
  margin-left: auto; flex: none; border: 0; background: none;
  color: var(--text-faint); font-size: 16px; line-height: 1; cursor: pointer;
  padding: 0 0 0 2px;
}
.toast-x:hover { color: var(--text); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
