/* p5js live — performer theme.
 *
 * Dark, usable in low light, and readable at 1280x720. Nothing here draws diagnostics
 * into the canvas because the canvas is what the audience sees.
 */

:root {
  --bg: #0a0a0c;
  --panel: #111114;
  --panel-2: #16161b;
  --line: #26262e;
  --text: #d7d7de;
  --dim: #7c7c8a;
  --ok: #3ddc97;
  --warn: #f0b429;
  --bad: #ff5c6c;
  --accent: #7aa2f7;
  /* Projected-code palette: saturated enough to read as algorave, separated enough
   * that syntax remains legible rather than becoming a rainbow of equal emphasis. */
  --code-text: #f2efff;
  --code-comment: #aa91c7;
  --code-string: #c6ff4a;
  --code-number: #ff55d7;
  --code-keyword: #a783ff;
  --code-call: #24f5d0;
  --code-host: #ffe94a;
  --code-font-size: 15px;
  --code-line-height: 22px;
  --code-gutter-font-size: 12px;
  /* Hydra-like backing: just enough black behind each code line to hold the type
   * together over a bright frame, without becoming an editor panel. */
  --code-line-bg: rgba(0, 0, 0, calc(0.12 + var(--tools-alpha) * 0.26));
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  /* Performance palette (docs/PUSH3-DISPLAY-STYLE.md); mirrored on the Push screen and LEDs. */
  --pal-lime: #BFFB00; --pal-purple: #D86CE4; --pal-mint: #25FFA8; --pal-cyan: #10A4EE; --pal-blue: #5480E4;
  --pal-red: #FF3636; --pal-yellow: #FFF034; --pal-white: #FFFFFF; --pal-orange: #FFA529;
  --pal-mod: var(--pal-orange);

  /* How much of the visuals shows through the tools — the drawer's fill, and the box
   * behind each line of code. Driven live by the slider in the drawer, because the
   * right value depends entirely on what is playing: over a dark set you want it low
   * to see anything at all, over a bright one you want it high to read the code.
   * There is no single correct number. */
  --tools-alpha: 1;
}

/* The default keeps the original stage palette. Thunk Machine borrows the
 * marketing site's ink, paper, and orange without changing the canvas itself. */
:root[data-code-theme='thunk'] {
  --code-text: #faf7ef;
  --code-comment: #b9a99a;
  --code-string: #f7ca83;
  --code-number: #ff9674;
  --code-keyword: #ff6c45;
  --code-call: #ffd2b7;
  --code-host: #ffb169;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/e85e24e2-3b86-4b63-980d-f8a312e1c096.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/assets/fonts/5a6f9c30-3a63-487e-8fb0-a01d16a5ad2e.woff2') format('woff2');
}
@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('/assets/fonts/992a1c2c-f5a2-4570-ba6e-f1492c4c0acd.woff2') format('woff2');
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--mono);
  overflow: hidden;
}

button {
  font: inherit;
  font-size: 11px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
}
button:hover:not(:disabled) {
  border-color: var(--accent);
  color: #fff;
}
button:disabled {
  opacity: 0.3;
  cursor: default;
}
button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --- layout: the stage IS the window ------------------------------------------
 *
 * The canvas fills the viewport and the performer's tools float over it. This is not
 * only about size; it is about aspect ratio:
 * with the tools taking a column, the performer composed on a ~5:4 canvas while the
 * projector showed 16:9, so the thing being made was never the shape of the thing
 * being shown. Now it is, and the tools occlude a corner of it rather than reshaping
 * it — and they can be hidden outright.
 *
 * The tools are DOM over the canvas, so they cannot reach the projection window,
 * which copies pixels rather than markup, keeping performer chrome out of projection.
 */

#app {
  position: relative;
  height: 100vh;
  /* Drawers animate beyond the stage. Focusing one must not scroll the entire
   * instrument sideways; code and tool panels have their own scroll containers. */
  overflow: clip;
}

#stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}
#stage canvas {
  display: block;
}

/* A performer-only veil for the moments when a bright composition makes the code
 * hard to read. This is DOM chrome, not a patch: it stays out of the canvas and the
 * audience projection. Its DOM position and z-index put it above #stage and below
 * #code-layer. */
#visual-dimmer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.52);
}
#visual-dimmer[hidden] {
  display: none;
}

/* --- the code layer ------------------------------------------------------------
 *
 * The editor is not in a panel and not in a column: it is the whole window, edge to
 * edge, with the visuals running underneath it. Nothing between the code and the
 * thing the code is making.
 *
 * What makes that readable is the box behind each line rather than a wash over the
 * whole surface. A wash over an edge-to-edge editor is a wash over the entire frame —
 * it would dim the composition everywhere, including the four fifths of the window
 * with no text on it at all. Per-line boxes cost visibility only where there are
 * actually glyphs, so the composition stays untouched wherever the code is not.
 *
 * A textarea cannot draw them, so #code-mirror paints the text and its boxes and the
 * textarea sits transparently on top holding the caret, the selection, and the value.
 * The two have to keep identical font metrics, padding and box sizing or the caret
 * drifts off the glyphs — every shared property below is load-bearing.
 */

#code-layer {
  position: absolute;
  /* Above the canvas, below everything else: the start card, the glyph row and the
   * drawer all have to be able to sit on top of the code rather than under it. */
  z-index: 1;
  inset: 0;
  transition: opacity 160ms ease;
}
#code-layer.is-hidden {
  opacity: 0;
  pointer-events: none;
}

#folded-code {
  /* One coordinate system for both summary rows and expanded editors. The disclosure
   * column grows with the performer's code-size setting instead of staying at the
   * browser's tiny native-marker size. */
  --folded-gutter-width: 58px;
  --folded-marker-width: max(25px, calc(var(--code-font-size) * 0.85));
  --folded-code-column: calc(var(--folded-gutter-width) + var(--folded-marker-width));
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  overflow: auto;
  /* Preserve the top breathing room formerly occupied by the fold/unfold toolbar.
   * Those actions now live in the key-command sheet. */
  padding: 35px 12px 34px;
  scrollbar-width: none;
}
#folded-code::-webkit-scrollbar {
  display: none;
}
#code-layer.is-folded #folded-code {
  display: block;
}
#code-layer.is-folded #line-numbers,
#code-layer.is-folded #fold-controls,
#code-layer.is-folded #code-mirror,
#code-layer.is-folded #code {
  visibility: hidden;
  pointer-events: none;
}
#folded-blocks {
  width: 100%;
  overflow: visible;
  background: transparent;
  border-top: 0;
}
.folded-new-patch {
  position: relative;
  display: flex;
  align-items: center;
  height: 0;
  min-height: 0;
  padding: 0;
  overflow: visible;
}
button.folded-new-patch-button {
  position: absolute;
  /* The control belongs to the boundary before the following cell, but sits beside
   * that cell's existing summary line until it is opened. It therefore costs no
   * vertical space in the folded outline. */
  top: calc((var(--code-line-height) + 6px) / 2);
  left: calc((var(--folded-gutter-width) - 26px) / 2);
  z-index: 1;
  width: 26px;
  min-width: 26px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  color: rgba(205, 205, 214, 0.76);
  border-color: transparent;
  background: rgba(10, 10, 12, 0.22);
  font-size: max(15px, calc(var(--code-font-size) * 0.68));
  line-height: 1;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 100ms ease, color 100ms ease, background 100ms ease;
}
.folded-new-patch:hover button.folded-new-patch-button,
.folded-new-patch:has(+ .folded-block > summary:hover) button.folded-new-patch-button,
button.folded-new-patch-button:hover,
button.folded-new-patch-button:focus-visible {
  color: var(--accent);
  border-color: rgba(122, 162, 247, 0.6);
  background: rgba(10, 10, 12, calc(0.78 + var(--tools-alpha) * 0.15));
  opacity: 1;
}
button.folded-new-patch-button::after {
  content: 'New patch';
  position: absolute;
  top: 50%;
  left: calc(100% + 5px);
  padding: 2px 6px;
  color: var(--text);
  border: 1px solid rgba(122, 162, 247, 0.5);
  border-radius: 3px;
  background: rgba(10, 10, 12, 0.94);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-3px);
  transition: opacity 100ms ease, transform 100ms ease;
}
button.folded-new-patch-button:hover::after,
button.folded-new-patch-button:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.folded-new-patch.is-editing {
  height: auto;
  min-height: max(32px, calc(var(--code-line-height) + 8px));
  padding-left: var(--folded-code-column);
}
.folded-new-patch-form {
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 12px);
  padding: 3px 5px;
  border: 1px solid rgba(122, 162, 247, 0.55);
  border-radius: 4px;
  background: rgba(10, 10, 12, calc(0.86 + var(--tools-alpha) * 0.1));
}
.folded-new-patch-name {
  width: min(20ch, 45vw);
  min-width: 11ch;
  padding: 2px 6px;
  color: var(--code-text);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  font: inherit;
}
.folded-new-patch-name[aria-invalid='true'] {
  border-color: var(--bad);
}
.folded-new-patch-error {
  flex-basis: 100%;
  color: var(--bad);
  font-size: 11px;
}
.folded-new-patch-error:empty {
  display: none;
}
.folded-empty-project {
  display: grid;
  gap: 8px;
}
.folded-empty-project .folded-new-patch {
  min-height: 28px;
}
.folded-empty-project button.folded-new-patch-button {
  opacity: 0.8;
}
.folded-block {
  margin: 0;
  background: transparent;
}
.folded-block > summary {
  position: relative;
  min-height: calc(var(--code-line-height) + 6px);
  padding: 3px 10px 3px var(--folded-code-column);
  cursor: pointer;
  list-style: none;
  color: rgba(205, 205, 214, 0.86);
  font-family: var(--mono);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  white-space: pre;
}
.folded-block > summary::-webkit-details-marker {
  display: none;
}
.folded-block > summary::before {
  content: '▸';
  position: absolute;
  top: 50%;
  left: var(--folded-gutter-width);
  display: grid;
  place-items: center;
  width: var(--folded-marker-width);
  height: max(28px, var(--code-line-height));
  color: rgba(205, 205, 214, 0.8);
  border-radius: 3px;
  font-size: max(16px, calc(var(--code-font-size) * 0.72));
  line-height: 1;
  transform: translateY(-50%);
}
.folded-block[open] > summary::before {
  content: '▾';
}
.folded-block > summary:hover::before,
.folded-block > summary:focus-visible::before {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}
.folded-block > summary:hover,
.folded-block > summary:focus-visible,
.folded-block[open] > summary {
  background: transparent;
}
.folded-block > summary:focus-visible {
  outline: none;
  box-shadow: inset 2px 0 var(--accent);
}
.folded-line {
  color: rgba(150, 150, 160, 0.56);
  font-family: var(--mono);
  font-size: var(--code-gutter-font-size);
  line-height: var(--code-line-height);
  user-select: none;
}
.folded-block > summary > .folded-line {
  position: absolute;
  top: 3px;
  left: 0;
  /* A single inline number rounds one pixel wider than the multi-line <pre> gutter
   * in Chromium; compensate so their glyph right edges coincide exactly. */
  width: calc(var(--folded-gutter-width) - 1px);
  padding-right: 9px;
  text-align: right;
}
.folded-preview {
  display: inline-block;
  padding-right: 4px;
  color: var(--code-text);
  background: var(--code-line-bg);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
}
.folded-block > summary:hover .folded-preview,
.folded-block > summary:focus-visible .folded-preview,
.folded-block[open] > summary .folded-preview {
  background: rgba(0, 0, 0, calc(0.2 + var(--tools-alpha) * 0.3));
}
.folded-ellipsis {
  color: rgba(170, 170, 180, 0.58);
}
.folded-open {
  display: none;
}
.folded-block[open] .folded-closed {
  display: none;
}
.folded-block[open] > summary .folded-open {
  display: inline;
}
.folded-source {
  position: relative;
  padding: 0;
  margin: 0;
}
.folded-source-mirror,
.folded-source-editor {
  position: absolute;
  top: 0;
  right: 0;
  left: var(--folded-gutter-width);
  width: calc(100% - var(--folded-gutter-width));
  margin: 0;
  padding: 0 10px 0 calc(var(--folded-code-column) - var(--folded-gutter-width));
  border: 0;
  border-radius: 0;
  overflow: hidden;
  color: var(--code-text);
  background: transparent;
  font-family: var(--mono);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  text-align: left;
  white-space: pre;
  tab-size: 2;
}
.folded-source-mirror {
  pointer-events: none;
}
.folded-source-mirror > span {
  position: relative;
  display: block;
  width: fit-content;
  min-height: var(--code-line-height);
  background: var(--code-line-bg);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
}
.folded-source-mirror > span:not(:empty) {
  padding-right: 4px;
}
.folded-indent-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--guide-level) * 2ch);
  border-left: 1px solid rgba(160, 160, 172, 0.2);
  pointer-events: none;
}
.folded-source-editor {
  z-index: 1;
  resize: none;
  outline: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  caret-color: #fff;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.folded-source-editor::-webkit-scrollbar {
  display: none;
}
.folded-source-editor:focus-visible {
  /* The global textarea focus ring reads as a bright blue panel outline here.
   * The caret and the active-cell wash below provide the local focus cue. */
  outline: none;
}
.folded-source-editor::selection {
  background: rgba(122, 162, 247, 0.42);
  -webkit-text-fill-color: transparent;
}
.folded-source:focus-within {
  background: transparent;
  box-shadow: none;
}
.folded-source-numbers {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--folded-gutter-width);
  margin: 0;
  padding-right: 9px;
  overflow: hidden;
  color: rgba(150, 150, 160, 0.56);
  border-right: 1px solid rgba(122, 122, 134, 0.28);
  background: transparent;
  font-family: var(--mono);
  font-size: var(--code-gutter-font-size);
  line-height: var(--code-line-height);
  text-align: right;
  user-select: none;
  pointer-events: none;
}
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#code-mirror,
#code {
  position: absolute;
  inset: 0;
  margin: 0;
  border: none;
  padding: 10px 14px 26px 54px;
  /* An INTEGER line height, not 1.5 (which would be 22.5px). The textarea lays its
   * lines out internally and the mirror lays them out as blocks; a fractional advance
   * gives the two a chance to round differently, and that error accumulates down the
   * buffer — right at the top, a line out by the bottom. Keep this a whole number. */
  font-family: var(--mono);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  letter-spacing: normal;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  scrollbar-width: none;
}
#code-mirror::-webkit-scrollbar,
#code::-webkit-scrollbar,
#line-numbers::-webkit-scrollbar {
  display: none;
}

#line-numbers {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 45px;
  margin: 0;
  padding: 10px 8px 26px 0;
  overflow: hidden;
  color: rgba(170, 145, 199, 0.62);
  background: transparent;
  font-family: var(--mono);
  font-size: var(--code-gutter-font-size);
  line-height: var(--code-line-height);
  text-align: right;
  user-select: none;
  pointer-events: none;
  scrollbar-width: none;
}

#fold-controls {
  --fold-scroll-y: 0px;
  position: absolute;
  inset: 0 auto 0 43px;
  z-index: 3;
  width: 12px;
  overflow: hidden;
  pointer-events: none;
}
.raw-fold-control {
  position: absolute;
  top: calc(var(--fold-line-top) - var(--fold-scroll-y));
  left: 0;
  width: 12px;
  height: var(--code-line-height);
  padding: 0;
  border: 0;
  color: rgba(205, 205, 214, 0.72);
  background: transparent;
  font-family: var(--mono);
  font-size: 10px;
  line-height: var(--code-line-height);
  text-align: center;
  pointer-events: auto;
}
.raw-fold-control:hover,
.raw-fold-control:focus-visible {
  color: #fff;
  background: var(--code-line-bg);
}

#code-mirror {
  color: var(--code-text);
  background: none;
  pointer-events: none;
  overflow: hidden;
}
/* One block per line, each only as wide as its own text — which is what makes the
 * boxes hug the code the way Hydra does rather than forming a slab. An empty line
 * keeps the vertical rhythm through min-height and shows no box, having no width.
 * The backing is deliberately light and translucent: it follows the glyphs while the
 * composition remains visible everywhere else.
 *
 * padding-right only: any padding on the left would shift the text off the transparent
 * textarea's own layout and put the caret between the wrong characters. */
#code-mirror > span {
  display: block;
  width: fit-content;
  min-height: var(--code-line-height); /* must equal the editor line-height exactly */
  background: var(--code-line-bg);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
}
/* An empty line has nothing to sit behind, and must not show the trailing few pixels
 * as a stub — it keeps its height and no width at all. */
#code-mirror > span:not(:empty) {
  padding-right: 4px;
}
#code-mirror.flash-ok > span,
.folded-source-mirror.flash-ok > span {
  background: rgba(45, 116, 70, 0.5);
}
#code-mirror.flash-bad > span,
.folded-source-mirror.flash-bad > span {
  background: rgba(138, 45, 57, 0.55);
}
.ai-changed-line,
#code-mirror > span.ai-changed-line,
.folded-source-mirror > span.ai-changed-line {
  background: rgba(46, 107, 143, 0.68);
  box-shadow: inset 3px 0 0 #24f5d0;
}
.folded-block.ai-staged-block > summary .folded-preview {
  background: rgba(46, 107, 143, 0.68);
  box-shadow: inset 3px 0 0 #24f5d0;
}
#code-layer.is-ai-staged #code,
#code-layer.is-ai-staged .folded-source-editor {
  cursor: default;
}
.folded-block.flash-bad > summary .folded-preview,
.folded-block.flash-bad .folded-source-mirror > span {
  background: rgba(138, 45, 57, 0.55);
}

/* Token colours (src/ui/highlight.js).
 *
 * Anything not listed keeps the body colour — punctuation, whitespace and ordinary
 * names are most of a file, and colouring them too is what turns a highlighter into
 * confetti. The four that earn a colour are the four you scan for: what is prose
 * (comment), what is a literal (string, number), and what is being called. */
.t-comment {
  color: var(--code-comment);
}
.t-string {
  color: var(--code-string);
}
.t-number {
  color: var(--code-number);
}
.t-keyword {
  color: var(--code-keyword);
}
.t-call {
  color: var(--code-call);
}
/* The small command vocabulary around otherwise ordinary JavaScript objects. */
.t-host {
  color: var(--code-host);
  font-weight: 700;
}

#code {
  z-index: 2;
  resize: none;
  /* Transparent text: the glyphs you read are the mirror's, underneath. The caret and
   * the selection are the textarea's, which is why it is the one on top. */
  color: transparent;
  caret-color: #fff;
  background: none;
}
#code::selection {
  background: rgba(122, 162, 247, 0.4);
}
#code::placeholder {
  color: var(--dim);
}

.right-drawer {
  /* Drawer-local contrast tokens. The global dim colour is deliberately subtle over
   * the dark stage, but disappears when a white patch is visible through this panel. */
  --text: #f6f5fa;
  --dim: #c7c7d2;
  --line: rgba(218, 218, 230, 0.24);
  --panel-2: #15151b;
  position: absolute;
  /* Keep the performance controls as a fixed landmark. Drawers begin underneath
   * their 24px row plus its top and bottom breathing room. */
  right: 0;
  bottom: 0;
  z-index: 5;
  width: 400px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  color: var(--text);
  /* Transparent enough to actually see through, including over dark visuals — which
   * is the hard case, since near-black panel over near-black canvas reads as solid
   * however low the alpha goes.
   *
   * The blur is deliberately light. A heavy blur smears the shapes behind into a
   * uniform smudge, which defeats the point: you stop seeing your composition and
   * start seeing fog. Legibility comes from the text shadow instead, which costs
   * nothing in visibility. */
  background: rgba(17, 17, 20, var(--tools-alpha));
  /* Brightness adapts with panel opacity: a very transparent drawer darkens the
   * canvas behind it more, while an opaque drawer needs almost no backdrop help. */
  -webkit-backdrop-filter:
    blur(7px)
    saturate(0.8)
    brightness(calc(0.42 + var(--tools-alpha) * 0.47));
  backdrop-filter:
    blur(7px)
    saturate(0.8)
    brightness(calc(0.42 + var(--tools-alpha) * 0.47));
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.98), 0 0 2px rgba(0, 0, 0, 0.88);
  transition: transform 160ms ease;
}
.right-drawer.is-hidden {
  transform: translateX(100%);
  pointer-events: none;
}

#reference-side {
  width: 350px;
}
.reference-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.reference-header .brand {
  flex: 1;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.reference-explainer {
  padding: 8px 10px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  background: rgba(15, 15, 19, 0.46);
  font-size: 10px;
  line-height: 1.45;
}
#reference-close {
  border: none;
  background: none;
  color: var(--dim);
  font-size: 16px;
}
#strategy-reference-list {
  min-height: 0;
  padding: 6px 10px 12px;
  overflow: auto;
}

/* --- the glyph row -------------------------------------------------------------
 *
 * The entire always-visible chrome: a few unlabelled glyphs in the corner the code
 * does not start in. No borders and no fills — a button that is only a glyph
 * disappears into the visuals until you look for it, and every one of them is also a
 * key command, so the row is a reminder rather than how you actually work mid-set.
 */

#icons {
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 6;
  display: flex;
  gap: 2px;
  align-items: center;
  transition: opacity 160ms ease;
}
#icons[hidden] {
  display: none;
}
#app:has(> #icons[hidden]) > #side {
  top: 0;
}

#audio-transport {
  display: flex;
  /* Let keyboard focus outlines extend past the transport's border. */
  margin-right: 4px;
  background: rgba(10, 10, 13, 0.72);
  border: 1px solid rgba(124, 124, 138, 0.42);
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
}
button.transport-control {
  min-width: 62px;
  height: 24px;
  padding: 0 7px;
  color: rgba(225, 225, 233, 0.82);
  background: none;
  border: 0;
  border-right: 1px solid rgba(124, 124, 138, 0.28);
  border-radius: 0;
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
}
button.transport-control:last-child {
  border-right: 0;
}
button.transport-control:hover:not(:disabled) {
  color: #fff;
  background: rgba(122, 162, 247, 0.16);
}
button.transport-control.is-on {
  color: var(--ok);
  background: rgba(61, 220, 151, 0.1);
}
button.transport-control:disabled {
  color: rgba(124, 124, 138, 0.38);
}
button.glyph {
  padding: 0 4px;
  font-size: 13px;
  line-height: 1;
  background: none;
  border: none;
  border-radius: 3px;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
button.glyph:hover:not(:disabled) {
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
}
button.glyph.is-on {
  color: var(--ok);
}
button.glyph.danger:hover:not(:disabled) {
  background: rgba(90, 42, 48, 0.6);
  color: #fff;
}

@media (max-width: 900px) {
  .right-drawer,
  #reference-side {
    width: 300px;
  }
  #code-layer {
    width: 60vw;
  }
}

/* --- transport --------------------------------------------------------------- */

#stagebar .brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-right: auto;
}
#file-label {
  cursor: pointer;
}
#audio-file {
  display: none;
}

.start-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- performance controls ------------------------------------------------------ */

#stagebar {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 40px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(22, 22, 27, var(--tools-alpha));
}
.stagebar-control {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--dim);
}
.stagebar-control select {
  min-width: 118px;
}
button.danger {
  border-color: #5a2a30;
  color: #ffb3bb;
}
button.danger:hover:not(:disabled) {
  background: #3a1a20;
  border-color: var(--bad);
  color: #fff;
}
button.is-on {
  border-color: var(--ok);
  color: var(--ok);
}

select,
input[type='number'] {
  font: inherit;
  font-size: 11px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 4px;
  max-width: 160px;
}
input[type='number'] {
  width: 64px;
}

/* --- trusted-code confirmation ------------------------------------------------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 4, 6, 0.8);
  padding: 24px;
}
.dialog-backdrop[hidden] {
  display: none;
}
.dialog {
  width: min(560px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 20px;
}
.dialog h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--text);
}
.dialog p {
  margin: 0 0 10px;
  color: var(--dim);
  line-height: 1.5;
}
.dialog .dialog-warning {
  color: var(--warn);
  border-left: 2px solid var(--warn);
  padding-left: 10px;
}
.dialog .dialog-preview {
  max-height: 30vh;
  overflow: auto;
  margin: 0 0 12px;
  padding: 8px 10px;
  background: #0d0d10;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 11px;
  white-space: pre-wrap;
  color: var(--text);
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.dialog-actions button {
  padding: 6px 14px;
}
.dialog-confirm {
  border-color: var(--warn);
  color: var(--warn);
}
.export-mode,
.export-asset-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  color: var(--text);
}
.export-assets {
  max-height: 30vh;
  overflow: auto;
  border-block: 1px solid var(--line);
  margin: 10px 0;
}
.export-asset-row small {
  margin-left: auto;
  color: var(--dim);
  white-space: nowrap;
}
.export-size { font-variant-numeric: tabular-nums; }
.project-assets { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.project-assets h3 { font-size: 13px; margin: 0 0 6px; }
.asset-attach-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.asset-attach-form input[type='text'] { min-width: 100px; flex: 1 1 110px; }
.asset-attach-form input[type='file'] { min-width: 150px; flex: 2 1 170px; }
.asset-list .row { gap: 8px; }
.asset-list .name { overflow-wrap: anywhere; }
.asset-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line); }
.asset-row span { min-width: 0; overflow-wrap: anywhere; }
.asset-row.is-missing span { color: var(--warn); }

/* --- editor ------------------------------------------------------------------ */

/* Opposite corner from the runtime bar, so the two never collide. */
#editor-hint {
  position: absolute;
  right: 12px;
  z-index: 4;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  pointer-events: none;
}
#reference-side:not(.is-hidden) ~ #editor-hint {
  right: 362px;
}

/* --- tool workspaces --------------------------------------------------------- */

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 12, 15, calc(var(--tools-alpha) * 0.72));
}
#side .tool-tabs button {
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  color: var(--dim);
  background: transparent;
  font-size: 10px;
}
.tool-tabs button:last-child {
  border-right: 0;
}
.tool-tabs button:hover:not(:disabled) {
  color: var(--text);
  background: rgba(197, 165, 222, 0.055);
}
.tool-tabs button[aria-selected='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: rgba(197, 165, 222, 0.09);
}
.tool-tabs button:focus-visible {
  position: relative;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  margin-left: 2px;
  padding: 0 4px;
  border-radius: 8px;
  color: var(--text);
  background: rgba(197, 165, 222, 0.15);
  font-size: 9px;
  letter-spacing: 0;
}
.tab-count[hidden] {
  display: none;
}

#panels {
  flex: 1 1 54%;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.tool-view {
  min-height: 100%;
}
.tool-view[hidden] {
  display: none;
}
.tool-view > .body {
  padding: 8px 10px 12px;
}
.tool-section {
  border-bottom: 1px solid var(--line);
}
.tool-section > h2 {
  margin: 0;
  min-height: 34px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.tool-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 10px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.tool-section-heading h2 {
  flex: 1;
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tool-section-heading button {
  padding-inline: 8px;
  color: var(--accent);
}
.tool-section > .body {
  padding: 4px 10px 10px;
}
.library-group > summary:focus-visible,
.compact-settings > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.summary-count {
  float: right;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.compact-settings {
  margin-top: 5px;
  border-top: 1px solid #1b1b21;
}
.compact-settings > summary {
  min-height: 30px;
  padding: 7px 0 4px;
  color: var(--dim);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.compact-settings[open] > summary {
  color: var(--text);
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #1b1b21;
}
.row:last-child {
  border-bottom: none;
}
.row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .version {
  color: var(--dim);
  font-size: 11px;
}
.row .actions {
  display: flex;
  gap: 4px;
}
.row-error {
  width: 100%;
  color: var(--bad);
  font-size: 11px;
  padding-bottom: 3px;
  white-space: pre-wrap;
  word-break: break-word;
}
.audio-load-state {
  display: grid;
  grid-template-columns: max-content minmax(70px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  color: var(--call);
  font-size: 10px;
}
.audio-load-state[hidden] {
  display: none;
}
.audio-load-state progress {
  width: 100%;
  height: 5px;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  background: #1b1b21;
  border: 0;
  border-radius: 999px;
}

.network-example {
  overflow-x: auto;
  margin: 8px 0;
  padding: 8px;
  color: var(--text);
  background: rgba(10, 10, 13, 0.7);
  border: 1px solid var(--line);
  font: inherit;
  font-size: 10px;
  line-height: 1.45;
  white-space: pre;
}

.beta-badge {
  margin-left: 0.35em;
  color: var(--warn);
  font-size: 0.7em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.network-beta-note {
  color: var(--warn);
}

/* --- AI source editor -------------------------------------------------------- */

.ai-settings .hint a {
  color: var(--accent);
}
.ai-key-field {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ai-key-field input {
  width: 100%;
  min-height: 30px;
  padding: 5px 7px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  font: 12px/1.4 var(--mono);
  letter-spacing: normal;
  text-transform: none;
}
.ai-remember-row {
  margin-top: 5px;
}
.ai-settings-actions {
  display: flex;
  gap: 6px;
  margin: 8px 0 4px;
}
#ai-key-status[data-ready='true'] {
  color: var(--ok);
}
button.ai-open-button {
  width: 100%;
  min-height: 32px;
  margin: 10px 0 4px;
  color: var(--accent);
}

.ai-assistant {
  position: absolute;
  left: 50%;
  bottom: 42px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 84px));
  overflow: hidden;
  color: #f6f5fa;
  border: 1px solid rgba(122, 162, 247, 0.58);
  border-radius: 10px;
  background: rgba(13, 13, 18, 0.94);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(12px) saturate(0.85);
  backdrop-filter: blur(12px) saturate(0.85);
  transform: translateX(-50%);
}
.ai-assistant[hidden] {
  display: none;
}
#side:not(.is-hidden) ~ .ai-assistant {
  left: auto;
  width: min(720px, calc(100vw - 440px));
  transform: none;
}
#reference-side:not(.is-hidden) ~ .ai-assistant {
  right: 366px;
  left: auto;
  width: min(720px, calc(100vw - 390px));
  transform: none;
}
.ai-assistant-header,
.ai-assistant-footer,
.ai-stage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-assistant-header {
  min-height: 40px;
  padding: 7px 10px 7px 14px;
  border-bottom: 1px solid var(--line);
}
.ai-assistant-header > div {
  flex: 1;
}
.ai-assistant-header strong {
  font-size: 12px;
  letter-spacing: 0.04em;
}
#ai-close {
  width: 28px;
  height: 26px;
  border: 0;
  background: transparent;
  font-size: 17px;
}
.ai-conversation {
  min-height: 92px;
  max-height: 280px;
  overflow: auto;
  padding: 10px 12px 2px;
}
.ai-message {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 9px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.45;
}
.ai-message-role {
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ai-message.is-user > div {
  color: #fff;
}
.ai-message.is-error > div,
.ai-message.is-error .ai-message-role {
  color: var(--bad);
}
.ai-stage-actions {
  flex-wrap: wrap;
  padding: 7px 10px;
  color: var(--ok);
  border-top: 1px solid rgba(61, 220, 151, 0.25);
  border-bottom: 1px solid rgba(61, 220, 151, 0.25);
  background: rgba(61, 220, 151, 0.07);
  font-size: 10px;
}
.ai-stage-actions[hidden] {
  display: none;
}
.ai-stage-actions > span {
  flex: 1;
  min-width: 170px;
}
.ai-stage-actions button.primary {
  color: #07120e;
  border-color: var(--ok);
  background: var(--ok);
}
.ai-stage-actions kbd {
  margin-left: 4px;
  color: inherit;
  opacity: 0.68;
  font-size: 8px;
}
.ai-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  padding: 10px 10px 5px;
}
.ai-composer textarea {
  grid-row: 1 / 3;
  min-height: 48px;
  max-height: 160px;
  resize: none;
  padding: 9px 10px;
  color: var(--text);
  border: 1px solid rgba(218, 218, 230, 0.28);
  border-radius: 7px;
  outline: none;
  background: rgba(5, 5, 8, 0.78);
  font: 12px/1.45 var(--mono);
}
.ai-composer textarea:focus {
  border-color: var(--accent);
}
.ai-composer button {
  width: 58px;
  min-height: 30px;
}
.ai-assistant-footer {
  flex-wrap: wrap;
  padding: 2px 11px 8px;
  color: var(--dim);
  font-size: 9px;
}
#ai-status {
  flex: 1;
  min-width: 180px;
}
#ai-configure {
  min-height: 24px;
  color: var(--accent);
}
@media (max-width: 900px) {
  #side:not(.is-hidden) ~ .ai-assistant,
  #reference-side:not(.is-hidden) ~ .ai-assistant {
    right: 312px;
    width: calc(100vw - 328px);
  }
  .ai-stage-actions kbd {
    display: none;
  }
}
.network-join-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin: 8px 0;
}
.network-join-form input,
.network-join-form button {
  min-width: 0;
}
.network-join-form input[type='password'],
.network-join-form button {
  grid-column: 1 / -1;
}
.network-room {
  margin-top: 8px;
  color: var(--accent);
  border-bottom-color: var(--line);
}
.network-stream,
.network-publication {
  padding-left: 8px;
}
.network-online,
.network-joined {
  color: var(--ok);
}
.network-connecting,
.network-reconnecting {
  color: var(--warn);
}
.network-unsupported,
.network-error {
  color: var(--bad);
}
.audio-load-state progress::-webkit-progress-bar {
  background: #1b1b21;
}
.audio-load-state progress::-webkit-progress-value {
  background: var(--call);
}
.audio-load-state progress::-moz-progress-bar {
  background: var(--call);
}
#load-audio.is-loading {
  color: var(--call);
  animation: audio-load-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes audio-load-pulse {
  to {
    opacity: 0.38;
  }
}
.strategy.is-idle .name {
  color: var(--dim);
}
.filter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 5px 0 7px;
}
.filter-tabs button {
  min-width: 0;
  padding: 4px 5px;
  color: var(--dim);
  border-color: var(--line);
  background: rgba(16, 16, 20, 0.55);
  font-size: 10px;
}
.filter-tabs button[aria-pressed='true'] {
  color: var(--text);
  border-color: rgba(197, 165, 222, 0.5);
  background: rgba(197, 165, 222, 0.1);
}
.filter-tabs button span {
  color: inherit;
  opacity: 0.7;
}
.patch-status {
  flex: none;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.03em;
  line-height: 1.35;
  text-transform: uppercase;
}
.patch-status.installed {
  color: var(--code-comment);
  border-color: rgba(190, 155, 220, 0.25);
}
.patch-status.active {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
.patch-status.running {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
}
.patch-status.failed {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}
.strategy .actions button:not(.icon) {
  padding: 3px 7px;
  white-space: nowrap;
  font-size: 10px;
}
.param input[type='range'] {
  width: 120px;
}

.controller-setup {
  border-bottom: 1px solid var(--line);
}

.controller-status-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.new-param-form {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--accent);
  background: rgb(11 10 16 / 88%);
}

.new-param-form > label,
.new-param-number-grid label,
.new-param-kind-fields label {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.new-param-form input,
.new-param-form select {
  width: 100%;
  box-sizing: border-box;
}

.new-param-form > label + label {
  margin-top: 9px;
}

.new-param-number-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 9px 0;
}

.new-param-kind-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 9px 0;
}

.new-param-number-grid[hidden],
.new-param-kind-fields[hidden] {
  display: none;
}

.new-param-checkbox {
  align-content: center;
  grid-template-columns: auto 1fr !important;
  justify-content: start;
}

.new-param-checkbox input {
  width: auto;
}

.param-control-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) auto minmax(7rem, 1.4fr) auto;
  gap: 7px;
  align-items: center;
}

.param-control-row .mapping {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82em;
}

.param-button {
  min-width: 7rem;
}

.param-button.is-on {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 55%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.param-control-row select {
  min-width: 7rem;
  max-width: 11rem;
}

.param-empty {
  display: grid;
  gap: 8px;
  padding: 12px 0;
}

.copies {
  color: var(--accent);
  font-size: 11px;
}

/* Installed strategies are a read-only object browser. The summary remains as compact
 * as the old shelf row; opening it reveals only a data projection, never the live
 * authored patch object itself. */
.strategy-reference {
  border-bottom: 1px solid #1b1b21;
}
.strategy-reference:last-child {
  border-bottom: none;
}
.strategy-reference > summary {
  list-style: none;
  cursor: pointer;
}
.strategy-reference > summary::-webkit-details-marker {
  display: none;
}
.strategy-reference > summary::before {
  content: '›';
  width: 8px;
  color: var(--dim);
  transform-origin: center;
  transition: transform 100ms ease;
}
.strategy-reference[open] > summary::before {
  transform: rotate(90deg);
  color: var(--accent);
}
.strategy-reference > .row-error {
  padding-left: 16px;
}
.strategy-api {
  margin: 1px 0 7px 16px;
  padding: 5px 7px 7px;
  border-left: 1px solid var(--line);
  color: var(--dim);
  font-size: 10px;
}
.strategy-kind {
  margin-bottom: 5px;
  color: var(--text);
}
.strategy-api-section + .strategy-api-section {
  margin-top: 5px;
}
.strategy-api-label {
  margin-bottom: 2px;
  color: var(--dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.strategy-api code {
  display: block;
  overflow: hidden;
  color: var(--code-call);
  font: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.strategy-api-properties code {
  color: var(--code-number);
}

/* Lifecycle filters and content groups are independent: a patch keeps its category
 * while moving from Available to Installed to Active. */
.library-group + .library-group {
  margin-top: 5px;
}
.library-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  min-height: 31px;
  padding: 7px 2px 5px;
  border-bottom: 1px solid rgba(197, 165, 222, 0.2);
  color: var(--code-comment);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.library-group-heading > span:first-child {
  flex: 1;
}
.library-group-heading > span:last-child {
  color: var(--dim);
  font-weight: 400;
}
.library-group[open] .library-group-heading {
  color: var(--text);
}
.library-group > .row {
  padding-left: 12px;
}
.shader-operator-reference {
  margin-top: 10px;
  border-top: 1px solid var(--line);
}
.shader-operator-reference > summary {
  padding: 7px 1px 4px;
  color: var(--code-keyword);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.shader-operator-body {
  padding: 2px 1px 5px;
  color: var(--dim);
  font-size: 10px;
  line-height: 1.55;
}
.shader-operator-body p {
  margin: 4px 0;
}
.shader-operator-body div + div {
  margin-top: 4px;
}
.shader-operator-body strong {
  display: block;
  color: var(--text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.shader-operator-body code {
  display: inline-block;
  margin: 1px 2px 1px 0;
  padding: 0 3px;
  border: 1px solid rgba(197, 165, 222, 0.16);
  color: var(--code-call);
  font: inherit;
}
.strategy.is-available .name {
  color: var(--dim);
}
.library-origin {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-origin.community {
  color: var(--code-comment);
}

/* Glyph buttons: square, so a row of them lines up and stays hittable in a dark room. */
button.icon {
  min-width: 22px;
  padding: 2px 0;
  font-size: 13px;
  line-height: 1.1;
  text-align: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
}
.dot.ok {
  background: var(--ok);
}
.dot.bad {
  background: var(--bad);
}
.dot.idle {
  background: #3a3a44;
}

.hint {
  color: var(--dim);
  font-size: 11px;
  padding: 4px 0;
}
.diagnostic.error .name {
  color: var(--bad);
}
.diagnostic.warn .name {
  color: var(--warn);
}
.diagnostic.success .name {
  color: var(--ok);
}

/* --- monitors ---------------------------------------------------------------- */

/* Bottom-left, outside the drawer and outside the code layer. Whether it is still
 * running, and what it last said, are the two things that must never be behind a
 * toggle — so this is the one piece of chrome with no way to hide it. */
#runtime-bar {
  position: absolute;
  left: 12px;
  bottom: 8px;
  z-index: 4;
  display: flex;
  align-items: center;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
#runtime-bar .label {
  color: rgba(124, 124, 138, 0.8);
}
#runtime-bar .value {
  color: rgba(215, 215, 222, 0.75);
}
#runtime-bar .value.warn {
  color: var(--warn);
}
#runtime-bar .value.error {
  color: var(--bad);
}
#runtime-bar .value.success {
  color: var(--ok);
}
#stat-status {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Performer orientation and evaluation feedback stay outside the rendered canvas. */
#icons {
  padding: 3px;
  border: 1px solid rgba(200, 200, 225, 0.2);
}
button.glyph { height: 28px; min-width: 28px; color: #dddde8; }
button.glyph.labeled-control { font-size: 11px; padding: 0 8px; }
button.glyph.danger { color: #ffb3bb; }
.right-drawer { top: 46px; }
#folded-code { padding-top: 52px; padding-bottom: 62px; }
#current-cell-bar {
  position: absolute;
  top: 47px;
  left: 54px;
  right: 18px;
  z-index: 4;
  display: flex;
  gap: 12px;
  align-items: center;
  width: fit-content;
  max-width: calc(100% - 72px);
  padding: 4px 8px;
  color: #eeeef6;
  background: rgba(12, 12, 18, 0.94);
  font-size: 12px;
}
#code-layer.is-folded #current-cell-bar { display: none; }
#code, #code-mirror, #line-numbers, #fold-controls { top: 84px; }
#code, #code-mirror, #line-numbers { padding-bottom: 62px; }
.cell-status {
  margin-left: 12px;
  font: 11px/1.4 var(--mono);
  color: #b7c8eb;
  white-space: nowrap;
}
.folded-delete {
  margin-left: 12px;
  padding: 3px 8px;
  border: 1px solid #575763;
  border-radius: 4px;
  background: #202027;
  color: #d4d4dd;
  font: 11px/1.4 var(--mono);
  cursor: pointer;
  vertical-align: middle;
}
.folded-delete {
  opacity: 0;
  pointer-events: none;
  border-color: transparent;
  background: transparent;
  color: #aaaab8;
}
.folded-block > summary:hover .folded-delete,
.folded-block > summary:focus-within .folded-delete {
  opacity: 1;
  pointer-events: auto;
}
@media (hover: none) {
  .folded-delete { opacity: 1; pointer-events: auto; }
}
.folded-delete:hover { color: #ffb3bb; }
.folded-delete:focus-visible { outline: 2px solid #a8bfff; outline-offset: 2px; }
.cell-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-left: var(--folded-code-column);
  padding: 3px 8px 5px 0;
  max-width: min(780px, calc(100% - var(--folded-code-column)));
}
.folded-block:not([open]) .cell-actions { display: none; }
.folded-block[open] > summary {
  position: sticky;
  top: 0;
  z-index: 4;
  width: fit-content;
  max-width: 100%;
  background: rgba(12, 12, 18, 0.96);
}
.folded-block[open] > .cell-actions {
  position: sticky;
  top: calc(6px + var(--code-line-height));
  z-index: 4;
  width: fit-content;
  background: rgba(12, 12, 18, 0.96);
}
.cell-feedback {
  font: 11px/1.5 var(--mono);
  color: #c8c8d5;
  padding: 2px 5px;
  background: rgba(12, 12, 18, 0.9);
  overflow-wrap: anywhere;
}
.cell-feedback:empty { display: none; }
[data-evaluation-state="error"] .cell-feedback { color: #ffb3bb; }
[data-evaluation-state="success"] .cell-feedback { color: #8de5b5; }
[data-evaluation-state="warning"] .cell-feedback { color: #eac58b; }
[data-evaluation-state="edited"] .cell-status { color: #eac58b; }
#runtime-bar {
  max-width: calc(100% - 24px);
  gap: 14px;
  min-height: 32px;
  padding: 3px 10px 3px 4px;
  border: 1px solid rgba(200, 200, 225, 0.2);
  background: rgba(12, 12, 18, 0.94);
  color: #dddde8;
  font-size: 11px;
}
#live-scene { display: flex; align-items: center; gap: 8px; min-height: 28px; border: 0; background: transparent; }
#live-scene-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-label { color: #8de5b5; font-size: 10px; letter-spacing: 0.08em; }
#live-safe-status { color: #b7c8bb; }
.runtime-details { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.library-scope { margin: 0; padding: 8px 0; }
#first-edit-hint {
  position: absolute;
  z-index: 5;
  bottom: 53px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(720px, calc(100% - 36px));
  padding: 12px;
  border: 1px solid #7970a6;
  border-radius: 5px;
  background: #191624;
  color: #e8e4f4;
  font-size: 12px;
}
#first-edit-hint[hidden] { display: none; }
#first-edit-hint button { flex-shrink: 0; min-height: 28px; }
#editor-hint { bottom: 8px; font-size: 11px; color: #c8c8d5; }
@media (max-width: 900px) {
  #icons { left: 10px; right: 10px; flex-wrap: wrap; justify-content: flex-end; }
  #folded-code { padding-top: 90px; }
  #current-cell-bar { top: 90px; }
  #code, #code-mirror, #line-numbers, #fold-controls { top: 128px; }
  .right-drawer { top: 90px; max-width: calc(100% - 20px); }
  #first-edit-hint { flex-wrap: wrap; }
}

/* Audio visualizers are patches now, so the reading lives on the stage rather than in
 * a panel that has to be open. What remains here is input configuration and onset. */
#onset-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2a2a33;
  vertical-align: middle;
}
#onset-dot.lit {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

/* --- start overlay ------------------------------------------------------------ */

#robot-easter-egg {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
}
#robot-easter-egg[hidden] {
  display: none;
}
#robot-easter-egg-video {
  display: block;
  width: 64vmin;
  height: 64vmin;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  object-fit: contain;
  background: #000;
}

#start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 7, 0.7);
  -webkit-backdrop-filter: blur(5px) saturate(0.7);
  backdrop-filter: blur(5px) saturate(0.7);
  padding: 24px;
  z-index: 7;
  overflow: auto;
}
.welcome-card {
  position: relative;
  width: min(600px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  color: #1a1a1a;
  background: #faf7ef;
  border: 1px solid rgba(226, 226, 223, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.54);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.welcome-hero {
  padding: 40px 40px 24px;
  background: #faf7ef;
}
#start-overlay .welcome-hero h1 {
  margin: 0 0 12px;
  color: #1a1a1a;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(48px, 8vw, 68px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.01em;
}
#start-overlay .welcome-hero .welcome-eyebrow {
  margin: 0 0 20px;
  color: #b53816;
  font-family: 'IBM Plex Mono', var(--mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.08em;
}
#start-overlay .welcome-hero .welcome-tagline {
  max-width: 480px;
  margin: 0;
  color: #b53816;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
}
.welcome-body {
  padding: 0 40px 30px;
  background: #faf7ef;
}
#start-overlay .welcome-intro {
  margin: 0;
  color: #1a1a1a;
  max-width: 60ch;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.55;
}
#start-overlay .welcome-credit {
  margin: 14px 0 0;
  color: #6b6b68;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
}
#start-overlay .welcome-credit a {
  color: #b53816;
  text-decoration-color: rgba(31, 107, 99, 0.42);
  text-underline-offset: 0.16em;
}
#start-overlay .welcome-credit a:hover {
  color: #8d2b10;
  text-decoration-color: currentColor;
}
#start-overlay .welcome-build {
  margin: 8px 0 0;
  color: #77746e;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  text-align: right;
}
.welcome-recent { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; padding: 0 40px 24px; background: #faf7ef; }
@media (max-width: 560px) { .welcome-recent { grid-template-columns: 1fr; } }
#start-overlay .welcome-recent h2 { margin: 0 0 8px; font-family: 'Space Grotesk', sans-serif; font-size: 14px; font-weight: 700; color: #1a1a1a; }
.welcome-recent-list { display: flex; flex-direction: column; gap: 4px; }
#start-overlay .welcome-recent-list button { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; width: 100%; padding: 6px 8px; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 6px; color: #b53816; font: inherit; font-size: 14px; }
#start-overlay .welcome-recent-list button:hover { background: #f1ece1; border-color: #e2e2df; }
#start-overlay .welcome-recent-list button.is-current { border-color: #b53816; }
#start-overlay .welcome-recent-list img { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; background: #111; }
#start-overlay .welcome-recent-list .welcome-recent-glyph { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 4px; background: #eceeeb; color: #4a4a47; font-size: 16px; }
#start-overlay .welcome-recent-list .welcome-recent-copy { min-width: 0; display: flex; flex-direction: column; }
#start-overlay .welcome-recent-list .welcome-recent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#start-overlay .welcome-recent-list .welcome-recent-meta { color: #6b6b68; font-size: 12px; }
#start-overlay .welcome-recent-list .welcome-recent-empty { color: #8a8a86; font-size: 13px; padding: 4px 8px; }
.welcome-start {
  padding: 24px 40px 28px;
  border-top: 1px solid #e2e2df;
  background: #f1ece1;
}
#start-overlay .welcome-start-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 14px;
}
#start-overlay .welcome-start-copy h2 {
  margin: 0;
  color: #1a1a1a;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}
#start-overlay .welcome-start-copy p {
  margin: 0;
  color: #6b6b68;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.35;
}
#start-overlay button {
  min-width: 0;
  min-height: 0;
  padding: 12px 14px;
  color: #1a1a1a;
  background: #faf7ef;
  border: 1px solid #1a1a1a;
  border-radius: 0;
  font-family: 'IBM Plex Mono', var(--mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}
#start-overlay button:focus-visible {
  outline: 2px solid #b53816;
  outline-offset: 2px;
}
#start-overlay button:hover:not(:disabled) {
  color: #1a1a1a;
  background: #fff;
  border-color: #b53816;
}
#start-overlay button.start-primary {
  color: #faf7ef;
  background: #b53816;
  border-color: #b53816;
  font-weight: 500;
}
#start-overlay button.start-primary:hover:not(:disabled),
#start-overlay button.start-primary:focus-visible {
  color: #fff;
  background: #8d2b10;
  border-color: #8d2b10;
}
#start-overlay button.start-secondary {
  color: #1a1a1a;
  background: #faf7ef;
  border-color: #1a1a1a;
}
#start-overlay button.start-secondary:hover:not(:disabled) {
  color: #b53816;
  background: #fff;
  border-color: #b53816;
}
#start-overlay button.start-tertiary {
  color: #1a1a1a;
  background: #faf7ef;
  border-color: #1a1a1a;
  font-weight: 500;
}
#start-overlay button.start-tertiary:hover:not(:disabled) {
  color: #b53816;
  background: #fff;
  border-color: #b53816;
}
#start-overlay .start-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}
#start-overlay .welcome-feedback {
  position: relative;
  min-height: 18px;
  margin-top: 12px;
}
#start-overlay .welcome-feedback > * {
  position: absolute;
  inset: 0;
}
#start-overlay #start-note {
  margin: 0;
  color: #6b6b68;
  font-family: inherit;
  font-size: 10.5px;
  line-height: 1.4;
}
#start-overlay #start-note.is-error {
  color: #8a2f2f;
  font-weight: 700;
}
#start-overlay .welcome-load-state {
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.7fr);
  margin: 0;
  padding: 0;
  color: #b53816;
}
#start-overlay .welcome-load-state:not([hidden]) + #start-note {
  visibility: hidden;
}
#start-overlay .welcome-load-state span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#start-overlay .welcome-load-state progress {
  height: 7px;
  background: #d7d7d3;
}
#start-overlay .welcome-load-state progress::-webkit-progress-bar {
  background: #d7d7d3;
}
#start-overlay .welcome-load-state progress::-webkit-progress-value {
  background: #1f6b63;
}
#start-overlay .welcome-load-state progress::-moz-progress-bar {
  background: #1f6b63;
}
#start-overlay[hidden] {
  display: none;
}

@media (max-width: 560px) {
  #start-overlay {
    align-items: flex-start;
    padding: 12px;
  }
  .welcome-card {
    width: 100%;
    max-height: calc(100vh - 24px);
  }
  .welcome-body,
  .welcome-start {
    padding-left: 24px;
    padding-right: 24px;
  }
  .welcome-hero {
    padding: 30px 24px 22px;
  }
  #start-overlay .welcome-hero h1 {
    font-size: clamp(46px, 14vw, 60px);
  }
}

@media (max-width: 430px) {
  #start-overlay .welcome-start-copy {
    display: block;
  }
  #start-overlay .welcome-start-copy p {
    margin-top: 3px;
  }
  #start-overlay .start-actions {
    grid-template-columns: 1fr 1fr;
  }
  #start-overlay button.start-tertiary {
    grid-column: 1 / -1;
  }
}

/* --- key commands (?) ---------------------------------------------------------- */

#keys-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 4, 6, 0.72);
  padding: 24px;
}
#keys-overlay[hidden] {
  display: none;
}
.keys-card {
  width: min(460px, 100%);
  max-height: 80vh;
  overflow: auto;
  padding: 18px 22px;
  background: rgba(17, 17, 20, 0.96);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.keys-card h2 {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.keys-card p {
  margin: 0 0 12px;
  color: var(--dim);
  font-size: 11px;
}
.keys-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  margin: 0 0 14px;
  font-size: 11px;
}
.keys-card dt {
  white-space: nowrap;
}
.keys-card dd {
  margin: 0;
  color: var(--dim);
}
.keys-card kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
  font-size: 10px;
  color: var(--text);
}

/* --- named performance recall ------------------------------------------------- */

.performance-hint {
  margin: 0 0 9px;
}
.library-current { display: flex; align-items: center; gap: 10px; }
.library-current .name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.library-thumb { width: 44px; height: 44px; flex: 0 0 44px; object-fit: cover; border-radius: 4px; background: #000; border: 1px solid #343c3e; }
.library-list .scene-row { cursor: pointer; }
.scene-row.is-current { border-color: var(--scene, var(--pal-mint)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--scene, var(--pal-mint)) 40%, transparent); }
.scene-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: middle; background: var(--scene, #4a5254); }
.scene-row:focus-visible { outline: 2px solid #b6cac4; outline-offset: 2px; }
.performance-row { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
.library-list .performance-row.is-current { border-color: var(--pal-lime); }
.library-list .performance-row.is-browsing { outline: 2px solid #ffb65d; outline-offset: 2px; }
.library-badge { font: 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--pal-lime); margin-left: 6px; }
.performance-save-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  margin-bottom: 8px;
}
.performance-save-row input {
  min-width: 0;
  padding: 5px 7px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
}
.performance-save-row input:focus {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.performance-list {
  display: grid;
  gap: 5px;
}
.performance-empty {
  padding: 7px 0 2px;
  color: var(--dim);
  font-size: 11px;
}
.performance-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.performance-copy {
  min-width: 0;
}
.performance-title {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.performance-meta {
  margin-top: 2px;
  color: var(--dim);
  font-size: 10px;
}
.performance-actions {
  display: flex;
  gap: 4px;
}
.performance-actions button {
  padding-inline: 6px;
}

/* Tools workspace — task navigation, readable controls, secondary setup. */
:root { --tools-width: 480px; }
#side {
  --text: #e6e6e2;
  --dim: #b9bab6;
  --line: #50514e;
  --panel-2: #3b3d3a;
  --accent: #ffb45e;
  width: var(--tools-width);
  max-width: calc(100% - 20px);
  background: rgba(43, 44, 42, var(--tools-alpha));
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  text-shadow: none;
  backdrop-filter: blur(7px) grayscale(1) brightness(.45);
  -webkit-backdrop-filter: blur(7px) grayscale(1) brightness(.45);
  border-color: #62645b;
  border-radius: 2px;
  box-shadow: 0 4px 20px #0005;
}
#side #stagebar { padding: 10px 16px; gap: 10px; background: transparent; border: 0; }
#stagebar .brand { font: 650 14px/1.3 var(--mono); color: var(--text); }
.tools-scene-name { flex: 1; min-width: 0; text-align: right; color: #65dcac; font: 11px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#side #tools-width, #side #tools-close { min-width: 30px; min-height: 32px; padding: 4px; background: transparent; border-color: transparent; font-size: 18px; }
#side .tool-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0 10px 8px; gap: 2px; background: transparent; }
#side .tool-tabs button { font: 12px system-ui, sans-serif; letter-spacing: 0; text-transform: none; border: 0; border-radius: 2px; min-height: 38px; padding: 8px 3px; }
#side .tool-tabs button[aria-selected='true'] { background: var(--section-color, #ffb45e); color: #242521; font-weight: 650; }
#side .secondary-tool-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 0; padding: 6px 12px; background: #252623; }
#side .secondary-tool-tabs button { font-size: 11px; min-height: 34px; }
#side .secondary-tool-tabs button[aria-selected='true'] { background: #3a4743; color: #e6e6e2; }
#side .tab-count { background: #ffb45e; color: #242521; }
#side #panels { scrollbar-width: thin; scrollbar-color: #73756f transparent; overscroll-behavior: contain; }
#side .tool-view > .body { padding: 20px; }
#side .tool-section > .body { padding: 12px 20px 18px; }
#side .tool-section-heading { padding: 18px 20px 10px; border: 0; }
#side .tool-section > h2 { padding: 18px 20px 10px; border: 0; }
#side .tool-section h2, #side .tool-section-heading h2 { font-size: 14px; font-weight: 650; letter-spacing: 0; text-transform: none; color: var(--text); }
.tool-view-heading { margin-bottom: 14px; }
.tool-view-heading h2 { font-size: 15px; letter-spacing: 0; margin: 0; }
.tool-view-heading p { color: var(--dim); font-size: 12px; margin: 7px 0 0; }
#side button { font-family: inherit; min-height: 34px; padding: 6px 10px; border-radius: 2px; }
#side button:focus-visible, #side summary:focus-visible, #side select:focus-visible { outline: 2px solid #ffb45e; outline-offset: 2px; }
#side input, #side select { font-family: inherit; font-size: 12px; border-radius: 2px; }
#side input[type='range'] { accent-color: #65dcac; min-height: 24px; cursor: pointer; }
#side input[type='number'] { padding: 7px; }
#side select { padding: 8px; }
#side .hint { font-family: inherit; font-size: 12px; line-height: 1.6; color: var(--dim); }
#side .tool-disclosure { border: 1px solid var(--line); border-radius: 2px; margin: 18px 20px; padding: 0 12px; }
#side .body > .tool-disclosure { margin: 18px 0; }
.tool-disclosure > summary { padding: 13px 0; cursor: pointer; font-size: 12px; color: var(--dim); }
.tool-disclosure > .body { padding: 0 0 14px; }
#side .tool-disclosure .row { flex-wrap: wrap; }
#side .tool-disclosure .row .name { white-space: normal; }
#side .compact-settings > summary, #side .shader-operator-reference > summary { min-height: 38px; letter-spacing: 0; text-transform: none; font-size: 12px; }
#side .library-search-label { display: grid; gap: 7px; font-size: 11px; color: var(--dim); }
#library-search { width: 100%; padding: 9px; color: var(--text); background: #222320; border: 1px solid #60625b; }
#side .filter-tabs { margin: 12px 0 0; padding: 4px; background: #222320; border: 1px solid var(--line); border-radius: 2px; gap: 4px; }
#side .filter-tabs button { min-width: 0; padding: 8px 4px; font-size: 11px; border: 0; background: transparent; }
#side .filter-tabs button[aria-pressed='true'] { color: #ecece7; background: #54564f; }
.library-browse-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 10px; color: var(--dim); padding: 12px 0; }
#side .library-browse-row select { background: transparent; border-color: transparent; font-size: 11px; padding: 5px; }
#library-result-count { white-space: nowrap; }
#side .library-group-heading { color: #c6c7c0; font-size: 11px; text-transform: none; letter-spacing: .01em; }
#side .library-card { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 6px 10px; padding: 10px 0; align-items: center; border-bottom: 1px solid var(--line); }
#side .library-card > .name { white-space: normal; overflow-wrap: anywhere; font-weight: 650; }
.library-card > .patch-status { grid-column: 3; text-transform: none; font: 9px var(--mono); border: 1px solid #65685e; color: #b9bab6; border-radius: 2px; padding: 3px 5px; }
.library-description { grid-column: 2 / -1; margin: 0; color: var(--dim); font-size: 12px; line-height: 1.45; }
#side .library-card > .library-origin { grid-column: 2; white-space: normal; font: 10px var(--mono); }
#side .library-card > .actions { grid-column: 3; justify-self: end; }
#side .library-card > .actions button { font-size: 11px; max-width: 200px; }
#side .library-card.is-available > .actions button { color: #242521; background: #ffb45e; border-color: #ffb45e; font-weight: 650; }
#side .library-scope { font-size: 10px; padding-top: 14px; }
#side .param-control-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--line); }
#side .param-control-row > .name { grid-column: 1; grid-row: 1; overflow-wrap: anywhere; white-space: normal; font-size: 13px; font-weight: 600; }
#side .param-control-row > .version { grid-column: 2; grid-row: 1; font: 13px var(--mono); }
#side .param-control-row > [data-param-role='value'] { grid-column: 1 / -1; grid-row: 2; width: 100%; max-width: none; }
#side .param-control-row > [data-param-role='learn'] { grid-column: 1 / -1; grid-row: 4; justify-self: end; font-size: 11px; background: transparent; color: #66c9cc; border-color: transparent; }
.param-limits { grid-column: 1 / -1; grid-row: 3; display: flex; justify-content: space-between; color: var(--dim); font: 10px var(--mono); }
#side .param-control-row .mapping { grid-column: 1 / -1; color: var(--dim); font-size: 11px; overflow-wrap: anywhere; }
#side .new-param-form { padding: 14px; border: 1px solid var(--line); border-radius: 2px; background: #333531; }
#side .new-param-form input, #side .new-param-form select { min-width: 0; max-width: 100%; }
#side .controller-setup .hint { font-size: 11px; }
#side .audio-source-actions { display: flex; gap: 6px; margin-bottom: 14px; }
#side .audio-source-actions button { flex: 1; min-width: 0; }
#side .audio-source-actions button[aria-pressed='true'] { background: #3a4743; border-color: #8a9a87; color: #ffb45e; }
#side .audio-source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding-bottom: 15px; }
#side #audio-source { grid-column: 1 / -1; font-size: 13px; font-weight: 650; white-space: normal; overflow-wrap: anywhere; }
#side #audio-position { grid-column: 1; font: 11px var(--mono); }
#side #onset-dot { grid-column: 2; grid-row: 2; }
#side .audio-source-row .actions { grid-column: 2; grid-row: 3; }
.audio-transport-row { display: flex; align-items: center; gap: 14px; margin: 16px 0; }
#side #tools-play-toggle { min-width: 90px; color: #242521; }
#audio-playback-progress { width: 100%; height: 6px; accent-color: #65dcac; }
#audio-input-row[hidden] { display: none; }
#audio-input-row { align-items: stretch; flex-direction: column; }
#side #input-device { max-width: 100%; width: 100%; }
.audio-signal { border: 1px solid var(--line); border-radius: 2px; padding: 16px; margin: 22px 0; }
.signal-heading { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.signal-heading h3 { font-size: 13px; margin: 0; }
#audio-signal-state { color: var(--dim); font-size: 11px; }
#audio-level { width: 100%; height: 16px; margin: 16px 0 12px; }
#audio-level::-webkit-meter-bar { background: #222320; border: 1px solid #555a50; }
#audio-level::-webkit-meter-optimum-value { background: #65dcac; }
#audio-level::-moz-meter-bar { background: #65dcac; }
.audio-bands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.audio-bands span { display: grid; gap: 7px; font-size: 10px; color: var(--dim); }
.audio-bands output { font: 15px var(--mono); color: #66c9cc; }
#side #settings-panel .row.param { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 20px 0; }
#side #settings-panel .row.param input { grid-column: 1 / -1; width: 100%; }
#side .audience-settings { border: 0; margin-top: 25px; }
#side .audience-settings > h2, #side .audience-settings > .body { padding-left: 0; padding-right: 0; }
#side .stagebar-control { width: 100%; justify-content: space-between; font-size: 12px; }
#side .performance-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
#side .performance-title { font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
#side .performance-actions { justify-content: flex-end; }
#side .performance-actions button:first-child { margin-right: auto; }
#side .performance-save-row { margin-bottom: 14px; }
#side .performance-save-row input { padding: 10px; min-width: 0; }
#side .project-reset { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
#side .runtime-details { border-bottom: 1px solid var(--line); font: 11px/1.7 var(--mono); }
#side .diagnostic { display: block; padding: 8px 0; overflow-wrap: anywhere; }
#side .diagnostic.error, #side .diagnostic.warn { padding: 10px 12px; margin: 6px 0; border: 1px solid #806345; background: #352d24; border-radius: 2px; }
#side .diagnostic .name { white-space: normal; line-height: 1.4; font-size: 12px; }
#side .diagnostic .row-error { margin-top: 4px; padding: 0; line-height: 1.4; }
#side .message-history-heading { padding: 12px 20px 0; }
#side .message-history-heading p { font-size: 11px; color: var(--dim); }
#side #ai-open { width: 100%; min-height: 40px; color: #242521; background: #ffb45e; font-weight: 650; }
#side:not(.is-hidden) ~ #editor-hint { right: calc(var(--tools-width) + 12px); }
#side:not(.is-hidden) ~ .ai-assistant { right: calc(var(--tools-width) + 12px); }
@media (max-width: 900px) {
  #side:not(.is-hidden) ~ .ai-assistant { left: 12px; right: 12px; }
}
@media (max-width: 600px) {
  #side { inset: 0; width: 100%; max-width: 100%; z-index: 7; border: 0; }
  #side #tools-width { display: none; }
  #side #stagebar { padding-top: max(14px, env(safe-area-inset-top)); }
  #side .secondary-tool-tabs { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  #side .tool-tabs button { font-size: 11px; }
  #side:not(.is-hidden) ~ #editor-hint { display: none; }
  #side .tool-view > .body { padding: 20px 16px; }
  #side .library-card > .actions button { max-width: 165px; }
  #side .library-browse-row select { max-width: 145px; }
}

/* Instrument chrome: track colors identify sections; green means live signal. */
#side #tool-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#side:has(#tools-width[aria-pressed='true']) #tool-tabs button { font-size: 10px; padding-inline: 2px; }
#side [data-tool-view='scene'] { --section-color: #e0a2bd; }
#side .scene-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#side .scene-heading h2 { margin: 4px 0 0; font: 600 18px var(--mono); overflow-wrap: anywhere; }
#side .scene-eyebrow { text-transform: uppercase; letter-spacing: .09em; font: 10px var(--mono); color: #e0a2bd; }
#side .scene-inspector-status { margin: 18px 0 12px; font: 11px var(--mono); color: #65dcac; }
#side .scene-tree { list-style: none; margin: 0; padding: 0; }
#side .scene-node { border: 1px solid #51534b; border-left: 3px solid #66c9cc; background: #292b27; margin: 5px 0; min-width: 0; }
#side .scene-node-group { border-left-color: #e0a2bd; }
#side .scene-node-effect { border-left-color: #b2a0de; }
#side .scene-node .scene-tree { padding: 0 8px 2px; }
#side .scene-node-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; min-width: 0; }
#side .scene-node-name { flex: 1; min-width: 0; min-height: 28px; text-align: left; overflow-wrap: anywhere; font: 12px var(--mono); background: transparent; border-color: transparent; padding: 3px 2px; }
#side .scene-node-name:hover { text-decoration: underline; }
#side .scene-node-kind { color: #c4c6bd; font: 10px var(--mono); flex-shrink: 0; }
#side .scene-node-moves { display: flex; gap: 3px; }
#side .scene-node-moves button { min-width: 26px; min-height: 26px; padding: 2px; }
#side .scene-node-moves button:disabled { opacity: .35; }
#side .scene-node.is-muted { border-left-color: #92968a; }
#side .scene-node.is-muted > .scene-node-row .scene-node-kind { color: #ffb45e; }
#side .scene-operations { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 10px 8px; }
#side .scene-operations button { font: 10px var(--mono); color: #d2c3ed; border-color: #65606c; white-space: normal; overflow-wrap: anywhere; text-align: left; max-width: 100%; }
#side .scene-pass-count { display: block; padding: 0 10px 10px; color: #b5b8ae; font: 10px var(--mono); }
#side .scene-recipe { margin-top: 20px; }
#side .scene-recipe pre { overflow-x: auto; padding: 12px; background: #222320; font: 11px/1.6 var(--mono); }
@media (max-width: 600px) { #side #tool-tabs button { padding-inline: 3px; font-size: 10px; } }
#side [data-tool-view='library'] { --section-color: #ffb45e; }
#side [data-tool-view='controls'] { --section-color: #66c9cc; }
#side [data-tool-view='audio'] { --section-color: #65dcac; }
#side [data-tool-view='project'] { --section-color: #b2a0de; }
#side [data-tool-view='modulations'] { --section-color: #f2c14e; }
.modulation-list { display: grid; gap: 10px; }
.modulation-notice { border: 1px solid var(--pal-mod); color: #ffe9cf; }
.modulation-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 10px 12px; background: #191e1f; border: 1px solid #343c3e; border-radius: 6px; }
.modulation-row { --mod: var(--pal-mod); }
.modulation-row.is-on { border-color: var(--mod); }
.cell-lock { margin-left: 8px; font: 10px var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: #8a9390; border: 1px solid #3a3f42; border-radius: 3px; padding: 1px 5px; }
.folded-block.is-locked .folded-source-editor { color: #a7adb0; cursor: default; }
.modulation-create { --mod: #8a9390; border-style: dashed; }
.modulation-create .modulation-name { color: #e2e4e5; grid-column: 1 / -1; }
.modulation-create .modulation-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 2px; }
.modulation-create-name input { font: 600 13px var(--mono); }
.modulation-row .modulation-name-text { color: var(--mod); }
.modulation-row .modulation-name { font: 600 13px var(--mono); display: flex; align-items: center; gap: 8px; min-width: 0; }
.modulation-row .modulation-name input { font: inherit; background: transparent; border: 0; border-bottom: 1px solid #343c3e; color: inherit; min-width: 0; width: 100%; }
.modulation-row .modulation-name-text { font: 600 13px var(--mono); padding: 2px 4px; border-radius: 4px; cursor: text; }
.modulation-row .modulation-name-text:hover { background: #23292a; }
.modulation-row .modulation-name-input { font: 600 13px var(--mono); width: 10ch; }
.modulation-row .modulation-scope { width: 160px; height: 40px; border-radius: 4px; border: 1px solid #343c3e; flex: 0 0 auto; }
.modulation-row .modulation-code { font: 11px var(--mono); color: #b9bdc1; background: #23292a; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.modulation-row .modulation-value { font: 12px var(--mono); color: #ffb65d; white-space: nowrap; }
.modulation-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 12px; }
.modulation-fields label[hidden] { display: none; }
.modulation-fields label { display: flex; flex-direction: column; gap: 4px; font: 11px var(--mono); color: #b9bdc1; min-width: 0; }
.modulation-fields select, .modulation-fields input[type='number'] { font: 12px var(--mono); }
.modulation-fields input[type='range'] { width: 100%; }
.modulation-actions { display: flex; gap: 6px; align-items: flex-start; }
.modulation-actions button.is-on { background: color-mix(in srgb, var(--mod) 28%, #191e1f); border-color: var(--mod); color: #fff; }
.surface-panel-profile { align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.surface-panel-profile label { display: inline-flex; align-items: center; gap: 6px; font: 11px var(--mono); color: #b9bdc1; }
.surface-panel-profile input[type='range'] { width: 110px; }
.surface-panel-profile output { min-width: 4ch; color: #e2e4e5; }
.surface-lower-buttons { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.surface-lower-buttons button { height: 26px; font: 12px var(--mono); padding: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #23292a; border: 1px solid #343c3e; color: #7c8886; }
.surface-lower-buttons button[data-state='defined'] { color: var(--mod, #e0c39b); border-color: color-mix(in srgb, var(--mod, #e0c39b) 35%, #23292a); }
.surface-lower-buttons button[data-state='running'] { color: #0c0c0c; background: var(--mod, var(--pal-mod)); border-color: var(--mod, var(--pal-mod)); font-weight: 600; }
#side #tool-tabs button { font-weight: 500; }
#side #stagebar .brand { text-transform: uppercase; letter-spacing: .12em; }
#side .tool-view-heading h2 { font-family: var(--mono); font-weight: 600; }
#side .tool-section-heading h2 { font-family: var(--mono); }
#side .library-group { --category-color: #92968a; }
#side [data-library-group='visual'] { --category-color: #66c9cc; }
#side [data-library-group='media'] { --category-color: #84c99d; }
#side [data-library-group='shader'] { --category-color: #b2a0de; }
#side [data-library-group='community'], #side [data-library-group='shared'] { --category-color: #e0a2bd; }
#side .library-group-heading { border-left: 3px solid var(--category-color); background: #343632; padding: 7px 9px; margin-top: 8px; font: 11px var(--mono); }
#side .library-card { padding-inline: 8px; }
#side .library-card > .name { font-family: var(--mono); font-size: 12px; }
#side .library-card > .patch-status { justify-self: end; }
#side .library-card.is-running > .patch-status, #side .library-card.is-active > .patch-status { color: #65dcac; border-color: #51866d; background: #253c31; }
#side .library-card.is-available > .actions button { color: #e6e6e2; background: #41443d; border-color: #696c62; font-weight: 500; }
#side .param-control-row > .version { color: #66c9cc; background: #222320; padding: 3px 7px; border: 1px solid #55584f; }
#side .param-control-row > .name { font-family: var(--mono); }
#side .param-control-row { padding-block: 14px; }
#side .audio-signal { background: #252723; }
#side #tools-play-toggle { background: #65dcac; border-color: #65dcac; }
#side .audio-bands output { background: #1d211c; border: 1px solid #494f44; padding: 5px 7px; font-variant-numeric: tabular-nums; }
#side .tool-disclosure > summary { padding-block: 10px; font-family: var(--mono); }
#side .performance-title { font-family: var(--mono); font-size: 13px; }
#side .performance-actions button:first-child { color: #b2a0de; border-color: #817397; }
#side .performance-row { border-left: 3px solid #b2a0de; padding: 12px; background: #333430; }
#icons { border-radius: 2px; background: rgba(37, 38, 35, .94); border-color: #65675e; }
#icons button.glyph { border-radius: 1px; }
#icons button.glyph.is-on { color: #ffb45e; }
#runtime-bar { border-radius: 2px; }

/* Browser chrome: neutral structure; scene colour belongs to the content. */
#side { border-color: #414440; box-shadow: none; }
#side #stagebar { padding: 10px 14px 6px; }
#side #stagebar .brand { font: 600 12px/1.4 system-ui, sans-serif; letter-spacing: .02em; text-transform: none; color: #c9ccc6; }
#side .tools-scene-name { font: 11px/1.4 system-ui, sans-serif; color: #9ca69f; }
#side #tool-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 12px 10px; gap: 2px; border-bottom: 1px solid #393c38; }
#side #tool-tabs button { min-height: 30px; padding: 5px 6px; font: 500 12px/1.4 system-ui, sans-serif; color: #aeb3ac; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; }
#side #tool-tabs button:hover { background: #ffffff08; color: #eef0eb; }
#side #tool-tabs button[aria-selected='true'] { background: #ffffff09; border-bottom-color: #c8cec3; color: #f0f2ec; }
#side .secondary-tool-tabs { background: #20231f; padding: 4px 12px; border-color: #393c38; }
#side #scene-panel > .body { padding: 18px 18px 24px; }
#side #scene-panel .scene-heading { margin: 0 0 14px; }
#side #scene-panel .scene-eyebrow { font: 500 10px/1.5 system-ui, sans-serif; color: #9da69e; letter-spacing: .06em; }
#side #scene-panel h2 { font: 500 20px/1.3 system-ui, sans-serif; margin-top: 3px; color: #e8ece4; }
#side #scene-panel button, #side #scene-panel summary { font: 500 11px/1.4 system-ui, sans-serif; }
#side #scene-panel button { min-height: 28px; padding: 5px 9px; border: 1px solid #494d46; border-radius: 2px; background: #30342e; color: #d4d9d0; box-shadow: none; }
#side #scene-panel button:hover:not(:disabled) { background: #41473c; border-color: #727b68; color: #fff; }
#side #scene-panel button:disabled { opacity: .35; }
#side #scene-panel input { min-height: 32px; padding: 6px 9px; font: 12px/1.4 system-ui, sans-serif; background: #252924; color: #e7ebe1; border: 1px solid #454b40; border-radius: 2px; }
#side #scene-panel :is(input, button, summary):focus-visible { outline: 2px solid #b6c4a7; outline-offset: 2px; }
#side #scene-panel input::placeholder { color: #929b8b; }
#side #scene-panel .performance-save-row { gap: 7px; margin: 0; }
#side #scene-panel .scene-guidance { margin: 10px 0 20px; color: #a0a79a; font: 11px/1.5 system-ui, sans-serif; }
.scene-guidance details { margin-top: 4px; }
.scene-guidance summary { cursor: pointer; color: #bdc5b6; width: fit-content; }
.scene-guidance p { margin: 8px 0 0; max-width: 40ch; }
#side #scene-panel .performance-list { gap: 0; border-top: 1px solid #41473d; }
#side #scene-panel .scene-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 0; border: 0; border-bottom: 1px solid #343a30; border-radius: 0; background: transparent; box-shadow: none; }
#side #scene-panel .scene-row.is-current { background: #ffffff10; box-shadow: inset 3px 0 var(--scene, #46d3bf); padding-left: 12px; }
#side #scene-panel .performance-title { font: 500 13px/1.5 system-ui, sans-serif; color: #e1e7da; overflow-wrap: anywhere; }
#side #scene-panel .scene-swatch { width: 6px; height: 6px; border-radius: 1px; margin-right: 8px; }
#side #scene-panel .performance-meta { font: 11px/1.5 system-ui, sans-serif; margin-top: 3px; color: #929c88; }
#side #scene-panel .scene-row.is-current .performance-meta { color: #becbb1; }
#side #scene-panel .performance-actions { display: flex; flex-wrap: nowrap; gap: 5px; align-items: center; }
#side #scene-panel .performance-actions button { padding: 4px 7px; font-size: 11px; background: transparent; border-color: transparent; }
#side #scene-panel .performance-actions > button:first-child { border-color: #4a5541; color: #d0ddbf; }
.scene-more { position: relative; }
#side #scene-panel .scene-more > summary { list-style: none; padding: 5px 6px; cursor: pointer; color: #a8b29e; }
.scene-more > summary::-webkit-details-marker { display: none; }
.scene-more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; display: grid; min-width: 120px; padding: 4px; border: 1px solid #525c47; border-radius: 3px; background: #272d22; box-shadow: 0 6px 16px #0008; }
#side #scene-panel .scene-more-menu button { text-align: left; }
#side #scene-panel .scene-more-menu button.danger { color: #e2a7a1; }
#icons { border-color: #444841; box-shadow: none; }
#icons button { text-shadow: none; box-shadow: none; }
@media (max-width: 600px) {
  #side #scene-panel > .body { padding-inline: 12px; }
  #side #scene-panel .scene-row { gap: 6px; }
}

/* Compact timing strip: source, tempo, and separate sound/clock feedback. */
.rhythm-section { border-top: 1px solid var(--line, #50504b); margin-top: 16px; padding-top: 12px; }
.rhythm-source-label, .rhythm-controls, .rhythm-indicators { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.rhythm-source-label select { flex: 1; min-width: 0; }
.rhythm-controls label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rhythm-controls input { width: 76px; min-width: 0; }
.rhythm-controls button { min-height: 32px; }
.rhythm-indicators { flex-wrap: wrap; font: 11px ui-monospace, monospace; justify-content: space-between; }
.rhythm-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #50504b; }
.rhythm-dot.lit { background: #ffb65b; }
#rhythm-onset-dot.lit { background: #58d5a3; }
#rhythm-phase, #rhythm-quality { display: block; width: 100%; height: 7px; margin-bottom: 10px; accent-color: #ffb65b; }
#rhythm-quality[hidden], #toolbar-bpm[hidden] { display: none; }
.toolbar-rhythm { display: inline-flex; align-items: center; gap: 6px; font: 11px ui-monospace, monospace; white-space: nowrap; }
#toolbar-tap, #rhythm-tap { font-variant-numeric: tabular-nums; }
#toolbar-tap kbd, #rhythm-tap kbd { font: 10px var(--mono); opacity: .7; }
#toolbar-tap.is-tapping, #toolbar-tap.is-beating,
#side #rhythm-tap.is-tapping, #side #rhythm-tap.is-beating { color: #242521; background: #ffb45e; border-color: #ffb45e; }
@media (max-width: 700px) { .toolbar-rhythm output { display: none; } }

/* Controller surface: restrained hardware-style chrome, with setup below the instrument. */
.surface-heading, .performance-surface header, .surface-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.surface-heading { justify-content: space-between; }
.performance-surface { width: min(1040px, 94vw); max-width: 94vw; max-height: 94vh; overflow: auto; padding: 20px 24px; color: #dce2e2; background: #202425; border: 1px solid #484e50; border-radius: 10px; font: 12px system-ui, sans-serif; box-shadow: 0 24px 80px #0007; }
.performance-surface::backdrop { background: #0009; }
.performance-surface header { margin-bottom: 16px; }
.performance-surface header > div { flex: 1; }
.surface-eyebrow, .surface-section-label { color: #93a09f; font: 10px var(--mono); letter-spacing: .12em; }
.performance-surface h2 { margin: 4px 0 0; font-size: 18px; font-weight: 550; letter-spacing: -.02em; }
.performance-surface button, .performance-surface select, .performance-surface input { box-sizing: border-box; font: inherit; color: #dce2e2; background: #2c3234; border: 1px solid #464e50; border-radius: 4px; padding: 6px 8px; min-height: 30px; }
.performance-surface button { cursor: pointer; }
.performance-surface button:hover { background: #3b4547; border-color: #7a8b8c; }
.performance-surface button:focus-visible, .performance-surface select:focus-visible, .performance-surface input:focus-visible { outline: 2px solid #ffb65d; outline-offset: 2px; }
.performance-surface [data-close] { background: transparent; border-color: transparent; color: #a5afaf; }
.performance-surface canvas { display: block; width: min(100%, 720px); height: auto; margin: 0 auto 18px; border: 1px solid #121718; border-radius: 5px; }
.surface-play { display: grid; grid-template-columns: minmax(0, 2fr) minmax(230px, 1fr); gap: 20px; }
.surface-play aside { border-left: 1px solid #394143; padding-left: 18px; min-width: 0; }
.surface-section-label { margin: 0 0 12px; font-weight: 500; }
.surface-encoders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.surface-encoder { position: relative; min-width: 0; text-align: center; background: #252b2c; border: 1px solid #384143; border-radius: 5px; padding: 6px; }
.surface-encoder-number { position: absolute; left: 8px; top: 11px; font: 9px var(--mono); color: #849391; }
.surface-encoder select { width: 100%; padding-left: 22px; background: transparent; border: 0; text-overflow: ellipsis; min-height: 25px; font-size: 11px; }
.surface-encoder output { display: block; color: #f0ba75; padding: 4px 0 6px; font: 13px var(--mono); }
.surface-encoder > div { display: flex; gap: 4px; }
.surface-encoder button { flex: 1; min-height: 24px; padding: 1px; border-color: #3b4547; background: #2c3436; }
.surface-encoder[data-assigned="false"] output { color: #748080; }
.surface-pads { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin-top: 12px; padding: 8px; background: #191e1f; border: 1px solid #343c3e; border-radius: 6px; }
.surface-pads button { --pad: #708883; height: 36px; min-width: 0; padding: 4px; font: 10px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid #3a4446; border-bottom: 3px solid var(--pad); background: #232a2b; color: #d8dedc; }
.surface-pads [data-status="empty"] { color: #879390; background: #292f30; border-color: #374143; border-bottom-color: #414c4e; }
.surface-pads [data-status="ready"] { border-color: var(--pad); color: #f1f4f2; }
.surface-pads [data-status="playing"] { color: #06110a; background: var(--pad); border-color: var(--pad); box-shadow: 0 0 12px color-mix(in srgb, var(--pad) 55%, transparent); font-weight: 600; }
.surface-pads [data-status="queued"], .surface-pads [data-status="loading"] { background: #3d2a12; border-color: var(--pal-mod); border-bottom-color: var(--pal-mod); }
.surface-pads [data-status="failed"] { border-color: var(--pal-red); border-bottom-color: var(--pal-red); }
.surface-pads [aria-pressed="true"] { outline: 1px solid #b6cac4; outline-offset: 2px; }
.surface-pads [data-effect="0"], .surface-pads [data-effect="1"], .surface-pads [data-effect="2"], .surface-pads [data-effect="3"], .surface-pads [data-effect="4"], .surface-pads [data-effect="5"], .surface-pads [data-effect="6"], .surface-pads [data-effect="7"] { margin-top: 10px; }
.surface-pads [data-status="on"] { color: #0b1a10; background: var(--pal-mint); border-color: var(--pal-mint); border-bottom-color: var(--pal-mint); font-weight: 600; }
.surface-pads [data-status="off"] { color: #b9c4c1; background: #2c3334; border-color: #4a5658; border-bottom-color: #5b6a6c; }
.surface-pads [data-status="unbound"] { color: #5f6a68; background: #202526; border-color: #2d3435; border-bottom-color: #33393a; }
.surface-status { color: #75d4b0; min-height: 1.4em; font-size: 11px; margin: 12px 0; overflow-wrap: anywhere; }
.surface-toolbar label { display: inline-flex; align-items: center; gap: 5px; color: #9faaa9; }
.surface-toolbar input { width: 50px; }
.surface-play .surface-toolbar { gap: 5px; font-size: 11px; }
.surface-play aside .surface-toolbar { border-top: 1px solid #394143; padding-top: 12px; }
.surface-play aside .surface-toolbar select { max-width: 160px; }
.performance-surface details { border-top: 1px solid #394143; padding-top: 12px; margin-top: 16px; color: #9faaa9; line-height: 1.6; }
.performance-surface details .surface-toolbar { margin-top: 12px; }
.performance-surface summary { cursor: pointer; font-size: 11px; }
@media (max-width: 760px) { .surface-play { grid-template-columns: 1fr; } .surface-play aside { border-left: 0; padding-left: 0; } .surface-encoders { grid-template-columns: repeat(4, minmax(0, 1fr)); } .performance-surface { padding: 16px; } }
@media (max-width: 480px) { .surface-pads { gap: 3px; padding: 5px; } .surface-pads button { font-size: 9px; } .surface-encoders { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Workspace navigation: performance content stays separate from setup. */
.workspace-disclosure { margin: 8px 0; font: 12px system-ui, sans-serif; }
.workspace-disclosure summary { cursor: pointer; padding: 6px 0; color: #bfc2bc; }
.workspace-disclosure button { margin: 3px; }
#icons { flex-wrap: wrap; gap: 5px; }
#icons button, #icons summary { font: 12px system-ui, sans-serif; text-shadow: none; }
#icons .toolbar-menu { position: relative; margin: 0; }
#icons .toolbar-menu summary { padding: 8px; }
#icons .toolbar-menu[open] { background: #272925; }
#icons .toolbar-menu[open] button { display: block; font-size: 12px; }
#project-panel .body, .workspace-connections { padding: 18px; }
#project-panel h2, #settings-panel h2 { font: 500 16px system-ui, sans-serif; }
#project-panel .hint, #settings-panel .hint { font: 12px/1.5 system-ui, sans-serif; }
#project-panel button, #settings-panel button, #project-panel input { font: 12px system-ui, sans-serif; min-height: 30px; padding: 6px 9px; border-radius: 2px; }
#project-panel .library-current { gap: 10px; align-items: center; }
#project-panel .library-current .name { font: 14px system-ui, sans-serif; }
#project-panel .library-thumb { width: 32px; height: 32px; object-fit: cover; }
#project-panel .performance-row { display: grid; grid-template-columns: 32px minmax(0,1fr) auto; gap: 10px; padding: 12px 0; background: transparent; border: 0; border-top: 1px solid #3a3d37; border-radius: 0; }
#project-panel .performance-title { font: 500 13px system-ui, sans-serif; overflow-wrap: anywhere; }
#project-panel .performance-meta { font: 11px/1.5 system-ui, sans-serif; color: #aaa; }
#project-panel .performance-actions { display: flex; align-items: start; gap: 5px; }
#project-panel .library-badge { font: 10px system-ui, sans-serif; color: #bac3b3; }
#project-panel .library-more { margin: 0; }
#project-panel .library-more[open] { max-width: 105px; }
#project-panel .library-more button { display: block; }
.workspace-connections .surface-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.workspace-connections select { max-width: 100%; }
#scene-panel .surface-heading { display: flex; align-items: center; justify-content: space-between; }
#scene-panel .surface-heading h3 { font: 500 13px system-ui, sans-serif; }

/* One navigation group: the selected section is always visible, including Settings. */
#side #stagebar .brand { flex: 1; font: 500 18px/1.3 system-ui, sans-serif; letter-spacing: 0; color: #edf2ee; }
#side #tools-scene-name[hidden] { display: none; }
#side #tool-tabs { gap: 3px; padding: 4px 12px 12px; }
#side #tool-tabs button { text-align: left; padding: 7px 10px; min-height: 32px; border: 1px solid transparent; border-radius: 2px; color: #aeb5af; }
#side #tool-tabs button[aria-selected='true'] { background: #35423d; border-color: #819a8d; color: #ffffff; font-weight: 600; }
#side #tool-tabs button:focus-visible { outline: 2px solid #c7e5d5; outline-offset: 1px; }
#side #tool-tabs button:hover:not([aria-selected='true']) { background: #ffffff0b; color: #e7eee8; }

#icons #panic[hidden] { display: none; }
/* Group destinations by task, and keep secondary actions out of row layout. */
#side #tool-tabs { display: flex; flex-direction: column; gap: 8px; background: #20251f; padding: 10px 14px 14px; }
#side #tool-tabs .navigation-group { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 8px; align-items: center; }
#side #tool-tabs .navigation-group-label { font: 10px system-ui, sans-serif; color: #9da99f; }
#side #tool-tabs .navigation-group-tabs { display: flex; gap: 4px; }
#side #tool-tabs .navigation-group-tabs button { flex: 1; min-width: 0; padding: 6px; font-size: 12px; }
#side #tool-tabs .navigation-group:last-child { border-top: 1px solid #3a443b; padding-top: 7px; }
#side #tool-tabs .navigation-group:last-child button { font-size: 11px; min-height: 26px; }
#project-panel .library-more, #project-panel .performance-options { position: relative; }
#project-panel .library-more[open] { max-width: none; }
#project-panel .performance-options-menu { position: absolute; right: 0; top: calc(100% + 3px); z-index: 12; display: flex; flex-direction: column; width: 150px; padding: 5px; background: #292f29; border: 1px solid #647064; box-shadow: 0 5px 16px #0008; }
#project-panel .performance-options-menu button { display: block; width: 100%; margin: 0; text-align: left; border: 0; background: transparent; padding: 8px 10px; }
#project-panel .performance-options-menu button:hover:not(:disabled) { background: #ffffff12; }
#project-panel .performance-options-menu button.danger { border-top: 1px solid #485047; color: #ee9c9c; }
#project-panel .performance-row { align-items: start; }
#project-panel .performance-heading { padding: 10px 18px; }
#project-panel .saved-performance-heading { padding: 10px 18px; background: #20271f; }
#project-panel .working-performance { padding-bottom: 12px; }
#project-panel .working-performance-status { min-height: 32px; }
.idle-faded { opacity: 0 !important; pointer-events: none !important; }
.idle-faded * { pointer-events: none !important; }
#icons, #side, #reference-side, #runtime-bar, #editor-hint, #code-layer { transition: opacity 250ms ease; }
.idle-fade-settings { margin: 16px 0; border: 1px solid #414a42; padding: 12px; }
.idle-fade-settings legend { font: 500 13px system-ui, sans-serif; padding: 0 5px; }
.fade-setting-row { display: grid; grid-template-columns: minmax(0,1fr) 125px; gap: 6px; align-items: center; margin: 10px 0; font: 12px system-ui, sans-serif; }
.fade-setting-row.is-manual { grid-template-columns: minmax(0,1fr) 100px 78px 20px; }
.fade-setting-row [hidden] { display: none !important; }
.fade-setting-row input, .fade-setting-row select { min-width: 0; width: 100%; }
@media (prefers-reduced-motion: reduce) { #icons, #side, #reference-side, #runtime-bar, #editor-hint, #code-layer { transition: none; } }
#project-panel .library-current[hidden] { display: none; }
#project-panel .performance-heading { background: #242b26; border-bottom: 1px solid #4e5951; padding: 10px 18px; }
#project-panel .performance-heading h2, #project-panel .saved-performance-heading h2 { font: 600 14px/1.4 system-ui, sans-serif; margin: 0; }
#project-panel .working-performance { padding-bottom: 12px; }
#project-panel .working-performance-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#project-panel .working-performance-status .hint { margin: 10px 0; }
#project-panel #performance-save-status.has-unsaved-changes { color: #edbd76; }
#project-panel .working-performance .workspace-disclosure { margin: 0; }
#project-panel .saved-performance-heading { margin: 0 -18px; padding: 10px 18px; background: #20271f; border-top: 1px solid #4e5951; border-bottom: 1px solid #4e5951; }
#project-panel .opens-up > .performance-options-menu { top: auto; bottom: calc(100% + 3px); }
#side #tool-tabs .navigation-group-tabs button { position: relative; background: transparent; border: 1px solid transparent; border-radius: 2px; color: #aeb6b0; font-weight: 400; }
#side #tool-tabs .navigation-group-tabs button[aria-selected="true"] { background: #ffffff04; border-color: transparent; color: #eef8f4; box-shadow: none; }
#side #tool-tabs .navigation-group-tabs button[aria-selected="true"]::after { content: ''; position: absolute; bottom: 0; left: 12px; right: 12px; height: 2px; background: #b4e3d8; box-shadow: 0 1px 5px #b4e3d866; }
#side #tool-tabs .navigation-group-tabs button:hover { background: #ffffff09; }
#project-panel .performance-heading, #project-panel .saved-performance-heading { background: transparent; border: 0; padding: 14px 18px 8px; }
#project-panel .performance-heading h2, #project-panel .saved-performance-heading h2 { font: 500 11px/1.4 system-ui, sans-serif; color: #a9b4ad; letter-spacing: .06em; text-transform: uppercase; }
#project-panel .working-performance { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 18px; padding-bottom: 24px; }
#project-panel .working-performance-preview { aspect-ratio: 16 / 9; background: #151a18; border: 1px solid #343e38; align-self: start; overflow: hidden; }
#project-panel .working-performance-preview .library-thumb { display: block; width: 100%; height: 100%; object-fit: contain; border: 0; border-radius: 0; }
#project-panel .working-performance-preview .library-thumb[hidden] { display: none; }
#project-panel .working-performance-identity { min-width: 0; }
#project-panel .working-performance-identity label { display: block; font: 11px system-ui, sans-serif; color: #a9b4ad; margin-bottom: 6px; }
#project-panel .working-performance-identity #library-save-form { flex-wrap: wrap; }
#project-panel .working-performance-identity #library-name { flex-basis: 100%; font-size: 18px; background: #171c19; border-color: #414b44; }
#project-panel .working-performance-status { align-items: baseline; gap: 6px; }
#project-panel .working-performance-status .hint { font-size: 11px; }
#project-panel .saved-performance-heading { border-top: 1px solid #3a443d; padding-top: 18px; }
#project-panel .performance-row { grid-template-columns: 96px minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 16px 0; }
#project-panel .performance-row .library-thumb { width: 96px; height: 54px; object-fit: contain; background: #151a18; border-radius: 0; }
#project-panel .performance-title { font-size: 14px; margin-bottom: 4px; }
#project-panel .library-badge { display: inline-block; margin-left: 8px; font-size: 9px; color: #b4e3d8; }
@media (max-width: 520px) {
  #project-panel .working-performance { grid-template-columns: 1fr; }
  #project-panel .working-performance-preview { max-width: 280px; }
  #project-panel .performance-row { grid-template-columns: 80px minmax(0,1fr); }
  #project-panel .performance-row .library-thumb { width: 80px; height: 45px; }
  #project-panel .performance-actions { grid-column: 2; }
}
#project-panel #library-save-form { display: flex; align-items: center; gap: 8px; }
#project-panel #library-save-form input { flex: 1; min-width: 0; }
#project-panel #library-save-form .library-thumb { flex: 0 0 32px; }
#side #tool-tabs[hidden], #side #tool-tabs button[hidden] { display: none; }
#icons :is(#fold-code, #toolbar-library, #tools-toggle, #workspace-settings) { color: #d7dcd7; background: transparent; border-color: transparent; }
#icons :is(#fold-code, #toolbar-library, #tools-toggle, #workspace-settings).is-on { color: #ffb45e; background: #ffffff05; }
#icons .toolbar-menu .audio-source-options { position: absolute; top: calc(100% + 6px); left: 0; width: 190px; padding: 6px; background: #242823; border: 1px solid #60685f; box-shadow: 0 5px 18px #0008; z-index: 20; }
#icons .toolbar-menu .audio-source-options button { width: 100%; margin: 0; text-align: left; padding: 10px; }
#icons .toolbar-menu summary { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#editor-hint #reference-toggle { pointer-events: auto; display: inline-block; font: 11px system-ui, sans-serif; margin-right: 12px; padding: 4px 7px; color: #d2d9d2; background: #20251f; border: 1px solid #4b534a; border-radius: 2px; }

/* Shared hierarchy: navigation, identity, controls, and supporting information. */
#side #stagebar { padding: 12px 16px; }
#side #stagebar .brand { font: 600 18px/1.3 system-ui, sans-serif; }
#side #tool-tabs { display: flex; flex-direction: row; flex-wrap: wrap; gap: 2px 10px; padding: 4px 14px 12px; background: #202020; border-bottom-color: #3c3c3c; }
#side #tool-tabs > button { --tab-accent: #d6d6d6; position: relative; flex: 0 0 auto; width: auto; min-height: 34px; padding: 7px 6px 10px; font: 400 12px/1.3 system-ui, sans-serif; color: #bcbcbc; border: 0; background: transparent; box-shadow: none; }
#side #tool-tabs > [data-tool-view="project"] { --tab-accent: #c18aff; }
#side #tool-tabs > [data-tool-view="scene"] { --tab-accent: #ffad66; }
#side #tool-tabs > [data-tool-view="controls"] { --tab-accent: #5bcfff; }
#side #tool-tabs > [data-tool-view="modulations"] { --tab-accent: #ee8ec8; }
#side #tool-tabs > [data-tool-view="audio"] { --tab-accent: #b6df58; }
#side #tool-tabs > [data-tool-view="rhythm"] { --tab-accent: #ffd064; }
#side #tool-tabs > [data-tool-view="messages"] { --tab-accent: #b8bdcc; }
#side #tool-tabs > [data-tool-view="ai"] { --tab-accent: #8d9dff; }
#side #tool-tabs > button[aria-selected="true"] { color: #f4f4f4; background: transparent; font-weight: 400; }
#side #tool-tabs > button[aria-selected="true"]::after { content: ''; position: absolute; height: 2px; bottom: 2px; left: 6px; right: 6px; background: var(--tab-accent); box-shadow: 0 1px 3px color-mix(in srgb, var(--tab-accent) 25%, transparent); }
#side #tool-tabs > button:focus-visible { outline-color: var(--tab-accent); }
#side #tool-tabs > button:hover:not([aria-selected="true"]) { color: #f0f0f0; }
#side button:focus-visible, #side summary:focus-visible { outline: 2px solid #abd6ec; outline-offset: 3px; }
#side .tool-view h2, #side .tool-view h3 { font-family: system-ui, sans-serif; font-size: 13px; font-weight: 600; line-height: 1.4; }
#side .tool-view button { font: 400 12px/1.4 system-ui, sans-serif; min-height: 30px; padding: 5px 9px; border: 1px solid #505b53; background: #252c27; color: #dde5df; border-radius: 2px; }
#side .tool-view button:disabled { opacity: .48; }
#side .tool-view button.danger { color: #edb3ad; border-color: #6c4844; background: transparent; }
#side .tool-view button:hover:not(:disabled) { background: #354138; }
#side .tool-view .hint { font: 12px/1.5 system-ui, sans-serif; color: #aeb9b1; }
#side .tool-view input:not([type="range"]):not([type="checkbox"]), #side .tool-view select { background: #141a16; border: 1px solid #4d5a50; color: #ecf1ed; border-radius: 2px; }
#side .tool-view .tool-view-heading { margin-bottom: 14px; }
#side #project-panel .working-performance { gap: 16px; padding-bottom: 18px; }
#side #project-panel .create-performance { margin-bottom: 24px; }
#side #project-panel .create-performance label { display: block; margin-bottom: 8px; font-size: 12px; }
#side #project-panel #library-list > .is-current { background: #ffffff0d; border-left: 3px solid #82d9cc; padding: 16px; }
#side #project-panel #library-list > .is-current > .performance-copy { grid-column: 1 / -1; }
#side #project-panel #library-list .working-performance { grid-column: 1 / -1; width: 100%; margin-top: 14px; }
#side #project-panel #library-list > .is-current > .performance-copy { order: 0; }
#side #project-panel #library-list > .is-current > .working-performance { order: 1; }
#side #project-panel #library-list > .is-current > .performance-actions { order: 2; grid-column: 1 / -1; border-top: 1px solid #ffffff18; padding-top: 12px; }
#side #project-panel #library-list .library-thumb[hidden] { display: none; }
#side #project-panel #library-rename-name { width: 100%; box-sizing: border-box; margin-bottom: 10px; }
#side #project-panel #library-save-changes { margin-bottom: 8px; }
#side #project-panel .performance-name-edit { font: inherit; color: inherit; padding: 0; background: transparent; border: 0; border-radius: 0; text-align: left; cursor: text; }
#side #project-panel .performance-name-edit:hover { text-decoration: underline; text-underline-offset: 4px; }
#side #project-panel .performance-name-input { font: inherit; width: min(100%, 320px); padding: 2px 4px; }
#side #project-panel #unsaved-performance[hidden] { display: none; }
#side .performance-image-group { min-width: 0; }
#side .image-actions, #side .item-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#side #project-panel .working-performance-status { min-height: 0; }
#side #project-panel .working-performance-status .hint { margin: 8px 0 0; }
#side #project-panel .performance-hint { margin: 10px 0 0; font-size: 11px; }
#side #project-panel #library-save-form { gap: 8px; }
#side #project-panel #library-save, #side #scene-panel #save-performance { background: #42584b; border-color: #839c8b; color: #fff; }
#side #project-panel .performance-row { grid-template-columns: 96px minmax(0,1fr); gap: 8px 14px; }
#side #project-panel .performance-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
#side #project-panel .performance-row > .library-thumb { grid-row: 1 / span 2; align-self: start; }
#side #project-panel .performance-actions button, #side #scene-panel .performance-actions button { display: inline-block; width: auto; margin: 0; }
#side .library-wide-actions { border-top: 1px solid #465148; margin-top: 18px; padding-top: 14px; }
#side .library-wide-actions h2 { margin: 0 0 10px; }
#side .library-wide-actions button { margin: 0 6px 6px 0; }
#side #scene-panel .scene-row { padding: 12px 0; }
#side #scene-panel .performance-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#side #scene-panel .scene-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#side #scene-panel #performance-launcher > .surface-heading,
#side #scene-panel #performance-launcher > .hint { display: none; }
#side .exposed-settings { padding: 14px 0; margin: 10px 0; border-top: 1px solid #3e4941; }
#side .exposed-settings > h3 { margin: 0 0 12px; color: #e1e9e3; }
#side .exposed-settings .surface-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
#side #ai-open { width: auto; background: #42584b; color: #fff; padding: 7px 14px; }
#side .diagnostic:not(.error):not(.warn) .row-error { color: #abb7af; }
#side .diagnostic.warn .row-error { color: #d8bc91; }
#side .diagnostic.error .row-error { color: #efb0a9; }
#side .audio-source-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; padding: 8px 0; }
#side .audio-source-row .name { flex: 1 1 160px; }
#side .audio-source-row .actions { margin-left: auto; }
#side .audio-transport-row { margin: 8px 0 16px; }
#side .library-examples button { margin: 0 6px 6px 0; }
#side .param-control-row { padding: 14px 0; margin: 0; border-top: 1px solid #425046; }
#side .param-control-row > button { width: auto; justify-self: start; }
#side .param-control-row > .name { font: 600 14px system-ui, sans-serif; }
#side .param-control-row > .version { font: 500 17px ui-monospace, monospace; }
#side .modulation-row { padding: 14px 0; border-top: 1px solid #425046; }
#side .modulation-fields { gap: 10px 12px; }
#side .modulation-fields label { font: 11px/1.5 system-ui, sans-serif; color: #b4c0b7; }
#side #parameters .param-control-row, #side .param-control-row { padding: 16px; margin: 0 0 12px; background: #181e1a; border: 1px solid #3c4840; border-radius: 2px; gap: 10px; }
#side .param-control-row > .version { border: 0; background: transparent; padding: 0; color: #b4e3d8; }
#side #parameters .param-control-row, #side .param-control-row { border-left: 3px solid var(--control-color, #66c9cc); }
#side .param-control-row > .param-limits { grid-column: 1 / -1; grid-row: 3; margin: -4px 0 0; font-size: 11px; color: #a6b2aa; }
#side .control-mapping-actions { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border-top: 1px solid #354139; padding-top: 10px; margin-top: 4px; }
#side .control-mapping-status { flex: 1 1 120px; font: 11px system-ui, sans-serif; color: #a6b2aa; }
#side .control-mapping-actions button { width: auto; }
#side #modulations-panel .modulation-row:not(.modulation-create) { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; padding: 16px; margin-bottom: 12px; background: #181e1a; border: 1px solid #3c4840; border-radius: 2px; }
#side #modulations-panel .modulation-row.is-on { border-left: 3px solid var(--mod); }
#side .modulation-row .modulation-name { align-self: center; font: 600 14px system-ui, sans-serif; }
#side .modulation-row .modulation-name-text { font: inherit; overflow-wrap: anywhere; }
#side .modulation-monitor { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid #354139; border-bottom: 1px solid #354139; font: 11px system-ui, sans-serif; color: #a6b2aa; }
#side .modulation-monitor .modulation-scope { flex: 1 1 120px; min-width: 0; max-width: 240px; border-radius: 0; }
#side .modulation-monitor .modulation-value { margin-left: auto; font: 500 18px ui-monospace, monospace; color: #d9ede4; }
#side .modulation-row:not(.modulation-create) .modulation-fields { display: flex; flex-direction: column; gap: 14px; }
#side .modulation-timing { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
#side .modulation-amount { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; border-top: 1px solid #354139; padding-top: 12px; }
#side .modulation-fields select, #side .modulation-fields input { min-width: 0; max-width: 100%; }
#side .modulation-actions { flex-wrap: wrap; }
.scene-source-dialog { width: min(900px, 90vw); max-height: 90vh; padding: 20px; background: #202020; color: #eee; border: 1px solid #666; }
.scene-source-dialog::backdrop { background: #000a; }
.scene-source-dialog h2 { margin: 0 0 10px; font: 600 18px system-ui, sans-serif; }
.scene-source-dialog p { font: 13px/1.5 system-ui, sans-serif; }
.scene-source-dialog textarea { display: block; box-sizing: border-box; width: 100%; height: 50vh; padding: 12px; background: #111; color: #eee; font: 14px/1.5 ui-monospace, monospace; tab-size: 2; }
.scene-source-dialog .actions { display: flex; justify-content: flex-end; gap: 10px; }
#side #scene-panel .performance-actions { flex-wrap: wrap; }
/* Library is a compact catalog, not a stack of settings cards. */
#side #library-panel .tool-view-heading { display: none; }
#side #library-panel .library-search-label { font: 12px system-ui, sans-serif; }
#side #library-panel #library-search { margin-top: 6px; }
#side #library-panel #library-filters { display: flex; gap: 16px; padding: 0; margin: 12px 0; border: 0; background: transparent; }
#side #library-panel #library-filters button { flex: 0 1 auto; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 6px 0; color: #bcbcbc; font: 12px system-ui, sans-serif; }
#side #library-panel #library-filters button[aria-pressed='true'] { color: #fff; border-bottom-color: #ffbd76; }
#side #library-panel .library-browse-row { margin: 8px 0 14px; font-size: 11px; }
#side #library-panel .library-group-heading { background: transparent; border: 0; border-bottom: 1px solid #424242; padding: 10px 0 7px; color: var(--category-color); font: 600 12px system-ui, sans-serif; }
#side #library-panel .library-card { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 12px 0; border-bottom-color: #303030; }
#side #library-panel .library-card > .name { grid-column: 1; grid-row: 1; font: 600 13px system-ui, sans-serif; color: #e6e6e6; }
#side #library-panel .library-card > .actions { grid-column: 2; grid-row: 1; }
#side #library-panel .library-card > .actions button { padding: 5px 9px; font-size: 11px; }
#side #library-panel .library-description { grid-column: 1 / -1; grid-row: 2; color: #aaa; font: 12px/1.45 system-ui, sans-serif; }
#side #library-panel .library-card > .patch-status { grid-column: 2; grid-row: 3; padding: 0; border: 0; background: transparent; font: 10px system-ui, sans-serif; }
#side #library-panel .library-card > .library-origin { grid-column: 1; grid-row: 3; font: 10px system-ui, sans-serif; color: #999; }
#side #library-panel .library-card > .dot { display: none; }
#side #library-panel .library-card > [hidden] { display: none; }
#side #library-panel .library-group-heading { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
#side #library-panel .library-group-heading::-webkit-details-marker { display: none; }
#side #library-panel .library-group-heading::before { content: '▸'; flex: 0 0 12px; font-size: 14px; color: #d0d0d0; }
#side #library-panel .library-group[open] > .library-group-heading::before { content: '▾'; }
#side #library-panel .library-group-heading > span:last-child { margin-left: auto; font: 11px system-ui, sans-serif; color: #aaa; }
#side #library-panel .library-empty { padding: 18px 12px; border: 1px dashed #505050; color: #bcbcbc; }
#side #rhythm-panel .rhythm-section { border-top: 0; margin-top: 0; padding-top: 0; }
#side #rhythm-panel .signal-heading h3 { font: 600 18px system-ui, sans-serif; }
#side .rhythm-tempo-group, #side .rhythm-beat-group { margin-top: 20px; padding-top: 16px; border-top: 1px solid #3c4840; }
#side .rhythm-tempo-group h3, #side .rhythm-beat-group h3 { margin: 0 0 12px; font: 600 13px system-ui, sans-serif; }
#side #rhythm-panel .rhythm-source-label { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#side #rhythm-panel .rhythm-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#side #rhythm-panel .rhythm-controls label { display: flex; gap: 8px; align-items: center; }
#side #rhythm-panel .rhythm-indicators { font: 12px system-ui, sans-serif; }
#side #audio-panel .audio-source-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#side #audio-panel .audio-signal { padding: 16px; background: #181e1a; border: 1px solid #3c4840; }
#side #audio-panel .audio-bands output { font-variant-numeric: tabular-nums; }
#side #audio-panel .exposed-settings .hint { font-size: 12px; line-height: 1.5; color: #a6b2aa; }
#side .modulation-name-text { cursor: default; }
#side .modulation-name-text:hover { text-decoration: none; background: transparent; }
#side .param-control-row button:focus-visible,
#side .modulation-actions button:focus-visible { outline: 2px solid #b4e3d8; outline-offset: 3px; }
#side .modulation-monitor .modulation-value,
#side .param-control-row > .version { font: 500 18px ui-monospace, monospace; font-variant-numeric: tabular-nums; }
#side .control-mapping-actions .danger,
#side .modulation-actions .danger { background: transparent; border-color: transparent; color: #b8aba9; }
#side .control-mapping-actions .danger:hover,
#side .modulation-actions .danger:hover { color: #ffaaa5; border-color: #98645f; }
@media (max-width: 520px) {
  #side #modulations-panel .modulation-row:not(.modulation-create) { grid-template-columns: minmax(0,1fr); }
  #side .modulation-timing { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 520px) {
  #side #project-panel .working-performance { grid-template-columns: 1fr; }
  #side #project-panel .performance-actions { grid-column: 1 / -1; }
}
#side #library-panel .library-card.is-included { border-left: 3px solid #ffb45e; background: #30291f; padding-left: 12px; }
#side #library-panel .library-card.is-included > .name { color: #ffcf91; }
#open-snippets { margin: 12px 0 18px; border-color: #ffb45e; color: #ffcf91; }
/* Give the catalog's controls, patch categories, and secondary actions distinct levels. */
#side #library-panel #open-snippets { margin: 0 0 18px; }
#side #library-panel .library-controls { padding: 14px 14px 4px; margin-bottom: 20px; border: 1px solid #414941; border-radius: 3px; background: #252a25; }
#side #library-panel .library-controls .library-browse-row { margin-bottom: 6px; padding-block: 8px; border-top: 1px solid #3d453d; }
#side #library-panel #library-filters { flex-wrap: wrap; gap: 8px 16px; margin: 14px 0 10px; }
#side #library-panel .library-group { overflow: hidden; border: 1px solid #414941; border-radius: 3px; background: #222622; }
#side #library-panel .library-group + .library-group { margin-top: 18px; }
#side #library-panel .library-group-heading { min-height: 42px; padding: 10px 12px; border: 0; border-left: 3px solid var(--category-color); border-bottom: 1px solid #414941; background: #303630; color: #e4e8e1; font-size: 13px; }
#side #library-panel .library-group-heading::before { color: var(--category-color); }

#side .code-theme-settings { margin: 0 0 20px; padding: 0; border: 0; }
#side .code-theme-settings legend { margin-bottom: 10px; padding: 0; color: #e8e9e4; font: 600 13px system-ui, sans-serif; }
#side .code-theme-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#side .code-theme-option { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; min-height: 58px; padding: 10px; border: 1px solid #50534d; border-radius: 3px; cursor: pointer; }
#side .code-theme-option:has(input:checked) { border-color: #c8cec3; background: #ffffff0a; }
#side .code-theme-option:has(input:focus-visible) { outline: 2px solid #c8cec3; outline-offset: 2px; }
#side .code-theme-option input { margin: 0; accent-color: #ff8059; }
#side .code-theme-name { color: #e4e8e1; font: 12px system-ui, sans-serif; }
#side .code-theme-swatches { grid-column: 2; display: flex; gap: 4px; }
#side .code-theme-swatches i { width: 14px; height: 7px; border-radius: 1px; background: var(--swatch); }
#side .electric-swatches i:nth-child(1) { --swatch: #aa91c7; }
#side .electric-swatches i:nth-child(2) { --swatch: #a783ff; }
#side .electric-swatches i:nth-child(3) { --swatch: #ff55d7; }
#side .electric-swatches i:nth-child(4) { --swatch: #24f5d0; }
#side .thunk-swatches i:nth-child(1) { --swatch: #b9a99a; }
#side .thunk-swatches i:nth-child(2) { --swatch: #ff6c45; }
#side .thunk-swatches i:nth-child(3) { --swatch: #ff9674; }
#side .thunk-swatches i:nth-child(4) { --swatch: #ffd2b7; }
#side .code-theme-settings .hint { margin: 9px 0 0; }
#side #library-panel .library-group-heading > span:last-child { color: #b5bdb3; }
#side #library-panel .library-card { padding-inline: 14px; border-bottom-color: #3b433c; }
#side #library-panel .library-card:last-child { border-bottom: 0; }
#side #library-panel .library-card.is-included { padding-left: 11px; }
#side #library-panel .library-scope { margin-top: 22px; padding-top: 16px; border-top: 1px solid #414941; }
#side #library-panel .tool-disclosure { margin-top: 18px; border-color: #414941; background: #252a25; }
#side #library-panel .tool-disclosure > summary { color: #e0e5dc; font-size: 12px; }
#side #library-panel .shader-operator-reference { margin-top: 12px; padding: 0 12px; border: 1px solid #414941; border-radius: 3px; background: #252a25; }
#side #library-panel .shader-operator-reference > summary { color: #e0e5dc; font-size: 12px; }
.snippet-picker { position: fixed; z-index: 1100; width: min(320px, calc(100vw - 16px)); padding: 8px; border: 1px solid #77644a; border-radius: 5px; background: #202521; color: #f1eee7; box-shadow: 0 12px 36px #0009; }
.snippet-picker[hidden] { display: none; }
.snippet-picker input { box-sizing: border-box; width: 100%; padding: 7px 9px; background: #131816; color: #fff; border: 1px solid #657166; }
.snippet-results { max-height: 164px; overflow: auto; margin-top: 5px; }
.snippet-option { display: block; width: 100%; padding: 7px 9px; border: 0; text-align: left; color: #e8dbbc; background: transparent; }
.snippet-option[aria-selected="true"], .snippet-option:hover { color: #ffcf91; background: #374039; }
#snippet-preview { max-height: 94px; overflow: auto; margin: 5px 0 0; padding: 7px 9px; border-top: 1px solid #455248; color: #c9c9c0; font: 12px/1.4 var(--mono); white-space: pre-wrap; }
#snippet-feedback:not(:empty), #snippet-manage-feedback:not(:empty) { margin: 6px 0 0; color: #ffcf91; font-size: 12px; }
#snippet-feedback:empty { display: none; }
#snippet-manager { margin: 0 0 18px; padding: 10px 12px; }
#snippet-manager label { display: grid; gap: 5px; margin-bottom: 8px; font-size: 12px; }
#snippet-manager input { padding: 7px; color: #fff; background: #131816; border: 1px solid #657166; }
.snippet-saved-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; border-top: 1px solid #455248; }

/* Thunk Machine welcome: compact identity, recent work, then source selection. */
.welcome-card { width:min(720px,100%); background:#faf7ef; border-color:#ded8cc; }
.welcome-hero { position:relative; padding:30px 36px 20px; background:#faf7ef; }
#start-overlay .welcome-hero h1 { font-size:64px; line-height:.86; letter-spacing:-4px; margin-bottom:18px; }
#start-overlay .welcome-hero .welcome-eyebrow { font-size:10px; margin-bottom:16px; color:#a63a1b; }
#start-overlay .welcome-hero .welcome-tagline { color:#171716; font:500 16px/1.4 'IBM Plex Mono',monospace; }
.welcome-mascot { position:absolute; width:216px; height:216px; object-fit:contain; top:8px; right:20px; mix-blend-mode:darken; }
.welcome-body { padding:0 36px 24px; background:#faf7ef; }
#start-overlay .welcome-intro { font-size:14px; color:#646158; }
.welcome-recent { padding:22px 36px 26px; margin:0; border-top:1px solid #ded8cc; gap:24px; background:#faf7ef; }
.welcome-recent-column { min-width:0; }
#start-overlay .welcome-recent h2 { margin-bottom:12px; font-size:14px; }
#start-overlay .welcome-recent-list button { color:#171716; border-radius:0; padding:9px 6px; }
#start-overlay .welcome-recent-list button:hover { border-color:#ff572b; background:#f1ece1; }
#start-overlay .welcome-recent-list button.is-current { border-color:#ff572b; }
#start-overlay .welcome-recent-list img { width:36px; height:36px; border-radius:3px; }
.welcome-start { padding:22px 36px 24px; background:#f1ece1; border-color:#ded8cc; }
#start-overlay button:focus-visible { outline-color:#b53816; }
#start-overlay button.start-primary { background:#ff572b; border-color:#ff572b; color:#171716; }
#start-overlay button.start-primary:hover:not(:disabled),#start-overlay button.start-primary:focus-visible { background:#e8481f; border-color:#e8481f; color:#171716; }
#start-overlay .welcome-credit { margin:0; padding:16px 36px 20px; font-size:10px; line-height:1.6; color:#737067; }
#start-overlay .welcome-credit a { color:inherit; text-decoration-color:#aaa397; }
@media(max-width:560px){
 .welcome-hero{padding:24px 24px 18px}
 .welcome-body{padding:0 24px 20px}
 .welcome-mascot{width:76px;height:76px;right:14px;top:46px}
 #start-overlay .welcome-hero h1{font-size:50px;letter-spacing:-3px}
 #start-overlay .welcome-hero .welcome-tagline{font-size:13px}
 .welcome-recent{padding:20px 24px;gap:22px}
 .welcome-start{padding:20px 24px}
 #start-overlay .welcome-credit{padding:14px 24px 18px}
}
