:root {
  color-scheme: dark;
  --bg: #0a0a0f;
  --surface: rgba(255,255,255,0.05);
  --surface-2: rgba(255,255,255,0.08);
  --surface-3: rgba(255,255,255,0.12);
  --text: #f0f0f5;
  --text-secondary: rgba(255,255,255,0.55);
  --accent: #6c5ce7;
  --accent-glow: rgba(108,92,231,0.35);
  --accent-2: #00cec9;
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-top: max(0px, env(safe-area-inset-top));
  --safe-bottom: max(0.5rem, env(safe-area-inset-bottom));
  --tab-h: calc(3.6rem + var(--safe-bottom));
  --mini-h: 58px;
  --header-h: 3.2rem;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  position: fixed;
  inset: 0;
}

/* ═══════════════ SPLASH ═══════════════ */
.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  transition: opacity 500ms ease;
}
.splash.fade-out { opacity: 0; pointer-events: none; }
.splash-icon {
  width: 88px;
  height: 88px;
  animation: splashPulse 1.2s ease-in-out infinite alternate;
}
.splash-name {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.splash-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
@keyframes splashPulse {
  from { transform: scale(0.95); opacity: 0.8; }
  to   { transform: scale(1.05); opacity: 1; }
}

/* ═══════════════ LAYOUT ═══════════════ */
.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ── Scrollable view area ── */
.view {
  display: none;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 0.6rem) 1rem 1rem;
  padding-bottom: calc(var(--tab-h) + var(--mini-h) + 1.5rem);
}
.view.active { display: block; }

/* ── Fixed header inside each view ── */
.view-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0 0.8rem;
}
.view-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.header-actions { display: flex; gap: 0.5rem; }

/* ═══════════════ BUTTONS ═══════════════ */
.pill-btn {
  border: 1px solid var(--surface-3);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms, border-color 150ms;
}
.pill-btn:active { background: var(--surface-3); }
.pill-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill-btn.accent:active { opacity: 0.85; }
.pill-btn.danger { background: rgba(255,107,107,0.15); border-color: rgba(255,107,107,0.3); color: var(--danger); }
.pill-btn.wide { width: 100%; text-align: center; }
.pill-btn.active-fav { background: rgba(255,107,107,0.15); border-color: rgba(255,107,107,0.3); color: #ff6b6b; }
.pill-btn.small-pill { padding: 0.25rem 0.6rem; font-size: 0.72rem; }

/* ═══════════════ SEARCH BAR ═══════════════ */
.search-bar { position: relative; margin-bottom: 1rem; }
.search-bar input {
  width: 100%;
  padding: 0.8rem 0.8rem 0.8rem 2.6rem;
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 200ms;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text-secondary); }
.search-icon {
  position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-secondary); pointer-events: none;
}
.search-bar.small { margin-bottom: 0; }
.search-bar.small input { padding: 0.6rem 0.6rem 0.6rem 2.2rem; font-size: 0.88rem; }
.search-bar.small .search-icon { left: 0.65rem; width: 16px; height: 16px; }

/* ═══════════════ LIBRARY TOOLS ═══════════════ */
.library-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  align-items: center;
}
select {
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 0.6rem 0.7rem;
  font-size: 0.82rem;
  font-family: inherit;
}

/* ═══════════════ SECTION LABELS ═══════════════ */
.section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

/* ═══════════════ RECENTLY PLAYED (horizontal scroll) ═══════════════ */
.recently-played-section { margin-bottom: 1rem; }
.recently-played-scroll {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.3rem;
  scrollbar-width: none;
}
.recently-played-scroll::-webkit-scrollbar { display: none; }

.recent-card {
  flex: 0 0 auto;
  width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.recent-card:active { opacity: 0.7; }
.recent-card-art {
  width: 72px; height: 72px; border-radius: 10px;
  object-fit: cover; background: var(--surface-2);
}
.recent-card-art.placeholder {
  display: grid; place-items: center;
  font-size: 1.5rem; color: var(--text-secondary);
}
.recent-card-title {
  font-size: 0.7rem;
  font-weight: 500;
  text-align: center;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.recent-card-artist {
  font-size: 0.62rem;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  margin-top: -0.15rem;
}

/* ═══════════════ SEARCH RESULTS ═══════════════ */
.search-results { display: grid; gap: 0.5rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-secondary); }
.empty-icon { font-size: 3rem; margin-bottom: 0.8rem; opacity: 0.4; }
.empty-state p { margin: 0.3rem 0; }
.hint { font-size: 0.82rem; color: var(--text-secondary); }

.result-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid transparent;
  transition: background 150ms;
  cursor: pointer;
}
.result-item:active { background: var(--surface-2); }

.art {
  width: 52px; height: 52px; border-radius: 8px;
  object-fit: cover; background: var(--surface-2);
}
.art.placeholder {
  display: grid; place-items: center;
  font-size: 1.2rem; color: var(--text-secondary);
}

.result-info { min-width: 0; }
.result-info .title {
  font-weight: 600; font-size: 0.92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-info .meta {
  font-size: 0.78rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 0.15rem;
}
.result-info .badge-row {
  display: flex; align-items: center; gap: 0.4rem; margin-top: 0.25rem;
}
.result-info .badge {
  display: inline-block; padding: 0.1rem 0.4rem;
  border-radius: 4px; font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase;
}
.badge.full { background: rgba(108,92,231,0.2); color: #a29bfe; }
.badge.preview { background: rgba(255,165,0,0.15); color: #ffa500; }
.duration-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.result-actions { display: flex; align-items: center; }
.add-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff;
  font-size: 1.2rem; display: grid; place-items: center;
  cursor: pointer; transition: transform 100ms;
}
.add-btn:active { transform: scale(0.9); }

/* ═══════════════ DOWNLOAD QUEUE ═══════════════ */
.download-queue { display: grid; gap: 0.4rem; margin-bottom: 0.8rem; }
.queue-item { padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); background: var(--surface); }
.queue-head { display: flex; justify-content: space-between; gap: 0.5rem; }
.queue-track { font-size: 0.82rem; font-weight: 500; }
.queue-state { font-size: 0.76rem; color: var(--text-secondary); }
.progress { margin-top: 0.35rem; height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px; transition: width 200ms ease;
}

/* ═══════════════ SONGS / LIBRARY ═══════════════ */
.songs { display: grid; gap: 0.4rem; }
.song {
  display: grid; grid-template-columns: 48px 1fr auto;
  gap: 0.6rem; align-items: center; padding: 0.55rem;
  border-radius: var(--radius-sm); background: var(--surface);
  transition: background 150ms;
}
.song:active { background: var(--surface-2); }
.song.now-playing-song { border: 1px solid var(--accent); background: rgba(108,92,231,0.08); }
.song-art { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.song-art.placeholder { display: grid; place-items: center; font-size: 1rem; color: var(--text-secondary); }
.song-main { min-width: 0; }
.song-title { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-meta { font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.1rem; }
.song-duration { font-size: 0.7rem; color: var(--text-secondary); margin-top: 0.1rem; }

.actions { display: flex; gap: 0.3rem; align-items: center; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--surface-2); color: var(--text); font-size: 0.82rem;
  display: grid; place-items: center; cursor: pointer; transition: background 100ms;
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.danger { background: rgba(255,107,107,0.12); color: var(--danger); }
.icon-btn.fav-active { color: #ff6b6b; }
.reorder { display: flex; flex-direction: column; gap: 0.15rem; }
.move-btn { background: var(--surface-2); border: none; border-radius: 6px; padding: 0.15rem 0.3rem; font-size: 0.68rem; color: var(--text); cursor: pointer; }

/* ═══════════════ PLAYLISTS ═══════════════ */
.create-playlist-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.create-playlist-form input {
  flex: 1; padding: 0.6rem 0.8rem;
  border: 1px solid var(--surface-3); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.88rem; font-family: inherit; outline: none;
}
.create-playlist-form input:focus { border-color: var(--accent); }
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
.playlist-card {
  padding: 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid transparent;
  cursor: pointer; transition: background 150ms, border-color 150ms;
}
.playlist-card.active { border-color: var(--accent); background: var(--surface-2); }
.playlist-card:active { background: var(--surface-2); }
.playlist-card .name { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; }
.playlist-card .count { font-size: 0.76rem; color: var(--text-secondary); }
.playlist-admin { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--surface-2); }
.admin-label { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.admin-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.admin-actions input {
  flex: 1; min-width: 120px; padding: 0.5rem 0.7rem;
  border: 1px solid var(--surface-3); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.85rem; font-family: inherit; outline: none;
}

/* ═══════════════ SETTINGS ═══════════════ */
.settings-section { margin-bottom: 1.5rem; }
.settings-section h3 {
  font-size: 0.88rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.7rem;
}
.settings-form { display: grid; gap: 0.5rem; }
.settings-form input {
  width: 100%; padding: 0.7rem 0.8rem;
  border: 1px solid var(--surface-3); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.9rem; font-family: inherit; outline: none;
}
.settings-form input:focus { border-color: var(--accent); }
.file-drop {
  display: block; border: 2px dashed var(--surface-3);
  border-radius: var(--radius); padding: 1.2rem;
  text-align: center; color: var(--text-secondary);
  font-size: 0.88rem; cursor: pointer; transition: border-color 150ms;
}
.file-drop:active { border-color: var(--accent); }
.file-drop input { display: none; }
.backup-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.fake-btn { display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* ═══════════════ MINI PLAYER ═══════════════ */
.mini-player {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--tab-h);
  height: var(--mini-h);
  background: rgba(16,16,24,0.97);
  /* backdrop-filter removed: at 0.97 alpha the blur was invisible but cost
     constant GPU compositing — a real lag source on older iPhones */
  border-top: 1px solid var(--surface-3);
  z-index: 90;
}
.mini-progress {
  height: 2px; background: var(--accent);
  width: 0; transition: width 300ms linear;
}
.mini-content {
  display: grid; grid-template-columns: 42px 1fr 42px;
  gap: 0.6rem; align-items: center;
  padding: 0.45rem 0.8rem; cursor: pointer;
  height: calc(var(--mini-h) - 2px);
}
.mini-art { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.mini-art.placeholder { display: grid; place-items: center; font-size: 0.9rem; color: var(--text-secondary); }
.mini-info { min-width: 0; }
.mini-title { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-artist { font-size: 0.74rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-play-btn {
  background: none; border: none; color: var(--text);
  cursor: pointer; padding: 0; display: grid; place-items: center;
}
.mini-play-btn svg { width: 28px; height: 28px; }

/* ═══════════════ NOW PLAYING ═══════════════ */
.now-playing {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center;
  padding: max(var(--safe-top), 0.5rem) 1.5rem max(env(safe-area-inset-bottom), 1rem);
  animation: slideUp 300ms ease-out;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.now-playing.hidden { display: none; }
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Top bar with close + sleep */
.np-top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  flex-shrink: 0;
}
.np-close {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 0.5rem;
}
.np-close svg { width: 28px; height: 28px; }
.np-top-btn {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 0.5rem;
  position: relative;
}
.np-top-btn svg { width: 22px; height: 22px; }
.np-top-btn.active { color: var(--accent); }

/* Sleep Timer */
.sleep-indicator {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(108,92,231,0.12);
  border: 1px solid rgba(108,92,231,0.25);
  border-radius: 999px;
  padding: 0.25rem 0.6rem 0.25rem 0.8rem;
  font-size: 0.76rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}
.sleep-cancel {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 0.8rem; padding: 0.1rem 0.2rem;
}

.sleep-menu {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 0.6rem;
  flex-shrink: 0;
}
.sleep-option {
  border: 1px solid var(--surface-3);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 150ms;
}
.sleep-option:active { background: var(--accent); border-color: var(--accent); }

.np-artwork-wrap {
  width: min(55vw, 260px); height: min(55vw, 260px);
  border-radius: 16px; overflow: hidden;
  margin-bottom: 1.2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  flex-shrink: 0;
}
.np-artwork { width: 100%; height: 100%; object-fit: cover; }
.np-artwork.placeholder {
  display: grid; place-items: center; background: var(--surface);
  font-size: 4rem; color: var(--text-secondary);
}
.np-info { text-align: center; margin-bottom: 0.8rem; width: 100%; max-width: 320px; flex-shrink: 0; }
.np-title { font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 0.88rem; color: var(--text-secondary); margin-top: 0.2rem; }
.np-progress { width: 100%; max-width: 320px; margin-bottom: 0.8rem; flex-shrink: 0; }
.seek-bar {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 999px;
  background: var(--surface-2); outline: none; cursor: pointer;
}
.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--text); border: none; cursor: pointer;
}
.seek-bar::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text); border: none; cursor: pointer;
}
.np-times { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.4rem; }

/* Controls with shuffle/repeat */
.np-controls {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}
.np-btn { background: none; border: none; color: var(--text); cursor: pointer; padding: 0; }
.np-btn svg { width: 32px; height: 32px; }
.np-play-btn {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--text); color: var(--bg);
  display: grid; place-items: center;
}
.np-play-btn svg { width: 28px; height: 28px; }
.np-play-btn:active { transform: scale(0.95); }

.np-ctrl-btn {
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer; padding: 0.3rem;
  position: relative;
  transition: color 150ms;
}
.np-ctrl-btn svg { width: 20px; height: 20px; }
.np-ctrl-btn.active { color: var(--accent); }
.repeat-one-badge {
  position: absolute;
  top: -2px; right: -4px;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg);
  border-radius: 50%;
  width: 14px; height: 14px;
  display: grid; place-items: center;
  line-height: 1;
}

/* ═══════════════ NOW PLAYING QUEUE ═══════════════ */
.np-queue-section {
  width: 100%;
  max-width: 320px;
  flex-shrink: 0;
}
.np-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.np-queue-header h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.np-queue-list {
  display: grid;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.queue-song {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem;
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: background 100ms;
}
.queue-song:active { background: var(--surface-2); }
.queue-song-art {
  width: 36px; height: 36px; border-radius: 6px;
  object-fit: cover; background: var(--surface-2);
}
.queue-song-art.placeholder {
  display: grid; place-items: center;
  font-size: 0.8rem; color: var(--text-secondary);
}
.queue-song-info { min-width: 0; }
.queue-song-title {
  font-size: 0.78rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-song-artist {
  font-size: 0.68rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-song-remove {
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  font-size: 0.75rem; padding: 0.2rem 0.4rem;
}
.queue-song-remove:active { color: var(--danger); }

/* ═══════════════ TAB BAR ═══════════════ */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(10,10,15,0.97);
  /* backdrop-filter removed for old-device performance (see mini-player note) */
  border-top: 1px solid var(--surface-2);
  padding: 0.4rem 0 var(--safe-bottom);
  z-index: 100;
}
.tab {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.2rem; padding: 0.4rem 0;
  background: none; border: none;
  color: var(--text-secondary); font-size: 0.65rem;
  font-family: inherit; font-weight: 500;
  cursor: pointer; transition: color 150ms;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }

/* ═══════════════ TOAST ═══════════════ */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--tab-h) + var(--mini-h) + 0.6rem);
  transform: translateX(-50%) translateY(200%);
  background: rgba(20,20,30,0.95);
  border: 1px solid var(--surface-3);
  padding: 0.55rem 1rem; border-radius: 999px;
  font-size: 0.82rem; z-index: 300;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.toast.show {
  animation: toastIn 1800ms ease forwards;
}
@keyframes toastIn {
  0%   { opacity: 0; visibility: visible; transform: translateX(-50%) translateY(200%); }
  8%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(200%); visibility: hidden; }
}

/* ═══════════════ STORAGE ═══════════════ */
.storage-info { margin-top: 0.3rem; }
.storage-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 0.4rem; }
.storage-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px; transition: width 400ms ease;
}
.storage-fill.warn { background: linear-gradient(90deg, #ffa500, #ff6b6b); }

/* ═══════════════ PWA BANNER ═══════════════ */
.pwa-banner {
  margin-top: 1.2rem; padding: 1rem;
  border-radius: var(--radius);
  background: rgba(108,92,231,0.12);
  border: 1px solid rgba(108,92,231,0.25);
}
.pwa-banner p { font-size: 0.85rem; line-height: 1.45; margin: 0 0 0.6rem; color: var(--text); }
.pwa-banner .pill-btn { width: 100%; text-align: center; }

.hidden { display: none !important; }

.splash-credit { margin-top: 0.5rem; font-size: 0.78rem; letter-spacing: 0.14em; color: var(--accent); font-weight: 600; }

/* ═══════════════ LYRICS (Spotify-style card, scroll down to see) ═══════════════ */
.lyrics-card {
  width: 100%;
  max-width: 320px;
  flex-shrink: 0;
  margin: 1.1rem 0 1rem;
  padding: 1rem 1.15rem 1.15rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--accent) 0%, #4534a8 100%);
}
.lyrics-card-title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.75);
  margin: 0 0 0.55rem;
}
.lyrics-scroll {
  position: relative;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.lyric-line {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.55;
  margin: 0.5rem 0;
  text-align: left;
  color: rgba(255,255,255,0.55);
  transition: color 0.2s ease;
  cursor: pointer;
}
.lyric-line.active { color: #ffffff; }
.lyrics-plain {
  white-space: pre-wrap;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.65;
  color: #ffffff;
  text-align: left;
}

/* ═══════════════ LOAD MORE ═══════════════ */
.load-more-btn { display: block; margin: 0.9rem auto 0.4rem; max-width: 240px; }

/* ═══════════════ ADD-TO-PLAYLIST SHEET ═══════════════ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 500px;
  background: #14141c;
  border-radius: 20px 20px 0 0;
  padding: 1.1rem 1.2rem calc(1.1rem + env(safe-area-inset-bottom));
  max-height: 70vh; display: flex; flex-direction: column;
  animation: slideUp 220ms ease-out;
}
.sheet-title { font-size: 1.05rem; margin: 0 0 0.15rem; }
.sheet-song { margin: 0 0 0.8rem; }
.sheet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; margin-bottom: 0.8rem; }
.sheet-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0.75rem 0.9rem; margin-bottom: 0.4rem;
  background: var(--surface); border: 1px solid transparent;
  border-radius: var(--radius); color: var(--text); font-size: 0.95rem;
  cursor: pointer;
}
.sheet-row.in-playlist { border-color: var(--accent); background: rgba(108,92,231,0.14); }
.sheet-row .check { color: var(--accent); font-weight: 700; }
.sheet-new { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; }
.sheet-new input {
  flex: 1; padding: 0.65rem 0.9rem; border-radius: var(--radius);
  border: 1px solid var(--surface-3); background: var(--surface); color: var(--text);
  font-size: 0.9rem;
}

/* ═══════════════ PLAYLIST CARDS + CHIP ═══════════════ */
.playlist-card-actions { display: flex; gap: 0.45rem; margin-top: 0.55rem; }
.playlist-card-actions .mini-act {
  flex: 1; padding: 0.4rem 0.5rem; font-size: 0.78rem;
  border-radius: 10px; border: 1px solid var(--surface-3);
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.playlist-card-actions .mini-act.play { background: var(--accent); border-color: var(--accent); color: #fff; }
.playlist-chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  margin: 0.55rem 0 0.15rem; padding: 0.35rem 0.5rem 0.35rem 0.8rem;
  background: rgba(108,92,231,0.16); border: 1px solid var(--accent);
  border-radius: 999px; font-size: 0.8rem; color: var(--text);
}
.playlist-chip button {
  background: none; border: none; color: var(--text-secondary);
  font-size: 0.85rem; cursor: pointer; padding: 0.1rem 0.3rem;
}

/* ═══════════════ SEARCH PREVIEW ═══════════════ */
.result-item.previewing { border: 1px solid var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.result-item.previewing .title { color: var(--accent); }

/* ═══════════════ DESKTOP ═══════════════ */
@media (min-width: 768px) {
  .view { max-width: 600px; margin: 0 auto; }
  .tab-bar { max-width: 500px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
  .mini-player { max-width: 500px; left: 50%; right: auto; transform: translateX(-50%); }
  .np-artwork-wrap { width: 300px; height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
