:root {
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #EDF1F7;
  --surface-3: #E4EAF2;
  --ink: #0F172A;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98A2B3;
  --line: #E4E7EC;
  --line-2: #D0D5DD;
  --accent: #2563EB;
  --accent-ink: #FFFFFF;
  --accent-soft: #EAF1FF;
  --accent-line: #B9CDFF;
  --warn: #B54708;
  --ok: #067647;
  --r: 14px;
  --r-sm: 10px;
  --shadow: 0 12px 32px -18px rgba(16, 24, 40, .35);
  --shell: 760px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

html[data-theme="dark"] {
  --bg: #0B0F15;
  --surface: #141A23;
  --surface-2: #1A212C;
  --surface-3: #212A37;
  --ink: #E9EDF3;
  --ink-2: #C6CEDA;
  --muted: #97A2B2;
  --faint: #75808F;
  --line: #232C3A;
  --line-2: #33404F;
  --accent: #7BA6FF;
  --accent-ink: #061020;
  --accent-soft: #16233B;
  --accent-line: #2C4370;
  --shadow: 0 14px 36px -18px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}
.num { font-variant-numeric: tabular-nums; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  max-width: var(--shell); margin: 0 auto;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid transparent;
}
.topbar.stuck { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.brand-t { font-weight: 680; letter-spacing: -.01em; }

.search-wrap {
  flex: 1; min-width: 0; position: relative;
  display: flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--faint);
}
.search-wrap:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--ink); font-size: 13.5px;
}
.search-wrap input::placeholder { color: var(--faint); }
.search-wrap input::-webkit-search-cancel-button { -webkit-appearance: none; }

.icon-btn {
  flex: 0 0 auto; width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn:disabled { opacity: .38; cursor: default; }

/* ---------- 布局 ---------- */
main { max-width: var(--shell); margin: 0 auto; padding: 4px 18px 20px; }
main:has(> .login:not([hidden])) {
  min-height: calc(100dvh - 8px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 18px 64px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.ttl { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.015em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- 口令 / 登录 ---------- */
.login { width: 100%; max-width: 400px; margin: 0 auto; padding: 26px; }
.login .ttl { font-size: 18px; }
.login .sub { margin-bottom: 18px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12.5px; }
.field input {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font-size: 15px; outline: 0;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.err { margin: 12px 0 0; color: var(--warn); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.qr-box { display: grid; place-items: center; gap: 12px; padding: 6px 0 14px; }
.qr-img {
  width: 216px; height: 216px; padding: 10px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: #fff; display: grid; place-items: center;
}
.qr-img img { width: 100%; height: 100%; display: block; }
.qr-skeleton { width: 100%; height: 100%; border-radius: 6px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .55 } }
.qr-state { color: var(--muted); font-size: 13px; text-align: center; }
.qr-state.ok { color: var(--ok); }
.qr-state.warn { color: var(--warn); }
.login-foot { display: flex; justify-content: center; }
.hint { margin: 12px 0 0; color: var(--faint); font-size: 12.5px; text-align: center; }

/* ---------- 列表 ---------- */
.lib { padding-top: 6px; }
.lib-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 10px 0 14px; }
.lib-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.tracks { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.track {
  display: grid; grid-template-columns: 34px 44px minmax(0, 1fr) auto;
  align-items: center; gap: 12px;
  padding: 9px 14px; cursor: default;
  border-top: 1px solid var(--line);
  transition: background .12s var(--ease);
}
.track:first-child { border-top: 0; }
.track:hover { background: var(--surface-2); }
.track .idx { color: var(--faint); font-size: 12.5px; text-align: right; }
.track .cov { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-3); display: block; }
.track .meta { display: block; min-width: 0; }
.track .nm { display: block; font-size: 14.5px; line-height: 1.35; font-weight: 560; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .ar { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .du { color: var(--faint); font-size: 12.5px; }
.track .badge { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px; font-size: 11px; line-height: 17px; color: var(--faint); border: 1px solid var(--line-2); vertical-align: 1px; }

.track.playing { background: var(--accent-soft); }
.track.playing .nm { color: var(--accent); font-weight: 660; }
.track.playing .idx { color: var(--accent); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { display: block; width: 2px; background: var(--accent); border-radius: 1px; animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(1) { height: 6px; animation-delay: -.2s }
.eq i:nth-child(2) { height: 11px; animation-delay: -.5s }
.eq i:nth-child(3) { height: 8px; animation-delay: -.8s }
@keyframes eq { 0%,100% { transform: scaleY(.5) } 50% { transform: scaleY(1) } }
.track.paused .eq i { animation-play-state: paused; }

.empty { padding: 44px 10px; text-align: center; color: var(--muted); font-size: 14px; }
.empty b { display: block; margin-bottom: 6px; color: var(--ink-2); font-size: 15px; }

/* ---------- 播放条 ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -10px 30px -22px rgba(16, 24, 40, .5);
}
.player > .progress { height: 14px; display: flex; align-items: center; cursor: pointer; padding: 0 0; }
.player > .progress:hover .p-fill { background: var(--accent); }
.p-track { position: relative; height: 4px; width: 100%; background: var(--line-2); }
.p-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 0 2px 2px 0; }
.p-dot {
  position: absolute; top: 50%; left: 0; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
  opacity: 0; transition: opacity .15s var(--ease);
}
.progress:hover .p-dot, .progress.dragging .p-dot { opacity: 1; }

.prow {
  max-width: var(--shell); margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 18px 10px;
}
.ptrack { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.pcover { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--surface-3); flex: 0 0 auto; }
.pmeta { min-width: 0; }
.pname { font-size: 14px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.partist { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pctrl { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.play-btn {
  width: 42px; height: 42px; margin: 0 4px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  transition: transform .12s var(--ease), filter .15s var(--ease);
}
.play-btn:hover { filter: brightness(1.07); }
.play-btn:active { transform: scale(.96); }
.play-btn:disabled { opacity: .45; cursor: default; transform: none; }

.pright { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.vol svg#muteIco { cursor: pointer; flex: 0 0 auto; }
.vol { display: flex; align-items: center; gap: 6px; color: var(--faint); width: 108px; }
.vol input {
  -webkit-appearance: none; appearance: none; width: 100%; height: 3px; border-radius: 2px;
  background: var(--surface-3); outline: 0; cursor: pointer;
}
.vol input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.vol input::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }

/* ---------- toast ---------- */
.resume {
  position: fixed; left: 50%; bottom: calc(116px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 16px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13.5px; font-weight: 620; cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(37, 99, 235, .55);
  z-index: 55;
}
.toast {
  position: fixed; left: 50%; bottom: calc(116px + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  max-width: 84vw; padding: 10px 14px;
  background: var(--ink); color: var(--bg);
  border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
  z-index: 60;
}
.toast.in { opacity: .95; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  main { padding: 0 12px 16px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand-t { display: none; }
  .search-wrap { height: 34px; }
  .login { padding: 22px; }
  .lib-head { align-items: center; }
  .ttl { font-size: 18px; }
  .tracks { border-radius: 12px; }
  .track { grid-template-columns: 30px 42px minmax(0, 1fr) auto; gap: 10px; padding: 8px 10px; }
  .track .cov { width: 42px; height: 42px; }
  .track .du { font-size: 11.5px; }
  .prow { padding: 6px 12px 8px; gap: 8px; }
  .pcover { width: 40px; height: 40px; }
  .pctrl { gap: 0; }
  .pctrl #shuffleBtn { display: none; }
  .play-btn { width: 40px; height: 40px; }
  .pright .vol svg#muteIco { cursor: pointer; flex: 0 0 auto; }
.vol { display: none; }
  .pright .time { font-size: 11.5px; }
  .pname { font-size: 13.5px; }
  .partist { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ---------- 歌词（全屏，网易云式） ---------- */
.lyric-btn {
  height: 26px; padding: 0 9px; margin-right: 2px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer;
  flex: 0 0 auto;
}
.lyric-btn:hover { color: var(--ink); border-color: var(--faint); }
.lyric-btn.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.lp {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column;
  background: #0C1016; color: #fff;
  opacity: 0; transition: opacity .24s var(--ease);
}
.lp.open { opacity: 1; }
.lp[hidden] { display: none !important; }
.lp-bg {
  position: absolute; inset: -14%;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  filter: blur(70px) saturate(1.55) brightness(.72);
  transform: scale(1.12);
}
.lp-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg,
    rgba(9,12,18,.46) 0%, rgba(9,12,18,.1) 26%,
    rgba(9,12,18,.24) 62%, rgba(9,12,18,.82) 100%);
}
.lp-top {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 4px;
}
.lp-close {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.12);
  color: #fff; cursor: pointer;
}
.lp-close:hover { background: rgba(255,255,255,.2); }
.lp-meta { flex: 1; min-width: 0; text-align: center; }
.lp-meta b {
  display: block; font-size: 14.5px; font-weight: 640; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lp-meta span {
  display: block; margin-top: 2px; font-size: 12px; color: rgba(255,255,255,.58);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lp-holder { width: 34px; height: 34px; }

.lp-body {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12%, #000 92%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 12%, #000 92%, transparent 100%);
}
.lp-scroll {
  position: absolute; left: 0; right: 0; top: 0; padding: 0 26px 40vh;
  transition: transform .5s cubic-bezier(.22,.61,.36,1);
  will-change: transform;
}
.lp-line {
  margin: 0; padding: 8px 0; text-align: center;
  color: rgba(255,255,255,.5); font-size: 15px; line-height: 1.45;
  opacity: .9;
  transition: color .24s var(--ease), font-size .24s var(--ease), opacity .24s var(--ease);
  cursor: pointer;
}
.lp-line.on { color: #fff; font-size: 19px; font-weight: 650; opacity: 1; }
.lp-tr { display: block; margin-top: 3px; font-size: 12.5px; font-weight: 400; color: rgba(255,255,255,.34); }
.lp-line.on .lp-tr { color: rgba(255,255,255,.7); }
.lp-empty { margin: 26vh 0 0; text-align: center; font-size: 14px; color: rgba(255,255,255,.45); }

.lp-foot {
  position: relative;
  padding: 2px 24px calc(16px + env(safe-area-inset-bottom));
}
.lp-prog { position: relative; height: 22px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.lp-track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: rgba(255,255,255,.26); }
.lp-fill { position: absolute; left: 0; height: 4px; width: 0; border-radius: 2px; background: #fff; }
.lp-dot { position: absolute; left: 0; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.45); }
.lp-times { display: flex; justify-content: space-between; margin-top: -2px; font-size: 11.5px; color: rgba(255,255,255,.55); font-variant-numeric: tabular-nums; }
.lp-ctrl { display: flex; align-items: center; justify-content: center; gap: 38px; margin-top: 10px; }
.lp-ibtn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: transparent; color: #fff; cursor: pointer; opacity: .92;
}
.lp-ibtn:hover { opacity: 1; }
.lp-play {
  width: 56px; height: 56px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: #fff; color: #10151C; cursor: pointer;
  box-shadow: 0 10px 26px -14px rgba(0,0,0,.8);
}
body.lp-open { overflow: hidden; }
