/* ============================================
   Suno Explorer - Public Site Styles
   ============================================ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-elevated: #1a1a25;
  --bg-active: #252535;
  --text-primary: #f0f0f5;
  --text-secondary: #8888aa;
  --text-muted: #555566;
  --accent: #7c5cff;
  --accent-dim: rgba(124, 92, 255, 0.15);
  --accent-bright: #9d85ff;
  --border: #2a2a3a;
  --error: #ff5c5c;
  --success: #5cff7c;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --header-height: 60px;
  --sidebar-width: 260px;
  --panel-width: 400px;
  --player-height: 72px;
}

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

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
  transition: opacity 0.3s, visibility 0.3s;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

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

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-content {
  max-width: 1800px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.header-nav {
  display: flex;
  gap: 24px;
}

.header-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--accent);
}

/* Main Layout */
.app {
  padding-top: var(--header-height);
}

.main-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px;
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: var(--player-height);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

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

.stat-item {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  display: block;
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

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

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

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

.view-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.view-options .option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.view-options input[type="radio"] {
  accent-color: var(--accent);
}

.filter-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

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

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

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

.insight-item {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.insight-item strong {
  color: var(--text-primary);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 20px;
  padding-bottom: calc(var(--player-height) + 20px);
}

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

.result-count {
  font-size: 14px;
  color: var(--text-secondary);
}

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

/* Song Grid */
.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.song-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.song-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.song-cover-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}

.song-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-elevated);
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 32px;
  cursor: pointer;
}

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

.play-overlay:hover {
  background: rgba(0, 0, 0, 0.7);
}

.song-cover-collage {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  gap: 2px;
  background: var(--bg-elevated);
}

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

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

.song-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
}

.song-badge {
  padding: 2px 6px;
  background: rgba(0,0,0,0.7);
  border-radius: var(--radius-sm);
  font-size: 10px;
}

.song-info {
  padding: 12px;
}

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

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

.song-links {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.song-link {
  padding: 3px 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
}

.song-link:hover {
  background: var(--accent);
  color: white;
}

/* Version Panel */
.version-panel {
  position: fixed;
  top: var(--header-height);
  right: -500px;
  width: var(--panel-width);
  bottom: var(--player-height);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  transition: right 0.3s ease;
  z-index: 90;
  display: flex;
  flex-direction: column;
}

.version-panel.open {
  right: 0;
}

.panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
}

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

.panel-header {
  padding: 20px;
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-cover {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

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

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

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

/* Quick Play Buttons */
.quick-play-buttons {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

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

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

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

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

.panel-tab {
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

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

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

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

.tab-action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.tab-action-btn:hover {
  background: var(--bg-elevated);
}

.tab-action-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Panel Tab Content */
.panel-tab-content {
  flex: 1;
  overflow-y: auto;
  display: none;
}

.panel-tab-content.active {
  display: block;
}

/* DNA Strand Headers */
.dna-strand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin: 16px 0 8px;
  background: linear-gradient(90deg, var(--bg-elevated), transparent);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 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(--text-primary);
}

.dna-strand-count {
  color: var(--text-secondary);
  background: var(--bg-active);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

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

/* Collapsed Group */
.collapsed-group {
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin: 8px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Inline Lineage Tree - Compact like Suno Explorer */
.lineage-tree-inline {
  padding: 8px;
  font-size: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 400px);
}

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

.lineage-controls button {
  padding: 4px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
}

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

.lineage-tree-inline .lineage-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

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

.lineage-tree-inline .lineage-node.playing {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
}

.lineage-tree-inline .lineage-node.root {
  border-left: 2px solid var(--accent);
}

.lineage-tree-inline .lineage-node.external {
  opacity: 0.7;
  border-left: 2px dashed var(--text-muted);
}

.lineage-external-parent {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent);
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.lineage-external-parent:hover {
  background: var(--bg-active);
  border-left-color: var(--accent-bright, #9d7cff);
}

.external-parent-expand {
  font-size: 10px;
  color: var(--accent);
  opacity: 0.7;
}

.lineage-external-parent:hover .external-parent-expand {
  opacity: 1;
}

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

.lineage-tree-inline .lineage-thumb.hidden {
  display: none;
}

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

.lineage-tree-inline .lineage-title {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.lineage-tree-inline .lineage-tag {
  padding: 1px 4px;
  background: var(--bg-active);
  border-radius: 2px;
  font-size: 9px;
}

.lineage-tree-inline .lineage-indent {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

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

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

/* ASCII Tree Structure (matching suno-explorer) */
.tree-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 2px;
}

.tree-branch {
  font-family: monospace;
  color: var(--border);
  white-space: pre;
  line-height: 40px;
  flex-shrink: 0;
  user-select: none;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex: 1;
  min-width: 0;
  transition: background 0.15s;
}

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

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

.tree-node.liked {
  border-left: 2px solid #ff5c5c;
}

.tree-node.external {
  opacity: 0.7;
  border-left: 2px dashed var(--text-muted);
}

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

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

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

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

.tree-model, .tree-vocal {
  padding: 1px 4px;
  background: var(--bg-active);
  border-radius: 3px;
  font-size: 10px;
}

.tree-tag {
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}

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

.tree-tag.tag-original {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
}

.tree-tag.tag-from-upload {
  background: rgba(124, 92, 255, 0.15);
  color: #a990ff;
}

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

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

/* Collapsed group in tree */
.tree-row .collapsed-group {
  flex: 1;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}

.tree-row .collapsed-group:hover {
  background: var(--bg-active);
  color: var(--text-secondary);
}

/* Version actions */
.version-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.trace-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0.6;
  transition: all 0.15s;
}

.trace-btn:hover {
  opacity: 1;
  background: var(--accent-dim);
}

/* Base Modal Overlay (for SunoModals) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay .modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay .modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.modal-overlay .modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: auto;
}

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

/* Lineage Modal Specific */
.lineage-modal-overlay .lineage-modal {
  width: 700px;
  max-width: 90vw;
}

.lineage-modal-title h2 {
  margin: 0;
  font-size: 18px;
}

.lineage-modal-title .lineage-root-name {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

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

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

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

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

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

.lineage-tree-container {
  padding: 16px;
  overflow-y: auto;
  max-height: 60vh;
}

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

.lineage-legend {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
}

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

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

.legend-dot.upload {
  background: var(--accent);
}

.legend-dot.extend {
  background: #5cff7c;
}

.legend-dot.edit {
  background: #ffb75c;
}

.legend-dot.other {
  background: #808080;
}

/* Tree Node in Full Modal */
.tree-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 4px 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

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

.tree-node.current {
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.tree-node.upload {
  border-left-color: var(--accent);
}

.tree-node.extend {
  border-left-color: #5cff7c;
}

.tree-node.edit {
  border-left-color: #ffb75c;
}

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

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

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

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

.tree-children {
  margin-left: 20px;
  padding-left: 12px;
  border-left: 1px dashed var(--border);
}

/* Trace Origin Modal */
.trace-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.trace-modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

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

.trace-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
}

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

.trace-body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
}

.trace-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

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

.trace-root-type {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

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

.trace-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: 10px;
  padding: 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

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

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

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

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

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

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

.ancestry-meta {
  font-size: 10px;
  color: var(--text-secondary);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.ancestry-tag {
  padding: 1px 5px;
  background: var(--bg-active);
  border-radius: 3px;
  font-size: 9px;
}

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

.ancestry-play {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-active);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 12px;
}

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

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

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

.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  transition: all 0.2s;
}

.panel-link:hover {
  background: var(--accent);
  color: white;
}

.version-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.version-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
  background: var(--bg-surface);
}

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

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

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

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

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

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

.version-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.version-tag {
  padding: 2px 6px;
  background: var(--bg-active);
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-secondary);
}

.version-tag.tag-vocal {
  background: rgba(92, 183, 255, 0.15);
  color: #5cb7ff;
}

.version-tag.tag-inst {
  background: rgba(255, 183, 92, 0.15);
  color: #ffb75c;
}

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

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

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

.version-tag.tag-derived {
  background: rgba(100, 149, 237, 0.15);
  color: #6495ed;
}

.version-tag.tag-link {
  background: rgba(92, 255, 124, 0.15);
  color: #5cff7c;
}

/* Origin row borders for quick visual distinction */
.version-item.origin-upload {
  border-left: 2px solid var(--accent);
}

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

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

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

/* Definitive badge */
.definitive-badge {
  color: #ffd700;
  margin-left: 4px;
}

/* Now Playing Menu */
.np-context-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 0;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
}

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

.np-context-menu .menu-item:hover:not([disabled]) {
  background: var(--bg-hover);
}

.np-context-menu .menu-item[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.np-action.np-menu {
  font-weight: bold;
  font-size: 18px;
  color: var(--text-secondary);
}

/* Now Playing Bar */
.now-playing {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-height);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 100;
  opacity: 0;
  transform: translateY(100%);
  transition: all 0.3s;
}

.now-playing.active {
  opacity: 1;
  transform: translateY(0);
}

.np-cover {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s;
}

.np-cover:hover {
  transform: scale(1.05);
}

.np-info {
  min-width: 150px;
  max-width: 200px;
}

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

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

.np-tag {
  padding: 1px 4px;
  background: var(--bg-active);
  border-radius: 3px;
  font-size: 9px;
}

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

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

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

.np-btn.primary {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: white;
}

.np-btn.primary:hover {
  transform: scale(1.08);
  background: var(--accent-bright);
}

.np-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
}

.np-time {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 36px;
  font-family: monospace;
}

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

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

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: var(--accent-bright);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
}

.progress-bar:hover .progress-fill::after {
  opacity: 1;
}

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

.np-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.2s;
}

.np-action:hover {
  background: var(--bg-active);
  color: var(--accent);
}

/* Legacy Lineage Modal - uses .active class to show */
#lineageModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

#lineageModal.active {
  opacity: 1;
  visibility: visible;
}

/* SunoModals lineage overlay - always visible when added to DOM */
/* SunoModals manages lifecycle by adding/removing from DOM */
.modal-overlay.lineage-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  opacity: 1 !important;
  visibility: visible !important;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s;
}

#lineageModal.active .modal-content {
  transform: scale(1);
}

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

.modal-header h2 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
}

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

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Lineage Tree */
.lineage-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lineage-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.lineage-node.root {
  border-left: 3px solid var(--accent);
}

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

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

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

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

.lineage-tag {
  padding: 2px 6px;
  background: var(--bg-active);
  border-radius: var(--radius-sm);
  font-size: 10px;
}

.lineage-indent {
  margin-left: 24px;
  border-left: 2px solid var(--border);
  padding-left: 12px;
}

/* Panel open state - adjust main content */
.app.panel-open .main-content {
  margin-right: var(--panel-width);
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .version-panel {
    width: 100%;
    right: -100%;
  }
}

@media (max-width: 600px) {
  .song-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .np-progress {
    display: none;
  }
  
  .np-info {
    min-width: 0;
    flex: 1;
  }
}

