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

:root {
  --bg:        #0a0a14;
  --surface:   #111120;
  --card:      #181828;
  --hover:     #1e1e32;
  --border:    rgba(255,255,255,0.07);

  --g1: #a855f7;
  --g2: #ec4899;
  --grad:     linear-gradient(135deg, var(--g1), var(--g2));
  --grad-h:   linear-gradient(90deg,  var(--g1), var(--g2));
  --glow:     rgba(168,85,247,0.3);
  --glow2:    rgba(236,72,153,0.2);

  --t1: #ffffff;
  --t2: #9090b4;
  --t3: #3e3e5a;

  --red:   #f43f5e;
  --green: #22c55e;

  --hdr:    56px;
  --mini:   68px;
  --nav:    62px;
  --safe-t: env(safe-area-inset-top,    0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%; background: var(--bg); color: var(--t1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; overflow: hidden;
}
button { background: none; border: none; color: inherit; cursor: pointer; font-family: inherit; }
input  { font-family: inherit; }
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════ */
#login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px; overflow: hidden;
}

.login-blob {
  position: absolute; border-radius: 50%;
  filter: blur(90px); pointer-events: none;
}
.login-blob-1 {
  width: 60vw; height: 60vw;
  background: radial-gradient(circle, rgba(168,85,247,0.4), transparent 70%);
  top: -20%; left: -15%;
  animation: blob-drift 9s ease-in-out infinite alternate;
}
.login-blob-2 {
  width: 50vw; height: 50vw;
  background: radial-gradient(circle, rgba(236,72,153,0.35), transparent 70%);
  bottom: -15%; right: -10%;
  animation: blob-drift 7s ease-in-out infinite alternate-reverse;
}
@keyframes blob-drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(6%,10%) scale(1.15); }
}

.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 360px;
  background: rgba(17,17,32,0.75);
  backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(168,85,247,0.18);
  border-radius: 28px;
  padding: 44px 32px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 0 80px rgba(168,85,247,0.1), 0 40px 80px rgba(0,0,0,0.6);
}

.login-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: linear-gradient(135deg, rgba(168,85,247,0.15), rgba(236,72,153,0.15));
  border: 1px solid rgba(168,85,247,0.25);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  animation: float 3.5s ease-in-out infinite;
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-7px)} }

.login-card h1, .login-title {
  font-size: 22px; font-weight: 800; letter-spacing: -0.4px;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
  white-space: nowrap;
}
.login-sub { color: var(--t2); font-size: 14px; margin-bottom: 20px; }

#login-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }

#username-input, #password-input {
  width: 100%; background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border); border-radius: 16px;
  color: var(--t1); font-size: 16px; padding: 16px 18px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#username-input:focus, #password-input:focus {
  border-color: var(--g1);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.15);
}

#login-btn {
  width: 100%; background: var(--grad); color: #fff;
  font-size: 16px; font-weight: 700; padding: 16px 20px;
  border-radius: 16px; letter-spacing: 0.3px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 6px 28px var(--glow);
  transition: opacity .15s, transform .1s, box-shadow .2s;
}
#login-btn:active { opacity: .82; transform: scale(.98); }

.login-error { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; }

/* ══════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════ */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── Header ──────────────────────────────────────────── */
#app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--hdr) + var(--safe-t));
  padding-top: var(--safe-t);
  background: rgba(10,10,20,0.88);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex; align-items: flex-end;
  padding-bottom: 8px;
  padding-left: 18px; padding-right: 18px;
}

.hview { display: flex; align-items: center; gap: 10px; width: 100%; }
.hview h2 {
  flex: 1; font-size: 22px; font-weight: 800; letter-spacing: -0.4px;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}

#search-input {
  flex: 1; background: rgba(255,255,255,0.07);
  border: 1.5px solid var(--border); border-radius: 12px;
  color: var(--t1); font-size: 15px; padding: 10px 14px; outline: none;
  transition: border-color .2s; -webkit-appearance: none;
}
#search-input:focus { border-color: var(--g1); }

.hbtn {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--t2); flex-shrink: 0;
  transition: color .15s, background .15s;
}
.hbtn:active { background: rgba(255,255,255,0.06); color: var(--t1); }
.hbtn.danger { color: var(--red); }

/* ── Main content ────────────────────────────────────── */
#main-content {
  position: fixed;
  top: calc(var(--hdr) + var(--safe-t));
  left: 0; right: 0;
  bottom: calc(var(--mini) + var(--nav) + var(--safe-b));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
#main-content::-webkit-scrollbar { width: 0; }

/* ══════════════════════════════════════════════════════
   TRACK LIST
══════════════════════════════════════════════════════ */
.track-item {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.035);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .12s; position: relative;
}
.track-item:active { background: rgba(255,255,255,0.04); }
.track-item.playing { background: rgba(168,85,247,0.07); }

.track-art {
  width: 52px; height: 52px; border-radius: 12px;
  flex-shrink: 0; overflow: hidden; position: relative;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  transition: box-shadow .25s;
}
.track-item.playing .track-art { box-shadow: 0 4px 22px var(--glow); }
.track-art img { width: 100%; height: 100%; object-fit: cover; }

/* Equalizer overlay */
.eq-ov {
  display: none; position: absolute; inset: 0; border-radius: 12px;
  background: rgba(10,10,20,0.5);
  align-items: flex-end; justify-content: center;
  gap: 3px; padding: 0 9px 8px;
}
.track-item.playing .eq-ov { display: flex; }
.eq-b { flex: 1; border-radius: 2px; background: var(--grad); }
.eq-b:nth-child(1) { animation: eq .55s ease-in-out infinite; }
.eq-b:nth-child(2) { animation: eq .55s ease-in-out infinite .13s; }
.eq-b:nth-child(3) { animation: eq .55s ease-in-out infinite .25s; }
.eq-b:nth-child(4) { animation: eq .55s ease-in-out infinite .07s; }
@keyframes eq { 0%,100%{height:18%} 50%{height:88%} }

.track-meta { flex: 1; min-width: 0; }
.track-title {
  font-size: 15px; font-weight: 600; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-item.playing .track-title {
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.track-sub {
  font-size: 12px; color: var(--t2); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-dur { font-size: 12px; color: var(--t3); flex-shrink: 0; }
.track-more {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--t3); flex-shrink: 0;
  transition: color .15s;
}
.track-more:active { color: var(--t1); }

/* ══════════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; padding: 80px 24px;
  color: var(--t3);
}
.empty-state p { font-size: 17px; font-weight: 600; color: var(--t2); }
.empty-state span { font-size: 14px; }

/* ══════════════════════════════════════════════════════
   PLAYLISTS
══════════════════════════════════════════════════════ */
.playlist-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.035);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}
.playlist-item:active { background: rgba(255,255,255,0.04); }

.pl-thumb {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, #1c0a36, #3d0a2c);
  border: 1px solid rgba(168,85,247,0.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--g1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
.pl-meta { flex: 1; min-width: 0; }
.pl-name {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-count { font-size: 12px; color: var(--t2); margin-top: 3px; }
.pl-chev { color: var(--t3); flex-shrink: 0; }

#playlist-detail-actions {
  display: flex; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.035);
}
.pill-btn {
  display: flex; align-items: center; gap: 7px;
  background: rgba(168,85,247,0.1); border: 1px solid rgba(168,85,247,0.25);
  border-radius: 24px; padding: 9px 20px;
  font-size: 14px; font-weight: 600; color: var(--t1);
  transition: background .15s;
}
.pill-btn:active { background: rgba(168,85,247,0.2); }

.pl-track-remove {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--red); flex-shrink: 0;
}
.pl-track-remove:active { background: rgba(244,63,94,0.12); }

/* ══════════════════════════════════════════════════════
   UPLOAD
══════════════════════════════════════════════════════ */
#upload-drop-zone {
  margin: 20px 16px;
  background: rgba(255,255,255,0.03);
  border: 2px dashed rgba(168,85,247,0.25);
  border-radius: 22px; padding: 52px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  cursor: pointer; transition: border-color .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
}
#upload-drop-zone:active, #upload-drop-zone.drag-over {
  border-color: var(--g1); background: rgba(168,85,247,0.06);
}
.upload-icon-wrap {
  width: 64px; height: 64px; border-radius: 18px;
  background: rgba(168,85,247,0.1); border: 1px solid rgba(168,85,247,0.2);
  display: flex; align-items: center; justify-content: center;
}
#upload-drop-zone p { font-size: 16px; font-weight: 600; }
#upload-drop-zone span { font-size: 13px; color: var(--t3); }
#file-input { display: none; }

.upload-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.035);
}
.upload-item-name {
  flex: 1; min-width: 0; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upload-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  padding: 4px 10px; border-radius: 20px; flex-shrink: 0; text-transform: uppercase;
}
.upload-badge.uploading { background: rgba(168,85,247,0.15); color: var(--g1); }
.upload-badge.done      { background: rgba(34,197,94,0.15);  color: var(--green); }
.upload-badge.error     { background: rgba(244,63,94,0.15);  color: var(--red); }

/* ══════════════════════════════════════════════════════
   MINI PLAYER
══════════════════════════════════════════════════════ */
#mini-player {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav) + var(--safe-b));
  height: var(--mini);
  background: rgba(17,17,32,0.96);
  backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px);
  border-top: 1px solid var(--border);
  z-index: 90;
  display: flex; flex-direction: column;
}

.mini-progress {
  height: 2px; background: rgba(255,255,255,0.06); flex-shrink: 0;
}
#mini-progress-fill {
  height: 100%; width: 0%;
  background: var(--grad); transition: width .5s linear;
}

.mini-body {
  flex: 1; display: flex; align-items: center;
  padding: 0 14px; gap: 10px;
}

.mini-left {
  display: flex; align-items: center; gap: 11px;
  flex: 1; min-width: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mini-art {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--card); flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.mini-art img { width: 100%; height: 100%; object-fit: cover; }

.mini-info { min-width: 0; }
.mini-title {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--t1);
}
.mini-artist { font-size: 12px; color: var(--t2); margin-top: 2px; }

.mini-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.mini-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--t1); transition: opacity .15s;
}
.mini-btn:active { opacity: .6; }

/* ══════════════════════════════════════════════════════
   BOTTOM NAV
══════════════════════════════════════════════════════ */
#bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(10,10,20,0.97);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  /* Canonical iOS safe area: padding below the buttons, not part of their height */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; flex-direction: column; z-index: 100;
}
.nav-row {
  display: flex;
  height: var(--nav);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  height: var(--nav);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: .3px;
  color: var(--t3); transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn.active { color: var(--g1); }
.nav-btn svg { transition: transform .12s; }
.nav-btn:active svg { transform: scale(.88); }

/* ══════════════════════════════════════════════════════
   NOW PLAYING  (full-screen overlay)
══════════════════════════════════════════════════════ */
#now-playing {
  position: fixed; inset: 0; z-index: 500;
  transform: translateY(100%);
  transition: transform .42s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  pointer-events: none;
}
#now-playing.open { transform: translateY(0); pointer-events: auto; }

/* Blurred artwork bg */
#np-bg {
  position: absolute; inset: -40px;
  background-size: cover; background-position: center;
  filter: blur(50px) saturate(1.8) brightness(0.32);
  transition: background-image .4s ease;
}
#np-bg.no-art {
  background: linear-gradient(160deg, #2a0a50, #1a0030, #0a0a14);
}

/* Dark gradient overlay */
.np-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(10,10,20,0.35) 0%,
    rgba(10,10,20,0.55) 50%,
    rgba(10,10,20,0.85) 100%
  );
}

/* Scrollable content area */
.np-content {
  position: relative; z-index: 1;
  height: 100%; display: flex; flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: calc(20px + var(--safe-b));
}

/* Top bar */
.np-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
}
.np-icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08);
  color: var(--t1); transition: background .15s;
}
.np-icon-btn:active { background: rgba(255,255,255,0.14); }

.np-topbar-center { text-align: center; }
.np-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  color: rgba(255,255,255,0.5); text-transform: uppercase;
}

/* Album art */
.np-art-wrap {
  display: flex; align-items: center; justify-content: center;
  flex: 1; padding: 16px 32px;
  position: relative;
}
.np-art-shadow {
  position: absolute;
  width: min(72vw, 300px); height: min(72vw, 300px);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 60px var(--glow);
}
.np-art {
  width: min(72vw, 300px); height: min(72vw, 300px);
  border-radius: 24px; overflow: hidden;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transition: transform .3s cubic-bezier(0.34,1.56,0.64,1);
}
.np-art.playing { transform: scale(1.04); }
.np-art img { width: 100%; height: 100%; object-fit: cover; }

/* Track info */
.np-info {
  padding: 0 28px 18px;
  display: flex; flex-direction: column; gap: 5px;
}
.np-title {
  font-size: 22px; font-weight: 800; letter-spacing: -0.4px;
  color: var(--t1); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-artist {
  font-size: 15px; color: rgba(255,255,255,0.6); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Seek bar */
.np-seek-wrap { padding: 0 28px 8px; }
#np-seek {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; outline: none; cursor: pointer;
  background: rgba(255,255,255,0.15);
}
#np-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px rgba(168,85,247,0.5), 0 2px 6px rgba(0,0,0,0.4);
}
#np-seek::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: none;
}
.np-times {
  display: flex; justify-content: space-between;
  padding-top: 8px;
  font-size: 12px; color: rgba(255,255,255,0.45);
  font-variant-numeric: tabular-nums;
}

/* Controls */
.np-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px 0;
}
.np-ctrl-sm {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.55);
  transition: color .15s, transform .1s;
}
.np-ctrl-sm:active { transform: scale(.88); }
.np-ctrl-sm.active { color: var(--g1); }

.np-ctrl-md {
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--t1); transition: opacity .15s, transform .1s;
}
.np-ctrl-md:active { opacity: .6; transform: scale(.88); }

.np-play-btn {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 6px 30px var(--glow), 0 2px 8px var(--glow2);
  transition: transform .12s, box-shadow .2s, opacity .15s;
}
.np-play-btn:active { transform: scale(.9); opacity: .85; }

/* ══════════════════════════════════════════════════════
   BOTTOM SHEET
══════════════════════════════════════════════════════ */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  backdrop-filter: blur(5px); z-index: 600; opacity: 0;
  transition: opacity .25s;
}
.sheet-backdrop.visible { opacity: 1; }

.bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-radius: 22px 22px 0 0;
  border: 1px solid var(--border); border-bottom: none;
  z-index: 601; padding-bottom: calc(24px + var(--safe-b));
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
}
.bottom-sheet.visible { transform: translateY(0); }

.sheet-handle {
  width: 40px; height: 4px; background: rgba(255,255,255,0.1);
  border-radius: 2px; margin: 12px auto 8px;
}
.sheet-track-info {
  padding: 12px 22px 14px; border-bottom: 1px solid var(--border);
}
.sheet-track-info .s-title { font-size: 15px; font-weight: 700; }
.sheet-track-info .s-artist { font-size: 13px; color: var(--t2); margin-top: 3px; }

.sheet-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 22px; font-size: 15px; font-weight: 500;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.sheet-item:active { background: rgba(255,255,255,0.04); }
.sheet-item svg { color: var(--t2); flex-shrink: 0; }
.sheet-item.danger { color: var(--red); }
.sheet-item.danger svg { color: var(--red); }

/* ══════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px); z-index: 700;
}
.modal {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid rgba(168,85,247,0.2);
  border-radius: 22px; padding: 28px 22px 18px; z-index: 701;
  box-shadow: 0 0 60px rgba(168,85,247,0.1), 0 40px 80px rgba(0,0,0,0.7);
}
.modal h3 {
  font-size: 18px; font-weight: 800; text-align: center; margin-bottom: 18px;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
#new-playlist-name {
  width: 100%; background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border); border-radius: 14px;
  color: var(--t1); font-size: 16px; padding: 14px 16px; outline: none;
  transition: border-color .2s;
}
#new-playlist-name:focus { border-color: var(--g1); }
.modal-btns { display: flex; gap: 10px; margin-top: 16px; }
.modal-btn {
  flex: 1; padding: 13px; border-radius: 14px;
  font-size: 15px; font-weight: 700;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--t1); transition: opacity .15s;
}
.modal-btn:active { opacity: .7; }
.modal-btn.primary {
  background: var(--grad); border-color: transparent;
  box-shadow: 0 4px 20px var(--glow);
}
#playlist-picker { display: flex; flex-direction: column; gap: 2px; }
.picker-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 8px; border-radius: 10px;
  font-size: 15px; cursor: pointer; transition: background .1s;
}
.picker-item:active { background: rgba(255,255,255,0.05); }

/* ── Loader ──────────────────────────────────────────── */
.loader {
  display: flex; justify-content: center; align-items: center;
  padding: 80px; color: var(--t3); gap: 12px; font-size: 14px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.06);
  border-top-color: var(--g1); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════
   OVERLAY PAGES (Track Edit, Queue)
══════════════════════════════════════════════════════ */
.overlay-page {
  position: fixed; inset: 0; z-index: 400;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: slideUp .3s cubic-bezier(0.32,0.72,0,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.overlay-header {
  height: calc(var(--hdr) + var(--safe-t));
  padding-top: var(--safe-t);
  padding-left: 10px; padding-right: 10px;
  background: rgba(10,10,20,0.95);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.overlay-header h2 {
  flex: 1; font-size: 18px; font-weight: 700;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.overlay-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + var(--safe-b));
}

/* ── Track Edit ─────────────────────────────────────── */
.edit-art-section {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 28px 16px 12px;
}
.edit-art-preview {
  width: min(56vw, 220px); height: min(56vw, 220px);
  border-radius: 20px; overflow: hidden;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.edit-art-preview img { width: 100%; height: 100%; object-fit: cover; }
.edit-art-actions { display: flex; gap: 10px; }

.preset-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; padding: 12px 16px;
}
.preset-item {
  aspect-ratio: 1; border-radius: 14px; overflow: hidden;
  cursor: pointer; border: 2px solid transparent;
  transition: border-color .15s, transform .1s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.preset-item:active { transform: scale(.93); }
.preset-item.selected { border-color: var(--g1); }
.preset-item img { width: 100%; height: 100%; object-fit: cover; }

.edit-fields { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.edit-label {
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: var(--t2); text-transform: uppercase;
  margin-top: 8px;
}
.edit-label:first-child { margin-top: 0; }
.edit-input {
  width: 100%; background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border); border-radius: 14px;
  color: var(--t1); font-size: 16px; padding: 14px 16px; outline: none;
  transition: border-color .2s;
}
.edit-input:focus { border-color: var(--g1); }

.edit-delete-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 32px 16px 16px; padding: 16px;
  background: rgba(244,63,94,0.08);
  border: 1.5px solid rgba(244,63,94,0.25); border-radius: 16px;
  color: var(--red); font-size: 15px; font-weight: 700;
  transition: background .15s;
}
.edit-delete-btn:active { background: rgba(244,63,94,0.15); }

/* ── Queue View ─────────────────────────────────────── */
.queue-now-section {
  padding: 16px; border-bottom: 1px solid var(--border);
}
.queue-now-section .track-item { background: rgba(168,85,247,0.08); border-radius: 14px; border: none; }
.queue-divider {
  padding: 14px 16px 8px; font-size: 12px; font-weight: 700;
  letter-spacing: .5px; color: var(--t2); text-transform: uppercase;
}
#queue-list .track-item { cursor: default; }

/* ── Sort Dropdown ──────────────────────────────────── */
.sort-dropdown {
  position: fixed; top: calc(var(--hdr) + var(--safe-t) + 4px);
  right: 16px; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 6px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  animation: fadeScale .15s ease;
}
@keyframes fadeScale {
  from { opacity: 0; transform: scale(.92) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.sort-option {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: var(--t1);
  cursor: pointer; transition: background .1s;
  white-space: nowrap;
}
.sort-option:active { background: rgba(255,255,255,0.05); }
.sort-option.active { color: var(--g1); }
.sort-option .check-mark { margin-left: auto; color: var(--g1); }

/* ── Volume Slider ──────────────────────────────────── */
.np-volume-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0 0;
  width: 160px; margin: 0 auto;
}
.np-vol-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; outline: none; cursor: pointer;
  background: rgba(255,255,255,0.15);
}
.np-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(0,0,0,0.4);
}
.np-vol-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: none;
}

/* ── Now Playing Extras ─────────────────────────────── */
.np-extras {
  display: flex; justify-content: center; gap: 20px;
  padding: 8px 28px 0;
}
.np-extra-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 20px;
  background: rgba(255,255,255,0.06);
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,0.55);
  transition: background .15s;
}
.np-extra-btn:active { background: rgba(255,255,255,0.1); }

/* ── Offline Bar ────────────────────────────────────── */
.offline-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 36px; z-index: 900;
  background: var(--red);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: #fff;
  animation: slideDown .3s ease;
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

/* ── Upload Gate ────────────────────────────────────── */
.upload-gate {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px; min-height: 60vh;
}
.upload-gate-card {
  text-align: center; max-width: 320px; width: 100%;
}
.upload-gate-card svg { margin-bottom: 16px; }
.upload-gate-card h3 {
  font-size: 20px; font-weight: 700; margin-bottom: 6px;
}
.upload-gate-card p {
  font-size: 14px; color: var(--t2); margin-bottom: 20px;
}
#upload-gate-form input {
  width: 100%; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--t1); font-size: 15px; margin-bottom: 12px;
  outline: none; transition: border-color .2s;
}
#upload-gate-form input:focus {
  border-color: var(--g1);
}
.upload-tracks-header {
  padding: 20px 16px 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .5px;
  color: var(--t2); text-transform: uppercase;
}
.upload-tracks-header h3 { font-size: 13px; font-weight: 700; color: var(--t2); margin: 0 0 10px; }
.upload-search-wrap {
  position: relative;
  display: flex; align-items: center;
  background: rgba(10,10,20,0.55);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 999px;
  padding: 0 10px;
  transition: border-color .15s ease, background .15s ease;
}
.upload-search-wrap:focus-within {
  border-color: rgba(168,85,247,0.55);
  background: rgba(20,15,40,0.7);
}
.upload-search-wrap > svg { color: var(--t3); flex-shrink: 0; }
.upload-search-wrap input {
  flex: 1; min-width: 0;
  appearance: none; -webkit-appearance: none;
  background: transparent; border: none; outline: none;
  color: var(--t1);
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 9px 8px;
  text-transform: none; letter-spacing: 0;
}
.upload-search-wrap input::placeholder { color: var(--t3); font-weight: 500; }
.upload-search-clear {
  appearance: none; background: rgba(255,255,255,0.08); border: none;
  color: var(--t1);
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .12s ease;
}
.upload-search-clear:hover { background: rgba(239,68,68,0.4); color: #fff; }
.upload-stat-card.clickable { cursor: pointer; transition: transform .15s, border-color .2s; }
.upload-stat-card.clickable:active { transform: scale(0.96); }
.upload-stat-card.clickable:hover { border-color: var(--g1); }

/* ── Upload Redesign ────────────────────────────────── */
.upload-stats {
  display: flex; gap: 12px; padding: 16px;
}
.upload-stat-card {
  flex: 1; background: var(--card);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; text-align: center;
}
.upload-stat-val {
  font-size: 24px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.upload-stat-label { font-size: 11px; color: var(--t2); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }

.upload-recent-header {
  padding: 12px 16px 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: var(--t2); text-transform: uppercase;
}

/* ── Now Playing Details ──────────────────────────── */
.np-details {
  font-size: 12px; color: var(--t2); margin-top: 4px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; text-align: center;
}
.track-details {
  font-size: 11px; color: var(--t2); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Users Section ────────────────────────────────── */
.users-section { padding: 16px; }
.users-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.users-header h3 {
  font-size: 16px; font-weight: 700; color: var(--t1);
}
.user-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
}
.user-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--grad); display: flex; align-items: center;
  justify-content: center; font-size: 18px; font-weight: 800;
  color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 15px; font-weight: 700; }
.user-role {
  font-size: 12px; color: var(--t2); margin-top: 2px;
  text-transform: capitalize;
}
.user-actions { display: flex; gap: 8px; }
.user-actions button {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05);
  transition: background .15s;
}
.user-actions button:active { background: rgba(255,255,255,0.12); }
.user-actions button.danger { color: var(--red); }

/* ── Public Badge ─────────────────────────────────── */
.public-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--g1);
  background: rgba(168,85,247,0.12); border-radius: 6px;
  padding: 3px 8px;
}
.pl-public-badge {
  font-size: 9px; font-weight: 700; color: var(--g1);
  background: rgba(168,85,247,0.12); border-radius: 4px;
  padding: 2px 6px; margin-left: 6px; text-transform: uppercase;
  letter-spacing: .3px;
}

/* ── Modal Toggle ─────────────────────────────────── */
.modal-toggle {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--t2); padding: 8px 0;
  cursor: pointer;
}
.modal-toggle input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--g1);
}

/* ── Modal User ───────────────────────────────────── */
#modal-user select {
  width: 100%; background: var(--surface); color: var(--t1);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; outline: none;
  margin-top: 8px; -webkit-appearance: none;
}
#modal-user-username, #modal-user-password {
  width: 100%; background: var(--surface); color: var(--t1);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; outline: none;
  margin-top: 8px;
}
#modal-user-username:focus, #modal-user-password:focus {
  border-color: var(--g1);
}

/* ── Track Visibility ─────────────────────────────── */
.edit-visibility {
  margin-top: 20px; padding: 16px;
  border-top: 1px solid var(--border);
}
.edit-vis-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.edit-vis-actions {
  display: flex; gap: 8px;
}
.edit-vis-actions button {
  font-size: 11px; font-weight: 700; color: var(--g1);
  padding: 4px 10px; border-radius: 8px;
  background: rgba(168,85,247,0.1);
  transition: background .15s;
}
.edit-vis-actions button:active {
  background: rgba(168,85,247,0.2);
}
.edit-vis-hint {
  font-size: 12px; color: var(--t2); margin: 4px 0 12px;
}
.edit-vis-list {
  display: flex; flex-direction: column; gap: 8px;
}
.vis-user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: border-color .2s;
}
.vis-user-row.checked {
  border-color: var(--g1);
  background: rgba(168,85,247,0.08);
}
.vis-user-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--g1);
  flex-shrink: 0;
}
.vis-user-name { font-size: 14px; font-weight: 600; }
.vis-user-role { font-size: 11px; color: var(--t2); margin-left: auto; text-transform: capitalize; }

/* ══════════════════════════════════════════════════════
   ANALYTICS DASHBOARD
══════════════════════════════════════════════════════ */
.analytics-period-select {
  background: var(--surface); color: var(--t1);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  outline: none; -webkit-appearance: none; margin-left: auto;
}

.analytics-dashboard {
  padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
  padding-bottom: 24px;
}

/* Stat cards */
.analytics-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.analytics-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.analytics-card-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(168,85,247,0.12), rgba(236,72,153,0.12));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.analytics-card-value {
  font-size: 24px; font-weight: 800; letter-spacing: -0.5px;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.analytics-card-label {
  font-size: 12px; color: var(--t2); font-weight: 600;
}

/* Section blocks */
.analytics-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 16px;
}
.analytics-section-title {
  font-size: 14px; font-weight: 700; color: var(--t1);
  margin-bottom: 14px;
}

/* Bar chart */
.analytics-chart {
  height: 160px; display: flex; align-items: flex-end;
  gap: 2px; position: relative;
}
.chart-bar-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; height: 100%; justify-content: flex-end;
}
.chart-bar {
  width: 100%; max-width: 28px; min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--grad); opacity: 0.85;
  transition: height 0.4s ease;
}
.chart-bar:hover { opacity: 1; }
.chart-bar-label {
  font-size: 9px; color: var(--t3); margin-top: 6px;
  text-align: center; white-space: nowrap;
}
.chart-bar-value {
  font-size: 9px; color: var(--t2); margin-bottom: 4px;
  font-weight: 600;
}

/* Analytics list */
.analytics-list {
  display: flex; flex-direction: column; gap: 2px;
}
.analytics-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  transition: background .15s;
}
.analytics-list-item:hover { background: rgba(255,255,255,0.03); }
.analytics-rank {
  font-size: 13px; font-weight: 800; color: var(--t3);
  width: 24px; text-align: center; flex-shrink: 0;
}
.analytics-rank.top-1 { color: #fbbf24; }
.analytics-rank.top-2 { color: #94a3b8; }
.analytics-rank.top-3 { color: #cd7f32; }
.analytics-item-info {
  flex: 1; min-width: 0;
}
.analytics-item-title {
  font-size: 13px; font-weight: 600; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.analytics-item-sub {
  font-size: 11px; color: var(--t2); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.analytics-item-stat {
  font-size: 13px; font-weight: 700; color: var(--g1);
  flex-shrink: 0;
}

/* User stats table */
.analytics-user-table {
  display: flex; flex-direction: column; gap: 10px;
}
.analytics-user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
}
.analytics-user-avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad); display: flex;
  align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.analytics-user-info { flex: 1; min-width: 0; }
.analytics-user-name {
  font-size: 14px; font-weight: 700; color: var(--t1);
}
.analytics-user-meta {
  font-size: 11px; color: var(--t2); margin-top: 2px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.analytics-user-stats {
  display: flex; gap: 14px; flex-shrink: 0;
}
.analytics-user-stat-item {
  text-align: center;
}
.analytics-user-stat-val {
  font-size: 15px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.analytics-user-stat-lbl {
  font-size: 9px; color: var(--t3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px;
}
.analytics-user-card { flex-direction: column; align-items: stretch; }
.analytics-user-card-main { display: flex; align-items: center; gap: 12px; }
.analytics-user-top {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.analytics-user-top-label {
  font-size: 9px; color: var(--t3); font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
}
.analytics-user-top-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px;
}
.analytics-user-top-title {
  color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.analytics-user-top-plays {
  color: var(--t2); font-weight: 700; flex-shrink: 0;
}

/* Library health mini-cards */
.analytics-mini-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
@media (max-width: 540px) { .analytics-mini-grid { grid-template-columns: 1fr; } }
.analytics-mini-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px;
}
.analytics-mini-label {
  font-size: 10px; color: var(--t3); font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
}
.analytics-mini-val {
  font-size: 22px; font-weight: 800; margin-top: 4px;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.analytics-mini-sub { font-size: 11px; color: var(--t2); margin-top: 2px; }

/* Now-playing live list */
.now-playing-list { display: flex; flex-direction: column; gap: 8px; }
.now-playing-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
}
.now-playing-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94, .5);
  animation: np-pulse 1.6s infinite;
}
@keyframes np-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(34,197,94, .5); }
  70%  { box-shadow: 0 0 0 10px rgba(34,197,94, 0); }
  100% { box-shadow: 0 0 0 0   rgba(34,197,94, 0); }
}

/* Device breakdown bar */
.device-bar {
  height: 4px; background: var(--border); border-radius: 2px;
  margin-top: 4px; overflow: hidden;
}
.device-bar-fill { height: 100%; background: var(--grad); }

/* Completion rate */
.analytics-completion {
  display: flex; align-items: center; gap: 16px;
}
.completion-ring {
  width: 80px; height: 80px; flex-shrink: 0;
}
.completion-ring circle {
  fill: none; stroke-width: 6;
}
.completion-ring .ring-bg { stroke: var(--border); }
.completion-ring .ring-fill {
  stroke: url(#completion-grad);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
  transform: rotate(-90deg);
  transform-origin: center;
}
.completion-info {
  display: flex; flex-direction: column; gap: 4px;
}
.completion-pct {
  font-size: 28px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.completion-label {
  font-size: 12px; color: var(--t2);
}

/* Recent activity timestamp */
.analytics-time {
  font-size: 10px; color: var(--t3); flex-shrink: 0;
  white-space: nowrap;
}

#analytics-refresh-btn.spinning svg { animation: arspin 0.6s linear; }
@keyframes arspin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ═══════════════ LIBRARY: FOLDER RAIL ═══════════════ */
.folder-hint {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 6px 14px 0;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(168,85,247,0.10), rgba(236,72,153,0.08));
  border: 1px solid rgba(168,85,247,0.25);
  border-radius: 12px;
  color: var(--t1);
  font-size: 12.5px; line-height: 1.45;
}
.folder-hint svg { flex-shrink: 0; color: #c4b5fd; margin-top: 1px; }
.folder-hint strong { color: #fff; font-weight: 700; }
.folder-hint button {
  appearance: none; background: transparent; border: none;
  color: var(--t2); cursor: pointer;
  margin-left: auto; flex-shrink: 0;
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s ease;
}
.folder-hint button:hover { background: rgba(255,255,255,0.08); color: #fff; }

.folder-rail {
  display: flex; gap: 8px; padding: 10px 16px 12px;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(10,10,20,0.4);
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(12px);
}
.folder-rail::-webkit-scrollbar { display: none; }

.folder-chip {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 4px 0 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  color: var(--t2);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  overflow: hidden;
}
.folder-chip-body {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: none;
  color: inherit; font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px 7px 14px;
}
.folder-chip:hover { background: rgba(255,255,255,0.07); color: var(--t1); }
.folder-chip-actions {
  display: inline-flex; gap: 2px;
  padding-right: 4px;
}
.folder-chip-action-btn {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,0.06);
  border: none;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--t2);
  cursor: pointer;
  transition: all .12s ease;
}
.folder-chip-action-btn:hover { background: rgba(255,255,255,0.16); color: #fff; }
.folder-chip-action-btn.danger:hover { background: rgba(239,68,68,0.25); color: #fca5a5; }
.folder-chip.active .folder-chip-action-btn { background: rgba(255,255,255,0.18); color: #fff; }
.folder-chip.active .folder-chip-action-btn:hover { background: rgba(255,255,255,0.3); }
.folder-chip.active .folder-chip-action-btn.danger:hover { background: rgba(239,68,68,0.4); color: #fff; }
.folder-chip.active {
  background: linear-gradient(135deg, rgba(168,85,247,0.25), rgba(236,72,153,0.22));
  border-color: rgba(168,85,247,0.5);
  color: #fff;
}
.folder-chip.drag-over {
  background: rgba(34,197,94,0.25);
  border-color: rgba(34,197,94,0.6);
  color: #fff;
  transform: scale(1.05);
}
.folder-chip .folder-count {
  font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,0.3);
  padding: 2px 7px; border-radius: 999px;
  color: var(--t2);
}
.folder-chip.active .folder-count { background: rgba(255,255,255,0.2); color: #fff; }
.folder-chip.folder-add {
  background: transparent;
  border-style: dashed;
  color: var(--g1);
}
.folder-chip.folder-add:hover { background: rgba(168,85,247,0.08); }

/* Inline folder pill on a track row */
.track-folder-pill {
  display: inline-block;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; margin-left: 6px;
  border-radius: 4px; vertical-align: middle;
  background: rgba(168,85,247,0.2);
  color: #cda9ff;
  letter-spacing: .3px; text-transform: uppercase;
}

/* ═══════════════ LIBRARY: MULTI-SELECT TOOLBAR ═══════════════ */
.lib-toolbar {
  position: fixed;
  top: calc(var(--hdr) + var(--safe-t));
  left: 0; right: 0;
  z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  gap: 12px;
  background: rgba(30,20,50,0.92);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(168,85,247,0.3);
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
.lib-tb-count {
  font-size: 13px; font-weight: 700; color: #fff;
}
.lib-tb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-tb-actions .pill-btn { font-size: 12px; padding: 6px 12px; }
.lib-tb-actions .pill-btn[disabled] { opacity: .4; pointer-events: none; }
.pill-btn.danger {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.35);
  color: #fca5a5;
}
.pill-btn.ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.1);
  color: var(--t2);
}
#lib-select-btn.active { color: var(--g1); }

/* Track row in select mode */
.track-item .track-select {
  display: flex; align-items: center;
  margin-right: 8px;
  cursor: pointer;
}
.track-item .track-select input {
  width: 20px; height: 20px;
  accent-color: var(--g1);
  cursor: pointer;
}
.track-item.selected {
  background: rgba(168,85,247,0.12);
}
.track-item.dragging { opacity: .5; }

/* ═══════════════ BULK EDIT OVERLAY ═══════════════ */
.bulk-hint {
  font-size: 13px; color: var(--t2);
  padding: 12px 16px;
  margin: 0;
}
.bulk-apply-demo {
  display: inline-block;
  width: 18px; height: 18px; line-height: 16px;
  text-align: center;
  border-radius: 4px;
  background: rgba(168,85,247,0.25);
  color: #d8b4fe;
  font-size: 11px;
  vertical-align: middle;
}
#bulk-edit-rows {
  padding: 0 12px 40px;
  display: flex; flex-direction: column;
  gap: 12px;
}
.bulk-row {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
}
.bulk-row-art {
  flex-shrink: 0;
  position: relative;
  width: 54px; height: 54px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a1e4a, #1a1030);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: pointer;
  border: none; padding: 0;
  transition: transform .12s ease, box-shadow .12s ease;
}
.bulk-row-art:hover { transform: scale(1.03); box-shadow: 0 4px 14px rgba(168,85,247,0.25); }
.bulk-row-art img { width: 100%; height: 100%; object-fit: cover; }
.bulk-art-hint {
  position: absolute;
  right: 3px; bottom: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(168,85,247,0.9);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* Per-row chips (Visibility + Playlists) */
.bulk-row-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 2px;
}
.bulk-row-chip {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  color: var(--t2);
  font: inherit; font-size: 11.5px; font-weight: 600;
  padding: 5px 10px;
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .12s ease;
}
.bulk-row-chip:hover { background: rgba(168,85,247,0.14); color: #fff; border-color: rgba(168,85,247,0.4); }
.bulk-chip-label { letter-spacing: .2px; }

/* Bulk-art modal bits */
.bulk-art-actions { display: flex; gap: 8px; padding: 4px 0 0; }

/* ═══════════════ PLAYLIST DETAIL EDIT ═══════════════ */
.pl-row-reorderable { cursor: grab; }
.pl-row-reorderable.dragging { opacity: 0.4; cursor: grabbing; }
.pl-drop-target {
  box-shadow: inset 0 3px 0 0 rgba(168,85,247,0.9);
}
.pl-already-in { opacity: 0.55; }

/* Playlist visibility mode picker */
.pl-vis-modes { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 10px; }
.pl-vis-mode {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  cursor: pointer;
  transition: all .12s ease;
}
.pl-vis-mode:hover { background: rgba(168,85,247,0.08); border-color: rgba(168,85,247,0.3); }
.pl-vis-mode input[type="radio"] { margin-top: 3px; flex-shrink: 0; }
.pl-vis-mode strong { color: #fff; font-size: 13px; }
.pl-vis-mode small { color: var(--t2); font-size: 11px; }
.bulk-row-fields {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.bulk-field {
  display: flex; align-items: center; gap: 6px;
}
.bulk-field label {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--t3);
  width: 56px; flex-shrink: 0;
}
.bulk-field .edit-input {
  flex: 1; min-width: 0;
  padding: 7px 10px;
  font-size: 13px;
  background: rgba(10,10,20,0.6);
}
.bulk-apply-all {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: rgba(168,85,247,0.15);
  border: 1px solid rgba(168,85,247,0.25);
  color: #d8b4fe;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s;
}
.bulk-apply-all:hover {
  background: rgba(168,85,247,0.3);
  color: #fff;
}

/* ═══════════════ DUPLICATE CONFIRM ═══════════════ */
.dup-confirm-wrap {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.dup-confirm {
  background: #1a1425;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 20px 24px;
  max-width: 420px; width: 100%;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}
.dup-confirm h3 { margin: 0 0 8px; font-size: 18px; color: #fff; }
.dup-confirm p { margin: 0 0 10px; font-size: 13px; color: var(--t2); }
.dup-list {
  margin: 0 0 18px; padding: 10px 18px;
  list-style: disc;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  font-size: 12px;
  color: var(--t2);
  max-height: 160px; overflow-y: auto;
}
.dup-list li { margin: 2px 0; }
.dup-list li.dup-more { list-style: none; color: var(--t3); font-style: italic; }
.dup-btns {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}

/* ═══════════════ FOLDER PICKER & PICKER-ADD ═══════════════ */
.picker-item.subtle { color: var(--t2); font-style: italic; }
.picker-item.picker-add { color: var(--g1); font-weight: 600; border-top: 1px solid rgba(255,255,255,0.07); margin-top: 6px; padding-top: 10px; }

/* ═══════════════ PER-USER LIBRARY MODAL ═══════════════ */
.modal.modal-wide {
  max-width: 560px; width: 92vw;
  max-height: 88vh;
  display: flex; flex-direction: column;
}
.user-library-toolbar {
  display: flex; flex-direction: column; gap: 8px;
  margin: 6px 0 4px;
}
.user-library-toolbar .edit-input { width: 100%; }
.user-library-filters, .user-library-bulk { display: flex; gap: 6px; flex-wrap: wrap; }
.user-library-filters .pill-btn { font-size: 12px; padding: 5px 11px; }
.user-library-filters .pill-btn.active {
  background: linear-gradient(135deg, rgba(168,85,247,0.3), rgba(236,72,153,0.22));
  border-color: rgba(168,85,247,0.6); color: #fff;
}
.user-library-summary {
  font-size: 12px; color: var(--t2); padding: 4px 2px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.user-library-summary span { color: #fff; font-weight: 700; }
.user-library-list {
  flex: 1; overflow-y: auto;
  margin-top: 6px;
  max-height: 50vh;
}
.user-library-btn {
  appearance: none; background: rgba(168,85,247,0.18);
  border: 1px solid rgba(168,85,247,0.4);
  color: #d8b4fe;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .12s ease;
}
.user-library-btn:hover { background: rgba(168,85,247,0.35); color: #fff; }

/* ═══════════════ FOLDERS TAB ═══════════════ */
#view-folders { padding: 12px; }
#folder-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.folder-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  transition: transform .12s, background .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.folder-card:hover { background: var(--hover); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.4); }
.folder-card.dragging { opacity: .5; }
.folder-card.drag-over { outline: 2px dashed var(--g1); outline-offset: -4px; }
.folder-card-cover {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: #0a0a14;
}
.folder-cover-tile {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #1e1e32, #2a2a44);
  overflow: hidden;
}
.folder-cover-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.folder-card-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.folder-card-name {
  font-weight: 600; font-size: 14px; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.folder-card-sub { font-size: 12px; color: var(--t2); }
.folder-card-actions {
  position: absolute; top: 14px; right: 14px;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity .15s;
}
.folder-card:hover .folder-card-actions { opacity: 1; }
/* Touch devices don't fire hover — always show the rename/delete buttons */
@media (hover: none) { .folder-card-actions { opacity: 1; } }
.folder-card-action {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(10,10,20,0.7);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.folder-card-action:hover { background: rgba(168,85,247,0.8); }
.folder-card-action.danger:hover { background: rgba(244,63,94,0.85); }
.folder-card-add { border-style: dashed; border-color: rgba(168,85,247,0.35); background: transparent; }
.folder-card-add:hover { background: rgba(168,85,247,0.06); }
.folder-card-cover-add {
  display: flex; align-items: center; justify-content: center;
  color: var(--g1); background: rgba(168,85,247,0.06);
}
#folders-reorder-btn.active { color: var(--g1); }
