/* ============ 错敏词检测工具 - 样式（浅色主题） ============ */
/* 公文排版字体（内嵌） */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --dim: #6b7280;
  --accent: #2563eb;
  --accent-weak: #eff6ff;
  --red: #dc2626;
  --red-weak: #fee2e2;
  --green: #16a34a;
  --green-weak: #dcfce7;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

html, body { height: 100%; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text h1 {
  font-size: 23px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 1px;
  color: var(--text);
  position: relative;
  padding-left: 16px;
}
.brand-text h1::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 24px;
  border-radius: 3px;
  background: linear-gradient(180deg, #dc2626, #f59e0b);
}
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.dict-ver {
  font-size: 12px; color: var(--dim); background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; white-space: nowrap;
}

/* ---------- 验证码状态横幅 ---------- */
.license-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 16px; font-size: 13px; text-align: center; flex-wrap: wrap;
}
.license-banner.expiring { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; }
.license-banner.expired { background: #fef2f2; color: #b91c1c; border-bottom: 1px solid #fecaca; }
.license-banner .lic-btn {
  background: transparent; border: 1px solid currentColor; color: inherit;
  border-radius: 6px; padding: 3px 12px; cursor: pointer; font-size: 12px;
}
.license-msg { font-size: 13px; margin: 8px 0 0; min-height: 18px; }
.license-msg.ok { color: var(--green); }
.license-msg.err { color: var(--red); }

/* ---------- 按钮 ---------- */
.btn {
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  border-radius: 8px; padding: 8px 16px; font-size: 13px;
  transition: filter .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; background: var(--accent-weak); color: var(--accent); }
.btn-danger { background: var(--red-weak); color: var(--red); border: 1px solid #fecaca; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-block { display: block; width: 100%; margin: 8px 0; text-align: left; }
.btn-ai {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff; border: none;
  box-shadow: 0 1px 4px rgba(124, 58, 237, .35);
}
.btn-ai:hover { filter: brightness(1.1); }
.btn-ai.loading { opacity: .7; pointer-events: none; }

/* ---------- 统计栏 ---------- */
.stats {
  display: flex; align-items: stretch; gap: 12px;
  padding: 12px 20px; background: var(--card);
  border-bottom: 1px solid var(--border);
}
.stat {
  min-width: 110px; padding: 6px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center;
}
.stat .num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat .num.err { color: var(--red); }
.stat .num.warn { color: var(--amber); }
.stat .num.blue { color: var(--accent); }
.stat .lbl { font-size: 11px; color: var(--dim); margin-top: 2px; }
.stat.grow { flex: 1; min-width: 260px; }
.stat-title { font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.bars { display: flex; flex-direction: column; gap: 3px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.bar-label { width: 96px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }
.bar-track { flex: 1; height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #60a5fa); border-radius: 4px; min-width: 2px; }
.bar-count { width: 28px; text-align: right; color: var(--text); font-weight: 600; flex: none; }

/* ---------- 主布局 ---------- */
.layout {
  flex: 1; display: flex; gap: 16px; padding: 16px 20px;
  min-height: 0;
}
.pane {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 0;
}
.pane.editor { flex: 1; min-width: 0; }
.pane.issues { width: 420px; flex: none; }

.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border);
  flex: none;
}
.pane-head.col { flex-direction: column; align-items: stretch; gap: 8px; }
.pane-head .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pane-head h2 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pane-head .count { font-size: 11px; color: var(--dim); font-weight: 400; }

.tabs { display: flex; gap: 4px; }
.tab {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--dim);
}
.tab:hover { background: var(--bg); }
.tab.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }

.editor-actions { display: flex; align-items: center; gap: 8px; }
.auto { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* ---------- 编辑器 ---------- */
#inputText {
  flex: 1; border: none; outline: none; resize: none;
  padding: 16px; font-size: 15px; line-height: 1.9;
  font-family: inherit; color: var(--text); background: var(--card);
  min-height: 0;
}
.view { flex: 1; overflow: auto; padding: 16px; min-height: 0; }
.hl-body { font-size: 15px; line-height: 2; white-space: pre-wrap; word-break: break-all; }

mark.err {
  background: var(--red-weak); color: #b91c1c;
  padding: 1px 3px; border-radius: 3px; font-weight: 700;
  cursor: pointer; border-bottom: 2px solid #f87171;
  transition: box-shadow .2s;
}
mark.err:hover, mark.err.flash { box-shadow: 0 0 0 3px rgba(220, 38, 38, .25); }
mark.err.c-med { border-bottom-color: #fbbf24; background: #fef3c7; color: #92400e; }
mark.err.c-low { border-bottom-color: #93c5fd; background: #dbeafe; color: #1d4ed8; }

.corr-del { background: var(--red-weak); color: #b91c1c; text-decoration: line-through; padding: 0 2px; }
.corr-ins { background: var(--green-weak); color: #15803d; font-weight: 700; padding: 0 2px; border-bottom: 2px solid #86efac; }
.corr-sus { background: #fef3c7; color: #92400e; font-weight: 700; padding: 0 2px; border-bottom: 2px dashed #f59e0b; }

/* ---------- 问题面板 ---------- */
.search {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; outline: none; min-width: 0;
}
.search:focus { border-color: var(--accent); }
.select {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px; font-size: 12px; outline: none; background: var(--card);
}
.cat-filter {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); max-height: 96px; overflow: auto;
}
.cat-chip {
  border: 1px solid var(--border); background: var(--card); color: var(--dim);
  border-radius: 999px; padding: 4px 12px; font-size: 11px; cursor: pointer;
}
.cat-chip:hover { background: var(--bg); }
.cat-chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.cat-none { font-size: 12px; color: var(--dim); }

.issue-list { flex: 1; overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.issue-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
  background: var(--card);
}
.issue-card:hover { border-color: #c7d2fe; box-shadow: var(--shadow); }
.issue-card.flash { box-shadow: 0 0 0 3px rgba(37, 99, 235, .25); border-color: var(--accent); }
.ic-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.ic-pos { font-size: 11px; color: var(--dim); margin-left: auto; }
.ic-del {
  flex: none; font-size: 11px; line-height: 1; color: var(--dim);
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.ic-del:hover { color: #b91c1c; border-color: #fca5a5; background: var(--red-weak); }
.chip { font-size: 10px; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; }
.chip.cat { background: var(--accent-weak); color: var(--accent); }
.chip.c-high { background: var(--red-weak); color: #b91c1c; }
.chip.c-med { background: #fef3c7; color: #92400e; }
.chip.c-low { background: #dbeafe; color: #1d4ed8; }
.chip.ai-src { background: #ede9fe; color: #6d28d9; border-color: #c4b5fd; font-weight: 700; }
.ic-body { font-size: 13px; line-height: 1.7; }
.ic-orig .red, .red { color: #b91c1c; font-weight: 700; }
.ic-fix .green, .green { color: #15803d; font-weight: 700; }
.ic-note { color: var(--dim); font-size: 12px; margin-top: 3px; }
.fix-badge {
  display: inline-block; margin-top: 6px; font-size: 11px;
  background: var(--green-weak); color: #15803d; padding: 2px 8px; border-radius: 999px;
}

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--dim); }
.empty .big { font-size: 16px; font-weight: 600; color: var(--dim); }
.dim { color: var(--dim); font-size: 12px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  z-index: 50; display: flex; align-items: center; justify-content: center;
}
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-box {
  background: var(--card); border-radius: 14px; width: 560px; max-width: 94vw;
  max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
  overflow: hidden;
}
.modal-box.wide { width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; }
.close {
  border: none; background: transparent; font-size: 22px; color: var(--dim);
  cursor: pointer; line-height: 1; padding: 2px 8px;
}
.close:hover { color: var(--red); }
.modal-body { padding: 16px 18px; overflow: auto; }

.hidden { display: none !important; }

/* ---------- 词库管理 ---------- */
.lib-meta { font-size: 13px; margin-bottom: 10px; }
.lib-meta b { color: var(--accent); }
.lib-actions { display: flex; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }
.lib-count { font-size: 12px; color: var(--dim); margin: 6px 0; }
.lib-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lib-table th, .lib-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.lib-table th { background: var(--bg); font-weight: 600; }
.lib-table td.ops { white-space: nowrap; display: flex; gap: 6px; }
.lib-table tr:hover td { background: #fafbfc; }
.lib-empty { color: var(--dim); padding: 30px; text-align: center; }

/* ---------- 设置 ---------- */
.set-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; cursor: pointer; }
.set-row.main { font-weight: 600; }
.set-title { font-size: 12px; color: var(--dim); margin: 12px 0 6px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.set-grid .set-row { border-bottom: 1px dashed #f0f2f5; }
.set-divider { border-top: 1px solid var(--border); margin: 16px 0 4px; }

/* ---------- AI 专家检测配置 ---------- */
.ai-config { margin-top: 4px; }
.ai-config .form-row input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.ai-config-note { line-height: 1.6; margin: 6px 0 10px; }
.ai-config-actions { display: flex; align-items: center; gap: 8px; }
.ai-status { font-size: 12px; color: var(--dim); }
.ai-status.ok { color: #16a34a; }
.ai-status.err { color: #dc2626; }

/* 模式切换 */
.ai-mode-toggle { display: flex; gap: 8px; margin: 8px 0 12px; }
.ai-mode-btn {
  flex: 1; padding: 8px 12px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); transition: all .15s;
}
.ai-mode-btn:hover { border-color: var(--accent); }
.ai-mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* 免费提示 */
.ai-free-hint { margin: -6px 0 10px; }
.ai-free-tip { font-size: 12px; color: #b45309; background: #fef3c7; padding: 4px 8px; border-radius: 6px; display: inline-block; }
.ai-free-tip a { color: #92400e; font-weight: 600; }
.ai-free-note { font-size: 12px; color: #6b7280; background: #f3f4f6; padding: 10px; border-radius: 8px; line-height: 1.7; margin-bottom: 8px; }
.ai-free-banner { font-size: 12px; color: #166534; background: #dcfce7; padding: 8px 10px; border-radius: 8px; line-height: 1.7; margin-bottom: 10px; border: 1px solid #bbf7d0; }

/* 本地代理模式 */
.ai-proxy-note { font-size: 12px; color: #6b7280; background: #eef2ff; padding: 10px; border-radius: 8px; line-height: 1.7; margin-bottom: 8px; }
.ai-proxy-note code { background: #e0e7ff; padding: 1px 5px; border-radius: 4px; color: #4338ca; }
.ai-proxy-status { display: block; margin-top: 6px; font-weight: 600; }
.ai-proxy-status.ok { color: #16a34a; }
.ai-proxy-status.err { color: #dc2626; }

/* 高级设置折叠 */
.ai-adv { margin: 4px 0 8px; }
.ai-adv summary { font-size: 12px; color: var(--dim); cursor: pointer; padding: 4px 0; }
.ai-adv summary:hover { color: var(--accent); }
.ai-adv .form-row { margin-top: 8px; }

/* ---------- 帮助 ---------- */
.help-body h4 { margin: 14px 0 6px; font-size: 13px; color: var(--accent); }
.help-body p, .help-body li { font-size: 13px; line-height: 1.8; color: var(--text); }
.help-body ul { padding-left: 20px; }
.help-body li { margin-bottom: 4px; }

/* ---------- 表单 ---------- */
.form-row { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); margin-bottom: 12px; }
.form-row input, .form-row textarea, .form-row select {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; outline: none; font-family: inherit; color: var(--text);
}
.form-row input:focus, .form-row textarea:focus { border-color: var(--accent); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s;
  z-index: 100; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .pane.issues { width: auto; height: 40vh; }
  .topbar { flex-wrap: wrap; }
  .dict-ver { display: none; }
}

/* ============ 公文排版（修正稿） ============ */
.doc-page {
  background: #fff;
  margin: 16px auto;
  padding: 3.5cm 2.6cm 3cm 2.8cm; /* 上3.5 右2.6 下3 左2.8 */
  max-width: 21cm;
  min-height: 29.7cm;
  box-shadow: 0 1px 6px rgba(15, 23, 42, .14);
  color: #000;
  font-size: 16pt; /* 三号 */
  line-height: 30pt; /* 行间距 30 磅 */
  text-align: justify; /* 两端对齐 */
  text-justify: inter-ideograph; /* 中文两端对齐 */
  line-break: strict; /* 中文标点禁则：句逗顿分冒问叹、右括号右引号不出现在行首 */
  word-break: break-word;
}
.doc-title {
  font-family: "方正小标宋简体", "STSong", "SimSun", serif;
  font-size: 22pt; /* 二号 */
  font-weight: normal;
  text-align: center;
  margin: 0 0 22px;
  line-height: 30pt;
}
.doc-h1 { font-family: "SimHei", "黑体", "Microsoft YaHei", sans-serif; font-size: 16pt; font-weight: normal; margin: 10px 0 4px; text-align: left; }
.doc-h2 { font-family: "KaiTi", "STKaiti", "楷体", serif; font-size: 16pt; font-weight: normal; margin: 8px 0 2px; text-align: left; }
.doc-h3 { font-family: "FangSong", "STFangsong", "仿宋", serif; font-size: 16pt; font-weight: bold; margin: 6px 0 0; text-align: left; }
.doc-body { font-family: "FangSong", "STFangsong", "仿宋", serif; font-size: 16pt; text-indent: 2em; margin: 0; text-align: justify; text-justify: inter-ideograph; }
.doc-empty { font-family: "FangSong", "STFangsong", "仿宋", serif; font-size: 16pt; text-indent: 2em; }
