:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #f2f3f5;
  --text-muted: #9aa0ab;
  --accent: #6366f1;
  --accent-2: #22c55e;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #e2e4ea;
  --text: #14161a;
  --text-muted: #676d7a;
  --shadow: 0 20px 50px rgba(20, 22, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  transition: background 0.3s ease, color 0.3s ease;
}

.app {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: 340px 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------- Player panel ---------- */
.player {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  border-right: 1px solid var(--border);
}

.brand {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand .dot {
  color: var(--accent);
}

.theme-toggle {
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  background: var(--border);
}

.theme-toggle:active {
  transform: scale(0.9);
}

.art-wrap {
  position: relative;
  width: 220px;
  height: 220px;
}

#song-image {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border: 6px solid var(--surface-2);
  transition: box-shadow 0.4s ease;
}

.art-wrap.playing #song-image {
  animation: spin 12s linear infinite;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 8px rgba(99, 102, 241, 0.12);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.song-meta {
  text-align: center;
  min-height: 52px;
}

#song-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

#song-artist {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

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

.time {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.song-progress {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  appearance: none;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.song-progress::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.song-progress::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

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

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s ease, transform 0.15s ease, color 0.2s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn:active {
  transform: scale(0.9);
}

.icon-btn.active {
  color: var(--accent);
}

#play-btn {
  width: 52px;
  height: 52px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
}

#play-btn:hover {
  background: #5457e0;
}

.volume-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 15px;
}

.volume-row i {
  font-size: 15px;
  width: 16px;
  text-align: center;
}

.volume-row input[type="range"] {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  appearance: none;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.volume-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-muted);
  cursor: pointer;
}

/* ---------- Library panel ---------- */
.library {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.library-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-box input:focus {
  border-color: var(--accent);
}

.search-box i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.playlist {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playlist::-webkit-scrollbar {
  width: 6px;
}

.playlist::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.playlist li {
  cursor: pointer;
  padding: 9px 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.playlist li:hover {
  background: var(--surface-2);
  transform: translateX(2px);
}

.playlist li.active {
  background: var(--surface-2);
  border-left-color: var(--accent);
}

.playlist li img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.track-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.track-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist li.active .track-title {
  color: var(--accent);
}

.track-artist {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-cc {
  display: flex;
  align-items: center;
  color: var(--accent-2);
  font-size: 13px;
  flex-shrink: 0;
}

.track-lang {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--border);
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.track-eq {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: none;
}

.playlist li.active .track-eq {
  display: block;
}

.track-eq span {
  display: inline-block;
  width: 2px;
  height: 100%;
  margin-right: 1px;
  background: var(--accent);
  animation: eq 0.9s ease-in-out infinite;
}

.track-eq span:nth-child(2) { animation-delay: 0.15s; }
.track-eq span:nth-child(3) { animation-delay: 0.3s; }

@keyframes eq {
  0%, 100% { height: 30%; }
  50% { height: 100%; }
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
  }
  .player {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .playlist {
    max-height: 320px;
  }
}
