/* Components: one class family per component in web/ds/*.js, from tokens only. The look follows
   the design prototype (quiet, dense: hairlines, flat 40px rows, one accent). Sections are in
   the order of docs/design/design-system.md. No inline styles (CSP). */

.ic { width: 1rem; height: 1rem; flex: none; }

/* ---------- Button, IconButton */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-height); padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg-raised); color: var(--fg);
  font: inherit; font-weight: var(--weight-medium); line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.btn:hover { background: var(--bg-muted); text-decoration: none; }
.btn:active:not(:disabled) { background: var(--bg-emphasis); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.8; }
.btn-sm { height: var(--control-height-sm); padding: 0 var(--space-2); gap: var(--space-1); font-size: var(--text-sm); }
.btn-sm .ic { width: 0.875rem; height: 0.875rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--fg-on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--bg-muted); color: var(--fg); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--fg-on-accent); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger:active:not(:disabled) { background: var(--danger-hover); }
.btn[aria-pressed="true"] { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent-text); }
.btn-icon { width: var(--control-height); padding: 0; }
.btn-icon.btn-sm { width: var(--control-height-sm); }
.btn-block { display: flex; width: 100%; }

/* ---------- Field, Input, Select, Textarea, Checkbox, RadioGroup */
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field-label, legend { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-muted); }
.field-hint { font-size: var(--text-sm); color: var(--fg-subtle); }
.field-error { font-size: var(--text-sm); color: var(--danger-text); }
.field-error::before { content: "⚠ "; }
select.select-sm { min-height: var(--control-height-sm); height: var(--control-height-sm); width: auto; padding-left: var(--space-2); font-size: var(--text-sm); }
.check { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); min-height: var(--control-height-sm); }
.check > label { cursor: pointer; }
.check > .field-hint { flex-basis: 100%; padding-left: calc(1rem + var(--space-2)); }
/* switch: a checkbox drawn as a toggle; keeps the native input, so keyboard and forms just work */
.check-switch input[type="checkbox"] {
  appearance: none; position: relative; width: 1.9rem; height: 1.1rem; margin: 0;
  border: 1px solid var(--border-control); border-radius: var(--radius-full); background: var(--bg-muted);
  cursor: pointer; transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.check-switch input[type="checkbox"]::after {
  content: ""; position: absolute; top: 1px; left: 1px; width: calc(1.1rem - 4px); height: calc(1.1rem - 4px);
  border-radius: 50%; background: var(--fg-subtle); transition: transform var(--duration) var(--ease), background var(--duration) var(--ease);
}
.check-switch input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.check-switch input[type="checkbox"]:checked::after { transform: translateX(0.8rem); background: var(--fg-on-accent); }
.radio-group { display: flex; flex-direction: column; gap: var(--space-1); }
.radio-inline { flex-direction: row; flex-wrap: wrap; gap: var(--space-1) var(--space-4); align-items: center; }
.radio-inline legend { flex-basis: 100%; }
.form-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-start; }
.form-row > .field { flex: 1 1 11rem; }
.form-row > .field-wide { flex: 2 1 16rem; }
/* buttons and checkboxes line up with the inputs, not the labels or hints above and below them */
.form-row > .btn, .form-row > .check { flex: none; margin-top: calc(var(--text-sm) * var(--leading) + var(--space-1)); }
.form-row > .check { min-height: var(--control-height); }
/* a compact one-line form (add a member): controls without visible labels, each with an aria-label */
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.inline-form > .field { flex: 0 1 auto; }
.inline-form > .inline-grow { flex: 1 1 14rem; }
.inline-form select { width: auto; }
.form { display: flex; flex-direction: column; gap: var(--space-3); max-width: 44rem; }
.form > .actions { margin-top: var(--space-1); }

/* ---------- SegmentedControl */
.segmented { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised); }
.segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-width: 2rem; height: 1.75rem; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg-subtle); font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer;
}
.segmented button:hover { color: var(--fg); }
.segmented button[aria-checked="true"] { background: var(--bg-emphasis); color: var(--fg); }
.segmented button .ic { width: 0.9rem; height: 0.9rem; }

/* ---------- Actions */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.actions-end { justify-content: flex-end; }
.confirm { display: inline-flex; gap: var(--space-1); align-items: center; }

/* ---------- Badge, Tag, Kbd */
.badge {
  display: inline-flex; align-items: center; gap: 0.2rem; height: 1.125rem; padding: 0 0.4rem;
  border-radius: var(--radius-sm); background: var(--bg-muted); color: var(--fg-muted);
  font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: 1; white-space: nowrap; vertical-align: middle;
}
.badge .ic { width: 0.7rem; height: 0.7rem; }
.badge-accent { background: var(--accent-subtle); color: var(--accent-text); }
.badge-warn { background: var(--warn-subtle); color: var(--warn-text); }
.badge-danger { background: var(--danger-subtle); color: var(--danger-text); }
.badge-success { background: var(--success-subtle); color: var(--success-text); }
.badge-plan { background: var(--plan-subtle); color: var(--plan); }
.badge-outline { background: transparent; border: 1px solid var(--border); }
.tag-link { color: var(--fg-muted); }
.tag-link:hover { color: var(--fg); text-decoration: none; background: var(--bg-emphasis); }
.tags { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); vertical-align: middle; }
.tag {
  display: inline-block; padding: 0 0.4rem; border-radius: var(--radius-sm);
  background: var(--bg-muted); color: var(--fg-muted); font: var(--text-xs)/1.25rem var(--font-mono); white-space: nowrap;
}
.kbd-group { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
.kbd {
  display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 0.3rem;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--radius-sm);
  background: var(--bg-raised); color: var(--fg-muted); font: var(--text-xs)/1 var(--font-sans);
}
.kbd-then { font-size: var(--text-xs); color: var(--fg-subtle); padding: 0 2px; }
.shortcut-hint { display: inline-flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* ---------- Identity: Avatar, UserLink, StatusDot, StatusPill, ToolMark, Role, KeyRole */
.avatar {
  --h: 270;
  display: inline-grid; place-items: center; flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: oklch(var(--av-l) var(--av-c) var(--h)); color: oklch(var(--av-fg-l) 0.08 var(--h));
  font-size: 0.6875rem; font-weight: var(--weight-semibold); line-height: 1;
}
.avatar-xxs { width: 1rem; height: 1rem; font-size: 0.5rem; }
.avatar-xs { width: 1.25rem; height: 1.25rem; font-size: 0.5625rem; }
.avatar-lg { width: 3.5rem; height: 3.5rem; font-size: var(--text-lg); }
.avatar-bot { --h: 200; border-radius: var(--radius); }
.avatar .ic { width: 70%; height: 70%; }
.avatar-more { background: var(--bg-muted); color: var(--fg-muted); }
.hue0 { --h: 20; } .hue1 { --h: 272; } .hue2 { --h: 150; } .hue3 { --h: 60; } .hue4 { --h: 320; } .hue5 { --h: 220; }
.avatar-stack { display: inline-flex; vertical-align: middle; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg-raised); }
.avatar-stack .avatar + .avatar { margin-left: -0.3rem; }
.who { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--fg); }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--border-strong); }
.dot-running { background: var(--success); box-shadow: 0 0 0 3px var(--success-subtle); animation: ds-pulse 2s ease-in-out infinite; }
.dot-ended-unknown { background: transparent; border: 1.5px solid var(--warn); }
.dot-unknown { background: transparent; border: 1.5px solid var(--border-control); }
@keyframes ds-pulse { 50% { box-shadow: 0 0 0 5px transparent; } }
@media (prefers-reduced-motion: reduce) { .dot-running { animation: none; } }
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem; height: 1.375rem; padding: 0 0.55rem;
  border: 1px solid var(--border); border-radius: var(--radius-full); color: var(--fg-muted); font-size: var(--text-sm);
}
.pill-running { color: var(--success-text); border-color: var(--success-border); }
.tool-mark {
  display: inline-grid; place-items: center; flex: none; width: 1.25rem; height: 1rem; border-radius: 3px;
  font: 700 0.5625rem/1 var(--font-mono); letter-spacing: 0.02em; color: oklch(0.99 0 0);
}
.tool-claude-code { background: var(--tool-cc); }
.tool-codex { background: var(--tool-cx); }
:root[data-theme="dark"] .tool-mark { color: oklch(0.17 0.02 272); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tool-mark { color: oklch(0.17 0.02 272); } }
.role { font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--fg-muted); }
.role-owner { color: var(--accent-text); }
.key-role { display: inline-block; padding: 0 0.4rem; border: 1px solid currentColor; border-radius: var(--radius-sm); font: var(--weight-semibold) var(--text-xs)/1.125rem var(--font-mono); }
.key-role-full { color: var(--danger-text); }
.key-role-read { color: var(--tool-cx); }
.key-role-upload { color: var(--success-text); }

/* ---------- CopyButton, Cmd, CodeBlock, Secret */
.cmd { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; text-align: left; }
.cmd-line {
  display: flex; align-items: center; gap: var(--space-1); min-width: 0;
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--code-bg);
}
.cmd code { flex: 1; min-width: 0; padding: 0.3rem 0; background: none; color: var(--fg); font-size: var(--text-sm); white-space: nowrap; overflow-x: auto; }
.cmd-prompt { color: var(--fg-subtle); user-select: none; }
.cmd-note { font-size: var(--text-sm); color: var(--fg-muted); }
.cmd-unsafe { padding: 0 var(--space-2); font-size: var(--text-xs); color: var(--danger-text); white-space: nowrap; }
.code-block { position: relative; min-width: 0; }
.code-block pre { max-height: 32rem; background: var(--code-bg); white-space: pre-wrap; word-break: break-word; font-size: var(--text-sm); }
.code-block-copy { position: absolute; top: var(--space-1); right: var(--space-1); }
.secret {
  display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3);
  border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent-subtle);
}
.secret-head { display: flex; align-items: center; gap: var(--space-2); color: var(--fg); }
.secret-head .ic { color: var(--accent-text); }
.secret-value { display: flex; gap: var(--space-1); }
.secret-value input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: var(--text-sm); background: var(--bg-raised); }
.secret-note { font-size: var(--text-sm); color: var(--fg-muted); }

/* ---------- MetaList */
.meta-list { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.meta-item { display: contents; }
.meta-list dt { color: var(--fg-muted); }
.meta-list dd { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); min-width: 0; margin: 0; }
.meta-list dd pre { flex: 1; margin: 0; max-height: 20rem; font-size: var(--text-sm); white-space: pre-wrap; word-break: break-word; }
.meta-inline { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.meta-inline .meta-item { display: inline-flex; gap: var(--space-1); }
.meta-inline dt::after { content: ":"; }

/* ---------- EmptyState, Skeleton, Spinner, Notice */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-12) var(--space-4); text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.empty-icon { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: var(--radius-lg); background: var(--accent-subtle); color: var(--accent-text); }
.empty-icon .ic { width: 1.4rem; height: 1.4rem; }
.empty-title { font-weight: var(--weight-semibold); font-size: var(--text-md); }
.empty-body { max-width: 34rem; color: var(--fg-muted); }
.empty .cmd { width: min(34rem, 100%); }
.empty-big { border: 0; padding-top: 12vh; }
.empty-code { font-size: 3rem; font-weight: var(--weight-semibold); line-height: 1; letter-spacing: -0.04em; color: var(--fg-subtle); }
.empty-danger .empty-icon { background: var(--danger-subtle); color: var(--danger-text); }
.empty-success .empty-icon { background: var(--success-subtle); color: var(--success-text); }
.skeleton { display: flex; flex-direction: column; }
.skeleton[aria-busy="true"]::before { content: none; }
.skeleton-row { display: flex; align-items: center; gap: var(--space-3); height: var(--row-height); padding: 0 var(--space-2); border-bottom: 1px solid var(--border); }
.skeleton-text .skeleton-row { height: 1.5rem; border: 0; padding: 0; }
.skeleton-block .skeleton-row { height: 8rem; border: 0; padding: 0; }
.skeleton-block .sk-main { width: 100%; height: 100%; border-radius: var(--radius-lg); }
.sk {
  display: block; height: 0.7rem; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-muted), var(--border), var(--bg-muted)) 0 0 / 200% 100%;
  animation: ds-shimmer 1.4s linear infinite;
}
.sk-lead { width: 0.5rem; height: 0.5rem; border-radius: 50%; }
.sk-w0 { width: 42%; } .sk-w1 { width: 58%; } .sk-w2 { width: 35%; } .sk-w3 { width: 50%; }
.sk-meta { width: 8rem; margin-left: auto; }
@keyframes ds-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.spinner { display: flex; align-items: center; gap: var(--space-1); color: var(--fg-muted); }
.spinner > span[aria-busy="true"]::before { margin-right: var(--space-1); }
.notice {
  display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-subtle); color: var(--fg-muted); font-size: var(--text-sm);
}
.notice > .ic { margin-top: 0.15rem; }
.notice strong { color: var(--fg); }
.notice-success { background: var(--success-subtle); border-color: var(--success-border); color: var(--success-text); }
.notice-warn { background: var(--warn-subtle); border-color: var(--warn-border); color: var(--warn-text); }
.notice-danger { background: var(--danger-subtle); border-color: var(--danger-border); color: var(--danger-text); }
.notice-success strong, .notice-warn strong, .notice-danger strong { color: inherit; }

/* ---------- Stat */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised); overflow: hidden; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: var(--space-4) var(--space-5); box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border); }
.stat-label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-subtle); }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat-sub { font-size: var(--text-sm); color: var(--fg-subtle); overflow-wrap: anywhere; }

/* ---------- Figures */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--space-4); padding: var(--space-4) 0; border-block: 1px solid var(--border); }
.figure { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.figure dt { font-size: var(--text-sm); color: var(--fg-subtle); }
.figure dd { margin: 0; font-size: var(--text-2xl); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.figure dd.figure-sub { font-size: var(--text-sm); font-weight: var(--weight-normal); color: var(--fg-muted); letter-spacing: 0; }
@media (max-width: 719.98px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Bars, Spark, ShareBar (SVG attributes; colours from tokens) */
.bars { margin: 0; }
.bars svg { display: block; width: 100%; height: 4.5rem; }
.bars .bar { fill: var(--border-strong); }
.bars .bar.is-last { fill: var(--accent); }
.bars .axis { stroke: var(--border); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.bars figcaption { display: flex; justify-content: space-between; padding-top: var(--space-1); font-size: var(--text-xs); color: var(--fg-subtle); }
.spark { display: inline-block; width: 7rem; vertical-align: middle; }
.spark .bars svg { height: 1.25rem; }
.share-bar { display: block; width: 100%; height: 4px; }
.share-bar .track { fill: var(--bg-muted); }
.share-bar .fill { fill: var(--accent); }
@media (forced-colors: active) { .bars .bar, .share-bar .fill { fill: CanvasText; } .bars .bar.is-last { fill: Highlight; } }

/* ---------- ModelMark */
.model-mark { display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; }
.more-models { padding: 0 0.3rem; border: 1px solid var(--border); border-radius: var(--radius-full); font-size: var(--text-xs); color: var(--fg-subtle); cursor: help; }

/* ---------- Sessions and projects: SessionRow, SessionMeta, OutputChip, ProjectCard */
.live { color: var(--success-text); font-weight: var(--weight-medium); }
.row-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-lines .row-title { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.row-project { color: var(--fg-muted); }
.row-project::before { content: ""; display: inline-block; width: 0.4rem; height: 0.4rem; margin-right: 0.3rem; border-radius: 2px; background: var(--fg-subtle); vertical-align: 0.1em; }
.session-meta { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.sep { color: var(--fg-subtle); }
.output-chip { display: inline-flex; align-items: baseline; gap: var(--space-2); margin: 0 var(--space-2) var(--space-2) 0; padding: var(--space-1) var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm); }
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.project-card { display: flex; flex-direction: column; gap: 2px; min-width: 0; height: 100%; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised); color: var(--fg); }
.project-card:hover { border-color: var(--border-strong); text-decoration: none; }
.project-card-name { font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card-remote { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Sessions home: Pulse strip and the rail; the session page's output view */
.pulse { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-8); align-items: end; }
.pulse .figures { border: 0; padding: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pulse-chart { display: flex; flex-direction: column; gap: var(--space-2); margin: 0; }
.pulse-chart > figcaption { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); color: var(--fg-muted); }
.pulse-chart .bars svg { height: 3.5rem; }
.rail-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.rail-list a { display: flex; flex-direction: column; gap: 2px; margin: 0 calc(-1 * var(--space-2)); padding: var(--space-2); border-radius: var(--radius); color: var(--fg); min-width: 0; }
.rail-list a:hover { background: var(--bg-muted); text-decoration: none; }
.rail-list a.rail-row { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-3); }
.rail-lines { display: flex; flex-direction: column; min-width: 0; }
.rail-title { font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rail-end { display: inline-flex; align-items: center; gap: var(--space-2); flex: none; }
.rail-end .spark { width: 4.5rem; }
.output-note { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.output-note > span:first-child { flex: 1 1 20rem; }
@media (max-width: 1100px) { .pulse { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 719.98px) { .pulse .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- History (Round 48): SyncRow, SyncCounts, SyncErrors, SyncStatus */
.sync-list .row-outcome { overflow: visible; white-space: normal; }
.sync-counts { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }
.sync-client { font-size: var(--text-sm); font-weight: var(--weight-normal); }
.sync-list .row-detail { flex-wrap: wrap; white-space: normal; }
/* in a narrow column the client goes under the machine instead of squeezing it */
@container (max-width: 40rem) { .sync-list .row-lines .row-title { flex-wrap: wrap; row-gap: 0; } .sync-client { flex-basis: 100%; } }
.sync-status { display: inline-flex; flex: none; }
.sync-errors { border-color: var(--danger-border); background: transparent; font-size: var(--text-sm); }
.sync-errors > summary { min-height: var(--control-height-sm); padding: 0 var(--space-3); font-weight: var(--weight-normal); color: var(--danger-text); }
.sync-errors > summary:hover { background: var(--danger-subtle); }
.sync-errors[open] > summary { border-bottom-color: var(--danger-border); }
.sync-errors .disclosure-body { padding: var(--space-2) var(--space-3); }
.sync-errors-sum { display: inline-flex; align-items: center; gap: var(--space-1); }
.sync-error-list { display: flex; flex-direction: column; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.sync-error-list li { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); overflow-wrap: anywhere; }
p.sync-not-sent { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.page-note { max-width: var(--measure); }

/* ---------- Card, Disclosure */
.card { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; padding: var(--panel-pad); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card-title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.section-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--fg-muted); }
.card-body { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.card-accent { border-color: var(--accent); }
.disclosure { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised); }
.disclosure > summary {
  display: flex; align-items: center; gap: var(--space-2); min-height: var(--row-height-table); padding: 0 var(--space-4);
  font-weight: var(--weight-medium); cursor: pointer; list-style: none; border-radius: var(--radius-lg);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { background: var(--bg-subtle); }
.disclosure-caret { color: var(--fg-subtle); transition: transform var(--duration) var(--ease); }
.disclosure[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.disclosure[open] .disclosure-caret { transform: rotate(90deg); }
.disclosure-body { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--panel-pad); }

/* ---------- PageHeader */
.page { display: flex; flex-direction: column; gap: var(--gap-page); width: 100%; max-width: var(--content-max); margin: 0 auto; }
.page-header h1 { font-size: var(--text-title); letter-spacing: -0.015em; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-width); gap: var(--gap-split); align-items: start; }
.split-main { display: flex; flex-direction: column; gap: var(--gap-section); min-width: 0; }
.split-rail { position: sticky; top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } .split-rail { position: static; } }
.page-header { display: flex; flex-direction: column; gap: var(--space-2); }
.page-header-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-4); }
.page-header-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; flex: 1; }
.page-header-row:has(.page-header-lead) { align-items: center; }
.page-header-lead { flex: none; }
.page-subtitle { color: var(--fg-muted); max-width: var(--measure); }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); color: var(--fg-muted); font-size: var(--text-sm); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: var(--space-1); padding: 0; list-style: none; font-size: var(--text-sm); color: var(--fg-muted); }
.crumbs li + li::before { content: "/"; margin-right: var(--space-1); color: var(--fg-subtle); }
.crumbs a { color: var(--fg-muted); }
.section { display: flex; flex-direction: column; gap: var(--space-4); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: var(--space-6); align-items: start; }
.card-narrow { max-width: 40rem; }
.danger-zone { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.danger-zone h3 { font-size: var(--text-base); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.section-head h2 { font-size: var(--text-md); }

/* ---------- Table, List, ListRow */
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline-offset: 0; }
.table th { height: auto; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border);
  font-size: var(--text-sm); font-weight: var(--weight-medium); text-transform: none; letter-spacing: 0; color: var(--fg-subtle); }
.table th:first-child, .table td:first-child { padding-left: var(--space-2); }
.table td { height: var(--row-height-table); padding: var(--space-1) var(--space-3); }
.table tbody tr:hover { background: var(--bg-muted); }
/* RowLink: the row's title is the link and the whole row is its hit target (a stretched link) */
.table tr:has(.row-link) { position: relative; cursor: pointer; }
.row-link { color: var(--fg); font-weight: var(--weight-medium); }
.row-link:hover { text-decoration: none; }
.row-link::after { content: ""; position: absolute; inset: 0; }
.row-link:focus-visible { outline: 2px solid transparent; }
.row-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--radius-sm); }
.table td .actions, .table td button, .table td select, .table td .check { position: relative; z-index: 1; }
.table-compact td { height: 2rem; font-size: var(--text-sm); }
.table tr.is-dim td { color: var(--fg-subtle); }
.table td .actions { flex-wrap: nowrap; }
.list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.row-main {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--row-height); padding: var(--space-2) var(--space-3);
  border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--fg); font: inherit; text-align: left;
}
a.row-main, button.row-main { cursor: pointer; }
a.row-main:hover, button.row-main:hover { background: var(--bg-muted); text-decoration: none; }
.row-main:focus-visible { outline-offset: -2px; }
.list-row.is-current .row-main { background: var(--bg-emphasis); box-shadow: inset 0 0 0 1px var(--accent); }
.row-lead { display: inline-flex; align-items: center; flex: none; }
.row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--weight-medium); }
.row-meta { flex: none; color: var(--fg-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.row-trail { display: inline-flex; align-items: center; gap: var(--space-2); flex: none; }
.row-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-lines .row-title { flex: none; }
.row-outcome { max-width: var(--measure); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); color: var(--fg-muted); }
.row-detail { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--space-1) var(--space-3); min-width: 0; overflow: hidden; white-space: nowrap; font-size: var(--text-sm); color: var(--fg-subtle); }
.row-detail > * { flex: none; }
.row-detail > :last-child, .row-detail > .detail-shrink, .row-detail > .model-mark { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row-detail > .model-mark > .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row-after { padding: 0 var(--space-3) var(--space-2); }
.list-group { list-style: none; }
.list-group-rows { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.group-h {
  position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: baseline; gap: var(--space-2);
  padding: var(--space-5) var(--space-3) var(--space-2); background: var(--bg);
  font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--fg-muted);
}
.list-group:first-child .group-h { padding-top: var(--space-2); }

/* In a narrow column (a Split main, a phone) the meta goes under the title instead of squeezing it. */
.list { container-type: inline-size; }
@container (max-width: 40rem) {
  /* the title may take two lines; the meta (a time, or "live") stays on line 1, right-aligned */
  .row-main { align-items: flex-start; }
  .row-main .row-lead { margin-top: 0.45rem; }
  .row-lines .row-title, .row-title-text { white-space: normal; }
  .row-meta { margin-top: 0.1rem; }
  /* the detail line keeps what tells sessions apart; you, bucket and id8 are on the session page */
  .row-detail > .detail-minor { display: none; }
}

/* ---------- Tabs */
.tabs { display: flex; gap: var(--space-4); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs [role="tab"], .tabs a {
  display: inline-flex; align-items: baseline; gap: var(--space-1); margin-bottom: -1px; padding: var(--space-2) 0;
  border: 0; border-bottom: 2px solid transparent; background: none; color: var(--fg-muted);
  font: inherit; font-weight: var(--weight-medium); white-space: nowrap; cursor: pointer;
}
.tabs a { padding: var(--space-3) 0; }
.tabs [role="tab"]:hover, .tabs a:hover { color: var(--fg); text-decoration: none; }
.tabs [role="tab"][aria-selected="true"], .tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab-count { font-size: var(--text-xs); color: var(--fg-subtle); font-variant-numeric: tabular-nums; }
.tab-panel { padding-top: var(--space-4); }
.tab-panel:focus-visible { outline-offset: 4px; }

/* ---------- SearchField, FilterChip, Menu, popover */
.search {
  display: flex; align-items: center; gap: var(--space-2); height: var(--search-height); padding: 0 var(--space-3);
  border: 1px solid var(--border-control); border-radius: var(--radius); background: var(--bg-raised); color: var(--fg-subtle);
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 25%, transparent); }
.search input, .search input:focus { flex: 1; min-width: 0; height: 100%; min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; outline: 2px solid transparent; }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1); height: 2rem; padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-full); background: var(--bg-raised);
  color: var(--fg-muted); font: inherit; font-size: var(--text-sm); cursor: pointer;
}
.chip:hover { background: var(--bg-muted); color: var(--fg); }
.chip.is-set { border-color: var(--accent); background: var(--accent-subtle); color: var(--fg); }
.chip .ic { width: 0.8rem; height: 0.8rem; }
.chip-clear { border-color: transparent; background: transparent; }
.toolbar { display: flex; flex-direction: column; gap: var(--space-2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.show-phone { display: none; }
.chip-label { white-space: nowrap; }
.chip-value { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--weight-semibold); color: var(--accent-text); }
.chip-value::before { content: ": "; color: var(--fg-muted); font-weight: var(--weight-normal); }
.caret { color: var(--fg-subtle); width: 0.85rem; height: 0.85rem; }
.menu { position: relative; display: inline-block; }
.menu-trigger { display: inline-flex; align-items: center; gap: var(--space-2); }
.popover {
  position: absolute; z-index: var(--z-popover); top: calc(100% + 4px); left: 0; min-width: 13rem; max-height: 20rem; overflow-y: auto;
  margin: 0; padding: var(--space-1); list-style: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised); box-shadow: var(--shadow-md);
}
.popover-end { left: auto; right: 0; }
.popover hr { margin: var(--space-1) 0; }
.menu-item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 2rem; padding: 0 var(--space-2);
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--fg); font: inherit; text-align: left; cursor: pointer;
}
.menu-item > span:first-of-type { flex: 1; }
.menu-item .ic { color: var(--fg-subtle); }
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-muted); text-decoration: none; outline: 2px solid transparent; }
.menu-item[aria-selected="true"] { font-weight: var(--weight-semibold); background: var(--bg-emphasis); }
.menu-danger, .menu-danger .ic { color: var(--danger-text); }
.menu-item.is-asking { background: var(--danger-subtle); color: var(--danger-text); font-weight: var(--weight-medium); }
.popover-sheet { padding: var(--space-4); min-width: 0; max-height: none; overflow: visible; display: flex; flex-direction: column; gap: var(--space-3); }
.popover-md { width: 24rem; max-width: calc(100vw - 2 * var(--space-4)); }
.popover-sm { width: 16rem; }
.menu-count { font-size: var(--text-xs); color: var(--fg-subtle); font-variant-numeric: tabular-nums; }
.menu-label { padding: var(--space-1) var(--space-2); font-size: var(--text-sm); color: var(--fg-muted); overflow-wrap: anywhere; }

/* ---------- Dialog, CommandPalette, ShortcutsDialog */
.dialog {
  width: min(28rem, calc(100% - 2 * var(--space-4))); max-height: calc(100% - 4rem); margin: 12vh auto auto; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised); color: var(--fg); box-shadow: var(--shadow-lg);
}
.dialog-lg { width: min(40rem, calc(100% - 2 * var(--space-4))); }
.dialog::backdrop { background: var(--bg-overlay); }
.dialog[open] { animation: ds-rise var(--duration) var(--ease); }
@keyframes ds-rise { from { transform: translateY(6px); opacity: 0.6; } }
.dialog-inner { display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: var(--text-md); }
.dialog-body { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); overflow-y: auto; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); background: var(--bg-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.palette .dialog-body { padding: 0; gap: 0; }
.palette-input { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4); border-bottom: 1px solid var(--border); color: var(--fg-subtle); }
.palette-input input, .palette-input input:focus { flex: 1; height: 3rem; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: var(--text-md); outline: 2px solid transparent; }
.palette-list { max-height: 22rem; margin: 0; padding: var(--space-1); overflow-y: auto; list-style: none; }
.palette-group { padding: var(--space-2) var(--space-2) var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-subtle); }
.palette-item { display: flex; align-items: center; gap: var(--space-2); min-width: 0; height: 2.25rem; padding: 0 var(--space-2); border-radius: var(--radius); cursor: pointer; }
.palette-item .ic { color: var(--fg-subtle); }
.palette-item.is-active { background: var(--bg-emphasis); }
.palette-item.is-active .ic { color: var(--accent-text); }
.palette-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { font-size: var(--text-xs); color: var(--fg-subtle); white-space: nowrap; }
.palette-none { padding: var(--space-4); color: var(--fg-muted); font-size: var(--text-sm); }
.palette-foot { display: flex; gap: var(--space-4); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); background: var(--bg-subtle); font-size: var(--text-xs); color: var(--fg-subtle); }
.palette-foot span { display: inline-flex; align-items: center; gap: var(--space-1); }
.shortcuts + .shortcuts { margin-top: var(--space-2); }
.shortcuts h3 { margin-bottom: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--fg-muted); }
.shortcuts dl { display: grid; grid-template-columns: 7rem 1fr; gap: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.shortcuts dl > div { display: contents; }
.shortcuts dd { margin: 0; color: var(--fg-muted); }

/* ---------- Toast */
.toasts {
  position: fixed; z-index: var(--z-toast); left: 50%; bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2); transform: translateX(-50%); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-radius: var(--radius-full);
  background: var(--fg); color: var(--bg); font-size: var(--text-sm); box-shadow: var(--shadow-md); animation: ds-rise var(--duration) var(--ease);
}
.toast-danger { background: var(--danger); color: var(--fg-on-accent); }

/* ---------- App shell: Brand, Sidebar, TopBar, TabBar, PlainShell */
.skip-link { position: absolute; left: var(--space-2); top: -3rem; z-index: var(--z-toast); padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--accent); color: var(--fg-on-accent); }
.skip-link:focus { top: var(--space-2); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); color: var(--fg); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 1.1rem; height: 1.1rem; border-radius: var(--radius-sm); flex: none;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 30% no-repeat,
    linear-gradient(var(--fg-subtle), var(--fg-subtle)) 0 50% / 70% 18% no-repeat,
    linear-gradient(var(--fg-subtle), var(--fg-subtle)) 0 100% / 45% 18% no-repeat;
}
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column; gap: var(--space-5); height: 100vh; padding: var(--space-4) var(--space-3);
  overflow-y: auto; border-right: 1px solid var(--border); background: var(--bg-subtle);
}
.palette-button {
  display: flex; align-items: center; gap: var(--space-2); height: var(--control-height); padding: 0 var(--space-2);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised); color: var(--fg-subtle); font: inherit; text-align: left; cursor: pointer;
}
.palette-button:hover { border-color: var(--border-strong); color: var(--fg-muted); }
.palette-button > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: var(--space-2); height: 2.25rem; padding: 0 var(--space-2); border-radius: var(--radius); color: var(--fg-muted); font-weight: var(--weight-medium); }
.nav-item:hover { background: var(--bg-muted); color: var(--fg); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--bg-emphasis); color: var(--fg); }
.nav-item[aria-current="page"] .ic { color: var(--accent-text); }
.nav-label { flex: 1; }
.nav-keys { opacity: 0; transition: opacity var(--duration) var(--ease); }
.nav-item:hover .nav-keys, .nav-item:focus-visible .nav-keys { opacity: 1; }
.side-sec { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.side-h { padding: 0 var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-subtle); }
.side-list { display: flex; flex-direction: column; gap: 1px; margin: 0; padding: 0; list-style: none; }
.side-link { display: flex; align-items: center; gap: var(--space-2); height: 1.75rem; padding: 0 var(--space-2); border-radius: var(--radius); color: var(--fg-muted); font-size: var(--text-sm); min-width: 0; }
.side-link:hover { background: var(--bg-muted); color: var(--fg); text-decoration: none; }
.side-link[aria-current="page"] { background: var(--bg-emphasis); color: var(--fg); }
.side-prefix { color: var(--fg-subtle); font-family: var(--font-mono); }
.side-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-none { padding: 0 var(--space-2); }
.sidebar-user { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-2); border-radius: var(--radius); color: var(--fg); line-height: var(--leading-tight); min-width: 0; }
.sidebar-user:hover { background: var(--bg-muted); text-decoration: none; }
.sidebar-user[aria-current="page"] { background: var(--bg-emphasis); }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); margin-top: auto; }
.sidebar-foot > * { max-width: 100%; }
.content { min-width: 0; padding: var(--page-pad) var(--page-pad) var(--space-16); }
.content:focus { outline: 2px solid transparent; }
.topbar, .tabbar { display: none; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-1); }
.plain { display: flex; flex-direction: column; min-height: 100vh; }
.plain-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.plain-main { flex: 1; width: 100%; max-width: calc(var(--content-max) + 2 * var(--page-pad)); margin: 0 auto; padding: var(--page-pad) var(--page-pad) var(--space-16); }
.plain-main:focus { outline: 2px solid transparent; }
.plain-narrow { max-width: calc(var(--content-narrow) + 2 * var(--page-pad)); padding-top: var(--space-12); }
.plain-main:not(.plain-narrow) { max-width: calc(56rem + 2 * var(--page-pad)); }
.plain-foot { padding: var(--space-4); text-align: center; border-top: 1px solid var(--border); }
/* AuthLayout: sign-in and its landing page */
.auth { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); min-height: 100vh; min-height: 100dvh; padding: var(--space-6) var(--space-4); background: var(--bg-subtle); }
.auth-actions { position: absolute; top: var(--space-3); right: var(--space-3); }
.auth-card { display: flex; flex-direction: column; gap: var(--space-4); width: min(24rem, 100%); padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised); }
.auth-card:focus { outline: 2px solid transparent; }
.auth-card h1 { font-size: var(--text-xl); }
.auth-center { align-items: center; text-align: center; }
.auth-center .secret, .auth-center .form { align-self: stretch; text-align: left; }
.auth-center .actions { justify-content: center; }
.brand-big { padding: 0; font-size: var(--text-lg); }
.auth-foot { text-align: center; }
.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--fg-subtle); font-size: var(--text-sm); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Phones: the sidebar becomes a top bar and a bottom tab bar */
@media (max-width: 719.98px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: var(--z-nav); display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); padding-top: calc(var(--space-2) + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border); background: var(--bg-subtle);
  }
  .tabbar {
    position: fixed; z-index: var(--z-nav); left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--border); background: var(--bg-subtle);
  }
  .tabbar .nav-item { flex-direction: column; justify-content: center; gap: 2px; height: auto; border-radius: 0; color: var(--fg-subtle); font-size: 0.6875rem; }
  .tabbar .nav-item .ic { width: 1.25rem; height: 1.25rem; }
  .tabbar .nav-item .nav-label { flex: none; }
  .tabbar .nav-item[aria-current="page"] { background: transparent; color: var(--accent-text); }
  .content { padding: var(--page-pad) var(--page-pad) calc(var(--tabbar-height) + var(--space-8)); }
  .toasts { bottom: calc(var(--tabbar-height) + var(--space-4) + env(safe-area-inset-bottom, 0px)); }
  .plain-narrow { padding-top: var(--space-6); }
  .search-hint, .nav-keys { display: none; }
  .page-actions { width: 100%; }
  .meta-list { grid-template-columns: 6rem minmax(0, 1fr); }
  .dialog { margin-top: var(--space-4); }
  .menu { position: static; }
  .popover { left: var(--space-4); right: var(--space-4); }
  .hide-phone { display: none; }
  .show-phone { display: block; }
  /* tables keep their natural width and scroll inside .table-wrap rather than squeezing text columns */
  .table { width: max-content; min-width: 100%; }
  .table td { max-width: 16rem; }
}

/* ---------------------------------------------------------------- prose (rendered Markdown) */
.prose { min-width: 0; overflow-wrap: anywhere; }
.prose > * + * { margin-top: var(--space-3); }
.prose :is(h2, h3, h4, h5, h6) { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.prose :is(ul, ol) { padding-left: var(--space-5); }
.prose li + li { margin-top: var(--space-1); }
.prose pre { overflow-x: auto; padding: var(--space-3); border-radius: var(--radius); background: var(--code-bg); font-size: var(--text-sm); }
.prose blockquote { padding-left: var(--space-3); border-left: 3px solid var(--border-strong); color: var(--fg-muted); }
.prose h1 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.prose h2 { padding-top: var(--space-2); font-size: var(--text-lg); }
.prose :is(h1, h2, h3, h4, h5, h6) { scroll-margin-top: var(--space-6); }
.prose pre code { padding: 0; background: none; }
.prose hr { border: 0; border-top: 1px solid var(--border); }
.prose img { max-width: 100%; }
/* a Markdown table scrolls inside itself on a phone instead of widening the page */
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: var(--text-sm); }
.prose :is(th, td) { height: auto; padding: var(--space-1) var(--space-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { font-weight: var(--weight-semibold); color: var(--fg-muted); white-space: normal; }
/* a column's alignment (`|--:|`) arrives as a class: the CSP allows no style attributes */
.prose :is(th, td).align-right { text-align: right; }
.prose :is(th, td).align-center { text-align: center; }
.prose td { min-width: 6rem; max-width: 32rem; }
.prose td:first-child { min-width: 0; }

/* ---------------------------------------------------------------- the lab (D37) */
.lab-sources { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); font-size: var(--text-sm); color: var(--fg-muted); }
.lab-source { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.lab-source strong { color: var(--fg); }
.lab-unreadable { color: var(--warn-text); }
.lab-head { padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); background: var(--bg-muted); }
.lab-file-list { display: flex; flex-direction: column; gap: var(--space-1); padding: 0; list-style: none; font-size: var(--text-sm); }
.lab-file-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); overflow-wrap: anywhere; }
.lab-file-list .subtle { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- native chat (share.json, Round 40) */
.chat { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-width); gap: var(--gap-split); align-items: start; }
.chat-main { display: flex; flex-direction: column; gap: var(--gap-section); min-width: 0; max-width: var(--measure); }
.chat-rail { position: sticky; top: var(--space-4); max-height: calc(100vh - var(--space-8)); overflow-y: auto; }
@media (max-width: 1100px) { .chat { grid-template-columns: minmax(0, 1fr); } .chat-rail { display: none; } }
.chat-head { display: flex; flex-direction: column; gap: var(--space-2); }
.chat-trust { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chat-summary { gap: var(--space-4); }
.chat-turns { display: flex; flex-direction: column; gap: var(--space-8); }
.chat-turn { display: flex; flex-direction: column; gap: var(--space-3); scroll-margin-top: var(--space-6); }
.chat-turn.is-target .chat-prompt { box-shadow: 0 0 0 2px var(--focus); }
.chat-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--fg-muted); }
.chat-label a { text-decoration: none; }
.chat-prompt { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); background: var(--accent-subtle); }
.chat-mid-turn .chat-prompt { background: var(--bg-muted); }
.chat-assistant { display: flex; flex-direction: column; gap: var(--space-3); padding-left: var(--space-4); border-left: 2px solid var(--border); }
.chat-tools { display: flex; flex-direction: column; gap: var(--space-1); padding: 0; list-style: none; font-size: var(--text-sm); }
.chat-tool { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; color: var(--fg-muted); }
.chat-tool .ic { flex: none; }
.chat-tool-name { color: var(--fg); }
.chat-tool-label { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.chat-tool.is-failed { color: var(--danger-text); }
.chat-agent { font-size: var(--text-sm); }
.chat-agent > p { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.chat-agent .ic { flex: none; }
.chat-compaction { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-xs); color: var(--fg-subtle); }
.chat-compaction::before, .chat-compaction::after { content: ""; flex: 1 0 1.5rem; border-top: 1px dashed var(--border-strong); }
.chat-compaction > span { text-align: center; }
.chat-index ol { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-2); padding: 0; list-style: none; font-size: var(--text-sm); }
.chat-index a { display: block; overflow: hidden; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); color: var(--fg-muted); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.chat-index a:hover { background: var(--bg-muted); color: var(--fg); }

/* ---------------------------------------------------------------- lenses (D29 B3). lens-* classes are the
   manager's frontend contract: defaults.js and vendored modules build them, the host styles them. */
.lens-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: var(--space-4); }
.lens-card .card-title a { color: inherit; text-decoration: none; }
.lens-card .card-title a:hover { text-decoration: underline; }
.lens-slot { min-width: 0; }
.lens-widget, .lens-overview { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.lens-line { overflow-wrap: anywhere; }
.lens-items { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.lens-item { display: inline-flex; align-items: baseline; gap: var(--space-1); }
.lens-value { font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }
.lens-label { color: var(--fg-muted); font-size: var(--text-sm); }
.lens-state { font-size: var(--text-sm); color: var(--fg-muted); }
.lens-state.stale { color: var(--warn-text); }
.lens-state.failed { color: var(--danger-text); }
.lens-md { min-width: 0; overflow-wrap: anywhere; }
.lens-plain p { white-space: pre-wrap; } /* Markdown the renderer could not draw, shown as its text */
.lens-md > * + * { margin-top: var(--space-3); }
.lens-md :is(ul, ol) { padding-left: var(--space-5); }
.lens-md pre, .lens-json pre { overflow-x: auto; padding: var(--space-3); border-radius: var(--radius); background: var(--code-bg); font-size: var(--text-sm); }
.lens-md blockquote, .lens-prompt { padding-left: var(--space-3); border-left: 3px solid var(--border-strong); color: var(--fg-muted); }
.lens-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-1) var(--space-4); font-size: var(--text-sm); }
.lens-meta dt { color: var(--fg-muted); }
.lens-table { width: 100%; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.lens-overview .lens-table { display: block; overflow-x: auto; }
.lens-files ul { padding-left: var(--space-5); }
/* an html lens page (D38): the frame takes the full width and the visible height; it inherits the app's
   color-scheme, so a page that follows prefers-color-scheme follows the app's theme (Chrome and Firefox map
   the frame's media query to the iframe's color-scheme); transparent, so the page's own background shows */
.lens-frame { display: block; width: 100%; height: max(28rem, calc(100dvh - 10rem)); border: 1px solid var(--border); border-radius: var(--radius); background: transparent; }
@media (max-width: 640px) { .lens-frame { height: max(24rem, calc(100dvh - 8rem)); } }
.lens-page.is-frame { grid-template-columns: minmax(0, 1fr); }
.lens-page.is-frame .lens-page-rail { max-width: 40rem; }
.lens-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.lens-toolbar-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.lens-viewing { color: var(--fg-muted); overflow-wrap: anywhere; }
.lens-page-body > .lens-slot + .lens-slot { margin-top: var(--space-6); }
.lens-page { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-width); gap: var(--gap-split); align-items: start; }
.lens-page-body { min-width: 0; }
.lens-page-rail { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
@media (max-width: 1100px) { .lens-page { grid-template-columns: minmax(0, 1fr); } }
.lens-page-line { color: var(--fg-muted); }
.lens-file-list { display: flex; flex-direction: column; gap: var(--space-1); padding: 0; list-style: none; font-size: var(--text-sm); }
.lens-file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); overflow-wrap: anywhere; }
.lens-file-list li.is-current a { font-weight: var(--weight-semibold); color: var(--fg); text-decoration: none; }
.lens-file-list .btn-icon { margin-left: auto; }
.lens-meta-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.lens-page { margin-top: var(--space-4); }
.lens-overview > h2 { font-size: var(--text-lg); }
.lens-overview .lens-table th { text-align: left; }
/* Markdown tables (the vendored renderer, once the manager's defaults.js has them): scroll sideways inside
   their wrapper, never the page; alignment arrives as a class, never a style */
.lens-table-wrap { max-width: 100%; overflow-x: auto; }
.lens-md .lens-table { width: auto; min-width: 50%; border-collapse: collapse; }
.lens-md .lens-table :is(th, td) { padding: var(--space-1) var(--space-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.lens-md .lens-table th { font-weight: var(--weight-semibold); border-bottom-color: var(--border-strong); }
.lens-md .lens-table :is(th, td) { overflow-wrap: normal; }
.lens-md .lens-table code { white-space: nowrap; }
.lens-table .lens-align-center { text-align: center; }
.lens-table .lens-align-right { text-align: right; }
.lens-md li > :is(ul, ol) { margin-top: var(--space-1); padding-left: var(--space-5); }
.chat-trust .badge { max-width: 100%; height: auto; padding-block: var(--space-1); line-height: var(--leading-tight); white-space: normal; }
.lens-bullets { display: flex; flex-direction: column; gap: var(--space-1); padding-left: var(--space-5); }
