:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #172033;
  --muted: #667188;
  --accent: #2476bd;
  --accent-soft: #e8f1f9;
  --ok: #2f7d4a;
  --warn: #b06a00;
  --error: #c0392b;
  --radius: 8px;
  --taskbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --border: #2c323c;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --accent: #5aa9e6;
    --accent-soft: #1c2b3a;
    --ok: #5fbf82;
    --warn: #e0a340;
    --error: #ef6a5c;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ——— 启动遮罩 ——— */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.boot[hidden] { display: none; }

.boot-card {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
}

.boot-title {
  font-size: 18px;
  font-weight: 600;
}

.boot-note {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.boot-track,
.task-track {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--border);
}

.boot-fill,
.task-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width .15s linear;
}

/* 进度未知时用条纹表示仍在工作，而不是停在 0% 让人以为没开始。 */
.boot-fill.is-indeterminate,
.task-fill.is-indeterminate {
  width: 100%;
  background-image: linear-gradient(
    115deg, transparent 25%, var(--accent) 25%, var(--accent) 50%,
    transparent 50%, transparent 75%, var(--accent) 75%);
  background-size: 200% 100%;
  animation: slide 1.1s linear infinite;
}

@keyframes slide {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.boot-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.boot-error {
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--error);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 13px;
  text-align: left;
}

/* ——— 顶栏 ——— */

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  font-weight: 600;
  white-space: nowrap;
}

.tabs {
  display: flex;
  flex: 1;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover { background: var(--bg); color: var(--text); }

.tab.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.topbar-tail {
  display: flex;
  gap: 4px;
}

.ghost {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.ghost:hover { color: var(--text); border-color: var(--muted); }

.ghost:disabled,
.primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.primary {
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

/* ——— 布局 ——— */

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: 0;
}

.files {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.dropzone {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 20px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone strong { font-size: 13px; color: var(--text); }

.file-list {
  flex: 1;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.file-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name remove"
    "meta remove";
  gap: 2px 8px;
  padding: 9px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.file-name { grid-area: name; }
.file-meta { grid-area: meta; }

/* 移除按钮：默认淡，悬停或聚焦到条目时才明显，避免一排 ✕ 抢注意力，
   但也不能藏到看不见——用户就是找不到删除入口才来问的。 */
.file-remove {
  grid-area: remove;
  align-self: center;
  padding: 2px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  opacity: .55;
}

.file-item:hover .file-remove,
.file-remove:focus-visible { opacity: 1; }

.file-remove:hover {
  border-color: var(--error);
  color: var(--error);
}

.file-item.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-item.is-failed { border-color: var(--error); }

.file-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.file-state {
  padding: 0 5px;
  border-radius: 3px;
  background: var(--border);
}

.file-state.is-error { background: var(--error); color: #fff; }
.file-state.is-ok { background: var(--ok); color: #fff; }
.file-state.is-busy { background: var(--accent); color: #fff; }

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

/* ——— 工作区 ——— */

.work {
  padding: 16px;
  overflow-y: auto;
}

.panel { display: none; }
.panel.is-active { display: block; }

.work-head { margin-bottom: 14px; }

.work-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.work-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tool-body { padding-top: 8px; }

.work-split {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

/* ——— 格式卡片 ——— */

.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.format-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.format-card:hover { border-color: var(--accent); }

.format-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.format-card:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.format-name { font-size: 13px; font-weight: 600; }

.format-ext {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.notice {
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
}

.notice.is-error { border-left-color: var(--error); }
.notice.is-ok { border-left-color: var(--ok); }

/* ——— 预览 ——— */

.preview-warning:empty { display: none; }
.preview-warning { margin-bottom: 10px; }

.preview-strip {
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 90px;
}

.preview-page {
  flex: none;
  text-align: center;
}

.preview-page img {
  display: block;
  height: 120px;
  border: 1px solid var(--border);
  background: #fff;
  object-fit: contain;
}

.preview-page.is-current img { border-color: var(--accent); }

.preview-page span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ——— 参数面板 ——— */

.options {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.option { margin-bottom: 12px; }

.option:last-of-type { margin-bottom: 0; }

.option > label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* 文本类输入框占满整行，勾选框与单选钮按固有尺寸。
   :not() 不能省：曾经这里只写 .option input，width:100% 把 checkbox 也撑成
   整行宽——勾选标记被推到行末，标签文字被挤到下一行，看起来像"复选框居中了"。
   用类型选择器而非 :not([type])，属性选择器多一层匹配且对未来的 type 无遗漏。 */
.option select,
.option input:not([type='checkbox']):not([type='radio']) {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.option-check {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 12.5px;
}

.option-check input { margin-top: 2px; }

.option-hint {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

/* 面板底部的说明区集中放 trade-off 提示：每个参数旁边都挂一句会太长。 */
.option-foot {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
}

/* ——— 结果 ——— */

.result {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.result-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.result-head strong { font-size: 13px; }

.result-meta {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ——— 报告表格 ——— */

.report-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.badge {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.badge.is-error { border-color: var(--error); color: var(--error); }
.badge.is-warn { border-color: var(--warn); color: var(--warn); }
.badge.is-info { border-color: var(--accent); color: var(--accent); }
.badge.is-ok { border-color: var(--ok); color: var(--ok); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.report {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 12.5px;
}

table.report th,
table.report td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.report th {
  position: sticky;
  top: 0;
  background: var(--bg);
  font-weight: 600;
  white-space: nowrap;
}

table.report tr:last-child td { border-bottom: 0; }

.sev-error { color: var(--error); font-weight: 600; }
.sev-warning { color: var(--warn); font-weight: 600; }
.sev-info { color: var(--accent); }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
}

.truncate {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ——— 分析 Tab ——— */

/* 已选中的子面板按钮：ghost 的边框只表示"可点"，选中要更明确。 */
.filter-bar .ghost.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* 包目录树。行高压得比正文小一档：节点常有上千行，密度优先。 */
.package-tree {
  max-height: 60vh;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
}

.tree-row {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 1px 0;
  border-radius: 4px;
}

.tree-row:hover { background: var(--bg); }

.tree-toggle {
  flex: none;
  width: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
}

/* 不可展开的节点占位，保证图标与名称对齐。 */
span.tree-toggle { display: inline-block; cursor: default; }

.tree-icon {
  flex: none;
  width: 14px;
  color: var(--muted);
  text-align: center;
}

.tree-name {
  flex: 1;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-size {
  flex: none;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* 签名卡片。 */
.signature-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.signature-card {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.signature-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.signature-head strong { font-size: 13px; }

.signature-detail {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.signature-more {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

.signature-more > summary {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.signature-more > summary:hover { color: var(--text); }

/* 分组标题：字段组之间的分隔。 */
.group-title {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* 价税合计这类要核对的数字加重：字段表里所有数字长得一样，
   不加粗就没法一眼找到要看的那几个。 */
.kv dd.is-strong {
  font-size: 14px;
  font-weight: 600;
}

/* 剪贴板不可用时的兜底显示。 */
.copy-fallback {
  max-height: 40vh;
  margin-top: 10px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
}

/* 键值表：签名与证书详情用，比 table 轻。 */
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 8px 0 0;
  font-size: 12px;
}

.kv dt { color: var(--muted); }

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* 统计卡片行。 */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

/* ——— 校验报告 ——— */

/* 参数区默认折叠：绝大多数用户只想知道"通过没有"，判据是例外。
   折叠控件用原生 details，省掉一套展开状态。 */
.validate-options {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.validate-options > summary {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.validate-options > summary:hover { color: var(--text); }

.option-body {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--border);
}

.option-body .option:first-child { margin-top: 10px; }

.report-host {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 筛选栏：计数徽标、搜索框、条款下拉、清除按钮排成一行，
   窄屏时自动换行而不是横向滚动。 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-search {
  flex: 1;
  min-width: 180px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.filter-select {
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}

.issue-hint {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.issue-code {
  margin-top: 2px;
  color: var(--muted);
}

/* 表格里的说明列允许换行，位置列截断。窄屏时表格横向滚动，
   而说明文字不跟着横向滚出视野。 */
table.report td:nth-child(4) { min-width: 220px; }
table.report td:nth-child(5) { max-width: 260px; }

/* ——— 工具条 ——— */

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.stat {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat b {
  display: block;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--muted);
  font-size: 11.5px;
}

/* ——— 任务条 ——— */

.taskbar {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 14px;
  align-items: center;
  height: var(--taskbar-h);
  padding: 0 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.taskbar[hidden] { display: none; }

.task-text {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

#task-label { font-size: 13px; font-weight: 500; }

.task-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-actions { display: flex; gap: 8px; }

/* ——— 内存面板 ——— */

.memory {
  position: fixed;
  right: 16px;
  bottom: calc(var(--taskbar-h) + 16px);
  z-index: 40;
  width: min(300px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(0 0 0 / .18);
}

.memory[hidden] { display: none; }

.memory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.memory-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  margin: 0 0 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.memory-body dt { color: var(--muted); }
.memory-body dd { margin: 0; text-align: right; }

.memory-actions { display: flex; gap: 6px; margin-bottom: 8px; }

/* ——— 对话框 ——— */

.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop { background: rgb(0 0 0 / .45); }

.dialog h2 { margin: 0 0 10px; font-size: 16px; }
.dialog p { margin: 0 0 10px; font-size: 13px; }
.dialog a { color: var(--accent); }

.about-promo {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* 二维码固定 150px：再小手机就扫不出来了。白色卡片自带留白，
   在深色对话框上也不糊。 */
.about-promo-qr {
  flex: none;
  width: 150px;
  height: 150px;
  border-radius: 8px;
}

.about-promo-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.about-promo-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.about-promo-search {
  display: block;
  width: 100%;
  height: auto;
}

.about-promo-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

/* 窄屏放横排会把两样都挤小，二维码就扫不动了，改成竖排。 */
@media (max-width: 420px) {
  .about-promo { flex-direction: column; align-items: stretch; }
  .about-promo-qr { width: 100%; height: auto; }
}

.dialog .warn {
  padding: 9px 11px;
  border-left: 3px solid var(--warn);
  background: var(--bg);
  font-size: 12.5px;
}

/* ——— 窄屏 ——— */

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }

  .files {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 34vh;
  }

  .work-split { grid-template-columns: 1fr; }

  .taskbar {
    grid-template-columns: 1fr auto;
    height: auto;
    padding: 10px 14px;
  }

  .task-track { grid-column: 1 / -1; }

  .brand { display: none; }

  .tab { padding: 6px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-fill.is-indeterminate,
  .task-fill.is-indeterminate { animation: none; }
  .boot-fill, .task-fill { transition: none; }
}

/* ——— 水印 —— */

.wm-body { display: grid; gap: 14px; }

.wm-form {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.wm-actions,
.wm-kind { margin: 0; }

.wm-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
}

.wm-fields[hidden] { display: none; }

/* 操作切到 remove 时，文字水印那组字段不再参与运算：留着一片灰说明
   它们会被忽略，比直接藏起来更容易让人以为设置生效了。 */
.wm-fields[data-stale='1'] { pointer-events: none; }

.field { display: grid; gap: 4px; }

.field-label {
  display: flex;
  gap: 6px;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.field input[type='color'] { padding: 2px; height: 30px; }

.wm-range output {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.wm-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.wm-radio-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* 单选项用两列网格：标签占第二列，说明另起一行。
   原来这里是 nowrap 的 flex 行，input、标签、说明挤在一行里，说明文字
   自己换行——「整体合并（ZIP 级）」配上 22 字的说明，单项就被撑到 73px 高，
   两个选项合起来白占一整块竖向空间。说明独占一行后稳定在两行文字。
   grid-template-columns 的 auto 列给 radio，1fr 给文字，说明落在同一列。 */
.wm-radio-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 6px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
}

.wm-radio-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wm-radio-item small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.wm-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 2px;
}

.wm-page {
  padding: 6px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.wm-page.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.wm-note {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.wm-note .hint { margin: 0; }

.wm-toggles { display: flex; flex-wrap: wrap; gap: 14px; }

.wm-check {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 12.5px;
}

.wm-check input { margin-top: 2px; }

/* 发票 Tab 的两个开关上下各有内容：上面是待处理文件清单，下面是「开始批量
   抽取」按钮行。.wm-fields 自身不带外边距，紧贴上方盒子、紧贴按钮行，读
   起来像三块内容粘在一起。12px 与 .tool-actions 在合并、长期保存面板上用的
   间距一致。 */
#invoice-options {
  margin: 12px 0;
}

/* 开关本身再留一点上下内边距：勾选框贴着文字框的边，鼠标经过时高亮区域
   看着比文字大一圈，显得不齐。 */
#invoice-options .wm-check {
  padding: 4px 0;
}

/* ——— 字体面板 ——— */

/* 字体列表比内存表长得多，面板要能滚动，否则几十个本地字体直接溢出屏幕。 */
.font-panel {
  width: min(380px, calc(100vw - 32px));
  max-height: min(84vh, 760px);
  overflow-y: auto;
}

.font-doc,
.font-list { margin-bottom: 12px; }

.font-list .group-title { margin-top: 0; }

.font-items {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}


.font-items li {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12.5px;
}

.font-items li button {
  flex: none;
  padding: 2px 8px;
  font-size: 12px;
}

/* 本机字体候选按按钮列出，名字可能很长（"微软雅黑 Light"），让它自己换行。 */
.font-list .font-items button.ghost { flex: 1; text-align: left; }

/* 预览区里的缺字体提示带一个"去注册字体"按钮，需要单独一行。 */
.notice-actions { margin-top: 6px; }
.notice-actions button { font-size: 12px; padding: 3px 10px; }

/* ——— 合并 ——— */

.merge-body { display: grid; gap: 14px; }

.merge-inputs {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.merge-list {
  display: grid;
  gap: 4px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.merge-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12.5px;
}

.merge-order {
  min-width: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 文件名可能很长，让它占满并截断，别把操作按钮挤出去。 */
.merge-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-meta {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.merge-icon {
  padding: 2px 7px;
  font-size: 12px;
  line-height: 1.2;
}

.merge-icon:disabled { opacity: .35; cursor: not-allowed; }

.merge-form .wm-fields[hidden] { display: none; }

/* 「开始合并」按钮行与上方内容的间距，理由同 .preserve-form + .tool-actions：
   .tool-actions 没有 margin-top，按钮直接贴住上方容器的下边框。
   合并这边上方是 .merge-body 网格容器，它内部的 gap 管不到跨容器间距，
   所以要在容器外面补。与长期保存同为 16px。 */
.merge-body + .tool-actions { margin-top: 16px; }

/* 合并 PDF 产物区里「下载 PDF」按钮与上方结果条的间距。同一类问题：
   .tool-actions 没有 margin-top，按钮直接贴住上方容器的下边框。
   与合并、长期保存面板的 16px 一致。 */
#invoice-pdf-result .tool-actions { margin-top: 16px; }

/* 合并 PDF 的选项区。块级分组 + 组内自适应网格：
   把几个 .wm-fields 塞进 .wm-form（它本身是 grid）会让它们并排成列、字段被
   拉到同一高度，group-title 也被当成网格项。这里用一层普通流容器分组，
   组内沿用 .wm-fields 的自适应列。 */
.invoice-pdf-opts {
  display: grid;
  gap: 12px;
}

.invoice-pdf-opts > .wm-check { padding: 0; }

.invoice-pdf-opts .group-title { margin: 0; }

/* 字体与提示占满一行：字体名可能很长，挤在半列里会被截断。 */
.invoice-pdf-opts #wm-invoice-pdf-font,
.invoice-pdf-opts #invoice-pdf-font { grid-column: 1 / -1; }

/* ——— 长期保存 ——— */

/* 预检/执行按钮行与上方表单的间距。
   .tool-actions 原本只有 margin-bottom，按钮行上方是 0；而长期保存的参数区是
   带边框的 .wm-form 卡片，按钮直接贴住卡片下边框，看起来像卡片的一部分。
   16px 略大于 .wm-form 内部的 12px 内边距，让按钮明确属于卡片之外。 */
.preserve-form + .tool-actions { margin-top: 16px; }

/* ——— 大图查看 ——— */

.image-viewer {
  width: auto;
  max-width: 94vw;
  max-height: 94vh;
}

.image-viewer-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.image-viewer img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border);
}

/* 缩略图能点开时要看得出来能点。 */
.preview-page.is-clickable { cursor: zoom-in; }

.preview-page.is-clickable:hover img,
.preview-page.is-clickable:focus-visible img {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* 候选列表自己滚，别把「注册所选」推到面板底下——
   字体多的时候要拖到底才能点，那是很烦的。 */
#font-candidates .font-items,
#font-list .font-items {
  max-height: 260px;
  overflow-y: auto;
}

/* 本机字体候选：整行可点，复选框与名字在同一行。 */
.font-pick {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

.font-pick input { flex: none; }

.font-pick input:disabled + span { color: var(--muted); }

/* ——— 长期保存 ——— */

.preserve-list {
  max-height: 220px;
  overflow-y: auto;
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

#preserve-plan details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}
