/* ============================================
   SUNO EXPLORER - Insights Page
   ============================================ */

:root {
  --bg-base: #09090b;
  --bg-surface: #111113;
  --bg-elevated: #18181b;
  --bg-hover: #232328;
  
  --text-primary: #fafafa;
  --text-secondary: #e6e6e6;
  --text-muted: #52525b;
  
  --accent: #a855f7;
  --accent-bright: #c084fc;
  --accent-dim: rgba(168, 85, 247, 0.15);
  
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --liked: #f43f5e;
  --info: #3b82f6;
  
  --gold: #fbbf24;
  --silver: #9ca3af;
  --bronze: #d97706;
  
  --border: #27272a;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --font-sans: 'Space Grotesk', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  height: 100%;
}

/* ============================================
   INSIGHTS LAYOUT WITH SIDEBAR NAV
   ============================================ */

.insights-layout {
  display: flex;
  min-height: calc(100vh - 70px);
}

.section-nav {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: fixed;
  top: 70px;
  left: 0;
  height: calc(100vh - 70px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}

/* Offset main content for fixed sidebar */
.insights-layout .main {
  margin-left: 200px;
}

.nav-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 16px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

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

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

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile: Hide sidebar, show compact nav */
@media (max-width: 900px) {
  .section-nav {
    display: none;
  }
  
  .insights-layout .main {
    margin-left: 0;
  }
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100%;
  overflow-x: hidden;
}

/* Performance optimizations */
.section {
  contain: content; /* Strong containment for sections */
}

.word-cloud,
.tag-cloud,
.genre-tags {
  contain: layout style;
}

/* Disable heavy transforms on many elements */
.word-cloud-word,
.tag,
.genre-tag {
  transform: none !important; /* Prevent transform animations on hover */
}

/* ============================================
   Header
   ============================================ */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.back-btn {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

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

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

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

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

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

.last-updated {
  font-size: 13px;
  color: var(--text-muted);
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

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

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

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

.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

/* ============================================
   Hero Stats
   ============================================ */

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 40px;
}

.hero-stat {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
}

.hero-value {
  display: block;
  font-size: 48px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-bottom: 8px;
}

.hero-label {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ============================================
   Sections
   ============================================ */

.section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.section-full {
  grid-column: 1 / -1;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   Two Column Layout
   ============================================ */

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

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

.column .section {
  flex: 1;
}

/* ============================================
   Achievements
   ============================================ */

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.achievement {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.achievement:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.achievement-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
}

.achievement-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.achievement-value {
  font-size: 12px;
  color: var(--text-muted);
}

.achievement.gold { border-color: var(--gold); }
.achievement.silver { border-color: var(--silver); }
.achievement.bronze { border-color: var(--bronze); }

.achievement.gold .achievement-icon { filter: drop-shadow(0 0 8px var(--gold)); }
.achievement.silver .achievement-icon { filter: drop-shadow(0 0 8px var(--silver)); }
.achievement.bronze .achievement-icon { filter: drop-shadow(0 0 8px var(--bronze)); }

/* ============================================
   Top Lists
   ============================================ */

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

.top-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  padding-right: 40px; /* Room for menu button */
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  transition: background 0.15s;
  position: relative;
}

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

.top-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.top-rank.rank-1 { background: var(--gold); color: #000; }
.top-rank.rank-2 { background: var(--silver); color: #000; }
.top-rank.rank-3 { background: var(--bronze); color: #fff; }
.top-rank.rank-other { background: var(--bg-base); color: var(--text-muted); }

.top-cover {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-base);
  flex-shrink: 0;
}

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

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

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

.top-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-bright);
  flex-shrink: 0;
}

/* ============================================
   Model Bars
   ============================================ */

.model-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.model-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.model-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.model-bar-label {
  font-weight: 500;
}

.model-bar-value {
  color: var(--text-muted);
}

.model-bar-track {
  height: 12px;
  background: var(--bg-base);
  border-radius: 6px;
  overflow: hidden;
}

.model-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}

.model-bar-fill.v3 { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.model-bar-fill.v35 { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
.model-bar-fill.v4 { background: linear-gradient(90deg, #22c55e, #4ade80); }
.model-bar-fill.v45 { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.model-bar-fill.v5 { background: linear-gradient(90deg, #a855f7, #c084fc); }
.model-bar-fill.upload { background: linear-gradient(90deg, #ec4899, #f472b6); }
.model-bar-fill.chirp { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }
.model-bar-fill.other { background: linear-gradient(90deg, #6b7280, #9ca3af); }

/* ============================================
   Tag Cloud
   ============================================ */

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

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

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

.toggle-badge {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.toggle-badge input {
  display: none;
}

.toggle-label {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s;
}

.toggle-badge input:checked + .toggle-label {
  background: var(--accent);
  border-color: var(--accent);
}

.tag-view-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: 8px;
}

.tag-tab {
  flex: 1;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

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

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

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

.tag {
  padding: 6px 14px;
  background: var(--bg-elevated);
  border-radius: 99px;
  font-size: 13px;
  transition: all 0.15s;
  cursor: default;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.tag:hover {
  background: var(--accent-dim);
  color: var(--accent-bright);
  transform: scale(1.03);
}

.tag-badge {
  background: rgba(168, 85, 247, 0.3);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  transition: all 0.15s;
}

.tag-cloud.hide-counts .tag-badge {
  opacity: 0;
  width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.tag-cloud.hide-counts .tag:hover .tag-badge {
  opacity: 1;
  width: auto;
  padding: 2px 6px;
  position: absolute;
  right: -10px;
  top: -10px;
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.tag-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Tag sizes based on frequency */
.tag.size-1 { font-size: 12px; opacity: 0.7; }
.tag.size-2 { font-size: 13px; opacity: 0.8; }
.tag.size-3 { font-size: 14px; opacity: 0.9; }
.tag.size-4 { font-size: 15px; font-weight: 500; }
.tag.size-5 { font-size: 16px; font-weight: 600; background: var(--accent-dim); color: var(--accent-bright); }

/* ============================================
   Activity Stats
   ============================================ */

.activity-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.activity-stat {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

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

.activity-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================
   Heatmap
   ============================================ */

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

.heatmap-header .section-title {
  margin: 0;
}

.year-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.year-nav-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
}

.year-nav-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}

.year-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.year-label {
  font-size: 18px;
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.heatmap-container {
  min-width: 900px;
}

.heatmap-months {
  display: flex;
  padding-left: 32px;
  margin-bottom: 4px;
}

.heatmap-month {
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
  flex-shrink: 0;
}

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

.heatmap-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--text-muted);
  width: 28px;
}

.heatmap-labels span {
  height: 12px;
  line-height: 12px;
}

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

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

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--bg-elevated);
  transition: all 0.15s;
  cursor: pointer;
}

.heatmap-cell:hover {
  transform: scale(1.3);
  outline: 2px solid var(--accent);
}

.heatmap-cell[data-level="0"] { background: var(--bg-elevated); }
.heatmap-cell[data-level="1"] { background: rgba(168, 85, 247, 0.25); }
.heatmap-cell[data-level="2"] { background: rgba(168, 85, 247, 0.45); }
.heatmap-cell[data-level="3"] { background: rgba(168, 85, 247, 0.65); }
.heatmap-cell[data-level="4"] { background: rgba(168, 85, 247, 0.85); }
.heatmap-cell[data-level="5"] { background: var(--accent); }

.heatmap-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.heatmap-stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.heatmap-stats span:first-child {
  font-weight: 600;
  color: var(--accent-bright);
}

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

.legend-cells {
  display: flex;
  gap: 3px;
}

.legend-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-cell[data-level="0"] { background: var(--bg-elevated); }
.legend-cell[data-level="1"] { background: rgba(168, 85, 247, 0.25); }
.legend-cell[data-level="2"] { background: rgba(168, 85, 247, 0.45); }
.legend-cell[data-level="3"] { background: rgba(168, 85, 247, 0.65); }
.legend-cell[data-level="4"] { background: rgba(168, 85, 247, 0.85); }

/* ============================================
   Fun Facts
   ============================================ */

.fun-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.fun-fact {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.fun-fact-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.fun-fact-content {
  flex: 1;
}

.fun-fact-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.fun-fact-value {
  font-size: 13px;
  color: var(--text-secondary);
}

.fun-fact-value strong {
  color: var(--accent-bright);
}

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

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

.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); }
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1024px) {
  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }
  
  .hero-stats {
    grid-template-columns: 1fr;
  }
  
  .hero-value {
    font-size: 36px;
  }
  
  .main {
    padding: 16px;
  }
}

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

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

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

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

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

/* Inline refresh button */
.btn-refresh-inline {
  margin-top: 16px;
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Loading Overlay */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 9, 11, 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-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;
}

/* ============================================
   Word Cloud
   ============================================ */

.dna-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
}

.word-cloud-tabs {
  display: flex;
  gap: 8px;
}

.dna-view-tabs {
  width: auto;
  flex-shrink: 0;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: 8px;
}

.dna-view-tab {
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

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

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

/* Aggregation mode toggle */
/* Insights Filters */
.insights-filters {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  background: var(--bg-surface);
  border: 1px solid transparent;
}

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

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

.filter-toggle input {
  display: none;
}

.filter-icon {
  font-size: 16px;
}

.filter-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-toggle:has(input:checked) .filter-label {
  color: var(--accent-bright);
}

.filter-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  font-style: italic;
}

.creator-select {
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  min-width: 140px;
  max-width: 200px;
}

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

.filter-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent);
  margin-left: 12px;
}

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

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

/* ============================================
   Genre Explorer
   ============================================ */

.section-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* Tag Search */
.tag-search-container {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.tag-search-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}

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

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

.tag-search-btn {
  padding: 12px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

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

.search-tags-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.search-tags-display {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.search-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 20px;
  color: var(--accent-bright);
  font-size: 13px;
}

.tag-remove-btn {
  background: none;
  border: none;
  color: var(--accent-bright);
  font-size: 16px;
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  margin-left: 4px;
  line-height: 1;
  transition: opacity 0.15s;
}

.tag-remove-btn:hover {
  opacity: 1;
}

.tag-plus {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.btn-back {
  margin-left: auto;
}

.genre-container {
  min-height: 300px;
}

.genre-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.genre-category {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border);
}

.genre-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.genre-category-icon {
  font-size: 18px;
}

.genre-category-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.genre-category-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 8px;
  border-radius: 10px;
}

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

.genre-tag {
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* Performance: reduce paint on hover */
.genre-tag,
.tag,
.word-cloud-word {
  backface-visibility: hidden;
}

.genre-tag-count {
  font-size: 10px;
  opacity: 0.6;
  font-weight: 500;
}

/* Genre Detail View */
.genre-detail {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
}

.genre-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.genre-detail-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-bright);
}

.genre-detail-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 4px 10px;
  border-radius: 12px;
}

.genre-song-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  max-height: 450px;
  overflow-y: auto;
  contain: layout style;
}

/* Universal Song Card */
.song-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  padding-right: 40px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: background 0.1s;
}

.song-card:hover {
  background: var(--bg-hover);
}

.song-card.playing {
  background: var(--accent-dim);
  outline: 1px solid var(--accent);
}

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

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

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

.card-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

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

.card-tag.liked {
  background: rgba(244, 63, 94, 0.15);
  color: var(--liked);
  padding: 2px 4px;
}

.card-tag.model {
  background: var(--accent-dim);
  color: var(--accent-bright);
}

.card-tag.type {
  padding: 2px 4px;
}

.card-play {
  position: absolute;
  left: 10px;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 2;
}

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

.song-card:hover .card-thumb {
  opacity: 0.5;
}

.song-card.playing .card-play {
  opacity: 1;
}

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

.card-menu {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: var(--bg-elevated);
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s;
}

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

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

/* Legacy class compatibility */
.genre-song-liked {
  color: var(--liked);
}

.genre-more {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 10px;
}

/* Clickable tags in tag cloud */
.clickable-tag,
.clickable-dna-tag {
  cursor: pointer;
  transition: all 0.15s;
}

.clickable-tag:hover,
.clickable-dna-tag:hover {
  background: var(--accent-dim) !important;
  border-color: var(--accent) !important;
  /* Removed transform for performance */
}

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

.now-playing-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.np-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 280px;
  min-width: 0;
}

.np-cover {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

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

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

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

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

.np-tag.liked { background: rgba(244, 63, 94, 0.2); color: var(--liked); }
.np-tag.model { background: var(--accent-dim); color: var(--accent-bright); }

.np-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 600px;
}

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

.np-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.15s;
}

.np-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.1);
}

#npPlayPause {
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

#npPlayPause:hover {
  background: var(--accent-bright);
}

.np-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

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

.np-time:last-child {
  text-align: right;
}

.np-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.np-progress-bar:hover {
  height: 6px;
}

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

.np-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.np-suno-link {
  font-size: 16px;
}

/* Add padding to main when player is visible */
body:has(.now-playing-bar[style*="flex"]) .main {
  padding-bottom: 100px;
}

/* Genre song item play button */
.genre-song-play {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s;
}

.genre-song-item:hover .genre-song-play {
  opacity: 1;
}

.genre-song-play:hover {
  transform: scale(1.1);
  background: var(--accent-bright);
}

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

.genre-song-item.playing .genre-song-play {
  opacity: 1;
}

/* Top list play buttons */
.playable-item {
  position: relative;
}

.top-play-btn {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.playable-item:hover .top-play-btn {
  opacity: 1;
}

.top-play-btn:hover {
  transform: translateY(-50%) scale(1.1);
  background: var(--accent-bright);
}

.playable-item:hover .top-rank {
  opacity: 0;
}

.playable-item.playing {
  background: var(--accent-dim);
}

.playable-item.playing .top-play-btn {
  opacity: 1;
}

/* Clip tags in top lists */
.clip-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  margin-right: 4px;
}

.clip-tag.liked {
  background: rgba(244, 63, 94, 0.15);
  color: var(--liked);
  padding: 2px 4px;
}

.clip-tag.model {
  background: var(--accent-dim);
  color: var(--accent-bright);
}

.clip-tag.type {
  padding: 2px 4px;
}

/* Top item menu button */
.top-item-menu {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: var(--bg-elevated);
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.playable-item:hover .top-item-menu {
  opacity: 1;
}

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

/* Context menu */
.clip-context-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 0;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

.clip-context-menu .menu-item:hover {
  background: var(--bg-hover);
}

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

/* 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: 3000;
}

.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-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;
}

.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;
}

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

.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;
}

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

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

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

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

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

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

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

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

/* Validation Modal */
.modal-wide {
  width: 600px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-wide .modal-body {
  flex: 1;
  overflow-y: auto;
  max-height: 60vh;
}

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

.validation-section {
  margin-bottom: 20px;
}

.validation-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.validation-section h4 .status-ok { color: var(--success); }
.validation-section h4 .status-warn { color: var(--warning); }
.validation-section h4 .status-error { color: var(--danger); }

.validation-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
}

.validation-stat-label {
  color: var(--text-secondary);
}

.validation-stat-value {
  font-weight: 500;
  font-family: var(--font-mono);
}

.validation-stat-value.ok { color: var(--success); }
.validation-stat-value.warn { color: var(--warning); }
.validation-stat-value.error { color: var(--danger); }

.validation-issues {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
}

.validation-issue {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.validation-issue:last-child {
  border-bottom: none;
}

.validation-issue-title {
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.validation-issue-reason {
  color: var(--text-muted);
  flex-shrink: 0;
}

.validation-summary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.validation-summary h4 {
  margin-bottom: 12px;
}

.validation-recommendation {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.validation-recommendation strong {
  color: var(--accent-bright);
}

/* Data Gaps Info Section */
.data-gaps-info {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.data-gaps-info h4 {
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.data-gaps-explanation {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.data-gaps-explanation p {
  margin-bottom: 8px;
}

.data-gaps-explanation ul {
  margin: 8px 0 8px 16px;
  padding: 0;
}

.data-gaps-explanation li {
  margin-bottom: 6px;
}

.data-gaps-explanation strong {
  color: var(--text-primary);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 4000;
}

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

.toast.success {
  border-color: var(--success);
}

#closeGenreDetail {
  font-size: 12px;
  padding: 6px 12px;
}

.btn-small {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

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

.wc-tab {
  padding: 8px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

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

.wc-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.word-cloud-container {
  background: var(--bg-base);
  border-radius: var(--radius-lg);
  padding: 32px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  max-width: 900px;
}

.word-cloud-word {
  padding: 4px 12px;
  border-radius: 4px;
  cursor: default;
  transition: all 0.2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.word-cloud-word:hover {
  transform: scale(1.1);
  background: var(--accent-dim);
}

.word-cloud-word .tag-badge {
  font-size: 10px;
  vertical-align: middle;
}

.word-cloud.hide-counts .word-cloud-word .tag-badge {
  opacity: 0;
  width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.word-cloud.hide-counts .word-cloud-word:hover .tag-badge {
  opacity: 1;
  width: auto;
  padding: 2px 6px;
  position: absolute;
  right: -10px;
  top: -10px;
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.word-cloud-word.size-1 { font-size: 12px; color: var(--text-muted); }
.word-cloud-word.size-2 { font-size: 15px; color: var(--text-secondary); }
.word-cloud-word.size-3 { font-size: 19px; color: var(--text-primary); font-weight: 500; }
.word-cloud-word.size-4 { font-size: 24px; color: var(--accent-bright); font-weight: 600; }
.word-cloud-word.size-5 { font-size: 30px; color: var(--accent); font-weight: 700; }

.word-cloud-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}

/* ============================================
   SUNO WRAPPED SHARE CARD
   ============================================ */

.wrapped-section {
  background: linear-gradient(135deg, var(--bg-surface), rgba(168, 85, 247, 0.05));
  border: 1px solid var(--accent-dim);
}

.wrapped-header {
  text-align: center;
  margin-bottom: 24px;
}

.wrapped-header .section-title {
  margin-bottom: 4px;
}

.wrapped-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* Wrapped Tabs */
.wrapped-tabs {
  display: flex;
  gap: 32px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.tab-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 500;
}

.tab-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.wrapped-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 70px;
}

.wrapped-tab:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.wrapped-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-bright);
}

.tab-icon {
  font-size: 24px;
  line-height: 1;
}

.tab-label {
  font-size: 11px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}

.wrapped-tab.active .tab-label {
  color: var(--accent-bright);
}

/* Controls row */
.wrapped-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.wrapped-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.wrapped-select:hover {
  border-color: var(--text-muted);
}

.wrapped-preview {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.preview-placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.wrapped-preview canvas {
  max-width: 100%;
  max-height: 500px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.wrapped-download {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

@media (max-width: 640px) {
  .wrapped-header {
    flex-direction: column;
  }
  
  .wrapped-actions {
    width: 100%;
  }
  
  .wrapped-select {
    flex: 1;
  }
}

/* ============================================
   LINEAGE EXPLORER
   ============================================ */

.upload-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.upload-stat {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  text-align: center;
}

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

.upload-stat .stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.uploads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.upload-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
}

.upload-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border-color: var(--accent);
}

.upload-thumbnail {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
}

.upload-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: var(--accent-bright);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}

.upload-info {
  padding: 12px;
}

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

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

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

.lineage-empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

.lineage-empty .muted {
  font-size: 13px;
  margin-top: 8px;
}

/* Lineage Modal */
.lineage-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  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);
}

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

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

.lineage-modal-filters {
  display: flex;
  gap: 8px;
  margin-left: auto;
  margin-right: 16px;
}

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

.lineage-filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

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

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

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

.lineage-stat.muted {
  color: var(--text-muted);
  background: transparent;
}

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

.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 thumbnails - hidden by default */
.node-thumb-wrap {
  display: none;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
}

.show-thumbnails .node-thumb-wrap {
  display: block;
}

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

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

.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; }

