/* ============================================================================
   Serberus — warm claude-style theme over the terminal grammar (Phase F c3)

   Sidebar + main column. The UI body is proportional on warm near-black;
   monospace survives ONLY for agent output, commands, diffs, and paths
   (the --font-mono classes below). Color still carries meaning:
     green  → ok/ready/connected, approve
     amber  → SIMULATED, pending, warnings
     red    → errors, stop, out-of-reservation, reject, REAL mode
     cyan   → commands, paths, links
     accent → brand mark, New chat, send/run/primary pills, focus rings
   Layout: a 280px sidebar (brand, New chat, nav, Recents, account chip) next
   to the five display-toggled views (the chat view is never unmounted), with
   the prompt area pinned at the bottom of the chat view. Timeline lines keep
   the js/terminal.js grammar in the DOM; the message-block rules below style
   it (user bubble, serberus name cap, mono agent chatter). Tags/statuses are
   soft pills — the bracketed [TAG] pseudo-element grammar is gone.
   ========================================================================== */

:root {
  --term-bg:      #262624;   /* main area (warm near-black) */
  --term-surface: #30302e;   /* cards, composer, message blocks */
  --term-line:    #3a3835;   /* hairlines, card borders */
  --term-ink:     #f5f4ef;   /* body text */
  --term-dim:     #a8a49c;   /* timestamps, meta, system lines */
  --term-green:   #4ade80;   /* ok/ready/conectado, approve (kept) */
  --term-amber:   #fbbf24;   /* [SIMULADO], pending, warnings (kept) */
  --term-red:     #f87171;   /* errors, stop, fuera-de-reserva, reject (kept) */
  --term-cyan:    #67e8f9;   /* commands, paths, links (kept) */
  --sidebar-bg:   #1a1918;   /* sidebar */
  --input-bg:     #393937;   /* inputs inside cards */
  --accent:       #d97757;   /* brand mark, send, New chat hover, focus rings */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-serif, Georgia, "Iowan Old Style", "Times New Roman",
    serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Mono",
    Consolas, monospace;
}

/* ---- Reset + base typography -------------------------------------------- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  background: var(--term-bg);
  color: var(--term-ink);
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* ---- The mono split (owner's rule: mono ONLY for agent output, commands,
   diffs, and paths). Everything else inherits the proportional UI stack. --- */

.line-agent,
.proposal-command,
.diff-preview,
.approval-evidence-files,
.approval-evidence-diff,
.approval-escape,
.approval-path,
.integration-changed,
.integration-escape,
.integration-path,
.lock-path,
.run-trace,
.worktree-input,
.project-path,
.run-id,
.autonomy-id,
.history-seq,
.history-type {
  font-family: var(--font-mono);
  font-size: 13px;
}

h1,
h2,
h3 {
  font-size: inherit;
  font-weight: 600;
}

a {
  color: var(--term-cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: rgba(103, 232, 249, 0.25);
}

/* Thin, dark scrollbars everywhere (WebKit + Firefox). */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--term-line) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--term-line);
  border-radius: 4px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ---- Shared controls: buttons, inputs, selects --------------------------- */

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  background: transparent;
}

button {
  cursor: pointer;
  border: 1px solid var(--term-line);
  background: var(--term-surface);
  color: var(--term-ink);
  padding: 0.2rem 0.7rem;
  border-radius: 8px;
}

button:hover:not(:disabled) {
  border-color: var(--term-dim);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

input,
select {
  border: 1px solid var(--term-line);
  background: var(--input-bg);
  color: var(--term-ink);
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
}

input::placeholder {
  color: var(--term-dim);
  opacity: 0.8;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--term-dim) 50%),
    linear-gradient(135deg, var(--term-dim) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 1.4rem;
}

/* Soft rounded pill button (the old [ label ] bracket grammar, de-bracketed
   in Phase F commit 1). */
.term-button {
  border: 1px solid var(--term-line);
  background: transparent;
  color: var(--term-ink);
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  white-space: nowrap;
}

.term-button:hover:not(:disabled) {
  border-color: var(--term-dim);
  background: rgba(245, 244, 239, 0.06);
}

.term-button:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.icon-button {
  border: none;
  background: transparent;
  color: var(--term-dim);
  padding: 0 0.3rem;
}

.icon-button:hover:not(:disabled) {
  color: var(--term-ink);
}

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

/* ---- Status dots (header connection + run states) ------------------------ */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--term-dim);
  flex: none;
}

.status-dot.online {
  background: var(--term-green);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

.status-dot.pending {
  background: var(--term-amber);
}

.status-dot.offline {
  background: var(--term-red);
}

.status-dot.busy {
  background: var(--term-cyan);
}

.status-dot.idle {
  background: var(--term-dim);
}

/* ---- Tag + badge pills ---------------------------------------------------- */
/* Badges render as small outlined pills (the bracketed [TAG] pseudo-element
   grammar is gone); color does the rest. The factories in js/components.js
   are unchanged; only this presentation layer differs. The SIMULATED tag
   stays amber and visible on every surface — that is load-bearing. */

.sim-badge,
.plan-source-badge,
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.6em;
}

.sim-badge {
  color: var(--term-amber);
}

.plan-source-badge {
  color: var(--term-dim);
  font-weight: 400;
}

.plan-source-badge.coordinator {
  color: var(--term-green);
}

.plan-source-badge.fallback {
  color: var(--term-amber);
}

/* Runtime tags on task/agent heads. */
.badge {
  font-weight: 400;
  color: var(--term-dim);
}

.badge.claude {
  color: var(--term-amber);
}

.badge.gemini {
  color: var(--term-cyan);
}

.badge.codex {
  color: var(--term-green);
}

.badge.fake {
  color: var(--term-dim);
}

/* Soft rounded tag pill (de-bracketed [TAG] grammar): the color rules below
   keep their exact status hues. */
.term-tag {
  display: inline-block;
  font-weight: 600;
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.6em;
}

.term-tag.tag-sim {
  color: var(--term-amber);
}

/* Red out-of-reservation tag on approval/integration escape blocks. */
.term-tag.tag-escape {
  color: var(--term-red);
}

/* Amber human-review tag on reviewer-fallback approvals. */
.term-tag.tag-human {
  color: var(--term-amber);
}

/* Red offline tag on the example roster note. */
.term-tag.tag-offline {
  color: var(--term-red);
}

/* ============================================================================
   Sidebar (brand, New chat, nav, Recents, account chip) + collapse toggle
   ========================================================================== */

/* Always-visible fixed toggle: below the modal backdrop (z 50), above the
   mobile sidebar overlay (z 40). */
.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 45;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--term-dim);
  font-size: 16px;
  line-height: 32px;
  text-align: center;
  border-radius: 8px;
}

.sidebar-toggle:hover:not(:disabled) {
  color: var(--term-ink);
  background: rgba(245, 244, 239, 0.08);
}

.sidebar {
  width: 280px;
  flex: none;
  min-height: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--term-line);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
}

body.sidebar-collapsed .sidebar {
  display: none;
}

/* Brand row clears the fixed toggle (12px + 32px button). */
.brand {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  padding-left: 38px;
  min-width: 0;
}

.brand-mark {
  color: var(--term-ink);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.brand-accent {
  color: var(--accent);
  font-size: 16px;
}

.new-chat-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
}

.new-chat-button:hover:not(:disabled) {
  background: rgba(217, 119, 87, 0.14);
}

.new-chat-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--sidebar-bg);
  font-weight: 600;
  line-height: 1;
  flex: none;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Sidebar nav rows (the account chip is one too, so showView's is-active
   toggling covers it unmodified). */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--term-dim);
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  white-space: nowrap;
}

.nav-link:hover:not(:disabled) {
  color: var(--term-ink);
  background: rgba(245, 244, 239, 0.06);
}

.nav-link.is-active {
  color: var(--term-ink);
  background: rgba(245, 244, 239, 0.1);
}

.nav-badge {
  margin-left: auto;
  color: var(--term-dim);
  font-size: 11px;
  background: rgba(245, 244, 239, 0.08);
  border-radius: 999px;
  padding: 0 0.55em;
  min-width: 1.7em;
  text-align: center;
}

.nav-badge.alert {
  color: var(--sidebar-bg);
  background: var(--term-amber);
  font-weight: 600;
}

/* ---- Recents: last 8 runs from the 5s poll (js/shell.js renderRecents) ---- */

.recents {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.6rem;
}

.recents-label {
  color: var(--term-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 0.6rem;
}

.recents-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.recents-empty {
  color: var(--term-dim);
  font-size: 12px;
  padding: 0.3rem 0.6rem;
}

.recent-run {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--term-dim);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
}

.recent-run:hover:not(:disabled) {
  background: rgba(245, 244, 239, 0.06);
  color: var(--term-ink);
}

.recent-run-id {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--term-ink);
  font-size: 13px;
}

.recent-run-mode {
  flex: none;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.55em;
  line-height: 1.6;
}

.recent-run-mode.simulated {
  color: var(--term-amber);
}

.recent-run-mode.real {
  color: var(--term-red);
}

.recent-run-time {
  flex: none;
  font-size: 11px;
  color: var(--term-dim);
}

/* ---- Account chip (pinned bottom): project + connection + gear ----------- */

.account-chip {
  flex: none;
  margin-top: 0.25rem;
  border-top: 1px solid var(--term-line);
  border-radius: 0 0 8px 8px;
  padding: 0.6rem;
  gap: 0.6rem;
}

.account-chip-gear {
  flex: none;
  font-size: 16px;
  color: var(--term-dim);
}

.account-chip:hover:not(:disabled) .account-chip-gear {
  color: var(--term-ink);
}

.account-chip-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.05rem;
}

.account-chip-project {
  color: var(--term-ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip-connection {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--term-dim);
  font-size: 11px;
  white-space: nowrap;
}

/* ============================================================================
   Views — the main column next to the sidebar, display-toggled, centered
   ========================================================================== */

.views {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  min-height: 0;
}

.view.is-active {
  display: flex;
  flex-direction: column;
}

/* Non-chat views scroll as one column. */
.view:not(.view-chat).is-active {
  overflow-y: auto;
  gap: 1.25rem;
}

.view-heading {
  color: var(--term-ink);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Stacked sections inside a view: rounded cards on the warm background. */
.block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--term-line);
  border-radius: 12px;
  padding: 1rem;
}

.block-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  border-bottom: 1px solid var(--term-line);
  padding-bottom: 0.35rem;
}

/* Small-caps section caption (replaces the old "▸ " glyph prefix). */
.block-label {
  color: var(--term-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Count pill (de-bracketed [n] grammar). */
.count {
  color: var(--term-dim);
  font-size: 11px;
  background: rgba(245, 244, 239, 0.08);
  border-radius: 999px;
  padding: 0 0.55em;
  min-width: 1.7em;
  text-align: center;
}

/* ============================================================================
   Chat view: timeline + floating composer card, with an idle hero
   ========================================================================== */

/* Two CSS states on one class (js/shell.js flips it from a MutationObserver
   on the timeline's children):
     idle    (.chat-idle, timeline empty) — centered column: serif greeting +
             project name + roles subtitle, the composer card, the suggestion
             chips; the (empty) timeline is display:none.
     active  (timeline has lines) — hero + chips hidden, timeline flex:1,
             composer in-flow at the bottom. The composer is NEVER
             position-fixed: `timeline.scrollTop = scrollHeight` pinning only
             means something while the timeline owns the remaining height. */
.view-chat {
  max-width: 820px;
  padding-bottom: 0.75rem;
  gap: 0;
}

.view-chat.chat-idle {
  justify-content: center;
  gap: 1.5rem;
}

.view-chat.chat-idle .timeline {
  display: none;
}

/* ---- Idle hero ------------------------------------------------------------ */

.chat-hero {
  display: none;
}

.view-chat.chat-idle .chat-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
}

.hero-greeting {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 400;
  color: var(--term-ink);
}

.hero-project {
  color: var(--term-dim);
}

.hero-project:empty {
  display: none;
}

.hero-subtitle {
  color: var(--term-dim);
}

/* ---- Suggestion chips (idle only; js/chat.js prefills the composer) ------- */

.suggestion-chips {
  display: none;
}

.view-chat.chat-idle .suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.suggestion-chip {
  border: 1px solid var(--term-line);
  background: transparent;
  color: var(--term-dim);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
}

.suggestion-chip:hover:not(:disabled) {
  color: var(--term-ink);
  border-color: var(--term-dim);
  background: rgba(245, 244, 239, 0.06);
}

.timeline {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 15px;
}

/* ---- Message blocks over the line grammar --------------------------------
   js/terminal.js keeps emitting the same article.line DOM (time gutter,
   per-kind prefix, body); these rules dress it as claude-style messages:
     user     surface bubble (rounded 12px), proportional, "> " prefix hidden
     serberus  plain proportional text under a small dim "serberus" name cap
     agent    mono, dim, cyan name — the terminal grammar kept, slight inset
     system   small dim proportional (· prefix, inline → actions)
     error    red (! prefix)
   The 11px time gutter survives on every kind and hides under 720px. */

.line {
  display: grid;
  grid-template-columns: 9ch max-content 1fr;
  column-gap: 0.75ch;
  align-items: baseline;
}

.line-time {
  color: var(--term-dim);
  opacity: 0.7;
  font-size: 11px;
}

.line-prefix {
  white-space: nowrap;
}

.line-text {
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 0;
}

/* User bubble: the ">" prefix stays in the DOM (and the strip history) but
   not on screen; the body becomes a surface block. */
.line-user {
  grid-template-columns: 9ch 1fr;
  margin: 0.3rem 0;
}

.line-user .line-prefix {
  display: none;
}

.line-user .line-text {
  justify-self: start;
  max-width: 100%;
  background: var(--term-surface);
  border-radius: 12px;
  padding: 0.45rem 0.9rem;
  color: var(--term-ink);
}

/* Serberus reply: a small lowercase name cap (the wordmark style) above plain
   proportional text, both indented past the time gutter. */
.line-serberus {
  grid-template-columns: 9ch 1fr;
  grid-template-areas:
    "time prefix"
    ".    text";
  margin: 0.3rem 0;
  row-gap: 0.1rem;
}

.line-serberus .line-time {
  grid-area: time;
}

.line-serberus .line-prefix {
  grid-area: prefix;
  color: var(--term-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.line-serberus .line-text {
  grid-area: text;
  color: var(--term-ink);
}

/* Agent chatter keeps the full terminal grammar (· name │ text), mono via the
   split above, slightly inset from the other kinds. */
.line-agent {
  padding-left: 1ch;
}

.line-agent .line-prefix {
  color: var(--term-cyan);
  opacity: 0.75;
}

.line-agent .line-text {
  color: var(--term-dim);
}

.line-system .line-prefix,
.line-system .line-text {
  color: var(--term-dim);
  font-size: 13px;
}

.line-error .line-prefix,
.line-error .line-text {
  color: var(--term-red);
}

/* Inline clickable affordance at the end of a system line ("→ activity"). */
.line-action {
  border: none;
  background: transparent;
  color: var(--term-cyan);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.line-action:hover:not(:disabled) {
  color: var(--term-ink);
}

/* Thinking line: amber, pulsing. */
.line-thinking .line-prefix {
  color: var(--term-amber);
}

.chat-thinking-text {
  color: var(--term-amber);
}

.chat-thinking {
  animation: chat-thinking-pulse 1.6s ease-in-out infinite;
}

@keyframes chat-thinking-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* ---- Proposal card -------------------------------------------------------- */
/* Rounded card aligned with the message text column (9ch time gutter + the
   grid gap); the green/amber status rail and the mono "$ command" line stay —
   they carry meaning. The run button is the accent pill: still the ONE
   explicit launch affordance. */

.proposal {
  margin: 0.5rem 0 0.5rem calc(9ch + 0.75ch);
  border: 1px solid var(--term-line);
  border-left: 3px solid var(--term-green);
  border-radius: 12px;
  background: var(--term-surface);
  padding: 0.6rem 0.9rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 64ch;
}

.proposal-heading {
  color: var(--term-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.proposal-summary {
  color: var(--term-ink);
}

.proposal-tasks {
  list-style: none;
  counter-reset: proposal-task;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.proposal-tasks li {
  counter-increment: proposal-task;
  color: var(--term-ink);
}

.proposal-tasks li::before {
  content: " " counter(proposal-task) ". ";
  color: var(--term-dim);
}

.proposal-command {
  color: var(--term-cyan);
  white-space: pre-wrap;
  word-break: break-word;
}

.proposal-command::before {
  content: "$ ";
  color: var(--term-dim);
}

.proposal-actions {
  display: flex;
  gap: 0.5rem;
}

.proposal-start {
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--sidebar-bg);
  font-weight: 600;
  padding: 0.3rem 1.1rem;
}

.proposal-start:hover:not(:disabled) {
  filter: brightness(1.1);
}

.proposal-start:focus-visible {
  outline: 2px solid var(--term-ink);
  outline-offset: 2px;
}

.proposal.simulated {
  border-left-color: var(--term-amber);
}

/* ============================================================================
   Composer card (form#commandForm — in-flow at the bottom of the chat view)
   ========================================================================== */

/* The FORM is the card: #worktreeRow stays a direct child so the readiness
   strip js/worktrees.js injects right after it lands INSIDE the card. The
   Phase E DOM order is unchanged; flex `order` moves the status strip and the
   simulated banner below the input row, where they read as captions. */
.prompt-area {
  flex: none;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: 1px solid var(--term-line);
  border-radius: 16px;
  background: var(--term-surface);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  padding: 0.75rem 1rem;
}

/* Status strip: the card's bottom caption (one dim line); every legacy
   `terminalOutput.textContent =` write replaces it (multi-line writes wrap,
   capped). The tooltip carries a short history. It stays VISIBLE — operators
   read every status/refusal message here. */
.status-strip {
  order: 10;
  color: var(--term-dim);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.5em;
  overflow-y: auto;
  padding: 0 0.25rem;
}

.prompt-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.prompt-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 0.25rem 0.25rem;
  caret-color: var(--accent);
}

.prompt-bar input:focus-visible {
  outline: none;
}

/* SIMULATED/REAL mode pill (same element, same semantics: amber simulated,
   red REAL — flipping it is a deliberate act, nothing else touches it). */
.mode-select {
  border-color: var(--term-line);
  border-radius: 999px;
  color: var(--term-amber);
  background-color: var(--term-bg);
  font-weight: 600;
  font-size: 12px;
}

.mode-select:has(option[value="installed"]:checked) {
  color: var(--term-red);
}

/* Circular accent send button ("↑"; the label lives on its title). */
.send-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--sidebar-bg);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.send-button:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* Persistent simulated banner: an amber-dot caption under the input row. */
.simulated-banner {
  order: 11;
  display: flex;
  gap: 0.6ch;
  align-items: baseline;
  color: var(--term-dim);
  font-size: 12px;
  padding: 0 0.25rem;
}

.simulated-banner::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--term-amber);
  align-self: center;
  flex: none;
}

.simulated-banner[hidden] {
  display: none;
}

/* ---- Worktree row (installed mode, above the prompt) ---------------------- */

.worktree-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.3rem 0.45rem;
  border: 1px dashed var(--term-line);
  border-radius: 10px;
}

.worktree-row[hidden] {
  display: none;
}

.worktree-input {
  flex: 1;
  min-width: 16rem;
  color: var(--term-cyan);
}

.prepare-button {
  white-space: nowrap;
}

.create-button:not(:disabled) {
  color: var(--term-green);
  border-color: var(--term-green);
}

.fallback-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--term-dim);
  white-space: nowrap;
}

/* ---- Readiness strip (injected after #worktreeRow) ------------------------ */

.readiness-strip {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.3rem 0.25rem;
  color: var(--term-dim);
}

.readiness-strip[hidden] {
  display: none;
}

.readiness-verdict {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.readiness-verdict-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  align-self: center;
}

.readiness-verdict.ready .readiness-verdict-dot {
  background: var(--term-green);
}

.readiness-verdict.blocked .readiness-verdict-dot {
  background: var(--term-red);
}

.readiness-verdict.ready .readiness-verdict-text {
  color: var(--term-green);
}

.readiness-verdict.blocked .readiness-verdict-text {
  color: var(--term-red);
}

.readiness-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.readiness-chip {
  display: inline-flex;
  gap: 0.5ch;
  align-items: baseline;
}

.readiness-key {
  color: var(--term-dim);
}

.readiness-key::after {
  content: ":";
}

.readiness-chip.ready .readiness-value {
  color: var(--term-green);
}

.readiness-chip.missing .readiness-value {
  color: var(--term-red);
}

.readiness-chip.info .readiness-value {
  color: var(--term-amber);
}

.readiness-chip.off .readiness-value {
  color: var(--term-dim);
}

.readiness-notes {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.readiness-note {
  color: var(--term-dim);
}

.readiness-note::before {
  content: "· ";
}

.readiness-note.ready {
  color: var(--term-green);
}

.readiness-note.warn {
  color: var(--term-amber);
}

.readiness-note.info {
  color: var(--term-dim);
}

.readiness-note.server {
  font-weight: 600;
}

/* ============================================================================
   Activity view content
   ========================================================================== */

/* ---- Generic card grammar: a left-ruled block on the surface tone. ------- */

.task-item,
.approval-item,
.integration-item,
.run-item,
.lock-item,
.history-item,
.autonomy-item {
  border: 1px solid var(--term-line);
  border-left: 3px solid var(--term-line);
  border-radius: 12px;
  background: var(--term-surface);
  padding: 0.55rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* 2s flash when a Recents row lands on its run card (js/shell.js). */
.run-item.flash-highlight {
  animation: run-flash 2s ease-out;
}

@keyframes run-flash {
  0% {
    background: rgba(217, 119, 87, 0.28);
    border-color: var(--accent);
  }
  100% {
    background: var(--term-surface);
    border-color: var(--term-line);
  }
}

.task-list,
.approval-list,
.integration-list,
.run-list,
.lock-list,
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: var(--term-dim); /* empty-state text renders dim */
}

/* ---- Plan summary + review queue (runs section header) ------------------- */

.plan-summary {
  color: var(--term-ink);
}

.review-box {
  color: var(--term-dim);
  white-space: pre-wrap;
}

/* ---- Tasks ---------------------------------------------------------------- */

.task-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.task-title {
  color: var(--term-ink);
  font-weight: 600;
}

.task-meta {
  color: var(--term-dim);
}

.task-item.simulated {
  border-left-color: var(--term-amber);
}

/* ---- Approvals ------------------------------------------------------------ */

.approval-item.pending {
  border-left-color: var(--term-amber);
}

.approval-item.approved {
  border-left-color: var(--term-green);
}

.approval-item.rejected {
  border-left-color: var(--term-red);
}

.approval-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.approval-title {
  color: var(--term-ink);
  font-weight: 600;
  flex: 1;
}

/* Status pill (de-bracketed [status] grammar); the state hues below stay. */
.approval-status {
  flex: none;
  color: var(--term-dim);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.6em;
}

.approval-status.pending {
  color: var(--term-amber);
}

.approval-status.approved {
  color: var(--term-green);
}

.approval-status.rejected {
  color: var(--term-red);
}

/* The HUMAN REVIEW term-tag pill inside carries the marker; no extra glyphs. */
.approval-fallback-flag {
  color: var(--term-amber);
}

.approval-summary {
  color: var(--term-ink);
}

.approval-meta {
  color: var(--term-dim);
}

.approval-path {
  color: var(--term-cyan);
  word-break: break-all;
}

.approval-error-label {
  color: var(--term-red);
  font-weight: 600;
}

.approval-error {
  color: var(--term-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 10em;
  overflow-y: auto;
  border-left: 1px solid var(--term-red);
  padding-left: 0.6rem;
}

.approval-escape-label {
  color: var(--term-red);
  font-weight: 600;
}

.approval-escape {
  color: var(--term-red);
  white-space: pre-wrap;
  word-break: break-all;
  border-left: 1px solid var(--term-red);
  padding-left: 0.6rem;
  max-height: 8em;
  overflow-y: auto;
}

/* ---- In-card approval evidence (g25): the diff sits ABOVE the buttons. ---- */

.approval-evidence {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-left: 1px solid var(--term-cyan);
  padding-left: 0.6rem;
}

.approval-evidence-head {
  color: var(--term-cyan);
}

.approval-evidence-note {
  color: var(--term-dim);
}

.approval-evidence-error {
  color: var(--term-red);
}

.approval-evidence-error::before {
  content: "! ";
}

.approval-evidence-files {
  color: var(--term-ink);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 8em;
  overflow-y: auto;
}

.approval-evidence-diff {
  color: var(--term-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 16em;
  overflow-y: auto;
  border-top: 1px solid var(--term-line);
  padding-top: 0.3rem;
}

.approval-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.approval-button {
  border: 1px solid var(--term-line);
  background: transparent;
}

.approval-button.approve {
  color: var(--term-green);
  border-color: var(--term-green);
}

.approval-button.reject {
  color: var(--term-red);
  border-color: var(--term-red);
}

.approval-button.inspect-diff {
  color: var(--term-cyan);
}

/* ---- Integrations ---------------------------------------------------------- */

.integration-item.ready {
  border-left-color: var(--term-amber);
}

.integration-item.integrated {
  border-left-color: var(--term-green);
}

.integration-item.blocked {
  border-left-color: var(--term-red);
}

.integration-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.integration-title {
  color: var(--term-ink);
  font-weight: 600;
  flex: 1;
}

/* Status pill (de-bracketed [status] grammar); the state hues below stay. */
.integration-status {
  flex: none;
  color: var(--term-dim);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.6em;
}

.integration-status.ready {
  color: var(--term-amber);
}

.integration-status.integrated {
  color: var(--term-green);
}

.integration-status.blocked {
  color: var(--term-red);
}

.integration-summary {
  color: var(--term-ink);
}

.integration-meta {
  color: var(--term-dim);
}

.integration-path {
  color: var(--term-cyan);
  word-break: break-all;
}

/* The link text already reads "PR #n open" — no bracket prefix needed. */
.integration-pr-link {
  color: var(--term-cyan);
  width: fit-content;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.integration-pushed {
  color: var(--term-dim);
}

.integration-changed-label {
  color: var(--term-green);
  font-weight: 600;
}

.integration-changed {
  color: var(--term-dim);
  white-space: pre-wrap;
  word-break: break-all;
  border-left: 1px solid var(--term-green);
  padding-left: 0.6rem;
  max-height: 8em;
  overflow-y: auto;
}

.integration-escape-label {
  color: var(--term-red);
  font-weight: 600;
}

.integration-escape {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-left: 1px solid var(--term-red);
  padding-left: 0.6rem;
}

.integration-escape-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--term-ink);
  word-break: break-all;
}

.integration-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.integration-button {
  border: 1px solid var(--term-line);
  background: transparent;
}

.integration-button.integrated {
  color: var(--term-green);
  border-color: var(--term-green);
}

.integration-button.blocked {
  color: var(--term-red);
  border-color: var(--term-red);
}

.integration-button.inspect-diff,
.integration-button.preview-pr {
  color: var(--term-cyan);
}

.integration-button.push-branch,
.integration-button.create-pr {
  color: var(--term-green);
}

/* ---- Runs ------------------------------------------------------------------ */

.run-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.run-id {
  color: var(--term-cyan);
  flex: 1;
  word-break: break-all;
}

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--term-dim);
  text-transform: capitalize;
}

.run-meta {
  color: var(--term-dim);
}

.run-item.simulated {
  border-left-color: var(--term-amber);
}

.run-message-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.run-message-input {
  flex: 1;
  min-width: 14rem;
}

.run-message-feedback {
  color: var(--term-amber);
}

.run-trace {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-top: 1px dashed var(--term-line);
  padding-top: 0.3rem;
  max-height: 16em;
  overflow-y: auto;
}

.trace-entry {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  flex-wrap: wrap;
  color: var(--term-dim);
}

.trace-time {
  font-size: 12px;
  opacity: 0.7;
}

/* Kind pill (de-bracketed [kind] grammar); the per-kind hues below stay. */
.trace-kind {
  color: var(--term-dim);
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.6em;
}

.trace-entry.trace-error .trace-kind {
  color: var(--term-red);
}

.trace-entry.trace-completed .trace-kind {
  color: var(--term-green);
}

.trace-entry.trace-output .trace-kind {
  color: var(--term-cyan);
}

.trace-agent {
  color: var(--term-cyan);
  opacity: 0.8;
}

.trace-text {
  flex-basis: 100%;
  color: var(--term-dim);
  white-space: pre-wrap;
  word-break: break-word;
  padding-left: 1.5ch;
}

/* ---- Diff preview ----------------------------------------------------------- */

.diff-preview {
  color: var(--term-dim);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--term-surface);
  border: 1px solid var(--term-line);
  border-left: 3px solid var(--term-line);
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  max-height: 30em;
  overflow-y: auto;
}

.diff-preview[data-state="ready"] {
  color: var(--term-ink);
  border-left-color: var(--term-cyan);
}

/* ---- Locks ------------------------------------------------------------------ */

.lock-item {
  border-left-color: var(--term-amber);
}

.lock-path {
  color: var(--term-cyan);
  word-break: break-all;
}

.lock-meta {
  color: var(--term-dim);
}

/* ---- History ----------------------------------------------------------------- */

.history-item {
  border-left-color: var(--term-line);
  padding: 0.3rem 0.7rem;
}

.history-head {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.history-seq {
  color: var(--term-dim);
}

.history-type {
  color: var(--term-cyan);
}

.history-time {
  margin-left: auto;
  font-size: 12px;
}

.history-detail {
  color: var(--term-ink);
  word-break: break-word;
}

.history-note {
  padding: 0.1rem 0;
}

/* ============================================================================
   Autonomy (overnight work) section
   ========================================================================== */

.autonomy-mode {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.autonomy-mode-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  border: 1px solid var(--term-line);
  background: transparent;
  padding: 0.25rem 0.7rem;
  color: var(--term-dim);
}

.autonomy-mode-option.is-active {
  border-color: var(--term-green);
  color: var(--term-ink);
}

.autonomy-mode-option.is-active .autonomy-mode-name {
  color: var(--term-green);
}

.autonomy-mode-name {
  font-weight: 600;
}

.autonomy-mode-hint {
  font-size: 11px;
  color: var(--term-dim);
}

.autonomy-start {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.autonomy-input {
  min-width: 11rem;
}

.autonomy-input-narrow {
  width: 7rem;
  min-width: 0;
}

.autonomy-pick select {
  width: 100%;
}

.autonomy-detail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--term-dim);
}

.autonomy-head {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.autonomy-id {
  color: var(--term-cyan);
  word-break: break-all;
}

.autonomy-item-title {
  color: var(--term-ink);
  font-weight: 600;
}

.autonomy-meta {
  color: var(--term-dim);
}

.autonomy-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.autonomy-button {
  border: 1px solid var(--term-line);
  background: transparent;
  color: var(--term-ink);
}

.autonomy-button:hover:not(:disabled) {
  border-color: var(--term-green);
  color: var(--term-green);
}

.autonomy-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-top: 1px dashed var(--term-line);
  padding-top: 0.4rem;
}

.autonomy-group-label {
  color: var(--term-dim);
  font-weight: 600;
}

.autonomy-group-label::before {
  content: "· ";
}

.autonomy-queue {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.autonomy-queue-row {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  flex-wrap: wrap;
  color: var(--term-ink);
}

/* The notice text says read-only itself; amber carries the warning tone. */
.autonomy-readonly {
  color: var(--term-amber);
}

.autonomy-wake {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 1px solid var(--term-line);
  border-left: 3px solid var(--term-cyan);
  border-radius: 12px;
  background: var(--term-surface);
  padding: 0.45rem 0.9rem;
}

.autonomy-wake-headline {
  color: var(--term-ink);
  font-weight: 600;
}

.autonomy-progress-status,
.autonomy-recovery-arm-status {
  color: var(--term-dim);
}

.autonomy-bedtime {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-top: 1px dashed var(--term-line);
  padding-top: 0.4rem;
}

.autonomy-bedtime-head {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.autonomy-bedtime-title {
  color: var(--term-ink);
  font-weight: 600;
}

.autonomy-bedtime-presets {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.autonomy-bedtime-preset-label,
.autonomy-bedtime-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--term-ink);
}

.autonomy-bedtime-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.autonomy-bedtime-status {
  color: var(--term-amber);
}

.autonomy-demo {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.autonomy-demo-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================================================
   Projects view
   ========================================================================== */

.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.side-project {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--term-ink);
  padding: 0.2rem 0.5rem;
  width: fit-content;
}

.side-project::before {
  content: "· ";
  color: var(--term-dim);
}

.side-project:hover:not(:disabled) {
  border-color: var(--term-line);
}

.side-project.is-active {
  color: var(--term-green);
  opacity: 1;
}

.side-project.is-active::before {
  content: "▸ ";
  color: var(--term-green);
}

.project-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.project-form input {
  flex: 1;
  min-width: 18rem;
  color: var(--term-cyan);
}

.project-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.project-name {
  color: var(--term-ink);
  font-weight: 600;
}

.project-path {
  color: var(--term-cyan);
  word-break: break-all;
}

/* Read-only CI line + its [update] action. */
.project-ci {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.project-detail {
  color: var(--term-dim);
}

/* ============================================================================
   Agents view
   ========================================================================== */

.agent-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.add-agent-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid var(--term-line);
  border-left: 3px solid var(--term-line);
  border-radius: 12px;
  background: var(--term-surface);
  padding: 0.55rem 0.9rem;
  max-width: 32rem;
}

.add-agent-form[hidden] {
  display: none;
}

.custom-agent-fields {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-left: 1px dashed var(--term-line);
  padding-left: 0.6rem;
}

.custom-agent-fields[hidden] {
  display: none;
}

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.agent-item {
  border: 1px solid var(--term-line);
  border-left: 3px solid var(--term-line);
  border-radius: 12px;
  background: var(--term-surface);
  padding: 0.55rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.agent-item.agent-ready {
  border-left-color: var(--term-green);
}

.agent-item.agent-auth-missing,
.agent-item.agent-unknown {
  border-left-color: var(--term-amber);
}

.agent-item.agent-not-installed {
  border-left-color: var(--term-red);
}

.agent-item.offline {
  opacity: 0.7;
}

.agent-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.agent-name {
  color: var(--term-ink);
  font-weight: 600;
}

.agent-meta {
  color: var(--term-dim);
}

.agent-model {
  color: var(--term-dim);
}

.agent-health.ready {
  color: var(--term-green);
}

.agent-health.auth-missing,
.agent-health.unknown {
  color: var(--term-amber);
}

.agent-health.not-installed {
  color: var(--term-red);
}

.agent-health-message {
  color: var(--term-amber);
}

.agent-health-message::before {
  content: "! ";
}

.agent-remediation {
  color: var(--term-dim);
}

.agent-remediation::before {
  content: "→ ";
}

.agent-empty,
.agent-offline-note {
  color: var(--term-dim);
}

.agent-offline-note {
  color: var(--term-red);
}

/* ============================================================================
   Settings view
   ========================================================================== */

.settings-field {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.settings-input {
  min-width: 22rem;
  max-width: 100%;
}

.settings-note {
  color: var(--term-dim);
  max-width: 60ch;
}

.settings-note.warning {
  color: var(--term-amber);
}

.settings-feedback {
  color: var(--term-red);
  min-height: 1.2em;
}

.settings-token.ok {
  color: var(--term-green);
}

.settings-token.missing {
  color: var(--term-red);
}

.settings-field select {
  min-width: 9rem;
}

/* ============================================================================
   New-project wizard (modal)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 11, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

/* Warm rounded card, same language as the composer. */
.modal-panel {
  background: var(--term-surface);
  border: 1px solid var(--term-line);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
  width: min(40rem, 100%);
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.project-wizard {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-head h2 {
  color: var(--term-ink);
  font-size: 17px;
}

.modal-head p {
  color: var(--term-dim);
}

.modal-close {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--term-dim);
  line-height: 1;
}

.modal-close:hover:not(:disabled) {
  color: var(--term-ink);
  background: rgba(245, 244, 239, 0.08);
}

.wizard-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.wizard-field span {
  color: var(--term-dim);
}

.wizard-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--term-dim);
}

.wizard-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.wizard-section-title {
  color: var(--term-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--term-line);
  padding-bottom: 0.2rem;
}

.wizard-agent-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.wizard-agent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.2rem 0;
}

.wizard-agent-row.is-warning .wizard-agent-runtime {
  color: var(--term-amber);
}

.wizard-agent-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wizard-agent-name {
  color: var(--term-ink);
}

.wizard-agent-runtime {
  color: var(--term-dim);
  font-size: 12px;
}

.wizard-empty {
  color: var(--term-dim);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* Accent pill = the wizard's single creating act; quiet pill = back out. */
.primary-button {
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--sidebar-bg);
  font-weight: 600;
  padding: 0.35rem 1.1rem;
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.secondary-button {
  border-radius: 999px;
  background: transparent;
  color: var(--term-dim);
  padding: 0.35rem 1rem;
}

.secondary-button:hover:not(:disabled) {
  color: var(--term-ink);
}

/* ============================================================================
   Narrow screens: the sidebar becomes a fixed overlay (default-collapsed via
   js/app.js) with a dim backdrop while open; tighten paddings.
   ========================================================================== */

@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.5);
  }

  /* Dim backdrop behind the open overlay sidebar (clicks on it land on body;
     js/shell.js collapses the sidebar on any outside click). */
  body:not(.sidebar-collapsed)::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.5);
  }

  .view {
    padding: 0.75rem;
  }

  /* No time gutter: each message kind collapses to its content columns. */
  .line {
    grid-template-columns: max-content 1fr;
  }

  .line-time {
    display: none;
  }

  .line-user {
    grid-template-columns: 1fr;
  }

  .line-serberus {
    grid-template-columns: 1fr;
    grid-template-areas:
      "prefix"
      "text";
  }

  .proposal {
    margin-left: 0;
  }

  /* Wide fixed-min inputs would overflow a phone column; let them shrink. */
  .worktree-input,
  .run-message-input,
  .autonomy-input,
  .project-form input,
  .settings-input {
    min-width: 0;
    width: 100%;
  }

  .modal-backdrop {
    padding: 0.75rem;
  }

  .modal-panel {
    padding: 1rem;
  }
}

/* ============================================================================
   Login page (apps/web/public/login.html — standalone, multi-mode auth)
   The shared <body> is a sidebar+main flex row; login.html sets the body
   class .login-body so this block recenters a single card instead.
   ========================================================================== */

.login-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 26rem;
  background: var(--term-surface);
  border: 1px solid var(--term-line);
  border-radius: 14px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login-brand {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  justify-content: center;
}

.login-brand .brand-mark {
  font-size: 22px;
}

.login-brand .brand-accent {
  font-size: 22px;
}

.login-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--term-dim);
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.login-field .block-label {
  font-size: 12px;
}

.login-input {
  width: 100%;
}

.login-submit {
  width: 100%;
  justify-content: center;
  text-align: center;
  padding: 0.45rem 0.8rem;
  font-weight: 600;
  border-color: var(--accent);
}

.login-submit:hover:not(:disabled) {
  background: var(--accent);
  color: var(--term-bg);
}

.login-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.login-error {
  color: var(--term-red);
  min-height: 1.2em;
  font-size: 13px;
  text-align: center;
}
