:root {
  color-scheme: dark;
  --bg: #101820;
  --bg-2: #17212d;
  --panel: rgba(255, 255, 255, .08);
  --panel-strong: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .13);
  --text: #f7fbff;
  --muted: #a9b8c9;
  --cyan: #51d6ff;
  --green: #56f0aa;
  --rose: #ff6b8a;
  --amber: #ffd166;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #edf7ff;
  --bg-2: #fff8f1;
  --panel: rgba(255, 255, 255, .72);
  --panel-strong: rgba(255, 255, 255, .92);
  --line: rgba(15, 28, 44, .13);
  --text: #101820;
  --muted: #5d7188;
  --shadow: 0 24px 70px rgba(29, 59, 93, .15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 14% 10%, rgba(81, 214, 255, .23), transparent 32%),
    radial-gradient(circle at 92% 18%, rgba(255, 107, 138, .22), transparent 28%),
    linear-gradient(145deg, var(--bg), var(--bg-2));
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

code {
  color: var(--amber);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 calc(30px + var(--safe-bottom));
}

.hero {
  min-height: 72vh;
  display: grid;
  align-content: center;
  gap: 20px;
  padding: 10px 0 28px;
}

.topbar {
  position: fixed;
  left: 14px;
  right: 14px;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.back-link,
.theme-toggle,
.search-panel,
.now-card,
.library,
.insight-grid article,
.track-card,
.toast {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.back-link,
.theme-toggle {
  pointer-events: auto;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.theme-toggle {
  border: 1px solid var(--line);
}

.hero-content {
  max-width: 780px;
  padding-top: 64px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(86, 240, 170, .34);
  background: rgba(86, 240, 170, .1);
  color: var(--green);
  font-weight: 850;
  font-size: 13px;
}

.live-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(86, 240, 170, .7);
  animation: pulse 1.8s infinite;
}

.hero h1 {
  margin: 16px 0 10px;
  max-width: 820px;
  font-size: clamp(42px, 9vw, 88px);
  line-height: .92;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  max-width: 660px;
  color: var(--muted);
  font-size: clamp(16px, 2.8vw, 20px);
  line-height: 1.6;
}

.search-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
}

.search-panel label {
  display: grid;
  gap: 7px;
}

.search-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.search-panel input {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .08);
  color: var(--text);
  outline: none;
  padding: 0 14px;
}

.search-panel input:focus {
  border-color: rgba(81, 214, 255, .58);
  box-shadow: 0 0 0 4px rgba(81, 214, 255, .12);
}

.search-panel button,
.player-controls button,
.tabs button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .09);
  color: var(--text);
  min-height: 44px;
  padding: 0 14px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.search-panel button {
  align-self: end;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  color: #101820;
  border-color: transparent;
}

button:hover,
.track-card:hover {
  transform: translateY(-2px);
  border-color: rgba(81, 214, 255, .5);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.insight-grid article {
  padding: 15px;
}

.insight-grid strong {
  display: block;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1;
}

.insight-grid span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
}

.content-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
  align-items: start;
}

.now-card,
.library {
  padding: 14px;
}

.now-card {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 14px;
}

.disc {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(16, 24, 32, .9) 0 16%, transparent 17%),
    conic-gradient(from 90deg, var(--cyan), var(--rose), var(--amber), var(--green), var(--cyan));
  box-shadow: inset 0 0 0 16px rgba(255, 255, 255, .08), 0 22px 70px rgba(81, 214, 255, .12);
  animation: spin 9s linear infinite paused;
}

.disc.playing {
  animation-play-state: running;
}

.disc span {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: #101820;
  font-size: 28px;
  font-weight: 950;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.now-card h2,
.library h2 {
  margin: 0;
  letter-spacing: 0;
}

#nowArtist {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.player-controls {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
}

.player-controls .primary {
  background: linear-gradient(135deg, var(--rose), var(--amber));
  color: #101820;
  border-color: transparent;
}

.progress-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input[type="range"] {
  accent-color: var(--green);
}

.library-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tabs button.active {
  background: var(--panel-strong);
  color: var(--green);
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.track-card {
  min-height: 132px;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  padding: 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.cover {
  position: relative;
  min-height: 84px;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, rgba(81, 214, 255, .36), rgba(255, 107, 138, .28));
}

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

.cover span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: 26px;
  font-weight: 950;
}

.track-info {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 6px;
}

.track-info strong,
.track-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-info span {
  color: var(--muted);
  font-size: 13px;
}

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

.track-meta em {
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(255, 255, 255, .08);
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.empty-state {
  display: none;
  min-height: 210px;
  place-items: center;
  text-align: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.empty-state.show {
  display: grid;
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p {
  margin: 0;
  line-height: 1.55;
}

.skeleton {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(100deg, rgba(255, 255, 255, .06) 20%, rgba(255, 255, 255, .16) 36%, rgba(255, 255, 255, .06) 52%);
  background-size: 220% 100%;
  animation: shimmer 1.1s linear infinite;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 30;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  color: var(--text);
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 12px rgba(86, 240, 170, 0); }
  100% { box-shadow: 0 0 0 0 rgba(86, 240, 170, 0); }
}

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

@keyframes shimmer {
  to { background-position-x: -220%; }
}

@media (max-width: 900px) {
  .hero {
    min-height: auto;
    padding-top: 74px;
  }

  .content-layout {
    grid-template-columns: 1fr;
  }

  .now-card {
    position: relative;
    top: auto;
    grid-template-columns: 110px 1fr;
    align-items: center;
  }

  .disc {
    width: 110px;
  }

  .player-controls,
  .progress-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 520px);
  }

  .hero h1 {
    font-size: clamp(40px, 13vw, 60px);
  }

  .search-panel,
  .insight-grid,
  .track-grid {
    grid-template-columns: 1fr;
  }

  .search-panel button {
    min-height: 46px;
  }

  .library-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs button {
    flex: 1;
  }

  .track-card {
    grid-template-columns: 72px 1fr;
  }

  .cover {
    min-height: 72px;
  }

  .toast {
    left: 12px;
    right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
