/* 青卷 · 试卷排版（A4 所见即所得） */
.a4-page {
  --paper-w: 210mm;
  --paper-h: 297mm;
  --ink: #161412;
  --rule: #2a2623;
  --muted: #4a453f;
  --cinnabar: #b8483b;
  --fill-blank: #161412;
}

.a4-page {
  width: var(--paper-w);
  height: var(--paper-h);
  background: #fffef9;
  color: var(--ink);
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
  font-family: "I.Ming", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", "Songti SC", serif;
  font-size: 12.5pt;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.a4-page.density-compact {
  font-size: 11pt;
  line-height: 1.5;
  --q-gap: 1.4mm;
  --space-ln: 5.6mm;
  --fig-max: 62mm;
}
.a4-page.density-normal {
  --q-gap: 3mm;
  --space-ln: 7.2mm;
  --fig-max: 92mm;
}
.a4-page.density-loose {
  font-size: 13.5pt;
  line-height: 2;
  --q-gap: 5mm;
  --space-ln: 9.5mm;
  --fig-max: 112mm;
}

.a4-page.tpl-primary {
  font-size: 13.5pt;
  line-height: 1.85;
}

.a4-page.tpl-modern {
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11.5pt;
}

.a4-page.tpl-english {
  font-family: "Times New Roman", "Source Han Serif SC", "STSong", serif;
  font-size: 12pt;
}

.a4-inner {
  height: 100%;
  box-sizing: border-box;
  padding: 12mm 16mm 16mm 18mm;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.a4-page.has-bind .a4-inner { padding-left: 22mm; }
.a4-page.has-seal .a4-inner { padding-left: 46mm; }
.a4-page.size-16k {
  --paper-w: 185mm;
  --paper-h: 260mm;
}

.bind-line {
  position: absolute;
  left: 8mm;
  top: 18mm;
  bottom: 18mm;
  border-left: 1.5px dashed #888;
  width: 8mm;
  z-index: 3;
  pointer-events: none;
}
.bind-line span {
  position: absolute;
  left: -1.15em;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  letter-spacing: 0.45em;
  font-size: 9pt;
  color: #888;
  font-family: "SimSun", serif;
}

.seal-col {
  position: absolute;
  left: 14mm;
  top: 14mm;
  bottom: 16mm;
  width: 28mm;
  border-right: 1.5px dashed #c45c4a;
  padding: 4mm 3mm 4mm 0;
  box-sizing: border-box;
  font-size: 9.5pt;
  line-height: 1.6;
  color: var(--muted);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2.5mm;
}
.a4-page.has-bind .seal-col { left: 18mm; }
.seal-col .seal-title {
  writing-mode: vertical-rl;
  letter-spacing: 0.2em;
  font-size: 9pt;
  color: var(--cinnabar);
  align-self: center;
}
.seal-col .seal-field {
  border-bottom: 1px solid #bbb;
  min-height: 1.6em;
  font-size: 9pt;
}
.seal-col .barcode {
  margin-top: auto;
  height: 22mm;
  border: 1px solid #bbb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8pt;
  color: #999;
}

.watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64pt;
  font-weight: 700;
  color: rgba(180, 72, 59, 0.07);
  transform: rotate(-24deg);
  pointer-events: none;
  z-index: 1;
  font-family: "STKaiti", "KaiTi", serif;
  letter-spacing: 0.2em;
}

.a4-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.a4-body.cols-2 {
  column-count: 2;
  column-gap: 8mm;
  column-rule: 1px solid #e4ddd0;
}

.running-h {
  display: none;
  font-size: 9pt;
  color: var(--muted);
  border-bottom: 0.6pt solid #bbb;
  padding-bottom: 1.5mm;
  margin-bottom: 3mm;
  justify-content: space-between;
  font-family: "SimSun", serif;
}
.a4-page:not(.is-first) .running-h { display: flex; }

.a4-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9pt;
  color: var(--muted);
  padding-top: 2mm;
  border-top: 0.6pt solid #ddd;
  margin-top: 2mm;
  font-family: "SimSun", serif;
}
.pg-num { letter-spacing: 0.08em; }

/* 标题区 */
.paper-head {
  text-align: center;
  margin-bottom: 4mm;
  page-break-inside: avoid;
  break-inside: avoid;
}
.paper-head .school {
  font-size: 12pt;
  letter-spacing: 0.25em;
  margin-bottom: 1mm;
}
.paper-head .main-title {
  font-size: 18pt;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-family: "STZhongsong", "SimHei", "Source Han Serif SC", serif;
  line-height: 1.35;
}
.tpl-primary .paper-head .main-title {
  font-size: 20pt;
  letter-spacing: 0.28em;
  color: #1e4f48;
}
.paper-head .sub-title {
  font-size: 14pt;
  letter-spacing: 0.35em;
  margin-top: 1mm;
  font-weight: 700;
}
.paper-head .meta-row {
  display: flex;
  justify-content: center;
  gap: 8mm;
  margin-top: 2.5mm;
  font-size: 11pt;
}
.paper-head .info-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3mm 7mm;
  margin-top: 3mm;
  font-size: 11.5pt;
}
.paper-head .info-grid .u {
  display: inline-block;
  min-width: 22mm;
  border-bottom: 1px solid var(--ink);
  height: 1.15em;
  vertical-align: bottom;
}
.score-box {
  position: absolute;
  right: 0;
  top: 0;
  border: 1.2pt solid var(--ink);
  width: 28mm;
  height: 16mm;
  font-size: 10pt;
  display: flex;
  flex-direction: column;
}
.score-box span:first-child {
  border-bottom: 1pt solid var(--ink);
  text-align: center;
  font-size: 9pt;
  padding: 1mm 0;
}
.score-box span:last-child { flex: 1; }

.head-rule {
  height: 0;
  border-top: 1.6pt solid var(--ink);
  border-bottom: 0.5pt solid var(--ink);
  padding-bottom: 1.2pt;
  margin: 3mm 0 3.5mm;
}

.instructions {
  font-size: 10pt;
  line-height: 1.65;
  margin-bottom: 3.5mm;
  color: var(--ink);
}
.instructions .ins-h {
  font-weight: 700;
  margin-right: 0.5em;
}
.instructions ol {
  margin: 0.4em 0 0 1.6em;
  padding: 0;
}

.vol-banner {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.4em;
  margin: 2mm 0 3mm;
  font-size: 12.5pt;
}

/* 大题 */
.sec-h {
  display: flex;
  align-items: baseline;
  gap: 3mm;
  margin: 2.5mm 0 2mm;
  break-inside: avoid;
  page-break-inside: avoid;
  font-size: 12.5pt;
  font-weight: 700;
}
.sec-h .sec-title {
  font-family: "STHeiti", "SimHei", "Source Han Sans SC", sans-serif;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sec-h .sec-ins {
  font-weight: 400;
  font-size: 11pt;
  flex: 1;
}
.sec-score {
  margin-left: auto;
  border: 1pt solid var(--ink);
  font-size: 9.5pt;
  font-weight: 400;
  padding: 0 2mm;
  white-space: nowrap;
  font-family: "SimSun", serif;
}
.tpl-primary .sec-h {
  background: linear-gradient(90deg, #e7f3ef, transparent 70%);
  padding: 1mm 2mm;
  border-left: 3pt solid #3d6e66;
}

/* 题目 */
.q-block {
  margin: 0 0 var(--q-gap, 3mm);
  break-inside: avoid;
  page-break-inside: avoid;
  position: relative;
}
.q-block.split-ok {
  break-inside: auto;
  page-break-inside: auto;
}
.q-block.is-selected {
  outline: 1.5px dashed #c45c4a;
  outline-offset: 2px;
  background: rgba(196, 92, 74, 0.04);
}
.q-hd {
  display: flex;
  gap: 1.5mm;
}
.q-no {
  flex: none;
  font-weight: 700;
  min-width: 1.6em;
}
.q-stem {
  flex: 1;
  text-align: justify;
}
.q-stem .blank {
  display: inline-block;
  min-width: 18mm;
  border-bottom: 1px solid var(--ink);
  height: 1em;
  margin: 0 0.15em;
  vertical-align: baseline;
}
.choice-paren {
  margin-left: 0.4em;
  white-space: nowrap;
  font-family: "Times New Roman", "SimSun", serif;
}
.q-fig {
  margin: 2mm auto;
  text-align: center;
  max-width: 92%;
}
.q-fig .fig-svg {
  width: min(100%, var(--fig-max, 92mm));
  height: auto;
  display: inline-block;
  vertical-align: middle;
}
.q-fig .fig-img {
  max-width: min(100%, 92mm);
  max-height: 70mm;
  object-fit: contain;
}
.fig-cap {
  font-size: 10pt;
  color: var(--muted);
  margin-top: 0.5mm;
}
.q-opts {
  margin: 1.2mm 0 0 1.8em;
  display: grid;
  gap: 0.4mm 4mm;
}
.q-opts.cols-2 { grid-template-columns: 1fr 1fr; }
.q-opts.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.q-opts.cols-1 { grid-template-columns: 1fr; }
.opt-mark {
  font-family: "Times New Roman", serif;
  margin-right: 0.35em;
}
.q-tf .tf-row {
  margin-left: 2em;
  letter-spacing: 0.4em;
}
.q-space {
  margin: 1.5mm 0 1mm 1.8em;
}
.q-space .ln {
  border-bottom: 1px solid #d4cec3;
  height: var(--space-ln, 7.2mm);
}
.q-space.blank-room .room {
  height: var(--space-ln, 7.2mm);
}
.essay-grid {
  margin: 2mm 0 0;
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  border-top: 1px solid #333;
  border-left: 1px solid #333;
  width: 100%;
}
.essay-grid i {
  display: block;
  aspect-ratio: 1;
  border-right: 1px solid #333;
  border-bottom: 1px solid #333;
  font-style: normal;
}
.passage {
  text-align: justify;
  font-size: 11.5pt;
  line-height: 1.9;
  margin: 1.5mm 0 2.5mm;
}
.passage p {
  margin: 0 0 1.2em;
  text-indent: 2em;
}
.passage-meta {
  text-align: center;
  font-size: 10pt;
  color: var(--muted);
  margin-bottom: 1.5mm;
}
.passage-meta .passage-source {
  display: block;
  text-align: right;
  font-size: 9pt;
  color: #8a8178;
}
.passage-author {
  text-align: center;
  font-weight: 700;
  margin-bottom: 0.5mm;
}
.sub-q { margin: 2mm 0 2mm 2mm; }
.req-list {
  margin: 1mm 0 2mm 2em;
  font-size: 11pt;
}
.cloze-n {
  display: inline-flex;
  min-width: 1.4em;
  justify-content: center;
  border-bottom: 1px solid var(--ink);
  font-size: 10pt;
  color: var(--cinnabar);
  font-family: "Times New Roman", serif;
}

/* 答案卷 */
.ans-q {
  margin-bottom: 2mm;
}
.ans-q .ans {
  color: var(--cinnabar);
  font-weight: 700;
}
.ans-q .ana {
  color: var(--muted);
  font-size: 10.5pt;
  margin-top: 0.6mm;
}
.answer-index {
  border: 1px solid #d8d1c4;
  padding: 2.5mm 3mm;
  margin-bottom: 3mm;
  break-inside: avoid;
}
.answer-index .idx-h {
  font-weight: 700;
  font-size: 11pt;
  margin-bottom: 1.5mm;
}
.answer-index .idx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22mm, 1fr));
  gap: 1.5mm 3mm;
}
.idx-cell {
  font-size: 10.5pt;
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 0.5em;
}
.idx-cell b { color: var(--cinnabar); font-family: "Times New Roman", serif; }
.ans-item {
  margin: 0 0 3mm;
  break-inside: auto;
}
.ans-head {
  display: flex;
  gap: 1.5mm;
  margin-bottom: 1mm;
}
.ans-head .ans-stem { flex: 1; }
.ans-item .sub-q .ans-q { margin: 0.6mm 0 2mm; }

/* 答题卡 */
.sheet-title {
  text-align: center;
  font-size: 17pt;
  font-weight: 700;
  letter-spacing: 0.35em;
  margin-bottom: 1mm;
}
.sheet-sub {
  text-align: center;
  font-size: 10pt;
  color: var(--muted);
  margin-bottom: 3mm;
}
.sheet-fields {
  display: flex;
  gap: 5mm;
  flex-wrap: wrap;
  font-size: 11pt;
  margin-bottom: 2.5mm;
}
.sheet-fields .sf { display: flex; gap: 0.5em; align-items: baseline; }
.sheet-fields .sf i { font-style: normal; }
.sheet-fields .sf b {
  display: inline-block;
  min-width: 20mm;
  border-bottom: 1px solid var(--ink);
  height: 1.15em;
}
.sheet-note {
  border: 1px solid #333;
  padding: 1.5mm 2.5mm;
  font-size: 9.5pt;
  margin-bottom: 3mm;
  line-height: 1.6;
}
.sheet-sec {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 1mm;
  margin: 2.5mm 0 2mm;
  break-inside: avoid;
}
.sheet-sec-s { font-weight: 400; font-size: 10pt; }
.sheet-sec-s b { display: inline-block; min-width: 14mm; border-bottom: 1px solid var(--ink); }
.bubbles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2mm 4mm;
  font-family: "Times New Roman", "SimSun", serif;
  font-size: 10.5pt;
  margin-bottom: 2mm;
}
.bubble-row {
  display: flex;
  align-items: center;
  gap: 1.5mm;
  break-inside: avoid;
}
.bubble-row .n { width: 1.7em; font-weight: 700; }
.bubble-row .bs { display: inline-flex; gap: 1.2mm; }
.bubble-row .sc {
  flex: 1;
  border-bottom: 1px dotted #bbb;
  height: 1em;
  margin-left: 1mm;
}
.bub {
  width: 4.6mm;
  height: 4.6mm;
  border: 1pt solid #333;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bub i {
  font-style: normal;
  font-size: 8pt;
  font-family: "Times New Roman", "SimSun", serif;
}
.sheet-write {
  border: 1pt solid #333;
  margin-bottom: 2.5mm;
  padding: 2mm 2.5mm;
  font-size: 10.5pt;
  break-inside: avoid;
}
.sheet-write .sw-h {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1mm;
}
.sheet-write .sw-h .n { font-weight: 700; }
.sheet-write .sw-h .sw-score { color: var(--muted); font-size: 9.5pt; }
.sw-hint {
  font-size: 9.5pt;
  color: #777;
  margin-bottom: 1.5mm;
  line-height: 1.5;
}
.sw-lines span {
  display: block;
  border-bottom: 1px solid #d4cec3;
  height: 8mm;
}
.sw-room {
  border: 1px solid #eee;
  min-height: 30mm;
}

.katex { font-size: 1.05em; }
.katex-display { margin: 0.4em 0; }

@media print {
  html, body {
    background: #fff !important;
    margin: 0;
    padding: 0;
  }
  .a4-page {
    box-shadow: none !important;
    margin: 0 !important;
    page-break-after: always;
    break-after: page;
  }
  .a4-page:last-child {
    page-break-after: auto;
  }
  .q-block.is-selected {
    outline: none;
    background: transparent;
  }
}

@page {
  size: A4;
  margin: 0;
}

/* 黑白模式只作用于卷面，工作台保留原有风格。 */
.a4-page.print-mono { background: #fff; --ink: #000; --rule: #000; --muted: #000; --cinnabar: #000; --fill-blank: #000; }
.a4-page.print-mono * { color: #000 !important; border-color: #000 !important; }
.a4-page.print-mono .sec-h, .a4-page.print-mono .essay-grid i { background: transparent !important; }
.a4-page.print-mono svg [stroke]:not([stroke="none"]) { stroke: #000 !important; }
.a4-page.print-mono svg text { fill: #000 !important; }
.a4-page.print-mono svg, .a4-page.print-mono img { filter: grayscale(1); }
.a4-page.print-mono .watermark { display: none; }

.answer-index .idx-note { font-size:9pt; margin-bottom:1.5mm; color:var(--muted); }
.idx-cell b { flex:none; }
.idx-answer { min-width:0; overflow-wrap:anywhere; }
.idx-ref { white-space:nowrap; font-size:9pt; }
.ans-head .ans-stem { min-width:0; }
.ans-q { overflow-wrap:anywhere; white-space:pre-wrap; }
