/* ===== 排版参数：CSS 变量驱动 ===== */
:root {
  --paper-w: 297mm;          /* 由 JS 按纸张+方向设置 */
  --paper-h: 210mm;
  --margin: 4mm;
  --cols: 2;
  --gap: 6mm;                /* 栏间距，由 JS(state.colGap) 覆盖 */
  --q-gap: 0.5em;            /* 题间距：题目/大题标题上下间距（2026-08-12 起由 0.25em 翻倍至 0.5em）*/
  --part-gap: calc(var(--q-gap) * 3.2); /* 大题间距：大题头(一、二、三、四)上下间距（2026-08-12 起由 q-gap*1.6 翻倍至 q-gap*3.2，即翻倍）；JS 用 state.partGapMul 覆盖 */
  --p-gap: 0.36em;           /* 段间距：恒定 0.36em（由 JS state.pGap 设定，不参与密度拟合）。0.12 最小单位 + 0.24 追加；段间留呼吸，段落仍靠「段首缩进2字符」区分 */
  --fs: 10.5pt;
  --lh: 1.35;
}

/* ===== 打印 ===== */
/* @page 的 size 由 JS 按用户选择的纸张+方向动态注入（见 #page-size-style）*/
@media print {
  body { background: white; }
  .sidebar, .toolbar, .debug-overlay, .measure-stage, .toolbox, .import-modal, .import-open-btn { display: none !important; }
  .paper-container { gap: 0; padding: 0; }
  .paper { box-shadow: none; margin: 0; page-break-after: always; break-after: page; zoom: 1; }
  .paper:last-child { page-break-after: auto; break-after: auto; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #e9e7e1;
  font-family: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "SimSun", serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}

/* ===== 左侧导航：试卷库 ===== */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #2b2a28 0%, #1f1e1c 100%);
  color: #f5f3ee;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid #1a1917;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid #3a3834;
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #d4a93a, #b8892d);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(212,169,58,.3);
}
.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: #f5f3ee;
}
.sidebar-search {
  padding: 14px 14px 10px;
}
.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: #1a1917;
  border: 1px solid #3a3834;
  border-radius: 6px;
  color: #f5f3ee;
  font-size: 12px;
  font-family: inherit;
  transition: .15s;
  outline: none;
}
.sidebar-search input:focus {
  border-color: #d4a93a;
  box-shadow: 0 0 0 2px rgba(212,169,58,.2);
}
.sidebar-search input::placeholder {
  color: #7a766d;
}
.sidebar-section-label {
  padding: 10px 18px 6px;
  font-size: 11px;
  color: #7a766d;
  letter-spacing: 1px;
  font-weight: 600;
  text-transform: uppercase;
}
.paper-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
}
.paper-list::-webkit-scrollbar { width: 6px; }
.paper-list::-webkit-scrollbar-track { background: transparent; }
.paper-list::-webkit-scrollbar-thumb {
  background: #4a4844;
  border-radius: 3px;
}
.paper-group {
  margin-bottom: 10px;
}
.paper-group-title {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #a8a39a;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
}
.paper-group-title:hover { background: rgba(255,255,255,.05); }
.paper-group-title .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #d4a93a;
  flex-shrink: 0;
}
.paper-group-title .chevron {
  margin-left: auto;
  font-size: 10px;
  color: #7a766d;
  transition: transform .2s;
}
.paper-group.collapsed .chevron { transform: rotate(-90deg); }
.paper-group.collapsed .paper-group-body { display: none; }
.paper-group-body {
  display: flex; flex-direction: column; gap: 4px;
  padding-left: 14px;
}
.paper-item {
  padding: 10px 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: .15s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.paper-item:hover {
  background: rgba(212,169,58,.08);
  border-color: rgba(212,169,58,.3);
}
.paper-item.active {
  background: linear-gradient(135deg, rgba(212,169,58,.18), rgba(212,169,58,.08));
  border-color: #d4a93a;
  box-shadow: 0 0 0 1px rgba(212,169,58,.2);
}
.paper-item .paper-name {
  font-size: 13px;
  font-weight: 600;
  color: #e8e4db;
  line-height: 1.3;
}
.paper-item.active .paper-name { color: #f5f3ee; }
.paper-item .paper-meta {
  font-size: 11px;
  color: #7a766d;
  display: flex; align-items: center; gap: 8px;
}
.paper-item.active .paper-meta { color: #c4bdb0; }
.paper-item .paper-meta .tag {
  padding: 1px 6px;
  background: rgba(255,255,255,.08);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}
.paper-item.active .paper-meta .tag {
  background: rgba(212,169,58,.25);
  color: #d4a93a;
}
.paper-item .paper-score {
  font-size: 10px;
  color: #6a665d;
}
.paper-item.active .paper-score { color: #9e988b; }
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid #3a3834;
  text-align: center;
}
.sidebar-footer .hint {
  font-size: 11px;
  color: #7a766d;
}

/* ===== 主内容区 ===== */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ===== 工具栏 ===== */
.toolbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  padding: 10px 16px;
  background: #2b2a28; color: #f5f3ee;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
}
.toolbar .group { display: flex; align-items: center; gap: 4px; }
.toolbar .label { color: #a8a39a; font-size: 12px; margin-right: 2px; }
.toolbar button {
  border: 1px solid #4a4844; background: transparent; color: #d8d4cc;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;
  transition: .15s;
}
.toolbar button:hover { background: #4a4844; }
.toolbar button.active { background: #d4a93a; color: #1a1917; border-color: #d4a93a; font-weight: 600; }
.toolbar #btn-autofit { background: #8fd0a8; color: #14241b; border-color: #8fd0a8; font-weight: 600; padding: 0 10px; }
.toolbar #btn-autofit:hover { background: #a3e0bd; }
#ans-toggle { border: 1px solid #4a4844; background: transparent; color: #7a766d; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; transition: .15s; }
#ans-toggle.toggle-on { background: #d4a93a; color: #1a1917; border-color: #d4a93a; font-weight: 600; }
#ans-toggle:not(.toggle-on):hover { color: #d8d4cc; }
.toolbar .sep { width: 1px; height: 20px; background: #4a4844; }
.toolbar select, .toolbar input[type=number] {
  border: 1px solid #4a4844; background: #1f1e1c; color: #f5f3ee;
  padding: 4px 8px; border-radius: 4px; font-size: 12px; font-family: inherit; cursor: pointer;
}
.toolbar select:focus, .toolbar input[type=number]:focus { outline: none; border-color: #d4a93a; }
.toolbar input[type=number] { width: 44px; cursor: text; }
.toolbar input[type=number]:disabled { opacity: .4; cursor: not-allowed; }
.page-hint { font-size: 11px; color: #b9b3a6; margin-left: 4px; max-width: 240px; line-height: 1.3; }

/* 一键撑满悬停说明（弹窗） */
.tip-wrap { position: relative; display: inline-flex; }
.tip-wrap .tip-text {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #2c2a27; color: #f5f3ee; border: 1px solid #4a4844; border-radius: 6px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5; width: 260px;
  box-shadow: 0 4px 14px rgba(0,0,0,.45); opacity: 0; visibility: hidden;
  transition: opacity .18s, visibility .18s; pointer-events: none; z-index: 60;
  text-align: left; font-weight: normal; white-space: normal;
}
.tip-wrap .tip-text::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #2c2a27;
}
.tip-wrap:hover .tip-text { opacity: 1; visibility: visible; }
.toolbar #btn-download { background: #5b8db8; color: #fff; border-color: #5b8db8; font-weight: 600; }
.toolbar #btn-download:hover { background: #6f9fc9; }

/* 模式切换 UI 已移除（固定 mode-3：JS分页·长文拆段） */

/* ===== 纸张容器：纵向排列多页 ===== */
.paper-container {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  padding: 24px 0 48px;
}

/* ===== 单页纸张：固定高度 ===== */
.paper {
  width: var(--paper-w);
  min-height: var(--paper-h);
  padding: var(--margin);
  font-size: var(--fs);
  line-height: var(--lh);
  background: white;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: relative;
  zoom: var(--zoom, 1);
}

/* 模式1：单页长卷，高度自适应 */
.mode-1 .paper {
  height: auto;
  min-height: var(--paper-h);
}
.mode-1 .page-wrap {
  display: block;
}
.mode-1 .col { border: none; padding: 0; width: auto; }

/* 模式2/3：内容跨栏跨页自然流动；用 min-height 而非固定 height，
   个别超长块（如整页阅读材料）可自然撑高，绝不被 overflow:hidden 静默裁切 */
.mode-2 .paper, .mode-3 .paper {
  min-height: var(--paper-h);
  overflow: visible;
}
/* 末页：沿用 balance（由 .cols-flow 继承），配合 JS 减栏自适应铺满整页宽度 */

/* ===== 头部：仅首页首栏上部、左对齐、不通栏（不跨栏）=====
   去掉 column-span:all，让卷头作为分栏流首块自然落入首页左栏顶部；
   左对齐（不通栏显示）。详见布局技能「试卷标题不通栏」。 */
.paper-header {
  break-inside: avoid;
  break-after: avoid;
  text-align: left;
  border-bottom: 1px solid #888;
  padding-bottom: 0.4em;
  margin-bottom: 0.5em;
}
/* 页脚改为绝对定位（脱离 flex 流），钉在纸张底部留白区内：
   1) 不再占用 .paper 的内容高度，.page-wrap(flex:1) 可占满整页内高，内容余量更大；
   2) 页脚永远落在物理页内，绝不会被 flex 撑到下一页 → 根除「每张卷多打一页空白」。
   注意：绝对定位的 bottom 相对 .paper 的 padding 盒，bottom:var(--margin) 即落在底部留白区，
   与 .page-wrap 内容区(到上内边距为止)不重叠。 */
.paper-footer {
  position: absolute;
  left: var(--margin); right: var(--margin); bottom: var(--margin);
  border-top: 1px solid #eee;
  padding-top: 0.3em;
  text-align: center; font-size: 0.78em; color: #999;
}

/* ===== 分栏主体 ===== */
.page-wrap {
  flex: 1;
  min-height: 0;
  overflow: visible;
}
/* JS手动分栏（旧） */
.page-wrap:not(.cols-flow) {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  column-gap: var(--gap);
}
/* CSS原生分栏：固定页高 + column-fill:auto（顺序填满各栏）。
   自动撑满与指定N页统一走此模式：内容自顶向下填满每栏，仅末页末栏可留白，
   非末页不再出现空白行（解决 balance 模式每页底部均分留白的问题）。 */
.page-wrap.cols-flow {
  column-count: var(--cols);
  column-gap: var(--gap);
  column-rule: 1px solid #e5e1d7;
  height: var(--content-h);
  column-fill: auto;
  overflow: hidden;
}
/* 指定原卷N页兼容类（高度/auto 已由基类统一提供） */
.page-wrap.cols-flow.fixed-fill {
  column-fill: auto;
}
.col {
  overflow: visible;
  border-right: 0.5pt solid #e0ddd5;
  padding-right: var(--gap);
}
.col:last-child { border-right: none; padding-right: 0; }

/* ===== 试卷内容样式 ===== */
.hd { text-align: center; margin: 0 0 0.2em; }   /* 卷头：试卷名与用时居中（仍随栏流首块，不通栏）*/
.hd .tit { font-size: 1.22em; font-weight: 400; letter-spacing: 0.5px; }
.hd .tit sm { font-size: 0.6em; font-weight: 400; color: #666; }
.hd .meta { font-size: 0.85em; color: #555; margin-top: 0.15em; }

.info-bar {
  display: flex; gap: 16px; justify-content: space-between;
  font-size: 0.85em; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;
  padding: 2px 0; margin-bottom: 0.2em;
}
.info-bar .field { display: flex; align-items: baseline; gap: 6px; }
.info-bar .line { display: inline-block; min-width: 60px; border-bottom: 1px solid #999; height: 1em; }

/* 试卷内容：段落与题目均允许自然跨栏/跨页流动；结构性标题(section/subheading)与卷头保持整体不切分 */
/* 大题头（一、现代文阅读（35分））：黑体加粗（黑体字体 + 700），与小题头形成层级 */
.section-title { font-family: "SimHei", "Heiti SC", "Microsoft YaHei", "黑体", sans-serif; font-weight: 700; font-size: 1.1em; margin: var(--part-gap, calc(var(--q-gap, 0.25em) * 1.6)) 0 calc(var(--q-gap, 0.25em) * 0.5); break-inside: avoid; break-after: avoid; color: #1a1a1a; }
/* 小题头（（一）现代文阅读Ⅰ（本题 共*小题，*分））：黑体（黑体字体 + 600，比大题头略轻，保留层级） */
.subheading  { font-family: "SimHei", "Heiti SC", "Microsoft YaHei", "黑体", sans-serif; font-weight: 600; font-size: 0.98em; margin: var(--q-gap, 0.25em) 0 calc(var(--q-gap, 0.25em) * 0.4); break-inside: avoid; break-after: avoid; color: #333; }

/* ===== 材料/文章：允许跨栏流动，按段切分（已按段拆），首行缩进，楷体 ===== */
.passage {
  margin: var(--p-gap, 0.12em) 0;
  text-align: justify;
  text-indent: 0;                /* 段首缩进改由内部 <p> 承担（每段2字符） */
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "楷体", "Noto Serif CJK SC", "Songti SC", serif;
  orphans: 2;
  widows: 2;
  break-inside: auto;
  line-height: var(--lh);
}
.passage p { margin: 0; text-indent: 2em; orphans: 2; widows: 2; }   /* 每段首行缩进2字符 */
.passage p + p { margin-top: var(--p-gap, 0.36em); }                  /* 段间距（恒定最小单位，由 JS --p-gap 设定） */
.passage .section-label { display: block; text-align: left; text-indent: 0; margin: 0; font-weight: bold; font-family: "SimHei", "Heiti SC", "Microsoft YaHei", "黑体", sans-serif; }  /* 材料一/二标签：居左、不缩进、黑体加粗 */
.passage-title-block { display: block; text-indent: 0; text-align: center; font-weight: normal; margin: 0; }  /* 标题作者（风 / （宋）司马光；割草 / [俄]列夫·托尔斯泰）居中、单独成行、不加粗 */
.passage-title-block strong { font-weight: inherit; }                         /* 去除 DB 中 <strong>割草</strong> 的粗体 */
/* 材料标题与作者字体（见布局技能「材料标题与作者字体」）：篇名(pt-title)宋体·不变楷体；作者(pt-author)楷体 */
.passage-title-block .pt-title { font-family: "Songti SC", "SimSun", "宋体", "Noto Serif CJK SC", serif; }
.passage-title-block .pt-author { font-family: "KaiTi", "STKaiti", "Kaiti SC", "楷体", "Noto Serif CJK SC", serif; }
.passage .source-cite, .passage .cite { display: block; text-align: right; text-indent: 0; }  /* 尾注（节选自… / 诗歌[注]）居右 */
.poem-body { display: block; text-align: center; text-indent: 0; line-height: 1.7; }  /* 诗歌：居中、不缩进、诗句间不留空行 */
.poem-intro { display: block; text-align: center; text-indent: 0; font-style: italic; color: #555; margin: 0.15em 0; }  /* 诗歌引导语（阅读下面两首唐诗…）：居中、斜体、浅色 */

/* ===== 源数据标记渲染：浪纹线 / 着重号 =====
   源数据(reading_material)用 <span class="wavy"> 标浪纹线(波浪下划线)、
   <em class="dot">字</em> 标着重号(字下圆点)。打印引擎原样保留这些 HTML 标签，
   此处补齐样式使其可见（见布局技能「特殊符号：浪纹线/着重号」）。 */
.passage .wavy, .wavy {
  text-decoration: underline wavy;       /* 浪纹线 = 波浪下划线 */
  text-decoration-skip-ink: none;
  text-underline-offset: 0.12em;
}
.passage em.dot, em.dot {
  font-style: normal;                    /* 着重号不是斜体 */
  text-emphasis: filled dot;             /* 字下着重号（圆点）*/
  text-emphasis-position: under;
  -webkit-text-emphasis: filled dot;
  -webkit-text-emphasis-position: under;
}

/* 题目：允许自然跨栏/跨页（题干/选项/答题区可随栏与页切割）；仅保护题号不孤行、单选项不碎裂 */
.question { margin: var(--q-gap, 0.25em) 0; orphans: 2; widows: 2; }
.question .qh { margin: 0; break-after: avoid; }
.question .sc { color: #b00; font-size: 0.85em; margin-left: 0.4em; }
.og { margin: 0.05em 0 0 1.5em; }
.o { display: block; padding: 0; break-inside: avoid; font-weight: normal; }  /* 选择题选项 ABCD 内容：不加粗 */

/* 答题区：none=不渲染；small=小答框/单行横线；large=多行横线答题区 */
.ans-area {
  margin: 0.1em 0;
  display: flex;
  align-items: center;
  min-height: 1.2em;
  break-before: avoid;
  break-inside: avoid;
}
.ans-area.large {
  display: block;
  min-height: 3.4em;
  margin-top: 0.2em;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0, transparent calc(1.2em - 1px),
      #cfccc4 calc(1.2em - 1px), #cfccc4 1.2em
    );
  border: 1px solid #cfccc4;
  border-radius: 2px;
  padding: 0 4px;
}
.ans-box-el {
  display: inline-block;
  width: 1.4em;
  height: 1.4em;
  border: 1px solid #666;
  text-align: center;
  line-height: 1.4em;
  font-size: 0.75em;
  color: #999;
}
.ans-line-el {
  display: block;
  width: 100%;
  border-bottom: 1px solid #999;
  height: 1.2em;
}
/* 翻译题：每个（N）子题成行，后跟一条长横线答区（分值在题干后，由 JS 按（1）（2）切分） */
.trans-item { margin: 0.12em 0 0; }
.trans-dash { margin: 0.1em 0 0.32em; }

.blankfill { margin: var(--q-gap, 0.25em) 0; orphans: 2; widows: 2; }
.blankfill .li { margin: 0; }

/* 作文：按自然段拆成独立 <p>（不合并为一段）；仅「材料」段用楷体，题干标题/写作要求用宋体 */
.composition { margin: var(--q-gap, 0.25em) 0; text-align: justify; orphans: 2; widows: 2; }
.composition p { margin: 0; line-height: var(--lh); orphans: 2; widows: 2; }
.composition p + p { margin-top: var(--p-gap, 0.36em); }
.comp-title { font-weight: 400; text-indent: 0; }   /* 题干标题（如「22 阅读下面的材料，根据要求写作。」）：宋体、不缩进，题号并入本行 */
.comp-material { font-family: "KaiTi", "STKaiti", "Kaiti SC", "楷体", "Noto Serif CJK SC", "Songti SC", serif; text-indent: 2em; }  /* 真实材料正文段：楷体、段落缩进2字符 */
.comp-bridge { font-weight: 400; text-indent: 2em; }   /* 过渡/写作任务句（「以上材料引发了…请写一篇文章」）：宋体、缩进2字符（属提示语，非材料，不变楷体） */
.comp-req { font-weight: 400; text-indent: 2em; }      /* 写作要求（「要求：…」）：宋体、缩进2字符 */
.composition .sc { color: #b00; font-size: 0.85em; margin-left: 0.4em; }  /* 作文分值（X分）：与选择题一致标红 */

/* 默写题：子题（1）（2）（3）单行、题间无空行、首行缩进2字符；分值写在题干后（由 JS 处理） */
.dict-item { margin: 0.04em 0 0; text-indent: 2em; }

/* ===== 答题卡：严格复刻 answer-sheet-8k.html 母版（8K横向 1049×737pt 三栏圆角框）=====
   sheet 内部尺寸恒为 1049×737pt，外层按当前纸张等比 scale，8K横向时 scale=1 像素级一致 */
.paper.answer-card { padding: 0; height: var(--paper-h); overflow: hidden; }
.ac-fit { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ac-sheet {
  width: 1049pt; height: 737pt; flex: 0 0 auto;
  transform-origin: center center;
  font-family: SimSun, STSong, 'Noto Serif CJK SC', serif; color: #111;
  padding: 10mm 10mm 10mm 20mm;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
  background: #fff; font-size: 9pt; line-height: 1.3;
}
.ac-sheet.p2 { padding: 10mm; }
/* 三栏圆角框 */
.ac-sheet .c3 { flex: 1; display: flex; gap: 5mm; min-height: 0; }
.ac-sheet .cl { flex: 1; display: flex; flex-direction: column; min-width: 0; border: 1pt solid #222; border-radius: 3pt; padding: 1.5mm 3pt 2mm; overflow: hidden; }
.ac-sheet .c3 > .cl:first-child { flex: 0 0 calc(33.333% - 15pt); }
.ac-sheet .c3 > .cl:nth-child(3) { flex: 1.02; }
/* 左边缘竖条信息区 */
.ac-sheet .c1v { position: absolute; left: 0; top: 0; bottom: 0; width: 30mm; display: flex; flex-direction: row; align-items: center; justify-content: center; white-space: nowrap; gap: 2mm; transform: rotate(-90deg); transform-origin: center center; font-size: 9pt; color: #444; letter-spacing: .5pt; }
.ac-sheet .c1v b { display: flex; flex-direction: row; align-items: baseline; gap: 0; }
.ac-sheet .c1v span { white-space: nowrap; position: relative; top: -15pt; }
.ac-sheet .c1v i { display: inline-block; width: 25mm; height: .5em; border-bottom: .6pt solid #333; vertical-align: middle; font-style: normal; margin-top: 13mm; position: relative; top: -10pt; }
/* 卷头 */
.ac-sheet .thd { text-align: center; padding: 22pt 0 12.5pt; border-bottom: .5pt solid #ddd; margin-bottom: 2.5pt; flex-shrink: 0; }
.ac-sheet .thd .tn { font-size: 14pt; font-weight: 700; letter-spacing: .5pt; }
.ac-sheet .thd .ts { font-size: 14pt; font-weight: 700; color: #555; letter-spacing: 2pt; margin-top: 6.5pt; }
/* 注意事项 + 条形码区 */
.ac-sheet .info { display: flex; flex-direction: column; gap: 2.5pt; flex-shrink: 0; }
.ac-sheet .nr { display: flex; gap: 3pt; border: .8pt solid #222; padding: 9pt 3pt; font-size: 6.3pt; line-height: 1.4; flex-shrink: 0; }
.ac-sheet .nr .nr-lb { flex: 0 0 auto; font-weight: 700; font-size: 8pt; writing-mode: vertical-lr; letter-spacing: 1.5pt; border-right: .5pt solid #ddd; display: flex; align-items: center; justify-content: center; padding: 0 2pt; }
.ac-sheet .nr .nr-ct { flex: 1; padding: 0 1.5pt; display: flex; flex-direction: column; }
.ac-sheet .nr .nr2 { flex: 1; border-left: .8pt solid #222; padding-left: 3pt; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1pt; }
.ac-sheet .bc { border: .8pt dashed #aaa; width: 55pt; height: 14pt; display: flex; align-items: center; justify-content: center; font-size: 6pt; color: #999; letter-spacing: .3pt; }
.ac-sheet .mk { display: flex; align-items: center; gap: 1.5pt; font-size: 6pt; color: #666; margin-top: 4pt; padding-left: 10pt; }
.ac-sheet .mk .bx { width: 7.5pt; height: 7.5pt; border: .5pt solid #222; display: inline-block; }
.ac-sheet .mk .bx.f { background: #222; }
/* 选择题填涂区 */
.ac-sheet .cho { border: .8pt solid #222; margin-top: 2.5pt; flex-shrink: 0; padding: 10pt; }
.ac-sheet .cho .g { padding: 1.5pt 2.5pt; display: grid; gap: 2.5pt 1.5pt; }
.ac-sheet .cho .row { display: flex; align-items: center; gap: 4.5pt; font-size: 6.5pt; }
.ac-sheet .cho .row.sp2 { grid-column: span 2; }
.ac-sheet .cho .row .n { font-weight: 600; min-width: 1.6em; text-align: right; padding-right: .5pt; color: #333; }
.ac-sheet .cho .row .ot { display: flex; gap: 6.5pt; }
.ac-sheet .cho .row .ot .o { width: 12pt; height: 12pt; border: .5pt solid #555; display: flex; align-items: center; justify-content: center; font-size: 4.5pt; color: #888; margin: .5pt 0; }
/* 主观题作答区 */
.ac-sheet .sh { font-size: 8pt; font-weight: 700; padding: 2pt 3pt; background: #222; color: #fff; flex-shrink: 0; margin: 10pt 0 2pt; letter-spacing: .3pt; align-self: flex-start; }
.ac-sheet .qw { display: flex; flex-direction: column; margin: 2pt 0 1pt; min-height: 0; }
.ac-sheet .qw:last-child { margin-bottom: 0; }
.ac-sheet .qw.qw-mt5 { margin-top: 5pt; }
.ac-sheet .qw .qh { display: flex; justify-content: space-between; font-size: 7.3pt; font-weight: 600; padding: 4pt 1.5pt; flex-shrink: 0; }
.ac-sheet .qw .qh .sc { font-weight: 400; font-size: 6.8pt; color: #888; }
.ac-sheet .qw .qa { width: 100%; border-collapse: collapse; border: .5pt solid #222; margin-top: .5pt; }
.ac-sheet .qw .qa td { height: 26pt; border-bottom: .5pt solid #222; padding: 0; }
.ac-sheet .qw .qa tr:last-child td { border-bottom: none; }
.ac-sheet .qw .qa-mx { width: 100%; border-collapse: collapse; border: none; margin-top: .5pt; }
.ac-sheet .qw .qa-mx td.mx { height: 26pt; padding: 2pt 4pt; border-bottom: none; display: flex; align-items: center; gap: 4pt; }
.ac-sheet .qw .qa-mx td.mx .lb { font-size: 6.5pt; color: #555; margin-right: 4pt; }
.ac-sheet .qw .qa-mx td.mx-first { padding-top: 6pt; }
.ac-sheet .qw .qa-mx td.mx .ul { flex: 1; border-bottom: .6pt solid #333; height: 0; margin: 14pt 2pt 0; }
.ac-sheet .qw .mx-box { border: .5pt solid #222; padding: 2pt 0; margin-top: 2pt; }
.ac-sheet .qw .qa-mx tr:last-child td { border-bottom: none; }
/* 第二面：写作方格 */
.ac-sheet .wrt { display: flex; justify-content: space-between; border-bottom: 1pt solid #222; padding-bottom: 1pt; margin-bottom: 2.5pt; flex-shrink: 0; }
.ac-sheet .wrt .t { font-size: 8pt; font-weight: 700; }
.ac-sheet .wrt .i { font-size: 5.5pt; color: #666; }
.ac-sheet .wg { flex: 1; display: flex; padding: 3pt 2pt; }
.ac-sheet .wg .g { display: grid; grid-template-columns: repeat(14, 1fr); gap: 0; width: 100%; }
.ac-sheet .wg .g .c { border-right: .3pt solid #222; border-top: .3pt solid #222; border-bottom: .3pt solid #222; margin-bottom: 4pt; background: #fff; position: relative; }
.ac-sheet .wg .g .c:nth-child(14n+1) { border-left: .3pt solid #222; }
.ac-sheet .wg .g .c:nth-last-child(-n+14) { margin-bottom: 0; }
.ac-sheet .wg .g .c .wm { position: absolute; bottom: -4pt; left: 0; right: 0; text-align: center; font-size: 3.5pt; color: #111; line-height: 1; pointer-events: none; }
/* 页脚 */
.ac-sheet .pf { text-align: center; font-size: 6pt; color: #999; border-top: .5pt solid #ddd; padding-top: 1pt; margin-top: auto; flex-shrink: 0; }
.ac-sheet .cpf { margin-top: auto; flex-shrink: 0; text-align: center; text-indent: 0; font-weight: bold; font-size: 6pt; color: #666; padding-top: 3pt; border-top: none; }
.ac-sheet .ac-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: #999; font-size: 16pt; }
@media print {
  /* 屏幕 fit-to-width 的 zoom 只在预览时生效；打印必须 1:1（@page 已定纸张尺寸），
     否则宽屏下 zoom>1 会把答题卡（固定高度 .answer-card + overflow:hidden）放大涨出页面 */
  .paper { zoom: 1 !important; }
  .ac-sheet .cho, .ac-sheet .nr, .ac-sheet .bc, .ac-sheet .sh,
  .ac-sheet .mk .bx.f, .ac-sheet .wg .g .c {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

/* ===== 测量区（隐藏但可测量）===== */
.measure-stage {
  position: absolute; left: -99999px; top: 0;
  opacity: 0;
  pointer-events: none;
}

/* ===== 调试覆盖层（默认关闭）===== */
.debug-overlay {
  display: none;
}

/* ===== 侧栏：导入我的试卷按钮 ===== */
.import-open-btn {
  width: 100%;
  padding: 10px 12px;
  background: linear-gradient(135deg, #d4a93a, #b8892d);
  color: #1a1917;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
  font-family: inherit;
}
.import-open-btn:hover { filter: brightness(1.08); box-shadow: 0 2px 10px rgba(212,169,58,.35); }

/* ===== 页脚：语文实用工具箱 ===== */
.toolbox {
  margin-top: auto;
  border-top: 1px solid #3a3834;
  background: #1a1917;
  padding: 18px 24px 22px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.toolbox-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.toolbox-brand {
  font-size: 13px; font-weight: 700; color: #d4a93a; letter-spacing: .5px;
  padding-right: 16px; border-right: 1px solid #3a3834; white-space: nowrap;
}
.toolbox-links { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbox-links a {
  font-size: 12px; color: #d8d4cc; text-decoration: none;
  padding: 6px 12px; border: 1px solid #4a4844; border-radius: 6px; transition: .15s;
}
.toolbox-links a:hover { background: #4a4844; color: #fff; border-color: #d4a93a; }
.toolbox-note { margin-left: auto; font-size: 11px; color: #7a766d; }

/* ===== 导入试卷弹窗 ===== */
.import-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.import-modal[hidden] { display: none; }
.import-panel {
  width: min(640px, 92vw); max-height: 88vh; overflow: auto;
  background: #232220; color: #f5f3ee; border: 1px solid #3a3834;
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.import-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #3a3834;
  font-size: 15px; font-weight: 700;
}
.import-x {
  background: transparent; border: none; color: #a8a39a; font-size: 16px;
  cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px;
}
.import-x:hover { background: #3a3834; color: #fff; }
.import-tabs { display: flex; gap: 0; padding: 0 18px; border-bottom: 1px solid #3a3834; }
.import-tabs button {
  background: transparent; border: none; color: #a8a39a; cursor: pointer;
  padding: 10px 14px; font-size: 13px; border-bottom: 2px solid transparent;
}
.import-tabs button.active { color: #d4a93a; border-bottom-color: #d4a93a; font-weight: 600; }
.import-body { padding: 16px 18px; }
.import-pane { display: flex; flex-direction: column; gap: 10px; }
.import-pane textarea {
  width: 100%; min-height: 200px; resize: vertical;
  background: #1a1917; border: 1px solid #4a4844; border-radius: 8px;
  color: #f5f3ee; padding: 10px 12px; font-size: 13px; line-height: 1.5;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.import-pane textarea:focus { outline: none; border-color: #d4a93a; }
.import-pane input[type=file] { color: #d8d4cc; font-size: 12px; }
.import-hint { font-size: 11px; color: #8a857c; line-height: 1.6; }
.import-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.import-pane .ghost {
  align-self: flex-start; background: transparent; color: #a8a39a; border: 1px solid #4a4844;
  padding: 8px 16px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.import-pane .ghost:hover { border-color: #d4a93a; color: #d4a93a; }
.import-pane .primary:disabled { opacity: .6; cursor: default; }
.import-pane .primary {
  align-self: flex-start; background: #d4a93a; color: #1a1917; border: none;
  padding: 8px 18px; border-radius: 6px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.import-pane .primary:hover { filter: brightness(1.06); }
.import-status { padding: 10px 18px 16px; font-size: 12px; min-height: 8px; }
.import-status.ok { color: #8fd0a8; }
.import-status.err { color: #e08a8a; }

/* ===== 导入弹窗 v2（上传为主，去掉粘贴/文本）===== */
.import-title { display: flex; flex-direction: column; gap: 2px; }
.import-title-main { font-size: 15px; font-weight: 700; }
.import-title-sub { font-size: 11px; font-weight: 400; color: #a8a39a; letter-spacing: .3px; }
.import-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 30px 16px; margin-bottom: 4px;
  border: 1.5px dashed #4a4844; border-radius: 10px;
  background: #1e1d1b; cursor: pointer; transition: .15s;
}
.import-drop:hover, .import-drop.drag { border-color: #d4a93a; background: #26241f; }
.import-drop-icon { font-size: 30px; line-height: 1; }
.import-drop-text { font-size: 13px; color: #f5f3ee; }
.import-drop-sub { font-size: 11px; color: #8a857c; }
.import-actions .primary.start { background: #8fd0a8; color: #14241b; }
.import-actions .primary.start:hover { filter: brightness(1.06); }
.import-actions .primary.share { background: #5b8db8; color: #fff; }
.import-actions .primary.share:hover { filter: brightness(1.08); }
.import-hint.share-hint { color: #c9b37a; }
.import-foot { padding: 0 18px 14px; font-size: 11px; color: #7a766d; }

/* ===== 修复：PDF/打印多出空白页 =====
   根因：.paper-footer 原是 flex 流内子元素(flex-shrink:0)，当某页内容被 JS 撑得很满时，
   .page-wrap(flex:1) 撑满后 + 页脚 + 内边距 使 .paper 实际高度略超物理页高(如 A4 297mm)，
   页脚(及偶尔最后几行)被 Chromium 挤到下一页 → 每张卷多打一页空白。
   修复见上方 .paper-footer：改为 position:absolute 钉在底部留白区，脱离 flex 流，
   既让 .page-wrap 占满整页内高(内容余量更大)，又保证页脚永不溢出物理页。
   配合 app.js 已把 @page margin 改为 0（可打印区=整页，留白由 .paper 自身 --margin 内边距承担）。 */
