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

:root {
  --bg: #121212;
  --surface: #181818;
  --surface-hover: #282828;
  --accent: #E91E8C;
  --accent-glow: rgba(233, 30, 140, 0.4);
  --text-primary: #FFFFFF;
  --text-secondary: #B3B3B3;
  --radius: 8px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  position: relative;
  max-width: 430px;
  margin: 0 auto;
  height: 100dvh;
  overflow: hidden;
}

/* === Views === */
.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#playlist-view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#playlist-view::-webkit-scrollbar {
  display: none;
}

#playlist-view.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

#playlist-view:not(.active) {
  transform: translateX(-30%);
  opacity: 0;
  pointer-events: none;
}

#now-playing-view {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

#now-playing-view.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* === Playlist Header === */
.playlist-header {
  padding: 60px 24px 24px;
  text-align: center;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Radio wave animation */
.radio-waves {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
}

.radio-waves span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
  animation: wave 1.2s ease-in-out infinite;
}

.radio-waves span:nth-child(1) {
  height: 12px;
  animation-delay: 0s;
}

.radio-waves span:nth-child(2) {
  height: 20px;
  animation-delay: 0.15s;
}

.radio-waves span:nth-child(3) {
  height: 16px;
  animation-delay: 0.3s;
}

@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.5); }
}

.tagline {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
}

/* === Track List === */
.track-list {
  list-style: none;
  padding: 8px 12px 32px;
  flex: 1;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.track-item:active,
.track-item:hover {
  background: var(--surface-hover);
}

.track-item.playing {
  background: var(--surface);
}

.track-item.playing .track-title {
  color: var(--accent);
}

.track-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
}

.track-meta {
  flex: 1;
  min-width: 0;
}

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

.track-artist {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Playing indicator bars */
.playing-indicator {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}

.track-item.playing .playing-indicator {
  display: flex;
}

.track-item.playing .track-duration {
  display: none;
}

.playing-indicator span {
  display: block;
  width: 3px;
  border-radius: 1.5px;
  background: var(--accent);
  animation: eq 0.8s ease-in-out infinite;
}

.playing-indicator span:nth-child(1) { height: 8px; animation-delay: 0s; }
.playing-indicator span:nth-child(2) { height: 14px; animation-delay: 0.2s; }
.playing-indicator span:nth-child(3) { height: 10px; animation-delay: 0.4s; }

@keyframes eq {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.4); }
}

/* === Now Playing === */
.btn-back {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 12px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-back:active {
  background: var(--surface-hover);
}

.now-playing-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px 40px;
  gap: 24px;
}

.album-art-wrapper {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.album-art-wrapper.playing {
  transform: scale(1.02);
}

.album-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.track-info {
  text-align: center;
  width: 100%;
  max-width: 300px;
}

.np-title {
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-artist {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 400;
}

/* === Progress Bar === */
.progress-container {
  width: 100%;
  max-width: 300px;
}

.progress-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-hover);
  outline: none;
  cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform 0.15s;
}

.progress-bar::-webkit-slider-thumb:active {
  transform: scale(1.3);
}

.progress-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px var(--accent-glow);
}

.progress-bar::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
}

.time-display {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* === Controls === */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  max-width: 300px;
}

.btn-control {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, color 0.2s;
  min-width: 44px;
  min-height: 44px;
}

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

.btn-play {
  background: var(--text-primary);
  color: var(--bg);
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.btn-play:active {
  transform: scale(0.93);
}

.btn-heart.liked {
  color: var(--accent);
}

.btn-heart.liked svg path {
  fill: var(--accent);
  stroke: var(--accent);
}

/* Heart pop animation */
@keyframes heart-pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.btn-heart.pop {
  animation: heart-pop 0.4s ease-out;
}

/* === Default Cover (SVG fallback) === */
.album-art-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #E91E8C 0%, #6B1D5E 50%, #1a1a2e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.track-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: linear-gradient(135deg, #E91E8C, #6B1D5E);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* === Utility === */
@media (min-width: 431px) {
  #app {
    border-left: 1px solid #282828;
    border-right: 1px solid #282828;
  }
}

/* Progress bar fill color via linear gradient trick */
.progress-bar {
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--progress, 0%),
    var(--surface-hover) var(--progress, 0%),
    var(--surface-hover) 100%
  );
}
