/* 音乐自由 · 本地聚合播放器 — 暗色 UI */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d1117; --panel: rgba(22,27,34,.82); --panel2: #161b22;
  --fg: #e6edf3; --dim: #8b949e; --accent: #7ee2a8; --accent2: #58a6ff;
  --line: #30363d; --danger: #f85149;
}
html, body { height: 100%; }
body {
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--fg);
  display: flex; flex-direction: column;
  /* 播放器固定一屏，列表/歌词各自内部滚动，避免歌词把整页顶上去 */
  height: 100vh; height: 100dvh; overflow: hidden;
}
#bg-blur { position: fixed; inset: -40px; z-index: -1; filter: blur(60px) saturate(1.4); background: radial-gradient(60% 50% at 20% 10%, #1f3b2c 0%, transparent 60%), radial-gradient(50% 40% at 85% 80%, #14263f 0%, transparent 60%), var(--bg); transition: background 1.2s; }
.dim { color: var(--dim); font-size: 12px; }
button { cursor: pointer; border: none; background: none; color: var(--fg); font: inherit; }
input, select { font: inherit; color: var(--fg); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
button.accent { background: linear-gradient(135deg, #2ea56b, #238636); color: #fff; border-radius: 8px; padding: 7px 16px; font-weight: 600; }
button.accent:hover { filter: brightness(1.1); }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.brand { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand .ver { font-size: 11px; color: var(--dim); font-weight: 400; }
.search-row { display: flex; gap: 8px; flex: 1; min-width: 260px; max-width: 560px; }
.search-row input { flex: 1; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 6px 14px; border-radius: 20px; color: var(--dim); }
.tab.active { background: rgba(126,226,168,.15); color: var(--accent); font-weight: 600; }

/* 主布局 */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 1fr) minmax(320px, 420px); gap: 14px; padding: 14px 18px; max-width: 1280px; width: 100%; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; backdrop-filter: blur(10px); display: flex; flex-direction: column; min-height: 0; }
.panel-head { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
#list-title { font-weight: 600; }

/* 曲目列表 */
.tracks { list-style: none; overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; }
.tracks li { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; border-bottom: 1px solid rgba(48,54,61,.5); }
.tracks li:hover { background: rgba(88,166,255,.07); }
.tracks li.cur { background: rgba(126,226,168,.12); }
.tracks li.cur .t-name { color: var(--accent); font-weight: 600; }
.t-idx { width: 26px; text-align: right; color: var(--dim); font-size: 12px; flex: none; }
.t-main { flex: 1; min-width: 0; }
.t-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-sub { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-act { flex: none; display: flex; gap: 8px; }
.t-act button { font-size: 16px; color: var(--dim); padding: 2px 6px; border-radius: 6px; }
.t-act button:hover { background: rgba(255,255,255,.08); color: var(--fg); }
.t-act .starred { color: #ffd76e; }
.more { text-align: center; padding: 10px; color: var(--dim); cursor: pointer; }
.inline-box { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.inline-box input { flex: 1; }
.inline-box button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; }

/* 侧栏：封面+歌词 */
.side-panel { padding: 16px; align-items: center; min-height: 0; overflow: hidden; }
.now-cover { position: relative; width: 170px; height: 170px; margin-top: 6px; }
.now-cover img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--panel2); }
.now-cover img[data-empty="1"] { opacity: .25; }
.playing .now-cover img, .playing #ring { animation: spin 22s linear infinite; }
#ring { position: absolute; inset: -8px; border-radius: 50%; border: 2px dashed rgba(126,226,168,.3); }
@keyframes spin { to { transform: rotate(360deg); } }
.now-meta { text-align: center; margin-top: 12px; max-width: 100%; }
#now-name { font-weight: 600; font-size: 16px; }
.src-chip-row { margin-top: 6px; min-height: 20px; }
.chip { background: rgba(88,166,255,.15); color: var(--accent2); border-radius: 12px; padding: 2px 10px; font-size: 12px; }
.lyric-box { flex: 1; width: 100%; overflow-y: auto; overscroll-behavior: contain; margin-top: 14px; scrollbar-width: none; min-height: 0; -webkit-mask-image: linear-gradient(transparent, black 12%, black 88%, transparent); mask-image: linear-gradient(transparent, black 12%, black 88%, transparent); }
.lyric-box::-webkit-scrollbar { display: none; }
#lyric-lines { list-style: none; text-align: center; }
#lyric-lines li { padding: 4px 8px; color: var(--dim); transition: all .3s; font-size: 13px; cursor: pointer; }
#lyric-lines li.on { color: var(--accent); font-weight: 600; font-size: 15px; transform: scale(1.04); }
.fav-btn { position: absolute; } /* 兼容占位 */
.side-panel { position: relative; }
.fav-btn { position: absolute; top: 12px; right: 14px; font-size: 22px; color: var(--dim); }
.fav-btn.starred { color: #ffd76e; }

/* 底部播放条 */
.player-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; padding: 8px 18px; background: var(--panel); border-top: 1px solid var(--line); backdrop-filter: blur(14px); z-index: 20; }
.pb-cover { width: 46px; height: 46px; border-radius: 8px; overflow: hidden; flex: none; }
.pb-cover img { width: 100%; height: 100%; object-fit: cover; background: var(--panel2); }
.pb-cover img[src=""] { visibility: hidden; }
.pb-meta { width: 170px; min-width: 0; display: flex; flex-direction: column; }
.pb-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-btns { display: flex; align-items: center; gap: 6px; flex: none; }
.pb-btns button { font-size: 18px; width: 38px; height: 38px; border-radius: 50%; }
.pb-btns button:hover { background: rgba(255,255,255,.08); }
.pb-btns .big { background: var(--accent); color: #0d1117; font-size: 16px; }
.pb-btns .big:hover { filter: brightness(1.1); }
.pb-progress { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 180px; }
.pb-progress span { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 6px; background: rgba(139,148,158,.25); border-radius: 3px; position: relative; cursor: pointer; }
.bar .fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 3px; pointer-events: none; }
.bar .knob { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); opacity: 0; transition: opacity .15s; pointer-events: none; }
.bar:hover .knob { opacity: 1; }
.bar.thin { max-width: 90px; }
.pb-vol { display: flex; align-items: center; gap: 6px; flex: none; }
.pb-vol button { font-size: 16px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #21262d; border: 1px solid var(--line); padding: 8px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99; max-width: 80vw; }
#toast.show { opacity: 1; }
#toast.err { border-color: var(--danger); color: var(--danger); }

/* 全部播放按钮（列表头右侧） */
.head-right { display: flex; align-items: baseline; gap: 10px; }
.mini-btn { font-size: 12px; color: var(--dim); border: 1px solid var(--line); border-radius: 14px; padding: 3px 12px; transition: all .18s; }
.mini-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(126,226,168,.1); }
.mini-btn.busy { color: var(--accent); border-color: var(--accent); opacity: .7; pointer-events: none; }

/* 下载音质弹窗（遮罩样式见 .modal-mask） */
.dl-box { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; width: min(520px, 94vw); max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.dl-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dl-head span { font-weight: 600; }
#dl-close { font-size: 15px; color: var(--dim); padding: 2px 8px; border-radius: 6px; }
#dl-close:hover { background: rgba(255,255,255,.08); color: var(--fg); }
.dl-track { padding: 10px 18px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-list { padding: 12px 18px; overflow-y: auto; scrollbar-width: thin; }
.dl-loading { text-align: center; color: var(--dim); font-size: 13px; padding: 22px 0; }
.dl-loading.err { color: var(--danger); }
.dl-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; transition: all .18s; }
.dl-row:hover { border-color: var(--accent); background: rgba(126,226,168,.08); }
.dl-t { font-weight: 600; flex: none; min-width: 74px; }
.dl-meta { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.dl-src { margin-left: auto; color: var(--accent2); font-size: 12px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46%; }
.dl-note { padding: 0 18px 14px; color: var(--dim); font-size: 11px; line-height: 1.6; border-top: 1px solid var(--line); padding-top: 10px; }

/* 账号区（顶栏右侧） */
.account { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.who { font-size: 12px; color: var(--accent); font-weight: 600; }

/* 遮罩层：登录与下载两个弹窗共用。
   之前只给 #dl-mask 写了样式，#auth-mask 漏写 → position 退化成 static，
   弹窗撑满文档流并被挤到页面左下角。统一用 .modal-mask 类避免再次漏掉。 */
.modal-mask { position: fixed; inset: 0; background: rgba(1,4,9,.72); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask[hidden] { display: none; }

/* 登录/注册弹窗 */
.auth-box { width: min(400px, 94vw); }
.auth-switch { display: flex; gap: 4px; padding: 14px 18px 0; }
.auth-tab { flex: 1; padding: 7px; border-radius: 8px; color: var(--dim); border: 1px solid var(--line); }
.auth-tab.active { color: var(--accent); border-color: var(--accent); background: rgba(126,226,168,.1); font-weight: 600; }
.auth-form { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--dim); }
.auth-form input { width: 100%; }
.auth-err { color: var(--danger); font-size: 12px; min-height: 17px; }
.auth-submit { padding: 9px; border-radius: 8px; font-weight: 600; }
.auth-foot { padding: 0 18px 14px; color: var(--dim); font-size: 11px; line-height: 1.6; }
.auth-foot code { background: var(--panel); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

/* 响应式 */
@media (max-width: 900px) {
  body { height: auto; min-height: 100vh; overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .side-panel { order: -1; }
  .tracks { max-height: 50vh; }
  .lyric-box { max-height: 160px; min-height: 120px; }
  .pb-meta { width: 110px; }
}
@media (max-height: 600px) {
  body { height: auto; min-height: 100vh; overflow: auto; }
  .tracks { max-height: 55vh; }
  .lyric-box { max-height: 180px; min-height: 100px; }
}
