/* ============================================================
   408 学习助手 · 视觉系统 v2
   参考：www.mikusama.online/helpdesk（用户自己的站，token 直接取自其 styles.css）
   概念：试卷与朱批
     · 页面 = 摊开的卷子：暖米纸底 + SVG 纸纹 + 1.5px 墨线 + 方角 + 硬投影（活字印刷感）
     · 对错与助手讲解 = 落在卷面上的朱批（印泥红 #b23a26）
     · 题号/计时/统计用等宽；标题用宋体；正文黑体
   ============================================================ */
:root {
  /* 纸与墨 */
  --paper: #e9deca;
  --paper-deep: #ddd0b8;
  --slip: #fcf8f0;
  --slip-2: #f6f0e4;
  --ink: #1f1b16;
  --ink-soft: #6b6152;
  --ink-faint: #9a8f7c;
  --rule: #cec2ab;
  --rule-strong: #a89a80;
  /* 印章四色 */
  --stamp: #b23a26;
  --stamp-dark: #7e2416;
  --stamp-blue: #2c5578;
  --stamp-green: #2c6342;
  --stamp-gray: #736b5f;
  /* 硬投影（无模糊） */
  --shadow: 5px 5px 0 rgba(31, 27, 22, .1);
  --shadow-sm: 3px 3px 0 rgba(31, 27, 22, .12);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E");
  /* 字族 */
  --font-display: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", SimSun, Georgia, serif;
  --font-body: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "DejaVu Sans Mono", monospace;
  /* 兼容旧变量名（组件仍在用） */
  --bg: var(--paper); --bg-2: var(--slip); --bg-3: var(--slip-2);
  --line: var(--rule); --fg: var(--ink); --fg-2: var(--ink-soft);
  --ok: var(--stamp-green); --bad: var(--stamp); --warn: #a8741a; --acc: var(--stamp-blue);
  /* 字号阶梯（5 档） */
  --t-xs: 12px; --t-sm: 13.5px; --t-md: 15px; --t-lg: 18px; --t-xl: 24px;
  --lh: 1.7; --lh-prose: 1.9;
  --measure: 66ch;
  /* 方角（参考站仅个别小件用 3px） */
  --r-card: 0; --r-ctl: 0; --r-pill: 0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
body {
  background: var(--paper); background-image: var(--grain); color: var(--ink);
  font: var(--t-md)/var(--lh) var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: .02em; line-height: 1.25; }
code, .mono, .num { font-family: var(--font-mono); font-variant-ligatures: none; }

/* 按钮：方角 + 墨线 + 硬投影 */
button {
  appearance: none; font: inherit; font-size: var(--t-sm); cursor: pointer;
  padding: 7px 14px; border: 1.5px solid var(--ink); background: var(--slip); color: var(--ink);
  box-shadow: var(--shadow-sm); border-radius: 0;
  transition: background .12s ease, color .12s ease, transform .06s ease;
}
button:hover { background: var(--slip-2); }
button:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 rgba(31, 27, 22, .12); }
button.on { background: var(--ink); color: var(--slip); border-color: var(--ink); }
button.mini { padding: 3px 9px; font-size: var(--t-xs); box-shadow: 2px 2px 0 rgba(31, 27, 22, .12); }
button.fill { background: var(--ink); border-color: var(--ink); color: var(--slip); }
button.fill:hover { background: #322b23; }
button.primary { background: var(--stamp); border-color: var(--stamp-dark); color: #fff; }
button.primary:hover { background: var(--stamp-dark); }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 1px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* 印章 */
.stamp {
  display: inline-block; font-family: var(--font-display); font-weight: 700; font-size: var(--t-xs);
  letter-spacing: .2em; text-indent: .2em; padding: 4px 8px 3px;
  border: 2px solid currentColor; color: var(--stamp); background: transparent;
}
.stamp--green { color: var(--stamp-green); }
.stamp--blue { color: var(--stamp-blue); }
.stamp--gray { color: var(--stamp-gray); }

/* ---------- 顶栏 ---------- */
header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px; padding: 11px 18px;
  background: var(--slip); background-image: var(--grain);
  border-bottom: 1.5px solid var(--ink); position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--font-display); font-size: var(--t-lg); font-weight: 700; letter-spacing: .04em; }
.brand span { color: var(--stamp); font-family: var(--font-mono); font-size: var(--t-md); }
nav { display: flex; gap: 6px; }
nav button { box-shadow: none; border-color: var(--rule-strong); background: transparent; color: var(--ink-soft); }
nav button:hover { background: var(--slip-2); color: var(--ink); }
nav button.on { background: var(--ink); color: var(--slip); border-color: var(--ink); }
.stat { color: var(--ink-soft); font-size: var(--t-xs); display: flex; align-items: baseline; }
.stat span { padding: 0 10px; border-left: 1px solid var(--rule); }
.stat span:first-child { border-left: 0; padding-left: 0; }
.stat b { color: var(--ink); font-family: var(--font-mono); }

main { display: flex; flex: 1 1 auto; min-height: 0; }

/* ---------- 全局科目条（台账索引标签） ---------- */
#subjectbar {
  flex: 0 0 auto; display: flex; align-items: flex-end;
  background: var(--paper-deep); background-image: var(--grain);
  border-bottom: 1.5px solid var(--ink); padding: 0 20px; overflow-x: auto;
}
.subjtab {
  display: flex; flex-direction: column; gap: 3px; min-width: 196px; flex: 0 0 auto;
  padding: 11px 18px 9px; cursor: pointer; background: transparent; color: var(--ink);
  border: 1.5px solid transparent; border-bottom: 0; box-shadow: none;
  margin-bottom: -1.5px;                          /* 选中时盖住下方墨线 → 标签页效果 */
  transition: background .12s ease;
}
.subjtab:hover { background: var(--slip-2); }
.subjtab.on { background: var(--slip); border-color: var(--ink); color: var(--ink); }
.subjtab .rowtop { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.subjtab .name { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.subjtab .wt { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); border: 1px solid var(--rule-strong); padding: 0 5px; white-space: nowrap; }
.subjtab.on .wt { color: var(--stamp); border-color: var(--stamp); }
.subjtab .meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }
.subjtab .bar { display: block; width: 100%; height: 4px; background: var(--slip-2); border: 1px solid var(--rule); margin-top: 2px; }
.subjtab.on .bar { border-color: var(--rule-strong); }
.subjtab .bar i { display: block; height: 100%; }

/* ---------- 侧栏（装订线） ---------- */
#side {
  width: 264px; min-width: 264px; background: var(--slip-2); background-image: var(--grain);
  border-right: 1px solid var(--rule-strong); overflow: auto; padding: 14px 12px;
}
#side-head { display: none; }
.chip {
  padding: 3px 10px; border: 1px solid var(--rule-strong); background: var(--slip);
  cursor: pointer; font-size: var(--t-xs); color: var(--ink-soft);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--slip); }
.row {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; cursor: pointer;
  font-size: var(--t-sm); border: 1px solid transparent;
}
.row:hover { background: var(--slip); border-color: var(--rule); }
.row.on { background: var(--slip); border-color: var(--ink); box-shadow: inset 3px 0 0 var(--stamp); }
.row .n { color: var(--ink-soft); font-size: var(--t-xs); margin-left: auto; white-space: nowrap; text-align: right; font-family: var(--font-mono); }
.bar { height: 5px; background: var(--paper-deep); overflow: hidden; margin-top: 4px; border: 1px solid var(--rule); }
.bar i { display: block; height: 100%; background: var(--ink); }

/* ---------- 主区：纸面票据 ---------- */
#stage { flex: 1; overflow: auto; padding: 26px 32px 64px; }
.card {
  background: var(--slip); background-image: var(--grain);
  border: 1.5px solid var(--ink); box-shadow: var(--shadow);
  padding: 24px 26px; max-width: 980px;
}
.qhead {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding-bottom: 11px; margin-bottom: 18px; border-bottom: 1.5px solid var(--ink);
}
.qhead .qid { font-family: var(--font-mono); font-weight: 600; font-size: var(--t-sm); letter-spacing: .06em; display: block; }
.qhead .kp { color: var(--ink-soft); font-size: var(--t-sm); display: block; margin-top: 3px; }
.qhead .warn { color: var(--stamp); font-size: var(--t-xs); border: 1px solid var(--stamp); padding: 1px 6px; }
.qhead .right { margin-left: auto; display: flex; align-items: baseline; gap: 14px; color: var(--ink-soft); font-size: var(--t-xs); font-family: var(--font-mono); }

.stem { font-size: var(--t-lg); line-height: var(--lh-prose); max-width: var(--measure); white-space: pre-wrap; }
.stemimg { max-width: 100%; border: 1.5px solid var(--ink); margin: 14px 0; background: #fff; box-shadow: var(--shadow-sm); }
.cap { color: var(--ink-soft); font-size: var(--t-xs); margin: 10px 0 4px; max-width: var(--measure); }

.opt {
  display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--rule-strong);
  background: var(--slip); padding: 11px 14px; margin: 8px 0; cursor: pointer; max-width: var(--measure);
}
.opt:hover { border-color: var(--ink); }
.opt.on { border-color: var(--ink); background: var(--slip-2); box-shadow: inset 3px 0 0 var(--ink); }
.opt.right { border-color: var(--stamp-green); background: #eef4ef; box-shadow: inset 3px 0 0 var(--stamp-green); }
.opt.wrong { border-color: var(--stamp); background: #fbf1ee; box-shadow: inset 3px 0 0 var(--stamp); }
.opt b { font-family: var(--font-mono); min-width: 20px; font-weight: 600; color: var(--ink-soft); }
.opt.right b { color: var(--stamp-green); }
.opt.wrong b { color: var(--stamp); }
.conf { display: flex; gap: 6px; align-items: center; margin: 16px 0 4px; color: var(--ink-soft); font-size: var(--t-xs); }
.conf button { padding: 3px 10px; font-size: var(--t-xs); box-shadow: none; border-color: var(--rule-strong); }
.conf button.on { background: var(--ink); color: var(--slip); border-color: var(--ink); }

/* 解析 = 朱批区 */
.res {
  margin-top: 18px; padding: 14px 16px; background: #fbf1ee; border-left: 4px solid var(--stamp);
  font-size: var(--t-md); line-height: var(--lh-prose); max-width: var(--measure); white-space: pre-wrap;
}
.res .tagline { display: block; margin-bottom: 8px; }
.res .kp { color: var(--ink-soft); font-size: var(--t-sm); margin-top: 6px; }
.kbar { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.timer { font-family: var(--font-mono); }
.timer.warn { color: var(--warn); }
.timer.bad { color: var(--stamp); }
.muted { color: var(--ink-soft); font-size: var(--t-sm); }
h3 { font-size: var(--t-lg); margin: 24px 0 10px; }
h4 { font-size: var(--t-md); margin: 16px 0 6px; }
.notice { border-left: 4px solid var(--stamp-blue); background: #eef3f8; padding: 9px 13px; font-size: var(--t-sm); margin: 12px 0; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 700; font-size: var(--t-xs); letter-spacing: .08em; border-bottom: 1.5px solid var(--ink); }
.score { display: inline-block; min-width: 56px; padding: 1px 8px; font-family: var(--font-mono); border: 1px solid currentColor; }
.s-hi { color: var(--stamp); background: #fbf1ee; }
.s-mid { color: var(--warn); background: #faf3e4; }
.s-lo { color: var(--stamp-green); background: #eef4ef; }

/* ---------- 输入 ---------- */
textarea, input {
  width: 100%; font: inherit; font-size: var(--t-md); color: var(--ink);
  background: var(--slip); border: 1.5px solid var(--rule-strong); padding: 9px 11px; resize: vertical;
}
textarea:focus, input:focus { border-color: var(--ink); outline: 2px solid var(--stamp); outline-offset: 1px; }
::placeholder { color: var(--ink-faint); }

/* ---------- 知识点详解 ---------- */
.md { font-size: var(--t-md); line-height: var(--lh-prose); max-width: var(--measure); }
.md h2 { font-size: var(--t-xl); margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 1.5px solid var(--ink); }
.md h3 { font-size: var(--t-lg); margin: 18px 0 8px; }
.md h4 { font-size: var(--t-md); margin: 14px 0 6px; color: var(--ink-soft); }
.md p { margin: 6px 0; }
.md ul { margin: 6px 0 6px 20px; }
.md li { margin: 3px 0; }
.md pre { background: var(--slip-2); border: 1px solid var(--rule-strong); padding: 10px; overflow: auto; font-family: var(--font-mono); font-size: var(--t-sm); }
.md code { background: var(--slip-2); border: 1px solid var(--rule); padding: 0 4px; font-family: var(--font-mono); font-size: .94em; }
.md a.qlink { color: var(--stamp-blue); text-decoration: none; border-bottom: 1px dotted var(--stamp-blue); font-family: var(--font-mono); }

/* ---------- 知识点树（目录条） ---------- */
.tree { font-size: var(--t-sm); }
.tree-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.tree-toolbar input { flex: 1; min-width: 220px; }
.tree-stat { color: var(--ink-soft); font-size: var(--t-xs); }
.tnode { margin: 0; }
.tnode > .tlabel { display: flex; align-items: center; gap: 8px; padding: 6px 8px; cursor: pointer; border: 1px solid transparent; }
.tnode > .tlabel:hover { background: var(--slip-2); border-color: var(--rule); }
.tnode > .tlabel .tw { color: var(--ink-soft); font-size: var(--t-xs); font-family: var(--font-mono); }
.tnode > .tlabel .tg { color: var(--ink-faint); font-size: 10px; transition: transform .12s ease; }
.tnode.open > .tlabel .tg { transform: rotate(90deg); }
.tnode > .tkids { display: none; margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--rule-strong); }
.tnode.open > .tkids { display: block; }
.tnode .lvl-subj > .tlabel { font-family: var(--font-display); font-size: var(--t-lg); font-weight: 700; }
.tnode .lvl-chap > .tlabel { font-family: var(--font-display); font-weight: 700; letter-spacing: .03em; }
.tnode .lvl-sec > .tlabel { color: var(--ink-soft); }
.terms { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 10px 8px; }
.term {
  border: 1px solid var(--rule-strong); background: var(--slip-2); color: var(--ink-soft);
  padding: 2px 8px; font-size: var(--t-xs); cursor: pointer;
}
.term:hover { border-color: var(--stamp); color: var(--stamp); background: #fbf1ee; }
.term.hit { border-color: var(--stamp); color: var(--stamp); background: #fbf1ee; }
.tnode.dim > .tlabel { opacity: .32; }
.tnode.hit > .tlabel { color: var(--stamp); }
.tempty { color: var(--ink-faint); font-size: var(--t-xs); padding: 4px 8px; }

/* ---------- 朱批（助手回复） ---------- */
.qchat { margin-top: 20px; padding-top: 14px; border-top: 1.5px solid var(--ink); max-width: var(--measure); }
.qchat-head { display: flex; align-items: center; gap: 10px; font-size: var(--t-xs); color: var(--ink-soft); margin-bottom: 10px; }
.qchat-body { max-height: 560px; overflow: auto; padding-right: 4px; }
.qcard { background: #fbf1ee; border: 1px solid var(--rule); border-left: 4px solid var(--stamp); padding: 12px 14px; margin: 10px 0; }
.qcard-h { font-size: var(--t-xs); color: var(--stamp); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.msg { white-space: pre-wrap; font-size: var(--t-md); line-height: var(--lh-prose); color: var(--ink); }
.msg.user { background: var(--slip-2); border: 1px solid var(--rule); padding: 10px 13px; margin-left: auto; max-width: 92%; }
.msg.partial { opacity: .8; }
.msg.partial::after { content: "▍"; color: var(--stamp); animation: blink 1.1s steps(2) infinite; }
.msg.thinking { color: var(--ink-soft); }
@keyframes blink { 50% { opacity: 0; } }
.qchat-input { display: flex; gap: 8px; margin-top: 10px; }
.qchat-input textarea { flex: 1; min-height: 46px; }
.thinking { color: var(--ink-soft); font-size: var(--t-sm); }
.ai-note { color: var(--ink-soft); font-size: var(--t-xs); }

/* ---------- 弹层 ---------- */
#modal { position: fixed; inset: 0; background: rgba(31, 27, 22, .45); display: flex; align-items: center; justify-content: center; z-index: 40; }
#modal-box {
  background: var(--slip); background-image: var(--grain); border: 1.5px solid var(--ink);
  box-shadow: var(--shadow); padding: 24px; min-width: 460px; max-width: 760px; max-height: 84vh; overflow: auto;
}

/* ---------- 可访问性 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 900px) {
  body { height: auto; overflow: auto; }
  #subjectbar { padding: 0 10px; }
  .subjtab { min-width: 140px; padding: 9px 12px 8px; }
  .subjtab .name { font-size: 15px; }
  main { flex-direction: column; }
  #side { width: 100%; min-width: 0; border-right: 0; border-bottom: 1px solid var(--rule-strong); }
  #stage { padding: 18px 16px 48px; }
  :root { --measure: 100%; }
}

/* 侧栏「上次做到哪」 */
.resume { border: 1px solid var(--rule-strong); background: var(--slip); padding: 8px 10px; margin: 8px 0 10px; font-size: var(--t-xs); }
.resume .muted { font-size: var(--t-xs); margin: 3px 0 7px; }
.resume .mono { font-weight: 600; }

/* 作答后的知识点块 */
.kpoint { margin-top: 16px; border: 1px solid var(--rule-strong); background: var(--slip); padding: 12px 14px; max-width: var(--measure); }
.kpoint-h { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.kpath { font-size: var(--t-sm); color: var(--ink); }
.kpoint .terms { padding: 0 0 6px 0; }
.kpoint .kbar { margin-top: 10px; }

/* 名词菜单（点名词弹出） */
.tmenu { position: absolute; z-index: 60; min-width: 168px; background: var(--slip); border: 1.5px solid var(--ink); box-shadow: var(--shadow); padding: 4px; }
.tmenu-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; box-shadow: none; padding: 7px 10px; font-size: var(--t-sm); }
.tmenu-item:hover { background: var(--slip-2); }
.tmenu-item:active { transform: none; }
.kclick { cursor: pointer; border-bottom: 1px dotted var(--rule-strong); }
.kclick:hover { color: var(--stamp); border-bottom-color: var(--stamp); }
select { font: inherit; font-size: var(--t-sm); color: var(--ink); background: var(--slip); border: 1.5px solid var(--rule-strong); padding: 4px 6px; }

/* 提示与弱点分标记 */
.hintnote { color: var(--stamp); font-size: var(--t-xs); border: 1px solid var(--stamp); padding: 0 6px; }
.wkn { font-size: var(--t-xs); color: var(--ink-soft); font-family: var(--font-mono); }
.wkn b { color: var(--stamp); }
.hintmark { color: var(--stamp); font-size: var(--t-xs); font-family: var(--font-mono); }

/* 偷看知识点的提示 */
.peek-note { border-left: 3px solid var(--warn); background: #faf3e4; padding: 6px 10px; margin: 8px 0; font-size: var(--t-xs); color: #7a5a12; }

/* ---------- 整卷模拟 ---------- */
.years { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.yearbtn { font-family: var(--font-mono); font-size: var(--t-md); padding: 9px 16px; }
.mock-top { display: flex; align-items: center; gap: 14px; padding-bottom: 11px; margin-bottom: 16px;
  border-bottom: 1.5px solid var(--ink); flex-wrap: wrap; }
.mock-timer { font-family: var(--font-mono); font-size: var(--t-xl); font-weight: 600; letter-spacing: .04em; }
.mock-timer.warn { color: var(--warn); }
.mock-timer.bad { color: var(--stamp); }
.mock-body { display: grid; grid-template-columns: 232px 1fr; gap: 26px; align-items: start; }
.mock-sheet { position: sticky; top: 8px; }
.sheet-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: 6px 0 2px; }
.sheet-n { padding: 4px 0; font-family: var(--font-mono); font-size: var(--t-xs); box-shadow: none;
  border-color: var(--rule-strong); background: var(--slip-2); color: var(--ink-soft); }
.sheet-n.done { background: var(--ink); border-color: var(--ink); color: var(--slip); }
.sheet-n.cur { outline: 2px solid var(--stamp); outline-offset: 1px; color: var(--stamp); }
.sheet-n.done.cur { color: var(--slip); }
.mock-q { min-width: 0; }
@media (max-width: 900px) { .mock-body { grid-template-columns: 1fr; } .mock-sheet { position: static; } }

.barhint { align-self: center; margin-left: 14px; padding: 3px 9px; font-size: var(--t-xs);
  color: var(--ink-soft); border: 1px dashed var(--rule-strong); }

/* ---------- 登录 / 注册 ---------- */
#auth { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--paper); background-image: var(--grain); overflow: auto; padding: 24px; }
.authcard { width: 100%; max-width: 420px; background: var(--slip); background-image: var(--grain);
  border: 1.5px solid var(--ink); box-shadow: var(--shadow); padding: 26px 26px 22px; }
.authcard .brand { font-size: var(--t-xl); margin-bottom: 4px; }
.tabs2 { display: flex; gap: 0; margin: 16px 0 14px; border-bottom: 1.5px solid var(--ink); }
.tabs2 button { border: 0; border-bottom: 3px solid transparent; box-shadow: none; background: transparent;
  color: var(--ink-soft); padding: 6px 14px; margin-bottom: -1.5px; }
.tabs2 button.on { color: var(--ink); border-bottom-color: var(--stamp); font-weight: 700; }
.flabel { display: block; font-size: var(--t-sm); color: var(--ink-soft); margin: 10px 0; }
.flabel input, .flabel select { display: block; margin-top: 5px; width: 100%; }
#who { box-shadow: none; border-color: var(--rule-strong); background: transparent; color: var(--ink-soft); }
#who:hover { color: var(--ink); border-color: var(--ink); }
.ai-steps { font-size: var(--t-xs); color: var(--ink-faint); margin: 4px 0 10px; font-family: var(--font-mono); }

/* 题干里的代码块 */
.stem .stemline { margin: 0 0 6px; }
.stem pre.code {
  font-family: var(--font-mono); font-size: 14.5px; line-height: 1.75;
  background: var(--slip-2); border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong);
  padding: 10px 14px; margin: 8px 0 12px; overflow-x: auto; white-space: pre;
}
.res pre.code { font-family: var(--font-mono); font-size: 13.5px; background: var(--slip-2); border: 1px solid var(--rule); padding: 8px 12px; white-space: pre-wrap; }

/* 题干里的填空线与空括号 */
.blank { display: inline-block; min-width: 5.5em; border-bottom: 1.5px solid var(--ink); margin: 0 .2em; vertical-align: baseline; }
.paren { white-space: nowrap; }

/* ---------- 公式渲染（$...$ 子集）与代码块 ---------- */
.math { font-family: "Cambria Math", "Latin Modern Math", "Times New Roman", Georgia, serif;
  font-style: italic; white-space: nowrap; }
.math sup, .math sub { font-style: normal; font-size: .7em; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center;
  margin: 0 .15em; line-height: 1.08; }
.frac > i { font-style: italic; padding: 0 .28em; }
.frac > i:first-child { border-bottom: 1.2px solid currentColor; }
.sqrt > i { border-top: 1.2px solid currentColor; padding: 0 .18em; font-style: italic; }
pre.code { background: var(--slip-2); border: 1px solid var(--rule-strong); padding: 8px 11px;
  margin: 8px 0; font-family: var(--font-mono); font-size: var(--t-sm); line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere; max-width: var(--measure); }

/* 错因本（我的错因） */
.mynote { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px;
  padding: 7px 10px; border-left: 4px solid var(--warn); background: #faf3e4; max-width: var(--measure); }
.notetag { font-family: var(--font-display); font-weight: 700; font-size: var(--t-xs); color: var(--warn); }
.notetext { font-size: var(--t-sm); }

/* ---------- 对话抽屉（流式 + 工具过程可见） ---------- */
body.chat-open main { margin-right: 424px; }
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; z-index: 30;
  background: var(--slip); background-image: var(--grain); border-left: 1.5px solid var(--ink);
  box-shadow: -5px 0 0 rgba(31, 27, 22, .07); display: flex; flex-direction: column; }
#drawer.hidden { display: none; }
.chat-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px;
  border-bottom: 1.5px solid var(--ink); }
.chat-head select { max-width: 168px; }
.chat-ctx { font-size: var(--t-xs); display: flex; align-items: center; gap: 4px; }
.chat-body { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; flex-direction: column; gap: 4px; max-width: 97%; }
.chat-msg.me { align-self: flex-end; align-items: flex-end; }
.chat-msg .bubble { padding: 9px 12px; border: 1px solid var(--rule-strong); background: var(--slip-2);
  font-size: var(--t-md); line-height: var(--lh-prose); overflow-wrap: anywhere; }
.chat-msg.ai .bubble { background: var(--slip); border-left: 4px solid var(--stamp); }
.chat-msg .bubble p { margin: 5px 0; }
.chat-msg .bubble ul, .chat-msg .bubble ol { margin: 5px 0 5px 20px; }
.chat-msg .bubble h3, .chat-msg .bubble h4, .chat-msg .bubble h5 { margin: 8px 0 4px; font-size: var(--t-md); }
.chat-msg .meta { font-size: var(--t-xs); color: var(--ink-faint); display: flex; gap: 8px; align-items: center; }
.chat-msg .meta button { box-shadow: none; padding: 0 6px; font-size: 11px; }
.chat-steps { font-size: var(--t-xs); }
.chat-steps summary { cursor: pointer; color: var(--ink-soft); }
.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--rule); }
.chat-compose { display: flex; gap: 8px; padding: 0 12px 6px; }
.chat-compose textarea { flex: 1; min-height: 40px; max-height: 160px; }
.chat-foot { padding: 0 12px 10px; font-size: var(--t-xs); }
.chat-empty { color: var(--ink-soft); font-size: var(--t-sm); line-height: var(--lh-prose); }
.chat-img { display: flex; gap: 8px; align-items: center; padding: 6px 12px; }
.chat-img img { max-height: 90px; border: 1px solid var(--rule-strong); }
.caret { display: inline-block; width: 6px; height: 1em; background: var(--stamp);
  vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@media (max-width: 900px) {
  body.chat-open main { margin-right: 0; }
  #drawer { width: 100%; }
}

/* 对话里的题目快照 */
.qs { border: 1px solid var(--rule-strong); background: var(--slip-2); padding: 6px 9px; margin-bottom: 2px; }
.chat-msg.me .qs { background: var(--slip); }
.qs-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: var(--t-xs); margin-bottom: 3px; }
.qs-s { font-size: var(--t-xs); color: var(--ink-soft); line-height: 1.55; }
.chat-msg .meta a, .muted a { color: var(--acc); }

/* ---------- 初音风格插图（大图氛围：明信片/贴纸，贴在纸面上） ---------- */
.illwrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0 18px; }
.illwrap .ill { display: block; max-width: 100%; border: 3px solid #fff;
  box-shadow: var(--shadow); background: var(--slip); }
.illwrap.wide .ill { max-height: 230px; width: auto; }
.illwrap:not(.wide) .ill { max-height: 300px; }
.illwrap .illcap { font-size: var(--t-xs); color: var(--ink-soft); letter-spacing: .04em; }
.illwrap:nth-child(odd) .ill { transform: rotate(-.6deg); }
.illwrap:nth-child(even) .ill { transform: rotate(.6deg); }

/* 登录页：左插画 + 右登录卡 */
.authwrap { display: flex; width: 100%; max-width: 1100px; height: 100vh; align-items: center; gap: 0; }
.authart { position: relative; flex: 1 1 46%; height: 100%; overflow: hidden; }
.authart img { width: 100%; height: 100%; object-fit: cover; object-position: 60% center; }
.authart::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(233,222,202,0) 62%, rgba(233,222,202,.92) 96%, var(--paper) 100%); }
.authart-cap { position: absolute; left: 22px; bottom: 26px; z-index: 2; color: #e9f6f4;
  font-family: var(--font-display); font-size: var(--t-md); letter-spacing: .08em;
  text-shadow: 0 1px 8px rgba(0,0,0,.55); }
.authwrap .authcard { flex: 0 0 420px; }
@media (max-width: 900px) { .authart { display: none; } .authwrap { justify-content: center; } }

/* 助手头像 */
.avatar { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--ink);
  object-fit: cover; background: var(--slip-2); }
.chat-head .muted { font-size: var(--t-xs); }

/* 科目条小图标 */
.subjicon { width: 20px; height: 20px; object-fit: cover; border: 1px solid var(--rule-strong);
  border-radius: 2px; vertical-align: -4px; }
.subjtab .rowtop { gap: 7px; }

/* ---------- 统一细滚动条（原来系统默认那条又宽又丑） ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); background-clip: content-box; }
::-webkit-scrollbar-corner, ::-webkit-scrollbar-button { background: transparent; height: 0; width: 0; }
pre.code::-webkit-scrollbar { height: 0; }

/* ============================================================
   手机端：同一网址自动判断（≤820px），无需单独域名/路由
   ============================================================ */
#side-toggle { display: none; }           /* 桌面不显示章节抽屉按钮 */
#side-backdrop { position: fixed; inset: 0; background: rgba(31, 27, 22, .38); z-index: 34; }
#side-backdrop.hidden { display: none; }

@media (max-width: 820px) {
  :root { --measure: 100%; --t-lg: 17px; --t-xl: 21px; --lh-prose: 1.8; }

  /* 顶栏：一行放不下就换行，导航横向滚动 */
  header { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .brand { font-size: var(--t-md); }
  #side-toggle { display: inline-flex; align-items: center; gap: 4px; }
  #today { display: none; }               /* 小屏藏顶栏统计（侧栏里能看到进度） */
  #who { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  nav { order: 5; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
        scrollbar-width: none; gap: 6px; padding-bottom: 2px; }
  nav::-webkit-scrollbar { height: 0; }
  nav button { padding: 8px 12px; white-space: nowrap; min-height: 36px; }

  /* 科目条：横向滑动 + 吸附 */
  #subjectbar { padding: 0 8px; scroll-snap-type: x proximity; }
  .subjtab { min-width: 116px; padding: 9px 10px 8px; scroll-snap-align: start; }
  .subjtab .name { font-size: 14.5px; }
  .subjtab .wt, .barhint { display: none; }

  /* 侧栏变成左侧抽屉（默认收起） */
  main { flex-direction: column; }
  #side { position: fixed; left: 0; top: 0; bottom: 0; width: 80vw; max-width: 330px; z-index: 36;
          transform: translateX(-103%); transition: transform .18s ease; border-right: 1.5px solid var(--ink);
          padding-top: 14px; }
  body.side-open #side { transform: none; }
  #stage { padding: 14px 12px 64px; }

  /* 触控友好 */
  button { min-height: 38px; }
  button.mini { min-height: 32px; }
  .opt { padding: 13px 14px; }
  .chip { padding: 6px 12px; }
  input, textarea, select { font-size: 16px; }   /* ≥16px 防 iOS 聚焦缩放 */

  /* 卡片与插图 */
  .card { padding: 16px 14px; }
  .illwrap .ill { max-height: 210px; }
  .illwrap.wide .ill { max-height: 170px; }
  .qhead .right { width: 100%; justify-content: space-between; }
  .kbar { gap: 8px; }

  /* 错题本：表格 → 卡片 */
  table.wb thead { display: none; }
  table.wb, table.wb tbody, table.wb tr, table.wb td { display: block; width: auto; }
  table.wb tr[data-row] { border: 1px solid var(--rule-strong); background: var(--slip-2);
    padding: 10px 12px; margin-bottom: 10px; }
  table.wb tr[data-row] td { border: 0; padding: 2px 0; }
  table.wb tr[data-row] td[data-l]:not(.stem-cell):not(.wb-ops)::before {
    content: attr(data-l) "　"; color: var(--ink-faint); font-size: var(--t-xs); }
  table.wb tr[data-row] td.stem-cell { font-size: var(--t-md); line-height: 1.6; padding: 4px 0 6px; }
  .wb-ops { display: flex; gap: 8px; margin-top: 8px; }
  table.wb tr.wb-detail td { border: 0; padding: 0; }
  .wb-detail-in { padding: 4px 2px 10px; }

  /* 对话抽屉：整屏 */
  #drawer { width: 100%; }
  .chat-compose { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .chat-quick { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }

  /* 登录页 */
  .authwrap { padding: 16px; height: auto; min-height: 100vh; }
  .authwrap .authcard { flex: 1 1 auto; width: 100%; max-width: none; }

  /* 其他表格（弱点看板等）横向滚动而不是压扁 */
  .card table:not(.wb) { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 420px) {
  .subjtab { min-width: 104px; }
  h3 { font-size: var(--t-md); }
  .brand { font-size: var(--t-sm); }
}

/* ---------- 备案号页脚（fixed，登录遮罩之上也可见；点它才可点） ---------- */
#site-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999; pointer-events: none;
  text-align: center; padding: 5px 12px calc(5px + env(safe-area-inset-bottom, 0px));
  font-size: 11.5px; letter-spacing: .04em; color: var(--ink-faint); }
#site-foot a { color: var(--ink-faint); text-decoration: none; pointer-events: auto;
  border-bottom: 1px dotted var(--rule-strong); }
#site-foot a:hover { color: var(--stamp); border-bottom-color: var(--stamp); }
body { padding-bottom: 22px; }        /* 给页脚留出位置，避免压住底部内容 */

/* ---------- 弹窗统一顶栏（桌面 sticky；手机见下方媒体查询） ---------- */
#modal-box { position: relative; }
.modal-bar {
  display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 3;
  margin: -24px -24px 16px; padding: 10px 14px;
  background: var(--slip); background-image: var(--grain);
  border-bottom: 1.5px solid var(--ink);
}
.modal-bar #modal-title {
  font-family: var(--font-display); font-weight: 700; font-size: var(--t-md);
  letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-bar #modal-x { margin-left: auto; flex: 0 0 auto; min-height: 34px; padding: 4px 12px; }

/* 弹窗内表单：标签与控件竖排更易读，长正文不撑破 */
#modal-box .flabel { display: block; }
#modal-box .md table, #modal-box table { max-width: 100%; }
#modal-box .md img, #modal-box img { max-width: 100%; height: auto; }

/* ---------- 移动端弹窗：底部抽屉 + 全宽 + 键盘友好 ---------- */
@media (max-width: 820px) {
  #modal { align-items: flex-end; padding: 0; }

  #modal-box {
    min-width: 0;                 /* ⚠️ 原来写死 460px，手机必横向溢出 */
    width: 100%; max-width: none;
    max-height: 92dvh;            /* dvh：不被地址栏算掉 */
    padding: 0 14px calc(16px + env(safe-area-inset-bottom, 0px));
    border-left: 0; border-right: 0; border-bottom: 0;
    border-radius: 14px 14px 0 0;
    overscroll-behavior: contain;
    scroll-padding-bottom: 34vh;  /* iOS 键盘弹出时，聚焦的输入框不会被挡住 */
  }

  /* 顶栏：sticky + 大一点的点按区，长表单也能随时关 */
  #modal-box .modal-bar {
    margin: 0 -14px 12px; padding: 10px 12px; border-radius: 14px 14px 0 0;
  }
  #modal-box .modal-bar #modal-x { min-height: 42px; padding: 6px 14px; font-size: var(--t-md); }

  /* 表单控件铺满一行（覆盖 html 里内联的 width:60px / 70px） */
  #modal-box input:not([type=checkbox]):not([type=radio]):not([type=file]),
  #modal-box select, #modal-box textarea { width: 100% !important; box-sizing: border-box; }

  /* 按钮行：主按钮占满、标签独占一行，避免挤压 */
  #modal-box .kbar { gap: 8px; }
  #modal-box .kbar > button { flex: 1 1 auto; min-height: 42px; }
  #modal-box .kbar > label { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; }
  #modal-box .kbar > label input:not([type=checkbox]) { flex: 1 1 auto; width: auto !important; }

  /* 正文里的表格/代码允许横向滑动，别把抽屉撑破 */
  #modal-box .md table, #modal-box table {
    display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch;
  }
  #modal-box .md pre, #modal-box pre { max-width: 100%; }
  #modal-box h4 { margin: 18px 0 8px; }

  /* 关闭用的内联按钮也放大 */
  #modal-box #doc-close, #modal-box #m-close { min-height: 42px; }
}

/* ---------- dvh 兜底：移动端 100vh 会被地址栏吃掉一截 ---------- */
@supports (height: 100dvh) {
  body { height: 100dvh; }
  #drawer { height: 100dvh; }
  .authwrap { height: auto; min-height: 100dvh; }
}

/* 助手调用失败：醒目但不刺眼（朱批色左边框 + 浅底） */
.chat-msg.err .bubble { border-color: var(--stamp); background: var(--stamp-wash); color: var(--ink); }
.chat-msg.err .err-head { font-size: var(--t-xs); color: var(--stamp); letter-spacing: .04em; margin-bottom: 4px; }

/* ---------- Markdown 表格（助手回复里的 | a | b |） ---------- */
.md-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; margin: 10px 0; }
.md-table { border-collapse: collapse; font-size: var(--t-sm); line-height: 1.5; }
.md-table th, .md-table td { border: 1px solid var(--rule-strong); padding: 6px 10px; vertical-align: top; }
.md-table th { background: var(--slip-2); font-family: var(--font-display); font-weight: 700; white-space: nowrap; }
.md-table tbody tr:nth-child(even) { background: rgba(31, 27, 22, .025); }

/* ---------- 用户界面 + 广场（新增） ---------- */
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--ink); background: var(--slip-2); }
.tagchip { display: inline-block; font-size: var(--t-xs); padding: 1px 7px; border-radius: 10px;
  border: 1px solid var(--rule-strong); background: var(--slip-2); color: var(--ink-soft); }
.spacer { flex: 1 1 auto; }
#me-nav { position: sticky; top: 0; background: var(--slip); z-index: 2; padding: 6px 0; }
.me-page #me-panel { margin-top: 10px; }

/* 回复底部的荐题跳转按钮 */
.qjump { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.qjump-btn { font-family: var(--font-mono); }

/* 广场列表 */
.plaza-item { border: 1px solid var(--rule-strong); background: var(--slip-2);
  padding: 10px 12px; margin-bottom: 10px; }
.plaza-item .pi-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plaza-item .pi-head b { cursor: pointer; }
.plaza-item .pi-body { margin-top: 4px; line-height: 1.6; }

/* 帖子里的题目与"做这题" */
.plaza-q { border: 1px dashed var(--rule-strong); padding: 10px 12px; margin: 10px 0; background: var(--slip); }
.plaza-run { border-top: 1px dashed var(--rule-strong); padding-top: 8px; margin-top: 8px; }

/* 评论（两级） */
.cmt { border-left: 2px solid var(--rule-strong); padding: 6px 0 6px 10px; margin: 8px 0; }
.cmt-kid { margin-left: 22px; border-left-color: var(--rule); }
.cmt-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--t-sm); }

@media (max-width: 820px) {
  .avatar-lg { width: 52px; height: 52px; }
  .plaza-item { padding: 8px 10px; }
  .cmt-kid { margin-left: 12px; }
}

/* 公式里的正体文字（\text{主存块号}）与渲染兜底 */
.math .mtext { font-style: normal; font-family: var(--font-body); }
.math { white-space: normal; }

/* ---------- 减法：侧栏/科目条在不需要的视图整条收起（内容全宽） ---------- */
body.no-side #side { display: none; }
body.no-subj #subjectbar { display: none; }
body.no-side #stage { padding-left: 28px; }

/* 侧栏小标题与小行（错题本按章 / 弱点排行 / 知识章列表） */
.side-cap { font-size: var(--t-xs); color: var(--ink-faint); letter-spacing: .04em;
  margin: 10px 0 4px; padding: 0 2px; }
#side .row.weak-row { align-items: center; }
#side .row .bar i.s-hi { background: var(--stamp); }
#side .row .bar i.s-mid { background: var(--warn); }
#side .row .bar i.s-lo { background: var(--ink-faint); }
#side .row button.mini { flex: 0 0 auto; }
@media (max-width: 820px) { body.no-side #stage { padding-left: 12px; } }

/* 站内对话框：危险操作按钮（朱批色） */
#modal-box button.danger { background: var(--stamp); border-color: var(--stamp); color: #fff; }
#modal-box button.danger:hover { filter: brightness(1.05); }
#modal-box .flabel { margin-bottom: 10px; }

/* ============================================================
   美化：站内对话框（确认/提示/表单）
   ============================================================ */
@media (min-width: 821px) {
  #modal-box.ui-dialog { min-width: 0; width: 440px; max-width: 92vw; padding: 0 20px 18px;
    border-radius: 3px; }
  #modal-box.ui-dialog .modal-bar { margin: 0 -20px 14px; padding: 11px 15px; }
  #modal-box.ui-dialog .modal-bar #modal-title { font-size: var(--t-md); letter-spacing: .05em; }
  #modal-box.ui-dialog .modal-bar #modal-title::before { content: '◆'; color: var(--stamp);
    margin-right: 8px; font-size: .78em; vertical-align: 1px; }
  #modal-box.ui-dialog .modal-bar #modal-x { min-height: 28px; padding: 1px 9px; font-size: var(--t-sm); }
  #modal-box.ui-dialog .md { font-size: var(--t-md); line-height: 1.75; margin: 2px 0 14px; }
  #modal-box.ui-dialog .ui-dialog-ops { justify-content: flex-end; gap: 10px; margin-top: 2px; }
  #modal-box.ui-dialog .ui-dialog-ops button { min-width: 92px; }
}
#modal-box.ui-dialog .flabel { font-size: var(--t-sm); }
#modal-box.ui-dialog .ui-dialog-ops { justify-content: flex-end; }

/* ============================================================
   美化：广场（帖子卡片 / 题目块 / 评论）
   ============================================================ */
.plaza-item { border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong);
  background: var(--slip-2); background-image: var(--grain);
  padding: 12px 14px 10px; margin-bottom: 12px; border-radius: 2px;
  transition: box-shadow .14s ease, border-color .14s ease; }
.plaza-item:hover { box-shadow: var(--shadow-sm); border-color: var(--rule-strong); }
.plaza-item.k-question { border-left-color: var(--stamp); }        /* 题目帖：朱批 */
.plaza-item.k-help     { border-left-color: var(--warn); }         /* 求助帖：琥珀 */
.plaza-item.k-discuss  { border-left-color: var(--ink-soft); }     /* 讨论帖：墨 */
.plaza-item .pi-head b { font-size: var(--t-md); letter-spacing: .01em; }
.plaza-item .pi-head b:hover { color: var(--stamp); }
.plaza-item .pi-body { color: var(--ink-soft); font-size: var(--t-sm); line-height: 1.65; margin-top: 6px; }
.plaza-item .kbar { margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--rule); }
.plaza-item .tagchip { font-family: var(--font-display); }
.plaza-item.k-question .tagchip { border-color: var(--stamp); color: var(--stamp); }
.plaza-item.k-help .tagchip { border-color: var(--warn); color: var(--warn); }

/* 帖子里的题目：像一小块卷面 */
.plaza-q { background: var(--slip); border: 1px dashed var(--rule-strong);
  border-left: 3px solid var(--stamp); padding: 12px 14px 10px; margin: 14px 0; }
.plaza-q .stem { font-size: var(--t-md); line-height: var(--lh-prose); }
.plaza-q .opt { cursor: default; }
.plaza-run { border-top: 1px dashed var(--rule-strong); padding-top: 10px; margin-top: 10px; }

/* 评论：首字母头像 + 两级层次 */
.avatarsm { display: inline-flex; width: 22px; height: 22px; border-radius: 50%;
  background: var(--paper-deep); border: 1px solid var(--rule-strong);
  align-items: center; justify-content: center; font-size: 11px;
  font-family: var(--font-display); color: var(--ink-soft); flex: 0 0 auto; }
.cmt { border-left: 2px solid var(--rule); padding: 7px 0 7px 12px; margin: 10px 0;
  background: linear-gradient(90deg, rgba(31,27,22,.022), transparent 62%); }
.cmt-kid { margin-left: 26px; border-left-style: dashed; }
.cmt-head { gap: 6px; align-items: center; }
.cmt-head b { font-size: var(--t-sm); }
.cmt > div:last-child { line-height: 1.7; margin-top: 3px; }

/* 发帖表单：字段更松快 */
#pc-form .flabel { margin-bottom: 11px; }
#pc-form textarea { width: 100%; box-sizing: border-box; }
#pc-form .kbar input { flex: 1 1 60px; min-width: 0; }

@media (max-width: 820px) {
  .plaza-item { padding: 10px 11px 8px; }
  .cmt-kid { margin-left: 14px; }
  .plaza-q { padding: 10px 11px 8px; }
}

/* 帖子详情：标题下的纸墨分隔线 + 元信息行 */
.plaza-detail > h3 { margin: 8px 0 6px; padding-bottom: 10px; border-bottom: 1.5px solid var(--ink); }
.plaza-detail > .muted:first-of-type { display: block; margin-bottom: 12px; letter-spacing: .02em; }
.plaza-detail .kbar:first-child { border-bottom: 1px dashed var(--rule); padding-bottom: 10px; }

/* 广场里的「我的帖子 / 草稿箱」就地视图 + 对话上下文行 */
.me-inline { margin-top: 6px; }
.chat-ctxline { padding: 6px 14px; border-bottom: 1px dashed var(--rule);
  font-size: var(--t-xs); color: var(--ink-soft); background: var(--slip-2); }
.chat-imgs { padding: 5px 14px; font-size: var(--t-xs); color: var(--stamp);
  border-bottom: 1px dashed var(--rule); background: var(--slip-2); }

/* 自动压缩摘要：折叠成一行，点开可看 */
.chat-summary { margin: 8px 0; }
.chat-summary summary { font-size: var(--t-xs); color: var(--ink-faint); cursor: pointer;
  border-top: 1px dashed var(--rule); padding-top: 6px; }
.chat-summary .md { font-size: var(--t-sm); color: var(--ink-soft); border-left: 2px solid var(--rule);
  padding-left: 10px; margin-top: 6px; }

/* 对话头部选项条：附带本题做成药丸按钮 */
.chat-optbar { display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  border-bottom: 1px dashed var(--rule); background: var(--slip-2); }
.wq-btn { border-radius: 999px; padding: 3px 12px; border: 1.5px solid var(--rule-strong);
  background: var(--slip); color: var(--ink-soft); font-size: var(--t-xs);
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .12s ease; }
.wq-btn:hover { border-color: var(--ink); color: var(--ink); }
.wq-btn.on { background: var(--ink); border-color: var(--ink); color: var(--paper);
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.14); }
.wq-btn.on::before { content: '✓ '; }
.wq-hint { font-size: var(--t-xs); color: var(--ink-faint); }

/* API Key 风险告知 */
.riskbox { margin: 4px 0 10px; border: 1px solid var(--rule-strong); background: var(--slip-2); }
.riskbox > summary { cursor: pointer; padding: 8px 11px; font-size: var(--t-sm); color: var(--stamp); }
.risktext { padding: 2px 12px 10px; font-size: var(--t-sm); line-height: 1.8; color: var(--ink-soft); }
.risktext p { margin: 7px 0; }
.risktext b { color: var(--ink); }
label.agree { display: block; margin: 2px 0 10px; font-size: var(--t-sm); }

/* ============================================================
   广场美化（第二轮：更像"内容社区"，不再单调）
   ============================================================ */
.plaza-item { position: relative; padding: 14px 16px 11px; }
.plaza-item .pi-head { gap: 10px; }
.plaza-item .pi-head b { font-size: var(--t-lg); line-height: 1.35; }
.plaza-item .pi-head .tagchip { padding: 2px 9px; font-weight: 600; letter-spacing: .02em; }
.plaza-item .pi-body { margin-top: 8px; font-size: var(--t-sm); color: var(--ink-soft); }
.plaza-item .kbar { border-top: 1px dashed var(--rule); margin-top: 10px; padding-top: 9px; gap: 8px; }
.plaza-item .kbar .muted { font-size: var(--t-xs); }
button.mini.ghost { background: transparent; border-color: transparent; color: var(--ink-faint); }
button.mini.ghost:hover { color: var(--stamp); border-color: var(--rule-strong); }

/* 帖子详情：文章感 */
.plaza-detail { padding: 18px 20px 14px; }
.plaza-detail > h3 { font-size: var(--t-xl); line-height: 1.35; }
.plaza-detail .plaza-q { margin: 16px 0; box-shadow: var(--shadow-sm); }
.plaza-detail h4 { margin-top: 18px; padding-bottom: 6px; border-bottom: 1px dashed var(--rule); }

/* 评论：卡片化 + 更清楚的层次 */
#pp-comments { margin-top: 6px; }
.cmt { border-left: 0; border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong);
  border-radius: 3px; background: var(--slip); background-image: var(--grain);
  padding: 9px 12px; margin: 10px 0; }
.cmt-kid { margin-left: 24px; border-left-style: solid; border-left-color: var(--ink-faint);
  background: var(--slip-2); }
.cmt-head { margin-bottom: 3px; }
.cmt-head b { font-family: var(--font-display); }
.cmt > div:last-child { font-size: var(--t-sm); line-height: 1.75; }
.cmt .kbar { margin-top: 5px; }

/* 管理页的举报表 */
#stage .card h4 { letter-spacing: .03em; }

/* 标题栏显示设置 */
.navset { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--rule-strong); background: var(--slip-2); margin-bottom: 6px; }
.navset-item { font-size: var(--t-sm); display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.navset-item input { width: auto; }
