:root {
  --bg: #0f0f12; --bg2: #17171c; --bg3: #212129; --line: #2a2a33;
  --fg: #f2f2f5; --muted: #9a9aa8; --accent: #ff7a3d; --accent2: #ffb27a; --ok: #3ddc84; --err: #ff5c5c;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --player-h: 64px; --nav-h: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
a { color: var(--accent2); }
.hidden { display: none !important; }

#app { min-height: 100%; }
.screen { padding: calc(var(--sat) + 12px) 14px calc(var(--nav-h) + var(--player-h) + var(--sab) + 20px); }
h1 { font-size: 26px; margin: 6px 0 14px; letter-spacing: -0.3px; }
h2 { font-size: 17px; margin: 18px 0 8px; color: var(--fg); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Login */
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; }
.login .logo { font-size: 44px; margin-bottom: 6px; }
.field { display: block; width: 100%; background: var(--bg3); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--fg); margin: 8px 0; outline: none; }
.field:focus { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #111; font-weight: 600; border-radius: 12px; padding: 11px 16px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn.ghost { background: var(--bg3); color: var(--fg); font-weight: 500; }
.btn.sm { padding: 7px 11px; border-radius: 10px; font-size: 13.5px; }
.btn:disabled { opacity: 0.5; }
.error { color: var(--err); margin: 8px 0; }

/* Search bar */
.searchbar { display: flex; gap: 8px; position: sticky; top: calc(var(--sat) + 4px); z-index: 5; background: var(--bg); padding: 4px 0 8px; }
.searchbar input { flex: 1; background: var(--bg3); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; color: var(--fg); outline: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { background: var(--bg3); border-radius: 999px; padding: 6px 12px; white-space: nowrap; font-size: 13px; color: var(--muted); }
.chip.on { background: var(--accent); color: #111; font-weight: 600; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; margin: 10px 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px; }
.card-h .title { font-weight: 600; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: 0.3px; padding: 3px 7px; border-radius: 6px; background: var(--bg3); color: var(--accent2); }
.badge.flac { background: #2b1d14; }
.tracks { border-top: 1px solid var(--line); }
.track { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.track:last-child { border-bottom: 0; }
.track .no { width: 26px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.track .meta { font-size: 12px; color: var(--muted); }
.add { width: 36px; height: 36px; border-radius: 50%; background: var(--bg3); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; color: var(--accent2); flex: none; }
.add.done { background: #15321f; color: var(--ok); }
.add.busy { color: var(--muted); }
.tog { color: var(--muted); font-size: 13px; padding: 6px 12px 10px; }

/* Library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tile { text-align: left; }
.tile img, .tile .ph { width: 100%; aspect-ratio: 1; border-radius: 10px; background: var(--bg3); object-fit: cover; display: block; }
.tile .t { margin-top: 6px; font-weight: 600; font-size: 13.5px; }
.tile .s { font-size: 12px; color: var(--muted); }
.list .item { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.list .item img, .list .item .ph { width: 46px; height: 46px; border-radius: 8px; background: var(--bg3); object-fit: cover; flex: none; }
.list .item.playing .t { color: var(--accent); }
.hero { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 14px; }
.hero img, .hero .ph { width: 128px; height: 128px; border-radius: 12px; background: var(--bg3); object-fit: cover; flex: none; }
.back { color: var(--accent2); margin-bottom: 8px; display: inline-block; }
.subtabs { display: flex; gap: 6px; margin-bottom: 8px; }
.subtabs button { padding: 7px 12px; border-radius: 999px; background: var(--bg3); color: var(--muted); font-size: 13.5px; }
.subtabs button.on { background: var(--fg); color: #111; font-weight: 600; }

/* Downloads */
.job { padding: 10px 0; border-bottom: 1px solid var(--line); }
.bar { height: 4px; background: var(--bg3); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.job.done .bar > i { background: var(--ok); }
.job.error .bar > i { background: var(--err); width: 100%; }
.job.tagging .bar > i { background: var(--accent2); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }
.retag { margin-top: 8px; padding: 10px; background: var(--bg2); border-radius: 12px; }
.retag .field { margin: 4px 0; padding: 9px 12px; }
.retag .row .field { flex: 1; }

/* Player bar */
.player { position: fixed; left: 8px; right: 8px; bottom: calc(var(--nav-h) + var(--sab) + 6px); height: var(--player-h); background: var(--bg3); border: 1px solid var(--line); border-radius: 14px; display: flex; align-items: center; gap: 10px; padding: 0 10px; z-index: 20; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.player img, .player .ph { width: 46px; height: 46px; border-radius: 8px; background: var(--bg2); object-fit: cover; flex: none; }
.player .ctl { font-size: 24px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.player .prog { position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; background: var(--line); border-radius: 2px; }
.player .prog > i { display: block; height: 100%; background: var(--accent); width: 0; }

/* Full player */
.full { position: fixed; inset: 0; background: var(--bg); z-index: 30; padding: calc(var(--sat) + 14px) 22px calc(var(--sab) + 20px); display: flex; flex-direction: column; }
.full .art { width: min(78vw, 360px); aspect-ratio: 1; border-radius: 16px; background: var(--bg3); object-fit: cover; margin: 18px auto; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.full .ti { font-size: 20px; font-weight: 700; text-align: center; }
.full .ar { text-align: center; color: var(--muted); margin-top: 4px; }
.full .seek { width: 100%; margin: 22px 0 4px; accent-color: var(--accent); }
.full .times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.full .ctls { display: flex; justify-content: center; align-items: center; gap: 28px; margin: 18px 0; }
.full .ctls .ctl { font-size: 30px; }
.full .ctls .big { width: 72px; height: 72px; border-radius: 50%; background: var(--fg); color: #111; font-size: 34px; display: inline-flex; align-items: center; justify-content: center; }
.full .queue { flex: 1; overflow: auto; margin-top: 8px; }
.full .close { position: absolute; top: calc(var(--sat) + 10px); left: 16px; font-size: 26px; color: var(--muted); }
.full .quality { position: absolute; top: calc(var(--sat) + 12px); right: 16px; }
select.field { width: auto; padding: 6px 10px; margin: 0; font-size: 13px; }

/* Nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--sab)); padding-bottom: var(--sab); background: rgba(15,15,18,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); display: flex; z-index: 25; }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); position: relative; }
.nav button.on { color: var(--accent); }
.nav .ic { font-size: 20px; }
.nav .dot { position: absolute; top: 8px; right: calc(50% - 18px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: #111; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--player-h) + var(--sab) + 18px); background: var(--fg); color: #111; padding: 9px 14px; border-radius: 10px; font-weight: 600; z-index: 40; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: pop .2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
