/* ==========================================================================
   Controller deck — dual mode (Workbench to set up, Stage to play)
   Markup: deck-view.mjs. Behaviour: deck.mjs (moves the shared blocks between
   the docks of the active mode and sets --level on controls).
   ========================================================================== */

/* .view's filled entrance animation would make it the containing block of the fixed drawer. */
.controller-deck.view { animation-fill-mode: none; }
.controller-deck {
  --deck-in: #5fd0ff; --deck-ok: #7ee2a8; --deck-warn: #ffb547; --deck-live: #ff5a48;
  --trace: var(--accent); --trace-fill: rgba(255,138,76,.2); --trace-input: #5fd0ff; --trace-grid: rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 14px;
}
.deck-micro-label { font: 600 10px/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.deck-panel { border-radius: var(--r-lg); background: var(--surface-1); box-shadow: 0 0 0 1px var(--line), var(--raise); }
.deck-dock { min-width: 0; }
.deck-dock:empty { display: none; }
.deck-icon-button { display: inline-grid; place-items: center; width: 36px; min-width: 36px; padding: 0; }
.deck-icon-button svg, .deck-mode-switch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── toolbar ───────────────────────────────────────────────────────────── */
.deck-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.deck-profile-name { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 300px; height: 40px; padding: 0 4px 0 12px; border-radius: var(--r); background: var(--surface-1); box-shadow: 0 0 0 1px var(--line); }
.deck-profile-name input { flex: 1; min-width: 0; height: 32px; border: 0; background: transparent; box-shadow: none; font-weight: 600; font-size: 14px; padding: 0 4px; }
html[data-design="graphite"] .deck-profile-name input { background: transparent; box-shadow: none; }
.deck-profile-actions, .deck-history-tools, .deck-view-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.deck-import-label { position: relative; }
.deck-file-input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.deck-mode-area { display: flex; align-items: center; gap: 8px; margin: 0 auto; }
.deck-mode-switch { position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 12px; background: var(--surface-0); box-shadow: 0 0 0 1px var(--line-2); }
.deck-mode-switch::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 9px; background: var(--ink); transition: transform .32s cubic-bezier(.2,.8,.2,1); }
.controller-deck[data-deck-mode="stage"] .deck-mode-switch::before { transform: translateX(100%); }
.deck-mode-switch button { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; padding: 0 16px; border: 0; background: none; color: var(--ink-dim); font: 600 13px var(--sans); cursor: pointer; transition: color .2s; }
.deck-mode-switch button[aria-selected="true"] { color: #0c0c0e; }
.deck-mode-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.deck-mode-key { font: 500 11px var(--mono); color: var(--ink-faint); padding: 2px 6px; border-radius: 5px; background: var(--surface-3); }
.deck-switch { position: relative; display: inline-flex; align-items: center; gap: 9px; min-height: 34px; cursor: pointer; user-select: none; font-weight: 600; font-size: 12.5px; }
.deck-switch input { position: absolute; inset: 0; z-index: 2; opacity: 0; width: 100%; height: 100%; min-height: 0; margin: 0; cursor: pointer; }
.deck-switch i { position: relative; width: 34px; height: 20px; border-radius: 99px; background: var(--surface-4); box-shadow: inset 0 0 0 1px var(--line-3); transition: background .15s; flex: none; }
.deck-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #cfcfd6; transition: transform .15s; }
.deck-switch input:checked + i { background: var(--accent); box-shadow: none; }
.deck-switch input:checked + i::after { transform: translateX(14px); background: var(--accent-ink); }
.deck-switch input:focus-visible + i { outline: 2px solid var(--ink); outline-offset: 2px; }
.deck-arm-switch { position: relative; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 14px 0 8px; border-radius: 99px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-3); cursor: pointer; user-select: none; }
.deck-arm-switch input { position: absolute; inset: 0; z-index: 2; opacity: 0; width: 100%; height: 100%; min-height: 0; margin: 0; cursor: pointer; }
.arm-switch-track { position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--surface-4); box-shadow: inset 0 0 0 1px var(--line-3); transition: background .15s; flex: none; }
.arm-switch-track i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #cfcfd6; transition: transform .16s; }
.deck-arm-switch input:checked + .arm-switch-track { background: #1d0b02; box-shadow: none; }
.deck-arm-switch input:checked + .arm-switch-track i { transform: translateX(16px); background: #fff; }
.deck-arm-switch input:focus-visible + .arm-switch-track { outline: 2px solid var(--ink); outline-offset: 3px; }
.deck-arm-switch strong, .deck-arm-switch small { display: block; line-height: 1.2; }
.deck-arm-switch strong { font-size: 12.5px; }
.deck-arm-switch small { font-size: 11px; color: var(--ink-dim); }
.deck-arm-switch:has(input:checked) { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 22px rgba(255,138,76,.35); }
.deck-arm-switch:has(input:checked) small { color: #4a2200; }
.deck-status-line { display: flex; align-items: center; gap: 10px; padding: 0 4px; font: 500 11.5px var(--mono); color: var(--ink-dim); }
.deck-led { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.controller-deck:has(#deckArm:checked) .deck-led { background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: led-pulse 1.4s ease-in-out infinite; }
@keyframes led-pulse { 50% { opacity: .45; } }
.deck-spec { margin-left: auto; color: var(--ink-faint); letter-spacing: .08em; white-space: nowrap; }

/* ── shared blocks: channels and banks ─────────────────────────────────── */
.deck-channel-keys { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 4px; }
.deck-channel-keys button { position: relative; display: grid; align-content: space-between; min-width: 0; height: 46px; padding: 6px 7px; border: 0; border-radius: 8px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); color: var(--ink-dim); text-align: left; cursor: pointer; }
.deck-channel-keys button span { font: 600 12px var(--mono); }
.deck-channel-keys .channel-dot { position: absolute; top: 8px; right: 7px; width: 5px; height: 5px; border-radius: 50%; }
.deck-channel-keys button.has-values .channel-dot { background: var(--ink-2); }
.deck-channel-keys button i { display: block; height: 4px; border-radius: 2px; background: var(--surface-4); overflow: hidden; position: relative; }
.deck-channel-keys button i::after { content: ""; position: absolute; inset: 0 100% 0 0; background: var(--deck-in); border-radius: 2px; transition: right .5s ease-out; }
.deck-channel-keys button.activity i::after { right: 0; transition: right .05s; }
.deck-channel-keys button:hover { background: var(--surface-3); }
.deck-channel-keys button.active { background: var(--ink); color: #0c0c0e; box-shadow: none; }
.deck-channel-keys button.active i { background: rgba(0,0,0,.15); }
.deck-channel-keys button.active i::after, .deck-channel-keys button.active.has-values .channel-dot { background: #0c0c0e; }
.deck-channel-keys button:focus-visible, .deck-bank-keys button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.deck-bank-keys { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface-0); box-shadow: 0 0 0 1px var(--line); }
.deck-bank-keys[hidden] { display: none; }
.deck-bank-keys button { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-dim); font: 600 12px var(--sans); cursor: pointer; }
.deck-bank-keys button small { font: 500 10.5px var(--mono); opacity: .65; }
.deck-bank-keys button.active { background: var(--ink); color: #0c0c0e; }

/* ── Workbench layout ──────────────────────────────────────────────────── */
.deck-wb { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.deck-wb[hidden], .deck-st[hidden] { display: none; }
.deck-wb-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.deck-wb-side { position: sticky; top: calc(var(--topbar-h, 64px) + 14px); }
.deck-wb-side .deck-inspector { max-height: calc(100vh - var(--topbar-h, 64px) - 28px); }
.deck-oled { overflow: hidden; }
.deck-oled > .deck-dock { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-0); }
.oled-main { display: grid; grid-template-columns: 292px minmax(0, 1fr) 270px; min-height: 250px; }
.oled-focus { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 16px 18px; border-right: 1px solid var(--line); }
.oled-topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.deck-source { font: 500 11px var(--mono); color: var(--ink-faint); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.deck-source::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.deck-source[data-source="received"] { color: var(--deck-in); } .deck-source[data-source="sent"] { color: var(--deck-ok); } .deck-source[data-source="local"] { color: var(--accent); } .deck-source[data-source="unread"], .deck-source[data-source="echo"] { color: var(--deck-warn); }
#oledTitle { font-size: 22px; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oled-value-line { display: flex; align-items: center; gap: 14px; cursor: zoom-in; }
#oledValue { font: 600 60px/1 var(--mono); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.oled-ring { width: 56px; height: 56px; flex: none; }
.oled-value-meta { display: grid; gap: 3px; min-width: 0; font: 12px var(--mono); color: var(--ink-dim); }
.oled-formatted-value { color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oled-facts { display: grid; gap: 6px; margin: auto 0 0; }
.oled-facts div { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-dim); }
.oled-facts dd { margin: 0; font: 500 12px var(--mono); color: var(--ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-ring { display: block; width: 100%; height: 100%; overflow: visible; }
.deck-ring path { fill: none; stroke-linecap: round; }
.ring-track { stroke: var(--surface-4); }
.ring-arc { stroke: var(--accent); stroke-dasharray: 0 100; transition: stroke-dasharray .06s linear; }
.oled-trace { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px 16px; }
.oled-trace-label { display: flex; justify-content: space-between; gap: 10px; font: 600 10px var(--sans); letter-spacing: .1em; color: var(--ink-faint); }
#oledChannelStatus { font: 500 11px var(--mono); letter-spacing: .04em; }
#oledActivity { display: block; width: 100%; height: 170px; }
.deck-axis { display: flex; justify-content: space-between; font: 10.5px var(--mono); color: var(--ink-faint); }
.oled-overview { display: grid; grid-template-rows: auto 1fr auto; gap: 8px; min-width: 0; padding: 14px 16px; border-left: 1px solid var(--line); }
.oled-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; align-content: start; }
.oled-mini { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 2px 6px; align-items: center; min-width: 0; font-size: 11px; color: var(--ink-dim); --level: 0; }
.mini-index { font: 10px var(--mono); color: var(--ink-faint); }
.mini-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-value { font: 500 11px var(--mono); color: var(--ink-2); }
.mini-track { grid-column: 2 / 4; height: 3px; border-radius: 2px; background: var(--surface-4); overflow: hidden; }
.mini-bar { display: block; height: 100%; width: calc(var(--level) * 100%); background: var(--ink-dim); border-radius: 2px; }
.oled-mini.selected { color: var(--ink); } .oled-mini.selected .mini-bar { background: var(--accent); }
.oled-mini.unassigned { opacity: .35; }
.oled-fader-section { display: grid; gap: 6px; }
#oledFaders { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; height: 44px; align-items: end; }
.oled-fader { position: relative; height: 100%; border-radius: 3px 3px 1px 1px; background: var(--surface-4); overflow: hidden; --level: 0; }
.oled-fader i { position: absolute; inset: auto 0 0 0; height: calc(var(--level) * 100%); background: var(--deck-in); opacity: .8; }
.oled-fader small { position: absolute; left: 0; right: 0; top: 2px; text-align: center; font: 9px var(--mono); color: var(--ink-faint); }
.oled-bottomline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-0); font-size: 12px; color: var(--ink-dim); }
.oled-bottomline b { color: var(--ink-2); font-weight: 600; }
.deck-clash { display: inline-flex; align-items: center; gap: 7px; min-height: 24px; padding: 0 10px; border-radius: 7px; background: rgba(255,181,71,.1); box-shadow: 0 0 0 1px rgba(255,181,71,.3); color: var(--deck-warn); font-weight: 600; }
.deck-clash::before { content: "!"; display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: var(--deck-warn); color: #241600; font: 800 10px var(--sans); }
.deck-rate { margin-left: auto; font: 11.5px var(--mono); }
.hardware-label { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.hardware-label > span { font: 600 13.5px var(--sans); color: var(--ink); }
.hardware-label small { margin-left: auto; font-size: 11.5px; color: var(--ink-faint); }
.deck-encoder-panel, .stage-encoder-panel { padding: 14px; }

/* ── encoders ───────────────────────────────────────────────────────────── */
.deck-knob-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.deck-knob { position: relative; display: grid; justify-items: center; gap: 4px; min-width: 0; padding: 9px 9px 8px; border-radius: 10px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); --level: 0; }
.deck-knob.selected { background: var(--surface-3); box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-soft); }
.knob-topline { display: flex; justify-content: space-between; align-items: center; width: 100%; font: 10.5px var(--mono); color: var(--ink-faint); }
.knob-flags { display: flex; gap: 4px; }
.knob-flags i { display: none; width: 6px; height: 6px; border-radius: 50%; }
.deck-knob.has-input .flag-input { display: block; background: var(--deck-in); }
.deck-knob.has-relay .flag-relay { display: block; background: var(--deck-ok); }
.knob-dial { position: relative; width: 66px; height: 66px; border-radius: 50%; cursor: ns-resize; touch-action: none; user-select: none; outline: none; }
.knob-dial:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.knob-dial .ring-arc { stroke: var(--ink-2); }
.deck-knob.selected .knob-dial .ring-arc { stroke: var(--accent); }
.knob-value { position: absolute; inset: 0; display: grid; place-items: center; font: 600 13px var(--mono); pointer-events: none; }
.knob-name { width: 100%; text-align: center; font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knob-route { font: 10.5px var(--mono); color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.knob-spark { width: 100%; height: 16px; display: block; }
.knob-spark polyline { fill: none; stroke: var(--line-3); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.deck-knob.selected .knob-spark polyline { stroke: var(--accent); }
.deck-knob.unassigned { opacity: .32; }
.deck-knob.unassigned .knob-dial { cursor: default; }
.deck-knob.unassigned .ring-arc { stroke: var(--line-3); }

/* ── faders & pads ──────────────────────────────────────────────────────── */
.lower-deck, .deck-memory { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; }
.fader-section, .pad-section { padding: 14px; }
.deck-fader-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.deck-fader { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 8px 2px; border-radius: 10px; --level: 0; }
.deck-fader.selected { background: var(--surface-3); box-shadow: 0 0 0 1.5px var(--accent); }
.deck-fader.unassigned { opacity: .35; }
.fader-value { font: 600 12px var(--mono); }
.fader-well { position: relative; width: 30px; height: 132px; border-radius: 8px; background: var(--surface-0); box-shadow: inset 0 0 0 1px var(--line-2); overflow: hidden; }
.fader-fill { position: absolute; inset: auto 0 0 0; height: calc(var(--level) * 100%); background: linear-gradient(to top, rgba(95,208,255,.38), rgba(95,208,255,.12)); pointer-events: none; }
.fader-well input[type="range"] { position: absolute; inset: 0; z-index: 1; writing-mode: vertical-lr; direction: rtl; appearance: none; -webkit-appearance: none; width: 100%; min-width: 0; height: 100%; min-height: 0; padding: 0; margin: 0; border: 0; background: transparent; box-shadow: none; cursor: ns-resize; }
html[data-design="graphite"] .fader-well input[type="range"] { background: transparent; box-shadow: none; }
.fader-well input[type="range"]::-webkit-slider-runnable-track { background: transparent; border: 0; }
.fader-well input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 8px; border-radius: 3px; border: 0; background: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.fader-well input[type="range"]::-moz-range-thumb { width: 24px; height: 8px; border-radius: 3px; border: 0; background: var(--ink); }
.fader-well input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.deck-fader.selected input[type="range"]::-webkit-slider-thumb { background: var(--accent); }
.fader-name { max-width: 100%; font-size: 11.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fader-route { max-width: 100%; font: 10px var(--mono); color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-pad-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.deck-pad { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px; min-width: 0; min-height: 78px; padding: 8px 10px; border: 0; border-radius: 10px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-2), inset 0 1px 0 rgba(255,255,255,.05); color: var(--ink); text-align: left; cursor: pointer; user-select: none; touch-action: none; transition: background .06s, box-shadow .06s; }
.deck-pad:hover { background: var(--surface-3); }
.deck-pad.selected { box-shadow: 0 0 0 1.5px var(--accent); }
.deck-pad.pressed, .deck-pad[aria-pressed="true"], .deck-pad:active { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 22px rgba(255,138,76,.35); }
.deck-pad:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pad-index { position: absolute; top: 8px; left: 10px; font: 600 10px var(--mono); color: var(--ink-faint); }
.pad-name { max-width: 100%; font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pad-route { max-width: 100%; font: 10.5px var(--mono); color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-pad.pressed :is(.pad-index, .pad-route) { color: #4a2200; }
.deck-pad i { position: absolute; top: 9px; right: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--surface-4); }
.deck-pad.pressed i { background: #fff; box-shadow: 0 0 8px #fff; }

/* ── snapshots / inputs / mapping table ─────────────────────────────────── */
.deck-snapshots, .deck-extra-inputs, .deck-mapping-table { padding: 14px 16px; }
.snapshot-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.snapshot-heading h3 { margin: 2px 0 0; font-size: 14px; }
.snapshot-hint { font-size: 11.5px; color: var(--ink-faint); }
.snapshot-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.snapshot-chip { display: grid; gap: 1px; min-width: 92px; padding: 7px 10px; border: 0; border-radius: 8px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); color: var(--ink); text-align: left; cursor: pointer; }
.snapshot-chip strong { font-size: 12.5px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snapshot-chip small { font: 10.5px var(--mono); color: var(--ink-faint); }
.snapshot-chip.active { box-shadow: 0 0 0 1.5px var(--ink); background: var(--surface-3); }
.snapshot-empty { margin: 0; font-size: 12px; color: var(--ink-faint); }
.snapshot-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; }
.snapshot-save, .snapshot-recall { display: flex; gap: 6px; min-width: 0; }
.snapshot-save input, .snapshot-recall select { flex: 1; min-width: 0; }
.deck-extra-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px); gap: 16px; }
.deck-memory .snapshot-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.deck-memory #snapshotSend { grid-column: 1 / -1; }
.deck-memory .deck-extra-inputs, .stage-more .deck-extra-inputs { grid-template-columns: minmax(0, 1fr); }
.deck-extra-inputs-copy h3 { margin: 2px 0 6px; font-size: 14px; }
.deck-extra-inputs-copy p { margin: 0; font-size: 12px; color: var(--ink-dim); }
.deck-extra-inputs-controls { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.deck-extra-inputs-controls p { margin: 0; font-size: 11.5px; color: var(--ink-dim); }
.deck-mapping-table summary { display: flex; align-items: baseline; gap: 12px; cursor: pointer; list-style: none; font-weight: 600; }
.deck-mapping-table summary::-webkit-details-marker { display: none; }
.deck-mapping-table summary::after { content: "Show"; margin-left: auto; font-size: 12px; font-weight: 500; color: var(--ink-dim); }
.deck-mapping-table[open] summary::after { content: "Hide"; }
.deck-mapping-table summary small { color: var(--ink-faint); font-weight: 400; font-size: 12px; }
.mapping-table-scroll { max-height: 420px; overflow: auto; margin-top: 12px; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--line); }
.deck-mapping-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.deck-mapping-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font: 600 10px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); padding: 9px 12px; }
.deck-mapping-table td { padding: 8px 12px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.deck-mapping-table tr:hover td { background: rgba(255,255,255,.025); cursor: pointer; }

/* ── inspector (pinned in Workbench, drawer on Stage) ───────────────────── */
.deck-inspector { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-radius: var(--r-lg); background: var(--surface-1); box-shadow: 0 0 0 1px var(--line), var(--raise); }
.inspector-heading { display: grid; gap: 8px; padding: 16px; border-bottom: 1px solid var(--line); }
.inspector-kicker { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; }
.deck-drawer-close { display: none; width: 32px; min-width: 32px; min-height: 32px; }
.inspector-heading h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.inspector-heading p { margin: 0; font: 11px/1.5 var(--mono); color: var(--ink-dim); overflow-wrap: anywhere; }
.deck-live-value { display: grid; gap: 6px; }
.deck-live-value > label { font-size: 11.5px; font-weight: 600; color: var(--ink-dim); }
.deck-value-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px auto; gap: 8px; align-items: center; }
.deck-value-bar { position: relative; height: 34px; border-radius: 8px; background: var(--surface-0); box-shadow: inset 0 0 0 1px var(--line-2); cursor: ew-resize; touch-action: none; overflow: hidden; }
.deck-value-bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-soft); border-right: 2px solid var(--accent); }
#deckValueInput { width: 100%; font: 600 15px var(--mono); text-align: right; color: var(--accent); }
.deck-reset-value { min-height: 34px; padding: 0 10px; font-size: 12px; }
#deckGateStatus { font: 11px var(--mono); color: var(--ink-faint); }
.device-enum-field { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--ink-2); }
.inspector-tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.inspector-tabs button { min-height: 0; padding: 11px 10px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--ink-dim); font: 600 13px var(--sans); cursor: pointer; }
.inspector-tabs button[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.inspector-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 0 16px 16px; }
.inspector-section { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; }
.inspector-section + .inspector-section { margin-top: 14px; border-top: 1px solid var(--line); }
.inspector-section-title { display: flex; align-items: center; gap: 10px; }
.inspector-section-title > span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-3); font: 700 10px var(--mono); color: var(--accent); }
.inspector-section-title h4 { flex: 1; margin: 0; font-size: 13.5px; }
.deck-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 11.5px; color: var(--ink-2); }
.deck-field label, .deck-field .field-label { font-weight: 600; color: var(--ink-dim); }
.deck-field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.deck-field textarea { font: 12px var(--mono); }
.deck-curve-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 8px; align-items: stretch; }
.deck-curve-preview { width: 100%; height: 38px; padding: 5px; border-radius: 8px; background: var(--surface-0); box-shadow: inset 0 0 0 1px var(--line-2); overflow: visible; }
.deck-curve-preview polyline, .stage-node-curve polyline { fill: none; stroke: var(--accent); stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.deck-raw-preview { display: block; padding: 8px 10px; border-radius: 8px; background: var(--surface-0); box-shadow: inset 0 0 0 1px var(--line); font: 11.5px var(--mono); color: var(--ink-dim); overflow-wrap: anywhere; }
.field-help, .inspector-description { margin: 0; font-size: 11.5px; color: var(--ink-dim); }
.button-learn, .button-learn-target { width: 100%; }
.button-learn-target { border-color: var(--accent-line) !important; color: var(--accent); background: var(--accent-soft) !important; }
.learn-actions { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.learn-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.button-learn.learning .learn-dot, .learning .learn-dot { animation: led-pulse .7s ease-in-out infinite; }
.learn-status { margin: 0; font: 11px var(--mono); color: var(--deck-in); }
.deck-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 12.5px; }
.deck-check strong, .deck-check small { display: block; }
.deck-check small { color: var(--ink-dim); font-size: 11px; }
.inspector-utility { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-0); }
.mapping-clipboard { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 6px; }
.mapping-clipboard .button { white-space: nowrap; }
.inspector-utility p { margin: 0; font-size: 11px; color: var(--ink-faint); }
.button-panic { width: 100%; color: #ffb3a8; border-color: rgba(255,90,72,.4) !important; background: rgba(255,90,72,.09) !important; }

/* ── Stage layout ──────────────────────────────────────────────────────── */
.deck-st { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.stage-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.stage-controls .deck-channel-keys { display: flex; gap: 2px; padding: 4px; border-radius: 99px; background: var(--surface-0); box-shadow: 0 0 0 1px var(--line); }
.stage-controls .deck-channel-keys button { display: grid; place-items: center; align-content: center; justify-content: center; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: transparent; box-shadow: none; }
.stage-controls .deck-channel-keys button span { font-size: 11px; }
.stage-controls .deck-channel-keys button i { position: absolute; inset: 2px; height: auto; border-radius: 50%; background: none; box-shadow: 0 0 0 2px var(--deck-in); opacity: 0; transition: opacity .5s; }
.stage-controls .deck-channel-keys button i::after { display: none; }
.stage-controls .deck-channel-keys button.activity i { opacity: 1; transition: opacity .05s; }
.stage-controls .deck-channel-keys .channel-dot { top: 3px; right: 3px; width: 4px; height: 4px; }
.stage-controls .deck-channel-keys button.active { background: var(--ink); }
.stage-controls .deck-bank-keys button small { display: none; }
.stage-controls .deck-bank-keys button { min-width: 38px; justify-content: center; }
.stage-focus { display: grid; grid-template-columns: 340px minmax(0, 1fr); overflow: hidden; }
.stage-dial-side { display: grid; justify-items: center; align-content: center; gap: 14px; padding: 22px; border-right: 1px solid var(--line); background: radial-gradient(120% 80% at 50% 30%, #1b1b1e, var(--surface-1) 70%); }
.stage-dial { position: relative; width: 250px; height: 250px; border-radius: 50%; cursor: ns-resize; touch-action: none; user-select: none; outline: none; }
.stage-dial:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.stage-dial[aria-disabled="true"] { cursor: default; opacity: .6; }
.stage-dial-readout { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; pointer-events: none; }
#stageValue { font: 600 60px/1 var(--mono); letter-spacing: -.04em; }
#stageRange { font: 12px var(--mono); color: var(--ink-dim); }
#stageName { margin: 0; font-size: 22px; letter-spacing: -.02em; text-align: center; overflow-wrap: anywhere; }
.stage-steps { display: flex; gap: 8px; }
.stage-flow-side { display: grid; gap: 14px; align-content: start; min-width: 0; padding: 18px 20px; }
.stage-flow-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stage-flow-head .button { margin-left: auto; }
.stage-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }
.stage-node { position: relative; display: grid; gap: 6px; align-content: start; min-width: 0; padding: 12px 13px; border: 0; border-radius: 12px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-2), inset 0 1px 0 rgba(255,255,255,.04); color: var(--ink); text-align: left; cursor: pointer; }
.stage-node:hover { box-shadow: 0 0 0 1px var(--line-3); }
.stage-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stage-node:not(:last-child)::after { content: ""; position: absolute; top: 50%; right: -23px; width: 22px; height: 2px; background: linear-gradient(90deg, var(--line-3), var(--ink-dim)); }
.stage-node:not(:last-child)::before { content: ""; position: absolute; top: calc(50% - 4px); right: -24px; z-index: 1; border: 5px solid transparent; border-left-color: var(--ink-dim); border-right: 0; }
.stage-node strong { font: 600 14px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-node small { font-size: 11.5px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-node.in { box-shadow: 0 0 0 1px rgba(95,208,255,.35); } .stage-node.in strong { color: var(--deck-in); }
.stage-node.out { box-shadow: 0 0 0 1px var(--accent-line); } .stage-node.out strong { color: var(--accent); }
.stage-node.none strong { color: var(--ink-faint); }
.stage-node-curve { width: 100%; height: 34px; display: block; }
.stage-node-curve polyline { stroke: var(--ink-2); }
.stage-trace { display: grid; gap: 8px; }
.stage-trace-label { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: 11.5px; color: var(--ink-dim); }
.trace-key::before { content: ""; display: inline-block; width: 14px; height: 2px; margin-right: 6px; vertical-align: middle; }
.trace-key-input::before { background: repeating-linear-gradient(90deg, var(--trace-input) 0 4px, transparent 4px 7px); }
.trace-key-output::before { background: var(--trace); }
#stageTrace { display: block; width: 100%; height: 210px; }
.stage-encoder-panel .deck-knob-grid { grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 6px; }
.stage-encoder-panel .deck-knob { padding: 8px 2px 7px; background: transparent; box-shadow: none; gap: 3px; }
.stage-encoder-panel .deck-knob:hover { background: var(--surface-2); }
.stage-encoder-panel .deck-knob.selected { background: var(--surface-3); box-shadow: 0 0 0 1.5px var(--accent); }
.stage-encoder-panel .knob-topline { justify-content: center; gap: 4px; font-size: 9.5px; }
.stage-encoder-panel .knob-dial { width: 52px; height: 52px; }
.stage-encoder-panel .knob-value { font-size: 12px; }
.stage-encoder-panel .knob-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; min-height: 2.5em; padding: 0 3px; font-size: 11px; line-height: 1.25; white-space: normal; overflow-wrap: anywhere; }
.stage-encoder-panel :is(.knob-route, .knob-spark) { display: none; }
.stage-dock { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.stage-dock .fader-well { width: 14px; overflow: visible; background: var(--surface-0); }
.stage-dock .fader-fill { border-radius: 7px; background: var(--deck-in); opacity: .6; }
.stage-dock .fader-well input[type="range"] { left: -10px; right: -10px; width: auto; }
.stage-dock .fader-well input[type="range"]::-webkit-slider-thumb { width: 28px; height: 14px; border-radius: 4px; }
.stage-dock .fader-route { display: none; }
.stage-dock .deck-pad { min-height: 74px; }
.stage-dock .snapshot-hint, .stage-dock .snapshot-heading .deck-micro-label { display: none; }
.stage-dock .snapshot-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.stage-dock .snapshot-chip { min-height: 60px; align-content: space-between; }
.stage-dock .snapshot-controls { grid-template-columns: minmax(0, 1fr); }
.stage-more { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.deck-drawer-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.45); }
.deck-drawer-scrim[hidden] { display: none; }
.deck-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 71; width: min(420px, 100vw); transform: translateX(100%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
.controller-deck.drawer-open .deck-drawer { transform: none; visibility: visible; transition: transform .22s ease; }
.controller-deck[data-deck-mode="workbench"] .deck-drawer { display: none; }
.deck-drawer .deck-inspector { height: 100%; border-radius: 0; box-shadow: -30px 0 60px rgba(0,0,0,.5), -1px 0 0 var(--line-2); background: #141416; }
.deck-drawer .deck-drawer-close { display: inline-grid; }

/* ── mode morph (View Transitions) ─────────────────────────────────────── */
#deckKnobs { view-transition-name: deck-knobs; }
.fader-section { view-transition-name: deck-faders; }
.pad-section { view-transition-name: deck-pads; }
.deck-snapshots { view-transition-name: deck-snapshots; }
.deck-channel-keys { view-transition-name: deck-channels; }
#oledValue, #stageValue { view-transition-name: deck-value; }
#oledTitle, #stageName { view-transition-name: deck-name; }
#oledRing, #stageDial { view-transition-name: deck-dial; }
#oledActivity, #stageTrace { view-transition-name: deck-trace; }
::view-transition-group(*) { animation-duration: .42s; animation-timing-function: cubic-bezier(.2,.8,.2,1); }

/* ── compact & full screen ──────────────────────────────────────────────── */
.controller-deck.deck-compact .oled-overview { display: none; }
.controller-deck.deck-compact .oled-main { grid-template-columns: 260px minmax(0, 1fr); min-height: 0; }
.controller-deck.deck-compact #oledActivity { height: 120px; }
.controller-deck.deck-compact .deck-wb .knob-dial { width: 50px; height: 50px; }
.controller-deck.deck-compact .deck-wb :is(.knob-route, .knob-spark) { display: none; }
.controller-deck.deck-compact .fader-well { height: 100px; }
.controller-deck.deck-compact .deck-pad { min-height: 56px; }
.controller-deck.deck-compact .stage-dial { width: 200px; height: 200px; }
.controller-deck.deck-compact #stageTrace { height: 150px; }
.controller-deck:fullscreen { padding: 22px; overflow: auto; background: var(--bg); }
.controller-deck:fullscreen .deck-wb-side { top: 14px; }
.controller-deck:fullscreen .deck-wb-side .deck-inspector { max-height: calc(100vh - 28px); }

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1500px) {
  .oled-main { grid-template-columns: 260px minmax(0, 1fr); }
  .oled-overview { display: none; }
  .stage-encoder-panel .deck-knob-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  .deck-wb { grid-template-columns: minmax(0, 1fr); }
  .deck-wb-side { position: static; }
  .deck-wb-side .deck-inspector { max-height: none; }
  .deck-wb-side .inspector-scroll { overflow: visible; }
  .deck-wb .deck-knob-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lower-deck, .deck-memory, .stage-dock, .stage-more { grid-template-columns: minmax(0, 1fr); }
  .stage-focus { grid-template-columns: minmax(0, 1fr); }
  .stage-dial-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-flow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .stage-node::before, .stage-node::after { display: none; }
  .deck-mode-area { margin: 0; }
}
@media (max-width: 760px) {
  .deck-toolbar > * { flex: 1 1 auto; }
  .deck-profile-name { flex-basis: 100%; }
  .deck-mode-area { order: -1; flex-basis: 100%; }
  .deck-mode-switch { width: 100%; }
  .deck-mode-key, .deck-spec { display: none; }
  .deck-channel-keys { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .stage-controls .deck-channel-keys { flex-wrap: wrap; border-radius: 16px; }
  .oled-main { grid-template-columns: minmax(0, 1fr); }
  .oled-focus { border-right: 0; border-bottom: 1px solid var(--line); }
  #oledValue { font-size: 48px; }
  .deck-wb .deck-knob-grid, .stage-encoder-panel .deck-knob-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .deck-fader-grid { gap: 4px; }
  .fader-well { width: 26px; }
  .snapshot-controls, .deck-extra-inputs { grid-template-columns: minmax(0, 1fr); }
  .stage-dial { width: 200px; height: 200px; }
  #stageValue { font-size: 48px; }
  .stage-flow { grid-template-columns: minmax(0, 1fr); }
  .hardware-label small { margin-left: 0; flex-basis: 100%; }
  .deck-value-row { grid-template-columns: minmax(0, 1fr) 76px auto; }
}
