* { box-sizing: border-box; }
:root {
  --bg: #0e0e10;
  --bg-elev: #17171a;
  --bg-elev-2: #1c1c20;
  --border: #26262b;
  --border-strong: #3a3a44;
  --text: #e8e8ea;
  --text-mute: #9494a0;
  --text-dim: #7a7a85;
  --accent: #9b8cff;
  --accent-strong: #6c5ce7;
  --shadow: 0 8px 32px rgba(0,0,0,.55);
}

html, body {
  height: 100%;
  margin: 0;
}
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(1200px 800px at 30% -20%, #1a1738 0%, var(--bg) 60%) no-repeat fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 23, 26, .8);
  backdrop-filter: blur(8px);
}
.brand { text-decoration: none; color: inherit; display: flex; align-items: baseline; gap: .4rem; }
.brand-name { font-size: 1.1rem; font-weight: 600; }
.brand-sub { color: var(--accent); font-size: .9rem; }
.link-back {
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
  padding: .4rem .8rem;
  border-radius: 6px;
}
.link-back:hover { background: var(--bg-elev-2); }

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  padding: 1.5rem;
  min-height: 0;
}

.now-playing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, rgba(108,92,231,.10) 0%, rgba(14,14,16,.4) 60%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  overflow-y: auto;
}

.cover {
  width: 280px;
  height: 280px;
  max-width: 60vw;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #2a2156 0%, #1a1738 100%);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.75rem;
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-icon {
  font-size: 5rem;
  color: rgba(255,255,255,.15);
}
.cover.playing { animation: cover-pulse 3s ease-in-out infinite; }
@keyframes cover-pulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(155,140,255,.4); }
  50%      { box-shadow: var(--shadow), 0 0 0 18px rgba(155,140,255,0); }
}
.cover.tap-to-play {
  cursor: pointer;
  position: relative;
}
.cover.tap-to-play::after {
  content: '▶';
  position: absolute;
  inset: 0;
  background: rgba(14, 14, 16, .55);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  text-shadow: 0 4px 24px rgba(0,0,0,.6);
  transition: background .15s, font-size .15s;
}
.cover.tap-to-play:hover::after {
  background: rgba(14, 14, 16, .35);
  font-size: 4.5rem;
}
.cover.tap-to-play.loading::after {
  content: '⌛';
  font-size: 2.5rem;
}

.track-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 .35rem;
  max-width: 600px;
  word-wrap: break-word;
}
.track-meta {
  color: var(--accent);
  font-size: .9rem;
  margin: 0 0 1.5rem;
  font-variant-numeric: tabular-nums;
}

audio {
  width: 100%;
  max-width: 480px;
  margin-bottom: 1rem;
}
audio::-webkit-media-controls-panel {
  background-color: rgba(23, 23, 26, .9);
}

.track-actions {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
.btn-link {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-mute);
  padding: .45rem .9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  transition: background .12s, color .12s;
}
.btn-link:hover { background: var(--bg-elev-2); color: var(--text); }
.btn-link.copied { color: #5fe080; border-color: #5fe080; }

.status {
  color: var(--text-mute);
  font-size: .8rem;
  min-height: 1.1em;
  margin-top: .5rem;
}

.queue {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  overflow-y: auto;
  min-height: 0;
}
.queue-title {
  margin: 0 0 .75rem;
  font-size: .8rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.queue-count { color: var(--text-dim); font-weight: 400; margin-left: .35rem; }

#playlist { list-style: none; margin: 0; padding: 0; }
#playlist li {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
#playlist li:hover { background: var(--bg-elev-2); }
#playlist li.playing { background: rgba(108,92,231,.18); }
#playlist li.arrived {
  animation: arrive 1.6s ease-out;
}
@keyframes arrive {
  0%   { background: rgba(95, 224, 128, .35); transform: translateX(-6px); }
  20%  { background: rgba(95, 224, 128, .35); transform: translateX(0); }
  100% { background: transparent; transform: translateX(0); }
}
#playlist li.playing::before {
  content: '▶';
  position: absolute;
  left: -2px;
  color: var(--accent);
  font-size: .65rem;
}

#playlist .thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
#playlist .thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 1.1rem;
}
#playlist .title {
  font-size: .85rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
#playlist .meta {
  font-size: .7rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
#playlist .share-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  width: 26px; height: 26px;
  border-radius: 5px;
  cursor: pointer;
  font-size: .9rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
#playlist li:hover .share-btn { opacity: 1; }
#playlist .share-btn:hover { background: var(--bg); color: var(--text); }

@media (max-width: 880px) {
  .grid {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(0, auto);
    padding: .85rem;
    gap: .85rem;
  }
  .now-playing {
    padding: 1.5rem 1rem;
  }
  .cover {
    width: 220px;
    height: 220px;
  }
  .track-title { font-size: 1.2rem; }
  .queue {
    max-height: 50vh;
  }
}
