:root {
  --bg: #0d0b14;
  --bg-soft: #16121f;
  --bg-card: #1c1728;
  --bg-hover: #261f36;
  --accent: #a855f7;
  --accent-2: #7c3aed;
  --accent-glow: rgba(168, 85, 247, 0.35);
  --text: #f3f0fa;
  --text-dim: #9d94b3;
  --heart: #f472b6;
  --player-h: 88px;
  --sidebar-w: 240px;
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input { font-family: inherit; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #3a2f52; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-soft);
  padding: 24px 16px calc(var(--player-h) + 16px);
  display: flex; flex-direction: column; gap: 28px;
  border-right: 1px solid rgba(168,85,247,.08);
  flex-shrink: 0;
  z-index: 60;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.35rem; }
.logo-icon { font-size: 1.5rem; }
.logo-text {
  background: linear-gradient(120deg, #c084fc, #a855f7, #7c3aed);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--text-dim); font-size: .95rem; font-weight: 600;
  transition: all .2s ease; text-align: left;
}
.nav-btn svg { width: 21px; height: 21px; flex-shrink: 0; }
.nav-btn:hover { color: var(--text); background: var(--bg-hover); }
.nav-btn.active {
  color: #fff;
  background: linear-gradient(120deg, rgba(168,85,247,.22), rgba(124,58,237,.14));
  box-shadow: inset 0 0 0 1px rgba(168,85,247,.3);
}
.playlists-section { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
.playlists-header {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text-dim); font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; padding: 0 10px;
}
.playlist-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.playlist-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: 8px; color: var(--text-dim);
  font-size: .9rem; transition: all .15s; text-align: left; width: 100%;
}
.playlist-item:hover { background: var(--bg-hover); color: var(--text); }
.playlist-item.active { color: var(--accent); }
.playlist-item .del { opacity: 0; color: var(--text-dim); padding: 2px; }
.playlist-item:hover .del { opacity: 1; }
.playlist-item .del:hover { color: #f87171; }
.playlist-item .del svg { width: 15px; height: 15px; display: block; }

/* ============ MOBILE HEADER ============ */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: rgba(13,11,20,.92); backdrop-filter: blur(12px);
  align-items: center; justify-content: space-between;
  padding: 0 14px; z-index: 55;
  border-bottom: 1px solid rgba(168,85,247,.1);
}
.mobile-header .logo { font-size: 1.1rem; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 59;
}
.sidebar-backdrop.show { display: block; }

/* ============ MAIN ============ */
.main {
  flex: 1; overflow-y: auto;
  padding: 32px 36px calc(var(--player-h) + 40px);
  background:
    radial-gradient(1000px 400px at 20% -10%, rgba(124,58,237,.16), transparent 60%),
    radial-gradient(800px 500px at 90% 0%, rgba(168,85,247,.1), transparent 55%),
    var(--bg);
}
.view { display: none; animation: fadeUp .35s ease; }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.hero { margin-bottom: 34px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; }
.hero p { color: var(--text-dim); margin-top: 8px; font-size: 1rem; }
.accent { color: var(--accent); }
.page-title { font-size: 1.7rem; font-weight: 800; margin-bottom: 22px; }
.section-title { font-size: 1.25rem; font-weight: 700; margin: 26px 0 16px; }

/* ============ ALBUM CARDS ============ */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
}
.album-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  transition: all .25s ease;
  border: 1px solid transparent;
}
.album-card:hover {
  background: var(--bg-hover);
  transform: translateY(-4px);
  border-color: rgba(168,85,247,.25);
  box-shadow: 0 12px 32px rgba(0,0,0,.4), 0 0 24px var(--accent-glow);
}
.album-cover {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 10px; margin-bottom: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.album-cover .note { font-size: 2.6rem; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
.album-cover .cover-play {
  position: absolute; right: 10px; bottom: 10px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(8px);
  transition: all .25s ease;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.album-card:hover .cover-play { opacity: 1; transform: none; }
.cover-play svg { width: 20px; height: 20px; margin-left: 2px; }
.album-name { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-artist { color: var(--text-dim); font-size: .82rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ GENRE GRID ============ */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.genre-card {
  position: relative; height: 92px; border-radius: var(--radius);
  padding: 16px; font-weight: 800; font-size: 1.05rem;
  overflow: hidden; text-align: left; color: #fff;
  transition: transform .2s ease, box-shadow .2s ease;
}
.genre-card:hover { transform: scale(1.04); box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.genre-card::after {
  content: '🎧'; position: absolute; right: -8px; bottom: -14px;
  font-size: 3.4rem; opacity: .35; transform: rotate(18deg);
}
.genre-card.selected { outline: 2px solid #fff; }

/* ============ TRACK LIST ============ */
.track-list { display: flex; flex-direction: column; gap: 2px; }
.track-row {
  display: grid;
  grid-template-columns: 34px 44px 1fr auto auto auto;
  align-items: center; gap: 14px;
  padding: 8px 14px; border-radius: 10px;
  transition: background .15s ease;
}
.track-row:hover { background: var(--bg-hover); }
.track-row.playing { background: linear-gradient(90deg, rgba(168,85,247,.16), transparent); }
.track-row.playing .t-title { color: var(--accent); }
.t-num { color: var(--text-dim); font-size: .9rem; text-align: center; }
.track-row.playing .t-num { color: var(--accent); }
.t-art {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.t-meta { min-width: 0; }
.t-title { font-weight: 600; font-size: .94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-artist { color: var(--text-dim); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-album { color: var(--text-dim); font-size: .84rem; display: none; }
.t-dur { color: var(--text-dim); font-size: .84rem; font-variant-numeric: tabular-nums; }
.t-actions { display: flex; align-items: center; gap: 2px; }
.t-actions .icon-btn { opacity: 0; width: 32px; height: 32px; }
.track-row:hover .t-actions .icon-btn,
.t-actions .icon-btn.faved { opacity: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  color: var(--text-dim); transition: all .15s ease;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.07); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.faved { color: var(--heart); }
.icon-btn.faved svg { fill: var(--heart); }
@media (min-width: 900px) {
  .track-row { grid-template-columns: 34px 44px 2fr 1.4fr auto auto; }
  .t-album { display: block; }
  .t-dur { min-width: 44px; text-align: right; }
}

/* ============ SEARCH ============ */
.search-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid rgba(168,85,247,.2);
  border-radius: 999px; padding: 13px 20px;
  max-width: 560px; margin-bottom: 26px;
  transition: all .2s ease;
}
.search-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-bar svg { width: 19px; height: 19px; color: var(--text-dim); flex-shrink: 0; }
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: .95rem;
}
.search-bar input::placeholder { color: var(--text-dim); }
.empty-state { color: var(--text-dim); text-align: center; padding: 44px 20px; font-size: .95rem; }

/* ============ PLAYER BAR ============ */
.player {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--player-h);
  background: rgba(18,14,26,.92); backdrop-filter: blur(16px);
  border-top: 1px solid rgba(168,85,247,.15);
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center; gap: 16px;
  padding: 0 18px; z-index: 70;
}
.now-playing { display: flex; align-items: center; gap: 12px; min-width: 0; }
.np-art {
  width: 54px; height: 54px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  transition: transform .3s ease;
}
.np-art.spin { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); box-shadow: 0 0 20px var(--accent-glow); } }
.np-info { min-width: 0; }
.np-title { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { color: var(--text-dim); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heart-btn { flex-shrink: 0; }

.player-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.controls { display: flex; align-items: center; gap: 6px; }
.ctrl { width: 36px; height: 36px; }
.ctrl.toggled { color: var(--accent); }
.play-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s ease;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.play-btn:hover { transform: scale(1.07); background: #b96fff; }
.play-btn svg { width: 21px; height: 21px; }

.progress-row { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; }
.time { font-size: .72rem; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 36px; }
.time:last-child { text-align: right; }
.progress-bar {
  flex: 1; height: 5px; background: rgba(255,255,255,.12);
  border-radius: 3px; cursor: pointer; position: relative;
}
.progress-bar:hover { height: 7px; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 3px; position: relative; transition: width .1s linear;
}
.progress-bar:hover .progress-fill::after {
  content: ''; position: absolute; right: -6px; top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
}

.player-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.volume-slider {
  -webkit-appearance: none; appearance: none;
  width: 96px; height: 5px; border-radius: 3px;
  background: rgba(255,255,255,.14); outline: none; cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); transition: transform .15s;
}
.volume-slider::-webkit-slider-thumb:hover { transform: scale(1.25); }
.volume-slider::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%; background: var(--accent);
}

/* ============ MODAL / POPOVER ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: none; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; animation: fadeUp .2s ease; }
.modal {
  background: var(--bg-card); border-radius: 16px; padding: 26px;
  width: min(92vw, 380px);
  border: 1px solid rgba(168,85,247,.25);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal h3 { margin-bottom: 16px; font-size: 1.1rem; }
.modal input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid rgba(168,85,247,.25);
  color: var(--text); font-size: .95rem; outline: none;
}
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn { padding: 10px 20px; border-radius: 999px; font-weight: 700; font-size: .88rem; transition: all .2s; }
.btn.ghost { color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #b96fff; box-shadow: 0 4px 16px var(--accent-glow); }

.popover {
  position: fixed; display: none; z-index: 110;
  background: var(--bg-card); border: 1px solid rgba(168,85,247,.3);
  border-radius: 12px; padding: 6px; min-width: 190px;
  box-shadow: 0 14px 40px rgba(0,0,0,.55);
  max-height: 260px; overflow-y: auto;
}
.popover.show { display: block; animation: fadeUp .15s ease; }
.popover button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 8px; font-size: .88rem; color: var(--text);
}
.popover button:hover { background: var(--bg-hover); color: var(--accent); }
.popover .pop-title { padding: 8px 12px; font-size: .72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }

/* toast */
.toast {
  position: fixed; bottom: calc(var(--player-h) + 16px); left: 50%;
  transform: translateX(-50%);
  background: var(--accent); color: #fff; font-weight: 600; font-size: .88rem;
  padding: 10px 22px; border-radius: 999px; z-index: 120;
  box-shadow: 0 8px 28px var(--accent-glow);
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ RESPONSIVE ============ */
@media (max-width: 899px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 0 60px rgba(0,0,0,.6);
  }
  .sidebar.open { transform: none; }
  .mobile-header { display: flex; }
  .main { padding: 76px 18px calc(var(--player-h) + 34px); }
  .player {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto; min-height: var(--player-h);
    padding: 10px 14px; row-gap: 6px;
  }
  .now-playing { grid-column: 1; }
  .player-right { grid-column: 2; grid-row: 1; }
  .player-center { grid-column: 1 / -1; grid-row: 2; }
  .volume-slider { width: 64px; }
  .np-art { width: 46px; height: 46px; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .track-row { gap: 10px; padding: 7px 8px; }
  .t-actions .icon-btn { opacity: 1; }
}
@media (max-width: 480px) {
  .player-right { display: none; }
  .player { grid-template-columns: 1fr; }
  .player-center { grid-column: 1; }
}
