/* ui-storybook — semantic CSS in rust-ui's dark zinc aesthetic.
 *
 * Plain CSS rather than Tailwind to keep the toolchain Rust-only. Class
 * naming intentionally mirrors rust-ui's component class hooks so swapping
 * to Tailwind later is a string replacement, not a rewrite.
 */

:root {
  /* Neutral-zinc palette. The recorder shell is intentionally hue-
   * free — slight blue cast from the Tailwind `zinc` family was
   * showing up as a subtle tint on the card surfaces, so the panel
   * and card backgrounds use these exact values (matching
   * neutral-950 / neutral-900) instead. */
  --bg: #0a0a0b;
  --bg-elev: #171719;
  --bg-row-alt: #1f1f1f;
  --fg: #ffffff;
  --fg-muted: #a1a1aa;      /* zinc-400 */
  --border: #272727;        /* neutral edge */
  --border-strong: #3f3f3f;
  --accent: #fafafa;
  --accent-fg: #09090b;
  --danger: #ef4444;        /* red-500 */
  --secondary: #1f1f1f;
  --kf-hold: #a1a1aa;
  --kf-linear: #38bdf8;     /* sky-400 */
  --kf-ease: #a78bfa;       /* violet-400 */
  --kf-marker: #facc15;     /* yellow-400 */

  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* ── Semantic UI-01 tokens ──────────────────────────────────
   *
   * Aliases for the recurring product surfaces. Components should
   * reach for these instead of the raw `--bg` / `--border` /
   * `--accent` values so the same component reads correctly in
   * popovers, panels, and selected rows. New semantic tokens are
   * added here when a component needs one that isn't yet defined.
   */
  --surface-base: var(--bg);
  --surface-elevated: var(--bg-elev);
  --surface-popover: #131313;
  --surface-selected: #232323;
  --surface-glass: rgba(23, 23, 25, 0.78);

  --text-primary: var(--fg);
  --text-secondary: var(--fg-muted);
  --text-tertiary: #71717a;

  --line-subtle: var(--border);
  --line-strong: var(--border-strong);
  /* Visible white edge for the recorder card/row outlines. 12 %
   * opacity reads as a clean hairline against the neutral panel
   * without screaming for attention; consumers apply it as
   * `border: 1.5px solid var(--line-card)`. */
  --line-card: rgba(255, 255, 255, 0.12);

  --action-record: var(--danger);
  --action-record-hover: #dc2626;

  --shadow-popover: 0 18px 48px rgba(0, 0, 0, 0.55);
  --shadow-elevated: 0 6px 16px rgba(0, 0, 0, 0.30);

  --radius-panel: var(--radius-lg);
  --radius-control: var(--radius);
  --radius-pill: 999px;

  --focus-ring: 0 0 0 2px rgba(56, 189, 248, 0.55);
}

/* ───── Surface ───── */
.surface {
  border-radius: var(--radius-panel);
}
.surface-base { background: var(--surface-base); }
.surface-elevated {
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  box-shadow: var(--shadow-elevated);
}
.surface-popover {
  background: var(--surface-popover);
  border: 1px solid var(--line-subtle);
  box-shadow: var(--shadow-popover);
}
.surface-selected {
  background: var(--surface-selected);
  border: 1px solid var(--line-strong);
}
.surface-glass {
  background: var(--surface-glass);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(12px);
}

/* ───── Badge ───── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}
.badge-neutral {
  background: var(--secondary);
  color: var(--text-primary);
}
.badge-accent {
  background: rgba(250, 250, 250, 0.10);
  color: var(--text-primary);
  border: 1px solid var(--line-subtle);
}
.badge-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
}
.badge-live {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}
.badge-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--action-record);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  animation: rec-pulse 1.4s ease-out infinite;
}
.badge-plan {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--line-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}
.badge-count {
  background: var(--secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  min-width: 18px;
  justify-content: center;
}

/* ───── Divider ───── */
.divider {
  background: var(--line-subtle);
}
.divider-h {
  height: 1px;
  width: 100%;
}
.divider-v {
  width: 1px;
  align-self: stretch;
}

/* ───── Kbd row ───── */
.kbd-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.kbd-key {
  font-family: var(--font-mono);
  background: var(--secondary);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
}

/* ───── ChevronDown ─────
 * Inline SVG that paints with `currentColor`, so the consuming
 * container's `color` rule controls the tint. The SVG carries its
 * own width/height, but `display:block` avoids the inline baseline
 * gap when sitting alongside text. */
.chevron-down {
  display: block;
  flex-shrink: 0;
}

/* ───── IconTile ───── */
.icon-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-control);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  border: 1px solid var(--line-subtle);
}
.icon-tile-workspace { background: linear-gradient(135deg, #4338ca, #db2777); color: #fff; border-color: transparent; }
.icon-tile-device    { background: var(--secondary); color: var(--text-secondary); }
.icon-tile-app       { background: #1e293b; color: #e2e8f0; }
.icon-tile-action    { background: var(--surface-elevated); }
.icon-tile-user      { background: #18181b; color: #fafafa; border-radius: 8px; }

/* ───── UI-01 story layout helpers ───── */
.token-grid {
  display: grid;
  grid-template-columns: 220px 80px 1fr;
  gap: 8px 14px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 14px 18px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-panel);
}
.token-name { color: var(--text-secondary); }
.token-swatch {
  width: 60px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-subtle);
}
.token-value { color: var(--text-primary); }

.surface-stack {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: var(--surface-base);
  border-radius: var(--radius-panel);
}
.surface-demo {
  padding: 16px 20px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
}

.badge-row { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px; }

/* ───── AppShell ───── */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 480px;
  background: var(--surface-base);
  border-radius: var(--radius-panel);
  overflow: hidden;
  border: 1px solid var(--line-subtle);
}
.app-shell-titlebar {
  padding: 8px 14px;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--line-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}
.app-shell-body { flex: 1; display: flex; min-height: 0; }
.app-shell-rail {
  width: 76px;
  background: var(--bg);
  border-right: 1px solid var(--line-card);
  display: flex;
  flex-direction: column;
}
.app-shell-main {
  flex: 1;
  background: var(--surface-base);
  padding: 18px 22px;
  overflow: auto;
  min-width: 0;
}
.app-shell-inspector {
  width: 280px;
  background: var(--surface-elevated);
  border-left: 1px solid var(--line-subtle);
  padding: 16px 18px;
  overflow: auto;
}
.app-shell-footer {
  background: var(--surface-elevated);
  border-top: 1px solid var(--line-subtle);
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ───── NavigationRail ───── */
.nav-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  height: 100%;
  gap: 14px;
  color: var(--text-secondary);
}
.nav-rail-top { display: flex; align-items: center; justify-content: center; }
.nav-rail-bottom {
  margin-top: auto;
  padding-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-rail-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  align-items: center;
}
/* Each rail entry is a uniform rounded-square icon tile (label
 * underneath). The base state is a flat surface-elevated tile; the
 * selected state is a brighter outlined version. */
.nav-rail-item {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  width: 56px;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.nav-rail-item .nav-rail-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* The icon child is an SVG that paints with `currentColor`, so
   * `color` here drives the stroke tint of the Lucide glyph. */
  color: rgba(255, 255, 255, 0.85);
}
.nav-rail-item:hover .nav-rail-icon {
  background: var(--surface-selected);
  color: #ffffff;
  border-color: var(--line-strong);
}
/* Active state brightens the label only; the tile itself stays
 * unchanged until :hover. */
.nav-rail-item-active {
  color: var(--text-primary);
}
.nav-rail-item-disabled { opacity: 0.4; cursor: not-allowed; }
.nav-rail-label {
  font-size: 11px;
  font-weight: 500;
  color: inherit;
  letter-spacing: 0.01em;
}
.nav-rail-count {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--action-record);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: var(--radius-pill);
  min-width: 14px;
  text-align: center;
}

/* ───── WorkspaceBadge ───── */
.workspace-badge {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
}
.workspace-badge-tile {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--action-record);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}
.workspace-badge-chevron {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 1px solid var(--line-strong);
  color: var(--text-secondary);
  font-size: 8px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.workspace-badge-open .workspace-badge-chevron { color: var(--text-primary); }

/* ───── UserAvatar ───── */
.user-avatar {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar-monogram {
  width: 100%;
  height: 100%;
  background: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* ───── App-shell story scaffolding ───── */
.shell-story { width: 720px; height: 460px; }
.shell-story .app-shell { height: 100%; min-height: 0; }
.shell-story-main-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 13px;
}
.shell-story-inspector-placeholder {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

/* ───── Button ───── */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; height: 28px; }
.btn-md { padding: 6px 14px; font-size: 14px; height: 34px; }
.btn-lg { padding: 8px 18px; font-size: 15px; height: 40px; }

.btn-default { background: var(--accent); color: var(--accent-fg); }
.btn-default:hover:not(:disabled) { background: #e4e4e7; }

.btn-outline { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--bg-elev); border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-elev); }

.btn-destructive { background: var(--danger); color: #fff; }
.btn-destructive:hover:not(:disabled) { background: #dc2626; }

.btn-secondary { background: var(--secondary); color: var(--fg); }
.btn-secondary:hover:not(:disabled) { background: #3f3f46; }

/* ───── Card ───── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.card-body { padding: 14px 18px; }

/* ───── Story layout helpers ───── */
.story-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
kbd {
  font-family: var(--font-mono);
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 12px;
}

/* ───── DopeSheet ───── */
.dope-sheet {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
}
.dope-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.dope-row:last-child { border-bottom: 0; }
.dope-row:nth-child(odd) .dope-track { background: var(--bg-row-alt); }
.dope-ruler { background: var(--bg-elev); color: var(--fg-muted); }

.dope-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
}
.dope-label-spacer { background: var(--bg-elev); }
.dope-label-glyph {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
}
.dope-label-text { color: var(--fg); }

.dope-track {
  position: relative;
  height: 28px;
}
.dope-ruler-track { height: 22px; }
.dope-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.dope-tick-label {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 10px;
  color: var(--fg-muted);
}

.dope-keyframe {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  transform: rotate(45deg);
  background: var(--kf-hold);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.dope-keyframe.kf-hold { background: var(--kf-hold); }
.dope-keyframe.kf-linear { background: var(--kf-linear); }
.dope-keyframe.kf-ease { background: var(--kf-ease); }
.dope-keyframe.kf-marker {
  background: var(--kf-marker);
  width: 3px;
  height: 22px;
  margin-left: -1.5px;
  margin-top: -11px;
  transform: none;
  border-radius: 1px;
}

.dope-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: 119px; /* offset past the labels column */
  background: var(--accent);
  box-shadow: 0 0 6px rgba(250, 250, 250, 0.4);
  pointer-events: none;
}

/* ───── DropZone ───── */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 56px 32px;
  border-radius: var(--radius-lg);
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease,
              transform 160ms ease;
  user-select: none;
}
.drop-zone-idle {
  background: var(--bg-elev);
  border: 1.5px dashed var(--border-strong);
}
.drop-zone-idle:hover {
  border-color: var(--fg-muted);
  background: #1c1c20;
}
.drop-zone-active {
  background: rgba(56, 189, 248, 0.08);
  border: 1.5px solid var(--kf-linear);
  transform: scale(1.005);
}
.drop-zone-glyph {
  font-size: 42px;
  line-height: 1;
  color: var(--fg-muted);
}
.drop-zone-active .drop-zone-glyph {
  color: var(--kf-linear);
}
.drop-zone-headline {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}
.drop-zone-subtext {
  font-size: 13px;
  color: var(--fg-muted);
}
.drop-zone-hint {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

/* ───── PlayerControls ───── */
.player-controls {
  display: grid;
  grid-template-columns: 36px auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.player-toggle {
  appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease;
}
.player-toggle:hover { transform: scale(1.05); }
.player-toggle-glyph {
  font-size: 11px;
  letter-spacing: -1px;
  line-height: 1;
}
.player-toggle-paused .player-toggle-glyph { padding-left: 2px; /* visual centering */ }
.player-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  min-width: 38px;
  text-align: center;
}
.player-scrub {
  display: flex;
  align-items: center;
  height: 30px;
}
.player-scrub-track {
  position: relative;
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.player-scrub-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--accent);
  border-radius: 2px;
}
.player-scrub-handle {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(250, 250, 250, 0.08);
  transition: box-shadow 120ms ease;
}
.player-scrub-handle:hover {
  box-shadow: 0 0 0 6px rgba(250, 250, 250, 0.14);
}

/* ───── Editor mock composition ───── */
.editor-mock {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.editor-mock-preview {
  margin-bottom: 12px;
}
.editor-mock-screen {
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(167, 139, 250, 0.16)),
    var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* ───── RecordingToolbar ───── */
.recording-toolbar {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.rec-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted);
}
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-muted);
  display: inline-block;
}
.rec-recording .rec-dot:not(.rec-dot-static) {
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  animation: rec-pulse 1.4s ease-out infinite;
}
.rec-paused .rec-dot:not(.rec-dot-static) {
  background: var(--kf-marker);
}
.rec-status-label {
  font-weight: 500;
}
.rec-recording .rec-status-label { color: var(--danger); }
.rec-paused .rec-status-label { color: var(--kf-marker); }
.rec-timer {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg);
  min-width: 60px;
}
.rec-source {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  justify-self: start;
}
.rec-source-glyph {
  color: var(--kf-linear);
  font-size: 14px;
  line-height: 1;
}
.rec-actions {
  display: flex;
  gap: 8px;
}
.rec-action {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 6px 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 120ms ease;
}
.rec-action-primary {
  background: var(--danger);
  color: #fff;
}
.rec-action-primary:hover { background: #dc2626; }
.rec-action-primary .rec-dot-static {
  background: #fff;
}
.rec-action-secondary {
  background: var(--secondary);
  color: var(--fg);
}
.rec-action-secondary:hover { background: #3f3f46; }
.rec-action-stop {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.rec-action-stop:hover {
  background: var(--bg-elev);
  border-color: var(--border-strong);
}

@keyframes rec-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0); }
}

/* ───── StatusBar ───── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 14px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--fg-muted);
}
.status-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.status-key {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: #71717a;
}
.status-value {
  color: var(--fg);
}
.status-spacer { flex: 1; }
.status-detail {
  font-size: 12px;
  color: var(--fg-muted);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
}
.status-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-pill-ready { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.status-pill-ready .status-pill-dot { background: #4ade80; }
.status-pill-busy { background: rgba(56, 189, 248, 0.12); color: var(--kf-linear); }
.status-pill-busy .status-pill-dot {
  background: var(--kf-linear);
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.5);
  animation: rec-pulse 1.4s ease-out infinite;
}
.status-pill-error { background: rgba(239, 68, 68, 0.14); color: #f87171; }
.status-pill-error .status-pill-dot { background: var(--danger); }

/* track-kind tints (subtle accents on the row backgrounds) */
.track-video .dope-track { background: linear-gradient(0deg, rgba(56, 189, 248, 0.04), rgba(56, 189, 248, 0.04)), var(--bg); }
.track-cursor .dope-track { background: linear-gradient(0deg, rgba(167, 139, 250, 0.04), rgba(167, 139, 250, 0.04)), var(--bg); }
.track-audio .dope-track { background: linear-gradient(0deg, rgba(34, 197, 94, 0.04), rgba(34, 197, 94, 0.04)), var(--bg); }
.track-caption .dope-track { background: linear-gradient(0deg, rgba(250, 204, 21, 0.04), rgba(250, 204, 21, 0.04)), var(--bg); }
.track-effect .dope-track { background: linear-gradient(0deg, rgba(244, 114, 182, 0.04), rgba(244, 114, 182, 0.04)), var(--bg); }

/* ───── PopoverSurface (UI-03) ───── */
.popover-surface {
  background: var(--surface-popover);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-popover);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-sans);
}
.popover-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line-subtle);
}
.popover-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.popover-description { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.popover-body { padding: 6px; }
.popover-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--line-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-elevated);
}

/* ───── MenuList ───── */
.menu-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }

/* ───── MenuSection ───── */
.menu-section { display: contents; }
.menu-section-heading {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 8px 10px 4px;
}
.menu-section-rows { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }

/* ───── MenuRow ───── */
.menu-row-item { list-style: none; }
.menu-row {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-control);
  font: inherit;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease;
  position: relative;
}
.menu-row:hover:not(:disabled) { background: var(--surface-elevated); }
.menu-row-selected { background: var(--surface-selected); }
.menu-row-action .menu-row-title { font-weight: 600; }
.menu-row-danger { color: #f87171; }
.menu-row-disabled { opacity: 0.45; cursor: not-allowed; }

.menu-row-leading { flex-shrink: 0; display: inline-flex; align-items: center; }
.menu-row-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.menu-row-title { font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-row-subtitle { font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-row-badges { display: inline-flex; gap: 6px; flex-shrink: 0; }
.menu-row-trailing {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  flex-shrink: 0;
}
.menu-row-check { color: var(--text-primary); font-size: 11px; margin-left: 4px; }

.menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ───── IconButton (UI-04) ───── */
.icon-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-elevated); color: var(--text-primary); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn-pressed { background: var(--surface-selected); color: var(--text-primary); border-color: var(--line-strong); }
.icon-btn-filled { background: var(--secondary); color: var(--text-primary); }
.icon-btn-danger { background: var(--action-record); color: #fff; }
.icon-btn-danger:hover:not(:disabled) { background: var(--action-record-hover); }

/* ───── ToggleSwitch ───── */
.toggle {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.toggle:disabled { cursor: not-allowed; }
.toggle-track {
  display: inline-block;
  width: 32px;
  height: 18px;
  background: var(--secondary);
  border-radius: 999px;
  position: relative;
  transition: background 120ms ease;
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 160ms ease;
}
.toggle-on .toggle-track { background: var(--text-primary); }
.toggle-on .toggle-knob { background: #09090b; transform: translateX(14px); }
.toggle-disabled { opacity: 0.45; }

/* ───── ToggleSwitch — single-element pill toggle ───── */
/* Used by the live RecorderPage rows (camera / mic / system-audio /
 * on-screen options). Renders as a <button role="switch"> with a
 * single <span class="toggle-switch-thumb"> child — no separate track
 * element, so the button itself is the track. Visual treatment matches
 * the two-element `.toggle` above but adapted to that flatter DOM.
 */
.toggle-switch {
  appearance: none;
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  padding: 0;
  background: var(--secondary);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 120ms ease;
  flex-shrink: 0;
}
.toggle-switch:disabled { cursor: not-allowed; opacity: 0.45; }
.toggle-switch:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.toggle-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 160ms ease, background 120ms ease;
}
.toggle-switch-checked { background: var(--text-primary); }
.toggle-switch-checked .toggle-switch-thumb {
  background: var(--surface-base);
  transform: translateX(14px);
}

/* ───── SegmentedControl ───── */
.segmented {
  display: inline-flex;
  background: var(--secondary);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.segment {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.segment:hover:not(:disabled) { color: var(--text-primary); }
.segment-active { background: var(--text-primary); color: #09090b; }
.segment-active:hover { color: #09090b; }
.segment-disabled { opacity: 0.4; cursor: not-allowed; }
.segment-icon { font-size: 12px; line-height: 1; }

/* ───── Slider ───── */
.slider {
  display: grid;
  grid-template-columns: 80px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}
.slider-label { white-space: nowrap; }
.slider-track {
  position: relative;
  height: 4px;
  background: var(--secondary);
  border-radius: 999px;
}
.slider-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--text-primary);
  border-radius: 999px;
}
.slider-thumb {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: var(--text-primary);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(250, 250, 250, 0.08);
}
.slider-readout {
  font-family: var(--font-mono);
  color: var(--text-primary);
  text-align: right;
}
.slider-disabled { opacity: 0.45; }

/* ───── SelectPill ───── */
.select-pill {
  appearance: none;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-pill);
  padding: 4px 10px 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}
.select-pill:hover:not(:disabled) { background: var(--surface-selected); }
.select-pill:disabled { opacity: 0.45; cursor: not-allowed; }
.select-pill-icon { font-size: 13px; line-height: 1; }
.select-pill-chevron { color: var(--text-tertiary); font-size: 9px; }
.select-pill-open .select-pill-chevron { color: var(--text-primary); transform: rotate(180deg); }

/* ───── ColorSwatch ───── */
.color-swatch {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
}
.color-swatch-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.color-swatch-selected {
  box-shadow: 0 0 0 2px var(--surface-base), 0 0 0 4px var(--text-primary);
}

/* ───── Meter ───── */
.meter { display: inline-flex; gap: 2px; align-items: center; }
.meter-bar {
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--secondary);
  border-radius: 1px;
}
.meter-bar-on { background: #4ade80; }
.meter-danger .meter-bar-on { background: var(--action-record); }

/* ───── DisplaySourceCard (UI-07) ───── */
.display-source-card {
  background: var(--surface-elevated);
  border: 2px solid transparent;
  border-radius: var(--radius-panel);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--font-sans);
  width: 360px;
  color: var(--text-primary);
}
.display-source-card-selected { border-color: var(--action-record); }
.display-source-card-unavailable { opacity: 0.6; }
.display-source-header { display: flex; align-items: center; gap: 8px; }
.display-source-label { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; }
.display-source-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.display-source-size {
  font-size: 11px;
  color: var(--text-secondary);
}
.display-source-star { color: var(--kf-marker); font-size: 12px; line-height: 1; }
.display-source-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.display-source-dims {
  background: var(--action-record);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.display-source-chevron { color: var(--text-tertiary); font-size: 11px; transition: transform 120ms; }
.display-source-chevron-open { color: var(--text-primary); transform: rotate(180deg); }

.display-source-unavailable-banner {
  font-size: 11px;
  color: var(--action-record);
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: var(--radius-control);
  padding: 6px 10px;
  text-align: center;
}

/* ───── DisplayPreviewFrame ───── */
.display-preview {
  width: 100%;
  background: linear-gradient(140deg, #2a2a32, #15151a);
  border-radius: var(--radius-control);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-subtle);
}
.display-preview-titlebar {
  background: #2a2a2f;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  height: 16px;
}
.display-preview-tlbtn { width: 8px; height: 8px; border-radius: 50%; }
.display-preview-tlbtn-red { background: #ef4444; }
.display-preview-tlbtn-amber { background: #f59e0b; }
.display-preview-tlbtn-green { background: #10b981; }
.display-preview-body {
  position: relative;
  flex: 1;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.10), rgba(167, 139, 250, 0.10)),
    radial-gradient(closest-side at 50% 60%, #1a1a20, #0b0b0e);
}
.display-preview-chip {
  position: absolute;
  border-radius: 4px;
  display: flex;
  align-items: flex-start;
  padding: 2px 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  color: var(--text-primary);
  font-size: 10px;
}
.display-preview-chip-label {
  font-family: var(--font-sans);
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
}
.display-preview-overlay {
  position: absolute;
  top: 6px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(250, 250, 250, 0.10);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  color: var(--text-primary);
}

/* ───── CaptureSourceRow (UI-08) ───── */
.capture-source-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-panel);
  font-family: var(--font-sans);
  width: 360px;
}
.capture-source-row-expanded { border-color: var(--line-strong); }
.capture-source-row-off { opacity: 0.85; }
.capture-source-leading { display: inline-flex; align-items: center; justify-content: center; }
.capture-source-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.capture-source-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.capture-source-star { color: var(--kf-marker); font-size: 11px; line-height: 1; }
.capture-source-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.capture-source-meter { display: inline-flex; align-items: center; }
.capture-source-toggle { display: inline-flex; align-items: center; }
.capture-source-chevron {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-control);
}
.capture-source-chevron:hover { background: var(--surface-selected); color: var(--text-primary); }
.capture-source-chevron-open { color: var(--text-primary); transform: rotate(180deg); }

/* ───── DevicePickerMenu / DevicePickerRow (UI-08) ───── */
.device-picker-row-item { list-style: none; }
.device-picker-row {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 36px 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-control);
  font: inherit;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease;
}
.device-picker-row:hover { background: var(--surface-elevated); }
.device-picker-row-selected { background: var(--surface-selected); }
.device-picker-thumb {
  width: 36px;
  height: 24px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 11px;
  flex-shrink: 0;
}
.device-picker-thumb-glyph {
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 5px;
  border-radius: 3px;
}
.device-picker-row-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.device-picker-row-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-picker-row-detail {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-picker-row-meter { display: inline-flex; align-items: center; }
.device-picker-row-check {
  color: var(--action-record);
  font-weight: 700;
  font-size: 12px;
}

.device-picker-state {
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.device-picker-state-glyph {
  font-size: 22px;
  color: var(--text-tertiary);
}
.device-picker-state-glyph-warn { color: var(--action-record); }
.device-picker-state-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.device-picker-state-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 240px;
}

.btn-sm { padding: 4px 10px; font-size: 12px; height: 26px; }

/* ───── SystemAudioRow + AppList (UI-09) ───── */
.system-audio-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-panel);
  width: 360px;
}
.system-audio-leading { display: inline-flex; align-items: center; }
.system-audio-icon-stack { display: inline-flex; align-items: center; }
.system-audio-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--surface-elevated);
  margin-left: -8px;
  flex-shrink: 0;
}
.system-audio-icon:first-child { margin-left: 0; }
.system-audio-icon-overflow {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface-elevated);
  margin-left: -8px;
}
.system-audio-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.system-audio-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.system-audio-subtitle { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); }
.system-audio-toggle { display: inline-flex; align-items: center; }
.system-audio-chevron {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-control);
}
.system-audio-chevron-open { color: var(--text-primary); transform: rotate(180deg); }

.system-audio-applist {
  background: var(--surface-popover);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-panel);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 360px;
}
.system-audio-filters {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--secondary);
  border-radius: var(--radius-pill);
  align-self: flex-start;
}
.system-audio-filter {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
}
.system-audio-filter:hover { color: var(--text-primary); }
.system-audio-filter-active { background: var(--text-primary); color: #09090b; }

.system-audio-rows {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audio-app-row {
  display: grid;
  grid-template-columns: 18px 24px 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-control);
}
.audio-app-row:hover { background: var(--surface-elevated); }
.audio-app-row-selected { background: var(--surface-selected); }

.audio-app-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--surface-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-primary);
}
.audio-app-check-on {
  background: var(--text-primary);
  color: #09090b;
  border-color: var(--text-primary);
}

.audio-app-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.audio-app-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.audio-app-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-app-context {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-app-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--action-record);
}
.audio-app-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--action-record);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  animation: rec-pulse 1.4s ease-out infinite;
}
.audio-app-meter { display: inline-flex; align-items: center; }

/* ───── OnScreenOptionsPopover (UI-10) ───── */
.on-screen-options {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.on-screen-option-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 6px;
  border-radius: var(--radius-control);
}
.on-screen-option-row:not(:last-child) {
  border-bottom: 1px solid var(--line-subtle);
  border-radius: 0;
  padding-bottom: 12px;
  margin-bottom: 2px;
}
.on-screen-option-row-disabled { opacity: 0.5; }
.on-screen-option-toggle { display: inline-flex; align-items: center; padding-top: 2px; }
.on-screen-option-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.on-screen-option-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.on-screen-option-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ───── UI-11 — Recording-controls footer ───── */
.recording-controls-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-popover);
  border-top: 1px solid var(--line-subtle);
  border-radius: 0 0 var(--radius-panel) var(--radius-panel);
}
.recording-controls-selects {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.recording-controls-zoom,
.recording-controls-countdown {
  display: inline-flex;
}

/* Inverted shortcut chips for the red Start button. */
.shortcut-badges {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
}
.shortcut-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.32);
  min-width: 14px;
  text-align: center;
}
.shortcut-badges-on-action .shortcut-badge {
  background: rgba(0, 0, 0, 0.32);
  border-color: rgba(0, 0, 0, 0.42);
}

/* Start recording button. */
.start-recording-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--action-record);
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset,
              0 1px 3px rgba(0, 0, 0, 0.35);
  transition: background 80ms ease;
}
.start-recording-btn:hover:not(:disabled) {
  background: var(--action-record-hover);
}
.start-recording-btn:disabled,
.start-recording-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.start-recording-loading {
  cursor: progress;
}
.start-recording-permission-blocked {
  background: #f59e0b; /* amber-500 */
  color: #111;
}
.start-recording-permission-blocked .shortcut-badge {
  background: rgba(0, 0, 0, 0.18);
  color: #111;
  border-color: rgba(0, 0, 0, 0.28);
}
.start-recording-glyph {
  font-size: 12px;
  line-height: 1;
}
.start-recording-label {
  font-size: 13px;
}

/* ───── UI-12 — Tray record popover ───── */
.tray-record-popover {
  display: flex;
  flex-direction: column;
  width: 420px;
  border-radius: var(--radius-panel);
  background: var(--surface-popover);
  border: 1px solid var(--line-subtle);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  position: relative;
}
.tray-record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-subtle);
}
.tray-record-workspace-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.tray-record-workspace-chip:hover { background: var(--surface-selected); }
.tray-record-workspace-label { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.tray-record-chevron { color: var(--text-tertiary); font-size: 10px; }

.tray-record-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.tray-record-display,
.tray-record-sources,
.tray-record-audio,
.tray-record-on-screen {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tray-record-on-screen-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}
.tray-record-on-screen-row:hover { background: var(--surface-selected); }
.tray-record-on-screen-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tray-record-on-screen-title { font-size: 13px; font-weight: 600; }
.tray-record-on-screen-summary { font-size: 11px; color: var(--text-secondary); }

.tray-popover-overlay {
  position: absolute;
  z-index: 10;
}
.tray-popover-overlay-workspace { top: 56px; left: 12px; }
.tray-popover-overlay-camera,
.tray-popover-overlay-microphone { top: 220px; right: 12px; }
.tray-popover-overlay-on-screen { bottom: 76px; right: 12px; }

/* ───── UI-13 — Compact recording status pill ───── */
.recording-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 12px;
}
.recording-status-recording { background: var(--action-record); color: #fff; border-color: rgba(0,0,0,0.25); }
.recording-status-paused { background: #f59e0b; color: #111; border-color: rgba(0,0,0,0.3); }
.recording-status-stopping { background: var(--surface-elevated); color: var(--text-secondary); }
.recording-status-stopped { background: #16a34a; color: #fff; border-color: rgba(0,0,0,0.2); }
.recording-status-error { background: #7f1d1d; color: #fee2e2; border-color: rgba(0,0,0,0.3); }
.recording-status-countdown { background: var(--action-record); color: #fff; padding: 4px 8px; }
.recording-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.recording-status-dot-live { background: #fff; box-shadow: 0 0 6px rgba(255,255,255,0.7); animation: status-pulse 1.5s ease-in-out infinite; }
.recording-status-dot-paused { background: #111; }
.recording-status-text { font-weight: 600; font-family: var(--font-mono); }
.recording-status-shortcuts { display: inline-flex; gap: 2px; margin-left: 4px; }
.recording-status-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0,0,0,0.3);
  color: rgba(255,255,255,0.92);
}
.recording-status-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: rgba(0,0,0,0.25);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  font-size: 10px;
}
.recording-status-action:hover { background: rgba(0,0,0,0.4); }
.recording-status-action-stop { background: rgba(255,255,255,0.18); }
.recording-status-action-stop:hover { background: rgba(255,255,255,0.28); }
.recording-status-glyph { font-size: 13px; }

.countdown-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.32);
}
.countdown-badge-digit {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ───── UI-14 — Library sidebar ───── */
.library-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  width: 220px;
  height: 100%;
  background: var(--surface-base);
  border-right: 1px solid var(--line-subtle);
  color: var(--text-primary);
}
.library-primary, .library-section-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.library-section-heading {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin: 0 4px 6px;
}
.library-nav-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-control);
  font-size: 13px;
  cursor: pointer;
}
.library-nav-row:hover { background: var(--surface-elevated); }
.library-nav-row-selected { background: var(--surface-selected); color: var(--text-primary); }
.library-nav-row-disabled { opacity: 0.5; cursor: not-allowed; }
.library-nav-icon { font-size: 14px; color: var(--text-secondary); text-align: center; }
.library-nav-row-selected .library-nav-icon { color: var(--text-primary); }
.library-nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-nav-count {
  color: var(--text-tertiary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.library-nav-badge {
  background: var(--action-record);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  min-width: 16px;
  text-align: center;
}

.storage-meter {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: var(--radius-control);
  background: var(--surface-elevated);
}
.storage-meter-bar {
  position: relative;
  height: 6px;
  background: var(--line-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.storage-meter-fill {
  display: block;
  height: 100%;
  background: var(--kf-linear);
  transition: width 200ms ease;
}
.storage-meter-warn .storage-meter-fill { background: var(--action-record); }
.storage-meter-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}
.storage-meter-plan {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ───── UI-15 — Recording card + library grid ───── */
.library-grid-host {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  width: 100%;
  background: var(--surface-base);
  color: var(--text-primary);
}
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.library-filters {
  display: flex;
  align-items: center;
  gap: 6px;
}
.library-filter {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.library-filter:hover { background: var(--surface-elevated); color: var(--text-primary); }
.library-filter-active {
  background: var(--surface-selected);
  color: var(--text-primary);
  border-color: var(--line-strong);
}
.library-toolbar-right { display: inline-flex; align-items: center; gap: 8px; }
.library-sort {
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-control);
  cursor: pointer;
}
.library-layout-toggle { display: inline-flex; border: 1px solid var(--line-subtle); border-radius: var(--radius-control); overflow: hidden; }
.library-layout-btn {
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
}
.library-layout-btn-active { background: var(--surface-selected); color: var(--text-primary); }

.library-grid {
  display: grid;
  gap: 14px;
}
.library-grid-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.library-grid-list {
  grid-template-columns: 1fr;
}
.library-grid-list .recording-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
}
.library-grid-list .recording-card-thumb { aspect-ratio: 16 / 9; min-height: 80px; }
.library-grid-list .recording-card-body { padding: 12px 16px; }

.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 12px;
  color: var(--text-secondary);
}
.library-empty-icon { font-size: 28px; color: var(--text-tertiary); }
.library-empty-message { font-size: 13px; }

.recording-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-panel);
  overflow: hidden;
  cursor: pointer;
}
.recording-card-selected { outline: 2px solid var(--kf-linear); outline-offset: 1px; }
.recording-card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background-size: cover;
}
.recording-card-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  padding: 2px 6px;
  background: rgba(0,0,0,0.65);
  border-radius: var(--radius-pill);
}
.recording-card-category {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border-radius: var(--radius-pill);
}
.recording-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 12px;
}
.recording-card-overlay-bar { position: relative; width: 60%; height: 6px; background: rgba(255,255,255,0.18); border-radius: var(--radius-pill); overflow: hidden; }
.recording-card-overlay-fill { display: block; height: 100%; background: #fff; }
.recording-card-overlay-failed { background: rgba(220,38,38,0.65); }
.recording-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
}
.recording-card-title { font-size: 13px; font-weight: 600; }
.recording-card-subtitle { font-size: 11px; color: var(--text-secondary); }
.recording-card-metrics { display: inline-flex; gap: 10px; margin-top: 4px; }
.recording-card-metric { font-size: 11px; color: var(--text-tertiary); }

/* ───── UI-16 — Editor shell ───── */
.editor-shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
}
.editor-titlebar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--line-subtle);
}
.editor-titlebar-traffic { display: inline-flex; gap: 6px; }
.traffic-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.traffic-close { background: #ff5f57; }
.traffic-min { background: #ffbd2e; }
.traffic-max { background: #28c840; }
.editor-titlebar-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  text-align: center;
}
.editor-titlebar-title { font-size: 13px; font-weight: 600; }
.editor-titlebar-subtitle { font-size: 11px; color: var(--text-secondary); }
.editor-titlebar-empty .editor-titlebar-title { color: var(--text-tertiary); font-style: italic; font-weight: 400; }

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface-base);
  border-bottom: 1px solid var(--line-subtle);
}
.editor-toolbar-actions { display: inline-flex; gap: 4px; }
.editor-toolbar-end { display: inline-flex; gap: 8px; }
.editor-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.editor-action:hover { background: var(--surface-elevated); color: var(--text-primary); }
.editor-action-selected { background: var(--surface-selected); color: var(--text-primary); border-color: var(--line-strong); }
.editor-action-disabled { opacity: 0.4; cursor: not-allowed; }
.editor-action-icon { font-size: 13px; }

.editor-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}
.editor-canvas {
  background:
    repeating-conic-gradient(var(--surface-elevated) 0% 25%, var(--surface-base) 0% 50%) 50% 50% / 24px 24px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-subtle);
  min-height: 280px;
}
/* Editor drop zone — shown in the canvas when no clip is loaded. Drop a
   video anywhere to open it for editing (handled globally by the app-root
   file-drop listener); `--active` is the drag-over highlight. */
.editor-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 280px;
  padding: 24px;
  background: var(--surface-base);
  border: 2px dashed var(--line-subtle);
  border-radius: var(--radius-panel);
  color: var(--fg-muted);
  text-align: center;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}
.editor-dropzone--active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-base));
  color: var(--fg);
}
.editor-dropzone-icon {
  font-size: 34px;
  line-height: 1;
  opacity: 0.75;
}
.editor-dropzone-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}
.editor-dropzone-hint {
  margin: 0;
  max-width: 320px;
  font-size: 12.5px;
}
.editor-inspector {
  background: var(--surface-elevated);
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-subtle);
  padding: 12px;
  overflow: auto;
}
.editor-timeline {
  background: var(--surface-elevated);
  border-top: 1px solid var(--line-subtle);
  padding: 8px 12px;
}

/* ───── UI-17 — Wisp canvas host + drop zone ───── */
.wisp-canvas-host {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 200px;
}
.wisp-canvas-host-css-fallback {
  background:
    repeating-conic-gradient(var(--surface-elevated) 0% 25%, var(--surface-base) 0% 50%) 50% 50% / 24px 24px;
}
.wisp-canvas-css-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.wisp-canvas-asset { max-width: 100%; max-height: 100%; object-fit: contain; }
.wisp-canvas-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: var(--radius-control);
  font-size: 12px;
}

.editor-drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-panel);
  border: 1px dashed var(--line-strong);
  background:
    repeating-conic-gradient(var(--surface-elevated) 0% 25%, var(--surface-base) 0% 50%) 50% 50% / 24px 24px;
  overflow: hidden;
  min-height: 360px;
}
.editor-drop-zone-active {
  border-color: var(--kf-linear);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.45) inset;
}
.editor-drop-zone-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(9, 9, 11, 0.55);
}
.editor-drop-zone-icon { font-size: 28px; color: var(--text-secondary); }
.editor-drop-zone-headline { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.editor-drop-zone-subtext { font-size: 12px; color: var(--text-secondary); }
.editor-drop-zone-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.editor-drop-zone-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  cursor: pointer;
}
.editor-drop-zone-action:hover { background: var(--surface-selected); }
.editor-drop-zone-action-icon { font-size: 16px; color: var(--text-secondary); }
.editor-drop-zone-action-label { font-size: 13px; font-weight: 600; }
.editor-drop-zone-action-desc { font-size: 11px; color: var(--text-secondary); }

.editor-recent-clips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  width: 100%;
}
.editor-recent-clips-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}
.editor-recent-clips-strip { display: flex; gap: 8px; overflow-x: auto; }
.editor-recent-clip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  padding: 6px;
  cursor: pointer;
  min-width: 140px;
}
.editor-recent-clip-thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: 4px; background-size: cover; }
.editor-recent-clip-meta { display: flex; flex-direction: column; gap: 2px; }
.editor-recent-clip-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.editor-recent-clip-duration { font-size: 10px; color: var(--text-tertiary); font-family: var(--font-mono); }

/* ───── UI-18 — Inspector panel ───── */
.inspector-panel {
  display: flex;
  flex-direction: column;
  width: 320px;
  height: 100%;
  background: var(--surface-base);
  color: var(--text-primary);
}
.inspector-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line-subtle);
}
.inspector-tab {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.inspector-tab:hover { background: var(--surface-elevated); color: var(--text-primary); }
.inspector-tab-active { background: var(--surface-selected); color: var(--text-primary); border-color: var(--line-strong); }

.inspector-body { padding: 8px 12px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }

.property-section { display: flex; flex-direction: column; gap: 6px; }
.property-section-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}
.property-section-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.property-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  font-size: 12px;
}
.property-row-disabled { opacity: 0.45; }
.property-row-label { color: var(--text-secondary); }
.property-row-value { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.property-row-control { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }

.property-slider {
  position: relative;
  flex: 1;
  height: 4px;
  background: var(--line-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.property-slider-fill { display: block; height: 100%; background: var(--kf-linear); }

.property-toggle {
  position: relative;
  width: 28px;
  height: 16px;
  background: var(--line-subtle);
  border-radius: var(--radius-pill);
  transition: background 120ms ease;
}
.property-toggle-on { background: var(--kf-linear); }
.property-toggle-knob {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 120ms ease;
}
.property-toggle-on .property-toggle-knob { transform: translateX(12px); }

.property-swatches { display: inline-flex; gap: 4px; }
.property-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line-subtle);
  cursor: pointer;
}
.property-swatch-selected { outline: 2px solid var(--kf-linear); outline-offset: 1px; }

.property-pill {
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
}
.property-control-value { font-size: 12px; color: var(--text-primary); }

/* ───── UI-19 — Timeline skeleton ───── */
.timeline-skeleton {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface-elevated);
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-subtle);
}
.timeline-transport {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}
.timeline-transport-toggle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-popover);
  border: 1px solid var(--line-strong);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 10px;
}
.timeline-timecode { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.timeline-timecode-sep { color: var(--text-tertiary); }
.timeline-timecode-total { color: var(--text-secondary); }

.timeline-tracks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.timeline-track-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-control);
  background: var(--surface-popover);
}
.timeline-track-row-selected { outline: 2px solid var(--kf-linear); outline-offset: -2px; }
.timeline-track-row-disabled { opacity: 0.45; }
.timeline-track-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.timeline-track-body {
  display: flex;
  align-items: center;
  min-height: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-control);
  padding: 0 8px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-style: italic;
}
.timeline-track-placeholder { user-select: none; }

/* ───── UI-20 — Cursor Studio shell + style picker ───── */
.cursor-studio-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
}
.cursor-studio-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 8px;
  padding: 8px;
  flex: 1;
  min-height: 200px;
}
.cursor-studio-preview {
  background: var(--surface-elevated);
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-subtle);
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cursor-studio-inspector {
  background: var(--surface-elevated);
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-subtle);
  padding: 12px;
}

.cursor-style-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line-subtle);
  background: var(--surface-base);
}
.cursor-style-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}
.cursor-style-tiles {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.cursor-style-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  cursor: pointer;
}
.cursor-style-tile:hover { background: var(--surface-selected); }
.cursor-style-tile-selected {
  background: #fafafa;
  color: #09090b;
  border-color: #fafafa;
}
.cursor-style-tile-disabled { opacity: 0.45; cursor: not-allowed; }
.cursor-style-tile-preview { font-size: 18px; }
.cursor-style-tile-label { font-size: 11px; font-weight: 600; }

/* ───── UI-21 — Cursor preview canvas + appearance panel ───── */
.cursor-preview-canvas {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 200px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-subtle);
  overflow: hidden;
}
.cursor-preview-arrow {
  font-size: 36px;
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.55);
  transform: rotate(-30deg);
}
.cursor-preview-ring {
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.45);
  animation: cursor-ring-pulse 1.6s ease-in-out infinite;
  pointer-events: none;
}
.cursor-preview-asset { max-width: 80%; max-height: 80%; object-fit: contain; }
.cursor-preview-banner {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

@keyframes cursor-ring-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.55; }
  50% { transform: scale(1.05); opacity: 1; }
}

.cursor-appearance-panel {
  display: flex;
  flex-direction: column;
  width: 320px;
  height: 100%;
  background: var(--surface-base);
}
.cursor-appearance-body {
  flex: 1;
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cursor-appearance-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line-subtle);
}

/* ───── UI-22 — Contact sheet ───── */
.contact-sheet {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--bg);
  color: var(--text-primary);
}
.contact-sheet-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0;
}
.contact-sheet-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.contact-sheet-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.contact-sheet-cursor-tile {
  width: 320px;
  height: 360px;
  overflow: hidden;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-subtle);
}

/* ───── DEV-03 / DEV-08 — Storybook index cockpit ───── */
.storybook-index-root {
  display: grid;
  grid-template-columns: 280px 1fr;
  width: 100vw;
  height: 100vh;
  background: var(--surface-base);
  color: var(--text-primary);
}
@media (max-width: 720px) {
  .storybook-index-root { grid-template-columns: 1fr; grid-template-rows: 240px 1fr; }
}
.storybook-index-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-subtle);
  background: var(--surface-elevated);
  overflow: hidden;
}
.storybook-index-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-subtle);
}
.storybook-index-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.storybook-index-count {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  background: var(--surface-popover);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}
.storybook-index-search { padding: 8px 12px; border-bottom: 1px solid var(--line-subtle); }
.storybook-index-search input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-popover);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 10px;
}
.storybook-index-search input::placeholder { color: var(--text-tertiary); }
.storybook-index-search input:focus {
  outline: none;
  border-color: var(--kf-linear);
  box-shadow: var(--focus-ring);
}

.storybook-index-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 16px;
  overflow-y: auto;
  flex: 1;
}
.storybook-index-list ul { list-style: none; margin: 0; padding: 0; }
.storybook-index-category { padding: 6px 0; }
.storybook-index-category.is-hidden { display: none; }
.storybook-index-heading {
  display: block;
  padding: 6px 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.storybook-index-row { display: block; }
.storybook-index-row.is-hidden { display: none; }
.storybook-index-row a {
  display: block;
  padding: 4px 14px 4px 22px;
  color: var(--text-secondary);
  font-size: 12px;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.storybook-index-row a:hover { background: var(--surface-popover); color: var(--text-primary); }
.storybook-index-row.is-active a {
  background: var(--surface-selected);
  color: var(--text-primary);
  border-left-color: var(--kf-linear);
}

.storybook-index-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-base);
}
.storybook-index-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-subtle);
}
.storybook-index-current {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}
.storybook-index-open {
  font-size: 11px;
  color: var(--text-tertiary);
  text-decoration: none;
}
.storybook-index-open:hover { color: var(--text-primary); }
.storybook-index-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--surface-popover);
  min-height: 0;
}

/* ───── Webcam bubble overlay (M-BUBBLE.0 / AUT-273) ──────────────
 *
 * The `webcam-bubble` Tauri window is transparent + borderless.
 * `.bubble-root` is the body's full-viewport child that draws the
 * visible circular surface. For M-BUBBLE.0 this is a coloured
 * placeholder so the empty window is findable; M-BUBBLE.2 (AUT-275)
 * replaces the inner content with a `<canvas>` painted from the
 * M-CAM.2 frame channel.
 *
 * IMPORTANT: do NOT change the bubble shape via `clip-path` or by
 * pre-clipping the canvas. The mask is wisp's responsibility — once
 * M-CAM.3's pipeline is real, the bubble canvas will receive
 * already-masked pixels. CSS-rounding the same edge would visibly
 * double-crop the circle (CLAUDE.md "Mask is wisp's, not CSS").
 */
.bubble-root {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #4338ca 0%, #1e1b4b 70%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.bubble-root:active { cursor: grabbing; }
.bubble-root-placeholder {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ───── Webcam bubble — overlay-on-circle (M-QUAL.4) ───────────────
 *
 * No card: the circle IS the widget. `.bubble-root--design` is a
 * transparent, drag-enabled window-filler that centers the
 * `.bubble-stage` (the circle) with a floating device caption below
 * it. The overlays (PREVIEW pill, icon cluster, control pill) are
 * painted on top of the circle as siblings of the clipped feed.
 * Sized for the 260×300 webcam-bubble window (tauri.conf.json).
 */
.bubble-root--design {
  background: transparent !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
  width: 100vw;
  height: 100vh;
  inset: 0;
  position: fixed;
  cursor: grab;
}
.bubble-root--design:active { cursor: grabbing; }

/* No card — the circle IS the widget. `.bubble-stage` is a relative
 * box (= the circle's bounding square) that holds the clipped camera
 * circle plus the overlays as siblings on top of it. overflow stays
 * visible so the top-right icon cluster can hover at the circle edge. */
.bubble-stage {
  position: relative;
  /* A hard 240×240 square → border-radius:50% is a perfect circle.
   * `flex-shrink:0` stops the vertical flex column from squashing the
   * height (which would make it an ellipse). NO `aspect-ratio` here:
   * with explicit width+height it's redundant, and `aspect-ratio` on a
   * flex item has WebKit sizing quirks that can yield a non-square box
   * (the crooked-preview bug). */
  box-sizing: border-box;
  width: 240px;
  height: 240px;
  flex-shrink: 0;
}

/* The clipped circular camera feed, filling the stage. Sibling
 * overlays below sit ON it (not inside, so they aren't clipped). */
.bubble-canvas-wrap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  /* No dark backing — the feed fills the circle, and before the first
   * frame the circle is transparent (no black disc). */
  background: transparent;
}
.bubble-canvas-wrap canvas,
.bubble-canvas-wrap .camera-preview-surface,
.bubble-canvas-wrap .camera-preview {
  width: 100%;
  height: 100%;
  display: block;
  /* Let clicks fall THROUGH the camera feed to `.bubble-canvas-wrap`
   * (a drag region) — Tauri starts a window drag only when the click
   * *target* is itself a drag-region element, and the canvas covers
   * the whole circle. Without this the bubble isn't draggable. */
  pointer-events: none;
}

/* PREVIEW pill — overlaid near the top of the circle, centered. */
.bubble-preview-chip {
  position: absolute;
  /* Sit inside the upper third of the circle (not on the narrow top
   * arc, where the pill pokes out of the bubble), nudged right of dead
   * center so it reads balanced over the feed. */
  top: 16%;
  left: 56%;
  transform: translateX(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: rgba(255, 255, 255, 0.95);
  font: 700 9px/1 var(--font-sans);
  letter-spacing: 0.12em;
  pointer-events: none;
}
.bubble-preview-chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 5px rgba(239, 68, 68, 0.85);
}

/* Pause + settings — top-right, hovering at the circle's upper-right
 * edge (the stage corner sits just outside the inscribed circle). */
.bubble-header-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.bubble-icon-btn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 3px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 0;
}
.bubble-icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.14); }
.bubble-icon-btn svg { width: 15px; height: 15px; }

/* Three controls — overlaid near the bottom of the circle (~85% down),
 * tightly grouped in a subtle dark pill for legibility over the feed. */
.bubble-controls {
  position: absolute;
  bottom: 9%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.bubble-control {
  appearance: none;
  border: none;
  border-radius: 999px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  line-height: 0;
}
.bubble-control:hover { background: rgba(255, 255, 255, 0.26); color: #fff; }
.bubble-control svg { width: 13px; height: 13px; }
.bubble-control--active { background: #fff; color: #161618; }
.bubble-control--active:hover { background: #fff; color: #161618; }

/* Caption — floating text below the circle on the page background (no
 * card); the shadow keeps it legible over whatever is behind. */
.bubble-caption {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 11px/1.2 var(--font-sans);
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.bubble-caption-icon {
  display: inline-flex;
  line-height: 0;
}
.bubble-caption-icon svg { width: 12px; height: 12px; }
.bubble-caption-label { font-weight: 600; color: rgba(255, 255, 255, 0.9); }
.bubble-caption-sep { opacity: 0.5; }
.bubble-caption-corner { white-space: nowrap; }

/* The bubble window's body is transparent so the borderless window's
 * corners are see-through. The dist/ HTML doesn't have a body class
 * hook, so we lean on `.bubble-root` being the first child to neutralise
 * the body's default rendering when present. */
html:has(.bubble-root),
body:has(.bubble-root) {
  /* Both html AND body must be transparent — the base `html, body`
   * rule paints `--bg` (#0a0a0b), and overriding only `body` left the
   * `html` element painting an opaque near-black behind the circle
   * (the "surrounding black" the bubble appeared to sit on). With both
   * transparent the borderless window shows only the circle + label. */
  background: transparent !important;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* "Show webcam bubble" toggle in the Recorder surface. */
.bubble-toggle {
  appearance: none;
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  padding: 8px 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  margin-top: 16px;
  align-self: flex-start;
  transition: background 120ms ease, border-color 120ms ease;
}
.bubble-toggle:hover {
  background: var(--surface-selected);
  border-color: var(--line-strong);
}
.bubble-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Click-through-mode active state (M-BUBBLE.1 v0 / AUT-274). When the
 * user has enabled passthrough, the toggle button stays "lit" so it's
 * obvious the bubble is currently not interactive. */
.bubble-toggle--clickthrough[data-active="true"] {
  background: var(--action-record);
  color: #fff;
  border-color: var(--action-record-hover);
}
.bubble-toggle--clickthrough[data-active="true"]:hover {
  background: var(--action-record-hover);
}

/* ───── Camera-pipeline diagnostics overlay (M-CAM.3 / AUT-257) ──
 *
 * Sits inside the Recorder surface. Polls preview_diagnostics every
 * 500ms; renders a small monospace table so the frame counter +
 * source dims / fps are easy to eyeball. Not a finalised UI — this
 * is a developer-facing proof-of-life that ships with the M-CAM.3
 * gst layer until the wisp render layer fills in the actual visible
 * canvas. */
.camera-diagnostics {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-control);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 480px;
  align-self: flex-start;
}
.camera-diagnostics-header {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.01em;
}
.camera-diagnostics-empty {
  margin: 0;
  font-style: italic;
  color: var(--text-tertiary);
}
.camera-diagnostics-rows {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
  row-gap: 2px;
}
.camera-diagnostics-rows dt {
  color: var(--text-tertiary);
}
.camera-diagnostics-rows dd {
  margin: 0;
  color: var(--text-primary);
}
.camera-diagnostics-frames {
  /* Frame counter ticks up at ~30 Hz — emphasise so the user can
   * eyeball it visibly changing. */
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.camera-diagnostics-dump {
  font-size: 11px;
  word-break: break-all;
  color: var(--text-secondary);
}

/* ───── Live RecorderPage — recording state ─────────────────────────
 *
 * The new app-ui live RecorderPage flips a `data-recording="true"`
 * attribute on the root section while a session is active. While
 * recording:
 *   - source rows + on-screen options dim (still readable, but you
 *     can't change selections mid-record — backend would reject)
 *   - the start-recording footer is replaced with a Stop button
 *   - a red pill at the top shows elapsed time + RECORDING label
 */
.recorder-page {
  position: relative;
}
.recorder-page-recording-pill {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--action-record, #ef4444);
  color: #fff;
  font: 600 11px/1 var(--font-sans);
  letter-spacing: 0.06em;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.35);
  z-index: 5;
}
.recorder-page-recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: recorder-page-pulse 1.2s ease-in-out infinite;
}
.recorder-page-recording-label {
  font-weight: 700;
  letter-spacing: 0.08em;
}
.recorder-page-recording-elapsed {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
@keyframes recorder-page-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}
.recorder-page[data-recording="true"] .recorder-page-sources,
.recorder-page[data-recording="true"] .recorder-page-audio,
.recorder-page[data-recording="true"] .recorder-page-on-screen,
.recorder-page[data-recording="true"] .recorder-page-display {
  opacity: 0.55;
  pointer-events: none;
}
.recording-controls-footer-stop {
  /* Mirror the regular footer but signal that we're in the stop state. */
}
.start-recording-stop {
  background: #fff !important;
  color: var(--action-record, #ef4444) !important;
  border: 2px solid var(--action-record, #ef4444);
}
.start-recording-stop:hover {
  background: var(--action-record, #ef4444) !important;
  color: #fff !important;
}


/* ───── RecorderPage layout (crates/app-ui/src/recorder_page.rs) ─────
 * Header + action bar are flex-shrink:0; middle body scrolls.
 * All rules scoped under `.recorder-page` / `.app-surface--recorder`
 * so storybook isolated stories keep their canonical sizes. */
.recorder-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  padding: 8px 12px 12px;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  font-size: 11px;
  overflow-x: hidden;
}
.recorder-page,
.recorder-page *,
.recorder-page *::before,
.recorder-page *::after {
  box-sizing: border-box;
}

/* AppShell wiring — pin the recorder flush to the rail, kill the
 * shell-main's default padding + scroll so the recorder owns its
 * internal scroll. `:has()` is supported in every webview Tauri 2
 * ships against. */
.app-surface--recorder {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.app-surface--recorder > .recorder-page {
  flex: 1;
  min-height: 0;
}
.app-shell-main:has(> .app-surface--recorder) {
  padding: 0;
  overflow: hidden;
  min-width: 0;
}

/* Header — capture-mode tabs + overflow menu. Pinned to top. */
.recorder-page-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.recorder-page-tabs {
  flex: 1;
  min-width: 0;
}
.recorder-page-tabs .segmented {
  width: 100%;
  display: flex;
  justify-content: space-between;
  background: var(--surface-elevated);
  border: 1px solid var(--line-subtle);
}
.recorder-page-tabs .segment {
  flex: 1;
  justify-content: center;
  font-size: 11px;
  padding: 5px 8px;
}
.recorder-page-tabs .segment-active {
  background: var(--surface-selected);
  color: var(--text-primary);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
.recorder-page-tabs .segment-icon { font-size: 11px; opacity: 0.85; }
.recorder-page-overflow {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 4px 8px;
  flex-shrink: 0;
}
.recorder-page-overflow:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}
.recorder-page .icon-tile {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-control);
}
/* White Lucide icons at 20 px inside the device tile (overrides
   the default muted zinc-400 color + the component's built-in size). */
.recorder-page .icon-tile-device { color: var(--text-primary); }
.recorder-page .icon-tile-device .lucide { width: 20px; height: 20px; }

/* Body — scrollable middle. */
.recorder-page-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  /* Slim webkit scrollbar so the column doesn't reserve a wide gutter. */
  scrollbar-width: thin;
  scrollbar-color: var(--surface-selected) transparent;
  /* Reserve the scrollbar slot even when content fits without it,
   * so the right edge of body content sits at a stable x-coordinate
   * (otherwise the right "margin" jumps by 6 px the moment scrolling
   * starts). `scrollbar-gutter` is supported in every modern WebKit
   * and Blink. */
  scrollbar-gutter: stable;
}
.recorder-page-body::-webkit-scrollbar { width: 6px; }
.recorder-page-body::-webkit-scrollbar-thumb {
  background: var(--surface-selected);
  border-radius: 3px;
}
.recorder-page-sources,
.recorder-page-audio { display: flex; flex-direction: column; gap: 6px; }
.recorder-page-display { display: flex; flex-direction: column; gap: 6px; }
.recorder-page-on-screen { display: flex; flex-direction: column; gap: 4px; }
.recorder-page-picker,
.recorder-page-applist { display: flex; flex-direction: column; }

.recorder-page-sources .capture-source-row,
.recorder-page-audio .system-audio-row {
  width: 100%;
}
.recorder-page-picker .popover-surface,
.recorder-page-applist .system-audio-applist {
  width: 100%;
}

/* ── Display selector row + stylized preview ─────────────────────
 * The label group (name + size pill + star) sits inline on the left
 * with natural width; the chevron is pushed to the right edge via
 * `margin-left: auto` so the right side stays anchored regardless
 * of label length. */
.recorder-display-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1.5px solid var(--line-card);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
  appearance: none;
}
.recorder-display-selector:hover { border-color: rgba(255, 255, 255, 0.22); }
.recorder-display-selector-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #ea580c;
  display: inline-block;
  flex-shrink: 0;
}
.recorder-display-selector-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.recorder-display-selector-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recorder-display-selector-size {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--surface-selected);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}
.recorder-display-selector-star {
  font-size: 11px;
  color: var(--text-tertiary);
}
.recorder-display-selector-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--text-secondary);
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 120ms;
}
.recorder-display-selector-chevron[data-open="true"] {
  color: var(--text-primary);
  transform: rotate(180deg);
}

/* Wraps the storybook DisplayPreviewFrame so we can layer a red
 * border + a dim badge over it without modifying the component. */
.recorder-display-preview-wrap {
  position: relative;
  border: 2px solid var(--action-record);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-base);
}
.recorder-display-preview-wrap .display-preview {
  border: 0;
  border-radius: 0;
  max-height: 220px;
}
.recorder-display-preview-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--action-record);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

/* Source rows (camera / mic) — restyled grid + reordered children.
 * Cards sit barely above the panel (`var(--surface-elevated)`,
 * `#171719`) and are outlined by a clearly visible 1.5 px hairline
 * — same treatment as the audio + on-screen + display-selector
 * rows so the column reads as one outlined set. */
.recorder-page-sources .capture-source-row {
  padding: 7px 10px;
  /* `auto` first column tracks the IconTile size; gap is a real
   * 12 px regardless of future tile-size changes. */
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  border-radius: var(--radius-control);
  background: var(--bg);
  border-width: 1.5px;
  border-color: var(--line-card);
}
.recorder-page-sources .capture-source-title { font-size: 12px; }
.recorder-page-sources .capture-source-subtitle { font-size: 10px; }
.recorder-page-sources .capture-source-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  color: var(--text-secondary);
  min-width: 26px;
  height: 26px;
}
.recorder-page-sources .capture-source-text .meter-bar { height: 7px; width: 2px; }

/* System-audio row — same grid columns + favorite + chevron + toggle. */
.recorder-page-audio .system-audio-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  padding: 7px 10px;
  gap: 12px;
  border-radius: var(--radius-control);
  background: var(--bg);
  align-items: center;
  border: 1.5px solid var(--line-card);
}
.recorder-page-audio .system-audio-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.recorder-page-audio .system-audio-subtitle { font-size: 10px; }
.recorder-page-audio .system-audio-inline-icons {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 3px;
  border-radius: 5px;
  background: var(--surface-selected);
}
.recorder-page-audio .system-audio-inline-icons .system-audio-icon {
  width: 14px;
  height: 14px;
  font-size: 8px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin: 0;
}
.recorder-page-audio .system-audio-inline-icons .system-audio-icon-overflow {
  font-size: 9px;
  padding: 0 3px;
}
.recorder-page-audio .system-audio-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  color: var(--text-secondary);
  min-width: 26px;
  height: 26px;
}

/* On-screen row — styled to match the source rows above it. */
.recorder-page-on-screen-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1.5px solid var(--line-card);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
}
.recorder-page-on-screen-row:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.recorder-page-on-screen-text {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.recorder-page-on-screen-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.recorder-page-on-screen-summary {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--surface-selected);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}
.recorder-page-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--text-secondary);
  transition: transform 120ms;
}
.recorder-page-chevron[data-open="true"] {
  color: var(--text-primary);
  transform: rotate(180deg);
}

/* Toggle switches — compact 26 × 15 inside the recorder. */
.recorder-page .toggle-switch { width: 26px; height: 15px; }
.recorder-page .toggle-switch-thumb { width: 11px; height: 11px; }
.recorder-page .toggle-switch-checked .toggle-switch-thumb {
  transform: translateX(11px);
}

/* Star buttons inside rows — same neutral tone, slightly more visible. */
.recorder-page .capture-source-star {
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1;
}

/* ── Pinned action bar (auto-zoom + countdown + Start) ─────────── */
.recorder-page-action-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

/* M-SAVE.3 — post-record Save panel (folder + format + Export/Discard). */
.recorder-save-panel {
  gap: 10px;
}
.recorder-save-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recorder-save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-control, 8px);
}
.recorder-save-key {
  flex-shrink: 0;
  width: 52px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim, #8a8f98);
}
.recorder-save-folder {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--text, #e6e6e6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl; /* keep the filename (tail) visible when truncating */
  text-align: left;
}
.recorder-save-change {
  flex-shrink: 0;
  font-size: 12px;
  padding: 4px 10px;
  background: transparent;
  color: var(--accent, #4fc3f7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-control, 8px);
  cursor: pointer;
}
.recorder-save-change:hover:not(:disabled) {
  border-color: var(--accent, #4fc3f7);
}
.recorder-save-format {
  flex: 1 1 auto;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--bg);
  color: var(--text, #e6e6e6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-control, 8px);
  cursor: pointer;
}
.recorder-save-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 8px;
}
.recorder-save-discard,
.recorder-save-edit,
.recorder-save-export {
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-control, 8px);
  cursor: pointer;
}
.recorder-save-discard {
  background: transparent;
  color: var(--text-dim, #8a8f98);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.recorder-save-discard:hover:not(:disabled) {
  color: var(--text, #e6e6e6);
  border-color: rgba(255, 255, 255, 0.24);
}
.recorder-save-edit {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text, #e6e6e6);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.recorder-save-edit:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}
.recorder-save-export {
  background: var(--accent, #4fc3f7);
  color: var(--bg, #0f1115);
  border: 1px solid var(--accent, #4fc3f7);
}
.recorder-save-export:hover:not(:disabled) {
  filter: brightness(1.08);
}
.recorder-save-panel button:disabled {
  opacity: 0.5;
  cursor: default;
}
.recorder-save-saved {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-control, 8px);
}

/* M-SAVE.4 — ⋯ "More options" menu (output-folder setting). */
.recorder-overflow-wrap {
  position: relative;
}
.recorder-overflow-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--bg);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-control, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.recorder-overflow-key {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim, #8a8f98);
}
.recorder-overflow-folder {
  font-size: 12px;
  color: var(--text, #e6e6e6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
}
.recorder-overflow-change {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  background: transparent;
  color: var(--accent, #4fc3f7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-control, 8px);
  cursor: pointer;
}
.recorder-overflow-change:hover {
  border-color: var(--accent, #4fc3f7);
}
.recorder-page-action-bar .recorder-page-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.recorder-page-action-bar .recorder-page-controls > * { width: 100%; }
.recorder-page-action-bar .select-pill {
  width: 100%;
  justify-content: flex-start;
  font-size: 12px;
  padding: 7px 10px;
  gap: 12px;
  border-radius: var(--radius-control);
  background: var(--bg);
  border-width: 1.5px;
  border-color: var(--line-card);
}
.recorder-page-action-bar .select-pill-icon { font-size: 13px; }
.recorder-page-action-bar .select-pill-label {
  flex: 1;
  text-align: left;
}
.recorder-page-action-bar .select-pill-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--text-secondary);
}

/* Start button — full-width red pill with target glyph + shortcut chips. */
.recorder-page-action-bar .recording-controls-footer {
  padding: 0;
  background: transparent;
  border-top: 0;
  border-radius: 0;
}
.recorder-page-action-bar .recording-controls-action { width: 100%; }
.recorder-page-action-bar .start-recording-btn {
  width: 100%;
  justify-content: flex-start;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: var(--radius-control);
}
.recorder-page-action-bar .start-recording-glyph { font-size: 13px; }
.recorder-page-action-bar .start-recording-label { font-size: 13px; font-weight: 600; }
.recorder-page-action-bar .start-recording-btn .shortcut-badges { margin-left: auto; }
.recorder-page-action-bar .shortcut-badge {
  font-size: 11px;
  padding: 2px 6px;
  min-width: 18px;
  border-radius: 4px;
}
