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

:root {
  --bg: #0d0d14;
  --surface: #16161f;
  --surface2: #1e1e2a;
  --border: rgba(255,255,255,0.08);
  --accent: #7c5cfc;
  --accent2: #c084fc;
  --gold: #f5c842;
  --silver: #b0bec5;
  --bronze: #cd7f32;
  --text: #f0f0f5;
  --text-muted: #8888aa;
  --radius: 16px;
  --transition: 0.2s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 60% at 20% 0%, rgba(124,92,252,0.18) 0%, transparent 60%),
              radial-gradient(ellipse 60% 50% at 80% 100%, rgba(192,132,252,0.12) 0%, transparent 60%);
}

header, main, footer {
  position: relative;
  z-index: 1;
}

header {
  padding: 2.5rem 2rem 1.5rem;
  text-align: center;
}

.header-inner {
  max-width: 700px;
  margin: 0 auto;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
  line-height: 1;
}

.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-text em {
  font-style: italic;
}

.tagline {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
}

main {
  flex: 1;
  padding: 0 1rem 4rem;
}

.picker-section {
  display: flex;
  justify-content: center;
  margin-bottom: 3rem;
}

.picker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.picker-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent2);
  margin-bottom: 1rem;
}

.picker-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

#date-input {
  font-family: 'Inter', sans-serif;
  font-size: 1.05rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1.5px solid rgba(124,92,252,0.35);
  background: var(--surface2);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  flex: 1;
  max-width: 230px;
}

#date-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,252,0.25);
}

#date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.go-btn {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1.6rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 16px rgba(124,92,252,0.4);
}

.go-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124,92,252,0.5);
}

.go-btn:active {
  transform: translateY(0);
}

.picker-hint {
  margin-top: 0.9rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chart-section {
  max-width: 780px;
  margin: 0 auto;
}

.chart-section.hidden { display: none; }

.chart-header {
  text-align: center;
  margin-bottom: 2rem;
}

.chart-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent2);
  border: 1px solid rgba(192,132,252,0.4);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  margin-bottom: 0.75rem;
}

.chart-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.chart-subtitle {
  margin-top: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.loading.hidden { display: none; }

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(124,92,252,0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.error-msg {
  text-align: center;
  padding: 2rem;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius);
  color: #f87171;
  font-size: 0.95rem;
  line-height: 1.6;
}

.error-msg.hidden { display: none; }

.song-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.song-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1.2rem;
  transition: background var(--transition), transform var(--transition), border-color var(--transition);
  animation: fadeInUp 0.3s ease both;
}

.song-item:hover {
  background: var(--surface2);
  border-color: rgba(124,92,252,0.3);
  transform: translateX(4px);
}

.song-item:nth-child(n) { animation-delay: calc(var(--i, 0) * 30ms); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.song-rank {
  min-width: 2.4rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.song-item:nth-child(1) .song-rank { color: var(--gold); font-size: 1.1rem; }
.song-item:nth-child(2) .song-rank { color: var(--silver); }
.song-item:nth-child(3) .song-rank { color: var(--bronze); }

/* Divider between the Top 40 and #41–#100 */
.chart-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0 0.7rem;
  list-style: none;
}

.chart-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245, 200, 66, 0.5), transparent);
}

.chart-divider-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex-shrink: 0;
}

.chart-divider-top {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold);
  white-space: nowrap;
}

.chart-divider-sub {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-top: 0.2rem;
  white-space: nowrap;
}

.song-album-art {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}

.song-album-art-placeholder {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--surface2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.song-info {
  flex: 1;
  min-width: 0;
}

.song-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artist-link {
  display: block;
  max-width: 100%;
  font-family: inherit;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color var(--transition);
}

.artist-link:hover {
  color: var(--accent2);
  text-decoration: underline;
}

.song-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}

.song-weeks {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.song-peak {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.peak-1 {
  color: var(--gold);
  font-weight: 600;
}

.song-movement {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  min-width: 3.2rem;
  text-align: center;
}

.move-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.4;
}

.move-up {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
}

.move-down {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.move-new {
  color: var(--gold);
  background: rgba(245, 200, 66, 0.15);
  letter-spacing: 0.5px;
}

.move-same {
  color: var(--text-muted);
}

.move-weeks {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.song-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #aaa;
  background: transparent;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}

.spotify-btn:hover {
  color: #1db954;
  background: rgba(29, 185, 84, 0.12);
}

.yt-btn:hover {
  color: #ff0000;
  background: rgba(255, 0, 0, 0.1);
}

.wiki-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.artist-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.artist-modal-overlay.open { display: flex; }

.artist-modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.artist-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition);
}

.artist-modal-close:hover { color: var(--text); }

.artist-modal-body .ah-header {
  text-align: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.2rem;
}

.artist-modal-body .ah-artist {
  font-family: 'Playfair Display', serif;
  font-size: 1.7rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.artist-modal-body .ah-summary {
  color: var(--accent2);
  font-size: 0.85rem;
  margin-top: 0.4rem;
  font-weight: 600;
}

.artist-modal-body .ah-hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

.artist-modal-body .ah-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.artist-modal-body .ah-song {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.artist-modal-body .ah-song-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.artist-modal-body .ah-song-title { font-weight: 600; font-size: 0.98rem; }

.artist-modal-body .ah-song-peak {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.artist-modal-body .ah-weeks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.artist-modal-body .ah-week {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  transition: all 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
}

.artist-modal-body .ah-week:hover {
  color: #fff;
  border-color: rgba(124, 92, 252, 0.5);
  background: rgba(124, 92, 252, 0.18);
}

.artist-modal-body .ah-song-stats {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0.35rem;
}

.artist-modal-body .ah-song-links {
  display: flex;
  gap: 0.15rem;
  margin-bottom: 0.4rem;
}

.artist-modal-body .ah-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: #888;
  text-decoration: none;
  background: transparent;
  transition: color var(--transition), background var(--transition);
}

.artist-modal-body .ah-spotify:hover { color: #1db954; background: rgba(29, 185, 84, 0.12); }
.artist-modal-body .ah-yt:hover { color: #f00; background: rgba(255, 0, 0, 0.1); }
.artist-modal-body .ah-wiki:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }

.artist-modal-body .ah-album {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.1rem 0 0.45rem;
  font-size: 0.74rem;
}

.artist-modal-body .ah-album-tag {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.6rem;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.artist-modal-body .ah-album-link {
  color: var(--accent2);
  text-decoration: none;
  border: 1px solid rgba(192, 132, 252, 0.35);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.68rem;
  transition: all 0.15s ease;
}

.artist-modal-body .ah-album-link:hover { background: rgba(192, 132, 252, 0.18); color: #fff; }

.artist-modal-body .ah-album-name { font-weight: 600; color: var(--text); font-size: 0.76rem; }
.artist-modal-body .ah-album-loading,
.artist-modal-body .ah-album-unknown { color: var(--text-muted); font-weight: 400; font-style: italic; }

.artist-modal-body .ah-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

.artist-modal-body .ah-bio-section {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.artist-modal-body .ah-artist-thumb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.artist-modal-body .ah-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.artist-modal-body .ah-thumb-fallback {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent2);
}

.artist-modal-body .ah-allmusic-btn {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent2);
  text-decoration: none;
  border: 1px solid rgba(192, 132, 252, 0.35);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  transition: all 0.15s ease;
}

.artist-modal-body .ah-allmusic-btn:hover { background: rgba(192, 132, 252, 0.15); color: #fff; }

footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 540px) {
  .picker-card { padding: 1.5rem 1.25rem; }
  .picker-row { flex-direction: column; }
  #date-input { max-width: 100%; width: 100%; }
  .go-btn { width: 100%; }
  .chart-title { font-size: 1.5rem; }
  .song-meta { display: none; }
  .song-album-art, .song-album-art-placeholder { width: 38px; height: 38px; }
  .song-item { gap: 0.6rem; padding: 0.75rem 0.85rem; }
  .song-links { gap: 0.1rem; }
  .icon-btn { width: 30px; height: 30px; }
}
