*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f0e8;
  --ink: #1a1208;
  --accent: #ff4d1c;
  --muted: #9a8f80;
  --border: #e0d8cc;
  --warm: #f0e6d3;
  /* Dynamic color vars — updated by JS */
  --dyn1: #f5f0e8;
  --dyn2: #e8e0d0;
}

body {
  background: linear-gradient(135deg, var(--dyn1) 0%, var(--dyn2) 100%);
  color: var(--ink);
  font-family: 'Syne', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 1.2s ease;
}

/* noise overlay */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 9999; opacity: 0.5;
}

/* ── LAYOUT ── */
.app {
  display: grid;
  grid-template-columns: 1fr 390px;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  gap: 0 32px;
}

/* ── HEADER ── */
header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0 18px;
  border-bottom: 2px solid var(--ink);
}
.logo {
  font-size: 28px; font-weight: 800; letter-spacing: -1px;
  display: flex; align-items: center; gap: 10px;
}
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.8s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(0.7)} }

.header-right { display: flex; align-items: center; gap: 16px; }
.track-counter {
  font-family: 'Space Mono', monospace; font-size: 11px;
  color: var(--muted); letter-spacing: 1px;
}
/* Keyboard shortcut hint */
.kb-hint {
  font-family: 'Space Mono', monospace; font-size: 10px;
  color: var(--muted); letter-spacing: 0.5px;
  background: var(--warm); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 4px; cursor: default;
}

/* ── PLAYER PANEL ── */
.player-panel {
  padding: 28px 0;
  display: flex; flex-direction: column; gap: 22px;
}

/* 1. Dynamic bg + 3. Cover zoom */
.cover-stage {
  position: relative;
  width: 100%; aspect-ratio: 1; max-width: 440px;
  border-radius: 4px; overflow: hidden;
  background: var(--warm);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  transition: box-shadow 0.3s;
}
.cover-stage.playing { box-shadow: 8px 8px 0 var(--accent); }

#coverImg {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: opacity 0.35s ease, transform 0.5s ease;
  transform-origin: center;
}
/* 3. Hover zoom */
.cover-stage:hover #coverImg { transform: scale(1.05); }

/* 7. Floating now-playing pill */
.now-pill {
  position: absolute; top: 14px; left: 14px;
  background: var(--ink); color: #fff;
  font-family: 'Space Mono', monospace; font-size: 9px;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 5px 10px; border-radius: 2px;
  display: flex; align-items: center; gap: 6px;
  animation: floatPill 3s ease-in-out infinite;
}
@keyframes floatPill {
  0%,100% { transform: translateY(0px); }
  50%      { transform: translateY(-4px); }
}
.now-pill .dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.cover-stage.playing .now-pill .dot { animation: blink 0.8s ease-in-out infinite; }

/* Song info */
.song-info { max-width: 440px; }
.song-title {
  font-size: clamp(22px, 3.5vw, 36px); font-weight: 800;
  line-height: 1.05; letter-spacing: -0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-sub {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; gap: 10px;
}
.song-artist {
  font-family: 'Space Mono', monospace; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-year {
  font-family: 'Space Mono', monospace; font-size: 11px; color: var(--muted);
  background: rgba(255,255,255,0.5); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 20px; flex-shrink: 0;
}

/* 5. Glowing progress bar */
.progress-section { max-width: 440px; }
.progress-track {
  position: relative; height: 6px; background: var(--border);
  border-radius: 3px; cursor: pointer;
}
.progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent); border-radius: 3px; width: 0%;
  pointer-events: none; transition: width 0.4s linear;
  box-shadow: 0 0 10px var(--accent), 0 0 4px var(--accent);
}
#progress {
  position: absolute; inset: -8px 0; opacity: 0;
  cursor: pointer; width: 100%; margin: 0;
}
.time-row {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-family: 'Space Mono', monospace; font-size: 11px; color: var(--muted);
}

/* Controls */
.controls-row {
  display: flex; align-items: center; gap: 6px; max-width: 440px;
}
.ctrl {
  background: none; border: 2px solid transparent; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); transition: all 0.15s; flex-shrink: 0;
}
.ctrl svg { fill: currentColor; }
.ctrl:hover { border-color: var(--ink); background: rgba(255,255,255,0.4); }
.ctrl:active { transform: scale(0.92); }
.ctrl.active { color: var(--accent); border-color: var(--accent); }

/* 2. Animated play button */
.play-ctrl {
  width: 64px; height: 64px; background: var(--ink);
  border: 2px solid var(--ink); border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.1s;
  flex-shrink: 0; margin: 0 6px;
  box-shadow: 4px 4px 0 var(--accent);
  position: relative; overflow: hidden;
}
.play-ctrl svg { fill: #fff; position: relative; z-index: 1; }
.play-ctrl:hover {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 4px 4px 0 var(--ink), 0 0 20px rgba(255,77,28,0.4);
}
.play-ctrl:active {
  transform: translate(2px,2px) scale(0.95);
  box-shadow: 2px 2px 0 var(--ink), 0 0 20px rgba(255,77,28,0.7);
}
/* Ripple */
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0); animation: rippleAnim 0.5s linear;
  pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(4); opacity: 0; } }

/* Volume */
.vol-row {
  display: flex; align-items: center; gap: 10px; max-width: 440px;
}
.vol-row svg { fill: var(--muted); width: 16px; height: 16px; flex-shrink: 0; }
.vol-slider {
  flex: 1; appearance: none; height: 3px; border-radius: 2px;
  outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--ink) 0%, var(--ink) 70%, var(--border) 70%);
}
.vol-slider::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--ink); transition: transform 0.15s;
}
.vol-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }

/* Error box */
#errorBox {
  display: none; background: #fff0ed; border: 2px solid var(--accent);
  color: var(--accent); font-family: 'Space Mono', monospace; font-size: 11px;
  padding: 8px 14px; border-radius: 4px; max-width: 440px;
  box-shadow: 3px 3px 0 var(--accent);
}

/* ── PLAYLIST PANEL ── */
.playlist-panel {
  border-left: 2px solid var(--ink);
  padding: 28px 0 28px 28px;
  display: flex; flex-direction: column; gap: 14px;
  overflow: hidden; min-height: 0;
}

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
}
.panel-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.panel-count { font-family: 'Space Mono', monospace; font-size: 11px; color: var(--muted); }

.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  fill: var(--muted); width: 14px; height: 14px; pointer-events: none;
}
#searchInput {
  width: 100%; background: rgba(255,255,255,0.6);
  border: 2px solid var(--border); border-radius: 4px;
  padding: 10px 12px 10px 34px;
  font-family: 'Syne', sans-serif; font-size: 13px; color: var(--ink);
  outline: none; transition: border-color 0.2s;
}
#searchInput:focus { border-color: var(--ink); }
#searchInput::placeholder { color: var(--muted); }

.filter-tabs { display: flex; gap: 6px; }
.tab {
  background: none; border: 2px solid var(--border); border-radius: 20px;
  padding: 4px 12px; font-family: 'Syne', sans-serif; font-size: 11px;
  font-weight: 700; cursor: pointer; color: var(--muted);
  transition: all 0.15s; letter-spacing: 0.5px;
}
.tab:hover { border-color: var(--ink); color: var(--ink); }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* 8. Recently played section */
.recent-section { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.recent-label {
  font-family: 'Space Mono', monospace; font-size: 9px;
  letter-spacing: 2px; text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px;
}
.recent-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.recent-chip {
  font-family: 'Space Mono', monospace; font-size: 10px; color: var(--ink);
  background: rgba(255,255,255,0.5); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; cursor: pointer;
  transition: all 0.15s; white-space: nowrap; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis;
}
.recent-chip:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 6. Styled scrollbar */
.playlist-scroll {
  overflow-y: auto; flex: 1; min-height: 0;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.playlist-scroll::-webkit-scrollbar { width: 4px; }
.playlist-scroll::-webkit-scrollbar-track { background: transparent; }
.playlist-scroll::-webkit-scrollbar-thumb {
  background: var(--accent); border-radius: 10px;
}

/* Playlist items — 4. Smooth slide hover */
.pl-item {
  display: grid;
  grid-template-columns: 22px 44px 1fr auto;
  align-items: center; gap: 10px;
  padding: 9px 8px 9px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, padding-left 0.15s, transform 0.2s;
  border-radius: 4px;
}
/* 4. Slide on hover */
.pl-item:hover { background: rgba(255,255,255,0.5); padding-left: 8px; transform: translateX(4px); }
.pl-item.active {
  background: var(--ink); padding-left: 8px;
  border-bottom-color: transparent; border-radius: 6px; margin-bottom: 1px;
  transform: none;
}
.pl-item.active:hover { transform: none; }
.pl-item.active .pl-name { color: #fff; }
.pl-item.active .pl-artist { color: rgba(255,255,255,0.45); }
.pl-item.active .pl-dur { color: rgba(255,255,255,0.45); }
.pl-item.active .pl-num { color: var(--accent); }

.pl-num-wrap { display: flex; align-items: center; justify-content: center; width: 22px; }
.pl-num { font-family: 'Space Mono', monospace; font-size: 10px; color: var(--muted); }
.eq-bars { display: none; gap: 2px; align-items: flex-end; height: 14px; }
.pl-item.active.is-playing .eq-bars { display: flex; }
.pl-item.active.is-playing .pl-num { display: none; }
.eq-bars span {
  width: 3px; background: var(--accent); border-radius: 1px;
  animation: eqbar 0.5s ease-in-out infinite alternate;
}
.eq-bars span:nth-child(1){height:5px;animation-delay:0s}
.eq-bars span:nth-child(2){height:12px;animation-delay:0.15s}
.eq-bars span:nth-child(3){height:7px;animation-delay:0.3s}
@keyframes eqbar { from{transform:scaleY(0.3)} to{transform:scaleY(1)} }

.pl-thumb {
  width: 44px; height: 44px; border-radius: 4px; object-fit: cover;
  background: var(--warm); border: 1px solid var(--border);
}
.pl-item.active .pl-thumb { border-color: rgba(255,255,255,0.15); }

.pl-info { min-width: 0; }
.pl-name {
  font-size: 12px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink); line-height: 1.3;
}
.pl-artist {
  font-family: 'Space Mono', monospace; font-size: 10px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.pl-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.pl-dur { font-family: 'Space Mono', monospace; font-size: 10px; color: var(--muted); }
.pl-fav { font-size: 12px; cursor: pointer; transition: transform 0.15s; line-height: 1; }
.pl-fav:hover { transform: scale(1.3); }
.no-results {
  text-align: center; color: var(--muted);
  font-family: 'Space Mono', monospace; font-size: 12px; padding: 40px 0;
}

/* ── 10. MINI PLAYER ── */
.mini-player {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--ink); color: #fff;
  display: none;
  align-items: center; justify-content: space-between;
  padding: 10px 24px; gap: 16px;
  border-top: 2px solid var(--accent);
  z-index: 1000;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.mini-cover {
  width: 38px; height: 38px; border-radius: 4px; object-fit: cover;
  border: 1px solid rgba(255,255,255,0.2); flex-shrink: 0;
}
.mini-info { flex: 1; min-width: 0; }
.mini-title {
  font-size: 13px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-artist { font-family: 'Space Mono', monospace; font-size: 10px; color: rgba(255,255,255,0.5); }
.mini-controls { display: flex; align-items: center; gap: 8px; }
.mini-btn {
  background: none; border: none; color: #fff; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.mini-btn svg { fill: #fff; }
.mini-btn:hover { background: rgba(255,255,255,0.1); }
.mini-progress {
  position: absolute; bottom: 0; left: 0;
  height: 2px; background: var(--accent);
  transition: width 0.4s linear;
}

/* 9. Keyboard shortcut tooltip */
.kb-tooltip {
  position: fixed; bottom: 80px; right: 20px;
  background: var(--ink); color: #fff;
  font-family: 'Space Mono', monospace; font-size: 11px;
  padding: 12px 16px; border-radius: 6px; border: 1px solid var(--accent);
  line-height: 2; z-index: 2000;
  display: none;
  box-shadow: 4px 4px 0 var(--accent);
}
.kb-tooltip.visible { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.kb-tooltip kbd {
  background: rgba(255,255,255,0.1); border-radius: 3px;
  padding: 1px 6px; font-size: 11px; margin-right: 6px;
  border: 1px solid rgba(255,255,255,0.2);
}

/* RESPONSIVE */
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; padding: 0 16px; }
  header { grid-column: 1; }
  .kb-hint { display: none; }
  .playlist-panel {
    border-left: none; border-top: 2px solid var(--ink);
    padding: 20px 0 80px; max-height: 60vh;
  }
  .cover-stage, .song-info, .progress-section, .controls-row, .vol-row, #errorBox { max-width: 100%; }
}