/* ==========================================================================
   AETHERIA - Modern Dark Futuristic Design System & Stylesheet
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-dark: #07090e;
  --bg-panel: rgba(14, 18, 28, 0.65);
  --bg-card: rgba(22, 28, 44, 0.5);
  --border-panel: rgba(255, 255, 255, 0.12);
  --border-highlight: rgba(99, 102, 241, 0.4);
  
  --primary-accent: #6366f1; /* Indigo Neon */
  --primary-glow: rgba(99, 102, 241, 0.5);
  --secondary-accent: #ec4899; /* Pink Neon */
  --secondary-glow: rgba(236, 72, 153, 0.5);
  --teal-accent: #14b8a6; /* Teal Cyber */
  --teal-glow: rgba(20, 184, 166, 0.5);
  --purple-accent: #a855f7; /* Purple Glow */
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* Fonts */
  --font-display: 'Orbitron', -apple-system, sans-serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing & Layout */
  --header-height: 64px;
  --dock-height: 220px;
  --border-radius: 16px;
  --border-radius-sm: 10px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  --glass-backdrop: blur(20px) saturate(180%);
  --box-shadow-panel: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* Reset & Global Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Background Kinetic Canvas */
#kinetic-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: crosshair;
}

/* Common Utility & Glassmorphism Panels */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--border-panel);
  box-shadow: var(--box-shadow-panel);
  border-radius: var(--border-radius);
}

.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Start Overlay Shield */
.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at center, rgba(14, 18, 30, 0.85) 0%, rgba(5, 6, 10, 0.95) 100%);
  backdrop-filter: blur(25px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.8s ease-out;
}

.start-card {
  max-width: 520px;
  width: 100%;
  padding: 40px;
  text-align: center;
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.start-logo {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: white;
  box-shadow: 0 0 40px var(--primary-glow);
}

.logo-pulse {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--primary-accent);
  animation: ripple 2s infinite ease-out;
}

.start-card h1 {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 4px;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff, #a5b4fc, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.start-card .subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--teal-accent);
  text-transform: uppercase;
}

.start-card .description {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.start-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
}

/* Primary Glow Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--primary-accent), #4f46e5);
  color: white;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 14px 28px;
  border-radius: 30px;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 30px var(--primary-glow), 0 0 15px rgba(255, 255, 255, 0.4);
}

.btn-primary:active {
  transform: translateY(1px);
}

/* Main Workspace UI */
.app-container {
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  transition: opacity 0.5s ease;
  pointer-events: none; /* Let background canvas get clicks outside panels */
}

/* Make UI panels interactive */
.top-header, .panel, .center-hud, .bottom-dock, .modal-card {
  pointer-events: auto;
}

/* Header */
.top-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

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

.brand-icon {
  font-size: 22px;
  color: var(--primary-accent);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 2px;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid var(--primary-accent);
  color: #a5b4fc;
  border-radius: 12px;
}

/* Presets Bar */
.preset-selector {
  display: flex;
  align-items: center;
  gap: 12px;
}

.selector-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.preset-buttons {
  display: flex;
  gap: 8px;
}

.preset-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.preset-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}

.preset-btn.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary-accent);
  color: white;
  box-shadow: 0 0 12px var(--primary-glow);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.master-volume-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-panel);
}

.master-volume-group i {
  color: var(--teal-accent);
  font-size: 14px;
}

.master-volume-group input[type="range"] {
  width: 70px;
}

#master-vol-readout {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 32px;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
}

.record-btn {
  width: auto;
  padding: 0 14px;
  gap: 8px;
  font-weight: 600;
  font-size: 12px;
  color: #ef4444;
}

.record-btn.recording {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  animation: pulse-red 1.5s infinite;
}

/* Main Workspace Grid Layout */
.workspace-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 310px 1fr 310px;
  gap: 16px;
  min-height: 0; /* Prevents overflow issues */
}

/* Side Panels */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px 12px 20px;
  border-bottom: 1px solid var(--border-panel);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header h2 i {
  color: var(--primary-accent);
}

.panel-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

.panel-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Custom Scrollbar */
.panel-scroll-content::-webkit-scrollbar {
  width: 5px;
}
.panel-scroll-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Sound Cards */
.sound-card {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--border-radius-sm);
  padding: 14px;
  transition: var(--transition-fast);
}

.sound-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

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

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.card-icon {
  font-size: 14px;
}
.color-purple { color: var(--purple-accent); }
.color-blue { color: #38bdf8; }
.color-teal { color: var(--teal-accent); }
.color-pink { color: var(--secondary-accent); }

/* Switch Toggle */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.3s;
  border-radius: 20px;
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: var(--primary-accent);
  box-shadow: 0 0 10px var(--primary-glow);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(18px);
}

/* Sliders & Inputs */
.card-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-row label {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
  transition: transform 0.15s ease;
}

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

/* Preset Chips */
.preset-chip-group {
  display: flex;
  gap: 4px;
}

.chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-panel);
  color: var(--text-muted);
  padding: 5px 2px;
  font-size: 10px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
}

.chip.active {
  background: rgba(20, 184, 166, 0.25);
  border-color: var(--teal-accent);
  color: white;
}

.custom-select {
  background: var(--bg-dark);
  border: 1px solid var(--border-panel);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
}

/* Control Blocks (Right Panel Synth) */
.control-block {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--border-radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block-title {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.wave-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.wave-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-panel);
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: var(--transition-fast);
}

.wave-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.wave-btn.active {
  background: rgba(236, 72, 153, 0.25);
  border-color: var(--secondary-accent);
  color: white;
  box-shadow: 0 0 10px var(--secondary-glow);
}

.adsr-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.adsr-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.adsr-item input[type="range"] {
  writing-mode: bt-lr; /* Vertical slider */
  -webkit-appearance: slider-vertical;
  height: 70px;
  width: 12px;
}

.adsr-item span {
  font-size: 10px;
  color: var(--text-dim);
}

.octave-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.octave-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sec {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-panel);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

#octave-display {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-main);
}

/* Center Visualizer HUD */
.center-hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  pointer-events: none;
}

.viz-selector-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: 30px;
}

.hud-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.hud-btn-group {
  display: flex;
  gap: 6px;
}

.hud-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.hud-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.hud-btn.active {
  background: rgba(20, 184, 166, 0.25);
  border-color: var(--teal-accent);
  color: white;
  box-shadow: 0 0 12px var(--teal-glow);
}

.interactive-hint-toast {
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(14, 18, 28, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: float 3s infinite ease-in-out;
}

.interactive-hint-toast i {
  color: var(--primary-accent);
}

/* Bottom Dock: Sequencer & Piano Keyboard */
.bottom-dock {
  height: var(--dock-height);
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  gap: 12px;
}

.dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dock-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dock-title i {
  color: var(--secondary-accent);
}

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

.btn-accent {
  background: linear-gradient(135deg, var(--secondary-accent), #db2777);
  border: none;
  color: white;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--secondary-glow);
  transition: var(--transition-fast);
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px var(--secondary-glow);
}

.btn-accent.playing {
  background: linear-gradient(135deg, var(--teal-accent), #0d9488);
  box-shadow: 0 2px 10px var(--teal-glow);
}

.bpm-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.bpm-control input {
  width: 55px;
  background: var(--bg-dark);
  border: 1px solid var(--border-panel);
  color: white;
  font-family: var(--font-mono);
  padding: 4px 6px;
  border-radius: 6px;
  text-align: center;
}

.btn-sec-small {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-panel);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.btn-sec-small:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

/* Sequencer Grid */
.sequencer-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 6px;
  height: 48px;
}

.seq-step {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-panel);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
}

.seq-step:nth-child(4n+1) {
  border-left: 2px solid rgba(255, 255, 255, 0.3);
}

.seq-step.active {
  background: rgba(236, 72, 153, 0.4);
  border-color: var(--secondary-accent);
  box-shadow: 0 0 10px var(--secondary-glow);
  color: white;
}

.seq-step.current {
  outline: 2px solid white;
}

/* Piano Keyboard */
.keyboard-container {
  flex: 1;
  display: flex;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-panel);
  background: rgba(10, 10, 15, 0.8);
}

.key-white {
  flex: 1;
  background: linear-gradient(to bottom, #e2e8f0 0%, #cbd5e1 100%);
  border: 1px solid #94a3b8;
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #334155;
  font-weight: bold;
  transition: background 0.1s;
}

.key-white:hover {
  background: #f8fafc;
}

.key-white.pressed {
  background: linear-gradient(to bottom, #a5b4fc 0%, #818cf8 100%);
  color: white;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.key-black {
  position: absolute;
  width: 4.5%;
  height: 60%;
  background: linear-gradient(to bottom, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
  border-radius: 0 0 4px 4px;
  cursor: pointer;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #94a3b8;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  transition: background 0.1s;
}

.key-black:hover {
  background: #334155;
}

.key-black.pressed {
  background: linear-gradient(to bottom, #ec4899 0%, #be185d 100%);
  color: white;
  box-shadow: 0 0 10px var(--secondary-glow);
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(15px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  width: 440px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.audio-player-wrapper audio {
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Keyframe Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes ripple {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.9); }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .app-container {
    overflow-y: auto;
  }
}
