/* ============================================================================
   DESIGN TOKENS — see DESIGN.md. Two tiers:
   1. PRIMITIVES (--c-*, --space-*, --radius-*, --text-*, …): raw ramps + scales.
      Referenced ONLY by the semantic layer below — never by component CSS/JS.
   2. SEMANTIC ROLES (--surface-*, --control-*, --text*, --accent*, …): the ONLY
      tokens component CSS/JS may use. This split is what makes a future
      [data-theme="light"] a ~20-token override instead of a rewrite.
   The original 7 tokens are kept as LEGACY ALIASES at the bottom so every
   existing rule renders pixel-identically; migrate off them over time.
   ============================================================================ */
:root {
  /* ---- PRIMITIVES ---------------------------------------------------------- */
  /* Neutral ramp: 0 deepest well → 8 lightest (control borders). Sourced from today's literals; 7–8 added to give
     control boundaries the 3:1 contrast WCAG 1.4.11 requires (the N5/N6 hairlines are decorative-divider weight). */
  --c-neutral-0: #0b0d11; /* input wells                    */
  --c-neutral-1: #0f1115; /* sunken / inset surfaces        */
  --c-neutral-2: #14161a; /* app background (was --bg)      */
  --c-neutral-3: #1c1f26; /* raised panel   (was --panel)   */
  --c-neutral-4: #1a2030; /* quiet-control fill             */
  --c-neutral-5: #2a2f3a; /* hairline border (was --line)   */
  --c-neutral-6: #3a4150; /* hover / strong divider         */
  --c-neutral-7: #656f86; /* control border — 3.3:1 (1.4.11) */
  --c-neutral-8: #717c96; /* control border, hover — 3.9:1  */
  --c-text-hi:  #e2e8f0;  /* primary text   (was --text)    */
  --c-text-mid: #8b96a8;  /* muted          (was --muted)   */
  --c-text-lo:  #828c9e;  /* faint / disabled — AA (4.5:1) at body size */

  --c-accent:     #f6ad55;                 /* was --accent   */
  --c-accent-a08: rgba(246, 173, 85, 0.08);
  --c-accent-a20: rgba(246, 173, 85, 0.2);
  --c-accent-a40: rgba(246, 173, 85, 0.4);

  --c-danger: #fc8181;  --c-danger-hi: #ff9aa8;  --c-danger-bg: #3a1418;  --c-danger-border: #7a2530;
  --c-success: #3ecf8e; --c-success-hi: #8ce89a;
  --c-info: #4ea1ff;    /* also the node "source"/audio port colour */

  /* Spacing — strict 4px grid. */
  --space-1: 4px;  --space-2: 8px;   --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px;  --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* Radii. */
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-pill: 999px; --radius-round: 50%;

  /* Type scale — bumped for readability in the constrained UI. */
  --text-2xs: 11px; --text-xs: 12px; --text-sm: 13px; --text-base: 14px;
  --text-md: 15px;  --text-lg: 18px; --text-xl: 22px; --text-2xl: 28px;

  --weight-normal: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);

  --z-footer: 5; --z-header: 10; --z-banner: 11; --z-overlay: 100; --z-modal: 1000; --z-tooltip: 1100;

  --transition-fast: 120ms ease; --transition-base: 180ms ease;

  /* ---- SEMANTIC ROLES (component CSS/JS uses ONLY these) ------------------- */
  --surface-bg: var(--c-neutral-2);
  --surface-panel: var(--c-neutral-3);
  --surface-inset: var(--c-neutral-1);
  --surface-input: var(--c-neutral-0);

  --control-bg: var(--c-neutral-4);
  --control-bg-hover: var(--c-neutral-6);
  /* Control boundaries must read at 3:1 (WCAG 1.4.11) — a control's border is often its only edge. Decorative
     dividers/card outlines below stay on the subtle N5/N6 (they also carry fill + shadow, so 1.4.11 doesn't bind). */
  --control-border: var(--c-neutral-7);
  --control-border-hover: var(--c-neutral-8);

  --border: var(--c-neutral-5);
  --border-strong: var(--c-neutral-6);

  --text: var(--c-text-hi);
  --text-muted: var(--c-text-mid);
  --text-faint: var(--c-text-lo);

  --accent: var(--c-accent);
  --accent-contrast: var(--c-neutral-0); /* text/icon on an accent fill */
  --accent-wash: var(--c-accent-a08);
  --focus-ring: var(--c-accent); /* solid, offset — reliably visible on any surface (incl. amber fills) */

  --danger: var(--c-danger); --danger-text: var(--c-danger-hi);
  --danger-bg: var(--c-danger-bg); --danger-border: var(--c-danger-border);
  --success: var(--c-success); --success-text: var(--c-success-hi);
  --link: var(--c-info);

  /* Waveform (wavesurfer canvas — read in JS via getComputedStyle, so themed). Cursor = --accent. */
  --wave-body: #3b4252;    /* unplayed waveform */
  --wave-progress: #5e81ac; /* played portion */

  /* ---- CATEGORICAL COLOUR LANGUAGE ---------------------------------------- */
  /* Node categories (seeded from CAT_COLOR in NodesScreen.tsx) — meaning-carrying, named. */
  --cat-source: #4ea1ff;   --cat-generator: #b078ff; --cat-processor: #3ecf8e;
  --cat-combine: #ffb454;  --cat-visualisation: #f2c14e; --cat-fx: #ff6b8a;
  --cat-channel: #5ad1cd;  --cat-layer: #7c9cff;     --cat-output: #e0e0e0; --cat-asset: #c084fc;
  /* Data-type / port colours (from PORT_COLOR). */
  --port-signal: #9aa4b2;  --port-video: #ff8c42;    --port-audio: #4ea1ff; --port-asset: #c084fc;
  /* Generic categorical ramp for arbitrary series (trace overlays, scene types, legends). */
  --series-1: #f6ad55; --series-2: #4ea1ff; --series-3: #3ecf8e; --series-4: #ff6b8a;
  --series-5: #b078ff; --series-6: #5ad1cd; --series-7: #f2c14e; --series-8: #7c9cff;

  /* ---- LEGACY ALIASES (keep existing rules pixel-identical; retire over time) */
  --bg: var(--surface-bg);
  --panel: var(--surface-panel);
  --line: var(--border);
  --muted: var(--text-muted);
  --gutter: 56px;
}

/* ============================================================================
   LIGHT THEME — opt-in via [data-theme="light"] on <html>. Overrides ONLY the
   semantic + categorical roles (never the primitives), so it's a drop-in. The
   app default has no data-theme → stays dark; this is scaffolding + previewable
   on the style-guide. Wiring an app-wide toggle is a later step. See DESIGN.md.
   ============================================================================ */
:root[data-theme="light"] {
  --surface-bg: #f4f1ea;      /* warm off-white */
  --surface-panel: #ffffff;
  --surface-inset: #ece8df;
  --surface-input: #ffffff;

  --control-bg: #eceae3;
  --control-bg-hover: #e0dccf;
  /* Controls carry their boundary by border alone (white input ≈ off-white bg), so it must hit 3:1 (1.4.11). */
  --control-border: #8f8674;
  --control-border-hover: #7a7362;

  --border: #ddd8cd;          /* decorative dividers/cards (cards also use fill + shadow) */
  --border-strong: #b3ab99;

  --text: #1d1b16;
  --text-muted: #6a6459;
  --text-faint: #5c5750;      /* AA (4.5:1) at body size on the light surfaces */

  --accent: #9a5a0d;          /* deep amber — white label passes AA (5.5:1) */
  --accent-contrast: #ffffff; /* text on an accent fill */
  --accent-wash: rgba(154, 90, 13, 0.12);
  --focus-ring: var(--accent); /* solid deep-amber ring on light too */

  --danger: #c0392b; --danger-text: #a5281b; --danger-bg: #fbe6e3; --danger-border: #e6a79f;
  --success: #1f9d63; --success-text: #167a4c;
  --link: #1a63c0;

  --wave-body: #c5bfb2;    /* mid warm-grey on white */
  --wave-progress: #2a7fd6; /* played portion — reads on light */

  /* Categorical: darken/saturate the dark-tuned hues for legibility on light. */
  --cat-source: #2a7fd6; --cat-generator: #8a4dd6; --cat-processor: #199f66;
  --cat-combine: #d98a1f; --cat-visualisation: #c79a1a; --cat-fx: #d63b62;
  --cat-channel: #2aa39d; --cat-layer: #4f6fd6; --cat-output: #6b6b6b; --cat-asset: #9a4fd6;
  --port-signal: #6a7480; --port-video: #d96a1f; --port-audio: #2a7fd6; --port-asset: #9a4fd6;
  --series-1: #c47a17; --series-2: #2a7fd6; --series-3: #199f66; --series-4: #d63b62;
  --series-5: #8a4dd6; --series-6: #2aa39d; --series-7: #c79a1a; --series-8: #4f6fd6;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============================================================================
   BASE + COMPONENT PRIMITIVES — see DESIGN.md.
   New, token-built base classes emitted by src/ui/components.ts and exercised
   on /styleguide.html. Existing screen classes (.detect-run, .profile-backend,
   …) are NOT folded in here yet — that happens during screen consolidation.
   ============================================================================ */

/* Form controls inherit typography; keyboard focus is always visible (a11y). */
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Respect the OS "reduce motion" setting — drop transitions/animations for those who ask. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* Button — one recipe, variants by modifier. Comfortable ~32px target, readable label. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 32px; box-sizing: border-box;
  background: var(--control-bg); color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3); font-size: var(--text-md); font-weight: var(--weight-medium); line-height: 1.2;
  cursor: pointer; transition: background var(--transition-fast), border-color var(--transition-fast), filter var(--transition-fast);
}
.btn:hover { background: var(--control-bg-hover); border-color: var(--control-border-hover); }
.btn:active { filter: brightness(0.94); }
.btn[hidden] { display: none; } /* .btn's display would otherwise defeat the `hidden` attribute */
.btn:disabled { opacity: 0.45; cursor: default; filter: none; background: var(--control-bg); border-color: var(--control-border); }
.btn--primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: var(--weight-semibold); }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.06); }
.btn--danger { color: var(--danger-text); border-color: var(--danger-border); background: var(--danger-bg); }
.btn--quiet { background: transparent; } /* ghost: keeps the border + text colour, just no fill */
.btn--quiet:hover { background: var(--control-bg); border-color: var(--control-border-hover); }
/* Icon button: borderless toolbar control (e.g. transport skip) so it doesn't compete with the primary action. */
.btn--icon { padding: var(--space-2); min-width: 32px; background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--icon:hover { background: var(--control-bg); border-color: transparent; color: var(--text); }
/* Emphasis = the LOUDEST tier, reserved for the most important chrome (transport Play, Engineer): solid accent,
   bigger + bolder, so it clearly outranks an ordinary Primary action. Prominence ladder: emphasis > primary >
   default > quiet > icon. */
.btn--emphasis {
  min-height: 36px; padding: var(--space-2) var(--space-5); font-size: var(--text-md); font-weight: var(--weight-semibold);
  background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); box-shadow: var(--shadow-1);
}
.btn--emphasis:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }

/* Text/number/select inputs — one recipe, ~32px target. */
.input, .select {
  min-height: 32px; box-sizing: border-box;
  background: var(--surface-input); color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3); font-size: var(--text-md);
  transition: border-color var(--transition-fast);
}
.input:hover, .select:hover { border-color: var(--control-border-hover); }
.range { width: 128px; accent-color: var(--accent); }
/* Custom chevron so selects match the design (native arrows vary by OS). Theme-aware via two rules. */
.select {
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='12'%20height='12'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%238b96a8'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M6%209l6%206%206-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-2) center; background-size: 12px;
  padding-right: var(--space-6);
}
:root[data-theme="light"] .select {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='12'%20height='12'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%236a6459'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M6%209l6%206%206-6'/%3E%3C/svg%3E");
}

/* Pill toggle-chip. Colour-coded via the BORDER when off and the FILL when on (a per-chip --chip-color, e.g.
   a signal/trace family). Geometry is identical in both states — no dot, no weight change — so the list never
   reflows/jumps when a chip is toggled. */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 28px; box-sizing: border-box;
  background: transparent; color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3); font-size: var(--text-base); cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.chip:hover { border-color: var(--control-border-hover); }
.chip.has-color { border-color: var(--chip-color); }                 /* off: colour-coded outline */
.chip.is-on { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.chip.has-color.is-on { background: var(--chip-color); border-color: var(--chip-color); } /* on: colour-coded fill */

/* Layout primitives: a card groups related controls; sections stack; rows lay controls out. */
.card {
  background: var(--surface-panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4);
  box-shadow: var(--shadow-1);
}
/* Card title = a real group heading (outranks field labels). Section title = a finer uppercase eyebrow. */
.card p { margin: 0; } /* the card's flex gap owns vertical rhythm — kill default <p> margins that double it */
.card > .card-title { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text); }
.section > .section-title { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.section { display: flex; flex-direction: column; gap: var(--space-3); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
/* Form row: align controls on a common bottom line so label-above-control fields line up next to a bare
   button/checkbox/select. Fields in here should not carry an inline hint (use a title tooltip). */
.row--end { align-items: flex-end; }

/* Labelled field: a label above its control, with an optional hint. */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field > .field-label { font-size: var(--text-base); color: var(--text-muted); font-weight: var(--weight-medium); }
.field > .field-hint { font-size: var(--text-sm); color: var(--text-faint); }

/* Inline checkbox: box + label on one line, comfortable target. */
.field-check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 28px; font-size: var(--text-md); cursor: pointer; }
.field-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Vertical side-nav (the pattern shared by Project + Settings). */
.side-nav { display: flex; flex-direction: column; gap: var(--space-1); }
.side-nav-item {
  background: transparent; color: var(--text-muted); border: 0; border-left: 2px solid transparent;
  text-align: left; padding: var(--space-2) var(--space-3); font-size: var(--text-lg); cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.side-nav-item:hover { color: var(--text); background: var(--accent-wash); }
.side-nav-item.active { color: var(--text); border-left-color: var(--accent); background: var(--accent-wash); font-weight: var(--weight-semibold); }

/* Page shell — one structure for every screen: centred max-width column, consistent header. */
.page { max-width: 920px; margin: 0 auto; padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-6); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); border-bottom: 1px solid var(--border); padding-bottom: var(--space-3); }
.page-title { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: 1.2; }
.page-sub { margin: var(--space-1) 0 0; font-size: var(--text-md); color: var(--text-muted); }
.page-actions { display: flex; gap: var(--space-2); }
.page-body { display: flex; flex-direction: column; gap: var(--space-4); }
/* Sub-navigation: a horizontal tab strip under the page header (keeps content full-width + consistent across
   pages, unlike a left rail). Used where a document page has switchable sub-sections. */
.page-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-2); }
.page-tab { background: transparent; color: var(--text-muted); border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: var(--space-2) var(--space-3); font-size: var(--text-md); font-weight: var(--weight-medium); cursor: pointer; transition: color var(--transition-fast); }
.page-tab:hover { color: var(--text); }
.page-tab.active { color: var(--text); border-bottom-color: var(--accent); } /* accent underline + brighter text at the same weight — semibold was wider and nudged the strip */

/* Colour-coded dot/swatch used in legends + inline labels (set --dot-color). */
.dot { width: 10px; height: 10px; border-radius: var(--radius-round); background: var(--dot-color, var(--text-muted)); display: inline-block; flex: 0 0 auto; }

/* App shell: fixed header · scrollable middle · arrange footer. */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  position: relative; /* anchor for the centred ✦ Engineer identifier */
  background: var(--panel);
  z-index: 10;
}
/* Surfaced non-fatal errors (e.g. a failed persistence write). */
.error-banner[hidden] {
  display: none; /* beat the .error-banner display:flex below (a bare [hidden] loses on specificity) */
}
.error-banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: #3a1418;
  color: #ffb4c0;
  border-bottom: 1px solid #7a2530;
  font: 13px system-ui, sans-serif;
  z-index: 11;
}
.error-banner-msg {
  flex: 1;
}
.error-banner-x {
  background: transparent;
  border: 0;
  color: #ffb4c0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.error-banner-x:hover {
  color: #fff;
}

.nav { display: flex; gap: 0; }
.tab {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-2);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.tab:hover { color: var(--text); background: var(--accent-wash); }
/* Active tab: highlight with the accent border + brighter text, NOT a heavier font — semibold is wider than the
   resting medium weight, which nudged the whole nav as the active item changed. Both states keep a 1px border. */
.tab.active {
  color: var(--text);
  background: var(--surface-inset);
  border-color: var(--accent);
}

.transport {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Middle: the active screen fills the space between header and footer (scrolls if tall). */
.screens {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  position: relative; /* anchors the app-wide Engineer overlay (.engineer-host) to the screens region */
}
/* The Engineer panel's overlay host: covers the screens area (not the topbar/footer); clicks pass through
   except on the panel itself, so the underlying screen stays interactive while the panel is closed. */
/* overflow:clip so the off-screen (translated) panel can't inflate .screens/#app scroll-width mid-slide — an
   overlay must never push its container's layout, or the whole page jerks as the panel animates in/out.
   Crucially clip (not hidden): hidden makes this a *scroll container*, so focusing the mid-slide textarea would
   scroll-into-view and yank the whole panel a full width deep into the page; clip creates no scroll container. */
.engineer-host { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: clip; }
.engineer-host .av-engineer-panel { pointer-events: auto; }
.screen { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 14px 40px; }
/* Document pages: always reserve the scrollbar gutter, so the centred .page column doesn't shift horizontally
   between a page that scrolls (Settings) and one that doesn't (Project). Scoped via :has so the full-bleed
   immersive screens (Home/Nodes/Preview) never get gutter strips beside their canvas. */
.screen:has(.page) { scrollbar-gutter: stable both-edges; }
/* Screens that fill their space rather than scroll (viz / editor / node workspace). */
.render-screen,
.code-screen,
.nodes-screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}
/* The node workspace: a top toolbar (add-node palette) + the React Flow canvas filling below. */
.nodes-screen > .nodes-root { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.av-canvas { flex: 1 1 auto; min-height: 0; position: relative; }
.nodes-status {
  position: absolute;
  z-index: 5;
  top: 8px;
  left: 8px;
  font: 12px system-ui, sans-serif;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-inset) 80%, transparent);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}
/* --- node workspace: DAW-dark nodes, category-coloured, sparkline in the body --- */
.av-node {
  min-width: 194px;
  background: var(--surface-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font: 13px system-ui, sans-serif; /* the Nodes island kept pre-migration 11px; bumped for legibility */
  box-shadow: 0 2px 10px #0007;
  overflow: hidden;
}
.av-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 4px 5px 9px;
  font-weight: 600;
  font-size: 13px; /* the node title should read first */
  color: var(--c-neutral-0); /* dark text over the category accent */
  letter-spacing: 0.02em;
  cursor: grab; /* the only drag handle — so the body + ports aren't hidden behind a grab cursor */
}
.av-node-head:active { cursor: grabbing; }
/* Centre the node title; actions float right. When a single video in/out is hoisted here, pad the sides so the
   edge handles don't sit under the title/actions. */
.av-node-head { position: relative; justify-content: center; }
.av-node-title { text-align: center; }
.av-node-actions { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.av-node-head.has-io { padding-left: 14px; padding-right: 14px; }
/* Video in/out dots sit on the COLOURED header, where the body's light 1px border vanishes — give them a
   slightly larger dot with a thicker dark ring so they read against the accent. */
.nodes-screen .react-flow__handle.av-head-handle { z-index: 2; width: 12px; height: 12px; border: 2px solid var(--bg); }
/* Node body is a normal cursor so the crosshair port hotspots stand out (not a sea of grab). */
.nodes-screen .react-flow__node { cursor: default; }
/* Divider: separate the options (body) from the IO (port rows / hoisted video spine). */
.av-node-body:not(:empty) { border-top: 1px solid var(--line); }
.av-node-body:not(:empty):has(+ .av-ports) { border-bottom: 1px solid var(--line); }
.av-node-del {
  background: transparent;
  border: 0;
  color: var(--c-neutral-0);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.65;
}
.av-node-del:hover {
  opacity: 1;
}
.av-node-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-node-actions { flex: none; display: flex; align-items: center; gap: 0; }
.av-node-bypass { background: transparent; border: 0; color: var(--c-neutral-0); font-size: 12px; line-height: 1; cursor: pointer; padding: 0 3px; border-radius: 3px; opacity: 0.5; }
.av-node-bypass:hover { opacity: 1; }
.av-node-bypass.active { opacity: 1; background: rgba(0, 0, 0, 0.2); } /* bypass engaged */
/* A bypassed/muted node dims its body + ports but keeps the header (with the toggle) clickable to re-enable. */
.av-node.bypassed > *:not(.av-node-head) { opacity: 0.4; }
.av-node-body {
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.av-node-summary {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.av-spark {
  position: relative;
  width: 176px;
  height: 36px;
}
.av-spark-meter {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--port-video);
  pointer-events: none;
}
.nodes-screen .react-flow__handle {
  width: 10px;
  height: 10px;
  background: var(--port-signal);
  border: 1px solid var(--surface-bg);
  cursor: crosshair;
  transition: box-shadow 0.08s ease;
}
/* A glow ring on hover (not a transform — RF uses transform to position the handle). */
.nodes-screen .react-flow__handle:hover {
  box-shadow: 0 0 0 4px #ffffff40;
}
/* Labelled port rows — the node grows with its ports (handles never overflow the box); each handle
   sits in a position:relative row, so it anchors to that row's centre. */
.av-ports {
  display: flex;
  flex-direction: column;
  padding: 2px 0;
}
.av-port {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 17px;
  padding: 1px 12px;
}
.av-in {
  justify-content: flex-start;
}
.av-out {
  justify-content: flex-end;
  text-align: right;
}
.av-port-lbl {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
/* Per-port param controls — a value slider (unwired) or a dual-thumb attenuverter (wired), stacked under the
   port label (see .av-port-stacked). */
.av-port-ctl {
  width: 100%;
  display: block;
}
.av-port-ctl .av-value-num,
.av-range-num input {
  background: var(--surface-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 12px;
  padding: 2px 4px;
}
/* A param-port row stacks its label above the control; plain IO rows stay single-line. */
.av-port-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding-top: 4px;
  padding-bottom: 4px;
}
.av-port-stacked .av-port-lbl { align-self: flex-start; }
/* add-node palette — a top toolbar (never overlaps the canvas/nodes) */
/* Node-editor ⇄ raw-JSON view toggle. */
.av-viewbar {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-inset);
}
/* Add node centred · warnings right. */
.av-viewbar-grp { display: flex; align-items: center; gap: 6px; }
.av-viewbar-mid { flex: 1; justify-content: center; }
.av-viewbar-end { flex: 0 0 auto; justify-content: flex-end; }
/* Match the app button primitive (.btn), scaled for the toolbar. Used for the Add node button. */
.av-view-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--control-bg);
  color: var(--text-muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.av-view-tab:hover {
  background: var(--control-bg-hover);
  border-color: var(--control-border-hover);
  color: var(--text);
}
.av-view-tab.active {
  background: var(--control-bg-hover);
  color: var(--text);
  border-color: var(--accent);
}
.av-graph-warn {
  margin-left: auto;
  align-self: center;
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.av-pal-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.av-pal-cat {
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.06em;
  margin-right: 2px;
}
.av-pal-add {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
}
.av-pal-add:hover {
  border-color: var(--muted);
}
/* Add-node "place mode": after picking a node in the modal picker, a ghost chip follows the cursor and the canvas
   goes crosshair; the next pane click drops the node there. See NodesScreen placement handlers. */
.av-placing,
.av-placing .react-flow__pane {
  cursor: crosshair !important;
}
.av-ghost-chip {
  position: fixed;
  z-index: var(--z-modal);
  pointer-events: none; /* never intercept the placing click */
  padding: 3px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-panel);
  font: var(--text-sm) / 1 system-ui, sans-serif;
  white-space: nowrap;
  box-shadow: var(--shadow-2);
}
/* inline node param editors */
.av-field {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--muted);
}
/* MIDI-learn button on the Knob node editor. */
.av-learn {
  margin-top: 4px;
  padding: 3px 8px;
  font-size: 10px;
  background: var(--surface-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.av-learn:hover { border-color: var(--muted); }
.av-learn.learning { border-color: var(--accent); color: var(--accent); }
.av-field > span {
  min-width: 34px;
}
.av-field input,
.av-field select {
  flex: 1;
  min-width: 0;
  background: var(--surface-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 10px;
}
/* Number fields hold short values (e.g. −1.25) — cap them so they don't balloon to half the node (ramp from/to). */
.av-field input[type="number"] { flex: 0 1 6ch; width: 6ch; }
.av-field-row {
  display: flex;
  gap: 5px;
}
.av-field-row .av-field {
  flex: 1;
}
.av-copy-sel {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 4px;
  font: 11px system-ui, sans-serif;
}
/* edge-delete ✕ at each connection's midpoint — subtle until hovered. */
.av-edge-del {
  width: 15px;
  height: 15px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  opacity: 0.28;
  padding: 0;
}
.av-edge-del:hover {
  opacity: 1;
  background: var(--danger);
  color: var(--c-neutral-0);
  border-color: var(--danger);
}
.av-field-chk input {
  flex: 0 0 auto;
}
.av-field-chk > span {
  min-width: 0;
}

/* --- Kind-aware value controls (nodeControls.tsx): slider + number + inline range, hue strip, dual-thumb range.
   Node-island styles (this screen isn't design-system-migrated) — legacy tokens + small type to match. --- */
.av-value { flex-direction: column; align-items: stretch; gap: 3px; }
.av-value-inline { flex-direction: row; align-items: center; gap: 4px; width: 100%; }
.av-value-inline .av-value-ctl { flex: 1 1 auto; }
.av-value-label { min-width: 0; color: var(--muted); }
.av-value-ctl { display: flex; align-items: center; gap: 4px; }
.av-value-end { flex: 0 0 auto; font-size: 10px; color: var(--muted); opacity: 0.75; font-variant-numeric: tabular-nums; }
.av-value-slider { flex: 1 1 auto; min-width: 24px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.av-value-num { flex: 0 0 6ch; width: 6ch; } /* 6ch so 4-digit / signed values (e.g. -0.05, 1.40) don't truncate */
/* Drop the number-input spinner arrows — they steal ~1ch on these narrow boxes (clipping "0.05" → "0.0"); you
   drag the slider or type the value. */
.av-value-num,
.av-range-num input { -webkit-appearance: textfield; -moz-appearance: textfield; appearance: textfield; }
.av-value-num::-webkit-outer-spin-button,
.av-value-num::-webkit-inner-spin-button,
.av-range-num input::-webkit-outer-spin-button,
.av-range-num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.av-value-dice { flex: 0 0 auto; padding: 0 2px; background: none; border: none; font-size: 12px; line-height: 1; cursor: pointer; }
/* Hue strip — the track IS the hue wheel so the choice reads at a glance. */
.av-hue-slider {
  flex: 1 1 auto; min-width: 24px; height: 14px; cursor: pointer; -webkit-appearance: none; appearance: none;
  border-radius: 7px; border: 1px solid var(--line);
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.av-hue-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 8px; height: 18px; border-radius: 3px; background: var(--text); border: 1px solid var(--bg); cursor: pointer; }
.av-hue-slider::-moz-range-thumb { width: 8px; height: 18px; border-radius: 3px; background: var(--text); border: 1px solid var(--bg); cursor: pointer; }
.av-hue-swatch { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line); }
/* Dual-thumb attenuverter (wired param port): rest→peak the 0..1 signal sweeps. */
.av-range { flex-direction: column; align-items: stretch; gap: 4px; }
.av-range-track { position: relative; height: 14px; margin: 2px 7px; background: var(--surface-inset); border: 1px solid var(--line); border-radius: 7px; }
.av-range-fill { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 7px; }
.av-range-thumb { position: absolute; top: 50%; width: 13px; height: 13px; margin-left: -6.5px; transform: translateY(-50%); border-radius: 50%; background: var(--accent); border: 1px solid var(--bg); cursor: ew-resize; touch-action: none; }
/* Hue attenuverter: the track IS the hue wheel, so a signal-driven hue sweep reads as a slice of the rainbow. */
.av-range-hue { background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.av-range-hue .av-range-thumb { border-color: var(--bg); border-width: 2px; }
.av-range-swatch { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.av-range-nums { display: flex; align-items: center; gap: 6px; }
.av-range-num { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.av-range-num input { width: 6ch; background: var(--surface-inset); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; font-size: 12px; }

.render-holder {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 200px;
  background: var(--surface-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
/* Stacked so a fade can crossfade two visuals (opacity set inline); black bg shows through. */
.render-holder canvas { position: absolute; top: 0; left: 0; display: block; }
.render-empty { color: var(--muted); padding: 20px; }

.code-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.code-info { color: var(--muted); font-size: 12px; }
.code-reset {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.code-reset:hover { color: var(--text); border-color: var(--muted); }
.code-status { font-size: 12px; margin-left: auto; }
.code-status.ok { color: var(--success); }
.code-status.err { color: var(--danger); }
/* Editor + reference-docs pane, side by side. */
.code-body {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
}
/* Container for the CodeMirror editor. */
.code-editor {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 200px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--c-neutral-1); /* fixed dark — the CodeMirror syntax theme is dark (see codeEditor.ts) */
}
.code-docs {
  flex: 0 0 300px;
  width: 300px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.docs-tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.docs-tab {
  flex: 1;
  padding: 7px 4px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.docs-tab:hover { color: var(--text); }
.docs-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.docs-body { flex: 1 1 auto; overflow-y: auto; padding: 8px; }
.docs-note { color: var(--muted); font-size: 11px; margin: 2px 2px 8px; line-height: 1.4; }
.docs-entry {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
}
.docs-entry:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--line); }
.docs-entry-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.docs-entry code {
  color: var(--accent);
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  user-select: text;
}
.docs-meta { color: var(--muted); font-size: 10px; }
/* The insert button — quiet until you hover the row. */
.docs-add {
  margin-left: auto;
  flex: 0 0 auto;
  align-self: center;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 18px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s, border-color 0.1s;
}
.docs-entry:hover .docs-add { opacity: 1; }
.docs-add:hover { color: var(--accent); border-color: var(--accent); }
.docs-add:focus-visible { opacity: 1; outline: none; color: var(--accent); border-color: var(--accent); }
.docs-help { color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.35; }
.docs-structure {
  margin: 6px 0;
  padding: 8px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 10.5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  line-height: 1.45;
}
.docs-subhead {
  margin: 14px 0 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}
.docs-defs { display: flex; flex-direction: column; gap: 4px; margin: 4px 2px 8px; }
.docs-def { display: flex; gap: 8px; align-items: baseline; }
.docs-def code {
  flex: 0 0 auto;
  min-width: 62px;
  color: var(--accent);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
}
.docs-def span { color: var(--muted); font-size: 11px; line-height: 1.35; }
.code-editor .cm-editor { height: 100%; }
.code-editor .cm-editor.cm-focused { outline: none; }
.code-editor .cm-editor.cm-focused { border-color: var(--muted); }

/* Preview overlay chrome floats over the live viz — so, like the Home hero, it uses FIXED primitives
   (never the theme-flipping semantic roles) and stays dark glass in both themes, readable over any viz.
   See DESIGN.md "Landing (Home)" + "Colour outside the DOM". (The Export panel below is NOT over-viz —
   it's a document-page card and keeps semantic tokens.) */
.preview-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 268px;
  padding: 8px 10px;
  background: rgba(20, 22, 26, 0.85);
  border: 1px solid var(--c-neutral-5);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  font-size: 12px;
}
/* Shared scene header (top of Preview + Config): colour · name · visualisation · delete. */
.scene-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  box-sizing: border-box;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--scene-color, var(--accent));
  border-radius: var(--radius-md);
  background: var(--surface-panel);
}
/* Scene identity (colour / name / viz / delete), flanked by the two transitions. */
.scene-header .sh-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 12px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
/* A transition side: Cut/Fade + duration. */
.scene-header .sh-tx {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.scene-header .sh-tx-type,
.scene-header .sh-tx-dir {
  background: var(--surface-input);
  color: var(--text);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 5px 6px;
  font-size: var(--text-xs);
  cursor: pointer;
}
.scene-header .sh-tx-dur {
  width: 52px;
  background: var(--surface-input);
  color: var(--text);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 5px 6px;
  font-size: var(--text-xs);
}
.scene-header .sh-tx-dur:disabled { opacity: 0.35; }
.scene-header .sh-color {
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}
.scene-header .sh-index {
  color: var(--text-muted);
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.scene-header .sh-name {
  background: var(--surface-input);
  color: var(--text);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 5px 8px;
  font-size: var(--text-sm);
  flex: 1 1 auto;
  min-width: 120px;
}
.scene-header .sh-name:focus { outline: none; border-color: var(--control-border-hover); }
.scene-header .sh-viz-label,
.scene-header .sh-asset-label {
  color: var(--text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.scene-header .sh-delete {
  margin-left: auto;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  font-size: var(--text-xs);
  cursor: pointer;
}
.scene-header .sh-delete:hover:not(:disabled) { color: var(--danger-text); border-color: var(--danger-border); }
.scene-header .sh-delete:disabled { opacity: 0.4; cursor: default; }
.scene-header .sh-ask { margin-left: auto; background: transparent; color: var(--accent); border: 1px solid var(--control-border); border-radius: var(--radius-md); width: 28px; font-size: var(--text-sm); line-height: 1; cursor: pointer; }
.scene-header .sh-ask + .sh-delete { margin-left: 6px; }
.scene-header .sh-ask:hover:not(:disabled) { border-color: var(--accent); }
.scene-header .sh-ask:disabled { opacity: 0.4; cursor: default; }
.pp-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--c-text-mid);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  margin-bottom: 6px;
}
/* Live macro sliders (Knob nodes) — the performance surface at the top of the panel. */
.pp-knobs { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--c-neutral-5); }
.pp-knobs-title { color: var(--c-text-mid); text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; margin-bottom: 4px; }
.pp-knob { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; margin: 4px 0 8px; }
.pp-knob-label { font-size: 12px; color: var(--c-text-hi); }
.pp-knob-val { font-size: 11px; color: var(--c-text-mid); font-variant-numeric: tabular-nums; }
.pp-knob input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--c-info); cursor: pointer; }
.pp-knob-ctl { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pp-rec, .pp-rec-clear, .pp-rec-op { font-size: 10px; padding: 1px 7px; background: var(--c-neutral-1); color: var(--c-text-mid); border: 1px solid var(--c-neutral-5); border-radius: 4px; cursor: pointer; }
.pp-rec:hover, .pp-rec-clear:hover, .pp-rec-op:hover { border-color: var(--c-neutral-6); color: var(--c-text-hi); }
.pp-rec.armed { color: var(--c-danger); border-color: var(--c-danger); }
.pp-punch { display: flex; align-items: center; gap: 3px; font-size: 10px; color: var(--c-text-mid); cursor: pointer; }
.pp-region { grid-column: 1 / -1; display: flex; align-items: center; gap: 5px; margin: 2px 0 4px; flex-wrap: wrap; }
.pp-region-label { font-size: 10px; color: var(--c-text-mid); }
.pp-region-bars { font-size: 10px; padding: 1px 6px; background: var(--c-neutral-1); color: var(--c-text-mid); border: 1px solid var(--c-neutral-5); border-radius: 4px; cursor: pointer; }
.pp-region-bars:hover { border-color: var(--c-neutral-6); color: var(--c-text-hi); }
.pp-knob-lane { grid-column: 1 / -1; position: relative; height: 26px; margin-top: 2px; border: 1px solid var(--c-neutral-5); border-radius: 4px; background: var(--c-neutral-0); overflow: hidden; cursor: crosshair; user-select: none; }
.pp-knob-lane canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pp-lane-region { position: absolute; top: 0; bottom: 0; background: var(--c-accent-a20); border-left: 1px solid var(--c-accent-a40); border-right: 1px solid var(--c-accent-a40); pointer-events: none; }
.pp-lane-marker { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--c-accent); pointer-events: none; }
.pp-hide {
  background: transparent;
  color: var(--c-text-mid);
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.pp-hide:hover { color: var(--c-text-hi); }
/* Chip to reveal the panel again once hidden. */
.pp-show {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  background: rgba(20, 22, 26, 0.85);
  color: var(--c-text-mid);
  border: 1px solid var(--c-neutral-5);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.pp-show:hover { color: var(--c-text-hi); border-color: var(--c-neutral-6); }

/* Fullscreen toggle — top-left so it never collides with the right-docked panel/chip. */
.pp-fs {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 22, 26, 0.85);
  color: var(--c-text-mid);
  border: 1px solid var(--c-neutral-5);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.pp-fs:hover,
.pp-fs.active { color: var(--c-text-hi); border-color: var(--c-neutral-6); }

/* Live render-rate readout — bottom-left, clear of the top chrome. Fixed dark-glass like the other over-viz
   controls (not theme-tokened). Colour signals real-time (green) → dropping frames (amber) → stalling (red);
   monospace + tabular figures so the number doesn't jitter as it updates. */
.pp-fps {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 5;
  background: rgba(20, 22, 26, 0.85);
  color: var(--c-success);
  border: 1px solid var(--c-neutral-5);
  border-radius: 8px;
  padding: 4px 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.pp-fps.warn { color: var(--c-accent); }
.pp-fps.bad { color: var(--c-danger); border-color: var(--c-danger-border); }
/* Export (offline MP4) — styled as a standard .card so it matches every other card in the app. */
/* The Export panel is a standard .card built from design-system primitives (field + .select + .btn), so its
   controls match Settings — a full-width card, a label-above Resolution field, and real buttons. */
.export-panel {
  padding: var(--space-4) var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  font-size: var(--text-sm);
  color: var(--text);
}
.pp-export-title { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text); }
.pp-export-field { max-width: 220px; } /* a resolution dropdown doesn't need the full card width */
.pp-export-fps { color: var(--text-muted); }
.pp-export-bar { height: 6px; background: var(--surface-input); border-radius: var(--radius-sm); overflow: hidden; }
.pp-export-fill { height: 100%; width: 0; background: var(--link); transition: width 0.1s linear; }
.pp-export-status { color: var(--text-muted); min-height: 14px; }
.pp-export-note { margin: 0; font-size: var(--text-sm); color: var(--text-faint); line-height: 1.4; }
.pp-export-actions { display: flex; gap: var(--space-2); }
/* Keep-tab-front warning banner — sits ABOVE the card (outside it) so it's the first thing you see. */
.export-panel-wrap { display: flex; flex-direction: column; gap: var(--space-3); }
.pp-export-warn { display: flex; gap: var(--space-2); align-items: flex-start; margin: 0; padding: var(--space-2) var(--space-3); background: var(--accent-wash); border: 1px solid var(--accent); border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--text); line-height: 1.4; }
.pp-export-warn-icon { flex: none; color: var(--accent); font-size: var(--text-md); line-height: 1.3; }
/* Two stacked, self-contained sections (Video / Thumbnail), split by a rule. */
.pp-export-section { display: flex; flex-direction: column; gap: var(--space-3); }
.pp-export-section + .pp-export-section { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.pp-export-section-title { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; font-weight: var(--weight-semibold); color: var(--text-muted); }
.pp-export-clip-toggle { display: inline-flex; align-items: center; gap: var(--space-2); width: fit-content; font-size: var(--text-sm); color: var(--text); cursor: pointer; }
/* "from [n] s  for [n] s" / "frame at [n] s [button]" — each label a tidy inline unit so nothing stacks. */
.pp-export-clip, .pp-export-grab { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; color: var(--text-muted); font-size: var(--text-sm); }
.pp-export-clip-field { display: inline-flex; align-items: center; gap: var(--space-2); }
.pp-export-clip .input, .pp-export-grab .input { width: 6ch; text-align: right; }
/* Hide the number spinners on these compact time fields so the value isn't clipped (scoped, not global). */
.pp-export-clip .input::-webkit-inner-spin-button, .pp-export-grab .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pp-export-clip .input, .pp-export-grab .input { -moz-appearance: textfield; }
.pp-export-clip.is-off { opacity: 0.45; } /* dimmed when the Clip box is unticked */
.pp-export-clip-note { margin: 0; font-size: var(--text-sm); color: var(--text-faint); line-height: 1.4; }
.pp-export-thumb-status { min-height: 14px; font-size: var(--text-sm); color: var(--text-muted); }

/* --- Export screen: uses the shared page shell; the panel fills the page-body like every other card. --- */
.export-screen { overflow: auto; }
.export-empty { color: var(--text-muted); font-size: var(--text-md); }
.export-screen .export-panel { padding: var(--space-4) var(--space-5) var(--space-6); font-size: var(--text-base); }
.pp-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05); /* hairline on glass — fixed over-viz */
}
.pp-row.dim { opacity: 0.42; }
.pp-head { display: flex; align-items: center; gap: 6px; }
.pp-head input { accent-color: var(--c-accent); cursor: pointer; flex: none; }
/* Constant-value knob (editable fixed param). */
.pp-const .pp-val { margin-left: auto; color: var(--c-accent); }
.pp-slider { width: 100%; accent-color: var(--c-accent); cursor: pointer; margin-top: 2px; }
.pp-name { color: var(--c-text-hi); cursor: help; }
.pp-src { color: var(--c-text-mid); font-size: 10px; }
.pp-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.15); /* swatch outline on glass — fixed over-viz */
}
.pp-val {
  margin-left: auto;
  color: var(--c-accent);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  min-width: 34px;
  text-align: right;
}
.pp-swatch + .pp-val { margin-left: 6px; }
.pp-solo {
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--c-neutral-5);
  border-radius: 4px;
  background: transparent;
  color: var(--c-text-mid);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.pp-solo:hover { color: var(--c-text-hi); border-color: var(--c-neutral-6); }
.pp-solo.active { background: var(--c-accent); color: var(--c-neutral-0); border-color: var(--c-accent); }

.pp-bar {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--c-neutral-1);
  overflow: hidden;
}
.pp-bar.hue {
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); /* hue wheel — literal by nature */
}
.pp-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(99, 179, 237, 0.35); /* modulated-range highlight — fixed over-viz */
}
.pp-bar.hue .pp-range { background: rgba(255, 255, 255, 0.18); }
.pp-marker {
  position: absolute;
  top: -1px;
  width: 2px;
  height: 8px;
  margin-left: -1px;
  background: var(--c-text-hi);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

/* --- arrange footer (persistent drawer: waveform + scene strip + scene header) --- */
.arrange-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--surface-panel);
  padding: 6px 14px 10px;
}
.arrange-footer.hidden { display: none; }
.af-togglebar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.af-bpm, .af-offset { display: flex; align-items: center; gap: 5px; font-size: var(--text-2xs); color: var(--text-muted); }
.af-bpm input, .af-offset input {
  width: 52px;
  background: var(--surface-input);
  color: var(--text);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 3px 6px;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}
.af-offset-set {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 3px 6px;
  font-size: var(--text-xs);
  line-height: 1;
  cursor: pointer;
}
.af-offset-set:hover { color: var(--text); border-color: var(--control-border-hover); }
.af-toggle {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 3px 10px;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.af-toggle:hover { color: var(--text); border-color: var(--control-border-hover); }
.af-wave { margin-bottom: 8px; position: relative; }
/* Signal-trace overlay (Project only): sits over the wave (72px tall, below the 16px timeline). Explicit CSS box
   because a <canvas> is a replaced element — absolute insets don't stretch it, so it must be sized here. */
.af-trace-overlay { position: absolute; left: 0; top: 16px; width: 100%; height: 72px; display: block; pointer-events: none; z-index: 3; }
/* Collapsed = a peek: waveform + strip stay, the editing controls fold away. */
.arrange-footer.collapsed .af-editing { display: none; }
.arrange-footer .scene-header { margin-bottom: 0; }

.scenes { margin: 0 0 8px; }
.scene-toolbar { display: flex; margin-bottom: 5px; }
.scene-split {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  font-size: var(--text-xs);
  cursor: pointer;
}
.scene-split:hover { color: var(--text); border-color: var(--control-border-hover); }
.scene-strip {
  position: relative;
  height: 30px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.scene-block {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-left: 2px solid var(--scene-color, var(--accent));
  background: color-mix(in srgb, var(--scene-color, var(--accent)) 16%, transparent);
  cursor: pointer;
  overflow: hidden;
}
.scene-block:hover { background: color-mix(in srgb, var(--scene-color, var(--accent)) 30%, transparent); }
.scene-block.focused { background: color-mix(in srgb, var(--scene-color, var(--accent)) 40%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.scene-name {
  color: var(--text);
  font-size: var(--text-2xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
/* Fade glyph (bowtie for a crossfade, single diagonal for a black fade). */
.scene-fade {
  position: absolute;
  top: 0;
  bottom: 0;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.scene-fade line {
  stroke: var(--accent);
  stroke-width: 1.25;
  opacity: 0.85;
  vector-effect: non-scaling-stroke;
}
/* Playhead on the section strip. */
.scene-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
  z-index: 3;
}
/* Draggable scene-boundary handle — a thin grip straddling the boundary; widens/brightens on hover + drag. */
.scene-boundary {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px; /* generous hit area straddling the 1px boundary line */
  margin-left: -4px;
  z-index: 4;
  cursor: ew-resize;
  touch-action: none;
}
.scene-boundary::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: var(--text-faint);
}
.scene-boundary:hover::before,
.scene-boundary.dragging::before { left: 3px; width: 3px; background: var(--accent); }

.setup-screen h2 { margin: 6px 0 10px; font-size: 16px; }

.project-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 620px;
}
.project-bar span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.project-bar select { flex: 1; } /* the .select primitive styles it; just grow to fill the bar */

.midi-row { display: flex; align-items: center; gap: var(--space-3); }
/* .midi-enable (a .btn) / .midi-select (a .select) are design-system primitives now — the classes remain only as
   test/behaviour hooks; their visuals come from .btn / .select. */
.midi-hint { font-size: var(--text-sm); color: var(--text-muted); }
.midi-link { color: var(--link); }
.midi-activity { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-sm); color: var(--text-muted); padding: 3px var(--space-2); border: 1px solid var(--control-border); border-radius: var(--radius-sm); max-width: 100%; }
.midi-activity.is-live { white-space: nowrap; }

/* Auto-detect scenes controls on the Project screen. */
.detect-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.detect-chk { display: flex; align-items: center; gap: var(--space-2); min-height: 28px; font-size: var(--text-md); color: var(--text); cursor: pointer; }
.detect-chk input { width: 16px; height: 16px; accent-color: var(--accent); }
/* .detect-run / .profile-backend styling now comes from the .btn / .select primitives (Analysis migrated);
   the classes remain only as behaviour/test hooks. */
.detect-progress { margin: 0 0 0 4px; align-self: center; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.detect-sens { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.detect-sens input[type="range"] { width: 92px; }

/* Project screen tabs — a vertical side-nav mirroring the Settings screen (Track / Analysis / Assets) */
/* .project-nav-item / .settings-nav-item are now the horizontal .page-tab (styling from there); these classes
   remain only as behaviour/test hooks. .project-tab-body is the card holding the active tab's content. */
.project-tab-body { min-width: 0; }

/* Analysis waveform: full-width whole-track wave + a signal trace overlay + hover-linked section bands */
/* Analysis "Explore": the trace picker (drives the footer overlay) + the focused-section readout */
.trace-picker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* .trace-chip styling now comes from the .chip primitive (border=off / fill=on, colour via --chip-color). */
.trace-multi { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 28px; box-sizing: border-box; border: 1px solid var(--chip-color, var(--control-border)); border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3); font-size: var(--text-base); color: var(--text-muted); }
.trace-multi.on { color: var(--text); }
.trace-multi select { background: var(--surface-input); color: var(--text); border: 1px solid var(--control-border); border-radius: var(--radius-sm); font-size: var(--text-xs); padding: 1px var(--space-1); }
/* Signals view — the selected traces drawn full-track (canvas), one labelled lane each. Canvas colours are set
   in JS (per-series + theme-resolved); the chrome here is all semantic tokens. */
.signals-list { display: flex; flex-direction: column; gap: var(--space-2); }
.signal-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: var(--space-3); }
.signal-row-label { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: var(--text-xs); color: var(--text-muted); }
.signal-row-label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-row-dot { flex: none; width: 10px; height: 10px; border-radius: var(--radius-round); }
.signal-row-trace { width: 100%; height: 40px; display: block; background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* An inline callout in the Analysis cards (e.g. the "still one scene — detect first" profile guard). */
.analysis-note { margin: 0; padding: var(--space-2) var(--space-3); background: var(--accent-wash); border: 1px solid var(--accent); border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--text); line-height: 1.5; }

.section-info { font-size: 12px; color: var(--muted); margin: 0 0 14px; }
.section-info strong { color: var(--text); }
.section-info-esc { color: var(--muted); opacity: 0.7; margin-left: 8px; font-style: italic; }

/* Profile result (Analysis tab) — the per-section table that makes backends comparable */
.profile-result { display: flex; flex-direction: column; gap: var(--space-3); }
.profile-table-scroll { overflow-x: auto; }
.profile-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.profile-table th, .profile-table td { text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
.profile-table th { color: var(--muted); font-weight: 600; }
.profile-table .profile-character { white-space: normal; color: var(--muted); min-width: 220px; }
.profile-table tr:hover td, .profile-table tr.hl td { background: rgba(246,173,85,0.12); }
.profile-table tr.focused td { background: rgba(246,173,85,0.18); }
.profile-table tr.profile-row { cursor: pointer; }
.profile-unanalysed { color: var(--muted); font-style: italic; }
.profile-edit { background: transparent; border: 1px solid transparent; border-radius: 3px; color: var(--text); font: inherit; padding: 2px 4px; width: 88px; }
.profile-edit.profile-edit-wide { width: 100%; min-width: 200px; color: var(--muted); }
.profile-edit:hover { border-color: var(--line); }
.profile-edit:focus { border-color: var(--accent); background: #0f1115; outline: none; color: var(--text); }
.detect-tempo { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-md); color: var(--text); }
.detect-tempo input { width: 64px; } /* the .input primitive styles it; just constrain the width */
.detect-min-w { width: 72px; } /* the min-scene number input — a fixed narrow control width */
.tempo-est { background: transparent; color: var(--accent); border: 1px solid var(--control-border); border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3); font-size: var(--text-sm); cursor: pointer; }
.tempo-est:hover { border-color: var(--accent); }
.tempo-est.applied { color: var(--text-muted); border-color: transparent; cursor: default; padding-left: 2px; } /* informational — already applied */
.af-offset-est { font-size: 11px; padding: 2px 7px; margin-left: 2px; } /* footer-scale beat-phase chip */
/* Current-scene readout — pushed to the far right of the toggle bar, follows the playhead. */
.af-scene-label { margin-left: auto; font-size: var(--text-sm); color: var(--text); font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.track-loaded { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-md); color: var(--text-muted); }
.track-loaded strong { color: var(--text); }

/* Shader node body: an Edit button + a uniform-count summary (the editor lives in a modal). */
.av-shader-node { display: flex; align-items: center; gap: 8px; }
.av-shader-edit { background: var(--control-bg); color: var(--text); border: 1px solid var(--control-border); border-radius: 4px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.av-shader-edit:hover { border-color: var(--control-border-hover); background: var(--control-bg-hover); }
.av-shader-node-sum { font-size: 11px; color: var(--muted); }

/* Full-screen shader editor modal (overlays the Nodes workspace). */
.av-shader-modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; }
.av-shader-modal-panel { width: 80vw; max-width: 1100px; height: 82vh; display: flex; flex-direction: column; gap: 8px; background: var(--surface-inset); border: 1px solid var(--border); border-radius: 8px; padding: 12px; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5); }
.av-shader-modal-head { display: flex; align-items: center; gap: 10px; }
.av-shader-modal-title { font-weight: 600; margin-right: auto; }
.av-shader-modal-close { background: var(--surface-inset); color: var(--text); border: 1px solid var(--control-border); border-radius: 4px; width: 28px; height: 28px; font-size: 14px; cursor: pointer; }
.av-shader-modal-close:hover { border-color: var(--muted); }
.av-shader-modal-body { flex: 1; min-height: 0; display: flex; gap: 10px; }
.av-shader-modal-editor { flex: 1; min-width: 0; min-height: 0; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--c-neutral-0); font-size: 13px; } /* fixed dark — dark CodeMirror syntax theme */
.av-shader-preview { position: relative; flex: 0 0 42%; min-width: 0; align-self: stretch; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: #000; } /* black = the shader render target, fixed in both themes */
.av-shader-preview-canvas { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.av-shader-preview-canvas canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.av-shader-preview-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; font-size: 12px; line-height: 1.5; color: var(--c-text-hi); background: rgba(0, 0, 0, 0.55); } /* over the black preview → fixed light text */
.av-shader-modal-editor .cm-editor { height: 100%; background: transparent; }
.av-shader-modal-editor .cm-editor.cm-focused { outline: none; }
.av-shader-modal-editor .cm-gutters { background: var(--c-neutral-0); border-right: 1px solid var(--border); }
.av-shader-tpl { background: var(--surface-inset); color: var(--text); border: 1px solid var(--control-border); border-radius: 4px; padding: 3px 6px; font-size: 12px; }
.av-shader-hint { font-size: 11px; color: var(--muted); }
.av-shader-err { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--danger-text); background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: 4px; padding: 6px 10px; max-height: 90px; overflow: auto; white-space: pre-wrap; }
.midi-activity.is-live { color: #7ee081; border-color: #2c6a2e; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-8);
  border: 1.5px dashed var(--control-border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dropzone:hover { border-color: var(--control-border-hover); background: var(--accent-wash); }
.dropzone.over { border-color: var(--accent); background: var(--accent-wash); }
.dropzone.busy { cursor: default; border-style: solid; color: var(--accent); }
.dropzone strong { color: var(--text); font-size: var(--text-md); }
.dropzone.busy strong { color: var(--accent); }
.dropzone span { font-size: var(--text-sm); }

.status { margin: 0; font-size: var(--text-md); }
.status.busy { color: var(--accent); }
.status.error { color: var(--danger-text); }
.status.idle { color: var(--text-muted); }

.track-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 420px;
  margin-top: 10px;
}
.track-item {
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.track-item:hover { border-color: var(--muted); }
.track-item.active { border-color: var(--accent); color: var(--accent); }

.track-row { display: flex; gap: 6px; }
.track-row .track-item { flex: 1; }

/* Image assets */
.asset-drop { min-height: 64px; padding: 12px; }
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.asset-cell {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-inset);
}
.asset-cell img,
.asset-cell video {
  display: block;
  width: 100%;
  height: 90px;
  object-fit: cover;
}
/* A colour asset renders as a solid swatch (its background is the hex, set inline) in place of an image thumb. */
.asset-swatch {
  display: block;
  width: 100%;
  height: 90px;
}
/* The "Add colour" control: a native colour input styled as a compact swatch beside the Add button. */
.colour-swatch {
  width: 34px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  cursor: pointer;
}
.asset-name {
  display: block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-del {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px var(--space-2);
  background: rgba(11, 13, 17, 0.85);
}
.rename-btn {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
}
.rename-btn:hover { color: var(--accent); border-color: var(--muted); }
.delete-btn {
  background: var(--control-bg);
  color: var(--text-muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-base);
  cursor: pointer;
}
.delete-btn:hover { color: var(--danger-text); border-color: var(--danger-border); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.modal.wide { max-width: 600px; }
.modal h3 { margin: 0 0 10px; font-size: 15px; padding-right: 24px; }
.modal-body { color: var(--text); font-size: 13px; line-height: 1.5; }
.modal-body p { margin: 0; }

/* Signal dialog */
.sig-dialog { display: flex; flex-direction: column; gap: 10px; }
.sig-row { display: flex; align-items: center; gap: 8px; }
.sig-label { font-size: 11px; color: var(--muted); min-width: 64px; }
.sig-name, .sig-source, .sig-add-proc, .sig-num input, .sig-num select {
  background: #0f1115;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}
.sig-name { flex: 1; }
.sig-source { flex: 1; }
.sig-chain-head { display: flex; align-items: center; gap: 8px; }
.sig-chain { display: flex; flex-direction: column; gap: 8px; }
.sig-proc { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: rgba(255, 255, 255, 0.02); }
.sig-proc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sig-proc-name { font-size: 12px; color: var(--accent); }
.sig-proc-rm { background: transparent; border: 1px solid var(--line); border-radius: 50%; width: 18px; height: 18px; color: var(--muted); cursor: pointer; line-height: 1; }
.sig-proc-rm:hover { color: #fc8181; border-color: #fc8181; }
.sig-proc-params { display: flex; flex-wrap: wrap; gap: 8px; }
.sig-num { display: flex; flex-direction: column; gap: 2px; font-size: 10px; color: var(--muted); }
.sig-num input, .sig-num select { width: 84px; }
.sig-empty { color: var(--muted); font-size: 11px; font-style: italic; margin: 0; }
.sig-preview { min-height: 90px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sig-err { color: #fc8181; font-size: 11px; min-height: 14px; margin: 0; }
.sig-btns { display: flex; gap: 8px; margin-top: 4px; }
.sig-save { background: var(--accent); color: #1a1a1a; border: none; border-radius: 6px; padding: 6px 14px; font-size: 12px; cursor: pointer; font-weight: 600; }
.sig-cancel { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 6px 14px; font-size: 12px; cursor: pointer; }
.sig-delete { margin-left: auto; background: transparent; color: #fc8181; border: 1px solid var(--line); border-radius: 6px; padding: 6px 14px; font-size: 12px; cursor: pointer; }
.sig-delete:hover { border-color: #fc8181; }

/* Cheat-sheet help */
.help-sec { margin: 16px 0 0; }
.help-sec h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.help-p { margin: 6px 0; line-height: 1.5; }
.help code { color: var(--accent); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.help-keys { display: flex; flex-direction: column; gap: 6px; }
.help-keys > div { display: flex; gap: 12px; align-items: baseline; }
.help kbd {
  flex: 0 0 auto;
  min-width: 92px;
  text-align: center;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  background: #0f1115;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text);
}
.help-keys > div > span { color: var(--muted); }
.help-code {
  margin: 6px 0 0;
  padding: 8px;
  background: #0f1115;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--text);
}
.help-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-round);
  width: 30px;
  height: 30px;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.help-btn:hover { color: var(--text); border-color: var(--control-border-hover); }

/* The app-wide Engineer identifier (topbar ✦). Accent-coloured so it reads as first-class; filled when open.
   position:relative reserves the corner for the Phase-2 unread badge. */
/* A labelled pill, centred in the topbar (absolute) so it stays put regardless of the nav/transport widths. */
/* Engineer identifier = emphasis tier: accent-tinted pill (closed) → solid amber (open). Reads as first-class. */
/* In normal flow, auto-margins centre it in the free space between the nav and the transport (so it can't
   overlap the last menu item on a narrow screen). */
.engineer-btn { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0 auto; background: var(--accent-wash); color: var(--text); border: 1px solid var(--accent); border-radius: var(--radius-pill); padding: var(--space-2) var(--space-4); min-height: 36px; font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: 1; cursor: pointer; box-shadow: var(--shadow-1); }
.engineer-btn .eng-mark { color: var(--accent); font-size: var(--text-md); }
.engineer-btn .eng-label { letter-spacing: 0.01em; }
.engineer-btn .eng-kbd { font: var(--weight-semibold) 10px/1 ui-monospace, "SF Mono", monospace; color: var(--text-muted); background: var(--surface-input); border: 1px solid var(--control-border); border-radius: var(--radius-sm); padding: 3px 5px; } /* always visible — the shortcut is part of the button's affordance */
.engineer-btn.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.engineer-btn.active .eng-mark { color: var(--accent-contrast); }
.engineer-btn.active .eng-kbd { color: rgba(20, 22, 26, 0.7); background: transparent; border-color: rgba(20, 22, 26, 0.35); }
.engineer-btn.unconfigured { color: var(--muted); opacity: 0.75; }
.engineer-btn.unconfigured .eng-mark { color: var(--muted); }
/* Hover fills solid accent (previews the active look). Placed AFTER the state rules so it wins by source order
   even when unconfigured; opacity:1 lifts the unconfigured dimming. The mark + shortcut chip flip to read on it. */
.engineer-btn:hover { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); opacity: 1; }
.engineer-btn:hover .eng-mark { color: var(--accent-contrast); }
.engineer-btn:hover .eng-kbd { color: rgba(20, 22, 26, 0.7); background: transparent; border-color: rgba(20, 22, 26, 0.35); }
.engineer-btn.working { animation: engineer-pulse 1.2s ease-in-out infinite; }
@keyframes engineer-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(246, 173, 85, 0); }
  50% { box-shadow: 0 0 0 3px rgba(246, 173, 85, 0.35); border-color: var(--accent); }
}
.engineer-btn.has-unread::after {
  content: attr(data-unread);
  position: absolute; top: -5px; right: -5px;
  min-width: 14px; height: 14px; padding: 0 3px; box-sizing: border-box;
  background: var(--accent); color: #14161a;
  font: 700 9px/14px system-ui, sans-serif; text-align: center;
  border-radius: 7px;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }

/* Transport Play = the emphasis tier (loudest chrome): solid amber, bigger + bolder, matches .btn--emphasis. */
.play-btn {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-5);
  min-height: 36px;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  min-width: 96px;
  box-shadow: var(--shadow-1);
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn:active { transform: translateY(1px); }

/* Loop = a quiet bordered toggle; filled amber when active. */
.loop-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.loop-btn:hover { background: var(--control-bg); border-color: var(--control-border-hover); }
.loop-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* Prev/next scene buttons flanking Play — borderless toolbar icons so they don't compete with Play. */
.scene-nav-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-2);
  min-width: 32px;
  font-size: var(--text-md);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.scene-nav-btn:hover { color: var(--text); background: var(--control-bg); }
.scene-nav-btn:active { transform: translateY(1px); }

.time-label {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-base);
}

.wave {
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  margin-bottom: 10px;
}

.traces {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.trace {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
/* Dense multi-series traces (bands / chroma) span the full row for horizontal room. */
.trace.wide { grid-column: 1 / -1; }

.trace-title {
  position: absolute;
  left: 8px;
  top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  padding: 0;
  pointer-events: none;
  z-index: 3;
}

/* Trace action buttons, pinned top-right of each box (help / edit / hide-delete). */
.trace-actions {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 4;
  display: flex;
  gap: 4px;
  pointer-events: none;
}
.trace-btn {
  pointer-events: auto;
  cursor: pointer;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(20, 22, 26, 0.6);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}
.trace-btn:hover { color: var(--text); border-color: var(--muted); }
.trace-hide:hover { color: #fc8181; border-color: #fc8181; }
.trace-edit:hover { color: var(--accent); border-color: var(--accent); }

/* The "add new signal" tile — same footprint as a trace, dashed to read as an add slot. */
.trace-add {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  border-style: dashed !important;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.trace-add:hover { color: var(--accent); border-color: var(--accent) !important; background: rgba(246, 173, 85, 0.04); }

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 2px 6px; }
th:first-child, td:first-child { text-align: left; color: var(--muted); }
thead th { color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); }

.readout .val { color: var(--accent); }
.stats .hint { color: var(--muted); }

.uplot { width: 100%; }

/* --- Engineer panel (Nodes workspace) --------------------------------------------------------------- */
.nodes-screen > .nodes-root { position: relative; }
.av-engineer-toggle.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.av-engineer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 20;
  width: 380px; max-width: 92vw;
  display: flex; flex-direction: column;
  background: var(--surface-inset); border-left: 1px solid var(--line);
  box-shadow: -4px 0 14px rgba(0, 0, 0, 0.4);
  transform: translateX(100%); transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.av-engineer-panel.open { transform: translateX(0); }

.av-engineer-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-inset); }
.av-engineer-title { font-weight: 600; margin-right: auto; color: var(--text); }
.av-engineer-head-actions { display: flex; gap: 4px; }
.av-engineer-iconbtn { display: inline-flex; align-items: center; justify-content: center; background: var(--control-bg); color: var(--text-muted); border: 1px solid var(--line); border-radius: 4px; width: 26px; height: 26px; font-size: 13px; cursor: pointer; }
.av-engineer-iconbtn:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.av-engineer-iconbtn:disabled { opacity: 0.4; cursor: default; }
.av-engineer-iconbtn.active { background: var(--control-bg-hover); color: var(--text); }

/* The panel is a flex column; only the transcript flexes/scrolls — everything else keeps its natural height
   (otherwise a tall transcript squeezes the tab strip and clips its text). */
.av-engineer-head, .av-engineer-tabs, .av-engineer-meta, .av-engineer-error, .av-engineer-composer { flex: none; }

/* Conversation tabs */
.av-engineer-tabs { display: flex; align-items: center; gap: 3px; padding: 5px 6px 0; background: var(--surface-inset); border-bottom: 1px solid var(--line); overflow-x: auto; }
.av-engineer-tab { display: flex; align-items: center; gap: 4px; max-width: 150px; min-height: 26px; padding: 5px 7px 6px 10px; font-size: 11.5px; line-height: 1.3; color: var(--text-muted); background: var(--surface-inset); border: 1px solid var(--line); border-bottom: 0; border-radius: 5px 5px 0 0; cursor: pointer; flex: 0 0 auto; }
.av-engineer-tab.active { background: var(--control-bg); color: var(--text); }
.av-engineer-tab-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-engineer-tab-close { flex: none; background: transparent; border: 0; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; padding: 0 2px; border-radius: 3px; }
.av-engineer-tab-close:hover { color: var(--text); background: var(--control-bg-hover); }
.av-engineer-tab-new { flex: none; align-self: center; margin-left: 2px; background: var(--control-bg); border: 1px solid var(--line); border-radius: 5px; color: var(--text); font-size: 11.5px; font-weight: 600; line-height: 1; cursor: pointer; padding: 4px 8px; }
.av-engineer-tab-new:hover { color: var(--text); border-color: var(--muted); }

/* Meta row above the composer: scene indicator + context-usage chip */
.av-engineer-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 8px; background: var(--surface-inset); border-top: 1px solid var(--line); }
.av-engineer-usage { flex: none; background: transparent; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 10.5px; padding: 1px 6px; cursor: pointer; }
.av-engineer-usage:hover { color: var(--text); border-color: var(--muted); }

/* Inline scope chip (from "ask about this node/scene") — sits above the composer, dismissible. */
.av-engineer-scope { display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--surface-inset); border-top: 1px solid var(--line); font-size: 11px; color: var(--accent); }
.av-engineer-scope-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-engineer-scope-clear { flex: none; background: transparent; border: 0; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; padding: 0 2px; }
.av-engineer-scope-clear:hover { color: var(--text); }

/* --- Home / landing ------------------------------------------------------------------------------- */
/* Full-bleed fluid hero (baked image, also the OG card) + a scrim so the wordmark stays legible. */
.home-screen {
  padding: 0;
  overflow: hidden; /* a full-bleed hero never scrolls — and stops the live canvas ever toggling a scrollbar */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0f13 url("/hero.jpg") center / cover no-repeat;
}
/* The live fluid canvas (when it starts) sits over the baked still and fades in; the scrim + content are above it. */
.home-viz {
  position: absolute;
  inset: 0;
  /* !important beats the inline px size three.js writes via renderer.setSize — otherwise the canvas can end
     up a few px larger than the host (DPR rounding), overflow, and toggle a scrollbar. display:block kills
     the inline-element baseline gap. */
  display: block;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.home-viz.is-live { opacity: 1; }
/* The scrim is a PANEL behind the hero content only — not a full-bleed darkening — so the viz stays vivid
   around it. A soft translucent-dark glass card (blurred, rounded) keeps the wordmark legible over any frame. */
.home-inner {
  position: relative;
  z-index: 2;
  margin: auto;
  max-width: 680px;
  padding: var(--space-10) var(--space-8);
  text-align: center;
  background: rgba(11, 13, 17, 0.62);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  box-shadow: var(--shadow-2);
}
/* Home is an always-dark image hero (see DESIGN.md), so it uses FIXED primitive colours — never the
   theme-flipping semantic tokens (those would make text vanish in light mode). Scale tokens are safe. */
.home-mark { color: var(--c-accent); }
/* The 6-point brand star, inline in the title: sized to the cap height, nudged onto the baseline. */
.brand-star { width: 0.82em; height: 0.82em; vertical-align: -0.04em; }
/* Weight-split wordmark (audio light / viz bold) — the channel treatment, brought in-app. */
.home-word .hw-lo { font-weight: var(--weight-normal); }
.home-word .hw-hi { font-weight: var(--weight-bold); }
.home-title { margin: 0 0 var(--space-4); font-size: 44px; font-weight: var(--weight-bold); letter-spacing: -0.01em; color: var(--c-text-hi); }
.home-tagline { margin: 0 auto var(--space-6); max-width: 560px; font-size: var(--text-lg); line-height: 1.6; color: #c9cdd6; }
.home-steps { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: var(--space-2) var(--space-1); margin: 0 0 var(--space-6); }
/* The 5 steps share the row equally (basis 0, grow 1) so they stay one row with their arrows, rather than
   wrapping a step onto its own line. */
.home-step { display: flex; flex-direction: column; gap: 3px; flex: 1 1 0; min-width: 0; padding: 0 var(--space-2); }
.hs-name { color: var(--c-accent); font-weight: var(--weight-semibold); font-size: var(--text-base); }
.hs-gloss { color: var(--c-text-mid); font-size: var(--text-sm); line-height: 1.35; }
.home-arrow { align-self: flex-start; margin-top: 1px; line-height: 1; color: var(--c-text-mid); }
.home-engineer { margin: 0 auto var(--space-6); max-width: 520px; font-size: var(--text-sm); line-height: 1.55; color: #aeb3bd; }
/* Inline ✦ Engineer pill — mirrors the header .engineer-btn (minus the keybind). Home is always-dark, so it
   uses FIXED primitives (never the theme-flipping semantic roles) like the rest of the hero. */
.home-eng {
  display: inline-flex; align-items: center; gap: var(--space-1); vertical-align: middle; white-space: nowrap;
  background: var(--c-accent-a08); color: var(--c-text-hi);
  border: 1px solid var(--c-accent); border-radius: var(--radius-pill);
  padding: 2px var(--space-2); font-weight: var(--weight-semibold);
}
.home-eng-mark { color: var(--c-accent); }
/* CTA = the emphasis tier (the one action on the landing). */
.home-cta {
  background: var(--c-accent); color: var(--c-neutral-0); border: 1px solid var(--c-accent); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-6); font-size: var(--text-md); font-weight: var(--weight-semibold); cursor: pointer;
  box-shadow: var(--shadow-2);
  transition: filter 0.15s ease, transform 0.1s ease;
}
.home-cta:hover { filter: brightness(1.08); }
.home-cta:active { transform: translateY(1px); }

/* The "get started" box — groups the flow, the Engineer line, and the two primary actions (Load a track + the
   first guided tour) into one bounded panel, set apart from the extra walkthroughs below. A subtle inset over the
   hero glass (fixed primitives — Home is always-dark). */
.home-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin: 0 0 var(--space-6);
}
.home-box .home-steps, .home-box .home-engineer { margin-bottom: var(--space-5); }
/* Primary actions row: the emphasis CTA + the first (guided) tutorial, side by side. */
.home-primary { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); }
.home-first-tut { display: contents; } /* let the first-tutorial button flex directly in .home-primary */

/* Guided-walkthrough launcher. The first tour lives in the box above; the rest lay out side-by-side here.
   Over-viz landing chrome → fixed primitives + dark glass. */
.home-tutorials { margin-top: var(--space-6); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.home-tut-grid { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); }
.home-tut-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-text-mid); }
.home-tut-btn { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4);
  background: rgba(20, 22, 26, 0.6); color: var(--c-text-hi); border: 1px solid var(--c-neutral-6);
  border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer;
  backdrop-filter: blur(4px); transition: border-color 0.15s ease, background 0.15s ease; }
.home-tut-btn:hover { border-color: var(--c-accent); background: rgba(20, 22, 26, 0.82); }
.home-tut-icon { font-size: 1.05em; line-height: 1; } /* 🎓 emoji — the "this is a tutorial" glyph */
.home-tut-check { color: var(--c-success-hi); font-size: var(--text-xs); } /* completed marker */
.home-tut-replay { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-mid); }

/* --- "Try a sample" — ready-made projects a new visitor can load in one click (see src/samples.ts) ------ */
.home-samples { margin-top: var(--space-6); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.home-samples-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-text-mid); }
.home-samples-grid { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; gap: var(--space-3); }
.home-sample-btn { display: flex; flex-direction: column; gap: var(--space-1); max-width: 15rem; padding: var(--space-3) var(--space-4);
  text-align: left; background: rgba(20, 22, 26, 0.6); color: var(--c-text-hi); border: 1px solid var(--c-neutral-6);
  border-radius: var(--radius-md); cursor: pointer; backdrop-filter: blur(4px);
  transition: border-color 0.15s ease, background 0.15s ease; }
.home-sample-btn:hover { border-color: var(--c-accent); background: rgba(20, 22, 26, 0.82); }
.home-sample-btn strong { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.home-sample-btn span { font-size: var(--text-xs); color: var(--c-text-mid); }
.home-samples.loading { opacity: 0.7; pointer-events: none; }
.home-samples-status { font-size: var(--text-xs); color: var(--c-text-mid); min-height: 1em; margin: 0; }

/* The tutorial's "sample track" download link on the Project import step (see ProjectScreen buildTrackTab). */
.sample-track-line { margin-top: 0; }
.sample-track-link { color: var(--c-accent); font-weight: var(--weight-medium); }
.sample-track-link:hover { text-decoration: underline; }

/* --- Narrow screens (phones): the top bar wraps into rows instead of overflowing / clipping. --------- */
@media (max-width: 640px) {
  .topbar { gap: 8px 10px; padding: 6px 10px; flex-wrap: wrap; }
  .nav { flex: 1 1 100%; overflow-x: auto; }            /* tabs get their own row; scroll horizontally if they overflow */
  .engineer-btn { position: static; transform: none; flex: 0 0 auto; }  /* flow inline (not absolute-centred) so it can't overlap the nav */
  .engineer-btn .eng-kbd { display: none; }  /* no hover / no keyboard on touch */
  .transport { margin-left: 0; gap: 8px; flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow-x: auto; }  /* one scrollable controls strip beside the ✦ (2-row topbar, no clipping) */
  .time-label { font-size: 12px; }
}

.av-engineer-transcript { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.av-engineer-empty { color: var(--muted); font-size: 12.5px; line-height: 1.6; padding: 8px 4px; }
.av-engineer-empty p { margin: 0 0 8px; } /* space the starter-hint paragraphs */
.av-engineer-empty p:last-child { margin-bottom: 0; }
.av-engineer-empty strong { color: var(--text); font-weight: 600; }
.av-engineer-empty em { color: var(--text); font-style: italic; }

.av-engineer-msg { font-size: 13px; line-height: 1.5; border-radius: 8px; padding: 8px 11px; white-space: pre-wrap; word-break: break-word; }
.av-engineer-user { background: var(--control-bg); color: var(--text); align-self: flex-end; max-width: 88%; }
.av-engineer-assistant { background: var(--surface-inset); color: var(--text); border: 1px solid var(--line); }

/* "Revert to here" — a quiet action revealed on hovering (or focusing within) a user turn that's still undoable. */
.av-engineer-revert { display: block; margin: var(--space-2) 0 0 auto; padding: 0; background: none; border: none; color: var(--text-faint); font-size: var(--text-2xs); cursor: pointer; opacity: 0; transition: opacity var(--transition-fast); }
.av-engineer-user:hover .av-engineer-revert, .av-engineer-revert:focus-visible { opacity: 1; }
.av-engineer-revert:hover { color: var(--accent); text-decoration: underline; }

/* Transient "Reverted …" toast, pinned above the composer; auto-clears from the manager. */
.av-engineer-notice { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); max-width: 88%; background: var(--surface-panel); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font-size: var(--text-xs); box-shadow: var(--shadow-2); z-index: var(--z-overlay); pointer-events: none; text-align: center; }

/* Markdown inside an assistant message (rendered from an AST — see Markdown.tsx). */
.av-md { font-size: 13px; line-height: 1.5; }
.av-md > :first-child { margin-top: 0; }
.av-md > :last-child { margin-bottom: 0; }
.av-md-p { margin: 0 0 8px; }
.av-md-h { font-weight: 600; margin: 10px 0 6px; color: var(--text); }
.av-md-h1 { font-size: 15px; }
.av-md-h2 { font-size: 14px; }
.av-md-h3, .av-md-h4 { font-size: 13px; }
.av-md-list { margin: 0 0 8px; padding-left: 20px; }
.av-md-list li { margin: 2px 0; }
.av-md-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: var(--surface-input); border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; }
.av-md-pre { background: var(--surface-input); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin: 0 0 8px; overflow-x: auto; }
.av-md-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text); white-space: pre; }
.av-md-quote { margin: 0 0 8px; padding-left: 10px; border-left: 2px solid var(--line); color: var(--muted); }
/* GFM tables (e.g. the Engineer's scene plan). Wrap scrolls horizontally so a wide table never blows out the panel. */
.av-md-table-wrap { margin: 0 0 8px; overflow-x: auto; }
.av-md-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.av-md-table th, .av-md-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.av-md-table th { background: var(--surface-inset); color: var(--text); font-weight: var(--weight-semibold); white-space: nowrap; }
.av-md-table td { color: var(--text); }
.av-md del { color: var(--muted); }
.av-md-hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.av-md-list .av-md-list { margin: 2px 0; } /* nested list — tighter than a top-level one */
.av-md-task { list-style: none; } /* the checkbox replaces the bullet */
.av-md-check { margin-right: 6px; accent-color: var(--accent); vertical-align: middle; }
.av-md a { color: var(--accent); }
.av-engineer-errmsg { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); font-size: 12px; }

.av-engineer-tool { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--text-muted); }
.av-engineer-tool-row { display: flex; align-items: baseline; gap: 6px; padding: 2px 4px; cursor: pointer; list-style: none; border-radius: 4px; }
.av-engineer-tool-row::-webkit-details-marker { display: none; }
.av-engineer-tool-row:hover { background: var(--surface-inset); }
.av-engineer-tool-row::before { content: "▸"; flex: none; color: var(--muted); font-size: 9px; transition: transform 0.12s; }
.av-engineer-tool[open] .av-engineer-tool-row::before { transform: rotate(90deg); }
.av-engineer-tool-icon { flex: none; width: 12px; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.av-engineer-tool-name { color: var(--text); font-weight: 600; flex: none; }
.av-engineer-tool-summary { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-engineer-tool-ok .av-engineer-tool-icon { color: var(--success-text); }
.av-engineer-tool-error .av-engineer-tool-icon { color: var(--danger-text); }
.av-engineer-tool-detail { margin: 2px 0 6px 22px; display: flex; flex-direction: column; gap: 3px; }
.av-engineer-tool-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.av-engineer-tool-detail pre { margin: 0 0 4px; padding: 6px 8px; background: var(--surface-input); border: 1px solid var(--line); border-radius: 4px; color: var(--text); font-size: 11px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }

/* Waiting-for-the-model indicator + the shared spinner. */
.av-engineer-working { display: flex; align-items: center; gap: 8px; padding: 4px 6px; color: var(--muted); font-size: 12px; }
.av-engineer-spin { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: av-spin 0.7s linear infinite; }
@keyframes av-spin { to { transform: rotate(360deg); } }

.av-engineer-error { font-size: 12px; color: var(--danger-text); background: var(--danger-bg); border-top: 1px solid var(--danger-border); padding: 6px 10px; white-space: pre-wrap; max-height: 90px; overflow: auto; }

.av-engineer-scene { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-engineer-meta-left { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.av-engineer-profile { flex: none; font-size: 11px; color: var(--muted); white-space: nowrap; }
/* ask_user form: structured choices above the composer */
.av-engineer-form { margin: 6px 8px; padding: 8px 10px; background: var(--surface-inset); border: 1px solid var(--accent); border-radius: 6px; display: flex; flex-direction: column; gap: 8px; }
.av-engineer-form-title { font-size: 12px; font-weight: 600; color: var(--text); }
.av-engineer-form-field { display: flex; flex-direction: column; gap: 3px; }
.av-engineer-form-label { font-size: 11.5px; color: var(--muted); }
.av-engineer-form-opt { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); margin-right: 10px; cursor: pointer; }
.av-engineer-form-submit { align-self: flex-start; background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 4px; padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.av-engineer-form-submit:hover { filter: brightness(1.08); }
.av-engineer-composer { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); background: var(--surface-inset); }
.av-engineer-input { flex: 1 1 auto; resize: none; background: var(--surface-input); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: 13px system-ui, sans-serif; }
.av-engineer-input:focus { outline: none; border-color: var(--muted); }
.av-engineer-send { flex: none; width: 34px; align-self: stretch; background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 6px; font-size: 15px; font-weight: 700; cursor: pointer; }
.av-engineer-send:disabled { opacity: 0.4; cursor: default; }

/* Engineer panel — unconfigured state (links to the Settings screen). */
.av-engineer-unconfigured { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 20px 16px; }
.av-engineer-unconfigured p { margin: 0; color: var(--text); font-size: 13.5px; }
.av-engineer-unconfigured-sub { color: var(--muted) !important; font-size: 12.5px !important; line-height: 1.55; }
.av-engineer-cta { margin-top: 4px; background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 6px; padding: 8px 14px; font: 600 13px system-ui, sans-serif; cursor: pointer; }
.av-engineer-cta:hover { filter: brightness(1.08); }

/* --- Settings screen ------------------------------------------------------------------------------- */
.settings-screen { overflow-y: auto; }
/* Settings sub-pages switch via the shared horizontal .page-tabs (below the header) — no left rail. */
.settings-body { min-width: 0; }
.settings-intro { color: var(--text-muted); font-size: var(--text-sm); line-height: 1.6; margin: 0 0 var(--space-4); }
.settings-form { display: flex; flex-direction: column; gap: var(--space-4); }
.settings-caveat { font-size: var(--text-sm); color: var(--text-muted); line-height: 1.6; background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); margin: 0; }

/* Conversation management (Settings → Engineer) */
.settings-conversations { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-1); }
.settings-usage-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.settings-usage { font-size: var(--text-base); color: var(--text-muted); }
.settings-conv-list { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.settings-conv-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); background: var(--surface-inset); cursor: pointer; }
.settings-conv-row:hover { background: var(--control-bg); }
.settings-conv-row.active { background: var(--control-bg); }
.settings-conv-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: var(--text-base); }
.settings-conv-meta { flex: none; font-size: var(--text-xs); color: var(--text-muted); }
.settings-conv-actions { flex: none; display: flex; gap: var(--space-1); }

/* Model introspection: a text box until fetched, then a dropdown (+ a Fetch/Refresh button). */
.settings-model-control { display: flex; gap: 6px; align-items: stretch; }
.settings-model-slot { flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; }
.settings-model-slot > input, .settings-model-slot > select { flex: 1 1 auto; min-width: 0; }
.settings-model-slot > .btn { flex: none; white-space: nowrap; }
.settings-model-control > .btn { flex: none; white-space: nowrap; }
.settings-model-hint { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.4; }
.settings-model-hint.error { color: var(--danger-text); }

/* Project storage-health warning (private/incognito window can't persist a track). Amber, like the export warn. */
.project-storage-warn { display: flex; gap: var(--space-2); align-items: flex-start; margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3); background: var(--accent-wash); border: 1px solid var(--accent);
  border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--text); line-height: 1.4; }
.project-storage-warn-icon { flex: none; color: var(--accent); font-size: var(--text-md); line-height: 1.3; }

/* ── Tutorial overlay (first-run walkthrough) ─────────────────────────────────────────────────────────
   Over-viz chrome: this floats over ANY screen incl. the live Nodes/Preview canvas, so — like .preview-panel
   — it uses FIXED primitives + dark glass, never theme-flipping semantic roles (DESIGN.md "Over-viz chrome").
   Geometry (positions, the arrow path) is written inline by src/tutorial/overlay.ts; this is just the look. */
/* A FIXED over-viz colour for the line + arrow — a bright cyan, deliberately OFF the amber accent so the guide
   reads as distinct from the app's amber buttons/active states (and pops over any viz). Not theme-flipped. */
:root { --tutorial-arrow: #35d0e6; }
.tutorial-overlay { position: fixed; inset: 0; z-index: var(--z-modal); pointer-events: none; }

/* The curly dotted line + fat arrow — one full-viewport, click-through SVG. Drop shadows on both, per the brief.
   Amber (fixed --c-accent) so it reads over anything. `overflow: visible` lets the wavy path bleed to edges. */
/* Stacked filters to make the guide POP off any background (dark UI or a bright viz): a tight near-black edge
   that reads as an outline, then a soft offset shadow for depth. Applies to the line + arrowhead together. */
.tutorial-arrow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.8))
    drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6)); }
.tutorial-line { fill: none; stroke: var(--tutorial-arrow); stroke-width: 3px; stroke-linecap: round;
  stroke-dasharray: 9 8; } /* dashes (round caps soften the ends) tracing the curl */
.tutorial-arrowhead { fill: var(--tutorial-arrow); }

/* The toast: dark-glass panel (the sanctioned over-viz value — --c-neutral-2 @ .85, matching .preview-panel). */
/* Cyan-accented so the panel is unmistakably WALKTHROUGH chrome, not an app panel: a cyan hairline border + a
   soft cyan glow. Quit/Back stay neutral (below) — only the panel frame + the forward action carry the cyan, so
   the hierarchy stays readable rather than turning into a wall of cyan. */
.tutorial-toast { position: fixed; width: min(340px, calc(100vw - var(--space-8))); box-sizing: border-box;
  padding: var(--space-4) var(--space-5); background: rgba(20, 22, 26, 0.85); border: 1px solid var(--tutorial-arrow);
  border-radius: var(--radius-lg); backdrop-filter: blur(8px);
  box-shadow: var(--shadow-2), 0 0 26px -6px var(--tutorial-arrow); color: var(--c-text-hi); pointer-events: auto; }
/* Top line: counter (left) + narration controls (right). */
.tutorial-topline { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin-bottom: var(--space-2); }
.tutorial-counter { font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--tutorial-arrow); }
.tutorial-audio { display: flex; align-items: center; gap: var(--space-1); }
.tutorial-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  padding: 0; background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--c-text-mid); cursor: pointer; }
.tutorial-iconbtn:hover { color: var(--c-text-hi); background: var(--c-neutral-5); }
.tutorial-iconbtn:focus-visible { outline: 2px solid var(--tutorial-arrow); outline-offset: 1px; }
.tutorial-iconbtn svg { width: 15px; height: 15px; }
.tutorial-mute.is-muted { color: var(--tutorial-arrow); } /* muted → cyan, so the active state is obvious */
.tutorial-title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--c-text-hi);
  margin-bottom: var(--space-1); }
.tutorial-text { font-size: var(--text-sm); line-height: 1.5; color: var(--c-text-mid); margin: 0; }
.tutorial-controls { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }
.tutorial-controls-spacer { flex: 1 1 auto; }
/* The forward action is CYAN (not the app's amber primary) so the tour's CTA can't be mistaken for an app button.
   Set on :hover too, else .btn--primary:hover would win by specificity and flash it amber. */
.tutorial-next, .tutorial-next:hover { background: var(--tutorial-arrow); border-color: var(--tutorial-arrow);
  color: var(--c-neutral-0); }
.tutorial-next:hover { filter: brightness(1.08); }

/* ---- Rich picker: the reusable modal "browser" (search + list + preview) for choosing one item ------------- */
.rp-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(0, 0, 0, 0.5);
}
.rp-modal {
  display: flex;
  flex-direction: column;
  width: min(880px, 92vw);
  height: min(620px, 88vh);
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.rp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.rp-title { margin: 0; font-size: var(--text-lg); }
.rp-body { display: flex; flex: 1; min-height: 0; }
.rp-left { display: flex; flex-direction: column; width: 300px; min-height: 0; border-right: 1px solid var(--border); }
.rp-search { margin: var(--space-3); }
.rp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-3) var(--space-3) 0; }
.rp-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 0 var(--space-2) var(--space-2); }
.rp-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.rp-item:hover { background: var(--surface-inset); }
.rp-item.active { background: var(--accent-wash); }
.rp-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-item-del { flex: 0 0 auto; padding: 0 var(--space-1); color: var(--text-faint); cursor: pointer; opacity: 0; }
.rp-item:hover .rp-item-del, .rp-item.active .rp-item-del { opacity: 1; }
.rp-item-del:hover { color: var(--accent); }
.rp-group-head {
  padding: var(--space-3) var(--space-2) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.rp-group-head:first-child { padding-top: var(--space-1); }
.rp-thumb { flex: 0 0 auto; width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border); object-fit: cover; }
/* A custom row thumbnail (feature picker: a mini signal trace) — wider than a swatch. */
.rp-thumb-custom { width: 62px; height: 22px; border: 1px solid var(--border); background: var(--surface-inset); overflow: hidden; }
.rp-trace-mini { display: block; width: 100%; height: 100%; }
/* The full-size trace in the detail pane (matches the on-canvas node sparkline). */
.rp-trace-big { display: block; width: 100%; height: 120px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-inset); }
.rp-preview { flex: 1; min-width: 0; overflow-y: auto; padding: var(--space-4); }
.rp-preview-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 240px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-inset);
  overflow: hidden;
}
.rp-preview-media img { width: 100%; height: 100%; object-fit: cover; }
.rp-preview-media video { width: 100%; height: 100%; object-fit: contain; }
/* A live viz mini-render fills its media box; the canvas is sized in JS to the box. */
.rp-preview-live { position: relative; }
.rp-preview-live canvas { width: 100%; height: 100%; display: block; border-radius: var(--radius-lg); }
.rp-preview-title { margin: var(--space-3) 0 var(--space-2); font-size: var(--text-md); }
/* Editable variant of the preview title (the rename field). Reads as the title but is clearly a text input:
   a subtle inset field that firms up on hover/focus so it invites a click. */
.rp-preview-name-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-1) var(--space-2);
  color: var(--text);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
}
.rp-preview-name-input:hover { border-color: var(--border-strong); }
.rp-preview-name-input:focus { border-color: var(--accent); }
.rp-preview-name-input::placeholder { color: var(--text-muted); }
.rp-preview-desc { margin: 0; color: var(--text-muted); }

/* Node picker schematic — a colour-coded I/O port diagram + ranges + "Good for" note in the detail pane. */
.node-schematic { display: flex; flex-direction: column; gap: var(--space-3); }
.ns-diagram {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-inset);
}
.ns-col { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.ns-col-in { align-items: flex-start; }
.ns-col-out { align-items: flex-end; }
.ns-port {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  padding: 2px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-panel);
  font-size: var(--text-sm);
}
.ns-port-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ns-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; }
.ns-node {
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-panel);
  font-weight: 600;
  white-space: nowrap;
}
.ns-none { color: var(--text-faint); font-style: italic; font-size: var(--text-sm); }
.ns-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.ns-legend-item { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--text-muted); font-size: var(--text-sm); }
.ns-section-head { margin-bottom: var(--space-1); font-size: var(--text-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.ns-range { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); padding: 1px 0; }
.ns-range-name { color: var(--text-muted); }
.ns-range-val { font-variant-numeric: tabular-nums; }
.ns-use-text { margin: 0; color: var(--text-muted); }
.rp-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }
.rp-empty { padding: var(--space-3); }

/* The node "choose…" buttons (pick an asset / pick a visualisation) — open the rich picker; show the current
   swatch / name. Styled as an ACCENTED button (amber border + wash + a ▾) so it reads as clickable and clearly
   "opens a picker", not as a static input field. */
.av-asset-choose {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  max-width: 160px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-wash);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.12s ease, filter 0.12s ease;
}
.av-asset-choose:hover { background: var(--accent); color: var(--accent-contrast); }
/* A dropdown affordance pinned to the end (never shrinks); the label between it and any swatch ellipsises. */
.av-asset-choose::after { content: "▾"; flex: 0 0 auto; margin-left: auto; padding-left: var(--space-1); opacity: 0.8; }
.av-asset-choose-swatch { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.av-asset-choose-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Asset-node canvas thumbnail — a small preview of the picked image/video in the assetSource node body, so you
   can see what a source is at a glance on the graph. Full node width, cropped to a tidy strip. */
/* Fixed height (not max-height) so ALL asset types are the same size — a colour is a bare <div> with no intrinsic
   height, so it needs an explicit one; images/videos crop into the same box via object-fit. */
.av-asset-thumb { display: block; width: 100%; height: 72px; object-fit: cover; border-radius: var(--radius-1); border: 1px solid var(--border); background: var(--surface-2); }
