/* ===== 题目作用域：命名空间隔离层（类似学科网 .xkw） =====
 * 所有题目子样式必须嵌套在 .question-scope 下才生效，离开作用域不污染第三方页面。
 * scope 本身承载基础渲染规则（字体/换行/overflow），并约束内部子元素样式。
 * display 不强制，由 HTML 元素决定（通常 div 即 block，独占一行）。 */
 .question-scope {
  /* 容器基础样式 */
  font-family: "Times New Roman", SimSun, "宋体", serif;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  /* 裁切纵向超出行框的 KaTeX（分式等）；公式高亮模式 .formula-highlight 会反转 */
  overflow: hidden;
}

/* 波浪线 */
.question-scope .wavy-underline {
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-color: currentColor;
  text-underline-offset: 0.2em;
}

/* 双下划线 */
.question-scope .double-underline {
  text-decoration: underline;
  text-decoration-style: double;
  text-decoration-color: currentColor;
  text-underline-offset: 0.2em;
}

/* 波浪线包裹双下划线时，双下划线向下偏移避免重叠 */
.question-scope .wavy-underline .double-underline {
  text-underline-offset: 0.6em;
}

/* 加点字 */
.question-scope .emphasis-dots {
  text-emphasis: filled circle;
  text-emphasis-position: under;
  -webkit-text-emphasis: filled circle;
  -webkit-text-emphasis-position: under;
}

.question-scope .fill {
  display: inline-block;
  white-space: break-spaces;
  overflow-wrap: anywhere;
  min-width: 1.5em;
  height: 1.25em;
  line-height: 1.25em;
  text-align: center;
  vertical-align: baseline;
}

/* 下划线形式的填空（用 border-bottom 使空/有内容时都能显示下划线，text-decoration 对空元素无效） */
.question-scope .fill-underline {
  border-bottom: 1px solid currentColor;
  margin: 0 0.25em;
}

/* 括号形式的填空 */
.question-scope .fill-brackets {
  display: inline;
  padding: 0 0.25em;
}

.question-scope table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.question-scope td,
.question-scope th {
  border: 1px solid #000;
  padding: 0.25em 0.5em;
  text-align: left;
  min-height: 1em;
  position: relative;
}

.question-scope table.no-border td,
.question-scope table.no-border th {
  border: none;
}

.question-scope th {
  background: rgba(220, 220, 220, 0.5);
  font-weight: bold;
}

.question-scope p {
  white-space: pre-wrap !important;
}

/* 图片视图样式 */
.question-scope img {
  display: inline-block;
  float: none;
  line-height: 0;
  max-width: 100%;
  user-select: none;
  vertical-align: baseline;
}

.question-scope .image-view--block { display: block; }
.question-scope .image-view--left { float: left; }
.question-scope .image-view--right { float: right; }

/* Ruby 标签样式 - 拼音在上方 */
.question-scope ruby {
  ruby-align: center;
  ruby-overhang: auto;
}

.question-scope rt {
  padding: 0 1px;
  font-size: 0.6em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  font-family: SimSun, "宋体", serif, "Times New Roman";
}

.question-scope .katex {
  font-size: 1em;
  font-family: KaTeX_Main, Times New Roman, serif;
}

/* ===== 选项自适应分列（嵌套在 scope 下，整道题统一一个隔离层） =====
 * 列数由 JS（renderQuestionOptionHTML）测量内容宽度后写 data-cols，
 * CSS 按 [data-cols] 提供 grid-template-columns。
 * 未写 data-cols 时默认 1 列（兜底，JS 未执行场景）。
 *
 * 间距覆盖：
 *   .question-scope .question-options { --option-gap: 8px; } */
.question-scope .question-options {
  --option-gap: 6px;
  display: grid;
  gap: var(--option-gap);
  grid-template-columns: 1fr;
}

.question-scope .question-options[data-cols="1"] { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.question-scope .question-options[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.question-scope .question-options[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.question-scope .question-options[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.question-scope .question-options[data-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.question-scope .question-options[data-cols="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* 离屏测量层：fixed 离屏不参与布局；.measure-item inline-block + nowrap 取内容自然宽度 */
.question-scope .question-options-measure {
  position: fixed;
  top: 0;
  left: -9999px;
  pointer-events: none;
  opacity: 0;
}

.question-scope .question-options-measure .measure-item {
  display: inline-block;
  white-space: nowrap;
  vertical-align: top;
}

.question-scope .question-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
  min-width: 0;
}

.question-scope .question-option__label {
  flex-shrink: 0;
  font-weight: 500;
}

.question-scope .question-option__content {
  min-width: 0;
  flex: 1 1 0;
}

/* ===== 题干 + 子题（嵌套在 scope 下，整道题统一一个隔离层） =====
 * 主干直接渲染到 .question-stem；每个子题一个 flex 行：
 *   .question-stem__child           flex 行容器，margin-left 让子题比主干缩进
 *   .question-stem__no              序号（材料题无），flex-shrink:0
 *   .question-stem__child-content   子题内容，min-width:0 允许收缩换行 */
.question-scope .question-stem__child {
  display: flex;
}

.question-scope .question-stem__no {
  flex-shrink: 0;
  word-break: break-all;
}

.question-scope .question-stem__child-content {
  min-width: 0;
  flex: 1 1 0;
}

/* ===== 公式高亮模式（可选，第三方自渲染场景一般用不到，保留以备用） =====
 * 祖先带 .formula-highlight 或与 .question-scope 同一元素均可 */
.formula-highlight .question-scope,
.question-scope.formula-highlight {
  overflow: visible !important;
}

.formula-highlight .question-scope span[data-latex],
.question-scope.formula-highlight span[data-latex] {
  overflow: visible !important;
}

.formula-highlight .question-scope .katex-display,
.question-scope.formula-highlight .katex-display {
  overflow: visible !important;
}

.formula-highlight .question-scope .katex,
.question-scope.formula-highlight .katex {
  overflow: visible !important;
  background-color: #e2a217;
  border-radius: 2px;
  /* 分式等上下延伸，需纵向 padding，仅用 0 2px 会出现背景盖不全 */
  padding: 0.32em 0.25em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ===== 空白作答区高亮模式（可选） ===== */
.show-tips-highlight .question-scope .fill,
.question-scope.show-tips-highlight .fill,
.show-tips-highlight .question-scope .fill-underline,
.question-scope.show-tips-highlight .fill-underline,
.show-tips-highlight .question-scope .fill-brackets,
.question-scope.show-tips-highlight .fill-brackets {
  background-color: #FFCC33;
}