/* metatidy · 深色高密度工作台样式
   ---------------------------------------------------------------------------
   设计契约（Design contract）
   Mission  : 内网 NAS 上单机音乐库的管理台。三个动作（改标签 / 刮削写入 / 整理移动）
              都会动真实文件，界面必须"先预览、后确认"，密度优先、装饰为零。
   Rhythm   : 4px 基准（--s1 4 · --s2 8 · --s3 12 · --s4 16 · --s5 20 · --s6 24 · --s7 32）；
              控件高 26/30，表格行 30，页签高 34。
   Type     : 13px 正文、11px 辅助信息与徽章、等宽字体用于路径/模板/文件名；
              中文优先字体栈，字号差只靠 400/500/600 三档字重，不用大字标题。
   Motion   : 只承载状态变化。--t-fast 90ms（hover/press 即时反馈）、
              --t 140ms（面板/列表进场）、--t-slow 220ms（抽屉/弹层）；
              减速缓动 --ease-out，列表进场用轻微回弹 --ease-spring + 小步进 stagger。
   Do       : :focus-visible 始终可见；长路径一律 ellipsis + title；颜色只表达语义
              （红=危险/失败/旧值，绿=成功/新值，黄=警告，蓝=可操作）。
   Don't    : 不用 transition: all；不用 0.3s ease 这类通用时长/缓动；
              不用常量线性动画；不用渐变/玻璃拟态做装饰；
              不用 overflow 裁剪掩盖布局缺陷（表格独立滚动区是有意设计，行高与列宽固定）。
   Reduced  : prefers-reduced-motion 下所有位移/动画关闭，仅保留颜色变化。
   --------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg-0: #0b0d10;
  --bg-1: #111418;
  --bg-2: #161a20;
  --bg-3: #1c212a;
  --bg-4: #232935;
  --line: #262d38;
  --line-2: #333c49;

  --fg: #e6eaf0;
  --fg-2: #a7b0be;
  --fg-3: #737d8c;

  --accent: #4b8dff;
  --accent-2: #7cabff;
  --accent-soft: rgba(75, 141, 255, 0.14);
  --accent-line: rgba(75, 141, 255, 0.45);

  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.13);
  --warn: #d29922;
  --warn-soft: rgba(210, 153, 34, 0.14);
  --err: #f85149;
  --err-soft: rgba(248, 81, 73, 0.13);
  --info: #58a6ff;
  --info-soft: rgba(88, 166, 255, 0.12);
  --neutral: #8b949e;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;

  --r1: 4px;
  --r2: 6px;
  --r3: 10px;

  --t-fast: 90ms;
  --t: 140ms;
  --t-slow: 220ms;
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring: cubic-bezier(0.3, 1.16, 0.42, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --h-ctl: 30px;
  --row-h: 30px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--fg);
  font: 400 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent-2); }

::selection { background: var(--accent-line); color: #fff; }

/* 滚动条：低对比、不抢视线 */
* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border: 3px solid transparent; background-clip: content-box; border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: #455063; background-clip: content-box; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: var(--r1);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: var(--s2) var(--s3);
  border-radius: 0 0 var(--r2) 0;
}
.skip-link:focus { left: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ 顶栏 */

.app-header {
  display: flex;
  align-items: center;
  gap: var(--s4);
  height: 46px;
  padding: 0 var(--s4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: var(--r1);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-2);
  font: 600 11px/1 var(--mono);
}
.brand h1 { font-size: 13px; letter-spacing: 0.2px; }
.brand-sub { color: var(--fg-3); font-size: 11px; }

.tabs { display: flex; align-items: center; gap: 2px; margin-left: var(--s2); }

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-2);
  font: 500 13px/1 var(--font);
  height: 28px;
  padding: 0 var(--s3);
  border-radius: var(--r2);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out);
}
.tab:hover { background: var(--bg-3); color: var(--fg); }
.tab[aria-selected="true"] {
  background: var(--bg-3);
  border-color: var(--line-2);
  color: var(--fg);
}
.tab[aria-selected="true"]::after {
  content: "";
  display: block;
  height: 2px;
  margin: 4px -2px -7px;
  background: var(--accent);
  border-radius: 2px;
  animation: tab-underline var(--t-slow) var(--ease-out) both;
}
@keyframes tab-underline {
  from { transform: scaleX(0.35); opacity: 0.4; }
  to { transform: scaleX(1); opacity: 1; }
}

.header-right { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

/* ------------------------------------------------------------ 通用控件 */

.btn {
  appearance: none;
  height: var(--h-ctl);
  padding: 0 var(--s3);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  background: var(--bg-3);
  color: var(--fg);
  font: 500 12.5px/1 var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.btn:hover:not(:disabled) { background: var(--bg-4); border-color: #43506a; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }

.btn-danger { background: var(--err-soft); border-color: rgba(248, 81, 73, 0.55); color: #ffb4b0; }
.btn-danger:hover:not(:disabled) { background: rgba(248, 81, 73, 0.22); border-color: var(--err); }

.btn-ok { background: var(--ok-soft); border-color: rgba(63, 185, 80, 0.5); color: #9ae6a6; }
.btn-ok:hover:not(:disabled) { background: rgba(63, 185, 80, 0.2); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--fg); border-color: var(--line); }

.btn-sm { height: 24px; padding: 0 var(--s2); font-size: 11.5px; }
.btn-icon { padding: 0 var(--s2); }

input[type="text"], input[type="number"], input[type="search"], input[type="password"], select, textarea {
  height: var(--h-ctl);
  width: 100%;
  min-width: 0;
  padding: 0 var(--s2);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  color: var(--fg);
  font: 400 12.5px/1.4 var(--font);
  transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
textarea { height: auto; min-height: 64px; padding: var(--s2); font-family: var(--mono); }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent-line); background: var(--bg-1); }
input::placeholder, textarea::placeholder { color: var(--fg-3); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }

input.mono, textarea.mono, .mono { font-family: var(--mono); font-size: 11.5px; }

select {
  appearance: none;
  padding-right: var(--s5);
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%),
    linear-gradient(135deg, var(--fg-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 13px, calc(100% - 9px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

label.field { display: block; min-width: 0; }
label.field > span.lbl,
.lbl {
  display: block;
  margin-bottom: var(--s1);
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.inline-field { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.hint { color: var(--fg-3); font-size: 11px; line-height: 1.5; }
.hint-warn { color: var(--warn); }
.hint-err { color: #ffb4b0; }
.hint-ok { color: #9ae6a6; }
.err-text { color: #ffb4b0; font-size: 11.5px; }

/* 勾选框 / 单选 */
input[type="checkbox"], input[type="radio"] {
  appearance: none;
  flex: none;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--bg-2);
  cursor: pointer;
  position: relative;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--accent-line); }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 0.5px;
  width: 4px; height: 8px;
  border: solid #06101f;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #06101f;
}
input[type="checkbox"]:indeterminate { background: var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"]:indeterminate::after {
  content: ""; position: absolute; left: 2px; top: 5px; width: 8px; height: 2px; background: var(--accent-2);
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--fg-2);
  font-size: 12px;
  cursor: pointer;
  min-width: 0;
}
label.check:hover { color: var(--fg); }
label.check input { margin-top: 0; }
label.check span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.switch { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: 12px; color: var(--fg-2); }
.switch input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 30px; height: 16px; flex: none; border-radius: 999px;
  background: var(--bg-4); border: 1px solid var(--line-2);
  transition: background-color var(--t) var(--ease-out), border-color var(--t) var(--ease-out);
  position: relative;
}
.switch .track::after {
  content: ""; position: absolute; top: 1px; left: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--fg-3);
  transition: transform var(--t) var(--ease-spring), background-color var(--t) var(--ease-out);
}
.switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent-line); }
.switch input:checked + .track::after { transform: translateX(14px); background: var(--accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 徽章 / 标签 / 胶囊 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--fg-2);
  font: 500 10.5px/1 var(--font);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); border-color: rgba(63, 185, 80, 0.45); color: #9ae6a6; }
.badge-warn { background: var(--warn-soft); border-color: rgba(210, 153, 34, 0.45); color: #e8c063; }
.badge-err { background: var(--err-soft); border-color: rgba(248, 81, 73, 0.5); color: #ffb4b0; }
.badge-info { background: var(--info-soft); border-color: rgba(88, 166, 255, 0.45); color: #a5d0ff; }
.badge-accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }
.badge-mute { color: var(--fg-3); }
.badge-mono { font-family: var(--mono); }
.count-chip { font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 var(--s2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--fg-2);
  font-size: 11.5px;
}
.chip strong { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 按钮式多选（数据源） */
.chip-toggle {
  appearance: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 var(--s2) 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--fg-2);
  font: 500 11.5px/1 var(--font);
  cursor: pointer;
  max-width: 220px;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out);
}
.chip-toggle .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); flex: none; }
.chip-toggle:hover { background: var(--bg-3); color: var(--fg); }
.chip-toggle[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--fg); }
.chip-toggle[aria-pressed="true"] .dot { background: var(--accent); }
.chip-toggle[data-status="内置"][aria-pressed="true"] .dot { background: var(--info); }
.chip-toggle[data-status="不可用"] { opacity: 0.7; }
.chip-toggle[data-status="不可用"] .dot { background: var(--warn); }
.chip-toggle span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ 布局骨架 */

.panel { display: none; padding: var(--s4); }
.panel[data-active="true"] { display: block; animation: panel-in var(--t) var(--ease-out) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.wrap { max-width: 1680px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s3); }

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.card-head h2, .card-head h3 { font-size: 12.5px; color: var(--fg); }
.card-head .grow { margin-left: auto; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.card-body { padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.card-body.tight { padding: var(--s2) var(--s3); gap: var(--s2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
.row.tight { gap: var(--s1); }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1 1 auto; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--line); border-radius: var(--r3); overflow: hidden; }
.stat {
  background: var(--bg-1);
  padding: var(--s2) var(--s3);
  display: flex; flex-direction: column; gap: 2px;
  text-align: left;
  border: none;
  min-width: 0;
}
button.stat { cursor: pointer; transition: background-color var(--t-fast) var(--ease-out); }
button.stat:hover { background: var(--bg-3); }
button.stat[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.stat .k { color: var(--fg-3); font-size: 11px; display: flex; align-items: center; gap: 4px; }
.stat .v { font: 600 17px/1.15 var(--font); font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 11px; color: var(--fg-3); font-weight: 400; margin-left: 3px; }
.stat .v.miss { color: #e8c063; }

/* ------------------------------------------------------------ 表格 */

.table-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}
.table-wrap.scroll { max-height: calc(100vh - 300px); }
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  table-layout: fixed;
}
table.data th, table.data td {
  padding: 0 var(--s2);
  height: var(--row-h);
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-2);
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  height: 30px;
  user-select: none;
}
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--fg); background: var(--bg-3); }
table.data thead th .sort-mark { color: var(--accent); margin-left: 3px; font-size: 10px; }
table.data tbody tr { transition: background-color var(--t-fast) var(--ease-out); }
table.data tbody tr:hover { background: var(--bg-2); }
table.data tbody tr[aria-selected="true"] { background: var(--accent-soft); }
tr.enter { animation: row-in var(--t) var(--ease-spring) both; }
@keyframes row-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
td.col-check, th.col-check { width: 30px; text-align: center; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.path, .path-cell { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }
.cell-title { font-weight: 500; }
.cell-sub { color: var(--fg-3); font-size: 11px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; min-width: 0; }

.thumb {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: var(--r1);
  background: var(--bg-3);
  border: 1px solid var(--line);
  overflow: hidden;
  vertical-align: middle;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.ph { color: var(--fg-3); font-size: 9px; letter-spacing: -0.3px; }
.thumb-lg { width: 64px; height: 64px; border-radius: var(--r2); }
.thumb-lg.ph { font-size: 10px; }

mark.hl { background: rgba(75, 141, 255, 0.22); color: inherit; border-radius: 2px; }

/* 分页 */
.pager {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  flex-wrap: wrap;
}
.pager .pageno { font-variant-numeric: tabular-nums; color: var(--fg-2); }
.pager input.jump { width: 56px; height: 24px; text-align: center; }

/* 空状态 / 加载 / 错误 */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
  padding: var(--s7) var(--s4);
  text-align: center;
  color: var(--fg-2);
}
.empty .ico { width: 34px; height: 34px; border-radius: var(--r2); display: grid; place-items: center; background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-3); font: 600 13px/1 var(--mono); }
.empty h3 { font-size: 13px; color: var(--fg); }
.empty p { font-size: 12px; color: var(--fg-3); max-width: 460px; }

.loading-line { display: flex; align-items: center; gap: var(--s2); color: var(--fg-3); font-size: 11.5px; padding: var(--s2) 0; }
.spinner {
  width: 12px; height: 12px; flex: none;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-row { height: var(--row-h); background: linear-gradient(90deg, var(--bg-2), var(--bg-3) 40%, var(--bg-2)); background-size: 200% 100%; animation: shimmer 1200ms linear infinite; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -20% 0; } }

.notice {
  display: flex; gap: var(--s2);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-2);
  border-left-width: 3px;
  border-radius: var(--r2);
  background: var(--bg-2);
  font-size: 12px;
  color: var(--fg-2);
  min-width: 0;
}
.notice strong { color: var(--fg); }
.notice-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.notice-err { border-left-color: var(--err); background: var(--err-soft); }
.notice-ok { border-left-color: var(--ok); background: var(--ok-soft); }
.notice-info { border-left-color: var(--info); background: var(--info-soft); }
.notice .body { min-width: 0; }

/* 进度 */
.progress { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-4);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-bar > i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width var(--t-slow) var(--ease-out);
}
.progress-bar.indet > i { width: 30% !important; animation: indet 1200ms var(--ease-out) infinite; }
@keyframes indet { from { transform: translateX(-110%); } to { transform: translateX(340%); } }
.progress-meta { display: flex; gap: var(--s2); align-items: baseline; font-size: 11.5px; color: var(--fg-3); min-width: 0; }
.progress-meta .msg { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 结果块（失败清单等） */
.result-block { display: flex; flex-direction: column; gap: var(--s2); }
.result-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--bg-0);
}
.result-list .item {
  display: flex; gap: var(--s2); align-items: baseline;
  padding: var(--s1) var(--s2);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
}
.result-list .item:last-child { border-bottom: none; }
.result-list .item .who { font-family: var(--mono); color: var(--fg-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.result-list .item .why { color: #ffb4b0; flex: 0 1 auto; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dl.kv { display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); gap: var(--s1) var(--s3); margin: 0; font-size: 12px; }
dl.kv dt { color: var(--fg-3); }
dl.kv dd { margin: 0; font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
dl.kv dd.bad { color: #ffb4b0; }
dl.kv dd.good { color: #9ae6a6; }

/* 抽屉（元数据编辑面板） */
.drawer {
  position: fixed;
  top: 46px;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--bg-1);
  border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform var(--t-slow) var(--ease-out), visibility var(--t-slow);
}
.drawer[data-open="true"] { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); }
.drawer-head h3 { font-size: 12.5px; }
.drawer-body { overflow: auto; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
.drawer-foot { margin-top: auto; padding: var(--s3); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s2); background: var(--bg-1); }

/* 弹层（预览差异 / 确认） */
dialog.modal {
  border: 1px solid var(--line-2);
  border-radius: var(--r3);
  background: var(--bg-1);
  color: var(--fg);
  padding: 0;
  width: min(900px, 94vw);
  max-height: 88vh;
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.modal::backdrop { background: rgba(4, 6, 9, 0.68); backdrop-filter: blur(1.5px); }
dialog.modal[open] { animation: modal-in var(--t-slow) var(--ease-spring) both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.995); } to { opacity: 1; transform: none; } }
dialog.modal.narrow { width: min(560px, 94vw); }
.modal-head { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 13.5px; }
.modal-head .sub { color: var(--fg-3); font-size: 11.5px; margin-top: 2px; }
.modal-body { padding: var(--s4); overflow: auto; max-height: 62vh; display: flex; flex-direction: column; gap: var(--s3); }
.modal-foot { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap; }

.diff-track { border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; background: var(--bg-0); }
.diff-track > header { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2); background: var(--bg-2); border-bottom: 1px solid var(--line); font-size: 11.5px; }
.diff-track > header .nm { font-weight: 500; color: var(--fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-table { width: 100%; border-collapse: collapse; font-size: 11.5px; table-layout: fixed; }
.diff-table th { text-align: left; color: var(--fg-3); font-weight: 500; padding: 3px var(--s2); border-bottom: 1px solid var(--line); font-size: 10.5px; }
.diff-table td { padding: 3px var(--s2); border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.diff-table tr:last-child td { border-bottom: none; }
.diff-table .fld { color: var(--fg-2); font-family: var(--mono); width: 120px; white-space: nowrap; }
.diff-old { color: #ffb4b0; text-decoration: line-through; text-decoration-color: rgba(248, 81, 73, 0.5); }
.diff-new { color: #9ae6a6; }
.diff-empty { color: var(--fg-3); font-style: italic; }

/* toast */
.toast-stack {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(420px, 92vw);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-2);
  border-left-width: 3px;
  border-radius: var(--r2);
  background: var(--bg-2);
  box-shadow: var(--shadow);
  animation: toast-in var(--t-slow) var(--ease-spring) both;
}
.toast[data-leaving="true"] { animation: toast-out var(--t) var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }
.toast-ok { border-left-color: var(--ok); }
.toast-err { border-left-color: var(--err); }
.toast-warn { border-left-color: var(--warn); }
.toast-info { border-left-color: var(--info); }
.toast .t { font-weight: 600; font-size: 12px; }
.toast .m { color: var(--fg-2); font-size: 11.5px; overflow-wrap: anywhere; }
.toast .x { margin-left: auto; }

/* 任务抽屉 */
.jobs-pop {
  position: fixed;
  top: 50px;
  right: var(--s4);
  width: min(520px, 92vw);
  max-height: 60vh;
  display: none;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r3);
  box-shadow: var(--shadow);
  z-index: 50;
  overflow: hidden;
}
.jobs-pop[data-open="true"] { display: flex; animation: modal-in var(--t) var(--ease-out) both; }
.jobs-pop .card-body { overflow: auto; gap: var(--s2); }

/* 三栏工作台（刮削） */
.workbench {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 330px;
  gap: var(--s3);
  align-items: start;
}
@media (max-width: 1380px) { .workbench { grid-template-columns: 280px minmax(0, 1fr); } .workbench > .zone-write { grid-column: 1 / -1; } }
@media (max-width: 1080px) { .workbench { grid-template-columns: minmax(0, 1fr); } .workbench > * { grid-column: auto; } }
@media (max-width: 820px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

.zone { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.zone .scroll-y { overflow: auto; max-height: 460px; }
.zone .card { min-width: 0; }

.pick-list { display: flex; flex-direction: column; }
.pick-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s3);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  min-height: 34px;
  transition: background-color var(--t-fast) var(--ease-out);
}
.pick-row:hover { background: var(--bg-2); }
.pick-row[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 0 var(--accent); }
.pick-row .nm { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row .sub { font-size: 10.5px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row .marks { display: flex; gap: 4px; align-items: center; }

.cand-list { display: flex; flex-direction: column; gap: var(--s2); }
.cand {
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--bg-2);
  padding: var(--s2) var(--s3);
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: var(--s3);
  align-items: start;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.cand:hover { border-color: var(--line-2); }
.cand[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); }
.cand-cover { display: flex; flex-direction: column; gap: var(--s1); align-items: center; }
.cand-cover .cap { font-size: 10px; color: var(--fg-3); }
.cand-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cand-title { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand-meta { font-size: 11px; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand-ctx { font-size: 10.5px; color: var(--fg-3); overflow-wrap: anywhere; }
.cand-side { display: flex; flex-direction: column; gap: var(--s1); align-items: flex-end; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s1) var(--s3); }
.field-grid label.check span { white-space: normal; }

.token-row { display: flex; flex-wrap: wrap; gap: var(--s1); }
.token-btn {
  appearance: none;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: var(--r1);
  background: var(--bg-2);
  color: var(--fg-2);
  font: 400 11px/1 var(--mono);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out);
}
.token-btn:hover { background: var(--bg-4); color: var(--fg); border-color: var(--line-2); }
.token-btn:active { transform: translateY(1px); }

.alias-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.alias-table th { text-align: left; color: var(--fg-3); font-weight: 500; font-size: 10.5px; padding: 0 var(--s2) var(--s1); }
.alias-table td { padding: 0 var(--s2) var(--s1) 0; }
.alias-table td.act { width: 34px; padding-right: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-property: background-color, border-color, color, opacity !important;
  }
  .panel[data-active="true"], tr.enter { animation: none !important; }
  .skeleton-row { animation: none !important; background: var(--bg-2); }
  .spinner { animation-duration: 900ms !important; animation-iteration-count: infinite !important; }
}

/* --------------------------------------------------- 布局工具类（尺寸/对齐） */

.row-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}
.row-inline > .lbl { margin-bottom: 0; white-space: nowrap; }
.row-inline > input:not(.w-90):not(.w-140), .row-inline > select { width: auto; }
.row-inline.flex-1 { flex: 1 1 180px; }
.row-inline.flex-1 > input { flex: 1 1 auto; width: 100%; }
.flex-1 { flex: 1 1 160px; min-width: 0; }
.w-90 { width: 90px; flex: none; }
.w-110 { width: 110px; flex: none; }
.w-140 { width: 140px; flex: none; }
.w-160 { width: 160px; flex: none; }

/* 表头排序按钮：整格可点，键盘可聚焦 */
.th-sort {
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  padding: 0;
  height: 100%;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.th-sort:hover { color: var(--fg); }
.th-sort:focus-visible { outline-offset: -2px; }
th[aria-sort] .th-sort { color: var(--fg); }

details > summary.lbl { list-style: none; display: inline-flex; align-items: center; gap: var(--s1); }
details > summary.lbl::before { content: "▸"; font-size: 9px; color: var(--fg-3); }
details[open] > summary.lbl::before { content: "▾"; }

/* ---------------------------------------------------------------------------
   浅色主题（顶栏「浅色/深色」按钮切换）
   ---------------------------------------------------------------------------
   只做两件事，**不改动上面任何既有规则**，避免为了主题去重写整套样式：
   1) 覆盖 :root 的配色变量；
   2) 单独修掉几处「只在深色底上好看」的硬编码浅色调（它们写在具体规则里，
      浅色底上对比度不够）。 */

:root { color-scheme: dark; }

[data-theme="light"] {
  color-scheme: light;

  --bg-0: #f5f6f8;
  --bg-1: #ffffff;
  --bg-2: #f0f2f6;
  --bg-3: #e6e9ef;
  --bg-4: #dbe0e8;
  --line: #d7dce4;
  --line-2: #bfc7d3;

  --fg: #15181e;
  --fg-2: #4b5361;
  --fg-3: #7a8291;

  --accent: #2f6fe4;
  --accent-2: #1f5cc8;
  --accent-soft: rgba(47, 111, 228, 0.12);
  --accent-line: rgba(47, 111, 228, 0.45);

  --ok: #1a7f37;
  --ok-soft: rgba(26, 127, 55, 0.10);
  --warn: #96690b;
  --warn-soft: rgba(150, 105, 11, 0.12);
  --err: #cf222e;
  --err-soft: rgba(207, 34, 46, 0.09);
  --info: #0969da;
  --info-soft: rgba(9, 105, 218, 0.10);
  --neutral: #6e7781;
}

/* 1) 深色底专用的浅色调 → 浅色主题下换成对应语义色 */
[data-theme="light"] .hint-err,
[data-theme="light"] .err-text,
[data-theme="light"] .result-list .item .why,
[data-theme="light"] dl.kv dd.bad,
[data-theme="light"] .diff-old { color: var(--err); }
[data-theme="light"] .hint-ok,
[data-theme="light"] dl.kv dd.good { color: var(--ok); }
[data-theme="light"] .stat .v.miss { color: var(--warn); }
[data-theme="light"] .btn-danger { color: var(--err); border-color: rgba(207, 34, 46, 0.35); }
[data-theme="light"] .btn-danger:hover:not(:disabled) { background: rgba(207, 34, 46, 0.12); }
[data-theme="light"] .btn-ok { color: var(--ok); border-color: rgba(26, 127, 55, 0.35); }
[data-theme="light"] .btn-ok:hover:not(:disabled) { background: rgba(26, 127, 55, 0.12); }
[data-theme="light"] .badge-ok { color: var(--ok); }
[data-theme="light"] .badge-warn { color: var(--warn); }
[data-theme="light"] .badge-err { color: var(--err); }
[data-theme="light"] .badge-info { color: var(--info); }

/* 2) 主按钮上的文字：深色主题用近黑，浅色主题用白 */
[data-theme="light"] .btn-primary { color: #ffffff; }
[data-theme="light"] ::selection { color: #ffffff; }
[data-theme="light"] .brand-mark { color: #ffffff; }

/* 3) 滚动条 / 遮罩 / 高亮：深色下偏暗，浅色下要反过来 */
[data-theme="light"] *::-webkit-scrollbar-thumb:hover { background: #a7b1c0; background-clip: content-box; }
[data-theme="light"] dialog.modal::backdrop { background: rgba(18, 22, 28, 0.42); }
[data-theme="light"] mark.hl { background: rgba(47, 111, 228, 0.16); }
[data-theme="light"] .btn:hover:not(:disabled) { border-color: #b3bdcb; }

/* 顶栏品牌图标：直接用同一份 icon.svg，
   这样「界面顶栏图标 = 浏览器标签图标 = Arcane 容器图标」三者一致。
   （原来这里是写着 "mt" 的方块，和 favicon 不一致。） */
img.brand-mark {
  background: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

/* 顶栏状态胶囊：存储没连上时变红（浅色主题下 --err 会自动换成深红） */
.chip.is-bad {
  color: var(--err);
  border-color: rgba(248, 81, 73, 0.45);
}
[data-theme="light"] .chip.is-bad {
  border-color: rgba(207, 34, 46, 0.35);
}

/* 歌词预览：候选自带歌词就摊开看，长歌词自己滚；配色走变量，日夜主题通用 */
.lyrics-box { margin-top: var(--s2); }
.lyrics-box > summary { cursor: pointer; }
.lyrics-box pre {
  margin: var(--s2) 0 0;
  max-height: 220px;
  overflow: auto;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--bg-2);
  color: var(--fg-2);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 登录遮罩：全屏挡住界面 —— 未通过之前连空表格都不给看（省得被当成「软件坏了」） */
.auth-veil {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  background: rgba(11, 13, 16, 0.88);
  background: color-mix(in srgb, var(--bg-0) 88%, transparent);
}
.auth-card {
  width: min(360px, 100%);
  display: grid;
  gap: var(--s3);
  padding: var(--s5);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.auth-card h2 { margin: 0; font-size: 14px; font-weight: 600; }
.auth-field { display: grid; gap: var(--s1); }
.auth-actions { display: flex; justify-content: flex-end; }
.auth-actions .btn { min-width: 96px; justify-content: center; }
