/* Loomcycle UI — dashboard styling. Themeable (light/dark) via the design
   tokens in tokens.css (imported first in main.tsx): the --bg / --fg / --accent
   / --border / … names used throughout this file are aliases of the themed
   --lc-* tokens, so this file follows the active theme for free. New rules
   should prefer the --lc-* tokens directly. */

* {
  box-sizing: border-box;
}
html, body, #root {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--lc-font-body);
  font-size: 14px;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Display font for headings (design-system: Outfit). Sizes are left to the
   existing per-component rules — the dense console keeps its scale. */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--lc-font-display);
}
a {
  color: var(--lc-link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
code, pre {
  font-family: var(--mono);
  font-size: 13px;
}
pre {
  margin: 4px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Homogeneous form controls (themed).
 * <input>/<textarea>/<select> don't inherit font or colors from <body>, so an
 * unstyled field falls back to the UA default. This base gives every text-like
 * control the same look as the topbar fields, themed via the design tokens.
 * :where() keeps the selector at element specificity (0,0,1) so any component
 * rule still wins; checkboxes / radios / file / range / color stay native. */
input,
textarea,
select {
  font-family: var(--lc-font-mono);
}
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"])),
textarea,
select {
  background: var(--lc-input-bg);
  color: var(--lc-text);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  padding: 6px 8px;
  font-size: var(--lc-text-sm);
}
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"])):focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--lc-accent);
}
input::placeholder,
textarea::placeholder {
  color: var(--lc-text-faint);
}

/* Topbar theme toggle (sun/moon). Quiet icon button matching the topbar. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  background: transparent;
  color: var(--lc-text-muted);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  cursor: pointer;
  padding: 0;
}
.theme-toggle:hover {
  color: var(--lc-text);
  border-color: var(--lc-accent);
}

.layout {
  display: flex;
  flex-direction: row;
  height: 100%;
}
/* main-col owns the old flex-column role so .content stays a flex child with
   a definite height. min-height:0 is load-bearing: it lets the column shrink
   to the viewport so .content's overflow:auto engages instead of the page
   growing (the Splitter-based views depend on this). */
.main-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}
.brand a {
  color: var(--fg);
  display: inline-flex;
  align-items: center;
}
/* loomcycle wordmark (web/public/loomcycle-logo.svg). Fixed height, intrinsic
   aspect ratio (1344×300); the SVG already carries the dark-theme wordmark
   colour so no filter is applied. */
.brand-logo {
  display: block;
  height: 22px;
  width: auto;
}
.version {
  color: var(--fg-soft);
  font-size: 12px;
  font-family: var(--mono);
}
.user-picker {
  display: flex;
  gap: 8px;
  align-items: center;
}
.user-picker label {
  color: var(--fg-soft);
  font-size: 12px;
}
.user-picker select,
.user-picker input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 13px;
  min-width: 280px;
}
.user-picker form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.user-picker button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
}
.user-picker button.manual-btn {
  background: transparent;
  color: var(--fg-soft);
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: 12px;
}
.user-picker button.manual-btn:hover {
  color: var(--fg);
  border-color: var(--accent);
}
.picker-err {
  color: var(--failed);
  font-size: 11px;
  font-style: italic;
}

/* Left-sidebar navigation. Collapsed = icons only (52px); expanded = icons +
   labels (200px). Replaces the old horizontal .nav-tabs strip. */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  transition: width 120ms ease;
  overflow: hidden;
}
.sidebar-collapsed {
  width: 52px;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  flex: 1;
  overflow-y: auto;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--fg-soft);
  font-size: 13px;
  white-space: nowrap;
}
.sidebar-nav a:hover {
  color: var(--fg);
  background: var(--bg-soft-2);
  text-decoration: none;
}
.sidebar-nav a.active {
  color: var(--fg);
  background: var(--bg-soft-2);
  font-weight: 600;
}
.sidebar-icon {
  flex-shrink: 0;
}
.sidebar-nav a.active .sidebar-icon {
  color: var(--accent);
}
.sidebar-collapsed .sidebar-label {
  display: none;
}
.sidebar-collapsed .sidebar-nav a {
  justify-content: center;
  padding: 8px 0;
}
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--fg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.sidebar-toggle:hover {
  color: var(--fg);
  border-color: var(--accent);
}
.sidebar-collapsed .sidebar-toggle {
  justify-content: center;
  padding: 8px 0;
}

.content {
  flex: 1;
  overflow: auto;
  padding: 16px;
}
.empty {
  color: var(--fg-soft);
  padding: 32px 16px;
  text-align: center;
}
.err {
  background: rgba(255, 93, 104, 0.1);
  border: 1px solid var(--failed);
  color: var(--failed);
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12px;
}

/* run list */
.run-list .toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.filter {
  display: flex;
  gap: 4px;
}
.filter button {
  background: var(--bg-soft);
  color: var(--fg-soft);
  border: 1px solid var(--border);
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  border-radius: 3px;
}
.filter button.on {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.meta {
  color: var(--fg-soft);
  font-size: 12px;
  display: flex;
  gap: 12px;
}
.spin {
  font-style: italic;
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree .children {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px dashed var(--border);
  margin-left: 14px;
  padding-left: 12px;
}
.node {
  margin: 2px 0;
}
.node .row {
  display: grid;
  /* col 2 is `auto` (not a fixed pill width) so the status + interactive
   * badges share one cell sized to their content — otherwise the extra
   * interactive pill takes its own grid track and shoves the agent name
   * (the 1fr column) far to the right. See .row-badges below. */
  grid-template-columns: 14px auto 1fr 200px 120px auto;
  gap: 12px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
}
/* Status pill + the optional `interactive` pill live in a single grid cell
 * so the agent name stays in the 1fr column directly after the badges. */
.row-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.tree-caret {
  background: transparent;
  border: none;
  color: var(--fg-soft);
  cursor: pointer;
  width: 14px;
  height: 14px;
  font-size: 10px;
  padding: 0;
  user-select: none;
  line-height: 1;
}
.tree-caret:disabled {
  cursor: default;
  opacity: 0.35;
}
.tree-caret:hover:not(:disabled) {
  color: var(--accent);
}

/* Breadcrumbs (v0.8.20 Web UI refactor) replace the standalone
 * "← runs" link on the agent detail. Shows ancestor chain from
 * root down to the selected agent. */
.crumbs-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.crumb-link {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
  text-decoration: none;
}
.crumb-link:hover { text-decoration: underline; }
.crumb-orphan {
  color: var(--fg-soft);
  font-family: var(--mono);
}
.crumb-sep {
  color: var(--fg-soft);
  margin: 0 4px;
  user-select: none;
}
.crumb-current {
  color: var(--fg);
  font-weight: 600;
}
.crumb-home {
  font-family: var(--mono);
  font-size: 11px;
}

/* Split agents view (v0.8.20). Two side-by-side panels: tree on
 * the left, selected agent's detail on the right. Both fill the
 * available height of the .content area; each has its own
 * internal scroll so headers stay sticky. */
.agents-view {
  /* Layout (grid-template-columns + gap) comes from .splitter. The
   * old static rules are retained for any non-splitter consumer
   * that still expects the visual styling. */
  height: 100%;
  min-height: 0;
}
.agents-view .left,
.agents-view .right {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  flex: 1;
}
.agents-tree-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.agents-tree-panel .toolbar {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.agents-tree-panel .tree-scroll {
  flex: 1;
  overflow: auto;
  padding: 8px 10px;
  min-height: 0;
}
.agents-view .right > .agent-detail {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 0 14px 14px;
}
.agents-view .right > .empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Tighten the tree row layout inside the narrow left pane — the
 * 80px / 200px / 120px columns from the standalone tree don't fit
 * a 420px panel. Drop model + time to single-line truncated. */
.agents-view .node .row {
  /* Status pill column = `auto` (grid sizes to widest content
   * across rows so all pills align). The pill has min-width 70px
   * but COMPLETED/CANCELLED naturally render ~84px; a fixed
   * column at 70px causes the pill to overflow into the agent
   * name. */
  grid-template-columns: 14px auto 1fr 80px;
  gap: 8px;
  padding: 5px 7px;
  font-size: 12px;
}
.agents-view .node .row .model,
.agents-view .node .row .error-flag {
  display: none;
}
.agents-view .node .row .time {
  text-align: right;
  color: var(--fg-soft);
  font-size: 11px;
  white-space: nowrap;
}
.agents-view .node.selected > .row {
  background: var(--bg-soft-2);
  border-left: 2px solid var(--accent);
}
.agents-view .agent-link {
  background: transparent;
  border: none;
  color: inherit;
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.agents-view .agent-link:hover strong {
  color: var(--accent);
}

/* View toggle (panels | terminal) sits between the breadcrumb
 * bar and the transcript body. Reuses .scope-tabs button styling. */
.view-toggle {
  padding: 6px 0 10px;
  margin-bottom: 8px;
}

/* Terminal transcript — log-tail-style monospace stream. Used when
 * ?view=terminal. Tight rows; auto-tails on new events when the
 * operator is already near the bottom. */
.terminal-transcript {
  background: #0a0c10;
  color: #c8cdd6;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  height: calc(100vh - 280px);
  overflow: auto;
  margin: 0;
}
.tl-row {
  display: grid;
  grid-template-columns: 110px 110px 12px 1fr;
  column-gap: 8px;
  align-items: start;
  padding: 1px 0;
}
.tl-ts {
  color: var(--fg-soft);
  font-variant-numeric: tabular-nums;
  white-space: pre;
}
.tl-kind {
  color: var(--fg-soft);
  text-transform: lowercase;
  white-space: pre;
}
.tl-sep {
  color: var(--fg-soft);
  text-align: center;
}
.tl-payload {
  white-space: pre-wrap;
  word-break: break-word;
}
.tl-row.tl-error .tl-payload,
.tl-row.tl-error .tl-kind {
  color: var(--failed);
}
.tl-row.tl-tool .tl-payload,
.tl-row.tl-tool .tl-kind {
  color: var(--accent);
}
.tl-row.tl-result .tl-payload {
  color: var(--completed);
}
.tl-row.tl-done .tl-payload {
  color: var(--cancelled);
}
.tl-row.tl-meta .tl-payload,
.tl-row.tl-meta .tl-kind {
  color: var(--fg-soft);
  opacity: 0.75;
}
.tl-row.tl-interrupt .tl-payload,
.tl-row.tl-interrupt .tl-kind {
  color: #fbbf24;
}
.tl-row.tl-steer .tl-payload,
.tl-row.tl-steer .tl-kind {
  color: var(--accent);
  font-weight: 600;
}
/* tl-user: the operator's OWN message echoed into the transcript ("❯ …").
   Distinct from the agent's text and from a drained `steer` frame. */
.tl-row.tl-user .tl-payload,
.tl-row.tl-user .tl-kind {
  color: var(--accent);
  font-weight: 600;
}
.tl-row.tl-user .tl-payload {
  white-space: pre-wrap;
}
/* Collapsible rows (tool results): the whole row is a click target that
   toggles between the one-line summary and the full output. */
.tl-row.tl-collapsible {
  cursor: pointer;
}
.tl-row.tl-collapsible:hover .tl-caret {
  color: var(--fg);
}
.tl-caret {
  color: var(--fg-soft);
  display: inline-block;
  width: 1em;
  font-size: 10px;
  user-select: none;
}
/* Expanded full output spans all grid columns on its own row. */
.tl-detail {
  grid-column: 1 / -1;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 2px 0 4px;
  cursor: text;
  color: var(--completed);
}
.tl-row.tl-collapsible.tl-error .tl-detail {
  color: var(--failed);
}
.agent-link {
  display: flex;
  gap: 8px;
  align-items: baseline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-id {
  color: var(--fg-soft);
}
.model {
  color: var(--fg-soft);
  font-size: 12px;
}
.replica {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  color: #222;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}
.time {
  color: var(--fg-soft);
  font-size: 12px;
  text-align: right;
}
.error-flag {
  color: var(--failed);
  font-size: 11px;
  text-transform: uppercase;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  min-width: 70px;
  font-weight: 600;
}
.pill.running { background: rgba(240, 160, 64, 0.2); color: var(--running); }
.pill.completed { background: rgba(78, 201, 176, 0.2); color: var(--completed); }
.pill.failed { background: rgba(255, 93, 104, 0.2); color: var(--failed); }
.pill.cancelled { background: rgba(176, 139, 208, 0.2); color: var(--cancelled); }

/* agent detail */
.crumbs {
  margin-bottom: 12px;
}
.agent-header {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 12px;
}
.agent-header .line1 {
  display: flex;
  align-items: center;
  gap: 12px;
}
.agent-header .line-await {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-header .line2 {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--fg-soft);
}

/* v0.8.21 awaited-state row tint — applied to running rows in the
 * agents tree so the operator can scan the tree and see at a glance
 * which agents are progressing vs. blocked. Colours mirror the
 * detail-pane chip (.await-chip-*) using lower-alpha fills so the
 * tint never overpowers the row content. The `.row` selector keeps
 * children rows (.children) un-tinted — only the immediate row
 * paints, since children inherit their own state via their own
 * tint class. */
.node.await-running > .row {
  background-color: rgba(110, 231, 163, 0.08);
  border-left: 3px solid #2a5a3a;
}
.node.await-channel > .row {
  background-color: rgba(255, 183, 102, 0.12);
  border-left: 3px solid #b97a30;
}
.node.await-interrupted > .row {
  background-color: rgba(201, 168, 255, 0.13);
  border-left: 3px solid #6b50b8;
}
/* Selected outranks the tint border so the operator can still tell
 * which row is currently open in the detail pane. */
.node.selected > .row {
  border-left-color: var(--accent);
}

/* v0.8.21 awaited-state chip — small pill that says what the
 * running agent is blocked on (a Channel.subscribe long-poll, a
 * pending Interruption, or none → plain "running"). Colours follow
 * the operator's mental model: green = healthy/active, orange =
 * waiting on inter-agent comms, violet = waiting on a human. */
.await-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-family: var(--mono);
  line-height: 1.4;
  border: 1px solid transparent;
}
.await-chip code {
  font-size: 11px;
  background: transparent;
  color: inherit;
}
.await-chip-running {
  background: #1a3a26;
  color: #6ee7a3;
  border-color: #2a5a3a;
}
.await-chip-channel {
  background: #3a2a14;
  color: #ffb766;
  border-color: #5a3a1e;
}
.await-chip-interrupted {
  background: #2a1f3a;
  color: #c9a8ff;
  border-color: #46347a;
}
.cancel-btn {
  background: var(--failed);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 4px 10px;
  cursor: pointer;
  margin-left: auto;
  font-size: 12px;
}
.cancel-btn:disabled {
  opacity: 0.6;
}
.resume-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 4px 10px;
  cursor: pointer;
  margin-left: 8px;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.resume-btn:hover {
  filter: brightness(1.1);
}
.agent-err {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(255, 93, 104, 0.1);
  border-left: 3px solid var(--failed);
  font-family: var(--mono);
  font-size: 12px;
}

.events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ev {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 80ms ease;
}
.ev:hover {
  background: var(--bg-soft-2);
}
.ev.open {
  background: var(--bg-soft-2);
}
.ev-header {
  display: grid;
  grid-template-columns: 14px 180px 1fr 80px;
  gap: 10px;
  align-items: center;
  padding: 6px 12px;
}
.ev-header .caret {
  color: var(--fg-soft);
  font-size: 9px;
  user-select: none;
}
.ev-header .kind {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-soft);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev-header .summary {
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev-header .ts {
  color: var(--fg-soft);
  font-size: 11px;
  font-family: var(--mono);
  text-align: right;
}
.ev-detail {
  padding: 6px 12px 10px 36px;
  border-top: 1px dashed var(--border);
  position: relative;
}
/* Copy-to-clipboard button anchored top-right in every expanded
 * EventCard. The card's onClick toggles open/closed, so the button
 * uses e.stopPropagation() (in the React handler) to suppress that.
 * State flips between idle / copied / error briefly. */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  background: var(--bg-soft);
  color: var(--fg-soft);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: color 80ms ease, border-color 80ms ease, background 80ms ease;
  z-index: 1;
}
.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg);
}
.copy-btn.copy-state-copied {
  color: var(--completed);
  border-color: var(--completed);
}
.copy-btn.copy-state-error {
  color: var(--failed);
  border-color: var(--failed);
}
.ev-detail .full-text {
  margin: 4px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 600px;
  overflow: auto;
}
.tool-detail .tool-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-soft);
  margin-bottom: 4px;
}
.tool-detail .tool-meta code {
  color: var(--fg);
}
.tool-detail .tool-params span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ev-text { border-left-color: #6b8caf; }
.ev-thinking { border-left-color: #b08bd0; }
.ev-thinking .summary,
.ev-thinking .full-text { color: var(--fg-soft); font-style: italic; }
.ev-tool_call { border-left-color: var(--accent); }
.ev-tool_call .kind { color: var(--accent); }
.ev-tool_result { border-left-color: var(--completed); }
.ev-tool_result.err { border-left-color: var(--failed); }
.ev-tool_result.err .kind { color: var(--failed); }
.ev-error { border-left-color: var(--failed); background: rgba(255, 93, 104, 0.05); }
.ev-error .kind { color: var(--failed); }
.ev-retry { border-left-color: var(--running); }
.ev-done { border-left-color: var(--fg-soft); }
/* v0.9.x — the "what the agent received" cards. Distinguish them
   from model output (which uses cool blues / greens) so operators
   eye-track to the run's inputs at a glance. Warm gold for the
   system prompt; muted teal for the user input. */
.ev-system_prompt { border-left-color: #d4a056; background: rgba(212, 160, 86, 0.04); }
.ev-system_prompt .kind { color: #d4a056; }
.ev-user_input { border-left-color: #5fa9a3; background: rgba(95, 169, 163, 0.04); }
.ev-user_input .kind { color: #5fa9a3; }
.user-input-segment { margin-bottom: 12px; }
.user-input-segment:last-child { margin-bottom: 0; }
.user-input-segment .seg-role {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-soft);
  margin-bottom: 4px;
}
.user-input-segment .seg-role code { color: var(--fg); }
.system-prompt-provenance {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.system-prompt-provenance span {
  font-family: var(--mono);
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.system-prompt-provenance code {
  font-family: var(--mono);
  color: var(--fg);
}

/* v0.8.0 Memory page — three-pane layout. */
.memory-view-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 12px;
  gap: 8px;
}
.memory-view-wrapper > .err {
  flex-shrink: 0;
}
.memory-view {
  /* Layout owned by .splitter (display:grid, grid-template-columns
   * via inline style). The previous static three-column grid is
   * replaced by an outer + inner Splitter so each gutter is
   * draggable. Pane styling (.memory-pane) still applies. */
  height: 100%;
  min-height: 0;
  flex: 1;
}
.memory-view-inner {
  height: 100%;
  min-height: 0;
}
.memory-pane {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.memory-pane .pane-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.memory-pane .pane-header.sub {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft-2);
}
.memory-pane .pane-header code {
  color: var(--fg);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}
.scope-tabs {
  display: flex;
  padding: 8px;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}
.scope-tabs button {
  flex: 1;
  background: var(--bg);
  color: var(--fg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.scope-tabs button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.scope-id-list,
.key-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.scope-id-list li,
.key-list li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.scope-id-list li:hover,
.key-list li:hover {
  background: var(--bg-soft-2);
}
.scope-id-list li.on,
.key-list li.on {
  background: var(--bg-soft-2);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}
.scope-id-list li .meta {
  color: var(--fg-soft);
  font-size: 11px;
  font-family: var(--mono);
}
.scope-id-list li code,
.key-list li code {
  font-size: 12px;
  word-break: break-all;
}
.empty-row {
  color: var(--fg-soft);
  padding: 16px 12px !important;
  cursor: default !important;
  font-style: italic;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.empty-row:hover {
  background: transparent !important;
}
.prefix-input {
  margin: 8px 12px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
}
.ttl-flag {
  background: var(--running);
  color: white;
  font-size: 10px;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 2px;
  letter-spacing: 0.04em;
}

/* v0.9.0 Vector Memory — model-distribution badge + reembed banner. */
.embed-badge-row {
  margin: 8px 12px 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--fg-soft);
}
.embed-badge-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.embed-badge {
  background: var(--bg-soft, #1f2937);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg);
}
.embed-badge-count {
  margin-left: 6px;
  color: var(--fg-soft);
}
.embed-badge-disabled .embed-badge-label {
  color: var(--fg-muted, #6b7280);
  font-style: italic;
}
.embed-reembed-btn {
  margin-left: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}
.embed-reembed-btn:hover:not(:disabled) {
  background: var(--bg-soft, #1f2937);
}
.embed-reembed-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.embed-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #60a5fa);
  margin-right: 6px;
  vertical-align: middle;
}

/* RFC I MR-6 — per-key embedding indicator. Same pill language as
   .embed-badge, scaled down for an inline table affordance. */
.embed-key-badge {
  margin-left: 8px;
  background: var(--bg-soft, #1f2937);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-soft);
  vertical-align: middle;
  white-space: nowrap;
}

.reembed-banner {
  margin: 6px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reembed-dryrun {
  background: var(--bg-soft, #1f2937);
}
.reembed-realrun {
  background: var(--success-soft, #064e3b);
}
.reembed-summary code {
  font-family: var(--mono);
  font-size: 11px;
}
.reembed-samples {
  font-size: 11px;
  color: var(--fg-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.reembed-samples code {
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 2px;
}
.reembed-actions {
  display: flex;
  gap: 8px;
}
.reembed-commit-btn,
.reembed-dismiss-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
}
.reembed-commit-btn:hover:not(:disabled) {
  background: var(--accent, #60a5fa);
  color: var(--bg);
}
.reembed-commit-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.meta-failed {
  color: var(--err, #f87171);
}
.entry-detail {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.entry-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  font-size: 12px;
}
.entry-meta div {
  display: contents;
}
.entry-meta div span {
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  align-self: center;
}
.entry-meta div code {
  font-size: 12px;
  word-break: break-all;
}
.entry-value {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  flex: 1;
  overflow: auto;
  margin: 0;
}
.detail-pane .empty {
  padding: 24px;
  color: var(--fg-soft);
  font-style: italic;
}
.memory-err {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--failed);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  max-width: 400px;
}

/* ---- Interruption inbox (v0.8.16) ---- */

.interrupt-inbox .toolbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.interrupt-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.interrupt-row {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.interrupt-row.priority-high {
  border-left: 4px solid var(--failed);
}
.interrupt-row.priority-low {
  border-left: 4px solid var(--bg-soft);
}

.interrupt-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--fg-soft);
  align-items: center;
  flex-wrap: wrap;
}

.interrupt-question {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}

.interrupt-context {
  font-size: 13px;
  color: var(--fg-soft);
  font-style: italic;
}

.interrupt-actions {
  display: flex;
  gap: 8px;
}

.interrupt-actions button {
  padding: 6px 14px;
  background: var(--running);
  color: white;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.interrupt-actions button:hover {
  filter: brightness(1.1);
}

.expires {
  color: var(--failed);
  font-variant-numeric: tabular-nums;
}

/* ---- Answer modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: auto;
}

.modal h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
}

.modal-context {
  color: var(--fg-soft);
  font-style: italic;
  font-size: 13px;
  margin-bottom: 16px;
}

.modal-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-options .option {
  padding: 12px 16px;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}

.modal-options .option:hover {
  border-color: var(--running);
}

.modal-options .option.selected {
  background: var(--running);
  color: white;
  border-color: var(--running);
}

.modal-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  margin-bottom: 16px;
  box-sizing: border-box;
  resize: vertical;
}

.modal-err {
  color: var(--failed);
  font-size: 13px;
  margin-bottom: 12px;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-buttons button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}

.modal-buttons button.primary {
  background: var(--running);
  color: white;
  border-color: var(--running);
  /* Hold the modal's existing 4px radius — the outer `button.primary`
   * rule down in the v0.10.4 block uses a pill radius for page-level
   * CTAs; locking it here keeps modal submit buttons rectangular. */
  border-radius: 4px;
  padding: 8px 16px;
}

.modal-buttons button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* v0.10.4 Library admin UI — LibraryEditModal styles. Extends the base
 * .modal-overlay + .modal anchors (used by AnswerModal) with a wider
 * layout, structured form rows, and a JSON / body textarea. */
.modal.library-modal {
  max-width: 720px;
  width: 92vw;
}
.library-modal-bootstrap-hint {
  font-size: 12px;
  color: var(--fg-muted, #888);
  font-weight: normal;
}
.library-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.library-form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted, #888);
  display: flex;
  align-items: center;
  gap: 8px;
}
.library-form-row input[type="text"] {
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  background: var(--bg-input, #1a1a1a);
  color: var(--fg, inherit);
}
.library-form-row-quad {
  display: grid;
  grid-template-columns: max-content 1fr max-content 1fr;
  align-items: center;
  gap: 8px;
}
.library-form-row-quad label {
  margin-bottom: 0;
}
.library-form-row-checkbox label {
  font-weight: normal;
  color: var(--fg, inherit);
}

/* v0.11.5 — slimmer field layout used by ChannelEditModal +
 * MemoryEntryEditModal (no JSON textarea — purely structured input). */
.library-modal-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.library-modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.library-modal-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted, #888);
}
.library-modal-field input,
.library-modal-field select,
.library-modal-field textarea {
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  background: var(--bg-input, #1a1a1a);
  color: var(--fg, inherit);
}
.library-modal-field input:disabled,
.library-modal-field select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.library-modal-field-row {
  display: flex;
  gap: 12px;
}
.memory-modal-checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.memory-modal-checkbox-field > span {
  order: 2;
}
.memory-modal-checkbox-field > input {
  flex: 0 0 auto;
}

/* v0.11.5 memory CRUD — header CTA + per-row edit/delete actions. */
.memory-keys-header {
  justify-content: space-between;
}
.memory-new-entry-btn {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.memory-new-entry-btn:hover {
  background: var(--accent);
  color: var(--bg);
}
.key-list li {
  position: relative;
}
.memory-key-actions {
  display: none;
  margin-left: auto;
  gap: 4px;
}
.key-list li:hover .memory-key-actions {
  display: inline-flex;
}
.memory-key-action {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-soft);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
}
.memory-key-action:hover {
  background: var(--bg-soft);
  color: var(--fg);
}
.memory-key-action-danger:hover {
  border-color: var(--danger, #d33);
  color: var(--danger, #d33);
}
.warning-banner {
  padding: 8px 12px;
  background: rgba(255, 196, 0, 0.1);
  border: 1px solid rgba(255, 196, 0, 0.4);
  color: #d4a017;
  border-radius: 4px;
  margin: 8px 0;
  font-size: 12px;
}
.library-json-textarea {
  width: 100%;
  padding: 8px;
  font-size: 12px;
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  background: var(--bg-input, #1a1a1a);
  color: var(--fg, inherit);
  resize: vertical;
  min-height: 120px;
}
.library-schema-hint {
  margin-top: 4px;
  padding: 8px;
  font-size: 11px;
  background: var(--bg-muted, #181818);
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  white-space: pre-wrap;
  color: var(--fg-muted, #888);
}
.library-schema-hint-toggle {
  background: none;
  border: 1px solid var(--border, #444);
  color: var(--fg-muted, #888);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  cursor: pointer;
}
.library-schema-hint-toggle:hover {
  color: var(--fg, inherit);
}
.library-radio-group {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: normal;
}
.library-radio-note {
  font-size: 11px;
  color: var(--fg-muted, #888);
  font-style: italic;
  font-weight: normal;
}
.library-headers-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.library-header-row {
  display: grid;
  grid-template-columns: 1fr 2fr max-content;
  gap: 6px;
}
.library-header-row input {
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border, #444);
  border-radius: 3px;
  background: var(--bg-input, #1a1a1a);
  color: var(--fg, inherit);
}
.library-header-row button {
  background: none;
  border: 1px solid var(--border, #444);
  color: var(--fg-muted, #888);
  cursor: pointer;
  padding: 0 8px;
  border-radius: 3px;
}
.library-header-row button:hover {
  color: var(--danger, #c33);
  border-color: var(--danger, #c33);
}

/* v0.11.6 — Library admin modal structured form. Inline help text
 * next to a label, a textarea that's a sibling of .library-json-textarea
 * but named for intent (skill body + agent system prompt are markdown,
 * not JSON), checkbox cluster for memory_scopes, and per-tier model
 * editor for the agent's models map. */
.library-modal-field-hint {
  font-weight: normal;
  font-size: 11px;
  color: var(--fg-muted, #888);
  font-style: italic;
}
.library-prompt-textarea {
  width: 100%;
  padding: 8px;
  font-size: 12px;
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  background: var(--bg-input, #1a1a1a);
  color: var(--fg, inherit);
  resize: vertical;
  min-height: 120px;
}
.library-checkbox-group {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: normal;
}
.library-models-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  background: var(--bg-muted, #181818);
}
.library-models-warning {
  padding: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  background: rgba(240, 160, 64, 0.08);
  border: 1px solid var(--running);
  border-radius: 4px;
  color: var(--fg);
}
.library-advanced-overlay {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px dashed var(--border, #444);
  padding-top: 10px;
}
.library-advanced-format {
  display: flex;
  gap: 16px;
  font-size: 12px;
}
.library-models-warning code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--running);
}
.library-models-tier-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.library-models-tier-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.library-models-tier-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  min-width: 60px;
}
.library-models-candidate-row {
  display: grid;
  grid-template-columns: 1fr 2fr max-content;
  gap: 6px;
}
.library-models-candidate-row input {
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border, #444);
  border-radius: 3px;
  background: var(--bg-input, #1a1a1a);
  color: var(--fg, inherit);
}
.library-models-candidate-row button {
  background: none;
  border: 1px solid var(--border, #444);
  color: var(--fg-muted, #888);
  cursor: pointer;
  padding: 0 8px;
  border-radius: 3px;
}
.library-models-candidate-row button:hover {
  color: var(--danger, #c33);
  border-color: var(--danger, #c33);
}

/* v0.10.4 — per-row mutation buttons in LineageTree + the page-level
 * "+ New" CTA in LineagePanel's right-pane header. */
.lineage-row-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.lineage-row-action {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-soft);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.1s, border-color 0.1s, background-color 0.1s;
}
.lineage-row-action:hover {
  color: var(--fg);
  border-color: var(--accent);
  background: rgba(91, 157, 255, 0.08);
}
.lineage-row-action-danger:hover {
  color: var(--failed);
  border-color: var(--failed);
  background: rgba(255, 93, 104, 0.08);
}
.lineage-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Top-level `.primary` — same convention as .user-picker button (accent
 * background + white text + rounded corners). The class is also used
 * inside .modal-buttons scope where it's overridden to use --running
 * (matches the InterruptInbox submit-answer convention). Outside that
 * scope, this rule provides the dark-theme primary CTA styling. */
button.primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s;
}
button.primary:hover {
  background: #4a8cee;
  border-color: #4a8cee;
}
button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* The Library "+ New" CTA. Inherits the primary button styling above;
 * `.lineage-create-cta` is just a marker for any future per-CTA tweaks. */
.lineage-create-cta {
  font-size: 12px;
}

/* v0.8.17 PauseControls — topbar runtime quiesce pill + actions. */
.pause-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-left: auto;
}
.runtime-state {
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.runtime-state-running {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
}
.runtime-state-pausing {
  background: rgba(240, 160, 64, 0.18);
  color: var(--running);
  border: 1px solid rgba(240, 160, 64, 0.4);
}
.runtime-state-paused {
  background: rgba(255, 93, 104, 0.18);
  color: var(--failed);
  border: 1px solid rgba(255, 93, 104, 0.4);
}
.pause-controls button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.pause-controls button:hover:not(:disabled) {
  border-color: var(--running);
}
.pause-controls button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.pause-controls .hint {
  color: var(--fg-soft);
  font-style: italic;
}
.pause-controls .flash {
  color: #4ade80;
  font-size: 12px;
}
.pause-controls .err {
  color: var(--failed);
  font-size: 12px;
}

/* v0.8.17 SnapshotsView — admin page for capture / restore / export. */
.snapshots-view {
  padding: 16px 24px;
}
.snapshots-view .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.snapshots-view .toolbar .meta {
  display: flex;
  gap: 12px;
  color: var(--fg-soft);
  font-size: 13px;
}
.snapshot-actions {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.snapshot-actions .capture,
.snapshot-actions .restore {
  display: flex;
  align-items: center;
  gap: 8px;
}
.snapshot-actions label {
  font-size: 13px;
  color: var(--fg-soft);
}
.snapshot-actions input[type="text"] {
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  min-width: 220px;
}
.snapshot-actions input[type="file"] {
  font-size: 13px;
}
.snapshot-actions button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft-2);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.snapshot-actions button:hover:not(:disabled) {
  border-color: var(--running);
}
.snapshot-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.flash-ok {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #d1fae5;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 13px;
}
.flash-err {
  background: rgba(255, 93, 104, 0.12);
  border: 1px solid rgba(255, 93, 104, 0.35);
  color: #fee2e2;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 13px;
}
/* Partial-success / timed-out tone (amber) — broadcast with failures, or an
   await that didn't satisfy. Distinct from flash-ok (all good) and
   error-banner (the call itself failed). */
.flash-warn {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fef3c7;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 13px;
}
.restore-warnings {
  margin: 6px 0 0 16px;
  padding: 0;
  color: var(--fg-soft);
  font-size: 12px;
}
.snapshots-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.snapshots-table th,
.snapshots-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.snapshots-table th {
  font-weight: 600;
  color: var(--fg-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.snapshots-table td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.snapshots-table td.actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.snapshots-table td.actions a,
.snapshots-table td.actions .link-btn {
  color: var(--running);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-size: 13px;
  font-family: inherit;
}
.snapshots-table td.actions a:hover,
.snapshots-table td.actions .link-btn:hover {
  color: var(--fg);
}
.snapshots-table .empty {
  color: var(--fg-soft);
  text-align: center;
  font-style: italic;
}
.snapshots-table .muted {
  color: var(--fg-soft);
}

/* v0.8.21 Splitter — draggable resizable two-pane container used by
 * Runs and Memory views. Owner: web/src/components/Splitter.tsx.
 * Layout is grid (left / handle / right); the inline style sets the
 * left column width, handle is fixed 6px, right grows. */
.splitter {
  display: grid;
  gap: 0;
  height: 100%;
  min-height: 0;
  /* Bound the single grid row to the splitter's height (not content). Without
   * this the implicit row is `auto` (content-sized), so each pane grows to its
   * content and the WHOLE view scrolls as one — the list + detail move together
   * and a selected agent's detail scrolls off-screen. minmax(0, 1fr) pins the
   * row to the available height with a 0 floor, so each pane's own
   * overflow-y:auto engages and the list + detail scroll INDEPENDENTLY. */
  grid-template-rows: minmax(0, 1fr);
}
.splitter.dragging {
  /* Suppress text-select highlighting during a drag — without this
   * the user's mouse sweep grabs the pane content as a selection. */
  user-select: none;
  cursor: col-resize;
}
.splitter > .splitter-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.splitter > .splitter-handle {
  background: transparent;
  cursor: col-resize;
  position: relative;
  z-index: 1;
}
.splitter > .splitter-handle::before {
  /* Thin centred line that becomes visible on hover/drag — the
   * 6px handle has 1px of visible vibe and 5px of forgiving hit
   * area. */
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: var(--border);
  transition: background 80ms ease;
}
.splitter > .splitter-handle:hover::before,
.splitter.dragging > .splitter-handle::before {
  background: var(--accent);
}

/* v0.8.21 Audit view — cross-session paginated event log. */
.audit-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

/* v0.8.21 Activity Monitor — page layout, toolbar, chart cards.
 * Three primary charts ship in this commit; diagnostic charts
 * land in the next one behind the `advanced` toolbar toggle. */
.activity-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
}
.audit-toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.activity-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.audit-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.audit-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-soft);
  font-size: 12px;
}
.audit-toolbar input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 12px;
  min-width: 140px;
}
.audit-toolbar button {
  background: var(--bg-soft-2);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}
.audit-toolbar button:hover:not(:disabled) {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.audit-toolbar button:disabled {
  opacity: 0.4;
  cursor: default;
}
.audit-status {
  color: var(--fg-soft);
  font-size: 12px;
}

.audit-table {
  flex: 1;
  overflow: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 0;
}
.audit-row {
  display: grid;
  grid-template-columns: 180px 160px 220px 1fr;
  gap: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  align-items: center;
}
.audit-row:hover {
  background: var(--bg-soft-2);
}
.audit-row.expanded {
  background: var(--bg-soft-2);
  border-bottom: none;
}
.audit-row.audit-head {
  background: var(--bg);
  color: var(--fg-soft);
  font-weight: 600;
  cursor: default;
  position: sticky;
  top: 0;
  z-index: 1;
}
.audit-row.audit-head:hover {
  background: var(--bg);
}
.audit-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.audit-ids .muted {
  color: var(--fg-soft);
}
.audit-preview {
  color: var(--fg-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-detail {
  position: relative;
  padding: 10px 14px 14px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
}
.audit-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--fg-soft);
  margin-bottom: 8px;
}
.audit-detail-meta strong {
  color: var(--fg);
  margin-right: 4px;
}
.audit-detail-payload {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 400px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg);
}

.audit-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px;
  color: var(--fg-soft);
  font-size: 12px;
}
.audit-pager button {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
}
.audit-pager button:disabled {
  opacity: 0.4;
  cursor: default;
}
.audit-pager button:hover:not(:disabled) {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.activity-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.activity-toolbar-label {
  color: var(--fg-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mode-tabs {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.mode-tab {
  background: transparent;
  color: var(--fg-soft);
  border: none;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.mode-tab:last-child { border-right: none; }
.mode-tab.on {
  background: var(--accent);
  color: white;
}
.mode-tab:hover:not(.on) {
  background: var(--bg-soft-2);
  color: var(--fg);
}
.toggle {
  background: var(--bg);
  color: var(--fg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
}
.toggle.on {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.toggle:hover:not(:disabled):not(.disabled) {
  background: var(--bg-soft-2);
  color: var(--fg);
}
.toggle.on:hover {
  background: var(--accent);
  color: white;
}
.toggle:disabled,
.toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.activity-toolbar-status {
  margin-left: auto;
  color: var(--fg-soft);
  font-size: 11px;
  font-family: var(--mono);
}

.activity-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
  padding-bottom: 12px;
}

.chart-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 220px;
}
.chart-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.chart-card-title {
  font-size: 13px;
  color: var(--fg);
  font-weight: 600;
}
.chart-card-current {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.chart-card-body {
  flex: 1;
  min-height: 180px;
  position: relative;
}
.chart-card-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  color: var(--fg-soft);
}
.legend-entry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.metrics-disabled {
  padding: 40px 24px;
  text-align: center;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--fg-soft);
}
.metrics-disabled-title {
  font-size: 16px;
  color: var(--fg);
  margin-bottom: 10px;
}
.metrics-disabled-body {
  max-width: 540px;
  margin: 6px auto;
  line-height: 1.6;
}
.metrics-disabled code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--mono);
  color: var(--fg);
}

/* Note card rendered when 'advanced' is on but mode != live —
 * diagnostic series aren't bucketed by the summary endpoint. */
.advanced-window-note {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
}
.advanced-window-note p {
  color: var(--fg-soft);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}
.advanced-window-note code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--mono);
  color: var(--fg);
}

/* v0.8.21 Activity Monitor — LineChart. Hand-rolled SVG; the
 * component owns its sizing via ResizeObserver and a matching
 * viewBox. CSS handles the tooltip overlay + empty state. */
.line-chart-wrap {
  width: 100%;
  position: relative;
}
.line-chart {
  width: 100%;
  display: block;
}
.line-chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-soft);
  font-size: 12px;
  font-style: italic;
  pointer-events: none;
}
.line-chart-tooltip {
  background: rgba(15, 17, 21, 0.96);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  min-width: 140px;
}
.line-chart-tooltip .tt-time {
  color: var(--fg-soft);
  margin-bottom: 4px;
}
.line-chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.5;
}
.line-chart-tooltip .tt-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.line-chart-tooltip .tt-label {
  flex: 1;
  color: var(--fg-soft);
}
.line-chart-tooltip .tt-value {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* ---- v0.9.x Introspection: Library + Channels + Lineage ---- */

/* Generic monospace utility — many new components use className="mono"
   for IDs / paths / cursor tokens. */
.mono {
  font-family: var(--mono);
}
.empty-state {
  color: var(--fg-soft);
  padding: 32px 16px;
  text-align: center;
}
.error-banner {
  background: rgba(255, 93, 104, 0.1);
  border: 1px solid var(--failed);
  color: var(--failed);
  padding: 8px 12px;
  border-radius: 4px;
  margin: 8px 0;
  font-family: var(--mono);
  font-size: 12px;
}
.error-banner-hint {
  margin-top: 4px;
  color: var(--fg-soft);
  font-style: italic;
}
.loading-indicator {
  color: var(--fg-soft);
  font-size: 12px;
  margin-left: 8px;
}

/* ---- Library page (top-level) ---- */
/* The @loomcycle/library root. It MUST propagate a definite height down to
 * .library-view → .library-content → .splitter, or the Splitter's grid row
 * (grid-template-rows: minmax(0,1fr)) has no bounded height to resolve against,
 * the panes grow to content, and the whole Library scrolls as ONE instead of
 * the list + detail scrolling independently. The package's own styles.css sets
 * only color vars here; the web app relies on this global sheet, so bound it. */
.loomcycle-library {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.library-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.library-subtabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.library-subtab {
  padding: 10px 16px;
  color: var(--fg-soft);
  text-decoration: none;
  /* The @loomcycle/library <Library> renders these tabs as <button>s (they
   * used to be anchors). Without these resets the browser's default button
   * chrome (grey fill + border) leaks through — web styles the library from
   * this global sheet, NOT the package's scoped styles.css, so it must carry
   * the same resets the package's `.loomcycle-library .library-subtab` does. */
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.library-subtab:hover {
  color: var(--fg);
}
.library-subtab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.library-subtab-count {
  margin-left: 6px;
  color: var(--fg-soft);
  font-family: var(--mono);
  font-size: 11px;
}
.library-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ---- LineagePanel: list-left, lineage-right ---- */
/* LineagePanel left pane: fixed filter/type/sort/hide-retired toolbar over a
   scrolling entry list (mirrors packages/library/src/styles.css; the embedded
   UI uses this sheet, not the package's scoped one). */
.lineage-left {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.lineage-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.lineage-toolbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.lineage-filter-text {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--mono);
  background: var(--bg);
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.lineage-toolbar-select {
  padding: 4px 6px;
  font-size: 12px;
  background: var(--bg);
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.lineage-toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--fg-soft);
  cursor: pointer;
  white-space: nowrap;
}
.lineage-list-empty {
  padding: 16px 14px;
  font-size: 12px;
  color: var(--fg-soft);
}
.lineage-name-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  height: 100%;
}
.lineage-left .lineage-name-list {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
.lineage-name-row {
  border-bottom: 1px solid var(--border);
}
.lineage-name-row.lineage-name-selected {
  background: rgba(91, 157, 255, 0.12);
}
.lineage-name-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 10px 14px;
  cursor: pointer;
}
.lineage-name-button:hover {
  background: var(--bg-soft);
}
.lineage-name-label {
  font-weight: 500;
  font-family: var(--mono);
  font-size: 13px;
}
.lineage-name-versions {
  font-size: 11px;
  color: var(--fg-soft);
}
.lineage-right {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 12px 16px;
}
.lineage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.lineage-header h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 16px;
}

/* ---- LineageTree: indented <ul> rows ---- */
.lineage-tree,
.lineage-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lineage-row {
  margin: 0;
}
.lineage-row-line {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px;
}
.lineage-row-line[role="button"] {
  cursor: pointer;
  border-radius: 3px;
}
.lineage-row-line[role="button"]:hover {
  background: rgba(255, 255, 255, 0.04);
}
.lineage-row-line[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.lineage-row.lineage-row-selected > .lineage-row-line {
  background: rgba(91, 157, 255, 0.18);
  border-radius: 3px;
}
.lineage-caret {
  background: transparent;
  border: 0;
  color: var(--fg-soft);
  cursor: pointer;
  width: 16px;
  font-family: var(--mono);
  font-size: 11px;
}
.lineage-caret:hover {
  color: var(--fg);
}
.lineage-caret-empty {
  cursor: default;
  user-select: none;
}
.lineage-row-button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 13px;
}
.lineage-row-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}
.lineage-content-indicator {
  font-size: 10px;
  color: var(--fg-soft);
  font-family: var(--mono);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  user-select: none;
}
.lineage-row-line[role="button"]:hover .lineage-content-indicator,
.lineage-row-line[role="button"][aria-expanded="true"] .lineage-content-indicator {
  color: var(--accent);
  border-color: var(--accent);
}
.lineage-version {
  font-family: var(--mono);
  font-weight: 500;
}
.lineage-defid {
  font-size: 11px;
  color: var(--fg-soft);
  margin-left: 4px;
}

/* ---- Lineage detail (version body) ---- */
.lineage-detail {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.lineage-detail-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  margin-bottom: 12px;
}
.lineage-detail-meta {
  color: var(--fg-soft);
}
.def-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.def-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.def-field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-soft);
}
.def-prompt {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
}
.def-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.def-pill {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
}
.def-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.def-meta-item {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 12px;
}
.def-meta-key {
  color: var(--fg-soft);
  font-size: 11px;
}
.def-meta-value {
  color: var(--fg);
}

/* ---- Definition chips (active / retired / bootstrapped) ---- */
.def-chip {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}
.def-chip-active {
  background: rgba(78, 201, 176, 0.15);
  color: var(--completed);
  border: 1px solid var(--completed);
}
.def-chip-retired {
  background: rgba(176, 139, 208, 0.15);
  color: var(--cancelled);
  border: 1px solid var(--cancelled);
}
.def-chip-bootstrap {
  background: rgba(240, 160, 64, 0.15);
  color: var(--running);
  border: 1px solid var(--running);
}
.def-chip-no-active {
  background: rgba(255, 93, 104, 0.1);
  color: var(--failed);
  border: 1px solid var(--failed);
}
/* Soft-reclaim markers: a fully-retired (inactive) name, or an active
   pointer still on a retired row (corrupt-legacy). Muted/warning tone. */
.def-chip-retired {
  background: rgba(150, 150, 160, 0.12);
  color: var(--fg-soft, #9aa);
  border: 1px solid var(--fg-soft, #9aa);
}
/* v0.9.x Library v2 source chips — name-level marker showing where
   the entity lives (yaml-only / substrate-only / both). The existing
   bootstrapped chip stays as the row-level marker inside the
   lineage tree (different scope). */
.def-chip-static {
  background: rgba(125, 165, 220, 0.15);
  color: #7da5dc;
  border: 1px solid #7da5dc;
}
.def-chip-dynamic {
  background: rgba(176, 139, 208, 0.15);
  color: #b08bd0;
  border: 1px solid #b08bd0;
}
/* The static base is the definition runs resolve to when no dynamic version
   is active — a FILLED accent chip so it reads as "live", visually distinct
   from the outlined "active ★" (which marks a promoted dynamic version). */
.def-chip-effective {
  background: var(--accent, #56c596);
  color: #0b0b0d;
  border: 1px solid var(--accent, #56c596);
  font-weight: 600;
}
.lineage-name-chips {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: 6px;
}

/* v0.9.x Library v2 inline content expansion — the whole row is
   clickable to toggle content. The .lineage-content-indicator is a
   visual chevron (▸/▾) at the row-end; the row-line itself is the
   click target. Independent of the parent/child tree caret. */
.lineage-row-detail {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-right: 8px;
  border-left: 2px solid var(--accent);
  margin-left: 8px;
  margin-bottom: 6px;
}

/* MCP discovered_tools per-tool expansion — pill that opens to show
   description + JSON schema beneath. */
.def-tool-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.def-tool-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.def-tool-pill {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
}
.def-tool-pill:hover {
  border-color: var(--accent);
}
.def-tool-caret {
  font-size: 9px;
  color: var(--muted);
}
.def-tool-detail {
  padding-left: 16px;
  padding-top: 4px;
  padding-bottom: 4px;
}
.def-tool-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.def-tool-name {
  font-size: 11px;
}
.def-tool-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 4px 0;
}
.def-tool-empty code {
  font-style: normal;
  font-size: 11px;
  background: var(--bg-soft);
  padding: 0 4px;
  border-radius: 3px;
}

/* ---- Channels page ---- */
.channels-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.channels-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.channels-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-soft);
}
.filter-chips {
  display: flex;
  gap: 6px;
}
.filter-chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-soft);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
}
.filter-chip:hover {
  color: var(--fg);
}
.filter-chip-active {
  background: rgba(91, 157, 255, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}
.channels-list {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-y: auto;
}
.channel-row {
  border-bottom: 1px solid var(--border);
}
.channel-row.channel-row-selected {
  background: rgba(91, 157, 255, 0.12);
}
.channel-row-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 10px 14px;
  cursor: pointer;
}
.channel-row-button:hover {
  background: var(--bg-soft);
}
.channel-name {
  font-family: var(--mono);
  font-size: 13px;
}
.channel-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--fg-soft);
}
.channel-scope,
.channel-semantic,
.channel-count {
  font-family: var(--mono);
}

/* v0.11.5 — source chip + row-level edit/delete actions for runtime channels. */
.channel-source {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.channel-source-yaml {
  color: var(--fg-soft);
  background: var(--bg-soft);
}
.channel-source-runtime {
  color: var(--accent);
  border-color: var(--accent);
}
.channel-source-orphan {
  color: var(--danger, #d33);
  border-color: var(--danger, #d33);
}
.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 8px;
}
.channel-row-actions {
  display: flex;
  gap: 4px;
}
.channel-row-action {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-soft);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.channel-row-action:hover {
  background: var(--bg-soft);
  color: var(--fg);
}
.channel-row-action-danger:hover {
  border-color: var(--danger, #d33);
  color: var(--danger, #d33);
}
.channels-new-button {
  margin-left: auto;
}
.channel-detail-description {
  margin: 4px 0 12px 0;
  font-size: 13px;
  color: var(--fg-soft);
}
.channel-detail {
  padding: 16px;
  overflow-y: auto;
  height: 100%;
}
.channel-detail-header h3 {
  margin: 0 0 6px 0;
  font-family: var(--mono);
}
.channel-detail-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--fg-soft);
  font-family: var(--mono);
  margin-bottom: 16px;
}
.channel-detail-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-soft);
  margin: 12px 0 8px 0;
}
.channel-messages {
  list-style: none;
  margin: 0;
  padding: 0;
}
.channel-message {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  background: var(--bg-soft);
}
.channel-message-meta {
  font-size: 10px;
  color: var(--fg-soft);
  margin-bottom: 4px;
}
.channel-message-value {
  font-size: 11px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- v0.25.0 channel fan-out (broadcast) / fan-in (await) forms ---- */
.channel-fan-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.channel-fan-results {
  list-style: none;
  margin: 6px 0 0 0;
  padding: 0;
  font-size: 11px;
}
.channel-fan-error {
  color: var(--failed);
}
.channel-fan-channel {
  margin-top: 8px;
}
.channel-fan-channel-name {
  font-size: 11px;
  color: var(--fg-soft);
  margin-bottom: 4px;
}
.channel-fan-fired {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 10px;
  background: rgba(74, 222, 128, 0.18);
  color: #d1fae5;
}

/* ---- v0.9.x AgentDetailPane sub-tabs (Transcript/Memory/Interrupts/Channels) ---- */
.agent-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: 0 0 8px 0;
}
.agent-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--fg-soft);
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
}
.agent-tab:hover {
  color: var(--fg);
}
.agent-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.agent-tab-body {
  padding: 8px 0;
  overflow-y: auto;
}
.agent-tab-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--fg-soft);
  font-family: var(--mono);
  margin-bottom: 12px;
}
.agent-tab-meta-key {
  color: var(--fg-soft);
}
.agent-tab-note {
  font-size: 11px;
  color: var(--fg-soft);
  font-style: italic;
  margin-top: 12px;
}
.agent-tab-note a {
  color: var(--accent);
}

/* Memory tab: per-key entry rows */
.memory-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.memory-entry {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  background: var(--bg-soft);
}
.memory-entry-key {
  font-size: 12px;
  color: var(--fg);
  margin-bottom: 4px;
  font-weight: 500;
}
.memory-entry-value {
  font-size: 11px;
  margin: 0 0 4px 0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}
.memory-entry-meta {
  font-size: 10px;
  color: var(--fg-soft);
}

/* Interrupts tab */
.interrupt-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.interrupt-row {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  background: var(--bg-soft);
}
.interrupt-header {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}
.interrupt-kind {
  font-size: 11px;
  color: var(--fg-soft);
}
.interrupt-id {
  font-size: 10px;
  color: var(--fg-soft);
  margin-left: auto;
}
.interrupt-question {
  font-size: 13px;
  margin-bottom: 4px;
}
.interrupt-answer {
  font-size: 12px;
  margin-bottom: 4px;
  font-family: var(--mono);
}

/* Channels tab */
.channel-cursor-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.channel-cursor-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.channel-cursor-name {
  font-size: 13px;
  font-weight: 500;
}
.channel-cursor-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--fg-soft);
}

/* ---------- /ui/schedules — RFC E v1.x ---------- */

.schedules-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px 16px;
  gap: 8px;
}

.schedules-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedules-header h2 {
  margin: 0;
  font-size: 18px;
}

.schedules-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.schedules-chip-row {
  display: flex;
  gap: 6px;
}

.schedules-chip {
  background: var(--bg-soft);
  color: var(--fg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
}

.schedules-chip-active {
  background: var(--running);
  color: white;
  border-color: var(--running);
}

.schedules-chip-count {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 1px 6px;
  margin-left: 4px;
  font-size: 11px;
}

.schedules-chip:not(.schedules-chip-active) .schedules-chip-count {
  background: var(--bg);
  color: var(--fg-soft);
}

.schedules-filter-text {
  flex: 1;
  max-width: 300px;
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}

.schedules-refresh-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}

.schedules-err {
  color: var(--failed);
  font-size: 13px;
  padding: 4px 0;
}

.schedules-list-pane {
  height: 100%;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.schedules-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.schedules-list-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.schedules-list-row:hover {
  background: var(--bg-soft);
}

.schedules-list-row-selected {
  background: var(--bg-soft);
  border-left: 3px solid var(--running);
}

/* Keyboard-focus outline — distinct from :hover/:selected so Tab
   users see where focus is even when the row isn't yet selected. */
.schedules-list-row:focus-visible {
  outline: 2px solid var(--running);
  outline-offset: -2px;
}

.schedules-list-row-name {
  font-weight: 500;
  font-size: 13px;
}

.schedules-list-row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.schedules-version-chip {
  background: var(--bg-soft);
  color: var(--fg-soft);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Source chips reused from /ui/library shape. */
.source-chip {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 500;
}

.source-chip-static-only {
  background: #2d5a2d;
  color: #b8e6b8;
}

.source-chip-dynamic-only {
  background: #5a4a2d;
  color: #e6d4b8;
}

.source-chip-both {
  background: #2d4a5a;
  color: #b8d4e6;
}

.schedules-empty {
  padding: 24px;
  color: var(--fg-soft);
  font-style: italic;
  font-size: 13px;
  text-align: center;
}

.schedules-detail-pane {
  height: 100%;
  overflow-y: auto;
  padding: 0 16px;
}

.schedule-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.schedule-detail-header h3 {
  margin: 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.schedule-detail-action {
  padding: 6px 14px;
  background: var(--running);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.schedule-detail-action:hover {
  filter: brightness(1.1);
}

.schedule-detail-err {
  background: rgba(220, 80, 80, 0.1);
  border: 1px solid var(--failed);
  color: var(--failed);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 12px;
}

.schedule-detail-block {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.schedule-detail-block h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.schedule-detail-field {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
  align-items: baseline;
}

.schedule-detail-label {
  min-width: 130px;
  color: var(--fg-soft);
  font-family: monospace;
  font-size: 12px;
}

.schedule-detail-value {
  flex: 1;
  word-break: break-all;
}

.schedule-detail-value code {
  font-family: monospace;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 3px;
}

.schedule-detail-paused {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(200, 150, 50, 0.1);
  color: #c89632;
  border-radius: 4px;
  font-size: 13px;
}

.schedule-detail-actions {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.schedule-detail-actions button {
  padding: 6px 14px;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.schedule-detail-actions button:hover:not(:disabled) {
  border-color: var(--running);
}

.schedule-detail-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.schedule-detail-danger {
  color: var(--failed) !important;
}

.schedule-hooks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.schedule-hook {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  font-size: 12px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px dashed var(--border);
}

.schedule-hook:last-child {
  border-bottom: none;
}

.schedule-hook-kind {
  background: var(--bg-soft);
  padding: 1px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: monospace;
  font-size: 11px;
}

.schedule-hooks-note {
  margin-top: 10px;
  color: var(--fg-soft);
  font-size: 11px;
  font-style: italic;
}

.schedule-hooks-empty {
  color: var(--fg-soft);
  font-style: italic;
  font-size: 12px;
  padding: 4px 0;
}

.schedule-hook-index {
  font-family: monospace;
  font-size: 11px;
  color: var(--fg-soft);
  min-width: 20px;
}

.schedule-hook-fields {
  flex: 1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.schedule-hook-fields code {
  font-family: monospace;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

.schedule-hook-remove {
  padding: 2px 10px;
  background: var(--bg-soft);
  color: var(--failed);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}

.schedule-hook-remove:hover:not(:disabled) {
  border-color: var(--failed);
}

.schedule-hook-remove:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.schedule-hook-form {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.schedule-hook-form-row {
  display: flex;
}

.schedule-hook-form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-soft);
  font-family: monospace;
  flex: 1;
}

.schedule-hook-form-row input,
.schedule-hook-form-row select,
.schedule-hook-form-textarea {
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}

.schedule-hook-form-textarea {
  font-family: monospace;
  resize: vertical;
}

.schedule-hook-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.schedule-hook-form-actions button {
  padding: 4px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.schedule-hook-form-actions button[type="submit"] {
  background: var(--running);
  color: white;
  border-color: var(--running);
}

.schedule-lineage {
  list-style: none;
  margin: 0;
  padding: 0;
}

.schedule-lineage-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
}

.schedule-lineage-active {
  font-weight: 600;
}

.schedule-lineage-version {
  font-family: monospace;
  min-width: 40px;
  color: var(--fg-soft);
}

.schedule-lineage-defid {
  font-family: monospace;
  font-size: 11px;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 3px;
}

.schedule-lineage-tag {
  background: var(--bg-soft);
  color: var(--fg-soft);
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 10px;
  text-transform: uppercase;
}

.status-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
}

.status-completed {
  background: #2d5a2d;
  color: #b8e6b8;
}

.status-failed {
  background: #5a2d2d;
  color: #e6b8b8;
}

.status-skipped, .status-skipped_disabled, .status-decode_def {
  background: #4a4a4a;
  color: #c8c8c8;
}

/* Fork form modal — extends the existing .modal-overlay/.modal. */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
/* RFC BN P1: a sticky top action bar for the explorer chunk/path edit dialogs
   (the modal is the scroll container) — gated on .sticky-top so other modals'
   headers are unaffected. */
.modal-header.sticky-top {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.modal-buttons-top {
  margin: 0;
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-soft);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-field > span {
  font-size: 12px;
  color: var(--fg-soft);
  font-family: monospace;
}

.modal-field input,
.modal-credentials-textarea {
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}

.modal-credentials-textarea {
  font-family: monospace;
  resize: vertical;
}

.modal-help {
  background: var(--bg-soft);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--fg-soft);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.modal-actions button {
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}

.modal-actions button[type="submit"] {
  background: var(--running);
  color: white;
  border-color: var(--running);
}

/* ---- Multi-tenant auth (RFC L UI): login page, identity gate, role badge ---- */

.auth-splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 60vh;
  color: var(--fg);
  opacity: 0.8;
  font-size: 0.95rem;
}
.auth-splash.auth-error {
  opacity: 1;
  color: var(--failed);
}
.auth-splash a {
  color: var(--accent);
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 1rem;
}
.login-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
  background: var(--panel, #161a22);
}
.login-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.login-title {
  margin: 0;
  font-size: 1.4rem;
  color: var(--fg);
}
.login-sub {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--fg);
  opacity: 0.7;
}
.login-sub code,
.login-hint code {
  background: var(--bg);
  padding: 0 0.3em;
  border-radius: 4px;
  font-size: 0.85em;
}
.login-input {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
}
.login-btn {
  padding: 0.6rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.login-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--fg);
  opacity: 0.55;
}

.role-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.role-badge.role-admin {
  background: rgba(220, 160, 40, 0.18);
  color: #e0a030;
  border: 1px solid rgba(220, 160, 40, 0.4);
}
.role-badge.role-tenant {
  background: rgba(80, 140, 220, 0.15);
  color: var(--accent);
  border: 1px solid rgba(80, 140, 220, 0.35);
}

/* Super-admin tenant-focus switcher (Layout topbar). Mirrors the
   user-picker so the two controls read as a pair. */
.tenant-switcher {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tenant-switcher label {
  color: var(--fg-soft);
  font-size: 12px;
}
.tenant-switcher input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 13px;
  min-width: 140px;
}
.tenant-switcher button.manual-btn {
  background: transparent;
  color: var(--fg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.tenant-switcher button.manual-btn:hover {
  color: var(--fg);
  border-color: var(--accent);
}

/* ---- Run view (v0.24.0 manual run launcher) ---- */
.run-view {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  /* .content (the page scroller) is NOT a flex container, so flex:1 here is
     inert. Fill .content's already-viewport-bounded height explicitly so the
     transcript pane below can cap to the window and scroll internally instead
     of growing the page forever. */
  height: 100%;
}
.run-view h2 {
  margin: 0 0 12px;
}
.run-view-body {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
}
.run-view-form-col {
  width: 380px;
  flex: 0 0 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.run-view-pane-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
}

/* Collapse toggle inside the expanded left column (top-right). */
.run-col-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
}
.run-col-toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-soft);
  border-radius: var(--lc-radius-sm, 6px);
  cursor: pointer;
  padding: 1px 9px;
  font-size: 15px;
  line-height: 1.4;
}
.run-col-toggle:hover {
  background: var(--bg-soft);
  color: var(--fg);
}

/* Collapsed left column: a thin vertical strip showing the running-interactive
   count + an expand affordance, so the live terminal gets the full width. */
.run-view-form-col-collapsed {
  flex: 0 0 38px;
  width: 38px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  color: var(--fg-soft);
}
.run-view-form-col-collapsed:hover {
  background: var(--bg-soft);
  color: var(--fg);
}
.run-col-toggle-icon {
  font-size: 16px;
  line-height: 1;
}
.run-col-collapsed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(86, 197, 150, 0.15);
  color: var(--accent, #56c596);
  border: 1px solid var(--accent, #56c596);
}
/* Zero running sessions: mute the badge so it doesn't read as a live count. */
.run-col-collapsed-badge[data-empty="1"] {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.run-col-collapsed-vtext {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Interactive-sessions switcher — a collapsible list at the top of the run
   page's left column. Lets the operator switch between / re-open running
   interactive sessions without the runs-page "resume in terminal" detour. */
.interactive-sessions {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.interactive-sessions-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.interactive-sessions-caret {
  color: var(--fg-soft, #9aa);
}
.interactive-sessions-title {
  font-weight: 600;
}
.interactive-sessions-list {
  max-height: 33vh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.interactive-sessions-empty {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--fg-soft, #9aa);
}
.interactive-session-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.interactive-session-row:hover:not(:disabled) {
  background: rgba(125, 165, 220, 0.08);
  border-color: var(--border);
}
.interactive-session-current {
  border-color: var(--accent);
  background: rgba(86, 197, 150, 0.1);
  cursor: default;
}
.interactive-session-agent {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.interactive-session-runid {
  color: var(--fg-soft, #9aa);
  font-size: 11px;
}

/* "interactive" tag — runs page (tree row + detail header) + the
   current-session marker in the switcher. Loom-wood accent. */
.pill-interactive {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
  background: rgba(86, 197, 150, 0.15);
  color: var(--accent, #56c596);
  border: 1px solid var(--accent, #56c596);
  /* In the runs tree row the chip sits in a 1fr grid column, so a stretched
     grid item filled the whole column. Keep it text-wide, left-aligned in its
     cell. justify-self is a no-op in the (non-grid) detail-pane + switcher uses. */
  justify-self: start;
}
/* RFC BK P3 — resident interactive sub-agent chip. Distinct hue (amber) from the
   interactive (green) chip so a resident child is scannable in the runs tree. */
.pill-resident {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
  background: rgba(230, 168, 84, 0.15);
  color: var(--warn, #e6a854);
  border: 1px solid var(--warn, #e6a854);
  justify-self: start;
}
.run-form-advanced {
  margin: 8px 0;
}
.run-form-advanced summary {
  cursor: pointer;
  color: var(--muted, #9aa);
  font-size: 13px;
  padding: 4px 0;
}
.run-form-actions {
  margin-top: 12px;
}
.live-run-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border, #2a2a32);
  border-radius: 6px;
  overflow: hidden;
}
.live-run-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #2a2a32);
}
.live-run-agentid {
  font-size: 12px;
  color: var(--muted, #9aa);
}
/* Context-size gauge in the live-run header: a thin bar + "ctx X/Y (Z%)". */
.ctx-gauge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--fg-soft, #9aa);
}
.ctx-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-muted, #181818);
  border: 1px solid var(--border, #2a2a32);
  overflow: hidden;
}
.ctx-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}
.ctx-bar-fill.ctx-mid {
  background: var(--running, #f0a040);
}
.ctx-bar-fill.ctx-high {
  background: var(--error, #e0556a);
}
.live-run-cancel {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 12px;
  border: none;
  border-radius: 999px;
  background: #9b2c2c; /* dark red — a clear "stop", distinct from the accent */
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}
.live-run-cancel:hover {
  background: #b5343a;
}
.live-run-cancel:active {
  background: #861f24;
}
/* Compact: a non-destructive action — neutral/outline pill, visually distinct
   from the red Stop. margin-left:auto pushes the action group to the right (the
   first right-floated control absorbs the free space; Stop follows it). */
.live-run-compact {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 12px;
  border: 1px solid var(--border, #2a2e3a);
  border-radius: 999px;
  background: var(--bg-soft-2, #1d2230);
  color: var(--fg-soft, #9aa);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}
.live-run-compact:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--fg, #e6e6e6);
}
.live-run-compact:disabled {
  opacity: 0.45;
  cursor: default;
}
.live-run-pane .terminal-transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
/* Claude-Desktop-style composer: a rounded, elevated card holding the input on
   top and a footer row (live model + MCP-tool chrome on the left, a circular
   send arrow on the right). Replaces the flat textarea+button bar. */
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 12px;
  padding: 10px 12px;
  background: var(--bg-soft-2, #1d2230);
  border: 1px solid var(--border, #2a2a32);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.composer:focus-within {
  border-color: var(--accent);
}
.composer-input {
  width: 100%;
  resize: none;
  overflow-y: auto;
  min-height: 24px;
  max-height: 160px;
  line-height: 1.45;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--fg, #e6e8ee);
  font-family: inherit;
  font-size: inherit;
  box-sizing: border-box;
}
.composer-input::placeholder {
  color: var(--fg-muted, #8a90a0);
}
.composer-input:disabled {
  opacity: 0.55;
}
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.composer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: var(--fg-muted, #8a90a0);
}
.composer-model {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-mcp {
  flex-shrink: 0;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border, #2a2a32);
  background: var(--bg-soft, #161922);
  white-space: nowrap;
}
.composer-send {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.composer-send:not(:disabled):hover {
  filter: brightness(1.1);
}
.composer-send:disabled {
  opacity: 0.4;
  cursor: default;
}
.live-run-awaiting {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--accent);
  border-top: 1px solid var(--border, #2a2a32);
}

/* Busy indicator — the agent is actively working (provider call in flight,
   response streaming, or a tool running). A flashing dot signals "waiting for
   the LLM response" so the operator knows the terminal isn't stalled. */
.live-run-busy {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--accent);
  border-top: 1px solid var(--border, #2a2a32);
}
.live-run-busy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: lc-pulse 1.1s ease-in-out infinite;
}
@keyframes lc-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.25; transform: scale(0.7); }
}
/* Respect reduced-motion: keep a steady dimmed dot, no pulsing. */
@media (prefers-reduced-motion: reduce) {
  .live-run-busy-dot { animation: none; opacity: 0.6; }
}
.live-run-pane-compact {
  min-height: 180px;
}

/* Inline interruption prompt (Claude-Code-style) — the agent is blocked on a
   question and the same SSE stream resumes once answered. */
.live-run-interrupt {
  border-top: 1px solid var(--border, #2a2a32);
  border-left: 3px solid #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.live-run-interrupt-q {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg);
}
.live-run-interrupt-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  flex-shrink: 0;
}
.live-run-interrupt-prio {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}
.live-run-interrupt-prio.prio-high {
  background: rgba(255, 93, 104, 0.18);
  color: var(--failed);
}
.live-run-interrupt-prio.prio-low {
  background: var(--bg-soft-2);
  color: var(--fg-soft);
}
.live-run-interrupt-context {
  font-size: 12px;
  color: var(--fg-soft);
}
.live-run-interrupt-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.live-run-interrupt-option {
  background: var(--bg-soft-2);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}
.live-run-interrupt-option:hover {
  border-color: #fbbf24;
}
.live-run-interrupt-form {
  display: flex;
  gap: 8px;
}
.live-run-interrupt-form input {
  flex: 1;
}

/* run mode tabs */
.run-view-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.run-tabs {
  display: flex;
  gap: 4px;
}
.run-tab {
  background: transparent;
  border: 1px solid var(--border, #2a2a32);
  color: var(--muted, #9aa);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.run-tab-active {
  color: var(--fg);
  border-color: var(--accent);
  background: rgba(120, 160, 255, 0.1);
}

/* fan-out */
.fanout-tab {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.fanout-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}
.fanout-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 8px;
  align-items: start;
}
.fanout-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.fanout-running-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.ensemble-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}
.ensemble-cell {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #2a2a32);
  border-radius: 6px;
  overflow: hidden;
}
.ensemble-cell-title {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
}
.ensemble-cell-agent {
  font-weight: 600;
}
.ensemble-cell-index {
  color: var(--muted, #9aa);
}

/* orchestrator */
.orchestrator-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.orchestrator-body {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
  margin-top: 12px;
}
.orchestrator-parent,
.orchestrator-children {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.orchestrator-parent h4,
.orchestrator-children h4 {
  margin: 0 0 8px;
}
.orchestrator-children {
  overflow-y: auto;
}

/* ---- RFC AH Phase 4 Volumes tab ---- */
.volumes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 12px;
}
.volumes-toolbar .muted {
  font-size: 13px;
  max-width: 70ch;
}
/* Reuse .snapshots-table layout; widen the path column + truncate long
   path / bound-by cells so a deep path doesn't blow the table width. */
.volumes-table .volumes-path {
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.volumes-table .volumes-boundby {
  display: inline-block;
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The dynamic_root marker sits next to the source chip. */
.volumes-table .badge-label {
  margin-left: 6px;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--bg-soft, #333);
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
/* Destructive purge action + confirm button — danger-coloured. */
.snapshots-table td.actions .link-btn-danger {
  color: var(--danger);
}
.snapshots-table td.actions .link-btn-danger:hover {
  color: var(--danger);
  font-weight: 600;
}
.modal-buttons button.primary-danger {
  background: var(--danger);
  border-color: var(--danger);
}

/* ───────────────────────────────────────────────────────────────────────────
 * RFC AM Phase 1 — Path tree console (/paths). Reuses the .splitter +
 * .tree/.children/.tree-caret skeleton + the .modal-* anchors; only the
 * path-specific row layout, toolbar, and detail pane are new.
 * ─────────────────────────────────────────────────────────────────────────── */
/* @loomcycle/explorer (RFC AZ) renders the Path console + Document viewer inside
 * a `.loomcycle-explorer` root wrapper. Web consumes the package SOURCE but not
 * its scoped styles.css, so this wrapper is otherwise unstyled here. The pre-
 * package pages placed `.paths-view` / `.doc-viewer` as a DIRECT child of the
 * viewport-bounded `.content`; the new wrapper would break `height:100%` on the
 * full-height Splitter (it'd collapse to content height). Make the wrapper a
 * transparent flex-fill pass-through so height resolves exactly as before —
 * mirrors what the package's own scoped sheet does for external hosts. (Inert
 * when the parent has no definite height, so it can't regress other layouts.) */
.loomcycle-explorer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.paths-view {
  height: 100%;
  min-height: 0;
}
.paths-view .left,
.paths-view .right {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  flex: 1;
}
.paths-view .left > .tree,
.paths-view .left > .empty {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 8px 10px;
}
.paths-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.paths-scope {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--lc-text-sm, 13px);
  color: var(--fg-soft);
}
.paths-scope select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
}
.paths-toolbar-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.paths-toolbar-actions button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}
.paths-toolbar-actions button:hover:not(:disabled) {
  border-color: var(--accent);
}
.paths-toolbar-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.paths-context {
  margin: 0;
  padding: 6px 12px;
  font-size: var(--lc-text-xs, 12px);
  color: var(--fg-soft);
  border-bottom: 1px solid var(--border);
}
.paths-err {
  margin: 0;
  padding: 8px 12px;
  color: var(--failed);
  font-size: var(--lc-text-sm, 13px);
  border-bottom: 1px solid var(--border);
}

/* Override the agents-tree 6-column grid for path rows — a path row is a
 * caret + a single name affordance, not status/model/replica/time columns. */
.paths-view .node .row {
  display: flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
}
.path-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
  min-width: 0;
}
.path-link:hover .path-name {
  color: var(--accent);
}
.path-kind-icon {
  font-size: 14px;
  line-height: 1;
}
.path-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.path-implicit {
  font-size: var(--lc-text-xs, 11px);
  color: var(--fg-soft);
  opacity: 0.7;
  font-style: italic;
}
.path-node.kind-document > .row .path-kind-icon {
  filter: none;
}

/* Detail (right) pane. */
.paths-detail {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 14px;
}
.paths-detail h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--lc-text-base, 14px);
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.paths-detail h2 code {
  font-family: var(--lc-font-mono, monospace);
  font-size: var(--lc-text-sm, 13px);
  word-break: break-all;
}
.paths-detail-kind {
  text-transform: uppercase;
  font-size: var(--lc-text-xs, 11px);
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--fg-soft);
}
.paths-detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  margin: 0 0 16px;
  font-size: var(--lc-text-sm, 13px);
}
.paths-detail-meta dt {
  color: var(--fg-soft);
}
.paths-detail-meta dd {
  margin: 0;
  word-break: break-all;
}
.paths-detail-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.paths-detail-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}
.paths-detail-actions button:hover {
  border-color: var(--accent);
}
.paths-detail-actions button.danger,
.modal-buttons button.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.modal-buttons button.danger {
  background: var(--danger);
  color: white;
  border-radius: 4px;
  padding: 8px 16px;
}
.paths-readonly,
.paths-note {
  font-size: var(--lc-text-sm, 13px);
  color: var(--fg-soft);
}

/* Modal field label/input for the create/rename dialogs. */
.path-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: var(--lc-text-sm, 13px);
  color: var(--fg-soft);
}
.path-modal-input {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  box-sizing: border-box;
}

/* ───────────────────────────────────────────────────────────────────────────
 * RFC AM Phase 2 — Document viewer (chunk tree + Markdown view + chunk editor).
 * Embedded in the Path console right pane (a document node) and on the
 * /documents/:id deep-link page. Reuses the .tree skeleton + .modal-* anchors.
 * ─────────────────────────────────────────────────────────────────────────── */

/* When a document is selected in the Path console, the right pane is a slim
 * action bar + the viewer filling the rest. */
.paths-doc {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.paths-doc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.paths-doc-path {
  font-family: var(--lc-font-mono, monospace);
  font-size: var(--lc-text-sm, 13px);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
.documents-page {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.doc-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.doc-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.doc-title {
  font-size: var(--lc-text-base, 14px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.doc-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.doc-toolbar-actions button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}
.doc-toolbar-actions button:hover {
  border-color: var(--accent);
}
.doc-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.doc-mode-toggle button {
  padding: 4px 10px;
  border: none;
  background: var(--bg);
  color: var(--fg-soft);
  cursor: pointer;
}
.doc-mode-toggle button.active {
  background: var(--accent);
  color: white;
}
.doc-split {
  flex: 1;
  display: flex;
  min-height: 0;
}
.doc-chunktree {
  width: 40%;
  max-width: 360px;
  overflow: auto;
  padding: 8px;
  border-right: 1px solid var(--border);
  min-height: 0;
}
.doc-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.doc-content-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.doc-content-head h3 {
  margin: 0 0 6px;
  font-size: var(--lc-text-base, 14px);
}
.doc-content-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.chunk-rev {
  font-size: var(--lc-text-xs, 11px);
  color: var(--fg-soft);
}
.doc-content-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* Direct-child only, so the nested .doc-mode-toggle keeps its segmented look. */
.doc-content-controls > button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}
/* RFC BP — up/down reorder + delete controls. */
.doc-content-controls > button:disabled {
  opacity: 0.4;
  cursor: default;
}
.doc-content-controls > button.danger {
  color: var(--danger);
  border-color: var(--danger);
}
/* The selected-chunk view (chunk body OR assembled markdown) scrolls
   independently of the fixed head — both modes can be long. */
.doc-content-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 14px;
}
.doc-empty-body {
  color: var(--fg-soft);
  font-style: italic;
}

/* Chunk tree rows — flex layout (override the agents-tree 6-col grid;
 * ancestor-independent so it also holds on the standalone /documents page). */
.chunk-node .row {
  display: flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
}
.chunk-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
  min-width: 0;
}
.chunk-link:hover .chunk-title {
  color: var(--accent);
}
.chunk-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chunk-badge {
  font-size: var(--lc-text-xs, 11px);
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg-soft);
}
.chunk-badge.chunk-status {
  border-style: dashed;
}

/* Chunk editor modal extras. */
.modal.chunk-editor {
  max-width: 720px;
  width: 92vw;
}
.chunk-editor-row {
  display: flex;
  gap: 12px;
}
.chunk-editor-row .path-field {
  flex: 1;
}
.chunk-body-input {
  font-family: var(--lc-font-mono, monospace);
}

/* Minimal Markdown renderer output. */
.md {
  font-size: var(--lc-text-sm, 13px);
  line-height: 1.55;
  word-wrap: break-word;
}
.md h1,
.md h2,
.md h3,
.md h4,
.md h5,
.md h6 {
  margin: 0.8em 0 0.4em;
  line-height: 1.25;
}
.md h1 {
  font-size: 1.6em;
}
.md h2 {
  font-size: 1.35em;
}
.md h3 {
  font-size: 1.15em;
}
.md p {
  margin: 0.5em 0;
}
.md ul,
.md ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}
.md code {
  font-family: var(--lc-font-mono, monospace);
  font-size: 0.92em;
  background: var(--bg-soft);
  padding: 1px 4px;
  border-radius: 3px;
}
.md-pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  overflow: auto;
}
.md-pre code {
  background: none;
  padding: 0;
}
.md blockquote {
  margin: 0.5em 0;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--fg-soft);
}
.md a {
  color: var(--accent);
}
/* RFC BN — GFM tables + Mermaid diagrams in the chunk Markdown view. */
.md table {
  border-collapse: collapse;
  margin: 0.75em 0;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  font-size: 0.92em;
}
.md th,
.md td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
  vertical-align: top;
}
.md th {
  background: var(--bg-soft);
  font-weight: 600;
}
.md tbody tr:nth-child(even) {
  background: rgba(127, 127, 127, 0.06);
}
.md-mermaid {
  margin: 0.75em 0;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
  text-align: center;
}
.md-mermaid svg {
  max-width: 100%;
  height: auto;
}
.md-mermaid-loading {
  color: var(--fg-soft);
  font-size: 0.9em;
  text-align: left;
}
.md-mermaid-error {
  border-left: 3px solid var(--danger);
}

/* ───────────────────────────────────────────────────────────────────────────
 * RFC AM Phase 3 — Document Assistant panel (a steered doc/manager run).
 * ─────────────────────────────────────────────────────────────────────────── */
.doc-toolbar-actions button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.doc-assistant {
  flex: 0 0 auto;
  max-height: 45%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.doc-assistant-hint {
  padding: 12px 14px;
  font-size: var(--lc-text-sm, 13px);
  color: var(--fg-soft);
}
.doc-assistant-start {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  align-items: flex-end;
}
.doc-assistant-input {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  resize: vertical;
  box-sizing: border-box;
}
.doc-assistant-start button.primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
}
.doc-assistant-start button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ======================================================
 * Settings hub — the top-bar gear → /settings.
 * Tokens / presets / runtime / health, web-reaching the
 * critical CLI surfaces for no-shell deployments (TrueNAS).
 * ====================================================== */
.settings-gear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  background: transparent;
  color: var(--lc-text-muted);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  cursor: pointer;
  padding: 0;
}
.settings-gear:hover,
.settings-gear.active {
  color: var(--lc-text);
  border-color: var(--lc-accent);
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  background: transparent;
  color: var(--lc-text-muted);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  cursor: pointer;
  padding: 0;
}
.logout-btn:hover {
  color: var(--lc-failed);
  border-color: var(--lc-failed);
}

.settings-view {
  padding: var(--lc-space-3);
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}
.settings-tabs {
  display: flex;
  gap: var(--lc-space-1);
  border-bottom: 1px solid var(--lc-rule);
  margin-bottom: var(--lc-space-3);
}
.settings-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--lc-text-muted);
  font-size: var(--lc-text-base);
  padding: var(--lc-space-1) var(--lc-space-2);
  cursor: pointer;
  margin-bottom: -1px;
}
.settings-tab:hover {
  color: var(--lc-text);
}
.settings-tab.active {
  color: var(--lc-text);
  border-bottom-color: var(--lc-accent);
  font-weight: 600;
}

.settings-panel {
  background: var(--lc-surface);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius);
  padding: var(--lc-space-3);
}
.settings-panel h2 {
  margin: 0 0 var(--lc-space-1);
  font-size: var(--lc-text-lg);
}
.settings-subhead {
  margin: var(--lc-space-3) 0 var(--lc-space-1);
  font-size: var(--lc-text-md);
}
.settings-help {
  color: var(--lc-text-muted);
  font-size: var(--lc-text-sm);
  line-height: 1.5;
  margin: 0 0 var(--lc-space-2);
}
.settings-help code,
.settings-panel code {
  font-family: var(--lc-font-mono);
  font-size: 0.92em;
  background: var(--lc-surface-2);
  padding: 1px 5px;
  border-radius: var(--lc-radius-sm);
}
.settings-muted {
  color: var(--lc-text-faint);
  font-size: var(--lc-text-sm);
}
.settings-error {
  color: var(--lc-failed);
  background: rgba(255, 93, 104, 0.1);
  border: 1px solid rgba(255, 93, 104, 0.3);
  border-radius: var(--lc-radius-sm);
  padding: var(--lc-space-1) var(--lc-space-2);
  font-size: var(--lc-text-sm);
  margin: var(--lc-space-1) 0;
}
.settings-flash {
  color: var(--lc-completed);
  font-size: var(--lc-text-sm);
  margin-top: var(--lc-space-1);
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--lc-text-sm);
}
.settings-table th {
  text-align: left;
  color: var(--lc-text-muted);
  font-weight: 600;
  padding: var(--lc-space-1);
  border-bottom: 1px solid var(--lc-rule);
}
.settings-table td {
  padding: var(--lc-space-1);
  border-bottom: 1px solid var(--lc-rule);
  vertical-align: middle;
}
.settings-row-actions {
  display: flex;
  gap: var(--lc-space-1);
  align-items: center;
}

/* Credentials create form (RFC AR) — a single responsive row of name / value /
   scope / submit that wraps on narrow viewports. */
.cred-create {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lc-space-2);
  align-items: center;
  margin: var(--lc-space-2) 0;
}
.cred-create input {
  flex: 1 1 200px;
  min-width: 0;
  padding: 6px 10px;
  font-size: var(--lc-text-sm);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  background: var(--lc-surface);
  color: var(--lc-text);
}
.cred-create select {
  padding: 6px 10px;
  font-size: var(--lc-text-sm);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  background: var(--lc-surface);
  color: var(--lc-text);
}
.cred-table {
  margin-top: var(--lc-space-2);
}

/* Buttons */
.primary-btn,
.ghost-btn {
  font-size: var(--lc-text-sm);
  padding: 6px 12px;
  border-radius: var(--lc-radius-sm);
  cursor: pointer;
  border: 1px solid var(--lc-rule);
}
.primary-btn {
  background: var(--lc-accent);
  color: var(--lc-text-inverse);
  border-color: var(--lc-accent);
  font-weight: 600;
}
.primary-btn:hover:not(:disabled) {
  background: var(--lc-accent-hover);
}
.ghost-btn {
  background: transparent;
  color: var(--lc-text);
}
.ghost-btn:hover:not(:disabled) {
  border-color: var(--lc-accent);
}
.ghost-btn.danger {
  color: var(--lc-failed);
}
.ghost-btn.danger:hover:not(:disabled) {
  border-color: var(--lc-failed);
}
.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Status pills */
.status-pill {
  display: inline-block;
  font-size: var(--lc-text-xs);
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
}
.status-ok {
  background: rgba(78, 201, 176, 0.16);
  color: var(--lc-completed);
}
.status-warn {
  background: rgba(240, 160, 64, 0.16);
  color: var(--lc-running);
}
.status-retired {
  background: var(--lc-surface-2);
  color: var(--lc-text-faint);
}

/* Token reveal (shown once) */
.token-reveal {
  background: var(--lc-accent-soft);
  border: 1px solid var(--lc-accent);
  border-radius: var(--lc-radius);
  padding: var(--lc-space-2);
  margin-bottom: var(--lc-space-3);
}
.token-reveal-head {
  display: flex;
  justify-content: space-between;
  gap: var(--lc-space-2);
  margin-bottom: var(--lc-space-1);
  flex-wrap: wrap;
}
.token-reveal-warn {
  color: var(--lc-running);
  font-size: var(--lc-text-xs);
}
.token-reveal-row {
  display: flex;
  gap: var(--lc-space-1);
  align-items: center;
  flex-wrap: wrap;
}
.token-secret {
  flex: 1;
  min-width: 220px;
  font-family: var(--lc-font-mono);
  font-size: var(--lc-text-sm);
  background: var(--lc-bg);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  padding: 6px 10px;
  word-break: break-all;
}
.token-reveal-meta {
  margin-top: var(--lc-space-1);
  color: var(--lc-text-muted);
  font-size: var(--lc-text-xs);
}

/* Token mint form */
.token-form {
  margin-bottom: var(--lc-space-3);
}
.token-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--lc-space-2);
  margin-bottom: var(--lc-space-2);
}
.token-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--lc-text-sm);
  color: var(--lc-text-muted);
}
.token-form input[type="text"] {
  background: var(--lc-input-bg);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  color: var(--lc-text);
  padding: 6px 10px;
  font-size: var(--lc-text-sm);
}
.token-form .optional {
  color: var(--lc-text-faint);
  font-weight: 400;
}
.token-scopes {
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  padding: var(--lc-space-1) var(--lc-space-2);
  margin-bottom: var(--lc-space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--lc-space-2);
}
.token-scopes legend {
  color: var(--lc-text-muted);
  font-size: var(--lc-text-sm);
  padding: 0 4px;
}
.scope-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--lc-text-sm);
}

/* Presets viewer */
.presets-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: var(--lc-space-2);
}
@media (max-width: 720px) {
  .presets-layout {
    grid-template-columns: 1fr;
  }
}
.presets-list {
  display: flex;
  flex-direction: column;
  gap: var(--lc-space-1);
}
.presets-item {
  text-align: left;
  background: var(--lc-surface-2);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  padding: var(--lc-space-1) var(--lc-space-2);
  cursor: pointer;
  color: var(--lc-text);
}
.presets-item:hover {
  border-color: var(--lc-accent);
}
.presets-item.active {
  border-color: var(--lc-accent);
  background: var(--lc-accent-soft);
}
.presets-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--lc-space-1);
}
.presets-item-desc {
  color: var(--lc-text-muted);
  font-size: var(--lc-text-xs);
  margin-top: 3px;
  line-height: 1.4;
}
.kind-pill {
  font-size: var(--lc-text-xs);
  padding: 0 7px;
  border-radius: 999px;
  font-weight: 600;
}
.kind-preset {
  background: rgba(80, 140, 220, 0.16);
  color: #6fa8e8;
}
.kind-bundle {
  background: var(--lc-accent-soft);
  color: var(--lc-accent);
}
.kind-env {
  background: rgba(176, 139, 208, 0.16);
  color: var(--lc-cancelled);
}
.presets-viewer {
  min-width: 0;
}
.settings-code {
  background: var(--lc-bg);
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius-sm);
  padding: var(--lc-space-2);
  font-family: var(--lc-font-mono);
  font-size: var(--lc-text-xs);
  line-height: 1.5;
  overflow-x: auto;
  max-height: 60vh;
  white-space: pre;
}
.runtime-state {
  font-size: var(--lc-text-sm);
  margin-bottom: var(--lc-space-2);
}

/* ---- Routing view (GET /v1/_routing) --------------------------------- */
.routing-view {
  padding: var(--lc-space-3);
}
.routing-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--lc-space-2);
  flex-wrap: wrap;
  margin-bottom: var(--lc-space-2);
}
.routing-header h1 {
  margin: 0;
  font-size: var(--lc-text-xl);
}
.routing-sub {
  margin: var(--lc-space-1) 0 0;
  color: var(--lc-text-muted);
  font-size: var(--lc-text-sm);
  max-width: 60ch;
}
.routing-actions {
  display: flex;
  align-items: center;
  gap: var(--lc-space-2);
}
.routing-generated {
  color: var(--lc-text-faint);
  font-size: var(--lc-text-xs);
}
.routing-tenant-note {
  color: var(--lc-text-faint);
  font-size: var(--lc-text-sm);
  margin: 0 0 var(--lc-space-2);
}

/* Active-providers header (admin only). */
.routing-providers {
  display: flex;
  align-items: center;
  gap: var(--lc-space-1);
  flex-wrap: wrap;
  margin-bottom: var(--lc-space-2);
}
.routing-providers-label {
  color: var(--lc-text-muted);
  font-size: var(--lc-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: var(--lc-space-1);
}
.routing-provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--lc-text-sm);
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--lc-rule);
  background: var(--lc-surface);
}
.routing-provider-chip.down {
  color: var(--lc-text-faint);
}

/* Availability dot — reused in the header chips, the legend, and rows. */
.routing-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--lc-text-faint);
  flex: none;
}
.routing-dot.up {
  background: var(--lc-completed);
}
.routing-dot.down {
  background: var(--lc-failed);
}

.routing-legend {
  display: flex;
  align-items: center;
  gap: var(--lc-space-2);
  flex-wrap: wrap;
  color: var(--lc-text-muted);
  font-size: var(--lc-text-xs);
  margin-bottom: var(--lc-space-3);
}
.routing-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.routing-selected-key {
  color: var(--lc-accent);
  font-weight: 600;
}

.routing-usertier {
  margin-bottom: var(--lc-space-4);
}
.routing-usertier h2 {
  font-size: var(--lc-text-md);
  margin: 0 0 var(--lc-space-2);
  color: var(--lc-text);
}
.routing-usertier h2 code {
  font-family: var(--lc-font-mono);
  font-size: 0.9em;
  background: var(--lc-surface-2);
  padding: 1px 6px;
  border-radius: var(--lc-radius-sm);
}

.routing-tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--lc-space-2);
}
.routing-tier-card {
  border: 1px solid var(--lc-rule);
  border-radius: var(--lc-radius);
  background: var(--lc-surface);
  padding: var(--lc-space-2);
}
.routing-tier-title {
  font-size: var(--lc-text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--lc-text-muted);
  margin-bottom: var(--lc-space-1);
}
.routing-tier-empty {
  color: var(--lc-text-faint);
  font-size: var(--lc-text-sm);
  font-style: italic;
}
.routing-cascade {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.routing-cand {
  display: flex;
  align-items: center;
  gap: var(--lc-space-1);
  padding: 5px 6px;
  border-radius: var(--lc-radius-sm);
  font-size: var(--lc-text-sm);
}
.routing-cand.selected {
  background: var(--lc-accent-soft);
}
.routing-cand.unavail .routing-model,
.routing-cand.unavail .routing-provider {
  color: var(--lc-text-faint);
}
.routing-rank {
  font-size: var(--lc-text-xs);
  color: var(--lc-text-muted);
  min-width: 4.5em;
}
.routing-provider {
  font-weight: 600;
}
.routing-model {
  font-family: var(--lc-font-mono);
  font-size: 0.9em;
  color: var(--lc-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.routing-selected-badge {
  margin-left: auto;
  font-size: var(--lc-text-xs);
  font-weight: 600;
  color: var(--lc-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── RFC AU — Claude Code import (ImportModal) preview + results ────────── */
.import-preview-list {
  max-height: 46vh;
  overflow-y: auto;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.import-row {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg-soft);
}
.import-row-blocked {
  opacity: 0.55;
}
.import-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.import-name-input {
  flex: 1 1 160px;
  min-width: 120px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-soft-2);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
}
.import-action-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.import-action-create {
  color: var(--accent);
  border-color: var(--accent);
}
.import-action-fork {
  color: var(--running);
  border-color: var(--running);
}
.import-action-blocked {
  color: var(--danger);
  border-color: var(--danger);
}
.import-row-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--fg-soft);
}
.import-row-warning {
  margin-top: 4px;
  font-size: 11px;
  color: var(--running);
}
.import-result-ok {
  color: var(--accent);
  font-weight: 700;
}
.import-result-error {
  color: var(--danger);
  font-weight: 700;
}
.import-result-skipped,
.import-result-pending {
  color: var(--fg-soft);
  font-weight: 700;
}

/* --- RFC AV: usage / cost report (UsageView) --- */
.usage-view {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
}
.usage-header h1 {
  margin: 0;
}
.usage-sub {
  margin: 4px 0 0;
  color: var(--fg-soft);
  font-size: 13px;
}
.usage-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-end;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--lc-radius-sm);
}
.usage-ctl-label {
  color: var(--fg-soft);
  font-size: 12px;
  margin-right: 8px;
}
.usage-dims {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.usage-dim-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-family: var(--mono);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.usage-range {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.usage-range label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--fg-soft);
}
.usage-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}
.usage-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.usage-stat-label {
  font-size: 11px;
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.usage-stat-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
}
.usage-stat.usage-warn .usage-stat-value {
  color: var(--accent);
}
.usage-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
}
.usage-table th,
.usage-table td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.usage-table th {
  background: var(--bg-soft);
  color: var(--fg-soft);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.usage-table th.num,
.usage-table td.num {
  text-align: right;
}
.usage-table tbody tr:hover {
  background: var(--bg-soft-2);
}
.usage-src-operator {
  color: var(--fg-soft);
}
.usage-src-tenant,
.usage-src-user {
  font-weight: 700;
}
.usage-unpriced {
  color: var(--accent);
  font-size: 11px;
}

/* --- RFC AW: per-scope token budgets (LimitsView) --------------------------
   Mirrors the .usage-* console conventions (--bg-soft cards, --mono table). */
.limits-view {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
}
.limits-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.limits-header h1 {
  margin: 0;
}
.limits-sub {
  margin: 4px 0 0;
  color: var(--fg-soft);
  font-size: 13px;
  max-width: 62ch;
}
.limits-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.limits-tenant {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--fg-soft);
}
/* Add-budget row: same soft card as .usage-controls, laid out inline. */
.limits-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--lc-radius-sm);
}
.limits-add-label {
  color: var(--fg-soft);
  font-size: 12px;
  margin-right: 4px;
}
.limits-add-err {
  flex-basis: 100%;
  margin: 4px 0 0;
}
.limits-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.limits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
}
.limits-table th,
.limits-table td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.limits-table th {
  background: var(--bg-soft);
  color: var(--fg-soft);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.limits-table th.num,
.limits-table td.num {
  text-align: right;
}
.limits-table tbody tr:hover {
  background: var(--bg-soft-2);
}
.limits-scopeid {
  color: var(--fg-soft);
}
.limits-num {
  width: 10ch;
  text-align: right;
  font-family: var(--mono);
}
/* Soft/hard editor: the input stacks over its live "= 5,000,000" recognition
   hint. inline-flex so it sits inline among the add-form's other controls; the
   hint only renders when there's something to show, so the extra row height is
   transient. */
.limits-amount {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.limits-amount-hint {
  font-size: 10px;
  line-height: 1;
  color: var(--fg-soft);
  font-family: var(--mono);
  white-space: nowrap;
}
.limits-amount-hint.invalid {
  color: var(--failed);
}
.limits-row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.limits-remove {
  color: var(--failed);
}
.limits-row-err {
  margin: 0;
}

/* limit crossing in the run terminal (TerminalTranscript): a colored banner
   line — amber for a soft warning, red for a hard cap. The row keeps the
   terminal grid (.tl-row); these only recolor + embolden the message cell. */
.limit-banner .tl-payload {
  font-weight: 600;
}
.limit-banner.soft .tl-payload {
  color: #fbbf24;
}
.limit-banner.hard .tl-payload {
  color: var(--failed);
}

/* ============================================================
   RFC BN — per-document color-scheme editor (explorer, dogfooded)
   ============================================================ */
.scheme-editor {
  max-width: 520px;
}
.scheme-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.scheme-editor-head h3 {
  margin: 0;
}
.scheme-editor-actions {
  display: flex;
  gap: 8px;
}
.scheme-editor-actions button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}
.scheme-editor-actions button.primary {
  background: var(--running);
  color: white;
  border-color: var(--running);
}
.scheme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: var(--lc-text-sm);
}
.scheme-group {
  margin-top: 14px;
}
.scheme-group h4 {
  margin: 0 0 6px 0;
  font-size: var(--lc-text-sm);
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.scheme-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
}
.scheme-row input[type="color"] {
  width: 28px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}
.scheme-key {
  flex: 1;
  font-size: var(--lc-text-sm);
}
.scheme-hex {
  color: var(--fg-soft);
  font-size: var(--lc-text-xs);
}
.scheme-editor-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.scheme-editor-foot button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}
.scheme-status {
  color: var(--fg-soft);
  font-size: var(--lc-text-xs);
}

/* ============================================================
   RFC BN P4 — cross-reference links + relationship graph (explorer)
   ============================================================ */
.chunk-link-badge {
  font-size: 0.85em;
  line-height: 1;
  opacity: 0.85;
}
.doc-refs {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.doc-refs h4 {
  margin: 0 0 6px 0;
  font-size: var(--lc-text-sm);
  color: var(--fg-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doc-refs-empty {
  color: var(--fg-soft);
  font-size: var(--lc-text-sm);
  margin: 0;
}
.doc-refs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.doc-ref {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--lc-text-sm);
}
.doc-ref-kind {
  font-family: var(--lc-font-mono, monospace);
  font-size: var(--lc-text-xs);
  color: var(--fg-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}
.doc-ref-arrow {
  color: var(--fg-muted);
}
.doc-ref-target {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
}
.doc-ref-target:hover {
  text-decoration: underline;
}
.doc-ref-target.external {
  color: var(--fg-soft);
  cursor: default;
}
.doc-graph {
  margin-top: 12px;
}
.doc-graph-toggle,
.doc-graph-more {
  background: none;
  border: none;
  color: var(--fg-soft);
  cursor: pointer;
  padding: 2px 0;
  font: inherit;
  font-size: var(--lc-text-sm);
}
.doc-graph-toggle:hover,
.doc-graph-more:hover {
  color: var(--accent);
}
.doc-graph-more {
  margin-top: 6px;
  font-size: var(--lc-text-xs);
}

/* ============================================================
   RFC BO — image & diagram chunks (explorer, dogfooded)
   ============================================================ */
.chunk-type-icon {
  font-size: 0.9em;
  line-height: 1;
  margin-right: 2px;
}
.doc-image {
  margin: 0;
  text-align: center;
}
.doc-image img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-soft);
}
.doc-image figcaption {
  margin-top: 6px;
  color: var(--fg-soft);
  font-size: var(--lc-text-sm);
  font-style: italic;
}
.doc-mermaid-source {
  margin-top: 10px;
}
.chunk-mermaid-preview {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  background: var(--bg-soft);
  margin-bottom: 16px;
  overflow-x: auto;
}
