:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  /* Lightened from #484f58 (~2.3:1) to clear WCAG 1.4.3 (4.5:1) — this
     colour carries real information (dates, counts, notices). */
  --text-muted: #7d8590;
  --accent: #58a6ff;
  --accent-green: #3fb950;
  --accent-orange: #d29922;
  --accent-red: #f85149;
  --accent-purple: #bc8cff;
  --border: #30363d;
  --radius: 8px;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); }

/* ─── ACCESSIBILITY UTILITIES ─── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Visible keyboard-focus indicator app-wide (2.4.7). */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.error-boundary {
  max-width: 480px;
  margin: 80px auto;
  text-align: center;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-red);
  border-radius: 12px;
  padding: 32px;
}
.error-boundary h2 { margin-bottom: 12px; }
.error-boundary p { color: var(--text-secondary); margin-bottom: 20px; }
.error-boundary button {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
}

/* ─── LANDING ─── */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #0d1a2e 0%, #0d1117 60%);
}

.landing-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px;
  max-width: 460px;
  width: 90%;
  text-align: center;
}

.landing-logo {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.landing-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 24px;
}

.landing-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
  line-height: 1.7;
}

.landing-card form {
  text-align: left;
}

.landing-card label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 16px;
}

.landing-card input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
}

.landing-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.landing-card button {
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.landing-card button:hover { opacity: 0.9; }
.landing-card button:disabled { opacity: 0.5; cursor: not-allowed; }

.landing-hint {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── HEADER ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 1.3rem;
  color: var(--accent);
}

.logo-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.user-badge {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 12px;
  border-radius: 20px;
}

.prefetch-bar-container {
  height: 4px;
  background: var(--bg-tertiary);
  position: relative;
  overflow: visible;
}

.prefetch-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-orange), var(--accent));
  transition: width 0.3s ease;
  border-radius: 0 2px 2px 0;
}

.prefetch-bar-label {
  position: absolute;
  right: 12px;
  top: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

@keyframes prefetchPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav button,
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
}

.nav button:hover,
.nav a:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav a.active { background: var(--bg-tertiary); color: var(--accent); border-color: var(--accent); }

.logout-btn {
  color: var(--accent-red) !important;
}

/* ─── MAIN ─── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.page-header h2 {
  margin-bottom: 0;
}

.clear-cache-btn {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-cache-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.page h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.page-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.loading {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.progress-bar-container {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  margin: 16px auto 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-bar-indeterminate {
  width: 30% !important;
  animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.progress {
  color: var(--accent);
  font-size: 0.9rem;
  margin: 12px 0;
  text-align: center;
}

.no-results {
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

/* ─── STATS ─── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 24px 0 32px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ─── ARTIST GRID ─── */
.artist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.artist-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  position: relative;
  transition: border-color 0.2s;
}

.artist-card:hover { border-color: var(--accent); }

.rank {
  position: absolute;
  top: -6px;
  left: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.artist-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.artist-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

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

.artist-info strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playcount {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.lost-tag {
  font-size: 0.75rem;
  color: var(--accent-orange);
}

.lost-date {
  font-size: 0.75rem;
  color: var(--accent-orange);
}

.artist-card.lost { border-color: var(--accent-orange); }

.artist-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: 4px;
}

.action-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.action-link:hover {
  background: var(--accent);
}

/* ─── SEARCH ─── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
}

.search-bar input:focus { outline: none; border-color: var(--accent); }

.search-bar-with-suggestions {
  align-items: flex-start;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--bg-tertiary);
}

.suggestion-unlistened {
  opacity: 0.5;
}

.suggestion-check {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--accent-green);
}

.suggestion-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.suggestion-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.search-history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.history-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.history-chip {
  padding: 4px 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.history-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.search-bar button {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.search-bar button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── RESULT ─── */
.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-top: 16px;
}

.result-card h3 { margin-bottom: 20px; font-size: 1.3rem; }

.result-card.error {
  border-color: var(--accent-red);
}

.first-play-details {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.result-img {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  object-fit: cover;
}

.result-info { flex: 1; }

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child { border-bottom: none; }

.result-row .label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.result-row .value {
  font-weight: 600;
  text-align: right;
}

.result-row .date { color: var(--accent); }

.result-row.highlight .value {
  color: var(--accent-green);
  font-size: 1.1rem;
}

/* ─── HEATMAP ─── */
.heatmap-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  overflow-x: auto;
}

.heatmap-year {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.heatmap-year-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.heatmap-year-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.heatmap-year-total {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.heatmap-body {
  display: flex;
  gap: 4px;
}

.heatmap-months {
  display: flex;
  margin-bottom: 8px;
  margin-left: 40px;
}

.heatmap-months span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.heatmap-grid {
  display: flex;
  gap: 4px;
}

.heatmap-labels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 6px;
}

.day-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  height: 13px;
  line-height: 13px;
}

.heatmap-weeks {
  display: flex;
  gap: 3px;
}

.heatmap-week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.heatmap-day {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  padding: 0;
  border: none;
  appearance: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.heatmap-day:hover { opacity: 0.8; }
.heatmap-day:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 1px; }

.heatmap-tooltip {
  position: fixed;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  pointer-events: none;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
  white-space: nowrap;
  transform: translate(-50%, -100%);
}

.heatmap-tooltip strong {
  color: var(--text-primary);
}

.heatmap-tooltip span {
  color: var(--text-secondary);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.heatmap-legend div {
  width: 13px;
  height: 13px;
  border-radius: 2px;
}

/* ─── YEAR SELECTOR ─── */
.year-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.year-selector span {
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
}

.year-selector button {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.year-selector button:disabled { opacity: 0.4; cursor: not-allowed; }

.year-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
  justify-content: center;
}

.year-pill {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.year-pill:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--accent);
}

.year-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.year-pill.current {
  border-color: var(--accent-green);
}

/* ─── YEAR REVIEW ─── */
.year-review h3 { margin: 24px 0 12px; }

.track-list { display: flex; flex-direction: column; gap: 8px; }

.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  position: relative;
}

.track-info {
  flex: 1;
}

.track-info strong { display: block; font-size: 0.95rem; }

.track-artist {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ─── COMPARE ─── */
.compare-results { margin-top: 24px; }

.compare-section { margin-bottom: 24px; }

.compare-section h3 { margin-bottom: 12px; }

.compare-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.compare-column h3 { margin-bottom: 12px; }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.tag.shared {
  background: rgba(63, 185, 80, 0.15);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.tag.only1 {
  background: rgba(88, 166, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.tag.only2 {
  background: rgba(188, 140, 255, 0.15);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin: 16px 0 24px;
}

.friend-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.friend-card:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.friend-card.active {
  border-color: var(--accent-green);
  background: rgba(63, 185, 80, 0.08);
}

.friend-letter {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.friend-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

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

.friend-info strong {
  display: block;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-info .playcount {
  font-size: 0.7rem;
}

.friend-compare-icon {
  font-size: 0.9rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.friend-card:hover .friend-compare-icon {
  opacity: 1;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .header { flex-direction: column; align-items: stretch; }
  /* Single scrollable row instead of a tall wrapped block. */
  .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .nav button,
  .nav a { flex: 0 0 auto; }
  .first-play-details { flex-direction: column; align-items: center; }
  .compare-split { grid-template-columns: 1fr; }
  .artist-grid { grid-template-columns: 1fr; }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .progress-bar-indeterminate { animation: none; width: 100% !important; opacity: 0.6; }
}

/* ─── LIBRARY ─── */
.library-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.library-search {
  flex: 1;
  min-width: 200px;
}

.library-search input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.library-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.library-sort {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
}

.library-sort:focus {
  outline: none;
  border-color: var(--accent);
}

.library-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.library-item:hover {
  border-color: var(--accent);
}

.library-item-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.library-item-info {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.library-item-info strong {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-item-info .playcount {
  flex-shrink: 0;
}

.library-more {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 16px;
  padding: 12px;
}

/* ─── TIMELINE ─── */
.build-btn {
  display: block;
  margin: 32px auto;
  padding: 14px 32px;
  font-size: 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.build-btn:hover {
  opacity: 0.85;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.timeline-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.rebuild-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.rebuild-btn:hover {
  background: var(--bg-tertiary);
}

.timeline-list {
  max-width: 640px;
  margin: 0 auto;
}

.timeline-item {
  display: flex;
  gap: 16px;
  min-height: 60px;
}

.timeline-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 14px;
  flex-shrink: 0;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 4px;
}

.timeline-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin: 4px 0;
}

.timeline-content {
  padding-bottom: 24px;
  flex: 1;
}

.timeline-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.timeline-artist {
  font-size: 1.05rem;
}

.timeline-playcount {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.timeline-date {
  font-size: 0.9rem;
  color: var(--accent);
}

.timeline-years {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.timeline-track {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.error-msg {
  color: #e74c3c;
  text-align: center;
  margin-top: 24px;
}

/* ─── FIRST-SCROBBLE INDEX BANNER ─── */
.index-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 4px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.index-banner .progress-bar-container { margin: 0; flex: 1; min-width: 160px; }
.index-link {
  padding: 5px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.index-link:hover { opacity: 0.9; }
.index-stale { color: var(--accent-orange); }
.index-error { color: var(--accent-red); }

.index-chip {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.index-chip.error { color: var(--accent-orange); border-color: var(--accent-orange); }

/* ─── LIBRARY SEARCH RESULTS ─── */
.search-section { margin-top: 20px; }
.search-section h3 { margin-bottom: 10px; }
.search-list { display: flex; flex-direction: column; gap: 2px; }
.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
  transition: border-color 0.2s;
}
button.search-row { cursor: pointer; }
button.search-row:hover { border-color: var(--accent); }
.search-row-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}
.search-row-note { display: flex; align-items: center; justify-content: center; color: var(--accent); }
.search-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search-row-info strong { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-row-sub { font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-row-cta { color: var(--text-muted); flex-shrink: 0; }

/* ─── INDEX GATE (blocks the app until the index is loaded) ─── */
.index-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #0d1a2e 0%, #0d1117 60%);
  padding: 24px;
}
.gate-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  max-width: 480px;
  width: 100%;
  text-align: center;
}
.gate-logo { font-size: 2rem; margin-bottom: 16px; }
.gate-card h2 { font-size: 1.3rem; margin-bottom: 10px; }
.gate-sub { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 24px; line-height: 1.6; }
.gate-card .progress-bar-container { margin: 0 auto; }
.gate-pct { color: var(--accent); font-size: 0.85rem; margin-top: 12px; }
.gate-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.gate-logout {
  padding: 8px 16px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}
.gate-logout:hover { color: var(--text-primary); border-color: var(--accent); }
