:root {
  --bg: #0f0f13;
  --bg2: #1a1a24;
  --bg3: #252535;
  --accent: #7c5cfc;
  --accent2: #a78bfa;
  --text: #e4e4eb;
  --text2: #9090a8;
  --border: #2a2a3c;
  --green: #22c55e;
  --red: #ef4444;
  --pink: #ec4899;
  --sidebar-w: 220px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overflow-x: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

/* --- Header --- */
.header {
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 20;
}
.header h1 { font-size: 17px; font-weight: 600; color: var(--accent2); white-space: nowrap; }
.header h1 sup { font-size: 10px; color: var(--accent); margin-left: 2px; }
.header .stats { font-size: 12px; color: var(--text2); white-space: nowrap; }
.search-box { flex: 1; max-width: 420px; position: relative; }
.search-box input {
  width: 100%; padding: 7px 12px 7px 34px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 13px; outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box::before {
  content: '🔍'; position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); font-size: 13px;
}
.btn {
  padding: 5px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text2); font-size: 11px; cursor: pointer;
  white-space: nowrap; transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.active { border-color: var(--accent); color: var(--accent2); background: rgba(124,92,252,0.1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.header-buttons { display: flex; gap: 8px; }

/* --- Main area with sidebar + table --- */
.main { flex: 1; display: flex; overflow: hidden; }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s, padding 0.2s;
}
.sidebar.collapsed { width: 0; padding: 0; border: none; }
.sidebar-header {
  padding: 10px 12px 6px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--accent2);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar-header .sidebar-actions { display: flex; gap: 6px; }
.sidebar-header .sidebar-btn {
  font-size: 10px; color: var(--text2); cursor: pointer; padding: 2px 6px;
  border-radius: 3px; transition: all 0.15s;
}
.sidebar-header .sidebar-btn:hover { color: var(--accent2); background: var(--bg3); }
.sidebar-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; font-size: 12px; cursor: pointer;
  transition: background 0.1s; white-space: nowrap;
}
.sidebar-item:hover { background: var(--bg3); }
.sidebar-item input[type="checkbox"] {
  accent-color: var(--accent); cursor: pointer;
  width: 14px; height: 14px;
}
.sidebar-item label { cursor: pointer; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-search {
  margin: 6px 10px;
  padding: 5px 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 11px; outline: none;
}
.sidebar-search:focus { border-color: var(--accent); }
.sidebar-backdrop { display: none; }

/* --- Table --- */
.table-container { flex: 1; overflow: auto; position: relative; }
table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12px; }
thead {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg2);
}
th {
  padding: 8px 10px; text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
  background: var(--bg2);
}
th:hover { color: var(--accent2); }
th.sorted { color: var(--accent2); }
th .sort-ind { margin-left: 4px; font-size: 10px; }
td {
  padding: 5px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
tr { transition: background 0.1s; cursor: pointer; }
tr:hover { background: var(--bg2); }
tr.playing {
  background: rgba(124,92,252,0.15) !important;
}
tr.playing td { border-top: 1px solid rgba(124,92,252,0.3); border-bottom: 1px solid rgba(124,92,252,0.3); }
td.col-title { color: var(--text); font-weight: 500; }
td.col-heart { width: 28px; text-align: center; padding: 5px 4px; }
.heart {
  color: #3a3a4c; font-size: 14px; cursor: pointer;
  transition: color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.heart:hover { color: #f472b6; transform: scale(1.2); }
.heart.liked { color: var(--pink); }

/* Empty state */
.empty-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--text2); padding: 40px;
}
.empty-state .es-icon { font-size: 48px; opacity: 0.5; }
.empty-state .es-title { font-size: 16px; color: var(--text); }
.empty-state .es-sub { font-size: 12px; }
.empty-state code { background: var(--bg3); padding: 1px 6px; border-radius: 3px; font-size: 11px; }

/* --- Player --- */
.player {
  flex-shrink: 0;
  background: linear-gradient(to top, #0d0d14, #161625);
  border-top: 1px solid var(--border);
  padding: 0;
  display: flex; flex-direction: column; gap: 0;
  min-height: 80px;
}
.player-row1 {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px 6px;
}
.player-cover {
  width: 56px; height: 56px; border-radius: 6px;
  background: var(--bg3); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text2);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.player-cover.has-song {
  background: linear-gradient(135deg, #7c5cfc 0%, #a78bfa 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(124,92,252,0.25), 0 4px 14px rgba(0,0,0,0.4);
}
.player-info { flex: 1; min-width: 0; max-width: 420px; }
.player-title {
  font-size: 13px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.1px;
  color: #fff; cursor: pointer;
}
.player-meta {
  font-size: 11px; color: var(--text2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.player-tags {
  font-size: 10px; color: var(--text2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 1px; opacity: 0.7;
}
.player-afterlike {
  flex-shrink: 0; font-size: 18px; cursor: pointer; user-select: none;
  color: #2a2a3c; transition: color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent; margin-right: 4px;
}
.player-afterlike:hover { color: #f472b6; transform: scale(1.1); }
.player-afterlike.liked { color: var(--pink); }
.player-transport {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.player-transport .tbtn {
  width: 32px; height: 32px; border: none; background: transparent;
  color: var(--text2); font-size: 15px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; padding: 0; line-height: 1;
}
.player-transport .tbtn:hover {
  color: #fff; background: rgba(255,255,255,0.06);
}
.player-transport .tbtn.play-btn {
  width: 40px; height: 40px; font-size: 18px;
  background: #fff; border: none; color: #0f0f13;
  margin: 0 4px;
}
.player-transport .tbtn.play-btn:hover {
  background: #e0e0e0; transform: scale(1.04);
}
.player-transport .tbtn.active {
  color: var(--accent); background: rgba(124,92,252,0.12);
}
.vol-slider {
  width: 80px; height: 3px; -webkit-appearance: none; appearance: none;
  background: var(--bg3); border-radius: 2px; outline: none; cursor: pointer;
  margin-left: 2px;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 10px; height: 10px; border-radius: 50%;
  background: #fff; cursor: pointer; border: none;
}
.vol-slider::-moz-range-thumb {
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; cursor: pointer; border: none;
}
.player-controls {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px 10px;
}
.player-controls audio { display: none; }
.player-time {
  font-size: 10px; color: var(--text2); font-variant-numeric: tabular-nums;
  min-width: 34px; text-align: center; flex-shrink: 0; user-select: none;
}
.player-seek {
  flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--bg3); border-radius: 2px; outline: none; cursor: pointer;
  transition: height 0.1s;
}
.player-seek:hover { height: 6px; }
.player-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 0px; height: 0px; border-radius: 50%;
  background: #fff; cursor: pointer; border: none;
  transition: width 0.1s, height 0.1s;
}
.player-seek:hover::-webkit-slider-thumb { width: 12px; height: 12px; }
.player-seek::-moz-range-thumb {
  width: 0px; height: 0px; border-radius: 50%;
  background: #fff; cursor: pointer; border: none;
}
.player-seek:hover::-moz-range-thumb { width: 12px; height: 12px; }

/* --- Now Playing overlay (mobile only) --- */
.np-overlay { display: none; }

/* Mobile-only elements hidden on desktop */
.mobile-nav { display: none; }
.mobile-filter-bar { display: none; }
#mobileCards { display: none; }

/* Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* Toast */
.toast {
  position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); color: var(--text); font-size: 13px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
  z-index: 300;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* --- Tablet --- */
@media (max-width: 900px) {
  .header { flex-wrap: wrap; gap: 8px; }
  .search-box { order: 2; flex: 1 1 100%; max-width: none; min-width: 0; }
  .header .stats { order: 3; width: 100%; }
  .header-buttons { order: 4; flex-wrap: wrap; }
  .player-row1 { padding: 8px 14px 4px; }
  .player-controls { padding: 0 14px 8px; }
  .player-cover { width: 44px; height: 44px; font-size: 18px; }
  .player-transport .tbtn { width: 30px; height: 30px; font-size: 14px; }
  .player-transport .tbtn.play-btn { width: 36px; height: 36px; font-size: 16px; }
  .player-info { max-width: 220px; min-width: 0; }
  td { max-width: 180px; }
  .vol-slider { display: none; }
  #btnVolMute { display: none; }
}

@media (hover: none) { .btn:hover { border-color: var(--border); color: var(--text2); } }

/* ================================================================
   MOBILE CARD VIEW (≤768px)
   ================================================================ */
@media (max-width: 768px) {
  body { overflow: hidden; height: 100vh; height: 100dvh; }

  .header {
    padding: 8px 10px; gap: 8px; flex-wrap: nowrap;
    align-items: center; min-height: 0;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .header h1 {
    font-size: 15px; flex-shrink: 0;
    white-space: nowrap; overflow: hidden;
  }
  .header h1 sup { display: none; }
  .header .stats { display: none; }
  .search-box { flex: 1 1 auto; min-width: 0; max-width: none; order: 0; }
  .search-box input {
    padding: 10px 12px 10px 34px; font-size: 16px;
    border-radius: 10px; background: var(--bg3);
    width: 100%;
  }
  .header #btnSidebar { display: none; }
  .header-buttons { display: none !important; }

  /* Mobile nav */
  .mobile-nav {
    display: flex !important;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    padding: 6px 8px; gap: 6px; flex-shrink: 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav .m-btn {
    flex: 0 0 auto; min-width: 64px; padding: 8px 6px; font-size: 11px;
    background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text2); cursor: pointer; text-align: center;
    white-space: nowrap; transition: all 0.15s;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
  }
  .mobile-nav .m-btn .m-icon { font-size: 16px; }
  .mobile-nav .m-btn.active { border-color: var(--accent); color: var(--accent2); background: rgba(124,92,252,0.12); }

  .mobile-filter-bar {
    display: flex !important;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 6px 10px; gap: 6px; align-items: center; flex-shrink: 0;
  }
  .mobile-filter-bar select {
    flex: 1; padding: 8px 8px; background: var(--bg3); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 13px; outline: none;
    -webkit-appearance: none; appearance: none;
  }
  .mobile-filter-bar .mf-count { font-size: 11px; color: var(--text2); flex-shrink: 0; white-space: nowrap; }

  .main { display: none !important; }

  #mobileCards {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 0; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px 12px; gap: 8px;
  }

  .song-card {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px; cursor: pointer; transition: background 0.15s, border-color 0.15s;
    position: relative; overflow: hidden;
    min-height: 68px;
    -webkit-tap-highlight-color: transparent;
  }
  .song-card:active { background: var(--bg3); }
  .song-card.playing { border-color: var(--accent); background: rgba(124,92,252,0.08); }
  .song-card .sc-cover {
    width: 52px; height: 52px; border-radius: 8px;
    background: var(--bg3); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--text2);
  }
  .song-card.playing .sc-cover {
    background: linear-gradient(135deg, #7c5cfc 0%, #a78bfa 100%);
    color: #fff;
  }
  .song-card .sc-body { flex: 1; min-width: 0; }
  .song-card .sc-title {
    font-size: 14px; font-weight: 600; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  .song-card .sc-tags {
    font-size: 11px; color: var(--text2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
  }
  .song-card .sc-meta {
    display: flex; gap: 8px; margin-top: 4px; font-size: 10px; color: var(--text2);
  }
  .song-card .sc-meta span { display: flex; align-items: center; gap: 2px; }
  .sc-heart {
    color: #3a3a4c; font-size: 16px;
    padding: 6px 8px; margin: -6px -4px;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }
  .sc-heart.liked { color: var(--pink); }
  .song-card .sc-actions {
    display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
    align-items: center;
  }
  .song-card .sc-action {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--bg3); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer; transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .song-card.playing .sc-play { background: var(--accent); border-color: var(--accent); color: #fff; }

  .mobile-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text2); font-size: 14px; gap: 8px; padding: 40px 20px;
    text-align: center;
  }
  .mobile-empty .me-icon { font-size: 40px; opacity: 0.4; }

  /* Mobile player */
  .player {
    padding: 0; gap: 0; flex-direction: column;
    min-height: auto; flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg2);
    border-top: 1px solid var(--border);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .player-row1 {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  }
  .player-cover { width: 40px; height: 40px; border-radius: 6px; box-shadow: none; font-size: 16px; }
  .player-info { flex: 1; min-width: 0; max-width: none; }
  .player-title { font-size: 13px; font-weight: 600; color: var(--text); }
  .player-meta { font-size: 10px; }
  .player-afterlike { display: none; }
  .player-transport { gap: 2px; flex-shrink: 0; }
  .player-transport .tbtn {
    width: 34px; height: 34px; font-size: 14px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
  }
  .player-transport .tbtn.play-btn {
    width: 40px; height: 40px; font-size: 16px;
    background: var(--accent); border-color: var(--accent); color: #fff;
  }
  #btnShuffleToggle, #btnLoopToggle, #btnVolMute, .vol-slider { display: none; }
  .player-controls { width: 100%; padding: 0 10px 6px; }
  .player-seek { height: 4px; }
  .player-seek::-webkit-slider-thumb { width: 12px; height: 12px; }
  .player-seek::-moz-range-thumb { width: 12px; height: 12px; }
  .player-time { font-size: 10px; min-width: 30px; }

  /* Now Playing full-screen */
  .np-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg); z-index: 80;
    flex-direction: column; overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .np-overlay.open { display: flex; }
  .np-header {
    display: flex; align-items: center; padding: 12px 16px; flex-shrink: 0;
  }
  .np-close {
    width: 36px; height: 36px; border: none; background: var(--bg3);
    color: var(--text); font-size: 18px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .np-header-title {
    flex: 1; text-align: center; font-size: 12px; color: var(--text2);
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
  }
  .np-header-action {
    width: 36px; height: 36px; border: none; background: var(--bg3);
    color: var(--text2); font-size: 16px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .np-header-action.liked { color: var(--pink); }
  .np-body {
    flex: 1; overflow-y: auto; padding: 0 24px;
    display: flex; flex-direction: column; align-items: center;
  }
  .np-cover {
    width: min(75vw, 300px); height: min(75vw, 300px);
    border-radius: 14px;
    background: linear-gradient(135deg, #7c5cfc 0%, #a78bfa 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 80px; color: #fff;
    box-shadow: 0 8px 30px rgba(124,92,252,0.25);
    margin-bottom: 20px;
  }
  .np-title { font-size: 20px; font-weight: 700; text-align: center; padding: 0 8px; }
  .np-tags { font-size: 13px; color: var(--text2); text-align: center; margin-top: 4px; }
  .np-seek-row {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 16px 0 4px;
  }
  .np-time { font-size: 11px; color: var(--text2); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; flex-shrink: 0; }
  .np-seek {
    flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
    background: var(--bg3); border-radius: 3px; outline: none; cursor: pointer;
  }
  .np-seek::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: none;
  }
  .np-seek::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
  .np-meta-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; width: 100%; margin-top: 16px; padding-bottom: 16px;
  }
  .np-meta-item {
    background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px;
  }
  .np-meta-item .np-ml { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.3px; }
  .np-meta-item .np-mv { font-size: 14px; font-weight: 600; margin-top: 2px; color: var(--text); }
  .np-actions {
    display: flex; gap: 8px; margin-top: 8px; padding-bottom: 16px; flex-wrap: wrap; justify-content: center;
  }
  .np-actions .np-abtn {
    flex: 1 1 60px; min-width: 60px; padding: 10px 4px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: 11px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    -webkit-tap-highlight-color: transparent;
  }
  .np-actions .np-abtn.active { border-color: var(--accent); color: var(--accent2); background: rgba(124,92,252,0.12); }
  .np-actions .np-abtn .np-ai { font-size: 18px; }

  .toast { bottom: 140px; }
}
  :root {
    --bg: #0f0f13;
    --bg2: #1a1a24;
    --bg3: #252535;
    --accent: #7c5cfc;
    --accent2: #a78bfa;
    --text: #e4e4eb;
    --text2: #9090a8;
    --border: #2a2a3c;
    --green: #22c55e;
    --red: #ef4444;
    --sidebar-w: 220px;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* --- Header --- */
  .header {
    padding: 8px 16px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    z-index: 20;
  }
  .header h1 { font-size: 17px; font-weight: 600; color: var(--accent2); white-space: nowrap; }
  .header .stats { font-size: 12px; color: var(--text2); white-space: nowrap; }
  .search-box { flex: 1; max-width: 420px; position: relative; }
  .search-box input {
    width: 100%; padding: 7px 12px 7px 34px;
    background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 13px; outline: none;
  }
  .search-box input:focus { border-color: var(--accent); }
  .search-box::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; }
  .btn { padding: 5px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); font-size: 11px; cursor: pointer; white-space: nowrap; transition: all 0.15s; }
  .btn:hover { border-color: var(--accent); color: var(--text); }
  .btn.active { border-color: var(--accent); color: var(--accent2); background: rgba(124,92,252,0.1); }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .header-buttons { display: contents; }

  /* --- Main area with sidebar + table --- */
  .main { flex: 1; display: flex; overflow: hidden; }

  /* --- Sidebar --- */
  .sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.2s, padding 0.2s;
  }
  .sidebar.collapsed { width: 0; padding: 0; border: none; }
  .sidebar-header {
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .sidebar-header .sidebar-actions { display: flex; gap: 6px; }
  .sidebar-header .sidebar-btn {
    font-size: 10px; color: var(--text2); cursor: pointer; padding: 2px 6px;
    border-radius: 3px; transition: all 0.15s;
  }
  .sidebar-header .sidebar-btn:hover { color: var(--accent2); background: var(--bg3); }
  .sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
  }
  .sidebar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
  }
  .sidebar-item:hover { background: var(--bg3); }
  .sidebar-item .drag-handle {
    cursor: grab; color: var(--text2); font-size: 11px; padding: 0 2px;
    user-select: none; flex-shrink: 0; opacity: 0.5; transition: opacity 0.15s;
  }
  .sidebar-item:hover .drag-handle { opacity: 1; }
  .sidebar-item.dragging { opacity: 0.4; background: var(--bg3); }
  .sidebar-item.drag-over { border-top: 2px solid var(--accent); }
  .sidebar-item input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
    width: 14px;
    height: 14px;
  }
  .sidebar-item label { cursor: pointer; flex: 1; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-item .col-type { font-size: 9px; color: var(--text2); background: var(--bg3); padding: 1px 5px; border-radius: 3px; }
  .sidebar-search {
    margin: 6px 10px;
    padding: 5px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 11px;
    outline: none;
  }
  .sidebar-search:focus { border-color: var(--accent); }

  /* --- Table --- */
  .table-container { flex: 1; overflow: auto; }
  table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12px; }
  thead { position: sticky; top: 0; z-index: 10; }
  th {
    background: var(--bg2); padding: 5px 8px 3px; text-align: left;
    font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--text2); border-bottom: 1px solid var(--border);
    user-select: none; white-space: nowrap; vertical-align: top;
    transition: border-left 0.1s;
  }
  th[draggable="true"] { cursor: grab; }
  th[draggable="true"]:active { cursor: grabbing; }
  th .th-label { cursor: pointer; display: inline-block; padding: 1px 0 3px; }
  th .th-label:hover { color: var(--accent2); }
  th .sort-arrow { margin-left: 3px; font-size: 9px; }
  th .col-filter { display: block; width: 100%; margin-top: 2px; position: relative; }
  th .col-filter .filter-row { display: flex; gap: 2px; align-items: center; }
  th .col-filter .filter-row select { flex: 1; min-width: 0; }
  th .col-filter .text-filter { margin-top: 2px; }
  th .col-filter .sort-toggle {
    flex-shrink: 0; width: 20px; height: 20px; padding: 0; border: 1px solid var(--border);
    background: var(--bg); color: var(--text2); font-size: 9px; border-radius: 3px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1;
  }
  th .col-filter .sort-toggle:hover { border-color: var(--accent); color: var(--accent2); }
  th .col-filter input, th .col-filter select {
    width: 100%; padding: 3px 5px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 3px; color: var(--text); font-size: 10px; outline: none;
    max-width: 280px;
  }
  th .col-filter input:focus, th .col-filter select:focus { border-color: var(--accent); }
  th .col-filter input::placeholder { color: var(--text2); opacity: 0.5; }
  td {
    padding: 6px 8px; border-bottom: 1px solid var(--border);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  tr { cursor: pointer; transition: background 0.1s; }
  tr:hover { background: var(--bg3); }
  tr.active { background: rgba(124,92,252,0.15); }
  tr.playing { background: rgba(124,92,252,0.18); }
  tr.playing td:first-child::before { content: '♫ '; color: var(--green); }
  tr.playing td { border-top: 1px solid rgba(124,92,252,0.3); border-bottom: 1px solid rgba(124,92,252,0.3); }
  .row-cover { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; vertical-align: middle; }
  .row-cover-cell { padding: 3px 4px; width: 36px; min-width: 36px; }

  /* --- Player --- */
  .player {
    flex-shrink: 0;
    background: linear-gradient(to top, #0d0d14, #161625);
    border-top: 1px solid var(--border);
    padding: 0;
    display: flex; flex-direction: column; gap: 0;
    min-height: 80px;
    max-height: 40vh;
    overflow-y: auto;
  }
  .player-row1 {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 20px 6px;
  }
  .player-cover {
    width: 56px; height: 56px; border-radius: 6px; object-fit: cover;
    background: var(--bg3); flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: box-shadow 0.3s;
  }
  .player-cover[src]:not([src=""]) {
    box-shadow: 0 4px 18px rgba(124,92,252,0.15), 0 4px 14px rgba(0,0,0,0.4);
  }
  .player-info { flex: 1; min-width: 0; max-width: 420px; }
  .player-title {
    font-size: 13px; font-weight: 600; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.1px;
    color: #fff;
  }
  .player-meta {
    font-size: 11px; color: var(--text2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
  }
  .player-tags {
    font-size: 10px; color: var(--text2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-top: 1px; opacity: 0.7;
  }
  .player-stats {
    font-size: 10px; color: var(--text2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-top: 1px; opacity: 0.7;
  }
  .player-stats span { margin-right: 8px; }
  .player-rating {
    flex-shrink: 0; font-size: 17px; letter-spacing: 1px;
    cursor: pointer; user-select: none;
  }
  .player-rating .star { color: #2a2a3c; transition: color 0.15s; }
  .player-rating .star.on { color: #facc15; }
  .player-rating:hover .star { color: #2a2a3c; }
  .player-rating:hover .star.hovered { color: #facc15; }
  .player-transport {
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  }
  .player-transport .tbtn {
    width: 32px; height: 32px; border: none; background: transparent;
    color: var(--text2); font-size: 15px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; padding: 0; line-height: 1;
  }
  .player-transport .tbtn:hover {
    color: #fff; background: rgba(255,255,255,0.06);
  }
  .player-transport .tbtn.play-btn {
    width: 40px; height: 40px; font-size: 18px;
    background: #fff; border: none; color: #0f0f13;
    margin: 0 4px;
  }
  .player-transport .tbtn.play-btn:hover {
    background: #e0e0e0; transform: scale(1.04);
  }
  .player-transport .tbtn.active {
    color: var(--accent); background: rgba(124,92,252,0.12);
  }
  .player-controls {
    display: flex; align-items: center; gap: 8px;
    padding: 0 20px 10px;
  }
  .player-controls audio { display: none; }
  .player-time {
    font-size: 10px; color: var(--text2); font-variant-numeric: tabular-nums;
    min-width: 34px; text-align: center; flex-shrink: 0; user-select: none;
  }
  .player-seek {
    flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
    background: var(--bg3); border-radius: 2px; outline: none; cursor: pointer;
    transition: height 0.1s;
  }
  .player-seek:hover { height: 6px; }
  .player-seek::-webkit-slider-thumb {
    -webkit-appearance: none; width: 0px; height: 0px; border-radius: 50%;
    background: #fff; cursor: pointer; border: none;
    transition: width 0.1s, height 0.1s;
  }
  .player-seek:hover::-webkit-slider-thumb { width: 12px; height: 12px; }
  .player-seek::-moz-range-thumb {
    width: 0px; height: 0px; border-radius: 50%;
    background: #fff; cursor: pointer; border: none;
    transition: width 0.1s, height 0.1s;
  }
  .player-seek:hover::-moz-range-thumb { width: 12px; height: 12px; }
  .player-seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; }
  .player-stem-row {
    display: flex; align-items: center; gap: 8px; padding: 0 20px 8px; justify-content: center;
  }
  .player-cover-row {
    display: flex; align-items: center; gap: 8px; padding: 0 20px 8px; justify-content: center; flex-wrap: wrap;
  }
  .player-cover-row .cover-link {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
    background: rgba(124,92,252,0.10); border: 1px solid rgba(124,92,252,0.25);
    border-radius: 12px; font-size: 12px; color: var(--accent); cursor: pointer;
    text-decoration: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .player-cover-row .cover-link:hover { background: rgba(124,92,252,0.20); }
  .player-cover-row .cover-label { font-size: 11px; color: var(--text2); margin-right: 2px; }
  .cover-toggle {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px;
    background: rgba(124,92,252,0.15); border: 1px solid rgba(124,92,252,0.3);
    border-radius: 14px; font-size: 12px; color: var(--accent); cursor: pointer;
    font-weight: 600; user-select: none;
  }
  .cover-toggle:hover { background: rgba(124,92,252,0.25); }
  .cover-list { display: flex; flex-wrap: wrap; gap: 6px; }
  .cover-list-collapsed { display: none; }
  .player-cover-row .cover-more { background: rgba(255,255,255,0.06); border-style: dashed; font-style: italic; }

  /* --- Now Playing overlay (mobile-only, hidden on desktop) --- */
  .np-overlay { display: none; }

  /* --- Playlist Manager --- */
  .pl-item {
    display: flex; align-items: center; padding: 10px 16px;
    border-bottom: 1px solid var(--border); cursor: pointer;
    transition: background 0.15s;
  }
  .pl-item:hover { background: var(--bg2); }
  .pl-info { flex: 1; min-width: 0; }
  .pl-name { font-size: 14px; font-weight: 500; color: var(--text); display: block; }
  .pl-count { font-size: 12px; color: var(--text2); }
  .pl-actions { display: flex; gap: 6px; }
  .pl-btn {
    background: none; border: 1px solid var(--border); border-radius: 4px;
    color: var(--text2); cursor: pointer; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
    transition: all 0.15s;
  }
  .pl-btn:hover { background: var(--bg3); color: var(--text); }
  .pl-btn-del:hover { background: rgba(239,68,68,0.15); color: var(--red); border-color: var(--red); }
  .pl-picker-item {
    padding: 12px 18px; cursor: pointer; border-bottom: 1px solid var(--border);
    font-size: 14px; color: var(--text); transition: background 0.15s;
  }
  .pl-picker-item:hover { background: var(--bg2); }
  .pl-picker-new { color: var(--accent); font-weight: 600; }

  ::-webkit-scrollbar { width: 7px; height: 7px; }
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--border); }

  /* --- Analytics overlay --- */
  .analytics-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75);
    z-index: 100;
    justify-content: center;
    align-items: center;
  }
  .analytics-overlay.open { display: flex; }
  .analytics-panel {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90vw; max-width: 1100px;
    height: 85vh; max-height: 780px;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }
  .analytics-header {
    padding: 14px 20px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    flex-shrink: 0;
  }
  .analytics-header h2 { font-size: 16px; color: var(--accent2); flex-shrink: 0; }
  .analytics-header .spacer { flex: 1; }
  .analytics-header select {
    padding: 5px 8px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 5px; color: var(--text); font-size: 12px; outline: none;
  }
  .analytics-header select:focus { border-color: var(--accent); }
  .analytics-header label { font-size: 11px; color: var(--text2); }
  .analytics-close {
    width: 30px; height: 30px; border: none; background: none; color: var(--text2);
    font-size: 20px; cursor: pointer; border-radius: 6px;
  }
  .analytics-close:hover { background: var(--bg); color: var(--text); }
  .analytics-body {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; gap: 20px; flex-wrap: wrap;
  }
  .chart-box {
    flex: 1; min-width: 420px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; display: flex; flex-direction: column;
  }
  .chart-box h3 { font-size: 13px; color: var(--accent2); margin-bottom: 10px; }
  .chart-box svg { width: 100%; flex: 1; }
  .stats-grid {
    width: 100%; min-width: 300px; max-width: 100%;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px;
  }
  .stat-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 12px 16px;
  }
  .stat-card .stat-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
  .stat-card .stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
  .stat-card .stat-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }
  .bar-row {
    display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 11px;
  }
  .bar-label { width: 80px; text-align: right; color: var(--text2); flex-shrink: 0; }
  .bar-track { flex: 1; height: 18px; background: var(--bg3); border-radius: 3px; position: relative; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
  .bar-val { width: 70px; font-size: 10px; color: var(--text2); }
  /* Analytics Dashboard */
  .analytics-tabs { display: flex; gap: 0; margin-right: 12px; }
  .analytics-tab {
    padding: 5px 14px; font-size: 12px; background: none; border: 1px solid var(--border);
    color: var(--text2); cursor: pointer; transition: all 0.15s;
  }
  .analytics-tab:first-child { border-radius: 6px 0 0 6px; }
  .analytics-tab:last-child { border-radius: 0 6px 6px 0; }
  .analytics-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .analytics-axis-controls { display: flex; align-items: center; gap: 8px; }
  .dash-section { width: 100%; min-width: 300px; }
  .dash-section h3 {
    font-size: 13px; color: var(--accent2); margin: 0 0 10px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .histo-row { display: flex; align-items: flex-end; gap: 2px; height: 120px; margin-bottom: 4px; }
  .histo-bar {
    flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-width: 12px;
    position: relative; cursor: default; transition: background 0.15s;
  }
  .histo-bar:hover { background: var(--accent2); }
  .histo-bar .histo-tip {
    display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background: var(--bg3); color: var(--text); font-size: 10px; padding: 2px 6px;
    border-radius: 4px; white-space: nowrap; pointer-events: none; z-index: 5;
  }
  .histo-bar:hover .histo-tip { display: block; }
  .histo-labels { display: flex; gap: 2px; font-size: 9px; color: var(--text2); }
  .histo-labels span { flex: 1; text-align: center; min-width: 12px; }
  .top-list { list-style: none; padding: 0; margin: 0; }
  .top-list li {
    display: flex; align-items: center; gap: 8px; padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 12px;
  }
  .top-list .top-rank { width: 22px; color: var(--text2); text-align: right; font-weight: 700; font-size: 11px; }
  .top-list .top-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); cursor: pointer; }
  .top-list .top-title:hover { color: var(--accent); }
  .top-list .top-val { color: var(--accent2); font-weight: 600; font-size: 11px; min-width: 50px; text-align: right; }
  .tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
  .tag-pill {
    padding: 3px 10px; border-radius: 12px; font-size: 11px;
    background: rgba(124,92,252,0.12); color: var(--accent); border: 1px solid rgba(124,92,252,0.2);
    cursor: default; transition: all 0.15s;
  }
  .tag-pill:hover { background: rgba(124,92,252,0.25); }
  .donut-container { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
  .donut-legend { font-size: 11px; }
  .donut-legend div { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
  .donut-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

  /* --- Trash / Papierkorb --- */
  .trash-badge {
    display: inline-block; font-size: 9px; background: var(--red); color: #fff;
    border-radius: 8px; padding: 0 5px; min-width: 16px; text-align: center;
    line-height: 16px; margin-left: 4px; vertical-align: middle;
  }
  .trash-badge:empty { display: none; }
  .btn-trash-active { border-color: var(--red) !important; color: var(--red) !important; background: rgba(239,68,68,0.1) !important; }
  .btn-batch-active { border-color: var(--accent) !important; color: var(--accent2) !important; background: rgba(124,92,252,0.12) !important; }
  .action-cell { width: 82px; min-width: 82px; max-width: 98px; padding: 4px 4px !important; text-align: center; }
  .action-btn {
    cursor: pointer; font-size: 13px; opacity: 0.3; transition: opacity 0.15s;
    user-select: none; padding: 2px;
  }
  tr:hover .action-btn, .action-btn.always { opacity: 1; }
  .action-btn:hover { transform: scale(1.2); }
  .action-cell .action-btn + .action-btn { margin-left: 4px; }
  .action-btn.batch-marker, .sc-action.batch-marker {
    border: 1px solid var(--border); border-radius: 999px; background: var(--bg3);
    color: var(--accent2); font-weight: 700;
  }
  .action-btn.batch-marker.selected, .sc-action.batch-marker.selected {
    border-color: var(--accent); background: rgba(124,92,252,0.18); color: #fff;
  }
  .batch-bar {
    padding: 6px 16px; background: rgba(124,92,252,0.08); border-bottom: 1px solid rgba(124,92,252,0.25);
    display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--accent2);
    flex-shrink: 0;
  }
  .batch-bar .btn { font-size: 11px; border-color: var(--accent); color: var(--accent2); }
  .batch-bar .btn:hover:not(:disabled) { background: rgba(124,92,252,0.15); }
  .batch-count { font-weight: 600; color: var(--text); }
  body.batch-delete-mode #tbody tr { cursor: pointer; }
  tr.batch-selected { background: rgba(124,92,252,0.16) !important; }
  /* --- Tablet --- */
  @media (max-width: 900px) {
    .header { flex-wrap: wrap; gap: 8px; }
    .search-box { order: 2; flex: 1 1 100%; max-width: none; }
    .header .stats { order: 3; width: 100%; }
    .player-row1 { padding: 8px 14px 4px; }
    .player-controls { padding: 0 14px 8px; }
    .player-cover { width: 44px; height: 44px; }
    .player-transport .tbtn { width: 30px; height: 30px; font-size: 14px; }
    .player-transport .tbtn.play-btn { width: 36px; height: 36px; font-size: 16px; }
    .player-info { max-width: 220px; }
    td { max-width: 180px; }
  }
  @media (hover: none) {
    .action-btn { opacity: 1; }
  }

  /* ================================================================
     MOBILE CARD VIEW (≤600px / iPhone SE 2022 = 375×667)
     Replaces table with a scrollable card list.
     ================================================================ */
  #mobileCards { display: none; }

  @media (max-width: 600px) {
    body { overflow: hidden; height: 100vh; height: 100dvh; }

    /* --- Mobile Header: compact single row --- */
    .header {
      padding: 8px 10px; gap: 8px; flex-wrap: nowrap;
      align-items: center; min-height: 0;
    }
    .header h1 { font-size: 16px; flex-shrink: 0; }
    .header .stats { display: none; }
    .search-box { flex: 1; max-width: none; order: 0; }
    .search-box input {
      padding: 10px 12px 10px 34px; font-size: 15px;
      border-radius: 10px; background: var(--bg3);
    }
    .header .btn#btnSidebar { display: none; }
    .header-buttons { display: none; }

    /* Mobile nav bar at top under header */
    .mobile-nav {
      display: flex !important;
      background: var(--bg2); border-bottom: 1px solid var(--border);
      padding: 6px 8px; gap: 4px; flex-shrink: 0;
      overflow-x: auto; -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .mobile-nav::-webkit-scrollbar { display: none; }
    .mobile-nav .m-btn {
      flex: 1; min-width: 0; padding: 8px 4px; font-size: 11px;
      background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
      color: var(--text2); cursor: pointer; text-align: center;
      white-space: nowrap; transition: all 0.15s;
      display: flex; flex-direction: column; align-items: center; gap: 2px;
    }
    .mobile-nav .m-btn .m-icon { font-size: 16px; }
    .mobile-nav .m-btn.active { border-color: var(--accent); color: var(--accent2); background: rgba(124,92,252,0.12); }
    .mobile-nav .m-btn .m-badge {
      font-size: 8px; background: var(--red); color: #fff;
      border-radius: 6px; padding: 0 4px; min-width: 14px;
      line-height: 14px; position: absolute; top: -2px; right: -2px;
    }

    /* Mobile sort/filter bar */
    .mobile-filter-bar {
      display: flex !important;
      background: var(--bg); border-bottom: 1px solid var(--border);
      padding: 6px 10px; gap: 6px; align-items: center; flex-shrink: 0;
    }
    .mobile-filter-bar select {
      flex: 1; padding: 8px 8px; background: var(--bg3); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text); font-size: 13px; outline: none;
      -webkit-appearance: none; appearance: none;
    }
    .mobile-filter-bar .mf-sort-dir {
      width: 36px; height: 36px; background: var(--bg3); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text2); font-size: 14px; cursor: pointer;
      display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    }
    .mobile-filter-bar .mf-count { font-size: 11px; color: var(--text2); flex-shrink: 0; white-space: nowrap; }

    /* Hide desktop table, sidebar, sidebar toggle */
    .main { display: none !important; }
    .trash-header-bar { font-size: 11px; padding: 6px 10px; flex-wrap: wrap; gap: 4px; }
    .batch-bar { font-size: 11px; padding: 6px 10px; flex-wrap: wrap; gap: 4px; }

    /* --- Card list container --- */
    #mobileCards {
      display: flex !important;
      flex-direction: column;
      flex: 1; overflow-y: auto; overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
      padding: 6px 10px; gap: 6px;
    }

    /* --- Song Card --- */
    .song-card {
      display: flex; align-items: center; gap: 10px;
      background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
      padding: 10px; cursor: pointer; transition: background 0.15s, border-color 0.15s;
      position: relative; overflow: hidden;
      min-height: 68px;
      -webkit-tap-highlight-color: transparent;
    }
    .song-card:active { background: var(--bg3); }
    .song-card.playing { border-color: var(--accent); background: rgba(124,92,252,0.08); }
    .song-card.batch-selected { border-color: var(--accent); background: rgba(124,92,252,0.16); }
    .song-card .sc-cover {
      width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
      background: var(--bg3); flex-shrink: 0;
    }
    .song-card .sc-body { flex: 1; min-width: 0; }
    .song-card .sc-title {
      font-size: 14px; font-weight: 600; white-space: nowrap;
      overflow: hidden; text-overflow: ellipsis;
    }
    .song-card .sc-tags {
      font-size: 11px; color: var(--text2); white-space: nowrap;
      overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
    }
    .song-card .sc-meta {
      display: flex; gap: 8px; margin-top: 4px; font-size: 10px; color: var(--text2);
    }
    .song-card .sc-meta span { display: flex; align-items: center; gap: 2px; }
    .song-card .sc-stars { font-size: 12px; letter-spacing: 0; }
    .song-card .sc-stars .star.on { color: #facc15; }
    .song-card .sc-stars .star { color: #3a3a4c; }
    .sc-heart { color: #3a3a4c; font-size: 14px; }
    .sc-heart.liked { color: #ec4899; }
    .song-card .sc-actions {
      display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
      align-items: center;
    }
    .song-card .sc-action {
      width: 34px; height: 34px; border-radius: 50%;
      background: var(--bg3); border: 1px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      font-size: 14px; cursor: pointer; transition: all 0.15s;
      -webkit-tap-highlight-color: transparent;
    }
    .song-card .sc-action:active { background: var(--accent); border-color: var(--accent); }
    .song-card.playing .sc-play { background: var(--accent); border-color: var(--accent); color: #fff; }

    /* --- Mobile Player: 2-row compact --- */
    .player {
      padding: 0; gap: 0; flex-direction: column; min-height: auto;
      padding-bottom: env(safe-area-inset-bottom);
      background: var(--bg2);
    }
    .player-row1 {
      display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    }
    .player-cover { width: 40px; height: 40px; border-radius: 6px; box-shadow: none; }
    .player-info { flex: 1; min-width: 0; max-width: none; }
    .player-title { font-size: 13px; font-weight: 600; color: var(--text); }
    .player-meta { font-size: 10px; }
    .player-rating { display: none; }
    .player-afterlike { display: none; }
    .player-transport { gap: 2px; flex-shrink: 0; }
    .player-transport .tbtn { width: 34px; height: 34px; font-size: 14px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
    .player-transport .tbtn.play-btn { width: 40px; height: 40px; font-size: 16px; background: var(--accent); border-color: var(--accent); color: #fff; }
    .player-transport .tbtn#btnPlayerTrash { display: none; }
    .player-transport .tbtn#btnShuffleToggle { display: none; }
    .player-controls { width: 100%; padding: 0 10px 6px; }
    .player-seek { height: 4px; }
    .player-seek::-webkit-slider-thumb { width: 12px; height: 12px; }
    .player-seek::-moz-range-thumb { width: 12px; height: 12px; }
    .player-time { font-size: 10px; min-width: 30px; }

    /* Empty state */
    .mobile-empty {
      flex: 1; display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      color: var(--text2); font-size: 14px; gap: 8px; padding: 40px 20px;
      text-align: center;
    }
    .mobile-empty .me-icon { font-size: 40px; opacity: 0.4; }

    /* Overlays: full-screen on mobile */
    .analytics-panel { width: 100vw; height: 100vh; height: 100dvh; max-width: 100vw; max-height: 100vh; border-radius: 0; }
    .analytics-header { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
    .analytics-header h2 { font-size: 14px; width: 100%; }
    .analytics-header label { font-size: 10px; }
    .analytics-header select { font-size: 11px; flex: 1; min-width: 0; }
    .analytics-body { padding: 12px; gap: 12px; }
    .chart-box { min-width: 100% !important; max-width: 100% !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
    .stat-card { padding: 10px 12px; }
    .stat-card .stat-value { font-size: 18px; }

    .shuffle-panel { width: 100vw; max-width: 100vw; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
    .shuffle-header { padding: 12px 14px; }
    .shuffle-body { padding: 14px; }
    .shuffle-row { gap: 8px; }
    .shuffle-row label { min-width: 80px; font-size: 12px; }

    .confirm-box { padding: 20px 16px; }
    .sidebar-backdrop { display: none !important; }

    /* --- Now Playing expanded overlay --- */
    .np-overlay {
      display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: var(--bg); z-index: 80;
      flex-direction: column; overflow: hidden;
    }
    .np-overlay.open { display: flex; }
    .np-header {
      display: flex; align-items: center; padding: 12px 16px; flex-shrink: 0;
    }
    .np-close {
      width: 36px; height: 36px; border: none; background: var(--bg3);
      color: var(--text); font-size: 18px; border-radius: 50%; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
    }
    .np-header-title {
      flex: 1; text-align: center; font-size: 12px; color: var(--text2);
      text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
    }
    .np-header-action {
      width: 36px; height: 36px; border: none; background: var(--bg3);
      color: var(--text2); font-size: 16px; border-radius: 50%; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
    }
    .np-body {
      flex: 1; overflow-y: auto; padding: 0 24px;
      display: flex; flex-direction: column; align-items: center;
    }
    .np-cover {
      width: min(75vw, 300px); height: min(75vw, 300px);
      border-radius: 14px; object-fit: cover; background: var(--bg3);
      box-shadow: 0 8px 30px rgba(0,0,0,0.5); margin-bottom: 20px;
    }
    .np-title { font-size: 20px; font-weight: 700; text-align: center; padding: 0 8px; }
    .np-tags { font-size: 13px; color: var(--text2); text-align: center; margin-top: 4px; }
    .np-stars {
      margin-top: 16px; font-size: 32px; letter-spacing: 6px;
      cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
    }
    .np-stars .star { color: #3a3a4c; transition: color 0.12s; }
    .np-stars .star.on { color: #facc15; }
    .np-stars:active .star { transform: scale(1.1); }
    .np-meta-grid {
      display: grid; grid-template-columns: 1fr 1fr;
      gap: 8px; width: 100%; margin-top: 20px; padding-bottom: 16px;
    }
    .np-meta-item {
      background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
      padding: 10px 12px;
    }
    .np-meta-item .np-ml { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.3px; }
    .np-meta-item .np-mv { font-size: 14px; font-weight: 600; margin-top: 2px; }
    .np-download-tile { cursor: pointer; text-align: center; }
    .np-download-tile:active { background: var(--accent); color: #fff; }
    .np-actions {
      display: flex; gap: 12px; margin-top: 16px; padding-bottom: 10px;
    }
    .np-actions .np-abtn {
      flex: 1; padding: 12px 8px; background: var(--bg2); border: 1px solid var(--border);
      border-radius: 10px; color: var(--text); font-size: 13px; cursor: pointer;
      display: flex; flex-direction: column; align-items: center; gap: 4px;
      -webkit-tap-highlight-color: transparent;
    }
    .np-actions .np-abtn:active { background: var(--bg3); border-color: var(--accent); }
    .np-actions .np-abtn .np-ai { font-size: 18px; }
    .np-actions .np-abtn.danger { border-color: rgba(239,68,68,0.3); color: var(--red); }
    .np-actions .np-abtn.liked { border-color: rgba(236,72,153,0.4); color: #ec4899; }
    .np-actions .np-abtn.liked .np-ai { transform: scale(1.15); }
    .np-stem-row {
      display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px;
      background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
      flex-wrap: wrap; justify-content: center;
    }
    .np-stem-toggle { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
    .np-stem-toggle button {
      padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--bg3); color: var(--text2); font-size: 12px; cursor: pointer;
      -webkit-tap-highlight-color: transparent; transition: all 0.15s;
    }
    .np-stem-toggle button.active {
      background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600;
    }
    .np-stem-trigger {
      padding: 6px 14px; border-radius: 8px; border: 1px solid rgba(124,92,252,0.3);
      background: transparent; color: var(--accent); font-size: 12px; cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }
    .np-stem-trigger:active { background: rgba(124,92,252,0.15); }
    .np-stem-trigger.loading { opacity: 0.5; pointer-events: none; }
    .np-stem-dl {
      padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--bg3); color: var(--text2); font-size: 14px; cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }
    .np-stem-dl:active { background: var(--accent); color: #fff; }
    .np-stem-trigger-inline {
      padding: 6px 10px; border-radius: 8px; border: 1px dashed rgba(124,92,252,0.4);
      background: transparent; color: var(--accent); font-size: 11px; cursor: pointer;
      -webkit-tap-highlight-color: transparent; white-space: nowrap;
    }
    .np-stem-trigger-inline:active { background: rgba(124,92,252,0.15); }
    .np-stem-trigger-inline.loading { opacity: 0.5; pointer-events: none; }
    .np-stem-extra { display: none; width: 100%; margin-top: 6px; }
    .np-stem-extra.open { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
    .np-stem-extra button {
      padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
      background: var(--bg3); color: var(--text2); font-size: 11px; cursor: pointer;
      -webkit-tap-highlight-color: transparent; transition: all 0.15s;
    }
    .np-stem-extra button.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
    .np-stem-extra button.np-stem-dl { padding: 4px 7px; font-size: 12px; }
    .np-stem-expand {
      padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
      background: var(--bg3); color: var(--text2); font-size: 11px; cursor: pointer;
    }
    .np-stem-expand:active { background: var(--accent); color: #fff; }
    .np-seek-row {
      display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 0 4px;
    }
    .np-time { font-size: 11px; color: var(--text2); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; flex-shrink: 0; }
    .np-seek { flex: 1; height: 6px; -webkit-appearance: none; appearance: none; background: var(--bg3); border-radius: 3px; outline: none; cursor: pointer; }
    .np-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
    .np-seek::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
    .np-transport {
      display: flex; align-items: center; justify-content: center;
      gap: 16px; padding: 10px 0;
    }
    .np-transport .tbtn { width: 44px; height: 44px; font-size: 18px; }
    .np-transport .tbtn.play-btn { width: 56px; height: 56px; font-size: 22px; }
    .np-audio { width: 100%; padding: 0 0 8px; }
    .np-audio audio { width: 100%; height: 32px; }

    /* Make mini-player tappable for expand */
    .player { cursor: pointer; -webkit-tap-highlight-color: transparent; }
  }
  .trash-header-bar {
    padding: 6px 16px; background: rgba(239,68,68,0.08); border-bottom: 1px solid rgba(239,68,68,0.2);
    display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--red);
    flex-shrink: 0;
  }
  .trash-header-bar .btn { font-size: 11px; border-color: var(--red); color: var(--red); }
  .trash-header-bar .btn:hover { background: rgba(239,68,68,0.15); }

  /* Confirm dialog */
  .confirm-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75); z-index: 200; justify-content: center; align-items: center;
  }
  .confirm-overlay.open { display: flex; }
  .confirm-box {
    background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
    padding: 28px 32px; max-width: 440px; width: 90%; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }
  .confirm-box h3 { font-size: 15px; color: var(--text); margin-bottom: 8px; }
  .confirm-box p { font-size: 12px; color: var(--red); margin-bottom: 20px; }
  .confirm-btns { display: flex; gap: 10px; justify-content: center; }
  .confirm-btns button {
    padding: 8px 20px; border-radius: 6px; border: 1px solid var(--border);
    font-size: 12px; cursor: pointer; transition: all 0.15s;
  }
  .confirm-btns .btn-cancel { background: var(--bg3); color: var(--text); }
  .confirm-btns .btn-cancel:hover { border-color: var(--accent); }
  .confirm-btns .btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
  .confirm-btns .btn-danger:hover { background: #dc2626; }

  /* --- Interactive scatter --- */
  .scatter-wrap { position: relative; min-height: 280px; }
  .scatter-wrap svg { width: 100%; height: auto; display: block; }
  .scatter-wrap svg circle.dot { cursor: pointer; transition: r 0.1s, opacity 0.1s; }
  .scatter-wrap svg circle.dot:hover { r: 5; opacity: 1 !important; }
  .scatter-wrap svg circle.dot.selected { fill: #22c55e; opacity: 1 !important; r: 4; }
  .scatter-wrap svg rect.sel-rect { fill: rgba(124,92,252,0.15); stroke: var(--accent); stroke-width: 0.8; stroke-dasharray: 4,2; pointer-events: none; }
  .selection-bar {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px; margin-top: 8px;
    background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.25); border-radius: 6px;
    font-size: 12px; color: var(--green);
  }
  .selection-bar .btn { font-size: 11px; border-color: var(--green); color: var(--green); }
  .selection-bar .btn:hover { background: rgba(34,197,94,0.12); }
  .bar-row.clickable { cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: 2px -4px; transition: background 0.15s; }
  .bar-row.clickable:hover { background: rgba(124,92,252,0.1); }
  tr.analytics-selected { background: rgba(34,197,94,0.12) !important; }
  .crosstab-cell-click { cursor: pointer; transition: outline 0.1s; }
  .crosstab-cell-click:hover { outline: 2px solid var(--accent); outline-offset: -2px; }

  /* --- Star Rating --- */
  .stars { white-space: nowrap; cursor: pointer; user-select: none; font-size: 15px; letter-spacing: 1px; }
  .stars .star { color: #3a3a4c; transition: color 0.1s; }
  .stars .star.on { color: #facc15; }
  .stars:hover .star { color: #3a3a4c; }
  .stars:hover .star.hovered { color: #facc15; }
  .stars .star-clear { font-size: 10px; color: var(--text2); margin-left: 4px; opacity: 0; transition: opacity 0.15s; vertical-align: middle; }
  .stars:hover .star-clear { opacity: 1; }
  .rating-filter select { min-width: 90px; }

  /* --- After-Like heart --- */
  .afterlike-toggle {
    cursor: pointer; font-size: 18px; color: #3a3a4c; transition: color 0.15s, transform 0.15s;
    user-select: none; -webkit-tap-highlight-color: transparent;
  }
  .afterlike-toggle:hover { color: #f472b6; transform: scale(1.15); }
  .afterlike-toggle.liked { color: #ec4899; }
  .afterlike-toggle.liked:hover { color: #f472b6; }

  .player-afterlike {
    flex-shrink: 0; font-size: 18px; cursor: pointer; user-select: none;
    color: #2a2a3c; transition: color 0.15s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    margin-right: 4px;
  }
  .player-afterlike:hover { color: #f472b6; transform: scale(1.1); }
  .player-afterlike.liked { color: #ec4899; }
  .player-afterlike.liked:hover { color: #f472b6; }

  /* --- Smart Shuffle overlay --- */
  .shuffle-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75);
    z-index: 100;
    justify-content: center;
    align-items: center;
  }
  .shuffle-overlay.open { display: flex; }
  .shuffle-panel {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 520px; max-width: 95vw;
    max-height: 85vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }
  .shuffle-header {
    padding: 14px 20px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    flex-shrink: 0;
  }
  .shuffle-header h2 { font-size: 16px; color: var(--accent2); flex: 1; }
  .shuffle-close {
    width: 30px; height: 30px; border: none; background: none; color: var(--text2);
    font-size: 20px; cursor: pointer; border-radius: 6px; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
  }
  .shuffle-close:hover { background: var(--bg); color: var(--text); }
  .shuffle-body {
    padding: 20px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 18px;
  }
  .shuffle-section h3 {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--accent2); margin: 0 0 10px; font-weight: 600;
  }
  .shuffle-row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  }
  .shuffle-row label {
    font-size: 12px; color: var(--text); min-width: 100px; flex-shrink: 0;
  }
  .shuffle-row input[type="range"] {
    flex: 1; accent-color: var(--accent); height: 6px; cursor: pointer;
  }
  .shuffle-row .range-val {
    font-size: 11px; color: var(--accent2); min-width: 24px; text-align: right; font-weight: 600;
  }
  .shuffle-row select, .shuffle-row input[type="text"], .shuffle-row input[type="number"] {
    flex: 1; padding: 5px 8px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 5px; color: var(--text); font-size: 12px; outline: none;
  }
  .shuffle-row select:focus, .shuffle-row input:focus { border-color: var(--accent); }
  .shuffle-row select.sf-multi { min-height: 52px; }
  .shuffle-row select.sf-multi option:checked { background: var(--accent); color: #fff; }
  .shuffle-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
  }
  .shuffle-footer .shuffle-count { font-size: 12px; color: var(--text2); flex: 1; }
  .shuffle-start {
    padding: 8px 22px; border: none; border-radius: 6px;
    background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
  }
  .shuffle-start:hover { background: var(--accent2); }
  .shuffle-stop {
    padding: 8px 22px; border: 1px solid var(--red); border-radius: 6px;
    background: none; color: var(--red); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
  }
  .shuffle-stop:hover { background: rgba(239,68,68,0.12); }
  #btnShuffle.active { background: var(--accent); color: #fff; border-color: var(--accent); }
