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

:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface2: #282828;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --text: #ffffff;
  --text-secondary: #b3b3b3;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

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

header h1 {
  font-size: 2rem;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

/* ---- Spotify Auth ---- */
.spotify-auth {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  justify-content: flex-end;
}

.spotify-login-btn {
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: 20px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
}

.spotify-login-btn:hover {
  background: var(--accent-hover);
}

.spotify-user {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}

.spotify-logout-btn {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--surface2);
  border-radius: 14px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.spotify-logout-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text);
}

/* ---- Mode Toggle ---- */
.mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--surface2);
  width: fit-content;
}

.mode-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  color: #000;
}

.view-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--surface2);
  width: fit-content;
}

.view-btn {
  padding: 0.45rem 0.95rem;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.view-btn.active {
  background: var(--surface2);
  color: var(--text);
}

/* ---- Audio Weight Sliders ---- */
.audio-weights {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.weights-heading {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}

.weights-heading .hint {
  font-weight: 400;
  font-size: 0.78rem;
  opacity: 0.6;
}

.weight-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.weight-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.weight-row label {
  min-width: 110px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.weight-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.weight-val {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  min-width: 2.8rem;
  text-align: right;
}

/* ---- Audio Feature Badges ---- */
.af-badge {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--text-secondary);
  background: var(--surface2);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  margin-right: 0.2rem;
  margin-top: 0.15rem;
  white-space: nowrap;
}

.seed-audio-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.seed-audio-features .af-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  color: var(--accent);
}

.drill-panel {
  margin-top: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}

.drill-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.crumb-btn {
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text-secondary);
  padding: 0.25rem 0.55rem;
  font-size: 0.76rem;
  cursor: pointer;
}

.crumb-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

.drill-profile {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ---- Form ---- */
.input-row {
  display: flex;
  gap: 0.5rem;
}

#track-url {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#track-url:focus {
  border-color: var(--accent);
}

#search-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#search-btn:hover {
  background: var(--accent-hover);
}

#search-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.limit-row {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.limit-row select {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--surface2);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

/* ---- Seed Track ---- */
.seed-track {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 4px solid var(--accent);
}

.seed-track img {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  object-fit: cover;
}

.seed-meta h2 {
  font-size: 1.1rem;
}

.seed-meta h2 a {
  color: var(--text);
  text-decoration: none;
}

.seed-meta h2 a:hover {
  text-decoration: underline;
  color: var(--accent);
}

.seed-meta .artists {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.seed-bpm {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--surface2);
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
}

.seed-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.seed-tag {
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--surface2);
  padding: 0.12rem 0.4rem;
  border-radius: 10px;
}

/* ---- Filter Panel ---- */
.filter-panel {
  margin-top: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.filter-panel summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.filter-panel summary:hover {
  color: var(--text);
}

/* BPM filter */
.bpm-filter {
  margin-top: 0.75rem;
}

.bpm-filter > label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.bpm-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bpm-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

#bpm-label {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  min-width: 3.5rem;
  text-align: right;
}

/* Tag filter */
.tag-filter {
  margin-top: 0.75rem;
}

.tag-filter > label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.tag-filter .hint {
  font-weight: 400;
  font-size: 0.8rem;
  opacity: 0.6;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.quick-filter-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 14px;
  border: 1px solid var(--surface2);
  background: var(--surface2);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.quick-filter-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: transparent;
}

.tag-sections {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tag-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tag-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-chip {
  background: var(--surface2);
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tag-chip:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.tag-chip.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
  border-color: var(--accent);
}

/* ---- Approximation Notice ---- */
.approx-notice {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--surface);
  border-left: 3px solid #f0ad4e;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

/* ---- Results ---- */
.results {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.results h3 {
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.track-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  transition: background 0.15s;
}

.track-card:hover {
  background: var(--surface2);
}

.track-card img {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
}

.img-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  background: var(--surface2);
}

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

.track-info .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-info .name a {
  color: var(--text);
  text-decoration: none;
}

.track-info .name a:hover {
  text-decoration: underline;
  color: var(--accent);
}

.track-info .detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.25rem;
}

.track-tag {
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--surface2);
  padding: 0.1rem 0.35rem;
  border-radius: 8px;
}

/* ---- Badges ---- */
.track-badges {
  flex-shrink: 0;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.match-badge {
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.bpm-badge {
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

/* ---- Track Actions ---- */
.track-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.play-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 1.3rem;
  padding: 0.25rem;
  line-height: 1;
}

.play-btn:hover {
  color: var(--accent-hover);
}

.queue-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.18rem 0.42rem;
  line-height: 1.1;
  cursor: pointer;
  transition: all 0.15s;
}

.queue-btn:hover {
  background: var(--accent);
  color: #000;
}

.queue-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.drill-btn {
  background: transparent;
  border: 1px solid var(--text-secondary);
  color: var(--text-secondary);
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.18rem 0.42rem;
  line-height: 1.1;
  cursor: pointer;
  transition: all 0.15s;
}

.drill-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.spotify-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  opacity: 0.7;
  transition: opacity 0.15s;
  padding: 0.2rem;
}

.spotify-btn:hover {
  opacity: 1;
}

/* ---- Actions Bar (playlist / queue) ---- */
.actions-bar {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover {
  background: var(--accent);
  color: #000;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-status {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.action-status a {
  color: var(--accent);
  text-decoration: none;
}

.action-status a:hover {
  text-decoration: underline;
}

/* ---- Discover More ---- */
.discover-more-btn {
  display: block;
  margin: 1.25rem auto 0;
  padding: 0.6rem 1.6rem;
  border: 2px solid var(--accent);
  border-radius: 24px;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.discover-more-btn:hover {
  background: var(--accent);
  color: #000;
}

/* ---- States ---- */
.hidden {
  display: none !important;
}

.loading {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.error {
  margin-top: 1.5rem;
  background: #3b1219;
  border: 1px solid #f44;
  color: #f88;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .track-badges {
    display: none;
  }

  .input-row {
    flex-direction: column;
  }

  .tag-chips {
    max-height: 120px;
    overflow-y: auto;
  }
}
