:root {
  --bg: #0E0E11;
  --fg: #F2F2F5;
  --muted: #9C9CA8;
  --surface: #1D1D23;
  --raised: #212128;
  --accent: #A897FF;
  --on-accent: #15102E;
  --accent-soft: #2B2550;
  --press: rgba(255, 255, 255, .06);
  --track: rgba(255, 255, 255, .16);
  --scrim: rgba(0, 0, 0, .55);
  --danger: #FF7B7B;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #F7F7FA;
    --fg: #15151A;
    --muted: #6A6A76;
    --surface: #E9E9EF;
    --raised: #FFFFFF;
    --accent: #5B49D6;
    --on-accent: #FFFFFF;
    --accent-soft: #E6E1FF;
    --press: rgba(0, 0, 0, .05);
    --track: rgba(0, 0, 0, .14);
    --scrim: rgba(0, 0, 0, .35);
    --danger: #C62F2F;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none;
  background: var(--bg); color: var(--fg);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
svg.ic { fill: currentColor; flex: none; display: block; }

/* ---------- layout ---------- */
#main { position: absolute; inset: 0; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.scroll {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(16px + var(--safe-b));
}
body.has-player .scroll { padding-bottom: calc(var(--mini-h) + 28px + var(--safe-b)); }

.top { display: flex; align-items: center; padding: 10px 8px 2px 20px; min-height: 56px; }
.top h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.top.detail { padding-left: 8px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--press); }
.icon-btn.big { width: 60px; height: 60px; }

.searchbar {
  flex: 1; display: flex; align-items: center; height: 46px; margin-right: 12px; margin-left: -8px;
  background: var(--surface); border-radius: 23px; padding-right: 16px;
}
.searchbar input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--fg);
  font: inherit; -webkit-appearance: none; appearance: none;
  -webkit-user-select: text; user-select: text;
}
.searchbar input::placeholder { color: var(--muted); }
.searchbar input::-webkit-search-cancel-button { display: none; }

.tabs { display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.chip {
  padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap;
  background: var(--surface); color: var(--muted);
}
.chip.sel { background: var(--accent); color: var(--on-accent); }

.hint {
  margin: 4px 16px 8px; padding: 12px 14px; border-radius: 14px; font-size: 14px;
  background: var(--accent-soft); color: var(--fg); display: flex; gap: 10px; align-items: center;
}
.hint span { flex: 1; }
.hint button { color: var(--accent); font-weight: 600; flex: none; padding: 6px 4px; }

/* ---------- lists ---------- */
.listhead { display: flex; align-items: center; padding: 0 16px 6px 20px; gap: 4px; }
.listhead .count { color: var(--muted); font-size: 14px; }
.grow { flex: 1; }
.textbtn { color: var(--accent); font-size: 14px; font-weight: 600; padding: 10px 8px; }

.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px; border-radius: 20px; font-size: 14px; font-weight: 600;
}
.pill.primary { background: var(--accent); color: var(--on-accent); }
.pill.tonal { background: var(--surface); color: var(--fg); }
.pill:active { opacity: .8; }
.pill:disabled { opacity: .4; }

.row {
  display: flex; align-items: center; gap: 14px; padding: 8px 4px 8px 20px;
  content-visibility: auto; contain-intrinsic-size: auto 64px;
}
.row:active { background: var(--press); }
.row.plain { padding-right: 20px; }
.txt { flex: 1; min-width: 0; }
.t1, .t2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t2 { color: var(--muted); font-size: 14px; }
.row.current .t1 { color: var(--accent); font-weight: 600; }
.dur { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.more { color: var(--muted); }

.art {
  position: relative; width: 48px; height: 48px; border-radius: 8px; overflow: hidden; flex: none;
  background: var(--surface); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.art svg { width: 45%; height: 45%; opacity: .55; }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.art.round { border-radius: 50%; }
.art.tile { background: var(--accent-soft); color: var(--accent); border-radius: 10px; }
.art.tile svg { width: 24px; height: 24px; opacity: 1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 16px; padding: 4px 20px 0; }
.card .art { width: 100%; height: auto; aspect-ratio: 1; border-radius: 14px; margin-bottom: 8px; }
.card:active { opacity: .75; }

.empty { padding: 56px 40px; text-align: center; }
.empty h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.empty p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* ---------- detail header ---------- */
.dhead { padding: 0 20px 12px; }
.dhead.center { text-align: center; }
.dhead .art { width: 210px; height: 210px; border-radius: 20px; margin: 0 auto 18px; }
.dhead h2 { margin: 0 0 2px; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.dhead p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.btnrow { display: flex; gap: 12px; }
.btnrow .pill { flex: 1; }

/* ---------- mini player ---------- */
#mini {
  position: absolute; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); height: var(--mini-h);
  display: flex; align-items: center; gap: 12px; padding: 0 4px 0 10px;
  background: var(--raised); border-radius: 18px; box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
  overflow: hidden; z-index: 5;
}
#mini .art { width: 44px; height: 44px; border-radius: 10px; }
#mini .t1 { font-size: 14px; font-weight: 600; }
#mini .t2 { font-size: 12px; }
#mini .icon-btn { margin-left: -8px; }
.mini-progress { position: absolute; left: 18px; right: 18px; bottom: 0; height: 2px; background: var(--press); }
#mini-bar { height: 100%; width: 0; background: var(--accent); }

/* ---------- full player ---------- */
#np {
  position: absolute; inset: 0; z-index: 10; background: var(--bg); overflow: hidden;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
}
#np.open { transform: none; visibility: visible; }
#np-backdrop {
  position: absolute; inset: -80px; background-size: cover; background-position: center;
  filter: blur(70px); opacity: .32;
}
.np-inner {
  position: relative; height: 100%; display: flex; flex-direction: column;
  padding: calc(6px + var(--safe-t)) 0 calc(20px + var(--safe-b));
}
.np-top { display: flex; align-items: center; padding: 0 8px; }
.np-top span { flex: 1; text-align: center; color: var(--muted); font-size: 14px; font-weight: 600; }
.np-artwrap {
  flex: 1; min-height: 0; margin: 20px 28px; display: flex; align-items: center; justify-content: center;
  container-type: size;
}
.np-artwrap .art { width: min(100%, 44vh); height: auto; aspect-ratio: 1; border-radius: 24px; }
@supports (width: 1cqw) {
  .np-artwrap .art { width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); }
}
.np-meta { display: flex; align-items: center; padding: 0 16px 0 28px; }
.np-meta .t1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.np-meta .t2 { font-size: 16px; }
#np-like { color: var(--muted); }
#np-like.on { color: var(--accent); }

.np-seek { padding: 14px 28px 0; }
.np-times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 2px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0; background: none;
  --p: 0%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--fg) var(--p), var(--track) var(--p));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--fg); margin-top: -5px;
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--fg); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--fg); }

.np-controls { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 0; }
.np-controls .icon-btn { color: var(--muted); }
.np-controls .icon-btn.big { color: var(--fg); }
.np-controls .icon-btn.on { color: var(--accent); }
.play-btn {
  width: 76px; height: 76px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.play-btn:active { transform: scale(.96); }

/* ---------- sheets, dialogs, toast ---------- */
#sheet { position: absolute; inset: 0; z-index: 20; }
#sheet .backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .2s; }
#sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 78%; display: flex; flex-direction: column;
  background: var(--raised); border-radius: 22px 22px 0 0; padding: 10px 0 calc(12px + var(--safe-b));
  transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
#sheet.open .backdrop { opacity: 1; }
#sheet.open .panel { transform: none; }
#sheet.dialog .panel {
  left: 24px; right: 24px; bottom: auto; top: 18%; border-radius: 22px; padding: 20px;
  transform: scale(.94); opacity: 0; transition: transform .2s, opacity .2s;
}
#sheet.dialog.open .panel { transform: none; opacity: 1; }
.panel h3 { margin: 6px 20px 10px; font-size: 20px; font-weight: 700; }
#sheet.dialog .panel h3 { margin: 0 0 14px; }
.panel .body { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.sheet-head { display: flex; align-items: center; gap: 14px; padding: 8px 20px 12px; }
.item { display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 22px; text-align: left; font-size: 16px; }
.item:active { background: var(--press); }
.item svg { color: var(--muted); }
.item.danger, .item.danger svg { color: var(--danger); }
.field {
  width: 100%; height: 48px; border-radius: 12px; border: 1.5px solid var(--track); background: none;
  color: var(--fg); font: inherit; padding: 0 14px; outline: 0;
  -webkit-user-select: text; user-select: text;
}
.field:focus { border-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 16px; }
.dialog-actions .textbtn { padding: 10px 14px; font-size: 15px; }
.dialog-actions .textbtn:disabled { opacity: .4; }
.dialog-text { margin: 0; color: var(--muted); font-size: 15px; }

#toast {
  position: absolute; left: 50%; bottom: calc(var(--mini-h) + 30px + var(--safe-b)); transform: translateX(-50%);
  z-index: 30; max-width: 86%; padding: 10px 16px; border-radius: 12px; font-size: 14px; text-align: center;
  background: var(--fg); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}

@media (prefers-reduced-motion: reduce) {
  #np, #sheet .panel, #sheet .backdrop { transition: none; }
}
