:root {
  --bg-deep: #0f0f23;
  --bg-panel: #1a1a2e;
  --bg-darker: #0a0a1a;
  --bg-filter: #0a1a0a;
  --cyan: #00fff7;
  --green: #39ff14;
  --magenta: #ff00ff;
  --red: #ff3333;
  --orange: #ff8c00;
  --blue: #4488ff;
  --white-dim: #aabbcc;
  --text: #e0e0e0;
  --border: #2a2a4e;
  --border-filter: #1a3a1a;
}

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

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

.pixel-font {
  font-family: 'Press Start 2P', monospace;
}

.scanlines {
  position: relative;
}
.scanlines::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
  z-index: 1;
}

.panel {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 4px;
  position: relative;
}
.panel::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px; bottom: -1px;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(0,255,247,0.1), transparent, rgba(255,0,255,0.05));
  z-index: -1;
}

.panel-filter {
  background: var(--bg-filter);
  border: 2px solid var(--border-filter);
  border-radius: 4px;
  position: relative;
}
.panel-filter::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px; bottom: -1px;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(57,255,20,0.08), transparent, rgba(0,255,247,0.04));
  z-index: -1;
}

.pcb-traces {
  background-image:
    linear-gradient(90deg, rgba(57,255,20,0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(57,255,20,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* FREQUENCY ARRAY PANEL */
.freq-array-panel {
  background: #080f10;
  border: 2px solid #1a3a2a;
  border-radius: 4px;
  position: relative;
  background-image:
    linear-gradient(90deg, rgba(0,255,247,0.02) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0,255,247,0.02) 1px, transparent 1px);
  background-size: 16px 16px;
}

@keyframes rec-border-pulse {
  0%, 100% { border-color: #ff3333; box-shadow: 0 0 8px rgba(255,51,51,0.3); }
  50% { border-color: #ff333366; box-shadow: 0 0 2px rgba(255,51,51,0.1); }
}

.rec-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 8px 16px;
  border: 3px solid;
  border-color: #555 #222 #222 #555;
  background: #2a1a1a;
  color: #ff3333;
  cursor: pointer;
  transition: all 0.1s;
  text-transform: uppercase;
}
.rec-btn:hover { background: #3a1a1a; }
.rec-btn.active {
  background: #ff3333;
  color: #000;
  border-color: #ff6666 #990000 #990000 #ff6666;
  animation: blink 0.8s infinite;
}

.export-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 5px 10px;
  border: 1px solid #2a3a2a;
  background: #0a1a0a;
  color: #39ff14;
  cursor: pointer;
  transition: all 0.1s;
  border-radius: 2px;
}
.export-btn:hover {
  background: #1a2a1a;
  border-color: #39ff14;
  box-shadow: 0 0 6px rgba(57,255,20,0.2);
}

.freq-table th {
  font-family: 'Press Start 2P', monospace;
}

.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 8px 16px;
  border: 3px solid;
  border-color: #555 #222 #222 #555;
  background: #333;
  color: var(--text);
  cursor: pointer;
  transition: all 0.05s;
  text-transform: uppercase;
}
.pixel-btn:hover { background: #444; }
.pixel-btn:active { border-color: #222 #555 #555 #222; transform: translateY(1px); }
.pixel-btn.active { background: var(--cyan); color: #000; border-color: #00cccc #006666 #006666 #00cccc; }

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.1s;
  flex-shrink: 0;
}
.led.active {
  box-shadow: 0 0 6px currentColor, 0 0 12px currentColor;
}

.cartridge-slot {
  background: linear-gradient(180deg, #111 0%, #1a1a1a 10%, #0d0d0d 90%, #000 100%);
  border: 3px solid #333;
  border-top: 5px solid #444;
  border-bottom: 5px solid #222;
  position: relative;
}
.cartridge-slot::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 4px;
  background: linear-gradient(90deg, transparent, #555, transparent);
}

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

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.bounce-bars {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  height: 12px;
}
.bounce-bars span {
  display: block;
  width: 3px;
  background: var(--green);
  animation: bounce-bar 0.6s ease-in-out infinite;
}
.bounce-bars span:nth-child(2) { animation-delay: 0.1s; }
.bounce-bars span:nth-child(3) { animation-delay: 0.2s; }
.bounce-bars span:nth-child(4) { animation-delay: 0.3s; }

@keyframes bounce-bar {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #333;
  border-radius: 0;
  outline: none;
  border: 1px solid #555;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 18px;
  background: #666;
  border: 2px solid;
  border-color: #999 #333 #333 #999;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 18px;
  background: #666;
  border: 2px solid;
  border-color: #999 #333 #333 #999;
  cursor: pointer;
  border-radius: 0;
}

.viz-canvas {
  background: #000;
  border: 2px solid #333;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-darker); }
::-webkit-scrollbar-thumb { background: #333; border: 1px solid #555; }

.track-list-item {
  padding: 6px 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.1s;
  font-size: 11px;
}
.track-list-item:hover {
  background: rgba(0,255,247,0.05);
  border-color: rgba(0,255,247,0.2);
}
.track-list-item.active {
  background: rgba(0,255,247,0.1);
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0,255,247,0.1);
}

.filter-toggle {
  position: relative;
  width: 40px;
  height: 20px;
  background: #222;
  border: 2px solid #444;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-toggle.active { border-color: var(--green); }
.filter-toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #555;
  border: 1px solid #777;
  transition: all 0.15s;
}
.filter-toggle.active .knob {
  left: 22px;
  background: var(--green);
  border-color: #5f5;
  box-shadow: 0 0 6px var(--green);
}

.bypass-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 8px 14px;
  border: 3px solid;
  border-color: #555 #222 #222 #555;
  background: #2a2a2a;
  color: #888;
  cursor: pointer;
  transition: all 0.1s;
  text-transform: uppercase;
}
.bypass-btn:hover { background: #333; }
.bypass-btn.active {
  background: #3a1111;
  color: var(--red);
  border-color: #ff3333 #990000 #990000 #ff3333;
  box-shadow: 0 0 12px rgba(255,51,51,0.3);
}

.filter-preset-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 4px 8px;
  border: 1px solid #333;
  background: #1a1a1a;
  color: #888;
  cursor: pointer;
  transition: all 0.1s;
}
.filter-preset-btn:hover { background: #252525; color: #aaa; }
.filter-preset-btn.active {
  background: #1a2a1a;
  color: var(--green);
  border-color: var(--green);
}

.freq-response-mini {
  width: 80px;
  height: 32px;
  background: #000;
  border: 1px solid #333;
}

.channel-card {
  transition: transform 0.1s, box-shadow 0.15s;
}
.channel-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.channel-card canvas {
  width: 100% !important;
  display: block;
}

@media (max-width: 640px) {
  .freq-array-panel table { font-size: 8px !important; }
  .freq-array-panel td, .freq-array-panel th { padding: 2px 4px !important; }
}