/*
 * FriedLiver's views: layout and the parts unique to one view. Colours, sizes, radii, shadows
 * and blur come from tokens.css; every button, pill, field, menu and card is a component in
 * components.css (spec: ~/code/FriedLiver-Code-design/COMPONENTS.md), which loads after this file.
 * test/designSystem.test.ts counts what this file still does by hand; that count only goes down.
 */

/* ---- Base ---- */

html,
body,
#root {
  height: 100%;
}
/* The view never scrolls as a whole (scrollIntoView included): its parts do. */
html {
  overflow: hidden;
}
body {
  margin: 0;
  padding: 0;
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: var(--font-features);
  font-optical-sizing: auto;
}
h1,
h2,
h3 {
  margin: 0;
}

/* ---- Utilities ---- */

.hint {
  color: var(--fg-2);
  font-weight: 400;
}
.spacer,
.grow {
  flex: 1;
}
.ellipsis {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sep {
  color: var(--fg-2);
}
.warn {
  color: var(--warn);
}
.sr {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.row.end {
  justify-content: flex-end;
}

/* ---- Small things: tags, chips, badges, counts ---- */

.chip .icon {
  width: var(--i-xs);
  height: var(--i-xs);
}
.count {
  display: inline-block;
  min-width: var(--h-2xs);
  height: var(--h-2xs);
  padding: 0 var(--sp-1);
  border-radius: var(--r-pill);
  /* --t-85 of the base size, not of the text around it: one badge size in a heading, a tab and a rail. */
  font-size: calc(var(--fs) * 0.85);
  font-weight: var(--w-strong);
  font-variant-numeric: tabular-nums;
  line-height: var(--h-2xs);
  text-align: center;
  color: var(--fg);
  background: var(--pill-bg);
}
.count.loud {
  color: var(--decision-fg);
  background: var(--decision);
}
.col-count {
  font-size: var(--t-85);
  font-weight: var(--w-regular);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
}
/* File references in steps and change lists. */
button.ref {
  height: var(--h-sm);
  padding: 0 var(--sp-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-ctl);
  font-family: var(--mono);
  font-size: var(--t-85);
  color: var(--fg-2);
}
button.ref:hover:not(:disabled) {
  color: var(--fg);
  background: var(--hover-bg);
}
/* Code references from the editor: a message's, and the composer's before sending. */
.refs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  white-space: normal;
}
.code-ref {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: var(--sp-half);
}
.code-ref button.ref {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.code-ref .ref .icon {
  width: var(--i-xs);
  height: var(--i-xs);
  color: var(--fg-2);
}
/* Badges: links between chats, shared files. */

.badge .icon {
  width: var(--i-xs);
  height: var(--i-xs);
}

.badge[data-kind='pipe'] .icon {
  color: var(--status-working);
}

.auto-badge .icon {
  width: var(--i-xs);
  height: var(--i-xs);
}

/* A filter field (§2.11 Search): a field's look, a 14 glyph at 8, text inset 30. */
.search {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--h-md);
  padding: 0 var(--sp-1) 0 var(--sp-2);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  color: var(--fg-2);
}
.search:focus-within {
  border-color: var(--focus);
}
.search .icon {
  width: var(--i-sm);
  height: var(--i-sm);
}
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: var(--t-90);
  outline: none;
}

/* ---- Popover contents (the panel is the Menu component) ---- */

.pop-scroll {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(320px, 50vh);
  overflow-y: auto;
}
.menu-label {
  flex: none;
}
.menu-sub {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg-2);
  font-size: var(--t-85);
}
.ask-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.ask-form .seg {
  flex-wrap: wrap;
}
.ask-form textarea {
  resize: none;
}
.pop-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--t-90);
  color: var(--fg-50);
}
.pick-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 var(--sp-1);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-4);
  cursor: pointer;
}
.pick-row:hover,
.pick-row[aria-selected='true'] {
  background: var(--hover-bg);
}
.pick-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-label {
  flex: none;
  color: var(--fg-2);
  font-size: var(--t-85);
}
.pop-empty {
  padding: var(--sp-2) var(--sp-3);
  color: var(--fg-2);
  font-size: var(--t-90);
}
.pop-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-1) 0;
  margin-top: 2px;
  border-top: 1px solid var(--border);
  font-size: var(--t-90);
}

/* The Agent Manager's plain buttons (zero specificity: any class wins). */
:where(body[data-surface='tasks']) button {
  justify-content: center;
  height: 28px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-6);
  background: var(--pill-bg);
  white-space: nowrap;
}
:where(body[data-surface='tasks']) button:hover:not(:disabled) {
  background: var(--pill-hover);
}

/* ---- Agent Manager ---- */

.manager {
  /* What the page keeps under the view at its end: the History row and the gap to it, and the end padding.
     The map's sticky detail panel is shorter by this much, so it is all in the window at the page's end too. */
  --mgr-end: 40px;
  --mgr-history: 28px;
  --mgr-below: var(--mgr-end);
  height: 100%;
  overflow: auto;
  padding: var(--sp-5) var(--sp-5) var(--mgr-end);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.manager > * {
  width: 100%;
}
.manager:has(> .history) {
  --mgr-below: calc(var(--sp-4) + var(--mgr-history) + var(--mgr-end));
}
.mgr-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
}
/* The page title (§2.35): 20/600, tracked in. */
.mgr-title h1 {
  margin: 0;
  color: var(--sel-fg);
  font-size: var(--t-hero);
  font-weight: var(--w-strong);
  letter-spacing: var(--track-title);
  line-height: var(--lh-tight);
}
.mgr-counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
  margin-top: var(--sp-1);
  font-size: var(--t-90);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
}
.count-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}
button.count-item {
  color: var(--fg-2);
  /* The row's size, not a step below it: "archived" reads as one of the counts. */
  font-size: inherit;
}
button.count-item .icon {
  width: var(--i-sm);
  height: var(--i-sm);
}
.mgr-head .search {
  width: min(240px, 100%);
}
/* A field on the page in every theme: its 3:1 edge. */
.search {
  border: 1px solid var(--field-border);
}

/* New task: the composer's material (§2.27): the input tone, a hairline, the rim, r12. */
/* The board's task box is a prompt zone (v3): the same lifted, edged box as the chat composer. */
.new-task {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--zone-prompt-edge);
  border-radius: var(--r-14);
  background: var(--zone-prompt-bg);
  box-shadow: var(--rim), var(--zone-prompt-lift);
}
.new-task:focus-within {
  border-color: var(--zone-prompt-edge-focus);
  box-shadow: var(--rim), var(--zone-prompt-lift), var(--zone-prompt-glow);
}
.new-task textarea {
  min-height: var(--sp-10);
  padding: var(--sp-3) var(--sp-4) var(--sp-half);
  border: 0;
  background: transparent;
  color: var(--sel-fg);
  font-size: var(--t-lg);
  resize: none;
  outline: none;
}
.new-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
}
.agent-pick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.agent-option {
  height: var(--h-md);
  padding: 0 var(--sp-3) 0 var(--sp-1);
  border-radius: var(--r-pill);
  border-color: transparent;
  background: transparent;
  color: var(--fg-2);
  font-weight: var(--w-medium);
}
.agent-option[aria-pressed='true'] {
  color: var(--sel-fg);
  background: var(--sel-bg);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--h-md);
  padding: 0 var(--sp-2);
  color: var(--fg-2);
  font-size: var(--t-90);
  cursor: pointer;
}
.mgr-view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
/* An empty view (§2.26): unboxed, start-aligned, voiced. */
.empty-view {
  padding: var(--sp-3) var(--sp-1);
  color: var(--fg-2);
}
.empty-view h2 {
  margin: 0;
  color: var(--fg);
  font-size: var(--t-lead);
  font-weight: var(--w-medium);
}
.empty-view p {
  margin: var(--sp-1) 0 0;
}

/* Board (§2.35): columns 16 apart, no column fill; a 26 head with a hairline under it. */
.columns {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: var(--sp-4);
  align-items: start;
}
@media (max-width: 960px) {
  .columns {
    grid-template-columns: 1fr;
  }
}
.column {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.col-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--h-md);
  margin: 0 0 var(--sp-1);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--hairline);
  color: var(--sel-fg);
  font-size: var(--t-100);
  font-weight: var(--w-strong);
  white-space: nowrap;
}
.col-sub {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg-2);
  font-size: var(--t-85);
  font-weight: var(--w-regular);
}
.column-empty {
  padding: var(--sp-3) var(--sp-1);
  color: var(--fg-2);
  font-size: var(--t-90);
}
/* A chat's subagents: small cards tucked under its card. */
.sub-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: -6px 0 0 var(--sp-4);
  padding: 0 0 0 10px;
  list-style: none;
  border-left: 1px solid var(--border);
}
.sub-row {
  cursor: pointer;
}
.sub-row.static {
  cursor: default;
}
[data-flash] {
  animation: flash 1.2s ease-out;
}
@keyframes flash {
  from {
    box-shadow: var(--shadow-flash);
  }
  to {
    box-shadow: var(--shadow-flash-end);
  }
}
.card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  min-width: 0;
  font-size: var(--t-85);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
}
.card-top > span:not(.chip) {
  white-space: nowrap;
}

.card-who {
  color: var(--fg-2);
  font-weight: var(--w-medium);
}
/* At most two lines, then an ellipsis; the whole title is in the tooltip. 13/500 in the strong text. */
.card-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
  color: var(--sel-fg);
  font-size: var(--t-100);
  font-weight: var(--w-medium);
  line-height: 1.4;
}
.title-btn {
  display: inline;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-1);
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.title-btn:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--fg-2);
}
.card-state {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  font-size: var(--t-90);
  color: var(--fg-2);
}
/* A question waiting on you reads in the strong text; the bullseye beside it says it's yours. */
.card-state[data-decision] {
  color: var(--sel-fg);
  font-weight: var(--w-regular);
}
.card-state-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.card-code {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-ctl);
  font-size: var(--t-90);
  color: var(--fg);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
/* A quoted request or command on a card: three lines at most; the chat has the rest. */
.card-code,
.card-quote {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.card-quote {
  /* Vertical room as transparent borders, not padding: the clamp clips at the padding edge, so a padding would show a sliver of line 4. */
  padding: 0 var(--sp-3);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 2px solid var(--hairline);
  font-size: var(--t-90);
  color: var(--fg-2);
  overflow-wrap: anywhere;
}
/* Files, turns and age: one muted line. */
.card-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
  overflow: hidden;
  font-size: var(--t-85);
  font-variant-numeric: tabular-nums;
  line-height: var(--lh);
  color: var(--fg-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* Branch, links and shared files: one row of pills that wraps. */
.card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  min-width: 0;
}
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  margin-right: var(--sp-1);
}
.meta-item .icon {
  width: var(--i-sm);
  height: var(--i-sm);
}
.card-top .card-connect + .pop,
.card-top .card-more {
  flex: none;
}
.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--sp-2);
  min-width: 0;
  min-height: var(--h-md);
}
/* Hand off, Ask and Pipe to: on hover or keyboard focus only (they are in ⋯ as well). */
.card-connect {
  flex: none;
  display: flex;
  gap: var(--sp-half);
  opacity: 0;
  transition: opacity var(--ease-toggle);
}
.task-card:hover .card-connect,
.task-card:focus-within .card-connect,
.task-card:focus .card-connect {
  opacity: 1;
}

/* Compare: one column per chat of a fan-out. */
.compare {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-box);
  background: var(--input-bg);
}
.compare-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  white-space: nowrap;
}
.compare-head > .icon {
  color: var(--fg-2);
}
.compare-head h2 {
  margin: 0;
  color: var(--sel-fg);
  font-size: var(--t-100);
  font-weight: var(--w-strong);
}
.compare-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg-2);
}
/* The heading and its count stay whole; the task's name takes what is left. Under 480px the count goes: the
   cards below are the count. */
.compare-head h2,
.compare-head > .hint {
  flex: none;
}
@media (max-width: 480px) {
  .compare-head > .hint {
    display: none;
  }
}
.compare-grid {
  display: grid;
  gap: var(--sp-3);
}
@media (max-width: 760px) {
  .compare-grid {
    grid-template-columns: 1fr !important;
  }
}
.compare-col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  padding: var(--sp-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-box);
  background: var(--bg);
}
.compare-top {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--t-90);
}
.compare-top {
  flex-wrap: wrap;
  min-width: 0;
}
.compare-agent {
  flex: none;
  color: var(--fg-2);
}
/* The topic gets a line of its own under the agent, status and numbers. */
.compare-topic {
  flex: 1 0 100%;
  order: 1;
  min-width: 0;
  font-weight: 600;
  font-size: var(--t-100);
}
.compare-stats {
  font-size: var(--t-85);
  color: var(--fg-2);
  white-space: nowrap;
}
.compare-reply {
  margin: 0;
  min-height: 3.1em;
  font-size: var(--t-90);
  line-height: 1.55;
  color: var(--fg-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* List */
/* Not clipped: a row's ⋯ menu opens over the rows below; the corner cells take the radius instead. */
.table-wrap {
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--menu-bg);
}
.chat-table tr:first-child > :first-child {
  border-top-left-radius: var(--r-8);
}
.chat-table tr:first-child > :last-child {
  border-top-right-radius: var(--r-8);
}
.chat-table tbody:last-child tr:last-child > :first-child {
  border-bottom-left-radius: var(--r-8);
}
.chat-table tbody:last-child tr:last-child > :last-child {
  border-bottom-right-radius: var(--r-8);
}
.chat-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--t-90);
}
.chat-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  padding: 0 var(--sp-3);
  background: var(--menu-bg);
  color: var(--fg-2);
  font-size: var(--t-xs);
  font-weight: 500;
  text-align: left;
  box-shadow: inset 0 -1px var(--border);
}
.th-btn {
  height: 24px;
  padding: 0 4px;
  margin-left: -4px;
  gap: 2px;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}
.th-btn:hover:not(:disabled) {
  color: var(--fg);
}
th[aria-sort] .th-btn {
  color: var(--fg);
}
.sort-mark {
  display: inline-flex;
  opacity: 0;
}
.sort-mark .icon {
  width: 12px;
  height: 12px;
}
.th-btn:hover .sort-mark {
  opacity: 0.5;
}
.sort-mark[data-on] {
  opacity: 1;
}
.sort-mark[data-on='asc'] .icon {
  transform: rotate(180deg);
}
.chat-table td {
  height: 48px;
  padding: 6px var(--sp-3);
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.chat-table tbody tr:first-child td {
  border-top: 0;
}
.chat-table tbody tr {
  cursor: pointer;
}
.chat-table tbody tr:hover td {
  background: var(--input-bg);
}
.chat-table tbody tr:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
/* Needs-you rows carry the bullseye, not a blue tint or bar (blue is marks only, §0). */
.c-status {
  width: 116px;
}
.c-agent {
  width: 124px;
}
.c-activity {
  width: 92px;
}
.c-files {
  width: 72px;
}
.c-age {
  width: 64px;
}
.c-act {
  width: 150px;
  text-align: right;
}
td.c-act {
  white-space: nowrap;
}
/* Narrow: the task keeps its room; activity, files and age go first, then the agent. */
/* Columns collapse to nothing rather than leave the table (the group rows span them all). */
@media (max-width: 900px) {
  .chat-table :is(.c-activity, .c-files, .c-age) {
    width: 0;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }
  .chat-table :is(.c-activity, .c-files, .c-age) > * {
    display: none;
  }
}
@media (max-width: 600px) {
  .chat-table .c-agent {
    width: 0;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }
  .chat-table .c-agent > * {
    display: none;
  }
  /* The task's name before its branch: the chip was taking half of a title that no longer fits. */
  .chat-table .cell-title > .fl-pill {
    display: none;
  }
}
/* A side bar: the buttons' column is as wide as its widest pair (Answer and More), not the page's 150px, and
   the second line is the activity alone; its relation chip was leaving both a few letters each. */
@media (max-width: 420px) {
  .chat-table .c-act {
    width: 112px;
  }
  .chat-table .cell-line > .mini-badge {
    display: none;
  }
}
td.c-act > * + * {
  margin-left: 4px;
}
.cell-status,
.cell-agent {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
  color: var(--fg-2);
}
.cell-agent {
  color: var(--fg);
}
.cell-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  color: var(--fg);
  font-weight: 500;
}
.cell-title-text,
.cell-line-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-line {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
  margin-top: var(--sp-half);
  font-size: var(--t-90);
  color: var(--fg-2);
}
.cell-line[data-decision] .cell-line-text {
  color: var(--decision);
}
.mini-badge {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--pill-bg);
  color: var(--fg-2);
  font-size: var(--t-85);
  white-space: nowrap;
}
td.num {
  font-family: var(--mono);
  font-size: var(--t-90);
  color: var(--fg-2);
  white-space: nowrap;
}
.conflict-mark {
  display: inline-flex;
  margin-left: 6px;
  vertical-align: -3px;
  color: var(--decision);
}
.conflict-mark .icon {
  width: 14px;
  height: 14px;
}

/* History */
.history-toggle {
  height: var(--mgr-history);
  padding: 0 var(--sp-2) 0 4px;
  gap: 6px;
  border-color: transparent;
  background: transparent;
  color: var(--fg-2);
}
.history-toggle:hover:not(:disabled) {
  background: var(--hover-bg);
  border-color: transparent;
}
.chev {
  display: inline-flex;
  transform: rotate(-90deg);
  transition: transform 0.15s;
}
.chev[data-open] {
  transform: none;
}
.history-list {
  list-style: none;
  margin: var(--sp-2) 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--menu-bg);
}
.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px var(--sp-3);
}
.history-row + .history-row {
  border-top: 1px solid var(--border);
}
.history-label {
  flex: none;
  width: 84px;
  font-size: var(--t-90);
  color: var(--fg-2);
}
.history-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-2);
}

/* ---- The agent map ---- */

.map-wrap {
  --lane: color-mix(in srgb, var(--fg) 3.5%, var(--bg));
  --edge: color-mix(in srgb, var(--fg) 40%, var(--bg));
  --edge-lit: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.map-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.map-head .map-legend {
  flex: 1;
}
/* A node's "▸ N agents": the fan-out pill (.map-group .group-pill), pressable like a node. */
.map-branch {
  cursor: pointer;
  outline: none;
  transition: opacity 0.15s;
}
.map-branch.dim {
  opacity: 0.45;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px var(--sp-4);
  margin: 0;
  padding: 0 2px;
  list-style: none;
  font-size: var(--t-90);
  color: var(--fg-2);
}
.map-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
}
.legend-file {
  width: 16px;
  height: 11px;
  border: 1px solid var(--decision);
  border-radius: 3px;
  background: var(--decision-soft);
}
.legend-bracket {
  fill: none;
  stroke: var(--fg-2);
  stroke-width: 1.5;
}
.map-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--bg);
}
.map-canvas {
  position: relative;
  margin-inline: auto;
}
svg.map {
  display: block;
  font-family: var(--font);
  overflow: visible;
}
.map-lane rect {
  fill: var(--lane);
}
.lane-head {
  font-size: var(--t-90);
}
.lane-name {
  fill: var(--fg);
  font-weight: 600;
}
.lane-meta {
  fill: var(--fg-2);
}
.lane-meta.loud {
  fill: var(--decision);
}
.map-glyph rect {
  fill: color-mix(in srgb, var(--fg) 9%, var(--menu-bg));
}
/* An unknown agent's line glyph takes the text colour; logos bring their own. */
.map-glyph svg {
  color: var(--fg-2);
}
.map-col-title {
  fill: var(--fg-2);
  font-size: var(--t-85);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.map-start {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}
.map-group .halo {
  fill: none;
  stroke: var(--lane);
  stroke-width: 7;
}
.map-group .bracket {
  fill: none;
  stroke: var(--fg-2);
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.map-group .group-pill {
  fill: var(--menu-bg);
  stroke: var(--fg-2);
}
.map-group .group-pill-text {
  fill: var(--fg);
  font-family: var(--mono);
  font-size: var(--t-80);
  font-weight: 600;
  text-anchor: middle;
}
.edge path {
  fill: none;
  stroke-linecap: round;
  transition: opacity 0.15s;
}
.edge .line {
  stroke: var(--edge);
  stroke-width: 1.5;
}
.edge.consult .line {
  stroke-dasharray: 5 4;
  stroke-linecap: butt;
}
.edge.subagent .line {
  stroke-dasharray: 1 4;
}
.map-sub .box {
  fill: var(--lane);
}
.edge .pipe-outer {
  stroke: var(--edge);
  stroke-width: 5;
}
.edge .pipe-inner {
  stroke: var(--lane);
  stroke-width: 2;
}
.edge .flow {
  stroke: var(--status-working);
  stroke-width: 2;
  stroke-dasharray: 2 9;
  animation: map-flow 0.9s linear infinite;
}
@keyframes map-flow {
  to {
    stroke-dashoffset: -11;
  }
}
/* The legend's sample moves only while something on the map does: a moving dash repaints every frame. */
.map-legend[data-still] .flow {
  animation: none;
}
.edge.lit .line,
.edge.lit .pipe-outer {
  stroke: var(--edge-lit);
}
.map-arrow {
  fill: var(--edge);
}
.map-arrow.lit {
  fill: var(--edge-lit);
}
svg[data-lit] .edge:not(.lit),
svg[data-lit] .edge-label:not(.lit),
svg[data-lit] .map-file-line:not(.lit) {
  opacity: 0.22;
}
.edge-label rect {
  fill: var(--menu-bg);
  stroke: var(--border);
}
.edge-label text {
  fill: var(--fg-2);
  font-family: var(--mono);
  font-size: var(--t-80);
  text-anchor: middle;
}
.edge-label.lit rect {
  stroke: var(--fg-2);
}
.edge-label.pipe text {
  fill: var(--fg);
}
.map-you rect {
  fill: var(--pill-bg);
  stroke: var(--border);
}
.map-you text {
  fill: var(--fg);
  font-size: var(--t-90);
  font-weight: 600;
}
.you-icon {
  fill: none;
  stroke: var(--fg-2);
  stroke-width: 1.4;
  stroke-linecap: round;
}
.you-badge {
  fill: var(--decision);
}
.map-you .you-badge-text {
  fill: var(--decision-fg);
  font-size: var(--t-80);
  font-weight: 600;
  text-anchor: middle;
}
.map-node {
  cursor: pointer;
  outline: none;
  transition: opacity 0.15s;
}
.map-node .box {
  fill: var(--menu-bg);
  stroke: var(--border);
}
.map-node:hover .box {
  stroke: var(--fg-2);
}
.map-node:focus-visible .box {
  stroke: var(--focus);
  stroke-width: 2;
}
/* A node's state is its status mark and ring, never a blue or red box (§0: blue marks only; no red borders). */
.map-node .ring {
  fill: none;
  stroke-width: 1.5;
}
.map-node[data-status='working'] .ring {
  stroke: var(--status-working);
  opacity: 0.55;
  animation: ring-pulse 1.6s ease-in-out infinite;
}
.map-node[data-status='needs-you'] .ring {
  stroke: var(--decision);
  stroke-width: 2;
}
@keyframes ring-pulse {
  0%,
  100% {
    opacity: 0.12;
  }
  50% {
    opacity: 0.85;
  }
}
.map-node.dim {
  opacity: 0.45;
}
.node-label {
  fill: var(--fg);
  font-size: var(--t-90);
  font-weight: 600;
}
.node-title {
  fill: var(--fg-2);
  font-size: var(--t-85);
}
.node-dot {
  --nd: var(--fg-2);
}
.node-dot .nd-line {
  fill: none;
  stroke: var(--nd);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.node-dot .nd-idle {
  stroke-width: 1.5;
}
.node-dot .nd-fill {
  fill: var(--nd);
}
.node-dot[data-state='working'] {
  --nd: var(--status-working);
}
.node-dot[data-state='needs-you'] {
  --nd: var(--status-waiting);
}
.node-dot[data-state='done'] {
  --nd: var(--status-done);
}
.node-dot[data-state='error'] {
  --nd: var(--status-failed);
}
.map-file {
  outline: none;
}
.map-file rect {
  fill: color-mix(in srgb, var(--decision) 12%, var(--bg));
  stroke: var(--decision);
}
.file-icon {
  fill: none;
  stroke: var(--decision);
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.map-file .file-name {
  fill: var(--decision);
  font-family: var(--mono);
  font-size: var(--t-90);
  font-weight: 500;
}
.map-file .file-meta {
  fill: var(--fg-2);
  font-size: var(--t-85);
}
.map-file-line {
  fill: none;
  stroke: var(--decision);
  stroke-width: 1.25;
  stroke-dasharray: 2 4;
  stroke-linecap: round;
  opacity: 0.85;
}
.chat-table .group-row th {
  /* A group's name is the list's heading: the rows' own size and the text colour, with room above it. */
  padding: var(--sp-4) var(--sp-2) var(--sp-1);
  color: var(--fg);
  font-size: calc(var(--fs) * 0.9);
  text-align: left;
  font-weight: 600;
  display: table-cell;
}
.chat-table .group-row .fl-dot {
  margin-right: 6px;
}
.chat-table .group-row .col-count {
  margin-left: var(--sp-2);
}
/* Grouped by status, the group header already says it: at narrow widths the column gives its room to the task. */
@media (max-width: 800px) {
  .chat-table[data-grouped] .c-status {
    width: 0;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }
  .chat-table[data-grouped] .c-status > * {
    display: none;
  }
}
.map-tip {
  position: fixed;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--vscode-editorHoverWidget-background, var(--menu-bg));
  box-shadow: var(--shadow-ctx);
  font-size: var(--t-90);
  overflow-wrap: anywhere;
  pointer-events: none;
}
.tip-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tip-title {
  font-size: var(--t-100);
  font-weight: 600;
  line-height: 1.35;
}
.tip-line {
  color: var(--fg-2);
}
.tip-line[data-decision] {
  color: var(--decision);
  font-weight: 500;
}
.tip-meta {
  color: var(--fg-2);
}
.tip-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

/* ---- Images: a tab per chat, source filters, a grid of thumbnails, a large preview ---- */

.gallery {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
/* Inside the Agent Manager the page scrolls, not the gallery. */
.mgr-view .gallery {
  height: auto;
}
/* The image tabs: Tab components, each with its count where a × would be. */
.gallery-tabs {
  flex: none;
  padding: var(--sp-1) var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.gallery-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
}
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.gallery-search {
  width: min(280px, 100%);
}
/* As many columns as fit, never a gutter wider than the gap. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr));
  align-content: start;
  gap: var(--sp-4) var(--sp-3);
  min-height: 0;
  margin: 0;
  padding: var(--sp-1) var(--sp-4) var(--sp-4);
  overflow-y: auto;
  list-style: none;
}
.mgr-view .gallery-grid {
  overflow: visible;
}
.mgr-view .gallery-tabs,
.mgr-view .gallery-bar,
.mgr-view .gallery-grid {
  padding-left: 0;
  padding-right: 0;
}
.gallery-item {
  position: relative;
  min-width: 0;
}
/* The pin sits at the meta row's end: shown on hover and focus, always once pinned. */
.gallery-item .gallery-meta {
  margin-right: var(--h-sm);
}
/* Two classes: the button's own position: relative (components.css, loaded last) must not win. */
.gallery-item > .gallery-pin {
  position: absolute;
  right: 0;
  bottom: calc(var(--sp-half) * -1);
  visibility: hidden;
}
.gallery-item:hover .gallery-pin,
.gallery-item:focus-within .gallery-pin,
.gallery-pin[aria-pressed='true'] {
  visibility: visible;
}
/* Space used and Done looking, at the bar's end. */
.gallery-store {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: auto;
}
.gallery-used {
  display: grid;
  gap: var(--sp-half);
  width: 112px;
  font-size: var(--t-85);
  color: var(--fg-2);
  white-space: nowrap;
}
button.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-6);
  background: none;
  white-space: normal;
  text-align: left;
}
button.gallery-card:hover:not(:disabled) {
  background: none;
}
button.gallery-card:focus-visible {
  outline: none;
}
.gallery-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  margin-bottom: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-6);
  background: var(--input-bg);
}
.gallery-card:hover .gallery-thumb {
  border-color: color-mix(in srgb, var(--border) 60%, var(--fg));
}
.gallery-card:focus-visible .gallery-thumb {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}
.gallery-thumb img[data-fit='whole'] {
  padding: var(--sp-2);
  object-fit: scale-down;
  object-position: center;
}
.gallery-thumb[data-state='wait'] {
  background: linear-gradient(90deg, var(--input-bg), var(--hover-bg), var(--input-bg)) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}
.gallery-ext {
  padding: 2px 6px;
  border-radius: var(--r-3);
  background: var(--code-bg);
  color: var(--fg-2);
  font-family: var(--mono);
  font-size: var(--t-85);
}
.gallery-title,
.gallery-meta,
.gallery-chat-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-title {
  color: var(--fg);
}
.gallery-meta,
.preview-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--t-85);
  color: var(--fg-2);
}
.gallery-meta > * + *::before,
.preview-meta > * + *::before {
  content: '·';
  margin-right: 6px;
}
.gallery-chat {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--t-85);
  color: var(--fg-2);
}
.preview-meta .gallery-chat {
  display: inline-flex;
  font-size: inherit;
}
.gallery-time {
  flex: none;
}
.gallery-empty {
  margin: var(--sp-4);
  padding: 40px var(--sp-4);
  border-radius: var(--r-8);
  background: var(--input-bg);
  color: var(--fg-2);
  text-align: center;
}
.mgr-view .gallery-empty {
  margin: var(--sp-4) 0;
}
.gallery-empty h2 {
  margin-bottom: var(--sp-1);
  font-size: var(--t-title);
  font-weight: 600;
  color: var(--fg);
}
.gallery-empty p {
  margin: 0;
}

/* The preview: a dialog over the 75% overlay, the image as large as the view allows. */
.gallery-overlay {
  position: fixed;
  z-index: var(--z-overlay);
  inset: 0;
  display: flex;
  padding: var(--sp-4);
  background: var(--overlay);
  animation: var(--fade-menu);
}
.gallery-preview {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--dialog-border);
  border-radius: var(--r-8);
  background: var(--dialog-bg);
  outline: none;
}
.preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.preview-text {
  flex: 1 1 240px;
  min-width: 0;
}
.preview-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-title);
  font-weight: 600;
  line-height: 1.5;
  color: var(--fg);
}
.preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.preview-stage {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  min-height: 0;
  padding: var(--sp-4) var(--sp-2);
}
/* The image fits the canvas; zoomed, it is its scaled size, centred plus the pan, and drags. */
.viewer-canvas {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}
.viewer-canvas[data-zoomed] {
  cursor: grab;
}
.viewer-canvas[data-zoomed]:active {
  cursor: grabbing;
}
.preview-img {
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  border-radius: var(--r-4);
  user-select: none;
}
.viewer-canvas[data-zoomed] .preview-img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  max-height: none;
  border-radius: 0;
}
.viewer-count {
  flex: none;
  min-width: 48px;
  color: var(--fg-2);
  font-size: var(--t-90);
  font-variant-numeric: tabular-nums;
}
.viewer-zoom {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: var(--sp-2);
}
button.viewer-scale {
  min-width: 48px;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
/* The filmstrip: the set along the bottom, the current one ringed. */
.viewer-strip {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
button.viewer-thumb {
  flex: none;
  justify-content: center;
  width: 64px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  background: var(--input-bg);
  overflow: hidden;
  opacity: 0.7;
}
button.viewer-thumb:hover {
  opacity: 1;
}
button.viewer-thumb[aria-selected='true'] {
  border-color: var(--focus);
  box-shadow: inset 0 0 0 1px var(--focus);
  opacity: 1;
}
.viewer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.viewer-thumb-name {
  color: var(--fg-2);
  font-size: var(--t-75);
}
.preview-none {
  justify-self: center;
  color: var(--fg-2);
}

@media (prefers-reduced-motion: reduce) {
  .gallery-thumb[data-state='wait'] {
    animation: none;
  }
}

.task-options {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}
.task-options .fl-select {
  max-width: 130px;
}
.approval-seg .icon {
  width: var(--i-xs);
  height: var(--i-xs);
}
.map-node .node-auto rect {
  fill: color-mix(in srgb, var(--error) 22%, transparent);
}
.map-node .node-auto path {
  fill: var(--error);
}
.tip-auto {
  color: var(--error);
}
.cc-card {
  border-style: dashed;
}
.cc-row {
  cursor: pointer;
}
.map-sub[data-selected] .box {
  stroke: var(--fg);
  stroke-width: 2;
}
.map-outside .box {
  stroke-dasharray: 4 3;
}
.map-body {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}
.map-body > .map-scroll {
  flex: 1;
  min-width: 0;
}
/* The detail panel stays in view wherever the page is scrolled: sticky in the right column, its own scroll. */
.map-detail {
  position: sticky;
  top: var(--sp-3);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 300px;
  max-height: calc(100vh - var(--sp-3) - max(var(--sp-3), var(--mgr-below)));
  overflow: auto;
  /* Long paths, commands and URLs break rather than push the panel wider (they have no spaces to break at). */
  overflow-wrap: anywhere;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--menu-bg);
  font-size: var(--t-90);
  outline: none;
}
.sheet-handle {
  display: none;
}
/* Narrow: a bottom sheet over the page, 60% high, rounded on top, with a handle to drag it away. */
@media (max-width: 900px) {
  .map-detail {
    position: fixed;
    z-index: var(--z-overlay);
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 60vh;
    max-height: 60vh;
    padding-top: 0;
    border-width: 1px 0 0;
    border-radius: var(--r-12) var(--r-12) 0 0;
    box-shadow: var(--shadow-sheet);
    animation: sheet-up 0.2s ease-out;
  }
  /* Room under the page for the sheet, so the agents it covers can still scroll above it. */
  .manager:has(.map-detail) {
    padding-bottom: calc(60vh + var(--sp-5));
  }
  .sheet-handle {
    display: block;
    flex: none;
    align-self: center;
    width: 36px;
    height: 4px;
    margin: var(--sp-2) 0;
    border-radius: var(--r-pill);
    background: var(--fg-2);
    opacity: 0.5;
    cursor: grab;
    touch-action: none;
  }
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .map-detail {
    animation: none;
  }
}
.map-detail-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--fg-2);
}
/* A step with a very long command takes two lines at most (the whole of it is the tooltip). */
.map-detail-step {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.map-detail-steps li[data-state='in_progress'] {
  color: var(--fg);
}
.map-detail-answer {
  white-space: pre-wrap;
  color: var(--fg);
}
.map-detail .fl-btn--link {
  align-self: flex-start;
}
/* A long title or parent takes two lines at most (the whole of it is the tooltip), so it never crowds out what is below it. */
.map-detail > :is(.tip-title, .sd-parent) {
  display: -webkit-box;
  flex: none;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
/* An outside Claude Code subagent's detail (COMPONENTS.md §2.31): a wider panel whose regions fill its height;
   two columns (story | facts and files) once it is 600 wide, one column that scrolls below that. */
.map-detail[data-rich] {
  container-type: inline-size;
  width: clamp(360px, 46%, 760px);
  overflow: hidden;
}
@media (max-width: 900px) {
  .map-detail[data-rich] {
    width: auto;
    height: 60vh;
  }
}
.sd {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
  min-height: 0;
  overflow: auto;
}
.sd-main,
.sd-side,
.sd-sec {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.sd-main,
.sd-side {
  gap: var(--sp-4);
}
.sd-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--h-sm);
}
.sd-h {
  margin: 0;
  font-size: var(--t-90);
  font-weight: var(--w-strong);
  color: var(--fg);
}
.sd-meta {
  font-size: var(--t-85);
  color: var(--fg-2);
}
.sd-empty {
  margin: 0;
  color: var(--fg-2);
}
.sd-brief:not([data-open]) {
  max-height: 7.5em;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, var(--fg) 60%, transparent);
}
.sd-more {
  align-self: flex-start;
}
/* One column: the whole panel scrolls, so the timeline that scrolls inside it stays shorter than the sheet (60vh). */
.sd-timeline {
  min-height: 12em;
  max-height: min(28em, 40vh);
  overflow: auto;
  overscroll-behavior: contain;
}
/* The browser skips laying out rows scrolled out of view: the window the host keeps (300) stays smooth. */
.sd-timeline > .tl {
  content-visibility: auto;
  contain-intrinsic-size: auto 34px;
}
.sd-note-text {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--fg);
}
.sd-note[data-kind='thought'] .sd-note-text {
  color: var(--fg-2);
}
.sd-note .step-verb {
  font-weight: var(--w-medium);
  color: var(--fg-2);
}
/* Label over value; as many across as fit (one column beside the story, several when it is the only column). */
.sd-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-3);
  margin: 0;
}
.sd-fact {
  display: flex;
  flex-direction: column;
  gap: var(--sp-half);
  min-width: 0;
}
.sd-facts dt {
  font-size: var(--t-85);
  color: var(--fg-2);
}
.sd-facts dd {
  min-width: 0;
  margin: 0;
}
.sd-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.sd-file-list {
  display: flex;
  flex-direction: column;
}
@container (min-width: 600px) {
  .sd {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 34%);
    flex: 1;
    min-height: 0;
  }
  .sd {
    overflow: hidden;
  }
  .sd-main,
  .sd-side {
    min-height: 0;
    overflow: auto;
  }
  .sd-steps {
    flex: 1;
    min-height: 12em;
  }
  .sd-timeline {
    flex: 1;
    max-height: none;
  }
}
.seg-bar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--sp-half);
}
.seg-bar i {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.seg-bar i[data-step='done'] {
  background: var(--status-done);
}
.seg-bar i[data-step='working'] {
  background: var(--status-working);
}

/* The Ultracode-style option row: its Toggle sits at the row's end. */
.cc-toggle {
  margin-left: auto;
}

/* ---- Chat layout ---- */

body[data-surface='chat'] {
  background: var(--bg);
}
.chat-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}
.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
/* A wide chat page: the transcript and composer, then the context rail (§2.34): 300 wide, 264 under 1300. */
.chat-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.chat-body[data-rail] {
  grid-template-columns: minmax(0, 1fr) 300px;
  border-top: var(--line) solid var(--hairline);
}
@media (max-width: 1300px) {
  .chat-body[data-rail] {
    grid-template-columns: minmax(0, 1fr) 264px;
  }
}
.chat-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  container: chat-col / inline-size;
}
.ctx-rail {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  min-width: 0;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4);
  border-left: var(--line) solid var(--border);
  background: var(--zone-shell);
  font-size: var(--t-step);
  contain: layout paint;
}
/* Details zone: section names are eyebrows (small caps-style, tracked), so the rail reads as reference,
   never as conversation. */
.ctx-rail h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-3);
  color: var(--fg-2);
  font-size: var(--t-eyebrow);
  font-weight: var(--w-strong);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}
.ctx-rail section + section {
  padding-top: var(--sp-5);
  border-top: var(--line) solid var(--hairline);
}
.ctx-rail .fl-row {
  margin: 0 calc(var(--sp-2) * -1);
  width: calc(100% + var(--sp-4));
}
.ctx-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.ctx-l {
  color: var(--fg-2);
  font-size: var(--t-eyebrow);
  font-variant-numeric: tabular-nums;
}
.ctx-v {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  /* Room for a working agent's ring under the label. */
  margin-top: var(--sp-1);
  color: var(--sel-fg);
  font-size: var(--fs);
  font-weight: var(--w-medium);
  font-variant-numeric: tabular-nums;
}
.ctx-more,
.ctx-empty {
  margin: 0;
  color: var(--fg-2);
  font-size: var(--t-90);
}
.ctx-empty {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
}

/* ---- Transcript (§2.8): full width, 20px gutters; messages 8px apart; a timeline for tools ---- */

.transcript-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}
/* The bottom fades into the background above the composer. */
.transcript-wrap::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--zone-prompt-fade);
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}
.transcript {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  /* Never sideways: a long word, path or URL anywhere in a message, card or notice wraps (inherited),
     so nothing can push the transcript wider and slide its content past the left gutter. Code blocks
     and diffs keep their own sideways scroll. */
  overflow-x: hidden;
  overflow-wrap: anywhere;
  padding: var(--sp-5) var(--gutter) 40px;
  line-height: 1.5;
}
/* The edge of the window: reaching it brings earlier items in. */
.transcript-more {
  height: 1px;
}
.transcript > :first-child {
  margin-top: 0;
  padding-top: 0;
}

/* Your message: a box that fits its text, three lines until Show more. */
.user-msg {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  padding: var(--sp-1) 0;
}
/* A new turn: more room above it (24, text to text) than between the steps inside a turn (16). */
.transcript > * + .user-msg {
  margin-top: var(--turn-gap);
}
/* You zone (v3): your message is a raised bubble at the right that fits its text, with a tighter corner
   toward you, so who said what reads at a glance and never looks like the agent's reply or a card. */
.user-msg {
  justify-content: flex-end;
}
.user-msg .bubble {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  max-width: var(--w-bubble);
  margin: var(--sp-1) 0;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-4);
  border: 1px solid var(--zone-you-edge);
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble-tail) var(--r-bubble);
  background: var(--zone-you-bg);
  color: var(--sel-fg);
  font-size: var(--t-reply);
  line-height: var(--lh-reply);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.bubble-text[data-clamped] {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
/* Show more / Show less: a row of its own under the text, at the box's bottom right; it never covers a glyph. */
button.msg-more {
  display: block;
  margin-left: auto;
  font-size: var(--t-85);
  line-height: 1.5;
}
/* The current turn's message, once scrolled away: a copy at the top, full width, never past three lines. */
/* A solid tone with a hairline under it and a fade below: what scrolls under it goes out of view
   softly, never a card head or a line cut in half against its edge. Items scrolled to (jump list,
   Show more) stop below it: scroll-margin-top on the transcript's items. */
.sticky-prompt {
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  z-index: var(--z-sticky);
  max-height: 30%;
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--hairline);
  background: var(--bg);
}
.transcript > * {
  scroll-margin-top: calc(var(--sp-12) * 2);
}
/* Speed: in a long chat, items far off screen skip style, layout and paint until they scroll near
   (content-visibility); the browser remembers each one's real height (auto), so the scrollbar and
   scroll anchoring stay true. The last items, where the agent is writing, always render. */
.transcript > :not(:nth-last-child(-n + 8)):not(.sticky-prompt) {
  content-visibility: auto;
  contain-intrinsic-size: auto var(--sp-12);
}
.sticky-prompt::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 1px);
  height: var(--sp-6);
  background: linear-gradient(to bottom, var(--bg) 40%, transparent);
  pointer-events: none;
}
.sticky-prompt .bubble {
  position: relative;
  margin: var(--sp-1) 0;
  padding: var(--sp-1) var(--sp-3);
  border: 0;
  border-radius: 0;
  box-shadow: var(--zone-ask-bar);
  background: transparent;
  color: var(--fg-2);
  font-size: var(--t-step);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble .refs,
.bubble .thumbs {
  margin-top: 6px;
}
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.thumbs img {
  display: block;
  max-height: 72px;
  max-width: 120px;
  border-radius: var(--r-4);
}
/* In the box's top-right corner: floated so text wraps around it, with negative margins so a one-line box doesn't grow. */
button.rewind-btn {
  float: right;
  margin: -2px -4px -6px var(--sp-2);
  color: var(--fg-2);
  opacity: 0;
}
.user-msg:hover .rewind-btn,
.rewind-btn:focus-visible {
  opacity: 1;
}
/* Its time (§2.32) floats over the box's top-right corner, left of Rewind, only while hovered or focused:
   it takes no room at rest and moves nothing when it shows (owner, 2026-10-20). */
.user-msg .msg-when {
  position: absolute;
  top: var(--sp-1);
  right: var(--sp-2);
  padding-left: var(--sp-2);
  background: inherit;
  pointer-events: none;
}
.user-msg .bubble:has(.rewind-btn) .msg-when {
  right: calc(var(--sp-2) + var(--h-sm) + var(--sp-1));
}

/* The agent's reply: plain text, Claude Code's paragraph rhythm. */
/* Reply zone (v3): no box; the largest reading type on the page and a long line height. */
.prose {
  position: relative;
  padding: var(--sp-2) 0;
  color: var(--fg);
  font-size: var(--t-reply);
  line-height: var(--lh-reply);
}
@container chat-col (min-width: 720px) {
  .prose {
    font-size: var(--t-reply-wide);
  }
}
.md > :first-child {
  margin-top: 0;
}
.md > :last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0.1em 0 0.2em;
  overflow-wrap: anywhere;
}
.md ul,
.md ol {
  margin: 0.2em 0;
  padding-inline-start: 2em;
}
.md li {
  position: relative;
  overflow-wrap: anywhere;
}
.md h3,
.md h4 {
  margin: 0.6em 0 0.2em;
  font-size: var(--t-100);
  font-weight: 600;
}
.md .md-label {
  margin: 0.6em 0 0.2em;
  font-size: var(--t-85);
  font-weight: 600;
  color: var(--fg-2);
}
.md a {
  color: var(--link);
}
/* Items that start with a symbol keep it, in the bullet's place; ✓ is green, ✗ red. */
.md li[data-mark] {
  list-style: none;
}
.md .li-mark {
  position: absolute;
  left: -1.2em;
  color: var(--fg-2);
}
.md li[data-tone='ok'] > .li-mark {
  color: var(--tl-success);
}
.md li[data-tone='bad'] > .li-mark {
  color: var(--error);
}
.md-table {
  max-width: 100%;
  margin: var(--sp-2) 0;
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r-box);
}
/* The whole message width (owner: use the whole screen): columns share it; numbers right-aligned, tabular. */
.md-table table {
  width: 100%;
  border-collapse: collapse;
}
.md-table th,
.md-table td {
  padding: var(--sp-1) var(--sp-2);
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}
.md-table tr:last-child td {
  border-bottom: 0;
}
.md-table th {
  color: var(--fg-2);
  font-size: var(--t-85);
  font-weight: var(--w-medium);
}
.md-table td[data-num] {
  font-variant-numeric: tabular-nums;
}
.md pre.md-mono {
  margin: var(--sp-2) 0;
  padding: var(--sp-2);
  border-radius: var(--r-4);
  background: var(--code-bg);
  font-size: var(--fs-mono);
  white-space: pre;
  word-break: normal;
  overflow-x: auto;
}
.md.clamped {
  max-height: calc(40 * 1.5em);
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 85%, transparent);
}
.sm-link {
  margin-top: 2px;
}
/* File paths: open at the line inside the chat's folder, copy otherwise. Inline, so a long one wraps. */
.path-link {
  color: var(--link);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.path-link:hover {
  text-decoration: underline;
}
.path-link.outside {
  color: inherit;
  text-decoration: underline dotted var(--fg-2);
  text-underline-offset: 3px;
  cursor: copy;
}
/* On the code well the link colour sits a shade under AA in a light theme: a little of the text's ink carries it over. */
.path-link code {
  color: color-mix(in srgb, var(--link) 85%, var(--fg));
}
.path-link.outside code {
  color: inherit;
}
/* The reply's time and Copy (§2.32): over the first line's end, on the page tone, only while the reply is
   hovered or focused. No room taken at rest, no shift when they show (owner, 2026-10-20). */
.msg-tools {
  position: absolute;
  top: var(--sp-1);
  right: 0;
  z-index: var(--z-content);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding-left: var(--sp-3);
  background: linear-gradient(to right, transparent, var(--bg) var(--sp-3));
  opacity: 0;
  pointer-events: none;
}
.prose:hover .msg-tools,
.prose:focus-within .msg-tools {
  opacity: 1;
  pointer-events: auto;
}

/* Code blocks: the code on its own tone, no border, no header; the tools show on hover. */
.code-block {
  position: relative;
  margin: var(--sp-2) 0;
}
pre.code {
  margin: 0;
  padding: var(--sp-2);
  border-radius: var(--r-4);
  color: var(--fg);
  font-size: var(--fs-mono);
  line-height: 1.5;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 4;
  /* A shade on the right edge while there's more to scroll to: the cover moves with the code and hides it at the end. */
  background:
    linear-gradient(to left, var(--code-bg) 40%, transparent) right / var(--sp-5) 100% no-repeat local,
    linear-gradient(to left, color-mix(in srgb, var(--fg) 14%, transparent), transparent) right / var(--sp-4) 100% no-repeat scroll,
    var(--code-bg);
}
/* A code block in a reply wraps unless its Wrap is off. */
.code-block[data-wrap] pre.code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre.code:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: -1px;
}
pre.code code {
  padding: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}
.code-tools {
  position: absolute;
  top: var(--sp-1);
  right: var(--sp-1);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding-left: var(--sp-1);
  border-radius: var(--r-4);
  background: var(--code-bg);
  opacity: 0;
}
.code-block:hover .code-tools,
.code-tools:focus-within {
  opacity: 1;
}
.code-lang {
  font-family: var(--mono);
  font-size: var(--t-85);
  color: var(--fg-2);
}
.run-short {
  display: none;
}
.tk-kw {
  color: var(--vscode-symbolIcon-keywordForeground, var(--vscode-charts-blue, #57a3f8));
}
.tk-fn {
  color: var(--vscode-terminal-ansiYellow, var(--vscode-charts-yellow, #e1c08d));
}
.tk-str {
  color: var(--vscode-debugTokenExpression-string, var(--vscode-charts-orange, #d97757));
}
.tk-num,
.tk-type {
  color: var(--vscode-debugTokenExpression-number, var(--vscode-charts-green, #89d185));
}
.tk-lit {
  color: var(--vscode-debugTokenExpression-boolean, var(--vscode-charts-blue, #57a3f8));
}
.tk-var,
.tk-prop {
  color: var(--vscode-terminal-ansiCyan, var(--link));
}
.tk-com {
  color: var(--fg-2);
  font-style: italic;
}
.tk-op {
  color: var(--fg-2);
}

/* The timeline: tool lines and thinking, a 7px dot at 9px and a 1px spine at 12px joining a run. */
/* Steps zone (v3): what the agent did is small and secondary on a hairline spine, so it never competes
   with the reply you read or the prompt you type. */
.tl {
  position: relative;
  padding: var(--sp-1) 0 var(--sp-1) 30px;
  min-width: 0;
  font-size: var(--t-step);
  color: var(--fg-2);
}
.tl::before {
  content: '';
  position: absolute;
  top: 11px;
  left: 9px;
  width: 7px;
  height: 7px;
  z-index: var(--z-content);
  border-radius: var(--r-round);
  background: var(--tl-default);
}
.tl::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 12px;
  width: 1px;
  background: var(--zone-step-spine);
}
.tl:not(.tl + .tl)::after {
  top: 18px;
}
.tl:not(:has(+ .tl))::after {
  bottom: calc(100% - 18px);
}
.tl[data-state='done']::before {
  background: var(--status-done);
}
.tl[data-state='error']::before,
.tl[data-state='denied']::before {
  background: var(--status-failed);
}
.tl[data-state='needs-you']::before {
  background: var(--status-waiting);
}
.tl[data-state='working']::before {
  background: var(--status-working);
  animation: blink 1s linear infinite;
}
/* A tool line: the tool in bold, its target in the editor's font; one line. */
.step-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  min-width: 0;
}
.step-main {
  display: flex;
  align-items: baseline;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
/* A step is a row in every surface: the Manager's plain-button look (see its rule) is not its look. */
.step-main,
.step-main:hover:not(:disabled) {
  justify-content: flex-start;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
button.step-main:hover {
  opacity: 0.8;
}
button.step-main:active {
  opacity: 0.65;
}
.step-verb {
  flex: none;
  margin-right: var(--sp-1);
  font-weight: var(--w-medium);
  color: var(--fg);
}
.step-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg-2);
}
.step-text.mono {
  font-family: var(--mono);
  font-size: var(--t-85);
  color: var(--fg);
}
.step-target {
  color: var(--link);
  cursor: pointer;
}
.step-text.mono.step-target {
  color: var(--link);
}
.step-target:hover {
  text-decoration: underline;
}
.step-lines {
  flex: none;
  margin-left: 6px;
  font-size: var(--t-85);
  color: var(--fg-2);
}
.step-end {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: none;
  margin-left: auto;
  font-size: var(--t-85);
  color: var(--fg-2);
}
.step-denied {
  color: var(--error);
}
.step-image {
  padding-top: var(--sp-1);
}
/* A folded run's heading: the label at half strength (--fg-50, which still reads at 4.5:1). */
.tl-group-btn {
  gap: 0;
  font-weight: 700;
}
.tl-group-btn .icon {
  width: 1em;
  height: 1em;
  transition: transform var(--ease-toggle);
}
.tl-group-btn[aria-expanded='false'] .icon {
  transform: rotate(-90deg);
}
.tl-group-label {
  margin-left: 0.5em;
  color: var(--fg-50);
}
.tl-group-btn:hover .tl-group-label {
  color: var(--fg-2);
}
.tl-group-btn:active .tl-group-label {
  opacity: 0.8;
}
/* A tool's body: IN/OUT rows in a .5px r5 box; each row clipped at 60px until asked. */
.step-about {
  margin-top: 2px;
  font-size: var(--t-85);
  color: var(--fg-2);
}
.tool-body {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  margin: var(--sp-2) 0;
  border: 0.5px solid var(--border);
  border-radius: var(--r-5);
  background: var(--tool-bg);
  overflow: hidden;
}
.tool-row {
  display: contents;
}
.tool-row + .tool-row > * {
  border-top: 0.5px solid var(--border);
}
.tool-row.out > * {
  background: var(--code-bg);
}
.tool-label {
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-1);
  font-family: var(--mono);
  font-size: var(--t-85);
  color: var(--fg-50);
}
.tool-cell {
  position: relative;
  min-width: 0;
  padding: var(--sp-1);
  font-size: var(--t-85);
}
.tool-cell pre.code {
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: var(--t-100);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tool-cell pre.code.capped {
  max-height: 60px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 50px, transparent 60px);
}
.tool-tools {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: var(--sp-1);
  border-radius: var(--r-4);
  background: var(--menu-bg);
  opacity: 0;
}
.tool-cell:hover .tool-tools,
.tool-tools:focus-within {
  opacity: 1;
}
.tool-meta {
  padding: 0 var(--sp-1);
  color: var(--fg-2);
  white-space: nowrap;
}
.tool-meta.bad {
  color: var(--error);
}
.tool-file {
  margin-bottom: 2px;
  color: var(--fg-2);
}
.tool-file .file-name {
  font-family: var(--mono);
  color: var(--fg);
}
.step-cut {
  font-size: var(--t-100);
}
.file-change {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.file-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.stats {
  display: inline-flex;
  gap: var(--sp-1);
  font-family: var(--mono);
  font-size: var(--t-85);
}
.plus {
  color: var(--added);
}
.minus {
  color: var(--removed);
}
/* A diff: its changed lines on the code tone. */
.diff {
  max-height: 320px;
  overflow: auto;
  padding: var(--sp-1) 0;
  border-radius: var(--r-4);
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: var(--t-85);
  line-height: 1.5;
}
.tool-cell .diff {
  font-size: var(--t-100);
}
.dl {
  display: flex;
  gap: 6px;
  padding: 0 var(--sp-2);
  white-space: pre;
}
.dl[data-op='add'] {
  background: color-mix(in srgb, var(--added) 12%, transparent);
}
.dl[data-op='del'] {
  background: color-mix(in srgb, var(--removed) 12%, transparent);
}
.dl-op {
  flex: none;
  width: 1ch;
  color: var(--fg-2);
}
.dl[data-op='add'] .dl-op {
  color: color-mix(in srgb, var(--added) var(--tone-ink), var(--fg));
}
.dl[data-op='del'] .dl-op {
  color: color-mix(in srgb, var(--removed) var(--tone-ink), var(--fg));
}
.dl-more {
  color: var(--fg-2);
  font-family: var(--font);
}

/* Thinking: a muted line on the timeline that opens to the thought. */
details.thought > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  list-style: none;
  color: var(--fg-2);
  opacity: 0.8;
  cursor: pointer;
}
details.thought > summary::-webkit-details-marker {
  display: none;
}
details.thought > summary:hover,
details.thought[open] > summary {
  opacity: 1;
}
details.thought > summary .icon {
  width: 16px;
  height: 16px;
  transform: rotate(-90deg);
  transition: transform var(--ease-toggle);
}
details.thought[open] > summary .icon {
  transform: none;
}
.thought-text {
  margin-top: var(--sp-1);
  color: var(--fg-2);
  white-space: pre-wrap;
}

/* A subagent on the timeline: "Task" and its title, its time; opened, its steps and answer. */
button.sa-head {
  display: flex;
  align-items: baseline;
  width: 100%;
  min-width: 0;
}
button.sa-head:hover {
  opacity: 0.8;
}
.sa-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-2);
}
.sa-time {
  flex: none;
  margin-left: var(--sp-2);
  font-size: var(--t-85);
  color: var(--fg-2);
}
.sa-last {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-85);
  color: var(--fg-2);
}
.sa-body {
  margin-top: var(--sp-1);
}
.sa-answer {
  margin: var(--sp-2) 0;
}
.sa-label,
.sa-empty {
  margin: 0;
  font-size: var(--t-85);
  color: var(--fg-2);
}
button.sa-manager {
  font-size: var(--t-85);
}

/* Working: the accent spinner. */
.working {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 1.85em;
  margin-top: var(--sp-1);
  color: var(--fg-2);
}
.spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--accent);
  border-top-color: transparent;
  border-radius: var(--r-round);
  animation: spin 0.8s linear infinite;
}

/* Images a step made: a thumbnail and its title; click opens the editor's preview. */
button.image-thumb,
.image-thumb {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
  max-width: 240px;
  font-size: var(--t-85);
  color: var(--fg-2);
  cursor: pointer;
}
.image-thumb img,
.image-thumb .image-wait {
  display: block;
  max-width: 240px;
  max-height: 160px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--r-6);
  background: var(--input-bg);
}
.image-thumb .image-wait {
  width: 240px;
  height: 120px;
}
.image-thumb .image-title {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-thumb.missing {
  flex-direction: row;
  align-items: center;
  cursor: default;
}
.image-strip {
  display: flex;
  gap: var(--sp-3);
  max-width: min(80vw, 760px);
  overflow-x: auto;
  padding: var(--sp-1);
}
.image-strip .image-thumb img,
.image-strip .image-thumb .image-wait {
  max-width: 160px;
  max-height: 110px;
}
.image-strip .image-thumb .image-wait {
  width: 160px;
  height: 90px;
}

/* ---- Agent map (§2.7): a modal over a 75% overlay; this chat, then its agents on elbow connectors ---- */

.cc-overlay {
  position: fixed;
  z-index: var(--z-overlay);
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  animation: var(--fade-menu);
}
.cc-map {
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  margin: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--dialog-border);
  border-radius: var(--r-8);
  background: var(--dialog-bg);
  color: var(--fg);
}
.cc-map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.cc-map-title {
  font-size: var(--t-title);
  font-weight: 600;
}
.cc-map-actions {
  display: flex;
  gap: 2px;
}
.cc-map-sub {
  margin-bottom: var(--sp-3);
  color: var(--fg-2);
}
.cc-map-body {
  min-height: 0;
  overflow: auto;
}
.cc-map-tree {
  display: flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-2) var(--sp-2) 0;
}
.cc-map-node {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 300px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  background: var(--menu-bg);
  color: var(--fg);
  line-height: 1.15;
  text-align: left;
}
button.cc-map-node:hover {
  background: linear-gradient(var(--hover-bg), var(--hover-bg)), var(--menu-bg);
}
.cc-map-main {
  position: sticky;
  top: 0;
  bottom: 0;
  width: 320px;
}
.cc-map-main .cc-map-name {
  font-weight: 600;
}
.cc-map-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-map-meta {
  padding-left: 14px;
  font-size: var(--t-85);
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Elbows: a 16px stub out of this chat, a spine from the first agent to the last, a stub into each. */
.cc-map-children {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-left: 32px;
}
.cc-map-children::before {
  content: '';
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: -16px;
  width: 1px;
  background: var(--border);
}
.cc-map-children > .cc-map-node::before,
.cc-map-main:has(+ .cc-map-children)::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 16px;
  height: 1px;
  background: var(--border);
}
.cc-map-children > .cc-map-node::before {
  left: -17px;
}
.cc-map-main::after {
  right: -17px;
}
/* Narrow: this chat on top, its agents under it. */
@media (max-width: 720px) {
  .cc-map {
    width: auto;
  }
  .cc-map-tree {
    flex-direction: column;
    align-items: stretch;
  }
  .cc-map-node,
  .cc-map-main {
    position: relative;
    width: auto;
  }
  .cc-map-children {
    margin-top: var(--sp-2);
  }
  .cc-map-children::before {
    top: -8px;
  }
  .cc-map-main:has(+ .cc-map-children)::after {
    display: none;
  }
}

/* ---- Decisions and cards in the transcript (§2.10, §2.11) ---- */

/* ---- Approvals (webview/approval.tsx; RESEARCH.md §3 A + C) ----
   Drawn with the components: Button (brand on the request the keys act on), SplitButton, the hold
   Button, Segmented, Pill, Countdown, MenuItem, and Card (bare: its rows pad themselves). */

/* A request (§2.29): a bare Card for review and careful, a ghost Card (one sentence row) for routine. Full
   width. Rows pad themselves at 12; the head, the preview and the foot are 8 apart. */
.apv {
  margin: var(--sp-2) 0;
  container-type: inline-size;
}
.apv-hd {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
  min-height: var(--h-xl);
  padding: var(--sp-2) var(--sp-3);
}
.task-card .apv {
  margin: 0;
}
/* On a board card the request is part of the card (no box in a box): its head sits on the card's own padding. */
.task-card .apv-hd {
  min-height: 0;
  padding: 0;
}
.apv-row .apv-hd {
  min-height: var(--sp-8);
  padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3);
}
.apv-what {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1 1 340px;
  min-width: 0;
}
/* The risk pill sits at the head's end (§2.29). */
.apv-what > .fl-pill {
  margin-left: auto;
}
.apv-kind {
  display: inline-flex;
  flex: none;
}
.apv-what > .fl-avatar,
.apv-what > .icon {
  flex: none;
}
.apv-what > .icon {
  color: var(--fg-2);
  transform: rotate(-90deg);
}
.apv-verb {
  flex: none;
  font-weight: var(--w-strong);
  color: var(--sel-fg);
}
/* Short of room, the target is cut before the risk pill beside it: the card below shows the target whole, and
   the pill is the one place the risk is named. */
.apv-tg {
  flex: 0 1000 auto;
  min-width: 4em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sel-fg);
}
.apv-tg.mono {
  font-family: var(--mono);
  font-size: var(--fs-mono);
}
.apv-wh {
  flex: 0 3 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg-2);
  white-space: nowrap;
}
.apv-label {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-2);
}
.apv-act {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}
/* The foot (§2.29): the answers at the end; Windows puts the primary first (Fluent order). */
.apv-ft {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3) var(--sp-3);
}
body[data-platform='windows'] .apv-ft > .apv-act {
  flex-direction: row-reverse;
}
/* Narrow: the actions get their own row, right-aligned. */
@container (max-width: 560px) {
  .apv-act {
    width: 100%;
    justify-content: flex-end;
  }
}
/* A side bar (~200-360px): the sentence wraps instead of cutting its target, label, commits and URL short;
   a pill keeps its one line and moves to its own. (Scoped under .apv so it outranks the rules further down; the risk pill wraps through .fl-pill--fit.) */
@container (max-width: 360px) {
  .apv .apv-what {
    flex-wrap: wrap;
    row-gap: var(--sp-half);
  }
  .apv .apv-what > .fl-pill {
    margin-left: 0;
  }
  .apv .apv-tg,
  .apv .apv-label,
  .apv .apv-subj,
  .apv .apv-url,
  .apv .apv-batch-text {
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .apv .apv-batch,
  .apv .apv-act,
  .apv .apv-dh {
    flex-wrap: wrap;
  }
  .apv .apv-dh {
    padding-block: var(--sp-half);
  }
  .apv .apv-batch-text {
    flex: 1 1 100%;
  }
  /* A dropped commit: hash and author on one line, its subject under them. */
  .apv .apv-commit {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 0;
  }
  .apv .apv-subj {
    grid-row: 2;
    grid-column: 1 / -1;
    overflow-wrap: break-word;
  }
}
/* Narrow: where it runs gives way to what it is. */
@container (max-width: 640px) {
  .apv-wh {
    display: none;
  }
  .apv-site .apv-el {
    display: none;
  }
}
.apv-bd {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  padding: 0 var(--sp-3) var(--sp-1);
}
/* "Why:" in the body text colour, 12px. */
.apv-why {
  color: var(--fg);
  font-size: var(--t-90);
}
.apv-why b {
  color: var(--sel-fg);
  font-weight: var(--w-medium);
}
/* The command well (§2.29): the code tone, --r-ctl, mono 12, the $ in --fg-2. */
.apv-pre {
  position: relative;
  border-radius: var(--r-ctl);
  background: var(--code-bg);
}
.apv-pre pre {
  max-height: 16em;
  overflow: auto;
  padding: var(--sp-2) var(--sp-10) var(--sp-2) var(--sp-3);
  color: var(--sel-fg);
  font-size: var(--fs-mono);
  line-height: var(--lh-code);
  white-space: pre-wrap;
}
.apv-pre pre .prompt {
  color: var(--fg-2);
}
.apv-pre .copy-btn {
  position: absolute;
  top: var(--sp-1);
  right: var(--sp-1);
  opacity: 0;
}
.apv-pre:hover .copy-btn,
.apv-pre .copy-btn:focus-visible {
  opacity: 1;
}
.apv-diff,
.apv-commits {
  overflow: hidden;
  border: var(--line) solid var(--hairline);
  border-radius: var(--r-ctl);
  background: var(--code-bg);
}
.apv-dh {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--h-lg);
  padding: 0 var(--sp-1) 0 var(--sp-3);
  border-bottom: var(--line) solid var(--hairline);
  background: var(--input-bg);
  color: var(--fg-2);
  font-size: var(--t-85);
}
.apv-dh .mono {
  color: var(--fg);
  font-size: var(--fs-mono);
}
.apv-file {
  min-width: 0;
}
.apv-dh .stats {
  font-family: var(--mono);
}
.apv-diff .diff {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.apv-diff:not(:has(.diff)) .apv-dh {
  border-bottom: 0;
}
.apv-plan {
  max-height: 20em;
  overflow: auto;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-ctl);
  background: var(--code-bg);
}
.apv-files {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
/* The effects (§2.29): plain sentences with a 12 glyph each, in a wrapping row. */
.apv-risks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--fg);
  font-size: var(--t-90);
}
.apv-risks li {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  min-width: 0;
}
.apv-risks li > .icon {
  flex: none;
  align-self: center;
  color: var(--warn);
}
.apv-risks li[data-safer] > .icon {
  color: var(--fg-2);
}
.apv-risks code {
  min-width: 0;
  color: var(--sel-fg);
}
/* A word, never broken a letter a line beside a long command. */
.apv-risks .apv-safer {
  flex: none;
}
.apv-commit {
  display: grid;
  grid-template-columns: 8ch minmax(0, 1fr) auto;
  gap: var(--sp-2);
  padding: var(--sp-half) var(--sp-3);
  font-size: var(--fs-mono);
  border-left: 2px solid var(--removed);
  background: color-mix(in srgb, var(--removed) 6%, transparent);
}
.apv-commit:last-child {
  padding-bottom: var(--sp-1);
}
.apv-hash,
.apv-author {
  color: var(--fg-2);
}
.apv-subj {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: color-mix(in srgb, var(--removed) var(--tone-ink), var(--fg));
}
.apv-author {
  font-family: var(--font);
  font-size: var(--t-90);
}
.apv-more-lines {
  padding: 0 var(--sp-3) var(--sp-1);
  color: var(--fg-2);
  font-size: var(--t-85);
}
.apv-site,
.apv-msg {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-ctl);
  background: var(--code-bg);
}
.apv-msg {
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-1);
}
.apv-fav {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--i-lg);
  height: var(--i-lg);
  border-radius: var(--r-4);
  background: var(--pill-bg);
  color: var(--fg);
  font-size: var(--t-75);
  font-weight: var(--w-strong);
}
.apv-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sel-fg);
  font-size: var(--fs-mono);
}
.apv-path {
  color: var(--fg-2);
}
.apv-el {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
  max-width: 45%;
  margin-left: auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--fg-2);
  font-size: var(--t-85);
}
.apv-to {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--fg-2);
  font-size: var(--t-85);
}
.apv-text {
  display: flex;
  gap: var(--sp-2);
  color: var(--sel-fg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.apv-text > .icon {
  flex: none;
  margin-top: var(--sp-half);
  color: var(--fg-2);
}
.apv-shares {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding-left: var(--sp-6);
  color: var(--fg-2);
  font-size: var(--t-85);
}
.apv-lock {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-3) var(--sp-2);
  color: var(--fg-2);
  font-size: var(--t-85);
}
.apv-warn {
  color: color-mix(in srgb, var(--warn) var(--tone-ink), var(--fg));
  font-size: var(--t-85);
}
/* Routine, counting down: the bar drains linearly; Esc stops it. */
.apv-auto {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3) var(--sp-2) var(--sp-8);
  color: var(--fg-2);
  font-size: var(--t-85);
}
/* The Countdown along the row's bottom edge. */
.apv-auto-bar {
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: 0;
}
/* "N more routine requests · Allow all". */
.apv-batch {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 var(--sp-2) var(--sp-2);
  padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3);
  border-top: var(--line) solid var(--hairline);
  color: var(--fg-2);
}
.inbox-main > .apv-batch {
  margin: 0;
}
.apv-batch b {
  font-weight: var(--w-strong);
  color: var(--fg);
}
.apv-batch-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The routine row's "once ▾" token and its little form. */
.apv-scope-pop {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(330px, calc(100vw - 48px));
}
.apv-scope-head {
  display: flex;
  justify-content: space-between;
  color: var(--fg-50);
  font-size: var(--t-85);
}
.apv-scope-rule {
  color: var(--fg-2);
  font-size: var(--t-85);
}

/* What saying yes would do: on the composer's tone inside the card. */
.cmdline,
.plan-text {
  max-height: 20em;
  overflow: auto;
  padding: var(--sp-2);
  border-radius: var(--r-4);
  background: var(--input-bg);
  color: var(--fg);
  font-size: var(--t-85);
}
.cmdline.lines {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}
.prompt {
  color: var(--fg-2);
}
.ask-text {
  white-space: pre-wrap;
  color: var(--fg-2);
  font-size: var(--t-90);
}
.quote {
  padding-left: var(--sp-3);
  border-left: 2px solid var(--border);
  color: var(--fg-2);
  white-space: pre-wrap;
}
.files {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
button.file-row {
  justify-content: flex-start;
  gap: 6px;
  height: 26px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-4);
  background: var(--input-bg);
}
button.file-row:hover {
  background: var(--hover-bg);
}
button.file-row .icon {
  width: 14px;
  height: 14px;
  color: var(--fg-2);
}
.file-row .file-name {
  font-family: var(--mono);
  font-size: var(--t-85);
}
/* An agent's question: a header chip, the question, the options as soft rows with their key inside. */
.fl-card.question {
  gap: var(--sp-2);
  padding: var(--sp-3);
}
.q-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.q-chip {
  max-width: 60%;
}
.q-step {
  margin-left: auto;
  color: var(--fg-2);
  font-size: var(--t-85);
  font-variant-numeric: tabular-nums;
}
.q-question {
  font-weight: 600;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.q-question .md p {
  margin: 0;
}
.q-body {
  display: grid;
  gap: var(--sp-2);
}
.q-body.with-preview {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 700px) {
  .q-body.with-preview {
    grid-template-columns: minmax(0, 1fr);
  }
}
.q-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.q-check .icon {
  width: 14px;
  height: 14px;
}

.q-other {
  padding: 2px 0;
}
.q-input {
  width: 100%;
}
.q-preview {
  min-width: 0;
}
.q-preview pre.code {
  max-height: 16em;
}
.q-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.q-answered {
  font-size: var(--t-90);
}
.question label.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* An answered request, in one muted line. */
.answered {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--sp-1) 0;
  color: var(--fg-2);
  font-size: var(--t-90);
}
.answered > .icon {
  width: 14px;
  height: 14px;
}
.answered:has(> .step-label) {
  flex-wrap: nowrap;
}
.step-label {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-1);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.answered > .step-label {
  flex: 0 1 auto;
}
.answered:has(> .step-label) > :not(.step-label) {
  flex: none;
}
.answered-block {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.answered-files {
  padding-left: 20px;
}

/* Cards in the transcript (plan, changes, notices) are the Card and Banner components; they sit 8 apart. */
.msg-card {
  margin: var(--sp-2) 0;
}
/* A message between chats. */
.link-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: var(--sp-2) 0;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--input-bg);
}
.plan-steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.plan-steps li {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.plan-steps .fl-dot {
  position: relative;
  top: -1px;
}
.plan-steps li[data-state='next'] .step-title {
  color: var(--fg-2);
}
.plan-steps li[data-state='done'] .step-title {
  color: var(--fg-2);
  text-decoration: line-through;
}
.step-title {
  min-width: 0;
  overflow-wrap: anywhere;
}
.notice-detail {
  display: block;
  margin: 0;
  white-space: pre-wrap;
}
.link-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--t-90);
  color: var(--fg-2);
}
.link-head > .icon {
  width: 14px;
  height: 14px;
}
.link-card[data-role^='piped'] .link-head > .icon {
  color: var(--status-working);
}
.link-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--fg);
}
/* Short of room, the time gives way before the title: who was asked or handed to is what the head is for.
   In a side bar the "by agent" pill goes too, whole, never cut in half. */
.link-head > .fl-time {
  flex-shrink: 1000;
  min-width: 0;
}
@media (max-width: 340px) {
  .link-head > .fl-pill {
    display: none;
  }
}
.link-body {
  overflow-wrap: anywhere;
}
.link-body.clamped {
  max-height: 10.5em;
  overflow: hidden;
  mask-image: linear-gradient(black 55%, transparent);
}

/* A command FriedLiver ran: the command line and its output, the tool body's look. */
.command {
  margin: var(--sp-2) 0;
  overflow: hidden;
  border: 0.5px solid var(--border);
  border-radius: var(--r-5);
}
.command[data-failed] {
  border-color: color-mix(in srgb, var(--error) 50%, transparent);
}
.command-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--t-85);
}
code.command-line {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0;
  background: none;
  color: var(--fg);
  font-size: var(--t-100);
}
.output {
  max-height: 220px;
  overflow: auto;
  padding: var(--sp-1) var(--sp-2);
  border-top: 0.5px solid var(--border);
  background: var(--code-bg);
  color: var(--fg-2);
}
/* A message waiting for the turn to end: your message's box, dashed. */
/* A queued message is yours too: the you-zone bubble at the right, dashed until it is sent. */
.bubble.queued {
  position: relative;
  width: fit-content;
  max-width: var(--w-bubble);
  margin: var(--sp-2) 0 var(--sp-2) auto;
  padding: var(--sp-2) var(--sp-4);
  border: 1px dashed var(--zone-prompt-edge);
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble-tail) var(--r-bubble);
  color: var(--fg);
  font-size: var(--t-reply);
  white-space: pre-wrap;
}
.queued-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
}
.queued-bar .tag .icon {
  width: 12px;
  height: 12px;
  margin-right: 2px;
}
/* Cmd/Ctrl + = - 0: the new size, briefly, as a tooltip at the top. */
.text-size-toast {
  position: fixed;
  top: var(--sp-2);
  left: 50%;
  z-index: var(--z-overlay);
  transform: translateX(-50%);
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-6);
  background: var(--menu-bg);
  box-shadow: var(--shadow-tip);
  font-size: var(--t-90);
  pointer-events: none;
  animation: var(--fade-banner);
}

/* ---- Chat tab chrome: recent chats, the header, the list of chats ---- */

.switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--sp-1) var(--sp-2);
  border-bottom: 1px solid var(--border);
  background: var(--zone-shell);
  container: switcher / inline-size;
}
/* Narrow (§2.18): the trailing cluster folds so the open tab keeps its title; the count and the
   Agent Manager are in the All chats popover, "+" stays. */
@container switcher (max-width: 359px) {
  .all-count,
  .switcher > .manager-btn {
    display: none;
  }
}
.tabs {
  display: flex;
  gap: var(--sp-1);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}

button.all-btn {
  width: auto;
  gap: var(--sp-1);
  padding: 0 6px;
}
.all-count {
  font-size: var(--t-85);
}
.chat-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  padding: var(--sp-2) var(--gutter);
  container: chat-head / inline-size;
}
.chat-head-text {
  flex: 1;
  min-width: 0;
}
.chat-head-row {
  display: flex;
  align-items: center;
  /* Room for a working agent's ring between its puck and the chat's name. */
  gap: var(--sp-3);
  min-width: 0;
}
/* The chat's name (§2.34): 13/600 in a side bar; on a wide page the page title, 20/600, tracked in. */
/* The chat's name is the page's heading; the h1 only carries the semantics, the button inside draws it. */
.chat-head-h {
  display: flex;
  min-width: 0;
  font-size: inherit;
  font-weight: inherit;
}
button.chat-head-title {
  display: block;
  min-width: 0;
  margin-left: calc(var(--sp-1) * -1);
  padding: var(--sp-half) var(--sp-1);
  border-radius: var(--r-ctl);
  font-weight: var(--w-strong);
  color: var(--sel-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@container chat-head (min-width: 720px) {
  button.chat-head-title {
    font-size: var(--t-hero);
    letter-spacing: var(--track-title);
    line-height: var(--lh-tight);
  }
}
@media (min-width: 720px) {
  .chat-head {
    padding-top: var(--sp-4);
  }
}
button.chat-head-title:hover {
  background: var(--hover-bg);
}
.status-pill {
  flex: none;
}
.status-pill .fl-dot {
  --dot: 10px;
  margin-right: var(--sp-1);
}
/* A side bar: the status keeps its shape and gives its words' room to the chat's name (the tab and the
   pill's tooltip still say it). */
@container chat-head (max-width: 340px) {
  .status-pill .status-words {
    display: none;
  }
  .status-pill .fl-dot {
    margin-right: 0;
  }
}
/* Accept all and Reject all stay side by side, and wrap under the words together. */
.edits-actions {
  display: inline-flex;
  flex: none;
  gap: var(--sp-2);
}
.chat-head-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-half);
}
button[aria-pressed='true'] .icon path {
  fill: currentColor;
}

.chat-head-row > .pop {
  display: inline-flex;
  min-width: 0;
}
@media (max-width: 720px) {
  .chat-head .branch-chip {
    display: none;
  }
}

.origin-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  margin: 0 var(--gutter) var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-6);
  background: var(--input-bg);
  color: var(--fg-2);
  font-size: var(--t-90);
  white-space: nowrap;
}
.origin-banner > .icon {
  width: 14px;
  height: 14px;
}
.origin-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding: 0 var(--gutter) var(--sp-2);
}
/* "In this chat": your messages, beside a wide transcript. */
.transcript-wrap[data-jump] .transcript {
  padding-right: 250px;
}
.transcript-wrap[data-jump] .sticky-prompt {
  right: 250px;
}
.jump-list {
  position: absolute;
  top: var(--sp-5);
  right: var(--sp-5);
  width: 210px;
  max-height: calc(100% - var(--sp-10));
  overflow-y: auto;
  font-size: var(--t-90);
  color: var(--fg-2);
}
/* In the context rail: a section like the others. */
.jump-list[data-rail] {
  position: static;
  width: auto;
  max-height: none;
  overflow: visible;
}
.ctx-jump:empty {
  display: none;
}
.jump-list b {
  display: block;
  margin-bottom: var(--sp-2);
  font-weight: var(--w-strong);
  color: var(--fg);
}
/* In the context rail its name is a details-zone eyebrow, like the rail's other section names. */
.ctx-rail .jump-list b {
  margin-bottom: var(--sp-3);
  color: var(--fg-2);
  font-size: var(--t-eyebrow);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}
button.jump-item {
  display: block;
  width: 100%;
  padding: var(--sp-1) var(--sp-2);
  border-left: 2px solid var(--hairline);
  color: var(--fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.jump-item:hover {
  color: var(--fg);
}
button.jump-item[aria-current='true'] {
  border-left-color: var(--sel-fg);
  color: var(--sel-fg);
}
@media (max-width: 1200px) {
  .transcript-wrap[data-jump] .transcript {
    padding-right: var(--gutter);
  }
  .transcript-wrap[data-jump] .sticky-prompt {
    right: var(--gutter);
  }
  .jump-list {
    display: none;
  }
}
/* No chat yet: one per agent. */
/* §2.26: unboxed and start-aligned, the whole width; the mark beside the heading. */
.empty {
  padding: var(--sp-5) var(--gutter);
  color: var(--fg-2);
  text-align: start;
}
.empty-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.empty-head .empty-mark {
  margin: 0;
}
.empty h2 {
  margin: 0;
  font-size: var(--t-title);
  font-weight: 600;
  color: var(--fg);
}
/* The agent cards: across the width, one size, the glyphs on one line (a note doesn't push its card's up). */
.pick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-2);
  margin: var(--sp-4) 0;
}
button.pick-agent {
  position: relative;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  text-align: start;
  /* Room at the bottom of every card for Demo's note, so it never sits on the name and the glyphs stay in line. */
  padding: var(--sp-4) var(--sp-3) calc(var(--sp-2) + 1.3em);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--input-bg);
  color: var(--fg);
}
button.pick-agent:hover {
  background: linear-gradient(var(--hover-bg), var(--hover-bg)), var(--input-bg);
}
.pick-agent .hint {
  font-size: var(--t-85);
}
.pick-agent .pick-note {
  position: absolute;
  bottom: var(--sp-2);
  left: var(--sp-3);
  right: var(--sp-3);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* A fresh chat's first messages to pick from, over the composer. */
.starters {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
  padding: 0 var(--sp-1) var(--sp-3);
}
button.starter {
  height: auto;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: none;
  color: var(--fg);
  text-align: left;
}
button.starter:hover {
  background: var(--hover-bg);
}
.starter-keys {
  margin: var(--sp-2) 0 0;
  font-size: var(--t-85);
}
.chat-item-time {
  flex: none;
  color: var(--fg-2);
  font-size: var(--t-85);
  font-variant-numeric: tabular-nums;
}
.chat-item:hover .chat-item-time,
.chat-item[aria-selected='true'] .chat-item-time {
  display: none;
}
.reopen {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: min(480px, 100%);
  margin: var(--sp-5) auto 0;
  text-align: left;
}
.reopen .fl-menu__title {
  margin: 0 0 var(--sp-1);
  padding: 0 var(--sp-3);
}
button.reopen-row {
  justify-content: flex-start;
  height: auto;
  border: 0;
  background: none;
  color: var(--fg);
}

/* The list of chats (its own side bar view, and All chats in a tab): menu rows on the side bar. */
.all-chats {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  width: min(380px, calc(100vw - 40px));
}
.fl-menu:has(.all-chats) {
  padding: var(--sp-2);
}
.all-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(440px, 62vh);
  overflow-y: auto;
}
.chat-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-side.chat-list-view {
  height: 100vh;
  padding: var(--sp-2);
}
.chat-side .all-chats {
  flex: 1;
  width: auto;
  min-height: 0;
}
.chat-side .all-list {
  flex: 1;
  max-height: none;
}
.chat-side .pop-foot {
  margin-top: auto;
}
button.new-chat {
  justify-content: space-between;
  height: 28px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-ctl);
  background: none;
  color: var(--fg);
}
button.new-chat:hover {
  background: var(--hover-bg);
}
button.new-chat > span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
button.new-chat kbd {
  font-size: var(--t-85);
}
.all-chats .pop-group {
  margin-top: var(--sp-2);
}
.all-chats .pop-group .icon {
  width: 14px;
  height: 14px;
}
.pick-row.chat-item {
  margin: 0;
  padding: var(--sp-1) var(--sp-2);
}
.chat-item-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.pick-row.chat-item[data-open] {
  color: var(--sel-fg);
  background: var(--sel-bg);
}
.chat-item-more {
  visibility: hidden;
}
.chat-item:hover .chat-item-more,
.chat-item[aria-selected='true'] .chat-item-more,
.chat-item-more:focus-within {
  visibility: visible;
}

/* Motion is a hint, never the only signal: everything still reads without it. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
/* Manage Permissions (permissions.tsx): the whole width, one table per kind. */
/* The page's own inset and title are the Agent Manager's and Agents & Accounts' (§2.35). */
.perms {
  padding: var(--sp-5) var(--gutter) var(--sp-8);
}
.perms-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.perms h1 {
  margin: 0 0 var(--sp-1);
  font-size: var(--t-hero);
  font-weight: var(--w-strong);
  letter-spacing: var(--track-title);
  line-height: var(--lh-tight);
  color: var(--sel-fg);
}
.perms h2 {
  margin: var(--sp-6) 0 2px;
  font-size: var(--t-100);
  font-weight: var(--w-strong);
  color: var(--sel-fg);
}
.perms .hint {
  margin: 0;
}
.perms p.hint {
  max-width: var(--w-prose);
  text-wrap: pretty;
}
.perms table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  /* The same columns in every group, so the tables line up. */
  table-layout: fixed;
}
/* "Asked by" takes what is left: enough for an agent's name on one line at half an editor's width. */
.perms th:nth-child(1) {
  width: 24%;
}
.perms th:nth-child(2) {
  width: 33%;
}
.perms th:nth-child(3) {
  width: 17%;
}
.perms th:nth-child(5) {
  width: 84px;
}
.perms th {
  text-align: left;
  font-weight: normal;
  white-space: nowrap;
  color: var(--fg-2);
  padding: 4px 12px 4px 0;
  border-bottom: 1px solid var(--border);
}
.perms td {
  padding: 7px 12px 7px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.perms tr:hover td {
  background: var(--hover-bg);
}
.perms td.scope {
  word-break: break-all;
}
.perms td.act {
  text-align: right;
  padding-right: 0;
}
.perms td.scope .hint {
  font-family: var(--font);
  /* A path may break anywhere; the words after it may not. */
  word-break: normal;
}
/* Too narrow for five columns: each rule is a block (what it allows, where, then when and who asked) with Revoke beside it. */
@media (max-width: 640px) {
  .perms thead {
    display: none;
  }
  .perms table,
  .perms tbody {
    display: block;
  }
  .perms tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--sp-half) var(--sp-2);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--border);
  }
  .perms td {
    grid-column: 1 / 3;
    padding: 0;
    border: 0;
  }
  .perms td:nth-child(3) {
    grid-column: 1;
  }
  .perms td:nth-child(4) {
    grid-column: 2;
    color: var(--fg-2);
  }
  .perms td.act {
    grid-column: 3;
    grid-row: 1 / 4;
    align-self: center;
  }
}
.perms .empty {
  margin-top: 24px;
}
/* What "Always allow" on a browser or agent-tool request would remember. */
.always-scope {
  color: var(--fg-2);
  font-size: 0.92em;
}

/* ---- Sign-in marks: an agent's last known sign-in, in pickers and on Agents & Accounts ---- */

.signin-mark {
  flex: none;
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: var(--r-round);
  background: var(--dot-idle);
  vertical-align: middle;
}
.signin-mark[data-state='signed-in'] {
  background: var(--status-done);
}
.signin-mark[data-state='needs-sign-in'] {
  background: var(--status-waiting);
}
.signin-mark[data-state='error'] {
  background: var(--status-failed);
}
.signin-mark[data-state='not-installed'],
.signin-mark[data-state='unknown'] {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--fg-2);
}
.signin-mark[data-state='checking'] {
  background: var(--status-working);
  animation: blink 1s linear infinite;
}

/* ---- Agents & Accounts ---- */

/* The whole width (no centred column), the chat's gutter. */
.acct-page {
  height: 100%;
  overflow: auto;
  padding: var(--sp-5) var(--gutter);
}
.acct-head h1 {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--t-hero);
  font-weight: var(--w-strong);
  letter-spacing: var(--track-title);
  color: var(--sel-fg);
}
/* The mark over an empty state (§2.26: the 40 line mark). */
.empty-mark {
  display: block;
  margin-bottom: var(--sp-2);
}
.acct-head p {
  margin: var(--sp-1) 0 var(--sp-4);
  max-width: var(--w-prose);
  text-wrap: pretty;
}
.acct-card {
  margin-bottom: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--input-bg);
  scroll-margin-top: var(--sp-3);
}
/* "Open links in": a setting row on the page's own card style, the choice as a segmented control. */
.acct-links-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.acct-links h2 {
  font-size: var(--t-100);
  font-weight: 600;
  color: var(--sel-fg);
}
.acct-links .hint {
  margin: 2px 0 0;
  max-width: var(--w-prose);
  text-wrap: pretty;
}
.acct-card[data-focused] {
  border-color: var(--focus);
}
.acct-top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
/* A card with many buttons (a custom agent: Check, Edit, Remove) in a narrow page: the name keeps a readable
   width and the status and buttons wrap under it, none past the card's edge. */
.acct-top {
  flex-wrap: wrap;
  row-gap: var(--sp-2);
}
.acct-top > .grow {
  flex-basis: 9em;
}
.acct-top h2 {
  font-size: var(--t-100);
  font-weight: 600;
  color: var(--sel-fg);
}
.acct-version {
  font-weight: 400;
  font-size: var(--t-85);
}
.acct-active {
  font-size: var(--t-90);
  overflow-wrap: anywhere;
}
.acct-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-90);
  white-space: nowrap;
}
.acct-status[data-state='needs-sign-in'] {
  color: var(--status-waiting);
}
.acct-status[data-state='error'] {
  color: var(--error);
}
.acct-when {
  margin: 2px 0 0 calc(32px + var(--sp-3));
  font-size: var(--t-80);
}
.acct-note {
  margin-top: var(--sp-2);
  font-size: var(--t-90);
  overflow-wrap: anywhere;
}
.acct-block {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.acct-block h3 {
  margin-bottom: var(--sp-2);
  font-size: var(--t-85);
  font-weight: 600;
  color: var(--fg-2);
}
.acct-block p {
  margin: var(--sp-1) 0 0;
  max-width: var(--w-prose);
  text-wrap: pretty;
}
.acct-kind {
  font-size: var(--t-85);
  color: var(--fg-2);
}
.acct-key {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-6);
}
.acct-key[data-active] {
  border-color: var(--status-done);
}
.acct-key .icon {
  vertical-align: -2px;
}
.acct-tag {
  margin-left: var(--sp-2);
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--pill-bg);
  font-size: var(--t-80);
}
.acct-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--sp-3);
  font-size: var(--t-80);
}
.acct-cli {
  margin-top: var(--sp-2);
}
.acct-line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
}
.acct-models {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
}
.acct-choice {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.acct-choice .fl-select {
  max-width: 260px;
}
.acct-foot {
  padding: var(--sp-2) 0 var(--sp-5);
}
/* "Add an agent": the button row, and the form (a card like the others; fields in as many columns as fit). */
.acct-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.acct-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--sp-3) var(--sp-4);
}
.acct-env {
  align-items: center;
}
.acct-env .fl-input:first-child {
  flex: 0 0 min(40%, 240px);
}
.acct-example {
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-6);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: var(--t-85);
}
.acct-form .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

/* ---- Decision Inbox: the queue on the left, what answering does on the right (webview/inbox.tsx) ---- */

.mgr-view[data-view='inbox'] {
  flex: 1;
  min-height: 0;
}
.inbox {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 36%) minmax(0, 1fr);
  gap: var(--sp-4);
}
/* The queue: a menu's surface; one group per chat under a section header, rows inset 4 (r4 in r8). */
.inbox-list,
.inbox-history ul {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 6px 0 4px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--menu-bg);
  outline: none;
}
.inbox-list:focus-visible {
  border-color: var(--focus);
}
/* Risk lanes: Careful, Review, Routine, each under a header with its dot and count. */
.inbox-lane + .inbox-lane {
  margin-top: var(--sp-1);
  padding-top: var(--sp-1);
  border-top: 1px solid var(--border);
}
.inbox-lane-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--t-85);
  font-weight: var(--w-strong);
  color: var(--fg-2);
}
.inbox-lane-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-round);
  background: var(--fg-50);
}
.inbox-lane[data-tone='careful'] .inbox-lane-dot {
  background: var(--error);
}
.inbox-lane[data-tone='review'] .inbox-lane-dot {
  background: var(--warn);
}
.inbox-lane-head .col-count {
  margin-left: auto;
}
.inbox-chat {
  flex: 0 1 auto;
  max-width: 40%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-50);
  font-size: var(--t-85);
}
.inbox-row[aria-selected='true'] .inbox-chat {
  color: var(--sel-fg);
  opacity: 0.7;
}
.inbox-row,
button.inbox-history-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  max-height: 40px;
  min-height: 28px;
  margin: 2px var(--sp-1) 0;
  padding: var(--sp-1) var(--sp-2);
  border: 0;
  border-radius: var(--r-4);
  color: var(--fg);
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
button.inbox-history-row {
  width: calc(100% - 2 * var(--sp-1));
  height: auto;
  justify-content: flex-start;
  font: inherit;
  text-align: left;
}
.inbox-row:hover,
button.inbox-history-row:hover:not(:disabled) {
  background: var(--hover-bg);
}
.inbox-row[aria-selected='true'] {
  color: var(--sel-fg);
  background: var(--sel-bg);
}
.inbox-row[aria-selected='true'] .inbox-kind,
.inbox-row[aria-selected='true'] .inbox-age {
  color: var(--sel-fg);
}
.inbox-kind {
  flex: none;
  display: inline-flex;
  color: var(--fg-2);
}
.inbox-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-age {
  flex: none;
  font-size: var(--t-85);
  color: var(--fg-2);
}
/* Answered: the row folds away. */
.inbox-row[data-leaving] {
  pointer-events: none;
  animation: inbox-leave 0.2s ease-in forwards;
}
@keyframes inbox-leave {
  to {
    max-height: 0;
    min-height: 0;
    margin-top: 0;
    padding-block: 0;
    opacity: 0;
  }
}

/* The selected request: its own card (the chat's), with "Or tell … instead" beside it. */
.inbox-detail {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--bg);
}
.inbox-detail-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.inbox-detail-head .inbox-kind {
  color: var(--fg-2);
}
.inbox-detail-head .inbox-kind[data-tone='careful'] {
  color: var(--error);
}
.inbox-detail-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-title);
  font-weight: 600;
  line-height: 1.3;
  color: var(--sel-fg);
}
.inbox-open {
  color: var(--link);
}
.inbox-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  color: var(--fg-2);
}
.inbox-meta .sep {
  color: var(--fg-50);
}
.inbox-meta-topic {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-timeout {
  color: var(--warn);
}
.inbox-detail {
  container-type: inline-size;
}
/* The reply under the card; beside it (C's decision rail) once the pane is wide. */
.inbox-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--sp-3);
}
@container (min-width: 860px) {
  .inbox-body:has(.inbox-reply) {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--sp-4);
  }
}
.inbox-main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.inbox-main > .fl-card.apv {
  margin: 0;
}
.inbox-reply {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-8);
  /* The card tone, so the Textarea's field tone stands off it. */
  background: var(--menu-bg);
}
.inbox-reply-label {
  color: var(--fg-50);
  font-size: var(--t-85);
}
.inbox-reply .fl-btn {
  align-self: stretch;
}
.inbox-question .q-question,
.inbox-question .q-options,
.inbox-question .q-foot {
  padding: 0 var(--sp-3);
}
.inbox-question {
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
}
.inbox-confirm {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--input-bg);
}
.inbox-confirm-head {
  font-weight: 600;
  color: var(--sel-fg);
}
.inbox-confirm-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--t-90);
}
.inbox-confirm-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.inbox-confirm-chat,
.inbox-confirm-where {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-confirm-where {
  flex: 1;
}
.inbox-confirm-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
/* One short line of key hints at the foot. */
.inbox-keys {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-top: auto;
  padding-top: var(--sp-2);
  color: var(--fg-50);
  font-size: var(--t-85);
}
.inbox-key {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  white-space: nowrap;
}

/* Nothing waits: say so, and what was answered lately (history only). */
.inbox-empty {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.inbox-empty-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--menu-bg);
}
.inbox-empty-head > .icon {
  flex: none;
  color: var(--tl-success);
}
.inbox-empty-head h2 {
  font-size: var(--t-title);
  font-weight: 600;
  line-height: 1.2;
  color: var(--fg);
}
.inbox-empty-head p {
  margin: var(--sp-1) 0 0;
}
.inbox-history h3 {
  padding: 0 var(--sp-3) var(--sp-2);
  font-size: var(--t-90);
  font-weight: 400;
  color: var(--fg-50);
}
.inbox-history > p {
  padding: 0 var(--sp-3);
}
.inbox-outcome {
  flex: none;
  display: inline-flex;
  color: var(--error);
}
.inbox-outcome[data-allowed] {
  color: var(--tl-success);
}
.inbox-history-outcome {
  flex: none;
  max-width: 30%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-2);
}
.inbox-history-topic {
  flex: none;
  max-width: 28%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-85);
  color: var(--fg-50);
}

/* The count beside Inbox, in the view switch and the chat list: the decision colour while something waits. */
.seg-count {
  color: inherit;
}
button.seg-item[aria-selected='true'] .seg-count {
  color: inherit;
}
button.inbox-entry[data-waiting] {
  color: var(--decision);
}

/* Narrow: the queue above, what answering does below; the reply under the card. */
@media (max-width: 720px) {
  .inbox {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(96px, 36%) minmax(0, 1fr);
  }
  .inbox-detail {
    padding: var(--sp-3) var(--sp-4);
  }

  .inbox-history-topic {
    display: none;
  }
}

/* ---- Welcome (§2.38, webview/welcome.tsx): the hero, the Ask box, two columns; the whole width ---- */

body[data-surface='welcome'] {
  background: var(--bg);
}
.welcome {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  height: 100%;
  overflow-y: auto;
  padding: var(--sp-8);
}
.wl-hero {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
}
.wl-mark {
  flex: none;
  width: var(--sp-12);
  height: var(--sp-12);
  color: var(--brand);
}
.wl-hello h1 {
  margin: 0;
  color: var(--sel-fg);
  font-size: var(--t-display);
  font-weight: var(--w-strong);
  letter-spacing: var(--track-display);
  line-height: var(--lh-tight);
}
.wl-hello p {
  margin: var(--sp-1) 0 0;
  color: var(--fg-2);
  font-size: var(--t-lg);
}
.wl-grow {
  flex: 1;
}
.wl-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: var(--sp-8);
}
@media (max-width: 900px) {
  .welcome {
    padding: var(--sp-4);
  }
  .wl-cols {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-6);
  }
}
.wl-col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  min-width: 0;
}
.wl-col > section {
  display: flex;
  flex-direction: column;
}
.wl-h {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-2);
  color: var(--fg);
  font-size: var(--t-100);
  font-weight: var(--w-strong);
}
/* Rows 40 with hairline rules (§2.38). */
.wl-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--h-xl);
  padding: 0 var(--sp-2);
  border-radius: var(--r-row);
  color: var(--fg);
  text-align: left;
}
.wl-row + .wl-row {
  border-top: var(--line) solid var(--hairline);
}
.wl-who {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.wl-row > .icon {
  flex: none;
  color: var(--fg-2);
}
.wl-name {
  flex: none;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sel-fg);
  font-weight: var(--w-medium);
}
.wl-sub {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-2);
  font-size: var(--t-90);
}
.wl-meta {
  flex: none;
  color: var(--fg-2);
  font-size: var(--t-85);
  font-variant-numeric: tabular-nums;
}
.wl-live {
  min-height: var(--h-touch);
}
.wl-two {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.wl-two b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sel-fg);
  font-weight: var(--w-medium);
}
.wl-two span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-2);
  font-size: var(--t-85);
}
.wl-bar {
  display: block;
  width: 72px;
}
.wl-agents {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3) var(--sp-6);
}
.wl-agent .wl-two b {
  color: var(--sel-fg);
  font-weight: var(--w-medium);
}
.wl-empty {
  margin: 0;
  padding: var(--sp-2);
  color: var(--fg-2);
  font-size: var(--t-90);
}
/* First run (V17): the agents 2×2 with their sign-in and a Connect action, the demo agent, and what happens next. */
.wl-agents > .wl-tile {
  flex-direction: row;
  align-items: center;
  gap: var(--sp-3);
}
@media (max-width: 600px) {
  .wl-first .wl-agents {
    grid-template-columns: minmax(0, 1fr);
  }
}
.wl-col > .wl-demo {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
}
.wl-demo .wl-empty {
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
}
.wl-steps {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wl-keys {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin: auto 0 0;
  color: var(--fg-2);
  font-size: var(--t-85);
}
