/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --red:    #BC002D;
  --red-dk: #960025;
  --white:  #ffffff;
  --text:   #111111;
  --muted:  #888888;
  --line:   #ebebeb;
  --hover:  #fafafa;
  --active-bg: #fff5f7;
}

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

/* ─── Base ──────────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--white);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Header / Moon ─────────────────────────────────────────────────────── */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 24px 48px;
  width: 100%;
}

.moon {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--red);
  margin-bottom: 28px;
  box-shadow:
    0 0 0 0 rgba(188, 0, 45, 0.4),
    0 12px 48px rgba(188, 0, 45, 0.22);
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(188,0,45,0.4), 0 12px 48px rgba(188,0,45,0.22); }
  50%       { box-shadow: 0 0 0 14px rgba(188,0,45,0), 0 12px 60px rgba(188,0,45,0.32); }
}

h1 {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.subtitle {
  margin-top: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── Main / Layout ─────────────────────────────────────────────────────── */
main {
  width: 100%;
  max-width: 600px;
  padding: 0 20px 60px;
  flex: 1;
}

/* ─── Player ────────────────────────────────────────────────────────────── */
.player-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 24px;
  margin-bottom: 12px;
}

/* Now playing row */
.now-playing {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  min-height: 42px;
}

.track-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.track-artist {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--muted);
}

.time-display {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
  display: flex;
  gap: 3px;
}

/* Progress bar */
.progress-wrap {
  position: relative;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  cursor: pointer;
  margin-bottom: 24px;
}

.progress-wrap:hover .progress-thumb { opacity: 1; }

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--red);
  border-radius: 2px;
  pointer-events: none;
  transition: width 0.1s linear;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.btn-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text);
  width: 40px;
  height: 40px;
  transition: background 0.15s, color 0.15s;
}

.btn-ctrl svg { width: 20px; height: 20px; }

.btn-ctrl:hover { color: var(--red); background: var(--active-bg); }

.btn-play {
  width: 56px;
  height: 56px;
  background: var(--red);
  color: var(--white);
}

.btn-play svg { width: 26px; height: 26px; }
.btn-play:hover { background: var(--red-dk); color: var(--white); }

/* Show/hide play vs pause icons */
.icon-pause { display: none; }
body.playing .icon-play  { display: none; }
body.playing .icon-pause { display: block; }

/* Volume */
.volume-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.vol-icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  border: none;
  cursor: pointer;
}

/* ─── Track List ─────────────────────────────────────────────────────────── */
.track-list {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.track-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.12s;
  gap: 14px;
}

.track-item:last-child { border-bottom: none; }
.track-item:hover { background: var(--hover); }
.track-item.active { background: var(--active-bg); }

/* Number / Bars indicator */
.track-num {
  width: 20px;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.track-item.active .track-num { color: var(--red); }

.bars {
  display: none;
  gap: 2px;
  align-items: flex-end;
  height: 14px;
  width: 20px;
  flex-shrink: 0;
}

.bar {
  width: 3px;
  background: var(--red);
  border-radius: 1px;
  animation: bounce 0.7s ease-in-out infinite alternate;
  height: 4px;
}
.bar:nth-child(2) { animation-delay: 0.15s; }
.bar:nth-child(3) { animation-delay: 0.3s;  }

@keyframes bounce {
  to { height: 13px; }
}

/* Show bars when active + playing, hide number */
.track-item.active.playing .track-num { display: none; }
.track-item.active.playing .bars { display: flex; }

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

.track-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-dur {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Empty / error state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.7;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.empty strong {
  display: block;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 8px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
footer {
  padding: 24px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--line);
  text-transform: uppercase;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  header { padding: 48px 20px 36px; }
  .moon  { width: 88px; height: 88px; }
  .player-wrap { padding: 22px 18px 20px; border-radius: 12px; }
  .track-list  { border-radius: 12px; }
  .track-item  { padding: 13px 16px; }
}
