/* ===================================================
   文心批改 — 视觉样式
   纸感底 + 朱红批改笔 + 墨绿辅助色
   =================================================== */

:root {
  --bg: #f4f1e9;
  --bg-grad: radial-gradient(1200px 600px at 8% -10%, #fdfaf2 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #eef1ea 0%, transparent 55%);
  --surface: #fffdf7;
  --surface2: #faf6ec;
  --surface3: #f2ece0;
  --ink: #1e222b;
  --ink2: #454b59;
  --muted: #868d9c;
  --line: #e2dac9;
  --line-soft: #efe9db;
  --accent: #b23a2e;
  --accent-hover: #9a3025;
  --accent-soft: #f7e5e1;
  --teal: #2e6e68;
  --teal-soft: #e3efeb;
  --gold: #a97e22;
  --gold-soft: #f7eed7;
  --blue: #2f5d8a;
  --blue-soft: #e4edf6;
  --violet: #6a4b8f;
  --violet-soft: #ece6f4;
  --shadow-sm: 0 1px 2px rgba(30, 34, 43, .05);
  --shadow: 0 1px 2px rgba(30, 34, 43, .04), 0 10px 30px -18px rgba(30, 34, 43, .28);
  --shadow-lg: 0 2px 6px rgba(30, 34, 43, .06), 0 30px 60px -30px rgba(30, 34, 43, .35);
  --r: 16px;
  --r-sm: 10px;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", Inter, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  --bg: #14161b;
  --bg-grad: radial-gradient(1000px 560px at 6% -12%, #1d2028 0%, transparent 62%),
             radial-gradient(900px 520px at 100% 0%, #17201e 0%, transparent 58%);
  --surface: #1c1f26;
  --surface2: #22262e;
  --surface3: #2a2f38;
  --ink: #e9e6df;
  --ink2: #b9bec9;
  --muted: #868e9d;
  --line: #2e333d;
  --line-soft: #262b33;
  --accent: #e2685a;
  --accent-hover: #ef7d70;
  --accent-soft: #3a2422;
  --teal: #63b8ac;
  --teal-soft: #1c2f2c;
  --gold: #d9b063;
  --gold-soft: #332a19;
  --blue: #7ea9d6;
  --blue-soft: #1c2735;
  --violet: #b192d8;
  --violet-soft: #2a2338;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 34px -20px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .4), 0 36px 70px -34px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

/* 关键：作者样式里的 display 会覆盖 [hidden] 的 UA 规则，这里强制生效 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

svg.ico, .icon-btn svg { width: 16px; height: 16px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: 0 0 auto;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 3px 10px -3px color-mix(in srgb, var(--accent) 60%, transparent);
  flex: 0 0 auto;
}

.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .06em;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface2);
  white-space: nowrap;
  transition: .2s;
}
.badge.on { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 40%, var(--line)); background: var(--teal-soft); }
.badge.off { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, var(--line)); background: var(--gold-soft); }
.badge.warn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); }

/* ---------------- 按钮 ---------------- */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, transform .12s, box-shadow .16s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }

.btn.ghost { background: transparent; color: var(--ink2); }
.btn.ghost:hover { background: var(--surface3); color: var(--ink); }

.btn.line { background: var(--surface); color: var(--ink2); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn.line:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent); }

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px -10px color-mix(in srgb, var(--accent) 80%, transparent);
  padding: 9px 16px;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .16);
  line-height: 1.5;
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink2);
  cursor: pointer;
  transition: .16s;
}
.icon-btn:hover { background: var(--surface3); color: var(--ink); }

/* ---------------- 布局 ---------------- */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(420px, 1.28fr);
  gap: 18px;
  padding: 18px 20px 20px;
  overflow: hidden;
}

.col { min-height: 0; min-width: 0; display: flex; }
.col-input { justify-content: stretch; }
.col-result { min-height: 0; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  min-width: 0;
}

.input-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}
.card-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink);
}
.counter { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 控件行 */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .06em;
  padding-left: 2px;
}
.field select, .field input {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: .16s;
  width: 100%;
  min-width: 0;
}
.field select:focus, .field input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.field.block { margin-bottom: 14px; }
.field.block > span { font-size: 12px; margin-bottom: 2px; }

/* 模型字段：标签行 + 测试按钮 + 诊断结果 */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .06em;
  padding-left: 2px;
  margin-bottom: 2px;
}
.mini-btn {
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.mini-btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent); }
.mini-btn:disabled { opacity: .55; cursor: default; }
.conn-test {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  padding-left: 2px;
  word-break: break-word;
}
.conn-test.good { color: var(--teal); }
.conn-test.bad { color: var(--accent); }
.conn-test.warn { color: var(--gold); }

/* 编辑区 */
.editor-wrap {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  padding: 0 12px;
  display: flex;
}
#essay {
  flex: 1;
  width: 100%;
  min-width: 0;
  resize: none;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0, transparent 30px,
      color-mix(in srgb, var(--line) 42%, transparent) 30px,
      color-mix(in srgb, var(--line) 42%, transparent) 31px);
  background-color: var(--surface2);
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 31px;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
#essay::placeholder { color: var(--muted); font-family: var(--sans); font-size: 13.5px; line-height: 31px; }
#essay:focus {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background-color: var(--surface);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 14px;
  flex-wrap: wrap;
}
.lang-tag {
  font-size: 11.5px;
  color: var(--teal);
  background: var(--teal-soft);
  border: 1px solid color-mix(in srgb, var(--teal) 28%, transparent);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  transition: .2s;
}
.lang-tag.idle { color: var(--muted); background: var(--surface2); border-color: var(--line); }
.foot-actions { display: flex; align-items: center; gap: 6px; }

/* ---------------- 结果区 ---------------- */
.result-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.result-scroll::-webkit-scrollbar { width: 9px; }
.result-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--line) 90%, transparent);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.result-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

.empty {
  height: 100%;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.empty-art svg { width: 112px; height: 112px; opacity: .95; }
.empty h3 {
  margin: 14px 0 6px;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: .1em;
  font-weight: 700;
}
.empty-sub { margin: 0 0 20px; font-size: 13px; color: var(--muted); letter-spacing: .04em; }

.steps {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
  max-width: 330px;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink2);
}
.steps b {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.empty-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.empty-note { margin: 18px 0 0; font-size: 11.5px; color: var(--muted); max-width: 420px; line-height: 1.7; }

/* 报告容器 */
#resultBody { display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }

/* 报告头部卡 */
.report-head {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.report-head::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--accent), color-mix(in srgb, var(--accent) 25%, transparent));
}
.rh-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.rh-meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rh-kicker {
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--muted);
  text-transform: uppercase;
}
.rh-meta h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: .04em;
}
.rh-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--ink2);
}
.tag.ai { color: var(--teal); background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal) 28%, transparent); }
.tag.local { color: var(--gold); background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 30%, transparent); }

/* 分数环 */
.score-ring { position: relative; width: 106px; height: 106px; flex: 0 0 auto; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--surface3); }
.score-ring .ring-fg { stroke: var(--accent); transition: stroke-dashoffset 1s cubic-bezier(.22,1,.36,1); }
.score-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
}
.score-num {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.score-den { font-size: 10.5px; color: var(--muted); }
.score-level { font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: .05em; }

/* 维度 */
.dims { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.dim { min-width: 0; }
.dim-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.dim-name { font-size: 12.5px; color: var(--ink2); font-weight: 500; }
.dim-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 5px; border-radius: 99px; background: var(--surface3); overflow: hidden; }
.bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 62%, var(--gold)), var(--accent));
  width: 0;
  transition: width .9s cubic-bezier(.22,1,.36,1);
}
.dim-comment { margin: 5px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.6; }

.summary {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--line-soft);
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink2);
  font-family: var(--serif);
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

/* 通用小节 */
.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.section-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-head h3 .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.section-head .count-pill {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.section-body { padding: 16px 18px; }

/* 亮点 / 建议 两列 */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.list-block { }
.list-block h4 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}
.plain-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 9px; }
.plain-list li {
  position: relative;
  padding-left: 22px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink2);
}
.plain-list li::before {
  content: "";
  position: absolute;
  left: 6px; top: 9px;
  width: 6px; height: 6px;
  border-radius: 2px;
  background: var(--teal);
  transform: rotate(45deg);
}
.plain-list.warn li::before { background: var(--gold); border-radius: 50%; transform: none; }

/* 批注 */
.anno-list { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; }
.anno {
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  background: var(--surface2);
  padding: 11px 13px;
  transition: .18s;
  scroll-margin-top: 14px;
}
.anno:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--surface); }
.anno.flash { animation: flash 1.1s ease; }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
  100% { box-shadow: 0 0 0 10px transparent; background: var(--surface2); }
}
.anno-head { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; flex-wrap: wrap; }
.anno-idx {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  min-width: 16px;
}
.chip {
  font-size: 10.5px;
  padding: 1.5px 7px;
  border-radius: 5px;
  font-weight: 500;
  letter-spacing: .04em;
  border: 1px solid transparent;
}
.chip.grammar   { color: var(--blue);   background: var(--blue-soft);   border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.chip.spelling  { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.chip.word      { color: var(--violet); background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 25%, transparent); }
.chip.structure { color: var(--teal);   background: var(--teal-soft);   border-color: color-mix(in srgb, var(--teal) 25%, transparent); }
.chip.punctuation { color: var(--gold); background: var(--gold-soft);   border-color: color-mix(in srgb, var(--gold) 28%, transparent); }
.chip.style     { color: var(--violet); background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 25%, transparent); }
.chip.logic     { color: var(--teal);   background: var(--teal-soft);   border-color: color-mix(in srgb, var(--teal) 25%, transparent); }

.sev { font-size: 10px; padding: 1px 6px; border-radius: 4px; color: var(--muted); background: var(--surface3); }
.sev.high {
  color: var(--accent);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.quote {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  margin-bottom: 8px;
  line-height: 1.7;
  word-break: break-word;
}
.quote::before { content: "「"; color: var(--accent); opacity: .6; }
.quote::after  { content: "」"; color: var(--accent); opacity: .6; }

.anno-issue { font-size: 13px; line-height: 1.75; color: var(--ink2); margin: 0 0 6px; }
.anno-fix {
  font-size: 13px;
  line-height: 1.75;
  color: var(--teal);
  margin: 0;
  padding-left: 9px;
  border-left: 2px solid color-mix(in srgb, var(--teal) 40%, transparent);
}
.anno-fix b { font-weight: 600; }
.anno-rewrite {
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  background: color-mix(in srgb, var(--teal-soft) 60%, var(--surface));
  border-radius: 7px;
  padding: 7px 10px;
  word-break: break-word;
}
.anno-rewrite .lbl {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--teal);
  display: block;
  margin-bottom: 2px;
}

/* 原文对照（高亮） */
.essay-view {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 2;
  color: var(--ink2);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 16px 18px;
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent 28px, color-mix(in srgb, var(--line) 30%, transparent) 28px, color-mix(in srgb, var(--line) 30%, transparent) 29px);
}
.essay-view mark {
  background: transparent;
  color: var(--ink);
  border-radius: 3px;
  padding: 1px 1px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: .15s;
}
.essay-view mark:hover { filter: brightness(.96); }
.essay-view mark.t-grammar,
.essay-view mark.t-spelling { text-decoration-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.essay-view mark.t-word,
.essay-view mark.t-style { text-decoration-color: var(--violet); background: color-mix(in srgb, var(--violet-soft) 70%, transparent); }
.essay-view mark.t-structure,
.essay-view mark.t-logic { text-decoration-color: var(--teal); background: color-mix(in srgb, var(--teal-soft) 70%, transparent); }
.essay-view mark.t-punctuation { text-decoration-color: var(--gold); background: color-mix(in srgb, var(--gold-soft) 80%, transparent); }
.essay-view mark.hi {
  box-shadow: 0 0 0 2px var(--accent);
  border-radius: 3px;
}

/* 深色模式下 soft 背景太暗，改用半透明主色，高亮才看得出来 */
html[data-theme="dark"] .essay-view mark.t-grammar,
html[data-theme="dark"] .essay-view mark.t-spelling { background: color-mix(in srgb, var(--accent) 26%, transparent); }
html[data-theme="dark"] .essay-view mark.t-word,
html[data-theme="dark"] .essay-view mark.t-style { background: color-mix(in srgb, var(--violet) 26%, transparent); }
html[data-theme="dark"] .essay-view mark.t-structure,
html[data-theme="dark"] .essay-view mark.t-logic { background: color-mix(in srgb, var(--teal) 26%, transparent); }
html[data-theme="dark"] .essay-view mark.t-punctuation { background: color-mix(in srgb, var(--gold) 28%, transparent); }

/* 修改稿 */
.polished {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 2.05;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 18px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--line-soft);
}
.section-actions { display: flex; gap: 6px; }

/* 空/加载 */
.loading-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 26px 24px;
}
.loading-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .05em;
  margin-bottom: 18px;
}
.pen {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.load-steps { display: flex; flex-direction: column; gap: 10px; }
.load-step {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--muted);
  transition: .3s;
}
.load-step .bullet {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid; place-items: center;
  flex: 0 0 auto;
  font-size: 9px;
  color: transparent;
}
.load-step.done { color: var(--ink2); }
.load-step.done .bullet { border-color: var(--teal); background: var(--teal); color: #fff; }
.load-step.active { color: var(--ink); font-weight: 500; }
.load-step.active .bullet { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }

.stream-note {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
  line-height: 1.6;
  max-height: 54px;
  overflow: hidden;
  opacity: .8;
}

.error-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.error-card h4 { margin: 0 0 8px; font-size: 14px; color: var(--accent); }
.error-card p { margin: 0 0 10px; font-size: 13px; line-height: 1.8; color: var(--ink2); }
.error-card pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--surface2);
  padding: 10px;
  border-radius: 8px;
  max-height: 160px;
  overflow: auto;
}

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0;
  background: color-mix(in srgb, #0b0d11 55%, transparent);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  animation: pop .22s cubic-bezier(.22,1,.36,1);
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-head h3 { margin: 0; font-family: var(--serif); font-size: 15px; letter-spacing: .08em; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  position: sticky; bottom: 0;
  background: var(--surface);
}

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0 14px;
  border-top: 1px solid var(--line-soft);
  margin-top: 4px;
}
.switch-row strong { display: block; font-size: 13px; font-weight: 500; }
.switch-row small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0;
  background: var(--surface3);
  border: 1px solid var(--line);
  border-radius: 99px;
  cursor: pointer;
  transition: .2s;
}
.switch i::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  top: 2px; left: 2px;
  transition: .2s;
}
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

.tip-box {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink2);
}
.tip-box p { margin: 0 0 7px; }
.tip-box p:last-child { margin-bottom: 0; }
.tip-box ul { margin: 0 0 7px; padding-left: 17px; }
.tip-box li { margin-bottom: 5px; }
.tip-box code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface3);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
}
.tip-sm { color: var(--muted); font-size: 11.5px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  padding: 9px 16px;
  border-radius: 99px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: .22s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1024px) {
  body { overflow: auto; }
  .layout {
    grid-template-columns: 1fr;
    overflow: visible;
    height: auto;
    padding: 14px;
    gap: 14px;
  }
  .col { min-height: auto; }
  .input-card { min-height: 540px; }
  #essay { min-height: 340px; }
  .result-scroll { overflow: visible; min-height: auto; }
  .empty { min-height: 380px; }
}

@media (max-width: 620px) {
  .topbar { height: 56px; padding: 0 13px; }
  .brand-text h2 { font-size: 15px; }
  .brand-text p { display: none; }
  .badge { display: none; }
  .controls { grid-template-columns: 1fr; }
  .editor-foot { padding: 10px 13px 13px; }
  .btn kbd { display: none; }
  .rh-top { gap: 14px; }
  .score-ring { width: 88px; height: 88px; }
  .score-num { font-size: 25px; }
  .dims { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .empty { padding: 26px 16px; }
  .empty-art svg { width: 88px; height: 88px; }
  .empty h3 { font-size: 19px; }
  .steps { font-size: 12.5px; }
  .report-head { padding: 16px; }
  .section-body { padding: 14px; }
  .essay-view, .polished { padding: 14px; font-size: 14px; }
  .toast { bottom: 16px; }
}

@media print {
  @page { margin: 14mm 12mm; }
  .topbar, .col-input, .empty, .modal-mask, .toast, .section-actions, .report-actions { display: none !important; }
  body { overflow: visible; background: #fff; }
  .layout { display: block; padding: 0; overflow: visible; height: auto; }
  .result-scroll { overflow: visible; }
  .col-result { display: block; }
  .section, .report-head, .anno { break-inside: avoid; box-shadow: none; }
  .anno-list { padding: 12px 14px; }
  .essay-view { background: none; }
}
