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

:root {
  --bg-dark: #080808;
  --bg-panel: #0e0e0e;
  --bg-section: #141414;
  --border-color: #2a2a2a;
  --amber: #ffaa00;
  --amber-dim: #cc8800;
  --amber-glow: #ff880066;
  --amber-bright: #ffcc44;
  --green-phosphor: #33ff33;
  --text-dim: #666;
  --text-mid: #999;
  --wood-dark: #1a1208;
  --wood-mid: #2a1f10;
  --bakelite: #1c1410;
  --bakelite-edge: #3a2a1a;
}

body {
  background: var(--bg-dark);
  color: var(--amber);
  font-family: 'Share Tech Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

#app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 10px;
}

/* HEADER */
#header {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  gap: 15px;
}

#header h1 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.4em;
  color: var(--amber);
  text-shadow: 0 0 10px var(--amber-glow), 0 0 30px var(--amber-glow);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 0.7em;
  color: var(--amber-dim);
  letter-spacing: 1px;
}

#header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.led-indicator {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #440;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.3s;
}

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

.led-indicator.sync-on {
  background: var(--green-phosphor);
  box-shadow: 0 0 6px var(--green-phosphor), 0 0 12px #33ff3366;
}

.led-label { font-size: 0.6em; color: var(--text-dim); }

#nipkow-disk { flex-shrink: 0; }

/* MAIN LAYOUT */
#main-layout {
  display: flex;
  gap: 15px;
  padding: 15px 0;
  min-height: calc(100vh - 140px);
}

/* CONTROL PANEL */
#control-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  scrollbar-width: thin;
  scrollbar-color: var(--amber-dim) var(--bg-panel);
}

.panel-section {
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 12px;
}

.panel-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65em;
  font-weight: 700;
  color: var(--amber-dim);
  letter-spacing: 3px;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-color);
}

/* DROP ZONE */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: radial-gradient(ellipse at center, #1a1a0a 0%, var(--bg-dark) 100%);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--amber);
  background: radial-gradient(ellipse at center, #2a2a10 0%, var(--bg-dark) 100%);
  box-shadow: 0 0 20px var(--amber-glow);
}

.jack-icon {
  font-size: 2.5em;
  color: var(--amber-dim);
  margin-bottom: 5px;
}

.drop-zone p { font-size: 0.8em; color: var(--text-mid); margin: 3px 0; }
.drop-zone .small { font-size: 0.65em; color: var(--text-dim); }

.file-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75em;
  color: var(--amber);
  padding: 5px;
  margin-top: 5px;
}

.hidden { display: none !important; }

#waveform-preview {
  width: 100%;
  height: 40px;
  margin-top: 5px;
  border: 1px solid var(--border-color);
  border-radius: 2px;
}

/* CONTROLS */
.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.75em;
}

.control-row label {
  color: var(--text-mid);
  flex-shrink: 0;
}

.control-row label span {
  color: var(--amber);
  font-weight: bold;
}

select, input[type="range"] {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--amber);
  font-family: 'Share Tech Mono', monospace;
  font-size: 1em;
  padding: 3px 6px;
  border-radius: 3px;
  outline: none;
}

select { max-width: 150px; cursor: pointer; }

select:focus { border-color: var(--amber-dim); }

input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  border: none;
  background: var(--border-color);
  border-radius: 2px;
  width: 120px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
  box-shadow: 0 0 4px var(--amber-glow);
}

/* TOGGLE SWITCH */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.toggle-label-l, .toggle-label-r {
  font-size: 0.85em;
  color: var(--text-dim);
  transition: color 0.3s;
}

.toggle-label-l.active, .toggle-label-r.active { color: var(--amber); }

.toggle-track {
  width: 30px; height: 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  position: relative;
}

.toggle-knob {
  width: 12px; height: 12px;
  background: var(--amber);
  border-radius: 50%;
  position: absolute;
  top: 1px; left: 1px;
  transition: left 0.2s;
  box-shadow: 0 0 4px var(--amber-glow);
}

.toggle-switch[data-value="horizontal"] .toggle-knob,
.toggle-switch[data-value="4:3"] .toggle-knob { left: 15px; }

/* COLOR SELECTOR */
.color-selector {
  display: flex;
  gap: 6px;
}

.color-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}

.color-btn.active, .color-btn:hover {
  border-color: #fff;
  box-shadow: 0 0 8px currentColor;
  transform: scale(1.15);
}

/* TRANSPORT */
.transport-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.bakelite-btn {
  background: linear-gradient(180deg, #2a2018 0%, #1a1208 50%, #0e0a04 100%);
  border: 1px solid var(--bakelite-edge);
  color: var(--amber);
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85em;
  transition: all 0.15s;
  text-shadow: 0 0 6px var(--amber-glow);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,170,0,0.1);
}

.bakelite-btn:hover {
  background: linear-gradient(180deg, #3a2a20 0%, #2a1a10 50%, #1a0e06 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,170,0,0.15), 0 0 10px var(--amber-glow);
}

.bakelite-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), inset 0 1px 3px rgba(0,0,0,0.3);
}

.bakelite-btn.wide { width: 100%; margin-bottom: 5px; text-align: center; }

.seven-seg {
  font-family: 'VT323', monospace;
  font-size: 1.4em;
  color: var(--amber);
  text-shadow: 0 0 8px var(--amber-glow);
  text-align: center;
  background: var(--bg-dark);
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  margin-bottom: 8px;
}

/* ROTARY DIAL */
.rotary-container { display: flex; justify-content: center; }

.rotary-dial {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3a2a18, #1a1208);
  border: 2px solid var(--bakelite-edge);
  position: relative;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,170,0,0.05);
}

.rotary-indicator {
  position: absolute;
  width: 3px; height: 12px;
  background: var(--amber);
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 1px;
  box-shadow: 0 0 4px var(--amber-glow);
  transform-origin: bottom center;
}

/* TV DISPLAY */
#display-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

#tv-bezel {
  background: linear-gradient(135deg, #1a1208 0%, #2a1f10 20%, #1a1208 50%, #2a1f10 80%, #1a1208 100%);
  border: 3px solid #3a2a1a;
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,170,0,0.03);
  position: relative;
}

#tv-screen-container {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 55vh;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

#tv-screen-container.wide { aspect-ratio: 4 / 3; }

#tv-screen {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

#tv-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

#tv-vignette {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}

#scanline-overlay {
  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;
}

#bezel-label {
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.55em;
  letter-spacing: 4px;
  color: var(--amber-dim);
  margin-top: 12px;
  opacity: 0.5;
}

/* SIGNAL PANEL */
#signal-panel {
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.signal-section {
  flex: 1;
  min-width: 120px;
}

.signal-section h4 {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.55em;
  color: var(--amber-dim);
  letter-spacing: 2px;
  margin-bottom: 5px;
}

.signal-section canvas {
  width: 100%;
  height: 60px;
  border: 1px solid var(--border-color);
  border-radius: 2px;
  display: block;
}

.signal-meters {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 200px;
  align-items: flex-start;
}

.signal-section.small {
  flex: 0 0 50px;
  text-align: center;
}

.signal-section.small .led-indicator {
  width: 16px; height: 16px;
  margin: 10px auto;
}

.vu-meter {
  width: 100%;
  height: 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.vu-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #33aa33, #aaaa33, #aa3333);
  transition: width 0.05s;
}

/* INFO PANEL */
#info-toggle { cursor: pointer; }
.info-content p {
  font-size: 0.75em;
  color: var(--text-mid);
  margin-bottom: 8px;
  line-height: 1.5;
}
.info-content strong { color: var(--amber); }

/* FOOTER */
#footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 0.7em;
  color: var(--text-dim);
}

#footer span {
  text-shadow: 0 0 6px var(--amber-glow);
  color: var(--amber-dim);
  opacity: 0.6;
}

#footer a {
  color: var(--amber);
  text-decoration: none;
  text-shadow: 0 0 8px var(--amber-glow);
}

#footer a:hover { text-decoration: underline; }

/* RESPONSIVE */
@media (max-width: 900px) {
  #main-layout {
    flex-direction: column;
  }
  #control-panel {
    width: 100%;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .panel-section { flex: 1 1 280px; }
  #tv-screen-container { max-height: 50vh; }
}

@media (max-width: 500px) {
  #header h1 { font-size: 1em; }
  .subtitle { font-size: 0.6em; }
  #tv-bezel { padding: 12px; }
  .transport-controls { justify-content: center; }
}