:root {
  --bg-core: #050a14;
  --bg-gradient: radial-gradient(circle at center, #0f1c2e 0%, #020408 100%);

  --accent: #00f2ff;
  --accent-glow: rgba(0, 242, 255, 0.6);
  --glass-panel: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-main: #ffffff;
  --text-muted: #8899a6;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Manrope', sans-serif;
  background: linear-gradient(125deg, #050a14, #0a1525, #020408, #0f1c2e);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes gradientBG {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

/* --- BACKGROUND --- */
#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 0%, #000 130%);
}

/* --- LAYOUT --- */
.app {
  position: relative;
  z-index: 10;
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 24px calc(24px + env(safe-area-inset-bottom));
}

/* On desktop, add some spacing and shadow */
@media (min-width: 600px) {
  .app {
    height: auto;
    min-height: 90vh;
    margin-top: 5vh;
    margin-bottom: 5vh;
    border-radius: 32px;
    background: rgba(5, 10, 20, 0.4);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
  }
}

/* HEADER */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  height: 60px;
  /* Consistent header height */
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0, 242, 255, 0.05);
  border: 1px solid rgba(0, 242, 255, 0.15);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.05);
  text-shadow: 0 0 10px var(--accent-glow);
}

.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  animation: neonPulse 3s infinite alternate;
}

.brand-text span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

@keyframes neonPulse {
  from {
    text-shadow: 0 0 5px rgba(0, 242, 255, 0.1);
    color: #fff;
  }

  to {
    text-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
    color: #e0f7fa;
  }
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.3s var(--ease);
}

.icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.neon-hover:hover {
  color: var(--accent);
  background: rgba(0, 242, 255, 0.1);
  box-shadow: 0 0 15px var(--accent-glow);
  text-shadow: 0 0 8px var(--accent);
}

.icon-svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* VISUALIZER & PLAY */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 20px;
  /* Consistent spacing between visualizer and text */
}

/* Responsive adjustment for very small screens */
@media (max-height: 700px) {
  .stage {
    gap: 10px;
  }

  .portal-container {
    transform: scale(0.85);
  }
}

.portal-container {
  position: relative;
  width: 280px;
  height: 280px;
  display: grid;
  place-items: center;
}

#visCanvas {
  position: absolute;
  inset: -40px;
  width: 360px;
  height: 360px;
  pointer-events: none;
}

.ring-guide {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.play-fab {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(20, 30, 40, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  position: relative;
}

.play-fab:hover {
  border-color: var(--accent);
  box-shadow: 0 0 30px var(--accent-glow);
  transform: scale(1.05);
}

.play-fab:active {
  transform: scale(0.95);
}

.play-fab svg {
  width: 32px;
  height: 32px;
  fill: #fff;
  transition: 0.3s;
  margin-left: 4px;
}

.play-fab.playing svg {
  margin-left: 0;
  fill: var(--accent);
}

.play-fab.playing {
  border-color: var(--accent);
  box-shadow: 0 0 40px rgba(0, 242, 255, 0.2);
}

.loader {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  display: none;
}

/* TRACK INFO */
.info-area {
  text-align: center;
  width: 100%;
  z-index: 2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: 0.3s;
}

.status-pill.active {
  background: rgba(0, 242, 255, 0.08);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.15);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.track-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  padding: 0 10px;
  /* Prevent text touching edges */
}

.track-artist {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 400;
}

/* DOCK */
.dock {
  flex-shrink: 0;
  background: rgba(10, 15, 25, 0.7);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 12px 24px;
  display: grid;
  grid-template-columns: 44px 44px 1fr 44px;
  gap: 16px;
  align-items: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  margin-top: auto;
  /* Push to bottom if space permits */
}

/* Dock responsive */
@media (max-width: 380px) {
  .dock {
    padding: 12px 16px;
    gap: 10px;
  }
}

.vol-area {
  position: relative;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
}

.vol-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.vol-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--v, 100%);
  background: #fff;
  border-radius: 2px;
  transition: width 0.1s;
}

.vol-area:hover .vol-fill {
  background: var(--accent);
  box-shadow: 0 0 15px var(--accent);
}

input[type=range] {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

/* DRAWER (Right Menu) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: #080e1a;
  border-left: 1px solid var(--glass-border);
  padding: 32px;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s var(--ease);
  box-shadow: -20px 0 50px #000;
  overflow-y: auto;
}

.drawer-overlay.open .drawer {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.drawer-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.menu-section {
  margin-bottom: 20px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #555;
  font-weight: 700;
  margin: 0;
  pointer-events: none;
}

.section-toggle {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  transition: 0.3s;
  color: #555;
  transform: rotate(0deg);
}

.menu-section.open .section-toggle {
  transform: rotate(180deg);
  color: var(--accent);
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
}

.menu-section.open .section-content {
  max-height: 500px;
  transition: max-height 0.5s ease-in-out;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  color: #aaa;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: 0.2s;
  cursor: pointer;
}

.menu-item:hover {
  color: var(--accent);
  padding-left: 8px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
}

/* Use filters to make original icons white/accent */
.menu-item img {
  width: 32px;
  height: 32px;
  filter: brightness(0) invert(0.7);
  transition: 0.2s;
}

.menu-item:hover img {
  filter: brightness(0) invert(1) drop-shadow(0 0 5px var(--accent));
}

/* HISTORY LIST */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 15px;
}

.history-item {
  font-size: 13px;
  color: #8899a6;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid transparent;
  transition: 0.2s;
}

.history-item.current {
  border-left-color: var(--accent);
  background: rgba(0, 242, 255, 0.05);
  color: #fff;
}

.history-time {
  font-size: 10px;
  color: #555;
  margin-bottom: 4px;
  display: block;
}

/* MODALS (Shared Styles) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #0c121e;
  border: 1px solid var(--glass-border);
  width: 90%;
  max-width: 340px;
  border-radius: 24px;
  padding: 24px;
  transform: scale(0.9);
  transition: 0.3s var(--ease);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.timer-val {
  color: var(--accent);
  font-weight: 700;
}

/* --- EQ UPDATED UI (Vertical Bars) --- */
.eq-container {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  height: 160px;
  padding: 0 10px;
}

.eq-band {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  justify-content: flex-end;
}

.eq-val-disp {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}

.eq-label {
  font-size: 10px;
  color: #666;
  margin-top: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Vertical Slider Wrap */
.eq-slider-vertical {
  width: 40px;
  height: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  cursor: ns-resize;
}

.eq-track-bg {
  width: 4px;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

/* Fill from bottom. 50% is 0dB */
.eq-fill-bar {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 50%;
  /* Default 0dB */
  background: #fff;
  border-radius: 2px;
  transition: height 0.1s;
}

.eq-slider-vertical:hover .eq-fill-bar {
  background: var(--accent);
  box-shadow: 0 0 15px var(--accent);
}

/* The input needs to be rotated to act vertically but use standard logic */
.eq-input-hidden {
  position: absolute;
  width: 120px;
  /* Length of slider */
  height: 40px;
  /* Hit area width */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

/* Timer Grid */
.time-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.t-chip {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: #888;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
}

.t-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.t-chip.active {
  background: var(--accent);
  color: #000;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
}

/* Common Modal Elements */
.custom-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.c-input {
  flex: 1;
  background: #182233;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0 14px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
}

.c-btn {
  background: #1f2d40;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 18px;
  align-items: center;
  gap: 15px;
}

/* Custom Checkbox */
.chk-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #888;
  cursor: pointer;
  margin-right: auto;
}

.chk-box {
  width: 20px;
  height: 20px;
  border: 2px solid #444;
  border-radius: 6px;
  display: grid;
  place-items: center;
  transition: 0.2s;
}

input:checked+.chk-box {
  background: var(--accent);
  border-color: var(--accent);
}

input:checked+.chk-box::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 2px solid #000;
  border-bottom: 2px solid #000;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* TOAST */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -20px);
  background: rgba(20, 20, 20, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: 0.3s var(--ease);
  pointer-events: none;
  z-index: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}