:root {
  --bg: #0a0a10;
  --bg-grad: radial-gradient(ellipse at top left, #1a1530 0%, #0a0a10 60%);
  --surface: #14141d;
  --surface-2: #1c1c28;
  --surface-3: #262635;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f0f0f7;
  --text-muted: #8a8aa0;
  --text-faint: #5a5a70;
  --primary: #7c5cff;
  --primary-hover: #9075ff;
  --primary-dim: rgba(124, 92, 255, 0.14);
  --primary-glow: rgba(124, 92, 255, 0.45);
  --accent: #5c8cff;
  --error: #ff5c7c;
  --success: #5cffaa;
  --warning: #ffc55c;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --player-h: 92px;
  --sidebar-w: 232px;
  --t: 0.18s ease;
  --t-slow: 0.3s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
*:focus { outline: none; }
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body { background: var(--bg-grad); background-attachment: fixed; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
img { display: block; max-width: 100%; }
input, select, textarea, button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); border: 2px solid transparent; background-clip: padding-box; }

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* === Login screen === */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-grad);
  z-index: 100;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s var(--t-slow);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-header h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
.login-header p { color: var(--text-muted); font-size: 14px; }

.logo-mark {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 18px;
  font-size: 32px;
  color: white;
  box-shadow: 0 12px 28px var(--primary-glow);
  font-weight: 600;
}
.logo-mark.sm {
  width: 32px; height: 32px;
  border-radius: 9px;
  font-size: 17px;
  margin: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* === Forms === */
.form { display: flex; flex-direction: column; gap: 16px; }

label { display: flex; flex-direction: column; gap: 6px; }
label > span:first-child {
  font-size: 11px; color: var(--text-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}

input[type="text"], input[type="url"], input[type="password"], input[type="email"], input[type="search"], select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  transition: border-color var(--t), background var(--t);
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus { border-color: var(--primary); background: var(--surface-3); }
input:disabled { opacity: 0.5; cursor: not-allowed; }

select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%238a8aa0' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

label.checkbox { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
label.checkbox > span:first-child { display: none; }
label.checkbox > span { text-transform: none; letter-spacing: normal; font-size: 13px; color: var(--text); font-weight: 400; }
input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--t);
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: transparent; border-color: rgba(255, 92, 124, 0.3); color: var(--error); }
.btn-danger:hover { background: rgba(255, 92, 124, 0.1); border-color: var(--error); }
.btn-block { width: 100%; }

.text-btn {
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--t);
}
.text-btn:hover { color: var(--text); }

.msg-error { color: var(--error); padding: 10px 12px; background: rgba(255, 92, 124, 0.1); border-radius: var(--radius-sm); font-size: 13px; }
.msg-success { color: var(--success); padding: 10px 12px; background: rgba(92, 255, 170, 0.1); border-radius: var(--radius-sm); font-size: 13px; }

/* === App shell === */
.app-shell {
  position: fixed; inset: 0 0 calc(var(--player-h) + env(safe-area-inset-bottom)) 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
  transition: bottom var(--t);
}
.app-shell.no-player { bottom: env(safe-area-inset-bottom); }

/* === Sidebar === */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 12px 16px max(12px, env(safe-area-inset-left));
  min-width: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 24px;
}
.sidebar-header .brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--t);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-dim); color: var(--primary); }
.nav-icon {
  font-size: 15px; width: 18px; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-footer { margin-top: auto; padding: 8px 4px; border-top: 1px solid var(--border); padding-top: 12px; }

/* === Content === */
.content {
  overflow-y: auto;
  padding: max(32px, env(safe-area-inset-top)) max(40px, env(safe-area-inset-right)) 48px 40px;
  scroll-behavior: smooth;
  /* Without this, an intrinsically-wide child (e.g. a long tab row) makes
     the 1fr grid track grow past the viewport. */
  min-width: 0;
}

.view {
  animation: fadeIn 0.25s var(--t);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.view-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-title { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.view-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 13px; }

.section { margin-bottom: 40px; }
.section-title {
  font-size: 17px; font-weight: 600;
  margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: baseline;
  letter-spacing: -0.005em;
}
.section-title a { color: var(--text-muted); font-size: 12px; font-weight: 500; }
.section-title a:hover { color: var(--primary); }

.tabs {
  display: flex; gap: 2px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--t);
  white-space: nowrap;
  flex-shrink: 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === Album grid === */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 24px 20px;
}
.album-card {
  cursor: pointer;
  transition: transform var(--t);
  min-width: 0;
}
.album-card:hover { transform: translateY(-4px); }
.album-cover {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
  margin-bottom: 12px;
}
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-size: 36px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
}
.play-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0.1) 60%);
  display: flex; align-items: flex-end; justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--t);
  padding: 12px;
}
.album-card:hover .play-overlay,
.album-card:focus-within .play-overlay { opacity: 1; }
.play-overlay-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: white;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
  transform: translateY(8px);
  transition: transform var(--t), background var(--t);
}
.album-card:hover .play-overlay-btn { transform: none; }
.play-overlay-btn:hover { background: var(--primary-hover); }
.album-name {
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13.5px;
}
.album-artist {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* === Artist grid === */
.artist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 28px 20px;
}
.artist-card { text-align: center; cursor: pointer; min-width: 0; }
.artist-avatar {
  width: 130px; height: 130px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  color: var(--text-faint);
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t);
  box-shadow: var(--shadow-sm);
}
.artist-card:hover .artist-avatar {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}
.artist-avatar img { width: 100%; height: 100%; object-fit: cover; }
.artist-name {
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.artist-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* === Detail page === */
.detail-header {
  display: flex; gap: 32px;
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.detail-cover {
  width: 220px; height: 220px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; flex: 1; }
.detail-eyebrow { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.detail-title {
  font-size: 38px; font-weight: 800;
  margin: 8px 0 12px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.detail-meta { color: var(--text-muted); margin-bottom: 18px; font-size: 13px; }
.detail-meta a { color: var(--text); font-weight: 500; }
.detail-meta a:hover { color: var(--primary); }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-play-large {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 28px;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  transition: all var(--t);
  border: none;
}
.btn-play-large:hover { background: var(--primary-hover); transform: scale(1.03); }
.btn-play-large .icon { font-size: 14px; }

/* === Track list === */
.track-list-header,
.track-row {
  display: grid;
  grid-template-columns: 40px 1fr 200px 60px 36px;
  gap: 16px;
  align-items: center;
  padding: 8px 12px;
}
.track-list-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  padding-bottom: 12px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.track-list-header .col-num { text-align: center; }
.track-list-header .col-dur { text-align: right; }
.track-row {
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t);
  user-select: none;
}
.track-row:hover { background: var(--surface-2); }
.track-row.playing { color: var(--primary); }
.track-row.playing .track-num { color: var(--primary); }
.track-num {
  color: var(--text-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.track-row:hover .track-num-text { display: none; }
.track-row:hover .track-num-icon { display: inline; }
.track-num-icon { display: none; color: var(--text); }
.track-row.playing .track-num-text { display: none; }
.track-row.playing .track-num-icon { display: inline; color: var(--primary); }
.track-title { overflow: hidden; min-width: 0; }
.track-title .name {
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.track-title .artist {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.track-album {
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px;
}
.track-album:hover { color: var(--text); }
.track-duration {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  text-align: right;
}

/* === Search === */
.search-input {
  width: 100%;
  font-size: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  transition: border-color var(--t), background var(--t);
}
.search-input:focus { border-color: var(--primary); }

.song-list { display: flex; flex-direction: column; gap: 2px; }

/* === Player bar === */
.player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--player-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(20, 20, 29, 0.85);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 2fr) minmax(220px, 1fr);
  align-items: center;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  gap: 24px;
  z-index: 50;
}

.player-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player-tap {
  display: flex; align-items: center; gap: 12px;
  min-width: 0; flex: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin: -4px;
  transition: background var(--t);
}
.player-tap:hover { background: var(--surface-2); }
@media (min-width: 641px) { .player-tap { cursor: default; } .player-tap:hover { background: transparent; } }
.player-art-wrap {
  position: relative;
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
}
.player-art {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
.player-art.loaded { display: block; position: relative; z-index: 1; }
.player-art-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-size: 22px;
}
.player-art.loaded ~ .player-art-placeholder { display: none; }
.player-meta { min-width: 0; flex: 1; }
.player-title {
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-artist {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: block;
}
.player-artist:hover { color: var(--text); }
.star-btn { color: var(--text-faint); }
.star-btn.active { color: var(--warning); }

.player-controls { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.player-buttons { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--t);
  font-size: 15px;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn.active { color: var(--primary); }
.btn-play {
  width: 38px; height: 38px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
}
.btn-play:hover { background: white; color: var(--bg); transform: scale(1.06); }
.btn-play:active { transform: scale(0.96); }

.player-seek { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 600px; }
.time {
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}
.time:last-child { text-align: right; }
.seek-track {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: height var(--t);
}
.seek-track:hover, .seek-track.dragging { height: 6px; }
.seek-buffered {
  position: absolute; top: 0; left: 0; height: 100%;
  background: var(--border-strong);
  border-radius: 2px;
  pointer-events: none;
  transition: width 0.3s ease;
}
.seek-progress {
  position: absolute; top: 0; left: 0; height: 100%;
  background: var(--text);
  border-radius: 2px;
  pointer-events: none;
}
.seek-track:hover .seek-progress,
.seek-track.dragging .seek-progress { background: var(--primary); }
.seek-thumb {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: opacity var(--t);
}
.seek-track:hover .seek-thumb,
.seek-track.dragging .seek-thumb { opacity: 1; }

.player-extras {
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end;
}
.player-status {
  font-size: 11px;
  color: var(--warning);
  margin-right: 4px;
  white-space: nowrap;
}

.volume-control { display: flex; align-items: center; gap: 6px; }
.volume-track {
  width: 90px;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: height var(--t);
}
.volume-track:hover { height: 6px; }
.volume-progress {
  position: absolute; top: 0; left: 0; height: 100%;
  background: var(--text);
  border-radius: 2px;
  pointer-events: none;
}
.volume-track:hover .volume-progress { background: var(--primary); }

/* === Modal === */
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.18s var(--t);
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.22s var(--t-slow);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 24px; overflow-y: auto; }
fieldset {
  border: none;
  margin-bottom: 18px;
  display: flex; flex-direction: column;
  gap: 12px;
}
fieldset legend {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 4px;
}
.hint { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 8px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* === Queue panel === */
.queue-panel {
  position: fixed;
  right: 16px;
  bottom: calc(var(--player-h) + env(safe-area-inset-bottom) + 12px);
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  z-index: 180;
  animation: fadeInUp 0.2s var(--t-slow);
}
.queue-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.queue-header h3 { font-size: 13px; font-weight: 600; }
.queue-actions { display: flex; align-items: center; gap: 4px; }
.queue-list { overflow-y: auto; padding: 8px; flex: 1; }
.queue-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t);
  position: relative;
}
.queue-item:hover { background: var(--surface-2); }
.queue-item.current { background: var(--primary-dim); color: var(--primary); }
.queue-item img {
  width: 36px; height: 36px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-3);
}
.queue-item .meta { flex: 1; min-width: 0; }
.queue-item .name {
  font-weight: 500;
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.queue-item .sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.queue-item.current .sub { color: var(--primary); opacity: 0.8; }

/* === Loading & empty states === */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 80px 20px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state .icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state .title {
  font-size: 16px;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 600;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(var(--player-h) + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  z-index: 300;
  animation: toastIn 0.2s var(--t);
}
.toast.error { background: rgba(255, 92, 124, 0.15); border-color: rgba(255, 92, 124, 0.4); color: var(--error); }
.toast.success { background: rgba(92, 255, 170, 0.12); border-color: rgba(92, 255, 170, 0.35); color: var(--success); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translateX(-50%); }
}

/* === Row action (⋯) === */
.row-action {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--t), background var(--t), color var(--t);
}
.track-row:hover .row-action,
.row-action:focus-visible { opacity: 1; }
.row-action:hover { background: var(--surface-3); color: var(--text); }

/* === Context menu === */
.context-menu {
  position: fixed;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 1000;
  min-width: 200px;
  max-width: 280px;
  animation: fadeIn 0.12s var(--t);
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: background var(--t);
}
.menu-item:hover,
.menu-item:focus-visible { background: var(--surface-2); }
.menu-icon {
  width: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.menu-item:hover .menu-icon { color: var(--text); }
.menu-label {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

/* === Playlist picker modal === */
.playlist-picker .modal-body {
  display: flex; flex-direction: column;
  gap: 14px;
}
.picker-create { display: flex; gap: 8px; }
.picker-create input { flex: 1; margin: 0; }
.picker-divider {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 4px;
}
.picker-list {
  display: flex; flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
}
.picker-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--t);
  width: 100%;
  text-align: left;
  font: inherit;
}
.picker-item:hover { background: var(--surface-2); }
.picker-item .meta { min-width: 0; flex: 1; }
.picker-item .name {
  font-weight: 500; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.picker-item .sub {
  color: var(--text-muted); font-size: 11px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* === Mobile full-screen player === */
/* Hidden entirely on desktop; on narrow screens, sits off-screen until .open */
.mobile-player {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at top, rgba(124, 92, 255, 0.25), transparent 60%),
    linear-gradient(180deg, #1a1530 0%, #0a0a10 100%);
  z-index: 150;
  display: none;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
}
.mobile-player.open { transform: none; }

.mp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 4px;
  flex-shrink: 0;
}
.mp-header-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}
#mp-close { font-size: 26px; line-height: 1; }

.mp-cover-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 4px 22px;
  min-height: 0;
}
.mp-cover-box {
  width: 100%;
  max-width: min(340px, 80vw);
  aspect-ratio: 1;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  background: var(--surface-2);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.mp-cover {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
  z-index: 1;
}
.mp-cover.loaded { display: block; }
.mp-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 96px;
  color: var(--text-faint);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
}
.mp-cover.loaded ~ .mp-placeholder { display: none; }

.mp-meta {
  text-align: center;
  padding: 0 0 12px;
  flex-shrink: 0;
}
.mp-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mp-artist {
  display: block;
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mp-seek-wrap {
  padding: 0 2px 18px;
  flex-shrink: 0;
}
.mp-seek-wrap .seek-track { height: 6px; }
.mp-seek-wrap .seek-track:hover,
.mp-seek-wrap .seek-track.dragging { height: 8px; }
.mp-times {
  display: flex; justify-content: space-between;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.mp-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  padding-bottom: 18px;
  flex-shrink: 0;
}
.mp-controls .icon-btn {
  width: 52px; height: 52px;
  font-size: 20px;
}
.mp-controls .btn-play {
  width: 68px; height: 68px;
  font-size: 24px;
}

.mp-extras {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
}
.mp-extras .icon-btn {
  width: 44px; height: 44px;
  font-size: 18px;
}

@media (max-width: 640px) {
  .mobile-player { display: flex; }
  /* Hide the cramped mini bar details when the full player is open */
  body.mobile-player-open #player-bar { display: none; }
}

/* === Responsive === */
@media (max-width: 900px) {
  .content { padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 32px 24px; }
  .detail-cover { width: 180px; height: 180px; }
  .detail-title { font-size: 28px; }
  .player-bar { grid-template-columns: 1fr 1fr; gap: 12px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .player-extras { display: none; }
  .player-seek { display: none; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 60px; }
  .sidebar { padding: max(12px, env(safe-area-inset-top)) 6px 12px max(6px, env(safe-area-inset-left)); }
  .sidebar-header {
    padding: 4px 0 16px;
    justify-content: center;
  }
  .sidebar-header .brand,
  .nav-item .nav-label { display: none; }
  .nav-item { justify-content: center; padding: 10px 4px; }
  .sidebar-footer {
    padding: 10px 0 4px;
    display: flex;
    justify-content: center;
  }
  .content { padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px 16px; }
  .detail-header { flex-direction: column; gap: 20px; }
  .detail-cover { width: 160px; height: 160px; align-self: flex-start; }
  .detail-title { font-size: 24px; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 18px 14px; }
  .artist-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 22px 14px; }
  .artist-avatar { width: 100px; height: 100px; font-size: 36px; }
  .track-list-header,
  .track-row { grid-template-columns: 32px 1fr 50px 32px; gap: 10px; padding: 8px; }
  .track-album, .col-album { display: none; }
  .player-bar {
    padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); gap: 8px;
    /* Skip the backdrop blur on mobile — it's a heavy per-frame GPU pass. */
    background: rgba(20, 20, 29, 0.96);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .player-art-wrap { width: 44px; height: 44px; }
  .btn-play { width: 44px; height: 44px; font-size: 14px; }
  .icon-btn { width: 38px; height: 38px; }
  .queue-panel { right: 8px; left: 8px; width: auto; }
}
