/* Dev Auto dashboard — one stylesheet, tokens on :root, light + dark. */

:root {
  --top-h: 52px;
  --gutter: 16px;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --fg: #1b1f24;
  --muted: #5f6b7d;
  --accent: #2f6fde;
  --accent-fg: #ffffff;
  --accent-soft: #e5edfc;
  --ok: #1a8a4a;
  --ok-soft: #e2f4e9;
  --warn: #a96b0c;
  --warn-soft: #fcf1dc;
  --err: #c53030;
  --err-soft: #fce8e8;
  --code-bg: #f2f3f6;
  --bubble: #ffffff;
  --mine: #e5edfc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);

  --st-queued: #7b8494;
  --st-preparing: #7a55d3;
  --st-running: #2f6fde;
  --st-waiting_hamza: #c97a00;
  --st-done: #1a8a4a;
  --st-failed: #c53030;
  --st-cancelled: #8a8f98;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2b303b;
    --fg: #e5e7eb;
    --muted: #9aa3b2;
    --accent: #6d9dff;
    --accent-fg: #0b1220;
    --accent-soft: #1c2944;
    --ok: #4cc27f;
    --ok-soft: #15301f;
    --warn: #e5a53d;
    --warn-soft: #33260e;
    --err: #ff6b6b;
    --err-soft: #3a191b;
    --code-bg: #12151b;
    --bubble: #1b1f27;
    --mine: #1c2944;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);

    --st-queued: #9099a8;
    --st-preparing: #a68bff;
    --st-running: #6d9dff;
    --st-waiting_hamza: #f0ad3c;
    --st-done: #4cc27f;
    --st-failed: #ff6b6b;
    --st-cancelled: #858b96;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 var(--font);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
h2, h3, h4 { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.spacer { flex: 1; }
.warn { color: var(--warn); }

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); cursor: pointer; white-space: nowrap;
  line-height: 1.2; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.btn.danger:hover { background: var(--err-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; }
.btn.option { border-color: var(--accent); color: var(--accent); }
.btn.option:hover { background: var(--accent-soft); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

input[type=text], input[type=number], input[type=password], input:not([type]), textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { opacity: .55; }
textarea { resize: vertical; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; border: 0; padding: 0; }
.field > span, .field > legend { font-weight: 600; font-size: 13px; padding: 0; }
fieldset.field legend { margin-bottom: 6px; }
.field-info { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-height: 1em; }
.radio-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.radio-row input[type=number] { max-width: 160px; }
.radio, .check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.form-error { color: var(--err); background: var(--err-soft); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; }
.jira-status { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
body[data-screen=login] .topbar, body[data-screen=loading] .topbar:empty { display: none; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--fg); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 22px; }
.brand-dot { width: 12px; height: 12px; border-radius: 4px; background: linear-gradient(135deg, var(--accent), var(--st-preparing)); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--fg); background: var(--surface-2); font-weight: 600; }
.count {
  display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; margin-left: 6px;
  background: var(--st-waiting_hamza); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px;
}
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-queued); }
.conn-live .dot { background: var(--ok); }
.conn-down .dot { background: var(--err); }
.conn-connecting .dot { background: var(--warn); }
.conc-num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- pages ---------- */
main { padding: var(--gutter); }
body[data-view=run] main { padding: 0; }
.page { max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.boot { padding: 40px; text-align: center; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); grid-column: 1 / -1; }
.empty-small { padding: 8px 0; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }

/* ---------- badges ---------- */
.badge {
  --c: var(--st-queued);
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.state-queued { --c: var(--st-queued); }
.state-preparing { --c: var(--st-preparing); }
.state-running { --c: var(--st-running); }
.state-waiting_hamza { --c: var(--st-waiting_hamza); }
.state-done { --c: var(--st-done); }
.state-failed { --c: var(--st-failed); }
.state-cancelled { --c: var(--st-cancelled); }
.state-running .dot, .state-preparing .dot { animation: pulse 1.6s ease-in-out infinite; }
.badge.dstate { --c: var(--muted); }
.badge.dstate-answered { --c: var(--ok); }
.badge.dstate-rejected { --c: var(--err); }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-family: var(--mono);
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.pending-badge {
  margin-left: auto; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--st-waiting_hamza); color: #fff; white-space: nowrap;
}
.pending-badge:hover { text-decoration: none; filter: brightness(1.08); }
.jira-key { font-family: var(--mono); font-weight: 700; font-size: 13px; white-space: nowrap; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 14px; }
.card {
  --c: var(--st-queued);
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c);
  border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow); min-width: 0;
}
.card.st-queued { --c: var(--st-queued); }
.card.st-preparing { --c: var(--st-preparing); }
.card.st-running { --c: var(--st-running); }
.card.st-waiting_hamza { --c: var(--st-waiting_hamza); }
.card.st-done { --c: var(--st-done); }
.card.st-failed { --c: var(--st-failed); }
.card.st-cancelled { --c: var(--st-cancelled); opacity: .85; }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-summary { color: var(--fg); font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.card-phase { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.phase-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.now {
  font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 5px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono);
}
.now.live { color: var(--fg); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); font-size: 12px; background: var(--surface); white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st-queued); }
.chip.running .dot { background: var(--ok); animation: pulse 1.4s ease-in-out infinite; }
.chip.muted { color: var(--muted); }
.chip-model { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 2px; font-size: 13px; }
.links { display: inline-flex; gap: 10px; flex-wrap: wrap; }
.meta { display: inline-flex; gap: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cost { font-variant-numeric: tabular-nums; }

/* ---------- run page ---------- */
.run-page { max-width: none; height: calc(100vh - var(--top-h) - var(--health-h, 0px)); height: calc(100dvh - var(--top-h) - var(--health-h, 0px)); display: flex; flex-direction: column; }
.run-head { padding: 10px var(--gutter); border-bottom: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.run-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.run-title h2 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.back { font-size: 18px; color: var(--muted); }
.run-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.run-sub .phase-title { color: var(--fg); }
.run-sub .sep { width: 1px; height: 14px; background: var(--border); }
.run-sub .branch { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-error { color: var(--err); background: var(--err-soft); padding: 6px 10px; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; }

.run-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 44%); }
.col-left, .col-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.col-right { border-left: 1px solid var(--border); background: var(--surface); }
.timeline { flex: 1; min-height: 0; overflow-y: auto; padding: 12px var(--gutter); overscroll-behavior: contain; }
.older { display: block; margin: 0 auto 10px; }

.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); overflow-x: auto; flex: none; }
.tab {
  border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.mobile-only { display: none; }
.tab-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px var(--gutter) 24px; }
.pane-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; position: sticky; top: -12px; background: var(--surface); padding: 6px 0; z-index: 1; }

/* timeline rows */
.events { display: flex; flex-direction: column; gap: 4px; }
.ev { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.ev-time { flex: none; margin-left: auto; font-size: 11px; color: var(--muted); padding-top: 3px; font-variant-numeric: tabular-nums; }
.ev.line { font-size: 13px; padding: 2px 0; flex-wrap: wrap; }
.ev-line { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ev.indent, .ev.sub { padding-left: 28px; }
.ev .mark { display: inline-block; width: 16px; text-align: center; color: var(--muted); }
.ev .mark.run, .ev .mark.ok { color: var(--ok); }
.ev .mark.ask { color: var(--st-waiting_hamza); font-weight: 700; }
.ev .mark.warn { color: var(--warn); }
.bubble {
  flex: 1; min-width: 0; background: var(--bubble); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; box-shadow: var(--shadow); overflow-wrap: anywhere; margin: 4px 0;
}
.bubble.small { font-size: 13px; background: var(--surface-2); box-shadow: none; padding: 6px 10px; }
.bubble-agent { font-size: 11px; font-weight: 700; color: var(--st-preparing); text-transform: none; margin-bottom: 2px; }
.ev.mine { justify-content: flex-end; }
.ev.mine .ev-time { margin-left: 0; order: -1; }
.bubble.mine { flex: 0 1 auto; max-width: 80%; background: var(--mine); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.ev.optimistic .bubble { opacity: .65; }
.ev.optimistic.sent .bubble { opacity: .85; }
.ev.optimistic.failed .bubble { border-color: var(--err); opacity: 1; }
.ev.optimistic.failed .bubble::after { content: "not delivered"; display: block; color: var(--err); font-size: 11px; }
.ev-details { flex: 1; min-width: 0; }
.ev-details > summary { cursor: pointer; list-style: none; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-details > summary::-webkit-details-marker { display: none; }
.ev-details > summary:hover { color: var(--fg); }
.ev-details[open] > summary { white-space: normal; color: var(--fg); }
.ev-details pre { margin: 6px 0; }
.ev.err .ev-details > summary { color: var(--err); }
.gear { color: var(--muted); }
.ev.status { padding: 6px 0; }
.ev.status .ev-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ev-detail { width: 100%; padding-left: 22px; font-size: 13px; }
.ev-detail summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.ev.notify .mark { font-weight: 700; }
.ev.notify.lvl-info .mark { color: var(--accent); }
.ev.notify.lvl-warning { color: var(--warn); }
.ev.notify.lvl-error { color: var(--err); }
.ev.error { color: var(--err); background: var(--err-soft); border-radius: 6px; padding: 4px 8px; }
.ev.git.ok .ev-line code { background: var(--ok-soft); color: var(--ok); padding: 0 4px; border-radius: 4px; }
.ev.git.err { color: var(--err); }
.ev.denied { background: var(--warn-soft); border-radius: 6px; padding: 3px 8px; }
.ev.result { color: var(--muted); border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 6px; }
.ev.agent { color: var(--fg); }
.inline-md, .inline-md > p { display: inline; margin: 0; }

.live { flex: none; max-height: 30vh; overflow-y: auto; padding: 6px var(--gutter); border-top: 1px dashed var(--border); background: var(--surface-2); }
.live-row { display: flex; gap: 8px; font-size: 13px; padding: 2px 0; min-width: 0; }
.live-who { flex: none; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--st-preparing); }
.live-text { color: var(--muted); font-style: italic; min-width: 0; }
.dot.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1s ease-in-out infinite; }

.composer { flex: none; border-top: 1px solid var(--border); padding: 8px var(--gutter) 10px; background: var(--surface); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 40vh; }
.run-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- decisions ---------- */
.dlist { display: flex; flex-direction: column; gap: 12px; }
.inbox-page .dlist { max-width: 900px; }
.decision {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  border-left: 3px solid var(--st-waiting_hamza); box-shadow: var(--shadow); min-width: 0; transition: box-shadow .3s;
}
.col-right .decision { box-shadow: none; }
.decision.dstate-answered { border-left-color: var(--ok); }
.decision.dstate-rejected { border-left-color: var(--err); }
.decision.dstate-cancelled { border-left-color: var(--st-cancelled); opacity: .75; }
.decision.busy { opacity: .6; }
.decision.flash { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent); }
.dlist.done .decision { padding: 10px 12px; }
.decision-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--st-waiting_hamza); }
.kind-commit .kind, .kind.kind-commit { color: var(--st-preparing); }
.kind.kind-pr { color: var(--accent); }
.q-question { font-size: 14px; }
.q-context { margin-top: 8px; font-size: 13px; color: var(--muted); }
.q-context > summary { cursor: pointer; font-weight: 600; }
.q-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: flex-start; }
.q-actions textarea { flex: 1 1 100%; }
.answer { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.kv { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; font-size: 13px; margin: 3px 0; align-items: baseline; }
.kv > span:first-child { color: var(--muted); }
.kv code { overflow-wrap: anywhere; }
.codebox { position: relative; margin: 10px 0 6px; }
.codebox .btn { position: absolute; top: 6px; right: 6px; background: var(--surface); border-color: var(--border); }
pre.code {
  margin: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; overflow-x: auto;
}
.codebox pre.code { padding-right: 64px; }
pre.code.small { font-size: 11.5px; max-height: 360px; overflow: auto; }
ul.files { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
ul.files li { overflow-wrap: anywhere; }

/* ---------- blueprint / diff / server ---------- */
.blueprint { font-size: 14px; line-height: 1.55; }
pre.diff { margin: 0; font-size: 12px; line-height: 1.45; white-space: pre; overflow-x: auto; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.d-add { color: var(--ok); }
.d-del { color: var(--err); }
.d-hunk { color: var(--accent); }
.d-file { color: var(--fg); font-weight: 700; }
.kvlist { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; }
.kvlist dt { color: var(--muted); }
.kvlist dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- markdown ---------- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .45em 0; }
.md ul, .md ol { margin: .4em 0; padding-left: 1.4em; }
.md li { margin: .15em 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: .9em 0 .4em; line-height: 1.25; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.08em; } .md h4, .md h5, .md h6 { font-size: 1em; }
.bubble .md h1, .bubble .md h2, .bubble .md h3 { font-size: 1.05em; }
.md code { background: var(--code-bg); padding: .05em .35em; border-radius: 4px; overflow-wrap: anywhere; }
.md pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; overflow-wrap: normal; }
.md blockquote { margin: .5em 0; padding: .1em .9em; border-left: 3px solid var(--border); color: var(--muted); }
.md table { border-collapse: collapse; margin: .6em 0; display: block; overflow-x: auto; max-width: 100%; font-size: .95em; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }
.md img { max-width: 100%; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: var(--gutter); bottom: var(--gutter); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 2 * var(--gutter))); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
}
.toast.lvl-warning { border-left-color: var(--warn); }
.toast.lvl-error { border-left-color: var(--err); }
.toast.lvl-success { border-left-color: var(--ok); }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- dialog, popover ---------- */
.dialog {
  width: min(540px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 32px); padding: 0;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 14, 20, .45); }
.start-form { padding: 16px 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dialog-head h3 { font-size: 17px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.popover {
  position: absolute; z-index: 50; width: min(380px, calc(100vw - 2 * var(--gutter))); padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.popover h4 { margin-bottom: 12px; }
.popover .check { margin-bottom: 14px; }

/* ---------- login ---------- */
.login { min-height: calc(100vh - 2 * var(--gutter)); display: grid; place-items: center; }
.login-card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.login-card p { margin: -6px 0 6px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .run-grid { display: flex; flex-direction: column; }
  .col-right { order: -1; border-left: 0; flex: 1; }
  .run-grid[data-mobile=timeline] .col-right { flex: none; }
  .run-grid[data-mobile=timeline] .tab-body { display: none; }
  .run-grid[data-mobile=tab] .col-left { display: none; }
  .col-left { flex: 1; }
  .mobile-only { display: inline-flex; }
  .tab.mobile-inactive.active { color: var(--muted); border-bottom-color: transparent; }
  .run-sub .branch { max-width: 100%; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .brand-text, .conc-label, .conn-label { display: none; }
  .nav a { padding: 6px 8px; }
  .run-title h2 { font-size: 14px; }
  .run-sub .sep, .run-sub .branch { display: none; }
  .bubble.mine { max-width: 92%; }
  .ev.indent, .ev.sub { padding-left: 14px; }
  .ev-time { display: none; }
  .composer-row .btn { padding: 7px 12px; }
  .kv { grid-template-columns: 56px minmax(0, 1fr); }
}

/* ---------- health banner ---------- */
.health {
  position: sticky; top: var(--top-h); z-index: 15; display: flex; align-items: flex-start; gap: 10px;
  padding: 8px var(--gutter); background: var(--err-soft); color: var(--err); border-bottom: 1px solid color-mix(in srgb, var(--err) 35%, var(--border));
  font-size: 13px;
}
.health-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.health ul { margin: 2px 0 0; padding-left: 18px; }
.health .toast-x { color: var(--err); }
.chip.ngrok-off { color: var(--muted); background: var(--surface-2); }
.popover .logout { margin-right: auto; }

/* ---------- Jira watcher ---------- */
.bubble.jira { flex: 0 1 auto; max-width: 80%; border-color: color-mix(in srgb, var(--st-preparing) 35%, var(--border)); background: color-mix(in srgb, var(--st-preparing) 7%, var(--bubble)); }
.bubble-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; margin-bottom: 4px; }
.jira-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--st-preparing); color: #fff; }
.ev.jira-st { color: var(--warn); }
.start-btn { position: relative; }
.cand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-waiting_hamza); box-shadow: 0 0 0 2px var(--surface); position: absolute; top: -3px; right: -3px; }
.cand-list { margin-top: 6px; border: 1px solid var(--border); border-radius: 8px; max-height: 220px; overflow-y: auto; background: var(--surface-2); }
.cand-title { padding: 6px 10px 4px; }
.cand { display: flex; align-items: center; gap: 4px; padding: 0 6px 0 0; border-top: 1px solid var(--border); }
.cand.selected { background: var(--accent-soft); }
.cand-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: none; cursor: pointer; text-align: left; font-size: 13px; }
.cand-pick:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.cand-pick:disabled { opacity: .55; cursor: default; }
.cand-summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand-src { font-size: 10.5px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--st-preparing); color: var(--st-preparing); }
.cand-x { font-size: 15px; line-height: 1; }
@media (max-width: 640px) { .cand-pick .jira-status { display: none; } .bubble.jira { max-width: 92%; } }

/* ---------- Jira comment gate, start errors ---------- */
.kind.kind-jira_comment { color: var(--st-preparing); }
.jc-label { margin: 8px 0 4px; }
.jc-preview { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
.jc-editor { margin-top: 10px; }
.jc-editor > summary { cursor: pointer; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.jc-edit { font-family: var(--mono); font-size: 12.5px; }
.subtask-chips { margin-top: 8px; }
.chip-btn { cursor: pointer; color: var(--fg); }
.chip-btn:hover { border-color: var(--accent); }
.cand.blocked .cand-pick { opacity: .5; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.popover .check-row .check { margin-bottom: 0; white-space: normal; }

/* ---------- GitHub reviews, re-open, archive ---------- */
.bubble.gh { border-color: color-mix(in srgb, var(--fg) 25%, var(--border)); background: var(--bubble); }
.gh-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--fg); color: var(--bg); }
.gh-state { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.gh-state.ok { background: var(--ok-soft); color: var(--ok); }
.gh-state.bad { background: var(--err-soft); color: var(--err); }
.gh-state.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.gh-where { font-size: 11.5px; background: var(--code-bg); padding: 0 5px; border-radius: 4px; overflow-wrap: anywhere; }
.gc-reply { color: var(--muted); margin: 2px 0 6px; }
.kind.kind-gh_comment { color: var(--fg); }
.ev.reopened { margin: 10px 0; }
.reopen-line { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--st-waiting_hamza); font-weight: 700; font-size: 13px; }
.reopen-line::before, .reopen-line::after { content: ""; flex: 1; height: 2px; background: var(--st-waiting_hamza); opacity: .55; border-radius: 2px; }
.watching { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.watching .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: pulse 2.4s ease-in-out infinite; }
.card.archived { opacity: .55; filter: grayscale(.6); }
.archived-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.archived-toggle { color: var(--muted); }
.archived-toggle.on { color: var(--fg); background: var(--surface-2); }
@media (max-width: 640px) { .archived-toggle { display: none; } }

/* ---------- structured questions, Mailpit ---------- */
.q-block { margin: 0 0 10px; }
.q-label { margin: 0 0 3px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.q-scenario > .md { padding-left: 12px; border-left: 3px solid var(--border); color: var(--fg); font-size: 13.5px; }
.q-recommend .q-rec { background: var(--accent-soft); color: var(--fg); border-radius: 8px; padding: 6px 10px; }
.q-why > .md { font-size: 13.5px; }
.btn.option.recommended { color: var(--accent-fg); border-color: var(--accent); }
.rec-line { font-size: 13px; margin: -2px 0 8px; }
.mailpit-link.disabled, .btn.disabled { opacity: .45; cursor: not-allowed; text-decoration: none; }
.btn.option.recommended:hover { background: var(--accent); color: var(--accent-fg); filter: brightness(1.08); }
