/* Chirp Studio. Visual language: an instrument's printed faceplate. Cool aluminium panels (or dark
   graphite), hairlines, small mono labels, graphite knobs with a lit tick ring, square LEDs, segmented
   meters. One accent colour, Delft blue, marks what is active; the readouts styled as the pedal's
   screen glow a lighter blue on black. Two themes: the system's (prefers-color-scheme) unless the
   Theme button picks one, which sets data-theme on <html> (studio.js, setTheme). */
:root {
  --bg: #eceef2;
  --panel: #fafbfc;
  --panel-2: #e1e4ea;
  --ink: #0f1524;
  --ink-2: #626a7a;
  --line: #cdd2da;
  --hair: #0f1524;
  --accent: #1f305e;
  --accent-ink: #ffffff;
  --link: #7c4fa8;
  --green: #2f8a5b;
  --yellow: #ffc000;
  --red: #d63a2f;
  --white-knob: #f6f7f9;
  --knob: #0f1524;
  --knob-track: #d3d7df;
  --knob-cap: #2a2f3a;
  --grid: var(--line);
  --pedal: #e1e4ea;
  --pedal-2: #d4d8e0;
  --pedal-ink: #0f1524;
  --pedal-ink-2: #626a7a;
  --led-off: #b9bfca;
  --led-on: #2f5fd0;
  --ok: #2f8a5b;
  --warn: #b26a00;
  --mod: #2b4a9a;
  --sig: #2f8a5b;
  --screen-bg: #0b0f19;
  --screen: #8fb4ff;
  --screen-off: #252c3d;
  --radius: 4px;
  --mono: "JetBrains Mono", "IBM Plex Mono", "SF Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117;
    --panel: #161a22;
    --panel-2: #1f2430;
    --ink: #e8ebf1;
    --ink-2: #8a93a5;
    --line: #2b3140;
    --hair: #e8ebf1;
    --accent: #7d9be6;
    --accent-ink: #0b1020;
    --link: #b28be3;
    --white-knob: #e6e9ef;
    --knob: #e8ebf1;
    --knob-track: #343b4b;
    --knob-cap: #3a4150;
    --grid: #1f2430;
    --pedal: #181c25;
    --pedal-2: #232937;
    --pedal-ink: #e8ebf1;
    --pedal-ink-2: #8a93a5;
    --led-off: #39404f;
    --led-on: #8fb0ff;
    --warn: #e0a23a;
    --mod: #7d9be6;
  --sig: #5fbf8a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117;
  --panel: #161a22;
  --panel-2: #1f2430;
  --ink: #e8ebf1;
  --ink-2: #8a93a5;
  --line: #2b3140;
  --hair: #e8ebf1;
  --accent: #7d9be6;
  --accent-ink: #0b1020;
  --link: #b28be3;
  --white-knob: #e6e9ef;
  --knob: #e8ebf1;
  --knob-track: #343b4b;
  --knob-cap: #3a4150;
  --grid: #1f2430;
  --pedal: #181c25;
  --pedal-2: #232937;
  --pedal-ink: #e8ebf1;
  --pedal-ink-2: #8a93a5;
  --led-off: #39404f;
  --led-on: #8fb0ff;
  --warn: #e0a23a;
  --mod: #7d9be6;
  --sig: #5fbf8a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  padding: 18px 22px 36px;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1 { font: 700 18px/1.1 var(--sans); margin: 0; letter-spacing: -0.015em; }
h2 { font: 700 15px/1.2 var(--sans); margin: 0; letter-spacing: -0.01em; }
.sub { margin: 3px 0 0; color: var(--ink-2); font: 11px/1.4 var(--mono); }
a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }

/* Keys: flat, square-ish, mono caps. The primary key is Delft blue, a held key is black. */
button {
  padding: 6px 11px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; white-space: nowrap;
  font: 500 11px/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
  box-shadow: 0 1px 0 var(--line);
  transition: background 80ms, border-color 80ms, transform 60ms;
}
button:hover:not(:disabled) { border-color: var(--hair); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 60%, #000); }
select, input[type=text], input[type=search], input[type=number] {
  padding: 6px 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); min-width: 0;
  font: 12px var(--mono);
}
select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--ink-2); opacity: 0.8; }

/* ---- header */
.top {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding-bottom: 14px; border-bottom: 1px solid var(--hair);
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 36px; height: 36px; flex: none; border-radius: 3px; position: relative;
  background: var(--hair);
}
.logo::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%;
  border: 2px solid var(--bg); border-top-color: var(--accent);
  transform: rotate(-45deg);
}
.transport { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 3px; font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.field.inline { flex-direction: row; align-items: center; gap: 6px; }
.field.check input { accent-color: var(--accent); margin: 0; }
.field select { color: var(--ink); font-size: 12px; text-transform: none; letter-spacing: 0; }
#play { min-width: 64px; }

/* Segmented LED meters. */
.meters { display: grid; gap: 4px; width: 150px; }
.meter { display: grid; grid-template-columns: 10px 1fr; gap: 6px; align-items: center; font: 10px var(--mono); color: var(--ink-2); }
.bar {
  height: 8px; border-radius: 1px; overflow: hidden; position: relative;
  background: repeating-linear-gradient(90deg, var(--knob-track) 0 5px, transparent 5px 7px);
}
.bar > div {
  height: 100%; width: 0; transition: width 60ms linear;
  background: repeating-linear-gradient(90deg, var(--green) 0 5px, transparent 5px 7px);
}
.meter .bar > div {
  background:
    repeating-linear-gradient(90deg, transparent 0 5px, var(--bg) 5px 7px),
    linear-gradient(90deg, var(--green) 0 105px, var(--yellow) 105px 125px, var(--red) 125px);
  background-size: 7px 100%, 140px 100%;
}
.budget { display: grid; grid-template-columns: auto 90px auto; gap: 6px; align-items: center; font: 10px var(--mono); color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.08em; }
.budget output { font: 600 11px var(--mono); color: var(--ink); letter-spacing: 0; }
.budget .bar > div { background: repeating-linear-gradient(90deg, var(--accent) 0 5px, transparent 5px 7px); }
.budget.over .bar > div { background: repeating-linear-gradient(90deg, var(--red) 0 5px, transparent 5px 7px); }

.tuner { display: grid; grid-template-columns: 44px 120px 52px; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.tuner-note { font: 700 20px var(--mono); text-align: center; }
.tuner-cents { font: 11px var(--mono); color: var(--ink-2); }
.tuner-scale { position: relative; height: 16px; border-radius: 2px; border: 1px solid var(--line); background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 12px) 0 50% / 100% 6px no-repeat, var(--panel); }
.tuner-scale::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--hair); }
/* Colour says how close: red far off, amber within 15 cents, green in tune (3 cents). The scale
   carries the same colours as a band, green in the middle. */
.tuner { --tune: var(--red); --amber: #f0a500; }
.tuner.close { --tune: var(--amber); }
.tuner.in-tune { --tune: var(--green); }
.tuner.silent { --tune: var(--ink-2); }
.tuner-scale { background:
  linear-gradient(90deg, var(--red), var(--amber) 34%, var(--green) 47% 53%, var(--amber) 66%, var(--red)) 0 100% / 100% 3px no-repeat,
  repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 12px) 0 50% / 100% 6px no-repeat, var(--panel); }
.tuner-needle { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 1px; background: var(--tune); box-shadow: 0 0 6px var(--tune); left: 50%; transition: left 80ms linear, background 120ms; }
.tuner .tuner-note { color: var(--tune) !important; transition: color 120ms; }
.tuner .tuner-cents { color: var(--tune); }
.tuner.in-tune .tuner-note { box-shadow: 0 0 0 2px var(--green); }
#tunerBtn[aria-pressed=true] { background: var(--hair); color: var(--bg); border-color: var(--hair); }

/* ---- A/B against bypass */
.ab { display: flex; align-items: center; gap: 8px; }
#abBtn[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ab-match { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); font-family: var(--mono); cursor: pointer; }
.ab-level { min-width: 6.5em; padding-left: 8px; border-left: 1px solid var(--line); font-size: 12px; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---- layout */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; margin-top: 16px; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.library {
  display: flex; flex-direction: column; gap: 8px; align-self: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
  max-height: calc(100vh - 120px); position: sticky; top: 12px;
}
@media (max-width: 860px) { .library { position: static; max-height: min(560px, 80vh); } }
.library > :not(.lib-list) { flex: none; }
.tabs { display: flex; gap: 0; border: 1px solid var(--hair); border-radius: var(--radius); overflow: hidden; }
.tabs button { flex: 1; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.tabs button + button { border-left: 1px solid var(--hair); }
.tabs button[aria-selected=true] { background: var(--hair); color: var(--bg); }
.lib-list { list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--line); }
.lib-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 9px 2px;
  border-bottom: 1px solid var(--line); background: transparent;
}
.lib-item:hover { background: var(--panel-2); }
.lib-item .name { font-weight: 700; letter-spacing: -0.01em; }
.lib-item .meta { grid-column: 1 / -1; font: 10.5px var(--mono); color: var(--ink-2); }
.lib-item .desc { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-item button { padding: 3px 8px; align-self: start; }
/* Filters, staff picks, remix families and creators (studio.js, renderLibrary) */
.lib-filters { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.lib-filters .chip { padding: 2px 8px; font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.05em; }
.lib-filters .chip[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.lib-filters select { margin-left: auto; font-size: 11px; padding: 2px 4px; }
.lib-item .meta button.linkish, .lib-view-head button.linkish { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; text-transform: none; letter-spacing: 0; box-shadow: none; }
.lib-item .meta button.tag { display: inline-block; font: 10px var(--mono); padding: 0 5px; border-radius: 2px; border: 1px solid var(--line); color: var(--ink); background: transparent; margin-right: 3px; text-transform: none; letter-spacing: 0; box-shadow: none; cursor: pointer; }
.lib-item .meta button.tag:hover { border-color: var(--accent); color: var(--accent); }
.lib-item .mine-actions { grid-column: 1 / -1; display: flex; gap: 14px; }
.lib-item .mine-actions button.linkish { padding: 0; border: 0; background: none; color: var(--accent); font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; box-shadow: none; }
button.danger { background: #b3261e; border-color: #b3261e; color: #fff; }
.lib-item .why { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--ink); }
.lib-item .note { grid-column: 1 / -1; font-size: 12px; color: var(--ink); border-left: 2px solid var(--accent); padding-left: 6px; }
.lib-item.pick .name::before { content: "★ "; color: var(--accent); }
.lib-item.current { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.lib-item .lic { cursor: help; border-bottom: 1px dotted var(--ink-2); }
.lib-actions { flex-wrap: wrap; }
#myName { flex-basis: 100%; text-transform: none; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }
.lib-item[style*="--depth"] { padding-left: calc(10px + (var(--depth) - 1) * 14px); border-left: 2px solid var(--line); }
.lib-section { list-style: none; padding: 8px 10px 4px; font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.lib-view-head { list-style: none; display: grid; gap: 3px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); }
.lib-view-head b { font-size: 15px; }
.lib-view-head .sub { font-size: 12px; color: var(--ink-2); }
.tag { display: inline-block; font: 10px var(--mono); padding: 0 5px; border-radius: 2px; border: 1px solid var(--line); color: var(--ink); margin-right: 3px; }
.lib-actions { display: flex; gap: 6px; }
.lib-actions button { flex: 1; }

/* ---- what a shared link brought */
.shared {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.shared-text { display: grid; gap: 3px; flex: 1 1 320px; min-width: 0; }
.shared-label { font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.shared-title { font-size: 14px; }
.shared-title b { font-size: 16px; }
.shared-more { font-size: 12.5px; color: var(--ink-2); }
.shared-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.shared-close { padding-inline: 10px; }
.shared .lic { cursor: help; border-bottom: 1px dotted var(--ink-2); }

/* ---- the board bar */
.boardbar {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
}
.board-name { font: 700 16px var(--sans) !important; letter-spacing: -0.01em; flex: 0 1 220px; border-color: transparent !important; background: transparent !important; padding-left: 2px !important; }
.board-name:hover, .board-name:focus { border-color: var(--line) !important; }
.snapshots { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 200px; }
.snapshots button.active { background: var(--hair); color: var(--bg); border-color: var(--hair); }
.snapshots .fs { font-size: 9px; color: var(--accent); margin-left: 5px; }
.snapshots button.active .fs { color: var(--accent); opacity: 1; }
.morph input { width: 110px; }
.board-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* Numbers that read like the pedal's little screen: light blue on black. */
.tempo input, .budget output, .tuner-note {
  background: var(--screen-bg) !important; color: var(--screen) !important; border-color: var(--screen-bg) !important;
  border-radius: 3px; font: 600 13px var(--mono); text-align: center;
}
.tempo input { width: 62px; }
.budget output { padding: 3px 6px; font-size: 11px; }
.tuner-note { padding: 1px 0; font-size: 18px; }
#tap.flash { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* ---- the looper */
.looper {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-top: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px;
}
.looper-title { font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); margin-right: 2px; }
.looper button { display: inline-flex; align-items: center; gap: 6px; font: 11px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.looper .led { width: 7px; height: 7px; border-radius: 1px; background: var(--led-off); }
.looper button.lit .led { background: var(--accent); }
.looper button.rec .led { background: var(--red); }
.loop-show {
  flex: 1 1 220px; min-width: 0; display: grid; gap: 4px; padding: 5px 9px; border-radius: 3px; background: var(--screen-bg);
  font: 600 12px var(--mono); color: var(--screen); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.loop-show.rec { color: #ff5a4b; }
.loop-show.empty { color: #8c8a85; }
.loop-bar { height: 2px; background: var(--screen-off); }
.loop-bar > div { height: 100%; width: 0; background: currentColor; }
.looper input[type="range"] { width: 90px; accent-color: var(--accent); }
.pedal-status { margin: 8px 2px 0; font: 11px var(--mono); color: var(--ink-2); }
.pedal-status.ok { color: var(--ok); }

/* ---- modules on the board */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; counter-reset: slot; }
.row-head { grid-column: 1 / -1; font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2);
  border-bottom: 1px solid var(--line); padding: 4px 2px 6px; margin-bottom: -4px; }
.row-head strong { color: var(--ink); font-weight: 700; }
.row-head ~ .row-head { margin-top: 6px; }
@media (max-width: 1200px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .board { grid-template-columns: 1fr; } }

.pedal {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 300px;
  background: var(--pedal); color: var(--pedal-ink); border-radius: 6px; padding: 12px;
  border: 1px solid var(--line);
  box-shadow: none;
  counter-increment: slot;
}
.pedal::before {
  content: counter(slot, decimal-leading-zero); position: absolute; top: 12px; right: 12px;
  font: 700 10px var(--mono); color: var(--bg); background: var(--hair); padding: 2px 5px; border-radius: 2px;
}
.pedal.off { opacity: 0.6; }
.pedal.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.pedal.empty {
  background: transparent; color: var(--ink-2); border: 1px dashed var(--ink-2); box-shadow: none;
  align-items: center; justify-content: center; text-align: center; font: 11px/1.5 var(--mono);
}
.pedal.empty::before { background: var(--ink-2); }
.pedal.empty.short { min-height: 64px; }
.pedal:not(.empty) .pedal-head { cursor: grab; }
.pedal.dragging { opacity: 0.4; }
.pedal.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }
.pedal-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; padding-right: 30px; border-bottom: 1px solid var(--hair); padding-bottom: 8px; }
.pedal-name { font: 600 14.5px/1.15 var(--sans); letter-spacing: -0.01em; }
.pedal-by { font: 10px var(--mono); color: var(--pedal-ink-2); margin-top: 2px; }
.units { font: 10px var(--mono); color: var(--pedal-ink-2); white-space: nowrap; }
.pedal select { background: var(--panel); border-color: var(--line); color: var(--pedal-ink); width: 100%; }
.pedal .field { color: var(--pedal-ink-2); }
.pedal-screen { display: block; width: 100%; height: 28px; background: var(--screen-bg); border-radius: var(--radius); }
.knobs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 2px; }
.knob { display: flex; flex-direction: column; align-items: center; gap: 1px; outline-offset: 0; border-radius: 4px; }
.knob svg { width: 60px; height: 60px; touch-action: none; cursor: ns-resize; overflow: visible; }
.knob .tick { stroke: var(--pedal-ink); stroke-width: 1.4; stroke-linecap: square; opacity: 0.22; }
.knob .tick.lit { stroke: var(--accent); opacity: 1; }
.knob .cap { fill: var(--knob-cap); }
.knob .pointer { stroke: #f4f4f1; }
.knob .name { font: 10px var(--mono); color: var(--pedal-ink-2); text-align: center; line-height: 1.1; text-transform: uppercase; letter-spacing: 0.06em; }
.knob .val { font: 600 11px var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.knob:focus-visible { outline: 2px solid var(--accent); }
.pedal-foot { margin-top: auto; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--hair); padding-top: 10px; }
.stomp {
  display: flex; align-items: center; gap: 6px; background: var(--panel); color: var(--pedal-ink);
}
.led { width: 8px; height: 8px; border-radius: 1px; background: var(--led-off); }
.stomp[aria-pressed=true] .led { background: var(--led-on); box-shadow: 0 0 3px color-mix(in srgb, var(--led-on) 60%, transparent); }
.pedal-foot button { letter-spacing: 0.02em; padding: 5px 7px; }
.pedal-foot .ghost { background: transparent; color: var(--pedal-ink); border-color: var(--line); box-shadow: none; }
.remix-of { font: 10px var(--mono); color: var(--pedal-ink-2); }
.lane { display: inline-block; font: 700 10px var(--mono); letter-spacing: 0.06em; padding: 1px 6px; border-radius: 2px;
  background: var(--hair); color: var(--bg); margin-top: 2px; text-transform: uppercase; }
.move { display: flex; gap: 2px; }
.move button { padding: 2px 7px; }

/* ---- the effect creator */
.creator {
  margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.creator-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--hair); padding-bottom: 10px; }
.creator-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.compile-status { margin: 8px 0; font: 11.5px var(--mono); }
.compile-status::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 1px; margin-right: 7px; vertical-align: 0; background: currentColor; }
.compile-status.ok { color: var(--ok); }
.compile-status.bad { color: var(--warn); }
#editor {
  width: 100%; height: 560px; resize: vertical; padding: 10px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel-2); font: 12.5px/1.45 var(--mono); tab-size: 2;
}
.view-tabs { display: inline-flex; border: 1px solid var(--hair); border-radius: var(--radius); overflow: hidden; }
.view-tabs button { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.view-tabs button + button { border-left: 1px solid var(--hair); }
.view-tabs button.on { background: var(--hair); color: var(--bg); }

/* The node editor (node_editor.js): palette, canvas, inspector. */
.ne { display: grid; grid-template-columns: 150px minmax(0, 1fr) 270px; gap: 10px; min-height: 520px; }
@media (max-width: 1100px) { .ne { grid-template-columns: 130px minmax(0, 1fr); } .ne-inspector { grid-column: 1 / -1; } }
@media (max-width: 640px) { .ne { grid-template-columns: 1fr; } .ne-palette { max-height: 180px; } }
.ne-palette { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-height: 560px; }
.ne-palette-head, .ne-section { font: 700 10px var(--mono); color: var(--ink); text-transform: uppercase; letter-spacing: 0.1em; }
.ne-palette input { width: 100%; padding: 5px 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.ne-blocks { overflow: auto; display: flex; flex-direction: column; gap: 3px; padding-right: 2px; }
.ne-cat { font: 10px var(--mono); color: var(--ink-2); margin: 8px 0 2px; text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.ne-block { text-align: left; padding: 4px 8px; font: 11.5px var(--mono); text-transform: none; letter-spacing: 0; cursor: grab; }
.ne-block:hover { background: var(--hair) !important; color: var(--bg); }
.ne-center { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ne-canvas {
  overflow: auto; height: 520px; background-color: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; outline: none;
}
.ne-canvas:focus-visible { border-color: var(--accent); }
.ne-svg { display: block; touch-action: none; user-select: none; }
.ne-hint { font: 10.5px var(--mono); color: var(--ink-2); }
.ne-canvas-box { position: relative; }
.ne-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.ne-tools button { background: var(--panel); }
.ne-node { cursor: grab; }
.ne-node .ne-body { fill: var(--panel); stroke: var(--hair); stroke-width: 1; }
.ne-node .ne-head { fill: var(--panel); }
.ne-node.control .ne-head { fill: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.ne-node.io .ne-body, .ne-node.io .ne-head { fill: var(--hair); stroke: var(--hair); }
.ne-node.io text { fill: var(--bg); }
.ne-node.picked .ne-body { stroke: var(--accent); stroke-width: 2.4; }
.ne-node.driven .ne-body { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }
.ne-driven-row { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.ne-cost { fill: var(--ink-2); font-weight: 700; }
.ne-cost.heavy { fill: var(--warn); }
.ne-value[data-knob] { cursor: help; }
.ne-swap select { width: 100%; margin: 2px 0 8px; }
/* The scope beside a port the pointer rests on (studio.js, showScope). */
.ne-scope { position: fixed; z-index: 50; pointer-events: none; background: var(--screen-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 6px 3px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.25); }
.ne-scope canvas { display: block; width: 180px; height: 60px; }
.ne-scope span { display: block; font: 10px var(--mono); color: var(--screen); margin-top: 2px; white-space: nowrap; }
.ne-node.problem .ne-body { stroke: var(--red); stroke-width: 2.2; stroke-dasharray: 5 3; }
.ne-title { font: 600 12px var(--sans); fill: var(--ink); }
.ne-kind { font: 9.5px var(--mono); fill: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.ne-label { font: 10.5px var(--mono); fill: var(--ink); }
.ne-label.param { fill: var(--ink-2); }
.ne-label.out { fill: var(--ink-2); font-size: 10px; }
.ne-value { font: 10px var(--mono); fill: var(--ink-2); }
.ne-value.on-knob { fill: var(--accent); font-weight: 700; }
.ne-port { stroke: var(--panel); stroke-width: 1.5; cursor: crosshair; }
.ne-port.audio, .ne-port.out { fill: var(--sig); }  /* sound */
.ne-port.out.ctl { fill: var(--mod); }  /* control: what moves settings */
.ne-port.late { fill: var(--link); }
.ne-port.node { fill: var(--link); }
.ne-port.param { fill: var(--panel); stroke: var(--mod); stroke-width: 1.8; }
.ne-port.param.modded { fill: var(--mod); }
.ne-port:hover { stroke: var(--accent); stroke-width: 3; }
.ne-wire { fill: none; stroke: var(--hair); stroke-width: 1.6; opacity: 0.85; pointer-events: none; }
.ne-wire.late { stroke: var(--link); stroke-dasharray: 6 4; }
.ne-wire.ref { stroke: var(--link); stroke-dasharray: 2 4; }
.ne-wire.mod { stroke: var(--mod); stroke-dasharray: 3 3; }
.ne-wire.ctl { stroke: var(--mod); }
.ne-wire.driven { stroke: var(--accent); stroke-width: 3; opacity: 1; }
.ne-wire.picked { stroke: var(--accent); stroke-width: 3; opacity: 1; }
.ne-wire.dragging { stroke: var(--accent); stroke-dasharray: 4 3; opacity: 1; }
.ne-hit { fill: none; stroke: transparent; stroke-width: 12; cursor: pointer; }
.ne-inspector {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; font-size: 12.5px;
  display: flex; flex-direction: column; gap: 8px; max-height: 560px; overflow: auto; min-width: 0;
}
.ne-insp-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.ne-name { flex: 1; min-width: 0; font: 700 13px var(--sans); padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); }
.ne-desc, .ne-text, .ne-tags { width: 100%; padding: 5px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); font: inherit; }
.ne-text { font: 12px var(--mono); }
.ne-tag { font: 10.5px var(--mono); color: var(--ink-2); }
.ne-doc { margin: 0; color: var(--ink-2); font-size: 12px; }
.ne-check { display: inline-flex; gap: 5px; align-items: center; font: 11px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.ne-check input, .ne-param input[type=checkbox] { accent-color: var(--accent); }
.ne-param { border-top: 1px solid var(--line); padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.ne-param-name { font: 11.5px var(--mono); }
.ne-param-name span { color: var(--ink-2); }
.ne-slider { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 6px; align-items: center; }
.ne-slider input[type=range], .ne-face-row input[type=range] { width: 100%; accent-color: var(--accent); }
.ne-slider input[type=number], .ne-range input { width: 100%; padding: 2px 4px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); color: var(--ink); font: 11px var(--mono); }
.ne-range { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 4px; align-items: center; font: 10.5px var(--mono); color: var(--ink-2); }
.ne-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
.ne-small { padding: 2px 7px; font-size: 10.5px; }
.ne-on { font: 11px var(--mono); color: var(--accent); display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.ne-danger { align-self: flex-start; color: var(--red); }
.ne-face-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto auto; gap: 4px; align-items: center; }
.ne-face-row input:not([type=range]) { min-width: 0; padding: 3px 5px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); color: var(--ink); }
.ne-face-what { grid-column: 1 / -1; font: 10.5px var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }

.foot { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); font: 10.5px/1.6 var(--mono); color: var(--ink-2); }
/* Sheets: sharing, remixing and your name, as a small dialog over the page. */
.sheet {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-top: 4px solid var(--accent);
  border-radius: 6px; box-shadow: 0 18px 48px rgb(0 0 0 / 0.35);
}
.sheet.wide { width: min(600px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgb(8 10 16 / 0.55); }
.sheet-body { display: grid; gap: 12px; padding: 16px 18px 18px; min-width: 0; }
.sheet-body > * { min-width: 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-x { border: none; background: none; font-size: 20px; line-height: 1; padding: 2px 6px; color: var(--ink-2); }
.sheet-note { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.sheet-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.sheet-fields.one { grid-template-columns: 1fr; }
.sheet-fields label, label.sheet-fields { display: grid; gap: 4px; }
.sheet-fields span { font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.sheet-body input[type=text], .sheet-body select, .sheet-body textarea { width: 100%; box-sizing: border-box; font: 13px var(--sans); padding: 7px 9px; }
.sheet-body textarea { resize: vertical; }
.sheet-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.4; }
.sheet-check input { margin-top: 2px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.share-preview {
  display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.starts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.start { display: grid; gap: 4px; text-align: left; padding: 10px 12px; text-transform: none; letter-spacing: 0; align-content: start; white-space: normal; min-width: 0; }
.start b { font: 600 13.5px var(--sans); color: var(--ink); }
.start span { font: 12px/1.4 var(--sans); color: var(--ink-2); white-space: normal; }
.start:hover { border-color: var(--accent); }
.share-link { font: 11.5px var(--mono) !important; color: var(--ink-2); }
.sheet [hidden] { display: none !important; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--hair); color: var(--bg); padding: 9px 14px; border-radius: var(--radius); font: 11.5px var(--mono);
  border-left: 4px solid var(--accent);
  transition: opacity 160ms, transform 160ms; pointer-events: none; max-width: min(90vw, 560px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Creator tools: listening at one block, quick add, recipes, port hints, the scope. */
.ne-probe {
  position: absolute; left: 8px; top: 8px; display: flex; gap: 8px; align-items: center;
  background: var(--hair); color: var(--bg); padding: 4px 6px 4px 10px; border-radius: var(--radius);
  font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
}
.ne-probe .ne-small { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 40%, transparent); box-shadow: none; }
.ne-probe-dot { width: 8px; height: 8px; border-radius: 1px; background: var(--accent); animation: ne-blink 1s steps(2, start) infinite; }
@keyframes ne-blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .ne-probe-dot { animation: none; } }
.ne-node.probed .ne-body { stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 6 3; }
.ne-probe-badge { font: 700 9px var(--mono); fill: var(--accent); letter-spacing: 0.08em; }
.ne-listen.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ne-svg.wiring .ne-port.in { opacity: 0.25; }
.ne-svg.wiring .ne-port.in.ok { opacity: 1; stroke: var(--accent); stroke-width: 2; }
.ne-block.recipe { border-color: var(--hair); font-family: var(--sans); font-weight: 600; }
.ne-quick {
  position: absolute; z-index: 5; width: 250px; background: var(--panel); border: 1px solid var(--hair);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.18); padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.ne-quick input { width: 100%; }
.ne-quick-list { max-height: 220px; overflow: auto; display: flex; flex-direction: column; }
.ne-quick-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; border: 0; box-shadow: none;
  background: transparent; padding: 4px 6px; text-transform: none; letter-spacing: 0; white-space: normal;
}
.ne-quick-item b { font: 600 12px var(--mono); }
.ne-quick-item.recipe b { font-family: var(--sans); }
.ne-quick-item span { font: 11px var(--sans); color: var(--ink-2); }
.ne-quick-item.on, .ne-quick-item:hover { background: var(--hair) !important; color: var(--bg); }
.ne-quick-item.on span, .ne-quick-item:hover span { color: color-mix(in srgb, var(--bg) 75%, transparent); }
.scope { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); height: 110px; }
.scope-canvas { display: block; width: 100%; height: 100%; }
.scope-label {
  position: absolute; right: 6px; top: 5px; font: 600 9.5px var(--mono); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-2); background: var(--panel); padding: 0 4px;
}
.scope-label.probe { color: var(--accent); }

/* Accounts (account-ui.js): the header button, logging in, your account. */
.acct-btn { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.acct-btn.in { text-transform: none; letter-spacing: 0; font: 600 12px var(--sans); }
.acct-btn.in::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 7px; vertical-align: 1px; }
.acct-google { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; font: 600 13.5px var(--sans); text-transform: none; letter-spacing: 0; }
.acct-google .g { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #4285f4; font: 700 13px var(--sans); border: 1px solid #dadce0; }
.acct-or { display: flex; align-items: center; gap: 10px; font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-2); }
.acct-or::before, .acct-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.acct-form { display: grid; gap: 10px; }
.acct-form input { width: 100%; box-sizing: border-box; font: 13.5px var(--sans); padding: 8px 10px; }
.acct-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
button.linkish { padding: 0; border: 0; background: none; color: var(--accent); font: 12.5px var(--sans); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; text-transform: none; letter-spacing: 0; box-shadow: none; }
.sheet-error { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--red); min-height: 0; }
.sheet-error:empty { display: none; }
.acct-local { margin: 0; padding: 6px 10px; border-radius: var(--radius); font: 11px var(--mono); background: color-mix(in srgb, var(--yellow) 18%, var(--panel)); color: var(--ink); }
.acct-h { margin: 4px 0 0; font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-2); font-weight: 400; }
.acct-pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.acct-pubs li:not(.sheet-note) { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.acct-pub-name { font: 600 13.5px var(--sans); }
.acct-pub-meta { grid-column: 1; font: 10.5px var(--mono); color: var(--ink-2); }
.acct-pubs button.linkish { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.acct-profile .sheet-actions { justify-content: space-between; align-items: center; }
.acct-public { font: 12.5px var(--sans); }

/* Touch screens: the small buttons get a finger-sized target (24px or more) without growing on a
   desktop. */
@media (pointer: coarse) {
  .lib-item button, .move button, .lib-filters .chip { min-height: 30px; }
  .lib-filters select { min-height: 30px; }
  .lib-item .meta button.tag, .lib-item .meta button.linkish { padding-top: 6px; padding-bottom: 6px; }
  .lib-item .meta button.tag { margin-bottom: 3px; }
  input[type=checkbox] { width: 20px; height: 20px; }
}
