/* Placeholder hand-rolled CSS (scaffold).
   Tailwind build (the catacloud pattern: npx tailwindcss + tailwind.config.js)
   lands with the first real UI work in Phase 2. */

:root {
  --bg: #14100c;
  --fg: #f4efe6;
  --muted: #a89f90;
  --card: #1f1a14;
  --accent: #febe11;
  /* the tool panel's open basis: .toolpanel's flex-basis (the collapsed
     rail flips it on body.panel-closed) */
  --panel-basis: clamp(16rem, 22vw, 21rem);
}

* { box-sizing: border-box; }

/* ── scrollbars: quiet, dark, palette-matched ──────────────────────
   Chromium/Safari get a custom rounded thumb via the -webkit
   pseudo-elements (hover brightens, active goes accent). Firefox has
   no such pseudo-elements, so it gets the standard scrollbar-* tint
   instead. The @supports split is load-bearing: Chrome 121+ ignores
   -webkit scrollbar styling whenever scrollbar-color applies, so the
   standard properties must not reach Chromium. */
@supports not selector(::-webkit-scrollbar) {
  :root {
    scrollbar-width: thin;
    scrollbar-color: #4a4132 transparent;
  }
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #4a4132;
  border: 3px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: #6e6350; }
::-webkit-scrollbar-thumb:active { background-color: var(--accent); }

body {
  margin: 0;
  /* viewport-fit=cover: keep content out from under a landscape notch */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-decoration: none; /* the logotype doubles as the way home */
}

.brand-mark { display: block; flex: none; }


main { flex: 1; padding: 1.5rem; max-width: 46rem; margin: 0 auto; width: 100%; }
/* conversation page: the transcript drops the card chrome (no box behind
   the messages) and runs a wider column than the index cards do.
   min-height: 0 keeps the shrink chain unblocked: when the composer grows,
   main must be ALLOWED to give that space back to nothing but itself. */
main.chat-page {
  max-width: 60rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Full-viewport chat layout (conversation page only): header — transcript —
   composer, the chat panel's own .chat-head sitting above the transcript
   (no page footer anymore, the meter lives there now). The body height is
   DEFINITE, not a floor: a floor (min-height) leaves the column
   content-sized, so a growing composer pushes past the viewport instead of
   squeezing the transcript. With a fixed height the flex chain distributes
   a real budget — main takes the space below the header, and the
   transcript scrolls INTERNALLY, giving its height up to the composer
   until the textarea hits its own max. */
body.chat-body {
  height: 100vh;
  height: 100dvh; /* mobile browsers: exclude the dynamic URL bar */
  min-height: 0; /* the base body's 100vh floor would defeat dvh on mobile */
  display: flex;
  flex-direction: column;
}

/* Sessions page: same flex chain as chat-body — the body's height is
   DEFINITE so main.wide gets a real budget between header and page end
   (this page has no footer), and the conversation list scrolls
   INTERNALLY while the head + filter bar stay
   put above it. min-height: 0 is what lets each link in the chain — body,
   main, the conversationList() wrapper div, the list — shrink to its flex
   budget instead of stretching the page. The filter bar keeps
   position: relative (its picker opens under the control that opened it). */
body.sessions-body {
  height: 100vh;
  height: 100dvh; /* mobile browsers: exclude the dynamic URL bar */
  min-height: 0; /* the base body's 100vh floor would defeat dvh on mobile */
  display: flex;
  flex-direction: column;
}

body.sessions-body main.wide {
  max-width: 60rem;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* let main shrink to its budget instead of overflowing */
  /* no overflow: hidden — the filter picker hangs below the bar and must
     not be clipped; the list's own overflow-y is the only scroller */
}

body.sessions-body .page-head,
body.sessions-body .filterwrap { flex-shrink: 0; }

body.sessions-body main.wide > div {
  /* the conversationList() wrapper: a plain block between main and the
     list. Its default min-height:auto refused to shrink below the rows,
     so the list rendered full-height and pushed past the viewport (the
     "still not working") — give it the same flex chain so the list's
     overflow-y is the only thing that moves. No overflow here: the
     filter picker hangs below the bar and must not be clipped. */
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.sessions-body .convlist {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.card {
  background: var(--card);
  border: 1px solid #33291d;
  border-radius: 0.6rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

h1 { margin-top: 0; color: var(--accent); }

.btn {
  background: var(--accent);
  color: #14100c;
  border: none;
  border-radius: 0.4rem;
  padding: 0.45rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.conversation-list { padding-left: 1.2rem; }

/* the chat panel's top bar (.chat-head): the same place, and the exact
   same styling, as the file viewer's .preview-head — border, padding,
   background, and no font-size/color overrides of its own (that bar sets
   none either, it just inherits the page's base type). min-height pins
   the row to that base type's own line box (1.55 is body's line-height):
   .preview-head gets that height from its un-shrunk .preview-path text,
   but .chat-head's only child (.session-meter) sets its OWN smaller
   font-size, which would otherwise shrink the row along with it — the
   explicit min-height keeps the two bars the same height regardless of
   what either one's content does to its own type. .chat now bleeds to
   the panel's full width (see .workbench > .chat-holder > .chat below)
   so this bar reaches edge to edge just like that one. Its one piece of
   content is the session meter, the page's only such bar left (other
   pages end with their content, no footer anymore). */
.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.55em;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid #33291d;
  background: var(--card);
}

/* the session meter (the chat head's only content): quiet metadata that
   brightens only on its numbers, aligned right */
.session-meter {
  margin-left: auto;
  display: flex;
  gap: 0.9rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.session-meter .meter-val { color: var(--accent); }

/* the ctx part doubles as the conversation's window-override editor:
   clickable (hover hints it), then an inline number input + save/cancel */
.session-meter .meter-part[data-part="ctx"] { cursor: pointer; }
.session-meter .meter-part[data-part="ctx"]:hover .meter-val { text-decoration: underline dotted; text-underline-offset: 3px; }
.session-meter .ctx-edit { display: inline-flex; gap: 0.45rem; align-items: center; }
.session-meter .meter-edit {
  width: 8rem;
  background: #14100c;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.3rem;
  padding: 0.1rem 0.35rem;
  font: inherit;
  font-size: 0.78rem;
  color-scheme: dark;
}
.session-meter .meter-edit:focus { outline: none; border-color: #55431f; }
.session-meter .meter-edit::placeholder { color: #6e6350; }
.session-meter .linkbtn { font-size: 0.74rem; }
.session-meter .meter-error { color: #e07b72; font-size: 0.72rem; }

.muted { color: var(--muted); }

code { background: #2a221a; padding: 0.1rem 0.35rem; border-radius: 0.25rem; }

/* ── chat (conversation.html, #5) ─────────────────────────────── */

[x-cloak] { display: none !important; }

/* the chat fills main (title + session id live in the global header);
   min-height: 0 passes the shrink down to .messages */
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.chat-title { font-size: 1.2rem; margin: 0; flex: 1; }

.messages {
  flex: 1;
  /* min-height:0 lets the transcript shrink inside the flex column so IT
     scrolls (not the page); there is no max-height — the area takes whatever
     the viewport leaves between header and composer */
  min-height: 0;
  overflow-y: auto;
  /* 0.7rem horizontal — the same rhythm as .chat-head and the file
     viewer's .preview-text, now that the transcript reads at the
     panel's full width instead of a narrow centered column */
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* column, not row: the bubble stacks over its action row, and align-items
   parks the pair on the message's side (both left) */
.msg { display: flex; flex-direction: column; }

/* lazy history: a stubbed render unit's quiet placeholder line (the unit's
   real markup returns on viewport approach — see stubDistantUnits) */
.lazy-stub {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  opacity: 0.5;
  padding: 0.15rem 0;
  user-select: none;
}
/* a turn (prompt + rounds) and a round (one model message: thinking, text,
   tool calls) stack like the transcript itself, so live, session and
   reloaded turns space identically */
.turn, .round { display: flex; flex-direction: column; gap: 0.6rem; }
.msg.user {
  align-items: flex-start;
  /* extra space under the user's prompt: it opens a turn, and the gap
     between it and the tool calls / reply below should read larger than
     the spacing inside that response block */
  margin-bottom: 0.4rem;
}
.msg.assistant { align-items: flex-start; }
/* the trailing "sent at" timestamp under every message bubble (user or
   assistant): quiet, always visible — unlike .branch-ctrl's hover-only
   icon row, it's informational, not an action. */
.msg-ts {
  color: var(--muted);
  font-size: 0.68rem;
  font-family: ui-monospace, monospace;
  margin-top: 0.15rem;
}
.msg-ts:empty { display: none; }
/* #83 R13: the model that ran a turn — a quiet label like .msg-ts, on the
   turn's last unit; truncates rather than wrapping at narrow widths. */
.turn-model {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.68rem;
  margin-top: 0.15rem;
}

.bubble {
  max-width: 85%;
  padding: 0.5rem 0.85rem;
  border-radius: 0.9rem;
  font-size: 0.9rem; /* message text sits a notch under body copy (16px → 14.4px) */
  white-space: pre-wrap;
  word-break: break-word;
}
/* intentional asymmetry: user messages are chips, agent text sits flat.
   Same font size as agent .md bubbles so neither side reads bigger. */
.msg.user .bubble { background: #3a2f1e; border: 1px solid #55431f; font-size: 0.85rem; }
/* a user message's annotations (annotation_chips.html): one row each —
   where + the comment, the quote behind the disclosure. The bubble keeps
   pre-wrap for the typed text; the chip rows set their own spacing. */
.msg-notes { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.35rem; white-space: normal; }
.msg-notes + span:empty { display: none; }
.msg-note { background: #2a2117; border: 1px solid #4a3a20; border-radius: 0.4rem; padding: 0.2rem 0.5rem; }
.msg-note summary { cursor: pointer; display: flex; gap: 0.45rem; align-items: baseline; list-style: none; }
.msg-note summary::-webkit-details-marker { display: none; }
.msg-note-where { flex: none; color: var(--accent); font-size: 0.78rem; }
.msg-note-comment { min-width: 0; white-space: pre-wrap; }
.msg-note-path { margin-top: 0.3rem; color: var(--muted); font-size: 0.72rem; }
.msg-note-quote {
  margin: 0.25rem 0 0.1rem;
  padding: 0.35rem 0.5rem;
  max-height: 14rem;
  overflow: auto;
  background: #120e0a;
  border-radius: 0.3rem;
  font-size: 0.72rem;
  white-space: pre;
}

/* ── markdown prose (assistant replies AND the file viewer's rendered
   mode) ── Rendered by server::markdown (history via the `markdown`
   filter, live turns and file previews via /api/markdown) — block markup
   needs normal white-space, so only .md surfaces relax the base pre-wrap;
   user bubbles stay plain text and keep it. .bubble.md is the chat
   bubble, .preview-md is the file viewer's rendered-markdown pane; same
   prose rules, different container. */
/* a notch under the base bubble: agent prose reads better slightly
   smaller (paragraphs AND the em-scaled headings shrink together) */
.bubble.md, .preview-md { white-space: normal; font-size: 0.85rem; }
.bubble.md p, .preview-md p { margin: 0 0 0.6em; }
.bubble.md > :first-child, .preview-md > :first-child { margin-top: 0; }
.bubble.md > :last-child, .preview-md > :last-child { margin-bottom: 0; }
.bubble.md h1, .bubble.md h2, .bubble.md h3,
.bubble.md h4, .bubble.md h5, .bubble.md h6,
.preview-md h1, .preview-md h2, .preview-md h3,
.preview-md h4, .preview-md h5, .preview-md h6 {
  margin: 0.8em 0 0.4em;
  line-height: 1.3;
  color: var(--accent);
}
.bubble.md h1, .preview-md h1 { font-size: 1.25em; }
.bubble.md h2, .preview-md h2 { font-size: 1.15em; }
.bubble.md h3, .bubble.md h4, .preview-md h3, .preview-md h4 { font-size: 1.05em; }
.bubble.md h5, .bubble.md h6, .preview-md h5, .preview-md h6 { font-size: 1em; }
.bubble.md code, .preview-md code {
  background: #2a221a;
  border-radius: 0.3rem;
  padding: 0.1em 0.35em;
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
}
.bubble.md pre, .preview-md pre {
  background: #120e0a;
  border: 1px solid #33291d;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin: 0 0 0.6em;
  overflow-x: auto;
}
.bubble.md pre code, .preview-md pre code { background: none; padding: 0; font-size: 0.8rem; }
/* a ```mermaid fence (base.html's MutationObserver): the <pre> hides once
   it renders, this sits where it was. A failed parse leaves the <pre>
   visible instead, tinted to flag it. */
.bubble.md .mermaid-diagram, .preview-md .mermaid-diagram {
  background: #120e0a;
  border: 1px solid #33291d;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 0 0 0.6em;
  overflow-x: auto;
  text-align: center;
}
.bubble.md .mermaid-diagram svg, .preview-md .mermaid-diagram svg { max-width: 100%; height: auto; }
.bubble.md pre.mermaid-error, .preview-md pre.mermaid-error { border-color: #7a4a33; }
/* a code/quote block's copy button (server::markdown): the block's last
   child, pinned to its top-right corner over the text — visible on hover
   or focus, like .branch-ctrl's row below the bubble. The file viewer's
   rendered markdown drops it: a passage there is selected for annotating,
   not copied. */
.bubble.md pre, .bubble.md blockquote { position: relative; }
.md-copy-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  background: #1c1710;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  opacity: 0;
  transition: opacity 0.15s;
  user-select: none;
}
.bubble.md pre:hover .md-copy-btn,
.bubble.md blockquote:hover .md-copy-btn,
.md-copy-btn:focus-visible { opacity: 1; }
.md-copy-btn:hover { color: var(--accent); }
.md-copy-btn.copied { color: var(--accent); }
.preview-md .md-copy-btn { display: none; }
.bubble.md ul, .bubble.md ol, .preview-md ul, .preview-md ol { margin: 0 0 0.6em; padding-left: 1.4em; }
.bubble.md li, .preview-md li { margin: 0.15em 0; }
.bubble.md blockquote, .preview-md blockquote {
  margin: 0 0 0.6em;
  padding: 0.15rem 0.8rem;
  border-left: 3px solid #33291d;
  color: var(--muted);
}
/* pinned absolute so the .md font-size drop above leaves tables unchanged */
.bubble.md table, .preview-md table { border-collapse: collapse; margin: 0 0 0.6em; font-size: 0.765rem; }
.bubble.md th, .bubble.md td, .preview-md th, .preview-md td {
  border: 1px solid #33291d;
  padding: 0.25rem 0.6rem;
  text-align: left; /* renderer's style attr overrides for centered/right cols */
}
.bubble.md th, .preview-md th { background: #241d15; }
.bubble.md a, .preview-md a { color: var(--accent); }
.bubble.md img, .preview-md img { max-width: 100%; border-radius: 0.5rem; }
.bubble.md hr, .preview-md hr { border: none; border-top: 1px solid #33291d; margin: 0.8em 0; }

/* #13 compaction: the folded-history summary renders as a quiet divider,
   not a user bubble — it was written by the summarizer, not the human */
.compaction-note {
  margin: 0.4rem 0;
  padding: 0.45rem 0.75rem;
  border-left: 3px solid #33291d;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}

/* the divider's head line: what happened + the token arithmetic
   (86.2k → 12.4k) — the summary text itself stays the body below */
.compaction-head {
  font-style: normal;
  letter-spacing: 0.02em;
  margin-bottom: 0.2rem;
}

/* Per-message actions (copy · compact · cut · fork · resend) render as a quiet icon row
   under the bubble — bottom-right for user messages, bottom-left for
   assistant ones (align-items above). Flow-positioned, not absolute: the
   row always reserves its line, so fading it in on hover shifts nothing
   and covers no text. Labels live in the title tooltips. */
.branch-ctrl {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.2rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg:hover .branch-ctrl,
.round:hover > .branch-ctrl,
.branch-ctrl:focus-within { opacity: 1; }
/* a round's controls close it, under its last tool box: pull them up to
   the bubble-to-controls distance instead of a full gap */
.round > .branch-ctrl { margin-top: -0.4rem; }
.iconbtn {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
}
.iconbtn:hover { color: var(--accent); }
.iconbtn.copied { color: var(--accent); }

/* Manual compaction in flight: feedback lives at the clicked message —
   the pressed 🗜 pulses and a note below the bubble says what is running.
   The generic Working... indicator at the scroller bottom is gated to real
   streaming turns (busy && turn) so it stays off while this is up. */
/* the ring spinner: a muted-brown track with an accent arc sweeping
   around — the one spinner look for the whole UI (compaction notes,
   the Working... row) */
.spinner {
  /* inline-block so it gets a box even outside a flex row (the conv
     list's state cell): a bare inline span ignores width/height, and the
     border paints chopped */
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border: 2px solid #33291d;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cog-spin 0.9s linear infinite;
  flex: none;
}
.compact-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
}
.iconbtn.compacting {
  color: var(--accent);
  animation: cog-pulse 1s ease-in-out infinite alternate;
}
/* honor the OS "reduce motion" setting like the Working spinner: no
   spinning, keep the opacity pulse so liveness still reads */
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .iconbtn.compacting { animation: cog-pulse 1.6s ease-in-out infinite alternate; }
}

/* model thinking (reasoning_content): a collapsible, quieter than tool
   calls — collapsed in history/committed turns, open while streaming
   (static `open` attr the user can toggle). Body renders as markdown. */
.thinking {
  border: 1px solid #2a221a;
  border-radius: 0.5rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}
.thinking summary {
  cursor: pointer;
  list-style: none; /* drop the default marker; a chevron follows */
  color: var(--muted);
  font-style: italic;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::after {
  content: "\25B8";
  display: inline-block;
  margin-left: 0.4rem;
  transition: transform 0.15s;
}
.thinking[open] summary::after { transform: rotate(90deg); }
.thinking-body {
  margin-top: 0.4rem;
  margin-left: 0.15rem;
  border-left: 2px solid #2a221a;
  padding-left: 0.6rem;
  color: var(--muted);
  white-space: normal;
}
.thinking-body p { margin: 0 0 0.5em; }
.thinking-body > :first-child { margin-top: 0; }
.thinking-body > :last-child { margin-bottom: 0; }
.thinking-body pre {
  background: #120e0a;
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.5rem 0.6rem;
  overflow-x: auto;
}
.thinking-body code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}

/* the system-prompt inspector: same collapsed-box language as .thinking,
   but its own class — it must stay visible under both the "show thinking"
   and "show tools" toggles, neither of which it is. */
.system-prompt {
  border: 1px solid #2a221a;
  border-radius: 0.5rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}
.system-prompt summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-style: italic;
}
.system-prompt summary::-webkit-details-marker { display: none; }
.system-prompt summary::after {
  content: "\25B8";
  display: inline-block;
  margin-left: 0.4rem;
  transition: transform 0.15s;
}
.system-prompt[open] summary::after { transform: rotate(90deg); }
.system-prompt pre {
  margin: 0.5rem 0 0;
  background: #120e0a;
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.5rem 0.6rem;
  overflow-x: auto;
  color: #c9c0b2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
}

/* tool activity renders distinctly from content, per the SSE contract.
   Each call + its result is one native <details> box, collapsed by default:
   the summary is a single quiet row (badge, one-line args preview, chevron);
   the full call and output live in the body. Failures start open so errors
   are seen without a click (:open drives it from the stream's ok flag). */
.toolcall {
  border: 1px solid #33291d;
  border-radius: 0.5rem;
  background: #191410;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}
.toolcall.running { border-style: dashed; }
.toolcall.failed { border-color: #6e2b26; }
/* subagent task boxes (subagents R21): the status chip in the summary row
   and the lazy-loaded child transcript in the body */
.task-chip {
  flex-shrink: 0;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}
.task-chip.completed { color: #7fae72; }
.task-chip.failed { color: #d0736a; }
.task-chip.cancelled { color: var(--muted); }
.task-chip.running { color: #d8a657; }
.task-chip.paused { color: #d8a657; }
.child-transcript {
  margin-top: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px dashed #33291d;
  border-radius: 0.4rem;
  font-size: 0.8rem;
  display: grid;
  gap: 0.4rem;
}
.child-transcript .child-role {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.child-transcript .child-prompt {
  color: var(--muted);
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
}
.child-transcript .child-text { white-space: pre-wrap; }
.child-transcript .child-call {
  color: #d8a657;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
}
.child-transcript .child-call-result {
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  padding-left: 0.8rem;
}
.child-transcript .child-empty { color: var(--muted); font-style: italic; }
.toolcall summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none; /* drop the default disclosure marker; a chevron follows */
}
.toolcall summary::-webkit-details-marker { display: none; }
.toolcall summary .badge {
  white-space: nowrap; /* tool names stay on one line, never wrap */
  flex-shrink: 0;
}
.toolcall summary .dur {
  flex-shrink: 0; /* pinned at the tail by .args stretching (flex-grow 1) */
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  white-space: nowrap;
}
.toolcall.running .dur { color: var(--accent); } /* live elapsed time */
/* the trailing "sent at" timestamp (every message type): same tail
   position as .dur on a tool call's summary line, same metrics — just the
   browser's local clock instead of a duration. */
.toolcall summary .ts {
  flex-shrink: 0;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  white-space: nowrap;
}
.toolcall summary .ts:empty { display: none; }
.toolcall summary .args {
  flex: 1 1 auto;
  min-width: 0; /* flex children need this before text-overflow can bite */
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toolcall summary::after {
  content: "\25B8"; /* ▸ — rotated to ▾ by [open] below */
  color: var(--muted);
  transition: transform 0.15s;
}
.toolcall[open] summary::after { transform: rotate(90deg); }
.toolcall .args, .toolcall pre {
  display: block;
  margin-top: 0.35rem;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 12rem;
  overflow-y: auto;
}
/* body of an expanded call: full args + output hang off a subtle left rule,
   visually grouping them under the summary row */
.toolcall > code.args, .toolcall > pre {
  margin-left: 0.15rem;
  border-left: 2px solid #33291d;
  padding-left: 0.6rem;
}

.badge {
  display: inline-block;
  background: #2a221a;
  border-radius: 0.3rem;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  color: var(--accent);
  font-family: ui-monospace, monospace;
}
.badge.ok { color: #9ecf7a; }
.badge.warn { color: #e0b972; }
.help.warn, .from.warn { color: #e0b972; }
.toolcall.failed .badge { color: #e07b72; }

/* the turn-run indicator: ring spinner + "Working...", shown the whole
   time a turn is busy (before the first event, during tool runs, while
   text streams) — sits at the tail of the live turn. Same ring the
   compaction note uses (.spinner); it replaced a spinning Feather gear
   that read as "settings," not "busy". */
.working {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.working .spinner {
  width: 0.9em; /* roughly x-height of the "Working..." text beside it */
  height: 0.9em;
}
@keyframes cog-spin {
  to { transform: rotate(360deg); }
}
@keyframes cog-pulse {
  from { opacity: 1; }
  to { opacity: 0.4; }
}
/* reduce-motion handling for the working row lives with the generic
   .spinner rule above (it covers every ring) */

.error {
  border: 1px solid #6e2b26;
  background: #2a1512;
  color: #e07b72;
  border-radius: 0.5rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
}

/* #35/#1: the stop control. It is the send button's slot mid-turn — the
   composer bar swaps `send` for `■ stop` in place while a turn runs, so
   there is one control to aim at instead of a small button floating in
   the transcript's working row. Same base look as send (it IS a .btn);
   the outline + stop colour says "escape hatch", not "primary action",
   and the disabled state covers the waiting-for-cancel window. The
   cancelled-note below is the quiet mark a stopped turn ends with (a
   choice, not an error — hence not .error's red). */
.composer-bar .stopbtn {
  margin-left: auto;
  background: transparent;
  color: #e07b72;
  border: 1px solid #6e2b26;
}
.composer-bar .stopbtn:hover { background: #2a1512; }
.composer-bar .stopbtn:disabled { opacity: 0.55; cursor: default; }
/* #2: with an empty box the stop slot is a split pill (the #41 pattern,
   .splitbtn supplies the radii/join): pause — the graceful sibling, the
   turn ends at its next boundary — sits in queue's seat as the split-off
   choice, drawn with the same icon set (and size) as stop, both seated
   on the baseline;
   stop stays the default
   right click. Both halves wear the stop look above; the divider takes
   the outline's red instead of the steer pill's dark ink. */
.composer-bar .stopsplit .btn:first-child { border-right: 1px solid rgba(110, 43, 38, 0.8); }
.composer-bar .stopsplit .btn:last-child { border-left: none; } /* the seam is the divider, not two borders */
.composer-bar .stopsplit .btn:disabled { opacity: 0.55; cursor: default; }
.cancelled-note {
  margin-top: 0.4rem;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}
/* ask_user (D5): the question that preceded the answer bubble below it —
   quiet like the other notes, not a collapsible tool box. */
.asked-note {
  margin: 0.4rem 0 0.2rem;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}
/* #41: the steer's in-flight pill (same quiet register as the notes) and
   the steered user bubble's marker class (no special styling yet — the
   hook exists so a future pass can distinguish a steer from the prompt). */
.steer-note {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  /* tucked under the "Working..." line it belongs to (the live turn's
     0.6rem gap would detach it) and indented the same */
  margin-top: -0.45rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.steer-note .hourglass {
  flex: none;
  width: 0.9em; /* the width of .working's spinner, so the text lines up */
  font-size: 0.8rem;
  line-height: 1.35rem; /* centred on the first text line */
  text-align: center;
}
.steer-note .hourglass .ico { vertical-align: -0.12em; }
.steer-note .steer-label { flex: none; }
.steer-note .steer-text {
  min-width: 0;
  color: var(--fg);
  font-style: italic;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
/* edit / remove: always shown (a queued steer is short-lived and these
   are its only controls; no hover on touch) in the muted icon colour */
.steer-note .steer-actions {
  flex: none;
  display: flex;
  gap: 0.15rem;
}
/* on the text's first line, like the hourglass */
.steer-note .steer-actions .iconbtn { line-height: 1.35rem; padding: 0 0.2rem; }

/* Composer: one visually-unified input box — textarea on top, modifier bar
   (model / effort chips, later attachments) under it, send at the right. */
.composer {
  margin-top: 0.9rem;
  flex-shrink: 0; /* growth comes out of the transcript, never the box */
  position: relative; /* anchors the top-border drag grip */
  background: #191410;
  border: 1px solid #33291d;
  border-radius: 0.5rem;
}
/* the top border doubles as a drag handle: an invisible strip overlaying
   it (no layout cost); hover tints it to the focus-border color so the
   affordance reads before the first grab */
.composer-grip {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 0.5rem 0.5rem 0 0;
  cursor: ns-resize;
  touch-action: none; /* pointer events, not scroll, on touch */
  z-index: 2;
}
.composer-grip:hover { background: #55431f; opacity: 0.55; }
body.resizing {
  cursor: ns-resize;
  user-select: none;
}
.composer:focus-within { border-color: #55431f; }
.composer textarea {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--fg);
  border: none;
  border-radius: 0.5rem 0.5rem 0 0;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.9rem; /* a notch under body copy, matching message bubbles */
  resize: none; /* height is owned by the auto-grow resize() in the template */
  overflow-y: auto;
  /* grow cap: viewport minus the fixed chrome around the textarea
     (header ≈3.4 + main padding 2×1.5 + composer margin 0.9 + bar ≈2.9 +
     footer ≈3.1 ≈ 13.3rem) — at the cap the composer's top edge lands
     just under the header, and the textarea scrolls internally */
  max-height: calc(100vh - 13.5rem);
  max-height: calc(100dvh - 13.5rem);
}
.composer textarea:focus { outline: none; }
.composer textarea:disabled { opacity: 0.6; }
.composer-bar {
  /* on the conversation page the bar carries the settings (gear, pickers);
     on /conversations/new the summary holds them — here it is the send */
  display: flex;
  align-items: center;
  gap: 0.45rem 0.55rem;
  padding: 0.3rem 0.5rem 0.45rem 0.6rem;
  border-top: 1px solid #221a13;
}
.composer-mod { display: inline-flex; align-items: baseline; gap: 0.35rem; }
.composer-mod-label {
  white-space: nowrap;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.composer-mod select {
  background: #241c15;
  color: var(--muted);
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.78rem;
  max-width: 11rem;
}
.composer-mod select:focus { outline: 1px solid #55431f; }
.composer-mod select:disabled { opacity: 0.6; }
.composer-bar .btn { margin-left: auto; }
/* #41: mid-turn with text, the send slot is a split button — queue (the
   stack) on the left, steer (the default) on the right, one pill */
.composer-bar .splitbtn { margin-left: auto; display: inline-flex; }
.composer-bar .splitbtn .btn { margin-left: 0; }
.splitbtn .btn:first-child {
  border-radius: 0.4rem 0 0 0.4rem;
  padding-left: 0.7rem;
  padding-right: 0.6rem;
  border-right: 1px solid rgba(20, 16, 12, 0.35);
  display: inline-flex;
  align-items: center;
}
.splitbtn .btn:last-child { border-radius: 0 0.4rem 0.4rem 0; }
/* the UI icon set (assets/icons/ui, sprite static/icons.svg): 1em square so
   an icon takes the font-size of whatever it sits in (an .iconbtn, a button
   label, a row) and the text colour via currentColor; the stroke style is
   the style guide's (docs/icon-style-guide.md): 1.5 on a 16px grid. */
.ico {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
}
/* the text beside an icon: the icon is a 1em box centred on the line, but a
   lowercase label's ink sits about a pixel below the line's middle, so the
   text reads low next to it. Nudge only the label up; the icon stays put. */
.lbl { position: relative; top: -0.07em; }
/* the settings gear (#4): the bar's only control besides send — matches
   the message icon buttons' size but scaled up to read as a peer of the
   send button, not a transcript annotation */
.composer-bar .iconbtn.gear { font-size: 1rem; padding: 0.15rem 0.3rem; }
.composer-bar .iconbtn.gear:disabled { opacity: 0.6; cursor: default; }

/* ── session settings menu (#4): the project / model / effort
   controls, shown as a popover anchored to the composer bar's gear —
   the header account menu's details/summary pattern (position:relative
   host, absolutely positioned panel below the toggle). .composer is
   position:relative and nothing between it and the panel clips, so the
   panel floats over the transcript instead of pushing content down;
   x-cloak keeps it hidden until Alpine's first paint. z-index 20 beats
   the page's own chrome but stays coverable by tool overlays. Fields
   sit one per line (label left, control right) — the pickers read as a
   settings form, not a sentence. ────────────────────── */
.settings-menu { position: relative; }
.settings-menu summary.iconbtn { list-style: none; }
.settings-menu summary.iconbtn::-webkit-details-marker { display: none; }
.settings-menu summary.iconbtn:hover { color: var(--accent); }
.settings-panel {
  position: absolute;
  left: 0;
  /* opens UPWARD: the composer is pinned to the viewport bottom (the
     transcript above it is what scrolls), so anything opening downward
     runs off-screen; anchoring the panel's bottom edge above the gear
     makes it grow into the transcript, which is always tall enough */
  bottom: calc(100% + 0.45rem);
  z-index: 20;
  width: max-content;
  max-width: min(26rem, calc(100vw - 2rem));
  background: var(--card);
  color: var(--fg);
  border: 1px solid #55431f;
  border-radius: 0.6rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.settings-panel .dlg-field {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 0 0.9rem;
}
.settings-panel .dlg-field:last-child { margin-bottom: 0.2rem; }
.settings-panel .dlg-field select { max-width: 13rem; }
/* the render toggles' checkboxes align with the pickers' controls (the
   label column's right edge), not the text baseline */
.settings-panel .dlg-field input[type="checkbox"] {
  align-self: center;
  margin: 0;
  accent-color: var(--accent);
}
/* the reload action sits below the toggles, set off with a divider
   instead of the field rows' label/control split — it is the one row
   with no picker on the right, a plain full-width button instead */
.settings-panel .dlg-field.dlg-action {
  justify-content: center;
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid #33291d;
}
.settings-panel .dlg-action .btn { width: 100%; text-align: center; }

/* the session-settings render toggles: one class over .messages hides
   every thinking block / tool box at once — server-rendered history, the
   pushed turns and the live stream alike (the binding sits on the
   scroller, so nothing re-renders and a reload starts hidden with no
   flash). Render-only: the transcript keeps everything. */
.messages.hide-thinking .thinking { display: none; }
.messages.hide-tools .toolcall { display: none; }

/* ── the action dialog (compact / fork, #1/#2): a styled replacement for
   the browser's confirm() — the native <dialog> gives Esc, backdrop and
   focus handling for free; ::backdrop dims the page behind it. The
   settings dialog (#4) shares these field styles from its own block. ── */
.action-dialog {
  background: var(--card);
  color: var(--fg);
  border: 1px solid #55431f;
  border-radius: 0.6rem;
  padding: 1.1rem 1.2rem;
  max-width: min(30rem, calc(100vw - 2rem));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.action-dialog::backdrop { background: rgba(10, 8, 5, 0.6); }
.action-dialog h3 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--accent); }
.action-dialog .dlg-note { margin: 0 0 0.9rem; font-size: 0.85rem; color: var(--muted); }
.action-dialog .dlg-note strong { color: var(--fg); font-style: italic; }
.action-dialog .dlg-field {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
}
.action-dialog .dlg-field select {
  background: #241c15;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.4rem;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
  max-width: 16rem;
}
.action-dialog .dlg-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

.row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.conversation-list a { color: var(--fg); text-decoration: none; }
.conversation-list a:hover { color: var(--accent); }

/* ── accounts (#16): auth forms, admin table ───────────────────── */
.linkbtn { color: var(--muted); }
.linkbtn:hover { color: var(--accent); }
.inline-form { display: inline; margin: 0; }
.linkbtn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.auth-card { max-width: 26rem; margin: 2rem auto; }
.stack-form { display: flex; flex-direction: column; gap: 0.8rem; margin: 1rem 0; }
.stack-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.stack-form label.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.stack-form input, .inline-form input {
  background: #14100c;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.35rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
}
.stack-form .btn { align-self: flex-start; }

/* ── the providers page's OpenAI-front form (create + inline edit): a row
   of labelled fields, same dark bordered input as .stack-form/.field
   rather than raw browser controls. */
.provider-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 0.6rem 0;
  padding: 0.75rem 0.85rem;
  background: #1c160f;
  border: 1px solid #332a1c;
  border-radius: 0.5rem;
}
.provider-edit label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.provider-edit label.inline { flex-direction: row; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.provider-edit input[type="text"], .provider-edit input[type="password"] {
  background: #14100c;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.35rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  min-width: 14rem;
}
.provider-edit input:focus { outline: none; border-color: #55431f; }
.provider-edit .acts { display: flex; gap: 0.5rem; align-items: center; }
.plain-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.plain-table th, .plain-table td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid #33291d; }
.mono { font-family: ui-monospace, monospace; font-size: 0.8rem; }

/* ── navigation (#85): one control, top-left, on every page ───────────
   ☰ + the brand mark (nav_menu.html). No header bar: on list/settings
   pages it leads the page head; on the conversation page it is the
   workbench panel's first row (.nav-row), and on a phone that panel is a
   drawer. The menu is the old account menu grown into the whole nav. */
.nav-home {
  position: relative; /* anchors .nav-menu */
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}
.nav-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  color: var(--fg);
  font: inherit;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
}
.nav-toggle:hover, .nav-toggle[aria-expanded="true"] { background: #2a221a; border-color: #33291d; }
.nav-toggle .ico { color: var(--muted); }
.nav-toggle .ico { width: 1.5rem; height: 1.5rem; }
/* something in ANOTHER project is waiting on you / has unread output */
.nav-attn {
  position: absolute;
  top: 0.05rem;
  left: 1.05rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}
.toolpanel .nav-attn { box-shadow: 0 0 0 2px var(--card); }
.nav-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 0.3rem);
  z-index: 50;
  min-width: 15rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: #1f1a14;
  border: 1px solid #33291d;
  border-radius: 0.45rem;
  padding: 0.45rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.86rem;
  /* a short (or landscape) window must not clip log out / about */
  max-height: calc(100vh - 3rem);
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
}
.nav-menu a, .nav-menu button.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0.5rem;
  border-radius: 0.3rem;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nav-menu a:hover, .nav-menu button.nav-item:hover { color: var(--fg); background: #2a221a; }
.nav-menu a.on { color: var(--fg); }
.nav-menu a.on::before {
  content: "";
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--accent);
  margin-left: -0.35rem;
}
.nav-menu .primary { color: var(--fg); font-weight: 600; }
.nav-menu .count { margin-left: auto; font-size: 0.72rem; font-weight: 400; color: var(--accent); }
.nav-menu .count.quiet { color: var(--muted); }
.nav-menu .group-label {
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.75;
  padding: 0.45rem 0.5rem 0.15rem;
}
.nav-menu hr { border: none; border-top: 1px solid #33291d; margin: 0.35rem 0; }
.nav-menu .who { font-size: 0.76rem; padding: 0.1rem 0.5rem; overflow-wrap: anywhere; }
.nav-menu .inline-form { display: block; }
.nav-menu .inline-form button { width: 100%; }
/* about: what this instance is running — version + the build commit the
   release was cut from (healthz's commit) */
.nav-menu .about { display: flex; flex-wrap: wrap; column-gap: 0.6rem; align-items: baseline; padding: 0 0.5rem 0.15rem; }
.nav-menu .about hr { flex: 0 0 100%; }
.nav-menu .about .version, .nav-menu .about .meta { font-size: 0.7rem; }
.nav-menu .about .meta { font-family: ui-monospace, monospace; user-select: all; }

/* the page head's own leading control: ☰ then a hairline before the title */
.page-head.nav-pagehead { align-items: center; } /* beats .page-head's baseline further down */
.nav-pagehead .nav-sep { align-self: stretch; width: 1px; margin: 0.2rem 0; background: #33291d; }
body > main > .nav-pagehead { margin-bottom: 0.4rem; }
/* "all sessions": only the conversation panel's row shows it */
.nav-all { display: none; }

/* conversation page: the panel's first row is the page's nav */
.nav-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.45rem;
  border-bottom: 1px solid #33291d;
  flex: none;
}
/* the include's wrapper dissolves: ☰, the menu and the shortcut become
   items of this row, and the menu anchors to the (relative) panel */
.nav-row .nav-home { display: contents; }
.nav-row .nav-all {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  font-size: 0.74rem;
  color: var(--muted);
  text-decoration: none;
}
.nav-row .nav-all:hover { color: var(--fg); }
.nav-row .nav-all .waiting-dot { color: var(--accent); font-weight: 700; }
.nav-row .nav-all .unread-dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--accent); }
.toolpanel .nav-menu { left: 0.45rem; top: 2.55rem; }
/* collapsed rail: ☰ on top, the expand toggle under it. The panel clips
   its content, so the menu needs the overflow back to escape the 2.2rem. */
body.panel-closed .toolpanel { overflow: visible; }
body.panel-closed .nav-row { flex-direction: column; border-bottom: none; padding: 0.4rem 0.2rem; gap: 0.5rem; }
body.panel-closed .nav-row .nav-all { display: none; }
body.panel-closed .nav-toggle { padding: 0.25rem; }
body.panel-closed .nav-attn { left: 0.85rem; }
body.panel-closed .toolpanel .nav-menu { left: 2.5rem; top: 0.4rem; }
body.panel-closed .toolpanel-body { display: none; }
.nav-row .nav-close { display: none; }

/* phone drawer trigger in the chat's top bar (shown ≤46rem, below) */
.chat-head .nav-drawer-btn { display: none; position: relative; }
.chat-head .nav-drawer-btn .nav-attn { left: 0.95rem; top: 0.1rem; box-shadow: 0 0 0 2px var(--card); }
.nav-scrim { display: none; }
main.wide { max-width: 60rem; }

.page-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.4rem; white-space: nowrap; display: flex; align-items: center; gap: 0.5rem; }
.page-head > .muted { font-size: 0.85rem; }
.page-head > .btn { margin-left: auto; }
.page-head a.muted { text-decoration: none; }
.page-head a.muted:hover { color: var(--accent); }
/* the title: the session title's own click-to-edit, same mechanism,
   this page's own copy (the card's version, projects.html, isn't
   reachable from here) */
.page-title-text { cursor: text; }
.page-title-text:hover { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: #55431f; }
.page-title-edit {
  font: inherit;
  font-weight: 700;
  font-size: inherit;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid #55431f;
  border-radius: 0.3rem;
  padding: 0 0.35rem;
  margin: 0;
  min-width: 10rem;
  max-width: 100%;
  outline: none;
}
.page-title-edit:focus { border-color: var(--accent); }
/* the colour: the big status-dot is now a button (reset below) that
   opens a preset-swatch popover anchored under it — catacloud's
   color_picker atom, trimmed to a preset grid only (this project's
   colour is always one of the 7 named presets or "none", never an
   arbitrary hex, so there is no custom-hex canvas or hue slider to
   port). */
.color-trigger { position: relative; display: inline-flex; }
button.status-dot { border: none; padding: 0; cursor: pointer; }
button.status-dot:hover { box-shadow: 0 0 0 3px #33291d; }
button.status-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.color-pop {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1.4rem);
  gap: 0.45rem;
  padding: 0.5rem;
  background: var(--card);
  border: 1px solid #33291d;
  border-radius: 0.45rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.color-swatch {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 1px solid #33291d;
  padding: 0;
  cursor: pointer;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.sel { box-shadow: 0 0 0 2px var(--accent); }
/* the machines page's "+ add workspace" folder picker (O9): a popover
   anchored under its own "browse…" button, same shape as .color-pop. */
.dir-pick { position: relative; display: inline-flex; align-items: center; gap: 0.35rem; }
.dir-pop {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 10;
  width: 18rem;
  max-width: 80vw;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem;
  background: var(--card);
  border: 1px solid #33291d;
  border-radius: 0.45rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.dir-pop-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.dir-pop-path { overflow-wrap: anywhere; font-size: 0.8rem; }
.dir-pop-list { max-height: 12rem; overflow-y: auto; display: flex; flex-direction: column; }
.dir-pop-entry {
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  padding: 0.25rem 0.4rem;
  border-radius: 0.3rem;
  cursor: pointer;
}
.dir-pop-entry:hover { background: #2a221a; }
.dir-pop-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
/* the project's description, under the title: the session title's own
   click-to-edit (cursor: text signals it), an empty one reads as a
   muted, italic placeholder rather than a blank line. */
.page-desc { margin: -0.4rem 0 0.9rem; }
.page-desc-text { cursor: text; font-size: 0.85rem; }
.page-desc-text:hover { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: #55431f; }
.page-desc-text.placeholder { color: var(--muted); font-style: italic; }
.page-desc-edit {
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: #191410;
  border: 1px solid #55431f;
  border-radius: 0.4rem;
  padding: 0.4rem 0.6rem;
  width: 28rem;
  max-width: 100%;
  outline: none;
}
.page-desc-edit:focus { border-color: var(--accent); }
a.btn { text-decoration: none; display: inline-block; }
.btn { white-space: nowrap; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid #33291d; }
.btn.ghost:hover { border-color: #55431f; }
.btn.small { padding: 0.25rem 0.65rem; font-size: 0.8rem; }
.btn.danger { background: transparent; color: #e07b72; border: 1px solid #6e2b26; }
.linkbtn.danger:hover { color: #e07b72; }
.linkbtn:disabled { opacity: 0.45; cursor: default; }
.search {
  background: #191410;
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  color: var(--fg);
  padding: 0.3rem 0.6rem;
  font: inherit;
  font-size: 0.82rem;
  width: 15rem;
}
.search:focus { outline: none; border-color: #55431f; }
.search[type="search"] { -webkit-appearance: none; appearance: none; }
#memory-search-q { width: 100%; max-width: 28rem; box-sizing: border-box; }
.newproject { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.newproject .error { padding: 0.2rem 0.6rem; }

/* project pill and workspace badge: the two new identities on screen */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 1rem;
  padding: 0.02rem 0.55rem;
  font-size: 0.74rem;
  background: #2a221a;
  color: var(--fg);
  border: 1px solid #33291d;
  text-decoration: none;
  white-space: nowrap;
}
a.pill:hover { border-color: #55431f; }
.pill .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; display: inline-block; }
.ws {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
}
.status-dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; display: inline-block; background: #6e6350; flex-shrink: 0; }
.status-dot.online { background: #9ecf7a; box-shadow: 0 0 6px #9ecf7a66; }
.status-dot.offline { background: #6e6350; }
.status-dot.big { width: 0.7rem; height: 0.7rem; }
.sep { color: #4a4132; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; font-size: 0.9rem; }
.revoked {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #e07b72;
  border: 1px solid #6e2b26;
  border-radius: 0.3rem;
  padding: 0 0.3rem;
}

/* min-width: 0 releases the flex item's content minimum: a long title
   shrinks to the header's free space instead of wrapping the row tall.
   (new_conversation.html's static "New session" h1 is the one .chat-title
   left, in its nav row.) */
.chat-title { flex: 0 1 auto; min-width: 0; }

/* where a tool call ran: quiet on the default workspace, highlighted on
   any other */
.toolcall summary .where {
  flex-shrink: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  padding: 0 0.35rem;
}
.toolcall summary .where.other { color: #e2b25c; border-color: #55431f; }

/* composer: context chips (also reused in the settings dialog, #4) */
.composer-mod .chipval {
  background: #241c15;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  white-space: nowrap;
}
.composer-mod .chipval.locked { color: var(--muted); }
/* the turn-context strip (#83): the where chip (a <span>) and the model
   chip (a <button>) in the composer bar. min-width:0 + ellipsis keep the
   bar ONE row — the chips give way, send/stop keep their size. Colour is
   never the only signal: the ⎇ glyph and the main / wt / default words
   carry the meaning too. */
.composer-bar .chip {
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 0.74rem;
  line-height: 1.5;
  padding: 0.1rem 0.45rem;
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  background: transparent;
  color: var(--muted);
}
.composer-bar .chip.where.wt { color: var(--accent); border-color: #55431f; }
.composer-bar .chip.where.changing { color: var(--accent); border-style: dashed; border-color: #55431f; }
.composer-bar .chip.model { cursor: pointer; }
.composer-bar .chip.model:hover { border-color: #55431f; }
.composer-bar .chip.model.override { color: var(--fg); border-color: #6b5a2a; background: #241c15; }
.composer-bar .chip.model.none { color: #e07b72; border-color: #6e2b26; }
.composer-bar .chip .chip-default { color: var(--muted); }
.composer-bar .chip .chip-once { margin-left: 0.25rem; color: var(--muted); }
.composer-bar .chip .chip-hidden { margin-left: 0.25rem; color: var(--warn, #b45309); }
.composer-bar .chip .chip-effort { margin-left: 0.25rem; }
.composer-bar .chip-short { display: none; }
.composer-bar .btn, .composer-bar .splitbtn { flex: none; }
@media (max-width: 46rem) {
  /* the where chip collapses to ⎇ wt / main (⎇ … while changing), the model
     chip drops its front label and effort; the full text stays in the
     title and aria-label */
  .composer-bar .chip-full { display: none; }
  .composer-bar .chip-short { display: inline; }
  .composer-bar .chip .chip-effort { display: none; }
}
/* the settings menu (#4) reuses the chips and pickers' inner styling */
.settings-panel .composer-mod-label {
  font-size: 0.7rem;
  color: var(--muted);
}
.settings-panel .chipval {
  background: #241c15;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  white-space: nowrap;
}
.settings-panel .chipval.locked { color: var(--muted); }
.settings-panel .chipval:hover { color: var(--accent); }
.settings-panel select {
  background: #241c15;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.4rem;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
}
.settings-panel select:focus { outline: 1px solid #55431f; }
.settings-panel select:disabled { opacity: 0.6; }

/* ── model picker (searchable popover, provider chips) ─────────────
   Opens upward from the trigger like the settings panel itself; the
   model field is the panel's first row, so it grows into the transcript. */
.mp-wrap { position: relative; flex: 0 1 13rem; min-width: 0; }
.mp-trigger {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  text-align: left; font-size: 13px; color: var(--fg); background: #241c15;
  border: 1px solid #4a4132; border-radius: 6px; padding: 4px 7px; cursor: pointer;
}
.mp-trigger:focus-visible, .mp-trigger[aria-expanded="true"] { border-color: var(--accent); outline: none; }
.mp-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-caret { color: var(--muted); flex: none; }
.mp-pop {
  position: absolute; right: 0; bottom: calc(100% + 0.35rem); z-index: 30;
  width: min(23rem, calc(100vw - 2rem)); max-height: min(26rem, 60vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid #55431f; border-radius: 0.6rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.mp-search { padding: 0.55rem 0.6rem 0.4rem; border-bottom: 1px solid #33291c; }
.mp-search input {
  width: 100%; background: #241c15; color: var(--fg); border: 1px solid #4a4132;
  border-radius: 6px; padding: 5px 8px; font: 13px ui-monospace, monospace;
}
.mp-search input:focus { outline: none; border-color: var(--accent); }
.mp-chipbar { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.6rem; border-bottom: 1px solid #33291c; }
.mp-chips {
  flex: 1; min-width: 0; display: flex; gap: 0.3rem; overflow-x: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%);
}
.mp-chips::-webkit-scrollbar { display: none; }
.mp-chip {
  flex: none; font: 11.5px ui-monospace, monospace; color: var(--muted); background: transparent;
  border: 1px solid #4a4132; border-radius: 999px; padding: 1px 8px; cursor: pointer;
  display: inline-flex; gap: 0.35rem; align-items: center;
}
.mp-chip .n { opacity: 0.6; }
.mp-chip.on { color: #14100c; background: var(--accent); border-color: var(--accent); }
.mp-chip.on .n { opacity: 0.75; }
.mp-clear { flex: none; font-size: 11.5px; color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: underline; }
.mp-list { overflow-y: auto; padding: 0.25rem; flex: 1; min-height: 4rem; }
.mp-group { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 0.5rem 0.5rem 0.2rem; }
.mp-row { display: flex; align-items: center; gap: 0.5rem; padding: 4px 8px; border-radius: 5px; cursor: pointer; font: 13px ui-monospace, monospace; }
.mp-row.active { background: #33291c; }
.mp-row.sel .name { color: var(--accent); }
.mp-row .prov { font-size: 10.5px; color: var(--muted); border: 1px solid #4a4132; border-radius: 4px; padding: 0 5px; min-width: 4.2rem; max-width: 6rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-row .name mark { background: transparent; color: var(--accent); font-weight: 700; }
.mp-row .tick { width: 1rem; color: var(--accent); }
.mp-empty { padding: 1.2rem; text-align: center; color: var(--muted); font-size: 13px; }
.mp-foot { display: flex; justify-content: space-between; padding: 0.35rem 0.7rem; border-top: 1px solid #33291c; font-size: 11px; color: var(--muted); }
.mp-foot kbd { background: #241c15; border: 1px solid #4a4132; border-radius: 4px; padding: 0 4px; font: 10.5px ui-monospace, monospace; }

/* new conversation: the empty transcript shows what it inherits */
.inherit {
  border: 1px dashed #33291d;
  border-radius: 0.5rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin: auto 0 0;
}
.inherit h3 { margin: 0 0 0.4rem; font-size: 0.82rem; color: var(--fg); font-weight: 600; }
.inherit dl { display: grid; grid-template-columns: 8rem 1fr; gap: 0.25rem 0.75rem; margin: 0; }
.inherit dt { color: var(--muted); }
.inherit dd { margin: 0; color: var(--fg); }
.inherit .from { color: var(--muted); font-size: 0.72rem; }
.inherit a.from { margin-left: 0.5rem; }
.inherit-ws { margin-right: 0.9rem; display: inline-flex; gap: 0.3rem; align-items: center; }
.default-mark { color: var(--accent); font-size: 0.75rem; }
/* the summary carries the settings themselves (R21): the pickers moved
   here from the composer bar, which is now just the send button */
.inherit-picker { display: inline-flex; align-items: baseline; gap: 0.35rem; }
/* the pickers get the same box as every other input in the app (settings
   fields, table grids): dark fill, border, radius, focus border-swap */
.inherit-picker select {
  background: #191410;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.8rem;
  color-scheme: dark;
  max-width: 16rem;
}
.inherit-picker select:focus { outline: none; border-color: #55431f; }
.inherit-picker select:disabled { opacity: 0.6; }
/* the project page's subagent-model pins (R15): a row per agent, its two
   selects boxed like every other input in the app (same as .inherit-picker) */
.pin-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.25rem 0; }
.pin-row > .mono:first-child { min-width: 8rem; font-size: 0.8rem; }
.pin-row select {
  background: #191410;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.8rem;
  color-scheme: dark;
  max-width: 16rem;
}
.pin-row select:focus { outline: none; border-color: #55431f; }
.pin-row select:disabled { opacity: 0.6; }
.inherit-name {
  background: #191410;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.8rem;
  width: 100%;
  max-width: 24rem;
}
.inherit-name:focus { outline: none; border-color: #55431f; }
.inherit-name:disabled { opacity: 0.6; }

/* ── settings pages (project, machines) ────────────────────────────── */
.settings { display: grid; grid-template-columns: 11rem 1fr; gap: 1.5rem; }
.settings nav.side { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; position: sticky; top: 1rem; align-self: start; }
.settings nav.side a { color: var(--muted); text-decoration: none; padding: 0.25rem 0.5rem; border-radius: 0.3rem; }
.settings nav.side a:hover { color: var(--fg); background: #241c15; }
.settings nav.side .group { margin: 0.4rem 0.5rem 0.2rem; }
@media (max-width: 46rem) { .settings { grid-template-columns: 1fr; } .settings nav.side { position: static; } }

.section { margin-bottom: 1.5rem; }
.section h2 { font-size: 1rem; margin: 0 0 0.2rem; color: var(--fg); }
.section > p.help { margin: 0 0 0.75rem; font-size: 0.8rem; color: var(--muted); }
.section a { color: var(--accent); }
/* a disclosure toggle (memory tree areas) that reads like the links beside it */
.section button.linklike { background: none; border: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; text-align: left; }

.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.85rem; }
.field label { font-size: 0.78rem; color: var(--muted); }
/* number inputs (tool round limit, context window) and the usage page's
   datetime-local range pickers get the same box as text inputs — the type
   list must cover every field on the settings pages */
.field input[type="text"], .field input[type="number"], .field input[type="datetime-local"], .field textarea, .field select {
  background: #191410;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
}
.field textarea { font-family: ui-monospace, monospace; font-size: 0.8rem; min-height: 9rem; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: #55431f; }
/* native datetime-local chrome (the calendar/clock icon, the picker
   popup) is otherwise light-on-light against this dark theme */
.field input[type="datetime-local"] { font-family: ui-monospace, monospace; font-size: 0.8rem; color-scheme: dark; }

/* the system prompt's miniature editor: .editor/.editor-gutter/
   .editor-input (the editor section below — the gutter + textarea pair
   is this page's alone since the file viewer moved to CodeMirror) and
   the file viewer's .preview-md, reused as-is — this wrapper just gives
   them a sized, resizable box to flex into outside the viewer's own
   full-height panel. */
.instr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem; }
.instr-editor {
  height: 18rem;
  resize: vertical;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #33291d;
  border-radius: 0.4rem;
}
.instr-editor .editor, .instr-editor .preview-md { border-radius: 0.35rem; }
/* `.field textarea` (below) outranks `.editor-input` on specificity
   (class+type beats one class) and was leaking its box — border,
   radius, background, padding, and critically font-size/line-height —
   onto the instructions textarea, which also knocked its row height off
   the gutter's 17px contract (see .editor-gutter's comment) and
   misaligned the line numbers. Restated here at higher specificity to
   win back `.editor-input`'s own metrics unchanged. */
.instr-editor .editor-input {
  border: none;
  border-radius: 0;
  background: #120e0a;
  padding: 0.55rem 0.7rem 0.55rem 0.6rem;
  font-size: 0.72rem;
  line-height: 17px;
}
/* a short system prompt rarely runs past three digits of line count —
   the base .editor-gutter's 3.2rem is sized for much longer files */
.instr-editor .editor-gutter { width: 2.2rem; padding: 0.55rem 0.4rem 0.55rem 0.5rem; }
.field input[type="number"] { font-family: ui-monospace, monospace; font-size: 0.8rem; color-scheme: dark; }
.field .note { font-size: 0.74rem; color: var(--muted); }
.fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

table.grid { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
table.grid th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #33291d;
}
table.grid td { padding: 0.5rem; border-bottom: 1px solid #221a13; vertical-align: baseline; }
table.grid td.actions { text-align: right; white-space: nowrap; }
table.grid td .linkbtn { text-decoration: none; padding: 0 0.3rem; font-size: 0.8rem; }
table.grid tr.adding td { background: #1a1510; }
table.grid input[type="text"], table.grid select {
  background: #191410;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.8rem;
  width: 100%;
}
.table-foot { margin-top: 0.6rem; display: flex; gap: 0.75rem; align-items: baseline; font-size: 0.8rem; }
/* the attach-workspace row's <select> sits below the table, not in it, so
   table.grid's own select rule never reaches it — same box regardless */
.table-foot select {
  background: #191410;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.8rem;
}
.table-foot select:focus { outline: none; border-color: #55431f; }

.callout {
  border: 1px solid #33291d;
  background: #191410;
  border-radius: 0.5rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.callout strong { color: var(--fg); }

/* machines: one card per machine */
.machine {
  border: 1px solid #33291d;
  border-radius: 0.55rem;
  background: var(--card);
  padding: 0.8rem 1rem;
  margin-bottom: 0.7rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
}
.machine.revoked { opacity: 0.75; }
.machine .name { font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.machine .name .mono { cursor: text; }
.machine .name .mono:hover { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: #55431f; }
.machine .name .state { font-size: 0.78rem; font-weight: 400; }
/* the inline rename input: swaps in for the name, same spot, same
   metrics (the session title's same pattern, site-wide: .title-edit) */
.machine .name-edit {
  font: inherit;
  font-weight: 600;
  font-size: inherit;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid #55431f;
  border-radius: 0.3rem;
  padding: 0 0.35rem;
  margin: 0;
  min-width: 8rem;
  max-width: 16rem;
  outline: none;
}
.machine .name-edit:focus { border-color: var(--accent); }
.machine .name-error { grid-column: 1; padding: 0.3rem 0.6rem; font-size: 0.78rem; width: fit-content; }
.machine .facts { grid-column: 1; font-size: 0.78rem; color: var(--muted); display: flex; gap: 0.5rem; flex-wrap: wrap; }
.machine .uses { grid-column: 1 / 3; font-size: 0.78rem; color: var(--muted); display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.3rem; }
.machine .acts { grid-row: 1 / 3; grid-column: 2; display: flex; flex-direction: column; gap: 0.3rem; align-items: end; }
.machine .acts .confirm { display: flex; gap: 0.4rem; align-items: center; font-size: 0.78rem; }

/* machine env (#61): the collapsed editor per machine card */
.machine-env { grid-column: 1 / 3; margin-top: 0.4rem; }
.machine-env summary { cursor: pointer; font-size: 0.78rem; color: var(--fg); user-select: none; }
.machine-env summary .muted { margin-left: 0.4rem; }
.machine-env-editor { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.machine-env-editor p { margin: 0; font-size: 0.78rem; }
.machine-env-editor .env-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.machine-env-editor .env-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.78rem; }
.machine-env-editor .env-row input[type="text"],
.machine-env-editor .env-row input[type="password"] {
  font-family: var(--mono, monospace);
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  background: var(--card);
  color: var(--fg);
}
.machine-env-editor .env-row .env-name { width: 11rem; }
.machine-env-editor .env-row .env-value { flex: 1 1 16rem; min-width: 8rem; }
.machine-env-editor .env-row .env-secret { display: inline-flex; gap: 0.25rem; align-items: center; }
.machine-env-editor .env-row .warn { color: #e0b44c; }
.machine-env-editor .env-row .linkish { background: none; border: 0; padding: 0; color: #e0b44c; cursor: pointer; text-decoration: underline; font-size: 0.78rem; }
@media (max-width: 640px) {
  /* rows stack: name over value, toggle and buttons inline */
  .machine-env-editor .env-row .env-name,
  .machine-env-editor .env-row .env-value { flex: 1 1 100%; width: 100%; }
}
.machine-env-editor .env-hints { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; font-size: 0.78rem; }
.machine-env-editor .env-hints .muted { margin-right: auto; }
/* workspace env (the same editor inside a workspace row's disclosure) */
.machine-env-editor > .warn { color: #e0b44c; font-size: 0.78rem; }
.machine-env-editor .env-inherited { display: flex; flex-direction: column; gap: 0.3rem; opacity: 0.85; }
.machine-env-editor .env-inherited-row .env-name { display: inline-block; width: 11rem; overflow-wrap: anywhere; }
.machine-env-editor .env-inherited-row .env-value { flex: 1 1 16rem; min-width: 8rem; overflow-wrap: anywhere; }
.machine-env-editor .env-row.env-unset .env-name { text-decoration: line-through; opacity: 0.7; }
.machine-env-editor .env-unset-badge { font-size: 0.7rem; padding: 0.05rem 0.4rem; border: 1px solid #e0b44c; border-radius: 0.6rem; color: #e0b44c; }
tr.env-disclosure > td { padding: 0.4rem 0.8rem 0.8rem; background: rgba(255, 255, 255, 0.02); }

/* machine-scoped workspaces (O9, #55): a collapsed editor per machine card */
.machine-workspaces { grid-column: 1 / 3; margin-top: 0.4rem; }
.machine-workspaces summary { cursor: pointer; font-size: 0.78rem; color: var(--fg); user-select: none; }
.machine-workspaces summary .muted { margin-left: 0.4rem; }
.machine-workspaces-editor { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.machine-workspaces-editor .grid { font-size: 0.82rem; }
/* per-field click-to-edit (name, description, directory): same signal as
   a session title or the project description — cursor: text, underline
   on hover; no separate rename/save/cancel buttons. */
.machine-workspaces-editor .ws-name-cell { vertical-align: top; }
.machine-workspaces-editor .click-edit { cursor: text; }
.machine-workspaces-editor .click-edit:hover { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: #55431f; }
/* the description, under the name: an unset one reads as a muted, italic
   placeholder rather than a blank line (the project description's own
   convention, .page-desc-text.placeholder). */
.machine-workspaces-editor .ws-desc { margin-top: 0.2rem; font-size: 0.78rem; }
.machine-workspaces-editor .ws-desc .placeholder { font-style: italic; }
.machine-workspaces-editor .ws-desc input[type="text"] { font-size: 0.78rem; }

/* pairing (R24): name → shown-once token + command → first connection */
/* providers (#34 S4, generalized #60): one card per front, either kind —
   same visual language as .machine. The wizard that adds one rides
   .pairing (below), the Machines page's own box. */
.provider {
  border: 1px solid #33291d;
  border-radius: 0.55rem;
  background: var(--card);
  padding: 0.8rem 1rem;
  margin-bottom: 0.7rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
}
.provider.disabled { opacity: 0.75; }
.provider .name { font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.provider .name .state { font-size: 0.78rem; font-weight: 400; }
.provider .facts { grid-column: 1; font-size: 0.78rem; color: var(--muted); display: flex; gap: 0.5rem; flex-wrap: wrap; }
.provider .acts { grid-row: 1 / 3; grid-column: 2; display: flex; flex-direction: column; gap: 0.3rem; align-items: end; }
.provider .acts .confirm { display: flex; gap: 0.4rem; align-items: center; font-size: 0.78rem; }
/* an Ollama card's test result and model list: the full card width */
.provider .ollama-detail { grid-column: 1 / 3; font-size: 0.8rem; overflow-x: auto; }
/* the Models panel under a card (provider-model-settings spec D11) */
.provider .mdl { grid-column: 1 / 3; font-size: 0.84rem; }
.mdl .mdl-bar { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; margin: 0.4rem 0 0.6rem; }
.mdl .mdl-table { width: 100%; border-collapse: collapse; }
.mdl .mdl-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 0.25rem 0.5rem; border-bottom: 1px solid #33291d; }
.mdl .mdl-table td { padding: 0.3rem 0.5rem; border-bottom: 1px solid #261e15; vertical-align: middle; }
.mdl .mdl-table tr.off td { opacity: 0.55; }
.mdl .mdl-table input[type=number], .mdl .mdl-table select, .mdl .mdl-bar input[type=text] {
  background: #191410; color: var(--fg); border: 1px solid #33291d; border-radius: 0.3rem;
  padding: 0.25rem 0.45rem; font: inherit; font-size: 0.8rem; color-scheme: dark;
}
.mdl .mdl-table input[type=number] { width: 8rem; font-family: ui-monospace, monospace; }
.mdl .mdl-table input[type=number]::placeholder { color: #6f6350; }
.mdl .mdl-table select { min-width: 7rem; }
.mdl .mdl-table input:hover:not(:disabled), .mdl .mdl-table select:hover:not(:disabled),
.mdl .mdl-bar input[type=text]:hover { border-color: #44371f; }
.mdl .mdl-table input:focus, .mdl .mdl-table select:focus, .mdl .mdl-bar input[type=text]:focus { outline: none; border-color: #55431f; }
.mdl .mdl-table select:disabled, .mdl .mdl-table input:disabled { opacity: 0.5; cursor: not-allowed; }
.mdl .mdl-table input[type=checkbox] { accent-color: var(--accent); width: 1rem; height: 1rem; cursor: pointer; }
.mdl .mdl-table .src { margin-top: 0.2rem; max-width: 18rem; line-height: 1.35; }
.mdl .src { font-size: 0.72rem; color: var(--muted); }
.mdl .src.ovr { color: var(--accent); }
.mdl .src.warn { color: #e0b050; }
.mdl .pill.warn { color: #e0b050; border-color: #8a6a20; }
.mdl .pill.stale { color: #d08070; border-color: #8a4030; }
.mdl .mdl-banner { border: 1px dashed #55431f; border-radius: 6px; padding: 0.4rem 0.7rem; margin: 0.5rem 0; color: var(--muted); }
.mdl .mdl-banner.warn { color: #e0b050; border-color: #8a6a20; }

/* the ChatGPT-plan connect box: the device code shown large and selectable */
.codex-code {
  font-size: 1.3rem;
  letter-spacing: 0.15em;
  padding: 0.3rem 0.6rem;
  border: 1px solid #4a4132;
  border-radius: 0.35rem;
  background: #14100c;
  display: inline-block;
  user-select: all;
}

/* the kind/machine picker: a row of toggle buttons (wizard + inline edit) */
.kind-pick { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0; }
.kind-pick .btn { display: inline-flex; align-items: center; gap: 0.4rem; }
.kind-pick .btn.on { border-color: var(--accent); color: var(--accent); }

/* the add/edit form, either kind: a bordered panel, stacked labels, dark
   inputs matching the site's other forms (.stack-form input) */
.provider-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border: 1px solid #33291d;
  border-radius: 0.45rem;
  background: #14100c;
  padding: 0.75rem 0.9rem;
  margin-top: 0.5rem;
  max-width: 28rem;
}
.provider-form.editing { grid-column: 1 / 3; max-width: none; }
.provider-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
.provider-form label.inline { flex-direction: row; align-items: center; gap: 0.4rem; }
.provider-form input[type="text"], .provider-form input[type="password"], .provider-form textarea {
  background: #191410;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.35rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  resize: vertical;
}
.provider-form input:focus, .provider-form textarea:focus { outline: none; border-color: #55431f; }
.provider-form .acts { display: flex; gap: 0.5rem; align-items: center; }

.pairing {
  border: 1px solid #55431f;
  border-radius: 0.55rem;
  background: #1a1510;
  padding: 1rem 1.1rem;
  margin-bottom: 1.2rem;
}
.pairing h2 { margin: 0 0 0.6rem; font-size: 1rem; }
.pairing .codex-callback {
  box-sizing: border-box;
  width: 100%;
  background: #191410;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.35rem;
  padding: 0.45rem 0.6rem;
}
.pairing .codex-callback:focus { outline: none; border-color: #55431f; }
.pairing ol { margin: 0; padding-left: 1.2rem; font-size: 0.85rem; }
.pairing li { margin-bottom: 0.7rem; }
.pairing li.pair-warning { list-style: none; margin-left: -1.2rem; }
.pairing .pair-name { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.35rem; }
.pairing .ok { color: #9ecf7a; }
.cmd {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #120e0a;
  border: 1px solid #33291d;
  border-radius: 0.4rem;
  padding: 0.45rem 0.7rem;
  margin: 0.35rem 0;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: nowrap;
}
.cmd code { background: none; padding: 0; flex: 1; }
.cmd .copied { font-size: 0.74rem; }
.waiting { display: flex; gap: 0.5rem; align-items: center; color: var(--muted); font-size: 0.82rem; }

/* pairing (#43): pending install commands and the advanced disclosure */
.pending-codes {
  border: 1px solid #33291d;
  border-radius: 0.55rem;
  background: var(--card);
  padding: 0.7rem 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.82rem;
}
.pending-codes h2 { margin: 0 0 0.5rem; font-size: 0.9rem; }
.pending-code { display: flex; gap: 0.6rem; align-items: baseline; margin-bottom: 0.3rem; }
.advanced-pairing {
  border: 1px dashed #33291d;
  border-radius: 0.55rem;
  padding: 0.7rem 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.85rem;
}
.advanced-pairing summary { cursor: pointer; color: var(--muted); }
.advanced-pairing[open] summary { margin-bottom: 0.6rem; }
.advanced-pairing ol { margin: 0; padding-left: 1.2rem; }
.advanced-pairing li { margin-bottom: 0.7rem; }

/* project cards (projects index) */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.8rem; }
.project {
  border: 1px solid #33291d;
  border-radius: 0.55rem;
  background: var(--card);
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.project:hover { border-color: #55431f; }
.project .pname { font-weight: 600; display: flex; align-items: center; gap: 0.45rem; }
/* the name is the inline-edit target, decoupled from the card's own
   open-on-click (cursor: text signals that, not the card's pointer); a
   keyboard activation or modifier/middle click still navigates normally
   — see projectsList()'s rowClick */
.project .pname-text { cursor: text; }
.project .pname-text:hover { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: #55431f; }
/* the inline rename input: swaps in for .pname-text, same spot, same
   metrics (the session title's and machine name's same pattern,
   site-wide: .title-edit, .name-edit) */
.project .pname-edit {
  font: inherit;
  font-weight: 600;
  font-size: inherit;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid #55431f;
  border-radius: 0.3rem;
  padding: 0 0.35rem;
  margin: 0;
  min-width: 6rem;
  max-width: 100%;
  outline: none;
}
.project .pname-edit:focus { border-color: var(--accent); }
.project .desc { font-size: 0.8rem; color: var(--muted); }
.project .pmeta { font-size: 0.74rem; color: var(--muted); display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ── conversation list (index.html, R33) ─────────────────────────────
   The filter bar is catacloud's component restyled: the search on its
   own line, and below it one 4-segment chip per filter (field |
   operator | values | ×), "+ Filter" and the two-panel picker (fields,
   then operator / values) that opens under the control it came from. */
.filterwrap { margin-bottom: 1rem; position: relative; }
.searchrow { display: flex; margin-bottom: 0.5rem; }
.filterbar { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; position: relative; }
.filterbar-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.filterchips { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.addfilter {
  background: transparent;
  border: 1px dashed #4a4132;
  border-radius: 0.4rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}
.addfilter:hover { color: var(--fg); border-color: #6e6350; }
.clearall { background: none; border: none; color: var(--muted); font: inherit; font-size: 0.78rem; cursor: pointer; text-decoration: underline; }
.clearall:hover { color: var(--accent); }
.chip {
  display: inline-flex;
  background: #241c15;
  border: 1px solid #4a4132;
  border-radius: 0.4rem;
  overflow: hidden;
  font-size: 0.78rem;
}
.chip button { background: none; border: none; color: var(--fg); font: inherit; padding: 0.2rem 0.5rem; cursor: pointer; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button + button { border-left: 1px solid #4a4132; }
.chip button:hover { background: #2f261b; }
.chip .op, .chip .x { color: var(--muted); }
.picker { position: absolute; top: calc(100% + 0.3rem); z-index: 10; display: flex; gap: 0.3rem; align-items: flex-start; }
.picker .menu {
  background: var(--card);
  border: 1px solid #33291d;
  border-radius: 0.45rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 0.35rem 0;
  min-width: 11rem;
}
.picker .menu.sub { min-width: 14rem; }
.picker .options { max-height: 16rem; overflow-y: auto; }
.picker .menu p { margin: 0; padding: 0.15rem 0.75rem 0.3rem; font-size: 0.66rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.picker .menu p.none { text-transform: none; letter-spacing: 0; font-size: 0.8rem; padding-top: 0.3rem; }
.picker .menu button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.83rem;
  text-align: left;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}
.picker .menu button:hover { background: #2a221a; }
.picker .menu button.sel, .picker .menu .check { color: var(--accent); }
.picker .opt { display: inline-flex; align-items: center; gap: 0.4rem; overflow-wrap: anywhere; }
.picker .opt .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; flex-shrink: 0; }
.picker input[type="date"] {
  margin: 0.25rem 0.75rem 0.4rem;
  background: #191410;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  color: var(--fg);
  padding: 0.2rem 0.4rem;
  color-scheme: dark;
}

/* saved views (#58, catacloud's quick-switch pills): one pill per view
   inline in the filter bar. A user view's pill is a two-part button —
   the name (click to apply) and a caret (click for rename/delete/update)
   sharing one seamless outline, like a split button — a preset's pill is
   just the name, nothing to manage. The same radius as every other
   button on the page (.addfilter/.btn), not a capsule: one button
   vocabulary site-wide. The rename/save popovers share the `.picker
   .menu` card styling above. */
.viewpills { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.viewpills .none { font-size: 0.78rem; color: var(--muted); }
.viewpill-wrap { position: relative; display: inline-flex; align-items: stretch; }
.viewpill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #241d14;
  border: 1px solid #4a4132;
  border-radius: 0.4rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}
.viewpill:hover { color: var(--fg); border-color: #6e6350; }
.viewpill.active { color: var(--fg); background: #332a1c; border-color: #6e6350; }
/* the split seam: the pill's right edge and the kebab's left edge meet
   with no gap and no doubled border */
.viewpill.split { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none; }
.viewkebab {
  display: inline-flex;
  align-items: center;
  background: #241d14;
  border: 1px solid #4a4132;
  border-radius: 0.4rem;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
}
.viewkebab:hover { color: var(--fg); border-color: #6e6350; }
.viewkebab.active { color: var(--fg); background: #332a1c; border-color: #6e6350; }
.viewkebabmenu {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  z-index: 10;
  min-width: 11rem;
  background: var(--card);
  border: 1px solid #33291d;
  border-radius: 0.45rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 0.35rem 0;
}
.viewkebabmenu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}
.viewkebabmenu button:hover { background: #2a221a; }
.picker.saveview .menu { min-width: 22rem; }
.picker.saveview form { display: flex; gap: 0.4rem; padding: 0 0.75rem 0.4rem; }
.picker.saveview input[type="text"] {
  flex: 1;
  background: #191410;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  color: var(--fg);
  font: inherit;
  padding: 0.4rem 0.6rem;
  min-width: 12rem;
}
.picker.saveview .error { margin: 0; padding: 0 0.75rem 0.4rem; font-size: 0.76rem; }

/* session tags (0029, catacloud's file-tags pattern): a read-only chip
   cluster in a row / the panel header, and the shared tag-editor popover
   (the picker/saveview precedent) its "+ tag" button opens. */
.tags { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.tagchip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #241c15;
  border: 1px solid #4a4132;
  border-radius: 0.8rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.05rem 0.55rem;
  cursor: pointer;
}
.tagchip:hover { color: var(--fg); border-color: #6e6350; }
.tagchip.removable { cursor: default; }
/* a row's chip is both a filter (the label) and a removal (the ×) —
   the label is a plain button so it keeps the chip's own look, not a
   button's default one */
.tagchip-label { display: inline; background: none; border: none; color: inherit; font: inherit; font-size: inherit; padding: 0; cursor: pointer; }
.tagchip .x { background: none; border: none; color: var(--muted); font: inherit; padding: 0; cursor: pointer; }
.tagchip .x:hover { color: #e07b72; }
.picker.tageditor .menu { min-width: 18rem; padding-bottom: 0.5rem; }
.picker.moveeditor .move-plan { padding: 0 0.75rem 0.4rem; display: flex; flex-direction: column; gap: 0.35rem; }
.picker.moveeditor .move-plan ul { margin: 0; padding-left: 1.1rem; }
.picker.moveeditor .move-plan button { align-self: flex-start; }
.picker.moveeditor .error { padding: 0 0.75rem; }
/* the Sessions list's row editor: viewport-fixed beside its row's button
   (top/bottom/left set inline), not under the filter bar */
.picker.tageditor.floating { position: fixed; z-index: 30; }
.tageditor-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0 0.75rem 0.4rem; }
.tageditor-chips .none { padding: 0; }
.picker.tageditor form { display: flex; gap: 0.4rem; padding: 0 0.75rem 0.4rem; }
.picker.tageditor input[type="text"] {
  flex: 1;
  background: #191410;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  color: var(--fg);
  font: inherit;
  padding: 0.3rem 0.5rem;
  min-width: 10rem;
}
.tageditor-suggestions { display: flex; flex-direction: column; border-top: 1px solid #33291d; padding-top: 0.2rem; }
.tageditor-suggestions button { background: none; border: none; color: var(--fg); font: inherit; font-size: 0.82rem; text-align: left; padding: 0.3rem 0.75rem; cursor: pointer; }
.tageditor-suggestions button:hover { background: #2a221a; }
.picker.tageditor .error { margin: 0; padding: 0.3rem 0.75rem 0; font-size: 0.76rem; }

/* one flat list, newest activity first; the day headings are rows too,
   so "load more" appends a page without regrouping */
.convlist { list-style: none; margin: 0; padding: 0; }
.convlist .bucket { font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 1.1rem 0 0.3rem; border-bottom: 1px solid #221a13; }
.convlist .bucket:first-child { padding-top: 0.2rem; }
.convlist .empty, .convlist .more { list-style: none; }
.convlist .more { text-align: center; padding: 0.8rem 0; }
.convrow {
  display: grid;
  grid-template-columns: 1.1rem 1fr auto;
  gap: 0 0.7rem;
  align-items: baseline;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid #221a13;
  /* the row (anywhere but the title, which edits — see below) opens the
     session; the pointer cursor reads that even before the hover
     background kicks in */
  cursor: pointer;
}
.convrow:hover { background: #1a1510; }
.convrow .state { font-size: 0.8rem; text-align: center; }
.convrow .state .failed { color: #e07b72; font-weight: 700; }
/* the turn is blocked on a pending ask_user question (listing.rs::WAITING,
   same-instance overlay on `running`) — reads as a call to action, not
   just activity, so it gets the unread row's weight too. */
.convrow .state .waiting-dot { color: var(--accent); font-weight: 700; }
.convrow.waiting .when { color: var(--accent); }
/* idle main agent with a background subagent/process still running
   (listing.rs::BACKGROUND): a hollow pulsing ring, so it reads as
   "something is going on" without claiming a turn is running */
.convrow .state .bg-dot {
  display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%;
  border: 2px solid var(--accent); box-sizing: border-box;
  animation: bg-pulse 1.6s ease-in-out infinite;
}
@keyframes bg-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .convrow .state .bg-dot { animation: none; } }
.convrow.background .when { color: var(--accent); }
.convrow.waiting .title { font-weight: 700; }
.sessions-head .waiting-dot { color: var(--accent); font-weight: 700; font-size: 0.8rem; }
/* #5: a title is one line, ellipsized when long — the row never grows to
   fit it. overflow:hidden also zeroes the grid item's automatic minimum
   (min-width:auto), so the 1fr track caps the width; the full title stays
   the anchor's text (find-in-page, screen readers) — a hover tooltip is
   a separate amenity, not part of this fix. */
.convrow .titlewrap { display: flex; align-items: center; gap: 0.3rem; min-width: 0; overflow: hidden; }
/* the title is its own link, decoupled from the row's own open-on-click
   (both go to the same place) so its hit-area stays sized to the text —
   it shouldn't swallow the empty space out to the timestamp, which is
   still row (navigate). */
.convrow .title { color: var(--fg); text-decoration: none; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; cursor: pointer; }
.convrow .title:hover { text-decoration: underline; text-underline-offset: 3px; }
.convrow .when { font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.convrow.running .when { color: var(--accent); }
/* #49: the row is unread — the agent finished a turn since the user last
   had it open. A dot in the state cell (the running spinner / failed `!`
   take precedence there) and a heavier title. */
.convrow.unread .title { font-weight: 700; }
/* 0027: an archived row (shown only when the "archived" chip is on) reads
   as put-away, not gone — dimmed, not struck through. */
.convrow.archived { opacity: 0.6; }
.convrow .titlewrap .badge { font-size: 0.68rem; padding: 0.05rem 0.4rem; }
/* the archive toggle sits at the end of the title line, not among the
   meta row's filters — it acts on the row itself, not a facet of it */
.convrow .titlewrap .archive-toggle { font-size: 0.76rem; flex-shrink: 0; margin-left: auto; }
.convrow .state .unread-dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.1em;
}
.convrow .meta { grid-column: 2 / 4; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.45rem; margin-top: 0.15rem; font-size: 0.76rem; color: var(--muted); }
/* the row's pill, workspace and model are buttons: each adds its filter */
.convrow .meta button { font: inherit; cursor: pointer; }
.convrow .meta button.pill { font-size: 0.74rem; }
.convrow .meta button.pill:hover { border-color: #55431f; }
.convrow .meta button.ws, .convrow .meta button.model { background: none; border: none; padding: 0; color: var(--muted); }
.convrow .meta button.ws { font-family: ui-monospace, monospace; font-size: 0.72rem; }
.convrow .meta button.model { font-family: ui-monospace, monospace; font-size: 0.74rem; }
.convrow .meta button.ws:hover, .convrow .meta button.model:hover { color: var(--fg); }
.convrow .state .spinner { width: 0.9em; height: 0.9em; vertical-align: -0.08em; }
/* the machines page's "waiting to connect" note still spins the ⚙ glyph;
   everything that once shared .spin now uses the .spinner ring */
.spin { display: inline-block; color: var(--accent); animation: cog-spin 1.2s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  .spin { animation: cog-pulse 1.6s ease-in-out infinite alternate; }
}

/* ── subagents: agents page cards (R9; the mockup's mock.css port) ──── */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(24rem, 1fr)); gap: 0.8rem; }
.agent {
  border: 1px solid #33291d;
  border-radius: 0.55rem;
  background: var(--card);
  padding: 0.8rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  cursor: pointer;
}
.agent.builtin { border-style: dashed; }
.review-item { margin-bottom: 0.8rem; }
.agent.off { opacity: 0.55; }
.agent .name { font-weight: 600; display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.agent .desc { grid-column: 1 / 3; font-size: 0.8rem; color: var(--muted); }
.agent .facts { grid-column: 1 / 3; font-size: 0.78rem; color: var(--muted); display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 0.2rem; }
.agent .acts { grid-row: 1; grid-column: 2; display: flex; flex-direction: column; gap: 0.3rem; align-items: end; cursor: default; }
.pill.ro { color: #9ecf7a; }
.pill.bi { color: var(--accent); }
.pill.off { color: var(--muted); }
.check { display: inline-flex; align-items: baseline; gap: 0.35rem; margin-right: 0.9rem; font-size: 0.82rem; white-space: nowrap; }
.check input { accent-color: var(--accent); }
.toolchecks { display: flex; flex-wrap: wrap; gap: 0.15rem; }

/* ══ the workbench (#19): the conversation page's shell ══
   From the reviewed mock (mock.css "workspace panel" block). Layout:
   .workbench is the flex row hosting the tool panel and the MAIN area;
   the panel is collapsible — body.panel-closed keeps a 2.2rem rail with
   the expand toggle, so nothing jumps and the affordance stays visible.
   The panel holds the TOOLS (chat, files — the tabs); the main area is
   their shared surface: the transcript for chat (the default), the file
   viewer for files. Tools never both show at once — a tool switch is a
   surface swap, not a split. */
.workbench {
  display: flex;
  flex: 1;
  min-height: 0; /* the shrink chain must reach the chat column */
  gap: 0.9rem;
  align-items: stretch;
  /* extra width lands around the main area, not after it: the surface
     centers in the space the panel leaves over (the mock's annotation) */
  justify-content: center;
}
/* split panes are their own bordered surfaces docked to the panel and
   the viewport edge (D11-era "flush" look, same reasoning as the two
   panes sitting flush against each other) — the gap and the page's own
   right gutter (below) are both bleed room for the single unsplit
   surface, so split drops them instead of carrying them forward. */
.workbench:has(> .chat-holder.split) { gap: 0; }

.toolpanel {
  position: relative; /* anchors .panel-grip */
  flex: 0 0 var(--panel-basis);
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid #33291d;
  overflow: hidden;
  transition: flex-basis 0.18s ease;
}
/* collapsed: a 2.2rem rail with the expand toggle. The class flips
   --panel-basis rather than flex-basis directly, so EVERYTHING that reads
   the panel's width moves together. The class lives on <body> so
   anything outside the panel can read it too. */
body.panel-closed { --panel-basis: 2.2rem; }

/* the panel's resize grip: a vertical strip over the right border, drag
   to set --panel-basis directly (JS clamps it, bypassing the clamp()
   default above — see startPanelResize). It lives INSIDE the box
   (right: 0, not a negative offset poking past it, unlike .composer-grip)
   because .toolpanel's own overflow: hidden would clip anything that did.
   Hidden while collapsed: the fixed rail width has nothing to resize. */
.panel-grip {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 6px;
  cursor: ew-resize;
  touch-action: none; /* pointer events, not scroll, on touch */
  z-index: 2;
}
.panel-grip:hover { background: #55431f; opacity: 0.55; }
body.panel-closed .panel-grip { display: none; }
/* mid-drag: the real cursor everywhere (not whatever's under the
   pointer), no text selection, and the panel follows the pointer
   immediately — the collapse transition would otherwise lag it */
body.panel-resizing { cursor: ew-resize; user-select: none; }
body.panel-resizing .toolpanel { transition: none; }
/* #2-conv: the panel reads as docked to the viewport's left edge on wide
   screens — the page drops its LEFT gutter there (see the media query
   below) while keeping the right one, so the panel starts at x=0 and the
   chat keeps 1.5rem of breathing room on both sides. The expansion then
   spends the page's own leftover width instead of creating horizontal
   scroll (#1-conv: the chat is the flexible member, never the page). */
main.chat-page:has(.workbench) {
  max-width: none;
  width: 100%;
  padding: 0 1.5rem;
}
/* split's second pane docks to the viewport's right edge the same way
   the panel docks to the left (above) — the page's right gutter is
   bleed room for the single unsplit surface too. */
main.chat-page:has(.chat-holder.split) { padding-right: 0; }
@media (min-width: 70rem) {
  /* #2-conv (wide layout): the page's left gutter goes to the panel, and
     the holder's own 0.6rem padding-left (base rule, every width — the
     file surfaces' -1.5rem eats it with the workbench gap) re-adds the
     inset the gutter used to provide, so the CHAT keeps that breathing
     room. Narrow screens keep the committed layout. */
  main.chat-page:has(.workbench) { padding-left: 0; }
}

/* the panel's tool views: no cap of their own anymore — the panel is
   user-resizable (the right-border grip), so whatever width the user
   dragged it to is width the tree/sessions list should actually use,
   not a fixed column floating in extra space. The chat surface lives in
   the main area (see .workbench > .chat-holder below); the panel body
   only hosts the files tool's workspace sections. .filestool re-states
   the flex chain the body gives it (flex: 1, min-height: 0) — the wrapper
   must pass the height budget down or the sections stop scrolling. */
.toolpanel > .toolpanel-body > .filestool {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  /* the sections (.wsx-sections) and the timeline each scroll on their
     own; the tool itself only lays them out. */
  overflow: hidden;
}

/* ── the sessions tool (the chat tab): the project's other sessions +
   "+ new", the same flex chain as .filestool above so the list scrolls
   instead of growing the panel. Three sub-lists now share it (OTHER
   SESSIONS, SUBAGENTS, PROCESSES) — each gets its own foldable head +
   scrolling .sessionlist, splitting the flex space evenly between the
   open ones. */
.toolpanel > .toolpanel-body > .sessionstool {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.sessions-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.4rem;
  cursor: pointer;
  user-select: none;
}
.sessions-head .twist {
  flex: none;
  width: 0.8rem;
  color: var(--muted);
  font-size: 0.7rem;
}
.sessions-label {
  flex: none;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
/* the OTHER SESSIONS head's own unread dot (#2 of the panel annotations):
   same dot a convrow shows in its state cell, just not nested under one —
   a bare rule of its own rather than widening the convrow selector. */
.sessions-head .head-unread-dot {
  display: inline-block;
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
}
/* a head's own running count (SUBAGENTS, PROCESSES): the same .badge
   chrome the toolcall summaries use, just sized into the head's flex row. */
.sessions-head .head-count {
  flex: none;
}
.sessions-new {
  flex: none;
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.76rem;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  padding: 0.1rem 0.5rem;
}
.sessions-new:hover { border-color: #55431f; background: #191410; }
.hide-completed-toggle {
  flex: none;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.68rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.hide-completed-toggle input {
  cursor: pointer;
  margin: 0;
  accent-color: var(--accent);
  color-scheme: dark;
}
.sessionlist { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0 0.2rem 0.5rem; }
.sessionlist .empty { list-style: none; color: var(--muted); font-size: 0.78rem; padding: 0.6rem 0.4rem; }
/* SUBAGENTS rows have no title link to a session of their own worth
   underlining on hover the same way, and no unread/current state */
.subagentlist .convrow .title:hover { text-decoration: none; }
/* PROCESSES rows: the title is the command itself, not a link, and the
   row opens nothing; a fourth column carries a running process's ✕ —
   hidden (not removed) on ended rows so the status column lines up */
.processlist .convrow { grid-template-columns: 1.1rem 1fr auto auto; cursor: default; }
.processlist .convrow .title { font-family: ui-monospace, monospace; font-size: 0.8rem; cursor: default; }
.processlist .convrow .title:hover { text-decoration: none; }
.processlist .convrow .iconbtn { padding: 0 0.15rem; line-height: 1; }
.processlist .convrow .iconbtn.ended { visibility: hidden; }

/* the panel's one constant header: this conversation's name and project,
   above the chat/files tabs (.toolpanel-head) so it reads regardless of
   which tool is open — see the template comment above .panel-context.
   (The collapse/expand toggle lives in .nav-row above it.) */
.panel-context {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.55rem 0.6rem 0.45rem;
  border-bottom: 1px solid #33291d;
  flex: none;
}
/* collapsed: the whole block disappears — the rail keeps only the nav
   row (☰ + the expand toggle, see .nav-row). */
body.panel-closed .panel-context { display: none; }
.panel-context-title {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* the inline-edit target: site-wide pattern (.title, .pname-text,
     machine .mono), cursor: text signals it, not the panel's own
     pointer cursor */
  cursor: text;
  width: fit-content;
  max-width: 100%;
}
.panel-context-title:hover { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: #55431f; }
/* the inline rename input: swaps in for .panel-context-title, same spot,
   same metrics (site-wide pattern: .title-edit, .pname-edit, .name-edit) */
.panel-context-title-edit {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid #55431f;
  border-radius: 0.3rem;
  padding: 0 0.35rem;
  margin: 0;
  width: 100%;
  outline: none;
}
.panel-context-title-edit:focus { border-color: var(--accent); }
.panel-context-error { margin: 0 0.6rem 0.45rem; padding: 0.3rem 0.6rem; font-size: 0.78rem; width: fit-content; }
/* the pill row below the title: project pill, the "archived" badge when
   set, and the archive/unarchive toggle — same elements and classes as a
   session row's .meta, just this panel's one conversation instead of a
   list of them. */
.panel-context-meta { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.panel-context-meta .pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.panel-context-meta .badge { font-size: 0.68rem; padding: 0.05rem 0.4rem; }
.panel-context-meta .archive-toggle,
.panel-context-meta .move-toggle { font-size: 0.76rem; }
/* 0029: the same tag chips/editor as a session row, mounted here instead
   — on its own line below the pill/badge row, not squeezed in beside it.
   .tagpop is its own positioning context so the popover (plain .picker
   CSS, no computed `left`) anchors under the "+ tag" button regardless of
   where .panel-context itself sits. */
.panel-context-tags { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.panel-context-tags .tagchip { font-size: 0.68rem; padding: 0.05rem 0.45rem; }
.tagpop { position: relative; display: inline-flex; }
.tagpop .tageditor { left: 0; }

.toolpanel-head {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #33291d;
  flex: none;
}
/* the toggle moved up into .panel-context — nothing left in here when
   collapsed (.tool-tabs hides too), so hide the whole bar rather than
   show an empty strip. */
body.panel-closed .toolpanel-head { display: none; }
.tool-tabs { display: flex; gap: 0.15rem; flex: 1; min-width: 0; }
body.panel-closed .tool-tabs { display: none; }
.tool-tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 0.3rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.74rem;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
}
.tool-tab:hover { color: var(--fg); }
.tool-tab.on { color: var(--accent); border-color: #33291d; background: #191410; }
.tool-tab:disabled { cursor: default; opacity: 0.55; }
.tool-tab:disabled:hover { color: var(--muted); }

.toolpanel-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.05rem 0.35rem;
  border-radius: 0.3rem;
  line-height: 1;
}
.toolpanel-toggle:hover { color: var(--accent); background: #2a221a; }
body.panel-closed .toolpanel-toggle { transform: scaleX(-1); } /* ‹ becomes › */

.toolpanel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* the active worktree readout inside an open workspace section (.wsx-detail):
   a quiet line, the same label chrome .sessions-label uses, inline rather
   than its own head row — nothing here to click. */
.wt-box {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0 0.5rem 0.5rem;
  font-size: 0.7rem;
  min-width: 0;
}
.wt-label {
  flex: none;
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.wt-branch {
  flex: 0 1 auto; min-width: 0; color: var(--accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wt-dir {
  color: #6e6350;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── the git bar (the tree's change awareness): a quiet toggle row the
   panel's top row. Colors are the four change kinds —
   added green, modified amber, deleted red, renamed blue. ── */
.gitbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #221a13;
  min-height: 1.55rem;
}
.git-toggle {
  background: none;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  padding: 0.05rem 0.45rem;
  cursor: pointer;
  line-height: 1.4;
}
.git-toggle:hover { color: var(--fg); }
.git-toggle.on { color: var(--accent); border-color: #55431f; background: #191410; }
.git-toggle.small { font-size: 0.62rem; padding: 0.05rem 0.35rem; }
.git-tools { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
/* #annotation-2: the base is a select now (was a static span). It keeps
   the span's muted look for the closed face but is a real control:
   solid surface, hover/focus accent, the mono the bar already uses. */
.git-base {
  color: var(--muted);
  font-size: 0.66rem;
  background: transparent;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  padding: 0.05rem 0.3rem;
  max-width: 16rem;
  cursor: pointer;
}
.git-base:hover { color: var(--fg); border-color: #55431f; }
.git-base:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.git-base option {
  color: var(--fg, #f4efe6);
  background: var(--card, #1f1a14);
  font-family: var(--mono, ui-monospace, monospace);
  padding: 0.2rem 0.4rem;
}
.git-legend { display: flex; gap: 0.3rem; margin-left: auto; }
.git-legend b { font-weight: 600; font-size: 0.66rem; }

/* the four change colors: named once, used by names, badges and dots.
   Chosen against the #14100c ground: readable but clearly secondary to
   the accent. */
:root {
  --git-added: #7fbf5f;
  --git-modified: #e0a545;
  --git-deleted: #e07b72;
  --git-renamed: #6f9fd8;
  --git-ignored: #7a7163;
}
.g-added { color: var(--git-added); }
.g-modified { color: var(--git-modified); }
.g-deleted { color: var(--git-deleted); }
.g-renamed { color: var(--git-renamed); }
.g-ignored { color: var(--git-ignored); }

.treerow {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  width: 100%;
  background: none;
  border: none;
  border-radius: 0.3rem;
  color: var(--fg);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.13rem 0.45rem;
  padding-right: 0.4rem;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.treerow:hover { background: #241c15; }
.treerow-wrap { position: relative; }
.treerow-wrap.drop-on > .treerow { background: #2a221a; outline: 1px dashed var(--accent); outline-offset: -1px; }
.tree-rows.drop-on { outline: 1px dashed var(--accent); outline-offset: -1px; }
.tree-acts {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 0.1rem;
  background: #241c15;
  border-radius: 0.25rem;
}
.treerow-wrap:hover .tree-acts,
.tree-acts:focus-within { display: flex; }
.treerow.renaming { cursor: default; align-items: center; }
.tree-rename {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--fg);
  background: #1a140e;
  border: 1px solid var(--accent);
  border-radius: 0.2rem;
  padding: 0 0.25rem;
}
.tree-rename:focus { outline: none; }
.tree-tools { display: flex; gap: 0.35rem; padding: 0.2rem 0.45rem; }
.treerow.sel { background: #2a221a; }
.treerow.sel .tname { color: var(--accent); }
/* git mode: the name takes the change color (the selected row keeps its
   paint — selection wins over status), directories inherit their
   subtree's kind from rowClass. The letter badge rides the right edge. */
.treerow.g-added .tname { color: var(--git-added); }
.treerow.g-modified .tname { color: var(--git-modified); }
.treerow.g-deleted .tname { color: var(--git-deleted); }
.treerow.g-renamed .tname { color: var(--git-renamed); }
.treerow.g-ignored .tname { color: var(--git-ignored); }
.treerow.sel.g-added .tname { color: var(--accent); }
.treerow.sel.g-modified .tname { color: var(--accent); }
.treerow.sel.g-deleted .tname { color: var(--accent); }
.treerow.sel.g-renamed .tname { color: var(--accent); }
.treerow.sel.g-ignored .tname { color: var(--accent); }
.treerow .twist { flex: none; width: 0.8rem; color: var(--muted); font-size: 0.7rem; }
.treerow .ficon { flex: none; font-size: 0.82rem; }
.treerow .tname {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.treerow.dir .tname { font-weight: 600; }
.treerow .tmeta { flex: none; color: #6e6350; font-size: 0.68rem; }
.treerow .gmark {
  flex: none;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0 0.15rem;
}
.treerow.g-added .gmark { color: var(--git-added); }
.treerow.g-modified .gmark { color: var(--git-modified); }
.treerow.g-deleted .gmark { color: var(--git-deleted); }
.treerow.g-renamed .gmark { color: var(--git-renamed); }
.tree-offline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem 0.8rem;
}
.tree-note {
  color: #6e6350;
  font-size: 0.68rem;
  padding: 0.35rem 0.6rem;
}

/* ── workspace sections (docs/2026-10-21-workspace-sections-spec.md): the
   files panel is one collapsible section per workspace, each head always
   showing state, behind/ahead and change count. Mock: docs/mockups/
   ws-sections. ── */
.wsx-bar { border-bottom: 1px solid #221a13; }
.wsx-total { color: #6e6350; font-size: 0.66rem; white-space: nowrap; }

.wsx-sections {
  /* accordion: the sections take the leftover height and scroll on their
     own, so a big tree never pushes the timeline out of view */
  flex: 1 1 auto; min-width: 0; min-height: 4rem;
  overflow-x: hidden; overflow-y: auto;
}
.wsx-section { border-bottom: 1px solid #221a13; border-left: 2px solid transparent; }
.wsx-section.active { border-left-color: var(--accent); }
/* dimmed ≠ low contrast: the name and state chip keep full contrast; only
   the strip's numbers fade (spec, Accessibility) */
.wsx-section.dim .wsx-count, .wsx-section.dim .wsx-sync { opacity: 0.55; }

/* the section head: the chat tab's .sessions-head, plus a status strip. The
   fold control is a real button (the head may not be one big button once it
   also carries more controls); a click anywhere on the row folds too. */
.wsx-head { gap: 0.4rem; position: relative; container-type: inline-size; padding: 0; }
.wsx-fold {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.4rem; background: none; border: 0; color: inherit;
  font: inherit; text-align: left; cursor: inherit;
}
.wsx-fold:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0.3rem; }
.wsx-fold[aria-disabled="true"] { cursor: default; }
.wsx-head .sessions-label {
  color: var(--fg); font-weight: 600; letter-spacing: 0.04em;
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.wsx-head .wsx-strip {
  display: flex; align-items: center; gap: 0.35rem; min-width: 0;
  flex: 1; overflow: hidden; font-size: 0.66rem;
}
.wsx-state {
  flex: none; padding: 0 0.35rem; border: 1px solid #33291d; border-radius: 0.3rem;
  color: var(--muted); line-height: 1.45; white-space: nowrap;
}
.wsx-state.wt { color: var(--accent); border-color: #55431f; background: #191410; }
.wsx-sync { flex: none; color: #6e6350; white-space: nowrap; }
.wsx-sync .behind.warn { color: #e0b972; }
.wsx-count { flex: none; color: var(--git-modified); white-space: nowrap; }
.wsx-count.zero { color: #6e6350; }
/* a narrow drawer: the count goes first, then the sync's ahead; never the
   state chip (the full text stays in the head's title) */
@container (max-width: 16rem) { .wsx-count { display: none; } }
@container (max-width: 12rem) { .wsx-sync .ahead { display: none; } }
@media (max-width: 46rem) { .wsx-fold { min-height: 2.25rem; } }

/* the expanded section's detail lines (worktree readout, base pick) */
.wsx-detail { min-width: 0; padding: 0 0.5rem 0.3rem 1.7rem; display: flex; flex-direction: column; gap: 0.25rem; }
.wsx-detail .wt-box { padding: 0; }
.wsx-menu .git-base { width: 100%; max-width: 100%; min-width: 0; }
.wsx-basepick { display: flex; align-items: baseline; gap: 0.4rem; min-width: 0; font-size: 0.68rem; color: var(--muted); }
.wsx-basepick > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsx-stale {
  font-size: 0.68rem; color: #e0b972; line-height: 1.4;
  border-left: 2px solid #55431f; padding-left: 0.4rem;
}

/* a section's rows: they flow in the one scroller (.filestool, D14) */
.wsx-section .tree-rows { padding: 0 0.2rem 0.5rem; }
.wsx-section .tree-tools { padding-left: 1.7rem; }
.wsx-empty { padding: 0.1rem 0.5rem 0.5rem 1.7rem; color: #6e6350; font-size: 0.7rem; }

/* the ⋯ menu: the old where-chip popover's chrome, anchored to the head and
   flipping up (.up) when the head sits low in the scroller. Notes (inline
   outcomes, never toasts) and the panel result box follow. */
.wsx-more {
  flex: none; margin-left: auto; align-self: center; background: none;
  border: 1px solid transparent; border-radius: 0.3rem; color: var(--muted);
  cursor: pointer; padding: 0 0.3rem; margin-right: 0.4rem;
  font: inherit; font-size: 0.85rem; line-height: 1.2;
}
.wsx-more:hover, .wsx-more.on { color: var(--fg); border-color: #33291d; background: #191410; }
.wsx-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 46rem) { .wsx-more { min-height: 2.25rem; min-width: 2.25rem; } }

.wsx-menu {
  position: absolute; z-index: 30; right: 0.4rem; top: 100%;
  width: min(19rem, calc(100% - 0.8rem));
  background: var(--card); border: 1px solid #33291d; border-radius: 0.5rem;
  box-shadow: 0 8px 24px #000a; padding: 0.4rem 0.5rem; cursor: default;
  font-size: 0.74rem; display: flex; flex-direction: column; gap: 0.35rem;
  user-select: text;
}
.wsx-menu.up { top: auto; bottom: 100%; }
/* each head is its own stacking context: the one owning an open menu must
   paint above its neighbours' heads */
.wsx-section.menu-open, .wsx-head.menu-open { z-index: 20; }
.wsx-section.menu-open { position: relative; }
.wsx-menu .wsx-menu-title { color: var(--muted); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; }
.wsx-menu select {
  width: 100%; min-width: 0; font-family: var(--mono, ui-monospace, monospace);
  background: #191410; color: var(--fg); border: 1px solid #33291d;
  border-radius: 0.35rem; padding: 0.2rem 0.4rem; font-size: 0.72rem;
}
.wsx-menu select option { color: var(--fg); background: var(--card, #1d1712); padding: 0.2rem 0.4rem; }
.wsx-menu .wsx-act { display: flex; align-items: baseline; gap: 0.5rem; }
.wsx-menu .wsx-note { color: #6e6350; font-size: 0.66rem; line-height: 1.35; }
.wsx-menu .wt-box { padding: 0; min-width: 0; overflow-wrap: anywhere; }
.wsx-menu hr { border: 0; border-top: 1px solid #221a13; margin: 0.1rem 0; width: 100%; }
.wsx-menu .wsx-pick { display: flex; align-items: center; gap: 0.35rem; }
.wsx-menu .wsx-pick select { flex: 1 1 auto; }
.wsx-menu .wsx-icons { display: flex; gap: 0.25rem; }
.wsx-menu .wsx-ic {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; padding: 0; font-size: 0.95rem; cursor: pointer;
  background: #191410; color: var(--muted); border: 1px solid #33291d; border-radius: 0.35rem;
}
.wsx-menu .wsx-ic:hover { color: var(--fg); border-color: #4a3a28; }
.wsx-menu .wsx-ic.m-fresh { color: var(--accent); }
.wsx-menu .wsx-ic.m-branch { color: #8fb8ff; }
.wsx-menu .wsx-ic.m-wt { color: #7fd1a0; }
.wsx-menu .wsx-ic.danger:hover { color: #ff7a7a; border-color: #6a2a2a; }
.wsx-menu .wsx-ic[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.wsx-menu .wsx-ic:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wsx-menu .linkbtn { flex: none; white-space: nowrap; }
.wsx-menu .linkbtn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.wsx-menu [role="menuitem"]:focus-visible, .wsx-menu select:focus-visible,
.wsx-menu .linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* a note under a head: a running action or its outcome (ok / err) */
.wsx-note-line {
  display: flex; align-items: flex-start; gap: 0.4rem;
  padding: 0 0.5rem 0.35rem 1.7rem; font-size: 0.68rem; line-height: 1.4; color: var(--muted);
}
.wsx-note-line .wsx-note-text { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.wsx-note-line.ok { color: var(--git-added); }
.wsx-note-line.err { color: var(--git-deleted); }
.wsx-note-line .iconbtn { flex: none; padding: 0 0.2rem; }
.wsx-note-line .spinner { flex: none; margin-top: 0.15rem; }

/* the panel-level result box above the section list */
.wsx-result {
  flex: none; display: flex; align-items: flex-start; gap: 0.4rem;
  margin: 0.4rem 0.5rem 0; padding: 0.35rem 0.5rem; font-size: 0.7rem; line-height: 1.4;
  background: #191410; border: 1px solid #33291d; border-radius: 0.4rem; color: var(--fg);
}
.wsx-result.ok { border-color: #2f4a26; }
.wsx-result.err { border-color: #5a2f2a; }
.wsx-result.run { color: var(--muted); }
.wsx-result .spinner { flex: none; margin-top: 0.15rem; }
.wsx-result .wsx-result-text { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.wsx-result .iconbtn { flex: none; padding: 0 0.2rem; }
.wsx-raw { margin-top: 0.2rem; color: var(--muted); font-size: 0.64rem; }
.wsx-raw summary { cursor: pointer; }
.wsx-raw pre { margin: 0.2rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 10rem; overflow: auto; user-select: text; }
/* changed-only: the change set's footer (the whole-set merge lives here) */
.wsx-merge {
  flex: none; padding: 0.5rem; border-top: 1px solid #221a13;
  display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.7rem;
}
.wsx-merge .wsx-merge-line { display: flex; align-items: center; gap: 0.5rem; }
.wsx-merge .wsx-note { color: #6e6350; font-size: 0.66rem; }
.wsx-merge .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
/* a deleted row, or a whole untracked folder in changed-only, opens nothing */
.treerow.gone, .treerow[aria-disabled="true"] { cursor: default; }
@media (max-width: 46rem) {
  /* reachable without scrolling a long change list: stuck to the drawer scroller's bottom */
  .wsx-merge { position: sticky; bottom: 0; background: var(--card); z-index: 5; }
}

/* flash the section a chip click jumped to; a static outline under
   prefers-reduced-motion */
.wsx-flash .sessions-head { animation: wsx-flash 1.4s ease-out; }
@keyframes wsx-flash { 0%, 40% { background: #3a2c12; } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  .wsx-flash .sessions-head { animation: none; outline: 2px solid var(--accent); outline-offset: -2px; }
}

/* the composer's where chip: status that links to the panel */
.chip.where.wsx-link { cursor: pointer; }
.chip.where.wsx-link:hover { border-color: #55431f; color: var(--fg); }
.chip.where.wsx-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* the timeline heading names the active workspace so it never reads as
   belonging to the section above it */

/* ── the file timeline (#67): the selected file's commit log, below the
   tree — VS Code's Timeline panel. Rows mirror .treerow's shape (one
   flex line, name/meta split), capped height with its own scroll so a
   long history doesn't push the tree out of view. ── */
.file-timeline {
  flex: 0 1 auto;
  max-height: 45%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #221a13;
}
.file-timeline-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.6rem 0.2rem;
}
.file-timeline:not(.open) { flex: none; } /* folded: exactly the head, never squeezed by the sections */
.file-timeline.open { min-height: 8rem; }
.file-timeline-head { cursor: pointer; }
/* FILES: the timeline's peer — open it takes whatever height the timeline leaves */
.files-section { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.files-section:not(.open) { flex: none; }
.files-head { flex: none; padding-top: 0.35rem; }
.files-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.files-section .file-timeline-fold .ico { transition: transform 0.12s; }
.files-section.open .file-timeline-fold .ico { transform: rotate(90deg); }
.file-timeline-fold { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 0.3rem; }
.file-timeline-fold .ico { width: 0.7rem; height: 0.7rem; transition: transform 0.12s; }
.file-timeline.open .file-timeline-fold .ico { transform: rotate(90deg); }
.file-timeline-rows { flex: 1; min-height: 0; overflow-y: auto; padding: 0 0.2rem 0.4rem; }
.ft-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  width: 100%;
  background: none;
  border: none;
  border-radius: 0.3rem;
  color: var(--fg);
  font: inherit;
  font-size: 0.76rem;
  padding: 0.16rem 0.4rem;
  cursor: pointer;
  text-align: left;
}
.ft-row:hover { background: #241c15; }
.ft-hash { flex: none; color: var(--accent); font-size: 0.7rem; }
.ft-subject {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ft-author { flex: none; color: #6e6350; font-size: 0.68rem; max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-when { flex: none; color: #6e6350; font-size: 0.66rem; }
/* the dirty file's own uncommitted row (#67 follow-up): no real hash to
   show, colored like the tree's own "modified" badge so it reads as the
   file's current, not-yet-committed state rather than a past commit */
.ft-row-uncommitted .ft-hash { color: var(--git-modified); }
.ft-row-uncommitted .ft-subject { font-style: italic; }

/* ── preview ── */
.preview { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── the viewer's tab bar (VSCode-style): one chip per open file, the
   active one lit, each closable on its own. A second row above
   .preview-head, which still shows the active tab's own path/meta —
   the tabs carry just the filename. ── */
.tab-bar {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
  padding: 0.3rem 0.4rem 0;
  overflow-x: auto;
  border-bottom: 1px solid #221a13;
}
.tab {
  flex: none;
  display: flex;
  align-items: center;
  max-width: 12rem;
  min-width: 0;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 0.3rem 0.3rem 0 0;
}
.tab.on { background: var(--card); border-color: #33291d; }
.tab-switch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1 1 auto;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.3rem 0.3rem 0.5rem;
  cursor: pointer;
}
.tab.on .tab-switch { color: var(--fg); }
.tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-dirty { flex: none; color: var(--git-modified); font-size: 0.7rem; }
.tab-close {
  flex: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.3rem 0.4rem 0.3rem 0.1rem;
  cursor: pointer;
  border-radius: 0.25rem;
}
.tab-close:hover { color: var(--fg); background: #2a221a; }

/* chat's pinned tab chip (D2): rendered first in DOM order (the fixed
   slot ahead of the x-for), so position: sticky + left: 0 keeps it from
   scrolling out of .tab-bar's horizontal overflow along with the rest —
   the solid background stops scrolled-under tabs from showing through. */
.tab-pinned {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card);
}
.tab-icon { flex: none; font-size: 0.78rem; }

.preview-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #221a13;
  min-width: 0;
}
.preview-head .iconbtn { flex: none; }
.preview-path {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  font-size: 0.78rem;
}
.preview-meta { flex: none; color: #6e6350; font-size: 0.68rem; }
.preview-meta-line {
  flex: none;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 0.35rem 0.6rem 0;
}
.preview-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.preview-text {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: #120e0a;
  color: #c9c0b2;
  font-size: 0.72rem;
  line-height: 1.45;
  /* pre-wrapped: long lines wrap instead of scrolling sideways */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* rendered markdown: same ground as the raw preview, the prose rules are
   the chat bubble's (.bubble.md below) — shared by selector, not copied */
.preview-md {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.7rem 0.9rem;
  background: #120e0a;
  color: #c9c0b2;
}

/* ── the editor box: the file viewer's CodeMirror 6 host (.editor-host,
   below) and project.html's system-prompt mini-editor (.editor-gutter +
   .editor-input, a plain textarea whose gutter only mirrors it, one
   shared vertical scroll). Same ground and type as the read-only preview
   so a truncated file (the fallback .preview-text above) doesn't change
   the room's lighting. ── */
.editor {
  flex: 1;
  min-height: 0;
  display: flex;
  background: #120e0a;
  /* the wrapper's metrics must agree with the children's contract
     (0.72rem / 17px) — anything inheriting a fractional row height
     reintroduces the drift the gutter/textarea rules pin down (CM6's
     own row box is restated under .cm-scroller below) */
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 17px;
}
.editor-gutter {
  flex: none;
  width: 3.2rem;
  overflow: hidden;
  padding: 0.55rem 0.5rem 0.55rem 0.7rem;
  text-align: right;
  color: #5c5243;
  background: #161109;
  border-right: 1px solid #221a13;
  user-select: none;
  /* the gutter and the textarea MUST compute the same line box or the
     numbers drift off their lines. Two contracts here:
     - font-size 0.72rem + line-height 17px on BOTH sides: the row box
       must be a whole number of CSS pixels. A fractional row (the
       1.45 factor was 16.704px) round-trips through each engine's
       device-pixel snapping differently for stacked blocks (the
       gutter's spans) than for a textarea's internal text rows — the
       mismatch is sub-pixel per row and ACCUMULATES with depth: the
       marks read one line low by ~line 60, many lines low by 2000.
     - the font-family: .editor-input's `font: inherit` shorthand loses
       the .mono tie on source order (family AND size); spelling the
       family here keeps the gutter monospace by its own declaration,
       not by luck. */
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 17px;
}
/* one row per span; the 17px floor mirrors the gutter/textarea row box
   (see .editor-gutter — a fractional height here would quantize the
   stacked spans differently from the textarea's rows) */
.editor-gutter span { display: block; min-height: 17px; position: relative; }
.editor-input {
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: none;
  outline: none;
  resize: none;
  margin: 0;
  padding: 0.55rem 0.7rem 0.55rem 0.6rem;
  background: #120e0a;
  color: #e6ddce;
  font: inherit;
  /* the alignment contract (see .editor-gutter): a whole-pixel row box —
     17px, not a fractional multiplier — and the mono family stated
     explicitly (the `font: inherit` above resets it to the shell's
     sans; the family tie with .mono is lost on source order) */
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 17px;
  /* nowrap: horizontal scroll like a code editor (wrap="off") */
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  caret-color: var(--accent);
}
.editor-input::selection { background: #3d3323; }

/* ── CodeMirror 6 (docs/2026-10-09-editor-syntax-highlighting-spec.md D10)
   both panes' file editor: .editor-host is the mount point (mountEditor)
   and CM6 grows its own line-number gutter, tinted below. The values
   port from .editor-input/.editor-gutter above (P11) — same rem/px
   units, targeting CM6's own stable class names. CM6's base theme is a
   <style> that style-mod inserts as <head>'s FIRST child, ahead of this
   sheet, so this sheet already wins a tie at equal specificity; the
   rules below that override a base-theme declaration (whose selectors
   are scoped under a generated class, `.ͼ1 .cm-scroller` — two classes)
   still carry an extra .cm-editor, so they win on specificity alone and
   don't hang on that injection order. */
.editor-host { flex: 1; min-width: 0; min-height: 0; }
.editor .cm-editor {
  height: 100%;
  background: #120e0a;
  color: #e6ddce;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
}
/* the base theme sets `font-family: monospace; line-height: 1.4` on
   .cm-scroller ITSELF — a declaration on the element beats whatever it
   would inherit from .cm-editor above, so both are restated here:
   `inherit` pulls .cm-editor's ui-monospace stack back down, and the row
   is a whole 17px, not a fractional multiplier */
.editor .cm-editor .cm-scroller { font-family: inherit; line-height: 17px; }
/* vertical padding in whole pixels: CM6 measures it with parseInt and
   offsets the gutter by that, so 0.55rem (8.8px) left every number 0.8px
   above its line — 9px is the nearest whole value */
.editor .cm-content { caret-color: var(--accent); padding: 9px 0.7rem 9px 0.6rem; }
.editor .cm-gutters {
  background: #161109;
  color: #5c5243;
  border-right: 1px solid #221a13;
}
/* the vendored bundle has no drawSelection(): caret and selection are
   the browser's own, on the contenteditable (caret-color above). The
   selected text lives in .cm-line descendants — Firefox applies
   ::selection only to the element that matches it, so the descendant
   form is the one that counts there; the bare one covers text directly
   in .cm-content. */
.editor .cm-content ::selection,
.editor .cm-content::selection { background: #3d3323; }
.editor .cm-editor.cm-focused { outline: none; }
/* bracketMatching(): the warm palette instead of the base theme's teal
   (`&.cm-focused .cm-matchingBracket`, hence the matching specificity) —
   the accent for a pair, the git-deleted red for a stray */
.editor .cm-editor.cm-focused .cm-matchingBracket {
  background: rgba(254, 190, 17, 0.16);
  outline: 1px solid rgba(254, 190, 17, 0.45);
  border-radius: 1px;
}
.editor .cm-editor.cm-focused .cm-nonmatchingBracket {
  background: rgba(224, 123, 114, 0.22);
  color: var(--git-deleted);
}

/* the line-number cells: three lanes left to right — the git bar
   (0.25rem), the hover "+" (0.55rem), then the right-aligned digits from
   1.15rem — so the two marks never overlap each other or a number (the
   old .editor-gutter kept its bar out in the padding, at -0.4rem). The
   base theme pads these `0 3px 0 5px`. */
.editor .cm-editor .cm-lineNumbers .cm-gutterElement { padding: 0 0.5rem 0 1.15rem; }

/* the diff tint (D5), both panes: classes the setLineMarks StateField
   attaches to a line's .cm-gutterElement (gutterLineClass — the cell CM6
   renders the number into, not a bespoke extra gutter column). A
   vertical bar in the change's color — the exact palette the file tree
   colors names with; position: relative because CM6's cell has none. */
.editor .cm-gutterElement { position: relative; }
.editor .cm-gutterElement.g-added::before,
.editor .cm-gutterElement.g-modified::before {
  content: '';
  position: absolute;
  left: 0.25rem;
  top: 0.15em;
  bottom: 0.15em;
  width: 0.22rem;
  border-radius: 0.1rem;
}
.editor .cm-gutterElement.g-added::before { background: var(--git-added); }
.editor .cm-gutterElement.g-modified::before { background: var(--git-modified); }
/* a deletion marks a boundary (the text sat between lines): a red tick
   fading in toward the anchor line's bottom edge, in the bar's lane — a
   gap, not a line. A background, not ::before, so a line that is both
   modified and a deletion's anchor (lineDiff's merged replace) shows
   both marks. */
.editor .cm-gutterElement.g-delmark {
  background: linear-gradient(to bottom, transparent, var(--git-deleted) 60%) no-repeat 0.25rem 100% / 0.22rem 0.5em;
}

/* the editor's annotation marks (D6, annotations spec §3.4), on the same
   .cm-gutterElement (one combined marker per line): the gutter as a line
   picker (a "+" before the hovered number says a click comments on it),
   and a line an annotation covers wears an accent bar on the cell's
   right edge, opposite the git bar. Scoped to .editor-annotatable, which
   both panes' editor hosts carry (docs/2026-10-10-pane2-annotation-
   parity-spec.md D1) — class-scoped, not pane-scoped, so this one rule
   serves either pane's CM6 gutter. */
.editor-annotatable .cm-gutters { cursor: pointer; }
.editor-annotatable .cm-gutterElement:hover::after {
  content: '+';
  position: absolute;
  left: 0.55rem;
  color: var(--accent);
}
.editor-annotatable .cm-gutterElement.a-note {
  color: var(--accent);
  box-shadow: inset -0.16rem 0 0 var(--accent);
}

/* ── annotations (docs/2026-10-07-annotations-spec.md §3) ──
   The 💬 and the comment popover hang off a gutter row but live in
   .preview-body (position: relative, below) — inside the gutter they
   would clip and scroll away. Their `top` comes from the row's viewport
   coordinates (cm1.coordsAtLine in the template), so it tracks scroll. */
.editor { position: relative; }
/* the 💬 and the popover are children of .preview-body (shared by the
   editor and the rendered-markdown view); .editor sits at its origin, so
   CM6's viewport coordinates minus .preview-body's own rect land in the
   same box the markdown view's measurements do */
.preview-body { position: relative; }
.preview-md:focus { outline: none; }
/* rendered markdown: a block an annotation covers (spec §4) */
.preview-md .a-note {
  background: rgba(254, 190, 17, 0.07);
  box-shadow: -0.45rem 0 0 rgba(254, 190, 17, 0.07), -0.6rem 0 0 var(--accent);
  border-radius: 0.15rem;
}
.note-add {
  position: absolute;
  left: 0.1rem;
  height: 17px;
  padding: 0 0.15rem;
  border: none;
  border-radius: 0.25rem;
  background: #2a2117;
  font-size: 0.7rem;
  line-height: 17px;
  cursor: pointer;
  z-index: 3;
}
.note-add:hover { background: #3d3323; }
/* the 💬's stand-in for a grid selection past the annotation cap:
   right-aligned on the same corner the 💬 would have taken */
.note-cap {
  position: absolute;
  transform: translateX(calc(-100% + 1.4rem));
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  background: #2a2117;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
}
/* a file still loading: shown only once the wait is noticeable (the
   0.3s delay), so a fast load never flashes it */
.preview-loading {
  position: absolute;
  top: 0.8rem;
  left: 1rem;
  z-index: 3;
  color: var(--muted);
  font-size: 0.75rem;
  animation: preview-loading-in 0s linear 0.3s both;
}
@keyframes preview-loading-in { from { visibility: hidden; } to { visibility: visible; } }
.note-pop {
  position: absolute;
  /* fallback only: in the editor the template sets left — and width,
     relative to it — from CM6's actual gutter width (it grows with the
     line count's digits) */
  left: 3.4rem;
  width: min(26rem, calc(100% - 4rem));
  padding: 0.5rem;
  background: var(--card);
  border: 1px solid #55431f;
  border-radius: 0.45rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 4;
  font-family: inherit;
}
.note-pop-head { color: var(--muted); font-size: 0.72rem; margin-bottom: 0.3rem; }
.note-pop textarea {
  display: block;
  width: 100%;
  resize: vertical;
  background: #120e0a;
  color: var(--fg);
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  padding: 0.35rem 0.45rem;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.35;
}
.note-pop textarea:focus { outline: none; border-color: #55431f; }
.note-pop-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.note-pop-hint { flex: 1; color: var(--muted); font-size: 0.7rem; }

/* the composer's pending annotations: one chip each, above the textarea */
.note-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.45rem 0.6rem 0;
}
.note-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  background: #2a2117;
  border: 1px solid #3d3323;
  border-radius: 0.35rem;
  font-size: 0.78rem;
}
.note-chip.orphaned { border-color: var(--git-modified); border-style: dashed; }
.note-chip-open {
  display: inline-flex;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.12rem 0.1rem 0.12rem 0.45rem;
  background: none;
  border: none;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.note-chip-where { flex: none; color: var(--accent); }
.note-chip-comment {
  min-width: 0;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.note-chip .iconbtn { padding: 0 0.3rem; }
/* the pending question itself (D3): sits above the pills (or, with no
   options, right above the bare textarea) so a free-text-only question
   reads as clearly as one with pills — not just a placeholder change on
   the textarea underneath it. */
.asked-question {
  padding: 0.5rem 0.6rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
}
/* memory_write confirmation: a compact card above the composer */
.memory-confirm {
  margin: 0.5rem 0.6rem 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 0.85rem;
}
.memory-confirm .mc-head { font-weight: 600; font-size: 0.9rem; color: var(--fg); }
.memory-confirm .mc-meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.1rem; }
.memory-confirm .mc-field { display: block; margin-top: 0.4rem; }
.memory-confirm .mc-label { display: block; color: var(--muted); font-size: 0.75rem; }
.memory-confirm input[type=text], .memory-confirm textarea {
  width: 100%; box-sizing: border-box;
  background: #191410; color: var(--fg);
  border: 1px solid #33291d; border-radius: 0.4rem;
  padding: 0.4rem 0.6rem;
  font: inherit; font-size: 0.85rem;
}
.memory-confirm input[type=text]:focus, .memory-confirm textarea:focus { outline: none; border-color: #55431f; }
.memory-confirm textarea { resize: vertical; }
.memory-confirm .mc-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; align-items: center; }
.memory-confirm .mc-reason { flex: 1 1 14rem; width: auto; }
.memory-confirm .mc-ref { margin-top: 0.25rem; font-size: 0.85rem; overflow-wrap: anywhere; }
.memory-confirm .mc-ref > .mc-label { display: inline; margin-right: 0.4rem; }
.memory-confirm .mc-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 10rem; overflow: auto; font-size: 0.85rem; padding: 0.25rem 0.4rem; border: 1px solid var(--muted); background: var(--card); border-radius: 4px; margin-top: 0.15rem; }
.memory-confirm .mc-current { margin-top: 0.4rem; }
.memory-confirm .mc-current > summary { cursor: pointer; color: var(--muted); font-size: 0.78rem; }
/* ask_user takeover (D3): one pill per proposed answer, above the
   textarea — a click sends immediately, no staging in the box. */
.ask-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem 0;
}
.ask-pills.busy .ask-pill { opacity: 0.6; pointer-events: none; }
.ask-pill {
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
}
/* multi-select (the structured-answer extension): a toggled pill stays
   checked instead of sending at once — the accent border/text mark it
   picked until the composer's send button submits the whole set. */
.ask-pill.selected {
  border-color: var(--accent);
  color: var(--accent);
}
.ask-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
}
/* a pending steer / queued prompt's annotations, beside its text */
.steer-note-chip { flex: none; font-size: 0.75rem; line-height: 1.35rem; color: var(--muted); }
.edit-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}
.edit-dirty { color: var(--git-modified); font-size: 0.8rem; line-height: 1; }
.edit-error {
  flex: none;
  color: #e07b72;
  font-size: 0.7rem;
  padding: 0.3rem 0.7rem;
  background: #1d130f;
  border-bottom: 1px solid #2a1a14;
}
.preview-image {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1rem;
  background: #120e0a;
}
.preview-image img { max-width: 100%; max-height: 100%; border-radius: 0.4rem; }
.preview-img-note { color: var(--muted); font-size: 0.72rem; }
.preview-bin {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 1.2rem;
  text-align: center;
  color: var(--fg);
  font-size: 0.85rem;
}
.preview-bin .ficon.big { font-size: 2rem; opacity: 0.7; }
.preview-bin p { margin: 0; }
.preview-bin .muted { font-size: 0.76rem; }

/* ── the file timeline's diff view (#67): a unified diff, one row per
   DiffLine. Same row box (0.72rem / 17px) as .editor-input/.editor-gutter
   — not shared CSS, a diff row isn't a textarea line, but the metrics
   must still agree so a comment's popover (noteRowTop-style math, see
   diffNoteTop) lands where it looks like it should. ── */
.diff-rows {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #120e0a;
  font-size: 0.72rem;
  line-height: 17px;
}
.diff-row { display: flex; }
.diff-row.diff-added { background: rgba(127, 191, 95, 0.1); }
.diff-row.diff-removed { background: rgba(224, 123, 114, 0.1); }
.diff-gutter {
  flex: none;
  width: 2.6rem;
  padding: 0 0.5rem;
  text-align: right;
  color: #5c5243;
  background: #161109;
  border-right: 1px solid #221a13;
  user-select: none;
  cursor: pointer;
}
.diff-gutter:hover { background: #241c15; }
.diff-gutter-new { border-right: 1px solid #332918; }
.diff-mark { flex: none; width: 1rem; text-align: center; font-size: 0.66rem; }
.diff-text {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 0.6rem;
  color: #e6ddce;
  white-space: pre;
}
.diff-row.diff-added .diff-text { color: var(--git-added); }
.diff-row.diff-removed .diff-text { color: var(--git-deleted); }

/* ── R14: a folded run of unchanged lines, one placeholder row standing
   in for them — click to expand back to plain .diff-row rows (same row
   box height as everything else here, so expanding never reflows the
   rows above it). ── */
.diff-fold {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.6rem;
  color: #8a7d68;
  background: #181309;
  border-top: 1px solid #221a13;
  border-bottom: 1px solid #221a13;
  cursor: pointer;
  user-select: none;
}
.diff-fold:hover { background: #241c15; color: #e6ddce; }

/* ── worktree mode's multi-file diff (R12): purely layout, not a new
   visual system — a flex row + a thin border telling one stacked file's
   block apart from the next. Absent entirely in file mode
   (files.length === 1, x-show gated) ── */
.diff-file-head {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.6rem;
  background: #161109;
  border-bottom: 1px solid #221a13;
}

/* ── PDF preview (pdf.js): a toolbar (find) over a scrollable stack of
   pages, each a canvas with a transparent, selectable text layer on top —
   the same annotation accent rendered markdown's blocks use (.a-note) */
.preview-pdf-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pdf-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid #2a1a14;
}
.pdf-search { display: flex; align-items: center; gap: 0.3rem; min-width: 0; }
.pdf-search input {
  min-width: 0;
  width: 12rem;
  background: #120e0a;
  border: 1px solid #33291d;
  border-radius: 0.3rem;
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
}
.pdf-search input:focus { outline: none; border-color: #55431f; }
.pdf-search-count { color: var(--muted); font-size: 0.7rem; white-space: nowrap; }
.pdf-zoom { display: flex; align-items: center; gap: 0.2rem; margin-left: auto; }
.pdf-zoom-level {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.72rem;
  width: 3rem;
  cursor: pointer;
}
.pdf-zoom-level:hover { color: var(--fg); }
/* UD4's "changed on disk — reload" bar, between the toolbar and the pages */
.pdf-stale {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  color: #e6c07b;
  background: #1d170c;
  border-bottom: 1px solid #33291d;
}
.preview-pdf {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #120e0a;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  /* lazy page sizing compensates scrollTop itself (sizePdfPage) — the
     browser's scroll anchoring would apply the same delta a second time */
  overflow-anchor: none;
}
/* flex: none — a not-yet-rendered placeholder is empty, so as a shrinkable
   flex item in the height-constrained column it collapsed to 0px and every
   page "intersected" the lazy-render observer at once */
.pdf-page { position: relative; flex: none; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.pdf-page canvas { display: block; }
/* pdf.js's own text-layer CSS (web/pdf_viewer.css, trimmed to what
   .pdf-text-layer uses — no annotation-editor/find-highlight rules, our
   own search-hit/a-note classes cover those): natural per-line <br>s and
   canvas-measured glyph widths, not a hand-rolled matrix reimplementation
   (that version was technically selectable but visually "horrid" — no
   line semantics, glyph-width mismatches against font substitution). */
.pdf-text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  text-align: initial;
  /* pdf.js's own default is 0.25 (a dim debug tint) — its own highlight
     DOM lives OUTSIDE this dimmed layer; ours doesn't (search-hit/the
     selection color toggle live directly on these spans), so full
     opacity here — the text itself stays invisible via color:
     transparent alone */
  opacity: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
}
.pdf-text-layer :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}
.pdf-text-layer span.markedContent { top: 0; height: 0; }
.pdf-text-layer ::selection { background: rgba(254, 190, 17, 0.35); }
.pdf-text-layer br::selection { background: transparent; }
.pdf-text-layer span.search-hit { background: rgba(254, 190, 17, 0.28); border-radius: 0.1rem; }
.pdf-text-layer span.search-hit.current { background: rgba(254, 190, 17, 0.65); }

/* ── the conversation find (session-history-search spec R11-R13): the
   PDF find's cousin over the transcript's render units, homed in the
   chat top bar — the search icon expands into the bar in place, the
   same way .pdf-toolbar swaps its toggle for the input. The marker is
   UNIT-level (D6): the whole unit (a bubble, a round, a toolgroup box)
   gets the accent edge, no DOM surgery inside rendered markdown. ── */
.chat-head .find-toggle { flex: none; }
.chat-head .find-bar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: none;
}
/* a compact box: room for ~4-5 words, not the whole bar — the query is
   short-lived and the count/cycle controls matter more than the field */
.chat-head .find-bar input {
  width: 18ch;
  min-width: 0;
  background: var(--bg-input, var(--bg, #1b1c22));
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  color: inherit;
  padding: 0.15rem 0.45rem;
  font-size: 0.82rem;
}
.chat-head .find-bar .find-count { font-size: 0.78rem; opacity: 0.75; white-space: nowrap; }
.messages .find-current {
  box-shadow: inset 0.2rem 0 0 var(--accent);
  background: rgba(254, 190, 17, 0.07);
  border-radius: 0.3rem;
}
/* an annotation covers this page (same accent .preview-md .a-note uses) */
.pdf-page.a-note { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), -0.45rem 0 0 rgba(254, 190, 17, 0.07), -0.6rem 0 0 var(--accent); }

/* ── spreadsheet/tabular grid viewer (build order phase 3, D9/D11): a
   sheet-tab bar over a hand-rolled, row-AND-column-virtualized grid. The
   scroll container (.preview-grid) holds only two children: .grid-sizer,
   an invisible box sized to the full (uncapped-by-viewport) row/column
   extent so the browser's native scrollbar reports the true range, and
   .grid-layer, a zero-size `position: sticky` wrapper pinned to the
   container's own top-left corner — cells inside it are placed with
   real inline top/left (conversation.html's renderGridWindow), repainted
   on every scroll tick rather than scrolled natively. ── */
.preview-grid-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.sheet-tabs {
  flex: none;
  display: flex;
  gap: 0.2rem;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #2a1a14;
  overflow-x: auto;
}
/* formula bar (D17): address box + fx + the editable formula/value, above the
   grid. A <textarea rows=1> styled flat: at rest it reads as text, focused it
   gets the app's ring and (JS) grows to 6 rows so a multi-line value keeps its
   newlines. The save-status cluster sits at its right edge and wraps below it
   in a narrow pane or the phone drawer. */
.grid-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.25rem 0.5rem;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #221a13;
  background: #16110a;
  font-size: 0.72rem;
}
.grid-bar-at {
  flex: none;
  min-width: 3.4rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid #2a1a14;
  border-radius: 0.25rem;
  color: var(--muted);
  font-size: inherit;
  text-align: center;
}
.grid-bar-fx { flex: none; color: var(--muted); font-style: italic; font-size: inherit; padding-top: 0.15rem; }
.grid-bar-val {
  flex: 1 1 8rem;
  min-width: 0;
  box-sizing: border-box;
  background: none;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  outline: 0;
  resize: none;
  overflow: hidden;
  white-space: pre;
  padding: 0.1rem 0.25rem;
  color: #c9c0b2;
  font-size: inherit;
  line-height: 1.35;
}
.grid-bar-val:not([readonly]):hover { border-color: #3a2e1c; }
.grid-bar-val:focus { border-color: rgba(254, 190, 17, 0.7); box-shadow: 0 0 0 1px rgba(254, 190, 17, 0.25); background: #1d160e; }
.grid-bar-val::placeholder { color: var(--muted); font-style: italic; }
/* the file's save status (P8): saved (quiet) / saving… / error · retry /
   conflict · Reload / read-only: <reason>. Icon + text, never colour alone. */
.grid-save {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.4rem;
  padding-top: 0.15rem;
  color: var(--muted);
  font-size: inherit;
}
.grid-save-msg { overflow-wrap: anywhere; }
.grid-save-saved { opacity: 0.8; }
.grid-save-error { color: #e07b72; }
.grid-save-readonly { color: var(--muted); }
.grid-save-ico { display: inline-block; }
.grid-save-ico.spin { animation: grid-spin 1s linear infinite; }
@keyframes grid-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .grid-save-ico.spin { animation: none; } }
/* the quiet "Dependent values not refreshed" label (D21) */
.grid-save-note {
  padding: 0 0.35rem;
  border: 1px dashed #5a4a2c;
  border-radius: 0.25rem;
  color: #d6b25a;
  cursor: help;
}
.grid-save-btn {
  background: none;
  border: 1px solid #3a2e1c;
  border-radius: 0.25rem;
  color: var(--fg);
  font: inherit;
  padding: 0 0.4rem;
  cursor: pointer;
}
.grid-save-btn:hover { border-color: rgba(254, 190, 17, 0.6); }
.grid-save-btn:focus-visible { outline: 1px solid rgba(254, 190, 17, 0.8); }
.sheet-tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 0.3rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
}
.sheet-tab:hover { color: var(--fg); }
.sheet-tab.on { background: #241c15; color: var(--fg); border-color: #3a2e1c; }
/* a sheet the workbook hides: still openable, just marked as such */
.sheet-tab.sheet-hidden { opacity: 0.55; font-style: italic; }
.preview-grid { flex: 1; min-height: 0; overflow: auto; position: relative; background: #120e0a; }
/* a sheet fetch in flight, or its error — centered over the (empty) grid */
.grid-status {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  max-width: 80%;
  padding: 0.45rem 0.8rem;
  background: #1c150d;
  border: 1px solid #3a2e1c;
  border-radius: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  pointer-events: none;
}
.grid-status.error { color: #e07b72; pointer-events: auto; user-select: text; }
.grid-sizer { position: absolute; top: 0; left: 0; visibility: hidden; pointer-events: none; }
.grid-layer { position: sticky; top: 0; left: 0; width: 0; height: 0; overflow: visible; }
.grid-cell {
  position: absolute;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 0.35rem;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 22px;
  color: #c9c0b2;
  /* D11's fill arrives as --cell-bg (renderGridWindow) so the selection
     below can layer over it instead of replacing it */
  background: var(--cell-bg, #120e0a);
  border-right: 1px solid #221a13;
  border-bottom: 1px solid #221a13;
  z-index: 0;
  /* D8: a drag picks a cell RANGE, not text — a native text selection
     fighting it over the same mousedown/mousemove would be worse than
     either alone */
  user-select: none;
}
/* frozen rows/columns (D9) and the synthetic header band both need an
   opaque background and a higher z-index than ordinary cells — they sit
   on top of whatever scrolls underneath them, never blended with it.
   The ladder: plain 0 < frozen by row OR column 1 (the other axis still
   scrolls under the next rung) < frozen by both 2 < header 2 (its own
   band, no overlap with data) < a frozen column/row's header 3 (the
   scrolling headers slide under it) < the corner 4. */
.grid-cell-frozen { z-index: 1; background: var(--cell-bg, #16110a); }
.grid-cell-frozen2 { z-index: 2; }
.grid-cell.grid-head {
  z-index: 2;
  background: #1c150d;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  user-select: none;
}
.grid-cell.grid-head-frozen { z-index: 3; }
.grid-cell.grid-corner { z-index: 4; }
/* D8: a drag/shift-click cell-range selection — the editor gutter's
   accent color, not a native browser selection, since the grid paints
   its own cells rather than letting text flow and select natively. A
   translucent tint layered OVER the cell's own opaque background (its
   fill, or the default), so neither a fill hides the selection nor a
   selected frozen cell lets the cells scrolling beneath show through. */
.grid-cell-sel {
  background: linear-gradient(rgba(254, 190, 17, 0.16), rgba(254, 190, 17, 0.16)), var(--cell-bg, #120e0a);
  box-shadow: inset 0 0 0 1px rgba(254, 190, 17, 0.45);
}
.grid-cell-frozen.grid-cell-sel {
  background: linear-gradient(rgba(254, 190, 17, 0.26), rgba(254, 190, 17, 0.26)), var(--cell-bg, #16110a);
}
/* a filled cell: a stronger tint and outline — 0.16 vanishes on a pale fill */
.grid-cell-filled.grid-cell-sel {
  background: linear-gradient(rgba(254, 190, 17, 0.38), rgba(254, 190, 17, 0.38)), var(--cell-bg);
  box-shadow: inset 0 0 0 2px rgba(254, 190, 17, 0.85);
}

/* P8: an edit not yet confirmed by the server (italic + dim), one the server
   refused (outline; the cell is back to its old value and the status line has
   the retry chip), and a value shown here that the file does not hold (D13/D21:
   dotted underline + tooltip — never colour alone) */
.grid-cell-pending { font-style: italic; opacity: 0.65; }
.grid-cell-error { outline: 1px solid #e07b72; outline-offset: -1px; }
.grid-cell-stale { text-decoration: underline dotted; text-underline-offset: 3px; }
/* D17: the in-cell editor — same font and size as a cell, above every frozen
   layer (corner is 4), a 1px accent border; sized/placed by JS (gridEditorStyle) */
.grid-editor {
  position: absolute;
  z-index: 6;
  box-sizing: border-box;
  margin: 0;
  padding: 0 0.35rem;
  border: 1px solid #febe11;
  border-radius: 0;
  background: #1d160e;
  color: #e6dccb;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 20px;
  white-space: pre;
  overflow: auto;
  resize: none;
  outline: 0;
  user-select: text;
}

/* OQ-I5/#71: the selected cell's full value in a strip under the grid —
   the grid cell itself is one 22px nowrap/ellipsis line, which silently
   hides embedded newlines and long text (a 3,300-char tox conclusion is
   unreadable in the grid). The strip wraps (pre-wrap) and scrolls so any
   value is readable; the meta line names the cell (A1-style). Hidden
   entirely when the selection is empty or a multi-cell range — a range's
   extent is already visible in the tint, and it has no single value. */
.grid-detail {
  flex: none;
  max-height: 9rem;
  overflow: auto;
  border-top: 1px solid #221a13;
  background: #16110a;
  padding: 0.4rem 0.6rem;
}
.grid-detail-meta {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}
.grid-detail-val {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #c9c0b2;
  /* the point of the strip: the full text is selectable/copiable here —
     the grid cell itself deliberately isn't (D8's drag picks a range) */
  user-select: text;
}

/* the panel takes its fixed basis; the main area takes the rest and
   hosts the active tool's surface — .chat already shrinks (flex: 1,
   min-height: 0). .chat-holder is the flex item; the surface column
   caps at 57rem (the base page's content box, 60rem minus its 2×1.5rem)
   and centers in whatever the holder has — same as the pre-workbench
   chat page. The panel's breathing room is declared on the wide layout
   above (0.6rem, next to the workbench's 0.9rem gap) — the narrow
   layout keeps the committed page gutter instead. */
/* Phase 5/D8: a CSS grid, not a flex row — the consolidated tab bar
   (one per pane, ".pane-tab-bar" below) is a layout-level sibling of
   its pane's content (section.chat/.preview.viewer/.preview.diff-viewer/
   .viewer-empty), not nested inside any of them, so it renders
   regardless of which of those is currently active. Grid is load-
   bearing here, not a style preference: a flex row can only lay flat
   siblings out as side-by-side COLUMNS, but a tab bar must stack ABOVE
   its own pane's content within the SAME column — named grid-areas let
   two non-adjacent, non-nested siblings (a pane's tab bar and whichever
   of its content alternatives is currently visible) share one visual
   slot by name, independent of DOM order. */
.workbench > .chat-holder {
  position: relative; /* anchors .split-overlay (stage 2) */
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "ptab" "pcontent";
  /* the file surfaces' docking inset (see .preview.viewer): their
     -1.5rem margin-left eats exactly this plus the workbench gap, at
     every width — one rule, no media split */
  padding-left: 0.6rem;
}
/* pane 1's tab bar/content share "ptab"/"pcontent"; pane 2's (only ever
   present once .split is on) share "stab"/"scontent" — see the
   .pane-order-2 re-purposing below (from a flex `order` to a grid-area
   picker, same class, same meaning: "the pane that renders second").
   Multiple siblings sharing the same named area is intentional: at
   most one of a pane's content alternatives is ever visible at a time
   (mutually exclusive x-show), same as before this phase, just no
   longer achieved by nesting a tab bar inside each alternative. */
.chat-holder > .pane-tab-bar { grid-area: ptab; }
.chat-holder > .chat,
.chat-holder > .preview.viewer,
.chat-holder > .preview.diff-viewer,
.chat-holder > .viewer-empty { grid-area: pcontent; }
.chat-holder > .pane-order-2.pane-tab-bar { grid-area: stab; }
.chat-holder > .pane-order-2:is(.chat, .preview.viewer, .preview.diff-viewer, .viewer-empty) { grid-area: scontent; }

/* ── drag-to-split overlay (stage 2): covers the holder while a tab is
   being dragged and no split exists yet — the one case with room for a
   new pane. onDragOverSplit computes the nearest edge; the zone div
   previews the new pane's size and position, VSCode-style. ── */
.split-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
}
.split-overlay-zone {
  position: absolute;
  background: rgba(254, 190, 17, 0.16);
  border: 2px solid var(--accent);
  border-radius: 0.4rem;
  transition: none; /* the pointer moves fast; a lagging preview reads as broken, not smooth */
  /* load-bearing: without this, the cursor crossing onto this CHILD
     div (the moment the zone it previews appears under it) makes the
     browser fire dragleave on .split-overlay — read as "the drag left
     the drop target" — which clears dropZone, which hides this div,
     which puts the cursor back over .split-overlay directly, which
     re-fires dragover and shows it again: a flicker loop racing the
     drop, so the zone dragover last landed on wins arbitrarily (often
     nothing). pointer-events: none keeps every dragover/dragleave
     targeted at .split-overlay itself, which never loses the drag
     just because its own preview child is visually in the way. */
  pointer-events: none;
}
.split-overlay-zone.left { inset: 0 50% 0 0; }
.split-overlay-zone.right { inset: 0 0 0 50%; }
.split-overlay-zone.top { inset: 0 0 50% 0; }
.split-overlay-zone.bottom { inset: 50% 0 0 0; }

/* the grab affordance; the browser's own native DnD ghost image is the
   drag feedback (no custom styling needed for that part) */
.tab[draggable] { cursor: grab; }

/* which slot a split pane renders in — a class, not :style="'order: '
   + …": Alpine's x-show toggles display by writing el.style.display
   directly, and a SEPARATE :style binding on the same element
   overwrites the whole inline style string on its own reactive tick,
   wiping out x-show's display:none the next time only :style's own
   dependencies change (section.chat stayed visible after unsplit() —
   splitWith/view both false — because :style's last write had already
   erased the display:none x-show set when they'd gone false). No class
   is every element's default (grid-area: ptab/pcontent, above); this
   is the only other class needed.
   Phase 5: re-purposed from a flex `order: 2` to a grid-area picker
   (ptab/pcontent → stab/scontent, above) when the grid replaced the
   flex row — same class, same call sites, same meaning ("the pane that
   renders second"), just a different mechanism underneath. The shared
   unsplit button still needs its own slot between the two panes; see
   its own rule near the bottom of the split section below for how it's
   placed now that there's no flex `order: 1` to pin it with either. */
.pane-order-2 { /* grid-area assigned per element type, see above */ }
/* .chat bleeds the full panel width now, the same way .preview.viewer
   does below (same -1.5rem math) — so its top bar (.chat-head) reaches
   edge to edge, matching the file viewer's .preview-head. The composer
   keeps the old 57rem reading cap (max-width + centering margin).
   .messages is its own scroll owner (x-ref="scroller") and used to carry
   that same cap+centering — which also capped the BOX the scrollbar
   draws against, leaving it stranded at the reading column's edge
   instead of the panel's. It now bleeds full width like .chat itself,
   and gets the 57rem reading width back as inset padding instead: the
   scrollbar tracks the full box (panel's far edge), the text inside
   still reads at the same width and position as before. max() keeps the
   base rule's 0.7rem floor once the panel narrows below 57rem+gutters,
   so this never goes negative and never pinches tighter than the base
   padding did. */
.workbench > .chat-holder > .chat {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  margin: 0 -1.5rem 0 -1.5rem;
  max-width: none;
  /* the same card chrome as .preview.viewer below — chat's tab row and
     content now read as one continuous bordered panel, same as a file's,
     instead of chat alone blending borderless into the page (its past
     look, dropped: a tab row belongs to a tabbed panel, and a panel
     looks like a panel regardless of which tab is active). */
  border: 1px solid #33291d;
  border-left: none;
  border-top: none; /* the pane's tab bar supplies the top edge, see .pane-tab-bar */
  border-radius: 0;
  background: var(--card);
  overflow: hidden;
}
.workbench > .chat-holder > .chat .messages {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  padding-left: max(0.7rem, calc((100% - 57rem) / 2));
  padding-right: max(0.7rem, calc((100% - 57rem) / 2));
}
.workbench > .chat-holder > .chat .composer {
  width: 100%;
  max-width: 57rem;
  margin-left: auto;
  margin-right: auto;
}

/* ── the file viewer (the files tool's main-area surface) ──────────────
   Opening a file flips the workbench to the files tool: the viewer takes
   the WHOLE main panel — the transcript is not beside it anymore, it is
   the other tab. The viewer fills the holder (flex: 1, not the old
   55%-of-the-chat-column) and scrolls itself; it must never stretch the
   column beyond the viewport (min-height: 0 keeps the shrink chain
   unblocked, min-width: 0 lets a long unbroken path squeeze). */
.workbench > .chat-holder > .preview.viewer,
.workbench > .chat-holder > .preview.diff-viewer {
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;      /* the scroll chain must keep working */
  min-width: 0;       /* a long unbroken path squeezes, never overflows */
  /* bleeds past the panel gap AND the holder's 0.6rem inset on the left,
     and past the page's gutter on the right: the left border drops
     (.toolpanel's right border becomes the one shared divider) and the
     right edge lands flush on the viewport. -1.5rem = the workbench gap
     (0.9rem) + the holder's own padding (0.6rem), the same at every
     width — the inset lives on the holder's base rule. */
  margin: 0 -1.5rem 0 -1.5rem;
  max-width: none;
  border: 1px solid #33291d;
  border-left: none;
  border-top: none; /* Phase 5: the pane's tab bar supplies the top edge now, see .pane-tab-bar below */
  border-radius: 0;
  background: var(--card);
  overflow: hidden;
}
.workbench > .chat-holder > .preview.viewer > .preview-head,
.workbench > .chat-holder > .preview.diff-viewer > .preview-head {
  border-bottom: 1px solid #33291d;
  padding: 0.45rem 0.7rem;
}
/* the viewer's empty state — the files tool with nothing open: a quiet
   card matching the viewer's chrome, never a bare blank panel. The
   chrome is the viewer's own bleeded one (see .preview.viewer): past
   the holder's side padding, square, no left border — .toolpanel's
   right border is the one shared divider. Only the dashed stroke sets
   it apart as a placeholder. */
.workbench > .chat-holder > .viewer-empty {
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  margin: 0 -1.5rem 0 -1.5rem;
  border: 1px dashed #33291d;
  border-left: none;
  border-top: none; /* Phase 5: see .preview.viewer above */
  border-radius: 0;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.workbench > .chat-holder > .viewer-empty .ficon.big { font-size: 2rem; opacity: 0.7; }
.workbench > .chat-holder > .viewer-empty p { margin: 0; }

/* ── the consolidated tab bar (D8/Phase 5): a layout-level sibling of
   its pane's content (grid-area, not nesting — see .chat-holder
   above), so it must carry its own box treatment instead of inheriting
   one from whichever content div it used to sit inside. Matches the
   file viewer's chrome above (border/background/bleed) always, chat's
   tab included — chat's content area now carries the same card look
   (.chat-holder > .chat above), so its tab row no longer needs the
   borderless exception it once had. ── */
.workbench > .chat-holder > .tab-bar.pane-tab-bar {
  margin: 0 -1.5rem 0 -1.5rem;
  border: 1px solid #33291d;
  border-left: none;
  border-bottom: 1px solid #221a13; /* the tab row's own divider colour, not the card border's */
  border-radius: 0;
  background: var(--card);
}

/* ── split (stage 1: the chat beside/below the files pane — dragging a
   file tab into its own split is a later increment). Both panes share
   the row/column evenly, with each pane keeping its own full border —
   there are two surfaces now, neither can rely on the panel's border
   as its one shared divider the way the lone bleed surface did. The
   two panes sit flush against each other (no gap, no manual unsplit
   control between them — a pane only collapses back by emptying out,
   see unsplit()). */
.workbench > .chat-holder.split {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "ptab stab" "pcontent scontent";
  padding-left: 0;
}
.workbench > .chat-holder.split.split-column {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto 1fr;
  grid-template-areas: "ptab" "pcontent" "stab" "scontent";
}
.workbench > .chat-holder.split > .chat,
.workbench > .chat-holder.split > .preview.viewer,
.workbench > .chat-holder.split > .preview.diff-viewer,
.workbench > .chat-holder.split > .viewer-empty {
  min-width: 0;
  margin: 0;
  max-width: none;
  border: 1px solid #33291d;
  border-top: none; /* Phase 5: the pane's tab bar (below) supplies the top edge */
  border-radius: 0;
  background: var(--card);
  overflow: hidden;
}
.workbench > .chat-holder.split > .tab-bar.pane-tab-bar {
  margin: 0;
  padding: 0;
  border: 1px solid #33291d;
  border-bottom: 1px solid #221a13;
  border-radius: 0;
  background: var(--card);
}

/* wide content INSIDE the main-panel surfaces is already handled by the
   transcript's own pre/overflow rules (.bubble.md pre, .thinking-body
   pre, .cmd): the panel column is the old 57rem chat column, so nothing
   that fit before can push the page wide now. */

/* the click's row keeps its selected state while the viewer is open:
   .treerow.sel (above) already paints it — visible now that the tree
   stays in the panel while the file renders in the main area */

/* Usage page (docs/2026-10-11-usage-analytics-spec.md Phase 3) */
.usage-controls { margin-bottom: 0.9rem; }
.usage-controls .fields-row { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0.6rem; }
.usage-chart { margin: 0.6rem 0 1.2rem; }
.usage-chart svg { width: 100%; height: 20rem; display: block; }
.usage-summary { margin-top: 0.6rem; }

/* visually hidden, still announced (aria-live regions) */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ≤46rem — the app's existing phone breakpoint (LAST in the file on purpose:
   it must out-rank the workbench rules above, same specificity): the panel leaves the
   flow as an off-canvas drawer (closed by default); the global menu opens
   INLINE at its top, not as a popover. A saved "collapsed" choice means
   nothing here (wspanel() keeps panel-closed off the body). */
@media (max-width: 46rem) {
  main.chat-page:has(.workbench) { padding: 0; }
  .workbench { gap: 0; }
  .workbench > .chat-holder { padding: 0; }
  /* the surfaces' -1.5rem bleed margins cancel the page gutter this drops */
  .workbench > .chat-holder > .chat,
  .workbench > .chat-holder > .preview.viewer,
  .workbench > .chat-holder > .preview.diff-viewer,
  .workbench > .chat-holder > .viewer-empty,
  .workbench > .chat-holder > .tab-bar.pane-tab-bar { margin: 0; }
  .workbench > .chat-holder > .chat { border-right: none; }
  .toolpanel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 22rem);
    flex: none;
    z-index: 60;
    transform: translateX(-100%);
    /* closed = out of the tab order and the a11y tree, not just off-screen
       (visibility flips after the slide-out, before the slide-in) */
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
  body.nav-drawer-open .toolpanel { transform: none; visibility: visible; transition-delay: 0s; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.5); }
  .panel-grip { display: none; }
  .nav-row { flex-wrap: wrap; }
  .nav-row .toolpanel-toggle { display: none; }
  .nav-row .nav-close { display: inline-flex; }
  .nav-row .nav-menu {
    position: static;
    order: 10;
    flex: 0 0 100%;
    box-shadow: none;
    border: none;
    border-top: 1px solid #33291d;
    border-radius: 0;
    margin-top: 0.3rem;
    padding: 0.4rem 0 0;
    min-width: 0;
  }
  .chat-head .nav-drawer-btn { display: inline-flex; }
  .chat-head { padding-top: calc(0.35rem + env(safe-area-inset-top)); }
  /* list pages: the menu must not run off a narrow screen */
  .page-head .nav-menu { position: fixed; left: 0.5rem; right: 0.5rem; top: 3rem; }
}

/* ── session import dialog (export/import spec D7/D9) ───────────── */
.import-dialog { width: min(34rem, calc(100vw - 2rem)); }
.import-risk { border-left: 3px solid var(--accent); padding-left: 0.6rem; color: var(--fg); }
.import-dialog .dlg-field input[type="file"] { max-width: 100%; font-size: 0.8rem; }
.import-sessions, .import-warnings { margin: 0 0 0.9rem; padding-left: 1.1rem; font-size: 0.85rem; }
.import-warnings { color: var(--muted); }
.import-error { margin: 0 0 0.9rem; }
.import-source { display: flex; gap: 0.4rem; }
.import-sessions .mono { word-break: break-all; }

/* Claude Code import, "From a machine" tab (spec D6): wider dialog, a table of
   origin directories, mapping cells, plan and job lists. Same palette as the
   rest of the dialog; nothing here is specific to a state. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.import-dialog.import-wide { width: min(70rem, calc(100vw - 2rem)); max-width: calc(100vw - 2rem); }
.import-tabs { display: flex; gap: 0.4rem; }
.cc-head { margin: 0 0 0.6rem; font-size: 0.9rem; color: var(--accent); }
.cc-head:focus { outline: none; }
.cc-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-machine .error { margin: 0 0 0.7rem; }
.cc-warnline { color: #e0b972; }
.cc-toolbar, .cc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.7rem; }
.cc-chips { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.cc-chips .btn.on { background: #33291d; border-color: #6b5a2a; color: var(--accent); }
.cc-machine input[type="text"], .cc-machine input[type="search"], .cc-machine select {
  background: #241c15;
  color: var(--fg);
  border: 1px solid #4a4132;
  border-radius: 0.4rem;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
  max-width: 100%;
}
.cc-filter { min-width: 14rem; flex: 1 1 14rem; }
.cc-inline { display: inline-flex; align-items: baseline; gap: 0.4rem; font-size: 0.82rem; }
.cc-tablewrap { max-height: 24rem; overflow: auto; border: 1px solid #33291d; border-radius: 0.4rem; margin: 0 0 0.7rem; }
.cc-groups { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.cc-groups th, .cc-groups td { text-align: left; vertical-align: top; padding: 0.4rem 0.55rem; border-bottom: 1px solid #2a221a; }
.cc-groups thead th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: normal; z-index: 1; }
.cc-groups tbody th { font-weight: normal; }
.cc-path { word-break: break-all; }
.cc-flags { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; margin-left: 0.3rem; }
.cc-flag:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cc-reason, .cc-prompt { display: block; color: var(--muted); font-size: 0.74rem; margin-top: 0.15rem; overflow-wrap: anywhere; }
.cc-prompt { font-style: italic; }
.cc-dates { white-space: nowrap; }
.cc-map { min-width: 15rem; }
.cc-sub { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.35rem; }
.cc-problem { margin: 0.3rem 0 0; color: #e07b72; font-size: 0.76rem; }
.cc-flagwarn { margin: 0.3rem 0 0; color: #e0b972; font-size: 0.76rem; }
.cc-attn { outline: 2px solid #e07b72; outline-offset: -2px; }
.cc-detail td { background: #1a1510; }
.cc-sessions { list-style: none; margin: 0 0 0.5rem; padding: 0; max-height: 14rem; overflow: auto; }
.cc-sessions li { margin: 0 0 0.25rem; overflow-wrap: anywhere; }
.cc-sess-actions { display: flex; gap: 0.4rem; margin: 0 0 0.4rem; }
.cc-summary { margin: 0 0 0.7rem; font-size: 0.85rem; color: var(--fg); }
.cc-warnbox { border: 1px solid #6b5a2a; border-left: 3px solid #e0b972; background: #241c15; padding: 0.5rem 0.7rem; margin: 0 0 0.9rem; font-size: 0.82rem; }
.cc-warnbox p { margin: 0 0 0.3rem; }
.cc-warnbox ul { margin: 0; padding-left: 1.1rem; }
.cc-plangroups, .cc-jobgroups { max-height: 14rem; overflow: auto; }
.cc-plangroups .mono, .cc-jobgroups .mono, .cc-warnbox .mono { overflow-wrap: anywhere; }
.cc-progress { width: 100%; margin: 0 0 0.7rem; accent-color: var(--accent); }

/* ── session export control (settings menu) ─────────────────────── */
.export-box { flex-wrap: wrap; align-items: center; }
.export-children { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; }
.export-notice { flex-basis: 100%; margin: 0; font-size: 0.75rem; }
.export-error { flex-basis: 100%; margin: 0; }

/* workspace mode: one collapsible block per git workspace */
.wtl-list { padding-top: 0; }
.wtl-block + .wtl-block { border-top: 1px solid #221a13; }
.wtl-head { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; cursor: pointer; color: var(--muted); font-size: 0.66rem; padding: 0.3rem 0.4rem 0.2rem; }
.wtl-head .file-timeline-fold .ico { transition: transform 0.12s; }
.wtl-block.open .file-timeline-fold .ico { transform: rotate(90deg); }
.wtl-base { color: #6e6350; white-space: nowrap; }
.wsx-menu .wsx-changed { align-self: flex-start; }
.files-head-git { display: inline-flex; align-items: center; gap: 0.5rem; margin-left: auto; }

/* "fold to diff": CM6's fold placeholder, in the diff view's unchanged-run style */
.editor .cm-fold-diff { display: inline-block; padding: 0 0.5rem; border-radius: 0.3rem; background: #1d1712; color: var(--muted); font-size: 0.7rem; cursor: pointer; }
.editor .cm-fold-diff:hover { background: #241c15; color: #e6ddce; }
.wsx-menu .wsx-toggles { display: flex; gap: 0.35rem; align-items: center; }

/* flat view: the file name always shows; its directory is muted and
   shortened from the start ("…/src/server") when the row is too narrow */
.treerow .tname.flat { flex: 0 0 auto; max-width: 100%; }
.treerow .tdir { flex: 1 1 0; min-width: 0; color: #6e6350; font-size: 0.68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }

/* hover over an editor change marker: the base's rows, pointer-transparent */
.gutter-old { position: fixed; z-index: 60; max-width: min(46rem, 60vw); max-height: 18rem; overflow: hidden; pointer-events: none;
  background: #1d1712; border: 1px solid #55431f; border-radius: 0.35rem; box-shadow: 0 6px 18px rgba(0,0,0,.45); font-size: 0.72rem; }
.gutter-old-head { color: var(--muted); padding: 0.15rem 0.5rem; background: #241c15; }
.gutter-old-row { padding: 0 0.5rem; white-space: pre; overflow: hidden; text-overflow: ellipsis; background: rgba(224,123,114,0.10); color: #e6c9c5; }
/* P9: the recalculate-on-open chip, the typed-text preview of a failed save, and
   the grid's modal question. All text + icon, never colour alone. */
.grid-save-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.35rem;
  border: 1px solid #3a2e1c;
  border-radius: 0.25rem;
  color: var(--fg);
  cursor: help;
}
.grid-save-held {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.35rem;
  border: 1px dashed #7a3d37;
  border-radius: 0.25rem;
  color: #e9b3ad;
}
.grid-dialog { max-width: min(34rem, calc(100vw - 2rem)); }
.grid-dialog .dlg-note { line-height: 1.45; }
.grid-dialog .dlg-note strong { font-style: normal; }
.cc-lock { border: 0; margin: 0; padding: 0; min-width: 0; }
.cc-lock:disabled { opacity: 0.6; }
.cc-lost, .cc-projnote, .cc-lostcount { font-size: 0.78rem; }
.cc-lost { color: var(--muted); }

/* ── the new-session page's read-only file viewer ──
   A file tab in the main area (the chat-holder grid, under the tab bar):
   the same card chrome as the chat surface. Lines select by click /
   shift-click / gutter drag; the 💬 comments on the range and the comment
   becomes a chip in the composer. */
.workbench > .chat-holder > .fview {
  grid-area: pcontent;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  margin: 0 -1.5rem 0 -1.5rem;
  display: flex;
  flex-direction: column;
  border: 1px solid #33291d;
  border-left: none;
  border-top: none;
  background: var(--card);
  overflow: hidden;
}
.fview-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.7rem;
  border-bottom: 1px solid #33291d;
  font-size: 0.82rem;
}
.fview-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fview-spacer { flex: 1; }
.fview-note { padding: 0.5rem 0.9rem; font-size: 0.85rem; }
.fview-body { flex: 1; min-height: 0; overflow: auto; font-size: 0.82rem; line-height: 1.45; padding: 0.3rem 0; }
.fview-row { min-width: max-content; }
.fview-line { position: relative; display: flex; white-space: pre; cursor: text; }
.fview-line:hover { background: #241c15; }
.fview-line.sel { background: #3a2e1c; }
.fview-line.noted .fview-no { color: var(--accent); opacity: 1; box-shadow: inset 3px 0 0 var(--accent); }
.fview-no { flex: none; width: 3.4rem; padding-right: 0.8rem; text-align: right; opacity: 0.5; user-select: none; cursor: pointer; }
.fview-text { flex: 1; }
/* the 💬 sits in the gutter of the selection's last line; .note-add is
   positioned against .fview-line */
.fview-line .note-add { top: 2px; left: 0.1rem; }
/* the comment popover opens inline, under the passage */
.fview-row > .note-pop { position: static; margin: 0.2rem 0 0.5rem 3.4rem; width: min(26rem, calc(100vw - 8rem)); white-space: normal; }
.tab-badge {
  flex: none;
  min-width: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 0.6rem;
  background: var(--accent);
  color: #1b150e;
  font-size: 0.68rem;
  text-align: center;
}

/* agents-as-roles D6/D11: the composer's agent chip, its menu, the amber
   fallback note, and the transcript's "agent changed" divider (a quiet
   marker like the compaction one — written by the switch, not the model) */
.agent-wrap { position: relative; gap: 0.3rem; align-items: center; }
.chip.agent { cursor: pointer; }
.chip.agent[disabled] { cursor: default; opacity: 0.7; }
span.chip.agent { cursor: default; }
.chip.agent-note { color: #e0a020; border-color: #e0a020; font-size: 0.72rem; }
.agent-err { color: var(--danger, #e06c5a); font-size: 0.72rem; }
.agent-menu {
  position: absolute; bottom: calc(100% + 0.3rem); left: 0; z-index: 30;
  min-width: 14rem; max-height: 18rem; overflow-y: auto;
  display: flex; flex-direction: column; padding: 0.25rem;
  background: var(--panel, #1b150f); border: 1px solid #33291d; border-radius: 0.5rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.agent-item {
  display: flex; gap: 0.4rem; align-items: baseline; text-align: left;
  background: none; border: 0; color: inherit; font: inherit; font-size: 0.8rem;
  padding: 0.3rem 0.5rem; border-radius: 0.35rem; cursor: pointer;
}
.agent-item:hover, .agent-item:focus-visible { background: #241d15; outline: none; }
.agent-item.on { color: var(--accent); }
.agent-note-divider {
  margin: 0.4rem 0; padding: 0.35rem 0.75rem; border-left: 3px solid #33291d;
  color: var(--muted); font-size: 0.78rem; font-style: italic; opacity: 0.85;
}
