/* ==================== CSS Variables ==================== */
:root {
  --bg-deep: #050510;
  --bg-dark: #0a0a1a;
  --bg-card: rgba(15, 15, 35, 0.6);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --text-primary: #f0f0ff;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --accent: #7c6ff7;
  --accent-glow: rgba(124, 111, 247, 0.4);
  --accent-secondary: #ff6b9d;
  --accent-tertiary: #4ecdc4;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --panel-width: 280px;
}

/* ==================== Reset & Base ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ==================== Canvases ==================== */
canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#bgCanvas {
  z-index: 0;
  opacity: 0.6;
}

#vizCanvas {
  z-index: 1;
}

/* ==================== Background Image Layer ==================== */
#bgImageLayer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#bgImageLayer.has-image {
  opacity: 0.3;
}

#particlesOverlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

/* ==================== Glass Card ==================== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ==================== App Container ==================== */
#app {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100vh;
  pointer-events: none;
}

#app > * {
  pointer-events: auto;
}

/* ==================== Header ==================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  flex-shrink: 0;
  background: transparent;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 24px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 8px var(--accent-glow)); }
  50% { filter: drop-shadow(0 0 20px var(--accent-glow)); }
}

.logo-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-track-info {
  flex: 1;
  text-align: center;
  overflow: hidden;
}

.header-track-name {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: 400px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ==================== Buttons ==================== */
.icon-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(124, 111, 247, 0.15);
  color: var(--accent);
  border-color: rgba(124, 111, 247, 0.3);
  transform: scale(1.08);
}

.icon-btn.active {
  color: var(--accent);
  border-color: rgba(124, 111, 247, 0.4);
  background: rgba(124, 111, 247, 0.15);
}

.glow-btn {
  box-shadow: 0 0 12px rgba(124, 111, 247, 0.2);
  transition: all var(--transition);
}

.glow-btn:hover {
  box-shadow: 0 0 24px rgba(124, 111, 247, 0.4), 0 0 48px rgba(124, 111, 247, 0.15);
}

.small-btn {
  background: rgba(124, 111, 247, 0.15);
  border: 1px solid rgba(124, 111, 247, 0.3);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition);
}

.small-btn:hover {
  background: rgba(124, 111, 247, 0.3);
  box-shadow: 0 0 16px rgba(124, 111, 247, 0.3);
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 12px;
  border-radius: 50%;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn:hover {
  color: var(--text-primary);
  transform: scale(1.12);
}

.ctrl-btn.small {
  padding: 8px;
}

.ctrl-btn.active {
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}

.ctrl-btn.play-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: white;
  padding: 18px;
  box-shadow: 0 4px 24px var(--accent-glow);
  transition: all var(--transition);
}

.ctrl-btn.play-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 36px var(--accent-glow), 0 0 60px rgba(124, 111, 247, 0.15);
}

.ctrl-btn.play-btn:active {
  transform: scale(0.95);
}

/* ==================== Main Content Layout ==================== */
.main-content {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 0 24px 16px;
  overflow: hidden;
  min-height: 0;
}

/* ==================== Side Panels ==================== */
.panel {
  width: var(--panel-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ==================== Left Panel - Playlist ==================== */
.playlist-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.playlist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 13px;
}

.playlist-empty .sub {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.6;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.playlist-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.playlist-item.active {
  background: rgba(124, 111, 247, 0.15);
  border-left: 3px solid var(--accent);
}

.playlist-item.active .pi-title {
  color: var(--accent);
}

.pi-index {
  width: 20px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.pi-info {
  flex: 1;
  min-width: 0;
}

.pi-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pi-duration {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.pi-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0;
  transition: all var(--transition);
  font-size: 12px;
}

.playlist-item:hover .pi-remove {
  opacity: 1;
}

.pi-remove:hover {
  color: #f75a6f;
  background: rgba(247, 90, 111, 0.1);
}

/* ==================== Center Area ==================== */
.center-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  pointer-events: none;
}

.center-area > * {
  pointer-events: auto;
}

/* ==================== Visualization Container ==================== */
.viz-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  max-width: 600px;
}

.cover-disc {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #1a1a3a, #2a1a4a, #1a2a4a, #1a1a3a);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    0 0 80px rgba(124, 111, 247, 0.2),
    0 0 120px rgba(124, 111, 247, 0.08),
    inset 0 0 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.5s ease;
  flex-shrink: 0;
}

.cover-disc.spinning {
  animation: spin 8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.cover-disc::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cover-disc::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-deep);
  border: 2px solid rgba(255, 255, 255, 0.1);
  z-index: 5;
}

.cover-inner {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, #1a1a3a 0%, #0a0a1a 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cover-default {
  color: var(--text-muted);
  opacity: 0.5;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.viz-mode-label {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--text-muted);
  text-transform: uppercase;
  opacity: 0.5;
}

/* ==================== Controls ==================== */
.controls {
  width: 100%;
  max-width: 600px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

/* Progress Bar */
.progress-bar {
  width: 100%;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: height 0.15s ease;
}

.progress-track:hover {
  height: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  border-radius: 2px;
  width: 0%;
  position: relative;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(124, 111, 247, 0.3);
}

.progress-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 50%;
  right: -7px;
  transform: translateY(-50%) scale(0);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}

.progress-track:hover .progress-thumb {
  transform: translateY(-50%) scale(1);
}

.progress-times {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Playback Row */
.playback-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Volume Row */
.volume-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* ==================== Right Panel - Track Detail ==================== */
.track-detail {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 13px;
}

.detail-empty .sub {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.6;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.detail-value {
  font-size: 13px;
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
}

/* ==================== Drag Overlay ==================== */
.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.drag-overlay .drag-content {
  position: absolute;
  inset: 16px;
  background: rgba(5, 5, 16, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 2px dashed rgba(124, 111, 247, 0.5);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  animation: fadeIn 0.2s ease;
  box-shadow: 0 0 60px rgba(124, 111, 247, 0.15), inset 0 0 60px rgba(124, 111, 247, 0.05);
}

.drag-overlay .drop-icon {
  font-size: 64px;
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.drag-overlay .drop-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}

.drag-overlay .drop-sub {
  font-size: 14px;
  color: var(--text-muted);
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ==================== Animations ==================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==================== Responsive ==================== */
@media (max-width: 1100px) {
  .panel-right {
    display: none;
  }
  :root {
    --panel-width: 240px;
  }
}

@media (max-width: 768px) {
  .header { padding: 12px 16px; }
  .main-content { padding: 0 12px 12px; gap: 8px; }
  .panel-left { display: none; }
  .cover-disc { width: 200px; height: 200px; }
  .cover-inner { width: 140px; height: 140px; }
  .controls { padding: 12px 16px; }
  .volume-slider { width: 80px; }
  .header-track-info { display: none; }
}