/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--color-border-interactive);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  min-height: 36px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, opacity 0.12s, transform 0.08s ease;
  white-space: nowrap;
  text-decoration: none;
  background: var(--color-surface-2);
  color: var(--color-text);
  font-family: var(--font-sans);
}

/* No border-color change on hover: --color-border-strong is 1.70:1, i.e. weaker
   than the 4.30:1 resting border, so lifting it here used to *lose* the edge.
   The surface step is the hover affordance. */
.btn:hover { background: var(--color-surface-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
}
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text-2); border-color: transparent; }

/* Pause button in "paused" state — highlighted to indicate click will resume */
#btn-pause-resume.paused {
  color: var(--color-warning);
  border-color: var(--color-warning);
  background: oklch(from var(--color-warning) l c h / 0.08);
}
#btn-pause-resume.paused:hover {
  background: oklch(from var(--color-warning) l c h / 0.15);
}

/* --color-primary-text, not --color-text-inverse: they happen to be equal today,
   but the first is defined as "the foreground for a primary fill" and travels
   with --color-primary if it ever changes. */
.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn-secondary {
  background: transparent;
  border-color: var(--color-border-interactive);
  color: var(--color-text);
}
.btn-secondary:hover { background: var(--color-surface-2); }

.btn-danger { background: var(--color-error); color: var(--color-text-inverse); border-color: var(--color-error); }
.btn-danger:hover { background: oklch(from var(--color-error) calc(l - 0.1) c h); }

.btn-icon {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  line-height: 1;
  min-width: 28px;
  min-height: 28px;
}
.btn-icon:hover { background: var(--color-surface-2); color: var(--color-text); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--font-size-xs); min-height: 28px; }
.btn-full { width: 100%; }

/* 44px is the WCAG/mobile minimum touch target — reserve for primary CTAs
   (auth, checkout, onboarding), not dense app chrome (see CLAUDE.md brand section). */
.btn-lg { padding: 12px 24px; min-height: 44px; font-size: var(--font-size-md); }

/* Social OAuth button (full-width bordered) */
.btn-social-oauth {
  border: 1.5px solid var(--color-border-interactive);
  border-radius: var(--radius-lg);
  width: 100%;
  padding: 12px 16px;
  background: var(--color-surface);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-social-oauth:hover {
  background: var(--color-surface-2);
}

/* View toggle */
.view-toggle { background: transparent; border: 1px solid var(--color-border-interactive); }
.view-toggle.active { background: var(--color-primary); color: var(--color-text-inverse); border-color: var(--color-primary); }

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

/* Chips / pills */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px var(--space-3);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: background 0.15s;
}
.chip:hover { background: var(--color-primary-light); border-color: var(--color-primary); }

.chip-action { background: var(--color-primary-light); color: var(--color-primary); border-color: var(--color-primary); }
.chip-topic { font-size: 11px; color: var(--color-text-muted); }

/* Inputs */
.input {
  width: 100%;
  border: 1px solid var(--color-border-interactive);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--color-primary); outline: none; }
.input::placeholder { color: var(--color-text-muted); }

.input-error { border-color: var(--color-error) !important; background-color: var(--color-error-soft); }

.input-sm { padding: 6px 10px; font-size: var(--font-size-xs); }
.input-xs { padding: 3px 6px; font-size: 11px; }

.input-search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  padding-inline-start: 32px;
}

/* Avatars */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-error { background: var(--color-error-soft); color: var(--color-error); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-mode { background: var(--color-surface-2); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* Mode badge in top bar */
.mode-badge {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* Breadcrumb */
.breadcrumb {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.breadcrumb:hover { background: var(--color-surface-2); }

/* Session list item */
.session-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: background 0.12s ease;
  border-radius: 0;
  position: relative;
}
.session-item:hover { background: var(--color-surface-2); }
.session-item.active { background: var(--color-primary-light); }

.session-item-title {
  font-size: var(--font-size-sm);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-item-pending { color: var(--color-warning); font-size: 8px; }
.session-item-error { color: var(--color-error); font-size: 8px; }
.session-item-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.session-mode-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-3);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  line-height: 1.4;
  white-space: nowrap;
}
.session-item-ts {
  font-size: 10px;
  color: var(--color-text-faint);
  white-space: nowrap;
  margin-inline-start: auto;
}
.session-empty-msg {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--color-text-faint);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-muted);
  gap: var(--space-3);
  padding: var(--space-8);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.empty-state-description {
  font-size: 14px;
  color: var(--color-text-muted);
  max-width: 320px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px;
  text-align: center;
}
.empty-dot { font-size: 36px; color: var(--color-text-faint); margin-bottom: 8px; }
.empty-icon { font-size: 40px; line-height: 1; margin-bottom: 12px; }
.empty-title { font-size: var(--font-size-md); color: var(--color-text); font-weight: 600; margin-bottom: 6px; }
/* Orientation copy for a new session — this is the first thing a new user reads,
   so it is body-sized and readable, not the 12px afterthought it used to be. */
.empty-sub { font-size: var(--font-size-sm); color: var(--color-text-2); line-height: 1.65; max-width: 46ch; }

/* Starter prompts: one-click first messages so the composer is never a blank page. */
.empty-starters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  margin-top: var(--space-6);
  width: 100%;
  max-width: 46ch;
}

.empty-starters-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.empty-starter {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 10px 14px;
  text-align: start;
  font-family: inherit;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  color: var(--color-text-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.empty-starter:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
  background: var(--color-surface-2);
}

.empty-starter:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Spinner (indeterminate loading indicator, for actions where a skeleton
   placeholder doesn't fit — inline buttons, small async regions, overlays) */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.4s; }
  .btn:active { transform: none; }
}

/* Node chips (inline mono labels) */
.node-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 5px;
}

.version-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-primary);
  background: var(--color-primary-light);
  border-radius: 4px;
  padding: 1px 5px;
}

.version-chip.active-indicator {
  font-size: 11px;
  color: var(--color-success);
  background: transparent;
  padding: 1px 4px;
}

.status-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  border-radius: 4px;
  padding: 1px 6px;
}
.status-chip.pending { background: var(--color-warning-soft); color: var(--color-warning); }
.status-chip.error { background: var(--color-error-soft); color: var(--color-error); }
.status-chip.retrying { background: var(--color-warning-soft); color: var(--color-warning); }
/* A count of zero isn't a warning or an error -- neutralize whatever status
   color the chip's type would otherwise carry (#110). */
.status-chip.zero { background: var(--color-surface-raised); color: var(--color-text-faint); }

.health-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-faint);
  flex-shrink: 0;
}
.health-dot.ok { background: var(--color-success); }
.health-dot.error { background: var(--color-error); }

/* Day divider */
.day-divider {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  text-align: center;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

/* Agent card */
.agent-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
  background: var(--color-surface);
}
.agent-card-info { flex: 1; min-width: 0; }
.agent-card-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.version-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0 4px;
  flex-shrink: 0;
}
.agent-card-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-pick--added {
  opacity: 0.65;
  background: var(--color-surface-2);
}
.agent-pick-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.agent-added-badge {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-success);
  white-space: nowrap;
}

/* Sub-tab buttons inside a panel or modal (e.g. the Add-agent modal). */
.stab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 10px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: color 0.15s, border-color 0.15s;
}
.stab-btn:hover { color: var(--color-text); }
.stab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ── Right-panel sections (session-scoped properties) ─────────────────── */
.panel-empty-note {
  color: var(--color-text-faint);
  font-size: var(--font-size-xs);
}
.panel-section-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: 10px;
}
.panel-section-title-spaced { margin-top: 24px; }

.panel-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}
.panel-action-status {
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
}
.panel-secondary-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.settings-hint-warning {
  display: block;
  margin-top: 6px;
  font-size: var(--font-size-xs);
  color: var(--color-warning);
}

/* Side-by-side "global default vs. this session" readout. */
.scope-compare {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.scope-compare-cell {
  flex: 1;
  padding: 10px 12px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.scope-compare-label {
  font-size: 10px;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.scope-compare-value { font-size: 13px; font-weight: 500; }
.scope-compare-inherit { color: var(--color-text-faint); font-weight: 400; }

.key-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--color-surface-2);
}
.key-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
}
.key-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.key-provider-name { font-weight: 600; font-size: 13px; }
.key-masked { font-family: var(--font-mono); font-size: 11px; color: var(--color-text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-card-actions { display: flex; gap: 4px; flex-shrink: 0; }

.key-models-details { border-top: 1px solid var(--color-border); }
.key-models-summary {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.key-models-summary::-webkit-details-marker { display: none; }
.key-models-body { padding: 8px 12px; }

/* ── Toolbar: search + a status segmented control + bulk actions ────────── */
.key-models-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.model-filter { flex: 1 1 200px; max-width: 280px; }
.model-filter-group {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.model-filter-btn {
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: transparent;
  border: none;
  border-inline-end: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.model-filter-btn:last-child { border-inline-end: none; }
.model-filter-btn:hover { background: var(--color-surface-3); color: var(--color-text); }
.model-filter-btn.active { background: var(--color-primary); color: var(--color-text-inverse); }
.model-filter-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.key-models-bulk { display: flex; gap: 4px; margin-inline-start: auto; flex-shrink: 0; }

/* ── The model list: a CSS-grid table in disguise ─────────────────────────
   Every row (and the header) shares one column template via --model-cols,
   so checkbox / name / mapping / health / primary line up exactly no matter
   how long a model's name, id, or badge set is. A flex row with optional
   content lets longer rows push their mapping dropdown further right than
   shorter ones — every cell below always renders (even empty) to prevent
   that drift. */
.key-models-list {
  --model-cols: 20px minmax(170px, 1.3fr) 190px 52px 106px 24px;
  max-height: 420px;
  overflow-y: auto;
}
.key-models-rows { display: flex; flex-direction: column; gap: 1px; }

.model-list-head {
  display: grid;
  grid-template-columns: var(--model-cols);
  column-gap: 10px;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px 4px 6px;
  background: var(--color-surface-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.model-row {
  display: grid;
  grid-template-columns: var(--model-cols);
  column-gap: 10px;
  align-items: center;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.model-row:hover { background: var(--color-surface-3); }
/* Unmapped rows can't be enabled yet (see requiresLink in key-management.js)
   — dim them so mapped, actionable rows read first when scanning. */
.model-row[data-mapped="false"] .model-name,
.model-row[data-mapped="false"] .model-raw-id { color: var(--color-text-faint); }

.model-cell { min-width: 0; }
.model-cell-check { display: flex; align-items: center; }
.model-cell-mapping { display: flex; }
.model-cell-health { display: flex; align-items: center; gap: 4px; }
.model-cell-primary { display: flex; justify-content: flex-end; }
.model-cell-more { display: flex; justify-content: center; }

/* display:contents makes the label transparent to the grid, so its two
   children (checkbox cell + identity cell) become direct grid items while
   the label still forwards clicks anywhere in either cell to the checkbox. */
.model-check-identity { display: contents; }

.model-identity { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.model-cell-identity { cursor: pointer; }
.model-name {
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-meta-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.model-raw-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-badge {
  font-size: 10.5px;
  line-height: 1;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: default;
  white-space: nowrap;
  flex-shrink: 0;
}
.model-price {
  color: var(--color-text-muted);
  background: var(--color-surface-3);
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
}
.model-speed {
  background: transparent;
}
.model-new {
  color: var(--color-success);
  background: var(--color-success-soft);
  font-weight: 500;
}
.model-deprecated {
  color: var(--color-warning);
  background: var(--color-warning-soft);
  font-weight: 500;
  cursor: help;
}
/* Left-edge warning tint so a deprecated row still reads at a glance once
   its badge scrolls out of view in a long, narrow panel. */
.model-row.is-deprecated {
  box-shadow: inset 3px 0 0 var(--color-warning);
  background: var(--color-warning-soft);
}
.model-row.is-deprecated:hover { background: var(--color-warning-soft); }

/* Capability overrides: a compact icon toggle instead of a per-row <details>
   that used to add a permanently-visible "▸ Capability overrides" line
   under every model, even collapsed — costly across 40+ rows. */
.model-overrides-toggle {
  width: 20px;
  height: 20px;
  padding: 0;
  min-height: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--color-text-faint);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.model-overrides-toggle:hover { background: var(--color-surface-3); color: var(--color-text); }
.model-overrides-toggle[aria-expanded="true"] { color: var(--color-primary); background: var(--color-primary-light); }
.model-overrides-toggle:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.model-overrides-panel {
  margin: 2px 4px 6px 30px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.model-overrides-panel textarea {
  width: 100%;
  font-size: 11px;
  font-family: var(--font-mono);
  resize: vertical;
}

@media (max-width: 700px) {
  .model-list-head { display: none; }
  .model-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 4px;
  }
  .model-check-identity { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; }
  .model-cell-mapping,
  .model-cell-health,
  .model-cell-primary { flex: 0 0 auto; }
  .model-overrides-panel { margin-inline-start: 4px; }
}

.add-key-form { margin-top: 12px; padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); }

.settings-field {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
}
.settings-field .input { margin-top: 4px; }
.settings-label { display: block; font-weight: 500; margin-bottom: 4px; }

.shortcuts-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.shortcuts-table th { text-align: start; padding: 4px 8px; border-bottom: 1px solid var(--color-border); font-weight: 600; color: var(--color-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.shortcuts-table td { padding: 5px 8px; border-bottom: 1px solid var(--color-border); }
.shortcuts-table tr:last-child td { border-bottom: none; }
kbd { font-family: var(--font-mono); font-size: 11px; background: var(--color-surface-3); border: 1px solid var(--color-border); border-radius: 3px; padding: 1px 5px; white-space: nowrap; }

.btn-xs { padding: 2px 6px; font-size: 11px; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.session-item-skeleton {
  height: 52px;
  margin: 0 var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    var(--color-surface-2) 25%, var(--color-border) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

/* DAG loading veil */
.dag-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-3);
  background: color-mix(in oklab, var(--color-bg) 70%, transparent);
  z-index: 5;
}

/* Stale node badge */
.stale-badge {
  font-size: 11px;
  color: var(--color-warning);
  background: var(--color-warning-soft);
  border-radius: 4px;
  padding: 1px 5px;
  margin-inline-start: 6px;
}

/* ── Agent bar chip picker (T067) ────────────────────────────────────── */
.agent-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px 10px 2px 7px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  color: var(--color-text-muted);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.agent-chip:hover { background: var(--color-surface-3); color: var(--color-text); }
.agent-chip:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.agent-chip.selected { background: var(--chip-color, var(--color-primary-light)); border-color: var(--chip-color, var(--color-primary)); color: var(--color-text); }
.agent-chip-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Agent card actions (T066) */
.agent-card { align-items: flex-start; }
.agent-card-actions { display: flex; gap: 2px; flex-shrink: 0; align-items: center; }
.agent-avatar { flex-shrink: 0; }

/* Context menu */
.ctx-menu {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  overflow: hidden;
  padding: 4px 0;
}
.ctx-item {
  display: block;
  width: 100%;
  text-align: start;
  background: none;
  border: none;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.1s;
}
.ctx-item:hover { background: var(--color-surface-2); }
.ctx-item-danger { color: var(--color-error); }
.ctx-item-danger:hover { background: var(--color-error-soft); }
.ctx-divider { border-top: 1px solid var(--color-border); margin: 4px 0; }

/* Session list indicators */
.session-item-content { flex: 1; min-width: 0; }
.session-item-indicators { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.session-item.deleting { opacity: 0.4; pointer-events: none; }
mark { background: oklch(from var(--color-warning) l c h / 0.30); color: inherit; border-radius: 2px; }

/* Mode picker (T072) — compact single-line rows; full name/description is
   shown once in mode-tab-header, so the switch list doesn't repeat it. */
.mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s;
}
.mode-option:hover { background: var(--color-surface-2); }
.mode-icon { font-size: 14px; flex-shrink: 0; }
.mode-name { font-size: 12px; font-weight: 500; }

/* Collapsed-by-default "Switch mode" disclosure in the Mode tab */
.mode-tab-switch { border-top: 1px solid var(--color-border); }
.mode-tab-switch > .mode-tab-section-title {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.mode-tab-switch > .mode-tab-section-title::-webkit-details-marker { display: none; }
.mode-tab-switch > .mode-tab-section-title::after {
  content: '\25BE';
  float: inline-end;
  color: var(--color-text-muted);
}
.mode-tab-switch[open] > .mode-tab-section-title::after { content: '\25B4'; }
.mode-tab-switch > :not(summary) { padding-inline: 6px; }
.mode-tab-switch > .mode-option:last-child { margin-bottom: 6px; }

/* Mode panel header — names the mode the session is actually in, so the
   picker's "switch modes from the mode badge" promise lands somewhere real. */
.mode-tab-header {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
}
.mode-tab-current {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.mode-tab-current-icon { font-size: 18px; line-height: 1; }
.mode-tab-current-label { font-size: var(--font-size-sm); font-weight: 600; color: var(--color-text); }
.mode-tab-current-desc {
  margin-top: 6px;
  font-size: var(--font-size-xs);
  line-height: 1.5;
  color: var(--color-text-2);
}
.mode-tab-section-title {
  padding: 12px 12px 6px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.mode-tab-empty {
  padding: 12px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Activation log entry (T072) */
.activation-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  flex-wrap: wrap;
}
.activation-entry:last-child { border-bottom: none; }

/* Stuck banner */
.stuck-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-warning-soft);
  border-bottom: 1px solid var(--color-border);
  padding: 8px 16px;
  font-size: 13px;
  color: var(--color-text-2);
}
.stuck-banner span { flex: 1; }

/* ── Graph node lifecycle states ─────────────────────────────────────────────
   These carried a card-wide `opacity` set inline (0.5–0.65), which dimmed the
   node's *text* to encode what its badge already said — small type at half
   contrast, the worst possible combination. De-emphasis now lives on the
   background tint and the avatar chip; the text stays readable. */
.gnode {
  background: var(--color-surface);
}

.gnode.deleted-card {
  background: color-mix(in oklch, var(--color-error) 15%, var(--color-surface));
}

.gnode.deprecated-card {
  background: color-mix(in oklch, var(--color-text-faint) 15%, var(--color-surface));
}

.gnode.orphaned-card {
  background: var(--color-surface-2);
}

.gnode.effectively-deleted-card {
  border-style: dashed !important;
  background: var(--color-surface-2);
}

/* The one channel still dimmed: the agent's colour chip, which is the loudest
   element on a card and carries no information the header doesn't repeat. */
.gnode.deleted-card .gnode-avatar,
.gnode.deprecated-card .gnode-avatar,
.gnode.effectively-deleted-card .gnode-avatar,
.gnode.orphaned-card .gnode-avatar {
  filter: grayscale(1);
  opacity: 0.55;
}

/* Hide deleted nodes when toggle is active */
.hide-deleted .gnode.deleted-card,
.hide-deleted .gnode.deprecated-card,
.hide-deleted .gnode.effectively-deleted-card,
.hide-deleted .gnode-agg.deleted-card,
.hide-deleted .gnode-agg.deprecated-card,
.hide-deleted .gnode-agg.effectively-deleted-card,
.hide-deleted .edge-deprecated,
.hide-deleted .edge-effectively-deleted,
.hide-deleted .revision-group {
  display: none;
}

/* Cost & Token Display */
#session-cost-counter {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
}

.session-cost-chip {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Mode picker (no-session welcome screen) ────────────────────────────────── */

/* justify-content:center here (not align-items) would clip-and-strand the
   top of the content the same way align-items did below — main-axis
   centering has the identical overflow bug on a row flex container. Keep
   this axis on plain start alignment. */
.mode-picker {
  display: flex;
  justify-content: center;
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
}

/* Vertical centering lives here as margin:auto rather than align-items on
   .mode-picker, because align-items:center on a scrollable flex container
   clips overflow off both the top and bottom of the centered item but only
   the bottom is reachable by scrolling — the top (e.g. the hero card) goes
   permanently out of reach once "Explore more modes" expands past the
   viewport. margin-block:auto collapses to 0 once content overflows, so
   scrolling reaches the very top. */
.mode-picker-inner {
  width: 100%;
  max-width: 580px;
  margin-block: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* On a phone, vertical centering puts the composer roughly mid-screen behind
   ~300px of dead space above the hero card, and it's the first thing a new
   session shows — every extra pixel between the top of the screen and where
   a thumb can start typing is friction. margin-block:0 (not align-items,
   see the comment above) keeps the no-clipping fix intact while starting the
   card right under the topbar instead of centered. */
@media (max-width: 767px) {
  .mode-picker-inner {
    margin-block: 0;
  }
}

.mode-picker-heading {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  text-align: center;
}

/* Hero card — Single Agent */
.mode-picker-hero {
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: box-shadow 0.15s ease;
}

.mode-picker-hero:hover {
  box-shadow: 0 0 0 1px var(--color-primary), var(--shadow-sm);
}

.mode-picker-hero-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.mode-picker-hero-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.mode-picker-hero-info {
  flex: 1;
  min-width: 0;
}

.mode-picker-hero-label {
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--color-text);
}

.mode-picker-hero-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}

.mode-picker-agent-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  background: none;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.mode-picker-agent-badge:hover {
  background: var(--color-primary-light);
}

.mode-picker-agent-caret {
  font-size: 9px;
  margin-inline-start: 2px;
  opacity: 0.7;
}

.mode-picker-agent-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-picker-agent-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: var(--font-size-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: background 0.1s ease, border-color 0.1s ease;
}

.mode-picker-agent-option:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
}

.mode-picker-agent-option.selected {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.mode-picker-agent-option-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: 1.3;
}

.mode-picker-hero-input {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.mode-picker-hero-input .input {
  flex: 1;
}

.mode-picker-textarea {
  resize: none;
  overflow-y: auto;
  max-height: 160px;
  line-height: 1.4;
  font-family: var(--font-sans);
}

/* Special card — Free Form */
.mode-picker-special {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mode-picker-special:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-2);
}

.mode-picker-special-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.mode-picker-special-body {
  flex: 1;
  min-width: 0;
}

.mode-picker-special-label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.mode-picker-special-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}

.mode-picker-special-btn {
  flex-shrink: 0;
}

/* Other modes section */
.mode-picker-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mode-picker-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mode-picker-section-title:hover {
  color: var(--color-text);
}

.mode-picker-section-caret {
  transition: transform 0.15s ease;
}

.mode-picker-section-title.is-expanded .mode-picker-section-caret {
  transform: rotate(180deg);
}

/* Wide enough for the description to sit on the card. The description is the
   only thing that teaches what a mode does, so it must never go back into a
   title= tooltip: 1s hover delay, invisible on touch, unreadable to AT. */
.mode-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-2);
}

.mode-picker-grid.is-collapsed {
  display: none;
}

.mode-picker-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  width: 100%;
  min-height: 36px;
  padding: 10px 12px;
  text-align: start;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mode-picker-card:hover {
  border-color: var(--color-primary);
  background: var(--color-surface-2);
}

.mode-picker-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.mode-picker-card-icon {
  font-size: 18px;
  line-height: 1.3;
  flex-shrink: 0;
}

.mode-picker-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mode-picker-card-label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.mode-picker-card-desc {
  font-size: var(--font-size-xs);
  line-height: 1.5;
  color: var(--color-text-2);
}

/* Footnote */
.mode-picker-note {
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
  text-align: center;
}

/* ==================== BRANCH NUDGE ====================
   Sits between the thread and the composer, so it is on the path the user's eye
   already takes. Shown once, when a conversation first branches, to teach the
   one rule the product never stated: Timeline reads a path, Graph shows them
   all (review §4.2). */
.branch-nudge {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin: var(--space-2) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-inline-start: 3px solid var(--color-primary);
  border-radius: var(--radius-md);
}

.branch-nudge-text {
  flex: 1 1 260px;
  min-width: 0;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--color-text-2);
}

.branch-nudge-text strong {
  display: block;
  color: var(--color-text);
}

.branch-nudge-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ==================== MOBILE RESPONSIVE (max-width: 768px) ==================== */
@media (max-width: 768px) {

  /* === SESSION ITEMS: touch-friendly === */
  .session-item {
    padding: 12px var(--space-4);
    min-height: 44px;
  }

  /* === MODE PICKER: mobile layout === */
  .mode-picker {
    padding: var(--space-3);
  }

  .mode-picker-inner {
    max-width: 100%;
  }

  .mode-picker-hero {
    padding: var(--space-2) var(--space-3);
  }

  .mode-picker-special {
    padding: var(--space-2) var(--space-3);
  }
}

/* ==================== THEME SWITCHER ====================
   Deliberately mirrors .lang-switcher-option in i18n.css: both are option rows
   inside the account menu and must be visually indistinguishable. The rules are
   duplicated rather than shared because the locale option carries bidi and
   font-stack handling that a theme option must not inherit. */

.theme-switcher-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  inline-size: 100%;
  min-height: 36px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--font-size-base);
  text-align: start;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-switcher-option:hover {
  background: var(--color-surface-hover);
}

.theme-switcher-option:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

/* The check glyph is appended after the label, so push it to the trailing edge. */
.theme-switcher-option > svg:last-child {
  margin-inline-start: auto;
}

.theme-switcher-option svg {
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.theme-switcher-option[aria-selected="true"] {
  color: var(--color-primary);
  font-weight: 600;
}

.theme-switcher-option[aria-selected="true"] svg {
  color: var(--color-primary);
}
