:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel2: #f2f4f7;
  --line: #e5e8ec;
  --line-strong: #d3d8de;
  --text: #1c2126;
  --muted: #6d7680;
  --accent: #1f6feb;
  --accent-weak: #eaf1fd;
  --danger: #c9352b;
  --ok: #1a7f37;
  --surface: #fafbfc;
  --surface2: #fbfcfd;
  --warn-bg: #fff9e8;
  --mono: "Cascadia Mono", "Consolas", "Courier New", monospace;
  --radius: 8px;
}
/* ---------- 深色主题 ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171b;
  --panel: #1b1f24;
  --panel2: #23282f;
  --line: #2b3138;
  --line-strong: #3a424b;
  --text: #d9dee4;
  --muted: #8b959f;
  --accent: #4d8dff;
  --accent-weak: #1a2740;
  --danger: #ff6b5e;
  --ok: #46c46a;
  --surface: #1a1e23;
  --surface2: #1e2228;
  --warn-bg: #33291a;
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] .top { background: var(--panel); border-bottom-color: var(--line); }
html[data-theme="dark"] .badge { background: var(--panel2); border-color: var(--line); }
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel { background: var(--panel); border-color: var(--line); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: var(--panel2); color: var(--text); border-color: var(--line-strong); }
html[data-theme="dark"] .bgmBtn.on { color: #fff; }
html[data-theme="dark"] .bgmBtn.on:hover:not(:disabled) { background: #3d7ae0; border-color: #3d7ae0; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 13.5px/1.6 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* 顶部 */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 17px; font-weight: 600; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.headerRight { display: flex; gap: 10px; align-items: center; }
.badge {
  font: 11.5px var(--mono); color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px;
}
.bgmBtn { font: 12px var(--mono); padding: 5px 12px; border-radius: 999px; }
.bgmBtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.bgmBtn.on:hover:not(:disabled) { background: #1a5fd0; border-color: #1a5fd0; color: #fff; }
.themeBtn {
  width: 30px; height: 30px; padding: 0; border-radius: 999px;
  font-size: 15px; line-height: 1; cursor: pointer;
  color: var(--text); background: var(--panel); border: 1px solid var(--line-strong);
}
.themeBtn:hover { border-color: var(--accent); color: var(--accent); }
.bgmBtn.off { color: var(--muted); }

/* 导入 / 音乐创建 模式切换 */
.modeSwitch { display: inline-flex; gap: 2px; padding: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; }
.modeBtn { border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 12px; font-size: 12px; }
.modeBtn:hover:not(:disabled) { background: var(--panel2); border-color: transparent; color: var(--text); }
.modeBtn.active { background: var(--panel); border-color: var(--line); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }

/* 卡片 */
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 20px 44px; display: grid; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.card h2 { margin: 0 0 12px; font-size: 13.5px; font-weight: 600; color: var(--text); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.info { font: 12px/1.6 var(--mono); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.info.inline { white-space: nowrap; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
.warn {
  color: #7a5300; background: var(--warn-bg); border: 1px solid #f0dfb0;
  padding: 8px 11px; border-radius: 6px; font-size: 12px; margin: 8px 0; white-space: pre-wrap;
}
.warn.hidden { display: none; }

/* 控件 */
button, .fileBtn {
  appearance: none; background: var(--panel); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 6px 12px; font-size: 12.5px; font-family: inherit; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled), .fileBtn:hover { background: var(--panel2); border-color: #b9c0c8; }
button:active:not(:disabled) { background: #e9ecf1; }
button:disabled { color: #a6adb6; background: var(--surface); border-color: var(--line); cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #1a5fd0; border-color: #1a5fd0; }
button.primary:disabled { background: var(--accent-weak); border-color: #cfe0fb; color: #85a4cd; }
button.danger { color: var(--danger); border-color: #edc6c2; }
button.danger:hover:not(:disabled) { background: #fdf3f2; border-color: #dfa9a3; }
.fileBtn { position: relative; overflow: hidden; display: inline-block; }
.fileBtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.search {
  flex: 1 1 220px; min-width: 180px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 10px; font: 12px var(--mono);
}
select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 6px 8px; font-size: 12.5px;
}
.search:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 111, 235, .14); }
.sel { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
input[type=checkbox], input[type=range] { accent-color: var(--accent); }

/* 模式切换 */
.modeTabs { display: flex; gap: 4px; margin-bottom: 12px; background: var(--panel2); padding: 3px; border-radius: 8px; width: max-content; }
.modeTab { border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 14px; color: var(--muted); }
.modeTab:hover:not(:disabled) { background: var(--panel2); border-color: transparent; color: var(--text); }
.modeTab.active { background: var(--panel); border-color: var(--line); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }

/* 曲目表 */
.tableWrap { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font: 12px var(--mono); }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; font-size: 11.5px; z-index: 1; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9fc; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.sel { display: table-row; background: var(--accent-weak); box-shadow: inset 2px 0 0 var(--accent); }
tbody tr.empty td { color: var(--muted); }
td.num { color: var(--muted); }
.tag {
  display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 999px;
  margin-right: 4px; color: var(--muted); font-size: 10.5px; line-height: 1.65; background: var(--surface);
}
td button { padding: 3px 10px; font-size: 12px; }
.badge-ok { color: var(--ok); border-color: #b7e0c3; background: #f2fbf5; }
.badge-warn { color: #7a5300; border-color: #f0dfb0; background: var(--warn-bg); }
.detail {
  margin-top: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; font: 12px/1.7 var(--mono); white-space: pre-wrap;
  /* E0/E2 那种一长串 JSON 没有空格，默认不会断行 → 撑出横向滚动条。这里强制可断。 */
  overflow-wrap: anywhere; word-break: break-word; max-width: 100%;
}

/* 目标槽 */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; padding-right: 6px; }
.slot {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px;
  background: var(--panel); cursor: pointer;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.slot:hover { border-color: #b9c0c8; box-shadow: 0 1px 3px rgba(16, 24, 40, .06); }
.slot.sel { display: block; border-color: var(--accent); background: var(--accent-weak); box-shadow: 0 0 0 1px var(--accent); }
.slot .code { font: 600 14px var(--mono); color: var(--text); }
.slot .page { font: 11px var(--mono); color: var(--muted); }
.slot .state { font-size: 11px; margin-top: 4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .state.on { color: var(--ok); }
.slot.sel .code { color: #144a9e; }
.bar { height: 4px; background: #eceff3; border-radius: 999px; overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; border-radius: 999px; }
.slotTools { margin-top: 10px; }
.importBar { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.occ { font: 12px var(--mono); color: var(--muted); flex: 1 1 300px; }
.occ b { color: var(--text); }

/* 备份 */
.backups { margin-top: 10px; display: grid; gap: 6px; }
.backup {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px 10px; font: 12px var(--mono);
}
.backup .t { color: var(--muted); }
.backup .grow { flex: 1; }

/* 播放条 */
audio { width: 100%; margin-top: 10px; }
.playerBar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.playerProgress { flex: 1; height: 4px; background: #eceff3; border-radius: 999px; overflow: hidden; min-width: 120px; }
#playerFill { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; border-radius: 999px; }
.playerVol { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.playerVol input { width: 90px; }

/* 忙碌 / 日志 */
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid #e5e8ec;
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busyOverlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 28, 38, .26); backdrop-filter: blur(2px); pointer-events: none;
}
.busyOverlay.hidden { display: none; }
.busyBox {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .18); color: var(--text); font: 12.5px/1.5 var(--mono);
}
.busyBox .spinner { width: 18px; height: 18px; }
.log {
  max-height: 180px; overflow: auto; margin: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px;
  font: 11px/1.55 var(--mono); color: #4b5563; white-space: pre-wrap;
}

/* 完整数据弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(20, 28, 38, .38); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal.hidden { display: none; }
.modalBox {
  width: min(1100px, 96vw); height: min(86vh, 900px); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(16, 24, 40, .22);
}
.modalHead {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.modalHead h3 { margin: 0; font-size: 14px; font-weight: 600; }
.dump { flex: 1; overflow: auto; margin: 0; padding: 12px 16px; background: var(--surface); color: var(--text); font: 12px/1.55 var(--mono); white-space: pre; }
.dumpTree { flex: 1; overflow: auto; padding: 6px 16px 14px; background: var(--surface); font: 12px/1.55 var(--mono); }
.dumpIntro { margin: 6px 0 10px; white-space: pre; color: var(--muted); }
.dumpSec { border-top: 1px solid var(--line); }
.dumpSec > summary {
  position: sticky; top: 0; z-index: 2; background: var(--surface); color: var(--text);
  padding: 7px 4px; cursor: pointer; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; user-select: none;
}
.dumpSec[open] > summary { border-bottom: 1px solid var(--line); }
.dumpBody { margin: 0; padding: 6px 4px 10px 20px; white-space: pre; color: #374151; }
.dumpSub { margin: 6px 0 0 0; }
.dumpSub > summary { color: var(--accent); padding: 4px 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.dumpSub .dumpBody { padding-left: 16px; }

/* BGM 曲目选择 */
.bgmSel {
  max-width: 160px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 12px; padding: 0 6px;
}

/* 悬浮播放条：导入模式下不用滚到底部就能暂停/停止 */
.floatPlayer {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  background: rgba(17, 24, 39, .92); color: #fff; border-radius: 999px;
  padding: 8px 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  font-size: 12px; max-width: min(92vw, 560px);
}
.floatPlayer.hidden { display: none; }
.floatTag { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .92; }
.floatTime { font-variant-numeric: tabular-nums; opacity: .75; }
.floatBtn {
  border: 0; border-radius: 999px; padding: 4px 10px; font-size: 12px;
  background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer;
}
.floatBtn:hover { background: rgba(255, 255, 255, .26); }
.floatStop { background: rgba(239, 68, 68, .85); }
.floatStop:hover { background: rgba(239, 68, 68, 1); }

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .wrap { padding: 10px 10px 32px; }
  th, td { padding: 5px 7px; }
}

/* ---------- 启动更新记录弹窗 ---------- */
.updMask {
  position: fixed; inset: 0; z-index: 9999; padding: 20px;
  background: rgba(16, 24, 40, .40);
  display: flex; align-items: center; justify-content: center;
}
.updBox {
  width: min(660px, 100%); max-height: min(80vh, 760px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 18px 46px rgba(16, 24, 40, .22);
}
.updHead {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--panel2);
}
.updHead h2 { margin: 0; font-size: 14.5px; font-weight: 600; flex: 1; }
.updVer {
  font: 11.5px var(--mono); color: var(--accent);
  background: var(--accent-weak); border: 1px solid #cfe0fb;
  padding: 2px 8px; border-radius: 999px;
}
.updX {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 13px; line-height: 1; padding: 5px 8px; border-radius: 6px; cursor: pointer;
}
.updX:hover { background: var(--panel2); color: var(--text); }
.updBody { flex: 1 1 auto; overflow-y: auto; padding: 14px 18px 6px; overscroll-behavior: contain; }
.updGroup + .updGroup { margin-top: 16px; }
.updDate {
  margin: 0 0 8px; font: 11.5px var(--mono); color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.updDate::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.updList { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.updList li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; line-height: 1.5; }
.updTag {
  flex: 0 0 auto; font: 10.5px var(--mono); padding: 1.5px 6px;
  border-radius: 4px; letter-spacing: .02em;
}
.updTag.new { color: #1a7f37; background: #e9f7ee; border: 1px solid #cbe9d6; }
.updTag.fix { color: #b3352b; background: #fdecea; border: 1px solid #f6d5d2; }
.updTag.imp { color: #1f6feb; background: var(--accent-weak); border: 1px solid #cfe0fb; }
.updFoot {
  display: flex; align-items: center; gap: 12px; flex: 0 0 auto;
  padding: 11px 18px; border-top: 1px solid var(--line); background: var(--panel2);
}
.updChk { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.updChk input { margin: 0; }
.updSpacer { flex: 1; }
.updTheme { display: inline-flex; align-items: center; gap: 5px; margin-left: 16px; }
.updThemeLbl { color: var(--muted); font-size: 11.5px; }
.updTheme button {
  font: 11.5px var(--mono); padding: 3px 9px; border-radius: 6px; cursor: pointer;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line-strong);
}
.updTheme button:hover { border-color: var(--accent); color: var(--accent); }
.updTheme button.on { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }

/* 深色下的更新弹窗细节 */
html[data-theme="dark"] .updBox { box-shadow: 0 18px 46px rgba(0, 0, 0, .55); }
html[data-theme="dark"] .updVer { color: #6ea8ff; background: var(--accent-weak); border-color: #25395c; }
html[data-theme="dark"] .updTag.new { color: #56d364; background: #12301c; border-color: #1f4a2c; }
html[data-theme="dark"] .updTag.fix { color: #ff8579; background: #35191a; border-color: #5a2a2a; }
html[data-theme="dark"] .updTag.imp { color: #6ea8ff; background: #17243c; border-color: #25395c; }
html[data-theme="dark"] .updMask { background: rgba(0, 0, 0, .58); }

/* ---------- 深色：零散浅色底的覆盖 ---------- */
html[data-theme="dark"] button:active:not(:disabled) { background: #2a3038; }
html[data-theme="dark"] button.danger:hover:not(:disabled) { background: #35191a; border-color: #6b3833; }
html[data-theme="dark"] tbody tr:hover { background: #1e2228; }
html[data-theme="dark"] .bar,
html[data-theme="dark"] .playerProgress { background: #2a3038; }
html[data-theme="dark"] .tag-ok,
html[data-theme="dark"] .tag-new { background: #12301c; color: #56d364; border-color: #1f4a2c; }
html[data-theme="dark"] .tag-warn { background: #33291a; color: #e3b341; border-color: #5a4620; }
html[data-theme="dark"] .tag-bad { background: #35191a; color: #ff8579; border-color: #5a2a2a; }
html[data-theme="dark"] .badge-ok { background: #12301c; border-color: #1f4a2c; }
