/* ========== 主题变量 ========== */
:root {
  --bg: #f5f6fa; --bg-2: #eceff5; --card: #ffffff; --card-2: #f8f9fc;
  --fg: #111827; --fg-2: #374151; --muted: #6b7280;
  --line: #e7eaf0; --line-2: #d5dae3;
  --pri: #4f46e5; --pri-2: #6366f1; --pri-soft: #eef2ff; --pri-fg: #fff;
  --ok: #059669; --ok-soft: #ecfdf5;
  --err: #dc2626; --err-soft: #fef2f2;
  --warn: #b45309; --warn-soft: #fffbeb;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 2px 10px rgba(16,24,40,.04);
  --shadow-lg: 0 16px 48px rgba(16,24,40,.14);
  --radius: 14px; --radius-sm: 9px;
  --sidebar: 228px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14; --bg-2: #141922; --card: #151a23; --card-2: #1b212c;
    --fg: #e7eaf0; --fg-2: #c3c8d3; --muted: #8a93a3;
    --line: #242b37; --line-2: #333b49;
    --pri: #7c7af8; --pri-2: #9593fa; --pri-soft: #23244a;
    --ok: #34d399; --ok-soft: #0f2a21;
    --err: #f87171; --err-soft: #2d1618;
    --warn: #fbbf24; --warn-soft: #2b2110;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 16px rgba(0,0,0,.25);
    --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
  }
}

/* ========== 基础 ========== */
* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pri); text-decoration: none }
a:hover { text-decoration: underline }
code { font-family: var(--mono); font-size: 12.5px; background: var(--bg-2); padding: 1px 6px; border-radius: 5px }
.mono { font-family: var(--mono) }
.hidden { display: none !important }
.muted { color: var(--muted) }
.err { color: var(--err) }
.ok { color: var(--ok) }
.right { text-align: right }
.center { text-align: center }
.hint { font-size: 12.5px }
.icon { width: 17px; height: 17px; flex: none; vertical-align: -3px }

/* ========== 登录页 ========== */
.screen { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px; overflow: hidden }
.glow { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35; pointer-events: none }
.glow-a { width: 420px; height: 420px; background: var(--pri); top: -120px; left: -80px }
.glow-b { width: 380px; height: 380px; background: #a855f7; bottom: -140px; right: -60px }
.login { position: relative; width: 100%; max-width: 380px; padding: 32px 30px; box-shadow: var(--shadow-lg); text-align: center }
.login h1 { margin: 14px 0 4px; font-size: 26px; letter-spacing: -.02em }
.login p { margin: 0 0 18px }
.login label { text-align: left }
.login .link { display: inline-block; margin-top: 16px; font-size: 13px }
.login .err { margin: 10px 0 0; min-height: 1.4em }

/* ========== 外壳布局 ========== */
.shell { display: flex; min-height: 100vh }
.sidebar {
  width: var(--sidebar); flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 14px;
  background: var(--card); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 17px; letter-spacing: -.01em }
.brand .tag { font-size: 10.5px; font-weight: 600; color: var(--pri); background: var(--pri-soft); padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--pri), #a855f7); box-shadow: 0 4px 12px rgba(99,102,241,.35) }
.logo-mark.lg { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto }
.logo-mark.lg .icon { width: 26px; height: 26px }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0 }
.nav-label { padding: 14px 11px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--muted); opacity: .8 }
.nav-label:first-child { padding-top: 0 }
.sidebar nav a, .sidebar-foot a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--fg-2); font-weight: 500; transition: background .15s, color .15s;
}
.sidebar nav a:hover, .sidebar-foot a:hover { background: var(--bg-2); color: var(--fg); text-decoration: none }
.sidebar nav a.active { background: var(--pri-soft); color: var(--pri) }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px }
.sidebar-foot .identity { padding: 4px 11px 9px; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
main { flex: 1; min-width: 0; padding: 30px 36px 56px; max-width: 1500px }
.tab { display: none; animation: fade .18s ease }
.tab.active { display: block }
@keyframes fade { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 0 0 20px }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.015em }
.page-head p { margin: 3px 0 0; color: var(--muted) }
.page-actions { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap }
.quality-control { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); white-space: nowrap }
.quality-control select { width: auto; min-width: 132px; margin: 0 }
h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 28px 0 10px; font-weight: 600 }
h4.card-title, .card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14.5px; font-weight: 600 }
.card-title .icon { color: var(--pri) }

/* ========== 卡片 / 布局工具 ========== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow) }
.card + .card { margin-top: 12px }
.grid2 > .card, .stats > .card, .overview-stats > .card { margin-top: 0 }
.stack > * + * { margin-top: 12px }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 18px }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; padding: 12px 14px }
.toolbar input, .toolbar select { width: auto; min-width: 140px }
.toolbar input[type="checkbox"] { min-width: 0; flex: none }
.toolbar .grow { flex: 1; min-width: 200px }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px }
.stat { padding: 16px 18px; position: relative; overflow: hidden }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--pri), #a855f7) }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; word-break: break-all }
.stat .k { color: var(--muted); font-size: 12px; margin-top: 4px }
.kv { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 }
.kv .k { color: var(--muted); min-width: 80px; font-size: 13px }
.kv input { flex: 1; min-width: 200px }
.connect p { margin: 0 0 6px }
.connect .hint { margin: 12px 0 0; padding-top: 12px; border-top: 1px dashed var(--line) }

/* ========== 管理概览 ========== */
.health-hero { min-height: 116px; padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: radial-gradient(circle at 90% 10%, var(--pri-soft), transparent 42%), var(--card); overflow: hidden }
.health-hero > div:first-child { display: flex; align-items: center; gap: 14px }
.health-dot { width: 48px; height: 48px; border-radius: 16px; display: block; position: relative; background: var(--bg-2) }
.health-dot::after { content: ""; position: absolute; inset: 15px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 7px color-mix(in srgb, currentColor 16%, transparent) }
.health-dot.ok { color: var(--ok); background: var(--ok-soft) }
.health-dot.warn { color: var(--warn); background: var(--warn-soft) }
.health-dot.err { color: var(--err); background: var(--err-soft) }
.health-title { font-size: 21px; font-weight: 750; letter-spacing: -.02em }
.health-platforms { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 6px; max-width: 48% }
.health-platforms small { flex-basis: 100%; color: var(--muted); text-align: right; margin-top: 4px }
.overview-stats { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-top: 14px }
.overview-stat { padding: 17px 18px; box-shadow: none; position: relative }
.overview-stat::after { content: ""; position: absolute; right: 14px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--pri); opacity: .65 }
.overview-stat.tone-ok::after { background: var(--ok) }
.overview-stat.tone-warn::after { background: var(--warn) }
.overview-stat .k { color: var(--muted); font-size: 12px }
.overview-stat .v { font-size: 25px; font-weight: 750; margin: 2px 0; letter-spacing: -.025em }
.overview-stat .note { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 12px; margin-top: 14px }
.overview-card { margin: 0 !important; min-height: 170px }
.data-lines > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px }
.data-lines > div:last-child { border-bottom: 0 }
.data-lines span { color: var(--muted) }
.pending-mini { color: var(--warn) }
.overview-section { margin-top: 24px }
.overview-section h3 { margin: 0 }
.dash-source-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 10px; margin-top: 10px }
.dash-source { padding: 13px 15px; box-shadow: none; margin: 0 !important }
.dash-source > div:first-child { display: flex; align-items: center; gap: 8px; min-width: 0 }
.dash-source > div:nth-child(2) { margin-top: 6px; font-size: 12px }
.source-error { margin-top: 7px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

/* ========== 完整备份 ========== */
.backup-top-grid .form-card { display: flex; flex-direction: column }
.backup-top-grid .form-card button[type="submit"] { margin-top: auto; align-self: flex-start }
.pending-restore { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: var(--warn-soft); margin-bottom: 14px }
.pending-restore h4 { margin: 8px 0 2px; font-size: 16px }
.pending-restore p { margin: 3px 0 }
.backup-result { margin-bottom: 14px; color: var(--ok); background: var(--ok-soft) }
.backup-preview { display: flex; flex-direction: column; gap: 2px; min-height: 62px; margin-bottom: 12px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--card-2); font-size: 12.5px }
.backup-preview.ok { color: var(--ok); border-style: solid; border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-soft) }
.backup-preview span { color: var(--muted) }
.danger-confirm { color: var(--err); margin: 12px 0 14px }
#webdavForm { margin-top: 4px }
#webdavForm .section-title { margin-bottom: 12px }
#webdavForm .card-title { margin: 0 }
.secret-clear-row { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 8px 0 14px; color: var(--muted) }
#remoteBackupTable td:first-child { max-width: 420px; word-break: break-all }

/* ========== 表单 ========== */
label { display: block; margin: 0 0 12px; font-size: 13px; color: var(--fg-2); font-weight: 500 }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400 }
label small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 4px }
input, select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--card); color: var(--fg); font: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft) }
input::placeholder { color: var(--muted); opacity: .8 }
input[type="file"] { padding: 6px; font-size: 13px }
input[type="file"]::file-selector-button { border: 0; border-radius: 6px; padding: 5px 10px; margin-right: 10px; background: var(--bg-2); color: var(--fg); font: inherit; cursor: pointer }
input[type="number"] { -moz-appearance: textfield }
input[type="checkbox"] { accent-color: var(--pri); width: 16px; height: 16px; margin: 0 }
label.inline { display: inline-flex; align-items: center; gap: 7px; margin: 0; cursor: pointer }
label.inline input { width: auto; margin: 0 }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 20px }
.form-card input { margin-bottom: 10px }
.form-card button { margin-top: 2px }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px }

/* 榜单设置：平台独立展开，较长目录在组内滚动。 */
.board-settings-panel { padding: 0; margin-bottom: 18px; overflow: hidden }
.board-settings-panel > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 14px 18px; cursor: pointer; list-style: none }
.board-settings-panel > summary::-webkit-details-marker { display: none }
.board-settings-panel > summary > span { display: flex; align-items: center; gap: 8px; font-weight: 600 }
.board-settings-panel > summary .icon { color: var(--pri) }
.board-settings-panel > summary small { color: var(--muted) }
.board-settings-panel > summary::after { content: '展开'; margin-left: auto; color: var(--muted); font-size: 12px }
.board-settings-panel[open] > summary { border-bottom: 1px solid var(--line) }
.board-settings-panel[open] > summary::after { content: '收起' }
.board-settings-panel > form { padding: 14px 18px 18px }
.board-settings-panel > form > p:first-child { margin-top: 0 }
.board-settings-notice { display: flex; align-items: center; gap: 12px; padding: 14px 18px; color: var(--muted) }
.board-selections { display: grid; gap: 10px; margin: 12px 0 18px }
.board-platform { border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; overflow: hidden }
.board-platform > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; cursor: pointer; background: var(--card-2) }
.board-platform > summary strong::before { content: '▸'; display: inline-block; margin-right: 8px; color: var(--muted) }
.board-platform[open] > summary strong::before { content: '▾' }
.board-platform > summary::-webkit-details-marker { display: none }
.board-platform > summary span { text-align: right; font-size: 12px; color: var(--muted) }
.board-content { padding: 12px 14px }
.board-content > label { max-width: 320px; margin-bottom: 8px }
.board-content p { margin: 8px 0 }
.board-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 }
.board-actions .hint { margin-right: auto }
.board-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 4px; max-height: 270px; overflow-y: auto; overscroll-behavior: contain; padding: 4px; border: 1px solid var(--line); border-radius: 7px }
.board-options label { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 8px; border-radius: 5px; cursor: pointer; font-weight: 400; overflow-wrap: anywhere }
.board-options label:hover { background: var(--card-2) }
.board-options input { flex: none; margin-top: 3px }
.board-options small { margin-top: 1px }

/* 开关 */
label.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; margin: 0; border-top: 1px solid var(--line); cursor: pointer }
label.switch:first-of-type { border-top: 0 }
label.switch small { margin-top: 1px }
label.switch input {
  appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 999px; flex: none;
  background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; margin: 0;
}
label.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s }
label.switch input:checked { background: var(--pri) }
label.switch input:checked::after { transform: translateX(18px) }
label.switch input:focus-visible { box-shadow: 0 0 0 3px var(--pri-soft) }

/* ========== 按钮 ========== */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--pri); color: var(--pri-fg); font: inherit; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s;
}
button:hover, .btn:hover { background: var(--pri-2); text-decoration: none }
button:active { transform: translateY(1px) }
button:disabled { opacity: .5; cursor: not-allowed; transform: none }
button.sec, .btn.sec { background: var(--card); color: var(--fg-2); border-color: var(--line-2) }
button.sec:hover, .btn.sec:hover { background: var(--bg-2); color: var(--fg) }
button.ghost { background: transparent; color: var(--fg-2) }
button.ghost:hover { background: var(--bg-2) }
button.danger { background: var(--err-soft); color: var(--err) }
button.danger:hover { background: var(--err); color: #fff }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px }
button.sm .icon { width: 14px; height: 14px }
button.block { width: 100%; padding: 10px; margin-top: 6px }

/* ========== 表格 ========== */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow) }
.table-wrap.sm { margin-top: 10px; box-shadow: none; border-radius: var(--radius-sm) }
table { width: 100%; border-collapse: collapse }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--card-2); white-space: nowrap }
.table-wrap.sm th, .table-wrap.sm td { padding: 8px 12px; font-size: 13px }
tbody tr:last-child td { border-bottom: 0 }
tbody tr:hover td { background: var(--card-2) }
td.actions { text-align: right; white-space: nowrap }
td.actions button { margin-left: 4px }
td[colspan] { padding: 22px 14px; text-align: center; color: var(--muted) }

/* ========== 徽章 / 平台标签 ========== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--bg-2); color: var(--muted); vertical-align: middle }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85 }
.badge.ok { background: var(--ok-soft); color: var(--ok) }
.badge.err { background: var(--err-soft); color: var(--err) }
.badge.warn { background: var(--warn-soft); color: var(--warn) }
.badge.pri { background: var(--pri-soft); color: var(--pri) }
.badge.off { background: var(--bg-2); color: var(--muted) }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--bg-2); font-size: 12px; border: 1px solid transparent }
.chip b { font-weight: 600 }
.chip span { color: var(--muted); font-family: var(--mono); font-size: 11.5px }

/* ========== 通用：分段切换、图标按钮、下拉菜单、提示条 ========== */
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--bg-2); flex-wrap: wrap }
.segmented button { padding: 5px 12px; font-size: 12.5px; border-radius: 7px; background: transparent; color: var(--muted); border: 0 }
.segmented button:hover { background: transparent; color: var(--fg) }
.segmented button:is([aria-selected=true], [aria-pressed=true]) { background: var(--card); color: var(--fg); box-shadow: 0 1px 2px rgba(16,24,40,.1) }
@media (prefers-color-scheme: dark) {
  .segmented { background: var(--bg) }
  .segmented button:is([aria-selected=true], [aria-pressed=true]) { background: var(--line-2); box-shadow: none }
  .chip { background: var(--line) }
}
.segmented button b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted) }
.segmented button b:empty { display: none }
button.icon-only { width: 34px; height: 34px; padding: 0; flex: none }
button.icon-only.sm { width: 28px; height: 28px }
.menu { position: relative }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 160px; padding: 5px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); box-shadow: var(--shadow-lg); display: flex; flex-direction: column }
.menu-list[hidden] { display: none }
.menu-list > button, .menu-list > a { display: flex; align-items: center; justify-content: flex-start; gap: 9px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--fg-2); font-size: 13px; font-weight: 500; text-align: left }
.menu-list > :is(button, a):hover, .menu-list > :is(button, a):focus-visible { background: var(--bg-2); color: var(--fg); text-decoration: none; outline: none }
.menu-list .icon { width: 15px; height: 15px; color: var(--muted) }
.menu-list .menu-danger { color: var(--err); margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px }
.menu-list .menu-danger .icon { color: currentColor }
.menu-list .menu-danger:hover { background: var(--err-soft); color: var(--err) }
:is(#tab-debug > .note, .src .note) { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--card-2); border: 1px solid var(--line); color: var(--fg-2); font-size: 13px }
:is(#tab-debug > .note, .src .note).warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn) }
:is(#tab-debug > .note, .src .note).err { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 25%, transparent); color: var(--err) }
.empty { text-align: center; color: var(--muted); padding: 40px 16px }

/* ========== 音源：添加 ========== */
.source-add { padding: 14px 16px }
.source-add-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px }
.source-add-head .card-title { margin: 0 }
.source-add-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap }
.source-add-form > input { flex: 1 1 240px; min-width: 0; margin: 0 }
.source-add-form > input[name=name] { flex: 1 1 200px }
.source-add-form label.inline { color: var(--muted); font-size: 13px; font-weight: 400 }
.list-head { margin: 24px 2px 10px }
.list-head h3 { margin: 0 }
.list-head .count { margin-left: 4px; color: var(--muted); letter-spacing: 0 }

/* ========== 音源：卡片 ========== */
.source-list { display: flex; flex-direction: column; gap: 10px }
.source-list > .card { margin: 0 }
.src { padding: 0; overflow: visible }
.src-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 0 }
.src-main { min-width: 0 }
.src-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; font-weight: 600 }
.src-name { overflow-wrap: anywhere }
.src-title .ver:empty { display: none }
.src-title .ver { color: var(--muted); font-weight: 400; font-size: 12px; font-family: var(--mono) }
.src .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow-wrap: anywhere }
.src .meta:empty { display: none }
.src-actions { display: flex; align-items: center; gap: 6px; flex: none }
.src-body { display: flex; align-items: center; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; padding: 10px 16px 12px }
.src-body .chips { margin: 0 }
.src-health { font-size: 12.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; cursor: default }
.src-health b { font-weight: 600 }
#tab-sources .src .note { margin: 0 16px 10px; padding: 7px 12px }
.source-update { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; padding: 7px 10px 7px 16px; border-top: 1px solid var(--line); background: var(--card-2); border-radius: 0 0 var(--radius) var(--radius); font-size: 12.5px }
.source-update-state { min-width: 0 }
.source-update-line { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; color: var(--fg-2) }
.source-update-line .muted { cursor: default }
.source-update-state p { margin: 4px 0 0 }
.source-update-actions { display: flex; gap: 2px }
.source-update-actions button { color: var(--pri) }
.source-update-actions button:hover:not(:disabled) { background: var(--pri-soft) }
.src-test:empty { display: none }
.src-test { padding: 10px 16px 12px; border-top: 1px solid var(--line) }
.src-test-head { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--fg-2) }
.src-test .table-wrap.sm { margin-top: 6px }
.src-logs { padding: 8px 16px 10px; border-top: 1px solid var(--line) }
.src-logs summary { color: var(--muted); font-size: 12.5px }
.src-logs pre { margin: 8px 0 0; max-height: 260px; padding: 10px 12px; font: 12px/1.6 var(--mono); background: var(--card-2); color: var(--fg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: auto; white-space: pre-wrap }

/* ========== 音源：调用统计 ========== */
.source-statistics { margin-top: 24px; min-width: 0 }
.source-stats-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap }
.source-stats-head .card-title { margin: 0 }
.source-stats-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0 }
.source-stats-filters select { width: auto; max-width: 200px; margin: 0; padding: 6px 10px }
#sourceStatsStatus { margin: 6px 0 0 }
.source-call-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0 18px }
.source-call-metric { border-radius: var(--radius-sm); padding: 12px 14px; min-width: 0; background: var(--card-2); border: 1px solid var(--line) }
.source-call-metric > span, .source-call-metric > small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.source-call-metric strong { display: block; font-size: 22px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; letter-spacing: -.02em }
.source-call-metric strong.warn { color: var(--warn) }
.source-stats-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px }
.source-call-legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted) }
.source-call-legend span { display: inline-flex; align-items: center; gap: 5px }
.source-call-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--ok) }
.source-call-legend .failed { background: var(--err) }
.source-call-legend .cancelled { background: var(--muted) }
.source-call-trend { display: flex; gap: 4px; align-items: flex-end; height: 88px; border-bottom: 1px solid var(--line); margin-top: 10px }
button.source-call-bar { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 3px 3px 0 0; background: transparent; display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 0; position: relative; overflow: hidden }
button.source-call-bar:hover, button.source-call-bar:focus-visible { background: var(--bg-2); box-shadow: none; outline: none }
.source-call-bar i { display: block; width: 100%; background: var(--ok); pointer-events: none; min-height: 0; opacity: .85 }
.source-call-bar:hover i { opacity: 1 }
.source-call-bar i.failed { background: var(--err) }
.source-call-bar i.cancelled { background: var(--muted) }
.source-call-bar.empty-bar::after { content: ''; position: absolute; bottom: 0; width: 100%; height: 2px; background: var(--line) }
.source-call-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 5px }
.source-call-period { display: block; color: var(--muted); font-size: 12px; min-height: 20px; margin: 4px 0 12px }
.source-statistics .table-wrap { box-shadow: none; margin: 8px 0 12px; max-width: 100%; border-radius: var(--radius-sm) }
.source-statistics table { font-size: 13px; min-width: 660px }
.source-statistics th, .source-statistics td { padding: 9px 12px }
.source-statistics th { white-space: nowrap }
.source-statistics td { font-variant-numeric: tabular-nums; white-space: nowrap }
.source-statistics .badge { white-space: nowrap }
.source-statistics .source-call-name { text-align: left; min-width: 120px; max-width: 240px; white-space: normal; overflow-wrap: anywhere; justify-content: flex-start; padding: 2px 6px; margin-left: -6px; color: var(--pri) }
.source-statistics details { border-top: 1px solid var(--line); padding: 11px 0 0; margin-top: 11px }
.source-statistics summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--fg-2) }
.source-statistics .source-stats-help summary { font-weight: 500; color: var(--muted); font-size: 12.5px }
.source-stats-help p { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 8px 0 0 }
.source-call-recent { max-height: 360px; overflow: auto }
.source-call-recent table { min-width: 860px }
.source-call-recent .call-song { max-width: 200px; overflow-wrap: anywhere; white-space: normal }
.source-call-recent .call-song small { display: block; color: var(--muted) }
.source-call-errors { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px }
.dash-source .source-call-mini { font-size: 12px; margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap }
@media (max-width: 600px) {
  .source-stats-filters { width: 100%; flex-wrap: nowrap }
  .source-stats-filters select { flex: 1; min-width: 0; max-width: none }
  .source-call-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px }
  .source-call-metric { padding: 10px }
  .source-call-metric strong { font-size: 20px }
  .source-call-trend { gap: 2px }
  .src-head { flex-direction: column; gap: 10px }
  .src-actions { width: 100% }
  .src-actions > button { flex: 1 }
  .source-add-form > button { flex: 1 }
}

/* ========== 日志 ========== */
.log-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden }
.log-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--line) }
.log-toolbar input { width: 240px; max-width: 100%; margin: 0; padding: 6px 10px }
.logbox { padding: 6px 0; max-height: calc(100vh - 230px); min-height: 240px; overflow: auto; font: 12.5px/1.65 var(--mono); color: var(--fg-2) }
.log-line { display: grid; grid-template-columns: 118px 58px minmax(0, 1fr); gap: 12px; padding: 2px 14px; white-space: pre-wrap; word-break: break-word; border-left: 2px solid transparent }
.log-line:hover { background: var(--card-2) }
.log-line .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap }
.log-line .lv { font-weight: 600; font-size: 11.5px; color: var(--muted) }
.log-line.lv-info .lv { color: var(--pri) }
.log-line.lv-warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-soft) 60%, transparent) }
.log-line.lv-warn .lv { color: var(--warn) }
.log-line.lv-error { border-left-color: var(--err); background: color-mix(in srgb, var(--err-soft) 70%, transparent) }
.log-line.lv-error .lv, .log-line.lv-error .m { color: var(--err) }
.log-line.lv-debug .lv, .log-line.lv-debug .m { color: var(--muted) }

/* ========== API 调试 ========== */
.debug-create { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: end; margin-bottom: 16px }
.debug-create > p, .debug-create > button { grid-column: 1 / -1 }
.debug-create > p { margin: 0 0 12px; font-size: 12.5px }
.debug-create > button { justify-self: start }
#debugSecret { margin-bottom: 16px }
#debugSecret h3 { margin: 0 0 12px; color: var(--warn) }
#debugTokenList { display: grid; gap: 10px }
#debugTokenList > .card { margin: 0 }
.debug-token { padding: 12px 16px }
.debug-token-head { display: flex; align-items: center; gap: 10px }
.debug-token-head b { overflow-wrap: anywhere; font-size: 13px }
.debug-token-head button { margin-left: auto }
.debug-token-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 16px; margin: 10px 0 0; font-size: 12.5px }
.debug-token-meta dt { color: var(--muted); font-size: 11.5px }
.debug-token-meta dd { margin: 0; color: var(--fg-2); overflow-wrap: anywhere }
@media (max-width: 600px) { .debug-create { grid-template-columns: 1fr } }

/* ========== 对话框 / 提示 ========== */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--fg); padding: 0; box-shadow: var(--shadow-lg); width: min(420px, calc(100vw - 32px)) }
dialog::backdrop { background: rgba(15,23,42,.45); backdrop-filter: blur(2px) }
.dialog-form { padding: 22px 24px }
.dialog-form h3 { margin: 0 0 16px; font-size: 16px; color: var(--fg); text-transform: none; letter-spacing: 0 }
.dialog-form p { margin: 0 0 12px }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: calc(100vw - 32px); animation: rise .2s ease }
.toast.err { background: var(--err) }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px) } to { opacity: 1; transform: translate(-50%, 0) } }

/* ========== 响应式 ========== */
@media (max-width: 820px) {
  .shell { flex-direction: column }
  .sidebar { width: auto; height: auto; flex-direction: row; align-items: center; gap: 4px; padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); z-index: 10 }
  .brand { padding: 0 10px 0 2px; font-size: 15px }
  .brand .tag { display: none }
  .logo-mark { width: 28px; height: 28px; border-radius: 8px }
  .sidebar nav { flex-direction: row; gap: 2px; overflow: visible }
  .nav-label { display: none }
  .sidebar nav a, .sidebar-foot a { padding: 7px 9px; white-space: nowrap; gap: 6px }
  .sidebar-foot { margin-top: 0; margin-left: auto; padding-top: 0; border-top: 0; flex-direction: row }
  .sidebar-foot a span { display: none }
  main { padding: 18px 14px 40px }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px }
  .toolbar input, .toolbar select { flex: 1; min-width: 120px }
  .log-line { grid-template-columns: auto minmax(0, 1fr); gap: 0 10px; padding: 4px 12px }
  .log-line .m { grid-column: 1 / -1 }
  .log-line .t { font-size: 11px }
  .log-toolbar input { width: 100% }
  .sidebar-foot .identity { display: none }
  .overview-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .overview-grid { grid-template-columns: 1fr }
  .health-hero { align-items: flex-start; flex-direction: column }
  .health-platforms { max-width: none; justify-content: flex-start }
  .health-platforms small { text-align: left }
}

/* ========== 统一歌单面板 ========== */
.playlist-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; align-items: start }
.playlist-pane { min-width: 0; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; padding-right: 2px }
.playlist-content { min-width: 0 }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px }
.section-title h2 { margin: 0; font-size: 18px; letter-spacing: -.01em }
.detail-head { margin-bottom: 14px; align-items: flex-start }
.detail-head h2 { font-size: 22px }
.detail-head .muted { font-size: 12.5px; margin-top: 2px }
.playlist-empty { text-align: center; color: var(--fg-2); padding: 80px 16px; font-size: 15px }
.icon.big { width: 40px; height: 40px; color: var(--line-2); margin-bottom: 10px }
.notice { display: flex; align-items: center; gap: 8px; color: var(--warn); background: var(--warn-soft); margin: 12px 0; padding: 12px 16px; box-shadow: none }
.count { font-weight: 400; font-size: 13px }

.playlist-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 }
.playlist-list .card { padding: 22px 12px; text-align: center; box-shadow: none }
.playlist-item { width: 100%; display: block; text-align: left; background: var(--card); color: var(--fg); border: 1px solid var(--line); padding: 11px 13px; border-radius: var(--radius-sm); transition: border-color .15s, background .15s, transform .05s }
.playlist-item:hover { background: var(--card-2); color: var(--fg); border-color: var(--line-2) }
.playlist-item.active { border-color: var(--pri); background: var(--pri-soft); box-shadow: inset 3px 0 0 var(--pri) }
.playlist-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0 }
.playlist-name > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.playlist-meta { display: flex; gap: 8px; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 400 }
.badge.public { background: var(--ok-soft); color: var(--ok) }
.create-card { margin-top: 14px !important; padding: 0; overflow: hidden }
.create-card summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; padding: 13px 16px; list-style: none; user-select: none }
.create-card summary::-webkit-details-marker { display: none }
.create-card summary .icon { color: var(--pri) }
.create-card[open] summary { border-bottom: 1px solid var(--line) }
.create-card form { padding: 14px 16px 16px }
.import-lists { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 12px; max-height: 220px; overflow: auto }
.import-lists label { display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 500 }
.import-lists label:last-child { border-bottom: 0 }
.import-lists input { width: 16px; height: 16px; margin: 0; accent-color: var(--pri); flex: none }
.import-lists .import-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.import-lists .import-meta { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap }
.import-lists .err { padding: 10px; margin: 0 }

.meta-grid { margin: 0 0 12px; display: grid; grid-template-columns: minmax(200px, 1fr) auto; gap: 0 20px; align-items: end }
.meta-grid .wide { grid-column: 1 / -1 }
.meta-grid .switch { margin: 0 0 4px }
.meta-grid .actions { margin-bottom: 4px }
.playlist-search-card { margin-top: 12px !important }
.search-row { display: grid; grid-template-columns: minmax(180px, 1fr) 140px auto; gap: 8px }
.search-row input, .search-row select { margin: 0 }
#searchResults > p { margin: 12px 0 0 }
.search-results { margin-top: 12px; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm) }
.search-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line) }
.search-item:last-child { border-bottom: 0 }
.search-item:hover { background: var(--card-2) }
.search-item button { padding: 5px 12px; font-size: 12.5px; border-radius: 7px }
.song-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.song-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.tracks-card { margin-top: 12px !important }
.tracks-card .card-title { margin-bottom: 0 }
.track-tip { margin-top: 2px }
.playlist-table-wrap { margin-top: 12px; box-shadow: none; border-radius: var(--radius-sm) }
#playlistTrackTable { table-layout: fixed }
#playlistTrackTable th.num, #playlistTrackTable td:first-child { width: 44px; color: var(--muted); text-align: center }
#playlistTrackTable th:nth-child(2) { width: 38% }
#playlistTrackTable th:nth-child(3) { width: 20% }
#playlistTrackTable th:nth-child(5) { width: 84px }
#playlistTrackTable th.track-actions { width: 104px }
#playlistTrackTable td:nth-child(2), #playlistTrackTable td:nth-child(3), #playlistTrackTable td:nth-child(4) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.track-row[draggable=true] { cursor: grab }
.track-row.dragging { opacity: .4 }
.track-row.drag-over td { box-shadow: inset 0 2px 0 var(--pri) }
.track-actions { white-space: nowrap; text-align: right }
.track-actions button { padding: 4px; width: 28px; height: 28px; margin-left: 2px; background: transparent; color: var(--fg-2); border-radius: 7px }
.track-actions button .icon { width: 15px; height: 15px }
.track-actions button:hover { background: var(--bg-2); color: var(--fg) }
.track-actions button.remove:hover { background: var(--err-soft); color: var(--err) }
.unavailable .song-title { color: var(--err) }
.unavailable .song-sub { color: var(--err); opacity: .7 }

@media (max-width: 1000px) {
  .playlist-layout { grid-template-columns: 1fr; gap: 16px }
  .playlist-pane { position: static; max-height: none }
  .playlist-list { max-height: 320px; overflow: auto }
  .playlist-empty { padding: 44px 16px }
}
@media (max-width: 600px) {
  .overview-stats { grid-template-columns: 1fr }
  .health-hero { padding: 18px }
  .pending-restore { flex-direction: column }
  #remoteBackupTable th:nth-child(2), #remoteBackupTable td:nth-child(2) { display: none }
  .meta-grid { grid-template-columns: 1fr }
  .search-row { grid-template-columns: 1fr }
  .detail-head { flex-direction: column; align-items: stretch }
  .detail-head h2 { font-size: 19px }
  #playlistTrackTable th:nth-child(4), #playlistTrackTable td:nth-child(4) { display: none }
  #playlistTrackTable th, #playlistTrackTable td { padding: 9px 7px }
  #playlistTrackTable th:nth-child(2) { width: auto }
  #playlistTrackTable th:nth-child(3) { width: 72px }
  #playlistTrackTable th:nth-child(5) { width: 64px }
  #playlistTrackTable th.track-actions { width: 84px }
  .track-actions button { width: 26px; height: 26px; margin-left: 0 }
  .section-title { align-items: flex-start }
}

/* ========== 搜歌与全局播放器 ========== */
#searchTable { table-layout: fixed; min-width: 820px }
#searchTable th:first-child { width: 24% }
#searchTable th:nth-child(2) { width: 16% }
#searchTable th:nth-child(4) { width: 98px }
#searchTable th.song-duration { width: 70px }
#searchTable th.song-quality { width: 112px }
#searchTable th:last-child { width: 168px }
#searchTable td { overflow: hidden; text-overflow: ellipsis }
#searchTable td:nth-child(2), #searchTable .badge { white-space: nowrap }
.song-actions { text-align: right; white-space: nowrap }
.song-actions button { vertical-align: middle }
.song-actions button + button { margin-left: 4px }
.search-item-actions { display: flex; align-items: center; gap: 6px }
.now-playing td, tbody tr.now-playing:hover td, .search-item.now-playing { background: var(--pri-soft) }
.now-playing .song-title { color: var(--pri) }
#playlistTrackTable th.track-actions { width: 138px }
button:focus-visible { outline: 2px solid var(--pri); outline-offset: 3px }

.player-bar {
  position: fixed; z-index: 30; left: var(--sidebar); right: 0; bottom: 0;
  display: grid; grid-template-columns: minmax(120px, 1fr) minmax(230px, 1.7fr) auto;
  align-items: center; gap: 14px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: var(--card); box-shadow: 0 -5px 24px rgba(16,24,40,.08);
}
#webAudio { display: none }
.player-info, .player-main { min-width: 0 }
.player-status { color: var(--muted); font-size: 11.5px; line-height: 1.45; margin-top: 3px; overflow-wrap: anywhere }
.player-status.err { color: var(--err) }
.player-buttons { display: flex; align-items: center; justify-content: center; gap: 7px }
.player-buttons button { width: 34px; height: 34px; padding: 6px; border-radius: 50% }
#playerPosition { min-width: 36px }
.player-progress { display: flex; align-items: center; gap: 10px; margin-top: 6px }
.player-bar input[type=range] { padding: 0; border: 0; border-radius: 0; height: 20px; box-shadow: none; accent-color: var(--pri); cursor: pointer; min-width: 0 }
.player-bar input[type=range]:focus-visible { outline: 2px solid var(--pri); outline-offset: 3px }
.player-bar input[type=range]:disabled { opacity: .4; cursor: default }
#playerSeek { flex: 1; width: 100% }
#playerTime { font-size: 11px; white-space: nowrap; color: var(--muted) }
.player-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end }
.player-volume { display: flex; gap: 4px; align-items: center }
#playerVolume { width: 78px }
#playerMute[aria-pressed=true] { color: var(--err) }
.has-player main { padding-bottom: calc(var(--player-height, 140px) + 24px) }
.has-player .playlist-pane { max-height: calc(100vh - var(--player-height, 140px) - 40px) }
.has-player .toast { bottom: calc(var(--player-height, 140px) + 16px) }
#collectSong { white-space: normal; overflow-wrap: anywhere }
#collectError:empty { display: none }
#collectHint.warn { color: var(--warn) }
@media (max-width: 1000px) {
  .has-player .playlist-pane { max-height: none }
}
@media (max-width: 820px) {
  .player-bar { left: 0; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)) }
  .player-main { grid-column: 1 / -1; grid-row: 2 }
  .player-actions { grid-column: 2; grid-row: 1 }
  .player-progress { margin-top: 3px }
}
@media (max-width: 600px) {
  #searchTable { min-width: 0 }
  #searchTable th, #searchTable td { padding: 9px 7px }
  #searchTable .song-album, #searchTable .song-duration, #searchTable .song-quality { display: none }
  #searchTable th:first-child { width: auto }
  #searchTable th:nth-child(2) { width: 66px }
  #searchTable th:nth-child(4) { width: 72px }
  #searchTable th:last-child { width: 114px }
  #searchTable .badge { padding: 2px 5px; font-size: 10px }
  #playlistTrackTable th.track-actions { width: 118px }
  #playlistTrackTable th.num, #playlistTrackTable td:first-child { width: 32px }
  .search-item { gap: 6px; padding: 9px 8px }
  .search-item-actions button { font-size: 11px; padding: 5px 7px }
}

.playback-list { max-height: 55vh; overflow: auto; min-width: 0 }
.queue-entry { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px; border-bottom: 1px solid var(--line) }
.queue-song { display: block; flex: 1; text-align: left; min-width: 0; white-space: normal; overflow-wrap: anywhere }
.queue-entry > .actions { flex: 0 0 84px; white-space: normal }
.queue-entry > div:first-child { min-width: 0; overflow-wrap: anywhere }
.queue-entry.now-playing { background: var(--pri-soft) }
.queue-song small, .lyric-line small { display: block; color: var(--muted); font-size: .8em }
.lyric-line { display: block; width: 100%; padding: 14px 8px; text-align: center; white-space: normal }
.lyric-line[aria-current=true] { color: var(--pri); font-weight: 700; background: var(--bg) }
#playerShuffle[aria-pressed=true] { font-weight: bold; outline: 2px solid currentColor }
.player-actions { flex-wrap: wrap }
.player-actions select { width: auto; max-width: 110px; padding: 6px }
#keyList { max-height: 32vh; overflow: auto }
@media(max-width:600px) { .queue-entry { flex-wrap: wrap } .player-actions { justify-content: center } }

.player-actions { flex-direction: row; flex-wrap: wrap; max-width: 230px; justify-content: flex-end; align-items: center }
#searchTable tr, #playlistTrackTable tr { scroll-margin-bottom: calc(var(--player-height, 140px) + 24px) }
html { scroll-padding-bottom: calc(var(--player-height, 0px) + 24px) }
.track-actions [data-track-action=repair] { width: auto; min-width: 32px; font-size: 11px; padding: 2px }
#playlistTrackTable th.track-actions { width: 196px }
#playlistTrackTable td.track-actions { white-space: normal }
@media(max-width:600px) {
  #playlistTrackTable th.track-actions { width: 118px }
  .player-actions { max-width: 180px; gap: 4px }
}

/* ========== 通用细节：按钮组间距、折叠面板与图标按钮 ========== */
:not(td).actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px }
button.icon-btn { width: 32px; height: 32px; padding: 0; border-radius: 8px; background: transparent; color: var(--fg-2); border-color: transparent }
button.icon-btn:hover { background: var(--bg-2); color: var(--fg) }
button.icon-btn.play { color: var(--pri) }
button.icon-btn.play:hover { background: var(--pri-soft); color: var(--pri) }
button.icon-btn .icon { width: 16px; height: 16px }
.song-actions .collect .icon { width: 13px; height: 13px }
#searchTable td.song-actions { overflow: visible; text-overflow: clip }
:is(details.card:not(.board-settings-panel, .create-card, .recent-playback, .smart-panel), .client-faq details, #settingsForm details, .source-statistics details, .src-logs) > summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; user-select: none }
:is(details.card:not(.board-settings-panel, .create-card, .recent-playback, .smart-panel), .client-faq details, #settingsForm details, .source-statistics details, .src-logs) > summary::-webkit-details-marker { display: none }
:is(details.card:not(.board-settings-panel, .create-card, .recent-playback, .smart-panel), .client-faq details, #settingsForm details, .source-statistics details, .src-logs) > summary::before { content: ""; flex: none; width: 6px; height: 6px; margin: 0 3px 0 1px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); opacity: .6; transition: transform .15s }
:is(details.card:not(.board-settings-panel, .create-card, .recent-playback, .smart-panel), .client-faq details, #settingsForm details, .source-statistics details, .src-logs)[open] > summary::before { transform: rotate(45deg) translate(-1px, -1px) }
#settingsForm details > summary { color: var(--fg-2); font-size: 13px; font-weight: 500 }

/* 搜歌：智能歌单折叠面板、搜索栏与分页按钮 */
.smart-panel { padding: 0; overflow: hidden }
.smart-panel > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; padding: 13px 18px; cursor: pointer; list-style: none; user-select: none }
.smart-panel > summary::-webkit-details-marker { display: none }
.smart-panel > summary > span { display: flex; align-items: center; gap: 8px; font-weight: 600 }
.smart-panel > summary .icon { color: var(--warn) }
.smart-panel > summary small { color: var(--muted); font-size: 12px }
.smart-panel > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(45deg); transition: transform .15s }
.smart-panel[open] > summary::after { transform: rotate(-135deg) }
.smart-panel[open] > summary { border-bottom: 1px solid var(--line) }
.smart-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 12px 18px 16px }
.smart-body > p { grid-column: 1 / -1; margin: 0 0 4px }
#songSearchForm { margin-top: 12px; padding: 10px 12px }
#songSearchStatus { margin: 4px 2px 8px }
#searchPaging { margin-bottom: 10px; gap: 6px }
#searchPaging:empty { display: none }
#searchPaging button { color: var(--pri); background: var(--pri-soft) }
#searchPaging button:hover:not(:disabled) { background: var(--pri); color: var(--pri-fg) }

/* 设置：保存按钮跟随滚动，长表单底部无需来回查找 */
#settingsForm .form-actions { position: sticky; bottom: 12px; z-index: 5; margin-top: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(6px); box-shadow: var(--shadow-lg) }
.has-player #settingsForm .form-actions { bottom: calc(var(--player-height, 140px) + 12px) }
#settingsForm + .card { margin-top: 18px }

@media (max-width: 600px) {
  #songSearchForm { display: grid; grid-template-columns: minmax(0, 1fr) auto }
  #songSearchForm input { grid-column: 1 / -1; min-width: 0 }
  #songSearchForm select { min-width: 0 }
  .song-actions .collect span { display: none }
  .song-actions .collect { width: 30px; height: 30px; padding: 0 }
  .song-actions .collect .icon { width: 15px; height: 15px }
  button.icon-btn { width: 30px; height: 30px }
  .song-actions button + button { margin-left: 1px }
  .smart-body { grid-template-columns: 1fr; padding: 12px 14px 14px }
  .smart-panel > summary { padding: 12px 14px }
}
.queue-entry > .actions { flex: none; flex-wrap: nowrap; gap: 4px }
#tab-sources .src-test .note { margin: 6px 0 0 }
