/* 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 {
  /* Sampled from the supplied AET logo; shared by event branding and its theme. */
  --aet-orange: #f78f27;
  --aet-pink: #ee2877;
  --aet-magenta: #b154a0;
  --aet-violet: #7353a3;
  --aet-yellow: #fdd314;
  --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;
  /* Controller colors are injected from the shared palette in push3Map.js. */
  /* Other performance UI colours remain separate from the five controller hues. */
  --pal-lime: #BFFB00; --pal-purple: #D86CE4; --pal-mint: #25FFA8; --pal-cyan: #10A4EE; --pal-blue: #5480E4;
  --pal-red: #FF3434; --pal-yellow: #F6BC58; --pal-white: #FAF7EF; --pal-orange: #FF572B;
  --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;
}

:root[data-code-theme='aet'] {
  --code-text: #f7f3fa;
  --code-comment: #aaa3b2;
  --code-string: var(--aet-yellow);
  --code-number: var(--aet-pink);
  --code-keyword: #c5aceb;
  --code-call: var(--aet-orange);
  --code-host: #df91d3;
}

:root[data-code-theme='dark-modern'] {
  --code-text: #d4d4d4;
  --code-comment: #858585;
  --code-string: #d7ba7d;
  --code-number: #e06c75;
  --code-keyword: #c586c0;
  --code-call: #66c7e6;
  --code-host: #dcdcaa;
}

:root[data-code-theme='dark-high-contrast'] {
  --code-text: #ffffff;
  --code-comment: #b8b8b8;
  --code-string: #ffe08a;
  --code-number: #ff6c7a;
  --code-keyword: #f5a2ff;
  --code-call: #78e6ff;
  --code-host: #ffc77a;
  --code-line-bg: rgba(0, 0, 0, 0.82);
}

:root[data-code-theme='eighties'] {
  --code-text: #fff0ff;
  --code-comment: #ad7bba;
  --code-string: #ffd166;
  --code-number: #ff5c8d;
  --code-keyword: #ed79ff;
  --code-call: #3bddff;
  --code-host: #ffb86b;
}

:root[data-code-theme='phosphor'] {
  --code-text: #d9ffcf;
  --code-comment: #83ae79;
  --code-string: #b8f5a7;
  --code-number: #e2ff8d;
  --code-keyword: #9be890;
  --code-call: #c4ffb7;
  --code-host: #efffd6;
}

:root[data-code-theme='amber'] {
  --code-text: #ffedc4;
  --code-comment: #b59a69;
  --code-string: #ffd68b;
  --code-number: #fff0aa;
  --code-keyword: #ffc46f;
  --code-call: #ffe1a1;
  --code-host: #fff5cb;
}

@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;
}
#visual-dimmer[data-level="2"] {
  background: rgba(0, 0, 0, 0.8);
}

/* --- 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;
}

/* One editable document, with folds and protected declaration ranges in place. */
.has-continuous-editor > :is(#current-cell-bar, #folded-code, #line-numbers, #fold-controls, #code-mirror, #code) {
  display: none !important;
}
#continuous-code {
  --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: max(18px, var(--toolbar-bottom, 54px)) 0 62px;
}
#continuous-code .cm-editor { height: 100%; background: transparent; color: var(--code-text); }
#continuous-code .cm-editor.cm-focused { outline: none; }
#editor-errors {
  position: absolute; z-index: 7; left: 18px; bottom: 72px;
  display: flex; align-items: flex-start; gap: 18px;
  max-width: min(760px, calc(100% - 36px)); box-sizing: border-box;
  max-height: 132px; overflow-y: auto;
  padding: 10px 14px; background: #111316f5; color: #e9e9e7;
  border: 1px solid #ffffff29; border-left: 3px solid #ffb45c;
  border-radius: 3px; box-shadow: 0 4px 16px #0005;
  font: 13px/1.5 var(--mono); overflow-wrap: anywhere;
}
#editor-errors[hidden] { display: none; }
/* Leave room for the notice so Show error cannot scroll its target behind it. */
#app:has(#editor-errors:not([hidden])) #continuous-code { bottom: 216px; }
#editor-errors strong, #editor-errors span { display: block; }
#editor-errors strong { color: #ffb45c; font-size: 12px; font-weight: 600; }
#editor-errors .editor-error-detail { margin-top: 2px; }
#editor-errors .editor-error-status { margin-top: 4px; color: #aeb6b6; font-size: 11px; }
#editor-errors button { flex: 0 0 auto; margin: 0; padding: 4px 8px; color: #ffcb8b; border: 1px solid #ffb45c4d; background: transparent; font: 11px/1.5 var(--mono); cursor: pointer; }
#editor-errors button:hover:not(:disabled) { background: #ffb45c18; border-color: #ffb45c; }
#editor-errors button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
#editor-errors button:disabled { opacity: 0.6; }
#continuous-code .continuous-error-line { box-shadow: inset 2px 0 #ffb45c; background: #ffb45c0d; }
#continuous-code .continuous-error-token { background: #ffb45c; color: #111316 !important; border-radius: 2px; box-shadow: 0 2px 0 #ffb45c; }
#continuous-code .continuous-error-point { display: inline-block; height: 1em; border-left: 2px solid #ffb45c; vertical-align: text-bottom; }
@media (max-width: 600px) {
  #editor-errors { gap: 8px; padding: 8px 10px; }
  #editor-errors button { white-space: normal; max-width: 116px; }
}
#continuous-code .continuous-edit-notice {
  position: absolute; left: 18px; bottom: 12px; z-index: 5;
  display: flex; align-items: flex-start; gap: 12px;
  max-width: min(760px, calc(100% - 36px)); box-sizing: border-box;
  padding: 10px 14px; font: 12px/1.5 var(--mono); background: #111316fa; color: #e9e9e7;
  border: 1px solid #ffffff29; border-left: 3px solid #ffb45c; border-radius: 4px;
}
#continuous-code .continuous-edit-notice[hidden] { display: none; }
#continuous-code .continuous-edit-notice button {
  flex: 0 0 auto; padding: 2px 6px; font: inherit; color: #ffcb8b;
  border: 1px solid #ffb45c4d; background: transparent; cursor: pointer;
}
#continuous-code .cm-scroller {
  font: var(--code-font-size)/var(--code-line-height) var(--mono);
  scrollbar-width: none;
}
#continuous-code .cm-content { padding: 0 12px 34px 0; caret-color: var(--code-text); }
#continuous-code .cm-line { padding: 0; }
#continuous-code .cm-gutters { background: transparent; border: 0; z-index: 0; }
#continuous-code .cm-lineNumbers { width: 58px; }
#continuous-code .cm-lineNumbers .cm-gutterElement {
  padding: 0 9px 0 0;
  color: rgba(150, 150, 160, 0.56);
  font-size: var(--code-gutter-font-size);
}
#continuous-code .cm-foldGutter { width: var(--folded-marker-width); }
#continuous-code .cm-foldGutter .cm-gutterElement { padding: 0; text-align: center; cursor: pointer; }
#continuous-code .continuous-disclosure {
  color: #adb0b8;
  font-size: max(18px, calc(var(--code-font-size) * 0.75));
  border: 0; background: transparent; padding: 0; width: 100%; min-height: 24px;
  font-family: inherit; cursor: pointer;
}
#continuous-code :is(.continuous-disclosure, .folded-ellipsis, .continuous-cell-actions button):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
#continuous-code .folded-ellipsis { border: 0; padding: 0; color: inherit; font: inherit; }
#continuous-code .continuous-code-run { background: var(--code-line-bg); }
#continuous-code .continuous-cell-heading { padding: 3px 0; }
#continuous-code .continuous-cell-heading .continuous-code-run { color: #b2adbc; }
#continuous-code .cm-line.is-in-use .continuous-code-run,
#continuous-code .cm-line.is-in-use .t-comment,
#continuous-code .scene-member-in-use .continuous-code-run,
#continuous-code .scene-member-in-use .continuous-code-run > span { color: #fff; }
#continuous-code .continuous-cell-actions {
  display: inline-flex; width: 0; transform: translateX(28px); user-select: none;
}
#continuous-code .continuous-cell-actions > * { flex-shrink: 0; }
#continuous-code .continuous-cell-actions > * { opacity: 0; }
#continuous-code .continuous-cell-heading:hover .continuous-cell-actions > *,
#continuous-code .continuous-cell-heading:focus-within .continuous-cell-actions > * { opacity: 1; }
#continuous-code .continuous-cell-actions .cell-status[data-state='error'] { opacity: 1; }
.cell-status[data-state='error'] { color: #ffb3a9; font-weight: bold; }
#continuous-code .cm-selectionBackground { background: rgba(127, 153, 240, 0.32) !important; }
#continuous-code .cm-cursor { border-left-color: var(--code-text); }
#continuous-code .folded-new-patch { margin-left: calc(-1 * var(--folded-code-column)); }
#continuous-code .folded-ellipsis { cursor: pointer; background: var(--code-line-bg); }
#continuous-code .continuous-code-run.flash-ok { background: rgba(45, 116, 70, 0.5); }
#continuous-code .continuous-code-run.flash-bad { background: rgba(138, 45, 57, 0.55); }

#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;
}
.declaration-preview-body {
  margin: 0;
  padding: 0 10px 0 var(--folded-code-column);
  color: #a7adb0;
  background: transparent;
  font: var(--code-font-size)/var(--code-line-height) var(--mono);
  white-space: pre;
  overflow-x: auto;
}
.declaration-preview-body > span { display: block; }
.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: 5; /* Above the adjacent sticky cell summary. */
  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.is-in-use > summary .folded-preview,
.folded-block.is-in-use > summary .folded-preview .t-comment,
.scene-member-in-use { color: #fff; }
.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);
}

.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 {
  top: var(--toolbar-bottom, 54px);
  position: absolute;
  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));
  /* At zero opacity, leave the canvas behind the drawer unfiltered. */
  -webkit-backdrop-filter:
    blur(calc(7px * var(--tools-alpha)))
    saturate(calc(1 - var(--tools-alpha) * 0.2))
    brightness(calc(1 - var(--tools-alpha) * 0.11));
  backdrop-filter:
    blur(calc(7px * var(--tools-alpha)))
    saturate(calc(1 - var(--tools-alpha) * 0.2))
    brightness(calc(1 - var(--tools-alpha) * 0.11));
  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 {
  /* 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;
  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;
}

#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;
  }
  #code-layer.has-continuous-editor { width: auto; }
}

/* --- transport --------------------------------------------------------------- */
#file-label {
  cursor: pointer;
}
#audio-file {
  display: none;
}

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

/* --- performance controls ------------------------------------------------------ */
.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;
  box-sizing: border-box;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; border: 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;
  flex-wrap: wrap;
  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; }

/* 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 --------------------------------------------------------- */
.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;
}
.compact-settings > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.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);
}

.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;
}
.code-size-setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.code-size-setting .name { white-space: normal; overflow: visible; }
.code-size-setting input[type='range'] { grid-column: 1 / -1; width: 100%; }

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

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

.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. */
.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);
}

/* 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);
}

/* 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; }
#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;
}
.cell-status:empty { display: none; }
.folded-copy,
.folded-save,
.folded-delete,
.folded-edit {
  margin-left: 12px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #aaaab8;
  font: 11px/1.4 var(--mono);
  cursor: pointer;
  vertical-align: middle;
}
.folded-copy:hover { color: #eeeef6; border-color: currentColor; }
.folded-save:hover { color: #eeeef6; border-color: currentColor; }
.folded-save { display: inline-grid; place-items: center; width: 26px; height: 24px; padding: 0; margin-left: 8px; box-sizing: border-box; }
.library-save-icon { width: 16px; height: 16px; background: currentColor; mask: url('../../vendor/lucide/book-plus.svg') center / contain no-repeat; }
.folded-edit:hover { color: #eeeef6; border-color: currentColor; }
.folded-block > summary .folded-copy,
.folded-block > summary .folded-save,
.folded-block > summary .folded-delete,
.folded-block > summary .folded-edit,
.folded-block > summary .cell-status,
.folded-block > summary .cell-lock {
  opacity: 0;
  pointer-events: none;
}
.folded-block > summary:hover :is(.folded-copy, .folded-save, .folded-delete, .folded-edit, .cell-status, .cell-lock),
.folded-block > summary:focus-within :is(.folded-copy, .folded-save, .folded-delete, .folded-edit, .cell-status, .cell-lock),
.folded-block[data-evaluation-state="error"] > summary .cell-status {
  opacity: 1;
  pointer-events: auto;
}
@media (hover: none) {
  .folded-block > summary :is(.folded-copy, .folded-save, .folded-delete, .folded-edit, .cell-status, .cell-lock) {
    opacity: 1;
    pointer-events: auto;
  }
}
.folded-delete:hover:not(:disabled) { color: #ffb3bb; }
.folded-delete:disabled { color: #777782; cursor: not-allowed; }
.folded-copy:focus-visible,
.folded-save:focus-visible,
.folded-delete:focus-visible,
.folded-edit: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 {
  /* Reserve the bottom-right Help and key-command strip. */
  max-width: calc(100% - 420px);
  box-sizing: border-box;
  gap: 0;
  min-height: 32px;
  padding: 2px;
  border: 1px solid #52564e;
  background: rgba(21, 24, 21, 0.96);
  color: #dddde8;
  font-size: 11px;
  text-shadow: none;
}
#runtime-bar > * { display: flex; align-items: center; min-height: 28px; padding: 0 10px; }
#runtime-bar > * + * { border-left: 1px solid #ffffff26; }
body:has(#reference-side:not(.is-hidden)) #runtime-bar { max-width: calc(100% - 770px); }
#live-performance, #live-scene, #live-crossfade { display: flex; align-items: center; gap: 8px; min-width: 0; }
#live-scene { min-height: 28px; border: 0; border-left: 1px solid #ffffff26; border-radius: 0; background: transparent; color: inherit; font: inherit; }
#live-scene:hover:not(:disabled) { background: #ffffff0a; }
#live-scene[hidden], #live-crossfade[hidden] { display: none; }
#live-performance-name, #live-scene-name, #live-crossfade-a, #live-crossfade-b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#live-performance-name, #live-scene-name { max-width: 200px; }
#live-crossfade-scenes { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; }
#live-crossfade-a, #live-crossfade-b { max-width: 110px; }
#live-crossfade-label, #live-crossfade-mix { flex-shrink: 0; }
#live-crossfade-scenes > [hidden] { display: none; }
#live-crossfade { color: var(--accent); }
#live-crossfade-mix { min-width: 7ch; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-label { color: #9fac9f; font-size: 10px; letter-spacing: 0; }
#runtime-bar > span:not(#live-performance):not(#live-crossfade), .live-label { flex-shrink: 0; white-space: nowrap; }
#live-fps { color: #b7c8bb; font-variant-numeric: tabular-nums; white-space: nowrap; }
#live-safe-status { color: #b7c8bb; }
.runtime-details { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
#first-edit-hint {
  position: absolute; z-index: 6; bottom: 76px; left: 24px; right: auto;
  display: flex; align-items: center; gap: 12px; width: 410px;
  max-width: calc(100% - 48px); padding: 22px 20px;
  border: 1px solid #d9ccb5; border-radius: 18px;
  background: #fff7e8; color: #24231f; box-shadow: 0 8px 32px #0005;
  font: 13px/1.5 system-ui, sans-serif; text-shadow: none;
}
#guide-success { position: absolute; top: 9px; right: 14px; padding: 3px 6px; border-radius: 3px; background: #203a31; color: #b8ee36; font: bold 10px/1.4 monospace; letter-spacing: .09em; }
#guide-success[hidden] { display: none; }
.guide-character { position: relative; flex: 0 0 90px; width: 90px; height: 110px; display: grid; place-items: center; }
#guide-confetti { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 96px; height: 96px; pointer-events: none; }
#guide-confetti > span { position: absolute; left: 50%; top: 50%; width: 9px; height: 5px; color: var(--confetti-color); background: var(--confetti-color); animation: guide-confetti-flick 1200ms cubic-bezier(.12,.6,.3,1) both; }
#guide-confetti > .code-confetti { width: auto; height: auto; background: none; font: bold 16px/1 monospace; }
@keyframes guide-confetti-flick {
  0% { opacity: 0; transform: translate(0, 0) scale(.3) rotate(0deg); }
  12% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--confetti-x), var(--confetti-y)) scale(.8) rotate(var(--confetti-turn)); }
}
#first-edit-hint[data-guide-state="color-success"] { border: 2px solid #659f5e; background: #f4ffdf; }
#first-edit-hint[data-guide-state="color-success"] #guide-title { font-size: 28px; }
#first-edit-hint[data-guide-state="color-success"] #guide-mascot { animation: guide-thunk-victory 950ms ease-in-out infinite; }
@keyframes guide-thunk-victory { 0%, 100% { transform: translateY(0) rotate(0); } 35% { transform: translateY(-18px) rotate(-12deg); } 65% { transform: translateY(-8px) rotate(9deg); } }
@media (prefers-reduced-motion: reduce) { #guide-confetti > span { animation: none; display: none; } #first-edit-hint[data-guide-state="color-success"] #guide-mascot { animation: none; } }
#first-edit-hint[hidden] { display: none; }
#guide-mascot { object-fit: contain; flex: 0 0 90px; width: 90px; height: 110px; }
#guide-progress { color: #ae4424; font: bold 10px/1.5 monospace; letter-spacing: .08em; }
#guide-title { margin: 7px 0; font-size: 22px; line-height: 1.15; letter-spacing: -.5px; }
#guide-instruction { margin: 0; }
#guide-shortcut { font: 11px/1.5 monospace; margin: 10px 0; }
#guide-lessons { display: grid; gap: 5px; margin: 10px 0; }
#guide-lessons[hidden] { display: none; }
#guide-lessons button { text-align: left; color: #373126; background: #efe6d6; border-color: #dbd0ba; padding: 8px 10px; cursor: pointer; }
#guide-lessons button:hover { background: #e4d7c0; }
#guide-lessons button span { display: block; font-size: 10px; color: #6d604d; }
#guide-choose { background: transparent; border-color: #d2c7b5; color: #514e46; }
#first-edit-hint button[hidden] { display: none; }
#app:has(#first-edit-hint:not([hidden])) #continuous-code { bottom: calc(var(--guide-height, 260px) + 92px); }
.guide-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#first-edit-hint button { min-height: 32px; border-radius: 7px; font-size: 12px; }
#first-edit-open { background: #ff572b; border-color: #ff572b; color: #211c17; }
#first-edit-dismiss { background: transparent; color: #514e46; border-color: #d2c7b5; }
#editor-hint #guide-open { pointer-events: auto; padding: 4px 7px; margin-right: 12px; font: 11px system-ui, sans-serif; color: #ffe2b9; background: #34281e; border: 1px solid #7a583a; border-radius: 2px; }
#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: var(--toolbar-bottom, 96px); 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 ------------------------------------------------------------ */





#start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 7, 0.32);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  padding: 24px;
  z-index: 7;
  overflow: auto;
}
#start-overlay:not([data-ready="true"]),
#start-overlay:not([data-brand-ready="true"]) { visibility: hidden; }
/* Keep the unfinished instrument out of the first paint while welcome assembles. */
#app:has(#start-overlay:not([hidden]):is(:not([data-ready="true"]), :not([data-brand-ready="true"])))
  > :is(#code-layer, #runtime-bar, #icons, #editor-hint) {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.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;
}
.performance-list {
  display: grid;
  gap: 5px;
}
.performance-empty {
  padding: 7px 0 2px;
  color: var(--dim);
  font-size: 11px;
}
.performance-copy {
  min-width: 0;
}

/* Tools workspace — task navigation, readable controls, secondary setup. */
:root { --tools-width: 480px; }

/* Instrument chrome: track colors identify sections; green means live signal. */
.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; }
.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: #242321; border: 1px solid #383633; color: #85817a; }
.surface-lower-buttons button[data-state='defined'] { color: var(--mod, #f6bc58); border-color: color-mix(in srgb, var(--mod, #f6bc58) 35%, #242321); }
.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; }
.surface-lower-buttons button[data-mode='modulation'][data-state='defined'] { color: #faf7ef; border-color: #faf7ef; }
.surface-lower-buttons button[data-mode='modulation'][data-state='editing'] { color: #0c0c0c; background: #faf7ef; border-color: #faf7ef; }
.surface-lower-buttons button[data-mode='scene'][data-state='defined'] { color: #faf7ef; }
.surface-lower-buttons button[data-mode='scene'][data-state='running'] { color: #faf7ef; background: #242321; border-color: var(--controller-blue); box-shadow: inset 0 -2px var(--controller-blue); animation: scene-playing-pulse 1s ease-in-out infinite alternate; }
#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: 5px; }

/* Browser chrome: neutral structure; scene colour belongs to the content. */
#icons { border-color: #444841; box-shadow: none; }
#icons button { text-shadow: none; box-shadow: none; }

/* Compact timing strip: source, tempo, and separate sound/clock feedback. */
#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 { color: #242521; background: #ffb45e; border-color: #ffb45e; }
#toolbar-link[aria-pressed="true"] { color: #77dcf1; background: #182930; border-color: #599eac; }
#toolbar-beat { color: #93938b; box-sizing: content-box; min-width: 5ch; font-size: 10px; font-variant-numeric: tabular-nums; border-left: 1px solid #ffffff1f; margin-left: 2px; padding: 0 9px; }
@media (max-width: 700px) { #toolbar-bpm { display: none; } }

/* Controller surface: restrained hardware-style chrome, with setup below the instrument. */
.performance-surface header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.performance-surface { width: min(1260px, 97vw); max-width: 97vw; max-height: 96vh; overflow: auto; padding: 16px 20px; color: #faf7ef; background: #202122; border: 1px solid #54575a; border-radius: 8px; font: 12px system-ui, sans-serif; box-shadow: 0 24px 80px #0009; }
.performance-surface::backdrop { background: #0009; }
.performance-surface header { margin-bottom: 16px; }
.performance-surface header > div { flex: 1; }
.surface-eyebrow, .surface-section-label { color: #aaa69f; font: 10px var(--mono); letter-spacing: 0; }
.performance-surface h2 { margin: 4px 0 0; font-size: 18px; font-weight: 550; letter-spacing: 0; }
.performance-surface button, .performance-surface select, .performance-surface input { box-sizing: border-box; font: inherit; color: #faf7ef; background: #282623; border: 1px solid #504840; border-radius: 4px; padding: 6px 8px; min-height: 30px; }
.performance-surface button { cursor: pointer; }
.performance-surface button:not(.surface-device button):hover { background: #39322c; border-color: #d2aa82; }
.performance-surface button:focus-visible, .performance-surface select:focus-visible, .performance-surface input:focus-visible { outline: 2px solid #ff572b; outline-offset: 2px; }
.performance-surface canvas { display: block; width: 100%; height: auto; margin: 0; border: 2px solid #0b0d0f; border-radius: 3px; background: #000; }
.surface-device { display: grid; grid-template-columns: minmax(115px, .18fr) minmax(0, 1fr) minmax(155px, .22fr); gap: 16px; min-width: 800px; padding: 20px 14px 16px; background: linear-gradient(145deg, #252729, #191a1c 58%, #232527); border: 1px solid #4b4d50; border-radius: 8px; box-shadow: inset 0 1px #4d4f52, inset 0 -2px #0f1011; }
.surface-center { min-width: 0; display: grid; grid-template-rows: auto auto auto auto auto; gap: 7px; }
.surface-left-rail, .surface-right-rail { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.surface-left-rail { gap: 0; }
.surface-device-mark { margin: 4px 0 13px; color: #d7d9dc; font: 700 14px system-ui, sans-serif; letter-spacing: 0; }
.surface-device-mark span { display: block; color: #858c94; font: 10px var(--mono); letter-spacing: 0; }
.surface-system-keys, .surface-mode-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; padding: 2px; background: #1b1d1f; border: 1px solid #0d0f11; border-radius: 3px; box-shadow: inset 0 1px #44474b, 0 1px 2px #0008; }
.surface-system-keys span, .surface-mode-keys span { display: grid; place-items: center; min-width: 0; height: 26px; color: #a9b8d2; font: 14px system-ui, sans-serif; border-right: 1px solid #101214; background: linear-gradient(#2e3033, #222426); text-shadow: 0 0 4px #6c8cbd55; }
.surface-system-keys span:last-child, .surface-mode-keys span:last-child { border-right: 0; }
.surface-left-head { display: grid; grid-template-columns: minmax(0, 1fr) 45px; align-items: center; gap: 8px; min-height: 113px; margin: 8px 0 12px; }
.surface-left-dial { width: min(100%, 70px); aspect-ratio: 1; border: 2px solid #131517; border-radius: 50%; background: radial-gradient(circle at 32% 27%, #343639, #1b1d1f 72%); box-shadow: inset 0 1px #55585c, 0 4px 8px #0009; }
.surface-rail-actions { display: grid; gap: 22px; }
.surface-rail-actions button { min-height: 37px; padding: 0 3px; font-size: 11px; }
.surface-mode-keys { margin-bottom: 12px; }
.surface-left-lower { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 33px; gap: 10px; min-height: 320px; }
.surface-left-controls { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.surface-left-secondary-dial { align-self: center; width: min(70%, 56px); aspect-ratio: 1; border: 2px solid #131517; border-radius: 50%; background: radial-gradient(circle at 32% 27%, #343639, #1b1d1f 72%); box-shadow: inset 0 1px #55585c, 0 4px 8px #0009; }
.surface-left-controls > button { min-height: 40px; }
.surface-tempo-keys, .surface-length-keys { display: grid; gap: 2px; padding: 2px; background: #1b1d1f; border: 1px solid #0d0f11; border-radius: 3px; }
.surface-left-controls [data-launch-modifier], .surface-unassigned-key { min-height: 30px; padding: 3px; font-size: 11px; }
.surface-unassigned-key { display: grid; place-items: center; color: #888; background: linear-gradient(#292b2d, #252729); }
.surface-length-keys { margin-top: 12px; }
.surface-left-controls .surface-tempo-keys .surface-tap { min-height: 40px; padding: 4px; font-size: 11px; }
.surface-tempo-keys .surface-tap::after { display: none; }
.surface-left-controls .surface-tap { min-height: 84px; padding: 10px 8px; text-align: left; align-self: stretch; border-bottom: 3px solid #efb400; }
.surface-tap span { display: block; }
.surface-tap::after { content: ''; display: block; height: 3px; margin-top: 16px; border-radius: 2px; background: #16181a; box-shadow: 0 1px #484b4f; }
.surface-left-controls [data-action='safe'] { margin-top: auto; }
.surface-left-controls .surface-play { min-height: 60px; padding: 0; color: #bff1c1; border-bottom: 3px solid #4caf23; font-size: 31px; line-height: 1; }
.surface-touch-strip { position: relative; min-height: 0; border: 1px solid #090b0c; border-radius: 3px; background: linear-gradient(90deg, #16181a, #25272a 18%, #17191b 75%, #101214); box-shadow: inset 1px 0 #404347, inset -1px 0 #34373a, 0 2px 3px #0008; }
.surface-touch-strip::before { content: ''; position: absolute; top: 7%; bottom: 7%; left: 50%; width: 2px; transform: translateX(-50%); background: #3a3d40; box-shadow: 1px 0 #0e1012; }
.surface-touch-strip { touch-action: none; cursor: ns-resize; }
.surface-touch-strip[aria-disabled="true"] { cursor: default; }
.surface-touch-strip[aria-disabled="true"] span { visibility: hidden; }
.surface-strip-thumb { pointer-events: none; position: absolute; left: 50%; top: var(--strip-position, 50%); width: 7px; height: 7px; transform: translate(-50%, -50%); border-radius: 50%; background: #fff; box-shadow: 0 0 7px #ffffff99; }
.surface-strip-end { pointer-events: none; position: absolute; left: 0; right: 0; text-align: center; font: 700 10px/16px var(--mono); }
.surface-strip-end[hidden] { display: none; }
.surface-strip-end-up { top: 1%; color: var(--controller-blue); }
.surface-strip-end-down { bottom: 1%; color: var(--controller-amber); }
.surface-touch-strip[data-crossfading] { border-color: color-mix(in srgb, var(--controller-blue) 55%, #34373a); background: linear-gradient(to bottom, color-mix(in srgb, var(--controller-blue) 28%, #17191b), #181c20 50%, color-mix(in srgb, var(--controller-amber) 24%, #17191b)); }
.surface-touch-strip[data-crossfading]::before { width: 8px; border-radius: 2px; background: linear-gradient(to bottom, color-mix(in srgb, var(--controller-blue) 80%, #25272a), color-mix(in srgb, var(--controller-amber) 75%, #25272a)); box-shadow: 0 0 8px #ffffff20; }
.surface-touch-strip[data-crossfading]::after { content: ''; pointer-events: none; position: absolute; top: var(--strip-position, 50%); left: 2px; right: 2px; height: 32px; transform: translateY(-50%); background: linear-gradient(to bottom, transparent, #ffffff30, transparent); }
.surface-touch-strip[data-crossfading] .surface-strip-thumb { z-index: 1; width: 26px; height: 6px; border-radius: 1px; box-shadow: 0 0 10px #ffffffaa; }
.surface-left-rail button, .surface-right-rail button { min-width: 0; min-height: 38px; color: #c5c8cc; background: linear-gradient(#303236, #242629 42%, #202225); border-color: #0b0d0f; box-shadow: inset 0 1px #54575b, inset 1px 0 #35383b, inset 0 -2px #151719, 0 3px 3px #000a; }
.surface-left-rail button:hover, .surface-right-rail button:hover { color: #fff; background: linear-gradient(#3a3d41, #2c2e32 45%, #25272a); }
.surface-encoders, .surface-upper-buttons { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.surface-encoder { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; text-align: center; }
.surface-encoder-number, .surface-encoder-label, .surface-encoder output { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.surface-encoder .surface-encoder-knob { position: relative; flex: none; width: 46px; height: 46px; min-height: 46px; padding: 0; border-radius: 50%; border: 2px solid #0d0e10; background: radial-gradient(circle at 35% 28%, #36393d, #1b1d20 65%); box-shadow: inset 0 1px #575b60, 0 3px 5px #000a; touch-action: none; }
.surface-encoder-knob::before { content: ''; position: absolute; inset: -5px; border-radius: 50%; background: conic-gradient(from 225deg, #4caf23 0deg var(--encoder-sweep, 0deg), #344139 var(--encoder-sweep, 0deg) 270deg, transparent 270deg); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px)); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px)); pointer-events: none; }
.surface-encoder-pointer { position: absolute; inset: 0; transform: rotate(var(--encoder-angle, 0deg)); pointer-events: none; }
.surface-encoder-pointer::after { content: ''; position: absolute; top: 3px; left: 50%; width: 3px; height: 12px; transform: translateX(-50%); background: #bec3c7; border-radius: 1px; box-shadow: 0 0 4px #0008; }
.surface-encoder > div { display: flex; gap: 3px; width: min(100%, 64px); }
.surface-encoder > div button { flex: 1; min-height: 18px; padding: 0; line-height: 16px; color: #a5acb2; background: linear-gradient(#303337, #222427); border-color: #0b0d0f; box-shadow: inset 0 1px #4a4e52, 0 2px 2px #0009; }
.surface-encoder[data-assigned='true'] .surface-encoder-knob { box-shadow: inset 0 1px #575b60, 0 3px 5px #000a, 0 0 0 1px #46755e; }
.surface-encoder[data-assigned='false'] .surface-encoder-knob::before { background: conic-gradient(from 225deg, #344139 0deg 270deg, transparent 270deg); }
@media (prefers-reduced-motion: reduce) { .surface-encoder-pointer { transition: none; } }
.surface-upper-buttons button { height: 28px; min-width: 0; padding: 0 8px; background: linear-gradient(#313337, #222427 42%, #1c1e20); border: 1px solid #0b0d0f; border-radius: 3px; box-shadow: inset 0 1px #51555a, inset 0 -2px #131517, 0 3px 2px #0009; }
.surface-upper-buttons button::after { content: ''; display: block; height: 3px; border-radius: 1px; background: #596269; box-shadow: inset 0 1px #aeb4b866, 0 0 4px #78828a55; }
.surface-upper-buttons button[data-state='assigned']::after { background: #4caf23; box-shadow: 0 0 8px #4caf23; }
.surface-upper-buttons button[data-state='editing']::after { background: #f4f7fa; box-shadow: 0 0 8px #f4f7fa; }
.surface-upper-buttons button:hover:not(:disabled) { background: linear-gradient(#3b3e42, #292c2f 42%, #202225); }
.surface-pads { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 3px; background: #111315; border: 1px solid #3c4044; border-radius: 3px; }
.surface-pads button { --pad: #aaa69f; aspect-ratio: 1.34; height: auto; min-width: 0; padding: 4px; font: 10px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid #9ca4ad; border-radius: 3px; background: radial-gradient(ellipse at 50% 42%, #e2e8ef, #b8c0ca 82%); color: #353c44; box-shadow: inset 0 1px #f6f9ff, inset 1px 0 #e8edf3aa, inset 0 -3px #87919b, 0 3px 2px #000b; }
.surface-right-system-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: 47px; padding: 2px; background: #1b1d1f; border: 1px solid #0d0f11; border-radius: 3px; box-shadow: inset 0 1px #44474b, 0 1px 2px #0008; }
.surface-right-system-keys span { display: grid; place-items: center; min-width: 0; height: 26px; color: #a9b8d2; font: 15px system-ui, sans-serif; border-right: 1px solid #101214; background: linear-gradient(#2e3033, #222426); text-shadow: 0 0 4px #6c8cbd55; }
.surface-right-system-keys span:last-child { border-right: 0; }
.surface-jog-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 7px; }
.surface-jog-actions { display: grid; align-content: space-around; gap: 14px; height: 100%; }
.surface-jog-actions button { min-height: 38px; padding: 0; font-size: 21px; }
.surface-jog { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.surface-jog .surface-jog-wheel { width: min(100%, 95px); aspect-ratio: 1; min-height: 0; padding: 0; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #32353a, #16181b 70%); border: 2px solid #0c0d0f; box-shadow: inset 0 1px #66696e, 0 4px 8px #000b; }
.surface-jog .surface-jog-wheel { touch-action: none; cursor: ns-resize; }
.surface-jog-nudge { display: flex; gap: 3px; width: 65%; }
.surface-jog-nudge button { flex: 1; min-height: 18px; padding: 0; font-size: 10px; line-height: 1; }
.surface-right-page-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: start; gap: 7px; }
.surface-master { margin: 0; min-height: 36px; padding: 2px; font-size: 9px; border-bottom: 3px solid #9bb0d1; }
.surface-master[aria-pressed='true'], .surface-shift[aria-pressed='true'] { color: #fff; border-bottom: 3px solid #00bfde; box-shadow: inset 0 1px #5c6268, 0 0 10px #00bfde66; }
.surface-dpad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, 28px) 18px; align-items: center; gap: 3px; padding: 8px 5px; background: #1d1f21; border: 1px solid #101214; border-radius: 3px; }
.surface-dpad button { min-height: 28px; padding: 0; font-size: 16px; }
.surface-dpad [data-hardware='dpadUp'] { grid-area: 1 / 2; }
.surface-dpad [data-hardware='dpadLeft'] { grid-area: 2 / 1; }
.surface-dpad [data-hardware='dpadCenter'] { grid-area: 2 / 2; }
.surface-dpad [data-hardware='dpadRight'] { grid-area: 2 / 3; }
.surface-dpad [data-hardware='dpadDown'] { grid-area: 3 / 2; }
.surface-dpad button:not(:disabled) { color: #f2f5f7; border-bottom: 3px solid #a9d3de; }
.surface-dpad button:disabled { color: #555c62; opacity: .5; }
.surface-dpad span { grid-area: 4 / 1 / 5 / 4; text-align: center; color: #c0c9d0; font: 10px var(--mono); overflow-wrap: anywhere; }
.surface-right-lower { flex: 1; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 7px; min-height: 320px; }
.surface-step-keys { display: grid; grid-template-rows: repeat(8, minmax(0, 1fr)); gap: 5px; min-height: 0; }
.surface-step-keys span { min-height: 0; padding: 7px 3px; color: #687079; background: linear-gradient(#292b2e, #202225); border: 1px solid #0c0e10; border-radius: 3px; box-shadow: inset 0 1px #44474a, 0 2px 2px #0008; font: 8px var(--mono); line-height: 1.6; }
.surface-right-tools { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-width: 0; }
.surface-tool-grid, .surface-tool-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; padding: 2px; background: #1a1c1e; border: 1px solid #0b0d0f; border-radius: 3px; box-shadow: inset 0 1px #45484b, 0 2px 2px #0008; }
.surface-tool-grid span, .surface-tool-pair span { min-width: 0; min-height: 39px; padding: 6px 2px; color: #b8bbcf; background: linear-gradient(#2e3033, #222426); font: 9px system-ui, sans-serif; overflow-wrap: anywhere; text-align: center; }
.surface-tool-grid:first-child span { min-height: 57px; color: #bcb7d6; font-size: 15px; }
.surface-tool-grid small { display: block; margin-top: 8px; font-size: 9px; }
.surface-tool-pair span { min-height: 34px; }
.surface-bank-controls { color: #818a92; font: 9px var(--mono); text-align: center; }
.surface-bank-pad { display: grid; grid-template-columns: 1fr 1.4fr 1fr; grid-template-rows: 20px 26px 20px; gap: 2px; align-items: stretch; margin-top: 4px; padding: 3px; background: #1a1c1e; border: 1px solid #0b0d0f; border-radius: 3px; }
.surface-bank-pad > span { grid-area: 1 / 2; color: #818a92; }
.surface-bank-pad > span:last-child { grid-area: 3 / 2; }
.surface-bank-pad [data-action='bankPrevious'] { grid-area: 2 / 1; }
.surface-bank-pad [data-action='bankNext'] { grid-area: 2 / 3; }
.surface-bank-pad button { min-height: 0; padding: 0; }
.surface-bank-pad strong { grid-column: 2; grid-row: 2; align-self: center; min-width: 0; color: #d6dce2; white-space: nowrap; font-size: 8px; }
.surface-bottom-keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.surface-bottom-keys button { min-height: 30px; padding: 2px; font-size: 9px; }
.surface-shift { margin: 0; }
.surface-bottom-keys [data-select-mirror][aria-pressed='true'],
.surface-left-controls [data-launch-modifier][aria-pressed='true'] { color: #fff; border-bottom: 3px solid #00bfde; }
.surface-utility { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.surface-utility .surface-status { flex: 1; min-width: 160px; margin: 0; }
.surface-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.surface-toolbar label { display: inline-flex; align-items: center; gap: 5px; }
.surface-toolbar input[data-slot] { width: 50px; }
.surface-toolbar select[data-assignment] { max-width: 150px; }
.surface-pads [data-status="empty"] { color: #85817a; background: #242321; border-color: #383633; border-bottom-color: #504840; }
.surface-pads [data-status="ready"] { border-color: var(--pad); color: #faf7ef; }
.surface-pads [data-status="playing"] { color: #171716; 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-kind="scene"][data-status="ready"] { border-color: #faf7ef; border-bottom-color: #faf7ef; }
@keyframes scene-playing-pulse { to { background: color-mix(in srgb, var(--controller-blue) 65%, #242321); box-shadow: 0 0 12px color-mix(in srgb, var(--controller-blue) 55%, transparent); } }
@keyframes crossfade-flash { 50% { box-shadow: inset 0 0 0 2px var(--controller-blue); background: color-mix(in srgb, var(--controller-blue) 35%, #242321); color: #faf7ef; } }
.scene-row.is-crossfading, .surface-device .surface-pads [data-status='crossfading'], .surface-lower-buttons button[data-state='crossfading'] {
  border-color: var(--controller-blue); animation: crossfade-flash 1s steps(1) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .scene-row.is-crossfading, .surface-device .surface-pads [data-status='crossfading'], .surface-lower-buttons button[data-state='crossfading'] { animation: none; box-shadow: inset 0 0 0 2px var(--controller-blue); }
}
@media (prefers-reduced-motion: reduce) { .surface-lower-buttons button[data-mode='scene'][data-state='running'] { animation: none; box-shadow: inset 0 -2px var(--controller-blue); } }
.surface-pads [data-status="queued"] { background: color-mix(in srgb, var(--controller-amber) 20%, #242321); border-color: var(--controller-amber); border-bottom-color: var(--controller-amber); }
.surface-pads [data-status="loading"] { background: #292929; border-color: #faf7ef; border-bottom-color: #faf7ef; }
.surface-pads [data-status="failed"] { border-color: var(--controller-red); border-bottom-color: var(--controller-red); border-style: dashed; }
.surface-pads [aria-pressed="true"] { outline: 1px solid #faf7ef; 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: #171716; background: var(--pad); border-color: var(--pad); border-bottom-color: var(--pad); font-weight: 600; }
.surface-pads [data-status="off"] { color: #aaa69f; background: #242321; border-color: #504840; border-bottom-color: #646158; }
.surface-pads [data-status="unbound"] { color: #646158; background: #1c1b1a; border-color: #302d2a; border-bottom-color: #383633; }
.surface-pads { gap: 5px; padding: 4px; background: #b9bdbb; border-color: #969e9f; box-shadow: inset 0 1px 3px #0005; }
/* Unlit pads are white silicone. Assigned pads add a diffused LED underneath. */
@property --pad-level { syntax: '<percentage>'; inherits: false; initial-value: 100%; }
@keyframes surface-pad-pulse { 0%, 100% { --pad-level: 100%; } 50% { --pad-level: 0%; } }
.surface-device .surface-pads button {
  --pad-light: #ffffff;
  --pad-glow: transparent;
  --pad-inner: transparent;
  --pad-halo: transparent;
  --pad-edge: transparent;
  color: #424b56;
  background: radial-gradient(ellipse at 50% 48%, var(--pad-glow) 0%, var(--pad-glow) 7%, var(--pad-inner) 23%, var(--pad-halo) 48%, var(--pad-edge) 76%, transparent 100%), linear-gradient(#e8e9f0, #dedfe7);
  border: 1px solid #b7bac3;
  border-radius: 4px;
  box-shadow: inset 0 1px 2px #ffffffed, inset 1px 0 2px #ffffffa6, inset 0 -2px 2px #b7bac680, 0 1px 2px #3c424455;
  animation: none;
  font-weight: 400;
}
.surface-device .surface-pads :is([data-status="ready"], [data-status="loading"]) {
  --pad-glow: #ffffff;
  --pad-inner: #e2f9ff;
  --pad-halo: #d0c5ef;
  --pad-edge: #c9b5ce88;
}
.surface-device .surface-pads :is([data-status="on"], [data-status="playing"], [data-status="queued"], [data-status="failed"]) {
  --pad-glow: color-mix(in srgb, var(--pad-light) var(--pad-level), transparent);
  --pad-inner: color-mix(in srgb, var(--pad-glow) 94%, transparent);
  --pad-halo: color-mix(in srgb, var(--pad-glow) 70%, transparent);
  --pad-edge: color-mix(in srgb, var(--pad-glow) 24%, transparent);
}
.surface-device .surface-pads [data-status="ready"] { color: #293440; }
.surface-device .surface-pads [data-status="on"], .surface-device .surface-pads [data-status="playing"] { --pad-light: var(--pad); font-weight: 600; }
.surface-device .surface-pads [data-kind="scene"][data-status="playing"] { --pad-light: var(--controller-blue, #00bfde); }
.surface-device .surface-pads :is([data-kind="scene"], [data-kind="clip"])[data-status="playing"] { animation: surface-pad-pulse 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .surface-device .surface-pads [data-status="playing"] { animation: none; } }
.surface-device .surface-pads [data-status="queued"] { --pad-light: var(--controller-amber, #f6bc58); }
.surface-device .surface-pads [data-status="loading"] { --pad-light: #ffffff; }
.surface-device .surface-pads [data-status="failed"] { --pad-light: var(--controller-red, #ff4040); border-style: dashed; }
.surface-device .surface-pads [aria-pressed="true"] { outline: 1px solid #7b8f9b; outline-offset: 1px; }
.surface-device .surface-pads [data-blend-end] { position: relative; padding-top: 16px; }
.surface-device .surface-pads [data-blend-end]::before { position: absolute; top: 3px; right: 4px; padding: 0 3px; font: 700 10px/13px var(--mono); border-radius: 2px; color: #101214; pointer-events: none; }
.surface-device .surface-pads [data-blend-end="a"]::before { content: '↓ A'; background: var(--controller-amber); }
.surface-device .surface-pads [data-blend-end="b"]::before { content: '↑ B'; background: var(--controller-blue); color: #fff; }
.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: 0; }
.surface-pads button:disabled { opacity: 1; color: #69717c; }
.surface-device button:not(:disabled):active { transform: translateY(1px); box-shadow: inset 0 2px 4px #0008, inset 0 1px #656a6e, 0 1px 1px #0008; }
.surface-pads button:not(:disabled):hover { filter: brightness(1.025); }
.surface-device .surface-pads button:not(:disabled):active { box-shadow: inset 0 1px 3px #8a92a066, inset 0 -1px #ffffffa6, 0 1px 1px #3c424433; }
.surface-lower-buttons { margin: 0; }
.surface-lower-buttons button { height: 28px; border: 1px solid #0b0d0f; border-radius: 3px; background: linear-gradient(#303236, #222427 45%, #1c1e20); box-shadow: inset 0 1px #51555a, inset 0 -2px #131517, 0 3px 2px #0009; }
.surface-lower-buttons button[data-state='defined'] { box-shadow: inset 0 -3px var(--mod, #f4f7fa), inset 0 1px #51555a, 0 3px 2px #0009; }
.surface-lower-buttons button[data-state='running'], .surface-lower-buttons button[data-state='editing'] { color: var(--mod, #f4f7fa); background: linear-gradient(#34373a, #222427 45%, #1c1e20); border-color: #0b0d0f; box-shadow: inset 0 -3px var(--mod, #f4f7fa), inset 0 1px #5a5e62, 0 3px 2px #0009, 0 0 8px color-mix(in srgb, var(--mod, #f4f7fa) 35%, transparent); }
.surface-lower-buttons button[data-mode='scene'][data-state='running'] { color: #faf7ef; box-shadow: inset 0 -3px var(--controller-blue), inset 0 1px #5a5e62, 0 3px 2px #0009, 0 0 8px #00bfde66; }
.surface-lower-buttons button:hover:not(:disabled) { background: linear-gradient(#3b3e42, #292c2f 42%, #202225); }
.surface-status { color: #f6bc58; min-height: 1.4em; font-size: 11px; margin: 12px 0; overflow-wrap: anywhere; }
.performance-surface details { border-top: 1px solid #383633; padding-top: 12px; margin-top: 16px; color: #aaa69f; line-height: 1.6; }
.performance-surface summary { cursor: pointer; font-size: 11px; }
.performance-surface[open] { display: flex; flex-direction: column; height: 96vh; overflow: hidden; }
.performance-surface > header, .performance-surface > details { flex: 0 0 auto; }
.surface-device-viewport { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.surface-device-viewport > .surface-device { flex: none; box-sizing: border-box; }
@media (max-width: 900px) { .performance-surface { padding: 12px; } .surface-device { gap: 10px; padding: 14px 10px; } }

/* Shared hardware rows keep both side strips aligned with the display buttons. */
.surface-device { container-type: inline-size; grid-template-columns: minmax(130px, .25fr) minmax(0, 1fr) minmax(150px, .25fr); grid-template-rows: auto auto auto auto auto; column-gap: 30px; row-gap: 28px; padding: 34px 24px 22px; background: linear-gradient(120deg, #292a2b, #222324 65%, #272829); }
.surface-center, .surface-left-rail, .surface-right-rail { display: grid; grid-template-rows: subgrid; grid-row: 1 / 6; gap: inherit; min-width: 0; }
.surface-left-rail { grid-column: 1; }
.surface-center { grid-column: 2; }
.surface-right-rail { grid-column: 3; }
.surface-device-mark { align-self: center; margin: 0; opacity: .5; }
.surface-system-keys, .surface-right-system-keys { grid-row: 2; margin: 0; }
.surface-system-keys span, .surface-right-system-keys span, .surface-mode-keys span { height: auto; background: linear-gradient(#292b2d, #252729); color: #bbbacc; text-shadow: none; }
.surface-left-head { grid-row: 3; grid-template-columns: minmax(0, 1fr) 36px; min-height: 0; margin: 0; gap: 12px; }
.surface-left-dial { width: min(100%, clamp(65px, 6.5cqw, 120px)); }
.surface-rail-actions { height: 100%; align-content: space-between; gap: 8px; }
.surface-rail-actions button { min-height: 36px; height: 36px; padding: 0; font-size: 10px; }
.surface-mode-keys { grid-row: 4; margin: 0; }
.surface-left-lower { grid-row: 5; }
.surface-encoders { align-items: center; min-height: clamp(64px, 6.2cqw, 108px); }
.surface-encoder .surface-encoder-knob { width: clamp(32px, 3.1cqw, 56px); height: clamp(32px, 3.1cqw, 56px); min-height: 32px; background: radial-gradient(circle at 35% 28%, #303234, #202123 70%); box-shadow: inset 0 1px #515356, 0 4px 5px #0009; }
.surface-encoder[data-assigned='true'] .surface-encoder-knob { box-shadow: inset 0 1px #515356, 0 4px 5px #0009; }
.surface-encoder-knob::before { opacity: .45; inset: -3px; }
.surface-encoder-pointer::after { height: 8px; width: 2px; background: #9da6aa; }
.surface-encoder > div { position: absolute; top: calc(100% + 6px); opacity: 0; transition: opacity 100ms; }
.surface-encoder:hover > div, .surface-encoder:focus-within > div { opacity: 1; }
.surface-upper-buttons, .surface-lower-buttons { gap: 9px; }
.surface-upper-buttons button, .surface-lower-buttons button { position: relative; height: clamp(36px, 3.1cqw, 56px); min-height: 36px; background: linear-gradient(#2b2d2f, #242628); box-shadow: inset 0 1px #3c3f42, inset 0 -1px #191a1c, 0 2px 2px #0008; }
.surface-upper-buttons button::after { position: absolute; left: 10%; right: 10%; bottom: 8px; height: 3px; }
.surface-upper-buttons button[data-state='assigned']::after { background: #9aafb9; box-shadow: 0 0 3px #a8c9dd55; }
.surface-device .surface-lower-buttons button { font-size: 0; border-color: #0b0d0f; box-shadow: inset 0 1px #3c3f42, inset 0 -1px #191a1c, 0 2px 2px #0008; animation: none; }
.surface-lower-buttons button::after { content: ''; position: absolute; left: 10%; right: 10%; top: 8px; height: 3px; border-radius: 1px; background: #596269; }
.surface-lower-buttons button[data-state='defined']::after { background: var(--mod, #b1bdca); }
.surface-lower-buttons button[data-state='running']::after, .surface-lower-buttons button[data-state='editing']::after { background: var(--mod, #e8f5ff); box-shadow: 0 0 5px var(--mod, #e8f5ff); }
.surface-center canvas { box-sizing: border-box; width: 100%; align-self: center; box-shadow: 0 0 3px #000, inset 0 0 2px #000; }
.surface-jog-row { grid-row: 3; grid-template-columns: 36px minmax(0, 1fr); gap: 18px; }
.surface-jog-actions { align-content: space-between; gap: 8px; }
.surface-jog-actions button { min-height: 36px; height: 36px; }
.surface-jog { position: relative; }
.surface-jog .surface-jog-wheel { width: min(100%, clamp(90px, 10.5cqw, 195px)); background: radial-gradient(circle at 40% 30%, #2c2e30, #202123 75%); box-shadow: inset 0 1px #4a4d50, 0 5px 7px #0008; }
.surface-jog-nudge { position: absolute; top: calc(100% + 4px); opacity: 0; }
.surface-jog:hover .surface-jog-nudge, .surface-jog:focus-within .surface-jog-nudge { opacity: 1; }
.surface-right-page-row { position: relative; grid-row: 4; grid-template-columns: 36px minmax(0, 1fr); gap: 18px; }
.surface-right-page-row .surface-master { height: 36px; min-height: 36px; padding: 0; font-size: 8px; }
.surface-dpad { position: absolute; top: 0; left: 54px; right: 0; }
.surface-right-lower { grid-row: 5; grid-template-columns: 36px minmax(0, 1fr); gap: 18px; }
.surface-right-tools { padding-top: 100px; }
@media (max-width: 900px) { .surface-device { column-gap: 18px; row-gap: 22px; padding: 24px 16px 18px; } }

/* Workspace navigation: performance content stays separate from setup. */
#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; }

/* One navigation group: the selected section is always visible, including Settings. */

#icons #panic[hidden] { display: none; }
/* Group destinations by task, and keep secondary actions out of row layout. */
.idle-faded { opacity: 0 !important; pointer-events: none !important; }
.idle-faded * { pointer-events: none !important; }
#icons, #reference-side, #runtime-bar, #editor-hint, #code-layer, #code-completion { transition: opacity 250ms ease; }
@media (prefers-reduced-motion: reduce) { #icons, #reference-side, #runtime-bar, #editor-hint, #code-layer, #code-completion { transition: none; } }

/* Performance primitive editor: compact in Tools, spacious when expanded. */
#icons #toolbar-push3 { color: #faf7ef; background: #272320; border-color: #685143; }
#icons #toolbar-push3[data-connected='full'] { color: #171716; background: #ff572b; border-color: #ff572b; }
#icons #toolbar-push3[data-connected='partial'] { color: #ffb992; border-color: #b76a48; }
#icons .toolbar-menu .share-options { left: auto; right: 0; }
#icons .toolbar-menu summary { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#editor-hint #manual-help { pointer-events: auto; display: inline-block; text-decoration: none; font: 11px system-ui, sans-serif; margin-right: 12px; padding: 4px 7px; color: #d2d9d2; background: #20251f; border: 1px solid #4b534a; border-radius: 2px; }
#editor-hint #manual-help:hover { background: #30372e; }

/* Give the catalog's controls, patch categories, and secondary actions distinct levels. */
#reference-side .shader-operator-reference { margin: 14px 12px; padding: 0 12px; border: 1px solid #414941; border-radius: 3px; background: #252a25; }
#reference-side .shader-operator-reference > summary { padding: 10px 0; color: #e0e5dc; font-size: 12px; letter-spacing: 0; text-transform: none; }
#reference-side .shader-operator-body { font-size: 11px; overflow-wrap: anywhere; }
.snippet-picker { position: fixed; z-index: 1100; box-sizing: border-box; width: min(320px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow-y: auto; 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-top: 8px; padding: 7px 2px 0; border-top: 1px solid #455248; }
#snippet-manager > summary { cursor: pointer; color: #d6dfd2; font-size: 12px; }
#snippet-manager .hint { margin: 8px 0; font-size: 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}
}

/* Event identity is scoped so the original Thunk welcome can be restored intact. */
#start-overlay[data-brand="ut"] .welcome-card,
#start-overlay[data-brand="ut"] .welcome-hero,
#start-overlay[data-brand="ut"] .welcome-body,
#start-overlay[data-brand="ut"] .welcome-recent { background:#fff; }
#start-overlay[data-brand="ut"] .welcome-start { background:#f4f4f4; }
#start-overlay[data-brand="ut"] .welcome-hero { padding:28px 36px 22px; }
#start-overlay[data-brand="ut"] .welcome-hero .welcome-eyebrow { color:var(--aet-violet); font-size:12px; margin-bottom:22px; }
#start-overlay[data-brand="ut"] .welcome-brand-logo { display:block; width:100%; height:auto; margin-bottom:24px; }
#start-overlay[data-brand="ut"] .welcome-accessible-title { position:absolute; width:1px; height:1px; padding:0; margin:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
#start-overlay[data-brand="ut"] .welcome-project-title { font-size:28px; line-height:1.2; letter-spacing:0; margin:0 0 20px; }
#start-overlay[data-brand="ut"] button.start-primary { background:var(--aet-orange); border-color:var(--aet-orange); color:#171716; }
#start-overlay[data-brand="ut"] button.start-primary:hover:not(:disabled),
#start-overlay[data-brand="ut"] button.start-primary:focus-visible { background:color-mix(in srgb, var(--aet-orange) 85%, white); border-color:var(--aet-orange); color:#171716; }
#start-overlay[data-brand="ut"] .start-actions button:not(.start-primary) { color:var(--aet-violet); border-color:var(--aet-violet); background:transparent; }
#start-overlay[data-brand="ut"] .start-actions button:not(.start-primary):hover:not(:disabled) { background:color-mix(in srgb, var(--aet-violet) 7%, white); }
#start-overlay[data-brand="ut"] button:focus-visible { outline-color:var(--aet-violet); }
#start-overlay[data-brand="ut"] .welcome-recent-list button:hover,
#start-overlay[data-brand="ut"] .welcome-recent-list button.is-current { border-color:var(--aet-magenta); }

/* Suppress horizontal overscroll history swipes where supported. */
html, body { overscroll-behavior-x: none; }

.persistence-notice{position:fixed;z-index:900;top:12px;left:50%;transform:translateX(-50%);width:min(680px,calc(100% - 24px));padding:16px;background:#faf7ef;color:#171716;border:2px solid #b53816;box-shadow:0 6px 24px #0008;display:flex;flex-wrap:wrap;gap:12px;align-items:center}
.persistence-notice[hidden]{display:none}
.persistence-notice span,.persistence-notice strong,.persistence-notice small{flex-basis:100%}
.persistence-notice select{max-width:100%;min-width:0}
#persistence-warning:not([hidden]) + .recovery-notice{top:160px}

.memory-monitor pre { white-space: pre-wrap; font-size: 12px; line-height: 1.6; }
.memory-monitor p { font-size: 12px; opacity: .7; }
.memory-monitor label { display: inline-flex; align-items: center; gap: .4rem; margin-right: .8rem; }
#memory-overlay { position: fixed; bottom: 48px; right: 12px; z-index: 800; margin: 0;
  padding: 10px 12px; max-width: calc(100vw - 24px); box-sizing: border-box; white-space: pre-wrap;
  background: rgba(12, 12, 12, .88); color: #d6ddd5; border: 1px solid #535d53;
  font: 11px/1.5 monospace; pointer-events: none; }

/* Keep a tab conflict visible without covering the instrument or welcome screen. */
#persistence-warning.is-conflict { top: auto; bottom: 12px; width: auto; max-width: calc(100% - 24px); box-sizing: border-box; padding: 8px 12px; gap: 8px; background: #202420; color: #e1e7da; border: 1px solid #65705f; font: 12px/1.4 system-ui, sans-serif; }
#persistence-warning.is-conflict span { flex-basis: auto; }
#persistence-warning.is-conflict #persistence-help { flex-basis: 100%; max-width: 480px; }
#persistence-warning.is-conflict #persistence-help[hidden] ~ #persistence-export { display: none; }
#persistence-warning button { font: inherit; }

#icons #open-snippets, #icons #share-menu { display: none; }
.scene-save-controls { display: inline-flex; align-items: center; gap: 2px; padding: 2px; margin-inline: 4px; border: 1px solid #52564e; border-radius: 5px; background: #151815; }
.scene-save-controls > button { margin: 0; }
.scene-save-controls > button + button { border-left: 1px solid #ffffff18; }

/* Reserve the indicator space so the Save control never changes width. */
#nav-save-scene::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: #ff514d;
  vertical-align: middle;
  visibility: hidden;
}
#nav-save-scene.is-dirty::after { visibility: visible; }

#icons #fold-code { display: none; }

#audio-loading-hud { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10000; display: flex; align-items: center; gap: 18px; width: min(420px, calc(100vw - 40px)); box-sizing: border-box; padding: 24px; background: #202620; color: #faf7ef; border: 1px solid #65705f; border-radius: 8px; box-shadow: 0 12px 40px #0008; }
#audio-loading-hud[hidden] { display: none; }
#audio-loading-hud-label { overflow-wrap: anywhere; min-width: 0; font: 15px/1.5 system-ui, sans-serif; }
.audio-loading-spinner { flex: none; width: 24px; height: 24px; border: 3px solid #555247; border-top-color: #ff572b; border-radius: 50%; animation: audio-loading-spin .9s linear infinite; }
@keyframes audio-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .audio-loading-spinner { animation: none; } }

/* Performance browsing echoes the controller's horizontal display. */
.performance-card-preview { aspect-ratio: 16 / 10; background: #302839; display: grid; place-items: center; border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.performance-card-preview img { width: 100%; height: 100%; object-fit: cover; }
.performance-card-preview > span { font: 700 64px system-ui, sans-serif; color: #ff875e; }
.performance-card-current { display: block; font: 10px system-ui, sans-serif; letter-spacing: .14em; color: #ff9b73; margin-bottom: 6px; }
.performance-card-meta { display: block; margin-top: 8px; color: #bdb8ac; font: 13px system-ui, sans-serif; }

.audio-loading-detail { flex: 1; min-width: 0; }
#audio-loading-hud progress { width: 100%; height: 5px; display: block; margin-top: 12px; accent-color: #ff572b; }
#audio-loading-hud progress[hidden], .audio-loading-spinner[hidden] { display: none; }


/* A compact instrument switch for boolean control defaults. Keep the native
   checkbox semantics and keyboard behavior while drawing the visual track. */
#patch-library-name-form:not([hidden]) { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 12px; }
#patch-library-name-form label, #patch-library-error { grid-column: 1 / -1; }
#patch-library-error { color: #ffaaa5; margin: 0; }
/* Completion stays outside the code mirror and never takes keyboard focus. */
.code-completion {
  position: fixed;
  z-index: 1000;
  width: max-content;
  max-width: min(440px, calc(100vw - 16px));
  background: #222324;
  color: #dcdedf;
  border: 1px solid #444648;
  border-radius: 3px;
  box-shadow: 0 2px 6px #0003;
  font: 13px/1.4 monospace;
}
.code-completion [role="listbox"] { max-height: 190px; overflow-y: auto; padding: 2px; }
.code-completion [role="option"] { display: flex; gap: 18px; justify-content: space-between; padding: 2px 6px; cursor: pointer; }
.code-completion [aria-selected="true"] { background: #123e54; }
.code-completion-detail { color: #9da5aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-completion-signature { padding: 4px 7px; border-top: 1px solid #444648; overflow-wrap: anywhere; }
.code-completion [role="listbox"][hidden] + .code-completion-signature { border-top: 0; }
.code-completion-argument { padding: 0 7px 4px; color: #9da5aa; font-size: 12px; overflow-wrap: anywhere; }
.code-completion [hidden], .code-completion[hidden] { display: none; }

.editor-help-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#editor-hint .editor-help-row :is(#manual-help, #guide-open) { margin-right: 0; }
.editor-key-hint { white-space: nowrap; }

#runtime-draft-status:not([hidden]) {
  display: block;
  margin-bottom: 6px;
  color: #ffd594;
  font-weight: 600;
}

/* Guide targets remain visible until the learner completes or leaves the step. */
#new-blank-scene.guide-target { outline: 3px solid #ff572b; outline-offset: 4px; box-shadow: 0 0 0 7px rgba(255, 87, 43, .18); }

.library-directory-link { margin-left: auto; align-self: center; padding: 8px; font-size: 12px; white-space: nowrap; color: #aaa; text-decoration: none; border-radius: 4px; }
.library-directory-link:hover { color: var(--accent, #ff8059); background: rgba(255, 255, 255, .04); }
.library-directory-link:focus-visible { color: var(--accent, #ff8059); outline: 2px solid currentColor; outline-offset: 2px; }

/* Loading a performance is optional; audio rows start the instrument. */
#start-overlay .welcome-optional { display:block; font-size:11px; font-weight:400; color:#646158; margin-top:3px; }
#start-overlay .welcome-recent-action { align-self:flex-start; margin-top:4px; font:600 10px/1.4 'IBM Plex Mono',monospace; color:#a63a1b; }
#start-overlay .welcome-recent-list button[data-kind="performance"].is-current { background:#f1ece1; }
#start-overlay .welcome-recent-list button[data-kind="audio"] .welcome-recent-action { color:#171716; }
