/* ===== 设计变量 ===== */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-soft: #60a5fa;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-sub: #6b7280;
  --ok: #10b981;
  --err: #ef4444;
  --warn: #f59e0b;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(31, 41, 55, 0.06), 0 4px 16px rgba(31, 41, 55, 0.06);
  --shadow-hover: 0 4px 12px rgba(37, 99, 235, 0.15), 0 8px 28px rgba(31, 41, 55, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 关键修复：作者样式里的 display:flex 会覆盖浏览器对 hidden 属性的 display:none，
   导致占位框无法隐藏。统一加一条最高优先级规则兜底。 */
[hidden] { display: none !important; }

/* 整页固定视口：任何内容都在列内滚动，页面本身不滚动 */
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: #f7f7f5;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

/* ===== 顶部导航栏（无背景、无阴影） ===== */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #2f6bff;
  border: none;
  box-shadow: none;
  color: #fff;
}
/* 左半区可点回首页 */
.topbar-left { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
/* logo 占位：白色圆角方块，后期直接放真实 logo 图 */
.logo {
  width: 28px; height: 28px; border-radius: 8px; background: #fff;
  display: inline-block; flex: 0 0 auto;
}
.topbar-title { font-size: 15px; font-weight: 600; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-link { color: var(--text-sub); text-decoration: none; font-size: 13px; }
.topbar-link:hover { color: var(--text); }

/* 头像 + 个人中心：白色圆角胶囊，无阴影 */
.avatar-menu { position: relative; }
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px 0 4px;
  background: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.user-pill:hover { background: #f1f1ef; }
.avatar {
  width: 26px; height: 26px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 140px;
  background: #fff;
  border: none;
  border-radius: 10px;
  box-shadow: var(--shadow-hover);
  padding: 6px;
  display: flex;
  flex-direction: column;
  z-index: 60;
}
.dropdown a {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.dropdown a:hover { background: #f1f1ef; }
.dropdown-divider { height: 1px; background: #efefed; margin: 4px 6px; }

/* ===== 三列主体：120px / 1fr / 1fr，列内独立滚动 ===== */
.layout {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: grid;
  /* 第三列（解析结果）封顶在纸面宽度附近，屏幕再宽也不跟着变宽，多出来的宽度全给第二列（原文） */
  --col3: clamp(600px, 52vw, 878px);   /* 878 = A4 纸 794 + 容器 padding 40 + 左右各 22，纸面四边间距一致 */
  grid-template-columns: 120px minmax(0, 1fr) var(--col3);
  gap: 12px;
  padding: 0 20px 12px;
}

.col {
  position: relative;      /* 状态栏绝对定位的参照 */
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ===== 列 1：缩略图（上） + 上传/清空/提示（下） ===== */
/* gap 必须与 .col 一致（8px），否则缩略图顶边会比右侧白区低 2px */
.col-thumbs { padding: 0; gap: 8px; }
.thumb-list {
  margin: 0;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  padding-right: 16px;   /* 右端留白：内容别顶到竖线（左 14 / 右 16，两边基本对称） */
}
.btn-upload {
  width: 100%;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: #fff;
  border: 1px dashed var(--primary);
  border-radius: 10px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
/* 中部组：占据剩余空间并垂直居中，保证「＋ 上传」在框内居中显示 */
.btn-upload .upload-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-upload:hover { background: rgba(37, 99, 235, 0.06); }
/* 上传满 5 张：置灰、不可点 */
.btn-upload:disabled,
.btn-upload.is-full {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-upload .plus { font-size: 20px; line-height: 1; }
.btn-clear {
  align-self: center;
  background: var(--primary);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.btn-clear:hover { background: var(--primary-light); }
.thumb-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.thumb {
  position: relative;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #efefed;
  aspect-ratio: 3 / 4;
  flex: 0 0 auto;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb.active { border-color: var(--primary); }
.thumb-remove {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  display: none;
}
.thumb:hover .thumb-remove { display: block; }
.thumbs-hint {
  flex: 0 0 auto;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  line-height: 1.5;
  margin: 0 0 8px;   /* 上传框内底部固定，不再作为框外说明文字 */
}

/* ===== 列 2 / 列 3：工具栏（强制单行，与左列顶边齐平） ===== */
.col-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
  height: 34px;          /* 三列工具栏高度锁死，第一列占位条才能精确对齐 */
  min-height: 34px;
  padding: 0;
  margin: 0;
  border: none;
}
.col-title { font-size: 14px; font-weight: 600; white-space: nowrap; }
.col-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.subject-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
/* 第一列顶部纯占位：无文字、无边框，只提供 34px 高度与另两列工具栏对齐 */
.col-toolbar-ghost { min-height: 34px; padding: 0; margin: 0; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.checkbox input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.checkbox-sub { color: var(--text-sub); font-size: 12px; }

/* 原图 / 微调版 / 去手写版 Tab：无边框透明文字 + 选中蓝色下划线（整卷/错题共用同一套） */
/* 图像 Tab 条：第二列区域上方，整卷 / 错题共用；按钮 26px + 上下 10px 内距，与第三列编辑工具栏高度一致；
   只圆上角、白底，与下方 source-view 融为同一张白卡（负外边距抵消 .col 的 8px gap，消灭灰色缝隙） */
.img-tabs-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
  background: #fff;
  border-radius: 10px 10px 0 0;
  margin-bottom: -8px;
}
/* Tab 条两模式常显（不再随处理结果显隐），只切换各 Tab 可用态 */
/* Tab 条右端：错题模式专属按钮（下载拼图 / 打印拼图）
   深灰字 + 浅灰圆角底，不加粗不蓝色；悬停加深，与左侧 Tab 视觉分离 */
.quiz-tab-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.quiz-tab-action {
  border: none;
  background: #f0f2f5;
  color: #4b5563;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
  height: 28px;
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.quiz-tab-action:hover:not(:disabled) { background: #e5e7eb; color: var(--text); }
/* 下载/打印拼图：自带图标，PC 只显示文字（手机端换成纯图标，见手机媒体块） */
.quiz-tab-action.has-ic .qic { display: none; }
.quiz-tab-action:disabled { opacity: 0.4; cursor: not-allowed; }

/* Tab 条内联动作小按钮：紧跟「微调版 / 去手写版」Tab，深灰字 + 浅灰圆角底 */
.img-tab-group { display: inline-flex; align-items: center; gap: 6px; }
.tab-inline-btn {
  border: none;
  background: #f0f2f5;
  color: #4b5563;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-inline-btn:hover:not(:disabled) { background: #e5e7eb; color: var(--text); }
.tab-inline-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 第三列编辑工具栏右端组：开关 + 保存 / 打印 */
.edit-toolbar-spacer { flex: 1; }

/* 配图去底灰：iOS 开关样式（默认关闭） */
.ios-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.ios-switch input { display: none; }
.ios-switch .ios-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: #d1d5db;
  transition: background 0.2s ease;
  flex: 0 0 auto;
}
.ios-switch .ios-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(31, 41, 55, 0.25);
  transition: left 0.2s ease;
}
.ios-switch input:checked + .ios-track { background: #34c759; }
.ios-switch input:checked + .ios-track::after { left: 16px; }
.ios-switch .ios-text { font-size: 12px; color: var(--text-sub); white-space: nowrap; }

/* ===== 开始解析：悬浮光环按钮（骑跨第二列/第三列交界，垂直居中） ===== */
.layout {
  position: relative;   /* 悬浮按钮的定位参照 */
  perspective: 800px;   /* 3D 视差透视 */
}
/* 渐变三色注册为可插值属性：状态切换时背景平滑渐变（旧浏览器降级为直接切换） */
@property --g1 { syntax: '<color>'; inherits: false; initial-value: #ffffff; }
@property --g2 { syntax: '<color>'; inherits: false; initial-value: #e5e7eb; }
@property --g3 { syntax: '<color>'; inherits: false; initial-value: #d1d5db; }
.btn-parse {
  --halo: 209, 213, 219;    /* 光环颜色（RGB 分量），随状态切换 */
  position: absolute;
  /* gap 中点 = 20px 内距 + 120px 缩略列 + 12px gap + 半个内容列宽 + 6px(半个 gap) = 50% + 66px；
     垂直方向扣掉底部 12px 内距的一半；居中用负 margin 承担，
     transform 只留 3D 旋转 —— 保证 hover 的 scale 呼吸严格绕球心缩放（位移不被 scale 放大漂移） */
  top: calc(50% - 6px);
  /* 交界中点 = 布局宽 - 左右内距差 - 第三列宽 - 半个按钮；第三列宽度由 .layout 的 --col3 给 */
  left: calc(100% - var(--col3) - 26px);
  margin-top: -25px;
  margin-left: -25px;
  transform-style: preserve-3d;
  will-change: transform;
  z-index: 999;
  width: 50px;
  height: 50px;
  padding: 0;
  border: none;
  border-radius: 50%;
  /* 轻拟物磨砂水晶：低饱和浅灰微渐变 + 柔和浅灰外发光，内高光克制不塑料 */
  background: radial-gradient(circle at 30% 30%, var(--g1) 0%, var(--g2) 70%, var(--g3) 100%);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.7),
    inset 0 -1px 2px rgba(31, 41, 55, 0.04),
    0 4px 15px rgba(209, 213, 219, 0.5);
  color: #4b5563;   /* 深灰文字，取消纯白 */
  font-size: 12px;
  font-weight: normal;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: --g1 0.3s ease, --g2 0.3s ease, --g3 0.3s ease,
    box-shadow 0.3s ease, color 0.3s ease, transform 0.1s ease-out, scale 0.3s ease;
}
/* 多层光环：两层 box-shadow 由内向外扩散、逐渐变淡（错峰呼吸），颜色随状态变 */
.btn-parse::before,
.btn-parse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.btn-parse::before { animation: parse-halo-1 2.4s ease-out infinite; }
.btn-parse::after  { animation: parse-halo-2 2.4s ease-out 0.8s infinite; }
@keyframes parse-halo-1 {
  0%   { box-shadow: 0 0 0 0 rgba(var(--halo), 0.35); }
  70%, 100% { box-shadow: 0 0 0 14px rgba(var(--halo), 0); }
}
@keyframes parse-halo-2 {
  0%   { box-shadow: 0 0 0 0 rgba(var(--halo), 0.22); }
  70%, 100% { box-shadow: 0 0 0 24px rgba(var(--halo), 0); }
}
/* 悬浮：清新科技蓝微渐变 + 蓝色发光光晕 + 白字 + 光环加速扩散 */
.btn-parse:hover {
  --g1: #79bbff;
  --g2: #409eff;
  --g3: #409eff;
  --halo: 64, 158, 255;
  color: #fff;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.35),
    inset 0 -1px 2px rgba(9, 46, 89, 0.08),
    0 4px 20px rgba(64, 158, 255, 0.4);
}
.btn-parse:hover::before,
.btn-parse:hover::after { animation-duration: 1.4s; }   /* 多层光环加速 */
/* 大小呼吸 + 点击回缩：动画与 :active 用 scale 独立属性，互不抢占也不碰内联 transform */
.btn-parse:hover:not(:active) { animation: parse-breathe 1.6s ease-in-out infinite; }
.btn-parse:active { scale: 0.92; }
@keyframes parse-breathe {
  0%, 100% { scale: 1; }
  50%      { scale: 1.1; }
}
/* 三层内容绝对定位叠加：状态切换 / 动画均不引起布局抖动 */
.btn-parse .p-idle,
.btn-parse .p-done,
.btn-parse .p-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateZ(20px);   /* 文字/图标浮出球面，增强立体悬浮感 */
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.btn-parse .p-done,
.btn-parse .p-loading { opacity: 0; visibility: hidden; }
.btn-parse.parse-done .p-idle,
.btn-parse.is-loading .p-idle { opacity: 0; visibility: hidden; }
.btn-parse.parse-done .p-done { opacity: 1; visibility: visible; }
.btn-parse.is-loading .p-done { opacity: 0; visibility: hidden; }
.btn-parse.is-loading .p-loading { opacity: 1; visibility: visible; }
/* 解析态悬浮：文字右滑消失，箭头从左滑入居中 */
.btn-parse .p-idle .text,
.btn-parse .p-idle .icon { transition: transform 0.25s ease, opacity 0.25s ease; }
.btn-parse .p-idle .icon {
  position: absolute;
  transform: translateX(-16px);
  opacity: 0;
}
.btn-parse:hover .p-idle .text { transform: translateX(20px); opacity: 0; }
.btn-parse:hover .p-idle .icon { transform: translateX(0); opacity: 1; }
/* 完成态悬浮：文字原地缩小消失，白色勾选圆放大居中 */
.btn-parse .p-done .text,
.btn-parse .p-done .icon-check { transition: transform 0.25s ease, opacity 0.25s ease; }
.btn-parse .p-done .icon-check {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  color: #67c23a;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.3);
  opacity: 0;
}
.btn-parse.parse-done:hover .p-done .text { transform: scale(0.5); opacity: 0; }
.btn-parse.parse-done:hover .p-done .icon-check { transform: scale(1); opacity: 1; }
/* 解析完成：翠绿微渐变 + 绿色发光光晕 + 多层细光环同步变绿 */
.btn-parse.parse-done {
  --g1: #95d475;
  --g2: #67c23a;
  --g3: #67c23a;
  --halo: 103, 194, 58;
  color: #fff;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.35),
    inset 0 -1px 2px rgba(40, 80, 20, 0.08),
    0 4px 20px rgba(103, 194, 58, 0.4);
}
.btn-parse.parse-done:hover {
  --g1: #85cb63;   /* 悬浮加深一档，保持绿色系 */
  --g2: #5aad30;
  --g3: #5aad30;
}
/* 加载态：蓝色球体 + 纯 CSS 转圈（文字完全隐藏，圆环居中） */
.btn-parse.is-loading {
  --g1: #79bbff;
  --g2: #409eff;
  --g3: #409eff;
  --halo: 64, 158, 255;
  color: #fff;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.35),
    inset 0 -1px 2px rgba(9, 46, 89, 0.08),
    0 4px 20px rgba(64, 158, 255, 0.4);
  cursor: wait;
}
.parse-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: parse-spin 0.8s linear infinite;
}
@keyframes parse-spin { to { transform: rotate(360deg); } }
/* 完成态悬浮气泡【重新解析】：贴着圆形按钮下方弹出，含隐形势桥防断触 */
.parse-rebubble {
  position: absolute;
  /* 与 .btn-parse 同一坐标系（都相对 main 绝对定位）：
     left 用按钮同一个表达式，top = 按钮中心(50% - 6px) + 半径25 + 间距12 */
  top: calc(50% - 6px + 37px);
  left: calc(100% - var(--col3) - 26px);
  transform: translateX(-50%);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.parse-rebubble::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 10px;    /* 隐形势桥：鼠标从按钮移向气泡不断触 */
}
.btn-parse.parse-done:hover + .parse-rebubble,
.parse-rebubble:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(4px);
}
.parse-rebubble button {
  border: none;
  background: #fff;
  color: var(--primary);
  font-size: 12px;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(31, 41, 55, 0.18);
  cursor: pointer;
  white-space: nowrap;
}
.parse-rebubble button:hover { background: #eff6ff; }

/* ===== 缩略图右下角状态标签：微调+N / 去手写 / 已解析（竖向排列，一行一个） ===== */
.thumb-tags {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  z-index: 2;
}
.thumb-tag {
  font-size: 10px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.92);
  color: #6b7280;
}
.thumb-tag.tag-manual { color: #2563eb; border-color: #bfdbfe; background: #eff6ff; }
.thumb-tag.tag-erase { color: #7c3aed; border-color: #ddd6fe; background: #f5f3ff; }
.thumb-tag.tag-parsed { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }
/* 移动端堆叠布局：悬浮按钮回归常规流式居中（!important 压过 JS 写入的内联 3D transform） */
@media (max-width: 768px) {
  .btn-parse {
    position: static;
    transform: none !important;
    display: block;
    width: 50px;
    height: 50px;
    margin: 12px auto;
  }
}
.img-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  align-items: center;
  background: transparent;
  padding: 0;
}
.img-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-family: inherit;
  line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
}
/* 选中项：文字加深 + 蓝色下划线（不铺底色，保持扁平） */
.img-tab.active { color: var(--text); font-weight: 600; }
.img-tab.active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 2px;
  border-radius: 1px;
  background: var(--primary);
}
.img-tab:not(.active):not(:disabled):hover { color: var(--text); }
.img-tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* 原图展示：白底、无边框，只有内容滚动。
   底部预留一行状态栏的空间，保证与第三列白区底边齐平；
   顶部直角：与上方 img-tabs-bar 拼成同一张白卡（交界处由 Tab 条的下边框分隔） */
.source-view {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: none;
  border-radius: 0 0 10px 10px;
  overflow: auto;
  padding: 12px 12px 28px;
}
.source-view img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 结果滚动区：高度锁死，只在框内滚 */
.result-scroll {
  flex: 1;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #fff;
  border-radius: 10px;
  padding: 0;
}

/* 空态占位 */
.empty-hint {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-sub);
  font-size: 13px;
  min-height: 200px;
}
/* 空态占位图标：现代极简线框 SVG（48px，浅灰描边，悬浮变主题蓝） */
.empty-icon {
  margin-bottom: 10px;
  color: #c0c4cc;
  transition: color 0.2s ease;
}
.empty-icon svg {
  width: 48px;
  height: 48px;
  display: block;
}
.empty-hint:hover .empty-icon { color: var(--primary); }
.empty-sub { font-size: 12px; color: #9ca3af; }
.empty-main { font-size: 14px; color: #4b5563; }

/* ===== 题目块悬浮选中 → 加入错题本（毛玻璃遮罩 + 置顶悬浮气泡） ===== */
.q-hoverable { position: relative; }
/* 这些按钮/气泡位于试卷卷面内，会继承卷面宋体字栈；显式统一为全站 UI 字体 */
.mistake-select-btn,
.btn-mistake-add,
.mistake-add-row,
.mistake-add-row *,
.mistake-pop,
.mistake-pop * {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
/* 按钮位于 contenteditable 卷面内：禁文字选中 + 阻断可编辑继承，杜绝文本插入符 */
.mistake-select-btn,
.btn-mistake-add,
.mistake-add-row,
.mistake-pop-actions button,
.btn-mistake-reselect {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-modify: read-only;
}
.mistake-select-btn svg,
.btn-mistake-add svg,
.mistake-pop-actions svg,
.btn-mistake-reselect svg { pointer-events: none; }   /* 点击目标始终落在 button 上 */
.mistake-pop input,
.mistake-pop select { user-select: text; -webkit-user-select: text; }
/* 三个按钮同一组件语言：8px 圆角、纯色/渐变底、无阴影；悬浮只在原地中心微放大 */
.mistake-select-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;          /* 与「保存修改 / 一键打印」一致 */
  background: #e8f1ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92);      /* 浮现动画：纯缩放，不做位置移动 */
  transform-origin: center center;
  transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease,
    scale 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.q-hoverable:hover .mistake-select-btn {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.mistake-select-btn:hover { scale: 1.05; background: #dbeafe; }   /* 独立 scale 属性：原地中心放大 */
.mistake-select-btn:active { scale: 0.96; }
/* 手机（没有 hover）：选中按钮常显，缩小一号贴题目右上角，点一下就是选中/取消 */
@media (hover: none), (max-width: 768px) {
  .q-hoverable .mistake-select-btn,
  .q-hoverable:hover .mistake-select-btn {
    opacity: 1; visibility: visible; transform: none;
    padding: 4px 9px; font-size: 11px; border-radius: 7px;
    background: rgba(232, 241, 255, .95);
  }
}
/* 选中态：橘红渐变「取消」，与主操作蓝形成主次区分 */
.mistake-select-btn.is-on {
  background: linear-gradient(135deg, #ff7a45, #ff5722);
  border-color: transparent;
  color: #fff;
}
.mistake-select-btn.is-on:hover {
  background: linear-gradient(135deg, #ff6c33, #f04d15);
}
/* 选中遮罩：毛玻璃（真实模糊下方文字），左右向外扩 16px，无边框 */
.mistake-mask {
  position: absolute;
  inset: -16px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: none;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  user-select: none;
  pointer-events: auto;
}
/* 中间主操作：蓝色渐变按钮，视觉层级最高（大号、无阴影、原地中心微放大） */
.btn-mistake-add {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 8px;          /* 与「保存修改 / 一键打印」一致 */
  background: linear-gradient(135deg, #4d8dff, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 22px;
  cursor: pointer;
  pointer-events: auto;
  z-index: 55;
  transform-origin: center center;
  transition: scale 0.18s ease;
}
.btn-mistake-add:hover { scale: 1.05; }
.btn-mistake-add:active { scale: 0.96; }

/* 已填字段 + 重新选择：一排展示；字段用灰色圆角标签（与按钮同一套底色语言） */
.mistake-add-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
  z-index: 55;
}
.mk-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e5e7eb;   /* 白底描边款（原「重新选择」样式） */
  border-radius: 8px;
  background: #fff;
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-mistake-reselect {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  border-radius: 8px;           /* 与「保存修改 / 一键打印」一致 */
  background: linear-gradient(135deg, #4d8dff, #2563eb);   /* 蓝色渐变主按钮款（原「加入错题本」样式） */
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  pointer-events: auto;
  transform-origin: center center;
  transition: scale 0.15s ease, background 0.15s ease, filter 0.15s ease;
}
.btn-mistake-reselect:hover { scale: 1.05; filter: brightness(1.08); }
.btn-mistake-reselect:active { scale: 0.96; }

/* 悬浮气泡分类卡：fixed 挂 body，以「加入错题本」按钮中心覆盖展开。
   脱离题目块的 overflow:hidden / 层叠上下文，z-index 9999 永远置顶，不被其他题目遮挡 */
.mistake-pop {
  position: fixed;
  left: 0;                     /* JS 按按钮中心写入具体 px */
  top: 0;
  z-index: 9999;
  width: 300px;
  transform: translate(-50%, -50%) scale(0.92);
  transform-origin: center center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(17, 24, 39, 0.16), 0 3px 10px rgba(17, 24, 39, 0.07);
  padding: 14px 14px 12px;
  transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.34, 1.45, 0.64, 1), visibility 0.2s;
}
.mistake-pop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.mistake-pop-row { display: flex; gap: 10px; margin-bottom: 10px; }
.mk-field { flex: 1; min-width: 0; }
.mk-field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #9ca3af;
  margin-bottom: 4px;
}
.mk-field select,
.mk-note {
  width: 100%;
  height: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mk-field select:focus,
.mk-note:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);   /* 聚焦柔光光环 */
}
.mk-note { margin-bottom: 12px; }
.mk-note::placeholder { color: #c0c4cc; font-size: 12px; }
.mistake-pop-actions { display: flex; justify-content: flex-end; gap: 8px; }
.mistake-pop-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 8px;          /* 与「保存修改 / 一键打印」一致 */
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transform-origin: center center;
  transition: scale 0.15s ease, background 0.15s ease;
}
.mk-cancel {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
}
.mk-cancel:hover { background: #f3f4f6; color: #374151; scale: 1.05; }
.mk-cancel:active { scale: 0.96; }
.mk-save {
  border: none;
  background: linear-gradient(135deg, #4d8dff, #2563eb);
  color: #fff;
}
.mk-save:hover { scale: 1.05; }
.mk-save:active { scale: 0.96; }

/* ===== 工作台顶栏【返回首页】按钮（SPA 切换，样式对齐 user-pill 高度） ===== */
.btn-back-landing {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 12px;
  margin-right: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  background: #fff;
  color: #6b7280;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-back-landing:hover { background: #f3f4f6; color: var(--text); }
/* ===== 试卷卷面（渲染后的文档） ===== */
/* 外层：白底容器，无边框无阴影 */
.paper-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  border: none;
  border-radius: 0;
  padding: 8px 0;
  overflow: auto;
  max-height: none;
}

/* 纸张本体：A4 比例（96dpi 下 794px 宽），白底、大留白、柔和外阴影 */
/* 只替换阿拉伯数字字形：宋体数字比汉字矮一截（x-height 小），
   用 Times 的数字（带 size-adjust 再放大），汉字仍走宋体，互不影响 */
@font-face {
  font-family: "PaperDigits";
  src: local("Times New Roman"), local("TimesNewRomanPSMT"), local("Georgia");
  unicode-range: U+0030-0039;
  size-adjust: 112%;
}

.paper {
  /* ===== 表格配图的可调参数（通用，一处改、全局生效） ===== */
  --fig-col: 40%;            /* 图列占表格宽度的比例（挤正文列，勿超 45%） */
  --fig-single-maxh: 170px;  /* 单图显示高度上限（打印不易模糊） */
  --fig-multi-h: 130px;      /* 多图统一高度（顶底对齐用） */

  width: 100%;
  max-width: 794px;
  min-height: 100%;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 4px;
  padding: 24px 28px 32px;   /* 扁平化：纸张内留白收窄，不再模拟桌面 */
  box-shadow: 0 2px 10px rgba(15, 23, 42, .07);
  color: #1a1a1a;
  /* PaperDigits 只覆盖 0-9，汉字继续走宋体 */
  font-family: "PaperDigits", "Songti SC", "STSong", "SimSun", "Noto Serif SC", "Times New Roman", serif;
  font-size: 14px;         /* 全局基准：接近 Word 五号，屏幕/打印一致 */
  font-weight: 400;      /* 全文默认不加粗，只有 **加粗** 才加粗 */
  line-height: 1.6;
  letter-spacing: 0.2px;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;   /* 禁止浏览器给 400 字重的字体"伪造"粗体 */
}

/* 标题（模型7》十字模型 / 【观察猜想】…）：
   与正文同字号、只加粗、统一左对齐，不再放大居中 */
.paper h1,
.paper h2,
.paper h3,
.paper h4,
.paper h5,
.paper h6 {
  font-size: 14px;        /* 与正文同字号，跟随全局缩小 */
  font-weight: 700;
  text-align: left;
  letter-spacing: 0;
  margin: 8px 0 2px;      /* 原来是 12/6，标题上下多出一行空白 */
  line-height: 1.5;       /* 原来继承正文的 1.8，标题行本身也被撑高 */
}

/* 正文：400 常规字重；段距收紧，避免题目之间出现大片空白 */
.paper p {
  margin: 4px 0;
  font-weight: 400;
}

/* 填空题的答题横线：长度统一，比一串下划线字符更接近原卷 */
.paper .blank {
  display: inline-block;
  min-width: 7em;
  height: 1em;
  border-bottom: 1px solid #1f2937;
  vertical-align: -0.15em;
}

/* 选择题选项组：按最长选项自动 4 列 / 2 列 / 单列，打印同样生效 */
.paper .choice-group {
  display: grid;
  gap: 10px 12px;
  margin: 4px 0;
  padding: 0;
}
.paper .choice-group.cols-4 { grid-template-columns: repeat(4, 1fr); }
.paper .choice-group.cols-2 { grid-template-columns: repeat(2, 1fr); }
.paper .choice-group.cols-1 { grid-template-columns: 1fr; }

/* 选择题块内的配图：居中放大（解答题图片仍按原布局） */
.paper .figure-choice {
  display: block;
  margin: 10px auto;
  max-width: 80%;
}

/* 漏题占位提示：浅黄底只包住文字，题号仍和真题一样对齐在左列 */
.paper .q-missing {
  color: #b45309;
  font-size: 13px;
  background: #fffbeb;
  border-radius: 4px;
}
.paper .question-row.q-missing { margin: 2px 0; }
.paper .question-row.q-missing .question-number { padding-left: 4px; }

/* 填空横线（解析兜底 .blank 与工具栏插入 .blank-line 同一套视觉） */
.paper .blank-line {
  display: inline-block;
  border-bottom: 1px solid #000;
  width: 120px;
  margin: 0 5px;
  vertical-align: -0.15em;
}
.paper .choice { display: block; line-height: 1.6; }

/* 配图白底化开关（第三列标题旁） */
.fig-white-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
  cursor: pointer;
}
.fig-white-toggle input { accent-color: var(--primary); margin: 0; }
.paper ul, .paper ol { margin: 4px 0; padding-left: 28px; }
.paper li { margin-bottom: 2px; }
/* 只有 Markdown 的 **粗体** 才加粗 */
.paper strong, .paper b { font-weight: 700; }
.paper hr { border: none; border-top: 1px solid #e5e7eb; margin: 24px 0; }

/* 表格：横向滚动容器 + 单元格最小宽度，避免文字被挤成竖排 */
.paper .table-wrap {
  width: 100%;
  overflow-x: auto;           /* 宽表格横向滑动，不撑爆页面 */
  margin: 0 auto;
}
.paper table {
  border-collapse: collapse;
  width: auto;                /* 按内容自适应，不撑满整屏 */
  max-width: 90%;             /* 太宽的表格压缩到容器 90% 内，不再左右滚动 */
  margin: 15px auto;          /* 表格整体居中 */
  table-layout: auto;        /* HTML 表格含 colspan/rowspan，自动布局才不会错位 */
  font-size: 13.5px;
  line-height: 1.6;
}
.paper td, .paper th { overflow-wrap: break-word; }  /* 压缩时长单元格内文字自动换行 */
.paper th, .paper td {
  border: 1px solid #c9ced6;
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;        /* 与原卷一致：标签、正文都顶对齐 */
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.paper th { background: #f4f7fb; font-weight: 600; }
.paper td { font-weight: 400; }

/* 单元格内的段落：行距、段距收紧，避免正文被 <p> 拆成多行后显得松散 */
.paper td p, .paper th p, .paper td div.md-line { margin: 0 0 2px; line-height: 1.65; }
.paper td p:last-child, .paper th p:last-child { margin-bottom: 0; }

/* 表格大标题行（整行只有一个跨列单元格）：居中 */
.paper td.table-title {
  text-align: center;
  font-weight: 600;
}

/* "材料1""解决问题"这类行标签：固定窄列，避免挤占正文 */
.paper td.row-label {
  width: 84px;
  min-width: 84px;
  white-space: nowrap;
  text-align: center;
  color: #374151;
}

/* 图片列：占比见 .paper 里的 --fig-col，文字列占其余 */
.paper td.figure-col {
  width: var(--fig-col);
  min-width: 200px;
}

/* 每个题目独立成块（纯块级，不做浮动/定位） */
.paper .question { overflow: hidden; }

/* 结果区小按钮（查看 Markdown） */
.btn-mini {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 12px;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  cursor: pointer;
}
.btn-mini:hover { background: #dbeafe; }

/* OCR 原始 Markdown 视图 */
.md-source {
  margin: 0;
  padding: 14px 16px;
  max-height: 70vh;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #111827;
  background: #f8fafc;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 配图基础约束：不撑破卷面，保持原比例 */
.paper img {
  display: block;
  float: none;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin: 8px auto;
  border-radius: 4px;
  background: #fff;
}

/* 题目配图区：贴在题目下方，图与图之间留间距 */
.paper .question-figures {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;    /* 顶边对齐：有的图带"备用图"图注、有的没有，也不会高低不平 */
  justify-content: flex-end;  /* 默认：单图靠右（原卷习惯） */
  gap: 22px;                 /* 图与图之间的间距 */
  margin: 12px 0 16px;
  clear: both;
}

/* 段落里直挂的图（OCR 有时不包 figure）：同样限到 200px，不许撑满整行 */
.paper section.question p > img:only-child:not(.figure-choice) {
  max-width: 200px !important;
  max-height: 200px !important;
  width: auto;
}

/* 没进图组、直接躺在题目里的单图：靠右 + 限尺寸（单图约 200px，不撑满整行） */
.paper section.question > figure.paper-figure {
  display: block;
  width: fit-content;
  max-width: 200px;
  margin: 12px 0 16px auto;
}
.paper section.question > figure.paper-figure > img:not(.img-resized) {
  max-width: 100%;
  max-height: 200px;
  width: auto;
  height: auto;
}

/* 单图组：解答题/填空单图靠右（复刻原卷习惯），尺寸压到选择题小图那一档；
   选择题的单图由下方 figure-choice 的 :has 规则覆盖回居中 */
.paper .question-figures.single { justify-content: flex-end; }
.paper .question-figures.single > figure.paper-figure { margin-left: auto; margin-right: 0; }
.paper .question-figures.single > figure.paper-figure > img:not(.img-resized):not(.fitted) {
  max-width: 200px;
  max-height: 200px;
  width: auto;
}
/* 工具栏【居中】：给图组容器加 fig-center，flex 布局下也能居中 */
.paper .question-figures.fig-center { justify-content: center !important; }
.paper .question-figures.fig-center > figure.paper-figure { margin: 0 auto !important; }
/* 选择题内的配图：强制居中放大，覆盖解答题的靠右规则 */
.paper .figure-choice { display: block; margin: 10px auto; max-width: 80%; }
/* 选择题里的图（无论单图组还是多图组）：容器与图都强制居中，覆盖"单图靠右" */
.paper .question-figures.single:has(> figure > img.figure-choice) { justify-content: center; }
.paper figure.paper-figure:has(> img.figure-choice) {
  max-width: 80%;
  width: auto;
  margin: 10px auto !important;
}
.paper figure.paper-figure img.figure-choice {
  max-width: 100% !important;
  max-height: 130px !important;
  margin: 0 auto;
}

/* 题目里落单、还没进图组的图片：居中 */
/* 题内落单图片：解答题靠右；选择题的落单图（figure-choice）仍居中 */
.paper section.question > p > img:only-child:not(.figure-choice) {
  margin-left: auto;
  margin-right: 0;
}

/* 多图：一行排列并整体居中（放不下自动换行）；顶边对齐，图注有无不一也不会错位 */
.paper .question-figures.multi {
  justify-content: center;
  align-items: flex-start;
}

/* 每张图都有图注：底边对齐，图注排在同一条横线上 */
.paper .question-figures.multi.all-captioned { align-items: flex-end; }

/* 多图尺寸由 JS 统一高度（fitMultiImages）；这里给尚未拟合的图一个稳定兜底 */
.paper .question-figures.multi figure.paper-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 31%;
}

.paper .question-figures.multi figure.paper-figure img:not(.fitted) {
  height: 120px;
  width: auto;
  max-width: 100%;
  margin: 0 0 6px;
}

/* JS 已算好统一高度的图：放开所有 CSS 尺寸限制，
   否则会被上面的 max-width/max-height 二次压缩而变形、看起来高低不一 */
.paper .question-figures img.fitted {
  max-width: none !important;
  max-height: none !important;
  width: auto;
  margin: 0 auto 6px;
}

.paper .question-figures figure.paper-figure {
  float: none;
  width: auto;               /* 不再固定 160px，按图片尺寸自适应 */
  margin: 0;
  text-align: center;
}

/* 题内配图（含单图兜底）：限制尺寸并保持原比例（解答题单图放宽到 340×300） */
.paper .question-figures img {
  max-width: 140px;
  max-height: 120px;
  margin: 0 auto 6px;
}

/* 图注：小一号灰字，居中贴在图下 */
.paper figure.paper-figure figcaption {
  font-size: 13px;
  line-height: 1.5;
  color: #6b7280;
  text-align: center;
}

/* 表格内的图 + 图注：整组居中、图下带图注 */
.paper .table-figures {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
  margin-top: 8px;
}
.paper .table-figure {
  display: block;
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  margin: 0;
  text-align: center;
}

/* 单图占满整格，图片才铺得开 */
.paper .table-figures:not(.multi) .table-figure { width: 100%; }

/* 单图：铺满图列宽度，高度按原比例 —— 391×109 这类长条图不会再被压成竖条 */
.paper .table-figure img {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: var(--fig-single-maxh);
  object-fit: contain;
  margin: 0 auto 4px;
}

/* 一格两张图：各占约一半，统一高度 → 顶边、底边都对齐 */
.paper .table-figures.multi .table-figure {
  flex: 0 1 46%;
  max-width: 46%;
}

.paper .table-figures.multi .table-figure img {
  width: auto;
  height: var(--fig-multi-h);
  max-width: 100%;
}

.paper .table-figure figcaption { font-size: 12.5px; color: #6b7280; }

/* 找不到对应图片的图注：居中灰色小字，不再乱飘 */
.paper p.caption-only {
  text-align: center;
  font-size: 12.5px;
  color: #6b7280;
  margin: 4px 0 12px;
}

/* 表格里的配图：宽度跟随单元格（即版面宽度），不再按 48% 缩成小图 */
.paper td img,
.paper th img {
  float: none;
  display: inline-block;
  vertical-align: bottom;
  max-width: 100%;
  max-height: 160px;
  margin: 2px 3px;
  object-fit: contain;
}

/* 含图的"行"：居中并排（原卷"图2 图3"并排一行时不会一左一右） */
.paper .img-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  margin: 8px 0 2px;
}

.paper .img-line img {
  display: block;
  margin: 0;
  max-width: 46%;
  max-height: 170px;
}

.paper .img-line img:only-child { max-width: 100%; }

/* 表格里"一图一注"：同高、图注贴在自己那张图下方 */
.paper .img-line .td-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  max-width: 46%;
}

.paper .img-line .td-figure img {
  height: var(--fig-multi-h);   /* 多图时等高 → 顶边、底边都齐平 */
  width: auto;
  max-width: 100%;
  margin: 0;
}

/* 单图：按图列宽度铺满、高度自适应 —— 长条横图不会被压成窄条 */
.paper .img-line .td-figure:only-child {
  max-width: 100%;
  width: 100%;
}

.paper .img-line .td-figure:only-child img {
  width: 100%;
  height: auto;
  max-height: var(--fig-single-maxh);
  object-fit: contain;
}

.paper .img-line .td-figure figcaption {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #4b5563;
  white-space: nowrap;
}

/* 表格里从图上方挪下来的图注（"图2 图3"）：居中排在图下方 */
.paper .td-captions {
  text-align: center;
  margin: 2px 0 8px;
  font-size: 13px;
  color: #4b5563;
}

/* 图片独占的段落去掉段距，避免多出一行空白 */
/* 孤立配图段落：强制居中，不挤占正文 */
.paper p.figure-only {
  margin: 10px 0;
  text-align: center;
}

/* 章节标题前后留白，避免与上方图片贴住 */
.paper h1, .paper h2, .paper h3, .paper h4 { clear: both; }

/* 配图加载失败时的占位提示 */
.paper .img-missing {
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
  margin: 10px 0;
}

.paper code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
}

/* 块级公式：独立成行、**左对齐**（与原卷正文对齐）、上下留白。
   vendor/katex/katex.min.css 里有 `.katex-display{text-align:center}`，
   这里用 !important 确保一定压住它 */
.paper .katex-display {
  display: block;
  text-align: left !important;
  margin: 14px 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* 公式本体也靠左，避免 KaTeX 内部行内盒自己居中 */
.paper .katex-display > .katex {
  text-align: left;
  display: inline-block;
}

/* 正文一律左对齐：防止某些容器（列表、表格、公式块）把居中继承下来 */
.paper p,
.paper li,
/* 题号悬挂：题号独占左列（Word 项目列表效果） */
.paper section.question {
  text-align: left;
  /* 左列宽度：正文段落/选项组共用，保证左边界一致 */
  --qnum-w: 22px;
}

/* 题干首行：flex 两列，题号固定宽度，正文占满剩余宽度并自然换行 */
.paper .question-row {
  display: flex;
  align-items: flex-start;
  margin: 4px 0 8px;
}
.paper .question-number {
  flex: 0 0 var(--qnum-w); /* 固定宽度：所有题号左对齐，不随文字变宽 */
  width: var(--qnum-w);
  font-weight: 700;        /* 题号保持加粗 */
  white-space: nowrap;
}
.paper .question-content {
  flex: 1;
  min-width: 0;            /* 允许内部换行，绝不缩到题号正下方 */
}

/* 小问、补充说明、小标题（【观察猜想】等）、选择题选项组与正文左边界对齐；
   图片/图注/表格不缩进 */
.paper section.question > p.question-body,
.paper section.question > .choice-group,
.paper section.question > h1,
.paper section.question > h2,
.paper section.question > h3,
.paper section.question > h4,
.paper section.question > h5,
.paper section.question > h6 {
  padding-left: var(--qnum-w);
}
/* 若块级公式被包在段落里，去掉段落底部多余间距 */
.paper p > .katex-display:only-child { margin-bottom: 0; }
/* 行内公式与正文同字号（恢复 1em） */
.paper p .katex { font-size: 1em; font-style: normal; }
.paper td .katex, .paper th .katex { font-size: 1em; }
.paper .katex { font-style: normal; }
/* 行内/行间公式字号强制与正文一致，不随环境跳变 */
.paper .katex { font-size: 1em !important; }
.paper .katex .katex-html { font-size: 1em; }
.paper .katex-display .katex { font-size: 1em; }

/* KaTeX 在 \sin/\cos/\tan 后插入的间距；有的落点不在 .katex 内，所以不限定父级 */
.paper .mspace, .paper .katex .mspace { margin-right: 0 !important; }

/* 数学变量（OAC、AB 等）应为斜体：TextIn 有时把变量包进 \mathrm 导致变正体 */
.paper .katex .mathnormal { font-style: italic; }
.paper .katex .mathrm { font-style: italic; }

/* 正文里裸露的线段名（AB、AC、BD…）：用 KaTeX 数学斜体字体，和公式里字母一致 */
.paper em.math-var {
  font-family: "KaTeX_Math", "Times New Roman", "Songti SC", serif;
  font-style: italic;
  font-weight: 400;
}

/* 被 TextIn 切到公式外的数字/函数名（"0.94,cos"、"tan"）：数学字体、无空格 */
.paper .math-piece {
  font-family: "KaTeX_Main", "Times New Roman", "Songti SC", serif;
  font-size: 1em;
  white-space: normal;
}

/* 渲染库加载失败时的降级显示 */
.paper pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.8;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
}

@media (max-width: 820px) {
  .paper { padding: 28px 20px 32px; font-size: 14px; }
  .paper-wrap { max-height: none; padding: 12px; }

  /* 小屏配图居中，可占满宽度 */
  .paper img {
    float: none;
    clear: none;
    display: block;
    margin: 12px auto;
    max-width: 100%;
    max-height: 180px;
  }
  .paper .question-figures {
    justify-content: center;
  }
  .paper .question-figures figure.paper-figure {
    max-width: 100%;
  }
  .paper .question-figures img {
    max-width: 100%;
    max-height: 170px;
  }
}

/* ===== 按钮（扁平：无渐变、无阴影） ===== */
.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:not(:disabled):hover { background: var(--primary-light); }
.btn-ghost {
  background: #f1f1ef;
  color: var(--text-sub);
  border: none;
}
.btn-ghost:hover { background: #e8e8e5; color: var(--text); }
.btn-mini {
  background: transparent;
  color: var(--primary);
  padding: 6px 8px;
}

/* 状态栏：绝对定位在第二列底部，高度固定，
   不再挤压预览区——两列白区顶/底边保持同一条水平线 */
.statusbar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  height: auto;
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-sub);
  min-height: 20px;
  pointer-events: none;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.status-dot.ok { background: var(--ok); }
.status-dot.err { background: var(--err); }
.status-dot.busy { background: var(--warn); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: 0.3; } }
.status-time { color: var(--primary-light); font-weight: 600; }

/* ===== 页脚：居中并排 ===== */
.footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  column-gap: 24px;
  row-gap: 2px;             /* 版权行与备案行贴紧，中间不再留一条空档 */
  flex-wrap: wrap;
  padding: 16px 20px 18px;
  font-size: 11px;
  color: #9ca3af;
}

/* 结果区里的纸张：跟随列高滚动，不再限制 68vh */
.col-result .paper-wrap { flex: 1; min-height: 0; max-height: none; }
.col-result .md-source { flex: 1; min-height: 0; overflow: auto; }

/* ===== 移动端：三列改上下堆叠（此时放开整页滚动） ===== */
@media (max-width: 768px) {
  body { height: auto; overflow: auto; }
  .layout { grid-template-columns: minmax(0, 1fr); overflow: visible; padding: 10px 12px 12px; align-content: start; }
  /* 手机上 #workspace-page 的 inline height:100vh 会把三列压成 0 高（行高被挤没了），必须放开 */
  #workspace-page { height: auto !important; min-height: 0; }   /* 不再撑满一屏：内容结束了紧接着就显示版权 */
  .col { overflow: visible; }
  .col-thumbs .col-toolbar { display: none; }
  .btn-upload { width: 76px; flex: 0 0 76px; }
  .btn-clear { align-self: flex-start; }
  .thumb-list { flex-direction: row; flex: 0 0 auto; overflow-x: auto; padding: 6px; }   /* 滚动条沿用统一细条 */
  .thumb { width: 64px; flex: 0 0 64px; }
  .thumbs-hint { display: none; }
  .source-view { min-height: 160px; }
  .result-scroll { overflow-y: visible; }

  /* ---------- 手机版整体收紧（原来这条页面上下堆得过高，纸面被挤到屏幕外） ---------- */
  /* 顶栏：一行放下，标题不换行，头像只留圆圈 */
  .topbar { padding: 10px 12px 12px; gap: 8px; }
  .topbar-left { gap: 8px; min-width: 0; }
  .topbar-title { font-size: 15px; letter-spacing: .3px; white-space: nowrap; }
  .logo { width: 26px; height: 26px; border-radius: 7px; }
  /* 头像组右缩到 11px：让圆圈中心正好压在下方「＋ 上传」按钮的中线上 */
  .topbar-right { gap: 8px; padding-right: 0; }
  .btn-back-landing { display: none !important; }
  .user-pill { padding: 2px; border-radius: 999px; }
  .avatar { width: 22px; height: 22px; font-size: 11px; }
  .user-pill > span:not(.avatar) { display: none; }

  /* 缩略图 + 上传：压成一条横带，别占半屏；上传和一键清空并排 */
  .col-thumbs { gap: 6px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .thumb-list { flex: 1 0 100%; max-height: 88px; padding: 4px; gap: 6px; }
  .thumb-list:empty { display: none; }
  .thumb { width: 56px; flex: 0 0 56px; }
  .btn-upload { width: 56px; flex: 0 0 56px; }
  .btn-upload .upload-center b { font-size: 12px; }
  .btn-clear { height: 28px; padding: 0 12px; font-size: 11.5px; align-self: center; }

  /* 原文预览列：限高，把版面留给纸面 */
  .col-source { max-height: 32vh; }

  /* 状态条不再绝对定位浮在图上，改成普通一行小字 */
  .statusbar { position: static; left: auto; right: auto; bottom: auto; padding: 4px 0 0; }

  /* 编辑工具条：横向滚动一行，不堆成三四行 */
  /* 编辑工具条分两部分：上排快捷格式按钮横向滚动，下排「开关 + 保存修改 + 一键打印」固定在右侧 */
  .edit-toolbar { flex-wrap: wrap; overflow: visible; padding: 8px 12px; gap: 8px; row-gap: 8px; }
  .edit-toolbar > * { flex: 0 0 auto; }
  .edit-toolbar .edit-format-group:not([hidden]) {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;          /* 手机不横滚：按钮换行完整显示，不裁字、不贴边 */
    overflow: visible;
    row-gap: 6px;
  }
  .edit-toolbar .edit-format-group::-webkit-scrollbar { display: none; }
  .edit-toolbar .edit-format-group > * { flex: 0 0 auto; }
  .edit-toolbar .edit-toolbar-spacer { display: none; }
  .edit-toolbar .ios-switch { flex: 0 0 auto; margin-right: 0; }
  .edit-toolbar #btn-save { margin-left: 0; }
  .edit-toolbar #btn-print { margin-left: 0; }

  /* 纸面：页边距收窄，尽量用满宽度 */
  .paper { padding: 18px 14px 24px; }
  .paper-wrap { padding: 0; }

  /* 手机端版面（v2.33 按截图重排） */
  /* 缩略图：左侧横滚；右侧一列竖排「上传 + 一键清空」 */
  /* 列间距收紧一点（缩略区和下方原图卡片之间原来空隙太大） */
  .layout { gap: 8px; }
  /* 原文列顶端那块「顶边对齐用」的幽灵占位在手机上是纯空白，直接去掉 */
  .col-source .col-toolbar-ghost { display: none; }

  .col-thumbs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 60px;
    grid-template-areas: "mode mode" "thumbs upload" "thumbs clear";
    column-gap: 8px; row-gap: 6px;
    align-items: start;
  }
  /* 手机上「整卷模式 / 错题模式」原来被隐藏了；放到缩略图上方的第一行 */
  .col-thumbs .col-toolbar {
    display: flex; grid-area: mode; padding: 0; margin: 0;
  }
  .col-thumbs .mode-switch { display: inline-flex; width: auto; gap: 6px; justify-self: start; }
  .col-thumbs .mode-btn { flex: 0 0 auto; height: 26px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
  /* 缩略图区：始终是白色圆角卡片（没有图片时也保留，不被 :empty 隐藏），图片横向滚动 */
  .thumb-list {
    grid-area: thumbs;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 84px;
    padding: 6px;
    gap: 8px;
  }
  .thumb-list:empty {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .thumb-list:empty::after {
    content: "上传的图片缩略图显示在这里";
    color: #9aa7b5;
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
    padding: 0 8px;
  }
  /* 缩略图放大到 72×72（原来 56 偏小，看不清是哪张图） */
  .thumb { width: 72px; height: 72px; flex: 0 0 72px; }
  /* 缩略图右下角标签：手机上字号再小一档，不压住缩略图主体 */
  .thumb-tag { font-size: 9px; padding: 2px 4px; border-radius: 5px; }
  .thumb-tags { gap: 3px; bottom: 3px; right: 3px; }
  /* 「上传」与「一键清空」等宽（56px），靠右一列竖排 */
  .btn-upload { grid-area: upload; width: 60px; height: 52px; min-height: 52px; aspect-ratio: auto; flex: none; justify-self: end; }
  .btn-clear { grid-area: clear; width: 60px; height: 26px; padding: 0; font-size: 11px; border-radius: 8px; justify-self: end; }
  .thumbs-hint { display: none; }

  /* 原文列：高度就按图片 100% 宽后自然撑开（不再一刀切限高把图裁掉） */
  .col-source { max-height: none; background: #fff; border-radius: 12px; overflow: hidden; }
  /* 固定高度：HEIC 转码时预览图还没出来，容器不能塌成 0，转圈才会落在原位 */
  .col-source .source-view { min-height: 0; height: auto; max-height: none; overflow: visible; min-height: 25vh; }
  .col-source .source-view .ptw-src-busy { z-index: 6; }
  .col-source .source-view img { width: 100%; height: auto; max-height: none; object-fit: contain; }
  /* 错题模式：桌面靠 absolute 填满固定列高，手机上列高是 auto，absolute 会让它塌成 25vh、内容被截。
     这里改回普通文档流，让裁片列表 + 拼图把卡片自然撑高，由整页滚动。 */
  .col-source .source-view .quiz-view {
    position: static;
    inset: auto;
    height: auto;
    max-height: none;
    overflow: visible;
    /* 关键：作为 .source-view 的 flex 子项，min-width:auto 会被裁片列表顶宽（整页横向溢出、列表也就不滚了） */
    width: 100%;
    min-width: 0;
  }
  /* 上面那条 .col-source .source-view img 的权重高于 .crop-frame img，会把方框里的裁片又撑成 width:100%+height:auto，
     这里补回来：裁片必须严格 contain 在 96px 方框内。 */
  .col-source .source-view .crop-frame img { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
  /* 错题模式：主图缩到 80% 宽居中，别再左右触边；裁片列表左右各留 12px */
  .col-source .source-view .quiz-preview-stage { padding: 4px 12px 8px; }
  .col-source .source-view .quiz-preview-stage #quiz-main-img { width: 80%; margin: 0 auto; }
  /* 手机：裁片方块缩到和缩略图一样 72×72，卡片跟着变矮，列表高度同步收 */
  .col-source .source-view .quiz-crop-list { padding: 6px 16px 6px 14px; max-width: 100%; height: 110px; max-height: 110px; }
  .col-source .source-view .crop-frame { width: 72px; height: 72px; }
  .col-source .source-view .crop-index { margin-top: 24px; }   /* (72+1)/2 - 12 - 1(卡片 padding) */
  .col-source .source-view .crop-item { padding: 5px; gap: 6px; }
  .col-source .source-view .crop-filename { max-width: 72px; font-size: 11px; margin-top: 2px; line-height: 1.15; }

  /* 原文 tab 条：横向滚动一行 */
  .img-tabs-bar { flex-wrap: wrap; overflow: visible; row-gap: 6px; padding: 8px 14px; }
  .img-tabs-bar > * { flex: 0 0 auto; }
  .layout > .col-source { margin-top: 0; }
  /* Tab 与内联小按钮字号统一到 12.5px（原来 13 / 11 两个字号看着不齐），组间间距拉开 */
  .img-tabs { gap: 6px; }
  /* 「重置恢复」原来 margin-left:auto 在滚动容器里失效，会紧贴「去手写」；这里改成固定间距 */
  .img-tabs-bar { gap: 8px; }
  .img-tabs-bar .quiz-tab-actions { margin-left: auto; gap: 6px; }
  /* 错题模式：下载拼图 / 打印拼图 收成 28×28 图标，保证和别的 Tab 挤在同一行 */
  .img-tabs-bar .quiz-tab-action.has-ic,
  .edit-toolbar .quiz-tab-action.has-ic {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; min-width: 28px; height: 28px; padding: 0;
  }
  .img-tabs-bar .quiz-tab-action.has-ic .lbl,
  .edit-toolbar .quiz-tab-action.has-ic .lbl { display: none; }
  /* 两排图标共用一套尺寸：16×16 且不许被 flex 压扁（工具栏按钮是 inline-flex，
     不加 flex:0 0 auto 的话 SVG 会被挤成 10×16，看着就比上面那排小一圈） */
  .img-tabs-bar .quiz-tab-action.has-ic .qic,
  .edit-toolbar .quiz-tab-action.has-ic .qic {
    display: block; flex: 0 0 auto; width: 16px; height: 16px;
  }
  .img-tabs-bar #btn-reset-img { padding: 0 10px; }
  /* 错题模式多出两个图标按钮：这一行再紧一档，保证和竖版一样只占一行 */
  .img-tabs-bar:has(#btn-quiz-png:not([hidden])),
  .img-tabs-bar:has(#btn-quiz-png:not([hidden])) .img-tabs,
  .img-tabs-bar:has(#btn-quiz-png:not([hidden])) .quiz-tab-actions { gap: 4px; }
  .img-tabs-bar:has(#btn-quiz-png:not([hidden])) .img-tab { font-size: 11.5px; padding: 0 2px; }
  .img-tabs-bar:has(#btn-quiz-png:not([hidden])) .tab-inline-btn { font-size: 11.5px; padding: 0 5px; }
  .img-tabs-bar:has(#btn-quiz-png:not([hidden])) #btn-reset-img { padding: 0 6px; }
  .img-tabs-bar:has(#btn-quiz-png:not([hidden])) .quiz-tab-action.has-ic { width: 28px; min-width: 28px; }
  .img-tab { font-size: 12.5px; height: 28px; padding: 0 4px; }
  .img-tab-group { gap: 8px; }
  .tab-inline-btn { font-size: 12.5px; height: 28px; padding: 0 8px; border-radius: 8px; }

  /* 手机上不需要「查看 Markdown」这类调试入口，整条工具栏和 md 预览都隐藏 */
  .col-result .col-toolbar { display: none; }
  #md-source { display: none !important; }

  /* 「整页视图 / 真纸尺寸」切换（只在手机上出现） */
  .ptw-paper-view { display: none; }
  .ptw-paper-view button {
    height: 26px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px;
    background: #fff; color: var(--text-sub); font-size: 12px; font-family: inherit;
    cursor: pointer; white-space: nowrap;
  }
  .ptw-paper-view button.is-on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

  /* 纸面容器：手机上四边间距收小，纸面阴影直接去掉（屏幕太小，阴影只是脏） */
  /* 整页视图下纸面直接贴满容器宽（外面那圈 10px 白边会跟纸内页边距叠成一大片空白）。
     真纸尺寸模式靠 overflow-x 横拖，不受此影响。 */
  /* 整页视图：纸面不许自己滚（否则超出一页的内容会被 wrap 吞掉、外层永远滚不动），
     真纸尺寸模式才需要横向滚动 */
  #paper-wrap.ptw-a4 { padding: 0 !important; overflow: visible !important; }
  #paper-wrap.ptw-a4.is-real { overflow-x: auto !important; overflow-y: hidden !important; }
  #paper-wrap.ptw-a4 #result-paper { box-shadow: none !important; border-radius: 0 !important; }
  /* 整页视图：屏幕上的纸面页边距按比例收紧（打印仍是真实 10mm / 18mm，@media print 里 padding:0 + 独立页容器） */
  #paper-wrap.ptw-a4:not(.is-real) #result-paper { padding: 3mm 5mm !important; }
  /* 手机第二行一条放五个：整页 / 真纸（左）… 配图去底灰 · 保存 · 打印（右）
     DOM 里视图按钮是最后 append 的，靠 order 提到最前 */
  .edit-toolbar .ptw-paper-view { display: flex; order: 3; flex: 0 0 auto; gap: 6px; margin: 0; }
  .edit-toolbar .ptw-paper-view button { height: 28px; padding: 0 10px; }
  .edit-toolbar .ios-switch { order: 2; flex: 0 0 auto; margin: 0 0 0 auto; }
  .edit-toolbar #btn-save { order: 3; margin-left: 6px; padding: 0 9px; }
  .edit-toolbar #btn-print { order: 4; margin-left: 4px; padding: 0 9px; }

  /* 打印预览顶栏：单行 flex 在 390 宽下把每个字挤成竖排，改成块状分行 */
  .ptw-print-bar { flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 12px; }
  .ptw-print-bar > b { order: 0; flex: 0 0 auto; white-space: nowrap; }
  .ptw-print-bar > button { order: 1; flex: 0 0 auto; }
  .ptw-print-bar > button:first-of-type { margin-left: auto; }
  .ptw-print-bar > .pbar-meta { order: 2; flex: 1 1 100%; white-space: normal; font-size: 12px; line-height: 1.5; }
  .ptw-print-bar > .pbar-note { order: 3; flex: 1 1 100%; white-space: normal; font-size: 11.5px; line-height: 1.5; }
  .ptw-print-bar > .pbar-grp { order: 4; flex: 1 1 100%; margin-left: 0 !important; flex-wrap: wrap; row-gap: 6px; }
  .ptw-print-bar > .pbar-grp > span { white-space: nowrap; }
  .ptw-print-bar > .pbar-ver, .ptw-print-bar > .sp { display: none; }

  /* 解析结果块：给足高度，至少能看到一页纸的比例 */
  /* 结果卡片：滚到它时吸顶占满一屏，之后只滚卡片内部（工具条常驻顶部）。
     纯 CSS sticky 在这里无效——父容器 .col-result 高度就等于卡片，
     没有粘滞行程；也不能加高父容器，否则页面底部就永远滚不到。
     所以用 JS 打 .ptw-pin-result，把卡片临时 fixed，父列拿 100vh 占位防跳动 */
  /* 卡片常态就占满一屏：这样「滚到结果块」和「页面滚到底」正好同时发生，
     钉住时不会因为高度变化跳一下 */
  .col-result { min-height: 0; height: 100vh; overflow: visible; }
  /* 结果卡默认不高：空态只占 25vh，解析后由纸面内容自己撑高（吸顶时另由 .ptw-pin-result 规则接管） */
  #workspace-page:not(.ptw-pin-result) .col-result .result-card { flex: 0 0 auto; height: auto !important; min-height: 25vh; }
  /* 纸面不能被 flex 压扁（全局给的是 flex:1 / height:100%），否则超出一页的内容
     会溢出纸面被裁掉。要让外层按纸的真实高度撑开，滚动才发生在 .result-scroll 上 */
  .result-card .result-scroll .paper-wrap { flex: 0 0 auto; height: auto !important; align-self: stretch; }
  .result-card .result-scroll { overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
  /* 钉住时的高度 = 可视高度减去底部悬浮积分条，避免最后几行被它压住 */
  /* 占位必须是满屏 100vh（不是卡片自己的高度）：卡片矮了以后它下面空出来的
     那一截正好留给版权页脚，页面总高不变、钉住瞬间才不会"回弹"跳一下 */
  #workspace-page.ptw-pin-result .col-result { height: 100vh; min-height: 100vh; }

  #workspace-page.ptw-pin-result .result-card {
    position: fixed; left: 12px; right: 12px; top: 0; bottom: auto;
    height: var(--ptw-fit-h, 100vh); max-height: var(--ptw-fit-h, 100vh); min-height: 0;
    z-index: 40; border-radius: 0 0 14px 14px;
  }
  /* 后面 .result-card .result-scroll{padding:20px} 同权重且更靠后，会盖掉这条，必须 !important */
  .result-card .result-scroll { min-height: 0; padding: 0 2px 4px !important; }
  .paper-wrap { min-height: 62vh; }

  /* 状态条：回到原文白卡底部（source-view 下方已预留 28px），与 PC 完全一致。
     右边界给解析按钮让出位置，否则按钮压住「手动微调第 N 次…」这行字 */
  /* 状态条改成流内一行（原来 absolute 浮在原文卡底部，会压住空态/加载中的提示文字） */
  .statusbar {
    position: static; left: auto; right: auto; bottom: auto; padding: 6px 12px 10px;
    flex-wrap: nowrap; row-gap: 0; font-size: 11px; line-height: 1.4;
    background: #fff; justify-content: flex-start; text-align: left;
  }
  /* 手机上不显示耗时（「总耗时 46 ms（其中解析服务 3029 ms）」太占位置） */
  .statusbar .status-time { display: none !important; }
  .statusbar.is-after-result { padding: 0; margin-top: 0; }
  /* 第一行：小圆点 + 状态文字（超出省略）；第二行：耗时右对齐。
     注意别写成 > span:first-child —— 第一个 span 是 status-dot，
     被撑成 100% 宽会变成一条横贯整行的色条（之前那次就是这个 bug）。 */
  .statusbar .status-dot { flex: 0 0 auto; }
  .statusbar #status-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .statusbar .status-time { flex: 0 0 auto; text-align: right; }
  /* 底部给两行状态条留够位置（原来只留 28px，两行会压到图片上） */
  .col-source .source-view { padding-bottom: 6px; }

  /* 解析按钮：作为两块之间的一个独立元素，居中放（不再悬浮遮挡纸面） */
  .layout { perspective: none; }
  .btn-parse.is-flow {
    position: relative;
    top: auto; left: auto;
    /* 上下各 -45，把 50px 的按钮压成 0 行高：按钮正好骑在「原文块 / 结果块」交界上，
       不再单独占一大块空白 */
    /* 行高仍压成 0（-45 + -5 抵消 50px），球心再往上抬：
       工具条现在只剩两行，保存/打印上移到第一行右端，球底会压住「打印」6px */
    margin: -35px 20px -25px auto;
    justify-self: end;
    align-self: start;
    z-index: 30;
  }
  .btn-parse:not(.is-flow) { position: fixed; top: auto; bottom: 66px; left: 50%; margin-left: -25px; margin-top: 0; }

  /* 版权页脚：底部要留出悬浮积分胶囊的高度，否则滚到底时版权字被胶囊压住看不见 */
  /* 版权页脚：底部那截 56px 是专门让底部积分胶囊落进来的，版权字本身不会被它压住；
     卡片与版权之间的空隙由 JS 里 fitH 的 12px 间距控制（图二要求收小） */
  .footer { padding: 10px 12px 56px; font-size: 11px; line-height: 1.35; text-align: center; }
}

/* ===== 横向可滚动区：藏掉系统滚动条，用下面这套「竖线 + 阴影 + 可拖圆点」 ===== */
.thumb-list, .quiz-crop-list, .img-tabs-bar, .edit-format-group, .user-mk-pills {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.thumb-list::-webkit-scrollbar,
.quiz-crop-list::-webkit-scrollbar,
.img-tabs-bar::-webkit-scrollbar,
.edit-format-group::-webkit-scrollbar,
.user-mk-pills::-webkit-scrollbar { display: none; }

/* 浮层：竖线在右内缘，竖线左侧一片阴影表示「还有内容藏着」；圆点直接压在容器下边框线上
   位置全部用「文档坐标」（absolute + 页面滚动偏移），页面滚动 / 下拉回弹时跟着一起走，不会浮在屏幕上 */
.ptw-hs-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 45; }
.ptw-hs { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.ptw-hs-fade {
  position: absolute; pointer-events: none;
  box-sizing: border-box;
  background: linear-gradient(90deg, rgba(100, 116, 139, 0) 0%, rgba(100, 116, 139, .20) 100%);
  /* 竖线直接用这一块的右边框：它跟着容器的右圆角一起弯，不会再戳出两个直角 */
}
.ptw-hs-line { position: absolute; width: 1px; background: #b7c4da; pointer-events: none; }
/* 左端：用「卡片底色 → 透明」的渐隐，滚进来的内容淡出，不会硬裁到边上，也不会蒙一层灰 */
.ptw-hs-fadel { position: absolute; pointer-events: none; }
/* 左端蒙层：内容滚进左边缘时被蒙住渐隐，看不出「触边硬裁」 */
.ptw-hs-fadel {
  position: absolute; pointer-events: none;
  background: linear-gradient(270deg, rgba(100, 116, 139, .20) 0%, rgba(100, 116, 139, 0) 100%);
}
.ptw-hs-track { position: absolute; pointer-events: none; }
.ptw-hs-dot {
  position: absolute; top: 0; width: 12px; height: 12px; border-radius: 50%;
  background: #b9c5da; box-shadow: 0 1px 3px rgba(15, 23, 42, .18);
  pointer-events: auto; cursor: grab; touch-action: none; transition: background .15s ease;
}
.ptw-hs-dot:hover { background: #94a6c4; }
.ptw-hs-dot:active { cursor: grabbing; background: #7f93b5; }

/* 打印预览打开时隐藏底部积分胶囊（它会透过半透明遮罩露出来） */
body.ptw-pv-open .ptw-bill { display: none !important; }

/* ===== 打印：只打印试卷本身 ===== */
@media print {
  body { background: #fff; padding: 0; gap: 0; height: auto; overflow: visible; }
  .topbar, .col-thumbs, .col-source, .col-toolbar, .footer { display: none !important; }
  .layout { display: block; overflow: visible; padding: 0; }
  .col { border: none; box-shadow: none; padding: 0; }
  .col-result .result-scroll { overflow: visible; }
  .col-result .paper-wrap { border: none; background: #fff; padding: 0; overflow: visible; }
  .paper { box-shadow: none; max-width: none; margin: 0; }
}

/* ===== WYSIWYG 编辑态 ===== */
/* 编辑聚焦：边框微微泛蓝（无赖样式侵入，只描边不位移） */
.paper[contenteditable="true"] { outline: none; cursor: text; position: relative; }
.paper[contenteditable="true"]:focus {
  /* inset：描边画在纸张内侧，不会被父级 overflow 裁掉上下两条 */
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.45);
  border-radius: 6px;
}
/* 公式可整体选中（KaTeX 内部结构别让浏览器拆着编辑） */
.paper[contenteditable="true"] .katex-display { user-select: contain; }

/* 图片选中框：贴着图片画（浏览器原生选区在 flex/浮动布局里会偏到整块上） */
.paper img.img-selected {
  outline: 2px solid #2f7cf6;
  outline-offset: 2px;
  border-radius: 2px;
}
/* 内容有改动：「保存修改」按钮呼吸提示 */
@keyframes save-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
.btn-dirty {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #fff !important;
  animation: save-pulse 1.6s ease-out infinite;
}

/* 右下角缩放手柄：位置由 JS 按图片 rect 实时定位，永远贴在图片右下角 */
.img-handle {
  position: fixed;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2f7cf6;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
  cursor: nwse-resize;
  z-index: 9998;
  touch-action: none;
}
.img-handle:hover { background: #1d63d8; }
/* 手动改过尺寸的图：放开所有 CSS 尺寸限制，否则会被 max-width 拉回去 */
.paper img.img-resized { max-width: none !important; max-height: none !important; }
.paper .question-figures figure.paper-figure:has(img.img-resized) { max-width: none !important; }
/* 拖动中的原图淡下去，跟手的半透明预览见 .img-drag-ghost */
.paper img.img-dragging { opacity: 0.35; }
.img-drag-ghost {
  position: fixed;
  pointer-events: none;
  opacity: 0.7;
  z-index: 9997;
  border-radius: 2px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
}
/* 落点指示线 */
.img-drop-marker {
  position: fixed;
  height: 2px;
  background: #2f7cf6;
  box-shadow: 0 0 0 1px rgba(47, 124, 246, 0.35);
  z-index: 9999;
  pointer-events: none;
}
/* 编辑态里图片始终可拖，鼠标移上去给个"可点"的手型 */
.paper[contenteditable="true"] img { -webkit-user-drag: element; cursor: pointer; }
.paper img.img-dragging { cursor: grabbing; }

/* ===== 第三列白底卡片：上半工具栏固定 + 下半编辑区独立滚动 ===== */
.result-card {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 工作台整体白底（纸面周围的淡蓝台面交给 #paper-wrap.ptw-a4） */
  background: #fff;
  border-radius: 8px;
}
.result-card .result-scroll {
  flex: 1;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
  border-radius: 0;
}
.result-card .paper-wrap { padding: 0; }
/* 「整页视图 / 真纸尺寸」只在手机出现；桌面 DOM 里也会被注入这组按钮，这里兜底隐藏，
   手机端用 .edit-toolbar .ptw-paper-view 提权重显示 */
.ptw-paper-view { display: none; }

/* 格式工具栏（有结果时显示）：白卡顶部固定条，不用 sticky */
.edit-toolbar {
  flex-shrink: 0;
  /* 三组：科目 | 快捷按钮（可横滚）| 开关+保存+打印，组间 14px */
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
  padding: 10px 20px;
  border: none;
  border-bottom: 1px solid #eee;
  border-radius: 0;
  background: #fff;
}
.edit-toolbar .subject-tag { order: 1; flex: 0 0 auto; }
.edit-toolbar .edit-format-group {
  order: 2; flex: 1 1 auto; min-width: 0;
  padding-right: 16px;   /* 右端留白：最后一个按钮别顶到竖线 */
  display: flex; align-items: center; gap: 4px; flex-wrap: nowrap;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding-bottom: 2px;
}
.edit-toolbar .edit-format-group > * { flex: 0 0 auto; }
.edit-toolbar .ptw-paper-view { order: 3; flex: 0 0 auto; gap: 6px; }   /* display 由手机块给：PC 不显示 */
.edit-toolbar .edit-right-tools { order: 4; margin-left: auto; flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.edit-toolbar .edit-toolbar-spacer { display: none; }
.edit-toolbar button {
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
}
.edit-toolbar button:hover { background: #e8eefc; }
.edit-toolbar-divider { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
/* 工具栏内嵌的 quiz-tab-action 按钮（保存修改 / 一键打印）：
   覆盖上面 .edit-toolbar button 的透明底样式，统一为与「重置恢复」一致的灰底圆角 */
.edit-toolbar button.quiz-tab-action {
  min-width: 0;
  height: 28px;
  padding: 0 12px;
  border-radius: 8px;
  background: #f0f2f5;
  color: #4b5563;
  font-size: 12px;
}
.edit-toolbar button.quiz-tab-action:hover:not(:disabled) { background: #e5e7eb; color: var(--text); }
/* 去灰底：按钮形态的开关，蓝底 = 已开启 */
.edit-toolbar button.quiz-tab-action.is-toggle.is-on,
.edit-toolbar button.quiz-tab-action.is-toggle.is-on:hover:not(:disabled) {
  background: var(--primary); color: #fff; font-weight: 600;
}
/* 格式按钮组容器：无解析内容时整组隐藏（编辑工具栏行本身常显） */
.edit-format-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.edit-format-group[hidden] { display: none; }

/* 符号下拉 */
.sym-menu-wrap { position: relative; }
.sym-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(31, 41, 55, 0.12);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.edit-toolbar .sym-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: auto;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: left;
}
.edit-toolbar .sym-item:hover { background: #f1f5f9; }
.sym-char { font-size: 15px; width: 20px; text-align: center; }
.sym-name { font-size: 12px; color: var(--text-sub); }
.sym-count { margin-left: auto; font-size: 10px; color: #c0c4cc; }
.sym-empty { padding: 8px 10px; font-size: 12px; color: #9ca3af; }
.paste-hint { margin-left: auto; font-size: 11px; color: #9ca3af; }

/* 粘贴图片缩放控制点（绝对定位于 paper-wrap，不在可编辑区里） */
.paper-wrap { position: relative; }
.img-resize-handle {
  position: absolute;
  z-index: 30;
  width: 12px;
  height: 12px;
  background: var(--primary);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(31, 41, 55, 0.35);
  cursor: nwse-resize;
}
body.resizing-img { user-select: none; cursor: nwse-resize; }
body.resizing-img img.pasted-img { cursor: nwse-resize; }

/* 粘贴进来的截图：不撑破卷面，打印也不糊 */
.paper img.pasted-img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  display: block;
  margin: 8px auto;
  border-radius: 4px;
}

/* ===== 打印：全局字号 + 防截断 ===== */
@media print {
  /* 与屏幕同版式：五号字、1.6 行高 */
  .paper { font-size: 14px; line-height: 1.6; }
  .edit-toolbar, .img-resize-handle { display: none !important; }

  /* 图片与图组绝不跨页断裂（断裂是打印截断/糊图的主因） */
  .paper img {
    max-width: 100% !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .paper figure.paper-figure,
  .paper .question-figures,
  .paper .table-figure {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* 表格允许跨页，但整行不拆、表头在每页重复 */
  .paper table { break-inside: auto; }
  .paper tr { break-inside: avoid; page-break-inside: avoid; }
  .paper thead { display: table-header-group; }

  /* 标题不悬在页尾：标题与后面第一段绑定 */
  .paper h1, .paper h2, .paper h3, .paper h4, .paper h5, .paper h6 {
    break-after: avoid;
    page-break-after: avoid;
  }
}

/* ===== 模式切换（第一列顶部：整卷 / 错题） ===== */
.mode-switch {
  display: flex;
  gap: 2px;
  width: 100%;
  height: 28px;
  align-items: center;
  background: #f1f1ef;
  border-radius: 8px;
  padding: 2px;
}
.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 12px;
  font-family: inherit;
  line-height: 1;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-btn.active { background: var(--primary); color: #fff; }
.mode-btn:not(.active):hover { color: var(--text); }

/* ===== 错题模式视图（第二列）：裁片列表 + 处理后的拼图 ===== */
.source-view { position: relative; }
/* 转码/解码中：预览区正中的转圈 + 文案已足够表达，把底下的空态提示淡出，避免两层字叠在一起 */
.source-view.is-busy .empty-hint { opacity: 0; transition: opacity .2s ease; }
.empty-hint { transition: opacity .2s ease; }
.quiz-view {
  position: absolute;
  inset: 12px 12px 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;          /* 裁片一多就整块滚动，别把主图压成一条缝 */
  -webkit-overflow-scrolling: touch;
}
/* 主预览区：Tab 已统一到第二列顶部工具栏（imgTabs），此处仅保留舞台 */
/* 单图舞台：撑满剩余空间，长图内部滚动，绝不撑长页面 */
.quiz-preview-stage {
  flex: 1 1 auto;            /* 占满裁片区以上，图片在里面按比例撑开、超长由 .quiz-view 滚动 */
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  overflow: visible;
  background: transparent;
  border: none;
  padding: 4px 2px 8px;
}
.quiz-preview-stage #quiz-main-img { width: 100%; height: auto; display: block; }
/* 裁片列表：横向滚动、限高 130px，白色/透明底 + 极细上边框与预览区分隔 */
.quiz-crop-list {
  flex: 0 0 auto;
  height: 140px;              /* 固定高：96px 方框 + 内边距 + 8px 滚动条，不跟着浏览器高度伸缩 */
  max-height: 140px;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  padding: 10px 2px;
  background: transparent;
  border-top: 1px solid #ebeef5;
}
.quiz-crop-list:empty { display: none; }   /* 没有裁片时不占高度 */
.quiz-crop-list::after { content: ''; flex: 0 0 12px; }   /* 滚到最右时最后一张与边缘留 12px */
.quiz-view-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-sub);
  font-size: 13px;
  text-align: center;
}
.quiz-view-empty-sub { font-size: 12px; color: #9ca3af; }
/* 裁片卡片：序号 - 细边框图片(80px 高) - 图片下方来源文件名 */
.crop-item {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;   /* 顶部对齐：序号相对图片高度居中，而不是相对整卡（含文件名）居中 */
  gap: 8px;
  background: #fff;
  padding: 8px;
  border-radius: 6px;
}
/* 序号：圆形浅灰底徽标 */
.crop-index {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f0f2f5;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  /* (96px 方框 + 2px 边框) / 2 - 12px 徽标半径 = 37px，正对图片垂直中心 */
  margin-top: 37px;
}
.crop-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.crop-frame {
  width: 96px;
  height: 96px;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  overflow: hidden;
  line-height: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.crop-frame img {
  /* 撑满方框 + contain：竖长裁片按比例缩进，绝不溢出 96px 框、也不被压成怪比例 */
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.crop-filename {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #909399;
  margin-top: 4px;
}
/* 右上角 X 删除按钮 */
.quiz-crop-del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--err);
  color: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(31, 41, 55, 0.25);
}
.quiz-crop-del:hover { background: #dc2626; }
/* 处理后的拼图（手动微调 / 去手写 Tab）：同样只刷新主预览区的 #quiz-main-img */

/* ===== 错题裁剪弹窗（全屏 Modal + Cropper.js） ===== */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.crop-modal-inner {
  width: min(1100px, 94vw);
  height: auto;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
}
.crop-modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.crop-modal-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 头部居中提示：题号务必截入，占满标题与关闭按钮之间的空档 */
.crop-modal-hint {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: #fa8c16;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crop-modal-stage {
  flex: 0 0 auto;            /* 高度由 fitCropStage() 按图片比例写入 */
  min-height: 0;
  overflow: hidden;
  background: #fff;
}
.crop-modal-stage img { display: block; max-width: 100%; }
.crop-modal-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
/* 本次框选的待添加区：小缩略图一排 */
.crop-pending {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 58px;
}
.crop-pending-item { position: relative; }
.crop-pending-item img {
  display: block;
  max-height: 58px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.crop-pending-item button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--err);
  color: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.crop-modal-actions { display: flex; align-items: center; gap: 8px; }
/* 弹窗底部按钮统一修型：去掉 .btn-mini 的透明底/蓝字/auto 边距，
   前两个（清空本次 / 加入本框选）改灰底圆角按钮，主按钮保持蓝底白字 */
.crop-modal-actions .btn {
  margin-left: 0;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}
.crop-modal-actions .btn-ghost,
.crop-modal-actions .btn-ghost:not(:disabled):hover {
  background: #f0f2f5;
  color: var(--text-sub);
}
.crop-modal-actions .btn-ghost:not(:disabled):hover { background: #e5e7eb; color: var(--text); }
.crop-modal-actions .btn-primary,
.crop-modal-actions .btn-primary:not(:disabled):hover,
.crop-modal-actions .btn-primary:not(:disabled):active {
  background: var(--primary);
  color: #fff;          /* 点击/悬停时文字保持白色，避免蓝底蓝字 */
}
.crop-pending-count { margin-right: auto; font-size: 12px; color: var(--text-sub); }

/* 错题模式中：隐藏整卷预览的空态提示 */
body.quiz-mode #source-empty { display: none; }

/* ===== 手机：第三列编辑工具栏分两行（放在文件最后，避免被上面 PC 基础规则压掉） ===== */
@media (max-width: 768px) {
  /* 两行网格：第 1 行 科目 + 快捷（可横滚）；第 2 行 整页/真纸 靠左、开关+保存+打印 靠右 */
  .edit-toolbar {
    display: grid;
    /* 第一行：科目 → 整页/真纸 → 去灰底 + 保存 + 打印（靠右）
       第二行：编辑器按钮组，横向滚动，整行占满 */
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 6px;          /* 科目靠左，5 个按钮整组靠右 */
    row-gap: 8px;
    align-items: center;
    padding: 8px 14px;        /* 和上面 tab 条对齐：左右各 14，不再一边 12 一边 20 */
  }
  .edit-toolbar .subject-tag { grid-area: 1 / 1; order: 0; }
  .edit-toolbar .ptw-paper-view { grid-area: 1 / 2; order: 0; margin: 0; justify-self: end; }
  .edit-toolbar .edit-right-tools { grid-area: 1 / 3; order: 0; margin: 0; justify-self: end; gap: 6px; }
  .edit-toolbar .ios-text { font-size: 11px; white-space: nowrap; }
  .edit-toolbar .ptw-paper-view button { padding: 0 8px; }
  .edit-toolbar .edit-format-group {
    grid-area: 2 / 1 / 3 / 4; order: 0;
    width: 100%; min-width: 0; flex: 0 0 auto;
    flex-wrap: wrap; row-gap: 6px; overflow: visible; gap: 4px;
  }
  .edit-toolbar .edit-format-group button {
    min-width: 0; height: 28px; padding: 0 5px; font-size: 12.5px;
  }
  .edit-toolbar .edit-format-group .edit-toolbar-divider { margin: 0 1px; }
}


/* ============ v2.80：控制台工具栏 / 上传区（手机 + 桌面） ============ */
.upload-label-m { display: none; }

/* 桌面：工具栏按钮透明，只留选中蓝高亮 */
@media (min-width: 769px) {
  .mode-btn { background: transparent; color: #6b7280; }
  .mode-btn:hover { background: #f3f5f9; }
  .mode-btn.active { background: #eff6ff; color: #2f6bff; }
  .quiz-tab-action { background: transparent; }
  .quiz-tab-action:hover:not(:disabled) { background: #f3f5f9; }
  .tab-inline-btn { background: transparent; }
  .tab-inline-btn:hover:not(:disabled) { background: #f3f5f9; }
}

/* 手机：上传 + 清空合并成一块；工具栏胶囊化 */
@media (max-width: 768px) {
  .btn-upload {
    aspect-ratio: auto; width: 100%; height: auto;
    padding: 20px 12px; gap: 6px;
    border-radius: 12px; border-width: 1.5px;
    justify-content: center;
  }
  .btn-upload .upload-center { flex: none; gap: 6px; }
  .btn-upload .plus { font-size: 24px; }
  .btn-upload .upload-label { display: none; }
  .upload-label-m { display: inline; font-size: 14px; font-weight: 600; letter-spacing: .4px; }
  .btn-upload .thumbs-hint { display: none; }

  .btn-clear {
    align-self: stretch; margin-top: 8px; padding: 8px 0;
    background: transparent; color: #e5484d;
    border-radius: 8px; font-size: 12px;
  }
  .btn-clear:hover { background: rgba(229, 72, 77, .08); }

  .col-toolbar { height: auto; min-height: 0; padding: 2px 0 6px; background: transparent; border: 0; }
  .mode-switch { background: transparent; border: 0; padding: 0; gap: 6px; box-shadow: none; }
  .mode-btn {
    height: 28px; padding: 0 12px; border: 0; border-radius: 8px;
    background: #f1f4f9; color: #6b7280; font-size: 12px; font-weight: 500;
  }
  .mode-btn.active { background: #eff6ff; color: #3b82f6; box-shadow: none; }

  .img-tabs-bar {
    background: transparent; border-bottom: 0; padding: 4px 14px 10px;
    border-radius: 0; margin-bottom: 0;
  }
  .img-tab {
    height: 28px; padding: 0 11px; border-radius: 8px;
    background: #f1f4f9; color: #6b7280; font-size: 12px;
  }
  .img-tab.active { background: #eff6ff; color: #3b82f6; font-weight: 600; }
  .img-tab.active::after { display: none; }
  .img-tab-group { gap: 5px; }
  .tab-inline-btn { background: #f1f4f9; border-radius: 8px; height: 24px; padding: 0 8px; }
  .quiz-tab-action { background: #f1f4f9; border-radius: 8px; }
}

@media (max-width: 768px) {
  /* 上传 + 清空合并成纵向一块：全宽虚线框在上，红色小字在下 */
  .col-thumbs {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "mode" "thumbs" "upload" "clear";
    row-gap: 8px;
  }
  .btn-upload { grid-area: upload; width: 100%; }
  .btn-clear { grid-area: clear; justify-self: center; }
  .thumb-list { min-height: 72px; }
  .upload-label-m { white-space: nowrap; }
}

@media (max-width: 768px) {
  .ptw-paper-view button { background: #f1f4f9; border: 0; border-radius: 8px; color: #6b7280; }
  .ptw-paper-view button.is-on { background: #eff6ff; color: #3b82f6; border: 0; font-weight: 600; }
}
@media (min-width: 769px) {
  .ptw-paper-view button { background: transparent; border: 0; }
  .ptw-paper-view button.is-on { background: #eff6ff; border: 0; color: #2f6bff; }
}

/* 去灰底等编辑工具栏按钮：PC 透明 / 手机浅灰胶囊；开启态浅蓝高亮 */
@media (min-width: 769px) {
  .edit-toolbar button.quiz-tab-action { background: transparent; }
  .edit-toolbar button.quiz-tab-action:hover:not(:disabled) { background: #f3f5f9; }
  .edit-toolbar button.quiz-tab-action.is-toggle.is-on,
  .edit-toolbar button.quiz-tab-action.is-toggle.is-on:hover:not(:disabled) {
    background: #eff6ff; color: #2f6bff;
  }
}
@media (max-width: 768px) {
  .edit-toolbar button.quiz-tab-action { background: #f1f4f9; }
  .edit-toolbar button.quiz-tab-action.is-toggle.is-on,
  .edit-toolbar button.quiz-tab-action.is-toggle.is-on:hover:not(:disabled) {
    background: #eff6ff; color: #3b82f6;
  }
}

/* ============ v2.83：手机端结果卡加高 / 清空按钮收身 ============ */
@media (max-width: 768px) {
  /* 第三块（结果卡）撑满一屏：空态时编辑器也有整屏高度 */
  #workspace-page:not(.ptw-pin-result) .col-result { height: 100vh; min-height: 100vh; }
  #workspace-page:not(.ptw-pin-result) .col-result .result-card {
    flex: 1 1 auto; height: auto !important;
    min-height: calc(100vh - 68px);
  }
  /* 一键清空：去掉额外上边距与上下内边距，只靠网格 row-gap 控制间距 */
  .btn-clear { margin-top: 0; padding: 0; }
}

/* ===== v2.92：手机端图像 Tab 条左右边距与下方编辑工具栏对齐（14px），并压成单行 ===== */
@media (max-width: 768px) {
  .img-tabs-bar {
    padding: 4px 14px 10px !important;
    flex-wrap: nowrap !important;
    gap: 5px !important;
  }
  .img-tabs-bar .img-tabs { gap: 5px; }
  .img-tabs-bar .img-tab { font-size: 11.5px; padding: 0 2px; }
  .img-tabs-bar #btn-reset-img { padding: 0 6px; font-size: 11.5px; }
  .img-tabs-bar .quiz-tab-actions { gap: 4px; }
  .img-tabs-bar .quiz-tab-action.has-ic { width: 25px; min-width: 25px; height: 25px; padding: 0; }
  .img-tabs-bar { gap: 4px !important; }
}

/* ===== 接口全关：工作台毛玻璃遮罩（v2.95） ===== */
.api-offline {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(244, 246, 251, 0.62);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
}
.api-offline[hidden] { display: none; }
.api-offline-card {
  width: min(420px, 100%);
  padding: 30px 28px 26px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 50px -18px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.04) inset;
  text-align: center;
}
.api-offline-ic {
  width: 48px; height: 48px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: #f1f5fd; color: #3b6ef5;
}
.api-offline-ic svg { width: 24px; height: 24px; }
.api-offline-card h3 { margin: 0 0 8px; font-size: 17px; font-weight: 600; color: #1f2430; }
.api-offline-card p { margin: 0 0 18px; font-size: 13px; line-height: 1.75; color: #7c8398; }
.api-offline-actions { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.api-offline-actions .btn { min-width: 112px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 640px) {
  .api-offline-card { padding: 26px 20px 22px; border-radius: 16px; }
  .api-offline-card h3 { font-size: 16px; }
}

/* ===== 无题号时的兜底分节（v3.3） =====
   教辅"例题 /（1）（2）（3）"排版没有 1．2．3．题号，wrapQuestions 分不出题，
   于是按段落兜底成 section.q-flat：只为了让每题都能挂「选中」按钮，
   不参与悬挂题号布局，段距保持原样（略收一点点，避免比原卷松散）。 */
#result-paper { counter-reset: qflat; }
#result-paper section.question.q-flat {
  margin: 0 0 .2em;
  overflow: visible;
  position: relative;
  padding-left: var(--qnum-w, 22px);
}
/* 一段 q-flat = 一整道大题（导语+题干+小问+图都在里面），一题一个号 */
#result-paper section.question.q-flat { counter-increment: qflat; }
#result-paper section.question.q-flat::before {
  content: counter(qflat) "．";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--qnum-w, 22px);
  font-weight: 700;
  color: #1f2430;
  white-space: nowrap;
}
#result-paper section.question.q-flat p { margin-left: 0; }
