/* ═══════════════════════════════════════════════════════════
   Soundmap — Dark Theme Styles
   Dracula-inspired palette
   ═══════════════════════════════════════════════════════════ */

/* ── Custom Properties ── */
:root {
  /* Colors */
  --bg-base:       #1a1a2e;
  --bg-surface:    #16213e;
  --bg-elevated:   #0f3460;
  --bg-card:       #1e1e3a;
  --bg-input:      #252547;
  --bg-hover:      #252560;

  --text-primary:  #e0e0e0;
  --text-secondary:#a0a0b8;
  --text-muted:    #606080;
  --text-inverse:  #1a1a2e;

  --accent-purple: #bd93f9;
  --accent-green:  #50fa7b;
  --accent-pink:   #ff79c6;
  --accent-cyan:   #8be9fd;
  --accent-yellow: #f1fa8c;
  --accent-orange: #ffb86c;
  --accent-red:    #ff5555;

  --border:        rgba(189, 147, 249, 0.15);
  --border-focus:  rgba(189, 147, 249, 0.5);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.6);
  --glow-purple:   0 0 20px rgba(189,147,249,0.3);
  --glow-cyan:     0 0 20px rgba(139,233,253,0.3);

  /* Typography */
  --font-sans:     'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:     'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --fs-xs:         0.7rem;
  --fs-sm:         0.8rem;
  --fs-base:       0.9rem;
  --fs-md:         1rem;
  --fs-lg:         1.1rem;
  --fs-xl:         1.3rem;
  --fs-2xl:        1.6rem;
  --fs-3xl:        2.2rem;
  --fs-hero:       3rem;

  /* Spacing */
  --sp-xs:   4px;
  --sp-sm:   8px;
  --sp-md:   12px;
  --sp-base: 16px;
  --sp-lg:   24px;
  --sp-xl:   32px;
  --sp-2xl:  48px;

  /* Layout */
  --topbar-h:      60px;
  --detail-w:      320px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-full:   9999px;

  /* Transitions */
  --tr-fast:   0.12s ease;
  --tr-base:   0.22s ease;
  --tr-slow:   0.35s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; }

svg { display: block; }

/* ══════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  height: var(--topbar-h);
  padding: 0 var(--sp-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 100;
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  white-space: nowrap;
}

.brand-icon {
  font-size: var(--fs-xl);
  color: var(--accent-purple);
  filter: drop-shadow(0 0 6px var(--accent-purple));
}

.brand-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

/* ── Global Filters ── */
.global-filters {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  flex: 1;
  min-width: 0;
}

.listener-toggle {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.toggle-btn {
  padding: 4px 14px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--tr-fast), color var(--tr-fast);
}

.toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--accent-purple);
  color: var(--text-inverse);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(189,147,249,0.4);
}

/* Search */
.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
  user-select: none;
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: var(--fs-base);
  font-family: inherit;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
  outline: none;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--glow-purple);
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: 2px 4px;
  border-radius: 50%;
  transition: color var(--tr-fast), background var(--tr-fast);
}

.search-clear:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ── Tab Nav ── */
.tab-nav {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.tab-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color var(--tr-fast), background var(--tr-fast);
  white-space: nowrap;
  text-decoration: none;
}

.tab-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.tab-link.active {
  color: var(--accent-purple);
  background: rgba(189,147,249,0.12);
}

.tab-icon { font-style: normal; }

/* ── Main Content ── */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Tab Panels ── */
.tab-panel {
  flex: 1;
  overflow: auto;
  display: none;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════
   EXPLORER TAB
══════════════════════════════════════════ */
.explorer-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.graph-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1a1a3e 0%, var(--bg-base) 70%);
}

#graph-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graph-svg:active { cursor: grabbing; }

/* Graph Controls */
.graph-controls {
  position: absolute;
  top: var(--sp-base);
  right: var(--sp-base);
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  z-index: 10;
}

.ctrl-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--fs-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tr-fast);
  backdrop-filter: blur(8px);
}

.ctrl-btn:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  background: rgba(189,147,249,0.1);
}

.ctrl-btn--text {
  width: auto;
  padding: 0 12px;
  font-size: var(--fs-sm);
}

.ctrl-btn--text.active {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  background: rgba(189,147,249,0.12);
}

/* Graph Loading / Empty */
.graph-loading,
.graph-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-base);
  color: var(--text-secondary);
  background: rgba(26,26,46,0.7);
  z-index: 5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(189,147,249,0.2);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Detail Panel */
.detail-panel {
  width: var(--detail-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  position: relative;
  padding: var(--sp-xl) var(--sp-base) var(--sp-base);
  transition: transform var(--tr-base);
}

.detail-close {
  position: absolute;
  top: var(--sp-md);
  right: var(--sp-md);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tr-fast);
}

.detail-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.detail-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-xs);
  line-height: 1.3;
}

.detail-subtitle {
  font-size: var(--fs-base);
  color: var(--accent-cyan);
  margin-bottom: var(--sp-base);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-base);
}

.detail-badge {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.detail-badge--matt   { background: rgba(189,147,249,0.2); color: var(--accent-purple); border: 1px solid rgba(189,147,249,0.3); }
.detail-badge--kids   { background: rgba(255,121,198,0.2); color: var(--accent-pink);   border: 1px solid rgba(255,121,198,0.3); }
.detail-badge--shared { background: rgba(139,233,253,0.2); color: var(--accent-cyan);   border: 1px solid rgba(139,233,253,0.3); }
.detail-badge--genre  { background: rgba(80,250,123,0.15); color: var(--accent-green);  border: 1px solid rgba(80,250,123,0.25); }

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
  margin-top: var(--sp-base);
}

.detail-stat {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
  border: 1px solid var(--border);
}

.detail-stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--accent-purple);
  line-height: 1;
}

.detail-stat-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Karaoke Score Meter */
.score-meter-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: var(--sp-base);
}

.score-meter {
  height: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.score-meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--tr-slow);
}

/* Graph Legend */
.graph-legend {
  display: flex;
  gap: var(--sp-base);
  padding: var(--sp-sm) var(--sp-base);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.legend-dot--large  { width: 14px; height: 14px; }
.legend-dot--medium { width: 10px; height: 10px; }
.legend-dot--small  { width: 6px;  height: 6px; background: var(--text-secondary); }

/* Graph node/link styles (applied via D3) */
.node circle { stroke-width: 2; transition: r 0.2s ease, filter 0.2s ease; }
.node circle:hover { filter: brightness(1.3); }
.node.highlighted circle { stroke: white; stroke-width: 3; filter: brightness(1.4) drop-shadow(0 0 6px currentColor); }
.node.dimmed circle { opacity: 0.2; }
.node.search-match circle { stroke: var(--accent-yellow); stroke-width: 2.5; }
.node.search-dim circle { opacity: 0.15; }

.link { stroke-opacity: 0.35; transition: stroke-opacity 0.2s ease; }
.link.highlighted { stroke-opacity: 0.8; }
.link.dimmed { stroke-opacity: 0.05; }

.node-label {
  font-size: 10px;
  fill: var(--text-secondary);
  pointer-events: none;
  user-select: none;
}

/* ══════════════════════════════════════════
   KARAOKE TAB
══════════════════════════════════════════ */
.karaoke-layout {
  flex: 1;
  padding: var(--sp-lg);
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.karaoke-filters {
  margin-bottom: var(--sp-lg);
}

.section-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-base);
}

.subsection-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-md);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.filter-row {
  display: flex;
  gap: var(--sp-md);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.filter-select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-base);
  cursor: pointer;
  outline: none;
  transition: border-color var(--tr-fast);
  min-width: 140px;
}

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

/* Karaoke Section */
.karaoke-section {
  margin-bottom: var(--sp-xl);
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-base);
}

/* Karaoke Card */
.kara-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-base) var(--sp-lg);
  transition: all var(--tr-base);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.kara-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.kara-card--matt::before   { background: var(--accent-purple); }
.kara-card--kids::before   { background: var(--accent-pink); }
.kara-card--shared::before { background: var(--accent-cyan); }

.kara-card:hover {
  border-color: rgba(189,147,249,0.35);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--bg-hover);
}

.kara-card:active { transform: translateY(0); }

.kara-song {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  line-height: 1.3;
}

.kara-artist {
  font-size: var(--fs-sm);
  color: var(--accent-cyan);
  margin-bottom: var(--sp-sm);
}

.kara-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.kara-plays-badge {
  padding: 2px 8px;
  background: rgba(139,233,253,0.12);
  border: 1px solid rgba(139,233,253,0.2);
  border-radius: var(--radius-full);
  color: var(--accent-cyan);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.kara-score-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kara-score-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.kara-score-value {
  font-weight: 700;
  color: var(--accent-yellow);
}

.kara-score-bar {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.kara-score-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Skeleton Cards */
.card-skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  height: 130px;
  position: relative;
  overflow: hidden;
}

.card-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}

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

/* Badge */
.badge {
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge--purple { background: rgba(189,147,249,0.2); color: var(--accent-purple); }
.badge--green  { background: rgba(80,250,123,0.15); color: var(--accent-green);  }
.badge--cyan   { background: rgba(139,233,253,0.15); color: var(--accent-cyan);  }

/* ══════════════════════════════════════════
   TIMELINE TAB
══════════════════════════════════════════ */
.timeline-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--sp-lg);
  gap: var(--sp-base);
  overflow: hidden;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.timeline-controls {
  display: flex;
  gap: var(--sp-sm);
}

.timeline-container {
  flex: 1;
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 300px;
}

#timeline-svg {
  width: 100%;
  height: 100%;
}

/* Tooltip (shared) */
.tooltip {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  pointer-events: none;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  max-width: 220px;
  backdrop-filter: blur(12px);
}

.tooltip-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--accent-cyan);
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-sm);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

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

/* Timeline annotation */
.timeline-annotation {
  flex-shrink: 0;
  min-height: 30px;
  padding: var(--sp-sm) 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.annotation-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(241,250,140,0.08);
  border: 1px solid rgba(241,250,140,0.15);
  border-radius: var(--radius-full);
  color: var(--accent-yellow);
  margin-right: var(--sp-sm);
  margin-bottom: 4px;
}

/* D3 axis styles */
.axis-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
}

.tick line { stroke: rgba(255,255,255,0.06); }
.tick text {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
}

.domain { stroke: rgba(255,255,255,0.1); }

/* ══════════════════════════════════════════
   STATS TAB
══════════════════════════════════════════ */
.stats-layout {
  flex: 1;
  padding: var(--sp-lg) var(--sp-xl);
  overflow-y: auto;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Big Number Cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-base);
  margin-bottom: var(--sp-xl);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg) var(--sp-xl);
  text-align: center;
  transition: all var(--tr-base);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  opacity: 0;
  transition: opacity var(--tr-base);
}

.stat-card:hover::after { opacity: 1; }
.stat-card:hover {
  border-color: rgba(189,147,249,0.3);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.stat-card--loading .stat-value { opacity: 0.3; }

.stat-value {
  font-size: var(--fs-hero);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: var(--sp-sm);
  transition: opacity var(--tr-base);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* Charts Row */
.stats-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
  margin-bottom: var(--sp-xl);
}

.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
}

/* Donut */
.donut-container {
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  flex-wrap: wrap;
}

#donut-svg { flex-shrink: 0; }

.donut-legend {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: var(--fs-sm);
}

.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-label { color: var(--text-secondary); flex: 1; }
.donut-legend-pct   { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Bar Container */
.bar-container { height: 220px; }
#listener-bar-svg { width: 100%; height: 100%; }

/* Top Artists */
.top-artists-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
}

.top-artists-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.artist-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  transition: background var(--tr-fast);
}

.artist-row:hover { background: var(--bg-hover); }

.artist-rank {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.artist-name {
  font-size: var(--fs-base);
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artist-bar-wrap {
  width: 120px;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.artist-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
}

.artist-plays {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 50px;
  text-align: right;
}

/* ══════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: var(--sp-lg);
  right: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-sm) var(--sp-base);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 0.3s ease forwards;
  max-width: 300px;
}

.toast--error  { border-left: 3px solid var(--accent-red); }
.toast--warn   { border-left: 3px solid var(--accent-orange); }
.toast--info   { border-left: 3px solid var(--accent-cyan); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ══════════════════════════════════════════
   SCROLLBARS
══════════════════════════════════════════ */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(189,147,249,0.3) transparent;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(189,147,249,0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(189,147,249,0.5); }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: var(--sp-sm) var(--sp-base);
    gap: var(--sp-sm);
  }

  .topbar-brand { flex: 1; }

  .global-filters {
    order: 3;
    width: 100%;
    flex: none;
  }

  .tab-nav {
    order: 2;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .tab-nav::-webkit-scrollbar { display: none; }

  .tab-link { padding: 6px 10px; }

  .detail-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    box-shadow: var(--shadow-lg);
  }

  .stats-charts {
    grid-template-columns: 1fr;
  }

  .stat-value { font-size: var(--fs-3xl); }
}

@media (max-width: 600px) {
  .brand-name { display: none; }

  .toggle-btn { padding: 4px 10px; font-size: var(--fs-xs); }

  .search-input { font-size: var(--fs-sm); }

  .tab-link .tab-icon { margin-right: 0; }

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

  :root { --detail-w: min(320px, 90vw); }

  .karaoke-layout,
  .stats-layout { padding: var(--sp-base); }

  .timeline-header { flex-direction: column; align-items: flex-start; gap: var(--sp-sm); }
}

/* ══════════════════════════════════════════
   ENRICHMENT TAB
══════════════════════════════════════════ */
.enrich-layout {
  flex: 1;
  padding: var(--sp-lg);
  overflow-y: auto;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

/* ── Header ── */
.enrich-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-sm);
}

.enrich-header .section-title {
  margin-bottom: 0;
}

.enrich-header-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.enrich-refresh-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 14px;
  user-select: none;
}

/* ── Status dot ── */
.enrich-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--tr-base);
}

.enrich-pulse-dot--running {
  background: var(--accent-green);
  box-shadow: 0 0 0 0 rgba(80, 250, 123, 0.6);
  animation: enrich-pulse 1.6s ease-in-out infinite;
}

@keyframes enrich-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(80, 250, 123, 0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(80, 250, 123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(80, 250, 123, 0); }
}

/* ── Source cards ── */
.enrich-sources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
}

.enrich-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.enrich-card--inactive {
  opacity: 0.7;
  border-style: dashed;
}

.enrich-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-xs);
}

/* Source badges */
.enrich-source-badge {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid;
}

.enrich-source-badge--lastfm {
  color: #e0143c;
  border-color: rgba(224, 20, 60, 0.4);
  background: rgba(224, 20, 60, 0.08);
}

.enrich-source-badge--spotify {
  color: #1DB954;
  border-color: rgba(29, 185, 84, 0.4);
  background: rgba(29, 185, 84, 0.08);
}

/* Run status badge */
.enrich-run-status {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.enrich-run-status--running {
  color: var(--accent-green);
  background: rgba(80, 250, 123, 0.12);
  border: 1px solid rgba(80, 250, 123, 0.3);
}

.enrich-run-status--idle {
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
}

.enrich-run-status--inactive {
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
}

/* ── Progress bars ── */
.enrich-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.enrich-metric-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.enrich-metric-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.enrich-counter {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-purple);
  font-size: var(--fs-base);
}

.enrich-progress-track {
  height: 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border);
}

.enrich-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  width: 0%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s ease;
  box-shadow: 0 0 8px rgba(189, 147, 249, 0.4);
  position: relative;
  overflow: hidden;
}

/* Shimmer sweep on progress bar when >0% */
.enrich-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  animation: enrich-shimmer 2.4s ease-in-out infinite;
}

@keyframes enrich-shimmer {
  0%   { left: -60%; }
  100% { left: 160%; }
}

.enrich-progress-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Counter tiles ── */
.enrich-counter-row {
  display: flex;
  gap: var(--sp-md);
}

.enrich-counter-tile {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
  text-align: center;
}

.enrich-counter-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  line-height: 1.1;
  text-shadow: var(--glow-cyan);
}

.enrich-counter-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Last run */
.enrich-last-run {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: var(--sp-xs);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-sm);
}

/* ── Placeholder card ── */
.enrich-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--sp-sm);
  padding: var(--sp-xl) var(--sp-lg);
  flex: 1;
}

.enrich-placeholder-icon {
  font-size: 2.4rem;
  opacity: 0.4;
}

.enrich-placeholder-text {
  font-size: var(--fs-md);
  color: var(--text-secondary);
  font-weight: 600;
}

.enrich-placeholder-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

.enrich-placeholder-sub code {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent-yellow);
  background: rgba(241, 250, 140, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── Bottom: tag cloud + log ── */
.enrich-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
  min-height: 280px;
}

.enrich-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
}

.enrich-panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  background: rgba(189, 147, 249, 0.15);
  color: var(--accent-purple);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  margin-left: 4px;
}

/* ── Tag cloud ── */
.enrich-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: var(--sp-sm) var(--sp-md);
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-sm) 0;
}

.enrich-tag {
  cursor: default;
  line-height: 1.2;
  font-weight: 500;
  transition: opacity var(--tr-fast), transform var(--tr-fast), text-shadow var(--tr-fast);
  padding: 2px 0;
  border-radius: 2px;
}

.enrich-tag:hover {
  opacity: 1 !important;
  transform: scale(1.08);
  text-shadow: 0 0 10px currentColor;
}

/* ── Activity log ── */
.enrich-panel--log {
  /* slightly tighter */
}

.enrich-log {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--sp-xs);
}

.enrich-log-row {
  display: grid;
  grid-template-columns: 9rem 4.5rem 4rem 1fr 4.5rem;
  gap: 0 var(--sp-sm);
  align-items: center;
  padding: 5px var(--sp-sm);
  border-radius: var(--radius-sm);
  transition: background var(--tr-fast);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.enrich-log-row:hover {
  background: var(--bg-elevated);
}

.enrich-log-ts {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.68rem;
}

.enrich-log-source {
  font-weight: 700;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.enrich-log-source--lastfm  { color: #e0143c; }
.enrich-log-source--spotify { color: #1DB954; }
.enrich-log-source--unknown { color: var(--text-muted); }

.enrich-log-type {
  color: var(--text-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.enrich-log-name {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enrich-log-status {
  font-weight: 600;
  font-size: 0.68rem;
  text-align: right;
  white-space: nowrap;
}

.enrich-log-status--ok      { color: var(--accent-green); }
.enrich-log-status--error   { color: var(--accent-red); }
.enrich-log-status--skipped { color: var(--accent-yellow); }

/* ── Generic loading text ── */
.enrich-loading-text {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: var(--sp-base);
  text-align: center;
  width: 100%;
}

/* ── Responsive: stack on narrow screens ── */
@media (max-width: 900px) {
  .enrich-sources,
  .enrich-bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .enrich-layout {
    padding: var(--sp-base);
  }

  .enrich-log-row {
    grid-template-columns: 7.5rem 3.5rem 1fr 4rem;
  }

  /* Hide type column on very small screens */
  .enrich-log-type { display: none; }
}

/* ══════════════════════════════════════════
   LOGIN OVERLAY
══════════════════════════════════════════ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(10, 10, 20, 0.92);
  backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
}

.login-overlay.active {
  display: flex;
}

.login-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--glow-purple);
  padding: var(--sp-2xl) var(--sp-xl);
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.login-brand .brand-icon {
  font-size: var(--fs-2xl);
  color: var(--accent-purple);
  filter: drop-shadow(0 0 8px var(--accent-purple));
}

.login-brand .brand-name {
  font-size: var(--fs-2xl);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-tagline {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-sm);
  text-align: center;
}

.clerk-signin-target {
  width: 100%;
  min-height: 60px;
}

/* Clerk widget iframe override */
.clerk-signin-target * { box-sizing: border-box; }

/* ══════════════════════════════════════════
   USER PILL (topbar)
══════════════════════════════════════════ */
.user-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px var(--sp-sm) 4px 4px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  max-width: 220px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-purple);
  flex-shrink: 0;
}

.user-email {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: color var(--tr-fast), background var(--tr-fast);
  flex-shrink: 0;
  line-height: 1;
}

.logout-btn:hover {
  color: var(--accent-red);
  background: rgba(255, 85, 85, 0.1);
}

/* Upload tab link — slight distinction */
.tab-link--upload {
  color: var(--accent-cyan);
}

.tab-link--upload:hover {
  background: rgba(139, 233, 253, 0.1);
}

/* ══════════════════════════════════════════
   SEARCH DROPDOWN
══════════════════════════════════════════ */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 500;
  animation: dropdown-in 0.12s ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 10px var(--sp-md);
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background var(--tr-fast);
  outline: none;
}

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

.search-result-item:hover,
.search-result-item:focus {
  background: var(--bg-hover);
}

.search-result-icon {
  font-size: var(--fs-sm);
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.search-result-type--song   { color: var(--accent-purple); }
.search-result-type--artist { color: var(--accent-cyan);   }
.search-result-type--genre  { color: var(--accent-green);  }

.search-result-name {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.search-result-genre {
  font-size: var(--fs-xs);
  color: var(--accent-green);
  background: rgba(80, 250, 123, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   EXPORT BUTTONS + SECTION TITLE ROW
══════════════════════════════════════════ */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  flex-wrap: wrap;
  margin-bottom: var(--sp-lg);
}

.section-title-row .section-title {
  margin-bottom: 0;
}

.export-actions {
  display: flex;
  gap: var(--sp-sm);
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px var(--sp-md);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--tr-fast);
  font-family: inherit;
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent-purple);
  color: var(--text-inverse);
  box-shadow: 0 0 14px rgba(189, 147, 249, 0.3);
}

.btn--primary:hover {
  background: #cba6fa;
  box-shadow: 0 0 20px rgba(189, 147, 249, 0.5);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn--sm {
  padding: 5px var(--sp-sm);
  font-size: var(--fs-xs);
}

.btn--export {
  background: var(--bg-card);
  color: var(--accent-cyan);
  border: 1px solid rgba(139, 233, 253, 0.25);
  font-size: var(--fs-xs);
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

.btn--export:hover {
  background: rgba(139, 233, 253, 0.1);
  border-color: rgba(139, 233, 253, 0.5);
  box-shadow: 0 0 10px rgba(139, 233, 253, 0.2);
}

/* ══════════════════════════════════════════
   UPLOAD TAB
══════════════════════════════════════════ */
.upload-layout {
  flex: 1;
  padding: var(--sp-xl);
  overflow-y: auto;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-xl);
}

.upload-header {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.upload-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

/* Instructions card */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
}

.instructions-list {
  margin: var(--sp-md) 0 0 var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

.instructions-list li { padding-left: var(--sp-xs); }
.instructions-list strong { color: var(--text-primary); }
.instructions-list a { color: var(--accent-cyan); }

/* Dropzone */
.upload-dropzone {
  border: 2px dashed rgba(189, 147, 249, 0.35);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color var(--tr-base), background var(--tr-base), box-shadow var(--tr-base);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  outline: none;
}

.upload-dropzone:hover,
.upload-dropzone:focus {
  border-color: var(--accent-purple);
  background: rgba(189, 147, 249, 0.05);
  box-shadow: var(--glow-purple);
}

.upload-dropzone--dragover {
  border-color: var(--accent-cyan);
  background: rgba(139, 233, 253, 0.08);
  box-shadow: var(--glow-cyan);
}

.upload-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-xl);
  pointer-events: none;
}

.upload-icon {
  font-size: 3rem;
  opacity: 0.6;
  margin-bottom: var(--sp-sm);
}

.upload-prompt {
  color: var(--text-primary);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.upload-or {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.upload-hint {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin-top: var(--sp-sm);
}

/* In the dropzone, browse button needs pointer-events: auto */
.upload-dropzone-inner .btn { pointer-events: auto; }

/* Progress area */
.upload-progress-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.upload-file-info {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
}

.progress-bar-wrap {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  transition: width 0.2s ease;
}

.upload-status-text {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

/* Success area */
.upload-success-area {
  background: var(--bg-card);
  border: 1px solid rgba(80, 250, 123, 0.3);
  border-radius: var(--radius-lg);
  padding: var(--sp-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  text-align: center;
}

.success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(80, 250, 123, 0.15);
  border: 2px solid var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent-green);
  box-shadow: 0 0 20px rgba(80, 250, 123, 0.3);
}

/* Pipeline steps */
.upload-pipeline-status {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  width: 100%;
  max-width: 320px;
  margin: var(--sp-sm) 0;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: all var(--tr-base);
}

.pipeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--tr-base);
}

.pipeline-step--active {
  color: var(--accent-cyan);
  border-color: rgba(139, 233, 253, 0.2);
  background: rgba(139, 233, 253, 0.05);
}

.pipeline-step--active .pipeline-dot {
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.pipeline-step--done {
  color: var(--accent-green);
  border-color: rgba(80, 250, 123, 0.2);
}

.pipeline-step--done .pipeline-dot {
  background: var(--accent-green);
}

.pipeline-step--error {
  color: var(--accent-red);
  border-color: rgba(255, 85, 85, 0.2);
}

.pipeline-step--error .pipeline-dot {
  background: var(--accent-red);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

/* ══════════════════════════════════════════
   GENOME TAB
══════════════════════════════════════════ */

/* ── Layout ── */
.genome-layout {
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-xl);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.genome-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.genome-section-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* ── Summary Cards Grid ── */
.genome-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-md);
}

.genome-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--sp-base);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease, box-shadow var(--tr-base), border-color var(--tr-base);
}

.genome-card--visible {
  opacity: 1;
  transform: translateY(0);
}

.genome-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.genome-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Card accent bar colors */
.genome-card--purple::before  { background: var(--accent-purple); box-shadow: 0 0 12px rgba(189,147,249,0.5); }
.genome-card--cyan::before    { background: var(--accent-cyan);   box-shadow: 0 0 12px rgba(139,233,253,0.5); }
.genome-card--green::before   { background: var(--accent-green);  box-shadow: 0 0 12px rgba(80,250,123,0.5);  }
.genome-card--orange::before  { background: var(--accent-orange); box-shadow: 0 0 12px rgba(255,184,108,0.5); }
.genome-card--yellow::before  { background: var(--accent-yellow); box-shadow: 0 0 12px rgba(241,250,140,0.5); }
.genome-card--pink::before    { background: var(--accent-pink);   box-shadow: 0 0 12px rgba(255,121,198,0.5); }

.genome-card--purple { border-color: rgba(189,147,249,0.25); }
.genome-card--cyan   { border-color: rgba(139,233,253,0.25); }
.genome-card--green  { border-color: rgba(80,250,123,0.25);  }
.genome-card--orange { border-color: rgba(255,184,108,0.25); }
.genome-card--yellow { border-color: rgba(241,250,140,0.25); }
.genome-card--pink   { border-color: rgba(255,121,198,0.25); }

.genome-card--skeleton {
  min-height: 130px;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  opacity: 1;
  transform: none;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Card inner layout */
.genome-card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.genome-card-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.genome-card-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.genome-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.genome-card-row {
  display: flex;
  gap: var(--sp-lg);
}

.genome-card-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.genome-metric-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.genome-metric-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Genre pills */
.genome-card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.genome-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: color-mix(in srgb, var(--pill-color, var(--accent-purple)) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--pill-color, var(--accent-purple)) 45%, transparent);
  color: var(--pill-color, var(--accent-purple));
  letter-spacing: 0.02em;
}

.genome-pill--shared {
  --pill-color: var(--accent-cyan);
}

/* Nostalgia gauge */
.genome-gauge-wrap {
  display: flex;
  justify-content: flex-start;
}

.genome-gauge {
  overflow: visible;
}

/* Trend arrow badge */
.genome-trend-arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent-yellow);
  background: rgba(241,250,140,0.1);
  border: 1px solid rgba(241,250,140,0.25);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  width: fit-content;
}

/* Listener split bar */
.genome-split-bar {
  display: flex;
  height: 10px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--bg-elevated);
}

.genome-split-fill {
  transition: width 0.8s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.genome-split-fill--matt { background: var(--accent-purple); }
.genome-split-fill--kids { background: var(--accent-pink);   }

.genome-split-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

/* ── River Chart Section ── */
.genome-section--river {
  gap: var(--sp-sm);
}

.genome-river-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-base);
}

.genome-river-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.genome-river-wrap {
  position: relative;
  width: 100%;
  min-height: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.genome-river-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  z-index: 2;
  background: var(--bg-card);
}

#genome-river-svg {
  width: 100%;
  display: block;
}

.genome-river-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm) var(--sp-base);
  padding: var(--sp-sm) var(--sp-base) var(--sp-base);
  border-top: 1px solid var(--border);
}

.genome-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.genome-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.genome-legend-name {
  white-space: nowrap;
}

/* ── Tooltip ── */
.genome-tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--fs-xs);
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  min-width: 120px;
}

.genome-tooltip strong {
  font-size: var(--fs-sm);
}

/* ── Comparison Section ── */
.genome-compare-wrap {
  display: grid;
  grid-template-columns: 1fr 180px 1fr;
  gap: var(--sp-lg);
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
}

.genome-radar-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
}

.genome-radar-label {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.genome-radar-svg {
  display: block;
}

/* Center column */
.genome-compare-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-base);
}

.genome-compare-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: var(--sp-xs);
}

.genome-shared-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
}

.genome-no-shared {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-style: italic;
}

/* Divergence meter */
.genome-divergence-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.genome-divergence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.genome-divergence-value {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

/* ── Genome Responsive ── */
@media (max-width: 1000px) {
  .genome-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .genome-compare-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    text-align: center;
  }

  .genome-radar-panel { flex-direction: row; justify-content: center; }

  .genome-compare-center {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .genome-cards {
    grid-template-columns: 1fr;
  }

  .genome-layout {
    padding: var(--sp-md);
  }

  .genome-river-header {
    flex-direction: column;
    gap: var(--sp-xs);
  }
}

/* ══════════════════════════════════════════
   PRINT
══════════════════════════════════════════ */
@media print {
  .topbar, .graph-controls, .detail-close { display: none; }
  .tab-panel { display: block !important; break-before: page; }
}

/* ══════════════════════════════════════════
   RESPONSIVE: new elements
══════════════════════════════════════════ */
@media (max-width: 900px) {
  .user-email { display: none; }
  .user-pill  { padding: 4px; }
}

@media (max-width: 600px) {
  .upload-layout { padding: var(--sp-base); }
  .section-title-row { flex-direction: column; align-items: flex-start; }
  .login-modal { padding: var(--sp-xl) var(--sp-base); }
}
