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

:root {
  --bg: #06060c;
  --bg-panel: rgba(8, 10, 20, 0.92);
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --text: #c0ccd8;
  --text-dim: #5a6a7a;
  --border: rgba(255,255,255,0.06);
  --glow: 0 0 20px rgba(0,255,136,0.3);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
  min-height: 36px;
}

#header .title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: var(--glow);
  color: var(--accent);
}

#info-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-dim);
}

#freq-display {
  min-width: 70px;
  text-align: right;
  color: var(--accent);
}

#amp-display {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vu-label { font-size: 9px; color: var(--text-dim); }

#vu-bar-container {
  width: 50px;
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px;
  overflow: hidden;
}

#vu-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.08s ease-out;
}

#fps-display {
  min-width: 50px;
  text-align: right;
}

/* Canvas area */
#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0a0a12;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#crt-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  z-index: 2;
}

#crt-overlay::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.4) 100%);
}

#crt-overlay.disabled {
  display: none;
}

/* Empty state */
#empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 3;
  pointer-events: none;
}

#empty-state.hidden { display: none; }

#empty-state .empty-line {
  width: 200px;
  height: 2px;
  background: var(--accent);
  margin: 0 auto 20px;
  box-shadow: 0 0 12px var(--accent), 0 0 30px rgba(0,255,136,0.2);
  animation: pulse-line 2s ease-in-out infinite;
}

@keyframes pulse-line {
  0%, 100% { opacity: 0.5; box-shadow: 0 0 8px var(--accent); }
  50% { opacity: 1; box-shadow: 0 0 20px var(--accent), 0 0 40px rgba(0,255,136,0.3); }
}

#empty-state p {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 6px;
}

#empty-state .hint {
  font-size: 10px;
  color: rgba(255,255,255,0.2);
}

/* Freeze indicator */
#freeze-indicator {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 0, 80, 0.15);
  border: 1px solid rgba(255, 0, 80, 0.4);
  padding: 4px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #ff3366;
  z-index: 5;
  letter-spacing: 2px;
}

#freeze-indicator.hidden { display: none; }

/* Progress bar */
#progress-container {
  height: 4px;
  background: rgba(255,255,255,0.04);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

#progress-container.hidden { display: none; }

#progress-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* Controls toggle */
#controls-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  z-index: 10;
}

#controls-toggle:hover {
  background: rgba(0,255,136,0.04);
}

.toggle-icon {
  font-size: 10px;
  color: var(--accent);
  transition: transform 0.3s ease;
}

.toggle-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

#controls-panel.collapsed + footer { display: none; }

/* Controls panel */
#controls-panel {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 300px;
  flex-shrink: 0;
}

#controls-panel.collapsed {
  max-height: 0;
}

.controls-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 16px;
  align-items: flex-start;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 140px;
}

.control-group label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.control-group label span {
  color: var(--accent);
  font-weight: 500;
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 4px;
}

.ctrl-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-btn:hover:not(:disabled) {
  background: rgba(0,255,136,0.08);
  border-color: rgba(0,255,136,0.2);
}

.ctrl-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ctrl-btn.active {
  background: rgba(0,255,136,0.12);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.ctrl-btn.small {
  padding: 4px 8px;
  font-size: 13px;
}

.transport-controls {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

/* Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0,255,136,0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Color swatches */
.color-presets {
  display: flex;
  gap: 5px;
  align-items: center;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.color-swatch:hover { transform: scale(1.15); }

.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.3);
}

#color-custom {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  background: transparent;
}

/* Toggles row */
.toggles {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  text-transform: none;
}

.toggles input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Actions */
.actions {
  flex-direction: row;
  gap: 6px;
  align-items: center;
}

/* Footer */
#footer {
  padding: 4px 16px;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#footer a {
  color: var(--accent-dim);
  text-decoration: none;
}

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

/* Drag-over state */
#canvas-container.drag-over::after {
  content: '🎵 Drop audio file here';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,255,136,0.06);
  border: 2px dashed var(--accent);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  z-index: 20;
  letter-spacing: 1px;
}

/* Mobile responsive */
@media (max-width: 700px) {
  .controls-inner {
    gap: 10px 12px;
  }
  .control-group {
    min-width: 120px;
  }
  #info-panel {
    gap: 8px;
  }
  #vu-bar-container {
    width: 30px;
  }
  #header .title {
    font-size: 13px;
  }
}

/* Keyboard shortcut hints */
.hidden { display: none !important; }