/* style.css — pi companion. Tokens first; every colour, radius and shadow below comes from them. */

:root {
  --bg: #0c0d10; --bg-2: #111318; --surface: #16181e; --surface-2: #1d2028; --raised: #20242d;
  --line: rgba(255, 255, 255, .075); --line-2: rgba(255, 255, 255, .14);
  --text: #eceef2; --text-2: #c3c8d2; --muted: #80868f;
  --accent: #8ea6ff; --accent-soft: rgba(142, 166, 255, .14); --on-accent: #0a0d18;
  --work: #f0b45b; --wait: #45d183; --err: #ff6b7f;
  --user: #1f2536; --code-bg: #0f1116;
  --shadow: 0 10px 34px rgba(0, 0, 0, .45); --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
  --r: 12px; --r-lg: 18px;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --blur: saturate(160%) blur(16px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9; --bg-2: #eef0f4; --surface: #ffffff; --surface-2: #f2f3f6; --raised: #ffffff;
    --line: rgba(16, 24, 40, .08); --line-2: rgba(16, 24, 40, .15);
    --text: #14161b; --text-2: #394150; --muted: #6b7280;
    --accent: #3b5bf0; --accent-soft: rgba(59, 91, 240, .1); --on-accent: #ffffff;
    --work: #c27a0e; --wait: #16a05a; --err: #d63a50;
    --user: #e7ecff; --code-bg: #f3f4f7;
    --shadow: 0 10px 34px rgba(16, 24, 40, .14); --shadow-sm: 0 2px 10px rgba(16, 24, 40, .08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--sans); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body { height: 100dvh; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.big { width: 36px; height: 36px; stroke-width: 1.4; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }
.pad { padding: 10px 12px; }
.err { color: var(--err); }

/* ── what may be selected ──────────────────────────────────────────────────────
   The transcript is a document; the chrome around it is an interface. A drag that
   starts inside a message used to run on into the session list, the header and the
   composer, so lifting the finger copied drawer labels along with the answer — the
   "selection extends into the left side panel" complaint. Denied at the ROOT rather
   than enumerated per panel, on purpose: a list of chrome to lock would drift the
   moment someone adds a panel, and the failure is silent (selection just leaks
   again). Reading surfaces get text back explicitly:
     • #view — the transcript, the thing worth copying;
     • form fields — a textarea must stay selectable AND editable;
     • the plan and swarm overlays — their prose is worth copying, and they sit over
       the page rather than beside it, so they cannot be part of a leaking drag.
   The per-element rules further down (.tool .dl .dm, .tool .term .prompt) still win
   where they are deliberate: a shell prompt or a gutter marker should not come along
   when copying a command. */
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#view, textarea, input, [contenteditable="true"], #planview .pv, #swarmview .pv {
  user-select: text; -webkit-user-select: text; -webkit-touch-callout: default;
}
/* A highlight that reads on both token sets and stays visible over --code-bg; the
   platform default is inconsistent and was near-invisible on dark code blocks. */
::selection { background: color-mix(in srgb, var(--accent) 38%, transparent); color: var(--text); }
::-moz-selection { background: color-mix(in srgb, var(--accent) 38%, transparent); color: var(--text); }

/* ── layout: drawer + main ───────────────────────────────────────────────────── */
#app { display: flex; height: 100dvh; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100dvh; position: relative; background: var(--bg); }
#drawer { width: 316px; flex: none; display: flex; flex-direction: column; height: 100dvh; position: relative;
  background: var(--bg-2); border-right: 1px solid var(--line); }
#scrim { display: none; }

.dhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 58px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
button.brand { background: none; border: 0; padding: 0; text-align: left; }
button.brand:hover .logo { border-color: var(--accent); color: var(--accent); }
.logo { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 16px;
  background: linear-gradient(135deg, var(--accent), #b388ff); color: var(--on-accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; transition: background .3s; }
.dot.up { background: var(--wait); } .dot.down { background: var(--err); }
.newbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px 0 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; font-weight: 600; }
.newbtn[hidden] { display: none; }
.newbtn svg.i { width: 16px; height: 16px; stroke-width: 2.2; }
.newbtn:hover { border-color: var(--accent); color: var(--accent); }
#dfilters { padding: 0 12px 6px 16px; }
.filters { display: flex; gap: 8px; }
.chip { background: var(--surface); border: 1px solid var(--line); color: var(--text-2); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; transition: border-color .15s, color .15s, background .15s; }
.chip.on { border-color: color-mix(in srgb, var(--wait) 60%, transparent); color: var(--wait); background: color-mix(in srgb, var(--wait) 10%, transparent); }
#slist { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 4px 8px calc(env(safe-area-inset-bottom) + 90px); }
h2.machine { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 10px 4px; }
.dempty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.dempty p { margin: 6px 0; }

.sitem { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0;
  border-radius: var(--r); padding: 10px; margin: 1px 0; position: relative; transition: background .12s; }
.sitem:hover { background: var(--surface); }
.sitem.on { background: var(--surface-2); }
.sitem.on::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--accent); }
.sbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.srow1 { display: flex; gap: 8px; align-items: baseline; }
.stitle { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.when { color: var(--muted); font-size: 11.5px; flex: none; font-variant-numeric: tabular-nums; }
.slast { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitem[data-state="stopped"] .stitle, .sitem[data-state="removing"] .stitle { color: var(--muted); font-weight: 500; }

.fab, .fab[hidden] { display: none; }

/* ── condition icons: working spins, needs-you pulses, parked is hollow, done is a check ── */
.st { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.sitem .st { margin-top: 1px; }
.st::before { content: ""; display: block; box-sizing: border-box; }
.st.working::before, .st.removing::before, .st.deleting::before { width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--work) 30%, transparent); border-top-color: var(--work); animation: spin .8s linear infinite; }
.st.removing::before, .st.deleting::before { border-color: var(--line-2); border-top-color: var(--muted); }
.st.waiting::before { width: 9px; height: 9px; border-radius: 50%; background: var(--wait); animation: ping 1.8s ease-out infinite; }
.st.idle::before, .st.unknown::before { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.st.stopped::before { width: 5px; height: 10px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.st.offline::before { width: 9px; height: 9px; border-radius: 50%; background: var(--err); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--wait) 55%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── transcript raster budget ───────────────────────────────────────────────────
   Entries paint only while on screen: with a long conversation the layout+paint of
   thousands of offscreen nodes is what capped scrolling (and made text selection
   repaint the world — copy/paste jank) well under a 120 Hz panel. The live bubble
   is excluded: it grows every repaint and must lay out truthfully.

   Both the `auto` keyword and the 120px fallback were MEASURED, not chosen by feel.
   `npm run e2e` runs a CV-POLICY experiment that re-opens a long transcript — which
   destroys the row elements, so every row above the reader is unrendered and the
   fallback is genuinely in force — and flings up under each candidate while counting
   layout-shift entries. `E2E_BENCH=1 npm run e2e` prices the same policies at two
   scales. Numbers from this tree:

     policy                        shifts over a 2.2k px fling   rebuild    maxFrame  frames>50ms
     as shipped (auto 120px)       4, sum 0.294, back=1          1.75ms@80   16.9ms      0
     blanket 320px                 2, sum 0.507, back=0          6.94ms@400  22.4ms      0
     content-visibility off        0, sum 0,      back=0          6.02ms@400  62.4ms      5

   Read as decisions rather than a table:
     • Dropping containment is REJECTED. It does remove all four shifts, but at 400 rows it
       costs a 62ms frame against 22ms, five frames over 50ms, and 141 frames per 3s instead
       of 183 — about 47fps versus 61fps. Trading four small shifts for visible frame drops
       is a worse version of the complaint this rule exists to fix. (The bench rebuilds with
       innerHTML, harsher than the app's in-place reconcile, but identically harsh for both
       policies, so the comparison holds.)
     • A bigger blanket estimate is REJECTED: 320px halved the shift COUNT (4 → 2) but made
       total displacement WORSE (0.294 → 0.507). Overestimating collapses content as it
       renders, which moves the reader further than underestimating expands it.
     • 120px stays because it sits at the measured median row height (119px; p90 209px). The
       residual shifts are rows taller than the median, which no single number fixes, and two
       of the four were input-attributed (hadRecentInput) so they do not count toward CLS.
   The change that WOULD remove them is a per-row measured height persisted across session
   switches: `contain-intrinsic-size: auto` already remembers each element's last rendered
   size, but that memory lives on the element and dies with it — precisely when it is needed.
   Not done: it costs a ResizeObserver plus storage to chase 0.294 of partly-input-attributed
   shift, while the frame-time evidence above says the containment is what keeps scrolling
   smooth in the first place. Re-run both measurements before revisiting. */
.msg:not(.live), .tool:not(.live), .tprompt {
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
}

/* ── header ──────────────────────────────────────────────────────────────────── */
#bar { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px 12px;
  position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line);
  /* solid, not color-mix + backdrop-filter: a blur under a sticky bar re-blurs every
     scrolled frame — software-composited on Android Firefox, it alone held scrolling
     near 10 fps. The 82 % mix read as solid anyway. */
  background: var(--bg); }
#heading { flex: 1; min-width: 0; }
#title { font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#subtitle { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; min-height: 18px; margin-top: 1px; }
#subtitle .muted { font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { width: 40px; height: 40px; padding: 0; border-radius: 12px; border: 0; background: none; display: inline-grid; place-items: center; flex: none; color: var(--text-2); }
.iconbtn[hidden] { display: none; }
.iconbtn:hover { background: var(--surface); color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 4px; flex: none; white-space: nowrap; font-size: 11.5px; font-weight: 600;
  padding: 1px 9px 1px 4px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.badge .st { width: 14px; height: 14px; transform: scale(.85); }
.badge.waiting { color: var(--wait); background: color-mix(in srgb, var(--wait) 12%, transparent); }
.badge.working { color: var(--work); background: color-mix(in srgb, var(--work) 12%, transparent); }
.badge.offline { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }

/* ── transcript ──────────────────────────────────────────────────────────────── */
/* overflow-anchor stays at its DEFAULT (auto) here, deliberately. It was a candidate for
   `none`, so that keepPlace() in app/view.ts would be the only thing compensating for content
   growing above the reader. Both were measured with the e2e scroll probe — a real touch fling
   over a long transcript while a reply streams, sampling scrollTop, layout-shift entries and
   every programmatic scroll write once per frame:

     default (auto):  shifts=1 sum=0.02 back=0 writes=0   (1412px of travel)
     none:            shifts=1 sum=0.02 back=0 writes=0   (1412px of travel)

   Identical, so `none` buys nothing — and it would cost something. Browser scroll anchoring
   is the only compensation available when a content-visibility row (see .msg/.tool below)
   swaps its 120px estimate for its real height as it scrolls into view: no paint happens
   then, so keepPlace never runs and cannot help. Removing a protection that measures free is
   a bad trade. Re-measure with `npm run e2e` and grep ANCHORING before revisiting.

   Measured again in CI's container (Chromium 153, 36 fonts) and the trade is worse than "buys
   nothing": with anchoring OFF, a late tool result growing the anchor row itself drifts the
   reader 164px and loses the topmost message outright, where with it ON the place holds to the
   pixel. keepPlace cannot cover that case on its own — offsetTop on a skipped row is an
   estimate, so it read delta=-21 for a real +82px growth and wrote it, fighting the browser
   that had already compensated. keepPlace now stands down when the anchor's viewport place
   survived the mutation (see the guard there). Anchoring is load-bearing, not redundant. */
#view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 16px 16px 24px; }
.empty { text-align: center; margin-top: 16vh; color: var(--text-2); }
.empty.small { margin-top: 10vh; }
.empty p { margin: 8px 0; }
.more { display: flex; margin: 0 auto 14px; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 4px 14px; font-size: 12px; }
.msg { margin: 14px 0; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { background: var(--user); border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg); padding: 9px 14px; max-width: min(88%, 640px);
  white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user.pending .bubble { opacity: .65; }
.via { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.via svg.i { width: 13px; height: 13px; }
.msg.assistant { display: flex; flex-direction: column; align-items: flex-start; }
.msg.assistant > * { max-width: 100%; }
.msg.assistant .md { overflow-wrap: anywhere; align-self: stretch; }
.md p { margin: 8px 0; } .md p:first-child { margin-top: 0; }
.md p.h { font-weight: 700; margin-top: 14px; } .md ul, .md ol { margin: 8px 0; padding-left: 22px; } .md li { margin: 3px 0; }
.md .h { font-weight: 700; line-height: 1.3; margin: 18px 0 8px; } .md .h:first-child { margin-top: 0; }
.md h2.h { font-size: 1.18em; } .md h3.h { font-size: 1.07em; } .md h4.h, .md h5.h, .md h6.h { font-size: 1em; color: var(--text-2); }
.md ul.tasks { list-style: none; padding-left: 4px; } .md li.task input { margin: 0 6px 0 0; vertical-align: -1px; accent-color: var(--wait); }
.md blockquote { margin: 10px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--line-2); color: var(--text-2); }
.md blockquote p { margin: 6px 0; }
.md hr { border: 0; border-top: 1px solid var(--line-2); margin: 16px 0; }
.md del { color: var(--muted); } .md em { font-style: italic; }
.md .math { font-family: var(--mono); font-size: .95em; white-space: pre; display: inline-block; max-width: 100%; overflow-x: auto; vertical-align: bottom; }
.md pre.math.block { background: none; border: 0; padding: 4px 2px; margin: 8px 0; overflow-x: auto; }
.md p.raw { color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.code .lang { position: absolute; top: 9px; right: 44px; font: 11px var(--mono); color: var(--muted); pointer-events: none; }
.diagram { margin: 10px 0; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
.diagram svg { max-width: 100%; height: auto; }
.md code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border-radius: 6px; padding: 1px 5px; }
.md a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.code { position: relative; margin: 10px 0; }
.code pre, .md pre.table, .tool pre { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; background: var(--code-bg);
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0; }
.md pre code { background: none; padding: 0; border-radius: 0; }
.copy { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; padding: 0; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); display: grid; place-items: center; }
.copy svg.i { width: 15px; height: 15px; }
.copy.done { color: var(--wait); border-color: var(--wait); }
.thought { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-style: normal; color: var(--muted); margin-bottom: 8px;
  padding: 2px 10px 2px 7px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.thought svg.i { width: 13px; height: 13px; color: #b388ff; }
.thought.live { animation: pulse 1.6s ease-in-out infinite; }
/* The aborted-tool chip. Was .stopped until "stopped" became a session STATE: the state
   dot renders as <span class="st stopped">, and this rule — later in the sheet, equal
   specificity — would have won and pushed the dot down by its margin-top. */
.aborted { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.aborted svg.i { width: 12px; height: 12px; }
.calling { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.typing-dots { display: inline-flex; gap: 4px; padding: 10px 2px; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; } .typing-dots span:nth-child(3) { animation-delay: .4s; }
.md.typing > :last-child::after { content: ""; display: inline-block; width: 7px; height: 15px; background: var(--accent);
  border-radius: 2px; margin-left: 3px; vertical-align: -2px; animation: pulse 1s infinite; }

.tool { border: 1px solid var(--line); border-radius: var(--r); margin: 8px 0; background: var(--surface); overflow: hidden; align-self: stretch; }
.tool summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13px; cursor: pointer; list-style: none; min-height: 38px; }
.tool summary::-webkit-details-marker { display: none; }
.tool .tname { font-family: var(--mono); font-weight: 600; flex: none; }
.tool .targs { font-family: var(--mono); color: var(--muted); font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool svg.tstate { width: 16px; height: 16px; stroke-width: 2.2; }
.tool svg.tstate.ok { color: var(--wait); } .tool svg.tstate.fail { color: var(--err); }
.tool svg.tchev { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.tool[open] svg.tchev { transform: rotate(90deg); }
.tool pre { margin: 0 8px 8px; max-height: 50vh; }
.tool.err { border-color: color-mix(in srgb, var(--err) 35%, transparent); }

.pending.note { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; margin: 10px auto; font-size: 12.5px; color: var(--text-2);
  padding: 5px 12px 5px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.pending.note svg.i { width: 15px; height: 15px; }
.pending.note.ok svg.i { color: var(--wait); }
.pending.err, .pending.err .via { color: var(--err); }
.endbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 18px 0 6px; padding: 12px 12px 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text-2); font-size: 13.5px; }
.endbar .etext { flex: 1; min-width: 140px; }
.eacts { display: flex; gap: 8px; }

/* ── buttons ─────────────────────────────────────────────────────────────────── */
button.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); border: 0;
  color: var(--on-accent); font-weight: 650; border-radius: var(--r); transition: filter .15s, transform .05s; }
button.primary:hover { filter: brightness(1.08); }
button.primary:active { transform: scale(.98); }
button.primary:disabled { opacity: .4; filter: none; }
button.big { padding: 13px 18px; font-size: 15px; width: 100%; }
.empty .narrow { width: auto; padding: 11px 20px; }
button.small { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 12px; font-size: 13px; }
button.small svg.i { width: 15px; height: 15px; }
button.small.accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }

/* ── composer ────────────────────────────────────────────────────────────────── */
#composer { padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); }
#composer[hidden] { display: none; }
.cbox { display: flex; align-items: flex-end; gap: 6px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 22px;
  padding: 5px 5px 5px 16px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.cbox:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
#input { flex: 1; min-width: 0; resize: none; background: none; color: var(--text); border: 0; outline: none;
  padding: 9px 0; font: inherit; font-size: 15.5px; max-height: 180px; line-height: 1.45; }
#input::placeholder { color: var(--muted); }
#actions { display: flex; gap: 8px; align-items: center; flex: none; }
.cbtn { width: 48px; height: 48px; padding: 0; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; flex: none; }
.cbtn svg.i { width: 20px; height: 20px; stroke-width: 2.2; }
.cbtn.primary { background: var(--accent); color: var(--on-accent); }
.cbtn.danger { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); margin-left: 4px; }   /* +8 gap = 12px from Send */
.cbtn:disabled { opacity: .35; }
#attach { margin-right: 12px; }   /* far left, apart from the text box and the action cluster */

#slash { margin-bottom: 8px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--raised);
  max-height: 38vh; overflow-y: auto; box-shadow: var(--shadow); }
#slash[hidden] { display: none; }
.srow { display: flex; gap: 12px; align-items: baseline; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
  font-size: 14px; padding: 11px 14px; text-align: left; }
.srow:last-child { border-bottom: 0; }
.srow:hover { background: var(--surface-2); }
.srow b { font-family: var(--mono); font-weight: 600; color: var(--accent); }
.srow span { color: var(--muted); font-size: 13px; }
.sargs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
.sargs .chip { font-family: var(--mono); font-size: 13px; padding: 6px 12px; }
.sargs .chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── new session ─────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 12px; margin: 0 auto 18px; max-width: 640px; }
.form label, .field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.form input, .form select, .form textarea { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--line-2);
  border-radius: var(--r); padding: 9px 12px; font: inherit; font-size: 15px; font-weight: 400; letter-spacing: 0; transition: border-color .15s, box-shadow .15s; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form textarea { resize: vertical; min-height: 72px; }
/* git-worktree row: a switch beside the explanation, shown only inside a git repo */
.form label.wtrow { flex-direction: row; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; }
.wtrow[hidden] { display: none; }
.wtrow .wt-ico { flex: none; display: inline-flex; color: var(--accent); }
.wtrow .wt-ico svg.i { width: 18px; height: 18px; }
.wtrow .wt-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wtrow .wt-txt b { color: var(--text); font-size: 13.5px; font-weight: 600; letter-spacing: 0; }
.wtrow .wt-txt small { color: var(--muted); font-size: 11.5px; font-weight: 400; letter-spacing: 0; line-height: 1.35; }
.wtrow input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 42px; height: 24px; margin: 0;
  border: 0; border-radius: 999px; background: var(--line-2); box-shadow: none; position: relative;
  transition: background .15s; cursor: pointer; }
.wtrow input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.35); transition: transform .15s; }
.wtrow input.switch:checked { background: var(--accent); }
.wtrow input.switch:checked::after { transform: translateX(18px); }
.wtrow input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#startbtn { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 8px); box-shadow: var(--shadow); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#spawnstatus:empty { display: none; }

.browser { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.pins { display: flex; gap: 6px; overflow-x: auto; padding: 7px 9px; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.pins[hidden] { display: none; }
.pin { flex: none; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); background: var(--surface-2);
  border-radius: 999px; padding: 4px 11px; font-family: var(--mono); font-size: 12.5px; font-weight: 400; letter-spacing: 0;
  color: var(--text); white-space: nowrap; }
.pin .ico { color: var(--work); display: inline-flex; }
.pin .ico svg { width: 12px; height: 12px; }
.pin.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pin .dname { min-width: 0; }
#upbtn { flex: none; width: 34px; height: 34px; border: 0; border-right: 1px solid var(--line); background: none;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
#upbtn svg.i { width: 17px; height: 17px; }
#upbtn:disabled { opacity: .3; }
#upbtn:not(:disabled):active { background: var(--surface); color: var(--text); }
.crumbbar { display: flex; align-items: center; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 1px; padding: 9px 12px; overflow-x: auto; white-space: nowrap;
  font-family: var(--mono); font-size: 13px; font-weight: 400; letter-spacing: 0; scrollbar-width: none; }
.crumbs button { background: none; border: 0; color: var(--accent); padding: 2px 3px; border-radius: 5px; }
.crumbs button:last-child { color: var(--text); font-weight: 650; }
.crumbs span { color: var(--muted); }
#pinbtn { flex: none; background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); padding: 10px 13px; display: inline-flex; }
#pinbtn.on { color: var(--work); }
#pinbtn:not(.on) svg path { fill: none; stroke: currentColor; stroke-width: 1.6; }
#dirfilter { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--bg-2); box-shadow: none; }
#dirfilter[hidden] { display: none; }
.dirs { max-height: 44vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dir { display: flex; align-items: center; gap: 11px; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 400; letter-spacing: 0; padding: 12px 13px; text-align: left; }
.dir:last-child { border-bottom: 0; }
.dir:hover { background: var(--surface-2); }
.dir .ico { color: var(--accent); display: inline-flex; width: 18px; justify-content: center; }
.dir .dname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.dir .tag { font-size: 10.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 0 7px; letter-spacing: .03em; }
.dir svg.chev { width: 16px; height: 16px; color: var(--muted); }

/* ── actions sheet ───────────────────────────────────────────────────────────── */
#sheet { position: fixed; inset: 0; z-index: 30; }
#sheet[hidden] { display: none; }
#sheet .backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .15s; }
#sheet .sheet-inner { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px; background: var(--raised);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 8px 14px calc(env(safe-area-inset-bottom) + 14px); display: flex; flex-direction: column; gap: 6px; animation: rise .2s ease-out; }
.grabber { width: 38px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 2px auto 8px; }
#sheet .sheet-title { display: flex; flex-direction: column; gap: 2px; padding: 0 4px 8px; overflow-wrap: anywhere; }
#sheet .sheet-title b { font-size: 15px; }
#sheet button { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border: 0; border-radius: 14px;
  padding: 14px 16px; font-size: 15px; text-align: left; }
#sheet button:hover { filter: brightness(1.1); }
#sheet button.danger { color: var(--err); }
#sheet button.cancel { justify-content: center; background: none; color: var(--muted); }
#sheet .sheet-inner.tall .browser { max-height: 52vh; display: flex; flex-direction: column; min-height: 200px; }
#sheet .sheet-inner.tall .dirs { overflow-y: auto; flex: 1; min-height: 120px; }
#sheet .dir.file .ico { color: var(--muted); }

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

/* ── wide (unfolded Fold, tablet, desktop): drawer always beside the session ── */
#splitter { display: none; }
@media (min-width: 700px) {
  #menu { display: none; }
  /* The list's width is the viewer's: dragged at its edge, folded away below a snap point. */
  #drawer { width: var(--drawer-w, 316px); overflow: hidden; }
  #splitter { display: block; flex: none; width: 14px; margin: 0 -7px; position: relative; z-index: 6; cursor: col-resize; touch-action: none; outline: none; }
  #splitter::before { content: ""; position: absolute; top: 0; bottom: 0; left: 6px; width: 2px; background: transparent; transition: background .15s; }
  #splitter::after { content: ""; position: absolute; top: 50%; left: 4px; width: 6px; height: 40px; margin-top: -20px; border-radius: 3px;
    background: var(--line-2); opacity: .8; transition: background .15s, opacity .15s; }
  #splitter:hover::before, #splitter:focus-visible::before, #splitter.dragging::before { background: var(--accent); }
  #splitter:hover::after, #splitter.dragging::after { background: var(--accent); opacity: 1; }
  #splitter.snap::before { background: var(--muted); }
  body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
  body.drawer-collapsed #drawer { display: none; }
  body.drawer-collapsed #splitter { margin: 0; border-right: 1px solid var(--line); background: var(--bg-2); }
  body.drawer-collapsed #menu { display: inline-flex; }
  #bar { padding-left: 20px; }
  #view { padding-left: max(20px, calc((100% - 820px) / 2)); padding-right: max(20px, calc((100% - 820px) / 2)); }
  #composer { padding-left: max(16px, calc((100% - 840px) / 2)); padding-right: max(16px, calc((100% - 840px) / 2)); }
}
/* ── narrow (folded phone): the list is home; the menu slides the drawer over a session ── */
@media (max-width: 699px) {
  #drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 340px); z-index: 20; border-right: 0;
    transform: translateX(-102%); transition: transform .22s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow); }
  body.drawer-open #drawer { transform: none; }
  body.drawer-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 19; animation: fade .15s; }
  /* thumb reach: New lives at the bottom on a phone */
  body.route-list .fab:not([hidden]) { display: inline-flex; position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 6;
    align-items: center; gap: 8px; height: 52px; padding: 0 20px 0 16px; border-radius: 18px; border: 0;
    background: var(--accent); color: var(--on-accent); font-weight: 650; font-size: 15px; box-shadow: var(--shadow); }
  .fab svg.i { width: 20px; height: 20px; stroke-width: 2.2; }
  /* the fab is the thumb-reach New on a phone; the strip's button would duplicate it */
  .hnew { display: none; }
  /* In selection mode the bulk bar owns the bottom of the screen. The fab sits at the same
     corner (bottom: safe-area + 18px) and would cover the bar's right end — Delete, the one
     verb you reach for most. Needs .route-list + :not([hidden]) to out-specify the rule above. */
  body.route-list.selmode .fab:not([hidden]) { display: none; }
}

/* ── home: the control plane over every session ─────────────────────────── */
.hstrip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.hstat { display: flex; flex-direction: column; align-items: center; min-width: 60px; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.hstat b { font-size: 19px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.hstat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.hstat.work b { color: var(--work); } .hstat.wait b { color: var(--wait); } .hstat.warn b { color: var(--work); }
/* button.primary sets no padding of its own, so this rendered at the UA default (1px 6px)
   and the label crowded the right edge. The plus is not flush to its box either — #i-plus
   spans x=5..19 of a 24 viewBox, so at 20px it carries ~4px of air on each side. Hence the
   asymmetry: 12 + 4 of icon air on the left balances 16 on the right. Fixed here rather
   than with a trailing &nbsp; in the markup, because that <span>New session</span> is shared
   with the empty-state button, which is justify-content: center and would sit off-centre. */
.hnew { margin-left: auto; padding: 11px 16px 11px 12px; }
.home h2.machine { margin: 18px 2px 8px; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 10px; }
.hcard { display: flex; flex-direction: column; gap: 5px; padding: 12px 14px; text-align: left; width: 100%;
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
button.hcard { font: inherit; color: inherit; cursor: pointer; }
button.hcard:hover { border-color: var(--line-2); transform: translateY(-1px); }
button.hcard:active { transform: scale(.99); }
.hcard[data-state=waiting], .hcard[data-state=prompt] { border-color: color-mix(in srgb, var(--wait) 45%, transparent); }
.hcard[data-state=working] { border-color: color-mix(in srgb, var(--work) 35%, transparent); }

/* ── the breathe: how a card says "something changed" without moving ─────────────
   A card keeps its slot for life (home.ts bySlot), so a change has to be shown rather
   than rearranged. Two loudnesses, and their durations are PULSE_MS in cards.ts — the
   class is cleared by a timer there, so these are the whole life of the effect:
     pulse-state   the condition changed (working → needs you → gone). Rare, and the one
                   thing the reader must not miss: a deeper breath, in and out.
     pulse-update  the contents moved underneath the same condition. Common — on a
                   streaming session it would strobe, so cards.ts floors it: one soft
                   glow, then nothing until the floor has passed.
   The glow is a pseudo-element laid over the card, not the card's own box: animating
   border-color / background-color directly would fight the resting tints below and the
   .sel-on pick, and snap when the animation ends. And nothing here animates transform —
   that belongs to button.hcard:hover/:active above, and moving is the one thing this
   exists to stop. The colour follows the condition through --breathe, so "needs you"
   breathes green and "gone" breathes red with no second class. */
.hcard, .sitem { --breathe: var(--accent); }
.hcard[data-state=waiting], .sitem[data-state=waiting],
.hcard[data-state=prompt], .sitem[data-state=prompt] { --breathe: var(--wait); }
.hcard[data-state=working], .sitem[data-state=working],
.hcard[data-state=removing], .sitem[data-state=removing] { --breathe: var(--work); }
.hcard[data-state=gone], .sitem[data-state=gone],
.hcard[data-state=offline], .sitem[data-state=offline] { --breathe: var(--err); }

.hcard.pulse-state::after, .hcard.pulse-update::after,
.sitem.pulse-state::after, .sitem.pulse-update::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
}
.hcard.pulse-state::after, .sitem.pulse-state::after { animation: breathe-state 1800ms ease-in-out; }
.hcard.pulse-update::after, .sitem.pulse-update::after { animation: breathe-update 900ms ease-out; }

/* Inset so the glow also reads inside the drawer, where #slist clips anything that
   spills past the panel; outset for the halo around a card on the board. */
@keyframes breathe-state {
  0%, 100% { opacity: 0; background: transparent; box-shadow: inset 0 0 0 0 transparent, 0 0 0 0 transparent; }
  40% {
    opacity: 1;
    background: color-mix(in srgb, var(--breathe) 11%, transparent);
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--breathe) 60%, transparent),
      inset 0 0 20px 0 color-mix(in srgb, var(--breathe) 22%, transparent),
      0 0 24px 3px color-mix(in srgb, var(--breathe) 26%, transparent);
  }
}
@keyframes breathe-update {
  0%, 100% { opacity: 0; background: transparent; box-shadow: inset 0 0 0 0 transparent, 0 0 0 0 transparent; }
  30% {
    opacity: 1;
    background: color-mix(in srgb, var(--breathe) 6%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--breathe) 34%, transparent),
      0 0 12px 1px color-mix(in srgb, var(--breathe) 14%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  /* The block above kills every animation, so without this a viewer who asked for no
     motion would get no signal at all. Hold the tint for as long as the class is on —
     cards.ts clears it on a timer, which is exactly why it cannot stick. */
  .hcard.pulse-state::after, .sitem.pulse-state::after {
    opacity: 1; background: color-mix(in srgb, var(--breathe) 13%, transparent);
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--breathe) 60%, transparent);
  }
  .hcard.pulse-update::after, .sitem.pulse-update::after {
    opacity: 1; background: color-mix(in srgb, var(--breathe) 7%, transparent);
  }
}
.htop { display: flex; align-items: center; gap: 8px; min-width: 0; }
.htop .st { margin-top: 0; }
.htitle { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.hmeta { color: var(--muted); font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.hrow .hl { flex: none; width: 52px; text-transform: uppercase; letter-spacing: .05em; font-size: 10px; }
.hrow .hv { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hpt { flex: none; width: 64px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; display: block; }
.hpt i { display: block; height: 100%; background: var(--wait); }
.hsw { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); }
.hsw svg.i { width: 13px; height: 13px; stroke-width: 2; }
.hlast { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.hres { align-self: flex-start; }

/* email sign-in */
.login { max-width: 26rem; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 12px; padding: 0 4px; }
.login h2 { margin: 0; }
.login .error { color: var(--err); margin: 0; }
.empty .code { font: 600 1.5rem/1.2 var(--mono); letter-spacing: .08em; color: var(--text); }

/* ── tables ─────────────────────────────────────────────────────────────── */
.tbl { position: relative; margin: 12px 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.tbl-scroll { overflow-x: auto; border-radius: var(--r); -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent); }
.tbl-scroll:hover, .tbl.full .tbl-scroll { mask-image: none; }
.tbl table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13.5px; line-height: 1.45; }
/* Cells wrap at spaces only (the transcript's break-anywhere would split words), prose
   columns cap at a readable measure, and a table still wider than the screen scrolls. */
.tbl th, .tbl td { padding: 8px 12px; text-align: left; vertical-align: top; overflow-wrap: normal; word-break: normal; }
.tbl td { max-width: min(20em, 62vw); }
.tbl td code { white-space: nowrap; }
.tbl th { font-weight: 650; font-size: 12px; letter-spacing: .02em; color: var(--text-2); background: var(--surface-2);
  border-bottom: 1px solid var(--line-2); white-space: nowrap; position: sticky; top: 0; }
.tbl tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.tbl td { border-bottom: 1px solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .a-right { text-align: right; } .tbl .a-center { text-align: center; }
.tbl.wide td:first-child, .tbl.wide th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.tbl.wide th:first-child { background: var(--surface-2); z-index: 2; }
.tbl tr.pick td { background: color-mix(in srgb, var(--wait) 10%, transparent) !important; }
.tbl tr.trap td { background: color-mix(in srgb, var(--err) 10%, transparent) !important; }
.tbl .rmark { font-weight: 700; margin-right: 6px; } .tbl .rmark.pick { color: var(--wait); } .tbl .rmark.trap { color: var(--err); }
.tbl-tools { position: absolute; top: -13px; right: 8px; display: flex; gap: 4px; opacity: .9; z-index: 3; }
.tbtn { width: 26px; height: 26px; padding: 0; border-radius: 7px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); display: grid; place-items: center; font-size: 13px; }
.tbtn svg.i { width: 13px; height: 13px; } .tbtn.done { color: var(--wait); border-color: var(--wait); }
.tbl.full { position: fixed; inset: 0; z-index: 50; margin: 0; border-radius: 0; border: 0; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 44px) 0 env(safe-area-inset-bottom); background: var(--bg); }
.tbl.full .tbl-tools { top: calc(env(safe-area-inset-top) + 8px); right: 12px; }
.tbl.full .tbtn { width: 34px; height: 34px; }
.tbl.full .tbl-scroll { overflow: auto; flex: 1; border-radius: 0; }
.tbl.full table { width: max-content; min-width: 100%; }

/* bars: a label column against numbers */
.bars { display: grid; grid-template-columns: minmax(0, max-content) 1fr auto; gap: 6px 10px; align-items: center; margin: 12px 0;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); font-size: 13.5px; }
.bars .b-head { font-size: 12px; font-weight: 650; color: var(--text-2); } .bars .b-span { grid-column: span 2; text-align: right; }
.bars .b-label { overflow-wrap: anywhere; } .bars .b-val { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bars .b-track { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bars .b-track i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }

/* ── named fences ────────────────────────────────────────────────────────── */
.fence { margin: 12px 0; font-size: 14px; }
.fence .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.fence .lab { font: 600 10.5px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 7px; }
.form-error { margin: 12px 0; border: 1px solid color-mix(in srgb, var(--work) 50%, var(--line)); border-radius: var(--r); overflow: hidden; }
.form-error .fe-band { background: color-mix(in srgb, var(--work) 14%, transparent); color: var(--work); font-size: 12.5px; padding: 7px 12px; }
.form-error pre { margin: 0; padding: 10px 12px; font: 12.5px/1.5 var(--mono); overflow-x: auto; color: var(--muted); }

.checks .sum { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.checks .meter { flex: 1; min-width: 80px; max-width: 220px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.checks .meter i { display: block; height: 100%; border-radius: 4px; }
.checks .meter.ok i { background: var(--wait); } .checks .meter.warn i { background: var(--work); } .checks .meter.bad i { background: var(--err); }
.checks .rest { color: var(--muted); font-size: 12.5px; }
.checks ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.checks li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .ico { width: 18px; flex: none; text-align: center; font-weight: 700; }
.checks .body { flex: 1; min-width: 0; } .checks .word { font-size: 11.5px; color: var(--muted); flex: none; }
.checks .s-pass .ico { color: var(--wait); } .checks .s-fail .ico { color: var(--err); } .checks .s-todo .ico { color: var(--work); }
.checks .s-refuted .what { text-decoration: line-through; color: var(--muted); } .checks .s-refuted .ico, .checks .s-skip .ico { color: var(--muted); }
.checks .s-skip { opacity: .7; }

.fcard { position: relative; padding: 9px 12px 9px 15px; margin: 6px 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; }
.fcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.fcard .tag { display: inline-flex; gap: 6px; align-items: center; font: 650 11px var(--sans); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px; }
.fcard.l-critical::before { background: var(--err); } .fcard.l-critical .tag { color: var(--err); }
.fcard.l-warn::before { background: var(--work); } .fcard.l-warn .tag { color: var(--work); }
.fcard.l-note .tag { color: var(--muted); }
.fcard.l-mitigated::before { background: var(--wait); } .fcard.l-mitigated .tag { color: var(--wait); } .fcard.l-mitigated .what { color: var(--text-2); }
.fcard.d-open::before { background: var(--accent); } .fcard.d-open .tag { color: var(--accent); }
.fcard.d-taken::before { background: var(--wait); } .fcard.d-taken .tag { color: var(--wait); }
.fcard.d-deferred .tag, .fcard.d-dropped .tag { color: var(--muted); } .fcard.d-dropped .q { text-decoration: line-through; color: var(--muted); }
.fcard .q { font-weight: 600; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-top: 10px; }
.opt { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg-2); font-size: 13px; }
.opt.pick { border-color: color-mix(in srgb, var(--wait) 55%, var(--line)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--wait) 30%, transparent); }
.opt.trap { border-color: color-mix(in srgb, var(--err) 45%, var(--line)); border-style: dashed; }
.opt .oname { font-weight: 600; margin-bottom: 4px; } .opt.pick .lab { color: var(--wait); } .opt.trap .lab { color: var(--err); }
.opt .pro, .opt .con { display: flex; gap: 6px; color: var(--text-2); margin-top: 2px; }
.opt .pro span { color: var(--wait); font-weight: 700; } .opt .con span { color: var(--err); font-weight: 700; }

.series { padding: 10px 12px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.series svg { width: 100%; max-width: 520px; height: auto; display: block; margin: 0 auto; }
.series path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series .grid { stroke: var(--line); stroke-width: 1; } .series .limit { stroke: var(--work); stroke-width: 1.4; stroke-dasharray: 5 4; }
.series .ax { fill: var(--muted); font: 11px var(--sans); } .series .ax.lim { fill: var(--work); }
.series .note { fill: none; stroke: var(--text); stroke-width: 1.6; }
.series .s1 { stroke: var(--accent); fill: var(--accent); } .series .s2 { stroke: #e0913d; fill: #e0913d; }
.series .s3 { stroke: #3fb58f; fill: #3fb58f; } .series .s4 { stroke: #c26bd9; fill: #c26bd9; }
.series path.s1, .series path.s2, .series path.s3, .series path.s4 { fill: none; }
.series .legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.series .lg i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.series .lg i.s1 { background: var(--accent); } .series .lg i.s2 { background: #e0913d; } .series .lg i.s3 { background: #3fb58f; } .series .lg i.s4 { background: #c26bd9; }
.series .unit { margin-left: auto; color: var(--muted); } .series .xname { text-align: center; font-size: 11.5px; color: var(--muted); }

.delta { padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); font-size: 13.5px; }
.delta .d-row { display: grid; grid-template-columns: minmax(5em, 30%) 1fr auto; gap: 4px 12px; align-items: center; padding: 6px 0; }
.delta .d-label { overflow-wrap: anywhere; } .delta .d-label.pick { font-weight: 700; } .delta .d-label.trap { color: var(--err); }
.delta .d-track { position: relative; height: 14px; min-width: 80px; }
.delta .d-track svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.delta .d-track line { stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.delta .d-track i { position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; }
.delta .d-track i.before { border: 2px solid var(--muted); background: var(--surface); }
.delta .d-track i.after { background: var(--accent); }
.delta .d-fig { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; color: var(--text-2); }
.delta .pct { font-size: 11.5px; color: var(--muted); }
@media (max-width: 420px) { .delta .d-row { grid-template-columns: 1fr auto; } .delta .d-track { grid-column: 1 / -1; grid-row: 2; } }

/* ── tool calls ─────────────────────────────────────────────────────────── */
.tool .dstat { display: inline-flex; gap: 6px; font: 12px var(--mono); flex: none; }
.tool .dstat .add { color: var(--wait); } .tool .dstat .del { color: var(--err); }
.tool .tchip { font: 11.5px var(--mono); color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; flex: none; }
.tool .tpath { font: 12px var(--mono); color: var(--muted); padding: 0 12px 6px; overflow-wrap: anywhere; }
/* One scroller for the whole diff: every row is as wide as the longest line, so a swipe
   moves all of them together; the +/- column stays pinned on the left. */
.tool .diff { margin: 0 8px 8px; border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; overflow-y: hidden;
  background: var(--code-bg); -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.tool .hunk { width: max-content; min-width: 100%; }
.tool .hunk + .hunk { border-top: 1px dashed var(--line-2); }
.tool .dl { display: flex; font: 12px/1.55 var(--mono); white-space: pre; }
.tool .dl .dm { flex: none; width: 1.6em; text-align: center; color: var(--muted); user-select: none;
  position: sticky; left: 0; z-index: 1; background: var(--code-bg); }
.tool .dl .dt { flex: 1; padding-right: 12px; }
.tool .dl.add { background: color-mix(in srgb, var(--wait) 14%, transparent); }
.tool .dl.add .dm { color: var(--wait); background: linear-gradient(color-mix(in srgb, var(--wait) 14%, transparent), color-mix(in srgb, var(--wait) 14%, transparent)), var(--code-bg); }
.tool .dl.del { background: color-mix(in srgb, var(--err) 13%, transparent); }
.tool .dl.del .dm { color: var(--err); background: linear-gradient(color-mix(in srgb, var(--err) 13%, transparent), color-mix(in srgb, var(--err) 13%, transparent)), var(--code-bg); }
.tool .dl.ctx .dt { color: var(--text-2); }
.tool .hunk:not(.open) .dl.fold { display: none; }
.tool .dgap { display: block; width: 100%; border: 0; border-radius: 0; background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent); font: 11.5px var(--mono); padding: 3px 10px; text-align: left; min-height: 0; }
.tool .tcode { margin: 0 8px 8px; } .tool .tcode pre { max-height: 40vh; margin: 0; }
.tool .term { margin: 0 8px 8px; border-radius: 10px; background: #0b0c0f; color: #d7dae0; overflow: hidden; }
.tool .term .tcmd { font: 12.5px/1.5 var(--mono); padding: 8px 12px 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: #e8eaee; }
.tool .term .prompt { color: #6ec27a; margin-right: 8px; user-select: none; }
.tool .term pre.tout { margin: 0; border: 0; border-radius: 0; background: transparent; color: #b8bec8; padding: 4px 12px 10px; max-height: 40vh; }
.tool pre.tout.err { color: var(--err); }

/* prose shapes: heading state, warning band, status block, pipeline */
.md .t-good { --tone: var(--wait); } .md .t-bad { --tone: var(--err); } .md .t-warn { --tone: var(--work); } .md .t-plain { --tone: var(--accent); }
.pill { display: inline-block; vertical-align: .12em; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  font: 650 10.5px/1.6 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent); }
.band { margin: 12px 0; padding: 9px 12px; border-left: 3px solid var(--tone); border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--tone) 9%, transparent); color: var(--text); }
.status { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 12px 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.status dt { color: var(--muted); font-size: 12.5px; font-weight: 600; padding-top: 1px; }
.status dd { margin: 0; min-width: 0; overflow-wrap: break-word; }
.status .pill { margin: 0 4px 0 0; }
.flow { margin: 12px 0; display: grid; gap: 8px; }
.flow-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.flow .stage { padding: 4px 10px; border-radius: 8px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font-size: 13.5px; font-weight: 600; color: var(--text); }
.flow .arr { color: var(--muted); font-size: 13px; }

/* a dialog holding pi in the terminal */
.st.prompt::before { width: 9px; height: 9px; border-radius: 2px; background: var(--work); animation: ping 1.8s ease-out infinite; }
.badge.prompt { color: var(--work); background: color-mix(in srgb, var(--work) 12%, transparent); }
.tprompt { margin: 12px 0; padding: 12px; border: 1px solid color-mix(in srgb, var(--work) 40%, transparent); border-left: 3px solid var(--work);
  border-radius: 0 10px 10px 0; background: color-mix(in srgb, var(--work) 7%, transparent); display: grid; gap: 8px; }
.tp-head { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); }
.tp-body { margin: 0; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.45 var(--mono, ui-monospace, monospace); color: var(--text-2); }

/* a dialog pi is blocked on, answered from the phone */
#dialog { position: fixed; inset: 0; z-index: 35; }
#dialog[hidden] { display: none; }
#dialog .backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); animation: fade .15s; }
#dialog .dg { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; max-height: 88dvh;
  display: flex; flex-direction: column; background: var(--raised); border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 40px rgba(0, 0, 0, .35); }
.dg-head { display: flex; align-items: center; gap: 10px; min-width: 0; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.dg-head .pill { margin: 0; flex: none; }
.dg-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-scroll { overflow: auto; flex: 1 1 auto; min-height: 60px; padding: 4px 2px 8px; -webkit-overflow-scrolling: touch; }
.dg-doc { font-size: 14.5px; }
.dg-doc h2 { font-size: 16px; }
.dg-path { font-size: 11.5px; overflow-wrap: anywhere; margin-top: 6px; }
.dg-text { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 var(--mono); color: var(--text-2); margin: 8px 0; }
.dg-q { font-weight: 650; margin: 12px 0 2px; }
.dg-actions { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.dg-opt { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--text); font: 600 15px var(--sans); text-align: center; }
.dg-opt.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.dg-opt.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); background: transparent; }
.dg-opt:disabled { opacity: .5; }
.dg-input { width: 100%; box-sizing: border-box; resize: vertical; min-height: 72px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: 15px/1.45 var(--sans); }
.dg-status { font-size: 13px; color: var(--muted); padding-top: 8px; } .dg-status.err { color: var(--err); }
.dg-foot { display: flex; justify-content: space-between; padding-top: 8px; }
.linkish { background: none; border: 0; color: var(--muted); font: 13.5px var(--sans); padding: 6px 2px; }
.tprompt .primary.narrow { justify-self: start; }
.dg-head .pill { --tone: var(--work); }

/* a thought as its gist: a line or two, clamped */
.thought.gist { display: flex; align-items: flex-start; max-width: 100%; border-radius: 12px; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.thought.gist svg.i { flex: none; margin-top: 2px; }
.thought.gist .tg { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.thought.gist { padding: 5px 12px 5px 8px; }
.thought.gist.live { animation: none; } .thought.gist.live svg.i { animation: pulse 1.6s ease-in-out infinite; }

/* staged attachments (the + button) and the chips bubbles show */
#atts { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 2px 8px; }
.att { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px 4px 8px; font-size: 12px; color: var(--text-2); max-width: 100%; }
.att img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; flex: none; }
.att svg.i { width: 16px; height: 16px; flex: none; }
.att .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.att button { border: 0; background: none; color: var(--muted); padding: 3px; display: grid; place-items: center; }
.att button svg.i { width: 13px; height: 13px; }
.bubble .atts { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 6px; }
.bubble .att { background: color-mix(in srgb, var(--on-accent) 12%, transparent); border-color: color-mix(in srgb, var(--on-accent) 22%, transparent); color: inherit; }

/* the session's plan: a tab in the header, a page over the chat */
.plantab { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 12px 0 9px; margin-right: 4px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: 600 13px var(--sans); }
.plantab[hidden] { display: none; }
.plantab svg.i { width: 16px; height: 16px; color: var(--accent); }
.plantab b { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.plantab .pt-meter { display: inline-block; width: 28px; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.plantab .pt-meter i { display: block; height: 100%; background: var(--wait); }
.swarmtab .sw-model { font-family: ui-monospace, monospace; font-style: normal; font-size: 11px; color: var(--text-2); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#swarmview { position: fixed; inset: 0; z-index: 34; }
#swarmview[hidden] { display: none; }
#swarmview .backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); animation: fade .15s; }
#swarmview .pv { position: absolute; left: 0; right: 0; bottom: 0; top: max(6dvh, 36px); margin: 0 auto; max-width: 780px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 0 0; overflow: hidden; }
.sw-body { flex: 1; min-height: 0; overflow: auto; padding: 6px 20px 24px; display: flex; flex-direction: column; gap: 10px; }
.sw-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.sw-top { display: flex; align-items: center; gap: 8px; }
.sw-top b { color: var(--text-2); font-variant-numeric: tabular-nums; }
.sw-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-sub { margin-top: 4px; font-size: 12px; color: var(--text-2); }
.sw-sub .sw-model { display: inline-block; background: var(--surface-2); border-radius: 6px; padding: 1px 6px; max-width: none; }
#planview { position: fixed; inset: 0; z-index: 34; }
#planview[hidden] { display: none; }
#planview .backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); animation: fade .15s; }
#planview .pv { position: absolute; left: 0; right: 0; bottom: 0; top: max(6dvh, 36px); margin: 0 auto; max-width: 780px;
  display: flex; flex-direction: column; background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, .35); }
.pv-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 8px 20px; }
.pv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pv-title b { font-size: 17px; line-height: 1.3; }
.pv-title .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-progress { display: flex; align-items: center; gap: 10px; padding: 0 20px 12px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.pv-progress .pill { margin: 0; --tone: var(--wait); }
.pv-meter { flex: 1; max-width: 240px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pv-meter i { display: block; height: 100%; background: var(--wait); border-radius: 4px; }
.pv-scroll { flex: 1; overflow: auto; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.pv-scroll .status { margin-top: 12px; }
.pv-scroll .status .pill { --tone: var(--accent); } .pv-scroll .status .pill.t-good { --tone: var(--wait); }
.pv-scroll .status .pill.t-bad { --tone: var(--err); } .pv-scroll .status .pill.t-warn { --tone: var(--work); }
.pv-scroll li.task { padding: 6px 8px; margin: 2px -8px; border-radius: 10px; }
.pv-scroll li.task:has(> input:checked) { color: var(--text-2); }
.pv-scroll li.task.now { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); color: var(--text); }
.pv-scroll li.task ul { font-size: 13px; color: var(--muted); margin-top: 4px; }
/* The plan's steps as a checklist: one compact row per step (its first clause),
   the full text behind the native expand. `.now` reuses li.task.now's highlight
   so the step being worked on looks identical in both renderings. */
.pv-scroll .pl-steps { margin: 10px 0; }
.pv-scroll .pl-step { margin: 5px 0; border-radius: 10px; border: 1px solid color-mix(in srgb, currentColor 16%, transparent); }
.pv-scroll .pl-step summary { display: flex; gap: 8px; align-items: baseline; padding: 7px 10px; cursor: pointer; list-style: none; }
.pv-scroll .pl-step summary::-webkit-details-marker { display: none; }
.pv-scroll .pl-step.done { opacity: .55; }
.pv-scroll .pl-step.now { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); opacity: 1; }
.pv-scroll .pl-step .pl-mark { width: 14px; text-align: center; }
.pv-scroll .pl-step .pl-id { color: var(--muted); font-size: 12px; font-weight: 600; }
.pv-scroll .pl-step .pl-title { flex: 1; overflow-wrap: anywhere; }
.pv-scroll .pl-step .pl-detail { padding: 2px 12px 10px 34px; font-size: 13px; color: var(--text-2); }
.pv-scroll .pl-step .pl-detail p { margin: 6px 0; }
.pv-path { font-size: 11.5px; overflow-wrap: anywhere; margin-top: 14px; }

/* the plan's designed page (mdview), or the plan as written */
.pv-modes { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.seg button { border: 0; background: none; color: var(--text-2); font: 600 13px var(--sans); padding: 6px 14px; border-radius: 8px; }
.seg button.on { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.pv-build { font-size: 12.5px; color: var(--muted); }
.pv-scroll.page { padding-left: 0; padding-right: 0; }
.pv-frame { overflow: hidden; position: relative; }
.pv-frame iframe { border: 0; display: block; transform-origin: 0 0; background: transparent; }
.pv-scroll.page .pv-path { padding: 0 20px; }

/* the / drawer's source tag, and the footer under the composer: context use */
.srow .ssrc { margin-left: auto; flex: none; font: 600 10px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-style: normal; }
#cfoot { display: flex; align-items: center; gap: 10px; padding: 6px 6px 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#cfoot[hidden] { display: none; }
#cfoot b { color: var(--text-2); font-weight: 600; }
.cf-meter { flex: none; width: 64px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.cf-meter i { display: block; height: 100%; background: var(--accent); }
.cf-meter.warn i { background: var(--work); } .cf-meter.bad i { background: var(--err); }
.cf-model { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* multi-select on home cards (long-press): the dot, the picked card, the bulk bar */
.seldot { display: none; }
body.selmode .seldot { display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface-2); }
body.selmode .hcard .seldot.on, body.selmode .sitem .seldot.on { background: var(--accent); border-color: var(--accent); }
body.selmode .hcard .seldot.on::after, body.selmode .sitem .seldot.on::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--on-accent); }
body.selmode .hcard.sel-on, body.selmode .sitem.sel-on { border-color: var(--accent); background: var(--accent-soft); }
/* Both selection surfaces, not just the cards: without this a long-press on a list row can
   start the native callout, and the pointercancel that follows kills the hold timer before
   selEnter ever runs — the row simply refuses to select. */
.hcard, .sitem { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
/* ── the copy chip ─────────────────────────────────────────────────────────────
   Floats beside a transcript selection and offers Copy / Copy as markdown. Its position
   comes from app/copy.ts's chipPlan() over plain numbers, so the arithmetic is unit-tested
   rather than eyeballed in a screenshot: it clamps inside #view, prefers the space ABOVE the
   selection (the reader's eyes are already there, and below would cover text they have not
   read yet), and declines entirely rather than sit on top of the selection it was summoned by.

   Two rules that are easy to lose and worth stating outright:
     • pointer-events are on for the pill only. The wrapper is inert, so it can never eat a
       tap that was meant for the transcript underneath it.
     • user-select: none. The chip's own labels must not join the selection they are offering
       to copy. body already denies selection, but this is what keeps a future "allow
       selection here" change from silently breaking every copy.
   z-index 26: above .selbar (25), so both can be on screen at once while selection mode is
   up, and under #sheet (30), so a sheet still wins. */
#copychip { position: fixed; z-index: 26; pointer-events: none; user-select: none; -webkit-user-select: none; }
#copychip .cc {
  pointer-events: auto;
  display: flex; gap: 2px; align-items: center;
  padding: 3px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface-2) 96%, transparent);
  border: 1px solid var(--line-2);
  box-shadow: 0 6px 18px rgba(0,0,0,.24);
  backdrop-filter: blur(10px);
}
#copychip button {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 11px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--text);
  font: 600 12.5px/1 var(--font-ui); letter-spacing: -.01em;
  cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
#copychip button:active { background: var(--surface-3); }
#copychip button + button { border-left: 1px solid var(--line); }
#copychip button.done { color: var(--ok); }
#copychip .i { width: 14px; height: 14px; }

.selbar { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 12px); z-index: 25;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; box-shadow: var(--shadow); flex-wrap: wrap;
  background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-lg); }
.selbar .seln { font-weight: 600; font-size: 14px; margin-right: auto; }
.selbar .bulk { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; padding: 9px 12px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text-2); cursor: pointer; }
.selbar .bulk:disabled { opacity: .45; cursor: default; }
.selbar .bulk.hard { background: color-mix(in srgb, var(--err) 16%, transparent); border-color: color-mix(in srgb, var(--err) 45%, transparent); color: var(--err); }
.selbar .bulk.hard:disabled { background: var(--surface-2); border-color: var(--line-2); }
