:root {
  --bg: #151110;
  --surface: #1b1715;
  --surface-2: #211c19;
  --surface-3: #2a2420;
  --line: #2c2622;
  --line-2: #3c3430;
  --text: #f2ede9;
  --muted: #a69d96;
  --faint: #776e68;
  --accent: #f07a4e;
  --accent-ink: #1a0d05;
  --accent-soft: rgba(240, 122, 78, 0.13);
  --l1: #5cc8a8;
  --l2: #b3a1ff;
  --l3: #f0bd5a;
  --ok: #46d37a;
  --err: #f2665e;
  --warn: #f0bd5a;
  --glow: rgba(240, 122, 78, 0.18);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
code, pre { font-family: var(--mono); font-size: 13px; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.grow { flex: 1; }
.lbl { color: var(--faint); font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }

#app { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: 100vh; }

/* ---------- sidebar ---------- */
.side { display: flex; flex-direction: column; gap: 10px; padding: 20px 14px 16px; border-right: 1px solid var(--line); min-height: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 10px; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 26px var(--glow); }
.mark svg { width: 21px; height: 21px; }
.brand-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.side-label { margin: 14px 10px 2px; color: var(--faint); font-size: 11.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }
.run-list { flex: 1 1 0; min-height: 70px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.run-item { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 1px 10px; align-items: center; padding: 9px 10px; border: 1px solid transparent; border-radius: 14px; }
.run-item:hover { background: var(--surface); }
.run-item.on { background: var(--surface-2); border-color: var(--line); }
.run-item .t { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.run-item .m { grid-column: 2; color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.empty-side { padding: 10px; color: var(--faint); font-size: 13.5px; }
.tiers { display: flex; flex-direction: column; overflow-y: auto; max-height: 36vh; }
.tier-row { display: grid; grid-template-columns: 8px auto auto minmax(0, 1fr); gap: 9px; align-items: center; padding: 5px 10px; font-size: 13px; }
.tier-row .mdl { color: var(--faint); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: right; font: 11.5px var(--mono); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.running { background: var(--accent); animation: pulse 1.6s infinite; }
.dot.done, .dot.on { background: var(--ok); }
.dot.error { background: var(--err); }
.dot.stopped, .dot.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.dot.waiting { background: var(--warn); animation: pulse 1.6s infinite; }
.dot.idle { background: color-mix(in srgb, var(--accent) 55%, var(--faint)); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--glow); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.badge { flex: none; padding: 0 7px; border: 1px solid var(--line-2); border-radius: 99px; font-size: 11px; line-height: 18px; color: var(--muted); }
.badge.l1 { color: var(--l1); border-color: color-mix(in srgb, var(--l1) 35%, transparent); }
.badge.l2 { color: var(--l2); border-color: color-mix(in srgb, var(--l2) 35%, transparent); }
.badge.l3 { color: var(--l3); border-color: color-mix(in srgb, var(--l3) 35%, transparent); }

/* ---------- buttons and pills ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border: 1px solid var(--line-2); border-radius: 99px; background: transparent; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { border-color: var(--accent); background: var(--accent-soft); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.btn.wide { width: 100%; }
.btn.small { height: 32px; padding: 0 13px; font-size: 13.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pills button, .pillbtn { height: 38px; padding: 0 17px; border: 1px solid var(--line-2); border-radius: 99px; background: transparent; color: var(--muted); font-size: 14.5px; transition: border-color 0.15s, color 0.15s, background 0.15s; }
.pills button:hover, .pillbtn:hover { color: var(--text); border-color: var(--faint); }
.pills button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.pills i { font-style: normal; color: var(--faint); margin-left: 4px; }
.pillbtn.danger:hover { border-color: var(--err); color: var(--err); }
.state { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); }
.tagp { padding: 0 11px; border: 1px solid var(--line-2); border-radius: 99px; color: var(--muted); font-size: 12.5px; line-height: 24px; }

/* ---------- composer ---------- */
#main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.compose { flex: 1; display: grid; justify-items: center; align-items: safe center; padding: 32px 20px; overflow-y: auto; }
.compose-in { width: min(740px, 100%); }
.compose h1 { margin: 0 0 10px; font-size: clamp(27px, 3vw, 36px); line-height: 1.12; letter-spacing: -0.03em; font-weight: 600; text-wrap: balance; }
.compose .sub { margin: 0 0 20px; color: var(--muted); font-size: 15px; max-width: 58ch; text-wrap: pretty; }
.box { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); transition: border-color 0.15s; }
.box:focus-within { border-color: var(--accent); }
.box textarea { display: block; width: 100%; min-height: 120px; padding: 20px 22px 6px; border: 0; background: none; resize: none; outline: none; font-size: 16.5px; line-height: 1.5; }
.box textarea::placeholder { color: var(--faint); }
.box-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px 14px; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 99px; }
.seg button { height: 30px; padding: 0 14px; border: 0; border-radius: 99px; background: none; color: var(--muted); font-size: 13.5px; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }
.sel { height: 36px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); font-size: 13.5px; }
.hint { margin: 14px 6px 0; color: var(--faint); font-size: 13.5px; }
.hint code { padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chip { padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--muted); font-size: 13.5px; }
.chip:hover { border-color: var(--line-2); color: var(--text); }
.err-line { margin: 10px 6px 0; color: var(--err); font-size: 13.5px; }

/* ---------- run view ---------- */
.run { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 20px 26px 22px; gap: 16px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.run-title { margin: 2px 0 0; font-size: 24px; line-height: 1.22; font-weight: 600; letter-spacing: -0.02em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.stat { padding: 14px 20px 15px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat .k { color: var(--faint); font-size: 11.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }
.stat .v { margin-top: 3px; font-size: 23px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .s { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 3px; margin-top: 7px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width 0.4s ease; }

.ask { padding: 18px 22px; border: 1px solid var(--accent); border-radius: var(--r); background: var(--accent-soft); }
.ask .q { font-size: 17px; font-weight: 600; }
.ask .who { display: block; color: var(--accent); font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.ask-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ask input { flex: 1 1 220px; height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); outline: none; }
.ask input:focus { border-color: var(--accent); }

.stage { flex: 1; min-height: 0; display: flex; }
.card { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); overflow: hidden; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 26px 16px; }
.card-hint { color: var(--muted); font-size: 14px; }
.pane { flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- graph ---------- */
.graph-wrap { position: relative; flex: 1; min-height: 0; margin: 0 18px 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); overflow: hidden; }
.graph { position: absolute; inset: 0; overflow: auto; }
.g-in { position: relative; transform-origin: 0 0; }
#gsvg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }

.edge { fill: none; stroke: var(--line-2); stroke-width: 1.3; }
.edge.done { stroke: color-mix(in srgb, var(--text) 22%, var(--line-2)); }
.edge.running, .edge.waiting { stroke: var(--accent); stroke-dasharray: 5 7; stroke-linecap: round; animation: flow 0.9s linear infinite; }
.edge.idle { stroke: color-mix(in srgb, var(--accent) 55%, var(--line-2)); }
.edge.error { stroke: var(--err); }
.edge.esc { stroke-dasharray: 4 5; stroke: color-mix(in srgb, var(--accent) 70%, var(--line-2)); }
@keyframes flow { to { stroke-dashoffset: -24; } }
.port { fill: color-mix(in srgb, var(--text) 40%, var(--line-2)); }
.port.running, .port.waiting { fill: var(--accent); }
.elabel-bg { fill: var(--bg); stroke: color-mix(in srgb, var(--accent) 40%, transparent); }
.elabel { fill: var(--accent); font: 500 11px var(--sans); }

.node { position: absolute; left: 0; top: 0; width: 256px; height: 68px; display: flex; align-items: center; gap: 13px; padding: 0 18px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface); text-align: left; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; }
.node:hover { border-color: var(--faint); background: var(--surface-2); }
.node.running, .node.waiting { border-color: color-mix(in srgb, var(--accent) 65%, var(--line-2)); box-shadow: 0 0 0 4px var(--accent-soft), 0 0 40px var(--glow); }
.node.error { border-color: color-mix(in srgb, var(--err) 60%, var(--line-2)); }
.node.on { border-color: var(--accent); }
.node.new { animation: pop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes pop { from { scale: 0.9; } }
.n-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.n-main b { font-size: 15px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.n-sub { display: flex; gap: 9px; align-items: baseline; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.n-model { font: 11.5px var(--mono); color: var(--muted); }
.n-model.l1 { color: var(--l1); }
.n-model.l2 { color: var(--l2); }
.n-model.l3 { color: var(--l3); }
.n-esc { color: var(--accent); }

.gmap { position: absolute; left: 16px; bottom: 16px; width: 148px; height: 92px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); overflow: hidden; pointer-events: none; }
.gmap i { position: absolute; height: 3px; min-width: 6px; border-radius: 2px; background: var(--faint); }
.gmap i.done { background: var(--ok); }
.gmap i.running, .gmap i.waiting, .gmap i.idle { background: var(--accent); }
.gmap i.error { background: var(--err); }
.gzoom-ctl { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); overflow: hidden; }
.gzoom-ctl button { display: grid; place-items: center; width: 44px; height: 42px; border: 0; background: none; color: var(--muted); }
.gzoom-ctl button + button { border-top: 1px solid var(--line); }
.gzoom-ctl button:hover { color: var(--text); background: var(--surface-2); }
.gzoom-ctl svg { width: 18px; height: 18px; }

/* ---------- agent transcript ---------- */
.modal-back { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 28px; background: rgba(8, 6, 5, 0.62); backdrop-filter: blur(3px); }
.modal { width: min(1040px, 100%); height: min(880px, 100%); display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; animation: lift 0.2s ease; }
@keyframes lift { from { translate: 0 10px; } }
.modal-h { display: flex; align-items: center; gap: 12px; flex: none; padding: 24px 24px 14px 32px; }
.who { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.who .dot { align-self: center; width: 10px; height: 10px; }
.who b { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.who .mdl { color: var(--faint); font: 13px var(--mono); }
.who .n-model { font-size: 13px; }
.xbtn { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.xbtn:hover { background: var(--surface-3); color: var(--text); }
.xbtn svg { width: 18px; height: 18px; }

.feed { padding: 8px 32px 36px; }
.it { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 0 18px; padding-bottom: 26px; }
.it::before { content: ""; position: absolute; left: 18.5px; top: 40px; bottom: 2px; width: 1px; background: var(--line); }
.it:last-child::before { display: none; }
.it.new { animation: rise 0.22s ease; }
@keyframes rise { from { transform: translateY(5px); } }
.tl-ico { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.tl-ico svg { width: 17px; height: 17px; }
.tl-body { min-width: 0; padding-top: 7px; }
.tl-h { display: flex; align-items: baseline; gap: 10px; color: var(--muted); font-size: 15.5px; }
.tl-h.accent { color: var(--accent); }
.tl-h.bad, .md.bad { color: var(--err); }
.tl-h code { color: var(--muted); }
.tl-h .tm, .tool .tm { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.md { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 15.5px; }
.md code { padding: 1px 6px; border-radius: 6px; background: var(--surface-3); }
.md .mh { margin: 8px 0 2px; font-weight: 600; }
.md .li { padding-left: 18px; position: relative; }
.md .li::before { content: ""; position: absolute; left: 5px; top: 0.74em; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.md pre.code { margin: 8px 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-3); }
.md.thinking { color: var(--muted); font-style: italic; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.taskbox, .finalbox { margin-top: 10px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2); }
.finalbox { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: color-mix(in srgb, var(--ok) 6%, var(--surface-2)); }
.caret::after { content: ""; display: inline-block; width: 7px; height: 16px; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tool > summary { display: flex; align-items: baseline; gap: 12px; cursor: pointer; list-style: none; }
.tool > summary::-webkit-details-marker { display: none; }
.tool .tn { color: var(--accent); font-size: 15.5px; white-space: nowrap; }
.tool.err .tn, .tool.err .tm { color: var(--err); }
.tool .ta { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.tool > summary:hover .ta { color: var(--text); }
.tprev { margin-top: 4px; color: var(--faint); font-size: 13.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tool[open] + .tprev { display: none; }
.tbody { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.tbody pre { max-height: 340px; overflow: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--muted); }
.tbody pre.cmd { color: var(--text); }
.tbody pre.del { background: color-mix(in srgb, var(--err) 8%, var(--bg)); }
.tbody pre.add { background: color-mix(in srgb, var(--ok) 8%, var(--bg)); }
.cap { color: var(--faint); font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kids { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kid { display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 15px; border: 1px solid var(--line-2); border-radius: 99px; background: transparent; }
.kid:hover { border-color: var(--accent); }
.vline { margin-top: 10px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.vline > * { margin-right: 8px; }
.vline code { padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--muted); overflow-wrap: anywhere; }
.vline .ok { color: var(--ok); white-space: nowrap; }
.vline .bad { color: var(--err); white-space: nowrap; }
.vline .up { color: var(--accent); white-space: nowrap; }
.brief { margin-top: 10px; color: var(--muted); }
.brief summary { cursor: pointer; color: var(--faint); font-size: 13.5px; }
.it.ans { display: flex; justify-content: flex-end; }
.it.ans::before { display: none; }
.ansb { max-width: 80%; padding: 10px 18px; border: 1px solid var(--accent); border-radius: 20px 20px 6px 20px; background: var(--accent-soft); }

/* ---------- files and preview ---------- */
.files { display: grid; grid-template-columns: 250px minmax(0, 1fr); height: 100%; }
.ftree { overflow-y: auto; padding: 14px; border-right: 1px solid var(--line); }
.frow { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 7px 12px; border: 0; border-radius: 10px; background: none; text-align: left; font: 13px var(--mono); }
.frow:hover { background: var(--surface-2); }
.frow.on { background: var(--surface-3); }
.frow span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.frow .sz { color: var(--faint); flex: none; }
.fview { overflow: auto; padding: 20px 24px; }
.blank { display: grid; place-items: center; height: 100%; padding: 24px; color: var(--faint); text-align: center; }
.pv { display: flex; flex-direction: column; height: 100%; }
.pv-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pv-url { flex: 1; min-width: 0; height: 32px; padding: 0 14px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font: 12.5px var(--mono); overflow: hidden; white-space: nowrap; }
.pv iframe { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .run-list { flex: none; max-height: 150px; }
  .side-label:nth-of-type(2), .tiers { display: none; }
  .run { padding: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat + .stat { border-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .stat:last-child { grid-column: 1 / -1; }
  .card { height: 76vh; flex: none; width: 100%; border-radius: 22px; }
  .card-h { padding: 16px 18px 12px; }
  .graph-wrap { margin: 0 10px 10px; }
  .gmap { display: none; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; border: 0; height: 100%; }
  .modal-h { padding: 16px 12px 10px 18px; }
  .feed { padding: 8px 16px 28px; }
  .it { grid-template-columns: 32px minmax(0, 1fr); gap: 0 12px; }
  .tl-ico { width: 32px; height: 32px; }
  .it::before { left: 15.5px; top: 34px; }
  .files { grid-template-columns: 130px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}

/* Compact workspace, matched to the supplied agent graph and findings views. */
:root { color-scheme: dark; --bg: #171310; --surface: #1d1916; --surface-2: #25201c; --surface-3: #2e2823; --line: #332d29; --line-2: #403934; --text: #f1ece7; --muted: #a79d96; --faint: #a0968e; --accent: #dc784e; --accent-soft: #dc784e18; --ok: #36ca78; --l4: #ed8da9; }
#app { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); height: 100dvh; }
.side {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 0;
  padding: 10px clamp(14px, 2.4vw, 32px);
  border-right: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.side .brand { flex: none; gap: 7px; padding: 0 10px 0 0; }
.side .btn { height: 34px; flex: none; font-size: 13px; }
.side .account-bar { min-width: 0; padding: 0 0 0 10px; border-top: 0; border-left: 1px solid var(--line); }
#accountName { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-menu { position: relative; }
.header-menu > summary { cursor: pointer; list-style: none; }
.header-menu > summary::-webkit-details-marker { display: none; }
.header-menu[open] > summary { border-color: var(--accent); color: var(--text); }
.header-menu > :is(.run-list, .tiers) {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(300px, calc(100vw - 28px));
  min-height: 0;
  max-height: min(52dvh, 360px);
  padding: 6px;
  overflow: auto;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.models-menu > .tiers { left: auto; right: 0; }
.mark { display: block; width: 30px; height: 30px; object-fit: contain; background: none; box-shadow: none; border-radius: 0; }
.brand-name { font-size: 17px; letter-spacing: -.025em; }
.pills { gap: 8px; }
.pills button, .pillbtn { display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px; border: 1px solid var(--line-2); background: transparent; border-radius: 999px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.pills button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px #dc784e24; }
.pills i { font-size: 12px; }
.run { gap: 14px; padding: 20px clamp(14px, 2.4vw, 32px) 24px; overflow-y: auto; }
.topbar { justify-content: space-between; gap: 10px; }
.run-controls, .run-context { display: flex; align-items: center; gap: 10px; }
.run-controls { flex-wrap: wrap; }
.run-context { flex-wrap: wrap; }
.run-context .run-title { flex: 1 1 12rem; min-width: 0; }
.run-context:has(.run-metrics[open]) .run-metrics { flex-basis: 100%; }
.run #ask:empty { display: none; }
.run-title { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; font-weight: 400; white-space: nowrap; text-overflow: ellipsis; display: block; }
.state { gap: 7px; font-size: 13px; }
.tagp { line-height: 23px; }
.run-metrics { flex: none; }
.run-metrics > summary { color: var(--faint); font-size: 12px; cursor: pointer; width: fit-content; }
.run-metrics[open] > summary { margin-bottom: 10px; }
.run-actions { position: relative; }
.run-actions > summary { cursor: pointer; list-style: none; }
.run-actions > summary::-webkit-details-marker { display: none; }
.export-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 10; min-width: 175px; padding: 6px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); box-shadow: var(--shadow); }
.export-menu a { display: block; padding: 8px 10px; border-radius: 7px; font-size: 12px; }
.export-menu a:hover { background: var(--surface-3); }
.stats { border-radius: 14px; }
.stat { padding: 10px 14px; }
.stat .v { font-size: 18px; }
.stat .k { font-size: 10px; }
.stat .s { font-size: 11px; }
.stage { flex: 1; min-height: 360px; }
.card { border: 1px solid var(--line-2); border-radius: 26px; background: var(--surface); }
.card-h { padding: 22px 24px 18px; }
.card-hint { color: var(--faint); font-size: 12px; }
.graph-wrap { margin: 0 24px 24px; border: 1px solid var(--line); border-radius: 19px; background: radial-gradient(circle, #f5e5d40b 1px, transparent 1px) 0 0 / 24px 24px, #1b1714; }
.node { width: 208px; height: 42px; gap: 8px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 12px; background: #211c18; box-shadow: none; }
.node > .dot { width: 6px; height: 6px; animation: none; box-shadow: none; }
.node .n-main { flex: 1; }
.n-main b { font-size: 12px; line-height: 1.25; font-weight: 400; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.node.running, .node.waiting { border-color: var(--line-2); box-shadow: none; }
.node:hover, .node.on { border-color: var(--accent); background: var(--surface-2); }
.edge, .edge.done { stroke: #625850; stroke-width: 1; }
.edge.running, .edge.waiting { stroke: #76665c; stroke-dasharray: none; animation: none; }
.port { fill: #92857a; }
.gmap { left: 18px; bottom: 18px; width: 110px; height: 68px; border-radius: 14px; background: var(--bg); }
.gzoom-ctl { right: 18px; bottom: 18px; border-radius: 14px; }
.gzoom-ctl button { width: 38px; height: 38px; }
.modal-back { padding: 12px; background: #100d0bd9; backdrop-filter: blur(4px); }
.modal { width: min(1280px,100%); height: min(940px,100%); border-radius: 30px; background: var(--surface); }
.modal-h { padding: 24px 28px 18px; }
.who b { font-size: 20px; }
.feed { padding: 8px 28px 32px; }
.it { padding-bottom: 26px; }
.tl-ico { background: transparent; border-color: var(--line); }
.it::before { background: var(--line); }
.tl-h { font-size: 15px; }
.md { font-size: 14px; line-height: 1.75; }
.md.thinking { display: block; overflow: visible; }
.taskbox, .finalbox { padding: 16px 18px; border-radius: 16px; background: var(--surface-2); }
.finalbox { background: #24271d; }
.badge.l4 { color: var(--l4); border-color: color-mix(in srgb,var(--l4) 35%,transparent); }
.n-model.l4 { color: var(--l4); }
@media (max-width: 980px) {
  .card { height: auto; flex: 1; width: auto; }
  .card-h { padding: 18px; }
  .graph-wrap { margin: 0 12px 12px; }
  .modal-back { padding: 8px; }
  .modal { height: 100%; border-radius: 20px; }
  .feed { padding: 8px 18px 28px; }
}
@media (max-width: 600px) {
  .side { gap: 8px; }
  .side .grow, .side #accountName { display: none; }
  .side .brand { padding-right: 0; }
  .side .btn, .side .pillbtn { padding-inline: 10px; font-size: 12px; min-height: 36px; }
  .header-menu { position: static; }
  .header-menu > :is(.run-list, .tiers) { left: 14px; right: auto; }
  .run { padding-block: 14px; }
  .topbar .pills { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding: 3px; }
  .topbar .pills button { flex: none; }
  .card-h { gap: 6px; }
  .card-hint { font-size: 11px; }
  .files { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(80px, 30%) minmax(0,1fr); }
  .ftree { border-right: 0; border-bottom: 1px solid var(--line); }
  .pv-bar { flex-wrap: wrap; }
  .pv-url { flex-basis: 100%; }
}

.limits { border-top: 1px solid var(--line); padding: 14px 20px; color: var(--muted); font-size: 13px; }
.limits summary { cursor: pointer; }
.limit-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.limit-fields label { display: grid; gap: 6px; }
.limit-fields input { width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.connection { padding: 10px 16px; border: 1px solid var(--line-2); border-radius: 12px; color: var(--warn); font-size: 13px; }
.result { display: block; min-width: 0; padding: 6px 2px 20px; }
.result-head h1 { margin: 0 0 20px; max-width: 42ch; font-size: clamp(22px, 3vw, 34px); line-height: 1.22; font-weight: 600; letter-spacing: -.03em; overflow-wrap: anywhere; text-wrap: pretty; }
.result-layout { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(210px, 1fr); gap: 16px; align-items: start; }
.result-copy, .result-facts { min-width: 0; padding: clamp(14px, 2.2vw, 26px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 20px; }
.result-layout h3 { margin: 0 0 12px; }
.result-copy .md { max-width: 82ch; }
.result-facts dl { margin: 0; font-size: 13px; }
.result-facts dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 0; }
.result-facts dl > div + div { border-top: 1px solid var(--line); }
.result-facts dt { color: var(--faint); }
.result-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; min-width: 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.result-actions .btn { min-height: 36px; height: auto; padding: 7px 13px; font-size: 13px; }
.result-error { color: var(--err); padding: 14px 18px; margin-bottom: 18px; background: #f2665e0c; border: 1px solid #f2665e40; border-radius: 12px; overflow-wrap: anywhere; }
.head-fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 14px; padding: 4px 18px 16px; }
.head-fields label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.head-fields .sel { width: 100%; min-width: 0; padding-inline: 12px; background: var(--surface-2); }
.head-fields .hint { grid-column: 1 / -1; margin: 0; }
@media (max-width: 680px) { .result-layout, .limit-fields { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 440px) { .head-fields { grid-template-columns: minmax(0,1fr); } }

.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line-2); border-radius: 28px; background: var(--surface); }
.login-brand { color: var(--accent); font-size: 18px; font-weight: 600; margin-bottom: 28px; }
.login-card h1 { font-size: 26px; letter-spacing: -.03em; margin: 0; }
.login-card form { display: grid; gap: 18px; margin-top: 24px; }
.login-card label { display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg); }
.account-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.key-form { padding: 22px; margin-top: 20px; }
.key-form h2 { margin: 0; font-size: 18px; }
.key-form label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.key-form input { padding: 12px; width: 100%; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); }

.login-brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
