:root {
  --bg: #060606;
  --bg-elevated: #0c0c0e;
  --surface: #111114;
  --surface-hover: #18181b;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.35);
  --accent-2: #8b5cf6;
  --favorite: #f43f5e;
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  --radius-sm: 10px;
  /* Dynamically overridden from cover art */
  --cover-accent: #38bdf8;
  --cover-accent-rgb: 56, 189, 248;
  --cover-glow: rgba(56, 189, 248, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: radial-gradient(circle at 50% 0%, #101014 0%, var(--bg) 55%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#visualizer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

.cover-backdrop {
  position: fixed;
  inset: -60px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(70px) saturate(1.5) brightness(0.7);
  opacity: 0;
  z-index: 0;
  transition: opacity 0.9s ease, background-image 0.6s ease;
  pointer-events: none;
  will-change: transform;
  transform: translateZ(0);
}

.cover-backdrop.loaded {
  opacity: 0.22;
}

.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(6, 6, 6, 0.9), rgba(6, 6, 6, 0.6));
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-glyph {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  box-shadow: 0 0 24px var(--accent-glow);
}

.brand-glyph svg {
  width: 24px;
  height: 24px;
}

.brand-title {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.app-main {
  position: relative;
  z-index: 5;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 420px);
  gap: 28px;
  padding: 28px;
  min-height: 0;
}

.deck-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 64px;
  min-height: 0;
}

.deck {
  position: relative;
  width: min(52vh, 520px);
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  background: linear-gradient(145deg, #15151a, #0d0d10);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-lg),
    0 0 0 1px var(--border);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.6s ease;
}

.deck.playing {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-lg),
    0 0 0 1px var(--border),
    0 0 70px rgba(var(--cover-accent-rgb), 0.16);
}

.deck-rim {
  width: 88%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a2a30, #0e0e11 65%);
  box-shadow:
    inset 0 0 20px rgba(0,0,0,0.8),
    0 0 0 8px #121216,
    0 0 0 9px rgba(255,255,255,0.04);
  display: grid;
  place-items: center;
}

.platter {
  width: 96%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #1f1f24, #050507 72%);
  display: grid;
  place-items: center;
}

.record {
  position: relative;
  width: 94%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background:
    repeating-radial-gradient(
      circle at 50% 50%,
      transparent 0px,
      transparent 2px,
      rgba(0,0,0,0.35) 3px,
      rgba(0,0,0,0.35) 4px
    ),
    linear-gradient(145deg, #1a1a1f, #0a0a0d);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 18px 40px rgba(0,0,0,0.6);
  animation: spin 1.818s linear infinite;
  animation-play-state: paused;
  transition: filter 0.3s ease, animation-duration 0.4s ease;
}

.record::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.08), transparent 50%);
  pointer-events: none;
}

.record.playing {
  animation-play-state: running;
}

.record.braking {
  animation-duration: 6s;
  filter: brightness(0.85);
}

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

.grooves {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: repeating-radial-gradient(
    circle at 50% 50%,
    rgba(0,0,0,0.25) 0px,
    rgba(0,0,0,0.25) 1px,
    transparent 2px,
    transparent 4px
  );
  pointer-events: none;
}

.label {
  position: absolute;
  inset: 32%;
  border-radius: 50%;
  overflow: hidden;
  background: conic-gradient(from 180deg, #1f2937, #111827, #374151, #111827);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.04);
}

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

.tonearm {
  position: absolute;
  top: 8%;
  right: 8%;
  width: 38%;
  height: 38%;
  transform-origin: 85% 15%;
  transform: rotate(-38deg);
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 4;
}

.tonearm.playing {
  transform: rotate(12deg);
}

.tonearm-pivot {
  position: absolute;
  top: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #9ca3af, #374151);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.tonearm-arm {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 90%;
  height: 8px;
  background: linear-gradient(90deg, #6b7280, #d1d5db 40%, #9ca3af);
  transform-origin: right center;
  transform: rotate(-45deg);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.tonearm-head {
  position: absolute;
  bottom: 8%;
  left: 8%;
  width: 22px;
  height: 32px;
  background: linear-gradient(180deg, #4b5563, #1f2937);
  border-radius: 6px;
  transform: rotate(-45deg);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}

.tonearm-head::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 10px;
  background: #ef4444;
  border-radius: 2px;
}

.deck-controls {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
}

.control-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn:hover {
  background: rgba(255,255,255,0.12);
  transform: scale(1.06);
}

.control-btn svg {
  width: 22px;
  height: 22px;
}

.play-btn {
  width: 56px;
  height: 56px;
  background: var(--text);
  color: var(--bg);
  border: none;
  box-shadow: 0 0 24px rgba(255,255,255,0.15);
}

.play-btn:hover {
  background: #fff;
  box-shadow: 0 0 32px rgba(255,255,255,0.25);
}

.play-btn svg {
  width: 28px;
  height: 28px;
}

.progress-wrap {
  position: absolute;
  bottom: -42px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}

.time {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 34px;
  text-align: center;
}

.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  position: relative;
  overflow: visible;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--cover-accent), var(--accent-2));
  box-shadow: 0 0 12px var(--cover-glow);
  transition: width 0.1s linear;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%) scale(0);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.3);
  transition: transform 0.15s ease, left 0.1s linear;
}

.progress-bar:hover .progress-thumb,
.progress-bar.dragging .progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.song-meta {
  text-align: center;
  max-width: 560px;
}

.song-title {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}

.song-details {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.song-theme {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0 auto 16px;
  max-width: 480px;
}

.favorite-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.favorite-btn:hover {
  border-color: var(--favorite);
  color: var(--favorite);
  background: rgba(244, 63, 94, 0.08);
}

.favorite-btn.active {
  background: rgba(244, 63, 94, 0.14);
  border-color: var(--favorite);
  color: var(--favorite);
}

.favorite-btn.active svg {
  fill: currentColor;
}

.favorite-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Download / Share actions ── */
.song-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* Share-bar containers — position only; the bar styles itself (tool-share.js). */
.tool-share {
  display: inline-flex;
}
.track-share {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.action-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 96px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.action-label svg {
  width: 15px;
  height: 15px;
  color: var(--cover-accent);
}

.action-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.action-btn:hover:not(:disabled) {
  color: var(--cover-accent);
  border-color: var(--cover-accent);
  background: rgba(var(--cover-accent-rgb), 0.1);
}

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

.action-status {
  min-height: 1em;
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--cover-accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.action-status.show {
  opacity: 1;
}

.panel-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius);
  background: rgba(12, 12, 14, 0.72);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  flex: 1;
  padding: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.panel-tab.active {
  color: var(--cover-accent);
  box-shadow: inset 0 -2px 0 var(--cover-accent);
}

.panel-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.panel-content {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.panel-content.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.library-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.library-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.library-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}

.library-item.active {
  border-color: var(--cover-accent);
  background: rgba(var(--cover-accent-rgb), 0.08);
}

.library-item .thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #000;
  flex-shrink: 0;
}

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

.library-item .info .name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-item .info .meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.library-item .fav-icon {
  width: 18px;
  height: 18px;
  color: var(--favorite);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.library-item.favorited .fav-icon {
  opacity: 1;
}

.lyrics-scroll {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.lyrics-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 40px 0;
}

.lyrics-section {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border-left: 2px solid transparent;
  transition: all 0.3s ease;
}

.lyrics-section.active {
  background: rgba(var(--cover-accent-rgb), 0.08);
  border-left-color: var(--cover-accent);
}

.lyrics-section h4 {
  margin: 0 0 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cover-accent);
}

.lyrics-section p {
  margin: 0 0 6px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.lyrics-section.active p {
  color: var(--text);
}

@media (max-width: 980px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
  }

  .deck {
    width: min(72vw, 380px);
  }

  .deck-section {
    padding-top: 10px;
  }

  .panel-section {
    min-height: 420px;
  }
}

@media (max-width: 520px) {
  .app-header {
    padding: 14px 18px;
  }

  .brand-title {
    font-size: 1rem;
  }

  .app-main {
    padding: 18px;
    gap: 20px;
  }

  .deck {
    padding: 16px;
  }

  .progress-wrap {
    bottom: -36px;
  }
}
