/* ============================================================
   SoundVault — Stylesheet
   Aesthetic: Dark luxury / editorial — deep blacks, warm reds,
   generous space, cinematic typography
   ============================================================ */

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

:root {
  /* Palette */
  --bg-deep: #0a0a0f;
  --bg-surface: #111118;
  --bg-raised: #18181f;
  --bg-hover: #22222e;
  --bg-active: #2a2a38;
  --border: rgba(255, 255, 255, 0.06);
  --border-hi: rgba(255, 255, 255, 0.12);

  /* Text */
  --text-primary: #f0ede8;
  --text-secondary: #8a8799;
  --text-muted: #4a4859;

  /* Accent */
  --red: #850f1c;
  --red-dim: #3d0f15;
  --red-glow: rgba(213, 0, 0, 1);
  --teal: #4ecdc4;
  --teal-dim: rgba(78, 205, 196, 0.15);

  /* Player */
  --player-h: 88px;
  --player-h-mob: 68px;
  --sidebar-w: 240px;
  --mobile-nav-h: 64px;

  /* Misc */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.8);

  /* Fonts */
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Transitions */
  --t: 0.2s ease;
  --t-slow: 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  height: 100%;
  font-size: 15px;
}

body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: 1fr var(--player-h);
  grid-template-areas:
    "sidebar main"
    "player  player";
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
}

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

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

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 0 24px;
  user-select: none;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--red);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-logo svg {
  width: 28px;
  height: 28px;
  color: var(--red);
}

.sidebar-nav {
  padding: 8px 10px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), color var(--t);
  text-align: left;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

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

.nav-btn.active {
  background: var(--bg-active);
  color: var(--red);
}

.sidebar-section {
  padding: 20px 10px 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: color var(--t);
  display: flex;
}

.section-header button svg {
  width: 16px;
  height: 16px;
}

.section-header button:hover {
  color: var(--text-primary);
}

#sidebar-playlists {
  list-style: none;
}

#sidebar-playlists li {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar-playlists li:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

#sidebar-playlists li.active {
  color: var(--red);
}

/* ── Main content ──────────────────────────────────────────── */
#main-content {
  grid-area: main;
  overflow-y: auto;
  padding: calc(32px + env(safe-area-inset-top)) 40px calc(100px + env(safe-area-inset-bottom));
  position: relative;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
  }
}

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

.view-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 24px;
}

h2.section-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin: 36px 0 16px;
  color: var(--text-primary);
}

/* ── Library Category List (Apple Music style) ─────────────── */
.library-category-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
}

.library-category-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--t);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

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

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

.library-category-item:active {
  background: var(--bg-active);
}

.lib-cat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lib-cat-icon svg {
  width: 24px;
  height: 24px;
  color: #fa243c;
}

.lib-cat-label {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 500;
  color: #fa243c;
}

.lib-cat-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Sub-view header ───────────────────────────────────────── */
.sub-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ── Songs actions bar ─────────────────────────────────────── */
.songs-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ── Songs track list (with album art thumbnails) ──────────── */
.songs-track-list li {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t);
  user-select: none;
}

.songs-track-list li:hover {
  background: var(--bg-hover);
}

.song-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.song-info {
  min-width: 0;
}

.song-info .track-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-info .player-album {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Artists list ──────────────────────────────────────────── */
.artists-list {
  list-style: none;
}

.artist-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t);
  user-select: none;
}

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

.artist-list-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-active);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.artist-list-avatar svg {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
}

.artist-list-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.artist-list-name {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.artist-list-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.artist-separator {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 8px 12px;
}

.az-scroll-container {
  position: sticky;
  top: 100px;
  height: calc(100vh - 300px);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  margin-left: 10px;
  padding-right: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--red);
  user-select: none;
  touch-action: none;
}

.az-char {
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background var(--t), color var(--t);
}

.az-char:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Artist detail hero ────────────────────────────────────── */
.artist-hero {
  display: flex;
  gap: 28px;
  align-items: flex-end;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.artist-avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--bg-active);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--border-hi);
}

.artist-avatar svg {
  width: 50%;
  height: 50%;
  color: var(--text-muted);
}

/* ── Card grid ─────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}

.album-card {
  cursor: pointer;
  border-radius: var(--radius-lg);
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: background var(--t), transform var(--t), border-color var(--t);
  position: relative;
  overflow: hidden;
}

.album-card:hover {
  background: var(--bg-raised);
  border-color: var(--border-hi);
  transform: translateY(-2px);
}

.album-card:hover .card-play-btn {
  opacity: 1;
  transform: translateY(0);
}

.card-art {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--bg-active);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.card-art svg {
  width: 40%;
  height: 40%;
  color: var(--text-muted);
}

.card-play-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--red);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--t), transform var(--t), box-shadow var(--t);
  box-shadow: 0 4px 16px rgba(200, 169, 110, 0.4);
  z-index: 2;
}

.card-play-btn svg {
  width: 16px;
  height: 16px;
  fill: #0a0a0f;
  margin-left: 2px;
}

.card-play-btn:hover {
  box-shadow: 0 6px 24px rgba(200, 169, 110, 0.6);
}

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Album colour strips for visual variety */
.card-art[data-hue="0"] {
  background: linear-gradient(135deg, #1a1018, #2a1520);
}

.card-art[data-hue="1"] {
  background: linear-gradient(135deg, #0f1a20, #152535);
}

.card-art[data-hue="2"] {
  background: linear-gradient(135deg, #161a0f, #252a15);
}

.card-art[data-hue="3"] {
  background: linear-gradient(135deg, #1a1018, #301825);
}

.card-art[data-hue="4"] {
  background: linear-gradient(135deg, #101820, #152530);
}

/* ── Search ────────────────────────────────────────────────── */
.search-bar-wrap {
  position: relative;
  margin-bottom: 28px;
}

.search-bar-wrap .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input,
#artists-search-input,
#songs-search-input,
#downloaded-search-input {
  width: 100%;
  padding: 14px 20px 14px 46px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}

#search-input:focus,
#artists-search-input:focus,
#songs-search-input:focus,
#downloaded-search-input:focus {
  border-color: var(--red-dim);
  box-shadow: 0 0 0 3px var(--red-glow);
}

#search-input::placeholder,
#artists-search-input::placeholder,
#songs-search-input::placeholder,
#downloaded-search-input::placeholder {
  color: var(--text-muted);
}

#search-results .search-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Album hero ────────────────────────────────────────────── */
.back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 6px 0;
  margin-bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--t);
}

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

.album-hero {
  display: flex;
  gap: 32px;
  align-items: flex-end;
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.album-art-lg {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-lg);
  background: var(--bg-active);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.album-art-lg svg {
  width: 50%;
  height: 50%;
  color: var(--text-muted);
}

.playlist-art {
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.album-meta {
  flex: 1;
  min-width: 0;
}

.meta-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.meta-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.album-meta h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 16px;
  line-height: 1.1;
}

.album-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-play-all {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--red);
  color: #fa243c;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity var(--t), transform var(--t);
}

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

.btn-play-all:hover {
  opacity: 0.85;
  transform: scale(1.02);
}

.btn-shuffle,
.btn-add-playlist,
.btn-secondary,
.pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-pill);
  color: #fa243c;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
}

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

.btn-shuffle:hover,
.btn-add-playlist:hover,
.btn-secondary:hover,
.pill-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hi);
}

.btn-danger {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid rgba(255, 80, 80, 0.3);
  border-radius: var(--radius-pill);
  color: #ff6060;
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--t);
}

.btn-danger:hover {
  background: rgba(255, 80, 80, 0.1);
}

/* ── Track list ────────────────────────────────────────────── */
.track-list {
  list-style: none;
}

.track-list li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t);
  user-select: none;
}

.track-list li:hover {
  background: var(--bg-hover);
}

.track-list li.active {
  background: var(--bg-active);
  color: var(--red);
}

.track-num {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.track-list li.active .track-num {
  color: var(--red);
}

.playing-indicator {
  display: none;
  align-items: center;
  gap: 2px;
  height: 14px;
}

.playing-indicator span {
  display: inline-block;
  width: 3px;
  background: var(--red);
  border-radius: 2px;
  animation: bar-bounce 0.8s ease infinite;
}

.playing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.playing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bar-bounce {

  0%,
  100% {
    height: 4px;
  }

  50% {
    height: 14px;
  }
}

.track-list li.active .track-num-wrap {
  display: none;
}

.track-list li.active .playing-indicator {
  display: flex;
}

.track-info {
  min-width: 0;
}

.track-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-list li.active .track-title {
  color: var(--red);
}

.track-duration {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.track-format {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-active);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

/* ── Player bar ────────────────────────────────────────────── */
#player-bar {
  grid-area: player;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 16px env(safe-area-inset-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  transition: all var(--t);
}

#player-bar.hidden {
  display: none !important;
}

/* Fullscreen Mode */
#player-bar.fullscreen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(40px + env(safe-area-inset-top)) 40px calc(40px + env(safe-area-inset-bottom));
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  z-index: 1000;
  border: none;
}

#player-bar.fullscreen .player-track {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "art art"
    "info info"
    "like add";
  justify-items: center;
  align-items: center;
  gap: 12px 0;
  margin-bottom: 30px;
}

#player-bar.fullscreen .player-art {
  grid-area: art;
  width: min(80vw, 320px);
  height: min(80vw, 320px);
  margin-bottom: 24px;
}

#player-bar.fullscreen .player-info {
  grid-area: info;
  text-align: center;
  margin-bottom: 8px;
}

#player-bar.fullscreen .player-title {
  font-size: 1.6rem;
  margin-bottom: 8px;
  white-space: normal;
}

#player-bar.fullscreen .player-album {
  font-size: 1rem;
}

#player-bar.fullscreen .player-like {
  grid-area: like;
  justify-self: end;
  margin-right: 20px;
}

#player-bar.fullscreen .player-add {
  grid-area: add;
  justify-self: start;
  margin-left: 20px;
}

#player-bar.fullscreen .player-controls {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 30px;
}

#player-bar.fullscreen .player-right {
  justify-content: center;
}

/* Premium Landscape Fullscreen Optimization */
@media (orientation: landscape) {
  #player-bar.fullscreen {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "track controls"
      "track right";
    align-items: center;
    gap: 12px 40px;
    padding: calc(20px + env(safe-area-inset-top)) calc(40px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(40px + env(safe-area-inset-left));
  }

  #player-bar.fullscreen .player-track {
    grid-area: track;
    margin-bottom: 0;
    gap: 8px 0;
  }

  #player-bar.fullscreen .player-art {
    width: min(48vh, 220px);
    height: min(48vh, 220px);
    margin-bottom: 8px;
  }

  #player-bar.fullscreen .player-title {
    font-size: 1.2rem;
    margin-bottom: 2px;
  }

  #player-bar.fullscreen .player-album {
    font-size: 0.85rem;
  }

  #player-bar.fullscreen .player-like {
    margin-right: 12px;
  }

  #player-bar.fullscreen .player-add {
    margin-left: 12px;
  }

  #player-bar.fullscreen .player-controls {
    grid-area: controls;
    margin: 0 auto;
    width: 100%;
    max-width: 400px;
  }

  #player-bar.fullscreen .player-right {
    grid-area: right;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    justify-content: space-between;
  }
}

/* Track info */
.player-track {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.player-art {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--bg-active);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.player-art svg {
  width: 60%;
  height: 60%;
  color: var(--text-muted);
}

.player-info {
  min-width: 0;
}

.player-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-album {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-like {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  transition: color var(--t);
}

.player-like svg {
  width: 18px;
  height: 18px;
}

.player-like:hover {
  color: var(--text-primary);
}

.player-like.liked {
  color: var(--red);
}

.player-like.liked svg {
  fill: var(--red);
}

/* Controls */
.player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

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

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--t), background var(--t);
}

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

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

.ctrl-btn.active {
  color: var(--red);
}

.ctrl-play {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg-deep);
  flex-shrink: 0;
}

.ctrl-play svg {
  width: 18px;
  height: 18px;
  fill: var(--bg-deep);
}

.ctrl-play:hover {
  background: var(--red);
  color: var(--bg-deep);
}

/* Progress */
.player-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

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

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

.progress-bar {
  height: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
}

.progress-track:hover .progress-bar {
  background: var(--red);
}

.progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 12px;
  height: 12px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform var(--t);
  pointer-events: none;
}

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

/* Right controls */
.player-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.stems-btn {
  color: var(--teal) !important;
}

.stems-btn:hover {
  background: var(--teal-dim) !important;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vol-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--bg-active);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text-primary);
  border-radius: 50%;
  cursor: pointer;
}

#volume-slider:hover::-webkit-slider-thumb {
  background: var(--red);
}

/* ── Panels ────────────────────────────────────────────────── */
.panel {
  position: fixed;
  bottom: calc(var(--player-h) + 12px);
  right: 20px;
  width: 320px;
  max-height: 480px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panelIn var(--t-slow);
}

.panel.hidden {
  display: none;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

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

.panel-header h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--t);
}

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

.panel-subtitle {
  padding: 10px 18px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Queue panel */
#queue-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

#queue-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  cursor: pointer;
  transition: background var(--t);
  font-size: 0.88rem;
}

#queue-list li:hover {
  background: var(--bg-hover);
}

#queue-list li.current {
  color: var(--red);
}

#queue-list .q-num {
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
}

#queue-list .q-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#queue-list .q-album {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Modal ─────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.15s ease;
}

#modal-overlay.hidden {
  display: none;
}

#modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 28px;
  min-width: 320px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: panelIn var(--t-slow);
}

#modal h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 18px;
}

#modal-body {
  margin-bottom: 18px;
}

#modal-body input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-active);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 12px;
}

#modal-body input:focus {
  border-color: var(--red-dim);
}

.modal-pl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--t);
}

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

.modal-pl-item .add-check {
  color: var(--red);
  display: none;
}

.modal-pl-item.in-playlist .add-check {
  display: block;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-red {
  padding: 10px 22px;
  background: var(--red);
  color: #0a0a0f;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: opacity var(--t);
}

.btn-red:hover {
  opacity: 0.85;
}

/* ── Context menu ──────────────────────────────────────────── */
#context-menu {
  position: fixed;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  list-style: none;
  padding: 6px;
  z-index: 600;
  min-width: 180px;
  animation: fadeIn 0.12s ease;
}

#context-menu.hidden {
  display: none;
}

#context-menu li {
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--t);
}

#context-menu li:hover {
  background: var(--bg-hover);
}

#context-menu li.danger {
  color: #ff6060;
}

#context-menu li.separator {
  height: 1px;
  background: var(--border);
  padding: 0;
  margin: 4px 0;
  pointer-events: none;
}

#context-menu li.hidden {
  display: none;
}

/* ── Playlist view ─────────────────────────────────────────── */
.playlist-list {
  list-style: none;
}

.playlist-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t);
}

.playlist-list li:hover {
  background: var(--bg-hover);
}

.pl-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--bg-active);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pl-icon svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

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

.pl-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Mobile nav ────────────────────────────────────────────── */
#mobile-nav {
  display: none;
}

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

/* ── Loading state ─────────────────────────────────────────── */
.loading-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ── Responsive: tablet ────────────────────────────────────── */
@media (max-width: 900px) {
  body {
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-rows: 1fr var(--player-h);
  }

  #sidebar {
    width: 64px;
  }

  .sidebar-logo span,
  .nav-btn span,
  .sidebar-section {
    display: none;
  }

  .sidebar-logo {
    padding: 20px;
    justify-content: center;
  }

  .nav-btn {
    justify-content: center;
    padding: 12px;
  }

  #main-content {
    padding: 24px 24px;
  }

  .album-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .album-art-lg {
    width: 160px;
    height: 160px;
  }

  .artist-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .artist-avatar {
    width: 120px;
    height: 120px;
  }

  .volume-wrap {
    display: none;
  }

  #player-bar:not(.fullscreen) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border-radius: var(--radius-lg);
    background: var(--bg-raised);
    height: 56px;
    padding: 6px 12px 6px 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-hi);
  }

  #player-bar:not(.fullscreen) .player-track {
    flex: 1;
    min-width: 0;
    gap: 10px;
  }

  #player-bar:not(.fullscreen) .player-art {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  }

  #player-bar:not(.fullscreen) .player-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    overflow: hidden;
  }

  #player-bar:not(.fullscreen) .player-title {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    display: block;
    padding: 0;
    animation: none;
  }

  #player-bar:not(.fullscreen) .player-album,
  #player-bar:not(.fullscreen) .player-like,
  #player-bar:not(.fullscreen) .player-add {
    display: none;
  }

  #player-bar:not(.fullscreen) .player-controls {
    display: flex;
    width: auto;
    margin: 0;
  }

  #player-bar:not(.fullscreen) .player-top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    justify-content: flex-end;
  }

  #player-bar:not(.fullscreen) .player-progress-row,
  #player-bar:not(.fullscreen) #btn-shuffle,
  #player-bar:not(.fullscreen) #btn-prev,
  #player-bar:not(.fullscreen) #btn-repeat {
    display: none;
  }

  #player-bar:not(.fullscreen) .ctrl-btn {
    width: 32px;
    height: 32px;
    padding: 4px;
    color: var(--text-primary);
  }

  #player-bar:not(.fullscreen) .ctrl-play {
    width: 32px;
    height: 32px;
    background: transparent;
  }

  #player-bar:not(.fullscreen) .ctrl-play svg {
    width: 24px;
    height: 24px;
  }

  #player-bar:not(.fullscreen) .player-right {
    display: none;
  }
}

/* ── Responsive: mobile ────────────────────────────────────── */
@media (max-width: 600px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 1fr auto auto;
    grid-template-areas:
      "main"
      "player"
      "mobile-nav";
  }

  #sidebar {
    display: none;
  }

  #mobile-nav {
    display: flex;
    grid-area: mobile-nav;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.65rem;
    cursor: pointer;
    transition: color var(--t);
  }

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

  .mnav-btn.active {
    color: var(--red);
  }

  #main-content {
    padding: calc(20px + env(safe-area-inset-top)) 16px 0;
    overflow-y: auto;
  }

  #player-bar:not(.fullscreen) {
    margin: 0 8px 8px 8px;
    /* Tighter margins on small mobile, no safe area because mobile-nav is below */
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
  }

  .album-art-lg {
    width: 130px;
    height: 130px;
  }

  .artist-avatar {
    width: 100px;
    height: 100px;
  }

  .album-meta h1 {
    font-size: 1.6rem;
  }

  .panel {
    width: calc(100vw - 24px);
    right: 12px;
  }

  .volume-wrap {
    display: none;
  }

  .library-category-item {
    padding: 16px;
  }

  .lib-cat-label {
    font-size: 1rem;
  }
}

/* ── iOS safe areas ────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #player-bar {
    padding-bottom: env(safe-area-inset-bottom);
    height: auto;
    min-height: var(--player-h);
  }

  @media (max-width: 900px) {
    #player-bar:not(.fullscreen) {
      padding-bottom: 6px;
      height: 56px;
      min-height: 56px;
    }
  }

  @media (max-width: 600px) {
    #mobile-nav {
      /* 
        HOW TO ADJUST BOTTOM SPACING:
        Currently this uses 'env(safe-area-inset-bottom)' which is Apple's default padding to clear the home swipe bar (about ~34px). 
        To move the nav bar closer to the bottom edge, you can multiply it by a decimal like 0.5, or replace it entirely with a fixed pixel value (e.g. padding-bottom: 12px;).
      */
      padding-bottom: calc(env(safe-area-inset-bottom) * 0.02);
    }
  }
}

/* ── Swipe to delete styles ────────────────────────────────── */
.track-list li,
.songs-track-list li {
  position: relative !important;
  overflow: hidden !important;
  padding: 0 !important;
  display: block !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  background: transparent !important;
}

.swipe-bg {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  z-index: 1;
  background: linear-gradient(90deg, #ff3b30, #ff2d55);
  color: white;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 20px;
  box-sizing: border-box;
  font-weight: 600;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.swipe-bg svg {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  fill: currentColor;
}

.swipe-content {
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease, background 0.15s ease;
  position: relative;
  z-index: 2;
  background: transparent;
}

/* Hover/active backgrounds on the swipe-content wrapper */
.track-list li:hover .swipe-content,
.songs-track-list li:hover .swipe-content {
  background: var(--bg-hover);
}

.track-list li.active .swipe-content {
  background: var(--bg-active);
  color: var(--red);
}

.track-list .swipe-content {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  box-sizing: border-box;
}

.songs-track-list .swipe-content {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  box-sizing: border-box;
}

#ctx-rename {
  color: var(--text-primary);
}

#ctx-rename:hover {
  background: var(--bg-hover);
  color: var(--red);
}

/* ── Active song wave animation ──────────────────────────────── */
.songs-list-item.active {
  background: var(--bg-active);
  color: var(--red);
}

.songs-list-item.active .track-title {
  color: var(--red);
}

/* Hide the cover art/icon when active */
.songs-list-item.active .song-thumb-art,
.songs-list-item.active .song-thumb-icon {
  display: none !important;
}

/* Show and center the playing wave indicator inside the thumbnail box */
.songs-list-item.active .song-thumb .playing-indicator {
  display: flex !important;
}

/* ── Stacked Album Covers for Playlists ─────────────────────── */
.playlist-stacked-art {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-active);
  border-radius: inherit;
}

.playlist-stacked-art .stacked-cover {
  position: absolute;
  width: 68%;
  height: 68%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-hi);
  transition: transform var(--t);
}

/* Rotation fan-out for 2 stacked covers */
.playlist-stacked-art.stack-2 .stacked-cover:nth-child(1) {
  transform: translate(-10%, -5%) rotate(-8deg);
  z-index: 1;
  opacity: 0.85;
}

.playlist-stacked-art.stack-2 .stacked-cover:nth-child(2) {
  transform: translate(10%, 5%) rotate(6deg);
  z-index: 2;
}

/* Rotation fan-out for 3 stacked covers */
.playlist-stacked-art.stack-3 .stacked-cover:nth-child(1) {
  transform: translate(-20%, -10%) rotate(-12deg);
  z-index: 1;
  opacity: 0.75;
}

.playlist-stacked-art.stack-3 .stacked-cover:nth-child(2) {
  transform: translate(0%, -5%) rotate(4deg);
  z-index: 2;
  opacity: 0.9;
}

.playlist-stacked-art.stack-3 .stacked-cover:nth-child(3) {
  transform: translate(20%, 10%) rotate(8deg);
  z-index: 3;
}

/* ── Fullscreen Player optimizations ────────────────────────── */
#player-bar.fullscreen .player-album {
  width: 100%;
  max-width: min(85vw, 360px);
  margin: 0 auto;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  text-overflow: clip;
}

#player-bar.fullscreen .player-album span {
  display: inline-block;
  transition: transform 0.5s ease;
}

#player-bar.fullscreen .player-album.marquee span {
  animation: player-marquee 10s linear infinite;
}

@keyframes player-marquee {
  0%, 15% {
    transform: translate3d(0, 0, 0);
  }
  50%, 65% {
    transform: translate3d(var(--scroll-dist, 0px), 0, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

#player-bar.fullscreen .progress-track {
  height: 6px;
}

/* Invisible touch padding overlay to make dragging easier on fingers */
.progress-track::after {
  content: '';
  position: absolute;
  top: -15px;
  bottom: -15px;
  left: 0;
  right: 0;
  z-index: 10;
}

#player-bar.fullscreen .progress-thumb {
  transform: translate(-50%, -50%) scale(1.2);
  opacity: 1;
  pointer-events: none;
}

#player-bar.fullscreen .ctrl-btn {
  width: 44px;
  height: 44px;
}

#player-bar.fullscreen .ctrl-btn svg {
  width: 22px;
  height: 22px;
}

#player-bar.fullscreen .ctrl-play {
  width: 56px;
  height: 56px;
}

#player-bar.fullscreen .ctrl-play svg {
  width: 26px;
  height: 26px;
}

#player-bar.fullscreen .player-top-controls {
  gap: 28px;
}