:root {
  --blue: #2e75b6;
  --dblue: #1f4e79;
  --gray: #7f7f7f;
  --line: #d7dee8;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #262626;
  /* 手机端界面用圆润一些的字体（iOS 有华文圆体/翩翩体；没有则自动回落到系统字体） */
  --font-ui: "Yuanti SC", "HanziPen SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  /* 打印页保持原来的字体，保证交上去的纸面整齐 */
  --font-print: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
}

.page, .page * { font-family: var(--font-print); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: linear-gradient(120deg, #1f4e79, #2e75b6);
  color: #fff;
  flex-wrap: wrap;
  /* 吸顶：滚到第 2/3 环节深处也能一键回首页 */
  position: sticky; top: 0; z-index: 120;
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: 1px; }
.topbar .sub { margin: 4px 0 0; font-size: 13px; opacity: .85; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.topbar-actions .btn { white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, .9);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .22);
}
.topbar-actions { display: flex; gap: 8px; }

.steps {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.steps button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--dblue);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}
.steps button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}

main { padding: 20px 24px 60px; max-width: 1080px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.panel h2 { margin: 4px 0 6px; font-size: 18px; color: var(--dblue); }
.hint { color: var(--gray); font-size: 13px; margin: 0 0 14px; }

.btn {
  border: 1px solid var(--blue);
  background: #fff;
  color: var(--blue);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--blue); color: #fff; font-weight: 600; }
.btn.ghost { border-color: var(--line); color: #445; }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.actions { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.count { color: var(--gray); font-size: 13px; }
.step-nav {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line);
}

.dropzone {
  display: block;
  border: 2px dashed #b9c6d8;
  border-radius: 12px;
  background: #fff;
  padding: 34px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--blue); background: #eef4fb; }
.dz-icon { font-size: 34px; }
.dz-small { color: var(--gray); font-size: 12.5px; margin-top: 6px; }

.file-list { list-style: none; margin: 14px 0 0; padding: 0; }
.file-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 6px; font-size: 13.5px;
}
.file-list .status { font-size: 12px; color: var(--gray); }
.file-list .status.err { color: #c0392b; }
.file-list .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.file-list .file-right .btn { min-height: 32px; padding: 4px 10px; }

.progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--dblue); }
.spinner {
  width: 18px; height: 18px; border: 3px solid #cfe0f0;
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.raw-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.raw-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--dblue); font-weight: 600;
}
.raw-head > div { display: flex; gap: 8px; }
#ocr-raw {
  width: 100%; min-height: 220px; border: 0; outline: none;
  padding: 12px; font-size: 14px; line-height: 1.7; resize: vertical;
  font-family: inherit;
}

.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.qnum {
  min-width: 52px; text-align: center; font-weight: 700; color: #fff;
  background: var(--blue); border-radius: 6px; padding: 4px 8px; font-size: 13px;
}
.card-head input.qnum-input {
  width: 64px; text-align: center; font-weight: 700; color: var(--dblue);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 13px;
}
.card-head .spacer { flex: 1; }
.card textarea {
  width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; font-size: 14px; line-height: 1.6; font-family: inherit; resize: vertical;
}
.card .tools { display: flex; gap: 6px; }
.card .tools button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 4px 8px; font-size: 12px; cursor: pointer; color: #445;
}
.card .tools button:hover { border-color: var(--blue); color: var(--blue); }
.card.wrong { border-color: var(--blue); box-shadow: 0 0 0 2px #e6f0fa; }

.items-mini { margin-top: 14px; }
.items-mini h3 { font-size: 14px; color: var(--dblue); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 6px 0;
  background: #eef4fb; border: 1px solid #cfe0f0; color: var(--dblue);
  border-radius: 999px; padding: 4px 10px; font-size: 12.5px;
}
.chip button { border: 0; background: none; color: #99a; cursor: pointer; font-size: 13px; }

.item-list { display: flex; flex-direction: column; gap: 12px; }
.item {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px;
}
.item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.item-hint { color: #7f7f7f; font-size: 13px; }
.item-head .qnum { background: var(--dblue); }
.item-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #445; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 14px;
  font-family: inherit;
}
.field textarea { min-height: 60px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 2px; }
.checks label { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; }

.tpl-controls {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px;
}
.tpl-controls label { font-size: 13.5px; color: #445; display: flex; align-items: center; gap: 8px; }
.tpl-controls select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 14px; }
.mapping { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; font-size: 13px; color: #445; }
.advanced-settings { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.advanced-settings summary { cursor: pointer; font-size: 13px; color: var(--dblue); font-weight: 600; }
.advanced-settings .mapping { margin-top: 10px; }
.mapping span { display: inline-flex; align-items: center; gap: 6px; }
.mapping select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 13px; }

.preview {
  margin-top: 16px; display: flex; flex-direction: column; gap: 18px; align-items: flex-start;
  overflow-x: auto; width: 100%;
}
.preview-summary {
  margin-top: 12px; font-size: 13px; color: var(--dblue);
  background: #eef4fb; border: 1px solid #cfe0f0; border-radius: 8px; padding: 8px 12px;
}
body.exporting .preview { gap: 0; zoom: 1 !important; }
body.exporting #preview { width: 210mm; }
body.exporting .page { box-shadow: none; page-break-after: auto; break-after: auto; margin: 0; }
.empty { color: var(--gray); padding: 40px; text-align: center; }

/* ============ A4 页面 ============ */
.page {
  width: 210mm; height: 297mm; background: #fff; padding: 9mm 10mm;
  box-shadow: 0 2px 14px rgba(20, 40, 80, .14);
  position: relative; overflow: hidden;
  page-break-after: always; break-after: page;
}
.page:last-child { page-break-after: auto; break-after: auto; }
.page-mark {
  position: absolute; top: 3mm; right: 5mm;
  font-size: 9px; color: #9aa7b8; letter-spacing: .3px;
  z-index: 2;
}

.tplA-title {
  text-align: center; color: #1a1a1a; font-size: 30px; letter-spacing: 10px;
  margin: 6px 0 14px; font-weight: 800;
}
.tplA { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tplA th, .tplA td {
  border: 1px solid #286df8; padding: 7px 9px; vertical-align: top;
  font-size: 12.5px; line-height: 1.55; word-break: break-word;
}
.tplA th {
  width: 15%; background: #f2f7ff; color: #1f4e79; font-weight: 700;
  text-align: center; white-space: nowrap;
}
.tplA td.write { height: 34px; }
.tplA td .blank { display: block; height: 30px; }
.tplA .checks { flex-wrap: wrap; gap: 2px 10px; }
.tplA .checks label { font-size: 12px; }
.page.fill-page { display: flex; flex-direction: column; }
.tplA { flex: 1; height: 100%; }
.tplA tr.r-stem td { height: 40mm; }
.tplA tr.r-analysis td { height: 30mm; }
.tplA tr.r-knowledge td { height: 22mm; }
.tplA tr.r-answer td { height: 55mm; }
.tplA tr.r-summary td { height: 32mm; }

.tplB-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 2px solid #2e75b6; padding-bottom: 8px; margin-bottom: 10px;
}
.tplB-head .t { color: #1f4e79; font-weight: 700; font-size: 15px; }
.tplB-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tplB-tags span {
  border: 1px solid #2e75b6; color: #2e75b6; border-radius: 999px;
  padding: 2px 10px; font-size: 11.5px;
}
.tplB-tags span.on { background: #2e75b6; color: #fff; }
.tplB-sec { margin-top: 10px; }
.tplB-label {
  display: inline-block; background: #2e75b6; color: #fff; font-size: 12px;
  border-radius: 4px; padding: 2px 8px; margin-bottom: 6px; font-weight: 700;
}
.tplB-box { border: 1px solid #cfd9e6; border-radius: 6px; padding: 8px; min-height: 44px; font-size: 12.5px; line-height: 1.6; }
.tplB-row { display: flex; gap: 18px; font-size: 12.5px; color: #445; margin-top: 8px; }
.tplB-row b { color: #1f4e79; }
.tplB-stem { font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.tplB .checks { margin-top: 4px; }
.tplB-sec.grow { flex: 1; display: flex; flex-direction: column; }
.tplB-sec.grow .tplB-box { flex: 1; }
.page.fill-page .tplB-stem { min-height: 34mm; }

.tplC { border-collapse: collapse; width: 100%; table-layout: fixed; flex: 1; height: 100%; }
.tplC td { border: 1px solid #c9d6e6; vertical-align: top; padding: 6px 8px; font-size: 12.5px; }
.tplC .pill {
  display: inline-block; background: #2e75b6; color: #fff; border-radius: 999px;
  padding: 2px 10px; font-size: 11.5px; font-weight: 700;
}
.tplC .step-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: #1f4e79; font-weight: 700; }
.tplC .writebox { min-height: 150px; white-space: pre-wrap; line-height: 1.7; }
.tplC .writebox.sm { min-height: 90px; }
.tplC .fold { text-align: center; color: #1f4e79; font-weight: 700; padding: 6px; }
.tplC .checkline { font-size: 11.5px; color: #7f7f7f; margin-top: 4px; }
.tplC .stem-text { white-space: pre-wrap; line-height: 1.7; }

/* ---- 模板 D：双栏错题本 ---- */
.d-page { padding: 6mm 7mm; }
.d-card {
  display: flex; border: 1px solid #222; background: #fff;
  height: 100%; min-height: 0; font-size: 10.5px; color: #111; overflow: hidden;
}
.grid .d-card { height: 100%; }
.grid.p2 .d-card { flex: 1; height: auto; }
.grid.p4 .d-card { width: calc(50% - 2mm); height: calc(50% - 2mm); }
.grid.p4.count1 .d-card { width: 100%; height: 100%; }
.grid.p4.count2 .d-card { width: 100%; height: calc(50% - 2mm); }
.grid.p4.count3 .d-card:last-child { width: 100%; }
.d-left {
  width: 31%; border-right: 1px solid #333; padding: 4mm 3.5mm;
  display: flex; flex-direction: column; min-height: 0;
}
.d-right { flex: 1; padding: 4mm 5mm; display: flex; flex-direction: column; min-height: 0; }
.d-row { display: flex; align-items: baseline; gap: 4px; border-bottom: 1px solid #ddd; padding: 1.2mm 0; }
.d-row .k { width: 15mm; flex-shrink: 0; color: #333; }
.d-row .v { flex: 1; }
.d-stars { color: #d48806; letter-spacing: 1px; font-size: 11px; }
.d-label { font-weight: 700; margin: 2mm 0 1mm; font-size: 10.5px; }
.d-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 1mm 3mm; font-size: 9.5px; }
.d-checks .box { font-size: 10px; }
.d-lines {
  flex: 0 0 auto; min-height: 12mm; white-space: pre-wrap; font-size: 10px; line-height: 1.7;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6.5'%3E%3Cpath d='M0 6.1H20' stroke='%23dedede' stroke-width='0.3'/%3E%3C/svg%3E");
  background-size: 100% 6.5mm;
  background-repeat: repeat-y;
}
.d-lines.grow { flex: 1; }
.d-head { display: flex; justify-content: space-between; gap: 4px; align-items: flex-start; border-bottom: 1px solid #333; padding-bottom: 1mm; margin-bottom: 2mm; }
.d-head .t { font-weight: 700; font-size: 12px; }
.d-qtypes { display: flex; flex-wrap: wrap; gap: 2mm; font-size: 9.5px; }
.d-qtypes .box { font-size: 10px; }
.d-stem { flex: 0 1 auto; font-size: 12px; line-height: 1.7; min-height: 16mm; overflow: hidden; }
.d-divider { border-top: 1px dashed #999; margin: 2mm 0; }
.d-answer { flex: 1; font-size: 12px; line-height: 1.9; min-height: 30mm; }
.d-answer-blank {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='7'%3E%3Cpath d='M0 6.6H20' stroke='%23dcdcdc' stroke-width='0.3'/%3E%3C/svg%3E");
  background-size: 100% 7mm;
  background-repeat: repeat-y;
}
.d-page-num { text-align: right; font-size: 9px; color: #666; margin-top: 1mm; }
.qimg-d { max-height: 45mm; }
.d-card-full .qimg-d { max-height: 130mm; }
.d-card-full .qimg-answer { max-height: 90mm; }
.d-card-full .d-left { width: 30%; font-size: 12px; padding: 6mm 5mm; }
.d-card-full .d-right { padding: 6mm 7mm; }
.d-card-full .d-stem { font-size: 13.5px; min-height: 16mm; }
.d-card-full .d-answer { font-size: 13.5px; min-height: 40mm; }
.d-card-full .d-label { font-size: 12px; }
.d-card-full .d-checks { font-size: 11px; }
.grid.p4 .d-card { font-size: 9px; }
.grid.p4 .d-stem, .grid.p4 .d-answer { font-size: 10px; }

/* ---- 多题一页：紧凑卡片 ---- */
.page.fill { display: flex; flex-direction: column; }
.grid { flex: 1; display: flex; gap: 4mm; min-height: 0; }
.grid.p2 { flex-direction: column; }
.grid.p2 .mcard { flex: 1; }
.grid.p4 { flex-wrap: wrap; align-content: stretch; }
.grid.p4 .mcard { width: calc(50% - 2mm); height: calc(50% - 2mm); }
.grid.p4.count1 { flex-direction: column; }
.grid.p4.count1 .mcard { width: 100%; height: 100%; }
.grid.p4.count2 { flex-direction: column; }
.grid.p4.count2 .mcard { width: 100%; height: calc(50% - 2mm); }
.grid.p4.count3 .mcard { height: calc(50% - 2mm); }
.grid.p4.count3 .mcard:last-child { width: 100%; }
.mcard {
  border: 1.5px solid #286df8; border-radius: 6px;
  padding: 3.5mm 4mm; display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.mc-head {
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid #dbe7f7; padding-bottom: 3px; margin-bottom: 4px;
}
.mc-num { font-weight: 700; color: #1f4e79; font-size: 13px; }
.mc-tag { background: #2e75b6; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 10.5px; }
.mc-date { margin-left: auto; color: #7f7f7f; font-size: 10.5px; }
.mc-stem { font-size: 12px; line-height: 1.55; white-space: pre-wrap; margin-bottom: 4px; }
.mc-line { font-size: 11.5px; line-height: 1.5; margin: 2px 0; }
.mc-line b { color: #1f4e79; }
.mc-write {
  font-size: 11.5px; line-height: 1.5; border-bottom: 1px dashed #b9c6d8;
  padding: 3px 0 6px; margin-top: 3px; flex: 1; min-height: 12mm;
}
.mc-write.blank { min-height: 20mm; }
.mc-step {
  margin: 5px 0 3px; font-size: 11.5px; color: #1f4e79; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.mcard .checks { gap: 1px 8px; }
.mcard .checks label { font-size: 10.5px; }
.mcard .pill { padding: 1px 7px; font-size: 10px; }

/* ---- 题目插图 ---- */
.qimg {
  display: block; max-width: 100%; margin: 4px 0;
  border: 1px solid #e3e9f2; border-radius: 4px; object-fit: contain;
}
.qimg-full { max-height: 60mm; }
.qimg-answer { max-height: 50mm; }
.qimg-compact { max-height: 30mm; }
.grid.p4 .qimg-compact { max-height: 18mm; }
.qimg-wrap { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; }
.qimg-wrap img { max-width: 240px; max-height: 140px; border: 1px solid #d7dee8; border-radius: 6px; }
.qimg-wrap button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 4px 8px; font-size: 12px; cursor: pointer; color: #445;
}
.img-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.img-edit .thumb { max-width: 180px; max-height: 110px; border: 1px solid #d7dee8; border-radius: 6px; }
.muted { color: #99a; font-size: 12.5px; }

/* ---- 双面打印：反面参考答案 ---- */
.switch-line { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: #445; margin-top: 10px; margin-right: 18px; }
.duplex-hint {
  margin-top: 8px; color: #8a6d3b; background: #fff8e8; border: 1px solid #f0d7b0;
  border-radius: 6px; padding: 6px 10px; font-size: 12.5px;
}
.answer-page .ans-head {
  display: flex; align-items: center; gap: 10px;
  border-bottom: 2px solid #e6a23c; padding-bottom: 8px; margin-bottom: 10px;
}
.ans-badge { background: #e6a23c; color: #fff; border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 700; }
.ans-title { font-size: 16px; font-weight: 700; color: #1f4e79; }
.ans-meta { margin-left: auto; color: #7f7f7f; font-size: 12px; }
.ans-question { font-size: 13px; line-height: 1.7; }
.answer-page .ans-question { min-height: 0; }
.ans-block { margin-top: 8px; }
.ans-space { flex: 1; min-height: 0; }
.ans-label { display: inline-block; background: #e6a23c; color: #fff; font-size: 12px; border-radius: 4px; padding: 2px 8px; margin-bottom: 6px; font-weight: 700; }
.ans-answer { border: 1px solid #f0d7b0; border-radius: 6px; padding: 10px; font-size: 14px; line-height: 1.8; background: #fff; min-height: 30mm; }
.ans-text { border: 1px solid #f0d7b0; border-radius: 6px; padding: 8px; font-size: 12.5px; line-height: 1.6; background: #fff; min-height: 14mm; }
.ans-row { display: flex; gap: 10px; margin-top: 10px; }
.ans-block.half { flex: 1; margin-top: 0; }
.answer-card { border-color: #e6a23c; background: #fffaf2; }
.answer-card .mc-tag { background: #e6a23c; }

/* ---- 题库 ---- */
.bank-box { width: min(780px, 94vw); }.bank-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bank-toolbar input[type="number"] { border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 13px; width: 76px; }
.bank-count { font-size: 13px; color: var(--gray); }
.bank-list { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.bank-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.bank-item:last-child { border-bottom: 0; }
.bank-item .t { flex: 1; line-height: 1.5; }
.bank-item .meta { color: #99a; font-size: 11.5px; margin-top: 2px; }
.bank-item img { max-width: 80px; max-height: 60px; border: 1px solid var(--line); border-radius: 4px; }
.bank-item button { border: 0; background: none; color: #c0392b; cursor: pointer; font-size: 12px; }
.match-badge { font-size: 11.5px; border-radius: 999px; padding: 2px 8px; background: #eef1f5; color: #7f8a99; border: 1px solid #dde4ee; white-space: nowrap; }
.match-badge.ok { background: #e8f7ee; color: #1e8e4e; border-color: #b9e4c9; }

/* ---- 直接打印 ---- */
.print-box { width: min(520px, 92vw); }
.print-form { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; color: #445; }
.print-form label { display: flex; align-items: center; gap: 8px; }
.print-form select, .print-form input[type="number"] { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 14px; }
.print-form select { flex: 1; min-width: 0; }

/* ---- 图片裁剪弹窗 ---- */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 20, 35, .62);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: 12px; padding: 14px;
  max-width: 94vw; max-height: 94vh;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.modal-head { display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--dblue); }
.modal-head .muted { font-weight: normal; }
.crop-stage {
  position: relative; overflow: hidden; background: #111;
  display: flex; justify-content: center; align-items: center;
  max-height: 70vh; border-radius: 8px;
}
.crop-stage img { max-width: 100%; max-height: 70vh; display: block; user-select: none; -webkit-user-select: none; }
.crop-rect {
  position: absolute; border: 2px solid #3b8ed0; background: rgba(59, 142, 208, .18);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .38);
  pointer-events: auto;
}
.rhandle {
  position: absolute; width: 34px; height: 34px; margin: 0;
  border-radius: 50%; background: rgba(255, 255, 255, .94);
  border: 2px solid #2e75b6; box-shadow: 0 1px 6px rgba(0, 0, 0, .45);
  touch-action: none;
}
/* 手柄放在框的内侧，框贴到屏幕边缘时也不会跑出去 */
.rhandle[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.rhandle[data-h="ne"] { right: 0; top: 0; cursor: nesw-resize; }
.rhandle[data-h="sw"] { left: 0; bottom: 0; cursor: nesw-resize; }
.rhandle[data-h="se"] { right: 0; bottom: 0; cursor: nwse-resize; }
.modal-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 相机取景 + 拍前框选 */
.camera-modal {
  position: fixed; inset: 0; z-index: 300; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px;
}
.camera-modal[hidden] { display: none; }
.cam-wrap { position: relative; background: #000; overflow: hidden; }
.cam-wrap video { display: block; width: 100%; height: 100%; object-fit: fill; background: #000; }
.cam-stage { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.cam-rect {
  position: absolute; border: 2px solid #2e9bff; border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5), 0 0 0 1px rgba(0, 0, 0, .25);
  pointer-events: auto;
}
.cam-tip { color: #e8eef6; font-size: 13px; text-align: center; margin-bottom: 10px; line-height: 1.5; }
.cam-bar { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.cam-bar .btn { min-width: 92px; }
.cam-bar .cam-shot { min-width: 132px; font-size: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1f4e79; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 99;
}
.app-version { text-align: center; color: #9aa7b8; font-size: 11px; padding: 14px 0 24px; }

/* 电脑端隐藏手机专用元素 */
#btn-more, .more-menu, #step-1 .step-nav { display: none; }
.step-ico { display: none; }

/* ---- 首页：欢迎卡 + 拍照入口 ---- */
.home-hero {
  background: linear-gradient(135deg, #e8f1fd 0%, #f7fbff 55%, #fff3e2 100%);
  border: 1px solid #dbe7f7;
  border-radius: 18px;
  padding: 16px 16px 14px;
  margin-bottom: 14px;
}
.home-hero-top { display: flex; align-items: center; gap: 12px; }
.home-logo {
  width: 54px; height: 54px; border-radius: 14px; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(46, 117, 182, .25);
}
.home-hero h2 {
  margin: 0; font-size: 19px; color: var(--dblue);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: .5px;
}
.home-badge {
  background: linear-gradient(135deg, #ffc94d, #ff9f43);
  color: #5a3300; font-size: 12px; font-weight: 800;
  font-family: "Wawati SC", "HanziPen SC", "Yuanti SC", sans-serif;
  padding: 3px 10px; border-radius: 999px; letter-spacing: 1.5px;
  box-shadow: 0 2px 6px rgba(255, 159, 67, .35);
}
.home-sub { margin: 5px 0 0; font-size: 12.5px; color: #5c7391; line-height: 1.5; }
.home-flow {
  list-style: none; display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; margin: 13px 0 0; padding: 0;
}
.home-flow li {
  background: rgba(255, 255, 255, .86); border: 1px solid #e4edf9;
  border-radius: 11px; padding: 7px 3px; text-align: center;
  font-size: 11px; color: #44586f;
}
.home-flow b { display: block; font-size: 13px; color: var(--blue); margin-bottom: 1px; }
.home-love {
  margin: 10px 0 0; text-align: right; color: #c8873d;
  font-size: 12px; letter-spacing: 1px;
}

.upload-actions { display: flex; gap: 10px; margin: 0 0 10px; }
.upload-actions .btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 210px; }
.upload-actions .btn .cta-ico { font-size: 18px; line-height: 1; }
.upload-actions .btn .cta-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.upload-actions .btn .cta-text small { font-weight: 400; font-size: 11px; opacity: .82; }
.cam-cta { box-shadow: 0 8px 20px rgba(46, 117, 182, .28); }
.home-hint { font-size: 12.5px; margin: -2px 0 12px; }

/* ================= 手机端独立排版 ================= */
@media screen and (max-width: 768px) {
  body { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 14px; gap: 8px; position: relative; flex-wrap: nowrap; }
  .topbar h1 { font-size: 18px; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .sub { display: none; }
  .logo { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; }
  .brand { min-width: 0; flex: 1 1 auto; overflow: hidden; gap: 8px; }
  .topbar .top-ver { display: none; }    /* 手机上版本号收进 ⋯ 菜单，给 🏠/⋯ 留位置（用更高优先级覆盖基础规则） */
  .subject-select { flex: 0 1 auto; max-width: 88px; }
  .topbar-actions .btn { display: none; }
  #btn-more, #btn-home {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1;
  }
  .more-menu {
    position: absolute; right: 14px; top: 56px; z-index: 80;
    display: flex; flex-direction: column; background: #fff;
    border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15); padding: 6px; min-width: 140px;
  }
  .more-menu button {
    border: 0; background: #fff; text-align: left; padding: 10px 14px;
    font-size: 15px; border-radius: 8px; color: #334;
  }
  .more-menu button:active { background: #eef4fb; }

  .steps {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 60;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--line);
    display: flex; justify-content: space-around; gap: 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
  }
  .steps button {
    flex: 1; border: 0; background: transparent; padding: 6px 2px;
    font-size: 11px; color: #7f8a99; border-radius: 10px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    min-height: 52px;
  }
  .steps button.active { background: #eef4fb; color: var(--dblue); font-weight: 700; }
  .step-ico { font-size: 18px; line-height: 1; display: block; }

  main { padding: 12px 14px 20px; max-width: none; }
  .panel h2 { font-size: 17px; margin-top: 0; }
  .hint { font-size: 13px; }
  .btn { min-height: 44px; font-size: 15px; }
  .upload-actions { flex-direction: column; gap: 10px; margin: 0 0 10px; }
  .upload-actions .btn { width: 100%; min-width: 0; min-height: 54px; justify-content: flex-start; padding-left: 18px; font-size: 16px; }
  .upload-actions .btn .cta-text { align-items: flex-start; }
  .home-hero { padding: 14px 14px 12px; border-radius: 16px; }
  .home-hero h2 { font-size: 17px; }
  .home-logo { width: 48px; height: 48px; border-radius: 12px; }
  .home-sub { font-size: 12px; }
  .home-flow { gap: 5px; margin-top: 11px; }
  .home-flow li { font-size: 10.5px; padding: 6px 2px; }
  .dropzone { display: none; }
  .actions { gap: 8px; }
  .actions .btn { min-height: 40px; }
  #step-1 .actions #btn-ocr { display: inline-flex; }
  .card-head { flex-wrap: wrap; gap: 6px; }
  .item-hint { display: none; }
  .qnum { white-space: nowrap; min-width: 64px; }
  .card textarea, .field input, .field select, .field textarea { font-size: 16px; }
  .item-grid { grid-template-columns: 1fr; }

  .step-nav {
    position: fixed; left: 0; right: 0;
    bottom: calc(68px + env(safe-area-inset-bottom));
    z-index: 55; margin: 0; padding: 8px 14px;
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(8px);
    display: flex; gap: 8px;
  }
  .step-nav .btn { flex: 1; }
  .preview { display: none; }
  .preview.show-mobile { display: flex; }
  .app-version { padding-bottom: 150px; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-box { width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 16px 16px 0 0; }
  .tpl-controls { padding: 10px; }
  .switch-line { font-size: 14px; }
  .qimg-full { max-height: 48mm; }
  #step-5 .actions #btn-download-pdf,
  #step-5 .actions #btn-direct-print { display: none; }
}

/* ============ 打印 ============ */
@page { size: A4 portrait; margin: 0; }
@media print {
  /* 清零一切外层偏移：body 的内联 padding-top（AI 横幅 38px）不清的话，
     第一页被下顶，偏移逐页累积，导致每张纸都溢出到第二张（用户实测） */
  html, body { margin: 0 !important; padding: 0 !important; padding-top: 0 !important; background: #fff; }
  .topbar, .steps, .panel, .toast, .actions, .tpl-controls { display: none !important; }
  .step-nav, .app-version, #preview-summary, .sticky-act { display: none !important; }
  body.sticky-open { padding-bottom: 0 !important; }
  main { padding: 0 !important; max-width: none; margin: 0 !important; }
  #step-5 { display: block !important; padding: 0 !important; margin: 0 !important; }
  #step-5 h2, #step-5 .hint { display: none !important; }
  .preview { margin: 0 !important; padding: 0 !important; gap: 0 !important; display: block; zoom: 1 !important; }
  /* 关键：不同浏览器/打印机的「可打印区域」不一样——
     iPhone Safari 会忽略 @page margin:0，按打印机默认边距（约 10~12.7mm）排版，
     可打印区只有 ~190×271mm。写死 210×295mm 会每页都溢出成两张纸。
     这里自适应：宽不超过 190mm、高不超过 270mm（A4 去掉最大边距后仍能放下），
     Chrome 桌面端 @page margin:0 时也安全，绝不溢出第二张。 */
  .page {
    width: 190mm; height: 260mm;
    margin: 0 auto !important;
    box-shadow: none; border-radius: 0;
    page-break-after: always; break-after: page; break-inside: avoid;
    overflow: hidden;
  }
  .page:last-child { page-break-after: auto; break-after: auto; }
}

/* ---- 第 3 步：一题一个框，点＋加入错题本 ---- */
.wrong-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px; margin: 12px 0 6px;
}
.pick-card {
  position: relative; background: #fff; border: 2px solid var(--line);
  border-radius: 12px; overflow: hidden; cursor: pointer; text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.pick-card:active { transform: scale(.997); }
.pick-card.on { border-color: var(--blue); box-shadow: 0 6px 18px rgba(46, 117, 182, .18); }
.pick-thumb { background: #fafbfd; max-height: 42vh; overflow: hidden; }
.pick-thumb img { display: block; width: 100%; height: auto; }
.pick-text { padding: 12px; font-size: 13px; color: #334; line-height: 1.6; max-height: 160px; overflow: hidden; }
.pick-num {
  position: absolute; left: 8px; top: 8px; z-index: 2;
  background: rgba(31, 78, 121, .86); color: #fff; font-size: 11.5px;
  padding: 2px 8px; border-radius: 999px;
}
.pick-edit {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  background: rgba(255, 255, 255, .94); border: 1px solid #c9d6e6; color: var(--blue);
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.pick-edit:active { background: #eaf2fc; }
.pick-plus {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(46, 117, 182, .92); color: #fff; font-size: 24px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25); pointer-events: none;
}
.pick-card.on .pick-plus { background: #27ae60; }

/* 相机：自动框开关、快门闪光、拍后预览 */
.cam-auto {
  position: absolute; left: 8px; top: 8px; z-index: 3;
  background: rgba(0, 0, 0, .55); color: #dfe9f5;
  border: 1px solid rgba(255, 255, 255, .55);
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.cam-auto.on { background: rgba(39, 174, 96, .92); color: #fff; border-color: transparent; }
.cam-flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; transition: opacity .09s;
}
.cam-flash.on { opacity: .85; }

.cam-stack {
  position: absolute; right: 12px; bottom: 92px; z-index: 5;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.cam-stack-pile { position: relative; width: 78px; height: 78px; }
.cam-stack-pile img {
  position: absolute; width: 68px; height: 68px; object-fit: cover;
  border-radius: 10px; border: 2px solid #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35); background: #fff;
}
.cam-stack-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, .58); border-radius: 999px; padding: 4px 6px 4px 12px;
}
.cam-stack-count { color: #eaf1f9; font-size: 12px; white-space: nowrap; }
.cam-stack-row .btn { min-height: 32px; padding: 0 12px; font-size: 13px; }

/* 拍完立刻给一次“框准这道题”的机会 */
.shot-crop {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(8, 12, 18, .95);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 12px;
}
.shot-crop[hidden] { display: none; }
.shot-crop-head { color: #dfe8f3; font-size: 13px; text-align: center; line-height: 1.5; }
.shot-crop-stage {
  position: relative; overflow: hidden; display: flex; justify-content: center;
  max-width: 100%; max-height: 66vh;
}
.shot-crop-stage img { display: block; max-width: 100%; max-height: 66vh; }
.shot-crop-actions { display: flex; gap: 10px; }
.shot-crop-actions .btn { min-width: 110px; }

/* 拍后“擦答案”手动画框 */
.shot-crop-tools { display: flex; gap: 10px; }
.shot-crop-tools .btn.on { background: #ff7043; color: #fff; border-color: #ff7043; }
.erase-layer { position: absolute; pointer-events: none; z-index: 3; }
.erase-marker {
  position: absolute; background: rgba(255, 255, 255, .9);
  border: 1px dashed #ff8a65; border-radius: 3px;
}
.erase-ghost {
  position: absolute; border: 2px dashed #ff7043;
  background: rgba(255, 112, 67, .2); pointer-events: none; z-index: 4;
}

/* 取景框四角的手柄小一半，别挡画面 */
.cam-rect .rhandle { width: 17px; height: 17px; }

/* 顶部显示版本号，方便确认手机是不是最新版 */
.top-ver {
  display: inline-block; margin-left: 8px; padding: 1px 6px;
  font-size: 10px; font-weight: 400; letter-spacing: 0;
  color: #cfe0f2; background: rgba(255, 255, 255, .16);
  border-radius: 999px; vertical-align: middle;
}

/* 点擦：点一下答案就擦掉 */
.tap-marker {
  position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid #ff5252; border-radius: 50%;
  background: rgba(255, 82, 82, .18); pointer-events: none;
}
#shot-tap.on { background: #ff5252; color: #fff; border-color: #ff5252; }

/* AI 擦除进度条（期间禁止进入导出） */
.ai-banner {
  position: fixed; left: 0; right: 0; top: 0; z-index: 60;
  padding: 10px 14px; font-size: 13px; text-align: center;
  background: #fff7e6; color: #8a5b00; border-bottom: 1px solid #ffe0a3;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.ai-banner.done { background: #e9f8ef; color: #1a7f4b; border-bottom-color: #b7e6cb; }
.nav-locked { opacity: .45; pointer-events: none; }

/* 拍后四点透视框 */
.shot-quad-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
#shot-quad-poly { fill: rgba(46,155,255,.10); stroke: #2e9bff; stroke-width: 2; }
.crop-rect.persp { border: 0; box-shadow: none; background: transparent; }

/* 科目切换（当前只启用数学） */
.subject-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.subject-label { font-size: 12px; color: #cfe0f2; opacity: .85; }
.subject-select {
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.14);
  color: #fff; outline: none;
}
.subject-select option { color: #222; }

/* 顶部栏精简：一行显示，去掉重复品牌区 */
.topbar { padding: 8px 12px; align-items: center; }
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.topbar .logo { width: 26px; height: 26px; border-radius: 6px; margin: 0; }
.topbar h1 { font-size: 16px; margin: 0; display: flex; align-items: center; gap: 6px; line-height: 1.2; }
.topbar .sub, .topbar .subject-label, .topbar .subject-row { display: none; }
.topbar .subject-select { font-size: 12px; padding: 3px 8px; background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; }
.topbar .subject-select option { color: #222; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.hero-line { margin: 4px 2px 12px; font-size: 12px; color: #667; }

/* ============ 视觉主题 v2（只改外观，不动功能/打印样式） ============ */
:root {
  --blue: #4361ee;
  --dblue: #1f2a44;
  --gray: #6b7385;
  --line: #e8ecf3;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --radius: 14px;
  --shadow-1: 0 1px 2px rgba(17, 24, 39, .04), 0 6px 18px rgba(17, 24, 39, .05);
}

body { background: #f5f7fb; color: var(--text); -webkit-font-smoothing: antialiased; }

/* 顶栏：白底 + 毛玻璃，一行 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  color: var(--text);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  gap: 10px;
}
.topbar .logo { width: 28px; height: 28px; border-radius: 8px; border: 0; box-shadow: none; }
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: .2px; color: var(--dblue); }
.top-ver {
  font-size: 10px; font-weight: 500; color: #7c8698;
  background: #f0f2f7; border-radius: 999px; padding: 1px 7px;
}
.subject-select {
  background: #f3f5fa; color: #3d4761; border: 1px solid #e6e9f2;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.topbar-actions .btn.icon {
  width: 34px; height: 34px; border-radius: 10px; font-size: 18px; line-height: 1;
  background: #f3f5fa; border: 1px solid #e6e9f2; color: #45506b;
}

/* 步骤条：分段控件 */
.steps {
  top: 53px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 6px;
}
.steps button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: #f2f4f9; color: #5a6274;
  padding: 9px 10px; border-radius: 11px; font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s, box-shadow .15s;
}
.steps button.active {
  background: #fff; color: var(--blue); font-weight: 700;
  box-shadow: 0 1px 2px rgba(17,24,39,.06), 0 4px 12px rgba(67,97,238,.12);
  border: 1px solid #e3e9ff;
}
.step-ico { font-size: 15px; }

/* 内容区与卡片 */
main { padding: 16px 14px 80px; }
.panel h2 { font-size: 16px; font-weight: 700; color: var(--dblue); margin: 2px 0 8px; }
.panel > .hint, .hero-line { color: #7c8698; font-size: 12.5px; }
.card, .item, .pick-card, .dropzone, .home-flow, .tpl-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

/* 按钮 */
.btn {
  border-radius: 12px; border: 1px solid #e3e7f0; background: #fff; color: #333c52;
  min-height: 40px; padding: 9px 14px; font-size: 14px; font-weight: 500;
  transition: transform .06s ease, box-shadow .15s, background .15s;
}
.btn:active { transform: scale(.985); }
.btn.primary {
  background: linear-gradient(135deg, #4361ee, #5b7cfa);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px rgba(67,97,238,.25);
}
.btn.ghost { background: #f7f9fc; border-color: #e6eaf2; color: #3d4761; }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 12.5px; border-radius: 10px; }

/* 大按钮 */
.upload-actions { display: grid; gap: 10px; margin: 14px 0 6px; }
.btn.big {
  min-height: 62px; border-radius: 16px; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; text-align: left;
}
.btn.big.cam-cta {
  background: linear-gradient(135deg, #4361ee, #7b5bf7);
  color: #fff; border: 0; box-shadow: 0 10px 24px rgba(67,97,238,.28);
}
.btn.big .cta-ico { font-size: 22px; }
.btn.big .cta-text { display: flex; flex-direction: column; font-size: 16px; font-weight: 600; }
.btn.big .cta-text small { font-size: 12px; font-weight: 400; opacity: .85; margin-top: 2px; }

/* 拖拽区 */
.dropzone { border-style: dashed; border-color: #dfe5f0; background: #fbfcfe; }
.dz-icon { font-size: 22px; }

/* 表单控件 */
input[type=text], input[type=date], select, textarea, .qnum-input, .subject-select {
  border-radius: 10px; border: 1px solid #e3e7f0; background: #fff; color: var(--text);
  padding: 9px 11px; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #b9c6ff; box-shadow: 0 0 0 3px rgba(67,97,238,.12); }

/* 列表卡片 */
.item { padding: 12px 12px 14px; margin-bottom: 12px; }
.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.qnum { font-weight: 700; color: var(--dblue); }
.item-hint { font-size: 11.5px; color: #98a1b3; }
.chip { background: #f2f4f9; border: 1px solid #e6e9f2; color: #4a5468; border-radius: 999px; }

/* 底部导航（若有） */
.bottom-nav, nav.bottom { background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }

/* toast */
#toast {
  background: rgba(31, 42, 68, .92); color: #fff; border-radius: 12px;
  padding: 10px 14px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

/* 更多菜单 */
.more-menu {
  border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(17,24,39,.14);
  overflow: hidden; background: #fff;
}
.more-menu button { padding: 12px 14px; font-size: 14px; background: #fff; border: 0; text-align: left; }
.more-menu button + button { border-top: 1px solid #f1f3f8; }

/* 预览页保持纸面质感 */
#preview .page { box-shadow: 0 6px 24px rgba(17,24,39,.10); border-radius: 4px; }

/* 手柄修正：四角居中、置顶，避免被覆盖层压住 */
.rhandle { z-index: 12; }
.crop-rect .rhandle { transform: translate(-50%, -50%); right: auto; bottom: auto; }
.crop-rect .rhandle[data-h="nw"] { transform: translate(-50%, -50%); }
.crop-rect .rhandle[data-h="ne"] { transform: translate(-50%, -50%); }
.crop-rect .rhandle[data-h="sw"] { transform: translate(-50%, -50%); }
.crop-rect .rhandle[data-h="se"] { transform: translate(-50%, -50%); }

/* 手机端：底部三个入口保持“底部导航条”，不要被上面的主题覆盖成竖条 */
@media screen and (max-width: 768px) {
  .steps {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0; right: 0;
    display: flex; flex-direction: row; justify-content: space-around;
    gap: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 0 -4px 16px rgba(17,24,39,.06);
    z-index: 40;
  }
  .steps button {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 6px 2px; min-height: 52px;
    border: 0; background: transparent; box-shadow: none;
    font-size: 11px; color: #7f8a99; border-radius: 10px;
  }
  .steps button.active { background: #eef2ff; color: var(--blue); font-weight: 700; box-shadow: none; border: 0; }
  .step-ico { font-size: 18px; line-height: 1; display: block; }
  main { padding-bottom: 88px; }
}

/* 底部导航：图标与文字同一行（横排，不竖着堆） */
@media screen and (max-width: 768px) {
  .steps button {
    flex-direction: row !important;
    gap: 6px;
    font-size: 13px;
    min-height: 48px;
  }
  .step-ico { font-size: 16px; }
  /* 拍后四角手柄：手机上加大一点，白底蓝边更醒目 */
  .crop-rect .rhandle {
    width: 26px !important; height: 26px !important;
    background: #fff; border: 3px solid #4361ee;
    box-shadow: 0 2px 8px rgba(0,0,0,.28);
  }
}

/* 拍后裁剪一打开，就强制隐藏相机取景框的四角，永不再出现两层圆点 */
#camera-modal:has(#shot-crop:not([hidden])) #cam-rect {
  display: none !important;
}
#camera-modal:has(#shot-crop:not([hidden])) .cam-auto {
  display: none !important;
}

/* 首页欢迎卡：身份 + 五步流程 + 妈妈寄语 */
.hero-card {
  position: relative;
  margin: 6px 0 14px;
  padding: 16px 16px 14px;
  border-radius: 18px;
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(255,255,255,.55), rgba(255,255,255,0) 55%),
    linear-gradient(135deg, #eef2ff, #f7f0ff 60%, #eaf6ff);
  border: 1px solid #e3e8f8;
  box-shadow: 0 10px 30px rgba(67, 97, 238, .10);
}
.hero-top { display: flex; align-items: center; gap: 12px; }
.hero-logo {
  width: 46px; height: 46px; border-radius: 12px;
  box-shadow: 0 6px 16px rgba(67,97,238,.22);
  flex-shrink: 0;
}
.hero-title { font-size: 20px; font-weight: 800; color: #1f2a44; display: flex; align-items: center; gap: 8px; }
.hero-badge {
  font-size: 10.5px; font-weight: 600; color: #4a5bd6;
  background: #fff; border: 1px solid #dfe4ff; border-radius: 999px;
  padding: 2px 8px; letter-spacing: .2px;
}
.hero-sub { font-size: 12.5px; color: #5c6580; margin-top: 4px; line-height: 1.5; }
.hero-flow {
  list-style: none; padding: 0; margin: 12px 0 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.hero-flow li {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: #3d4761;
  background: rgba(255,255,255,.75);
  border: 1px solid #e6ebfa; border-radius: 999px;
  padding: 4px 9px;
}
.hero-flow b {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: #4361ee; color: #fff; font-size: 10px; font-weight: 700;
}
.hero-love {
  margin-top: 10px; font-size: 11.5px; color: #8a6a8f;
  display: flex; align-items: center; gap: 4px;
}

/* 首页再精简：欢迎卡只留身份+流程，不再重复 logo/标题 */
.hero-card { padding: 12px 14px 10px; }
.hero-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-sub { font-size: 12.5px; color: #5c6580; }
.hero-flow { margin-top: 9px; gap: 5px; }
.hero-flow li { padding: 3px 8px; font-size: 11px; }
.hero-love { margin-top: 8px; }
.hero-title, .hero-logo, .hero-top { display: none !important; }

/* 科目下拉：显示文字，别只剩箭头 */
.topbar .subject-select {
  min-width: 74px; text-align: center; text-align-last: center;
  -webkit-appearance: none; appearance: none;
  background-image: none; color: #3d4761;
  padding-right: 10px;
}
.topbar .subject-select::-ms-expand { display: none; }

/* 页底版本号已移除，避免与顶部重复 */
.app-version { display: none !important; }
.more-menu .menu-ver { color: #98a1b3; font-size: 12px; }
.more-menu .menu-ver[disabled] { opacity: 1; }

/* 回退透视：拍后裁剪只用矩形框，四角手柄回 CSS 定位，整体可拖动 */
#shot-quad-svg { display: none !important; }

/* 四角手柄：放回框内四角（不居中、不跑到框外），保证点得到 */
.crop-rect .rhandle {
  transform: none !important;
  width: 28px !important; height: 28px !important;
  background: #fff !important;
  border: 3px solid #4361ee !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  z-index: 14;
}
.crop-rect .rhandle[data-h="nw"] { left: 0 !important; top: 0 !important; right: auto !important; bottom: auto !important; }
.crop-rect .rhandle[data-h="ne"] { right: 0 !important; top: 0 !important; left: auto !important; bottom: auto !important; }
.crop-rect .rhandle[data-h="sw"] { left: 0 !important; bottom: 0 !important; right: auto !important; top: auto !important; }
.crop-rect .rhandle[data-h="se"] { right: 0 !important; bottom: 0 !important; left: auto !important; top: auto !important; }

/* 教材模板库弹层 */
.tpl-lib {
  position: fixed; inset: 0; z-index: 80; background: rgba(17,24,39,.5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.tpl-lib-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px;
  max-height: 70vh; overflow: auto;
}
.tpl-cell { margin: 0; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.tpl-cell img { width: 100%; display: block; }
.tpl-cell figcaption { font-size: 11px; color: #5c6580; padding: 4px 6px; text-align: center; }
.tpl-lib > * { max-width: 900px; width: 100%; }

.tpl-lib > .tpl-lib-head, .tpl-lib > .tpl-grid { background: #fff; }
.tpl-lib .tpl-grid { background: #fff; border-radius: 0 0 12px 12px; padding: 10px; }
.tpl-lib .tpl-lib-head { background: #fff; border-radius: 12px 12px 0 0; padding: 10px 12px 4px; }

/* ===== 手机端装修 v3 ===== */
@media screen and (max-width: 768px) {
  body { font-size: 15px; }

  /* 顶栏 */
  .topbar {
    padding: 8px 12px; min-height: 48px;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid #eef1f6;
  }
  .topbar .logo { width: 24px; height: 24px; border-radius: 7px; }
  .topbar h1 { font-size: 16px; font-weight: 700; gap: 6px; }
  .top-ver { font-size: 9.5px; padding: 1px 6px; background: #f2f4f9; color: #7c8698; }
  .topbar .subject-select {
    font-size: 11.5px; padding: 3px 8px; min-width: 58px;
    background: #f3f5fa; border: 1px solid #e6e9f2; color: #47506a;
  }
  .topbar-actions .btn.icon { width: 32px; height: 32px; border-radius: 9px; }

  /* 首页欢迎卡 */
  .hero-card {
    margin: 10px 0 12px; padding: 14px 14px 12px; border-radius: 16px;
    background: linear-gradient(135deg,#eef2ff 0%,#f6f0ff 55%,#eaf7ff 100%);
    border: 1px solid #e6eaf8;
    box-shadow: 0 8px 22px rgba(67,97,238,.08);
  }
  .hero-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .hero-badge {
    font-size: 10px; padding: 3px 8px; border-radius: 999px;
    background: #fff; color: #4a5bd6; border: 1px solid #dfe4ff; font-weight: 600;
  }
  .hero-sub { font-size: 12px; color: #5c6580; }
  .hero-flow {
    display: flex; gap: 6px; margin: 11px -2px 0; padding: 0 2px 2px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .hero-flow::-webkit-scrollbar { display: none; }
  .hero-flow li {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; padding: 5px 9px; border-radius: 999px;
    background: rgba(255,255,255,.85); border: 1px solid #e7ecfb; color: #3d4761;
  }
  .hero-flow b {
    width: 15px; height: 15px; font-size: 9.5px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; background: #4361ee; color: #fff;
  }
  .hero-love { margin-top: 9px; font-size: 11px; color: #8d6f92; }

  /* 大按钮 */
  .upload-actions { display: grid; gap: 10px; margin: 0 0 12px; }
  .btn.big { min-height: 58px; border-radius: 16px; padding: 12px 16px; gap: 12px; }
  .btn.big.cam-cta {
    background: linear-gradient(135deg,#4361ee,#7b5bf7);
    box-shadow: 0 10px 22px rgba(67,97,238,.26);
  }
  .btn.big .cta-text { font-size: 16.5px; font-weight: 700; }
  .btn.big .cta-text small { font-size: 11.5px; font-weight: 400; opacity: .9; margin-top: 1px; }
  .btn.big .cta-ico { font-size: 22px; }
  .upload-actions label.btn.big {
    background: #fff; border: 1px solid #e8ecf5; color: #2f3a52;
    box-shadow: 0 2px 10px rgba(17,24,39,.04);
  }

  /* 卡片与表单 */
  .card, .item, .pick-card, .dropzone {
    border-radius: 16px; border: 1px solid #eef1f6;
    box-shadow: 0 2px 10px rgba(17,24,39,.04);
  }
  .item { padding: 12px; margin-bottom: 12px; }
  .panel h2 { font-size: 16.5px; margin: 6px 0 6px; }
  .hint { font-size: 12.5px; line-height: 1.6; }
  input[type=text], input[type=date], select, textarea { font-size: 15px; padding: 10px 12px; border-radius: 11px; }
  .btn { min-height: 44px; border-radius: 12px; font-size: 15px; }
  .btn.small { min-height: 34px; font-size: 12.5px; border-radius: 9px; }

  /* 底部导航 */
  .steps {
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.97);
    border-top: 1px solid #eef1f6;
    box-shadow: 0 -6px 20px rgba(17,24,39,.06);
  }
  .steps button {
    flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center;
    gap: 6px; font-size: 13px; min-height: 44px; border-radius: 12px;
    color: #7d8798;
  }
  .steps button.active { background: #eef2ff; color: #3b5bf0; font-weight: 700; }
  .step-ico { font-size: 17px; }

  main { padding: 12px 14px 92px; }
}

/* ===== 首页头图 v4：主题 / 口号 / 数据 / 流程 ===== */
.hero-card {
  position: relative; overflow: hidden;
  margin: 10px 0 14px; padding: 18px 16px 14px; border-radius: 20px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255,255,255,.28), rgba(255,255,255,0) 60%),
    radial-gradient(90% 80% at 0% 100%, rgba(255,255,255,.20), rgba(255,255,255,0) 55%),
    linear-gradient(135deg, #4361ee 0%, #5b6ff5 45%, #7b5bf7 100%);
  box-shadow: 0 14px 34px rgba(67,97,238,.28);
  color: #fff;
}
.hero-card::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px;
  border-radius: 50%; background: rgba(255,255,255,.10);
}
.hero-topline { display: flex; align-items: center; gap: 8px; position: relative; z-index: 1; }
.hero-badge {
  font-size: 10px; font-weight: 600; letter-spacing: .2px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.38); color: #fff;
}
.hero-tag { font-size: 10px; color: rgba(255,255,255,.85); }
.hero-slogan {
  position: relative; z-index: 1;
  margin: 10px 0 6px; font-size: 24px; line-height: 1.25; font-weight: 800; letter-spacing: .5px;
  color: #fff;
}
.hero-desc { position: relative; z-index: 1; margin: 0; font-size: 12.5px; color: rgba(255,255,255,.88); }
.hero-stats {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 8px;
  margin-top: 10px; font-size: 11.5px; color: rgba(255,255,255,.9);
}
.hero-stats b { font-size: 15px; font-weight: 800; color: #fff; }
.hero-stats .dot { width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,.6); }
.hero-flow {
  position: relative; z-index: 1; display: flex; gap: 6px; margin: 12px -2px 0; padding: 0 2px 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.hero-flow::-webkit-scrollbar { display: none; }
.hero-flow li {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 5px 9px; border-radius: 999px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.26); color: #fff;
}
.hero-flow b {
  width: 15px; height: 15px; font-size: 9.5px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: #4361ee; font-weight: 800;
}
.hero-love {
  position: relative; z-index: 1; margin-top: 10px; font-size: 11px; color: rgba(255,255,255,.78);
}

/* 相机：书本四边形识别框 */
.cam-quad-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }
#cam-quad-poly {
  fill: rgba(46,155,255,.08);
  stroke: #2e9bff; stroke-width: 3; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(46,155,255,.45));
}

/* 第 4 步：干净页状态条 */
.items-status {
  font-size: 12.5px; color: #3d4761;
  background: #eef7f1; border: 1px solid #cfe9d8; border-radius: 12px;
  padding: 8px 12px; margin: 0 0 10px;
}
.items-status b { color: #177a45; }
.steps button small { font-size: 9.5px; font-weight: 400; opacity: .75; }

/* 整页模板版式：图片占满版面，尽量大且不裁切 */
.tpl-page { padding: 6mm 8mm; display: flex; flex-direction: column; }
.tpl-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #444; margin-bottom: 3mm; }
.tpl-num { font-weight: 700; color: #222; }
.tpl-meta { color: #666; }
.tpl-tag { margin-left: auto; font-size: 10px; color: #888; }
.tpl-img-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tpl-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.tpl-answer { margin-top: 3mm; font-size: 11px; line-height: 1.6; max-height: 40mm; overflow: hidden; }

/* 正反面并排预览 */
.pair-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.pair-cell { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fafbfe; }
.pair-cell img { width: 100%; height: 150px; object-fit: contain; display: block; background: #fff; }
.pair-cell figcaption { font-size: 10.5px; color: #5c6580; text-align: center; padding: 4px 2px; }

/* 反面整页原图：占满版面，等比不裁切 */
.ans-full { display: flex; flex-direction: column; padding: 6mm 8mm; }
.ans-photo { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ans-photo img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.ans-full .ans-foot { margin-top: 2mm; font-size: 11px; line-height: 1.5; color: #333; }

/* ================= 处理进度（全屏） ================= */
body.job-open { overflow: hidden; }
.job {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 24px calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background: rgba(15, 23, 42, .48);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: jobFade .18s ease both;
}
.job[hidden] { display: none; }
@keyframes jobFade { from { opacity: 0 } to { opacity: 1 } }
.job-card {
  width: min(92vw, 400px); background: #fff; border-radius: 18px;
  padding: 20px 20px 18px; box-shadow: 0 24px 60px rgba(15,23,42,.28);
  animation: jobPop .22s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes jobPop { from { transform: translateY(10px) scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }
.job-title { font-size: 16px; font-weight: 700; color: #16233b; margin-bottom: 14px; }
.job-stages { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 9px; }
.job-stages li { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #98a2b3; transition: color .2s; }
.job-stages .js-dot {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 16px;
  border: 2px solid #d5dbe6; background: #fff; position: relative; transition: all .2s;
}
.job-stages li.active { color: #16233b; font-weight: 600; }
.job-stages li.active .js-dot { border-color: #2f6bff; background: #eaf0ff; }
.job-stages li.active .js-dot::after {
  content: ''; position: absolute; inset: 3px; border-radius: 50%;
  background: #2f6bff; animation: jobPulse 1s ease-in-out infinite;
}
.job-stages li.done { color: #1a9c5b; }
.job-stages li.done .js-dot { border-color: #1a9c5b; background: #1a9c5b; }
.job-stages li.done .js-dot::after {
  content: '✓'; position: absolute; inset: 0; color: #fff; font-size: 11px;
  line-height: 12px; text-align: center; font-weight: 700;
}
@keyframes jobPulse { 0%,100% { transform: scale(.7); opacity: .9 } 50% { transform: scale(1); opacity: 1 } }
.job-bar { height: 8px; border-radius: 99px; background: #eef1f6; overflow: hidden; }
.job-bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #2f6bff, #5b8bff);
  border-radius: 99px; transition: width .35s ease;
}
.job-meta { display: flex; justify-content: space-between; font-size: 12px; color: #6b7892; margin-top: 8px; }
.job-hint { margin-top: 10px; font-size: 12px; color: #6b7892; line-height: 1.5; }
.job.fail .job-card { box-shadow: 0 0 0 2px #f3c2c2 inset, 0 24px 60px rgba(15,23,42,.28); }
.job.fail .job-bar > i { background: linear-gradient(90deg, #e04a4a, #ff7a7a); }

/* 切换步骤时的入场动画 */
.panel.active { animation: panelIn .28s ease both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* ===== 手机端底部两条固定栏（步骤导航 + 返回/下载）不压住内容 ===== */
@media screen and (max-width: 768px) {
  main { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
  #step-5 .preview { padding-bottom: 8px; }
  /* 预览页之间留白，翻页时不会被工具栏“切一刀” */
  #preview .page { margin: 0 auto; }
}

/* 题号胶囊：之前背景和文字同色，看起来是个黑块 */
.item-head .qnum {
  background: #eef4fb !important; color: #1f4a7a !important;
  border-radius: 8px; padding: 3px 10px; font-weight: 700;
}

/* 导出页：工具栏不再悬浮压住 A4 预览 */
@media screen and (max-width: 768px) {
  #step-5 .step-nav {
    position: static; margin: 12px 0 0; border-radius: 12px;
    border: 1px solid var(--line); background: #fff;
    box-shadow: 0 4px 14px rgba(17,24,39,.06);
  }
  #step-5 .actions #btn-download-pdf { display: inline-flex; }
}

/* ===== 2026.11.29w 视觉细节升级 ===== */

/* 匹配结果胶囊：一眼看出这道题出没出干净页 */
.item-hint.hint-ok {
  display: inline-flex; align-items: center; gap: 3px;
  background: #e8f8ef; border: 1px solid #bfe9d2; color: #157a4b;
  border-radius: 999px; padding: 3px 10px; font-weight: 600;
}
.item-hint.hint-warn {
  display: inline-flex; align-items: center;
  background: #fdf6e7; border: 1px solid #f2e3bd; color: #9a6b16;
  border-radius: 999px; padding: 3px 10px;
}

/* 空状态：给个图标和引导感，不再是一行灰字 */
.empty {
  color: #8a94a8; padding: 36px 20px; text-align: center;
  border: 1.5px dashed #dde4f0; border-radius: 14px; background: #fbfcfe;
  font-size: 13.5px;
}

/* 进度卡：顶部细渐变条 + 标题区更聚焦 */
.job-card { border-top: 4px solid transparent; }
.job-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(90deg, #4361ee, #7b5bf7, #4361ee);
  background-size: 200% 100%; animation: jobSheen 2.2s linear infinite;
}
@keyframes jobSheen { from { background-position: 0 0 } to { background-position: 200% 0 } }
.job-card { position: relative; overflow: hidden; }
.job.fail .job-card::before { background: linear-gradient(90deg, #e04a4a, #ff8a8a); animation: none; }

/* 步骤条：图标随激活态轻微放大，更有点击感 */
.steps button .step-ico { transition: transform .15s; }
.steps button.active .step-ico { transform: scale(1.12); }

/* 首页大按钮：按下反馈更明显 */
.cam-cta:active { transform: scale(.98); box-shadow: 0 6px 16px rgba(67,97,238,.22); }

/* 正反面对比图：圆角 + 描边，像两张小卡片 */
.pair-imgs { gap: 10px; }
.pair-cell {
  margin: 0; border: 1px solid #e6eaf2; border-radius: 12px; overflow: hidden;
  background: #fff; box-shadow: 0 2px 8px rgba(17,24,39,.05);
}
.pair-cell img { display: block; width: 100%; }
.pair-cell figcaption {
  font-size: 11px; color: #6b7892; padding: 5px 8px; background: #f8fafd;
  border-top: 1px solid #eef1f6;
}

/* ===== 未匹配教材页：醒目警告 + 导出拦截 ===== */
.unmatched-banner {
  display: flex; align-items: center; gap: 10px;
  background: #fff4f0; border: 1.5px solid #f5c6b8; border-radius: 12px;
  padding: 10px 12px; margin: 0 0 10px;
}
.unmatched-banner .ub-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.unmatched-banner b { color: #b4432e; font-size: 13px; }
.unmatched-banner .ub-text span { color: #7c5a4e; font-size: 12px; line-height: 1.5; }
.unmatched-banner .btn {
  flex-shrink: 0; background: #d9534f; border-color: #d9534f; color: #fff;
  font-weight: 600; border-radius: 10px;
}
.unmatched-acked {
  background: #f2f7fb; border: 1px dashed #c9d6e6; color: #5a6c82;
  border-radius: 10px; padding: 7px 10px; margin: 0 0 10px; font-size: 12px;
}
.status-warn { color: #b4432e; font-weight: 600; }

/* 进度卡警告态（有未匹配）：琥珀色 */
.job.warn .job-bar > i { background: linear-gradient(90deg, #e8a13c, #f5c26b); }
.job.warn .job-card::before { background: linear-gradient(90deg, #e8a13c, #f5c26b); animation: none; }
.job.warn .job-card { box-shadow: 0 0 0 2px #f5d9a8 inset, 0 24px 60px rgba(15,23,42,.28); }

/* ===== 下拉刷新指示器 ===== */
body { overscroll-behavior-y: contain; }   /* 关掉系统级下拉，统一用自定义的 */
#pull-refresh {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%) translateY(-10px);
  display: flex; align-items: center; gap: 6px;
  background: rgba(31, 42, 68, .92); color: #fff;
  font-size: 12.5px; font-weight: 500;
  padding: 8px 16px; border-radius: 999px;
  z-index: 60; opacity: 0; pointer-events: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
}
#pull-refresh.show { opacity: 1; }
#pull-refresh .pr-arrow { display: inline-block; font-size: 14px; line-height: 1; }
#pull-refresh.spin .pr-arrow { animation: prSpin .7s linear infinite; }
@keyframes prSpin { to { transform: rotate(360deg); } }

/* ===== 参考答案页：截图放开到纸面宽度（v2026.11.30o） =====
   原来限高 50mm/30mm 太小；反面内容少，截图应适当占满宽度。
   只放宽 max-width/max-height，保持原始比例，绝不拉伸变形。 */
.answer-page .ans-question .qimg-answer { max-height: 180mm; }
.answer-card .qimg-compact { max-height: 60mm; }
.grid.p4 .qimg-compact { max-height: 26mm; }

/* 反面答案卡去掉三行文字后，截图占满卡片可用高度（v2026.11.30p） */
.answer-card .mc-stem { flex: 1; min-height: 0; overflow: hidden; }
.answer-card .qimg-compact { max-height: 95mm; }
.grid.p4 .qimg-compact { max-height: 40mm; }

/* ===== 第 4 步悬浮操作栏：不滚动直达导出（v2026.11.30q） ===== */
.sticky-act {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 250;
  display: flex; gap: 8px; align-items: stretch;
  padding: 10px calc(14px + env(safe-area-inset-right))
           calc(10px + env(safe-area-inset-bottom))
           calc(14px + env(safe-area-inset-left));
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(17, 24, 39, .08);
}
.sticky-act .btn { flex: 1; margin: 0; white-space: nowrap; }
.sticky-act .btn.primary { flex: 1.4; }
.sticky-act[hidden] { display: none !important; }
body.sticky-open { padding-bottom: 72px; }
@media (min-width: 760px) {
  .sticky-act { max-width: 720px; margin: 0 auto; border-radius: 14px 14px 0 0; }
  body.sticky-open main { padding-bottom: 90px; }
}

/* 悬浮栏按钮被导出锁锁住时的视觉状态 */
.sticky-act .btn.nav-locked { opacity: .5; }

/* 底部栏的首页按钮（第 2/3 环节常驻） */
.sticky-act .sa-home { flex: 0 0 auto; width: 48px; padding-left: 0; padding-right: 0; }

/* ===== 正面错题图放大（v2026.12.01s）：原来 max-height 45mm，打出来看不清 =====
   每页 2 题时，右栏标题下方尽量给足版面：图占满栏宽、高度放到 74mm；
   正解栏保留书写空间（min-height 30mm）。 */
.grid.p2 .qimg-d {
  max-height: 58mm;      /* 折中：原来 45mm 太小，占满整栏又太大 */
  max-width: 96%;
  width: auto;
  object-fit: contain;
  margin: 0 auto;
}
.grid.p2 .d-stem { min-height: 0; }
.grid.p2 .d-answer { min-height: 26mm; }
/* 单题整页时更大 */
.d-card-full .qimg-d { max-height: 150mm; }
