/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #08081a;
  --bg-sidebar:   #0d0b2e;
  --bg-card:      rgba(255,255,255,0.05);
  --bg-card-h:    rgba(255,255,255,0.09);
  --bg-player:    #100e2a;
  --bg-panel:     #0f0d28;
  --accent:       #7c3aed;
  --accent2:      #9f7aea;
  --accent-glow:  rgba(124,58,237,0.35);
  --red:          #dc2626;
  --text:         #f1f5f9;
  --text2:        #8892b0;
  --text3:        #4a5378;
  --border:       rgba(255,255,255,0.07);
  --progress-bg:  rgba(255,255,255,0.12);
  --sidebar-w:    128px;
  --panel-w:      240px;
  --radius:       12px;
  --radius-sm:    7px;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
a { cursor: pointer; text-decoration: none; color: inherit; }
img { display: block; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* ===== LAYOUT ===== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Purple ambient glow blobs */
#app::before {
  content: '';
  position: fixed;
  top: -100px; left: -80px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.18) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
#app::after {
  content: '';
  position: fixed;
  bottom: -80px; left: 40px;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236,72,153,0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0 16px;
  z-index: 10;
  position: relative;
}

#logo {
  cursor: pointer;
  margin-bottom: 28px;
}
#logo-img {
  width: 72px;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

#main-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 10px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  user-select: none;
}
.nav-item svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.3), rgba(124,58,237,0.12));
  color: var(--accent2);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

/* ===== MAIN CONTENT ===== */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 22px 20px 22px;
  position: relative;
  z-index: 1;
}

/* ===== RIGHT PANEL ===== */
#right-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  position: relative;
}

/* Panel toggle tabs */
#panel-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-tab {
  flex: 1;
  padding: 13px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text3);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  letter-spacing: 0.02em;
  text-align: center;
}
.panel-tab:hover { color: var(--text2); }
.panel-tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Songs panel */
#songs-panel {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}
#recommended-songs-list { padding: 0; }

.song-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 6px;
  margin: 0 6px 2px;
  transition: background 0.15s;
  position: relative;
}
.song-row:hover { background: var(--bg-card-h); }
.song-row.active { background: rgba(124,58,237,0.18); }
.song-row.active .song-row-title { color: var(--accent2); }

.song-thumb {
  width: 38px; height: 38px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card);
}
.song-row-info { flex: 1; min-width: 0; }
.song-row-title {
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.song-row-artist { font-size: 11px; color: var(--text2); }
.song-row-dur { font-size: 11px; color: var(--text3); flex-shrink: 0; }

.song-row-actions {
  display: none;
  gap: 4px;
  position: absolute;
  right: 40px;
}
.song-row:hover .song-row-actions { display: flex; }
.song-action-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  transition: background 0.15s;
  color: var(--text2);
}
.song-action-btn:hover { background: var(--accent); color: #fff; }
.song-action-btn svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.fav-btn.is-fav svg { fill: #f43f5e; stroke: #f43f5e; }

/* Lyrics panel */
#lyrics-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
}
#lyrics-content { display: flex; flex-direction: column; gap: 14px; }
.lyric-line {
  font-size: 13px;
  color: var(--text3);
  text-align: center;
  line-height: 1.6;
  transition: all 0.3s ease;
  cursor: default;
}
.lyric-line.active {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.lyric-line.near {
  color: var(--text2);
  font-size: 13.5px;
}
.lyrics-placeholder {
  color: var(--text3);
  text-align: center;
  padding: 30px 0;
  font-size: 13px;
}

/* ===== MUSIC PLAYER ===== */
#player {
  border-top: 1px solid var(--border);
  background: var(--bg-player);
  padding: 18px 16px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#player-art-wrap {
  width: 74px; height: 74px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.4), 0 8px 24px rgba(0,0,0,0.5);
  flex-shrink: 0;
}
#player-art {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  transition: transform 0.1s;
}
#player-art.spinning {
  animation: spin 8s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

#player-info { text-align: center; width: 100%; }
#player-title {
  font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
#player-artist { font-size: 10.5px; color: var(--text2); margin-top: 2px; }

/* Progress bar */
#progress-wrap { width: 100%; cursor: pointer; user-select: none; }
#progress-bg {
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  position: relative;
  overflow: visible;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s linear;
  position: relative;
}
#time-display {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--text3);
}

/* Player controls */
#player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ctrl-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: all 0.15s;
}
.ctrl-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ctrl-btn:hover { color: var(--text); transform: scale(1.1); }

.play-btn {
  width: 40px; height: 40px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.play-btn svg { width: 17px; height: 17px; fill: currentColor; stroke: none; }
.play-btn:hover { background: var(--accent2); transform: scale(1.05); }

/* ===== SECTION HEADINGS ===== */
.section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* ===== CAROUSEL ===== */
.carousel-wrap {
  position: relative;
  margin-bottom: 24px;
}
.carousel-track-outer {
  overflow: hidden;
  border-radius: var(--radius);
}
.carousel-track {
  display: flex;
  gap: 16px;
  transition: transform 0.45s cubic-bezier(.25,.8,.25,1);
}
.carousel-card {
  min-width: calc(33.33% - 11px);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  aspect-ratio: 16/9;
  flex-shrink: 0;
  transition: transform 0.3s, box-shadow 0.3s;
}
.carousel-card:hover { transform: translateY(-4px); box-shadow: 0 14px 40px rgba(0,0,0,0.5); }
.carousel-card img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.carousel-card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.1) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
}
.carousel-card.featured {
  min-width: calc(43% - 11px);
  box-shadow: 0 0 0 2px var(--accent), 0 14px 40px rgba(0,0,0,0.5);
}
.carousel-card-title {
  font-size: 16px; font-weight: 700;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}
.carousel-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 7px 16px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: background 0.2s;
  width: fit-content;
}
.carousel-listen-btn:hover { background: var(--accent); border-color: var(--accent); }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.carousel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--progress-bg);
  cursor: pointer;
  transition: all 0.2s;
}
.carousel-dot.active {
  background: var(--text);
  width: 22px;
  border-radius: 4px;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  transition: background 0.2s;
  font-size: 16px;
}
.carousel-arrow:hover { background: var(--accent); }
.carousel-arrow.left { left: -18px; }
.carousel-arrow.right { right: -18px; }

/* ===== FEATURED ARTISTS ===== */
.artists-scroll {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
  margin-bottom: 24px;
}
.artists-scroll::-webkit-scrollbar { display: none; }
.artist-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 70px;
  transition: transform 0.2s;
}
.artist-item:hover { transform: translateY(-4px); }
.artist-avatar {
  width: 66px; height: 66px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-card);
  border: 2px solid transparent;
  transition: border-color 0.2s;
}
.artist-item:hover .artist-avatar { border-color: var(--accent); }
.artist-avatar-initials {
  width: 66px; height: 66px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  flex-shrink: 0;
  user-select: none;
  letter-spacing: -0.5px;
}
.artist-item:hover .artist-avatar-initials { border-color: var(--accent); }
.artist-name {
  font-size: 11px;
  text-align: center;
  color: var(--text2);
  max-width: 70px;
  word-break: break-word;
  line-height: 1.3;
}

/* Written-by header in lyrics panel */
#lyrics-writtenby {
  font-size: 10.5px;
  color: var(--text3);
  text-align: center;
  padding: 6px 0 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ===== ALBUM GRID ===== */
.album-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.album-grid.large { grid-template-columns: repeat(4, 1fr); }

.album-card {
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  transition: transform 0.2s, background 0.2s;
  position: relative;
  group: true;
}
.album-card:hover { transform: translateY(-4px); background: var(--bg-card-h); }
.album-cover-wrap {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
}
.album-cover {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}
.album-card:hover .album-cover { transform: scale(1.05); }
.album-play-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.album-card:hover .album-play-overlay { opacity: 1; }
.album-play-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.album-play-icon svg { width: 18px; height: 18px; fill: #fff; margin-left: 3px; }
.album-info { padding: 10px 10px 12px; }
.album-info-title {
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.album-info-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* ===== TRENDING PAGE ===== */
.trending-list { display: flex; flex-direction: column; gap: 4px; }
.trending-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  background: var(--bg-card);
}
.trending-item:hover { background: var(--bg-card-h); }
.trending-item.now-playing { background: rgba(124,58,237,0.18); }
.trending-num { font-size: 13px; color: var(--text3); min-width: 22px; text-align: right; }
.trending-cover {
  width: 46px; height: 46px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.trending-info { flex: 1; min-width: 0; }
.trending-title {
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.trending-item.now-playing .trending-title { color: var(--accent2); }
.trending-album { font-size: 11.5px; color: var(--text2); margin-top: 2px; }
.trending-dur { font-size: 12px; color: var(--text3); flex-shrink: 0; }
.trending-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.trending-item:hover .trending-actions { opacity: 1; }
.t-action-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: background 0.15s;
}
.t-action-btn:hover { background: var(--accent); color: #fff; }
.t-action-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.t-action-btn.is-fav svg { fill: #f43f5e; stroke: #f43f5e; }

/* ===== ALBUM DETAIL (inside modal) ===== */
.album-detail-header {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  margin-bottom: 24px;
}
.album-detail-cover {
  width: 140px; height: 140px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.album-detail-info { flex: 1; }
.album-detail-name { font-size: 18px; font-weight: 800; margin-bottom: 5px; }
.album-detail-meta { font-size: 11px; color: var(--text2); margin-bottom: 12px; }
.album-detail-play-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.album-detail-play-all:hover { background: var(--accent2); transform: scale(1.03); }
.album-detail-play-all svg { width: 14px; height: 14px; fill: currentColor; }

.track-list { display: flex; flex-direction: column; gap: 2px; }
.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.track-item:hover { background: var(--bg-card-h); }
.track-item.now-playing { background: rgba(124,58,237,0.2); }
.track-num { font-size: 13px; color: var(--text3); min-width: 24px; text-align: center; flex-shrink: 0; }
.track-item.now-playing .track-num { color: var(--accent2); }
.track-title {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-item.now-playing .track-title { color: var(--accent2); }
.track-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.track-item:hover .track-actions { opacity: 1; }
.track-fav-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: background 0.15s;
}
.track-fav-btn:hover { background: #f43f5e; color: #fff; }
.track-fav-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }
.track-fav-btn.is-fav svg { fill: #f43f5e; stroke: #f43f5e; }
.track-add-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: background 0.15s;
}
.track-add-btn:hover { background: var(--accent); color: #fff; }
.track-add-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* ===== PLAYLIST PAGE ===== */
.playlist-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.btn-new-playlist {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  padding: 9px 18px;
  border-radius: 30px;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.2s;
}
.btn-new-playlist:hover { background: var(--accent2); }
.btn-new-playlist svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.playlist-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.playlist-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.playlist-card:hover { transform: translateY(-4px); background: var(--bg-card-h); }
.playlist-card-mosaic {
  display: grid;
  grid-template-columns: 1fr 1fr;
  aspect-ratio: 1;
  overflow: hidden;
}
.playlist-mosaic-img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.playlist-card-info { padding: 10px; }
.playlist-card-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.playlist-card-count { font-size: 11px; color: var(--text2); }
.playlist-card-del {
  float: right;
  font-size: 11px;
  color: var(--text3);
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.playlist-card-del:hover { background: #dc2626; color: #fff; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state-icon { font-size: 52px; margin-bottom: 14px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text2); margin-bottom: 8px; }

/* ===== SEARCH ===== */
.search-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
}
.search-bar-wrap svg {
  width: 18px; height: 18px;
  stroke: var(--text3); fill: none;
  stroke-width: 2; stroke-linecap: round;
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
}
.search-input::placeholder { color: var(--text3); }

/* ===== PAGE SEARCH TRIGGER (top of main content) ===== */
.page-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  color: var(--text3);
  cursor: pointer;
  transition: border-color 0.2s;
  min-width: 200px;
}
.search-trigger svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.search-trigger:hover { border-color: var(--accent2); color: var(--text2); }

/* ===== MODAL ===== */
#modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#modal-overlay.open { display: flex; }
#modal-box {
  background: #12103a;
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(680px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}
#modal-close {
  position: absolute;
  top: 16px; right: 18px;
  font-size: 18px;
  color: var(--text3);
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
#modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* Playlist modal */
#playlist-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#playlist-modal-overlay.open { display: flex; }
#playlist-modal-box {
  background: #12103a;
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(340px, 90vw);
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.7);
}
#playlist-modal-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
#playlist-picker-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; max-height: 220px; overflow-y: auto; }
.playlist-pick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s;
  width: 100%;
}
.playlist-pick-btn:hover { background: var(--bg-card-h); }
#new-playlist-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
#new-playlist-name {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#new-playlist-name:focus { border-color: var(--accent2); }
#new-playlist-row button {
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
#new-playlist-row button:hover { background: var(--accent2); }
.modal-cancel-btn {
  width: 100%;
  padding: 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text2);
  font-size: 13px;
  transition: background 0.15s;
}
.modal-cancel-btn:hover { background: var(--bg-card-h); }

/* ===== INLINE CREATE PLAYLIST FORM ===== */
.new-playlist-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  max-width: 400px;
}
.new-playlist-form input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.new-playlist-form input:focus { border-color: var(--accent2); }
.new-playlist-form button {
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.new-playlist-form button:hover { background: var(--accent2); }

/* ===== LOADING ===== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== PLAYLIST DETAIL ===== */
.playlist-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  transition: background 0.15s;
}
.back-btn:hover { background: var(--bg-card-h); }
.play-all-small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.2s;
}
.play-all-small:hover { background: var(--accent2); }
.play-all-small svg { width: 13px; height: 13px; fill: currentColor; }

/* Notification toast */
#toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #1e1b4b;
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 13px;
  z-index: 999;
  transition: transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }
