/* ==========================================================================
   FOURIER VISUALIZATION & SYNTHESIZER - DESIGN SYSTEM & STYLES
   ========================================================================== */

:root {
  --bg-primary: #07090e;
  --bg-surface: rgba(16, 22, 36, 0.72);
  --bg-surface-hover: rgba(25, 34, 54, 0.85);
  --bg-card: rgba(13, 18, 30, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 240, 255, 0.25);

  --text-primary: #f0f4fc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #00f0ff;
  --accent-cyan-dim: rgba(0, 240, 255, 0.15);
  --accent-magenta: #ff2a85;
  --accent-magenta-dim: rgba(255, 42, 133, 0.15);
  --accent-violet: #8a2be2;
  --accent-amber: #ffb703;
  --accent-green: #10b981;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 20px rgba(0, 240, 255, 0.2);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  display: flex;
  flex-direction: column;
}

/* Background Subtle Gradient & Grid */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 18% 25%, rgba(0, 240, 255, 0.04) 0%, transparent 45%),
    radial-gradient(circle at 82% 75%, rgba(255, 42, 133, 0.04) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(138, 43, 226, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* p5 Canvas Container */
#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

canvas {
  display: block;
}

/* UI Overlay Layer */
.ui-overlay {
  position: relative;
  z-index: 10;
  pointer-events: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
}

.interactive {
  pointer-events: auto;
}

/* Glassmorphism Common */
.glass {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.glass:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   HEADER & TOP CONTROLS
   ========================================================================== */

header.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  max-width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #c7d2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

/* Mode Switch Tabs */
.mode-switch {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--text-primary);
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(138, 43, 226, 0.2));
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

/* Top Right Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon.active {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
}

.btn-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pill:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-surface-hover);
}

.btn-pill.primary {
  background: linear-gradient(135deg, #00f0ff, #0284c7);
  color: #050b14;
  border: none;
  font-weight: 600;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.btn-pill.primary:hover {
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.5);
  transform: translateY(-1px);
}

/* ==========================================================================
   CENTER HUD / FLOATING WORKSPACE
   ========================================================================== */

.hud-layout {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex: 1;
  margin-top: 14px;
  position: relative;
  pointer-events: none;
}

/* Wave Preset Bar */
.preset-bar-container {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-full);
}

.preset-chip {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
}

.preset-chip:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.preset-chip.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Right Side HUD: Formula & Spectrum */
.side-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-left: auto;
}

.hud-card {
  padding: 16px;
  border-radius: var(--radius-md);
}

.hud-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hud-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-title svg {
  width: 14px;
  height: 14px;
  color: var(--accent-cyan);
}

/* Math Formula Card */
.formula-display {
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: #e2e8f0;
  overflow-x: auto;
}

.formula-highlight {
  color: var(--accent-cyan);
  font-weight: 600;
}

.formula-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
}

.gibbs-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-amber);
  font-weight: 500;
}

/* Harmonic Spectrum Bars */
.spectrum-container {
  display: flex;
  align-items: flex-end;
  height: 70px;
  gap: 3px;
  padding: 8px 4px 4px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.spectrum-bar-wrap {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
}

.spectrum-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(to top, var(--accent-violet), var(--accent-cyan));
  transition: height 0.15s ease;
}

.spectrum-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ==========================================================================
   BOTTOM DOCK & CONTROLS
   ========================================================================== */

.bottom-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  max-width: 100%;
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.slider-unit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 170px;
}

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.slider-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-cyan);
  font-size: 12px;
  background: rgba(0, 240, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.2);
}

/* Custom Styled Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.8), 0 1px 3px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
  border: 2px solid var(--accent-cyan);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-cyan);
}

/* Step Buttons */
.step-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-tiny {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-tiny:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: var(--bg-surface-hover);
}

/* Quick Toggles in Bottom Dock */
.toggle-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.toggle-chip:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.toggle-chip.active {
  color: var(--accent-cyan);
  background: var(--accent-cyan-dim);
  border-color: rgba(0, 240, 255, 0.3);
}

/* Transport Controls (Play, Pause, Step) */
.transport-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   DRAWING OVERLAY MODAL (FOR 2D DFT CUSTOM SKETCH)
   ========================================================================== */

.draw-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.85);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.draw-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.draw-modal-content {
  width: 90vw;
  max-width: 640px;
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.draw-pad-wrapper {
  position: relative;
  width: 100%;
  height: 380px;
  background: #020408;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(0, 240, 255, 0.35);
  overflow: hidden;
  cursor: crosshair;
}

#draw-canvas {
  width: 100%;
  height: 100%;
}

.draw-placeholder-tip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.draw-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Responsive Rules */
@media (max-width: 900px) {
  .side-panel {
    display: none; /* Hide side HUD on compact screens to maintain clean visual space */
  }
  .bottom-dock {
    flex-wrap: wrap;
    justify-content: center;
  }
  .preset-bar-container {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .hud-layout {
    flex-direction: column;
  }
}

