/* ========================================================
   小学数学 · 单元同步练生成器 —— 现代高质感 UI 样式 (v0.8.0)
   - 屏幕端：现代化教育工作台、毛玻璃、精细阴影、动效与卡片排版
   - 打印端：严格遵循 A4 规范无溢出排版，纯净黑白输出
   ======================================================== */

:root {
  /* 现代教育科技蓝色彩体系 */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --emerald: #059669;
  --emerald-light: #ecfdf5;
  --emerald-border: #a7f3d0;
  
  --amber: #d97706;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;

  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --purple-border: #ddd6fe;

  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --line: #e2e8f0;
  --line-light: #f1f5f9;
  --bg: #f8fafc;
  --panel: #ffffff;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-paper: 0 25px 50px -12px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(15, 23, 42, 0.04);
}

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

.mode-card, .diff-card {
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
}

button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── 顶栏与背景修饰 ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  padding: 12px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.brand-text h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.brand-text .tag {
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-block;
  margin-top: 3px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.steps {
  display: flex;
  align-items: center;
  background: var(--line-light);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.step {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  background: transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.15);
  color: var(--muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.step.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.step.active .step-num {
  background: #fff;
  color: var(--primary);
}

.btn-admin-link {
  font-size: 12px;
  font-weight: 600;
  color: #4338ca;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 7px 14px;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-admin-link:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

/* ── 主容器 ── */
.container {
  max-width: 920px;
  margin: 32px auto 60px;
  padding: 0 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-light);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-header h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header .subtext {
  font-size: 13px;
  color: var(--muted);
}

/* ── 练习方式选择卡片 ── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.mode-card {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-card:hover {
  border-color: var(--primary-border);
  background: #fafcff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.mode-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
}

.mode-card .mode-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-card .mode-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.badge-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
}

.badge-tag.hot {
  background: #fee2e2;
  color: #b91c1c;
}

/* ── 字段组 ── */
.field {
  margin-bottom: 24px;
}

.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 10px;
}

/* ── 选项药丸与卡片 ── */
.options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.opt {
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-secondary);
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.opt:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: #fafcff;
}

.opt.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.opt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f1f5f9;
}

/* ── 搜索框 ── */
.search-bar {
  margin-bottom: 18px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 38px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
}

/* ── 单元卡片网格 ── */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.unit-item {
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 86px;
  box-shadow: var(--shadow-sm);
}

.unit-item:not(:disabled):hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: #fafcff;
}

.unit-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
}

.unit-item:disabled {
  color: var(--muted);
  background: #f8fafc;
  cursor: not-allowed;
  opacity: 0.6;
}

.unit-header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.unit-idx-pill {
  font-family: Consolas, monospace;
  font-weight: 700;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
}

.unit-name-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.unit-footer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.unit-mini-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--line-light);
  color: var(--muted);
}

.unit-mini-badge.diagram {
  background: #e0f2fe;
  color: #0369a1;
}

.unit-mini-badge.gradient {
  background: #dcfce7;
  color: #15803d;
}

/* ── 难度选择卡片 ── */
.difficulty-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 680px) {
  .difficulty-cards { grid-template-columns: 1fr; }
}

.diff-card {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.diff-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.diff-card[data-v="easy"].selected {
  border-color: var(--emerald);
  background: var(--emerald-light);
  box-shadow: 0 0 0 1px var(--emerald), var(--shadow-md);
}

.diff-card[data-v="medium"].selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
}

.diff-card[data-v="hard"].selected {
  border-color: var(--purple);
  background: var(--purple-light);
  box-shadow: 0 0 0 1px var(--purple), var(--shadow-md);
}

.diff-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diff-name {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.diff-card[data-v="easy"] .diff-name { color: #047857; }
.diff-card[data-v="medium"] .diff-name { color: #1d4ed8; }
.diff-card[data-v="hard"] .diff-name { color: #6d28d9; }

.diff-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ── 题量胶囊 ── */
.count-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.count-chip {
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-secondary);
  transition: all 0.15s ease;
}

.count-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.count-chip.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
}

/* ── 底部操作区 ── */
.row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line-light);
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-secondary);
}

.btn.secondary:hover {
  background: var(--line-light);
  border-color: var(--muted-light);
}

.btn.success {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
  box-shadow: 0 2px 10px rgba(22, 163, 74, 0.3);
}

.btn.success:hover:not(:disabled) {
  background: #15803d;
  border-color: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.4);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn.ghost:hover {
  color: var(--ink);
  background: var(--line-light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 14px;
  min-height: 20px;
}

.hidden { display: none !important; }

/* ── 试卷视图工作台 ── */
.paper-wrap {
  max-width: 940px;
  margin: 20px auto 80px;
  padding: 0 20px;
}

.paper-workbench-bar {
  position: sticky;
  top: 76px;
  z-index: 90;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-lg);
  flex-wrap: wrap;
  gap: 12px;
}

.workbench-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workbench-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 拟真 A4 纸张 */
.paper {
  background: #ffffff;
  border-radius: 4px;
  box-shadow: var(--shadow-paper);
  padding: 56px 64px;
  min-height: 1120px;
  line-height: 1.9;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.paper.answers {
  margin-top: 36px;
  background: #fcfdfe;
  break-before: page;
  page-break-before: always;
}

/* 试卷规范抬头 */
.paper-head {
  text-align: center;
  margin-bottom: 30px;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 18px;
}

.paper-badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.paper-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #0f172a;
  margin-bottom: 8px;
}

.paper-sub {
  color: #475569;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 14px;
}

.paper-meta-grid {
  display: flex;
  justify-content: center;
  gap: 32px;
  font-size: 13.5px;
  color: #1e293b;
  font-weight: 500;
  flex-wrap: wrap;
}

.blank-line {
  display: inline-block;
  border-bottom: 1px solid #64748b;
  min-width: 72px;
  height: 16px;
  vertical-align: middle;
}

.score-box {
  display: inline-flex;
  align-items: center;
  border: 1px solid #0f172a;
  padding: 2px 12px;
  border-radius: 4px;
  font-weight: 700;
}

/* 试卷题目分组 */
.section-block {
  margin-bottom: 28px;
}

.section-title {
  font-size: 15.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 24px 0 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-score {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px 36px;
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.calc-grid .q {
  white-space: normal;
  display: flex;
  align-items: baseline;
}

.app-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  font-size: 15.5px;
  line-height: 1.85;
}

.app-list .q {
  margin-bottom: 8px;
}

.question-diagram {
  display: block;
  max-width: 100%;
  height: auto;
  color: #111;
  margin: 8px 0;
}

.vertical-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 36px;
}

.vertical-grid > div {
  min-height: 200px;
  break-inside: avoid;
}

.vertical-problem {
  margin: 12px 0 0 20px;
  width: max-content;
  font: 20px/1.7 Consolas, "Courier New", monospace;
  white-space: pre;
}

.vertical-stack {
  text-align: right;
  border-bottom: 1.5px solid #0f172a;
  min-width: 100px;
}

.division-setup {
  display: flex;
  align-items: start;
  gap: 8px;
  padding-top: 18px;
}

.dividend {
  border-top: 1.5px solid #0f172a;
  border-left: 1.5px solid #0f172a;
  border-radius: 6px 0 0 0;
  padding: 0 6px 0 10px;
}

.write-space {
  border-bottom: 1px dashed #cbd5e1;
  height: 52px;
  position: relative;
}

.write-space::after {
  content: "答：";
  position: absolute;
  left: 0;
  bottom: 6px;
  font-size: 13px;
  color: #94a3b8;
}

.write-space.tall {
  height: 72px;
}

.question-table {
  border-collapse: collapse;
  text-align: center;
  margin: 10px 0;
  font-size: 13px;
}

.question-table th, .question-table td {
  border: 1px solid #475569;
  padding: 4px 12px;
}

/* 答案区 */
.ans-list {
  font-size: 14px;
  line-height: 1.8;
}

.ans-item {
  margin-bottom: 6px;
}

.ans-cols {
  columns: 3;
  column-gap: 32px;
  font-size: 14px;
  line-height: 1.9;
}

.ans-cols .ans-item {
  break-inside: avoid;
}

.ans-diagrams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 28px;
  font-size: 14px;
}

/* ── 考试测验卷与新题型样式 ── */
.exam-meta-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px 28px;
  font-size: 13.5px;
  color: #1e293b;
  margin-top: 12px;
  padding: 8px 16px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.choice-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  margin: 8px 0 14px 24px;
  font-size: 14.5px;
  color: #334155;
}

.choice-options-grid .opt-item {
  background: #f8fafc;
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid #f1f5f9;
}

.solve-workspace {
  margin: 12px 0 20px 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px 16px;
  break-inside: avoid;
}

.solve-space {
  min-height: 96px;
  position: relative;
  background-image: linear-gradient(to bottom, transparent 31px, #e2e8f0 32px);
  background-size: 100% 32px;
}

.solve-answer-line {
  border-top: 1px dashed #cbd5e1;
  margin-top: 8px;
  padding-top: 8px;
  color: #334155;
  font-weight: 500;
  font-size: 14.5px;
  letter-spacing: 0.5px;
}

/* 递等式 / 脱式计算三步作答留白 */
.steps-workspace {
  margin: 10px 0 18px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  break-inside: avoid;
}

.step-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: #475569;
}

.step-rule {
  flex: 1;
  max-width: 320px;
  border-bottom: 1px dashed #cbd5e1;
  height: 1px;
  display: inline-block;
}

/* 作图与几何题作答横线 */
.draw-answer-line {
  margin: 10px 0 16px 20px;
  color: #475569;
  font-size: 14px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 6px;
}

.ans-exp {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: #047857;
  background: #ecfdf5;
  padding: 6px 12px;
  border-radius: 4px;
  border-left: 3px solid #10b981;
}

.exp-badge {
  font-weight: 700;
  margin-right: 4px;
}

/* ── 手机移动端触控吸底栏 ── */
.mobile-action-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-status-text {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-mobile-next {
  min-width: 108px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 20px;
}

/* ── 移动端深度适配 (Mobile-First) ── */
@media (max-width: 768px) {
  .topbar { padding: 10px 14px; }
  .panel { padding: 18px 14px 80px; }
  .steps { display: none; }
  .mobile-action-bar { display: flex; }

  .mode-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 18px;
  }
  .mode-card {
    padding: 12px 14px;
  }
  .mode-card .mode-title {
    font-size: 14.5px;
  }
  .mode-card .mode-desc {
    font-size: 12px;
  }

  .paper-wrap {
    padding: 0 6px;
    margin: 12px auto 90px;
  }
  .paper {
    padding: 24px 14px;
    min-height: auto;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  }
  .paper-title {
    font-size: 19px;
    letter-spacing: 1px;
  }
  .paper-meta-grid {
    flex-wrap: wrap;
    gap: 10px 18px;
    font-size: 12.5px;
  }
  .exam-meta-bar {
    font-size: 12px;
    gap: 8px 14px;
    padding: 8px 10px;
  }

  .calc-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 14px;
  }
  .choice-options-grid {
    grid-template-columns: 1fr;
    margin-left: 12px;
    gap: 6px;
  }
  .solve-workspace {
    margin-left: 8px;
    padding: 10px 12px;
  }
  .solve-space {
    min-height: 60px;
  }

  .paper-workbench-bar {
    top: 56px;
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .paper-workbench-bar .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ── 打印样式（A4 专业级输出） ── */
@media print {
  @page {
    size: A4;
    margin: 14mm 16mm;
    @bottom-center {
      content: counter(page);
      font-size: 9pt;
      color: #555;
    }
  }

  body {
    background: #fff;
    color: #000;
  }

  .no-print {
    display: none !important;
  }

  .paper-wrap {
    margin: 0;
    padding: 0;
    max-width: none;
  }

  .paper {
    border: none;
    padding: 0;
    box-shadow: none;
    min-height: auto;
    border-radius: 0;
  }

  .hidden {
    display: none !important;
  }

  #answer-sheet {
    page-break-before: always;
  }

  .section-title {
    margin-top: 20px;
    break-after: avoid;
  }

  .calc-grid {
    gap: 20px 32px;
  }

  .calc-grid .q {
    break-inside: avoid;
  }

  .app-list {
    gap: 22px;
  }

  .app-list > div, .ans-item {
    break-inside: avoid;
  }

  .diagram-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 24px;
  }

  .diagram-list .question-diagram[data-kind="grid"] {
    width: 200px;
  }

  .vertical-grid > div {
    break-inside: avoid;
    min-height: 50mm;
  }

  .write-space {
    height: 44px;
  }

  .write-space.tall {
    height: 60px;
  }

  .ans-list {
    columns: 2;
    column-gap: 30px;
  }

  .ans-diagrams .question-diagram {
    max-width: 210px;
  }

  .solve-workspace {
    margin: 6mm 0 10mm 4mm !important;
    border: 1px dashed #94a3b8 !important;
    background: transparent !important;
    padding: 8px 12px !important;
    break-inside: avoid !important;
    box-shadow: none !important;
  }

  .solve-space {
    min-height: 26mm !important;
    background-image: linear-gradient(to bottom, transparent 25px, #e2e8f0 26px) !important;
    background-size: 100% 26px !important;
  }

  .solve-answer-line {
    border-top: 1px dashed #94a3b8 !important;
    color: #000000 !important;
    padding-top: 6px !important;
  }

  .steps-workspace {
    margin: 4mm 0 8mm 8mm !important;
    gap: 6mm !important;
    break-inside: avoid !important;
  }

  .step-line {
    color: #000000 !important;
  }

  .step-rule {
    border-bottom: 1px dashed #94a3b8 !important;
    max-width: 280px !important;
  }

  .draw-answer-line {
    margin: 4mm 0 8mm 4mm !important;
    color: #000000 !important;
    border-bottom: 1px dashed #94a3b8 !important;
  }
}

/* ── 全局直接导出 PDF 提示气泡 ── */
.export-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.35), 0 8px 12px -6px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: toastFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}
