/* Music — dark, phone-first player. */
:root {
  --bg: #0f1115; --bg2: #161920; --surface: #1b1f27; --surface2: #252a34; --line: #2a303b;
  --ink: #eef0f5; --muted: #98a0af; --acc: #ff5a5f; --acc2: #c2348f; --acc-ink: #fff; --danger: #ff6b5e;
  --radius: 14px; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --mini-h: 64px; --tabs-h: 58px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- buttons, fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 22px; font-weight: 650; background: var(--surface2); }
.btn svg.i { width: 20px; height: 20px; }
.btn-primary { background: linear-gradient(135deg, var(--acc), var(--acc2)); color: var(--acc-ink); }
.btn-danger { color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger); background: transparent; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn:active, .icon-btn:active { transform: scale(.95); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; flex: none; color: var(--ink); }
.icon-btn[disabled] { opacity: .3; }
.icon-btn.on { color: var(--acc); }
.icon-btn.danger { color: var(--danger); }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .input { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg2); outline: none; }
.field input:focus, .input:focus { border-color: var(--acc); }
.check-row { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 14.5px; color: var(--muted); }
.check-row input { width: 20px; height: 20px; accent-color: var(--acc); }
.form-err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 0 0 10px; }

/* ---------- login ---------- */
.lock { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px 20px; overflow-y: auto;
  background: radial-gradient(120% 60% at 50% 0%, rgba(255, 90, 95, .25), var(--bg) 65%); }
.lock-card { width: 100%; max-width: 380px; }
.brand-mark { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 18px; background: url(../icons/icon-192.png) center/cover; box-shadow: 0 10px 30px rgba(255, 90, 95, .35); }
.lock-title { text-align: center; margin: 0; font-size: 28px; }
.lock-msg { text-align: center; color: var(--muted); margin: 4px 0 26px; }

/* ---------- frame ---------- */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--safe-t)) 8px 4px 16px; flex: none; }
#btn-back:not([hidden]) + .topbar-title { margin-left: -6px; }
#btn-back { margin-left: -10px; }
.topbar-title { flex: 1; margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.searchbar { padding: 0 16px 8px; flex: none; }
.searchbar input { width: 100%; height: 44px; border-radius: 22px; border: 0; background: var(--surface2); padding: 0 18px; outline: none; }
.offline-banner { flex: none; margin: 0 12px 8px; padding: 9px 12px; border-radius: 12px; background: #3a2f12; color: #ffd98a; font-size: 13.5px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.offline-banner svg.i { width: 20px; height: 20px; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 16px; }

/* ---------- covers ---------- */
.cover { flex: none; display: grid; place-items: center; overflow: hidden; background: linear-gradient(135deg, #2b3040, #1d212b); color: var(--muted); border-radius: 8px; position: relative; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.sm { width: 46px; height: 46px; border-radius: 6px; }
.cover.sm svg.i { width: 20px; height: 20px; }
.cover.md { width: 56px; height: 56px; }
.cover.lg { width: 180px; height: 180px; border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.cover.lg svg.i { width: 64px; height: 64px; }
.cover.xl { width: min(78vw, 46vh, 380px); aspect-ratio: 1; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.55); }
.cover.xl svg.i { width: 30%; height: 30%; }
.cover.tile { width: 100%; aspect-ratio: 1; border-radius: 10px; }
.cover.tile svg.i { width: 40%; height: 40%; }
.cover.round { border-radius: 50%; }
.cover.add { background: var(--surface2); color: var(--ink); }
.cover.liked { background: linear-gradient(135deg, #5b4bff, #c2348f); color: #fff; }

/* ---------- song rows ---------- */
.tracks { list-style: none; margin: 0; padding: 0 4px 0 12px; }
.trk { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 6px 0; cursor: pointer; }
.trk:active { opacity: .7; }
.trk.dim { opacity: .38; }
.trk-no { width: 28px; text-align: center; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; flex: none; }
.trk-text { flex: 1; min-width: 0; }
.trk-text b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trk-text small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trk-text small i { display: inline-flex; flex: none; }
.trk-text small svg.i { width: 14px; height: 14px; }
.trk-text .dl { color: #3ccf8e; }
.trk-text .lk { color: var(--acc); }
.trk-dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.trk-more { color: var(--muted); width: 40px; }
.trk.playing .trk-text b { color: var(--acc); }
.trk.playing .cover::after, .trk.playing .trk-no::after { content: ""; position: absolute; inset: 0; background:
  linear-gradient(var(--acc), var(--acc)) 30% 100% / 3px 40% no-repeat,
  linear-gradient(var(--acc), var(--acc)) 50% 100% / 3px 70% no-repeat,
  linear-gradient(var(--acc), var(--acc)) 70% 100% / 3px 50% no-repeat, rgba(0,0,0,.55);
  animation: eq .9s ease-in-out infinite alternate; }
.trk.playing .trk-no { position: relative; color: transparent; height: 28px; }
.trk.playing.paused .cover::after, .trk.playing.paused .trk-no::after { animation: none; }
@keyframes eq {
  0% { background-size: 3px 30%, 3px 80%, 3px 50%, auto; }
  50% { background-size: 3px 80%, 3px 40%, 3px 70%, auto; }
  100% { background-size: 3px 50%, 3px 70%, 3px 30%, auto; }
}
.trk.past { opacity: .5; }
.tracks.edit .trk { cursor: default; }
.more-rows { height: 40px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; }
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 16px 10px; }
.list-tools select { background: var(--surface2); border: 0; border-radius: 18px; padding: 9px 14px; }

/* ---------- grids & rows ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 14px; padding: 4px 16px 16px; }
.tile { text-align: left; min-width: 0; }
.tile b { display: block; margin-top: 8px; font-size: 14.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows { list-style: none; margin: 0; padding: 0 12px; }
.row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px 4px; text-align: left; border-radius: 10px; }
.row:active { background: var(--surface); }
.row-text { flex: 1; min-width: 0; }
.row-text b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text small { color: var(--muted); font-size: 13px; }
.sec { margin: 14px 16px 6px; font-size: 18px; }

/* ---------- collection header ---------- */
.coll-head { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 16px 14px; gap: 12px; }
.coll-info h2 { margin: 0; font-size: 22px; }
.coll-info p { margin: 2px 0 0; }
.coll-actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.coll-actions .btn { min-width: 120px; }
.dl-row { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 480px; padding: 10px 14px; border-radius: 12px; background: var(--surface); text-align: left; }
.dl-row > span:first-child { flex: 1; display: flex; flex-direction: column; font-weight: 600; font-size: 15px; }
.dl-row > span:first-child svg.i { display: none; }
.dl-row small { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--surface2); transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: #3ccf8e; }
.switch input:checked + span::after { transform: translateX(20px); }

.empty { text-align: center; padding: 56px 30px; color: var(--muted); }
.empty > svg.i { width: 56px; height: 56px; color: var(--acc); }
.empty h2 { color: var(--ink); font-size: 19px; margin: 12px 0 6px; }
.empty.small { padding: 24px 30px; }
.empty .btn { margin-top: 14px; }
.empty svg.i { vertical-align: middle; width: 18px; height: 18px; }

/* ---------- mini player & tabs ---------- */
.mini { flex: none; position: relative; display: flex; align-items: center; gap: 4px; margin: 0 8px; padding: 8px 6px 8px 8px; border-radius: 12px;
  background: linear-gradient(135deg, #2a1d2a, #1f222c); box-shadow: 0 -2px 16px rgba(0,0,0,.4); }
.mini-progress { position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: rgba(255,255,255,.12); border-radius: 1px; overflow: hidden; }
.mini-progress b { display: block; height: 100%; width: 0; background: var(--ink); }
.mini-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
.mini-text { min-width: 0; }
.mini-text b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-text small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .icon-btn svg.i { width: 26px; height: 26px; }
.tabs { flex: none; display: flex; justify-content: space-around; padding: 6px 4px calc(4px + var(--safe-b)); background: var(--bg); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.tabs button.on { color: var(--ink); }
.tabs button.on svg.i { color: var(--acc); }

/* ---------- full player ---------- */
.full { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; padding: var(--safe-t) 20px calc(14px + var(--safe-b)); background: #14161c; overflow: hidden; animation: up .26s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.full-bg { position: absolute; inset: -40px; background: center/cover no-repeat; filter: blur(50px) saturate(1.4) brightness(.45); transform: scale(1.2); z-index: -1; }
.full::before { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent, rgba(0,0,0,.45)); z-index: -1; }
.full-top { display: flex; align-items: center; gap: 8px; margin: 6px -10px 0; }
.full-source { flex: 1; text-align: center; min-width: 0; }
.full-source small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.full-source b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.full-art { flex: 1; display: grid; place-items: center; min-height: 0; padding: 12px 0; }
.full-meta { display: flex; align-items: center; gap: 10px; }
.full-text { flex: 1; min-width: 0; }
.full-text h2 { margin: 0; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link { color: var(--muted); font-size: 16px; text-align: left; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.like.on { color: var(--acc); }
.like svg.i { width: 28px; height: 28px; }
.seek { margin: 14px 0 4px; }
.seek input { width: 100%; -webkit-appearance: none; appearance: none; height: 22px; background: transparent; margin: 0; --p: 0%; }
.seek input::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--ink) var(--p), rgba(255,255,255,.18) var(--p)); }
.seek input::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.18); }
.seek input::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--ink); }
.seek input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; }
.seek input::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; justify-content: space-between; margin: 8px -6px 10px; }
.icon-btn.big svg.i { width: 34px; height: 34px; }
.play-btn { width: 72px; height: 72px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; }
.play-btn svg.i { width: 32px; height: 32px; }
.play-btn.loading { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .6; } }
.full-bottom { display: flex; justify-content: space-between; margin: 0 -6px; }
.full-bottom .icon-btn { color: var(--muted); }
.full-bottom .icon-btn.on { color: var(--acc); }

/* ---------- settings ---------- */
.settings { padding: 0 16px 24px; }
.set-h { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 6px 8px; }
.set-group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; min-height: 54px; }
.set-row:last-child { border-bottom: 0; }
.set-row .lbl { flex: 1; min-width: 0; }
.set-row .lbl small { display: block; color: var(--muted); font-size: 12.5px; }
.set-row.danger { color: var(--danger); }
.about { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* ---------- overlays (shared with ui.js) ---------- */
.ov { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.55); animation: fade .18s; }
.ov.center { align-items: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 14px calc(14px + var(--safe-b)); animation: up .24s cubic-bezier(.2,.8,.2,1); }
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; }
.sheet-title { font-size: 16px; font-weight: 700; margin: 2px 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 8px; border-radius: 12px; text-align: left; font-weight: 550; }
.sheet-item:active { background: var(--surface2); }
.sheet-item.danger { color: var(--danger); }
.sheet-item small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.queue-sheet .tracks { padding: 0; }
.queue-sheet .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.queue-sheet .icon-btn svg.i { width: 20px; height: 20px; }
.dialog { width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; padding: 22px 20px 16px; animation: fade .18s; }
.dialog h3 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 14px; color: var(--muted); }
.dialog .row { display: flex; gap: 10px; margin-top: 8px; padding: 0; }
.dialog .row .btn { flex: 1; }
.progress-card { width: 100%; max-width: 340px; background: var(--surface); border-radius: 20px; padding: 24px 22px; text-align: center; }
.progress-card h3 { margin: 0 0 4px; font-size: 17px; }
.progress-card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; word-break: break-word; }
.spinner { width: 36px; height: 36px; margin: 0 auto 14px; border-radius: 50%; border: 3.5px solid var(--surface2); border-top-color: var(--acc); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; }
.bar b { display: block; height: 100%; width: 0; background: var(--acc); transition: width .2s; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 24px + var(--safe-b)); transform: translate(-50%, 20px); background: #2b303c; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14.5px; opacity: 0; pointer-events: none; transition: .22s; z-index: 60; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
body.has-mini .toast { bottom: calc(var(--tabs-h) + var(--mini-h) + 24px + var(--safe-b)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #7d2620; }

@media (min-width: 760px) {
  .coll-head { flex-direction: row; text-align: left; align-items: flex-end; }
  .coll-actions { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
