/* ================= SiroBeat ================= */
:root {
  --bg: #0d0d12;
  --bg-2: #14141c;
  --bg-3: #1d1d28;
  --card: #181822;
  --card-hover: #232333;
  --text: #f2f2f7;
  --text-dim: #9a9aad;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --grad: linear-gradient(135deg, #8b5cf6, #22d3ee);
  --danger: #f87171;
  --radius: 14px;
  --sidebar-w: 248px;
  --player-h: 76px;
  --tabbar-h: 60px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }
img { user-select: none; -webkit-user-drag: none; }

#app { display: flex; height: 100dvh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  padding: 20px 14px calc(var(--player-h) + 16px);
  gap: 8px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo { width: 36px; height: 36px; }
.brand-name {
  font-size: 1.35rem; font-weight: 800; letter-spacing: -0.5px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-dim); font-weight: 600; font-size: 0.95rem;
  transition: 0.15s;
  text-align: left;
}
.nav-link:hover { color: var(--text); background: var(--bg-3); }
.nav-link.active { color: var(--text); background: var(--bg-3); }
.nav-ic { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-section { flex: 1; overflow-y: auto; margin-top: 14px; }
.sidebar-section-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 12px 8px; color: var(--text-dim);
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
}
.sidebar-playlists { display: flex; flex-direction: column; gap: 1px; }
.sidebar-pl {
  padding: 8px 12px; border-radius: 8px; color: var(--text-dim);
  font-size: 0.9rem; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-pl:hover { color: var(--text); background: var(--bg-3); }
.sidebar-foot { padding: 10px 12px 0; display: flex; flex-direction: column; gap: 4px; }
.net-status { font-size: 0.8rem; color: #4ade80; font-weight: 600; }
.net-status.offline { color: var(--danger); }
.foot-note { font-size: 0.72rem; color: var(--text-dim); }

/* ---------- Main ---------- */
.main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 28px 12px;
}
.topbar-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; }
.searchbox { flex: 1; max-width: 460px; }
.searchbox input {
  width: 100%; padding: 12px 18px; border-radius: 24px;
  border: 1px solid var(--bg-3); background: var(--bg-3); color: var(--text);
  outline: none; font-size: 0.95rem;
}
.searchbox input:focus { border-color: var(--accent); }
.install-btn {
  margin-left: auto; padding: 9px 18px; border-radius: 20px;
  background: var(--grad); color: #0d0d12; font-weight: 700; font-size: 0.85rem;
}
.view-container {
  flex: 1; overflow-y: auto;
  padding: 8px 28px calc(var(--player-h) + 32px);
  scroll-behavior: smooth;
}

/* ---------- Sections / cards ---------- */
.section { margin-bottom: 34px; }
.section-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 14px; letter-spacing: -0.3px; }
.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; cursor: pointer; transition: background 0.2s, transform 0.15s;
  position: relative;
}
.card:hover { background: var(--card-hover); }
.card:active { transform: scale(0.98); }
.card-art {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 10px; background: var(--bg-3); margin-bottom: 10px;
  display: block;
}
.card-title {
  font-weight: 700; font-size: 0.92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-sub {
  color: var(--text-dim); font-size: 0.8rem; margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-play {
  position: absolute; right: 22px; bottom: 74px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--grad); color: #0d0d12; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(8px); transition: 0.2s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}
.card:hover .card-play { opacity: 1; transform: translateY(0); }

/* ---------- Track list ---------- */
.tracklist { display: flex; flex-direction: column; }
.track-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
.track-row:hover { background: var(--bg-3); }
.track-row.playing .tr-title { color: var(--accent-2); }
.tr-art { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--bg-3); }
.tr-meta { min-width: 0; }
.tr-title { font-weight: 600; font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-artist { color: var(--text-dim); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-dur { color: var(--text-dim); font-size: 0.82rem; }
.tr-actions { display: flex; gap: 2px; }
.tr-actions .icon-btn { opacity: 0; transition: 0.15s; }
.track-row:hover .tr-actions .icon-btn, .tr-actions .icon-btn.on { opacity: 1; }
@media (hover: none) { .tr-actions .icon-btn { opacity: 1; } }

/* ---------- Buttons ---------- */
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 1rem; transition: 0.15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.icon-btn.on { color: var(--accent-2); }
.icon-btn.big { font-size: 1.5rem; width: 52px; height: 52px; }
.play-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--text); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: transform 0.1s;
}
.play-btn:hover { transform: scale(1.06); }
.play-btn.big { width: 64px; height: 64px; font-size: 1.5rem; background: var(--grad); color: #0d0d12; }
.chip-btn {
  padding: 9px 16px; border-radius: 20px; background: var(--bg-3);
  color: var(--text); font-size: 0.85rem; font-weight: 600;
}
.chip-btn:hover { background: var(--card-hover); }
.chip-btn.on { background: var(--accent); color: #fff; }
.primary-btn {
  padding: 11px 24px; border-radius: 22px; background: var(--grad);
  color: #0d0d12; font-weight: 800; font-size: 0.9rem;
}

/* ---------- Hero ---------- */
.hero {
  border-radius: 18px; padding: 28px;
  background: linear-gradient(120deg, rgba(139,92,246,0.35), rgba(34,211,238,0.18)), var(--card);
  margin-bottom: 28px;
}
.hero h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.5px; }
.hero p { color: var(--text-dim); margin: 8px 0 0; max-width: 560px; font-size: 0.92rem; }

/* Detail header (playlist / album) */
.detail-head { display: flex; gap: 22px; align-items: flex-end; margin-bottom: 24px; flex-wrap: wrap; }
.detail-art { width: 180px; height: 180px; border-radius: 14px; object-fit: cover; background: var(--bg-3); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.detail-info h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; }
.detail-info .sub { color: var(--text-dim); margin: 6px 0 14px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Player bar ---------- */
.playerbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--player-h);
  background: rgba(20, 20, 28, 0.92);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; padding: 0 18px; gap: 12px; z-index: 50;
}
.pb-progress {
  position: absolute; top: -3px; left: 0; right: 0; height: 3px;
  background: rgba(255,255,255,0.08); cursor: pointer;
}
.pb-progress:hover { height: 6px; top: -6px; }
.pb-progress-fill { height: 100%; width: 0%; background: var(--grad); pointer-events: none; }
.pb-left { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.pb-art { width: 50px; height: 50px; border-radius: 8px; object-fit: cover; background: var(--bg-3); }
.pb-meta { min-width: 0; }
.pb-title { font-weight: 700; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-artist { color: var(--text-dim); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-center { display: flex; align-items: center; gap: 6px; }
.pb-right { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.pb-time { color: var(--text-dim); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
input[type=range] { accent-color: var(--accent); }
#pbVolume { width: 96px; }

/* ---------- Now playing (fullscreen) ---------- */
.nowplaying {
  position: fixed; inset: 0; z-index: 90;
  background: linear-gradient(180deg, #24243a, var(--bg) 70%);
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 28px calc(env(safe-area-inset-bottom, 0px) + 32px);
  overflow-y: auto;
}
.np-close { align-self: flex-start; font-size: 1.4rem; }
.np-art {
  width: min(72vw, 340px); aspect-ratio: 1; object-fit: cover;
  border-radius: 18px; margin: 4vh 0 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.np-title { font-size: 1.35rem; font-weight: 800; text-align: center; }
.np-artist { color: var(--text-dim); margin: 6px 0 22px; }
.np-seek { display: flex; align-items: center; gap: 10px; width: min(90vw, 480px); }
.np-seek input { flex: 1; }
.np-seek span { color: var(--text-dim); font-size: 0.78rem; font-variant-numeric: tabular-nums; min-width: 38px; }
.np-controls { display: flex; align-items: center; gap: 18px; margin: 22px 0; }
.np-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Tabbar (mobile) ---------- */
.tabbar { display: none; }

/* ---------- Toast & modal ---------- */
.toast {
  position: fixed; bottom: calc(var(--player-h) + 20px); left: 50%; transform: translateX(-50%);
  background: var(--grad); color: #0d0d12; font-weight: 700; font-size: 0.88rem;
  padding: 12px 22px; border-radius: 24px; z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 150;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--bg-2); border-radius: 16px; padding: 24px;
  width: min(92vw, 400px); max-height: 80vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; font-size: 1.1rem; }
.modal input[type=text] {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--bg-3); background: var(--bg-3); color: var(--text);
  outline: none; margin-bottom: 14px;
}
.modal input[type=text]:focus { border-color: var(--accent); }
.modal-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.modal-list button {
  text-align: left; padding: 12px 14px; border-radius: 10px; background: var(--bg-3);
  font-weight: 600;
}
.modal-list button:hover { background: var(--card-hover); }
.modal-row { display: flex; gap: 10px; justify-content: flex-end; }

/* Empty states */
.empty {
  text-align: center; color: var(--text-dim); padding: 60px 20px;
}
.empty .big-ic { font-size: 3rem; display: block; margin-bottom: 14px; }

/* Skeletons */
.skel { background: linear-gradient(90deg, var(--bg-3) 25%, #262637 50%, var(--bg-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 220px; border-radius: var(--radius); }

/* Download progress ring */
.dl-progress { font-size: 0.7rem; color: var(--accent-2); font-weight: 700; }

/* Search category chips */
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .sidebar { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(13,13,18,0.95); backdrop-filter: blur(18px);
    border-top: 1px solid rgba(255,255,255,0.06); z-index: 60;
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--text-dim); font-size: 0.68rem; font-weight: 600;
  }
  .tab span { font-size: 1.25rem; }
  .tab.active { color: var(--accent-2); }
  .playerbar {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    height: 60px; grid-template-columns: 1fr auto; padding: 0 12px;
    border-radius: 12px; left: 8px; right: 8px; margin-bottom: 6px;
    border: 1px solid rgba(255,255,255,0.06);
  }
  .pb-right, #pbShuffle, #pbRepeat, #pbPrev { display: none; }
  .pb-art { width: 42px; height: 42px; }
  .view-container { padding: 4px 16px calc(var(--tabbar-h) + 90px); }
  .topbar { padding: 14px 16px 10px; }
  .topbar-title { font-size: 1.35rem; }
  .card-row { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px; }
  .card { padding: 10px; }
  .card-play { display: none; }
  .detail-art { width: 130px; height: 130px; }
  .detail-info h1 { font-size: 1.4rem; }
  .toast { bottom: calc(var(--tabbar-h) + 80px); }
}

/* ================= Auth screen ================= */
.auth-screen {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(circle at 20% 15%, rgba(139,92,246,0.28), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(34,211,238,0.22), transparent 45%),
    var(--bg);
}
.auth-card {
  width: min(92vw, 400px); background: rgba(24,24,34,0.72);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 24px;
  padding: 34px 28px 26px; text-align: center;
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  animation: rise 0.4s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.97); } }
.auth-logo { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 12px 34px rgba(0,0,0,0.5); }
.auth-brand {
  font-size: 1.9rem; font-weight: 800; margin-top: 14px; letter-spacing: -0.5px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-tag { color: var(--text-dim); font-size: 0.9rem; margin: 4px 0 24px; }
.auth-body { text-align: left; }
.auth-label { display: block; font-size: 0.82rem; color: var(--text-dim); margin: 0 0 8px 4px; font-weight: 600; }
.auth-mobile {
  display: flex; align-items: center; gap: 8px; margin-bottom: 18px;
  background: var(--bg-3); border: 1px solid transparent; border-radius: 14px; padding: 4px 14px;
  transition: 0.15s;
}
.auth-mobile:focus-within { border-color: var(--accent); }
.auth-mobile .cc { color: var(--text-dim); font-weight: 700; }
.auth-mobile input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 1.15rem; padding: 12px 0; letter-spacing: 1px; }
.auth-otp {
  width: 100%; text-align: center; font-size: 1.7rem; letter-spacing: 12px;
  padding: 14px; border-radius: 14px; border: 1px solid var(--bg-3);
  background: var(--bg-3); color: var(--text); outline: none; margin-bottom: 14px;
}
.auth-otp:focus { border-color: var(--accent); }
.auth-name {
  width: 100%; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--bg-3);
  background: var(--bg-3); color: var(--text); outline: none; margin-bottom: 14px; font-size: 1rem;
}
.auth-name:focus { border-color: var(--accent); }
.auth-full { width: 100%; padding: 14px; font-size: 0.95rem; }
.auth-link { display: block; width: 100%; text-align: center; color: var(--text-dim); font-size: 0.85rem; padding: 12px 0 2px; font-weight: 600; }
.auth-link:hover { color: var(--accent-2); }
.auth-resend { display: flex; justify-content: space-between; }
.auth-resend .auth-link { width: auto; }
.dev-otp { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: rgba(34,211,238,0.12); color: var(--accent-2); font-size: 0.85rem; text-align: center; }
.auth-err { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: rgba(248,113,113,0.14); color: var(--danger); font-size: 0.85rem; text-align: center; }
.auth-foot { color: var(--text-dim); font-size: 0.72rem; margin-top: 20px; }

/* ================= Profile row ================= */
.profile-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 10px; margin-bottom: 8px; text-align: left;
}
.profile-row:hover { background: var(--bg-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #0d0d12; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
}
.profile-name { flex: 1; font-size: 0.88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-ic { color: var(--text-dim); font-size: 1rem; }
.profile-row:hover .logout-ic { color: var(--danger); }

/* ================= Admin Studio ================= */
.admin-grid { display: flex; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-stat { flex: 1; min-width: 130px; background: var(--card); border-radius: 14px; padding: 18px 20px; }
.admin-stat .n { font-size: 1.8rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.admin-stat .l { color: var(--text-dim); font-size: 0.82rem; margin-top: 2px; }
.upload-form { background: var(--card); border-radius: 16px; padding: 20px; }
.drop {
  border: 2px dashed var(--bg-3); border-radius: 14px; padding: 30px 20px; text-align: center;
  color: var(--text-dim); cursor: pointer; transition: 0.15s; margin-bottom: 16px;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); background: rgba(139,92,246,0.06); }
.drop-ic { display: block; font-size: 2rem; margin-bottom: 8px; }
.drop small { opacity: 0.7; }
.upload-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.upload-fields input, .upload-fields select {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--bg-3);
  background: var(--bg-3); color: var(--text); outline: none; font-size: 0.92rem;
}
.upload-fields input:focus, .upload-fields select:focus { border-color: var(--accent); }
.upload-fields input#upTitle { grid-column: 1 / -1; }
.art-pick { grid-column: 1 / -1; padding: 12px 14px; border-radius: 10px; background: var(--bg-3); color: var(--text-dim); font-size: 0.9rem; cursor: pointer; }
.art-pick:hover { color: var(--text); }
.up-bar { height: 4px; background: var(--bg-3); border-radius: 2px; margin-top: 14px; overflow: hidden; }
.up-bar-fill { height: 100%; width: 0; background: var(--grad); transition: width 0.2s; }
@media (max-width: 820px) { .upload-fields { grid-template-columns: 1fr; } }

/* MFA / authenticator */
.auth-hint { color: var(--text-dim); font-size: 0.8rem; line-height: 1.5; margin: -6px 0 16px 2px; }
.mfa-qr { display: block; width: 180px; height: 180px; margin: 4px auto 12px; border-radius: 14px; background: #fff; padding: 8px; }
.mfa-secret { text-align: center; color: var(--text-dim); font-size: 0.8rem; margin-bottom: 16px; word-break: break-all; }
.mfa-secret b { color: var(--accent-2); font-family: ui-monospace, monospace; letter-spacing: 1px; }
