/* The GUI builder page. Two halves: the builder's own chrome (gb-*), and the
   FoxSDR template it edits (fx-*), which takes every colour, font and size from
   custom properties builder.js sets on #fx from the foxsdr-ui/1 document.
   The fonts are the site's own files; the CSP allows nothing from elsewhere. */

@font-face {
  font-family: "Merriweather";
  src: url("/assets/fonts/merriweather-300-900.woff2") format("woff2");
  font-weight: 300 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  --gb-bg: #1b1812; --gb-panel: #25211a; --gb-panel2: #2e2920; --gb-line: #4a4234;
  --gb-text: #efe7d2; --gb-muted: #b9ad94; --gb-amber: #f0a840; --gb-green: #8fd9a0; --gb-red: #ff8a6a;
  --gb-focus: #7df3ff;
  --gb-serif: "Merriweather", Georgia, serif;
  --gb-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--gb-bg); color: var(--gb-text); font: 14px/1.45 var(--gb-serif); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gb-focus); outline-offset: 2px; }
.gb-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gb-skip { position: absolute; left: -999px; top: 0; background: var(--gb-amber); color: #14110c; padding: 6px 10px; z-index: 50; }
.gb-skip:focus { left: 8px; }

/* ---- top bar ---- */
.gb-top { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 18px; padding: 10px 16px;
  background: linear-gradient(180deg, #3b3427, #2a251c); border-bottom: 1px solid var(--gb-line); }
.gb-brand { display: flex; align-items: center; gap: 10px; align-self: center; }
.gb-lamp { width: 12px; height: 12px; border-radius: 50%; background: var(--gb-green); box-shadow: 0 0 8px var(--gb-green); }
.gb-top h1 { margin: 0; font-size: 20px; font-weight: 400; letter-spacing: .02em; }
.gb-top h1 b { color: var(--gb-amber); font-weight: 700; }
.gb-top h1 span { font-family: var(--gb-mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--gb-muted); margin-left: 6px; }
.gb-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; flex: 1 1 520px; }
.gb-meta label { display: flex; flex-direction: column; gap: 2px; font-family: var(--gb-mono); font-size: 11px; letter-spacing: .08em; color: var(--gb-muted); text-transform: uppercase; }
.gb-meta label small { text-transform: none; letter-spacing: 0; }
.gb-meta input, .gb-meta textarea { background: #0d0b07; border: 1px solid var(--gb-line); border-radius: 3px; padding: 5px 8px;
  color: var(--gb-amber); font-family: var(--gb-mono); font-size: 13px; letter-spacing: 0; text-transform: none; }
#gb-name { width: 200px; } #gb-version { width: 90px; } #gb-author { width: 160px; }
.gb-desc { flex: 1 1 220px; } .gb-desc textarea { width: 100%; resize: vertical; min-height: 30px; }
.gb-meta [aria-invalid="true"] { border-color: var(--gb-red); box-shadow: 0 0 0 1px var(--gb-red); }
.gb-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.gb-actions button, .gb-props button, .gb-block button {
  padding: 6px 12px; border: 1px solid var(--gb-line); border-radius: 3px; cursor: pointer;
  background: linear-gradient(180deg, #8b8069, #6e6552); color: #14110c; font-family: var(--gb-mono); font-size: 12px; letter-spacing: .06em; }
.gb-actions button:disabled, .gb-block button:disabled { opacity: .45; cursor: not-allowed; }
.gb-actions .gb-primary { background: linear-gradient(180deg, #f5b95c, #d38b22); font-weight: 500; }
.gb-actions .gb-secondary { background: linear-gradient(180deg, #b3a78c, #8b8069); }
.gb-status { margin: 0; min-height: 30px; padding: 5px 16px; font-family: var(--gb-mono); font-size: 13px; color: var(--gb-green);
  background: #13110c; border-bottom: 1px solid var(--gb-line); }
.gb-status.gb-bad { color: var(--gb-red); }

/* ---- three columns ---- */
.gb-main { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; gap: 12px; padding: 12px 16px 24px; align-items: start; }
.gb-main h2 { margin: 0 0 6px; font-size: 13px; font-family: var(--gb-mono); letter-spacing: .25em; text-transform: uppercase; color: var(--gb-muted); font-weight: 500; }
.gb-hint { font-size: 12px; color: var(--gb-muted); margin: 6px 0 10px; }
.gb-palette, .gb-props { background: var(--gb-panel); border: 1px solid var(--gb-line); border-radius: 4px; padding: 10px; max-height: calc(100vh - 150px); overflow: auto; position: sticky; top: 8px; }
@media (max-width: 1150px) {
  .gb-main { grid-template-columns: minmax(0, 1fr); }
  .gb-palette, .gb-props { position: static; max-height: none; }
}

/* ---- palette ---- */
.gb-group h3 { margin: 10px 0 4px; font: 500 11px var(--gb-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--gb-amber); }
.gb-parts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.gb-parts-swatches { grid-template-columns: repeat(8, 1fr); }
.gb-part { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 5px 6px; min-height: 34px; text-align: left;
  background: var(--gb-panel2); border: 1px solid var(--gb-line); border-radius: 3px; cursor: grab; font-size: 12px; line-height: 1.2; }
.gb-part:hover { border-color: var(--gb-amber); }
.gb-part[aria-pressed="true"] { border-color: var(--gb-focus); box-shadow: 0 0 0 2px var(--gb-focus) inset; background: #1d3038; }
.gb-part-swatch { padding: 3px; min-height: 0; align-items: stretch; }
.gb-part-swatch .gb-swatch { width: 100%; height: 20px; }
.gb-part-preset { grid-column: span 1; }
.gb-note { font-size: 10px; color: var(--gb-muted); font-family: var(--gb-mono); }
.gb-swatch { display: inline-block; width: 18px; height: 14px; border: 1px solid #000; border-radius: 2px; }
.gb-presetchip { display: flex; gap: 1px; } .gb-presetchip .gb-swatch { width: 14px; height: 12px; }
.gb-glyph { display: inline-block; width: 26px; height: 16px; border: 1px solid #000; background: #6e6552; }
.gb-glyph-face { background: #1a0f06; border-radius: 3px; } .gb-glyph-face.gb-v-lcd { background: #b0bf70; } .gb-glyph-face.gb-v-vfd { background: #05090c; box-shadow: inset 0 0 6px #7df3ff; }
.gb-glyph-face.gb-v-nixie, .gb-glyph-face.gb-v-neon { box-shadow: inset 0 0 6px #f07a2e; }
.gb-glyph-keys.gb-v-pill { border-radius: 8px; } .gb-glyph-keys.gb-v-raised { box-shadow: inset 0 2px 0 rgba(255,255,255,.35), 0 2px 2px #000; }
.gb-glyph-keys.gb-v-engraved { box-shadow: inset 0 2px 3px #000; } .gb-glyph-keys.gb-v-flat { background: #8b8069; }
.gb-glyph-stop { width: 18px; height: 18px; background: #c2461f; } .gb-glyph-stop.gb-v-round { border-radius: 50%; } .gb-glyph-stop.gb-v-pill { width: 28px; border-radius: 9px; }
.gb-glyph-knob { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #5a5a5a, #111); }
.gb-glyph-knob.gb-v-chrome { background: conic-gradient(#ddd, #777, #eee, #666, #ddd); } .gb-glyph-knob.gb-v-flat { background: #444; }
.gb-glyph-meter { background: #efe7d2; } .gb-glyph-meter.gb-v-bar { background: linear-gradient(90deg, #8fd9a0 60%, #333 60%); } .gb-glyph-meter.gb-v-digital { background: #0d0b07; }
.gb-glyph-lamp { width: 12px; height: 12px; background: #8fd9a0; border-radius: 50%; } .gb-glyph-lamp.gb-v-square { border-radius: 1px; } .gb-glyph-lamp.gb-v-bar { width: 22px; height: 7px; border-radius: 2px; }
.gb-glyph-spacer { background: repeating-linear-gradient(90deg, transparent 0 3px, #b9ad94 3px 5px); }
.gb-trash { margin-top: 12px; padding: 12px 8px; border: 2px dashed var(--gb-line); border-radius: 4px; text-align: center; font-size: 12px; color: var(--gb-muted); }
.gb-trash.gb-trash-live { border-color: var(--gb-red); color: var(--gb-text); }
.gb-trash.gb-drop-ok { background: #3a1a12; }

/* ---- stage ---- */
.gb-stage { min-width: 0; }
.gb-stage-scroll { overflow: hidden; }
.gb-stage-box { position: relative; overflow: hidden; border-radius: 4px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }

/* ---- properties ---- */
.gb-block { margin: 0 0 12px; padding: 0 0 10px; border: 0; border-bottom: 1px solid var(--gb-line); }
.gb-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.gb-block .gb-danger { background: linear-gradient(180deg, #d9582e, #a8401e); color: #fff3e0; }
.gb-block .gb-primary-lite { margin-top: 4px; background: linear-gradient(180deg, #f5b95c, #d38b22); }
.gb-field { display: flex; flex-direction: column; gap: 3px; margin: 0 0 8px; }
.gb-field label { font-family: var(--gb-mono); font-size: 11px; letter-spacing: .08em; color: var(--gb-muted); text-transform: uppercase; }
.gb-field select { background: #0d0b07; border: 1px solid var(--gb-line); border-radius: 3px; padding: 4px 6px; }
.gb-field input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gb-amber); }
.gb-range { display: flex; align-items: center; gap: 8px; } .gb-range input { flex: 1; accent-color: var(--gb-amber); }
.gb-range output { font-family: var(--gb-mono); color: var(--gb-amber); min-width: 3.5em; text-align: right; }
.gb-help { margin: 0; font-size: 11px; color: var(--gb-muted); }
.gb-colours legend { font-family: var(--gb-mono); font-size: 11px; letter-spacing: .18em; color: var(--gb-amber); text-transform: uppercase; padding: 0; margin-bottom: 4px; }
.gb-colour { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 5px; }
.gb-colourname { flex: 0 0 90px; font-family: var(--gb-mono); font-size: 12px; }
.gb-colour input[type="color"] { width: 38px; height: 26px; padding: 0 2px; background: #0d0b07; border: 1px solid var(--gb-line); border-radius: 3px; cursor: pointer; }
.gb-gradtoggle { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--gb-muted); }
.gb-warn { color: #ffd27a; margin: 0; font-size: 11px; flex-basis: 100%; }
.gb-checks { list-style: none; padding: 0; margin: 0 0 10px; font-size: 12px; }
.gb-checks li { padding: 4px 6px; margin: 0 0 3px; border-radius: 3px; background: #1a1712; }
.gb-checks .gb-bad { color: var(--gb-red); } .gb-checks .gb-warn { color: #ffd27a; } .gb-checks .gb-good { color: var(--gb-green); }
.gb-props h3 { margin: 10px 0 6px; font: 500 11px var(--gb-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--gb-muted); }
#gb-published a.gb-dl { display: inline-block; padding: 6px 12px; background: linear-gradient(180deg, #8fd9a0, #5fa872); color: #0d0b07; border-radius: 3px; font-family: var(--gb-mono); font-size: 12px; text-decoration: none; }
.gb-hash { word-break: break-all; font-size: 11px; color: var(--gb-muted); } .gb-small { font-size: 11px; }

/* ======================================================================
   The template (1440 x 880, scaled by builder.js)
   ====================================================================== */
.fx { position: absolute; left: 0; top: 0; width: 1440px; height: 880px; transform-origin: 0 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px; padding: 0 10px 10px;
  background: var(--c-bg); color: var(--h-text); font-family: var(--f-ui); font-size: calc(13px * var(--ui)); line-height: 1.3; }
.fx *, .fx *::before, .fx *::after { box-sizing: border-box; }
.fx-caption, .fx-cap { font-family: var(--f-caption); }
.fx-muted { color: var(--h-muted); } .fx-ok { color: var(--h-ok); font-weight: 700; }
.fx-reading { color: var(--h-reading); font-family: var(--f-reading); font-variant-numeric: tabular-nums; }
.fx-small { font-size: calc(12px * var(--readings)); }
.fx-big { font-size: calc(15px * var(--readings)); letter-spacing: .04em; }
.fx-sub { font-size: 11px; letter-spacing: .08em; }

/* frame */
.fx-frame { height: 30px; flex: none; display: flex; align-items: center; justify-content: space-between; margin: 0 -10px; padding: 0 10px;
  background: var(--c-frame); color: var(--h-frameText); font-size: 13px; }
.fx-winbtns { display: flex; gap: 6px; }
.fx-winbtn { width: 26px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
  border: 1px solid var(--h-ctrlBorder); background: var(--c-ctrl); color: var(--h-ctrlText); border-radius: 2px; }

/* deck */
.fx-deck { position: relative; flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 30px; padding: 14px 26px;
  background: var(--c-deck); border: 1px solid var(--h-border); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 2px 4px rgba(0,0,0,.4); }
.fx-xl .fx-deck { gap: 10px 18px; }
.fx-deckhandle { position: absolute; left: 4px; top: 3px; font: 9px var(--f-caption); letter-spacing: .2em; color: var(--h-deckInk); opacity: .75; padding: 0 3px; }
.fx-item { flex: none; position: relative; }
.fx-stop { width: 84px; height: 84px; border-radius: 50%; border: 5px solid var(--h-stopRing); background: var(--stop-bg);
  color: var(--h-stopText); font: 700 17px var(--f-caption); letter-spacing: .12em; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,.45); }
.stop-square .fx-stop { border-radius: var(--radius); background: var(--c-stopBg); }
.stop-pill .fx-stop { width: 124px; border-radius: 42px; background: var(--c-stopBg); }
.fx-lampwrap { display: flex; flex-direction: column; gap: 10px; }
.fx-master { font-size: 12px; letter-spacing: .3em; color: var(--h-deckInk); }
.fx-lamprow { display: flex; gap: 16px; }
.fx-lampcell { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fx-lampcell .fx-cap { font-size: 11px; letter-spacing: .08em; color: var(--h-deckInk); }
.fx-lamp { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--h-border); background: var(--h-off); }
.fx-lamp-on { background: var(--h-ok); box-shadow: 0 0 8px var(--h-ok); }
.lamp-square .fx-lamp { border-radius: 2px; }
.lamp-bar .fx-lamp { width: 24px; height: 8px; border-radius: 2px; }
.fx-plate { position: relative; padding: 8px 12px; background: var(--c-plate); border: 2px solid var(--h-border); border-radius: var(--radius); box-shadow: 0 3px 10px rgba(0,0,0,.4); }
.fx-platecap { display: flex; justify-content: space-between; gap: 24px; font: 10px var(--f-caption); letter-spacing: .2em; color: var(--h-plateInk); margin: 0 0 6px; }
.fx-platecap:last-child { margin: 6px 0 0; }
.fx-digits { display: flex; align-items: flex-start; }
.fx-dcell { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-right: 4px; }
.fx-dcell.fx-group { margin-right: calc(12px * var(--scale)); }
.fx-dcell:last-child { margin-right: 0; }
.fx-digit { position: relative; display: flex; align-items: center; justify-content: center; line-height: 1; overflow: hidden;
  border: 1px solid var(--h-border); border-radius: 3px; background: var(--digit-bg); color: var(--digit);
  font-family: var(--f-counter); text-shadow: var(--digit-glow); }
.fx-digit.fx-dim { color: var(--h-digitDim); text-shadow: none; }
.counter-nixie .fx-digit { font-weight: 300; }
.face-nixie .fx-digit::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(0,0,0,.18) 0 1px, transparent 1px 4px),
  repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 4px); pointer-events: none; }
.face-neon .fx-digit { font-weight: 600; text-shadow: var(--digit-glow), 0 0 14px var(--digit); }
.face-plain .fx-digit, .face-lcd .fx-digit, .face-flip .fx-digit, .face-drum .fx-digit { text-shadow: none; }
.face-lcd .fx-digit, .face-led7 .fx-digit, .face-vfd .fx-digit { background: var(--c-digitBg); border-radius: 2px; }
.face-lcd .fx-digit::before, .face-led7 .fx-digit::before, .face-vfd .fx-digit::before { content: "8"; position: absolute; color: var(--h-digitDim); opacity: .35; text-shadow: none; }
.face-lcd .fx-digit { box-shadow: inset 0 2px 4px rgba(0,0,0,.35); }
.face-led7 .fx-digit { font-style: italic; font-weight: 600; transform: skewX(-6deg); }
.face-vfd .fx-digit { border-radius: 6px; box-shadow: inset 0 0 10px rgba(0,0,0,.6); }
.face-flip .fx-digit { background: linear-gradient(180deg, var(--h-digitBg) 0 49%, #000 49% 51%, var(--h-digitBg) 51% 100%); border-radius: 4px;
  box-shadow: 0 2px 3px rgba(0,0,0,.5); }
.face-drum .fx-digit { background: linear-gradient(180deg, #000 0%, var(--h-digitBg) 25%, var(--h-digitBg) 75%, #000 100%); }
.fx-switch { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fx-switch .fx-cap { font-size: 7px; letter-spacing: .1em; color: var(--h-plateInk); }
.fx-sw { width: 14px; height: 14px; border-radius: 50%; background: var(--knob-bg); border: 1px solid var(--h-border); position: relative; }
.fx-sw::after { content: ""; position: absolute; left: 4.5px; top: -4px; width: 3px; height: 9px; background: var(--h-knobCap); border-radius: 2px; }
.fx-volwrap, .fx-meterwrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fx-knob { width: 58px; height: 58px; border-radius: 50%; border: 2px solid var(--h-border); background: var(--knob-bg); display: flex; justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,.45); }
.knob-flat .fx-knob { box-shadow: none; }
.fx-knobcap { width: 4px; height: 20px; margin-top: 5px; border-radius: 2px; background: var(--h-knobCap); }
.fx-spacer { flex: 1 1 24px; min-width: 24px; align-self: stretch; min-height: 40px; border: 1px dashed transparent; border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.fx-spacer-mark { font: 9px var(--f-caption); letter-spacing: .2em; color: var(--h-deckInk); opacity: 0; }
.fx .fx-spacer:hover, .fx .fx-spacer.gb-selected, .fx .fx-spacer:focus-visible { border-color: var(--h-deckInk); }
.fx .fx-spacer:hover .fx-spacer-mark, .fx .fx-spacer.gb-selected .fx-spacer-mark { opacity: .7; }
.fx-metertitle { font-size: 12px; letter-spacing: .12em; color: var(--h-deckInk); }
.fx-volwrap .fx-reading, .fx-meterwrap .fx-reading { color: var(--h-deckInk); font-family: var(--f-ui); }
.fx-meterface { width: 150px; height: 86px; border: 2px solid var(--h-border); border-radius: var(--radius); background: var(--h-meterFace); overflow: hidden; position: relative; }
.fx-xl .fx-meterface { width: 118px; height: 68px; }
.fx-needle { display: block; width: 100%; height: 100%; }
.fx-ink-stroke { stroke: var(--h-meterInk); } .fx-ink-fill { fill: var(--h-meterInk); } .fx-needle-line { stroke: var(--h-meterNeedle); }
.fx-needle text { font-family: var(--f-ui); }
.fx-bar { display: flex; gap: 2px; padding: 18px 8px 6px; height: 56px; }
.fx-xl .fx-bar { height: 44px; padding-top: 12px; }
.fx-seg { flex: 1; background: var(--h-meterInk); opacity: .18; border-radius: 1px; }
.fx-seg-on { opacity: 1; background: var(--h-ok); } .fx-seg-on.fx-seg-hot { background: var(--h-meterNeedle); }
.fx-barscale { text-align: center; font: 9px var(--f-caption); color: var(--h-meterInk); letter-spacing: .08em; }
.fx-digital { margin: 14px 10px 0; padding: 4px 8px; text-align: right; background: var(--h-meterInk); color: var(--h-meterFace);
  font: calc(26px * var(--readings)) var(--f-reading); border-radius: 3px; font-variant-numeric: tabular-nums; }
.fx-xl .fx-digital { margin-top: 8px; font-size: calc(20px * var(--readings)); }
.fx-digital-unit { text-align: right; padding: 2px 12px; font: 10px var(--f-caption); color: var(--h-meterInk); }

/* body */
.fx-body { flex: 1 1 auto; min-height: 0; display: flex; gap: 8px; }
.fx-panel { background: var(--c-panel); border: 1px solid var(--h-border); border-radius: var(--radius); overflow: hidden; }
.fx-rail { width: var(--rail-w); flex: none; display: flex; flex-direction: column; }
.fx-panelhead { padding: 10px 0 8px; text-align: center; background: var(--h-panelHead); font-size: 13px; letter-spacing: .3em; color: var(--h-label); }
.fx-tabs { padding: 8px 8px 6px; }
.fx-tabrow { display: flex; gap: 4px; } .fx-tabrow .fx-key { flex: 1; }
.fx-key { display: inline-flex; align-items: center; justify-content: center; padding: 5px 4px; border: 1px solid var(--h-ctrlBorder); border-radius: var(--radius);
  background: var(--c-ctrl); color: var(--h-ctrlText); font: 12px var(--f-caption); letter-spacing: .06em; white-space: nowrap; }
.fx-key-on { background: var(--c-activeBg); color: var(--h-activeText); box-shadow: inset 0 -3px 0 var(--h-activeLine); }
.keys-raised .fx-key { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 2px 3px rgba(0,0,0,.45); }
.keys-raised .fx-key-on { box-shadow: inset 0 -3px 0 var(--h-activeLine), 0 1px 2px rgba(0,0,0,.4); }
.keys-flat .fx-key { box-shadow: none; } .keys-flat .fx-key-on { box-shadow: inset 0 -3px 0 var(--h-activeLine); }
.keys-engraved .fx-key { box-shadow: inset 0 2px 4px rgba(0,0,0,.55), inset 0 -1px 0 rgba(255,255,255,.12); }
.keys-engraved .fx-key-on { box-shadow: inset 0 2px 4px rgba(0,0,0,.55), inset 0 -3px 0 var(--h-activeLine); }
.keys-pill .fx-key { border-radius: 999px; }
.fx-railbody { flex: 1 1 auto; min-height: 0; overflow: hidden; padding: 4px 10px 8px; display: flex; flex-direction: column; gap: 5px; }
.fx-section { font-size: 11px; letter-spacing: .25em; color: var(--h-muted); padding: 2px 0; }
.fx-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; background: var(--c-ctrl); border: 1px solid var(--h-ctrlBorder); border-radius: var(--radius); color: var(--h-ctrlText); }
.fx-rowlabel { flex: 1; }
.fx-check { width: 16px; height: 16px; flex: none; border: 1px solid var(--h-ctrlBorder); border-radius: 3px; background: var(--h-accent); }
.fx-check-off { background: var(--h-well); }
.fx-tag { padding: 1px 6px; background: var(--h-tag); color: var(--h-tagText); font-size: 11px; letter-spacing: .06em; border-radius: 2px; }
.fx-rowlamp { width: 10px; height: 10px; border-radius: 50%; background: var(--h-ok); } .fx-rowlamp.fx-lamp-off { background: var(--h-off); }
.fx-combo { display: flex; justify-content: space-between; padding: 5px 8px; border: 1px solid var(--h-ctrlBorder); border-radius: var(--radius); background: var(--h-well); color: var(--h-text); }
.fx-combo-short { width: 120px; } .fx-combo-grow { flex: 1; }
.fx-line { display: flex; gap: 8px; align-items: center; }
.fx-sliderrow { display: flex; align-items: center; gap: 8px; }
.fx-val { width: 70px; text-align: right; font-size: calc(13px * var(--readings)); }
.fx-track { flex: 1; height: 6px; border-radius: 3px; background: var(--h-well); position: relative; }
.fx-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--h-accent); border-radius: 3px; }
.fx-thumb { position: absolute; top: -5px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--h-accent); border: 2px solid var(--h-well); }
.fx-sliderlabel { width: 64px; font-size: 12px; letter-spacing: .06em; color: var(--h-muted); }
.fx-modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.fx-railfoot { padding: 6px 10px; border-top: 1px solid var(--h-border); font-size: 12px; color: var(--h-muted); line-height: 1.5; }

.fx-mainarea { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fx-well { position: relative; background: var(--h-well); border: 1px solid var(--h-border); border-radius: var(--radius); overflow: hidden; }
.fx-mainarea > .fx-spectrum { height: 300px; flex: none; }
.fx-xl .fx-mainarea > .fx-spectrum { height: 250px; }
.fx-mainarea > .fx-waterfall { flex: 1 1 auto; min-height: 0; }
.fx-fill-abs { position: absolute; inset: 0; }
.fx-grid { position: absolute; inset: 0; background-image: linear-gradient(var(--h-grid) 1px, transparent 1px), linear-gradient(90deg, var(--h-grid) 1px, transparent 1px);
  background-size: 100% 12.5%, 12.5% 100%; }
.fx-selband { position: absolute; left: 60.5%; width: 7%; top: 0; bottom: 0; background: var(--h-sel); }
.fx-marker { position: absolute; left: 64%; width: 2px; top: 0; bottom: 0; background: var(--h-accent); opacity: .85; }
.fx-trace { position: absolute; left: 44px; top: 50px; width: calc(100% - 44px); height: calc(100% - 84px); }
.fx-trace path { stroke: var(--h-trace); }
.fx-spectitle { position: absolute; left: 12px; top: 8px; font-size: 13px; letter-spacing: .12em; color: var(--h-label); }
.fx-spectitle .fx-sub { margin-top: 2px; }
.fx-peak { position: absolute; right: 12px; top: 8px; text-align: right; font-size: 12px; letter-spacing: .12em; }
.fx-yaxis { position: absolute; left: 8px; top: 50px; bottom: 34px; display: flex; flex-direction: column; justify-content: space-between; font-size: 10px; }
.fx-xaxis { position: absolute; left: 44px; right: 0; bottom: 8px; height: 16px; font-size: 11px; }
.fx-xaxis span { position: absolute; }
.fx-span { position: absolute; right: 12px; bottom: 30px; padding: 3px 8px; border: 1px solid var(--h-border); background: var(--h-panel); font-size: 11px; letter-spacing: .1em; }
.fx-wf { position: absolute; left: 40px; right: 0; top: 0; bottom: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.10) 0 1px, transparent 1px 3px), linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.18)), var(--wf); }
.fx-ago { position: absolute; left: 0; top: 0; bottom: 0; width: 40px; display: flex; flex-direction: column; justify-content: space-between; padding: 6px 0;
  font-size: 11px; text-align: center; background: var(--h-panel); }
.fx-wfkey { position: absolute; right: 12px; top: 12px; padding: 8px 10px; background: var(--h-panel); border: 1px solid var(--h-border); border-radius: var(--radius); font-size: 11px; letter-spacing: .08em; }
.fx-wfkeybar { width: 180px; height: 8px; margin: 6px 0 4px; background: var(--wf-key); }
.fx-wfkeyscale { display: flex; justify-content: space-between; font-size: 10px; }
.fx-wfkey .fx-sub { margin-top: 4px; display: inline; }
.fx-wfinfo { position: absolute; left: 52px; bottom: 10px; padding: 5px 10px; background: var(--h-panel); border: 1px solid var(--h-border); border-radius: var(--radius);
  font-size: 11px; letter-spacing: .06em; line-height: 1.5; }

.fx-status { width: var(--status-w); flex: none; display: flex; flex-direction: column; padding: 0 8px 8px; }
.fx-statushead { padding: 10px 0 6px; text-align: center; font-size: 13px; letter-spacing: .3em; color: var(--h-label); }
.fx-statusbody { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.fx-statbox { padding: 6px 8px; background: var(--h-well); border: 1px solid var(--h-border); border-radius: var(--radius); line-height: 1.35; }
.fx-statbox .fx-label { font-size: 11px; letter-spacing: .2em; color: var(--h-label); }
.fx-statval { font-size: calc(14px * var(--readings)); }
.fx-ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-grow { flex: 1 1 auto; }
.fx-statusbody .fx-key { padding: 7px 0; }

/* ---- the builder's marks on the template ---- */
.fx .gb-handle { cursor: pointer; }
.fx .gb-handle:focus-visible { outline: 3px solid var(--gb-focus); outline-offset: 2px; }
.fx .gb-slot:not(.fx):hover { outline: 1px dashed rgba(125,243,255,.6); outline-offset: 1px; }
.fx .gb-selected:not(.fx) { outline: 3px solid var(--gb-amber); outline-offset: 2px; }
.fx.gb-selected { box-shadow: inset 0 0 0 3px var(--gb-amber); }
.fx.gb-armed .gb-slot:not(.fx), .fx.gb-dragging-part .gb-can-drop:not(.fx) { outline: 2px dashed var(--gb-focus); outline-offset: 1px; }
.fx .gb-drop-ok { outline: 3px solid var(--gb-green) !important; outline-offset: 2px; }
.fx.gb-drop-ok { box-shadow: inset 0 0 0 4px var(--gb-green); }
.fx .gb-drop-no { outline: 3px solid var(--gb-red) !important; }
.fx .gb-dragging { opacity: .45; }
.fx .fx-item[draggable="true"], .fx .fx-rail[draggable="true"], .fx .fx-status[draggable="true"] { cursor: grab; }
@media (prefers-reduced-motion: no-preference) { .gb-part, .fx .gb-slot { transition: outline-color .12s, border-color .12s; } }

/* ======================================================================
   Parts drawn from their variants (parts*.js), 2.42.0
   ====================================================================== */
.fx-drawn { display: block; }
.fx-partsvg { display: block; width: 100%; height: 100%; }
.fx .fx-switch.gb-slot { cursor: pointer; }
.fx-switch .fx-partsvg { width: 16px; height: 21px; }
.fx-swhit { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; z-index: 2; cursor: pointer; }

/* A container drawn from a variant: the drawing sits behind its content. */
.fx-skinned { position: relative; isolation: isolate; }
.fx-skin { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; display: block; }
.fx-deck.fx-skinned { background: none; border-color: transparent; box-shadow: none; }
.fx-rail.fx-skinned { background: none; border-color: transparent; }
.fx-rail.fx-skinned .fx-panelhead { background: transparent; }
.fx-well.fx-skinned { background: none; border-color: transparent; }
.fx-spectrum.fx-skinned .fx-grid, .fx-spectrum.fx-skinned .fx-selband, .fx-spectrum.fx-skinned .fx-marker, .fx-spectrum.fx-skinned .fx-trace { display: none; }
.fx-waterfall.fx-skinned .fx-wf { display: none; }
.fx-statbox.fx-skinned { background: none; border-color: transparent; min-height: 58px; }
.fx-statbox.fx-skinned > :not(.fx-skin), .fx-frame.fx-skinned > :not(.fx-skin) { visibility: hidden; }
.fx-frame.fx-skinned { background: none; }
.fx .fx-key.fx-skinned { background: none !important; border-color: transparent !important; box-shadow: none !important; color: transparent !important; }

/* The placement matrix: the deck as 60 x 8 cells of 24 px, full width. */
.fx-deck.fx-deck-grid { display: block; flex: none; margin: 0 -10px; width: 1440px; height: 192px; padding: 0; border: 0; border-radius: 0;
  box-shadow: inset 0 -1px 0 var(--h-border), inset 0 1px 0 rgba(255,255,255,.14); }
.fx-deck-grid .fx-cellpart { position: absolute; margin: 0; }
.fx-gridmode .fx-cellpart { touch-action: none; cursor: grab; }
.fx.fx-gridmode { user-select: none; -webkit-user-select: none; }
.fx-gridmode .fx-rail, .fx-gridmode .fx-status, .fx-gridmode .fx-spectrum, .fx-gridmode .fx-waterfall { touch-action: none; }
.fx-matrix { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
.fx-zone { position: absolute; z-index: 20; pointer-events: none; border: 3px dashed; border-radius: 4px; display: flex; align-items: center;
  justify-content: center; font: 500 14px var(--gb-mono); letter-spacing: .2em; }
.fx-zone-ok { border-color: var(--gb-green); background: rgba(143,217,160,.10); color: var(--gb-green); }
.fx-zone-no { border-color: var(--gb-red); background: rgba(255,138,106,.08); color: var(--gb-red); }
.fx-zone.fx-zone-hover-ok { background: rgba(143,217,160,.38); color: #0d2012; }
.fx-zone.fx-zone-hover-no { background: rgba(255,90,60,.38); color: #2a0a04; }
.fx-ghost { position: absolute; z-index: 21; pointer-events: none; border: 3px solid; border-radius: 3px; display: flex; align-items: flex-end;
  padding: 2px 5px; font: 500 12px var(--gb-mono); letter-spacing: .04em; white-space: nowrap; overflow: hidden; }
.fx-ghost-ok { border-color: var(--gb-green); background: rgba(143,217,160,.30); color: #0d2012; }
.fx-ghost-no { border-color: var(--gb-red); background: rgba(255,90,60,.34); color: #2a0a04; }
.gb-actions button[aria-pressed="true"] { background: linear-gradient(180deg, #8fd9a0, #5fa872); }

/* ---- the selection sheet ---- */
.gb-scrim[hidden], .gb-sheet[hidden] { display: none; }
.gb-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .25s; }
.gb-scrim.gb-open { opacity: 1; }
.gb-sheet { position: fixed; left: 0; right: 0; bottom: 0; height: min(80vh, 780px); z-index: 50; display: flex; flex-direction: column;
  background: var(--gb-panel); border-top: 3px solid var(--gb-amber); box-shadow: 0 -12px 34px rgba(0,0,0,.6);
  transform: translateX(-100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.gb-sheet.gb-open { transform: none; }
@media (prefers-reduced-motion: reduce) { .gb-sheet, .gb-scrim { transition: none; } }
.gb-sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; border-bottom: 1px solid var(--gb-line); }
.gb-sheet-head h2 { margin: 0; font: 400 18px var(--gb-serif); }
.gb-sheet-steps { display: flex; gap: 6px; }
.gb-sheet button, .gb-sheet-close { padding: 8px 14px; min-height: 40px; border: 1px solid var(--gb-line); border-radius: 3px; cursor: pointer;
  background: linear-gradient(180deg, #8b8069, #6e6552); color: #14110c; font-family: var(--gb-mono); font-size: 12px; letter-spacing: .06em; }
.gb-sheet button:disabled { opacity: .45; cursor: not-allowed; }
.gb-sheet .gb-step-on { background: linear-gradient(180deg, #f5b95c, #d38b22); }
.gb-sheet .gb-sheet-close { margin-left: auto; }
.gb-sheet .gb-primary-lite { background: linear-gradient(180deg, #f5b95c, #d38b22); }
.gb-sheet-hint { margin: 8px 16px 0; font-size: 13px; color: var(--gb-muted); }
.gb-sheet-body { flex: 1 1 auto; overflow: auto; padding: 10px 16px 18px; }
.gb-sheet .gb-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gb-sheet .gb-cards-wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.gb-sheet .gb-cards-theme { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.gb-sheet .gb-card { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 8px; min-height: 44px; text-align: left;
  background: var(--card-bg, #7d7360); border: 2px solid var(--gb-line); border-radius: 6px; color: var(--gb-text); }
.gb-sheet .gb-card:hover { border-color: var(--gb-amber); }
.gb-sheet .gb-card-on { border-color: var(--gb-green); box-shadow: 0 0 0 2px var(--gb-green) inset; }
.gb-cardpic { display: flex; align-items: center; justify-content: center; height: 110px; }
.gb-cards-tall .gb-cardpic { height: 230px; }
.gb-cardname, .gb-cardid { display: block; padding: 2px 4px; background: rgba(20,17,12,.82); border-radius: 2px; }
.gb-cardname { font: 600 13px var(--gb-serif); color: var(--gb-text); }
.gb-cardid { font: 11px var(--gb-mono); color: var(--gb-muted); }
.gb-colourstep { display: grid; grid-template-columns: minmax(220px, 460px) minmax(0, 1fr); gap: 20px; align-items: start; }
.gb-bigpic { display: flex; align-items: center; justify-content: center; height: 250px; padding: 12px; border-radius: 6px; background: var(--card-bg, #7d7360); }
.gb-colournow { margin: 0 0 6px; font-family: var(--gb-mono); }
.gb-contrast { margin: 0 0 8px; font-size: 13px; }
.gb-good { color: var(--gb-green); }
.gb-palette-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.gb-sheet .gb-swatchbtn { position: relative; width: 44px; height: 44px; min-height: 0; padding: 4px; background: #0d0b07; border: 2px solid var(--gb-line); border-radius: 6px; }
.gb-swatchbtn .gb-swatch { display: block; width: 100%; height: 100%; }
.gb-sheet .gb-swatch-on { border-color: var(--gb-green); box-shadow: 0 0 0 2px var(--gb-green); }
.gb-lowmark { position: absolute; right: 1px; top: -2px; font: 700 13px var(--gb-mono); color: #ffd27a; text-shadow: 0 0 2px #000; }
.gb-customcolour { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gb-customlabel { font: 11px var(--gb-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--gb-muted); }
.gb-customcolour input[type="color"] { width: 48px; height: 40px; padding: 0 2px; background: #0d0b07; border: 1px solid var(--gb-line); border-radius: 3px; }
.gb-hexin, .gb-linkin { background: #0d0b07; border: 1px solid var(--gb-line); border-radius: 3px; padding: 8px; font-family: var(--gb-mono); }
.gb-hexin { width: 96px; }
.gb-sheetbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.gb-thememodes { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--gb-line); border-radius: 4px; }
.gb-thememodes legend { font: 11px var(--gb-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--gb-amber); padding: 0 4px; }
.gb-radio { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.gb-radio input { width: 18px; height: 18px; accent-color: var(--gb-amber); }
.gb-themepic { display: flex; align-items: center; gap: 8px; height: 96px; padding: 8px; border-radius: 4px; }
.gb-themepic .fx-partsvg { height: 100%; width: auto; flex: 0 0 auto; }
.gb-themepic .fx-partsvg + .fx-partsvg { flex: 1 1 auto; width: 0; }
.gb-themepic .fx-partsvg:last-child { flex: 0 0 auto; width: auto; }
.gb-themestrip { display: flex; gap: 2px; }
.gb-themestrip .gb-swatch { flex: 1; height: 12px; }
.gb-linkrow { display: flex; gap: 6px; }
.gb-linkin { flex: 1 1 auto; min-width: 0; }
.gb-partblock .gb-partnow { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.gb-nudge button { min-width: 42px; }
@media (max-width: 760px) {
  .gb-sheet { height: 90vh; }
  .gb-colourstep { grid-template-columns: minmax(0, 1fr); }
  .gb-bigpic { height: 180px; }
  .gb-sheet .gb-cards-wide { grid-template-columns: minmax(0, 1fr); }
}
