@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg-primary: #080a0f;
  --bg-secondary: #0f121b;
  --bg-tertiary: #171b26;
  --panel-bg: rgba(16, 20, 31, 0.85);
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent-cyan: #00e5ff;
  --accent-green: #00e676;
  --accent-magenta: #ff007f;
  --accent-gold: #ffb300;
  --text-main: #f0f4f8;
  --text-muted: #8c9ba8;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-glow: 0 0 20px rgba(0, 229, 255, 0.25);
  --shadow-elevated: 0 10px 30px rgba(0, 0, 0, 0.5);
  --transition-fast: 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Top Studio Bar
   ========================================================================== */
.studio-header {
  height: 56px;
  min-height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 20;
  backdrop-filter: blur(12px);
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  text-decoration: none;
}

.brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}

.brand-icon svg {
  fill: #0a0c10;
}

.brand-title span {
  color: var(--accent-cyan);
}

.song-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulseAnimation 2s infinite ease-in-out;
}

@keyframes pulseAnimation {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   Buttons & Form Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: var(--bg-tertiary);
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #00b0ff, #00e5ff);
  color: #06090e;
  border: none;
  box-shadow: 0 2px 10px rgba(0, 229, 255, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #18b7ff, #38efff);
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.45);
}

.btn-accent {
  background: linear-gradient(135deg, #ff007f, #ff4081);
  color: #fff;
  border: none;
}

.btn-accent:hover {
  background: linear-gradient(135deg, #ff1a8c, #ff5c93);
  box-shadow: 0 4px 16px rgba(255, 0, 127, 0.4);
}

.select-control {
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: var(--bg-tertiary);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.select-control:focus {
  border-color: var(--accent-cyan);
}

.select-control optgroup {
  background: #171b26;
  color: var(--accent-cyan);
  font-weight: 700;
}

.select-control option {
  background: #10131d;
  color: #fff;
  font-weight: 500;
}

/* ==========================================================================
   Waterfall Canvas Stage
   ========================================================================== */
.canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #07080b;
}

#waterfallCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Floating overlay hints */
.canvas-hint {
  position: absolute;
  top: 14px;
  right: 18px;
  background: rgba(16, 20, 31, 0.7);
  border: 1px solid var(--panel-border);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

/* ==========================================================================
   Bottom Floating Transport Dock
   ========================================================================== */
.transport-dock {
  height: 56px;
  min-height: 56px;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  z-index: 20;
  backdrop-filter: blur(16px);
}

.desktop-selectors {
  display: flex;
  align-items: center;
  gap: 10px;
}

.transport-left, .transport-center, .transport-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.transport-center {
  flex: 1;
  max-width: 620px;
  padding: 0 20px;
}

.play-pause-btn {
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), #00b0ff);
  color: #06090e;
  border: none;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.play-pause-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.55);
}

.play-pause-btn.playing {
  background: linear-gradient(135deg, #ff007f, #ff4081);
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 0, 127, 0.4);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.timeline-container {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.time-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 36px;
}

.range-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  cursor: pointer;
  transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

.volume-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume-slider {
  width: 75px;
}

/* ==========================================================================
   Pattern Generator Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 520px;
  background: var(--bg-secondary);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

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

.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: var(--bg-tertiary);
  color: #fff;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.quick-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tag-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag-btn:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.field-hint {
  font-size: 0.76rem;
  color: var(--accent-cyan);
  margin-top: 4px;
  opacity: 0.85;
}

/* ==========================================================================
   Responsive & Tablet Adaptations
   ========================================================================== */
@media (max-width: 1150px) {
  .desktop-selectors {
    display: none !important;
  }
}

@media (max-width: 900px) {
  .studio-header {
    padding: 0 10px;
    height: 48px;
    min-height: 48px;
  }
  .brand-title {
    display: none;
  }
  .song-status-pill {
    display: none;
  }
  .header-controls .hide-mobile {
    display: none !important;
  }
  .transport-dock {
    height: 52px;
    min-height: 52px;
    padding: 0 10px;
    gap: 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }
  .transport-left, .transport-center, .transport-right {
    gap: 8px;
  }
  .transport-center {
    padding: 0 8px;
  }
  .play-pause-btn {
    padding: 6px 12px;
    font-size: 0.88rem;
  }
  .play-pause-btn span {
    display: none;
  }
  .timeline-container {
    gap: 6px;
  }
  .time-badge {
    font-size: 0.72rem;
    min-width: 28px;
  }
  .volume-slider {
    width: 55px;
  }
}

@media (max-width: 600px) {
  .volume-wrapper {
    display: none !important;
  }
  .header-controls .btn span {
    display: none;
  }
  .header-controls .btn {
    padding: 6px 10px;
  }
  #songSelect {
    max-width: 140px;
    font-size: 0.78rem;
    text-overflow: ellipsis;
  }
}

@media (max-height: 650px) {
  .studio-header {
    height: 42px;
    min-height: 42px;
    padding: 0 8px;
  }
  .brand-logo {
    font-size: 1.1rem;
  }
  .brand-icon {
    width: 24px;
    height: 24px;
  }
  .transport-dock {
    height: 46px;
    min-height: 46px;
    padding: 0 8px;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  }
  .btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }
  .select-control {
    padding: 4px 8px;
    font-size: 0.8rem;
  }
}
