/* ==========================================================================
   SynthFrame — Pure CSS Wireframe Styling (No frameworks, no external deps)
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg-app: #111317;
  --bg-panel: #171a20;
  --bg-elevated: #1e222a;
  --bg-viewport: #0c0e12;
  --bg-canvas: #151921;
  --bg-module: rgba(255, 255, 255, 0.02);
  --bg-widget: #1b2029;
  --bg-screen: #0d1117;
  --bg-input: #111419;

  --ink: #e4e8f0;
  --ink-muted: #8b95a7;
  --ink-faint: #525b6c;
  --stroke: #384152;
  --stroke-strong: #6d7a92;
  --wire: #cdd5e3;
  --wire-dim: #5d687d;

  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --signal: #f59e0b;
  --danger: #f87171;
  --led-on: #38bdf8;

  --grid-dot: rgba(148, 163, 184, 0.15);
  --grid-major: rgba(148, 163, 184, 0.06);
  --wood-1: #3b281e;
  --wood-2: #2a1b14;
  --shadow-chassis: 0 20px 50px rgba(0, 0, 0, 0.55);
}

[data-theme="light"] {
  --bg-app: #eef1f5;
  --bg-panel: #f8f9fb;
  --bg-elevated: #ffffff;
  --bg-viewport: #dfe4ec;
  --bg-canvas: #fcfdff;
  --bg-module: rgba(15, 23, 42, 0.02);
  --bg-widget: #f3f6fa;
  --bg-screen: #e9eef6;
  --bg-input: #ffffff;

  --ink: #161b26;
  --ink-muted: #556074;
  --ink-faint: #8a95a8;
  --stroke: #cbd3e1;
  --stroke-strong: #7b889e;
  --wire: #1e293b;
  --wire-dim: #7c899e;

  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.12);
  --signal: #d97706;
  --danger: #dc2626;
  --led-on: #0284c7;

  --grid-dot: rgba(30, 41, 59, 0.18);
  --grid-major: rgba(30, 41, 59, 0.05);
  --wood-1: #8c5a3c;
  --wood-2: #6e452c;
  --shadow-chassis: 0 16px 40px rgba(15, 23, 42, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ==========================================================================
   Shell & Top Toolbar
   ========================================================================== */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

.topbar {
  min-height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--stroke);
  user-select: none;
  overflow-x: auto;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink);
}

.brand-badge svg {
  color: var(--accent);
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--stroke);
  margin: 0 4px;
}

.toolbar-select,
.toolbar-btn,
.icon-btn,
.chip-btn {
  height: 30px;
  border-radius: 5px;
  border: 1px solid var(--stroke);
  background: var(--bg-elevated);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s, color 0.12s;
}

.toolbar-select {
  padding: 0 8px;
  font-size: 12px;
  background: var(--bg-input);
  max-width: 255px;
}

.template-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.template-switcher .icon-btn {
  width: 26px;
  font-size: 10px;
}

.toolbar-btn {
  padding: 0 11px;
  font-size: 12px;
  font-weight: 500;
}

.toolbar-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06131d;
  font-weight: 600;
}

[data-theme="light"] .toolbar-btn.primary {
  color: #ffffff;
}

.toolbar-btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled),
.chip-btn:hover:not(:disabled),
.toolbar-select:hover {
  border-color: var(--stroke-strong);
}

.toolbar-btn.primary:hover {
  filter: brightness(1.08);
}

.icon-btn {
  width: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:disabled,
.toolbar-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.chip-btn {
  padding: 0 9px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-muted);
}

.chip-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.mode-group {
  background: var(--bg-input);
  padding: 3px;
  border-radius: 7px;
  border: 1px solid var(--stroke);
  gap: 2px;
}

.mode-btn {
  height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.mode-btn:hover {
  color: var(--ink);
}

.mode-btn.active {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--stroke);
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.zoom-controls .icon-btn {
  border: none;
  border-radius: 0;
  width: 26px;
  height: 28px;
}

.zoom-readout {
  border: none;
  border-left: 1px solid var(--stroke);
  border-right: 1px solid var(--stroke);
  background: var(--bg-input);
  height: 28px;
  min-width: 50px;
  padding: 0 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  cursor: pointer;
}

/* ==========================================================================
   Main 3-Column Workspace & Sidebars
   ========================================================================== */

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  flex-shrink: 0;
  min-height: 0;
  user-select: none;
}

.sidebar-left {
  width: 244px;
  border-right: 1px solid var(--stroke);
}

.sidebar-right {
  width: 280px;
  border-left: 1px solid var(--stroke);
}

.sidebar-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-header {
  padding: 12px;
}

.sidebar-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.palette-search {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid var(--stroke);
  background: var(--bg-input);
  font-size: 12px;
  outline: none;
}

.palette-search:focus {
  border-color: var(--accent);
}

.palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.palette-category-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 6px 2px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.palette-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--stroke);
  border-radius: 6px;
  cursor: grab;
  text-align: center;
  transition: border-color 0.12s, transform 0.08s, background-color 0.12s;
}

.palette-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.palette-card:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.palette-card svg {
  width: 34px;
  height: 26px;
  color: var(--wire);
  flex-shrink: 0;
}

.palette-card-name {
  font-size: 11px;
  line-height: 1.2;
  color: var(--ink);
}

.sidebar-footer {
  padding: 9px 12px;
  border-top: 1px solid var(--stroke);
  background: var(--bg-input);
}

.shortcut-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-muted);
}

.shortcut-hint kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--stroke);
  background: var(--bg-elevated);
  color: var(--ink);
}

/* ==========================================================================
   Center Viewport & Synth Chassis
   ========================================================================== */

.viewport-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-viewport);
}

.mode-banner {
  flex-shrink: 0;
  padding: 4px 12px;
  text-align: center;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--accent);
  color: var(--accent);
}

.viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  padding: 28px;
  outline: none;
  position: relative;
}

.viewport.panning {
  cursor: grab !important;
}

.viewport.panning:active {
  cursor: grabbing !important;
}

.canvas-stage {
  margin: auto;
  position: relative;
  flex-shrink: 0;
}

.synth-chassis {
  transform-origin: top left;
}

.synth-chassis {
  display: inline-flex;
  align-items: stretch;
  border-radius: 6px;
  box-shadow: var(--shadow-chassis);
  user-select: none;
}

.chassis-body {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--stroke-strong);
  background: var(--bg-canvas);
  border-radius: 4px;
  overflow: hidden;
}

.synth-chassis.has-wood-cheeks .chassis-body,
.synth-chassis.has-rack-ears .chassis-body {
  border-radius: 0;
}

.chassis-cheek {
  display: none;
  width: 22px;
  background: repeating-linear-gradient(
    90deg,
    var(--wood-1) 0px,
    var(--wood-1) 4px,
    var(--wood-2) 4px,
    var(--wood-2) 7px
  );
  border-top: 1.5px solid var(--stroke-strong);
  border-bottom: 1.5px solid var(--stroke-strong);
}

.chassis-cheek-left {
  border-left: 1.5px solid var(--stroke-strong);
  border-radius: 5px 0 0 5px;
}

.chassis-cheek-right {
  border-right: 1.5px solid var(--stroke-strong);
  border-radius: 0 5px 5px 0;
}

.synth-chassis.has-wood-cheeks .chassis-cheek {
  display: block;
}

.chassis-ear {
  display: none;
  width: 28px;
  background: var(--bg-elevated);
  border-top: 1.5px solid var(--stroke-strong);
  border-bottom: 1.5px solid var(--stroke-strong);
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
}

.chassis-ear-left {
  border-left: 1.5px solid var(--stroke-strong);
  border-radius: 3px 0 0 3px;
}

.chassis-ear-right {
  border-right: 1.5px solid var(--stroke-strong);
  border-radius: 0 3px 3px 0;
}

.synth-chassis.has-rack-ears .chassis-ear {
  display: flex;
}

.rack-hole {
  width: 14px;
  height: 9px;
  border-radius: 99px;
  border: 1.5px solid var(--stroke-strong);
  background: var(--bg-viewport);
}

.chassis-header {
  display: none;
  height: 30px;
  padding: 0 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--stroke);
  background: var(--bg-panel);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
}

.synth-chassis.has-header-bar .chassis-header {
  display: flex;
}

.chassis-brand,
.chassis-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chassis-title-text {
  font-weight: 700;
  color: var(--wire);
}

#chassis-dims-text {
  color: var(--ink-faint);
  font-size: 10px;
}

.screw-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--stroke-strong);
  position: relative;
  display: inline-block;
}

.screw-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 1px;
  right: 1px;
  height: 1px;
  background: var(--stroke-strong);
  transform: rotate(-35deg);
}

.eurorack-rail {
  display: none;
  height: 18px;
  background:
    radial-gradient(circle at 18px 9px, var(--bg-viewport) 3.5px, var(--stroke-strong) 4px, transparent 4.6px),
    radial-gradient(circle at calc(100% - 18px) 9px, var(--bg-viewport) 3.5px, var(--stroke-strong) 4px, transparent 4.6px),
    repeating-linear-gradient(90deg, transparent 0, transparent 18px, var(--grid-major) 18px, var(--grid-major) 19px),
    var(--bg-panel);
}

.eurorack-rail-top {
  border-bottom: 1px solid var(--stroke);
}

.eurorack-rail-bottom {
  border-top: 1px solid var(--stroke);
}

.synth-chassis.has-eurorack-rails .eurorack-rail {
  display: block;
}

/* ==========================================================================
   Synth Canvas, Grid, Layers & Wireframe Items
   ========================================================================== */

.synth-canvas {
  position: relative;
  background-color: var(--bg-canvas);
  overflow: hidden;
  --grid-size: 10px;
}

.synth-canvas.show-grid {
  background-image:
    radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}

.connections-layer,
.items-layer,
.guides-layer {
  position: absolute;
  inset: 0;
}

.connections-layer {
  width: 100%;
  height: 100%;
  z-index: 15;
  pointer-events: none;
}

.synth-canvas.mode-connect .connections-layer {
  pointer-events: auto;
}

.signal-line-hit {
  stroke: transparent;
  stroke-width: 12px;
  fill: none;
  cursor: pointer;
}

.signal-line {
  stroke: var(--signal);
  stroke-width: 1.6px;
  stroke-dasharray: 5 3;
  fill: none;
  opacity: 0.85;
}

.signal-group:hover .signal-line {
  stroke: var(--danger);
  stroke-width: 2.2px;
  opacity: 1;
}

.items-layer {
  z-index: 10;
}

.guides-layer {
  z-index: 25;
  pointer-events: none;
}

.align-guide {
  position: absolute;
  background: var(--accent);
  opacity: 0.75;
}

.align-guide.vertical {
  top: 0;
  bottom: 0;
  width: 1px;
}

.align-guide.horizontal {
  left: 0;
  right: 0;
  height: 1px;
}

.marquee-box {
  position: absolute;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
}

/* Individual Wireframe Element on Canvas */
.wf-item {
  position: absolute;
  display: flex;
  flex-direction: column;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.wf-item:active {
  cursor: grabbing;
}

.synth-canvas.mode-connect .wf-item {
  cursor: crosshair;
}

.synth-canvas.mode-test .wf-item {
  cursor: pointer;
}

.wf-item.is-container {
  z-index: 1;
}

.wf-item:not(.is-container) {
  z-index: 5;
}

.wf-item.selected {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
}

.wf-item.connect-source {
  outline: 2px dashed var(--signal);
  outline-offset: 3px;
}

.wf-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.wf-node-badge {
  position: absolute;
  top: 2px;
  right: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  padding: 0 3px;
  border-radius: 2px;
  background: var(--accent-soft);
  color: var(--accent);
  pointer-events: none;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Resize Handles */
.resize-handle {
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--bg-canvas);
  border: 1.5px solid var(--accent);
  border-radius: 1px;
  z-index: 20;
}

.resize-handle[data-dir="nw"] { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle[data-dir="n"]  { top: -5px; left: calc(50% - 3.5px); cursor: ns-resize; }
.resize-handle[data-dir="ne"] { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle[data-dir="e"]  { top: calc(50% - 3.5px); right: -5px; cursor: ew-resize; }
.resize-handle[data-dir="se"] { bottom: -5px; right: -5px; cursor: nwse-resize; }
.resize-handle[data-dir="s"]  { bottom: -5px; left: calc(50% - 3.5px); cursor: ns-resize; }
.resize-handle[data-dir="sw"] { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle[data-dir="w"]  { top: calc(50% - 3.5px); left: -5px; cursor: ew-resize; }

/* ==========================================================================
   Wireframe Component Primitives (Inside .wf-inner)
   ========================================================================== */

.wf-caption {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--wire);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  flex-shrink: 0;
}

.wf-subcaption {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  color: var(--ink-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
  flex-shrink: 0;
}

/* Section / Module Frame */
.wf-section {
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-module);
  display: flex;
  flex-direction: column;
}

.wf-section.dashed {
  border-style: dashed;
}

.wf-section.double {
  border-style: double;
  border-width: 3px;
}

.wf-section-header {
  height: 20px;
  padding: 0 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--stroke);
  background: rgba(127, 140, 165, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--wire);
}

.wf-section-sub {
  font-weight: 400;
  font-size: 9px;
  color: var(--ink-muted);
}

/* Text Label & Divider */
.wf-label-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-divider-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wf-divider-line {
  background: var(--stroke-strong);
}

/* SVG Graphic Controls (Knob, Fader, Slider, XY, Wheels, Display, Jack, VU) */
.wf-svg-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wf-svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* OLED / LCD Screen */
.wf-screen {
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-screen);
  display: flex;
  flex-direction: column;
  padding: 5px 7px;
  position: relative;
}

.wf-screen-top {
  display: flex;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

/* Drum Pads */
.wf-pad-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 5px;
  padding: 2px;
}

.wf-pad-cell {
  border: 1.5px solid var(--wire-dim);
  border-radius: 3px;
  background: var(--bg-widget);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  color: var(--ink-muted);
}

.wf-pad-cell.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--wire);
}

.wf-pad-led {
  width: 6px;
  height: 3px;
  border-radius: 1px;
  background: var(--stroke-strong);
}

.wf-pad-cell.active .wf-pad-led {
  background: var(--led-on);
}

/* Step Sequencer */
.wf-seq-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wf-seq-header {
  display: flex;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  color: var(--ink-muted);
}

.wf-seq-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 3px;
}

.wf-seq-step {
  border: 1px solid var(--wire-dim);
  border-radius: 2px;
  background: var(--bg-widget);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 3px 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  color: var(--ink-faint);
}

.wf-seq-step.beat-accent {
  border-color: var(--stroke-strong);
}

.wf-seq-step.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--wire);
}

.wf-seq-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid var(--wire-dim);
}

.wf-seq-step.on .wf-seq-dot {
  background: var(--led-on);
  border-color: var(--led-on);
}

/* Push Button + LED */
.wf-btn-widget {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.wf-btn-cap {
  width: 100%;
  flex: 1;
  min-height: 16px;
  border: 1.5px solid var(--wire);
  border-radius: 3px;
  background: var(--bg-widget);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 2px 4px;
}

.wf-btn-cap.round {
  border-radius: 999px;
  aspect-ratio: 1 / 1;
  width: auto;
  height: 100%;
  max-width: 100%;
}

.wf-btn-cap.led-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wf-led-pill {
  width: 10px;
  height: 4px;
  border-radius: 99px;
  border: 1px solid var(--wire-dim);
  background: transparent;
}

.wf-btn-cap.led-active .wf-led-pill {
  background: var(--led-on);
  border-color: var(--led-on);
}

/* Top Menu / Preset Bar */
.wf-topmenu {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: var(--bg-panel);
  border: 1.5px solid var(--stroke-strong);
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-topmenu-left,
.wf-topmenu-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.wf-topmenu-brand {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--wire);
  padding-right: 6px;
  border-right: 1px solid var(--stroke);
  white-space: nowrap;
}

.wf-topmenu-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}

.wf-topmenu-item {
  font-size: 9.5px;
  padding: 3px 6px;
  border-radius: 3px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.wf-topmenu-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.wf-preset-box {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--stroke-strong);
  border-radius: 3px;
  background: var(--bg-screen);
  font-size: 9.5px;
  color: var(--accent);
  white-space: nowrap;
}

.wf-preset-arrow {
  color: var(--ink-muted);
  font-size: 8.5px;
  padding: 0 2px;
}

.wf-status-pill {
  font-size: 8.5px;
  padding: 2px 5px;
  border-radius: 2px;
  border: 1px solid var(--stroke);
  background: var(--bg-widget);
  color: var(--ink-muted);
  white-space: nowrap;
}

/* Tabs / Section Switcher */
.wf-tabs {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.wf-tabs.style-folder {
  gap: 3px;
  border-bottom: 1.5px solid var(--stroke-strong);
}

.wf-tabs.style-folder .wf-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 1px solid var(--stroke);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: var(--bg-module);
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wf-tabs.style-folder .wf-tab.active {
  background: var(--bg-widget);
  border-color: var(--accent);
  border-top-width: 2px;
  color: var(--wire);
}

.wf-tabs.style-pills {
  gap: 3px;
  padding: 3px;
  background: var(--bg-screen);
  border: 1px solid var(--stroke-strong);
  border-radius: 5px;
}

.wf-tabs.style-pills .wf-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 3px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wf-tabs.style-pills .wf-tab.active {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
}

.wf-tabs.style-underline {
  gap: 8px;
  border-bottom: 1px solid var(--stroke);
}

.wf-tabs.style-underline .wf-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wf-tabs.style-underline .wf-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Button Row / Bank Strip */
.wf-btnrow-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wf-btnrow {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 4px;
}

.wf-btnrow-cell {
  border: 1px solid var(--wire-dim);
  border-radius: 3px;
  background: var(--bg-widget);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 2px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 600;
  color: var(--ink-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.wf-btnrow-cell.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--wire);
}

.wf-btnrow-led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid var(--wire-dim);
  flex-shrink: 0;
}

.wf-btnrow-cell.on .wf-btnrow-led {
  background: var(--led-on);
  border-color: var(--led-on);
}

/* Transport / MIDI Clock Bar */
.wf-transport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 8px;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-panel);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-trans-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.wf-trans-btn {
  min-width: 24px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid var(--wire-dim);
  border-radius: 3px;
  background: var(--bg-widget);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--wire);
}

.wf-trans-btn.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.wf-trans-btn.rec.on {
  border-color: var(--danger);
  color: var(--danger);
}

.wf-trans-lcd {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  border: 1px solid var(--stroke);
  border-radius: 3px;
  background: var(--bg-screen);
  font-size: 9.5px;
  color: var(--accent);
  white-space: nowrap;
}

/* Piano Roll / MIDI Note Grid */
.wf-pianoroll {
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-screen);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wf-pianoroll-head {
  height: 18px;
  padding: 0 7px;
  border-bottom: 1px solid var(--stroke);
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  color: var(--ink-muted);
}

/* MIDI Mapping / Mod Matrix Table */
.wf-miditable-wrap {
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-screen);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-miditable-title {
  padding: 4px 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--stroke);
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--wire);
}

.wf-miditable {
  width: 100%;
  border-collapse: collapse;
  font-size: 9px;
  table-layout: fixed;
}

.wf-miditable th {
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--stroke-strong);
  color: var(--ink-muted);
  font-weight: 700;
  background: rgba(127, 140, 165, 0.07);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wf-miditable td {
  padding: 3.5px 6px;
  border-bottom: 1px solid var(--stroke);
  color: var(--wire);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wf-miditable tr.active-row td {
  background: var(--accent-soft);
  color: var(--accent);
}

.insp-textarea {
  width: 100%;
  min-height: 82px;
  padding: 6px 7px;
  border-radius: 4px;
  border: 1px solid var(--stroke);
  background: var(--bg-input);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  resize: vertical;
  outline: none;
}

.insp-textarea:focus {
  border-color: var(--accent);
}

/* Pin Matrix / Crosspoint Modulation Grid */
.wf-pinmatrix-wrap {
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-screen);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-pinmatrix-head {
  padding: 3px 7px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--stroke);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--wire);
  flex-shrink: 0;
}

.wf-pinmatrix-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  padding: 3px 5px 5px;
  gap: 1px;
  align-items: center;
}

.wf-pm-colhead {
  font-size: 7.5px;
  color: var(--ink-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 1px 3px;
  border-bottom: 1px solid var(--stroke);
}

.wf-pm-rowhead {
  font-size: 8px;
  color: var(--wire);
  padding-right: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: 1px solid var(--stroke);
}

.wf-pm-cell {
  width: 100%;
  height: 100%;
  min-height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px dashed rgba(127, 140, 165, 0.14);
  border-bottom: 1px dashed rgba(127, 140, 165, 0.14);
}

.wf-pm-socket {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid var(--wire-dim);
  background: var(--bg-canvas);
}

.wf-pm-cell.pinned .wf-pm-socket {
  width: 8px;
  height: 8px;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Dropdown / NumBox / Parameter Field */
.wf-dropdown {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-dropdown-box {
  flex: 1;
  min-height: 20px;
  padding: 0 8px;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 3px;
  background: var(--bg-screen);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 9.5px;
  color: var(--accent);
  overflow: hidden;
  white-space: nowrap;
}

.wf-dropdown-box.numbox {
  border-color: var(--wire-dim);
  color: var(--wire);
  font-weight: 700;
}

/* Chord Pads */
.wf-chord-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 4px;
}

.wf-chord-cell {
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-widget);
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-chord-cell.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wf-chord-deg {
  font-size: 8px;
  color: var(--ink-muted);
}

.wf-chord-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--wire);
}

.wf-chord-cell.active .wf-chord-name {
  color: var(--accent);
}

/* Multi-Track Drum Matrix */
.wf-drumgrid-wrap {
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-screen);
  display: flex;
  flex-direction: column;
  padding: 4px 6px;
  gap: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wf-drumgrid-row {
  flex: 1;
  min-height: 0;
  display: grid;
  align-items: stretch;
  gap: 2px;
}

.wf-dg-name {
  font-size: 8px;
  font-weight: 700;
  color: var(--wire);
  display: flex;
  align-items: center;
  padding-right: 4px;
  overflow: hidden;
  white-space: nowrap;
}

.wf-dg-cell {
  border: 1px solid var(--stroke);
  border-radius: 2px;
  background: var(--bg-widget);
}

.wf-dg-cell.beat {
  border-color: var(--stroke-strong);
}

.wf-dg-cell.on {
  background: var(--accent);
  border-color: var(--accent);
}

/* Patchbay Strip */
.wf-patchbay {
  width: 100%;
  height: 100%;
  border: 1.5px dashed var(--stroke-strong);
  border-radius: 4px;
  background: var(--bg-module);
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wf-patchbay-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 4px;
  align-items: center;
}

.wf-pb-jack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 7.5px;
  color: var(--wire);
}

.wf-pb-jack.is-out span {
  background: var(--wire);
  color: var(--bg-canvas);
  padding: 0 3px;
  border-radius: 2px;
  font-weight: 700;
}

/* ==========================================================================
   Bottom Status Bar
   ========================================================================== */

.status-bar {
  height: 28px;
  flex-shrink: 0;
  padding: 0 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--ink-muted);
  user-select: none;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-sep {
  color: var(--ink-faint);
}

/* ==========================================================================
   Right Inspector Forms & Controls
   ========================================================================== */

.inspector-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.insp-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--stroke);
}

.insp-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.insp-section-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.insp-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insp-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.insp-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.insp-label {
  font-size: 11px;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.insp-input,
.insp-select {
  width: 100%;
  height: 28px;
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid var(--stroke);
  background: var(--bg-input);
  font-size: 12px;
  outline: none;
}

.insp-input[type="number"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.insp-input:focus,
.insp-select:focus {
  border-color: var(--accent);
}

.insp-range {
  width: 100%;
  accent-color: var(--accent);
  margin: 2px 0;
}

.insp-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
}

.insp-check input {
  accent-color: var(--accent);
}

.insp-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.insp-btn {
  height: 28px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--stroke);
  background: var(--bg-elevated);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.insp-btn:hover {
  border-color: var(--stroke-strong);
}

.insp-btn.danger {
  color: var(--danger);
}

.insp-btn.danger:hover {
  border-color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}

.align-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.conn-pill-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conn-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 7px;
  border-radius: 4px;
  border: 1px solid var(--stroke);
  background: var(--bg-input);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.conn-pill button {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0 3px;
}

.conn-pill button:hover {
  color: var(--danger);
}

/* ==========================================================================
   Drag Ghost & Export/Import Modal
   ========================================================================== */

.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1.5px dashed var(--accent);
  background: var(--bg-elevated);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5, 8, 13, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  width: min(780px, 100%);
  max-height: 86vh;
  background: var(--bg-panel);
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  border-bottom: 1px solid var(--stroke);
  background: var(--bg-input);
}

.modal-tab {
  padding: 7px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
  cursor: pointer;
}

.modal-tab.active {
  background: var(--bg-panel);
  border-color: var(--stroke);
  color: var(--accent);
  font-weight: 600;
}

.modal-body {
  padding: 14px 16px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.modal-desc {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.svg-preview-box {
  padding: 12px;
  border: 1px solid var(--stroke);
  border-radius: 5px;
  background: var(--bg-viewport);
  max-height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.svg-preview-box svg {
  max-width: 100%;
  max-height: 185px;
  height: auto;
}

.modal-code {
  width: 100%;
  min-height: 240px;
  flex: 1;
  padding: 10px 12px;
  border-radius: 5px;
  border: 1px solid var(--stroke);
  background: var(--bg-input);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}

.modal-code:focus {
  border-color: var(--accent);
}

.modal-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-footer-left,
.modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-feedback {
  font-size: 12px;
  color: var(--accent);
}
