/* Tahara Workbench: a night desk for supervising agents.
   One idea carries the design: color says who holds the next move.
   Saffron is yours (decisions, approvals, primary buttons). Pool blue is the agents' (running
   work). Sage means done, coral means broken. Everything else is quiet ink and bone, so a glance
   at the list tells you whether anything is waiting on you.
   Type: Geologica for everything people read; JetBrains Mono only for real code, paths and hashes. */
:root {
  --bg: #10131b;
  --panel: #161a24;
  --raised: #1c2130;
  --sunken: #0c0f15;
  --line: #242a39;
  --line-strong: #343c50;
  --ink: #ece6da;
  --ink-2: #c3bdb1;
  --muted: #8e909b;
  --you: #f0b54a;
  --you-ink: #1d1404;
  --you-soft: #2b2214;
  --you-glow: rgb(240 181 74 / 14%);
  --you-text: #f7cb78;
  --agent: #7ab5e2;
  --agent-soft: #152338;
  --ok: #94c58c;
  --ok-soft: #18271a;
  --danger: #ef826f;
  --danger-soft: #33191a;
  --shadow: 0 18px 40px rgb(3 5 10 / 55%);
  --sans: "Geologica", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --r-lg: 12px;
  --r: 9px;
  --r-sm: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 300 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, h5, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; font-weight: 500; letter-spacing: -.01em; }
strong, b { font-weight: 500; }
a { color: var(--agent); text-underline-offset: .22em; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
code { font: .84em var(--mono); color: var(--ink-2); background: var(--sunken); border-radius: 4px; padding: .1em .38em; overflow-wrap: anywhere; }
ul, ol { margin: .4rem 0 0; padding-left: 1.15rem; }
li + li { margin-top: .3rem; }
.muted { color: var(--muted); }
.key { color: var(--muted); font-size: .78rem; font-weight: 400; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: .76rem; }
.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.error-text { color: var(--danger); font-size: .875rem; }
.error-text:empty { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Controls. Primary buttons are always a move of yours, so they wear saffron. */
button, input, select, textarea { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.3rem; padding: .35rem .95rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--raised); color: var(--ink); font-size: .875rem; font-weight: 400; cursor: pointer; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--you); border-color: var(--you); color: var(--you-ink); font-weight: 500; }
button.primary:hover:not(:disabled) { background: var(--you-text); border-color: var(--you-text); }
button.danger { background: var(--danger); border-color: var(--danger); color: #230b07; font-weight: 500; }
button.ghost, button.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover:not(:disabled), button.quiet:hover:not(:disabled) { color: var(--ink); background: var(--raised); }
button.compact { min-height: 1.9rem; padding: .15rem .65rem; font-size: .8rem; }
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--you); outline-offset: 2px; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 2.35rem; padding: .45rem .65rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--sunken); font-weight: 300;
}
textarea { resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--muted); }
select { appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
:is(input, select, textarea):disabled { opacity: .65; }
label { display: grid; gap: .32rem; font-size: .82rem; font-weight: 400; color: var(--ink-2); }
.checkbox { display: flex; align-items: flex-start; gap: .6rem; font-weight: 300; color: var(--ink); }
.checkbox input { width: auto; min-height: 0; margin-top: .3rem; accent-color: var(--you); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
details > summary { cursor: pointer; font-weight: 400; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: .5rem; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: .4rem; height: .4rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: .1rem; }
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { color: var(--ink); }

/* Tags: soft pills that only ever carry state. */
.chip, .tag, .stage-tag, .severity {
  display: inline-flex; align-items: center; gap: .3rem; padding: .08rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 400; line-height: 1.6; white-space: nowrap; background: var(--raised); color: var(--ink-2);
}
.tag.positive, .stage-tag.shipped { background: var(--ok-soft); color: var(--ok); }
.tag.warning { background: var(--you-soft); color: var(--you-text); }
.tag.error, .severity.blocking { background: var(--danger-soft); color: var(--danger); }
.tag.info, .stage-tag.building, .stage-tag.review, .stage-tag.qa { background: var(--agent-soft); color: var(--agent); }
.stage-tag.inbox { background: var(--raised); color: var(--ink-2); }
.severity { font-weight: 500; }
.mark { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 10px;
  background: var(--you); color: var(--you-ink); font: 600 1.15rem/1 "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", system-ui, sans-serif; flex: none; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding-block: 1rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: radial-gradient(60rem 30rem at 50% -10%, var(--you-glow), transparent 70%), var(--bg); }
.login-card { width: min(100%, 370px); display: grid; gap: 1rem; padding: 1.8rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.login-card h1 { font-size: 1.5rem; }

/* App shell */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.topbar { display: flex; align-items: center; gap: .9rem; padding-block: .55rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); border-bottom: 1px solid var(--line); background: var(--bg); min-width: 0; }
.brand { display: flex; align-items: center; gap: .6rem; font-size: .98rem; font-weight: 500; white-space: nowrap; }
.sprint-picker { display: block; }
.sprint-select { width: auto; min-height: 2rem; padding: .2rem 2rem .2rem .8rem; border-radius: 999px; border-color: var(--line-strong); background-color: var(--panel); font-size: .84rem; font-weight: 400; }
.topbar-meta { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .1rem; }
.runner-state { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .8rem; margin-right: .6rem; white-space: nowrap; }
.runner-state::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.runner-state.off::before { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.layout { display: grid; grid-template-columns: minmax(310px, 390px) 1fr; min-height: 0; }

/* Task rail */
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
.sidebar-head { display: grid; gap: .65rem; padding: .9rem .9rem .75rem; }
.segmented { display: grid; grid-template-columns: repeat(4, auto); gap: .2rem; padding: .2rem; border-radius: var(--r); background: var(--sunken); }
.segmented button { min-height: 2rem; padding: .2rem .4rem; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: .8rem; }
.segmented button:hover:not(:disabled) { color: var(--ink); }
.segmented button.selected { color: var(--ink); background: var(--raised); }
.segmented [data-count] { font-size: .74rem; color: var(--muted); }
.segmented .alert-count [data-count] { color: var(--you-ink); background: var(--you); border-radius: 999px; padding: 0 .38rem; font-weight: 500; }
.task-list { flex: 1; overflow: auto; padding: 0 .55rem 1rem; overscroll-behavior: contain; }
.rail-hint { padding: .55rem .9rem .7rem; font-size: .74rem; color: var(--muted); border-top: 1px solid var(--line); }
.group-title { display: flex; align-items: center; gap: .5rem; padding: 1rem .45rem .35rem; color: var(--muted); font-size: .8rem; font-weight: 400; }
.group-title .count { margin-left: auto; font-size: .76rem; }
.group-title.you { color: var(--you-text); font-weight: 500; }
.group-title.running { color: var(--agent); }

.task-row { display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem; width: 100%; padding: .6rem .65rem; border: 1px solid transparent; border-radius: var(--r); background: transparent; text-align: left; white-space: normal; align-items: start; }
.task-row + .task-row { margin-top: .15rem; }
.task-row:hover:not(:disabled) { background: var(--raised); border-color: transparent; }
.task-row.selected { background: var(--raised); border-color: var(--line-strong); }
.task-row.cursor { border-color: var(--muted); }
.task-row .title { grid-column: 1 / -1; font-size: .92rem; font-weight: 400; line-height: 1.35; overflow-wrap: anywhere; color: var(--ink); }
.task-row .status { grid-column: 1 / -1; display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .79rem; min-width: 0; }
.task-row .status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .excerpt { grid-column: 1 / -1; color: var(--ink-2); font-size: .8rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* The one loud element: a task waiting on you. */
.task-row.you { background: var(--you-soft); border-color: rgb(240 181 74 / 22%); }
.task-row.you:hover:not(:disabled), .task-row.you.selected { background: #352914; border-color: rgb(240 181 74 / 45%); }
.task-row.you .status { color: var(--you-text); font-weight: 400; }
.task-row.running .status { color: var(--agent); }
.task-row.stale .status { color: var(--danger); }
.task-children { margin-inline-start: .9rem; padding-inline-start: .45rem; border-inline-start: 1px solid var(--line-strong); }
.dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.you { background: var(--you); }
.dot.running { background: var(--agent); animation: pulse 1.6s ease-in-out infinite; }
.dot.done { background: var(--ok); }
.dot.error { background: var(--danger); }
.sprint-head { display: flex; align-items: baseline; gap: .5rem; padding: 1.2rem .45rem .1rem; font-size: .9rem; font-weight: 500; color: var(--ink); }
.sprint-head .key { margin-left: auto; }
.list-empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); font-size: .88rem; }

/* Detail */
.detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.placeholder { margin: auto; display: grid; justify-items: center; gap: .9rem; max-width: 300px; text-align: center; color: var(--muted); padding: 2rem; }
.detail-head { padding: 1.3rem 2rem 1.1rem; border-bottom: 1px solid var(--line); }
.detail-head .row { gap: .6rem; }
.detail-head h2 { margin: .55rem 0 .5rem; font-size: 1.7rem; line-height: 1.22; overflow-wrap: anywhere; max-width: 34ch; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.1rem; color: var(--muted); font-size: .84rem; }
.meter { display: inline-flex; align-items: center; gap: .5rem; }
.meter i { display: block; width: 4.5rem; height: .32rem; border-radius: 999px; background: var(--raised); overflow: hidden; }
.meter i b { display: block; height: 100%; background: var(--agent); border-radius: inherit; }
.meter.full i b { background: var(--you); }
.back { display: none; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.detail-body { flex: 1; overflow: auto; padding: 1.4rem 2rem 3rem; overscroll-behavior: contain; display: grid; align-content: start; grid-auto-rows: max-content; gap: 1rem; }
.detail-body > * { max-width: 860px; min-width: 0; }
.detail-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .55rem; padding: .75rem 2rem; border-top: 1px solid var(--line); background: var(--panel); }

/* Pipeline track: five stations. Filled stations are done; the current one takes the color of
   whoever holds it (blue while an agent works, saffron while it waits on you). */
.timeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem; list-style: none; padding: 0; margin: 1.05rem 0 0; }
.timeline li { margin: 0; display: grid; gap: .4rem; }
.timeline li::before { content: ""; height: .3rem; border-radius: 999px; background: var(--raised); }
.timeline li span { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline li.done::before { background: var(--ok); opacity: .7; }
.timeline li.done span { color: var(--ink-2); }
.timeline li.current::before { background: var(--ink-2); }
.timeline li.running::before { background: var(--agent); animation: pulse 1.6s ease-in-out infinite; }
.timeline li.waiting::before { background: var(--you); }
.timeline li:is(.current, .running, .waiting) span { color: var(--ink); font-weight: 400; }
.timeline li.waiting span { color: var(--you-text); }

/* Sections */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem 1.25rem; }
.panel > header { margin-bottom: .65rem; }
.panel h3 { font-size: 1.05rem; }
.panel h4 { font-size: .86rem; font-weight: 500; color: var(--ink-2); margin-bottom: .45rem; }
.panel p + p { margin-top: .4rem; }
.disclosure { padding: .85rem 1.25rem; }
.disclosure > summary { font-size: .95rem; font-weight: 400; }
.disclosure-body { margin-top: .85rem; display: grid; gap: .75rem; }
.disclosure .panel { border: 0; padding: 0; background: transparent; }
.inline-disclosure { margin-top: .8rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.inline-disclosure > :not(summary) { margin-top: .6rem; }
.inline-disclosure > summary { font-size: .86rem; }
.section-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-bottom: .65rem; }
.runner-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, .9fr); gap: .65rem; }
.account-field { grid-column: 1 / -1; }
.files { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.files code { font-size: .72rem; }
pre { margin: 0; max-height: 26rem; overflow: auto; padding: .8rem .9rem; background: var(--sunken); border-radius: var(--r); font: .78rem/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.alert { padding: .6rem .8rem; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); font-size: .86rem; }

/* Diff: colored lines, one file at a time readable on a phone. */
.review-diff { margin-top: .8rem; }
.review-diff pre { white-space: pre; max-height: 70vh; padding: .5rem 0; }
.review-diff pre span { display: block; padding: 0 .9rem; min-height: 1.6em; }
.review-diff .d-add { background: rgb(148 197 140 / 10%); color: #c4e3bd; }
.review-diff .d-del { background: rgb(239 130 111 / 10%); color: #f2b3a7; }
.review-diff .d-hunk { color: var(--agent); background: var(--agent-soft); margin-top: .35rem; }
.review-diff .d-file { color: var(--ink); font-weight: 500; background: var(--raised); margin-top: .9rem; padding-block: .3rem; border-block: 1px solid var(--line); }
.review-diff .d-file:first-child { margin-top: 0; }
.review-diff .d-meta { color: var(--muted); }

/* Your move: the decision card. The page's one bold surface. */
.attention { position: relative; border-radius: var(--r-lg); padding: 1.15rem 1.3rem 1.2rem; background: linear-gradient(180deg, var(--you-soft), #221c13); border: 1px solid rgb(240 181 74 / 30%); box-shadow: 0 0 0 4px var(--you-glow); }
.attention > strong { display: block; font-size: 1.12rem; font-weight: 500; color: var(--you-text); margin-bottom: .3rem; }
.attention p { color: var(--ink); max-width: 68ch; }
.attention.error, .attention.blocked, .attention.budget { background: var(--danger-soft); border-color: rgb(239 130 111 / 35%); box-shadow: none; }
.attention.error > strong, .attention.blocked > strong, .attention.budget > strong { color: var(--danger); }
.attention.stopped { background: var(--panel); border-color: var(--line-strong); box-shadow: none; }
.attention.stopped > strong { color: var(--ink); }
.attention .inline-form { display: grid; gap: .65rem; justify-items: start; margin-top: .9rem; }
.attention .inline-form label:not(.checkbox) { width: 100%; }
.attention .inline-disclosure { border-top-color: rgb(240 181 74 / 20%); }
.mobile-api-report { list-style: none; margin: .85rem 0; padding: 0; display: grid; gap: .65rem; }
.mobile-api-report > li { padding: .8rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--panel); }
.mobile-api-report > li > p { margin-top: .35rem; }
.mobile-api-report dl { margin: .55rem 0 0; }
.mobile-api-report dt { color: var(--muted); font-size: .8rem; }
.mobile-api-report dd { margin: .1rem 0 .4rem; }

/* An agent is working: blue, with a running line along the top. */
.job-status { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: .95rem 1.2rem; background: var(--agent-soft); border: 1px solid rgb(122 181 226 / 22%); }
.job-status::before { content: ""; position: absolute; inset: 0 auto auto 0; height: 2px; width: 35%; background: var(--agent); animation: run 2.2s ease-in-out infinite; }
.job-status.stale { background: var(--danger-soft); border-color: rgb(239 130 111 / 35%); }
.job-status.stale::before { background: var(--danger); }
.job-status .section-heading > span { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); }
.job-status .section-heading strong { font-weight: 500; }
.pulse { width: .55rem; height: .55rem; border-radius: 50%; background: var(--agent); animation: pulse 1.6s ease-in-out infinite; }
.note-form { display: flex; gap: .5rem; margin-top: .75rem; }
.job-status .muted { margin-top: .45rem; font-size: .8rem; }

/* The plan reads like a short brief: summary, ordered steps, the checks that define done. */
.plan-panel { padding: 1.35rem 1.5rem; }
.plan-summary { font-size: 1.06rem; line-height: 1.7; color: var(--ink); max-width: 66ch; padding-bottom: 1.1rem; }
.plan-steps { list-style: none; padding: 0; counter-reset: step; display: grid; gap: 1rem; margin: 0 0 1.2rem; }
.plan-steps > li { counter-increment: step; display: grid; grid-template-columns: 1.9rem 1fr; gap: .75rem; margin: 0; }
.plan-steps > li::before { content: counter(step); display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--ink-2); font-size: .8rem; }
.plan-step h5 { font-size: .96rem; font-weight: 500; line-height: 1.45; padding-top: .12rem; }
.plan-step p { color: var(--ink-2); font-size: .9rem; margin-top: .15rem; max-width: 66ch; }
.plan-checks, .plan-out { padding: .9rem 1.05rem; border-radius: var(--r); background: var(--raised); margin-bottom: .75rem; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { position: relative; padding-left: 1.55rem; font-size: .9rem; }
.checklist li::before { content: ""; position: absolute; left: .1rem; top: .32rem; width: .8rem; height: .8rem; border: 1.5px solid var(--ok); border-radius: 3px; }
.plan-out ul { font-size: .88rem; color: var(--ink-2); }
.questions { margin-top: 1.2rem; display: grid; gap: .7rem; }
.questions > h4 { color: var(--you-text); font-size: .95rem; margin: 0; }
.questions > p { font-size: .82rem; }
.question-card { padding: .9rem 1rem; border-radius: var(--r); background: var(--you-soft); border: 1px solid rgb(240 181 74 / 20%); display: grid; gap: .45rem; }
.question-card strong { font-size: .95rem; }
.question-card p { font-size: .82rem; }
.plan-feedback { margin-top: 1.2rem; padding-top: 1.05rem; border-top: 1px solid var(--line); display: grid; gap: .75rem; }
.plan-feedback .section-actions { margin-top: 0; }
.plan-image-paste { position: relative; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .65rem; padding: .75rem .85rem; border: 1px dashed var(--line-strong); border-radius: var(--r); cursor: pointer; }
.plan-image-paste:focus-within, .plan-image-paste:hover { border-color: var(--muted); }
.plan-image-paste small { display: block; color: var(--muted); }
.plan-image-paste input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.plan-image-pick { color: var(--ink); font-size: .82rem; }
.plan-images { display: flex; flex-wrap: wrap; gap: .65rem; }
.plan-images:not(:empty) { margin-top: .65rem; }
.plan-image { width: 120px; margin: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; text-align: center; }
.plan-image img { display: block; width: 100%; height: 78px; object-fit: contain; background: var(--sunken); }

/* Review and QA */
.findings { display: grid; gap: .5rem; margin-top: .8rem; }
.finding { padding: .7rem .8rem; border-radius: var(--r); background: var(--raised); }
.finding p { font-size: .87rem; margin-top: .3rem; }
.finding.checkbox > span { display: block; min-width: 0; flex: 1; }
.qa-checks { list-style: none; padding: 0; }
.qa-checks li { padding: .55rem 0; border-top: 1px solid var(--line); font-size: .88rem; }
.qa-checks li:first-child { border-top: 0; }
.qa-checks details { margin-top: .3rem; }
.qa-checks details summary { font-size: .78rem; }
.qa-checks .tag { margin-right: .4rem; }

/* Runs and tokens per phase */
.usage-table { display: grid; gap: .55rem; font-size: .85rem; }
.usage-row { display: grid; grid-template-columns: 6.5rem 1fr auto; gap: .75rem; align-items: center; }
.usage-row i { display: block; height: .45rem; border-radius: 999px; background: var(--raised); overflow: hidden; }
.usage-row i b { display: block; height: 100%; background: var(--agent); border-radius: inherit; }
.usage-row span:last-child { color: var(--muted); text-align: right; white-space: nowrap; }

/* Activity: a quiet vertical log. */
.activity { display: grid; gap: 0; font-size: .85rem; }
.activity > div { display: grid; grid-template-columns: 5.5rem 1fr; gap: .8rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.activity > div:first-child { border-top: 0; }
.activity time { color: var(--muted); font-size: .78rem; padding-top: .1rem; }

/* Settings */
dialog { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 0; }
dialog::backdrop { background: rgb(4 6 10 / 70%); }
.settings { width: min(calc(100% - 32px), 640px); max-height: min(90vh, 920px); }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.35rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.settings-head h2 { font-size: 1.15rem; }
.settings section { padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--line); display: grid; gap: .7rem; }
.settings section:last-of-type { border-bottom: 0; }
.settings h3 { font-size: .98rem; }
.settings p { font-size: .86rem; color: var(--muted); max-width: 68ch; }
.settings form { display: grid; gap: .7rem; justify-items: start; }
.settings form > :is(label, .role, div) { width: 100%; }
.role { padding: .8rem .9rem; border-radius: var(--r); background: var(--raised); display: grid; gap: .5rem; }
.role strong { font-size: .9rem; }
.role p { font-size: .8rem; }
.limits { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.providers { display: flex; flex-wrap: wrap; gap: .4rem; }
.limits label { padding: .6rem .75rem; border-radius: var(--r); background: var(--raised); font-size: .76rem; color: var(--muted); }
.limits input { font-size: 1.05rem; }
.checkbox small, .secret small { display: block; font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.secret { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .3rem .5rem; }
.secret > small { grid-column: 1 / -1; margin-top: 0; }
#settings-error { padding: 0 1.35rem 1rem; }

/* Toast */
.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: .65rem 1rem; border-radius: var(--r); background: var(--ink); color: var(--bg); font-size: .88rem; font-weight: 400; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #230b07; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes run { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* Narrow screens: the rail and the task become separate views; actions sit at the thumb. */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: .5rem .6rem; }
  .topbar-meta, .runner-state, .rail-hint { display: none; }
  .layout { grid-template-columns: 1fr; }
  .app.show-detail .sidebar { display: none; }
  .app:not(.show-detail) .detail { display: none; }
  .back { display: inline-flex; }
  .detail-head, .detail-body, .detail-foot { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .detail-head h2 { font-size: 1.4rem; }
  .detail-foot { position: sticky; bottom: 0; padding-bottom: max(.75rem, env(safe-area-inset-bottom, 0px)); }
  .detail-foot button { flex: 1; }
  .runner-fields { grid-template-columns: 1fr 1fr; }
  .runner-fields > :first-child { grid-column: 1 / -1; }
  .limits { grid-template-columns: 1fr; }
  .attention .section-actions button { flex: 1 1 auto; }
}
@media (max-width: 460px) {
  .brand-name { display: none; }
  .topbar-actions button { padding-inline: .5rem; }
  .field-grid { grid-template-columns: 1fr; }
  .timeline li span { font-size: .68rem; }
  .usage-row { grid-template-columns: 5rem 1fr auto; }
  .activity > div { grid-template-columns: 1fr; gap: .1rem; }
}

/* A failure waiting on you is still your move, but it reads as broken, not as a decision. */
.task-row.you.broken { background: var(--danger-soft); border-color: rgb(239 130 111 / 25%); }
.task-row.you.broken:hover:not(:disabled), .task-row.you.broken.selected { background: #3d1e1d; border-color: rgb(239 130 111 / 45%); }
.task-row.you.broken .status { color: var(--danger); }

/* Chat with the implementer */
.chat-thread { display: flex; flex-direction: column; gap: .6rem; max-height: 26rem; overflow-y: auto; margin: .75rem 0; padding-right: .2rem; }
.chat-msg { max-width: 92%; padding: .65rem .85rem; border-radius: var(--r-lg); background: var(--agent-soft); border: 1px solid rgb(122 181 226 / 18%); }
.chat-msg.you { align-self: flex-end; background: var(--you-soft); border-color: rgb(240 181 74 / 22%); }
.chat-msg.error { background: var(--danger-soft); border-color: rgb(239 130 111 / 35%); }
.chat-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .75rem; color: var(--muted, inherit); margin-bottom: .3rem; }
.chat-meta strong { color: var(--ink); font-weight: 500; }
.chat-text { line-height: 1.5; }
.chat-msg button { margin-top: .5rem; }
.chat-wait { display: flex; align-items: center; gap: .5rem; }
.chat-form textarea { width: 100%; }
.chat-form .section-actions { margin-top: .5rem; }

.button-link { display: inline-flex; align-items: center; min-height: 2.3rem; padding: .35rem .95rem; border: 1px solid transparent;
  border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; }
.button-link:hover { color: var(--ink); background: var(--raised); }
.button-link[hidden] { display: none; }
.chat-panel { border-left: 3px solid var(--you); }
/* Running status: long agent progress wraps instead of being clipped. */
.task-row.running .status { align-items: flex-start; }
.task-row.running .status span:last-child { white-space: normal; overflow: visible; overflow-wrap: anywhere; line-height: 1.4; }
.task-row.running .status .dot { margin-top: .3rem; flex: none; }
.job-status .section-heading > span { flex-wrap: wrap; min-width: 0; flex: 1 1 16rem; row-gap: .2rem; }
.job-status .section-heading > span .muted { overflow-wrap: anywhere; }
.job-status .pulse { flex: none; }
.agent-role { display: grid; gap: .6rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.agent-role legend { float: left; width: 100%; font-weight: 500; color: var(--ink); margin-bottom: .2rem; }
.agent-role label.check { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: .5rem; font-size: .85rem; color: var(--muted); }
.agent-role label.check input { width: 1rem; height: 1rem; min-height: 0; margin: 0; padding: 0; flex: none; }
.agent-role:has([name="useDefault"]:checked) .runner-fields { opacity: .45; pointer-events: none; }
.agent-role[disabled] { opacity: .6; }
.runner-fields label > input[name="model"] { margin-top: .4rem; }

.optimize { width: min(calc(100% - 32px), 920px); }
.optimize .row { display: flex; gap: .7rem; align-items: end; flex-wrap: wrap; }
.routes { width: 100%; border-collapse: collapse; font-size: .85rem; }
.routes th { text-align: left; color: var(--muted); font-weight: 500; padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
.routes td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.routes td:first-child { word-break: break-all; }
.routes td:nth-child(2), .routes td:nth-child(3) { white-space: nowrap; }
.routes .share { display: inline-block; width: 48px; height: 6px; border-radius: 3px; background: var(--line); margin-right: .4rem; overflow: hidden; vertical-align: middle; }
.routes .share i { display: block; height: 100%; background: var(--agent); }
