/* ============================================================
   PlayMusic — Spotify-inspired Design System
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Tokens ────────────────────────────────────────────────── */
:root {
  --bg-base: #0c0c0e;
  --bg-elevated: #141416;
  --bg-surface: #1c1c20;
  --bg-surface-hover: #28282e;
  --bg-highlight: #202024;
  --bg-card: #1c1c20;
  --bg-card-hover: #28282e;
  --bg-player: #141416;
  --text-primary: #f2efe8;
  --text-secondary: #b0a898;
  --text-subdued: #6b6560;
  --accent: #D4A054;
  --accent-hover: #e0b56a;
  --accent-pressed: #b8893e;
  --accent-glow: rgba(212,160,84,0.3);
  --accent-subtle: rgba(212,160,84,0.1);
  --border-subtle: rgba(255,255,255,0.06);
  --border-active: rgba(255,255,255,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-card: 0 8px 24px rgba(0,0,0,0.3);
  --overlay-hover: rgba(255,255,255,0.08);
  --overlay-active: rgba(255,255,255,0.1);
  --overlay-card: rgba(255,255,255,0.06);
  --overlay-card-hover: rgba(255,255,255,0.12);
  --scrollbar-thumb: rgba(255,255,255,0.15);
  --slider-track: rgba(255,255,255,0.15);
  --nav-arrow-bg: rgba(0,0,0,0.7);
  --nav-arrow-bg-hover: rgba(0,0,0,0.9);
  --logo-circle: #1a1a1a;
  --overlay-dialog: rgba(0,0,0,0.7);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 500px;
  --transition-fast: 0.15s ease;
  --transition-med: 0.25s ease;
  --transition-slow: 0.35s cubic-bezier(0.25,0.46,0.45,0.94);
  --sidebar-width: 280px;
  --player-height: 90px;
  --danger: #ef4444;
  color-scheme: dark;
}

/* ── Light Mode (auto via system preference) ──────────────── */
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg-base: #f8f5f0;
    --bg-elevated: #ffffff;
    --bg-surface: #f0ebe3;
    --bg-surface-hover: #e5ddd2;
    --bg-highlight: #f3efe8;
    --bg-card: #f0ebe3;
    --bg-card-hover: #e5ddd2;
    --bg-player: #ffffff;
    --text-primary: #1a1815;
    --text-secondary: #5c5549;
    --text-subdued: #94897a;
    --accent: #b8893e;
    --accent-hover: #a67832;
    --accent-pressed: #946828;
    --accent-glow: rgba(184,137,62,0.2);
    --accent-subtle: rgba(184,137,62,0.08);
    --border-subtle: rgba(0,0,0,0.06);
    --border-active: rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-card: 0 4px 16px rgba(0,0,0,0.06);
    --overlay-hover: rgba(0,0,0,0.04);
    --overlay-active: rgba(0,0,0,0.07);
    --overlay-card: rgba(0,0,0,0.03);
    --overlay-card-hover: rgba(0,0,0,0.06);
    --scrollbar-thumb: rgba(0,0,0,0.15);
    --slider-track: rgba(0,0,0,0.12);
    --nav-arrow-bg: rgba(0,0,0,0.06);
    --nav-arrow-bg-hover: rgba(0,0,0,0.1);
    --logo-circle: #f0ebe3;
    --overlay-dialog: rgba(0,0,0,0.3);
    color-scheme: light;
  }
}

/* ── Light Mode (manual toggle) ───────────────────────────── */
html[data-theme="light"] {
  --bg-base: #f8f5f0;
  --bg-elevated: #ffffff;
  --bg-surface: #f0ebe3;
  --bg-surface-hover: #e5ddd2;
  --bg-highlight: #f3efe8;
  --bg-card: #f0ebe3;
  --bg-card-hover: #e5ddd2;
  --bg-player: #ffffff;
  --text-primary: #1a1815;
  --text-secondary: #5c5549;
  --text-subdued: #94897a;
  --accent: #b8893e;
  --accent-hover: #a67832;
  --accent-pressed: #946828;
  --accent-glow: rgba(184,137,62,0.2);
  --accent-subtle: rgba(184,137,62,0.08);
  --border-subtle: rgba(0,0,0,0.06);
  --border-active: rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-card: 0 4px 16px rgba(0,0,0,0.06);
  --overlay-hover: rgba(0,0,0,0.04);
  --overlay-active: rgba(0,0,0,0.07);
  --overlay-card: rgba(0,0,0,0.03);
  --overlay-card-hover: rgba(0,0,0,0.06);
  --scrollbar-thumb: rgba(0,0,0,0.15);
  --slider-track: rgba(0,0,0,0.12);
  --nav-arrow-bg: rgba(0,0,0,0.06);
  --nav-arrow-bg-hover: rgba(0,0,0,0.1);
  --logo-circle: #f0ebe3;
  --overlay-dialog: rgba(0,0,0,0.3);
  color-scheme: light;
}

/* ── Dark Mode (manual toggle) ────────────────────────────── */
html[data-theme="dark"] {
  --bg-base: #0c0c0e;
  --bg-elevated: #141416;
  --bg-surface: #1c1c20;
  --bg-surface-hover: #28282e;
  --bg-highlight: #202024;
  --bg-card: #1c1c20;
  --bg-card-hover: #28282e;
  --bg-player: #141416;
  --text-primary: #f2efe8;
  --text-secondary: #b0a898;
  --text-subdued: #6b6560;
  --accent: #D4A054;
  --accent-hover: #e0b56a;
  --accent-pressed: #b8893e;
  --accent-glow: rgba(212,160,84,0.3);
  --accent-subtle: rgba(212,160,84,0.1);
  --border-subtle: rgba(255,255,255,0.06);
  --border-active: rgba(255,255,255,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-card: 0 8px 24px rgba(0,0,0,0.3);
  --overlay-hover: rgba(255,255,255,0.08);
  --overlay-active: rgba(255,255,255,0.1);
  --overlay-card: rgba(255,255,255,0.06);
  --overlay-card-hover: rgba(255,255,255,0.12);
  --scrollbar-thumb: rgba(255,255,255,0.15);
  --slider-track: rgba(255,255,255,0.15);
  --nav-arrow-bg: rgba(0,0,0,0.7);
  --nav-arrow-bg-hover: rgba(0,0,0,0.9);
  --logo-circle: #1a1a1a;
  --overlay-dialog: rgba(0,0,0,0.7);
  color-scheme: dark;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ── Layout Grid ───────────────────────────────────────────── */
#root {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr var(--player-height);
  height: 100vh;
  gap: 0;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  padding: 0;
  grid-row: 1 / 2;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  padding: 18px 24px 8px;
  gap: 10px;
  color: var(--text-primary);
}
.brand-logo, .brand img {
  height: 40px;
  transition: filter var(--transition-fast);
}
.brand:hover .brand-logo,
.brand:hover img { filter: brightness(1.15); }

/* Navigation links */
.sidebar-nav {
  padding: 8px 12px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.938rem;
  transition: all var(--transition-fast);
  cursor: pointer;
}
.nav-item:hover { color: var(--text-primary); }
.nav-item.active {
  color: var(--text-primary);
}
.nav-item svg, .nav-item .nav-icon {
  width: 24px; height: 24px;
  flex-shrink: 0;
}
/* Account access lives in .sidebar-user on desktop/tablet; this tab is
   mobile-only (see the ≤768px block for where it's shown). */
.nav-item-account { display: none; }
/* Playlists live in .library-panel on desktop; mobile-only tab below. */
.nav-item-playlists { display: none; }

/* Library panel */
.library-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}
.library-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.938rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}
.library-header-title:hover { color: var(--text-primary); }
.library-header-title svg { width: 24px; height: 24px; }

.library-header-actions {
  display: flex; gap: 8px;
}
.library-header-actions button {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-size: 1.25rem;
}
.library-header-actions button:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

/* Library filter chips */
.library-filters {
  display: flex;
  gap: 8px;
  padding: 0 16px 8px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  font-size: 0.813rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.filter-chip:hover { background: var(--bg-surface-hover); }
.filter-chip.active {
  background: var(--text-primary);
  color: var(--bg-base);
}

/* Playlist list inside library */
.library-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
.library-list::-webkit-scrollbar { width: 8px; }
.library-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
.library-list::-webkit-scrollbar-track { background: transparent; }

.library-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.library-item:hover { background: var(--bg-surface-hover); }

.library-item-art {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-hover);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
  color: var(--text-subdued);
  overflow: hidden;
}
.library-item-art img {
  width: 100%; height: 100%; object-fit: cover;
}

.library-item-info {
  flex: 1;
  min-width: 0;
}
.library-item-name {
  font-size: 0.938rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-item-meta {
  font-size: 0.813rem;
  color: var(--text-subdued);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.library-item-delete {
  opacity: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}
.library-item:hover .library-item-delete { opacity: 1; }
.library-item-delete:hover { color: var(--text-primary); background: var(--overlay-active); }

/* ── Main Content ──────────────────────────────────────────── */
.main {
  background: var(--bg-elevated);
  border-radius: var(--radius-md) 0 0 0;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

/* Gradient header */
.main-gradient {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-elevated) 60%, transparent);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

/* Navigation arrows */
.nav-arrows { display: flex; gap: 8px; }
.nav-arrow {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--nav-arrow-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}
.nav-arrow:hover { background: var(--nav-arrow-bg-hover); transform: scale(1.05); }
.nav-arrow:disabled { opacity: 0.3; cursor: default; }

/* Search bar */
.search-container {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-container input {
  width: 100%;
  height: 42px;
  padding: 0 16px 0 42px;
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-med);
}
.search-container input::placeholder { color: var(--text-subdued); }
.search-container input:focus {
  background: var(--bg-surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subdued);
  width: 16px; height: 16px;
  pointer-events: none;
  transition: color var(--transition-fast);
}
.search-container input:focus ~ .search-icon,
.search-container:focus-within .search-icon { color: var(--accent); }

/* Content area */
.content-area {
  padding: 0 32px 32px;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 16px;
}
.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.section-see-all {
  font-size: 0.813rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color var(--transition-fast);
}
.section-see-all:hover { color: var(--text-primary); }

/* ── Track Grid ────────────────────────────────────────────── */
.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px;
}

.track-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: background var(--transition-med);
  position: relative;
}
.track-card:hover { background: var(--bg-card-hover); }

.track-art-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--bg-surface-hover);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.track-art-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-surface-hover);
}
/* Default music icon when no art */
.track-art-img::after {
  content: '♪';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-subdued);
}

/* Play button overlay on card */
.card-play-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(8px);
  transition: all var(--transition-med);
  z-index: 2;
}
.card-play-btn svg { width: 24px; height: 24px; fill: #000; }
.card-play-btn:hover { transform: translateY(0) scale(1.06); background: var(--accent-hover); }
.track-card:hover .card-play-btn { opacity: 1; transform: translateY(0); }

.track-title {
  font-size: 0.938rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.track-sub {
  font-size: 0.813rem;
  color: var(--text-subdued);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
  line-height: 1.4;
}

/* ── Track List (Table View) ───────────────────────────────── */
.track-list {
  width: 100%;
}
.track-list-header {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 100px;
  gap: 16px;
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
  color: var(--text-subdued);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.track-list-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 100px;
  gap: 16px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  align-items: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.track-list-row:hover { background: var(--overlay-active); }
.track-list-row.playing { color: var(--accent); }
.track-list-row.playing .track-row-title { color: var(--accent); }

.track-row-num {
  font-size: 0.938rem;
  color: var(--text-subdued);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.track-list-row:hover .track-row-num .num-text { display: none; }
.track-list-row:hover .track-row-num .play-icon { display: flex; }
.track-row-num .play-icon { display: none; color: var(--text-primary); justify-content: center; }

.track-row-info {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.track-row-text { min-width: 0; }
.track-row-title {
  font-size: 0.938rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-row-artist {
  font-size: 0.813rem;
  color: var(--text-subdued);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-row-album {
  font-size: 0.875rem;
  color: var(--text-subdued);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-row-duration {
  font-size: 0.875rem;
  color: var(--text-subdued);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.track-row-end {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}

.track-row-menu {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subdued);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -1px;
  opacity: 0;
  transition: color var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
}
.track-list-row:hover .track-row-menu,
.track-row-menu:focus-visible {
  opacity: 1;
}
.track-row-menu:hover,
.track-row-menu:focus-visible {
  color: var(--text-primary);
  background: var(--overlay-active);
}

/* Context menu for adding to playlist */
.track-row-actions {
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.track-list-row:hover .track-row-actions { opacity: 1; }
.track-row-actions button {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  font-size: 1rem;
  transition: all var(--transition-fast);
}
.track-row-actions button:hover { color: var(--text-primary); background: var(--overlay-active); }

/* ── Welcome / Quick-pick cards ────────────────────────────── */
.greeting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.greeting-card {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--overlay-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: background var(--transition-fast);
  height: 64px;
}
.greeting-card:hover { background: var(--overlay-card-hover); }
.greeting-card-art {
  width: 64px; height: 64px;
  background: var(--bg-surface-hover);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.greeting-card-name {
  flex: 1;
  padding: 0 16px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.greeting-card-play {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px;
  opacity: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: all var(--transition-med);
}
.greeting-card:hover .greeting-card-play { opacity: 1; }
.greeting-card-play svg { width: 16px; height: 16px; fill: #000; }

/* ── Player Bar ────────────────────────────────────────────── */
.player-bar {
  grid-column: 1 / -1;
  grid-row: 2;
  background: var(--bg-player);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2fr minmax(180px, 1fr);
  align-items: center;
  padding: 0 16px;
  height: var(--player-height);
  z-index: 100;
}

/* Left: Now Playing */
.player-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.mini-art {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-hover);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  transition: all var(--transition-med);
}
.mini-art:hover { border-radius: var(--radius-md); }
.now-playing-info { min-width: 0; }
.now-playing-title {
  position: relative;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  transition: color var(--transition-fast);
  cursor: pointer;
}
.now-playing-title:hover { text-decoration: underline; }
.now-playing-title .marquee-inner { display: inline-block; white-space: nowrap; }
/* Set by updateNowPlayingMarquee() in app.js only when the title actually overflows */
.now-playing-title.overflowing {
  text-overflow: clip;
  mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
}
.now-playing-title.overflowing .marquee-inner {
  animation: now-playing-marquee var(--marquee-duration, 8s) linear infinite;
  animation-delay: 1.4s;
}
@keyframes now-playing-marquee {
  0%, 12% { transform: translateX(0); }
  88%, 100% { transform: translateX(var(--marquee-distance, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .now-playing-title.overflowing .marquee-inner { animation: none; }
  .now-playing-title.overflowing { text-overflow: ellipsis; mask-image: none; }
}
.now-playing-artist {
  font-size: 0.688rem;
  color: var(--text-subdued);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  cursor: pointer;
}
.now-playing-artist:hover { color: var(--text-primary); text-decoration: underline; }
.player-like {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  font-size: 1rem;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.player-like:hover { color: var(--text-primary); }
.player-like.liked { color: var(--accent); }

/* Center: Controls + Progress */
.player-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 722px;
  margin: 0 auto;
  width: 100%;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.controls button {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all var(--transition-fast);
}
.controls button:hover { color: var(--text-primary); transform: scale(1.05); }
.controls button.active { color: var(--accent); }

.play-main {
  width: 36px !important; height: 36px !important;
  background: var(--text-primary) !important;
  color: var(--bg-base) !important;
  font-size: 1.125rem !important;
}
.play-main:hover { transform: scale(1.08) !important; background: var(--text-primary) !important; }

/* Progress bar */
.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.time-label {
  font-size: 0.688rem;
  color: var(--text-subdued);
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}
.time-label:first-child { text-align: right; }
.time-label:last-child { text-align: left; }

/* Custom range sliders */
.progress-bar {
  flex: 1;
  position: relative;
  height: 12px;
  display: flex;
  align-items: center;
}
.progress-bar input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--scrollbar-thumb);
  border-radius: 2px;
  outline: none;
  position: relative;
  cursor: pointer;
  transition: height var(--transition-fast);
}
.progress-bar:hover input[type="range"] { height: 6px; }

.progress-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.progress-bar:hover input[type="range"]::-webkit-slider-thumb { opacity: 1; }
.progress-bar input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.progress-bar:hover input[type="range"]::-moz-range-thumb { opacity: 1; }

/* Right: Volume + extras */
.player-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.player-right button {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}
.player-right button:hover { color: var(--text-primary); }
.player-right button.active { color: var(--accent); }

.volume-container {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 125px;
}
.volume-bar {
  flex: 1;
  position: relative;
  height: 12px;
  display: flex;
  align-items: center;
}
.volume-bar input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--scrollbar-thumb);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.volume-bar:hover input[type="range"] { height: 5px; }
.volume-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.volume-bar:hover input[type="range"]::-webkit-slider-thumb { opacity: 1; }
.volume-bar input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: none;
  background: var(--text-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.volume-bar:hover input[type="range"]::-moz-range-thumb { opacity: 1; }

/* ── Queue Panel ───────────────────────────────────────────── */
.queue-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: var(--player-height);
  width: 360px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
}
.queue-panel.visible { transform: translateX(0); }

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.queue-header h3 {
  font-size: 1rem;
  font-weight: 800;
  margin: 0;
}
.queue-header button {
  font-size: 0.75rem;
  color: var(--text-subdued);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
}
.queue-header button:hover { color: var(--text-primary); background: var(--overlay-active); }

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.queue-item:hover { background: var(--overlay-hover); }
.queue-item.active { background: var(--overlay-active); }
.queue-item-art {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-hover);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.queue-item-info { flex: 1; min-width: 0; }
.queue-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-item-artist {
  font-size: 0.75rem;
  color: var(--text-subdued);
}
.queue-item-remove {
  opacity: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}
.queue-item:hover .queue-item-remove { opacity: 1; }
.queue-item-remove:hover { color: var(--text-primary); background: var(--overlay-active); }

/* ── Playlist dropdown ─────────────────────────────────────── */
.playlist-dropdown {
  position: absolute;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 1px var(--border-subtle);
  padding: 4px;
  min-width: 200px;
  z-index: 200;
  animation: dropdown-in 0.15s ease;
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.playlist-dropdown-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: transparent;
}
@keyframes dropdown-in {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.playlist-dropdown-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}
.playlist-dropdown-item:hover {
  background: var(--overlay-active);
  color: var(--text-primary);
}
.playlist-dropdown-item.create {
  color: var(--text-subdued);
  font-weight: 600;
}
.playlist-dropdown-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* ── Toast notifications ───────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--player-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #000;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Mobile Controls (hidden on desktop) ─────────────────── */
.mobile-controls { display: none; }

/* ── Now Playing / Account sheets (mobile-only full-screen views).
   Without this, they have no base rule and render inline in normal
   document flow below the player bar on desktop widths, since their
   `position: fixed` + slide-in `transform` are only defined inside the
   ≤768px media query below. */
.now-playing-sheet, .account-sheet { display: none; }

/* ── Responsive ────────────────────────────────────────────── */
/* ── Tablet (≤1024px) ────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { width: 72px; padding: 12px 8px; }
  .brand img { width: 36px; }
  .brand { padding: 18px 12px 8px; justify-content: center; }
  .brand-logo text { display: none; }
  .nav-item { font-size: 0; gap: 0; padding: 12px; justify-content: center; }
  .nav-icon { margin: 0; }
  .library-panel { display: none; }
  /* Playlists panel is gone here — expose the dedicated nav entry. */
  .nav-item-playlists { display: flex; }
  .sidebar-user-details { display: none; }
  .sidebar-user-avatar { width: 28px; height: 28px; font-size: 0.75rem; }
  .sidebar-user { padding: 8px; }
  .sidebar-user-info { justify-content: center; padding: 6px; }
  .greeting-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .content-area { padding: 0 20px 32px; }
}

/* ── Mobile (≤768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    /* 68px fit a single packed row; now two rows (identity+transport row,
       ~48px, plus a progress row whose tallest sibling is the 44px lyrics/
       queue buttons) need more vertical space: 48 + 6 gap + 44 + 16 padding. */
    --player-height: 116px;
    /* Safe-area helpers (notches / home indicator). 0px fallback on non-iOS. */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --nav-height: 56px;
  }
  #root {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr var(--player-height);
    height: 100vh;
    height: 100dvh;
  }
  /* Sidebar → bottom tab bar (anchored to safe area on iOS) */
  .sidebar {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    width: 100%;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    flex-direction: row;
    border-radius: 0;
    z-index: 1000;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-base);
  }
  .brand { display: none; }
  .sidebar-nav {
    display: flex; flex-direction: row;
    width: 100%; justify-content: space-around;
    padding: 0; gap: 0;
    height: var(--nav-height);
  }
  .nav-item {
    font-size: 0.55rem; gap: 1px;
    flex-direction: column; align-items: center; justify-content: center;
    padding: 6px 2px; border-radius: 0;
    min-width: 44px; min-height: 44px; flex: 1;
  }
  .nav-icon { width: 22px; height: 22px; margin: 0; }
  .library-panel { display: none; }
  .sidebar-user { display: none; }
  /* .sidebar-user (login/profile/premium/admin/logout) is hidden above with
     no other entry point — this tab is the mobile replacement. `.nav-item`
     already sizes evenly via flex:1 on `.sidebar-nav`, so a 7th tab just
     needs to become visible. */
  .nav-item-account { display: flex; }
  .nav-item-playlists { display: flex; }
  /* Keep the bottom bar to 7 tabs: playlists replaces stats on mobile. */
  .nav-item-stats { display: none; }
  /* The account dropdown positioning for mobile lives further down in this
     same media query, at `body .user-dropdown` — it pre-dates the mobile
     "Cuenta" tab and already centers + anchors it above the player bar. */

  .mobile-playlists-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
  }
  .mobile-playlist-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: inherit;
    text-align: left;
    cursor: pointer;
    min-height: 64px;
  }
  .mobile-playlist-card:active {
    background: var(--bg-surface-hover);
  }
  .mobile-playlist-art {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-pressed));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #111;
    flex-shrink: 0;
  }
  .mobile-playlist-info { flex: 1; min-width: 0; }
  .mobile-playlist-name {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-playlist-meta {
    font-size: 0.8rem;
    color: var(--text-subdued);
    margin-top: 2px;
  }
  .mobile-playlist-chevron {
    color: var(--text-subdued);
    font-size: 1.4rem;
    line-height: 1;
  }

  /* Main area — pad bottom for player + navbar + safe area */
  .main {
    border-radius: 0;
    padding-bottom: calc(var(--player-height) + var(--nav-height) + var(--safe-bottom) + 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .content-area { padding: 0 12px 16px; }
  .nav-arrows { display: none; }
  .main-gradient {
    padding: 10px 14px;
    padding-top: calc(10px + var(--safe-top));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-elevated);
    backdrop-filter: none;
  }
  /* Theme toggle — 44x44 tap target on mobile */
  .theme-toggle {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
  }
  .search-container { 
    width: 100%; max-width: none; flex: 1;
  }
  .search-container input {
    font-size: 16px !important;
    padding: 0 14px 0 44px !important;
    height: 42px;
  }

  /* Player bar compact — sits above bottom nav, respects safe-area.
     Two rows: [art + title + like + transport] on top, [progress + lyrics/
     queue] below — was a single packed row with the progress bar entirely
     hidden (see IMPROVEMENTS.md, Mobile UX, 2026-07-25). */
  .player-bar {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom));
    left: 0; right: 0;
    min-height: var(--player-height);
    height: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 6px;
    padding: 8px 8px;
    z-index: 999;
    gap: 0;
  }
  /* player-left takes the full first row by itself; player-center
     (progress row only — its desktop `.controls` are hidden below, since
     `.mobile-controls` already covers transport) and player-right share
     the second row. */
  .player-left { order: 1; }
  .player-center {
    display: flex;
    order: 2;
    /* flex-basis must NOT be 0: flex-wrap decides whether an item moves to
       a new line using its hypothetical (basis) size, not its post-grow
       size. With `flex: 1` (basis 0%) this always "fits" in whatever room
       is left on player-left's line — even zero room — so it never wraps
       and renders squashed to 0px instead of sharing the row below with
       player-right. `auto` sizes the hypothetical width from the actual
       content (the progress row), which correctly doesn't fit and wraps. */
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    width: auto;
  }
  .player-center .controls { display: none; }
  .player-center .progress-row { width: 100%; }
  .player-right {
    display: flex;
    order: 3;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 8px;
  }
  .player-right .volume-container { display: none; }
  /* Lyrics / queue toggles — bumped to 44x44 tap target */
  .player-right button {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    padding: 4px;
  }
  .player-right button svg { width: 18px; height: 18px; }
  .player-left {
    gap: 8px;
    flex: 1 1 100%;
    min-width: 0;
  }
  /* Progress bar needs to be reachable without hover (no hover on touch):
     show the drag handle always and give the track a taller hit area. */
  .progress-bar { height: 24px; }
  .progress-bar input[type="range"]::-webkit-slider-thumb {
    opacity: 1; width: 14px; height: 14px;
  }
  .progress-bar input[type="range"]::-moz-range-thumb {
    opacity: 1; width: 14px; height: 14px;
  }
  .time-label { font-size: 0.7rem; min-width: 34px; }
  .mini-art { width: 44px; height: 44px; border-radius: 6px; flex-shrink: 0; }
  .now-playing-info {
    flex: 1; min-width: 0;
    max-width: none;
  }
  .now-playing-title { font-size: 0.8rem; max-width: none; }
  .now-playing-artist { font-size: 0.7rem; max-width: none; }
  /* Show inline play controls on player-bar for mobile */
  .player-bar::after {
    content: '';
    display: none;
  }

  /* Mobile play controls — 44x44 tap targets */
  .mobile-controls {
    display: flex; align-items: center; gap: 0;
    flex-shrink: 0;
  }
  /* Hide shuffle and repeat on mobile player bar — too many buttons for small screens */
  /* Scoped with the `.mobile-controls` ancestor (not just the bare class)
     so this beats `.mobile-controls button`'s `display: flex` on
     specificity (0,2,0 vs 0,1,1) — the bare-class version below it lost
     that fight silently and these were never actually hidden. */
  .mobile-controls .mobile-shuffle, .mobile-controls .mobile-repeat { display: none; }
  .mobile-controls button {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-subdued);
    background: none; border: none; cursor: pointer;
    border-radius: 50%;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-controls button.active { color: var(--accent); }
  .mobile-prev, .mobile-next {
    color: var(--text-primary) !important;
  }
  .mobile-play {
    width: 48px !important; height: 48px !important;
    min-width: 48px; min-height: 48px;
    background: var(--text-primary) !important;
    color: var(--bg-base) !important;
    border-radius: 50%;
    margin: 0 2px;
  }
  .mobile-play svg { fill: var(--bg-base); width: 22px; height: 22px; }
  .player-like {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    font-size: 1.1rem;
    margin: 0;
    flex-shrink: 0;
  }

  /* Track lists */
  .track-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .track-list-header { display: none; }
  .track-list-row {
    grid-template-columns: 32px 1fr auto;
    padding: 8px 6px;
    gap: 10px;
    min-height: 52px;
    align-items: center;
  }
  .track-list-row:active { background: var(--overlay-active); }
  .track-row-album { display: none; }
  .track-row-duration { font-size: 0.7rem; }
<<<<<<< HEAD
  /* ⋯ menu always visible on touch — no hover */
  .track-row-menu {
    opacity: 1;
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    font-size: 1.2rem;
  }
=======
  .track-row-art { width: 44px; height: 44px; }
  .track-row-delete { display: none; }
  .track-row-menu {
    opacity: 1;
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    font-size: 0.85rem;
    -webkit-tap-highlight-color: transparent;
  }
  .track-row-duration { display: none; }
>>>>>>> origin/main
  /* Explore add-to-library button — 44x44 tap target */
  .explore-lib-btn {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    font-size: 1.25rem;
  }

  /* On phones the actions menu behaves as a scrollable bottom sheet. This
     keeps admin actions reachable even with many playlists. */
  .playlist-dropdown {
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: calc(var(--player-height) + var(--nav-height) + var(--safe-bottom) + 8px);
    width: auto;
    max-height: calc(100dvh - var(--player-height) - var(--nav-height) - var(--safe-bottom) - 24px);
    padding: 8px !important;
    border-radius: 16px !important;
  }
  .playlist-dropdown-item {
    min-height: 48px;
    padding: 12px 14px !important;
  }
  .playlist-dropdown-backdrop {
    background: rgba(0, 0, 0, 0.28);
  }

  /* Greeting cards */
  .greeting-grid { grid-template-columns: 1fr 1fr; }
  .greeting-card { height: 56px; }
  .greeting-card-art { width: 56px; height: 56px; }
  .greeting-card-name { font-size: 0.75rem; padding: 0 10px; }
  .greeting-card-play { display: none; }
  
  .section-title { font-size: 1.1rem; }
  .section-subtitle { font-size: 0.75rem; }

  /* Playlist dropdown → bottom sheet on mobile */
  .playlist-dropdown {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 8px 8px calc(8px + var(--safe-bottom)) !important;
    animation: sheetSlideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1) !important;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .playlist-dropdown-item {
    min-height: 48px !important;
    padding: 14px 16px !important;
    font-size: 0.938rem !important;
  }
  .playlist-dropdown-sep { margin: 2px 8px !important; }

  /* Add-to-playlist modal fullscreen on mobile */
  #addToPlaylistModal .playlist-modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    position: fixed;
    bottom: 0;
    animation: sheetSlideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1) !important;
  }

  /* Modals better sized on mobile */
  .playlist-modal-overlay { align-items: flex-end; }
  .playlist-modal {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    width: 100%;
    padding-bottom: calc(32px + var(--safe-bottom));
  }

  /* Queue panel — sits above the player bar + nav, no overlap */
  .queue-panel {
    width: 100%;
    position: fixed;
    right: 0;
    bottom: calc(var(--player-height) + var(--nav-height) + var(--safe-bottom));
    height: 60vh;
    height: 60dvh;
    border-radius: 16px 16px 0 0;
    border-left: none;
  }
  .queue-list { padding-bottom: 16px; }
  .queue-item {
    padding: 12px;
    min-height: 56px;
  }
  /* Always-visible remove on touch, 44x44 tap target */
  .queue-item-remove {
    opacity: 1;
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    font-size: 1rem;
  }
  .queue-header {
    padding: 14px 16px;
    min-height: 56px;
  }
  .queue-header button {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  /* Lyrics panel — sits above the player bar + nav, no overlap */
  .lyrics-panel {
    width: 100%;
    border-radius: 16px 16px 0 0;
    bottom: calc(var(--player-height) + var(--nav-height) + var(--safe-bottom));
    border-left: none;
  }
  /* Fullscreen on mobile claims full viewport above player + nav */
  .lyrics-panel.fullscreen {
    bottom: calc(var(--player-height) + var(--nav-height) + var(--safe-bottom));
    border-radius: 0;
  }
  .lyrics-header {
    padding: 12px 14px;
    padding-top: calc(12px + var(--safe-top));
    min-height: 56px;
  }
  .lyrics-header-actions { gap: 2px; }
  .lyrics-header-actions button {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    font-size: 1.05rem;
  }
  /* Lyrics body — readable size, no horizontal overflow, comfortable padding */
  .lyrics-content {
    padding: 20px 18px 32px;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .lyrics-line {
    font-size: 1.125rem;
    line-height: 1.55;
    padding: 8px 4px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }
  .lyrics-plain {
    font-size: 1rem;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }
  .lyrics-placeholder {
    padding: 48px 16px;
    font-size: 0.9rem;
  }
  .lyrics-footer { padding: 10px 14px; }

  /* Modals — bottom-sheet style on mobile */
  .modal-overlay { align-items: flex-end; }
  .modal-card {
    padding: 24px 18px;
    padding-bottom: calc(24px + var(--safe-bottom));
    width: 100vw; max-width: 100%;
    border-radius: 20px 20px 0 0;
    animation: sheetSlideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .modal-tabs { gap: 0; }
  
  /* Confirm dialog — bottom sheet on mobile */
  .confirm-dialog {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 28px 20px calc(20px + var(--safe-bottom));
    animation: sheetSlideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .confirm-dialog-actions { flex-direction: column; gap: 8px; }
  .confirm-dialog-actions button { width: 100%; min-height: 48px; }

  /* User dropdown positioned via the consolidated rule at the bottom of this block */

  /* Download page */
  .download-section { max-width: 100%; }
  .download-input-wrapper { 
    flex-direction: column; gap: 10px; 
    align-items: stretch;
  }
  .download-input { 
    font-size: 16px !important;
    padding: 14px 16px !important;
    min-height: 48px;
    width: 100%;
    border-radius: 14px;
  }
  .download-btn { 
    white-space: nowrap; padding: 0 20px;
    min-height: 48px; font-size: 0.9rem;
    width: 100%;
    justify-content: center;
    border-radius: 14px;
  }
  .download-hint { font-size: 0.72rem; line-height: 1.5; margin-top: -4px; }

  /* All inputs & textareas bigger on mobile (except search bar) */
  input[type="text"]:not(#search), input[type="password"], input[type="email"], textarea, select {
    font-size: 16px !important;
    padding: 12px 14px !important;
    min-height: 44px;
  }
  
  /* Search bar */
  .search-bar input { font-size: 16px !important; padding: 10px 14px !important; }

  /* Auth modal inputs */
  .modal-card input { font-size: 16px !important; padding: 12px 14px !important; }
  .modal-card button { min-height: 44px; font-size: 0.95rem; }

  /* Search results mobile */
  .yt-result-thumb { width: 64px; height: 36px; }
  .yt-result-card { padding: 10px 6px; gap: 10px; min-height: 56px; }
  .yt-result-title { font-size: 0.8rem; }
  .yt-result-dl {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
  }
  .yt-result-dl svg { width: 18px; height: 18px; }

  /* Stats cards */
  .stats-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 16px 8px; }
  .stat-number { font-size: 1.5rem; }

  /* Toast — push above player + nav + safe area on mobile */
  .toast {
    bottom: calc(var(--player-height) + var(--nav-height) + var(--safe-bottom) + 12px);
  }

  /* User dropdown — centered & positioned above player + nav + safe area.
     Scoped with `body` (specificity 0,1,1) so it reliably beats the base
     `.user-dropdown { left: 16px; ... }` rule (0,1,0) regardless of which
     comes later in the file — this rule pre-dates the mobile "Cuenta" tab
     and was dead code until that tab made the dropdown reachable on
     mobile at all, which is when the plain-class version silently lost
     this fight and left the dropdown positioned off-screen. */
  body .user-dropdown {
    position: fixed;
    top: auto;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--player-height) + var(--nav-height) + var(--safe-bottom) + 8px);
  }
  .user-dropdown-item {
    min-height: 44px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
  }

  /* Prevent horizontal overflow on the whole document on phones */
  html, body { overflow-x: hidden; max-width: 100vw; }

  /* ── Now Playing Sheet — full-screen "now playing" view, opened by
     tapping the player bar (see app.js). Mobile-only: desktop already has
     room for everything in the bar itself. */
  .now-playing-sheet {
    position: fixed; inset: 0;
    background: var(--bg-base);
    z-index: 1000;
    display: flex; flex-direction: column;
    padding: calc(18px + var(--safe-top)) 22px 22px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.4, 1);
  }
  .now-playing-sheet.open { transform: translateY(0); }

  /* Shared by both full-screen sheets (now-playing + account): an explicit
     close button, not just a subtle drag-handle bar that isn't obviously
     tappable — plus a draggable zone for swipe-down-to-dismiss. */
  .sheet-drag-zone {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    height: 44px;
    margin: -4px 0 4px;
    touch-action: none;
  }
  .sheet-handle-bar {
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--border-active);
    pointer-events: none;
  }
  .sheet-close-btn {
    position: absolute; left: 0; top: 0;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; line-height: 1;
    color: var(--text-secondary);
  }
  .sheet-art {
    width: min(72vw, 300px); height: min(72vw, 300px);
    margin: 8px auto 22px;
    border-radius: var(--radius-lg);
    background: var(--bg-surface-hover);
    background-size: cover; background-position: center;
    box-shadow: var(--shadow-lg);
  }
  .sheet-title {
    font-size: 1.15rem; font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    overflow-wrap: anywhere;
  }
  .sheet-artist {
    font-size: 0.9rem; color: var(--text-subdued);
    text-align: center; margin-top: 4px; margin-bottom: 26px;
  }
  .sheet-progress-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 26px;
  }
  .sheet-progress-bar { height: 28px; }
  .sheet-progress-bar input[type="range"]::-webkit-slider-thumb,
  .sheet-progress-bar input[type="range"]::-moz-range-thumb { opacity: 1; }
  .sheet-transport {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 4px; margin-bottom: 30px;
  }
  .sheet-transport button {
    display: flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px;
    color: var(--text-secondary);
    position: relative;
  }
  .sheet-transport button.active { color: var(--accent); }
  .sheet-play {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--text-primary); color: var(--bg-base) !important;
  }
  .sheet-secondary {
    display: flex; align-items: center; justify-content: center; gap: 40px;
    margin-top: auto;
  }
  .sheet-secondary button {
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-subdued);
    font-size: 1.2rem;
  }
  .sheet-secondary button.liked { color: var(--accent); }

  /* ── Account Sheet — full-screen "Cuenta" view, opened from the mobile
     tab. Replaces an earlier floating dropdown that had no backdrop (taps
     could land on list content underneath it) and relied on a fragile
     document-click-to-close listener; this full-screen sheet matches the
     already-proven now-playing sheet pattern instead. */
  .account-sheet {
    position: fixed; inset: 0;
    background: var(--bg-base);
    z-index: 1000;
    display: flex; flex-direction: column;
    padding: calc(18px + var(--safe-top)) 22px 22px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.4, 1);
  }
  .account-sheet.open { transform: translateY(0); }
  .account-sheet-identity {
    display: flex; flex-direction: column; align-items: center;
    padding: 40px 0 30px;
  }
  .account-sheet-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-pressed));
    color: #000;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.6rem;
    margin-bottom: 14px;
  }
  .account-sheet-name { font-size: 1.05rem; font-weight: 800; color: var(--text-primary); }
  .account-sheet-plan {
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-subdued); margin-top: 4px;
  }
  .account-sheet-plan.premium { color: var(--accent); }
  .account-sheet-actions { display: flex; flex-direction: column; gap: 2px; }
  .account-sheet-item {
    min-height: 52px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: none; border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem; font-weight: 600;
    text-align: left; cursor: pointer;
  }
  .account-sheet-item.danger { color: #e74c3c; }
  .account-sheet-item.hidden { display: none; }
}

@keyframes sheetSlideUp {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .now-playing-sheet, .account-sheet { transition: none; }
  .playlist-dropdown { animation: none !important; }
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.track-card { animation: fadeInUp 0.3s ease both; }
.track-card:nth-child(1) { animation-delay: 0.02s; }
.track-card:nth-child(2) { animation-delay: 0.04s; }
.track-card:nth-child(3) { animation-delay: 0.06s; }
.track-card:nth-child(4) { animation-delay: 0.08s; }
.track-card:nth-child(5) { animation-delay: 0.10s; }
.track-card:nth-child(6) { animation-delay: 0.12s; }
.track-card:nth-child(7) { animation-delay: 0.14s; }
.track-card:nth-child(8) { animation-delay: 0.16s; }
.track-card:nth-child(9) { animation-delay: 0.18s; }
.track-card:nth-child(10) { animation-delay: 0.20s; }

.greeting-card { animation: fadeInUp 0.25s ease both; }
.greeting-card:nth-child(1) { animation-delay: 0.02s; }
.greeting-card:nth-child(2) { animation-delay: 0.04s; }
.greeting-card:nth-child(3) { animation-delay: 0.06s; }
.greeting-card:nth-child(4) { animation-delay: 0.08s; }
.greeting-card:nth-child(5) { animation-delay: 0.10s; }
.greeting-card:nth-child(6) { animation-delay: 0.12s; }

/* Now playing bar glow */
.player-bar.playing::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.4;
}

/* Loading/buffering feedback in the player bar (mobile "tarda en reproducir"
   fix: gives the user visible feedback between clicking play and audio
   actually starting, instead of silence). */
.player-bar.loading .mini-art { animation: pm-loading-pulse 1.1s ease-in-out infinite; }
@keyframes pm-loading-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.player-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(128,128,128,0.35);
  border-top-color: var(--bg-base);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.mobile-play .player-spinner { width: 20px; height: 20px; border-top-color: var(--bg-base); }

/* Active track highlight */
.track-card.playing .track-title,
.track-card.playing .card-play-btn { color: var(--accent); }
.track-card.playing .track-title { color: var(--accent); }
.track-card.playing { box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(0,0,0,.4); }

/* Active list row highlight */
.track-list-row.playing { background: var(--accent-subtle); }
.track-list-row.playing .track-row-title { color: var(--accent); font-weight: 700; }
.track-list-row.playing .track-row-artist { color: var(--accent); opacity: 0.7; }

/* Active greeting card */
.greeting-card.playing { box-shadow: 0 0 0 2px var(--accent), 0 4px 16px rgba(0,0,0,.3); }
.greeting-card.playing .greeting-card-title { color: var(--accent); }

/* Equalizer animation for playing state */
.eq-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}
.eq-bar {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
  animation: eq-bounce 0.6s ease-in-out infinite alternate;
}
.eq-bar:nth-child(1) { height: 40%; animation-delay: 0s; }
.eq-bar:nth-child(2) { height: 70%; animation-delay: 0.15s; }
.eq-bar:nth-child(3) { height: 50%; animation-delay: 0.3s; }
.eq-bar:nth-child(4) { height: 80%; animation-delay: 0.1s; }

@keyframes eq-bounce {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* ── Download Page ─────────────────────────────────────────── */
.download-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding-bottom: 48px;
}

.download-hero {
  position: relative;
  isolation: isolate;
  min-height: 270px;
  padding: clamp(32px, 5vw, 64px);
  margin-bottom: 24px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  border: 1px solid rgba(212, 160, 84, 0.24);
  border-radius: 28px;
  background:
    radial-gradient(circle at 82% 10%, rgba(212, 160, 84, 0.24), transparent 32%),
    linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-elevated) 65%, rgba(212, 160, 84, 0.12) 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.download-hero::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 280px;
  height: 280px;
  right: -100px;
  bottom: -170px;
  border-radius: 50%;
  border: 50px solid rgba(212, 160, 84, 0.08);
}

.download-hero-copy { max-width: 690px; }
.download-eyebrow,
.download-step {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.download-hero h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(2.15rem, 5vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}
.download-hero h1 span { color: var(--accent); }
.download-hero p {
  max-width: 610px;
  margin: 20px 0 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.65;
}
.download-hero-icon {
  width: 112px;
  height: 112px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #18130c;
  border-radius: 32px;
  background: linear-gradient(145deg, var(--accent-hover), var(--accent));
  box-shadow: 0 20px 50px rgba(212, 160, 84, 0.3);
  transform: rotate(5deg);
}
.download-hero-icon svg { width: 44px; height: 44px; }

.download-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    'search url'
    'spotify url';
  gap: 24px;
}
.download-search-card { grid-area: search; }
.download-spotify-card { grid-area: spotify; }
.download-tool-card {
  min-width: 0;
  padding: 28px;
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  background: linear-gradient(145deg, var(--bg-surface), var(--bg-elevated));
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.12);
}
.download-tool-card .section-header { margin-bottom: 22px; }
.download-tool-title {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}
.download-url-card {
  grid-area: url;
  border-color: rgba(212, 160, 84, 0.28);
  background:
    radial-gradient(circle at 100% 0, rgba(212, 160, 84, 0.13), transparent 35%),
    linear-gradient(145deg, var(--bg-surface), var(--bg-elevated));
}
.download-url-field {
  min-height: 68px;
  padding: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-active);
  border-radius: 18px;
  background: var(--bg-base);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.download-url-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.download-link-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  color: var(--accent);
  border-radius: 12px;
  background: var(--accent-subtle);
}
.download-url-field .download-input {
  min-width: 0;
  height: 52px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.download-url-field .download-input:focus { box-shadow: none; }
.download-url-field .download-btn { flex: 0 0 auto; }
.download-url-card .download-hint {
  margin: 14px 0 22px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.download-url-card .download-hint span,
.download-url-card .download-hint a {
  padding: 5px 9px;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--overlay-card);
  font-size: 0.72rem;
  line-height: 1;
  text-decoration: none;
}
.download-url-card .download-hint a { color: var(--accent); }
.download-tool-card .download-input-wrapper { margin-bottom: 0; }
.download-spotify-card > .download-hint {
  margin: 12px 0 0;
  padding: 0;
}
.download-tool-card .yt-search-results { margin-top: 16px; }
.download-tool-card #downloadProgress,
.download-tool-card #spotifyProgress { margin-top: 16px; }

.download-section {
  max-width: 720px;
}
.download-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}
.download-input {
  flex: 1;
  height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.938rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}
.download-input::placeholder { color: var(--text-subdued); }
.download-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.download-input.error { border-color: #e74c3c; }
.download-input.error:focus { box-shadow: 0 0 0 4px rgba(231,76,60,0.15); }

.download-btn {
  height: 52px;
  padding: 0 32px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 0.938rem;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.download-btn:hover { background: var(--accent-hover); transform: scale(1.02); }
.download-btn:active { transform: scale(0.98); }
.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.download-hint {
  font-size: 0.813rem;
  color: var(--text-subdued);
  margin-top: -16px;
  margin-bottom: 24px;
  padding-left: 20px;
}

/* Download progress cards */
.download-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: fadeInUp 0.3s ease both;
  border: 1px solid var(--border-subtle);
}
.download-card-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #ff0000, #cc0000);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.5rem;
}
.download-card-info {
  flex: 1;
  min-width: 0;
}
.download-card-title {
  font-size: 0.938rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.download-card-status {
  font-size: 0.75rem;
  color: var(--text-subdued);
  display: flex;
  align-items: center;
  gap: 8px;
}
.download-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--overlay-active);
  border-radius: 2px;
  overflow: hidden;
  max-width: 200px;
}
.download-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.download-card-check {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: #000;
  flex-shrink: 0;
}
.download-card-error {
  color: #e74c3c;
  font-size: 0.75rem;
}

/* Spinner animation */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-active);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Source badge */
.source-badge {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}
.source-badge.youtube {
  background: rgba(255,0,0,0.15);
  color: #ff4444;
}
.source-badge.local {
  background: var(--accent-glow);
  color: var(--accent);
}

/* Track menu button in list */
.track-row-menu {
  opacity: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  font-size: 1.1rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  z-index: 2;
  background: none;
  border: none;
  padding: 0;
  flex-shrink: 0;
}
.track-list-row:hover .track-row-menu { opacity: 1; }
.track-row-menu:hover { color: var(--text-primary); background: var(--bg-surface-hover); }

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.confirm-dialog {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: dropdown-in 0.2s ease;
}
.confirm-dialog h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}
.confirm-dialog p {
  color: var(--text-subdued);
  font-size: 0.875rem;
  margin: 0 0 24px;
  line-height: 1.5;
}
.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.confirm-dialog-actions button {
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}
.confirm-cancel {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-active);
}
.confirm-cancel:hover { background: var(--overlay-hover); }
.confirm-danger {
  background: #e74c3c;
  color: #fff;
}
.confirm-danger:hover { background: #c0392b; transform: scale(1.02); }

/* Download history section */
.download-history {
  margin-top: 32px;
}

/* ── Paste detection visual ────────────────────────────────── */
.paste-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 400;
  opacity: 0;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.paste-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Lyrics Panel ──────────────────────────────────────────── */
.lyrics-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: var(--player-height);
  width: 420px;
  background: linear-gradient(180deg, rgba(18,18,18,0.98), rgba(8,8,8,0.99));
  border-left: 1px solid var(--border-subtle);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}
.lyrics-panel.visible { transform: translateX(0); }

/* Fullscreen mode */
.lyrics-panel.fullscreen {
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--player-height);
  border-left: none;
  background: linear-gradient(180deg,
    rgba(212,160,84,0.1) 0%,
    rgba(18,18,18,0.99) 30%,
    rgba(8,8,8,1) 100%
  );
  z-index: 60;
}

.lyrics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.lyrics-header h3 {
  font-size: 1rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
}
.lyrics-header-actions {
  display: flex;
  gap: 4px;
}
.lyrics-header-actions button {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}
.lyrics-header-actions button:hover {
  color: var(--text-primary);
  background: var(--overlay-active);
}

.lyrics-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px 60px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
  position: relative;
}
.lyrics-content::-webkit-scrollbar { width: 6px; }
.lyrics-content::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* Placeholder */
.lyrics-placeholder {
  text-align: center;
  color: var(--text-subdued);
  font-size: 0.938rem;
  padding: 80px 20px;
  line-height: 1.6;
}
.lyrics-placeholder .lyrics-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
  opacity: 0.4;
}

/* Loading state */
.lyrics-loading {
  text-align: center;
  padding: 60px 20px;
}
.lyrics-loading .spinner {
  margin: 0 auto 16px;
}

/* Lyrics lines */
.lyrics-line {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.7;
  color: rgba(255,255,255,0.3);
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.4s ease, transform 0.3s ease, text-shadow 0.4s ease;
  user-select: text;
  letter-spacing: -0.01em;
}
.lyrics-line:hover {
  color: rgba(255,255,255,0.55);
}

/* Active (karaoke) line */
.lyrics-line.active {
  color: #ffffff;
  transform: scale(1.03);
  text-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(212,160,84,0.12);
}

/* Past lines - slightly brighter than future */
.lyrics-line.past {
  color: rgba(255,255,255,0.45);
}

/* Next upcoming line */
.lyrics-line.upcoming {
  color: rgba(255,255,255,0.5);
}

/* Instrumental / gap markers */
.lyrics-instrumental {
  text-align: center;
  color: var(--text-subdued);
  font-size: 0.875rem;
  padding: 16px 0;
  font-style: italic;
  opacity: 0.5;
}

/* Fullscreen enhancements */
.lyrics-panel.fullscreen .lyrics-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 40px 100px;
}
.lyrics-panel.fullscreen .lyrics-line {
  font-size: 2rem;
  line-height: 1.8;
  padding: 8px 8px;
  text-align: center;
}
.lyrics-panel.fullscreen .lyrics-line.active {
  transform: scale(1.06);
  text-shadow: 0 0 40px var(--accent-glow), 0 0 80px rgba(212,160,84,0.15);
}

/* Footer */
.lyrics-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.lyrics-source {
  font-size: 0.688rem;
  color: var(--text-subdued);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lyrics-footer-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lyrics-match-info {
  color: var(--text-subdued);
  opacity: 0.7;
  font-size: 0.625rem;
}
.lyrics-footer-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.lyrics-action-btn {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-subdued);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.688rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 600;
}
.lyrics-action-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}
.lyrics-action-btn:hover:first-child {
  border-color: #e74c3c;
  color: #e74c3c;
}
.lyrics-action-refresh:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* No lyrics found */
.lyrics-not-found {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-subdued);
}
.lyrics-not-found .lyrics-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
  opacity: 0.4;
}
.lyrics-not-found p {
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
}
.lyrics-retry-btn {
  margin-top: 16px;
  padding: 10px 24px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 24px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lyrics-retry-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Plain lyrics (non-synced) */
.lyrics-plain {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.8;
  color: rgba(255,255,255,0.75);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.lyrics-panel.fullscreen .lyrics-plain {
  font-size: 1.5rem;
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
}

/* Animation for lyrics appearing */
@keyframes lyricFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.lyrics-line, .lyrics-plain {
  animation: lyricFadeIn 0.4s ease both;
}

/* Responsive */
@media (max-width: 768px) {
  .lyrics-panel { width: 100%; }
  .lyrics-panel.fullscreen .lyrics-line { font-size: 1.5rem; }
  .lyrics-panel.fullscreen .lyrics-content { padding: 40px 20px 80px; }
}

/* ── YouTube Search Results ─────────────────────────────── */
.yt-search-results { margin-top: 20px; }
.yt-search-loading, .yt-search-error {
  text-align: center; padding: 32px;
  color: var(--text-subdued); font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.yt-search-header {
  font-size: 0.85rem; color: var(--text-subdued);
  margin-bottom: 12px; font-weight: 600;
}
.yt-results-grid {
  display: flex; flex-direction: column; gap: 4px;
}
.yt-result-card {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: 8px;
  transition: background 0.15s;
  cursor: default;
}
.yt-result-card:hover { background: var(--bg-surface-hover); }
.yt-result-thumb {
  width: 80px; height: 45px; flex-shrink: 0;
  border-radius: 6px; background: var(--bg-surface) center/cover no-repeat;
  position: relative; overflow: hidden;
}
.yt-result-duration {
  position: absolute; bottom: 3px; right: 3px;
  background: rgba(0,0,0,0.8); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  padding: 1px 5px; border-radius: 3px;
}
.yt-result-info { flex: 1; min-width: 0; }
.yt-result-title {
  font-weight: 600; font-size: 0.85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.yt-result-artist {
  font-size: 0.75rem; color: var(--text-subdued);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.yt-result-dl {
  background: var(--accent); color: #fff; border: none;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.yt-result-dl:hover { transform: scale(1.1); background: var(--accent-hover); }
.yt-result-dl svg { width: 16px; height: 16px; }

/* ── Stats Page ──────────────────────────────────────────── */
.stats-page { padding-bottom: 32px; }
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
}
.stat-number {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-subdued);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
  font-weight: 600;
}
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stats-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  transition: background 0.1s;
}
.stats-list-item.clickable { cursor: pointer; }
.stats-list-item.clickable:hover { background: var(--bg-surface-hover); }
.stats-rank {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.stats-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-plays {
  font-size: 0.75rem;
  color: var(--text-subdued);
  font-weight: 600;
  flex-shrink: 0;
}

/* Hidden utility */
.hidden { display: none !important; }

/* ── Sidebar User Profile ────────────────────────────────── */
.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.sidebar-user-info:hover { background: var(--bg-surface-hover); }
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-pressed));
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-plan {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-subdued);
}
.sidebar-user-plan.premium { color: var(--accent); }

/* ── User Dropdown ───────────────────────────────────────── */
.user-dropdown {
  /* Always appended to <body> (see openAccountMenu() in app.js) so it works
     from both the desktop sidebar and the mobile account tab — `fixed`
     positions it against the viewport either way. `.sidebar` has no
     `position` of its own, so this was already viewport-relative before. */
  position: fixed; bottom: 72px; left: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 4px;
  z-index: 9999;
  min-width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
/* Identity header inside the dropdown itself — on desktop who's logged in
   is always visible in .sidebar-user, but mobile has nowhere else to show
   it, so an admin/premium user (who has no redeem action) would otherwise
   open this menu to find nothing but a bare "Cerrar sesión". */
.dropdown-user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}
.dropdown-user-avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-pressed));
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem;
}
.dropdown-user-name {
  font-size: 0.85rem; font-weight: 700; color: var(--text-primary);
}
.dropdown-user-plan {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-subdued); margin-top: 2px;
}
.dropdown-user-plan.premium { color: var(--accent); }
.user-dropdown-item {
  display: block; width: 100%;
  padding: 10px 14px;
  background: none; border: none;
  color: var(--text-primary);
  font-size: 0.8rem; font-weight: 500;
  text-align: left; cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}
.user-dropdown-item:hover { background: var(--bg-surface-hover); }
.user-dropdown-item.danger { color: #e74c3c; }
.user-dropdown-item.danger:hover { background: rgba(231,76,60,0.1); }

/* ── Auth Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 32px;
  width: 380px; max-width: 90vw;
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none;
  color: var(--text-subdued); font-size: 1.2rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }
.modal-tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-tab {
  flex: 1; padding: 10px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-subdued); font-weight: 600; font-size: 0.875rem;
  cursor: pointer; transition: all 0.15s;
}
.modal-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
.modal-tab:hover { color: var(--text-primary); }
.modal-field {
  margin-bottom: 16px;
}
.modal-field label {
  display: block; font-size: 0.75rem; font-weight: 600;
  color: var(--text-subdued); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.modal-field input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none; transition: border-color 0.15s;
  box-sizing: border-box;
}
.modal-field input:focus {
  border-color: var(--accent);
}
.remember-me {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
  cursor: pointer;
  font-size: 0.825rem;
  color: var(--text-secondary);
  user-select: none;
}
.remember-me input[type="checkbox"] {
  width: 18px; height: 18px;
  border-radius: 5px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.remember-me span { line-height: 1; }

.modal-error {
  color: #e74c3c; font-size: 0.8rem; font-weight: 600;
  min-height: 20px; margin-bottom: 8px;
}
.modal-submit {
  width: 100%; padding: 12px;
  background: var(--accent); color: #000;
  border: none; border-radius: 24px;
  font-weight: 700; font-size: 0.9rem;
  cursor: pointer; transition: all 0.15s;
}
.modal-submit:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
}
.modal-submit:disabled {
  opacity: 0.5; cursor: not-allowed;
  transform: none;
}
.modal-title {
  font-size: 1.3rem; font-weight: 800;
  text-align: center; margin-bottom: 8px;
}
.modal-desc {
  text-align: center; color: var(--text-subdued);
  font-size: 0.85rem; margin: 0 0 20px;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Download Limit Badge ────────────────────────────────── */
.download-limit-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-subdued);
}
.download-limit-badge.at-limit { color: #e74c3c; border-color: rgba(231,76,60,0.3); }
.download-limit-badge.premium { color: var(--accent); border-color: rgba(212,160,84,0.3); }

/* ── Stats Page ─────────────────────────────────────────────── */
.stats-page {
  max-width: 800px;
  animation: fadeInUp 0.35s ease both;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.stat-card {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-hover));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  transition: all var(--transition-med);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  opacity: 0.6;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  border-color: var(--accent-glow);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--text-subdued);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.stats-list-item:hover,
.stats-list-item.clickable:hover {
  background: var(--bg-surface-hover);
}
.stats-list-item.clickable {
  cursor: pointer;
}

.stats-rank {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-subdued);
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.stats-list-item:nth-child(1) .stats-rank { color: var(--accent); font-size: 1.1rem; }
.stats-list-item:nth-child(2) .stats-rank { color: var(--text-secondary); }
.stats-list-item:nth-child(3) .stats-rank { color: var(--text-secondary); }

.stats-name {
  flex: 1;
  font-size: 0.938rem;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-plays {
  font-size: 0.813rem;
  color: var(--text-subdued);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Stats mobile */
@media (max-width: 768px) {
  .stats-page { max-width: 100%; }
  .stats-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 16px 10px; }
  .stat-number { font-size: 1.5rem; }
  .stat-label { font-size: 0.688rem; }
  .stats-list-item { padding: 10px 12px; gap: 12px; min-height: 48px; }
  .stats-list-item.clickable:active { background: var(--overlay-active); }
  .stats-rank { min-width: 24px; font-size: 0.875rem; }
  .stats-name { font-size: 0.813rem; }
  .stats-plays { font-size: 0.75rem; }
  .stats-chart-container { padding: 14px; }
  .stats-chart-container canvas { max-height: 180px; }
}
@media (max-width: 380px) {
  .stats-cards { grid-template-columns: repeat(2, 1fr); }
  .greeting-grid { grid-template-columns: 1fr; }
}

/* ── Theme Toggle Button ──────────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  background: var(--bg-surface-hover);
}
.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
  transform: scale(1.08);
}

/* Show correct icon per theme */
.theme-icon-dark, .theme-icon-light, .theme-icon-auto { display: none; }
html[data-theme="auto"] .theme-icon-auto { display: block; }
html[data-theme="dark"] .theme-icon-dark { display: block; }
html[data-theme="light"] .theme-icon-light { display: block; }

/* Smooth theme transition */
html { transition: background-color 0.3s ease, color 0.3s ease; }
body, .sidebar, .main, .player-bar { transition: background-color 0.3s ease, color 0.3s ease; }

/* ── Stats Chart ──────────────────────────────────────────── */
.stats-chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 24px;
}
.stats-chart-container canvas {
  width: 100% !important;
  max-height: 220px;
}

/* Stats streak badges */
.stats-streak-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.streak-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  transition: all var(--transition-med);
}
.streak-badge:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.streak-badge .streak-icon { font-size: 1.5rem; margin-bottom: 4px; }
.streak-badge .streak-value {
  font-size: 1.75rem; font-weight: 900;
  color: var(--accent); line-height: 1.2;
}
.streak-badge .streak-label {
  font-size: 0.688rem; font-weight: 600;
  color: var(--text-subdued); text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 2px;
}

/* Wrapped summary section */
.wrapped-section {
  background: linear-gradient(135deg, var(--bg-surface), var(--accent-subtle));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 24px;
}
.wrapped-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.wrapped-item {
  text-align: center;
}
.wrapped-item .wrapped-label {
  font-size: 0.688rem; font-weight: 600;
  color: var(--text-subdued); text-transform: uppercase;
  letter-spacing: 0.05em;
}
.wrapped-item .wrapped-value {
  font-size: 1rem; font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
}

@media (max-width: 768px) {
  .stats-streak-grid { grid-template-columns: repeat(2, 1fr); }
  .wrapped-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .streak-badge { padding: 12px; }
  .streak-badge .streak-value { font-size: 1.25rem; }
}

/* ── Apple-Style Playlist Modal ───────────────────────────── */
.playlist-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.playlist-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 32px;
  width: 340px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  animation: modalSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.playlist-modal-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--accent-subtle);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.playlist-modal-title {
  font-size: 1.15rem; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.playlist-modal-desc {
  font-size: 0.813rem;
  color: var(--text-subdued);
  margin-bottom: 20px;
}
.playlist-modal-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.938rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.playlist-modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.playlist-modal-input::placeholder { color: var(--text-subdued); }
.playlist-modal-actions {
  display: flex; gap: 10px;
  margin-top: 20px;
}
.playlist-modal-btn {
  flex: 1;
  padding: 11px 0;
  border-radius: 12px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.playlist-modal-btn.cancel {
  background: var(--bg-surface);
  color: var(--text-secondary);
}
.playlist-modal-btn.cancel:hover {
  background: var(--bg-surface-hover);
}
.playlist-modal-btn.confirm {
  background: var(--accent);
  color: #fff;
}
.playlist-modal-btn.confirm:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
}
.playlist-modal-btn.confirm:active {
  transform: scale(0.98);
}

/* ── Add-to-Playlist modal items ───────────────────────────── */
.add-to-pl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.add-to-pl-item:hover { background: var(--bg-surface-hover); }
.add-to-pl-art {
  width: 44px; height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.add-to-pl-info { min-width: 0; }
.add-to-pl-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-to-pl-count {
  font-size: 0.775rem;
  color: var(--text-subdued);
  margin-top: 2px;
}
#addToPlaylistNew:hover {
  background: var(--bg-surface-hover) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* ── Global Refinements ───────────────────────────────────── */

/* Smooth scroll for main content */
.main { scroll-behavior: smooth; }

/* Buttons — universal touch style */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* Cards — soft shadows and larger radius */
.stat-card {
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1), box-shadow 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

/* Track cards — press feedback */
.track-card {
  transition: background var(--transition-med), transform 0.12s ease, box-shadow var(--transition-med);
}
.track-card:active {
  transform: scale(0.97);
}

/* Track list items — refined hover and active */
.track-list-row {
  transition: background var(--transition-fast), transform 0.1s ease;
}

/* Track list items — Apple-style hover with rounded inset */
.track-item {
  border-radius: 10px;
  transition: background 0.15s ease;
}
.track-item:hover {
  background: var(--bg-surface-hover);
}
.track-item:active {
  background: var(--bg-highlight);
  transform: scale(0.99);
}

/* Sidebar nav — pill-shaped active indicator */
.nav-item {
  border-radius: 10px;
  transition: all 0.15s ease;
  position: relative;
}
.nav-item.active {
  background: var(--accent-subtle);
}
.nav-item:hover:not(.active) {
  background: var(--bg-surface-hover);
}

/* Library item — refined */
.library-item {
  border-radius: 10px;
  transition: background 0.15s ease;
}
.library-item:active {
  transform: scale(0.98);
}

/* Download button — pill shape */
.download-btn {
  border-radius: 12px !important;
  font-weight: 600;
  transition: all 0.15s ease;
}
.download-btn:hover {
  transform: scale(1.02);
}
.download-btn:active {
  transform: scale(0.98);
}

/* Player controls — larger touch targets, rounded */
.player-btn {
  border-radius: 50%;
  transition: all 0.15s ease;
}
.player-btn:hover {
  background: var(--bg-surface-hover);
  transform: scale(1.08);
}
.player-btn:active {
  transform: scale(0.92);
}

/* Playlist dropdown — frosted glass */
.playlist-dropdown {
  background: var(--bg-elevated) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 14px !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px !important;
}
.playlist-dropdown-item {
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-size: 0.875rem;
  transition: background 0.12s ease;
}
.playlist-dropdown-item:hover {
  background: var(--bg-surface-hover) !important;
}

/* Search input — Apple pill style */
#search {
  border-radius: 12px;
}

/* Stats list — refined */
.stats-list-item {
  border-radius: 10px;
  transition: background 0.15s ease;
}
.stats-list-item:hover {
  background: var(--bg-surface-hover);
}

/* Toast — Apple-style notification */
.toast {
  border-radius: 14px !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ── Empty state for sidebar playlists ─────────────────────── */
.library-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.library-empty-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--accent-subtle);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.library-empty-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.library-empty-desc {
  font-size: 0.813rem;
  color: var(--text-subdued);
  margin-bottom: 16px;
  line-height: 1.5;
}
.library-empty-btn {
  padding: 10px 24px;
  border-radius: 500px;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.library-empty-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}
.library-empty-btn:active { transform: scale(0.96); }

/* ── Explore View — Library Button ─────────────────────────── */
.explore-lib-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--text-subdued);
  background: transparent;
  color: var(--text-subdued);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
}
.explore-lib-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1);
}
.explore-lib-btn.in-lib {
  border-color: var(--accent);
  background: var(--accent);
  color: #000;
}
.explore-lib-btn.in-lib:hover {
  background: transparent;
  color: var(--accent);
}
.explore-row {
  display: flex;
  align-items: center;
}
.explore-row .track-row-duration {
  margin-right: 12px;
}

/* ============================================================
   LIGHT MODE OVERRIDES
   Fix all remaining hardcoded colors that break in light mode
   ============================================================ */

/* Shared selector for both light modes */
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] .brand img,
  html[data-theme="auto"] .brand img {
    color: var(--text-primary);
  }
}

/* Brand logo: circle background and text must adapt */
html[data-theme="light"] .brand img,
html[data-theme="auto"] .brand img {
  color: var(--text-primary);
}

/* Logo SVG circle inside — override via CSS filter for better contrast */
html[data-theme="light"] .brand img {
  filter: none;
}

/* Play button hover — don't use #fff on light bg */
html[data-theme="light"] .play-main:hover,
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] .play-main:hover {
    background: var(--text-primary) !important;
  }
}

/* Nav arrows: in light mode, use subtle bg instead of dark */
html[data-theme="light"] .nav-arrow {
  color: var(--text-primary);
}

/* Greeting card play button SVG: fill should contrast accent */
html[data-theme="light"] .card-play-btn svg,
html[data-theme="light"] .greeting-card-play svg {
  fill: #fff;
}

/* Lyrics: use dark-based colors in light mode */
html[data-theme="light"] .lyrics-line {
  color: rgba(0,0,0,0.25);
}
html[data-theme="light"] .lyrics-line:hover {
  color: rgba(0,0,0,0.5);
}
html[data-theme="light"] .lyrics-line.active {
  color: #1a1815;
  text-shadow: none;
}
html[data-theme="light"] .lyrics-line.past {
  color: rgba(0,0,0,0.4);
}
html[data-theme="light"] .lyrics-line.upcoming {
  color: rgba(0,0,0,0.45);
}

/* Lyrics action button hover */
html[data-theme="light"] .lyrics-action-btn:hover {
  background: var(--overlay-hover);
}

/* Auth overlay */
html[data-theme="light"] .auth-overlay {
  background: var(--overlay-dialog);
}

/* Mobile mini player and controls */
html[data-theme="light"] .mobile-player-bg {
  background: var(--bg-player);
  border-top: 1px solid var(--border-subtle);
}

/* Download badge in downloads section */
html[data-theme="light"] .download-badge {
  color: #fff;
}

/* YT result duration badge */
html[data-theme="light"] .yt-result-duration {
  background: rgba(0,0,0,0.7);
  color: #fff;
}

/* Tooltip */
html[data-theme="light"] .tooltip {
  background: var(--text-primary);
  color: var(--bg-base);
}

/* Edit metadata modal */
html[data-theme="light"] .edit-overlay {
  background: var(--overlay-dialog);
}

/* Premium code input */
html[data-theme="light"] .premium-input {
  border-color: var(--border-active);
}

/* Scrollbar in explore list */
html[data-theme="light"] .queue-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
}

/* Ensure the explore-lib-btn has proper contrast */
html[data-theme="light"] .explore-lib-btn.in-lib {
  color: #fff;
}

/* Media session badge on download page */
html[data-theme="light"] .source-badge.youtube {
  background: rgba(255,0,0,0.1);
}

/* Download workspace responsiveness (kept after the legacy mobile rules so
   the card layout remains predictable at every breakpoint). */
@media (max-width: 900px) {
  .download-tools-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'search' 'url' 'spotify';
  }
}

@media (max-width: 768px) {
  .download-page { padding-bottom: 24px; }
  .download-hero {
    min-height: 0;
    padding: 30px 22px;
    margin-bottom: 14px;
    border-radius: 22px;
  }
  .download-hero h1 {
    font-size: clamp(2rem, 10vw, 3rem);
    line-height: 1.02;
  }
  .download-hero p { margin-top: 16px; font-size: 0.9rem; line-height: 1.55; }
  .download-hero-icon { display: none; }
  .download-tools-grid { gap: 14px; }
  .download-tool-card { padding: 22px 18px; border-radius: 18px; }
  .download-tool-card .section-header { margin-bottom: 18px; }
  .download-url-field {
    padding: 10px;
    flex-wrap: wrap;
    border-radius: 16px;
  }
  .download-link-icon { display: none; }
  .download-url-field .download-input {
    flex-basis: 100%;
    width: 100%;
    padding: 0 6px !important;
  }
  .download-url-field .download-btn { width: 100%; }
  .download-url-card .download-hint { margin-top: 12px; }
  .download-card { padding: 13px; gap: 11px; }
  .download-card-icon { width: 42px; height: 42px; }
  #textImportSection > div { flex-wrap: wrap; }
  #textImportSection .download-btn { width: 100%; }
}

/* Auto light mode: repeat all the same overrides */
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] .lyrics-line { color: rgba(0,0,0,0.25); }
  html[data-theme="auto"] .lyrics-line:hover { color: rgba(0,0,0,0.5); }
  html[data-theme="auto"] .lyrics-line.active { color: #1a1815; text-shadow: none; }
  html[data-theme="auto"] .lyrics-line.past { color: rgba(0,0,0,0.4); }
  html[data-theme="auto"] .lyrics-line.upcoming { color: rgba(0,0,0,0.45); }
  html[data-theme="auto"] .lyrics-action-btn:hover { background: var(--overlay-hover); }
  html[data-theme="auto"] .auth-overlay { background: var(--overlay-dialog); }
  html[data-theme="auto"] .download-badge { color: #fff; }
  html[data-theme="auto"] .yt-result-duration { background: rgba(0,0,0,0.7); color: #fff; }
  html[data-theme="auto"] .tooltip { background: var(--text-primary); color: var(--bg-base); }
  html[data-theme="auto"] .edit-overlay { background: var(--overlay-dialog); }
  html[data-theme="auto"] .card-play-btn svg,
  html[data-theme="auto"] .greeting-card-play svg { fill: #fff; }
  html[data-theme="auto"] .explore-lib-btn.in-lib { color: #fff; }
  html[data-theme="auto"] .source-badge.youtube { background: rgba(255,0,0,0.1); }
  html[data-theme="auto"] .queue-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); }
  html[data-theme="auto"] .nav-arrow { color: var(--text-primary); }
}
