/* ============================================
   Vibecheck — Design System v2
   Apple Music-inspired dark UI
   ============================================ */

/* ---- 1. CSS Custom Properties ---- */
:root {
  /* Backgrounds */
  --bg-main:    #0a0a0a;
  --bg-sidebar: #0e0e0e;
  --bg-card:    #111111;

  /* Borders */
  --border-soft: #1a1a1a;
  --border-mid:  #222222;

  /* Text */
  --text-primary:   #ffffff;
  --text-body:      #cccccc;
  --text-secondary: #888888;
  --text-tertiary:  #555555;
  --text-dim:       #444444;

  /* Accent */
  --accent:       #fc3c44;
  --accent-hover: #ff5a60;
  --accent-subtle: rgba(252, 60, 68, 0.12);

  /* Tags */
  --tag-text:   #aaaaaa;
  --tag-bg:     #1a1a1a;
  --tag-border: #252525;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;

  /* Layout */
  --sidebar-width: 220px;
  --tab-height:     48px;
  --pill-height:    52px;

  /* Z-index */
  --z-sidebar: 50;
  --z-pill:   100;
  --z-tabbar: 100;
  --z-overlay: 200;

  /* Transitions */
  --transition: 0.2s ease;
}

/* ---- 2. Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  font-size: 13px;
  background: var(--bg-main);
  color: var(--text-body);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input {
  font-family: inherit;
}

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

/* ---- 3. Utility Classes ---- */
.hidden {
  display: none !important;
}

.status-msg {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  gap: 8px;
}

.empty-state svg,
.empty-state .empty-icon {
  opacity: 0.3;
  margin-bottom: 4px;
}

/* Instant session-based visibility (no JS delay) */
.has-session #connect-screen { display: none !important; }
.has-session #app { display: flex !important; }

/* ---- 4. Overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  max-width: 360px;
  padding: 32px 24px;
  width: 100%;
}

/* Brand inside overlays */
.overlay .brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.overlay .brand span {
  color: var(--accent);
}

.overlay p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 280px;
}

/* Overlay heading */
.overlay h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Connect overlay */
#overlay-connect .overlay-content {
  gap: 16px;
}

/* Indexing overlay */
#overlay-indexing .overlay-content,
#overlay-analysis .overlay-content {
  gap: 16px;
}

/* Progress inside overlays */
.overlay .progress-wrap {
  width: 100%;
  margin-bottom: 0;
}

/* ---- 5. Progress Bars ---- */
.progress-wrap {
  margin-bottom: 16px;
  width: 100%;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--border-soft);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* ---- 6. Buttons ---- */
.btn-connect {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn-connect:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
}

.btn-connect:active {
  transform: scale(0.98);
}

.btn-connect svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-connect-spotify {
  background: #1DB954;
  color: #fff;
}
.btn-connect-spotify:hover {
  background: #1ed760;
}

.connect-divider {
  color: var(--text-dim, #666);
  font-size: 0.85rem;
  margin: 12px 0;
  text-transform: lowercase;
}

.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-primary-sm:hover {
  background: var(--accent-hover);
}

.btn-primary-sm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--bg-card);
  color: var(--text-body);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

.btn-sm:hover {
  background: #1a1a1a;
  border-color: #333;
  color: var(--text-primary);
}

.btn-sm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.btn-clear {
  color: var(--text-tertiary);
  border-color: var(--border-soft);
}
.btn-clear:hover {
  color: #ff3b30;
  border-color: rgba(255, 59, 48, 0.4);
}

/* ---- 7. App Shell ---- */
#app {
  display: flex;
  min-height: 100vh;
}

/* ---- 8. Sidebar ---- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow: hidden;
}

.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.sidebar-brand .brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-brand .brand span {
  color: var(--accent);
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: left;
  width: 100%;
  border: none;
  background: none;
  position: relative;
  text-decoration: none;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-body);
}

.nav-item:hover svg {
  opacity: 0.8;
}

.nav-item.active {
  background: rgba(252, 60, 68, 0.1);
  color: var(--accent);
}

.nav-item.active svg {
  opacity: 1;
  color: var(--accent);
}

/* Sidebar badge */
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 980px;
  padding: 1px 6px;
  line-height: 1.5;
  flex-shrink: 0;
}

/* Sidebar section label */
.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 10px 4px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 10px;
  color: var(--text-dim);
  padding: 4px 10px;
  line-height: 1.5;
}

.sidebar-stat {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 0 16px;
  margin-bottom: 4px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 0 16px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4caf50;
  flex-shrink: 0;
}

/* ---- 9. Main Content ---- */
#main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-bottom: calc(var(--pill-height) + 24px);
  min-height: 100vh;
  min-width: 0;
}

/* ---- 10. Views ---- */
.view {
  display: none;
  padding: 20px 20px 0;
  min-height: calc(100vh - var(--pill-height) - 24px);
}

.view.active {
  display: block;
  animation: viewFadeIn 0.15s ease;
}

@keyframes viewFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Section headers inside views */
.view-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* ---- 11. Queue Toolbar ---- */
.view-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Vibe input */
.vibe-input {
  flex: 1;
  max-width: 280px;
  padding: 7px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
}

.vibe-input::placeholder {
  color: var(--text-tertiary);
}

.vibe-input:focus {
  border-color: #333;
}

/* Vibe preset chips */
.vibe-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 8px;
  overflow: hidden;
}

.vibe-row-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.vibe-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}

.vibe-chips::-webkit-scrollbar {
  display: none;
}

.vibe-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.vibe-chip:hover {
  border-color: var(--border-mid);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.vibe-chip:active {
  transform: scale(0.96);
}

.vibe-chip.loading {
  border-color: var(--accent);
  color: var(--accent);
  opacity: 0.8;
  pointer-events: none;
}

.vibe-chip-loves {
  border-color: rgba(255, 45, 85, 0.3);
  color: #ff2d55;
  font-weight: 500;
}

.vibe-chip-loves:hover {
  border-color: rgba(255, 45, 85, 0.5);
  background: rgba(255, 45, 85, 0.08);
  color: #ff2d55;
}

.vibe-chip-loves:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.vibe-chip-recent {
  border-style: dashed;
  border-color: var(--border-soft);
}

.vibe-chip-recent:hover {
  border-style: solid;
}

/* Mode bar (Library / Vibe tabs) */

.mode-bar {
  padding: 10px 12px 6px;
  overflow: hidden;
}

.mode-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}

.mode-chips::-webkit-scrollbar {
  display: none;
}

.mode-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.mode-chip:hover {
  border-color: var(--border-mid);
  color: var(--text-primary);
}

.mode-chip.active {
  background: var(--text-primary);
  color: var(--bg-main);
  border-color: var(--text-primary);
  font-weight: 500;
}

.mode-chip-loves {
  border-color: rgba(255, 45, 85, 0.3);
  color: #ff2d55;
}

.mode-chip-loves:hover {
  border-color: rgba(255, 45, 85, 0.5);
}

.mode-chip-loves.active {
  background: #ff2d55;
  border-color: #ff2d55;
  color: #fff;
}

.mode-chip-loves:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* Recent vibes row */
.recent-vibes {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.recent-vibes::-webkit-scrollbar { display: none; }
.recent-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.recent-vibes-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.recent-vibes-chips::-webkit-scrollbar { display: none; }
.mode-chip-recent {
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px dashed var(--border-soft);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.mode-chip-recent.has-results {
  border-style: solid;
  border-color: var(--border-mid);
  color: var(--text-primary);
}
.mode-chip-recent:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.mode-chip-recent.active {
  background: var(--accent);
  border-style: solid;
  border-color: var(--accent);
  color: #fff;
}

/* Vibe mode loading */

.vibe-mode-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Filter dropdown wrapper */
.filter-wrap {
  position: relative;
}

.filter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #161616;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 140px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.filter-dropdown label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text-body);
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition);
}

.filter-dropdown label:hover {
  background: rgba(255,255,255,0.05);
}

.filter-dropdown input[type="checkbox"] {
  accent-color: var(--accent);
}

.show-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.show-filter select {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-body);
  font-size: 11px;
  padding: 4px 8px;
}

/* ---- 12. Song List & Rows ---- */
.song-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  cursor: default;
}

.song-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Artwork */
.row-artwork {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

.row-artwork img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-sm) - 1px);
}

.artwork-placeholder {
  width: 42px;
  height: 42px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Row info */
.row-info {
  flex: 1;
  min-width: 0;
}

.row-song {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.row-artist {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.row-meta {
  font-size: 9px;
  color: var(--text-tertiary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row timestamp */
.row-time {
  font-size: 9px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Play button — larger, between artwork and info */
.row-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.row-play:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}
.row-play svg {
  margin-left: 2px; /* optical center for play triangle */
}
.row-play.now-playing {
  color: var(--accent);
  position: relative;
}
.row-play.now-playing .play-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.row-play.now-playing .play-ring circle {
  fill: none;
  stroke-width: 2.5;
}
.row-play.now-playing .play-ring .ring-bg {
  stroke: rgba(255, 255, 255, 0.1);
}
.row-play.now-playing .play-ring .ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s linear;
}

/* Artist line with secondary actions */
.row-artist-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.row-secondary {
  display: flex;
  gap: 0;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.song-row:hover .row-secondary {
  opacity: 1;
}
@media (hover: none) {
  .row-secondary { opacity: 0.7; }
}
.row-link {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  padding: 0 5px;
  white-space: nowrap;
  border-right: 1px solid var(--border-soft);
  transition: color 0.15s;
}
.row-link:last-child { border-right: none; }
.row-link:hover { color: var(--text-secondary); }
.row-link-block:hover { color: #ff3b30; }

/* "Heard It" inline confirmation */
.row-secondary.confirming {
  opacity: 1 !important;
  gap: 4px;
}
.row-link-prompt {
  font-size: 11px;
  color: var(--text-secondary);
  padding-right: 4px;
  white-space: nowrap;
}
.row-link-confirm {
  font-size: 14px;
  padding: 2px 8px;
  border-right: none !important;
  transition: transform 0.1s;
}
.row-link-confirm:hover {
  transform: scale(1.2);
  color: var(--text-primary);
}

/* Row actions */
.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.row-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-mid);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.row-btn svg {
  width: 13px;
  height: 13px;
}

.row-btn:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text-primary);
  border-color: #333;
}

.row-btn.liked {
  background: rgba(52, 199, 89, 0.15);
  border-color: rgba(52, 199, 89, 0.4);
  color: #34c759;
}

.row-btn.disliked {
  background: rgba(255, 69, 58, 0.15);
  border-color: rgba(255, 69, 58, 0.4);
  color: #ff453a;
}

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

.row-btn.play-btn:hover {
  background: var(--accent-subtle);
}

/* Row score/confidence badge */
.row-score {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 980px;
  flex-shrink: 0;
}

.score-high   { background: rgba(52, 199, 89, 0.15);  color: #34c759; }
.score-medium { background: rgba(255, 159, 10, 0.15); color: #ff9f0a; }
.score-low    { background: rgba(142, 142, 147, 0.15); color: #8e8e93; }

.load-more {
  padding: 12px 8px;
  text-align: center;
}

/* ---- 13. Sub-tabs (History) ---- */
.sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}

.sub-tab {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.sub-tab:hover {
  color: var(--text-body);
}

.sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- 14. Profile / Taste DNA ---- */
.taste-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.taste-header {
  margin-bottom: 16px;
}

.taste-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.taste-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

/* Pattern tags */
.taste-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.pattern-tag {
  padding: 4px 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
  border-radius: 980px;
  font-size: 11px;
  font-weight: 500;
}

/* Taste grid: three columns */
.taste-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
  align-items: start;
}

.taste-radar,
.taste-stats,
.taste-genres {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.taste-col-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* Radar chart container */
.taste-radar canvas,
.taste-radar .chart-wrap {
  width: 100%;
  max-width: 270px;
  margin: 0 auto;
}

/* Stat bars */
.stat-bar-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.stat-bar-row:last-child {
  margin-bottom: 0;
}

.stat-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-bar-label {
  font-size: 11px;
  color: var(--text-body);
}

.stat-bar-pct {
  font-size: 11px;
  color: var(--text-secondary);
}

.stat-bar-track {
  width: 100%;
  height: 3px;
  background: var(--border-soft);
  border-radius: 2px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Stat rows (renderStatBars output) */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.stat-row:last-child {
  margin-bottom: 0;
}

.stat-label {
  font-size: 10px;
  color: var(--text-body);
  min-width: 70px;
}

.stat-value {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
}

.stat-row .stat-bar-track {
  width: 100%;
}

/* Mood bar — center line + labels */
.mood-bar .stat-bar-track {
  position: relative;
  overflow: visible;
}

.stat-bar-center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--text-tertiary);
}

.mood-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Stat cards (BPM / Keys) */
.stat-cards {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.stat-card-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-card-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card-sub {
  font-size: 9px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Genre card (renderGenreBreakdown output) */
.genre-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.genre-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.genre-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.genre-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}

.genre-name {
  font-size: 11px;
  color: var(--text-body);
}

.genre-pct {
  font-size: 9px;
  color: var(--text-tertiary);
  margin-left: 4px;
}

.genre-bar-track {
  width: 100%;
  height: 3px;
  background: var(--border-soft);
  border-radius: 2px;
  overflow: hidden;
}

.genre-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.genre-footer {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

/* Genre list in taste panel */
.taste-genre-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--text-body);
}

.taste-genre-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.taste-genre-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.taste-genre-pct {
  font-size: 10px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Profile footer */
.profile-footer {
  padding: 12px 0;
  border-top: 1px solid var(--border-soft);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-footer p {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ---- 15. Player Pill ---- */
#player-pill {
  position: fixed;
  bottom: 16px;
  left: calc(var(--sidebar-width) + 16px);
  right: 16px;
  height: var(--pill-height);
  background: rgba(20, 20, 20, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  z-index: var(--z-pill);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  transform: translateY(100%);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#player-pill:not(.hidden) {
  transform: translateY(0);
}

#player-pill.hidden {
  display: none !important;
}

/* Pill artwork */
.pill-artwork {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--bg-card);
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

.pill-artwork img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Pill info */
.pill-info {
  flex-shrink: 0;
  max-width: 200px;
  padding-right: 24px;
  min-width: 0;
}

.pill-song {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.pill-artist {
  font-size: 10px;
  color: #777777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.pill-time {
  font-size: 9px;
  color: #555555;
  margin-top: 1px;
}

/* Pill scrubber */
.pill-scrubber {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  cursor: pointer;
  min-width: 60px;
  position: relative;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.pill-scrubber-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
  transition: height 0.15s ease;
}

.pill-scrubber:hover .pill-scrubber-track,
.pill-scrubber.scrubbing .pill-scrubber-track {
  height: 6px;
  transform: translateY(-50%);
}

.pill-scrubber-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.pill-scrubber.scrubbing .pill-scrubber-fill {
  transition: none;
}

.pill-scrubber-thumb {
  position: absolute;
  left: 0%;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s ease;
  pointer-events: none;
  z-index: 1;
}

.pill-scrubber:hover .pill-scrubber-thumb,
.pill-scrubber.scrubbing .pill-scrubber-thumb {
  transform: translate(-50%, -50%) scale(1);
}

/* Pill controls */
.pill-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pill-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #777777;
  cursor: pointer;
  font-size: 14px;
  border-radius: 50%;
  transition: color var(--transition);
  padding: 0;
}

.pill-btn svg {
  width: 14px;
  height: 14px;
}

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

.pill-play {
  width: 32px;
  height: 32px;
  background: var(--text-primary);
  color: var(--bg-main);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
  font-size: 13px;
  padding: 0;
}

.pill-play svg {
  width: 13px;
  height: 13px;
}

.pill-play:hover {
  transform: scale(1.05);
  background: #e0e0e0;
}

/* ---- 16. Mobile Tab Bar ---- */
#tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-height);
  background: rgba(14, 14, 14, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-soft);
  z-index: var(--z-tabbar);
  flex-direction: row;
  align-items: stretch;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  padding: 6px 4px;
}

.tab-item svg {
  width: 20px;
  height: 20px;
  opacity: 0.5;
  transition: opacity var(--transition);
}

.tab-item:hover {
  color: var(--text-secondary);
}

.tab-item.active {
  color: var(--accent);
}

.tab-item.active svg {
  opacity: 1;
  color: var(--accent);
}

/* ---- 17. Crawler Toast ---- */
.crawler-toast {
  position: fixed;
  bottom: calc(var(--pill-height) + 28px);
  left: calc(var(--sidebar-width) + 16px);
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: calc(var(--z-pill) - 1);
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity var(--transition);
  max-width: 320px;
}

.crawler-toast.hidden {
  display: none !important;
}

.crawler-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: crawler-pulse 1.5s ease-in-out infinite;
}

@keyframes crawler-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1;   }
}

.crawler-toast.complete .crawler-dot {
  background: #34c759;
  animation: none;
  opacity: 1;
}

/* ---- 17b. Error Toast ---- */
.error-toast {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(252, 60, 68, 0.15);
  border: 1px solid rgba(252, 60, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.error-toast p {
  font-size: 12px;
  color: var(--text-body);
  margin: 0;
}

.error-toast button {
  font-size: 11px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
}

/* ---- 18. Loading Spinner ---- */
.queue-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ---- 19. Confidence / badges ---- */
.confidence-high   { background: rgba(52, 199, 89, 0.15);  color: #34c759; }
.confidence-medium { background: rgba(255, 159, 10, 0.15); color: #ff9f0a; }
.confidence-low    { background: rgba(142, 142, 147, 0.15); color: #8e8e93; }

/* ---- 20. Mobile Responsive ---- */
@media (max-width: 767px) {
  /* Hide sidebar, show tab bar */
  #sidebar {
    display: none;
  }

  #tab-bar {
    display: flex;
  }

  /* Main content fills full width, extra bottom for tab bar + pill */
  #main-content {
    margin-left: 0;
    padding-bottom: calc(var(--pill-height) + var(--tab-height) + 28px);
  }

  /* Views */
  .view {
    padding: 14px 14px 0;
  }

  /* Player pill repositions */
  #player-pill {
    left: 8px;
    right: 8px;
    bottom: calc(var(--tab-height) + 8px);
    gap: 10px;
    padding: 8px 12px;
  }

  .pill-scrubber-thumb {
    width: 18px;
    height: 18px;
  }

  .pill-scrubber {
    height: 32px;
  }

  /* Crawler toast */
  .crawler-toast {
    left: 8px;
    right: 8px;
    bottom: calc(var(--pill-height) + var(--tab-height) + 20px);
    max-width: 100%;
  }

  /* Pill info tighter */
  .pill-info {
    max-width: 130px;
    padding-right: 8px;
  }

  /* Toolbar wraps */
  .view-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    width: 100%;
  }

  .toolbar-right {
    width: 100%;
    justify-content: flex-end;
  }

  .vibe-input {
    max-width: 100%;
    flex: 1;
  }

  /* Taste grid stacks vertically */
  .taste-grid {
    grid-template-columns: 1fr;
  }

  /* Sub-tabs scroll */
  .sub-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sub-tabs::-webkit-scrollbar {
    display: none;
  }

  /* Row actions: show on tap via hover fallback */
  .row-actions {
    gap: 3px;
  }
}

/* ---- 21. Transitions on interactive elements ---- */
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}

/* Subtle row index numbers (optional) */
.row-num {
  width: 20px;
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  user-select: none;
}

/* ---- 22. Scrollbar styling ---- */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: #333;
}

/* ============================================
   Explore View
   ============================================ */

.explore-container {
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
}

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

.explore-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.explore-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.explore-btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  color: var(--text-body);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 8px 14px;
}

.explore-btn-secondary:hover {
  background: var(--border-soft);
  border-color: var(--accent);
  color: var(--text-primary);
}

.explore-status-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.explore-controls {
  margin-bottom: 20px;
}

.explore-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.explore-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.explore-input:focus {
  border-color: var(--accent);
}

.explore-input::placeholder {
  color: var(--text-dim);
}

.explore-btn {
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}

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

.explore-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.explore-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.explore-select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-body);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  min-width: 120px;
}

.explore-select:focus {
  border-color: var(--accent);
}

/* Results grid */
.explore-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.explore-loading,
.explore-empty,
.explore-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.explore-error {
  color: var(--accent);
}

/* Song row */
.explore-song {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.explore-song:hover {
  background: var(--border-soft);
}

.explore-song.in-library {
  border-left: 2px solid var(--accent);
}

/* Artwork */
.explore-song-art {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border-soft);
}

.explore-song-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.explore-art-placeholder {
  width: 100%;
  height: 100%;
  background: var(--border-mid);
}

/* Preview button */
.explore-preview-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition);
}

.explore-song:hover .explore-preview-btn {
  opacity: 1;
}

.explore-preview-btn.playing {
  opacity: 1;
  background: rgba(252, 60, 68, 0.6);
}

/* Song info */
.explore-song-info {
  flex: 1;
  min-width: 0;
}

.explore-song-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.explore-song-artist {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.explore-song-meta {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  flex-wrap: wrap;
}

/* Badges */
.explore-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.explore-badge.genre {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.explore-badge.year {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-tertiary);
}

.explore-badge.library {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Taste score bar */
.explore-score {
  width: 60px;
  flex-shrink: 0;
  position: relative;
  height: 20px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  overflow: hidden;
}

.explore-score-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-subtle), var(--accent));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.explore-score-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Pagination */
.explore-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding: 12px;
}

.explore-pagination .explore-btn {
  padding: 8px 14px;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  color: var(--text-body);
}

.explore-pagination .explore-btn:hover:not(:disabled) {
  background: var(--border-soft);
  border-color: var(--accent);
}

#explore-page-info {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
  .explore-container {
    padding: 12px;
  }

  .explore-filters {
    flex-direction: column;
  }

  .explore-select {
    min-width: unset;
    width: 100%;
  }

  .explore-score {
    width: 48px;
  }

  .explore-song-art {
    width: 38px;
    height: 38px;
  }
}

/* ============================================
   Database Dashboard
   ============================================ */

#db-dashboard {
  padding: 20px;
  max-width: 640px;
  margin: 0 auto;
}

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

.db-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.db-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background 0.3s;
}

.db-live-dot.active {
  background: #34c759;
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.5);
  animation: db-pulse 2s ease-in-out infinite;
}

@keyframes db-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Stats Row */
.db-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.db-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
}

.db-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.db-stat-denominator {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  opacity: 0.6;
}

.db-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Progress Bar */
.db-progress-section {
  margin-bottom: 16px;
}

.db-progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.db-progress-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.db-progress-pct {
  font-size: 12px;
  color: var(--text-body);
  font-variant-numeric: tabular-nums;
}

.db-progress-bar {
  height: 6px;
  background: var(--border-soft);
  border-radius: 3px;
  overflow: hidden;
}

.db-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0;
}

/* Info Grid */
.db-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.db-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px;
}

.db-info-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.db-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}

.db-info-row span:first-child {
  color: var(--text-secondary);
}

.db-info-row span:last-child {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* Queue Breakdown */
.db-queue-card {
  margin-bottom: 16px;
}

.db-queue-bar-track {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--border-soft);
  margin-bottom: 8px;
}

.db-queue-bar-seg {
  transition: width 0.5s ease;
  min-width: 2px;
}

.db-queue-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.db-queue-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.db-queue-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.db-queue-empty {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  padding: 8px;
}

/* Control Buttons */
.db-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.db-actions .btn-primary-sm,
.db-actions .btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.db-actions .btn-primary-sm:disabled,
.db-actions .btn-sm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.db-governor-select {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-body);
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
  appearance: auto;
}

.db-governor-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Activity Log */
.db-log-section {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px;
}

.db-log {
  max-height: 200px;
  overflow-y: auto;
}

.db-log-entry {
  font-size: 12px;
  color: var(--text-body);
  padding: 3px 0;
  border-bottom: 1px solid var(--border-soft);
  font-family: 'SF Mono', 'Menlo', monospace;
}

.db-log-entry:last-child {
  border-bottom: none;
}

.db-log-time {
  color: var(--text-tertiary);
  margin-right: 8px;
}

/* Responsive */
@media (max-width: 600px) {
  .db-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .db-info-grid {
    grid-template-columns: 1fr;
  }

  .db-stat-value {
    font-size: 18px;
  }
}

/* ---- Love / Like / Dislike / Hate Feedback Buttons ---- */
.row-btn-love {
  color: #e04060;
  border-color: rgba(224, 64, 96, 0.3);
}
.row-btn-love:hover {
  background: rgba(255, 59, 95, 0.12);
  color: #ff3b5f;
  border-color: rgba(255, 59, 95, 0.5);
}

.row-btn-like {
  color: #3a9a5c;
  border-color: rgba(58, 154, 92, 0.3);
}
.row-btn-like:hover {
  background: rgba(52, 199, 89, 0.12);
  color: #34c759;
  border-color: rgba(52, 199, 89, 0.5);
}

.row-btn-hate {
  color: #8e4040;
  border-color: rgba(142, 64, 64, 0.3);
  font-size: 12px;
  font-weight: 700;
}
.row-btn-hate:hover {
  background: rgba(255, 59, 48, 0.12);
  color: #ff3b30;
  border-color: rgba(255, 59, 48, 0.5);
}

.row-btn-dislike {
  color: #a06030;
  border-color: rgba(160, 96, 48, 0.3);
}
.row-btn-dislike:hover {
  background: rgba(255, 149, 0, 0.12);
  color: #ff9500;
  border-color: rgba(255, 149, 0, 0.5);
}

.row-btn svg {
  display: block;
}

/* Vibe mode: sound-match feedback buttons */
.row-btn-vibe-yes {
  color: #34c759;
  border-color: rgba(52, 199, 89, 0.3);
}
.row-btn-vibe-yes:hover {
  background: rgba(52, 199, 89, 0.15);
  color: #30d158;
  border-color: rgba(52, 199, 89, 0.5);
}

.row-btn-vibe-no {
  color: #8e4040;
  border-color: rgba(142, 64, 64, 0.3);
}
.row-btn-vibe-no:hover {
  background: rgba(255, 59, 48, 0.12);
  color: #ff3b30;
  border-color: rgba(255, 59, 48, 0.5);
}

.row-btn-skip {
  color: var(--text-tertiary);
  border-color: transparent;
  font-size: 13px;
}

.row-btn-skip:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

/* Row select checkbox (multi-select for library add) */
.row-select {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-mid);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: -4px;
  transition: all var(--transition);
}

.row-select:checked {
  background: #5ac8fa;
  border-color: #5ac8fa;
}

.row-select:checked::after {
  content: '\2713';
  display: block;
  color: #fff;
  font-size: 11px;
  text-align: center;
  line-height: 18px;
}

/* Add to Library button — detached from feedback actions */
.row-btn-add-lib {
  flex-shrink: 0;
  margin-left: 4px;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
}

.row-btn-add-lib:hover {
  color: #5ac8fa;
  border-color: rgba(90, 200, 250, 0.4);
  background: rgba(90, 200, 250, 0.08);
}

.row-btn-added {
  color: #30d158 !important;
  border-color: rgba(48, 209, 88, 0.3) !important;
  pointer-events: none;
}

/* Batch action bar */
.batch-bar {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e1e;
  border: 1px solid var(--border-mid);
  border-radius: 24px;
  padding: 8px 8px 8px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.batch-bar-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.batch-bar-info span {
  color: #5ac8fa;
  font-weight: 700;
}

.batch-bar-actions {
  display: flex;
  gap: 6px;
}

.btn-playlist {
  background: #6c5ce7 !important;
  border-color: #6c5ce7 !important;
}
.btn-playlist:hover {
  background: #7d6ff0 !important;
}

/* History actions bar (select all + count) */
.history-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}
.select-all-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #5ac8fa;
  cursor: pointer;
}
.history-song-count {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Playlist picker modal */
.playlist-picker-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 12px 0;
}
.playlist-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.playlist-picker-item:hover {
  background: var(--bg-hover);
}
.picker-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}
.picker-count {
  font-size: 12px;
  color: var(--text-tertiary);
}
.picker-create {
  color: #5ac8fa;
  border-top: 1px solid var(--border-soft);
  margin-top: 4px;
  padding-top: 12px;
}
.picker-create .picker-name {
  color: #5ac8fa;
}

/* Compact row actions on small screens */
@media (max-width: 600px) {
  .row-actions {
    gap: 3px;
  }
  .row-btn {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }
  .row-btn svg { width: 12px; height: 12px; }
  .row-btn-hate { font-size: 10px; }
  .row-play { width: 30px; height: 30px; }
  .row-play svg { width: 14px; height: 14px; }
  .row-secondary { opacity: 0.6; }
}

/* ---- Birth Year Overlay ---- */
.birth-year-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.birth-year-input {
  width: 120px;
  padding: 10px 16px;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  margin-bottom: 20px;
  -moz-appearance: textfield;
}
.birth-year-input::-webkit-outer-spin-button,
.birth-year-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.birth-year-input:focus {
  border-color: var(--accent);
}

.birth-year-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.btn-skip {
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-skip:hover {
  color: var(--text-primary);
}

/* ---- Formative Window (Profile) ---- */
.profile-birth-year {
  margin-bottom: 12px;
  font-size: 13px;
}
.formative-label {
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}
.formative-range {
  color: var(--text-primary);
  font-weight: 600;
}
.btn-birth-year-edit,
.btn-birth-year-add {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 12px;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s;
}
.btn-birth-year-edit:hover,
.btn-birth-year-add:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.btn-birth-year-add {
  font-size: 13px;
  padding: 4px 14px;
  margin-left: 0;
}

/* ---- Playlists ---- */

.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.playlist-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.playlist-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.playlist-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.playlist-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.playlist-art {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  flex-shrink: 0;
  background: var(--bg-card);
}

.playlist-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.playlist-art-empty {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #2a1a3e);
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

.playlist-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.playlist-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Playlist detail */

.playlist-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}

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

.playlist-detail-info h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.playlist-detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.playlist-songs {
  padding: 0 12px;
}

.playlist-song-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.playlist-song-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.playlist-song-row .row-art {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.playlist-song-row .row-art-empty {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.btn-back {
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}

.btn-back:hover {
  border-color: var(--border-mid);
  color: var(--text-primary);
}

.btn-danger {
  color: #ff453a !important;
  border-color: rgba(255, 69, 58, 0.3) !important;
}

.btn-danger:hover {
  background: rgba(255, 69, 58, 0.1) !important;
}

.btn-danger-subtle {
  color: var(--text-tertiary);
}

.btn-danger-subtle:hover {
  color: #ff453a;
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #1a1a1a;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 400px;
  width: 100%;
}

.modal-content h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  box-sizing: border-box;
}

.modal-input:focus {
  border-color: var(--border-mid);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Toast */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2a2a2a;
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1100;
  pointer-events: none;
  white-space: nowrap;
  border: 1px solid var(--border-soft);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Listening Stats ---- */

.stats-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 12px;
}

.stats-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-breakdown {
  margin-bottom: 20px;
}

.breakdown-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.breakdown-seg {
  transition: width 0.3s;
}

.breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.breakdown-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.breakdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stats-chart-wrap {
  margin-bottom: 20px;
}

.stats-chart-wrap h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.stats-list {
  margin-bottom: 20px;
}

.stats-list h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

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

.stats-artist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.stats-artist-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.stats-rank {
  font-size: 11px;
  color: var(--text-tertiary);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}

.stats-artist-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-artist-count {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.stats-genre-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-genre-tag {
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.stats-genre-tag span {
  color: var(--text-tertiary);
  font-size: 10px;
}

@media (max-width: 480px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
