:root {
  --bg: #14111f;
  --bg2: #1d1930;
  --card: #241f3a;
  --line: rgba(255,255,255,.08);
  --text: #f3f0fa;
  --muted: #a39cbc;
  --accent: #ff8a3d;
  --accent2: #e6457a;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --tabs-h: 62px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; color: var(--text); }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
.muted { color: var(--muted); }
.error { color: #ff7b8f; min-height: 1.2em; margin: 0; font-size: 14px; }

/* ---------- auth ---------- */
.screen.center { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; }
.auth { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.auth h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.auth-logo { width: 64px; height: 64px; align-self: center; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field, label input, label select {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none; width: 100%;
}
label input:focus, .field:focus { border-color: var(--accent); }
.btn { border-radius: 12px; padding: 12px 18px; font-weight: 600; text-align: center; }
.btn.primary { background: var(--grad); color: #fff; }
.btn.ghost { border: 1px solid var(--line); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: #ff7b8f; border: 1px solid rgba(255,123,143,.3); }
.btn:disabled { opacity: .5; }

/* ---------- layout ---------- */
#app { max-width: 920px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(20,17,31,.92); backdrop-filter: blur(12px);
  padding: calc(10px + var(--safe-t)) 16px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.brand img { width: 30px; height: 30px; }
.brand b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 20px; height: 20px; color: var(--muted); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 11px 0; font-size: 16px; }
main { padding: 8px 16px calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 24px); min-height: 60dvh; }
@media (min-width: 720px) {
  .topbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .search { width: 340px; }
}

.view-head { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.view-head h2 { margin: 0; font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-head .count { color: var(--muted); font-size: 13px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--muted); }
.chip.on { background: var(--grad); color: #fff; border-color: transparent; }
.play-all { display: inline-flex; align-items: center; gap: 6px; }
.play-all svg { width: 18px; height: 18px; }

/* ---------- song rows ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 12px; }
.row:active, .row:hover { background: rgba(255,255,255,.04); }
.row.playing .r-title { color: var(--accent); }
.art { width: 44px; height: 44px; border-radius: 10px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 16px; color: rgba(255,255,255,.9); }
.r-main { flex: 1; min-width: 0; text-align: left; }
.r-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.r-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 13px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); flex: none; }
.icon-btn:hover { color: var(--text); }
.icon-btn.on, .fav.on { color: var(--accent2); }
.dur { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- grid (artists / categories) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tile .art { width: 52px; height: 52px; border-radius: 50%; font-size: 20px; }
.tile.cat .art { border-radius: 12px; }
.tile b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile small { color: var(--muted); }

/* ---------- mini player + tabs ---------- */
.mini { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabs-h) + var(--safe-b) + 6px); max-width: 904px; margin: 0 auto; height: var(--mini-h);
  background: #2c2548; border-radius: 14px; display: flex; align-items: center; gap: 4px; padding: 0 6px 0 8px; z-index: 6; box-shadow: 0 8px 24px rgba(0,0,0,.4); overflow: hidden; }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255,255,255,.08); }
.mini-progress i { display: block; height: 100%; width: 0; background: var(--grad); }
.mini-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
.mini .art { width: 44px; height: 44px; }
.mini .txt { min-width: 0; display: flex; flex-direction: column; }
.mini .txt b, .mini .txt small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .txt small { color: var(--muted); }
.mini .icon-btn { color: var(--text); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: rgba(20,17,31,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); }
.tabs button svg { width: 22px; height: 22px; }
.tabs button.on { color: var(--accent); }

/* ---------- full player ---------- */
.player { position: fixed; inset: 0; z-index: 10; background: linear-gradient(180deg, #3a2a55 0%, var(--bg) 60%);
  padding: calc(12px + var(--safe-t)) 24px calc(24px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 16px; overflow-y: auto; }
.player > * { width: 100%; max-width: 420px; }
.player .close { align-self: flex-start; color: var(--text); width: 44px; }
.big-art { aspect-ratio: 1; border-radius: 24px; display: grid; place-items: center; font-size: 96px; font-weight: 700; color: rgba(255,255,255,.9);
  box-shadow: 0 20px 50px rgba(0,0,0,.45); max-width: min(420px, 80vw, 42dvh); margin-top: 8px; }
.now { display: flex; align-items: center; gap: 12px; }
.now-txt { flex: 1; min-width: 0; }
.now h2 { margin: 0; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now p { margin: 4px 0 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#seek { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: rgba(255,255,255,.15); outline: none; margin: 0; }
#seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; }
#seek::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-top: -8px; }
.controls { display: flex; align-items: center; justify-content: space-between; }
.controls .icon-btn { width: 52px; height: 52px; color: var(--text); }
.controls .icon-btn svg { width: 28px; height: 28px; }
.controls #pShuffle:not(.on), .controls #pRepeat:not(.on) { color: var(--muted); }
.play-big { width: 72px; height: 72px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 10px 30px rgba(230,69,122,.4); }
.play-big svg { width: 36px; height: 36px; }
.buffer { text-align: center; font-size: 12px; min-height: 1em; margin: 0; }
#pRepeat { position: relative; }
#pRepeat[data-mode="one"]::after { content: "1"; position: absolute; top: 9px; right: 9px; font-size: 10px; font-weight: 700; }

/* ---------- sheet / toast ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; background: var(--bg2); border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.sheet h3 { margin: 0; font-size: 18px; }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { flex-direction: row; align-items: center; gap: 6px; }
.checks input { display: none; }
.checks span { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; color: var(--muted); font-size: 13px; }
.checks input:checked + span { background: var(--grad); color: #fff; border-color: transparent; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 20px); z-index: 30;
  background: #fff; color: #14111f; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: calc(100% - 32px); }
@media (min-width: 720px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; } }

/* ---------- upload / admin ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 12px 0; display: flex; flex-direction: column; gap: 12px; }
.panel h3 { margin: 0; font-size: 16px; }
.drop { border: 2px dashed rgba(255,255,255,.18); border-radius: 14px; padding: 28px 16px; text-align: center; color: var(--muted); display: block; cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }
.uploads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.uploads li { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.uploads .bar { height: 4px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.uploads .bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }
.uploads .st { font-size: 12px; color: var(--muted); }
.uploads .st.ok { color: #6ee7a8; } .uploads .st.bad { color: #ff7b8f; }
.urow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.urow:last-child { border-bottom: 0; }
.urow span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.inline { display: flex; gap: 8px; }
.inline .field { flex: 1; min-width: 0; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 10px; border-radius: 10px; user-select: all; word-break: break-all; }

/* ---------- Prime Computers credit ---------- */
.footer-credit { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px 0 8px; }
.footer-credit .credit-label { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.footer-credit .credit { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); transition: transform .15s ease; }
.footer-credit .credit:hover { transform: translateY(-1px); }
.footer-credit .credit-logo { display: block; height: 16px; width: auto; }
