/* ============================================
   SUNO EXPLORER - Library Browser
   ============================================ */

:root {
  /* Dark theme - sleek and modern */
  --bg-base: #0a0a0f;
  --bg-surface: #12121a;
  --bg-elevated: #1a1a25;
  --bg-hover: #22222f;
  --bg-active: #2a2a3a;
  
  --text-primary: #f5f5f7;
  --text-secondary: #e6e6e6;
  --text-muted: #606070;
  
  --accent: #a855f7;
  --accent-bright: #c084fc;
  --accent-dim: rgba(168, 85, 247, 0.15);
  
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --liked: #f43f5e;
  
  --border: #2a2a3a;
  --border-subtle: #1f1f2a;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  
  --font-sans: 'Space Grotesk', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --sidebar-width: 280px;
  --panel-width: 480px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.4;
}

/* App Layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

.app.panel-open {
  grid-template-columns: var(--sidebar-width) 1fr var(--panel-width);
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Search */
.search-container {
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

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

/* Navigation */
.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-bright);
}

.nav-icon {
  font-size: 18px;
}

.nav-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-base);
  padding: 2px 8px;
  border-radius: 99px;
}

.nav-item.active .nav-count {
  background: var(--accent);
  color: white;
}

/* Insights Card */
.insights-card {
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.insights-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent-bright);
}

.insight {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid var(--border-subtle);
}

.insight:first-of-type {
  border-top: none;
  padding-top: 0;
}

.insight-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

/* Stats Card */
.stats-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-bright);
  font-family: var(--font-mono);
}

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

.stats-info {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* Keyboard Hints */
.keyboard-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-base);
  border-radius: var(--radius-md);
}

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

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.btn-insights {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  background: linear-gradient(135deg, var(--accent-dim), rgba(168, 85, 247, 0.25));
  border: 1px solid var(--accent);
  color: var(--accent-bright);
  margin-bottom: 8px;
}

.btn-insights:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(168, 85, 247, 0.35));
}

.insights-quick-link {
  display: block;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  text-align: center;
  transition: color 0.15s;
}

.insights-quick-link:hover {
  color: var(--accent-bright);
}

/* ============================================
   Main Content
   ============================================ */

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
  min-height: 0; /* Important: fixes flex overflow bug */
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.header-title {
  font-size: 24px;
  font-weight: 600;
}

.header-count {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 12px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.header-controls.compact {
  gap: 4px;
}

.header-controls.compact select,
.header-controls.compact button {
  padding: 6px 8px;
  font-size: 12px;
}

.creator-select,
.sort-select {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
}

.creator-select {
  min-width: 140px;
  max-width: 200px;
}

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

.view-toggle {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-btn {
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

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

.view-btn.active {
  background: var(--accent);
  color: white;
}

/* Song Container */
.song-container {
  flex: 1;
  min-height: 0; /* Important: fixes flex overflow bug */
  overflow-y: auto;
  padding: 24px;
}

.song-container.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px);
  grid-auto-rows: minmax(280px, auto);
  gap: 16px;
  align-content: start;
  justify-content: start;
}

/* Thumbnail size variants */
.song-container.view-grid.size-small {
  grid-template-columns: repeat(auto-fill, 140px);
  grid-auto-rows: minmax(200px, auto);
  gap: 12px;
}

/* Small thumbnails */
.song-container.view-grid.size-small {
  grid-template-columns: repeat(auto-fill, 140px);
  grid-auto-rows: minmax(200px, auto);
  gap: 12px;
}

.song-container.view-grid.size-small .song-card {
  width: 140px;
  min-height: 200px;
}

.song-container.view-grid.size-small .song-cover-wrapper {
  height: 140px;
}

.song-container.view-grid.size-small .song-title {
  font-size: 12px;
}

.song-container.view-grid.size-small .song-meta {
  font-size: 10px;
}

.song-container.view-grid.size-small .song-badges {
  gap: 2px;
}

.song-container.view-grid.size-small .badge {
  font-size: 9px;
  padding: 2px 4px;
}

.song-container.view-grid.size-small .song-cover-placeholder {
  font-size: 32px;
}

.song-container.view-grid.size-small .song-menu-btn {
  width: 24px;
  height: 24px;
  font-size: 14px;
}

/* Large thumbnails */
.song-container.view-grid.size-large {
  grid-template-columns: repeat(auto-fill, 280px);
  grid-auto-rows: minmax(380px, auto);
  gap: 20px;
}

.song-container.view-grid.size-large .song-card {
  width: 280px;
  min-height: 380px;
}

.song-container.view-grid.size-large .song-cover-wrapper {
  height: 280px;
}

.song-container.view-grid.size-large .song-title {
  font-size: 16px;
}

.song-container.view-grid.size-large .song-cover-placeholder {
  font-size: 64px;
}

.song-container.view-grid.size-large .song-info {
  padding: 14px;
}

.song-container.view-grid.size-large .badge {
  font-size: 12px;
  padding: 4px 8px;
}

.song-container.view-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state h2 {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
}

/* ============================================
   Song Cards (Grid View)
   ============================================ */

.song-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  width: 200px;
  min-height: 100px;
}

.song-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.song-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.song-card:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.song-cover-wrapper {
  position: relative;
  width: 100%;
  height: 200px; /* Fixed height matching grid column width */
  background: var(--bg-elevated);
  overflow: hidden;
}

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

.song-cover-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-active));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.song-info {
  padding: 14px;
}

.song-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.song-badges {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}

.badge {
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-versions {
  background: var(--accent);
  color: white;
}

.badge-liked {
  background: var(--liked);
  color: white;
}

.badge-disliked {
  background: #6b7280;
  color: white;
}

.badge-upload {
  background: #3b82f6;
  color: white;
}

.badge-derived {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: white;
}

.badge-strand-upload {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
}

.badge-strand-scratch {
  background: linear-gradient(135deg, #10b981, #34d399);
  color: white;
}
.song-card.is-upload {
  border-color: rgba(59, 130, 246, 0.3);
}

.song-card.derived-from-upload {
  border-color: rgba(139, 92, 246, 0.3);
}

.song-card.strand-from-upload {
  border-color: rgba(59, 130, 246, 0.3);
}

.song-card.strand-from-scratch {
  border-color: rgba(16, 185, 129, 0.3);
}

.song-card.is-upload:hover {
  border-color: #3b82f6;
}

.version-derived {
  color: #3b82f6;
  font-size: 10px;
}

/* Origin tags for version items */
.origin-tag {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.origin-tag.origin-upload {
  background: rgba(124, 92, 255, 0.15);
  color: #a78bfa;
}

.origin-tag.origin-fresh {
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
}

.origin-tag.origin-from-upload {
  background: rgba(124, 92, 255, 0.1);
  color: #c4b5fd;
}

.origin-tag.origin-derived {
  background: rgba(100, 149, 237, 0.15);
  color: #93c5fd;
}

.origin-tag.origin-released {
  background: rgba(92, 255, 124, 0.15);
  color: #86efac;
}

/* Origin row borders */
.version-item.origin-upload {
  border-left: 2px solid #a78bfa;
}

.version-item.origin-fresh {
  border-left: 2px solid #ffd700;
}

.version-item.origin-from-upload {
  border-left: 2px solid #c4b5fd;
}

.version-item.origin-derived {
  border-left: 2px solid #93c5fd;
}

/* Derived songs section */
#derivedSection {
  border-top: 1px solid var(--border);
}

.derived-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

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

.derived-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.derived-item:hover {
  background: var(--bg-active);
}

.derived-title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.derived-meta {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}

/* Play overlay on hover */
.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  width: 60px;
  height: 60px;
  background: rgba(168, 85, 247, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  opacity: 0;
  transition: all 0.2s;
  pointer-events: none;
  z-index: 2;
}

.song-card:hover .play-overlay {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.view-list .play-overlay {
  display: none;
}

/* ============================================
   Song Cards (List View)
   ============================================ */

.view-list .song-card {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-md);
}

.view-list .song-card::after {
  display: none;
}

.view-list .song-card {
  width: 100%;
}

.view-list .song-cover-wrapper {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.view-list .song-cover,
.view-list .song-cover-placeholder {
  border-radius: var(--radius-sm);
}

.view-list .song-cover-placeholder {
  font-size: 20px;
}

.view-list .song-info {
  flex: 1;
  padding: 0 16px;
  min-width: 0;
}

.view-list .song-title {
  margin-bottom: 2px;
}

.view-list .song-badges {
  position: static;
  flex-shrink: 0;
}

.view-list .song-card:hover .song-play {
  opacity: 1;
}

.song-play {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 16px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  margin-right: 8px;
}

.song-play:hover {
  background: var(--accent-bright);
}

/* ============================================
   Version Panel
   ============================================ */

.version-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  z-index: 100;
}

.version-panel.open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s;
}

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

.panel-header {
  display: flex;
  gap: 16px;
  padding: 24px;
  background: linear-gradient(180deg, var(--bg-elevated), transparent);
}

.panel-cover {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  background: var(--bg-active);
}

.panel-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}

.panel-meta {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Audio Player */
.panel-player {
  padding: 0 24px 24px;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-base);
  border-radius: var(--radius-md);
}

.play-btn {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.play-btn:hover {
  background: var(--accent-bright);
  transform: scale(1.05);
}

.player-progress {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
}

.player-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0;
  transition: width 0.1s linear;
}

.player-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 40px;
}

/* Panel Sections */
.panel-section {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

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

.panel-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.copy-btn {
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

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

/* Version List */
.version-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.version-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}

.version-item:hover {
  background: var(--bg-active);
}

.version-item.playing {
  border: 1px solid var(--accent);
  background: var(--accent-dim);
}

.version-number {
  width: 28px;
  height: 28px;
  background: var(--bg-base);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

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

.version-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  align-items: center;
}

.version-tags {
  align-items: center;
  margin: 2px 0;
}

.version-tag {
  padding: 0px 6px;
  border-radius: 3px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.version-date {
  color: var(--text-muted);
}

.version-liked {
  color: var(--liked);
}

.version-disliked {
  color: #6b7280;
}

.public-badge {
  color: var(--accent);
  font-size: 14px;
  opacity: 0.9;
}

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

.version-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-base);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

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

/* Lyrics */
.panel-lyrics {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* Tags */
.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 6px 12px;
  background: var(--bg-elevated);
  border-radius: 99px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================
   Toast Notification
   ============================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
}

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

.toast.success {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.15);
}

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--bg-active);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   Loading State
   ============================================ */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  grid-column: 1 / -1;
}

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

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

.loading-text {
  margin-top: 16px;
  color: var(--text-muted);
}

/* Loading Overlay */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 15, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  text-align: center;
}

.loading-message {
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.loading-subtitle {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.4;
}

.loading-bar {
  width: 200px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin-top: 16px;
  overflow: hidden;
}

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

/* ============================================
   Vocal/Instrumental Badges
   ============================================ */

.badge-vocal,
.badge-instr,
.badge-mixed {
  font-size: 10px;
  padding: 2px 4px;
}

.badge-definitive {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #000;
}

/* ============================================
   Definitive Version Styling
   ============================================ */

.version-item.is-definitive {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.1), transparent);
  border-left: 3px solid #fbbf24;
}

.definitive-badge {
  font-size: 12px;
  margin-left: 6px;
  vertical-align: middle;
}

.definitive-badge.vocals {
  color: var(--accent-bright);
}

.definitive-badge.instr {
  color: #22c55e;
}

/* Version vocal tag */
.version-vocal-tag {
  font-size: 12px;
}

.version-vocal-tag.vocals {
  color: var(--accent-bright);
}

.version-vocal-tag.instrumental {
  color: #22c55e;
}

.version-vocal-tag.unknown {
  color: var(--text-muted);
}

/* ============================================
   Version Context Menu
   ============================================ */

.version-context-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  min-width: 180px;
  max-height: calc(100vh - 20px); /* Never taller than viewport minus padding */
  overflow-y: auto; /* Scrollable if content is too tall */
  overflow-x: hidden;
}

/* Scrollbar styling for context menus */
.version-context-menu::-webkit-scrollbar {
  width: 8px;
}

.version-context-menu::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px;
}

.version-context-menu::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.version-context-menu::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Fade indicators at top/bottom when scrollable */
.version-context-menu::before,
.version-context-menu::after {
  content: '';
  position: sticky;
  display: block;
  height: 8px;
  pointer-events: none;
  z-index: 1;
}

.version-context-menu::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg-surface), transparent);
}

.version-context-menu::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg-surface), transparent);
}

.version-context-menu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.version-context-menu .menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.1s;
}

.version-context-menu .menu-item:hover {
  background: var(--accent);
  color: white;
}

.version-context-menu .menu-item.active {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-bright);
}

.version-context-menu .menu-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 14px 4px;
  font-weight: 600;
}

.version-context-menu .menu-submenu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
}

.version-context-menu .menu-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.version-context-menu .menu-select {
  flex: 1;
  padding: 4px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
}

.version-context-menu .menu-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* External Link Modal */
.link-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.link-preview .platform-icon {
  font-size: 20px;
}

.link-preview .platform-name {
  font-weight: 500;
  color: var(--text-primary);
}

.link-preview .embed-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--accent-dim);
  color: var(--accent-bright);
  border-radius: 10px;
  margin-left: auto;
}

/* Links Viewer */
.links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  max-height: 300px;
  overflow-y: auto;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.link-item .link-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.link-item .link-content:hover {
  color: var(--accent);
}

.link-item .platform-icon {
  font-size: 18px;
}

.link-item .platform-name {
  font-weight: 500;
  color: var(--text-primary);
}

.link-item .link-url {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.btn-remove-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
}

.btn-remove-link:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* DNA Badge */
.dna-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(59, 130, 246, 0.2));
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 10px;
  font-size: 11px;
  color: var(--accent-bright);
  cursor: help;
}

/* DNA Strand Headers in Version List */
.dna-strand-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(59, 130, 246, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--radius-sm);
  margin: 8px 0 4px 0;
  font-size: 12px;
}

.dna-strand-header:first-child {
  margin-top: 0;
}

.dna-strand-icon {
  font-size: 14px;
}

.dna-strand-label {
  font-weight: 600;
  color: var(--accent-bright);
}

.dna-strand-count {
  color: var(--text-muted);
  font-size: 11px;
}

.dna-strand-root {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 10px;
  opacity: 0.8;
}

/* Release Link Badge on Thumbnail */
.song-card .release-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 4px;
  font-size: 10px;
}

.song-card .release-badge .platform-icon {
  font-size: 12px;
}

/* Version menu button */
.version-menu-btn {
  font-size: 18px;
  font-weight: bold;
  letter-spacing: -2px;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-radius: 4px;
}

.version-menu-btn:hover {
  background: var(--accent);
  color: white;
}

/* ============================================
   Section Actions (filter + copy)
   ============================================ */

.section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-btn:hover {
  background: var(--bg-active);
}

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

/* ============================================
   Quick Play Buttons
   ============================================ */

.quick-play-buttons {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.quick-play-btn {
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-play-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.quick-play-btn.vocals {
  border-color: var(--accent-dim);
}

.quick-play-btn.instr {
  border-color: rgba(34, 197, 94, 0.3);
}

.quick-play-btn.upload {
  border-color: rgba(59, 130, 246, 0.3);
}

/* ============================================
   Versions Hidden Notice
   ============================================ */

.versions-hidden-notice {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  border: 1px dashed var(--border);
}

/* ============================================
   Version Thumbnails
   ============================================ */

.version-thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  margin-right: 8px;
}

.version-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.version-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ============================================
   Thumbnail Mode Selector
   ============================================ */

/* Filter Toggle (Stems, etc.) */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-right: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.filter-toggle:hover {
  border-color: var(--accent);
}

.filter-toggle.active {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.filter-toggle .filter-label {
  font-weight: 500;
}

/* Name Mode Toggle */
.name-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-right: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.name-mode-toggle:hover {
  border-color: var(--accent);
}

.name-mode-toggle.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-bright);
}

.name-mode-icon {
  font-size: 14px;
}

.name-mode-label {
  font-weight: 500;
}

/* Song Card Menu Button */
.song-menu-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.song-card:hover .song-menu-btn {
  opacity: 1;
}

.song-menu-btn:hover {
  background: var(--accent);
  transform: scale(1.1);
}

/* List view menu button */
.view-list .song-menu-btn {
  position: static;
  opacity: 0;
  background: var(--bg-elevated);
  color: var(--text-primary);
  margin-left: 8px;
}

.view-list .song-card:hover .song-menu-btn {
  opacity: 1;
}

.song-card-menu {
  min-width: 180px;
}

/* ============================================
   Custom Name Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal.modal-wide {
  width: 700px;
  max-width: 95vw;
}

/* Stems Grid */
.stems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 8px 0;
  max-height: 50vh;
  overflow-y: auto;
}

.stem-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.stem-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.stem-card.playing {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.stem-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.stem-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

.stem-duration {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stem-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.stem-btn {
  padding: 4px 8px;
  font-size: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

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

/* Stems button in panel */
.stems-btn {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2)) !important;
  border-color: rgba(139, 92, 246, 0.5) !important;
  color: var(--text-primary) !important;
  white-space: nowrap;
  min-width: auto;
  width: fit-content;
  padding: 6px 10px !important;
}

.stems-btn:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(59, 130, 246, 0.3)) !important;
}

.stems-btn #stemsCount {
  margin-left: 4px;
}

/* ============================================
   SIDEBAR SETTINGS PANEL
   ============================================ */

.settings-panel {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: auto;
}

.settings-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.settings-toggle .toggle-chevron {
  font-size: 10px;
  transition: transform 0.2s;
}

.settings-toggle.open .toggle-chevron {
  transform: rotate(180deg);
}

.settings-content {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

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

.setting-select {
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

.setting-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.setting-toggle-label:hover {
  color: var(--text-primary);
}

.setting-toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ============================================
   CONTROLS PANEL (New Compact Design)
   ============================================ */

.controls-panel {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  overflow: hidden;
  flex-shrink: 0;
}

.controls-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s;
}

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

.controls-toggle .toggle-icon {
  font-size: 14px;
}

.controls-toggle .toggle-text {
  flex: 1;
  text-align: left;
  font-weight: 500;
}

.controls-toggle .toggle-chevron {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.controls-toggle.open .toggle-chevron {
  transform: rotate(180deg);
}

.controls-content {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controls-section-header {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-weight: 600;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.control-select {
  padding: 4px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  min-width: 90px;
}

.control-select.compact {
  padding: 3px 6px;
  font-size: 10px;
  min-width: 80px;
}

.control-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 0;
}

.control-toggle:hover {
  color: var(--text-primary);
}

.control-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

/* Help Button */
.help-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
}

.help-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-bright);
}

/* Help Modal Content */
.help-content {
  max-height: 60vh;
  overflow-y: auto;
}

.help-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.help-section h4 {
  color: var(--accent-bright);
  font-size: 14px;
  margin-bottom: 8px;
}

.help-section p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
}

.help-section ul {
  margin: 8px 0;
  padding-left: 20px;
}

.help-section li {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 4px;
  line-height: 1.5;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.help-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.help-table td:first-child {
  color: var(--text-primary);
  white-space: nowrap;
  width: 120px;
}

.help-table td:last-child {
  color: var(--text-secondary);
}

.help-table kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Sidebar Actions Row */
.sidebar-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  flex-wrap: wrap;
}

.sidebar-actions .btn {
  flex: 1;
  min-width: 70px;
  padding: 8px 10px;
  font-size: 11px;
  text-align: center;
}

/* ============================================
   LINK TO UPLOAD MODAL
   ============================================ */

.link-mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg-base);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.link-mode-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

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

.link-mode-tab.active {
  background: var(--accent);
  color: white;
}

.link-upload-search {
  margin-bottom: 12px;
}

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

.modal-description {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-description strong {
  color: var(--accent-bright);
}

.uploads-list {
  max-height: 35vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  margin-bottom: 12px; /* Space for player */
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s;
}

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

.upload-item:hover {
  background: var(--bg-hover);
}

.upload-item.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.upload-item-art {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

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

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

.upload-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.upload-item-duration {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.upload-item-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-bright);
  border-radius: 4px;
}

.uploads-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.uploads-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.uploads-more {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

.link-upload-selected {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
}

.selected-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}

.selected-upload {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Link button in panel */
.link-upload-btn {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.2), rgba(234, 179, 8, 0.2)) !important;
  border-color: rgba(251, 146, 60, 0.5) !important;
  color: #fb923c !important;
}

.link-upload-btn:hover {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.3), rgba(234, 179, 8, 0.3)) !important;
}

/* Orphan indicator */
.orphan-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-radius: 4px;
  margin-left: 8px;
}

.linked-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-radius: 4px;
  margin-left: 8px;
}

/* Step Header */
.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.step-badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.step-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Upload Preview Player */
.upload-preview-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  /* Remove margin-top, now relies on uploads-list margin-bottom */
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.preview-art {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

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

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

.preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.preview-seek {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
  margin: 0;
}

.preview-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.preview-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.preview-seek::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}

.preview-seek::-moz-range-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}

.preview-time {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 35px;
}

/* Upload item play button */
.upload-item-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.upload-item-play:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.upload-item-play.playing {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Existing Link Info Banner */
.existing-link-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--warning);
}

.existing-link-icon {
  font-size: 14px;
}

.existing-link-text strong {
  color: var(--text-primary);
}

/* Selected Upload Banner (Step 2) */
.selected-upload-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(59, 130, 246, 0.1));
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.banner-art {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

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

.banner-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

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

/* Apply Options */
.apply-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.apply-base {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.apply-base-icon {
  font-size: 16px;
}

.apply-base-text {
  font-size: 13px;
  color: var(--text-primary);
}

.apply-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.apply-option:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.apply-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.apply-option input[type="radio"],
.apply-option input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.override-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(251, 146, 60, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.3);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.override-icon {
  font-size: 14px;
}

.override-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.override-text strong {
  color: #fb923c;
}

.option-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.option-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.option-count {
  font-size: 11px;
  color: var(--accent-bright);
  font-weight: 500;
}

.option-count.option-warning {
  color: var(--warning);
}

/* Affected Preview */
.affected-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.affected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.affected-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.affected-count {
  font-size: 11px;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
}

.affected-list {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-base);
}

.affected-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

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

.affected-item.will-link {
  color: var(--text-primary);
}

.affected-item.wont-link {
  color: var(--text-muted);
  background: rgba(239, 68, 68, 0.05);
}

.affected-icon {
  font-size: 14px;
}

.affected-title-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.affected-type {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--text-secondary);
}

.affected-note {
  font-size: 10px;
  font-style: italic;
  padding: 2px 6px;
  border-radius: 4px;
}

.affected-note.note-new {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.affected-note.note-update {
  color: var(--accent-bright);
  background: rgba(168, 85, 247, 0.1);
}

.affected-note.note-override {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.1);
}

.affected-note.note-good {
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.affected-note.note-primary {
  color: var(--accent-bright);
  background: rgba(168, 85, 247, 0.2);
  font-weight: 500;
}

.affected-note.note-chain {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.affected-item.already-good {
  opacity: 0.6;
}

.affected-item.gets-via-chain {
  opacity: 0.7;
  background: rgba(59, 130, 246, 0.05);
}

.affected-item.primary {
  background: rgba(168, 85, 247, 0.1);
  border-left: 3px solid var(--accent);
}

.affected-divider {
  padding: 8px 12px;
  background: var(--bg-elevated);
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.affected-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Fix change button size */
#btnChangeUpload {
  padding: 4px 10px;
  font-size: 11px;
  white-space: nowrap;
  width: 80px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

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

.modal-body {
  padding: 20px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px 0;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

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

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

.modal-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0 0 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.btn-modal {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-cancel {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.btn-cancel:hover {
  background: var(--bg-active);
}

.btn-clear {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}

.btn-clear:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-save {
  background: var(--accent);
  color: white;
}

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

.thumb-mode-toggle {
  margin-right: 8px;
}

.thumb-mode-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}

.thumb-mode-select:hover {
  border-color: var(--accent);
}

.thumb-size-toggle {
  margin-right: 8px;
}

.thumb-size-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  min-width: 45px;
}

.thumb-size-select:hover {
  border-color: var(--accent);
}

/* Art Preview in Modal */
.art-preview {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 200px;
}

.art-preview img {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
}

/* Custom Art Modal */
.custom-art-modal {
  max-width: 500px;
}

.art-mode-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.art-mode-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.art-mode-option input[type="radio"] {
  display: none;
}

.art-mode-preview {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  transition: all 0.15s;
}

.art-mode-option input:checked + .art-mode-preview {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.3);
}

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

.art-mode-preview.art-mode-url {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  font-size: 24px;
}

.art-mode-label {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

.art-mode-option input:checked ~ .art-mode-label {
  color: var(--accent-bright);
  font-weight: 500;
}

.custom-url-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Version picker grid for custom art */
.art-version-thumb {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.art-version-thumb img {
  transition: all 0.15s;
}

.art-version-thumb:hover img {
  transform: scale(1.05);
}

.art-version-thumb input:checked + img {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.5);
}

.art-version-grid::-webkit-scrollbar {
  width: 6px;
}

.art-version-grid::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.art-version-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   Cover Collage
   ============================================ */

.song-cover-collage {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 2px;
  background: var(--bg-base);
}

.song-cover-collage.collage-2 {
  grid-template-columns: 1fr 1fr;
}

.song-cover-collage.collage-3 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.song-cover-collage.collage-3 img:first-child {
  grid-row: span 2;
}

.song-cover-collage.collage-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* Large mode collages (5-9 images) */
.song-cover-collage.collage-5 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.song-cover-collage.collage-5 img:first-child {
  grid-row: span 2;
}

.song-cover-collage.collage-6 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.song-cover-collage.collage-7 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.song-cover-collage.collage-7 img:first-child {
  grid-row: span 2;
}

.song-cover-collage.collage-8 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.song-cover-collage.collage-8 img:first-child {
  grid-column: span 2;
}

.song-cover-collage.collage-9 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

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

/* ============================================
   Now Playing Bar
   ============================================ */

.now-playing-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 64px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  transition: right 0.3s;
}

.panel-open .now-playing-bar {
  right: var(--panel-width);
}

.np-cover {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-elevated);
}

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

.np-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-tags {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.np-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--text-muted);
}

.np-tag.liked { color: #ef4444; }
.np-tag.definitive { color: #fbbf24; background: rgba(251, 191, 36, 0.15); }
.np-tag.vocal { color: var(--accent-bright); }
.np-tag.instr { color: #22c55e; }
.np-tag.upload { color: #3b82f6; }

.np-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.np-progress-wrap {
  flex: 1;
  max-width: 300px;
  min-width: 120px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.np-progress {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s;
  /* Don't use flex here - width should be controlled by JS */
}

.np-time {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

.np-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.np-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-elevated);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--text-primary);
}

.np-btn.np-prev,
.np-btn.np-next {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.np-btn.np-play {
  width: 40px;
  height: 40px;
  font-size: 18px;
  background: var(--accent);
}

.np-btn.np-menu {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-weight: bold;
  font-size: 18px;
}

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

.np-open {
  border-radius: var(--radius-sm);
}

.np-menu {
  font-size: 18px;
  font-weight: bold;
  letter-spacing: -2px;
}

.np-time {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 40px;
}

/* Adjust main content when now playing is visible */
.main.has-now-playing {
  padding-bottom: 80px;
}

/* ============================================
   Definitive Name Feature
   ============================================ */

.definitive-name-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent-bright);
  cursor: help;
}

.song-custom-name {
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
  font-style: italic;
}

.edit-name-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  border-radius: 4px;
}

.edit-name-btn:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

/* Song card custom names */
.song-custom-title {
  color: var(--accent-bright);
}

.song-original-title {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

.has-custom-name {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.6;
}

/* Panel custom name */
.panel-custom-name {
  display: block;
  color: var(--accent-bright);
}

.panel-original-name {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 4px;
}

/* ============================================
   LINEAGE MODAL
   ============================================ */

/* Panel Tabs */
.panel-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.panel-tab:hover {
  color: var(--text-primary);
}

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

.tab-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.panel-tab-content {
  padding: 0 16px 16px;
  max-height: 400px;
  overflow-y: auto;
}

/* Lineage Controls */
.lineage-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.lineage-controls button {
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.lineage-controls button:hover {
  background: var(--bg-hover);
}

.lineage-controls button.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Lineage tree inline */
.lineage-tree-inline {
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-x: auto;
}

/* Tree node with thumbnail */
.lineage-tree-inline .tree-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border-radius: 6px;
  cursor: pointer;
}

.lineage-tree-inline .tree-node:hover {
  background: var(--bg-active);
}

.lineage-tree-inline .tree-thumb {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.lineage-tree-inline .tree-info {
  flex: 1;
  min-width: 0;
}

.lineage-tree-inline .tree-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Compact mode for lineage tree */
.lineage-tree-inline.compact .tree-thumb,
.lineage-tree-inline.compact .lineage-thumb {
  display: none;
}

.lineage-tree-inline.compact .tree-node,
.lineage-tree-inline.compact .lineage-node {
  padding: 4px 8px;
}

.lineage-tree-inline.compact .tree-meta {
  display: inline;
}

.lineage-tree-inline .tree-row {
  display: flex;
  align-items: flex-start;
  margin: 2px 0;
  min-width: 0;
}

.lineage-tree-inline .tree-branch {
  flex-shrink: 0;
  color: var(--text-muted);
  white-space: pre;
}

.lineage-tree-inline .tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  min-width: 0;
  flex-wrap: wrap;
}

.lineage-tree-inline .tree-node:hover {
  background: var(--bg-hover);
}

.lineage-tree-inline .node-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.lineage-tree-inline .node-model {
  font-size: 10px;
  padding: 1px 4px;
  background: var(--bg-surface);
  border-radius: 3px;
  color: var(--text-muted);
}

.lineage-tree-inline .node-type-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Collapsed unliked indicator */
.collapsed-group {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: 6px;
  margin: 4px 0;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.collapsed-group:hover {
  background: var(--bg-hover);
}

.collapsed-group-expand {
  color: var(--accent);
  margin-left: 8px;
}

/* Filter button active state */
.filter-btn.active {
  background: var(--accent-dim);
  color: var(--accent-bright);
}

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

.derived-header h3 {
  margin: 0;
}

.lineage-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.lineage-modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.lineage-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.lineage-modal-title h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.lineage-root-name {
  font-size: 14px;
  color: var(--text-muted);
}

.lineage-modal-controls {
  display: flex;
  gap: 6px;
}

.lineage-mode-btn,
.lineage-filter-btn,
.lineage-thumbs-btn {
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.lineage-mode-btn:hover,
.lineage-filter-btn:hover,
.lineage-thumbs-btn:hover {
  background: var(--bg-hover);
}

.lineage-mode-btn.active,
.lineage-filter-btn.active,
.lineage-thumbs-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.lineage-modal-stats {
  display: flex;
  gap: 12px;
}

.lineage-stat {
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--accent-bright);
}

/* Direct ancestry view */
.direct-ancestry {
  padding: 16px;
}

.ancestry-summary {
  margin-bottom: 16px;
  text-align: center;
}

.ancestry-root-type {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.ancestry-root-type.upload {
  background: rgba(124, 92, 255, 0.2);
  color: var(--accent);
}

.ancestry-root-type.generated {
  background: rgba(92, 255, 124, 0.2);
  color: #5cff7c;
}

.ancestry-chain {
  display: flex;
  flex-direction: column;
}

.ancestry-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.ancestry-item:hover {
  background: var(--bg-hover);
}

.ancestry-item.current {
  border-left: 3px solid var(--accent);
}

.ancestry-item.root {
  border-left: 3px solid #5cff7c;
}

.ancestry-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

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

.ancestry-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ancestry-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.ancestry-tag {
  padding: 2px 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  font-size: 10px;
}

.ancestry-tag.upload {
  background: rgba(124, 92, 255, 0.2);
  color: var(--accent);
}

.ancestry-play {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 14px;
  transition: background 0.15s;
}

.ancestry-play:hover {
  background: var(--accent-dim);
}

.ancestry-connector {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  padding: 6px 0;
}

/* Tree thumbnails in lineage modal */
.lineage-tree-container .tree-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.lineage-tree-container .tree-info {
  flex: 1;
  min-width: 0;
}

.lineage-tree-container .tree-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  align-items: center;
}

.lineage-tree-container .tree-node {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Compact mode for lineage modal */
.lineage-tree-container.compact .ancestry-thumb,
.lineage-tree-container.compact .tree-thumb {
  display: none;
}

.lineage-tree-container.compact .ancestry-item {
  padding: 8px 12px;
}

.lineage-tree-container.compact .ancestry-thumb {
  display: none;
}

.lineage-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}

.lineage-close:hover {
  color: var(--text-primary);
}

.lineage-tree-container {
  flex: 1;
  overflow: auto;
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.tree-row {
  display: flex;
  align-items: center;
  margin: 2px 0;
}

.tree-branch {
  color: var(--text-muted);
  white-space: pre;
  user-select: none;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}

.tree-node:hover {
  background: var(--bg-elevated);
}

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

.type-upload .node-type-dot { background: #ec4899; }
.type-extend .node-type-dot { background: #22c55e; }
.type-edit .node-type-dot, .type-remix .node-type-dot { background: #f59e0b; }
.type-cover .node-type-dot { background: #8b5cf6; }
.type-upsample .node-type-dot { background: #0ea5e9; }
.type-other .node-type-dot { background: #6b7280; }

.node-title {
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.node-badges {
  font-size: 12px;
}

.node-model {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.lineage-legend {
  display: flex;
  gap: 16px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

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

.legend-dot.upload { background: #ec4899; }
.legend-dot.extend { background: #22c55e; }
.legend-dot.edit { background: #f59e0b; }
.legend-dot.cover { background: #8b5cf6; }
.legend-dot.other { background: #6b7280; }
