/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  overflow: hidden;
  background: #000;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #fff;
  height: 100%;
  width: 100%;
  user-select: none;
}

/* Canvas - fullscreen */
#visualizer-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  display: block;
}

/* Audio status overlay - centered, for permission/error messages */
#audio-status {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,0.7);
  text-align: center;
  font-size: 16px;
  font-weight: 300;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.5s ease;
  max-width: 400px;
  line-height: 1.6;
}
#audio-status.hidden { opacity: 0; }
#audio-status .status-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}
#audio-status .status-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  margin-top: 8px;
}

/* Settings button zone - invisible until hover */
#settings-zone {
  position: fixed;
  bottom: 0; right: 0;
  width: 80px; height: 80px;
  z-index: 100;
}

#settings-btn {
  position: absolute;
  bottom: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.6);
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#settings-zone:hover #settings-btn,
body.sidebar-open #settings-btn {
  opacity: 1;
}

#settings-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
  transform: scale(1.1) rotate(30deg);
  color: rgba(255,255,255,0.9);
}

body.sidebar-open #settings-btn {
  background: rgba(255,255,255,0.1);
}

/* Sidebar - glass morphism, slides from right */
.sidebar {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 320px;
  max-width: 90vw;
  background: rgba(8, 8, 14, 0.92);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border-left: 1px solid rgba(255,255,255,0.06);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 24px;
}
.sidebar.open { transform: translateX(0); }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Sidebar content */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-title {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
}

.sidebar-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  line-height: 1;
}
.sidebar-close:hover { color: rgba(255,255,255,0.8); }

/* Control groups */
.control-group {
  margin-bottom: 20px;
}

.control-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-bottom: 8px;
}

/* Select dropdowns */
.control-select {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.4)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.control-select:hover {
  border-color: rgba(255,255,255,0.15);
  background-color: rgba(255,255,255,0.06);
}
.control-select:focus {
  border-color: rgba(255,255,255,0.2);
}
.control-select option {
  background: #1a1a2e;
  color: #fff;
}

/* Range sliders */
.control-range {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  outline: none;
  margin: 8px 0;
}
.control-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
  transition: transform 0.15s, background 0.15s;
}
.control-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #fff;
}
.control-range::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
}
.range-value {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  text-align: right;
  margin-top: 2px;
}

/* Toggle switches */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.toggle-label {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}
.toggle-switch {
  position: relative;
  width: 40px; height: 22px;
  cursor: pointer;
}
.toggle-switch input {
  opacity: 0;
  width: 0; height: 0;
}
.toggle-track {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.08);
  border-radius: 11px;
  transition: background 0.25s;
}
.toggle-switch input:checked + .toggle-track {
  background: rgba(0, 255, 242, 0.3);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: rgba(255,255,255,0.6);
  border-radius: 50%;
  transition: transform 0.25s, background 0.25s;
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: #00fff2;
}

/* Color scheme swatches */
.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
}
.color-swatch:hover {
  transform: scale(1.1);
  border-color: rgba(255,255,255,0.2);
}
.color-swatch.active {
  border-color: rgba(255,255,255,0.6);
}
.color-swatch .swatch-color {
  flex: 1 1 50%;
  min-height: 50%;
}

/* Visualizer grid */
.viz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.viz-option {
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.viz-option:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
}
.viz-option.active {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
}

/* Section dividers */
.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 20px 0;
}

/* FPS counter */
#fps-counter {
  position: fixed;
  top: 12px; left: 12px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: rgba(255,255,255,0.3);
  z-index: 10;
  pointer-events: none;
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive */
@media (max-width: 400px) {
  .sidebar { width: 100vw; max-width: 100vw; }
}
