:root {
  --bg-primary: #0f1218;
  --bg-secondary: #161b24;
  --bg-panel: #1a2030;
  --bg-recessed: #0c0f14;
  --cyan: #00d4ff;
  --cyan-dim: #00a0cc;
  --cyan-glow: rgba(0, 212, 255, 0.3);
  --amber: #ff9f1c;
  --amber-dim: #cc7a00;
  --amber-glow: rgba(255, 159, 28, 0.3);
  --green: #00ff88;
  --red: #ff4444;
  --text-primary: #e0e6f0;
  --text-secondary: #8090a8;
  --text-dim: #4a5568;
  --border: #2a3444;
  --border-light: #3a4a5e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

.font-mono { font-family: 'JetBrains Mono', monospace !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-recessed); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* LCD Display */
.lcd-display {
  background: #0a1a0a;
  border: 2px solid #1a3a1a;
  border-radius: 4px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.6), 0 0 12px rgba(0,212,255,0.08);
  font-family: 'JetBrains Mono', monospace;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-glow);
}

/* Panel styling */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 2px 8px rgba(0,0,0,0.3);
}

.panel-recessed {
  background: var(--bg-recessed);
  border: 1px solid rgba(0,0,0,0.4);
  border-radius: 4px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

/* Knob */
.knob-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  cursor: ns-resize;
}

.knob-outer {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a3444, #1a2030);
  border: 2px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.knob-outer:hover {
  border-color: var(--cyan-dim);
}

.knob-indicator {
  width: 2px;
  height: 14px;
  background: var(--cyan);
  border-radius: 1px;
  position: absolute;
  top: 4px;
  transform-origin: bottom center;
  box-shadow: 0 0 4px var(--cyan-glow);
}

.knob-label {
  font-size: 9px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.knob-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--cyan);
  margin-top: 1px;
}

/* LED */
.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
}

.led-on {
  background: var(--green);
  box-shadow: 0 0 6px var(--green), 0 0 12px rgba(0,255,136,0.3);
}

.led-off {
  background: #1a2a1a;
}

.led-cyan {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan), 0 0 12px var(--cyan-glow);
}

.led-amber {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber), 0 0 12px var(--amber-glow);
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--bg-recessed);
  padding: 3px;
  border-radius: 4px;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'IBM Plex Sans', sans-serif;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
}

.tab-btn.active {
  color: var(--cyan);
  background: var(--bg-panel);
  border-color: var(--border);
  box-shadow: 0 0 8px var(--cyan-glow);
}

/* Operator strip */
.op-strip {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 90px;
  transition: border-color 0.2s;
}

.op-strip.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.op-strip.carrier { border-top: 3px solid var(--amber); }
.op-strip.modulator { border-top: 3px solid var(--cyan); }

/* Fader */
.fader-track {
  width: 6px;
  height: 100px;
  background: var(--bg-recessed);
  border-radius: 3px;
  position: relative;
  border: 1px solid rgba(0,0,0,0.3);
  cursor: pointer;
}

.fader-fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  border-radius: 0 0 3px 3px;
  transition: height 0.05s;
}

.fader-thumb {
  position: absolute;
  width: 20px;
  height: 8px;
  left: -7px;
  background: linear-gradient(180deg, #4a5a6a, #2a3444);
  border: 1px solid var(--border-light);
  border-radius: 2px;
  cursor: ns-resize;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Toggle button */
.toggle-btn {
  padding: 3px 8px;
  font-size: 9px;
  font-weight: 700;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.toggle-btn.on {
  background: var(--cyan);
  color: var(--bg-primary);
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

.toggle-btn.off {
  background: var(--bg-recessed);
  color: var(--text-dim);
}

/* Keyboard */
.keyboard-container {
  position: relative;
  display: flex;
  background: var(--bg-recessed);
  border-top: 2px solid var(--border);
  padding: 8px 12px;
}

.white-key {
  width: 36px;
  height: 120px;
  background: linear-gradient(180deg, #f0f0f0, #d8d8d8);
  border: 1px solid #999;
  border-radius: 0 0 4px 4px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background 0.05s;
}

.white-key:hover { background: linear-gradient(180deg, #fff, #e8e8e8); }
.white-key.pressed {
  background: linear-gradient(180deg, var(--cyan), #00a0cc) !important;
  box-shadow: 0 0 12px var(--cyan-glow);
}

.black-key {
  width: 24px;
  height: 76px;
  background: linear-gradient(180deg, #333, #111);
  border: 1px solid #000;
  border-radius: 0 0 3px 3px;
  cursor: pointer;
  position: absolute;
  z-index: 2;
  margin-left: -12px;
  transition: background 0.05s;
}

.black-key:hover { background: linear-gradient(180deg, #444, #222); }
.black-key.pressed {
  background: linear-gradient(180deg, var(--cyan-dim), #0088aa) !important;
  box-shadow: 0 0 8px var(--cyan-glow);
}

.key-label {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: #999;
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}

.black-key .key-label { color: #666; bottom: 2px; }

/* Algorithm display */
.algo-node {
  fill: var(--bg-panel);
  stroke-width: 2;
  cursor: pointer;
  transition: all 0.15s;
}

.algo-node.carrier { stroke: var(--amber); }
.algo-node.modulator { stroke: var(--cyan); }
.algo-node.selected { stroke-width: 3; filter: drop-shadow(0 0 6px var(--cyan-glow)); }

.algo-line {
  stroke: var(--text-dim);
  stroke-width: 2;
  fill: none;
}

/* Envelope canvas */
.envelope-canvas {
  background: var(--bg-recessed);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Oscilloscope */
.scope-display {
  background: #050a05;
  border: 2px solid #1a2a1a;
  border-radius: 6px;
  box-shadow: inset 0 0 20px rgba(0,20,0,0.5);
  overflow: hidden;
  position: relative;
}

.scope-display::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,20,0,0.1) 2px,
    rgba(0,20,0,0.1) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* Pitch/Mod wheels */
.wheel-track {
  width: 28px;
  height: 120px;
  background: var(--bg-recessed);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  cursor: ns-resize;
}

.wheel-thumb {
  width: 26px;
  height: 16px;
  background: linear-gradient(180deg, #4a5a6a 0%, #2a3444 50%, #4a5a6a 100%);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  position: absolute;
  left: 0;
  cursor: ns-resize;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 8px;
  font-weight: 700;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'JetBrains Mono', monospace;
}

.badge-carrier {
  background: rgba(255,159,28,0.15);
  color: var(--amber);
  border: 1px solid rgba(255,159,28,0.3);
}

.badge-modulator {
  background: rgba(0,212,255,0.15);
  color: var(--cyan);
  border: 1px solid rgba(0,212,255,0.3);
}

/* Animations */
@keyframes glow-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes flash-value {
  0% { color: #fff; text-shadow: 0 0 8px rgba(255,255,255,0.5); }
  100% { color: var(--cyan); text-shadow: none; }
}

.flash { animation: flash-value 0.3s ease-out; }

@keyframes boot-line {
  from { width: 0; }
  to { width: 100%; }
}

.boot-progress {
  height: 2px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
  animation: boot-line 2s ease-out forwards;
}

/* Waveform icons */
.wf-icon {
  width: 32px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  padding: 2px;
  transition: all 0.15s;
  background: var(--bg-recessed);
}

.wf-icon:hover { border-color: var(--text-secondary); }
.wf-icon.active { border-color: var(--cyan); box-shadow: 0 0 6px var(--cyan-glow); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.03);
}

/* Status bar */
.status-bar {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  display: flex;
  gap: 20px;
  align-items: center;
}

/* Mini envelope preview */
.mini-env {
  width: 70px;
  height: 30px;
  background: var(--bg-recessed);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}

.mini-env:hover { border-color: var(--cyan-dim); }

/* Tooltip */
.tooltip {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  font-family: 'IBM Plex Sans', sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}