/* ========================================================================
   SessionWeave Cockpit · Plan #2 extensions
   Appended to cockpit.css. Inherits all tokens, fonts, eyebrow, brand-mark,
   .hl half-height highlighter, OKLCH palette, focus rings.
   New surfaces only: sessions list, settings (relays / keys / profile),
   modals (add key, manage models), login page.
   ======================================================================== */

/* ---------- 11. Router shell variants ---------- */
/* For views that don't need the chat 4-area grid, the app collapses the
   right panel and the central area becomes a single column.
   The sidebar is reused as a nav surface (Sessions / Settings sub-routes). */
.app[data-route-kind="page"] {
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar central";
}
.app[data-route-kind="page"] .rightpanel,
.app[data-route-kind="page"] .rightpanel-rail { display: none; }

/* ---------- 12. Global nav (replaces sidebar-actions on /sessions and /settings) ---------- */
.nav-section {
  padding: 14px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.nav-section .eyebrow { margin-bottom: 8px; }
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--bg-elev); color: var(--ink); }
.nav-item[aria-current="page"] {
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 500;
}
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.nav-item .icon { width: 15px; height: 15px; flex-shrink: 0; color: currentColor; }
.nav-item .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}

/* ---------- 13. Page header (used by Sessions list and every Settings tab) ---------- */
.page {
  grid-area: central;
  overflow-y: auto;
  background: var(--bg);
  padding: 0;
}
.page-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 32px 64px;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.page-header .titles { min-width: 0; }
.page-header .eyebrow { margin-bottom: 8px; }
.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.page-header .lead {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  max-width: 56ch;
}
.page-header .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- 14. Generic buttons (canonical set for forms) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { border-color: var(--line-strong); background: var(--bg-elev); }
.btn[disabled] { pointer-events: none; cursor: not-allowed; }
.btn .icon { width: 14px; height: 14px; }
.btn .kbd {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 4px;
}
.btn--primary {
  /* Accent fill + always-dark text — reads obviously as a clickable CTA on
     both themes. The previous "inverted ink" style produced a dark slab
     with white text on light theme, which looked closer to a banner badge
     than a button. Dark text on the teal accent gives the same iOS/Apple
     feel users expect from a submit button. */
  background: var(--accent);
  color: oklch(15% 0.01 250);
  border-color: var(--accent-ink);
  font-weight: 700;
}
.btn--primary:hover {
  background: color-mix(in oklab, var(--accent) 88%, var(--ink) 12%);
  border-color: var(--ink);
}
/* Disabled primary: clearly muted — no inverted-ink look, no bold weight, so
   the user can tell at a glance that the action isn't available yet.
   Overrides the generic .btn[disabled] opacity rule that previously made
   the disabled primary still look filled-and-active. */
.btn--primary[disabled],
.btn--primary[disabled]:hover {
  background: var(--bg-elev);
  color: var(--ink-mute);
  border-color: var(--line);
  font-weight: 500;
  opacity: 1;
}
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
}
.btn--ghost:hover { background: var(--bg-elev); color: var(--ink); border-color: transparent; }
.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 35%, var(--line));
}
.btn--danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn--small { padding: 4px 9px; font-size: 12px; }

/* ---------- 15. Form controls ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}
.field .hint {
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.field input,
.field select,
.field textarea {
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 11px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color var(--transition);
  font-family: inherit;
}
.field input[type="password"],
.field input[data-mono="true"],
.field input[name="key"],
.field input[name="base_url"],
.field input[name="session_id"] {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.field-error {
  font-size: 11px;
  color: var(--danger);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- 16. Card / list row (used by sessions, relays, keys) ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card + .card { margin-top: 8px; }
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 4px 0; }
.row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  transition: var(--transition);
}
/* Backwards-compat: rows that were rendered without a checkbox keep
   their original 3-column shape via :not() — the row-select cell only
   appears when a checkbox is wired. */
.row:not(:has(.row-select)) {
  grid-template-columns: auto 1fr auto;
}
.row-select {
  display: grid;
  place-items: center;
}
.row-select input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  margin: 0;
}
/* A / S glyph variants for the tier indicator. Admin = stronger accent
   border + tint; Supervised = neutral muted tile so the eye lands on
   admin rows first. */
.row .glyph--admin {
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--line));
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0;
}
.row .glyph--supervised {
  background: var(--bg-elev);
  color: var(--ink-soft);
  border-color: var(--line);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0;
}
/* Bulk-action toolbar above each session group. */
.card-header__right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.session-select-all-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.session-select-all {
  cursor: pointer;
  width: 16px;
  height: 16px;
  margin: 0;
}
.session-bulk-count {
  font-size: 11px;
  color: var(--ink-mute);
  font-weight: 500;
  margin-left: 4px;
  letter-spacing: 0.02em;
}
.session-bulk-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.session-bulk-actions .btn--icon {
  padding: 6px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid transparent;
}
.session-bulk-actions .btn--icon:hover:not([disabled]) {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}
.session-bulk-actions .btn--icon[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-elev); }
.row .glyph {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-transform: uppercase;
  flex-shrink: 0;
  overflow: hidden;
}
.row .glyph--brand {
  background: transparent;
  border-color: transparent;
  padding: 0;
}
.row .glyph .glyph-svg {
  width: 26px;
  height: 26px;
  display: block;
}
.row[data-state="default"] .glyph { background: var(--accent-bg); color: var(--accent-ink); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); }
.row .main { min-width: 0; }
.row .main .top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.row .main .label {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}
.row .main .url,
.row .main .key-preview,
.row .main .sid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.row .main .sub {
  margin-top: 3px;
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.row .actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

/* ---------- 17. Badges (re-use teal accent + danger; add neutral / live) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--ink-mute);
  background: var(--bg);
  font-weight: 500;
}
.badge--default {
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--line));
}
.badge--creator { background: var(--accent-bg); color: var(--accent-ink); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); }
.badge--participant { background: var(--bg-elev); color: var(--ink-soft); border-color: var(--line-strong); }
.badge--supervisor { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in oklab, var(--danger) 35%, var(--line)); }
.badge--live { color: oklch(58% 0.14 145); border-color: color-mix(in oklab, oklch(58% 0.14 145) 35%, var(--line)); background: color-mix(in oklab, oklch(58% 0.14 145) 12%, var(--bg)); }
.badge--live::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: fh-pulse 2s infinite;
}

/* ---------- 18. Empty state ---------- */
.empty {
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0,
      transparent 12px,
      color-mix(in oklab, var(--line) 35%, transparent) 12px,
      color-mix(in oklab, var(--line) 35%, transparent) 13px
    ),
    var(--bg);
}
.empty h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--ink);
}
.empty p {
  margin: 0 auto 16px;
  max-width: 44ch;
  color: var(--ink-soft);
  font-size: 13px;
}
.empty .actions {
  display: inline-flex;
  gap: 8px;
}

/* ---------- 19. Callout (security-model note) ---------- */
.callout {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  margin-bottom: 24px;
}
.callout .icon { color: var(--accent); margin-top: 2px; }
.callout .body {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.callout .body strong { color: var(--ink); font-weight: 600; }
.callout .body code,
.callout .body .mono {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ---------- 20. Provider grouping (Settings → keys) ---------- */
.provider-group { margin-bottom: 18px; }
.provider-group .card-header .provider-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600;
}
.provider-group .card-header .provider-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.provider-icon {
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg);
  flex-shrink: 0;
}
.provider-icon[data-provider="anthropic"] { color: oklch(58% 0.14 35); border-color: color-mix(in oklab, oklch(58% 0.14 35) 50%, var(--line)); }
.provider-icon[data-provider="openai_compat"],
.provider-icon[data-provider="openai"] { color: oklch(58% 0.14 145); border-color: color-mix(in oklab, oklch(58% 0.14 145) 50%, var(--line)); }
.provider-icon[data-provider="google"] { color: oklch(58% 0.14 245); border-color: color-mix(in oklab, oklch(58% 0.14 245) 50%, var(--line)); }
.provider-icon[data-provider="mistral"] { color: oklch(58% 0.14 75); border-color: color-mix(in oklab, oklch(58% 0.14 75) 50%, var(--line)); }

/* Pill showing "12 models, 8 enabled" */
.models-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}
.models-pill .num { color: var(--ink); font-weight: 600; }
.models-pill .num--accent { color: var(--accent-ink); }

/* ---------- 21. Modal dialog ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, oklch(0% 0 0) 45%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: modal-in 0.15s ease;
}
@keyframes modal-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  max-width: 520px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 40px -12px color-mix(in oklab, oklch(0% 0 0) 30%, transparent);
}
.modal[data-size="wide"] { max-width: 640px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.modal-header .title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header .close {
  background: transparent;
  border: none;
  color: var(--ink-mute);
  width: 28px; height: 28px;
  border-radius: var(--radius);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 14px;
}
.modal-header .close:hover { background: var(--bg-elev); color: var(--ink); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Probe state inside Add Key modal */
.probe {
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--mono);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}
.probe[data-state="idle"] { color: var(--ink-mute); }
.probe[data-state="loading"] .dot { background: var(--accent); animation: fh-pulse 1.4s infinite; }
.probe[data-state="success"] { border-color: color-mix(in oklab, oklch(58% 0.14 145) 50%, var(--line)); color: oklch(58% 0.14 145); }
.probe[data-state="error"] { border-color: color-mix(in oklab, var(--danger) 50%, var(--line)); color: var(--danger); }
.probe .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-mute);
  flex-shrink: 0;
}
.probe[data-state="success"] .dot { background: oklch(58% 0.14 145); }
.probe[data-state="error"] .dot { background: var(--danger); }

/* Models picker checklist */
.models-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  max-height: 280px;
  overflow-y: auto;
}
.models-list li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  cursor: pointer;
}
.models-list li:last-child { border-bottom: none; }
.models-list li:hover { background: var(--bg-elev); }
.models-list li input[type="checkbox"] {
  appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 3px;
  background: var(--bg);
  cursor: pointer;
  display: grid; place-items: center;
  margin: 0;
}
.models-list li input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.models-list li input[type="checkbox"]:checked::after {
  content: "✓";
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
}
.models-list li .model-id {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
}
.models-list li[data-new="true"] .model-id::after {
  content: "NEW";
  margin-left: 8px;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--accent-ink);
  background: var(--accent-bg);
  padding: 1px 5px;
  border-radius: 3px;
}
.models-list li .model-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}
.models-bulk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  margin: 8px 2px 0;
}
.models-bulk button {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
}
.models-bulk button:hover { color: var(--accent-ink); text-decoration-color: var(--accent); }

/* Manage Models — search + preset row (0.3.10) */
.models-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.models-filter-input {
  flex: 1 1 auto;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 11px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
}
.models-filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.models-filter-presets {
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Diff banner inside Manage Models modal */
.diff-banner {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  background: var(--accent-bg);
  border: 1px solid color-mix(in oklab, var(--accent) 40%, var(--line));
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 14px;
}
.diff-banner[data-state="clean"] {
  color: var(--ink-mute);
  background: var(--bg-elev);
  border-color: var(--line);
}

/* ---------- 22. Login page ---------- */
body.login-page {
  background:
    radial-gradient(1200px circle at 50% -120px,
      color-mix(in oklab, var(--accent) 14%, transparent) 0%,
      transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  max-width: 420px;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px 32px 28px;
}
.login-card .brand {
  margin-bottom: 6px;
}
.login-card h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 14px 0 6px;
  letter-spacing: -0.01em;
}
.login-card p.lead {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 24px;
}
.login-card .methods {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-card .oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}
.login-card .oauth-btn:hover { border-color: var(--accent); background: var(--bg-elev); }
.login-card .oauth-btn .icon { width: 16px; height: 16px; }
.login-card .divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin: 18px 0 14px;
}
.login-card .divider::before,
.login-card .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.login-card form.magic {
  display: flex;
  gap: 6px;
}
.login-card form.magic input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
}
.login-card form.magic input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.login-card .footnote {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  line-height: 1.6;
}

/* ---------- 23. Toast notifications ---------- */
.toast-host {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  max-width: 360px;
  box-shadow: 0 12px 30px -10px color-mix(in oklab, oklch(0% 0 0) 30%, transparent);
  pointer-events: auto;
  animation: toast-in 0.18s ease;
}
.toast[data-tone="success"] { border-left: 3px solid oklch(70% 0.14 145); }
.toast[data-tone="error"]   { border-left: 3px solid var(--danger); }
.toast[data-tone="info"]    { border-left: 3px solid var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 24. Session route base padding tweaks ---------- */
/* Session mode grid + roster-open/collapsed variants are defined further
   down (see "Session-detail view" section). The `.page` padding override
   below keeps the central area's gutter consistent — the new chat view
   handles its own paddings via .session-timeline + .session-composer. */
.app[data-route-kind="session"] .page { padding: 0; }

/* ---------- 25. User menu popover ---------- */
.user-menu-popover {
  z-index: 60;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px -8px color-mix(in oklab, oklch(0% 0 0) 35%, transparent);
  padding: 4px;
  animation: modal-in 0.12s ease;
}
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border-radius: 4px;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--bg-elev); }
.user-menu-item:focus { outline: none; background: var(--bg-elev); }

.user-menu-item--disabled {
  color: var(--ink-mute);
  cursor: not-allowed;
  opacity: 0.6;
}
.user-menu-item--disabled:hover { background: transparent; }
.user-menu-hint {
  font-size: 11.5px;
  color: var(--ink-mute);
  padding: 6px 11px 8px;
  line-height: 1.4;
  border-top: 1px dashed var(--line);
  margin-top: 2px;
  max-width: 220px;
}
.user-menu-hint a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* /settings/profile — Appearance card theme switcher */
.theme-toggle-group {
  display: inline-flex;
  gap: 6px;
}
.theme-toggle-group .btn {
  min-width: 64px;
}

/* Setup-wizard / system view — inline error after a failed Save */
.section-error {
  border: 1px solid var(--danger);
  border-radius: 5px;
  padding: 10px 12px;
  background: color-mix(in oklab, var(--danger) 8%, transparent);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  max-width: 640px;
}
.section-error__headline {
  font-weight: 600;
  color: var(--danger);
  word-break: break-word;
}
.section-error__hint {
  margin-top: 6px;
  color: var(--ink-soft);
}
.section-error__hint a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

/* Sessions list — group title count helper */
.session-group-count {
  color: var(--ink-mute);
  font-weight: 400;
  margin-left: 4px;
}

/* ============================================================== */
/* Session-detail view (Plan #2.6 rewrite, replaces session-legacy/). */
/* ============================================================== */

/* Session mode = chat-focused full-width layout. The settings sidebar would
   be noise here; the back button in the session header is the way out.
   When the roster is open the chat column sits beside the rightpanel; the
   composer pinned at the bottom spans both columns (it's always visible
   regardless of roster state). The composer is parked in a separate
   .session-composer-slot at #app level (see views.js) so it can live in
   its own grid row independent of #route-outlet. */
/* Four layout variants depending on whether the optional left
   (workspace) and right (participants) panels are open. */
/* Session layout adds a session-header band right under the global
   topbar. The header spans the full width across leftpanel + central
   + rightpanel so the back link, workspace toggle, and participants
   toggle sit on one consistent control row regardless of which panels
   are open. The grid grows from 3 rows to 4: topbar / session-header
   / panels / composer. */
.app[data-route-kind="session"][data-leftpanel="closed"][data-rightpanel="open"] {
  grid-template-columns: 1fr 296px;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "topbar topbar"
    "session-header session-header"
    "central rightpanel"
    "composer composer";
}
.app[data-route-kind="session"][data-leftpanel="closed"][data-rightpanel="collapsed"] {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "topbar"
    "session-header"
    "central"
    "composer";
}
.app[data-route-kind="session"][data-leftpanel="open"][data-rightpanel="open"] {
  grid-template-columns: 280px 1fr 296px;
  grid-template-rows: auto auto 1fr auto;
  /* Leftpanel extends to the bottom row: workspace tree owns the
     whole left edge while chat + composer share the right side. */
  grid-template-areas:
    "topbar topbar topbar"
    "session-header session-header session-header"
    "leftpanel central rightpanel"
    "leftpanel composer composer";
}
.app[data-route-kind="session"][data-leftpanel="open"][data-rightpanel="collapsed"] {
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "topbar topbar"
    "session-header session-header"
    "leftpanel central"
    "leftpanel composer";
}
/* Back-compat for routes that pre-date data-leftpanel — treat absence as closed. */
.app[data-route-kind="session"]:not([data-leftpanel]) {
  grid-template-columns: 1fr 296px;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "topbar topbar"
    "session-header session-header"
    "central rightpanel"
    "composer composer";
}
.app[data-route-kind="session"] .sidebar { display: none; }
.app[data-route-kind="session"][data-rightpanel="open"] .rightpanel,
.app[data-route-kind="session"][data-rightpanel="open"] .session-rightpanel {
  display: flex;
  flex-direction: column;
  grid-area: rightpanel;
  border-left: 1px solid var(--line);
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}
.app[data-route-kind="session"][data-rightpanel="collapsed"] .rightpanel,
.app[data-route-kind="session"][data-rightpanel="collapsed"] .session-rightpanel {
  display: none;
}
.app[data-route-kind="session"][data-leftpanel="open"] .session-leftpanel {
  display: flex;
  flex-direction: column;
  grid-area: leftpanel;
  border-right: 1px solid var(--line);
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}
.app[data-route-kind="session"][data-leftpanel="closed"] .session-leftpanel,
.app[data-route-kind="session"]:not([data-leftpanel]) .session-leftpanel {
  display: none;
}
.session-composer-slot {
  grid-area: composer;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.session-header-slot {
  grid-area: session-header;
  background: var(--bg);
}

/* Workspace tree panel ───────────────────────────────────────────
   VS-Code-ish dark band on the left of the session view. Holds a
   tiny header (status dot + "Workspace" label + refresh / stop icon
   buttons) and a lazy expand/collapse tree underneath. */
.app[data-route-kind="session"] .session-leftpanel {
  background: color-mix(in oklab, var(--bg-elev) 50%, var(--ink) 6%);
  color: var(--ink);
}
.session-leftpanel__head {
  padding: 8px 12px;
  border-bottom: 1px solid color-mix(in oklab, var(--line) 70%, var(--ink) 10%);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.session-leftpanel__head .ws-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-mute);
  flex-shrink: 0;
}
.session-leftpanel__head .ws-dot[data-state="bound"]    { background: oklch(58% 0.14 145); }
.session-leftpanel__head .ws-dot[data-state="serving"]  { background: oklch(58% 0.14 145); animation: fh-pulse 1.6s infinite; }
.session-leftpanel__head .ws-dot[data-state="error"]    { background: var(--danger); }
.session-leftpanel__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  flex: 1 1 auto;
}
.session-leftpanel__ops {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: auto;
}
.session-leftpanel__ops .btn--icon {
  padding: 4px 5px;
  min-width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
}
.session-leftpanel__ops .btn--icon:hover {
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  color: var(--ink);
  border-color: var(--line);
}
.session-leftpanel__ops .btn--icon .icon { width: 13px; height: 13px; }
.session-leftpanel__cta {
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.session-leftpanel__empty {
  color: var(--ink-mute);
  font-size: 12px;
  line-height: 1.5;
}
.session-leftpanel__tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  font-size: 12.5px;
  font-family: var(--mono);
}

/* One tree row + its (lazy-rendered) children container. */
.ws-row-wrap {
  display: block;
}
.ws-row {
  display: grid;
  grid-template-columns: 14px 16px 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px calc(8px + var(--ws-indent, 0) * 12px);
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink);
  position: relative;
}
.ws-row:hover {
  background: color-mix(in oklab, var(--bg) 60%, transparent);
}
.ws-row__arrow {
  width: 14px; text-align: center;
  font-size: 9px; line-height: 1;
  color: var(--ink-mute);
  -webkit-user-select: none;
  user-select: none;
}
.ws-row__icon {
  font-size: 12px;
  opacity: 0.85;
}
.ws-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 12px;
}
.ws-row--directory .ws-row__name { color: var(--ink); font-weight: 500; }
.ws-row--file      .ws-row__name { color: var(--ink-soft); }
.ws-row__menu {
  opacity: 0;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-mute);
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
}
.ws-row:hover .ws-row__menu { opacity: 0.7; }
.ws-row__menu:hover {
  opacity: 1;
  background: color-mix(in oklab, var(--bg-elev) 70%, transparent);
  color: var(--ink);
}
.ws-row__menu-popup { min-width: 240px; }
.ws-row__children { display: block; }
.ws-row--loading,
.ws-row--empty {
  padding: 4px 14px 4px calc(28px + var(--ws-indent, 0) * 12px);
  color: var(--ink-mute);
  font-size: 11px;
  font-style: italic;
  cursor: default;
}

/* File-write bubble — "filename" + boxed content (used when a
   worker dispatches a workspace_call op=write). */
.msg-panel__file-write {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.msg-panel__file-write__path {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}
.msg-panel__file-write__body {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg-elev) 60%, var(--bg));
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

/* Modal file-content viewer used by the "Open" action. */
.ws-file-view {
  max-height: 60vh;
  overflow: auto;
  padding: 10px 12px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in oklab, var(--bg-elev) 60%, var(--bg));
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Roster toggle pill — primary state shows participants count; pressed=open. */
.session-header__roster-toggle {
  display: inline-flex; align-items: center; gap: 6px;
}
.session-header__roster-toggle[aria-pressed="true"] {
  background: var(--bg-elev);
  border-color: var(--line-strong);
  color: var(--ink);
}
.session-header__roster-count { color: var(--ink-mute); font-size: 11px; }

/* Central column is a 3-row grid: header (auto), chat-stream (1fr, fills),
   composer (auto, pinned at the bottom). `min-height: 0` + `overflow: hidden`
   on the container ensures the timeline scrolls instead of overflowing the
   viewport. The `.page` parent (id=route-outlet) needs `min-height: 0` too
   for the grid to actually compress to viewport-height. */
.app[data-route-kind="session"] .page {
  min-height: 0;
  overflow: hidden;
}
.session-view {
  grid-area: central;
  display: grid;
  grid-template-rows: auto 1fr;  /* tab bar (auto) + timeline (1fr) */
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* Tab bar — sits between the session-header band and the timeline.
   Default has just "All"; opening a Private Message adds a tab per
   participant. Active tab gets the accent underline; the close × on
   DM tabs removes them. Layout: row of compact pills. */
/* Chat tab bar inside the session view (All + per-participant DMs).
   Named `chat-*` instead of `session-tab*` to avoid colliding with
   the Add-Session modal's Supervise/Administer toggle that also
   uses `.session-tab*` classes. */
.chat-tabs {
  display: flex;
  flex-wrap: nowrap;          /* always a single row — overflow scrolls */
  justify-content: flex-start;
  align-items: center;
  gap: 2px;
  padding: 2px 16px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: thin;
}
.chat-tab {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;             /* width hugs the text, never stretches */
  width: auto;
  gap: 5px;
  padding: 3px 8px 5px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;  /* overlap parent's border-bottom */
  white-space: nowrap;
  transition: var(--transition);
}
.chat-tab:hover {
  color: var(--ink);
  background: var(--bg-elev);
}
.chat-tab--active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.chat-tab__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-tab__label {
  text-transform: capitalize;
}
.chat-tab__close {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-left: 1px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-mute);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}
.chat-tab__close:hover {
  background: var(--bg-elev);
  color: var(--ink);
}

/* Unified file/folder picker — one button that flips its label and
   carries an inline × clear badge once something is picked. */
.source-picker__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.source-picker__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.source-picker__clear {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-mute);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.source-picker__clear:hover {
  background: var(--bg-elev);
  color: var(--ink);
}
.source-picker__menu {
  /* Reuse .participant-menu styling — same dropdown shape, just wider
     so the longer hint text fits without wrapping aggressively. */
  min-width: 320px;
}

/* DM reply: a worker's response to a targeted supervisor.note.
   Subtle left-edge accent so the supervisor can spot the 1-on-1
   threads in the firehose without losing them in the noise. */
.session-timeline .msg--dm-reply {
  border-left: 3px solid color-mix(in oklab, var(--accent) 60%, var(--line));
  padding-left: 12px;
}

/* Panel-style message cards.
   Every entry in the timeline is now a small card. Related events
   (a command + its replies + its completed status) flow into the
   same card so the chat reads as a sequence of grouped
   conversations rather than a flat stream of low-level events. */
.session-timeline .msg-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 10px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  margin: 8px 0;
  gap: 6px;
  /* Reset legacy .msg-* layout overrides — panels manage their own
     padding/border. */
  border-left-width: 1px;
}
.session-timeline .msg-panel__head {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
  text-transform: lowercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-timeline .msg-panel__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.session-timeline .msg-panel__bubble {
  min-width: 0;
}
.session-timeline .msg-panel__bubble--reply {
  /* Reply bubbles sit slightly indented so the visual rhythm matches
     a Q→A exchange inside the card. */
  padding-left: 12px;
  border-left: 2px solid color-mix(in oklab, var(--accent) 25%, var(--line));
}
.session-timeline .msg-panel__footer {
  display: flex;
  justify-content: flex-end;
  color: var(--ink-mute);
  font-size: 11px;
  font-family: var(--mono);
  margin-top: 2px;
}
.session-timeline .msg-panel--task {
  border-color: color-mix(in oklab, var(--ink) 8%, var(--line));
  background: color-mix(in oklab, var(--bg-elev) 60%, var(--bg));
}
.session-timeline .msg-panel--note {
  /* Broadcast supervisor.note */
  border-color: var(--line);
}
.session-timeline .msg-panel--dm {
  /* Private supervisor↔worker thread — accent tinted so 1-on-1
     conversations stand out at a glance. */
  border-color: color-mix(in oklab, var(--accent) 35%, var(--line));
  background: color-mix(in oklab, var(--accent-bg) 50%, var(--bg));
}
.session-timeline .msg-panel--exchange {
  /* peer-to-peer command + result pair */
  border-color: var(--line);
}
.session-timeline .msg-panel--exchange.msg-panel--settled {
  border-color: color-mix(in oklab, var(--ink-mute) 20%, var(--line));
}
.session-timeline .msg-panel--exchange.msg-panel--error {
  border-color: color-mix(in oklab, var(--danger) 35%, var(--line));
}
.session-timeline .msg-panel--system {
  background: transparent;
  border-style: dashed;
  border-color: color-mix(in oklab, var(--line) 80%, transparent);
  padding: 6px 12px;
}
.session-timeline .msg-panel--system .msg-panel__head { display: none; }
.session-timeline .msg-panel--system .msg-panel__body { color: var(--ink-mute); font-size: 12px; }

.session-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.session-header__back { white-space: nowrap; flex-shrink: 0; }
.session-header__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}
.session-header__sid {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.session-header__sid:hover { color: var(--accent-ink); }
.session-header__purpose {
  font-size: 13px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.session-header__ops {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Rightpanel close button */
.session-rightpanel .rp-close {
  margin-left: auto;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--ink-mute);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.session-rightpanel .rp-close:hover {
  background: var(--bg-elev);
  color: var(--ink);
}

.fh-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-soft);
}
.fh-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-mute);
}
.fh-pill[data-state="live"] {
  border-color: color-mix(in oklab, var(--accent) 50%, var(--line));
  color: var(--accent-ink);
}
.fh-pill[data-state="live"]::before {
  background: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 25%, transparent);
}
.fh-pill[data-state="reconnecting"]::before { background: var(--danger); }
.fh-pill[data-state="closed"] { opacity: 0.65; }

/* ChatGPT / Claude.ai-style timeline: full-width scroller with a centered
   reading column, avatar + sender at the top of each message, body flowing
   below in readable typography. No bordered boxes around chat bubbles —
   relies on spacing for visual rhythm. Supervisor notes get a soft accent
   wash on the left to read as "moderator voice". */
.session-timeline {
  overflow-y: auto;
  padding: 24px 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: 0;
  background: var(--bg);
}

.session-timeline .msg {
  width: 100%;
  max-width: 760px;
  padding: 0 24px;
  box-sizing: border-box;
}
.session-timeline .msg__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.session-timeline .msg__avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--avatar-color, var(--ink-mute));
  color: white;
  font-size: 11.5px;
  font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.session-timeline .msg__meta {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.session-timeline .msg__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  text-transform: capitalize;
}
.session-timeline .msg__role-chip {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--accent) 25%, var(--line));
  padding: 1px 6px;
  border-radius: 3px;
}
.session-timeline .msg__time {
  font-size: 11px;
  color: var(--ink-mute);
}
.session-timeline .msg__body {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  margin-left: 36px; /* aligned with the sender label, sitting under the avatar */
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
}
/* Collapsible long-message variant. Closed state caps height; the
   toggle pill at the bottom lets the user expand to read everything. */
.session-timeline .msg__body--collapsible {
  position: relative;
  padding-bottom: 4px;
}
.session-timeline .msg__body--collapsible[data-state="collapsed"] .msg__body-text {
  max-height: 7.2em;            /* ~4.5 lines */
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}
.session-timeline .msg__body--collapsible[data-state="expanded"] .msg__body-text {
  max-height: none;
}
.session-timeline .msg__body-toggle {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  padding: 4px 0;
  cursor: pointer;
}
.session-timeline .msg__body-toggle:hover { color: var(--ink); }

/* Task seed bubble — at the top of the timeline, prominent. */
.session-timeline .msg--task {
  background: color-mix(in oklab, var(--accent) 4%, transparent);
  border-left: 3px solid color-mix(in oklab, var(--accent) 55%, var(--line));
  padding: 14px 0 16px;
  margin-left: -3px;
}
.session-timeline .msg--task .msg__role-chip {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
}

/* Supervisor note variant: soft accent wash + accent vertical bar. */
.session-timeline .msg--note {
  background: color-mix(in oklab, var(--accent) 6%, transparent);
  border-left: 3px solid color-mix(in oklab, var(--accent) 45%, var(--line));
  padding-top: 14px;
  padding-bottom: 14px;
  margin-left: -3px; /* keep the centered column visually centered */
}

/* System events: thin compact dividers, faded text. */
.session-timeline .msg--system {
  text-align: center;
  padding: 2px 0;
  border: none;
  background: transparent;
}
.session-timeline .msg__system-text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}
.session-timeline .msg--ended .msg__system-text {
  color: var(--danger);
  font-weight: 600;
}

/* Raw fallback: still surfaces unknown events but quietly. */
.session-timeline .msg--raw .msg__system-text { opacity: 0.6; }

.session-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 24px 16px;
  background: var(--bg);
  align-items: end;
}
.session-composer__input {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  max-height: 240px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
}
.session-composer__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.session-composer__send {
  height: 38px;
  padding-left: 18px;
  padding-right: 18px;
}

/* Roster panel */
.session-rightpanel .rp-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.session-rightpanel .rp-title { margin: 0; font-size: 13px; font-weight: 600; }
.session-rightpanel .rp-count { color: var(--ink-mute); font-size: 12px; }
.roster-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
.roster-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.roster-row:last-child { border-bottom: none; }
.roster-row[data-online="0"] { opacity: 0.55; }
.roster-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.roster-meta { min-width: 0; }
.roster-role {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-transform: capitalize;
}
.roster-obj {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.roster-pid {
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.roster-offline {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  text-transform: uppercase;
}

/* Add session modal — Supervise vs Administer tab bar */
.session-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
}
.session-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--ink-soft);
  transition: var(--transition);
}
.session-tab:hover {
  border-color: var(--line-strong);
  background: var(--bg-elev);
  color: var(--ink);
}
.session-tab--active {
  border-color: var(--ink);
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 0 var(--ink);
}
.session-tab__label {
  font-size: 13px;
  font-weight: 600;
}
.session-tab--active .session-tab__label {
  color: var(--ink);
}
.session-tab__sub {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
}

/* ─── Plan #3: fan-out team builder ─────────────────────────────────── */
.modal.modal--wide { max-width: 880px; }
.fanout-team {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.fanout-row {
  display: grid;
  /* Role · Key · Model · Prompt · Count · Turns · Wait · Kickoff · X */
  grid-template-columns: 1fr 1.3fr 1.2fr 0.9fr 60px 60px 60px 50px 38px;
  gap: 6px;
  padding: 8px 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.fanout-row input[type="checkbox"] {
  width: auto;
  justify-self: center;
}
.fanout-row__kickoff {
  padding: 8px 10px;
  border-top: 1px dashed var(--line);
  background: color-mix(in oklab, var(--bg-elev) 30%, var(--bg));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fanout-row__kickoff-target {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.fanout-row__kickoff-target select { max-width: 200px; }
.fanout-row__kickoff textarea {
  width: 100%;
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  resize: vertical;
}
.fanout-row:last-child { border-bottom: none; }
.fanout-row--head {
  background: var(--bg-elev);
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.fanout-row input,
.fanout-row select {
  width: 100%;
  font-size: 12.5px;
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.fanout-row input[type="number"] { font-family: var(--mono); }
.btn--icon {
  padding: 4px 6px;
  min-width: 30px;
  display: inline-grid;
  place-items: center;
}
.btn--icon .icon { width: 14px; height: 14px; }

/* Spinner used by the swap-model flow (modal submit + chat card). */
.swap-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  vertical-align: -2px;
  border-radius: 50%;
  border: 2px solid color-mix(in oklab, var(--accent) 22%, transparent);
  border-top-color: var(--accent);
  animation: sw-spin 0.8s linear infinite;
}
@keyframes sw-spin {
  to { transform: rotate(360deg); }
}
.msg--swap__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  font-family: var(--mono);
}
.msg--swap__status--applied {
  color: var(--accent-ink);
}
.msg--swap__status--failed {
  color: var(--danger);
}
.msg--swap__status--failed .swap-check {
  background: color-mix(in oklab, var(--danger) 30%, transparent);
  color: var(--danger);
}
.swap-check {
  display: inline-block;
  width: 18px; height: 18px;
  vertical-align: -3px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--accent) 30%, transparent);
  color: var(--accent-ink);
  text-align: center;
  line-height: 18px;
  font-weight: 700;
  font-size: 11px;
}

/* Per-participant popover menu (anchored to the clicked roster row) */
.roster-row { cursor: pointer; }
.roster-row:hover { background: var(--bg-elev); }
.participant-menu {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 14px 32px -12px color-mix(in oklab, oklch(0% 0 0) 35%, transparent);
  min-width: 240px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.participant-menu__entry {
  background: transparent;
  border: none;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  color: var(--ink);
}
.participant-menu__entry:hover {
  background: var(--bg-elev);
}
.participant-menu__entry--danger .participant-menu__label {
  color: var(--danger);
}
.participant-menu__entry--danger:hover {
  background: color-mix(in oklab, var(--danger) 8%, transparent);
}
.participant-menu__label {
  font-size: 13.5px; font-weight: 600;
}
.participant-menu__hint {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 2px;
  font-family: var(--mono);
  letter-spacing: 0.01em;
}

/* Details modal — labeled rows */
.details-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.details-row:last-of-type { border-bottom: none; }
.details-row__label {
  color: var(--ink-mute);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding-top: 2px;
}
.details-row__value { color: var(--ink); word-break: break-word; }
.details-row__value.mono { font-family: var(--mono); font-size: 12.5px; }
.details-section {
  margin-top: 18px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-strong);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 700;
}
.fanout-row__container {
  border-bottom: 1px solid var(--line);
}
.fanout-row__container:last-child { border-bottom: none; }
.fanout-row__container .fanout-row {
  border-bottom: 1px dashed var(--line);
}
.fanout-row__custom {
  padding: 8px 10px 10px;
  background: var(--bg-elev);
}
.fanout-row__custom textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
  min-height: 80px;
}
