/**
 * RUNSPEC component kit — facelift step 2. The contract is the Components table of
 * docs/facelift/DESIGN_MANIFEST.md; every class below is shown, in every state, on
 * /preview/ui-kit. Load after runspec-tokens.css.
 *
 * Rules for this file (tests/test_ui_kit.py holds it to them):
 *   - class prefix rs-;
 *   - colours, type, space, radius and sizes come from var(--rs-*) tokens — no colour
 *     literal, no important flag;
 *   - no theme selector: the dark theme works because the tokens change, not the rules.
 *
 * Path colour. A tab, a step strip, a rail item and the agent bubble take the colour of
 * the path they belong to from two hooks, --rs-tool and --rs-tool-tint. They are not
 * tokens: the page sets them, on the element or any ancestor, with .rs-tool--runspec /
 * --keyword / --spectre or inline (style="--rs-tool: var(--rs-tool-spectre)").
 * Every use falls back to the Runspec path, so an element with no hook still renders.
 */

/* ── Path hooks ─────────────────────────────────────────────────────────── */

.rs-tool--runspec { --rs-tool: var(--rs-tool-runspec); --rs-tool-tint: var(--rs-accent-tint); }
.rs-tool--keyword { --rs-tool: var(--rs-tool-keyword); --rs-tool-tint: var(--rs-tool-keyword-tint); }
.rs-tool--spectre { --rs-tool: var(--rs-tool-spectre); --rs-tool-tint: var(--rs-tool-spectre-tint); }

/* ── Utilities ──────────────────────────────────────────────────────────── */

.rs-mono {
  font-family: var(--rs-font-mono);
  font-variant-numeric: tabular-nums;
}
.rs-muted { color: var(--rs-ink-3); }
.rs-label {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-label);
  line-height: var(--rs-lh-label);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--rs-ink-3);
}
.rs-title {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-title);
  line-height: var(--rs-lh-title);
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--rs-ink);
  margin: 0;
}
.rs-heading {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-heading);
  line-height: var(--rs-lh-heading);
  font-weight: 600;
  color: var(--rs-ink);
  margin: 0;
}
.rs-caption {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-caption);
  line-height: var(--rs-lh-caption);
  color: var(--rs-ink-3);
}
.rs-stack {
  display: flex;
  flex-direction: column;
  gap: var(--rs-space-3);
  min-width: 0;
}
.rs-stack--sm { gap: var(--rs-space-2); }
.rs-stack--lg { gap: var(--rs-space-5); }
.rs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rs-space-2);
  min-width: 0;
}
.rs-spacer { flex: 1 1 auto; }

/* ── Dot ────────────────────────────────────────────────────────────────── */

.rs-dot {
  display: inline-block;
  flex: none;
  width: var(--rs-dot);
  height: var(--rs-dot);
  border-radius: var(--rs-radius-pill);
  background: var(--rs-tool, var(--rs-tool-runspec));
}
.rs-dot--on { background: var(--rs-ok); }
.rs-dot--off {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--rs-ink-4);
}

/* ── Focus: 2 px accent ring, keyboard only ─────────────────────────────── */

.rs-btn:focus-visible,
.rs-tab:focus-visible,
.rs-step:focus-visible,
.rs-seg__item:focus-visible,
.rs-rail__item:focus-visible {
  outline: 2px solid var(--rs-accent);
  outline-offset: 2px;
}
.rs-input:focus-visible,
.rs-select:focus-visible,
.rs-textarea:focus-visible {
  outline: 2px solid var(--rs-accent);
  outline-offset: -1px;
}
.rs-btn:focus:not(:focus-visible),
.rs-tab:focus:not(:focus-visible),
.rs-step:focus:not(:focus-visible),
.rs-seg__item:focus:not(:focus-visible),
.rs-rail__item:focus:not(:focus-visible) {
  outline: none;
}

/* ── Button ─────────────────────────────────────────────────────────────── */

.rs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rs-space-1);
  box-sizing: border-box;
  height: var(--rs-control-h);
  padding: 0 var(--rs-space-3);
  border: 1px solid transparent;
  border-radius: var(--rs-radius-sm);
  background: transparent;
  color: var(--rs-ink);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-control);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.rs-btn__icon {
  display: inline-flex;
  flex: none;
  font-size: var(--rs-text-heading);
  line-height: 1;
}

.rs-btn--primary {
  background: var(--rs-btn-primary);
  color: var(--rs-on-btn-primary);
}
.rs-btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--rs-accent) 85%, var(--rs-surface));
}
.rs-btn--primary:active:not(:disabled) {
  background: color-mix(in srgb, var(--rs-accent) 75%, var(--rs-surface));
}

.rs-btn--secondary {
  background: var(--rs-surface);
  border-color: var(--rs-border);
  color: var(--rs-ink);
}
.rs-btn--secondary:hover:not(:disabled) {
  background: var(--rs-surface-sunken);
  border-color: var(--rs-border-strong);
}
.rs-btn--secondary:active:not(:disabled) {
  background: color-mix(in srgb, var(--rs-surface-sunken) 50%, var(--rs-border));
}

.rs-btn--ghost { color: var(--rs-ink-2); }
.rs-btn--ghost:hover:not(:disabled) {
  background: var(--rs-surface-sunken);
  color: var(--rs-ink);
}
.rs-btn--ghost:active:not(:disabled) {
  background: color-mix(in srgb, var(--rs-surface-sunken) 50%, var(--rs-border));
  color: var(--rs-ink);
}

/* Destructive, but not a second accent: danger text on the surface, tint on hover. */
.rs-btn--danger {
  background: var(--rs-surface);
  border-color: color-mix(in srgb, var(--rs-danger) 45%, var(--rs-border));
  color: var(--rs-danger);
}
.rs-btn--danger:hover:not(:disabled) { background: var(--rs-danger-tint); }
.rs-btn--danger:active:not(:disabled) {
  background: color-mix(in srgb, var(--rs-danger-tint) 70%, var(--rs-danger));
  color: var(--rs-ink);
}

.rs-btn--icon {
  width: var(--rs-control-h);
  padding: 0;
}

.rs-btn--sm {
  height: calc(var(--rs-control-h) - var(--rs-space-1));
  padding: 0 var(--rs-space-2);
}
.rs-btn--sm.rs-btn--icon {
  width: calc(var(--rs-control-h) - var(--rs-space-1));
  padding: 0;
}

.rs-btn:disabled,
.rs-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Row-1 icon button ──────────────────────────────────────────────────────
   Login round 7 (owner 2026-11-02): every icon button in a page's top bar looks like the
   app shell's account icon — no border, no circle, transparent; radius-sm; 28 px hit area,
   16 px icon; --rs-ink-2, hover --rs-surface-sunken / --rs-ink. The one rule for the app
   shell (row 1), the public nav, the sign-in bar and Spectre's dashboard bar; their own
   stylesheets keep only placement (display, margins). */
.rs-shell__header .rs-shell__help-btn,
.rs-shell__header .rs-shell__page-icon,
.rs-shell__header .rs-shell__account > summary,
.rs-shell__header .topnav-icon-btn,
.rs-auth-bar .theme-toggle,
.nav .ws-theme-toggle,
.nav .nav-hamburger,
.topnav .topnav-icon-btn,
.topnav .ws-theme-toggle {
  align-items: center;
  justify-content: center;
  flex: none;
  box-sizing: border-box;
  width: calc(var(--rs-control-h) - var(--rs-space-1));
  height: calc(var(--rs-control-h) - var(--rs-space-1));
  padding: 0;
  border: 0;
  border-radius: var(--rs-radius-sm);
  background: transparent;
  color: var(--rs-ink-2);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-heading);
  line-height: 1;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transform: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.rs-shell__header .rs-shell__help-btn,
.rs-shell__header .rs-shell__page-icon,
.rs-shell__header .topnav-icon-btn,
.rs-auth-bar .theme-toggle,
.topnav .topnav-icon-btn,
.topnav .ws-theme-toggle { display: inline-flex; }
.rs-shell__header .rs-shell__help-btn:hover,
.rs-shell__header .rs-shell__page-icon:hover,
.rs-shell__header .rs-shell__account > summary:hover,
.rs-shell__header .topnav-icon-btn:hover,
.rs-auth-bar .theme-toggle:hover,
.nav .ws-theme-toggle:hover,
.nav .nav-hamburger:hover,
.topnav .topnav-icon-btn:hover,
.topnav .ws-theme-toggle:hover {
  background: var(--rs-surface-sunken);
  color: var(--rs-ink);
  transform: none;
}
.rs-shell__header .rs-shell__help-btn:focus-visible,
.rs-shell__header .rs-shell__page-icon:focus-visible,
.rs-shell__header .topnav-icon-btn:focus-visible,
.rs-auth-bar .theme-toggle:focus-visible,
.nav .ws-theme-toggle:focus-visible,
.nav .nav-hamburger:focus-visible,
.topnav .topnav-icon-btn:focus-visible,
.topnav .ws-theme-toggle:focus-visible {
  outline: 2px solid var(--rs-accent);
  outline-offset: 2px;
}

/* ── Tabs (header row 1) ────────────────────────────────────────────────── */

.rs-tabs {
  display: flex;
  align-items: stretch;
  gap: var(--rs-space-1);
  height: var(--rs-header-h);
  margin: 0;
  padding: 0;
  list-style: none;
}
.rs-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--rs-space-2);
  padding: 0 var(--rs-space-3);
  border: 0;
  background: transparent;
  color: var(--rs-ink-2);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-control);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.rs-tab::after {
  content: "";
  position: absolute;
  left: var(--rs-space-3);
  right: var(--rs-space-3);
  bottom: 0;
  height: 2px;
  border-radius: var(--rs-radius-pill);
  background: transparent;
}
.rs-tab:hover { color: var(--rs-ink); }
.rs-tab--active,
.rs-tab[aria-selected="true"] { color: var(--rs-ink); }
.rs-tab--active::after,
.rs-tab[aria-selected="true"]::after { background: var(--rs-tool, var(--rs-tool-runspec)); }

/* ── Step pills (workflow strip, row 2) ─────────────────────────────────── */

.rs-steps {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rs-step {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--rs-space-2);
  box-sizing: border-box;
  height: calc(var(--rs-control-h) - var(--rs-space-1));
  padding: 0 var(--rs-space-3) 0 var(--rs-space-1);
  border: 0;
  border-radius: var(--rs-radius-pill);
  background: transparent;
  color: var(--rs-ink-2);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-control);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.rs-step + .rs-step { margin-left: var(--rs-space-5); }
.rs-step + .rs-step::before {
  content: "\2192" / "";
  position: absolute;
  left: calc(-1 * var(--rs-space-5));
  width: var(--rs-space-5);
  text-align: center;
  color: var(--rs-ink-4);
  pointer-events: none;
}
.rs-step:hover { color: var(--rs-ink); }
.rs-step__n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-sizing: border-box;
  width: calc(var(--rs-space-4) + var(--rs-space-1));
  height: calc(var(--rs-space-4) + var(--rs-space-1));
  border: 1px solid var(--rs-ink-4);
  border-radius: var(--rs-radius-pill);
  font-size: var(--rs-text-caption);
  line-height: 1;
  font-weight: 600;
}
.rs-step--next { color: var(--rs-ink-2); }
.rs-step--active,
.rs-step[aria-current="step"] {
  background: var(--rs-tool-tint, var(--rs-accent-tint));
  color: var(--rs-ink);
  font-weight: 600;
}
.rs-step--active .rs-step__n,
.rs-step[aria-current="step"] .rs-step__n {
  border-color: var(--rs-tool, var(--rs-tool-runspec));
  color: var(--rs-ink);
}
.rs-step--done .rs-step__n {
  border-color: var(--rs-tool, var(--rs-tool-runspec));
  background: var(--rs-tool, var(--rs-tool-runspec));
  color: var(--rs-surface);
}

/* ── Segmented control ──────────────────────────────────────────────────── */

.rs-seg {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--rs-space-1) / 2);
  box-sizing: border-box;
  height: var(--rs-control-h);
  padding: calc(var(--rs-space-1) / 2);
  border-radius: var(--rs-radius-sm);
  background: var(--rs-surface-sunken);
}
.rs-seg__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rs-space-1);
  height: 100%;
  padding: 0 var(--rs-space-3);
  border: 0;
  border-radius: var(--rs-radius-sm);
  background: transparent;
  color: var(--rs-ink-2);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-control);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.rs-seg__item:hover { color: var(--rs-ink); }
.rs-seg__item--selected,
.rs-seg__item[aria-pressed="true"],
.rs-seg__item[aria-checked="true"],
.rs-seg__item[aria-selected="true"] {
  background: var(--rs-surface);
  color: var(--rs-ink);
  box-shadow: 0 0 0 1px var(--rs-border);
}
/* A destructive tab (User & Subscription › Delete account): danger text in every state. */
.rs-seg__item--danger,
.rs-seg__item--danger:hover,
.rs-seg__item--danger[aria-selected="true"] { color: var(--rs-danger); }
.rs-seg__item:disabled {
  color: var(--rs-ink-4);
  cursor: not-allowed;
}

/* ── Card ───────────────────────────────────────────────────────────────── */

.rs-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-md);
  background: var(--rs-surface);
  color: var(--rs-ink);
}
.rs-card__head {
  display: flex;
  align-items: center;
  gap: var(--rs-space-2);
  padding: var(--rs-space-3) var(--rs-space-4);
  border-bottom: 1px solid var(--rs-border);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-body);
  line-height: var(--rs-lh-body);
  font-weight: 600;
}
.rs-card__body {
  padding: var(--rs-space-4);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-body);
  line-height: var(--rs-lh-body);
}
.rs-card__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--rs-space-2);
  padding: var(--rs-space-3) var(--rs-space-4);
  border-top: 1px solid var(--rs-border);
}

/* ── KPI tile ───────────────────────────────────────────────────────────── */

.rs-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--rs-space-1);
  min-width: 0;
  padding: var(--rs-space-4);
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-md);
  background: var(--rs-surface);
}
.rs-kpi__label {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-label);
  line-height: var(--rs-lh-label);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--rs-ink-3);
}
.rs-kpi__value {
  font-family: var(--rs-font-mono);
  font-size: var(--rs-text-kpi);
  line-height: var(--rs-lh-kpi);
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--rs-ink);
}
.rs-kpi__unit {
  margin-left: var(--rs-space-1);
  font-family: var(--rs-font-mono);
  font-size: var(--rs-text-caption);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--rs-ink-3);
}
.rs-kpi__note {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-caption);
  line-height: var(--rs-lh-caption);
  color: var(--rs-ink-3);
}

/* ── Tag (tool identity) and status badge ───────────────────────────────── */

.rs-tag,
.rs-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--rs-space-1);
  box-sizing: border-box;
  height: calc(var(--rs-space-4) + var(--rs-space-1));
  padding: 0 var(--rs-space-2);
  border-radius: var(--rs-radius-pill);
  font-family: var(--rs-font-sans);
  font-weight: 500;
  white-space: nowrap;
  background: var(--rs-surface-sunken);
  color: var(--rs-ink-2);
}
.rs-tag {
  font-size: var(--rs-text-label);
  line-height: var(--rs-lh-label);
}
.rs-tag--runspec { background: var(--rs-accent-tint); color: var(--rs-accent-deep); }
.rs-tag--keyword { background: var(--rs-tool-keyword-tint); color: var(--rs-tool-keyword); }
.rs-tag--spectre { background: var(--rs-tool-spectre-tint); color: var(--rs-tool-spectre); }
.rs-tag--neutral { background: var(--rs-surface-sunken); color: var(--rs-ink-2); }

.rs-badge {
  font-size: var(--rs-text-caption);
  line-height: var(--rs-lh-caption);
}
.rs-badge__icon {
  display: inline-flex;
  font-size: var(--rs-text-control);
  line-height: 1;
}
.rs-badge--ok { background: var(--rs-ok-tint); color: var(--rs-ok); }
.rs-badge--warn { background: var(--rs-warn-tint); color: var(--rs-warn); }
.rs-badge--danger { background: var(--rs-danger-tint); color: var(--rs-danger); }
.rs-badge--neutral { background: var(--rs-surface-sunken); color: var(--rs-ink-2); }

/* ── Rail ───────────────────────────────────────────────────────────────── */

.rs-rail {
  display: flex;
  flex-direction: column;
  gap: calc(var(--rs-space-1) / 2);
  margin: 0;
  padding: var(--rs-space-2);
  list-style: none;
}
.rs-rail__item {
  display: flex;
  align-items: center;
  gap: var(--rs-space-2);
  box-sizing: border-box;
  width: 100%;
  min-height: var(--rs-control-h);
  padding: 0 var(--rs-space-3);
  border: 0;
  border-radius: var(--rs-radius-sm);
  background: transparent;
  color: var(--rs-ink-2);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-control);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.rs-rail__item:hover {
  background: var(--rs-surface-sunken);
  color: var(--rs-ink);
}
.rs-rail__item--selected,
.rs-rail__item[aria-current="page"],
.rs-rail__item[aria-current="true"] {
  background: var(--rs-tool-tint, var(--rs-accent-tint));
  color: var(--rs-ink);
  font-weight: 600;
}
.rs-rail__item .rs-dot {
  width: var(--rs-space-2);
  height: var(--rs-space-2);
}
.rs-rail__meta {
  margin-left: auto;
  font-family: var(--rs-font-mono);
  font-size: var(--rs-text-caption);
  font-weight: 400;
  color: var(--rs-ink-3);
}

/* ── Panel / slide-over ─────────────────────────────────────────────────── */

.rs-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-md);
  background: var(--rs-surface);
  box-shadow: var(--rs-shadow-float);
  color: var(--rs-ink);
}
.rs-panel__head {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--rs-space-2);
  padding: var(--rs-space-3) var(--rs-space-4);
  border-bottom: 1px solid var(--rs-border);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-heading);
  line-height: var(--rs-lh-heading);
  font-weight: 600;
}
.rs-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--rs-space-4);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-body);
  line-height: var(--rs-lh-body);
}
.rs-panel__foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: var(--rs-space-2);
  padding: var(--rs-space-3) var(--rs-space-4);
  border-top: 1px solid var(--rs-border);
  background: var(--rs-surface);
}

/* ── Dialog (modal) ─────────────────────────────────────────────────────────
   One look for every dialog (owner 2026-11-05, D4/D5): scrim · box · header
   (title left, × top-right) · optional tab bar · scrolling body · optional foot.
   The box has a FIXED size per size class, so switching tabs or states never
   resizes it; the body scrolls inside. --sm is for short confirmations (fixed
   width, height of its content up to the viewport). The page keeps showing and
   hiding the root as before (style.display / .visible / hidden); static/js/
   rs-dialog.js closes the topmost one on Escape through its × button. */

.rs-dialog {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: var(--rs-space-4);
  background: color-mix(in srgb, var(--rs-brand-navy) 55%, transparent);
}
.rs-dialog[hidden] { display: none; }
.rs-dialog__box {
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(560px, 100%);
  height: min(640px, 100%);
  overflow: hidden;
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-md);
  background: var(--rs-surface);
  box-shadow: var(--rs-shadow-float);
  color: var(--rs-ink);
  text-align: left;
}
.rs-dialog__box--sm { width: min(440px, 100%); height: auto; max-height: 100%; }
.rs-dialog__box--lg { width: min(880px, 100%); height: min(720px, 100%); }
.rs-dialog__box--xl { width: min(1180px, 100%); height: min(860px, 100%); }
.rs-dialog__head {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--rs-space-2);
  min-height: var(--rs-header-h);
  box-sizing: border-box;
  padding: var(--rs-space-2) var(--rs-space-3) var(--rs-space-2) var(--rs-space-5);
  border-bottom: 1px solid var(--rs-border);
}
.rs-dialog__title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-title);
  line-height: var(--rs-lh-title);
  font-weight: 600;
  color: var(--rs-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rs-dialog__close {
  flex: none;
  margin-left: auto;
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-title);
  line-height: 1;
}
.rs-dialog__tabs {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--rs-space-3);
  padding: var(--rs-space-3) var(--rs-space-5) 0;
}
.rs-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--rs-space-4) var(--rs-space-5);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-body);
  color: var(--rs-ink-2);
}
.rs-dialog__body--flush { padding: 0; overflow: hidden; }
.rs-dialog__foot {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: var(--rs-space-2);
  padding: var(--rs-space-3) var(--rs-space-5);
  border-top: 1px solid var(--rs-border);
}

/* ── Toast ──────────────────────────────────────────────────────────────────
   One stack, bottom right, at most three visible: append new toasts at the end and
   the oldest beyond three are hidden. Deduplication and the 4 s timer are JS (step 9). */

.rs-toast-stack {
  position: fixed;
  right: var(--rs-space-5);
  bottom: var(--rs-space-5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--rs-space-2);
  width: var(--rs-agent-w);
  max-width: calc(100vw - 2 * var(--rs-space-5));
  pointer-events: none;
}
.rs-toast-stack > .rs-toast:nth-last-child(n + 4) { display: none; }
/* In-flow copy of the stack, for previews and docs only. */
.rs-toast-stack--inline {
  position: static;
  max-width: 100%;
}
.rs-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--rs-space-2);
  padding: var(--rs-space-3);
  border: 1px solid var(--rs-border-strong);
  border-radius: var(--rs-radius-md);
  background: var(--rs-surface);
  box-shadow: var(--rs-shadow-float);
  color: var(--rs-ink);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-control);
  pointer-events: auto;
}
.rs-toast__icon {
  display: inline-flex;
  flex: none;
  font-size: var(--rs-text-heading);
  line-height: var(--rs-lh-control);
  color: var(--rs-ink-3);
}
.rs-toast__body {
  flex: 1 1 auto;
  min-width: 0;
}
.rs-toast--ok .rs-toast__icon { color: var(--rs-ok); }
.rs-toast--warn .rs-toast__icon { color: var(--rs-warn); }
.rs-toast--danger .rs-toast__icon { color: var(--rs-danger); }

/* ── Empty state ────────────────────────────────────────────────────────── */

.rs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rs-space-3);
  padding: var(--rs-space-6) var(--rs-space-4);
  text-align: center;
  color: var(--rs-ink-2);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-body);
  line-height: var(--rs-lh-body);
}
.rs-empty__icon {
  font-size: calc(var(--rs-control-h) - var(--rs-space-1));
  line-height: 1;
  color: var(--rs-ink-4);
}
.rs-empty__text { margin: 0; }

/* ── Inputs ─────────────────────────────────────────────────────────────── */

.rs-field {
  display: flex;
  flex-direction: column;
  gap: var(--rs-space-1);
  min-width: 0;
}
.rs-field__label {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-label);
  line-height: var(--rs-lh-label);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--rs-ink-3);
}
.rs-field__hint {
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-caption);
  line-height: var(--rs-lh-caption);
  color: var(--rs-ink-3);
}

.rs-input,
.rs-select,
.rs-textarea {
  box-sizing: border-box;
  width: 100%;
  height: var(--rs-control-h);
  margin: 0;
  padding: 0 var(--rs-space-3);
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-sm);
  background: var(--rs-surface);
  color: var(--rs-ink);
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-control);
  line-height: var(--rs-lh-control);
}
.rs-input::placeholder,
.rs-textarea::placeholder { color: var(--rs-ink-4); }
.rs-input:hover:not(:disabled),
.rs-select:hover:not(:disabled),
.rs-textarea:hover:not(:disabled) { border-color: var(--rs-border-strong); }
.rs-input[aria-invalid="true"],
.rs-select[aria-invalid="true"],
.rs-textarea[aria-invalid="true"] { border-color: var(--rs-danger); }
.rs-input:disabled,
.rs-select:disabled,
.rs-textarea:disabled {
  background: var(--rs-surface-sunken);
  color: var(--rs-ink-4);
  cursor: not-allowed;
}
.rs-input--mono {
  font-family: var(--rs-font-mono);
  font-size: var(--rs-text-value);
  font-variant-numeric: tabular-nums;
}
.rs-select {
  appearance: none;
  padding-right: var(--rs-space-6);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--rs-ink-3) 50%),
    linear-gradient(135deg, var(--rs-ink-3) 50%, transparent 50%);
  background-position:
    calc(100% - var(--rs-space-4)) 50%,
    calc(100% - var(--rs-space-3)) 50%;
  background-size: var(--rs-space-1) var(--rs-space-1);
  background-repeat: no-repeat;
}
.rs-textarea {
  height: auto;
  min-height: calc(3 * var(--rs-control-h));
  padding: var(--rs-space-2) var(--rs-space-3);
  line-height: var(--rs-lh-body);
  resize: vertical;
}

/* ── Chat bubble ────────────────────────────────────────────────────────── */

.rs-bubble {
  box-sizing: border-box;
  max-width: 85%;
  font-family: var(--rs-font-sans);
  font-size: var(--rs-text-body);
  line-height: var(--rs-lh-body);
  overflow-wrap: anywhere;
}
/* Inverse of the page in both themes: ink fill, text in the surface colour. */
.rs-bubble--user {
  align-self: flex-end;
  padding: var(--rs-space-2) var(--rs-space-3);
  border-radius: var(--rs-radius-md) var(--rs-radius-md) 0 var(--rs-radius-md);
  background: var(--rs-ink);
  color: var(--rs-surface);
}
.rs-bubble--agent {
  display: flex;
  align-items: flex-start;
  gap: var(--rs-space-2);
  align-self: flex-start;
  color: var(--rs-ink);
}
.rs-bubble__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--rs-space-5);
  height: var(--rs-space-5);
  border-radius: var(--rs-radius-pill);
  background: var(--rs-tool-spectre-tint);
  color: var(--rs-tool-spectre);
  font-size: var(--rs-text-control);
  line-height: 1;
}
.rs-bubble__text { min-width: 0; }

/* ── Shell: header 40 / strip 44 / [rail 224 | main | agent 300] ───────────
   Below 1280 px the two header rows become one and the rails stack under main. */

.rs-shell {
  display: grid;
  grid-template-columns: var(--rs-rail-w) minmax(0, 1fr) var(--rs-agent-w);
  grid-template-rows: var(--rs-shell-row1-h) var(--rs-strip-h) minmax(0, 1fr);
  grid-template-areas:
    "header header header"
    "strip  strip  strip"
    "rail   main   agent";
  min-height: 0;
  background: var(--rs-page);
  color: var(--rs-ink);
  font-family: var(--rs-font-sans);
}
.rs-shell__header,
.rs-shell__strip {
  display: flex;
  align-items: center;
  gap: var(--rs-space-3);
  min-width: 0;
  padding: 0 var(--rs-space-4);
  border-bottom: 1px solid var(--rs-border);
  background: var(--rs-surface);
}
.rs-shell__header { grid-area: header; }
.rs-shell__strip { grid-area: strip; }
.rs-shell__rail {
  grid-area: rail;
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--rs-border);
  background: var(--rs-surface);
}
.rs-shell__main {
  grid-area: main;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: var(--rs-space-5);
}
.rs-shell__agent {
  grid-area: agent;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--rs-border);
  background: var(--rs-surface);
}

@media (max-width: 1279px) {
  .rs-shell {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: var(--rs-shell-row1-h) auto auto auto;
    grid-template-areas:
      "header strip"
      "main   main"
      "rail   rail"
      "agent  agent";
  }
  .rs-shell__header { padding-right: var(--rs-space-2); }
  .rs-shell__strip { padding-left: var(--rs-space-2); }
  .rs-shell__rail,
  .rs-shell__agent {
    overflow: visible;
    border-right: 0;
    border-left: 0;
    border-top: 1px solid var(--rs-border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rs-btn { transition: none; }
}
