/* ========== 全局变量与基础设置 ========== */
:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --bg: #f9fafb;

  --tone1: #dc2626;
  --tone2: #ea580c;
  --tone3: #16a34a;
  --tone4: #2563eb;
  --tone5: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.app-header { padding: 32px 20px 12px; text-align: center; }
.app-header h1 { margin: 0 0 8px; font-size: 2.2rem; letter-spacing: -0.02em; }
.tagline { margin: 0 auto; max-width: 650px; color: var(--muted); font-size: 1.05rem; line-height: 1.5; }
.tagline strong { color: var(--ink); }
.seo-desc { margin: 12px auto 0; max-width: 600px; font-size: 0.85rem; color: #9ca3af; }

.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  padding: 20px 40px;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 20px; } }

.controls {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  position: sticky;
  top: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.field { margin-bottom: 18px; }
.relative { position: relative; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; }

.field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; background: #f9fafb; transition: all 0.2s;
}
.field textarea:focus, .field select:focus {
  outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.field textarea { resize: vertical; }

/* Clear 按钮挪到文本框下方的计数行里：比原来压在半透明角标上更容易看见，
   也不占额外纵向空间，同时不再需要给 textarea 预留 padding-bottom */
.hint { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 0.75rem; color: var(--muted); }
.clear-btn {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  font-size: 0.72rem; color: var(--muted); padding: 3px 10px; cursor: pointer; transition: 0.2s;
}
.clear-btn:hover { border-color: #fca5a5; color: #b91c1c; background: #fef2f2; }
.hint-sub { margin: 4px 0 0; font-size: 0.72rem; font-style: italic; color: var(--muted); line-height: 1.45; }
/* 控件下方的动态说明（网格风格差异等）：不加斜体，读起来更像解释而非脚注 */
.field-note { margin: 6px 0 0; font-size: 0.72rem; line-height: 1.45; color: var(--muted); }
.truncate-warn { margin: 4px 0 0; color: #b91c1c; font-weight: 600; font-size: 0.75rem; }
.field-warn {
  margin: 8px 0 0; font-size: 0.75rem; line-height: 1.45;
  color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; padding: 8px 10px;
}
.error-state {  color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 12px; padding: 32px 24px; text-align: center; line-height: 1.6;
}

.file-upload-wrapper { position: relative; overflow: hidden; display: inline-block; width: 100%; }
.file-upload-btn {
  width: 100%; padding: 10px 12px; background: #f9fafb; border: 1px dashed #9ca3af;
  border-radius: 10px; font-size: 0.9rem; color: var(--muted); cursor: pointer; transition: all 0.2s;
}
.file-upload-btn:hover { background: #f3f4f6; border-color: var(--accent); color: var(--accent); }
.file-upload-btn:disabled { opacity: 0.6; cursor: wait; }

/* 上传进度反馈：busy 时转圈，完成/失败显示静态文字几秒后自动隐藏 */
.upload-status {
  margin: 8px 0 0; font-size: 0.75rem; color: var(--muted); line-height: 1.45;
  display: flex; align-items: center; gap: 7px;
}
.upload-status.busy::before {
  content: ""; flex: 0 0 auto;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: upload-spin 0.7s linear infinite;
}
@keyframes upload-spin { to { transform: rotate(360deg); } }

/* 一键清空手改读音：低调的文字按钮，只在确实存在覆盖值时出现 */
.reset-py {
  margin-top: 8px; padding: 0; border: none; background: none;
  font-size: 0.72rem; color: #b45309; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.reset-py:hover { color: #92400e; }
.reset-py:disabled { color: var(--muted); cursor: default; text-decoration: none; }

/* 手改读音的可见标记：虚线下划线 = 这是手动覆盖，不是词典识别错。
   打印件上不出现，老师看到的仍是干净的练习纸 */
.py-custom { text-decoration: underline dotted #94a3b8; text-decoration-offset: 3px; text-underline-offset: 3px; }
.pinyin-letter.py-custom { text-decoration: underline dotted #94a3b8; text-underline-offset: 3px; }
@media print { .py-custom, .pinyin-letter.py-custom { text-decoration: none; } }

/* 视觉隐藏但保留可访问性（radio 输入、读屏状态播报共用） */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.file-upload-wrapper input[type="file"] { position: absolute; left: 0; top: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* 2×2 网格：同一行卡片自动等高；标题与说明分两层，行高放宽，四张卡不会一大一小。
   注意：.field label (0,1,1) 优先级高于 .radio-card (0,1,0)，会把 display:flex
   压成 block、并继承 600 字重，因此这里必须用 .field label.radio-card 反压 */
.radio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field label.radio-card {
  display: flex; flex-direction: column; gap: 3px; justify-content: flex-start;
  font-weight: 400; margin-bottom: 0;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 9px;
  text-align: center; cursor: pointer; background: #fff; position: relative;
  min-height: 78px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
/* 视觉隐藏但保留可聚焦，否则键盘用户无法切换模式 */
.radio-card input {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.radio-card:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.radio-card .radio-title { font-size: 0.82rem; font-weight: 600; color: var(--ink); line-height: 1.3; }
.radio-card .radio-desc { font-size: 0.68rem; font-weight: 400; color: var(--muted); line-height: 1.4; }
.radio-card:hover { border-color: #9ca3af; }
.radio-card.selected { border-color: var(--accent); background: #eff6ff; box-shadow: 0 0 0 1px var(--accent); }
.radio-card.selected .radio-title { color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-field label { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 0.9rem; margin-bottom: 8px; cursor: pointer; }
/* 带说明文字的选项：勾选框与首行文字顶端对齐，说明缩进到文字下方 */
.checkbox-field label.opt-stacked { align-items: flex-start; }
.checkbox-field label.opt-stacked input { margin-top: 4px; flex: 0 0 auto; }
.opt-hint { display: block; margin-top: 2px; font-size: 0.72rem; line-height: 1.4; color: var(--muted); }

.actions { display: flex; gap: 12px; margin-top: 24px; }
button { font-family: inherit; cursor: pointer; transition: all 0.2s; border-radius: 10px; }
button.primary { flex: 1; padding: 12px; background: var(--accent); border: 1px solid var(--accent); color: #fff; font-weight: 600; font-size: 0.95rem; }
button.primary:hover { background: var(--accent-hover); }
button.secondary { flex: 1; padding: 12px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 0.95rem; }
button.secondary:hover { background: #f3f4f6; }

.privacy-note { margin: 16px 0 0; font-size: 0.75rem; color: var(--muted); text-align: center; }

.preview { min-height: 400px; }

/* 手机端：作业单是固定像素格宽，窄屏必然溢出。给预览区横向滚动，
   并在上方提示可以左右滑动（桌面端完全隐藏这条提示） */
.mobile-hint { display: none; }
@media (max-width: 900px) {
  .mobile-hint {
    display: block; margin: 0 0 8px; font-size: 0.72rem; color: var(--muted);
    text-align: center; line-height: 1.45;
  }
  .preview { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .preview .sheet { min-width: max-content; }
}
.empty-state { color: var(--muted); text-align: center; padding: 80px 20px; border: 2px dashed var(--line); border-radius: 16px; background: #fff; }

.sheet { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 32px 40px; margin-bottom: 24px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05); }
.sheet-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 6px; }
.sheet-subtitle { font-size: 0.85rem; color: var(--muted); margin: 0 0 24px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }

.words { display: grid; gap: 24px 16px; }
.words.cols-1 { grid-template-columns: 1fr; }
.words.cols-2 { grid-template-columns: 1fr 1fr; }
.words.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.word-item { 
  border: 1px solid var(--line); 
  border-radius: 8px; 
  padding: 12px 16px; 
  background: #fff;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.word-pinyin { font-size: 1.1rem; letter-spacing: 0.05em; font-family: "Times New Roman", Times, serif; }

.tone-1 { color: var(--tone1); } .tone-2 { color: var(--tone2); } .tone-3 { color: var(--tone3); } .tone-4 { color: var(--tone4); } .tone-5 { color: var(--tone5); }

.grid-line { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 6px; 
  width: 100%;
}
.grid-line .cell {
  /* 边长、字号全部由 --cell 推导：Size Adjustment 或 Grid Size 一变，格子 / 四线带 / 字号同步缩放，
     不会出现「格子变大了但字没变大」 */
  width: var(--cell, 40px); height: var(--cell, 40px);
  border: 1px solid var(--ink); position: relative;
  /* 成为堆叠上下文：让 ::before/::after 的十字辅助线（z-index:-1）垫在文字下面，
     否则绝对定位的线条画在行内文字之上，打印出来横竖线压在汉字上 */
  z-index: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell, 40px) * 0.55);
  font-family: var(--hanzi-font, "Kaiti SC", "STKaiti", KaiTi, "Noto Serif SC", "Songti SC", serif);
  line-height: 1; background: #fff; flex: 0 0 auto;
}
.grid-line .cell.blank { color: transparent; }
/* 带标点的格子：汉字略向左上偏移，给右下角的标点腾位置，避免两者叠在一起。
   必须用 calc(var(--cell)) 而不是 %：百分比 padding 参照包含块宽度，
   答案页的格子直接躺在整行宽的 flex 里，4% 会放大成二十几像素把字挤出格子 */
.grid-line .cell.has-punct { padding-right: calc(var(--cell, 40px) * 0.16); }

/* 标点：不单独占格、不进四线三格、不注音，只贴在所属汉字的格子里。
   与汉字同行、坐在同一书写基线上（跟在字后，像正常书写那样），而不是缩在角落。
   句号逗号本身字形偏下，bottom 对齐后视觉落在格内下沿，符合教材写法 */
.cell-punct {
  position: absolute; z-index: 3; pointer-events: none;
  font-size: calc(var(--cell, 40px) * 0.42); line-height: 1;
  color: var(--ink); font-family: inherit;
}
.cell-punct.trail { right: 2%; bottom: 8%; }
/* 。，、 的墨迹在 em 框左下角，必须向右平移半个字宽，墨点才会落在格子右缘 */
.cell-punct.trail.corner { transform: translateX(58%); }
.cell-punct.lead  { left: 4%;  top: 4%; }

/* 拼音改正按钮：屏幕可见、打印消失。默认淡出，悬停才实心，避免干扰阅读 */
.char-column { position: relative; }
.py-edit {
  position: absolute; top: -2px; right: -4px;
  width: 15px; height: 15px; padding: 0; line-height: 13px;
  font-size: 10px; text-align: center;
  background: #fff; color: #9ca3af;
  border: 1px solid var(--line); border-radius: 50%;
  opacity: 0; transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.char-column:hover .py-edit, .py-edit:focus-visible { opacity: 1; color: var(--accent); border-color: var(--accent); }
/* 触屏没有 hover，常显淡色，否则功能等于不存在 */
@media (hover: none) { .py-edit { opacity: 0.55; } }

/* 田字格/米字格辅助线：用 border 画（background 在打印时会被浏览器整体丢弃） */
.grid-tian .cell::before, .grid-tian .cell::after, .grid-mi .cell::before, .grid-mi .cell::after { content: ""; position: absolute; z-index: 1; }
.grid-tian .cell::before, .grid-mi .cell::before { left: 0; right: 0; top: 50%; height: 0; border-top: 1px solid #d1d5db; z-index: -1; }
.grid-tian .cell::after, .grid-mi .cell::after  { top: 0; bottom: 0; left: 50%; width: 0; border-left: 1px solid #d1d5db; z-index: -1; }
.grid-mi .cell .diag-1, .grid-mi .cell .diag-2 { position: absolute; width: 141%; height: 0; border-top: 1px solid #d1d5db; top: 50%; left: -20.5%; transform: rotate(45deg); z-index: -1; }
.grid-mi .cell .diag-2 { transform: rotate(-45deg); }
.grid-mi .cell span:not(.diag-1):not(.diag-2), .grid-tian .cell span:not(.diag-1):not(.diag-2), .grid-line .cell { z-index: 2; }
.grid-underline .cell { border: none; border-bottom: 1px solid var(--ink); border-radius: 0; }
.grid-none .cell { border: none; }

.answer-label { display: inline-block; font-size: 0.75rem; font-weight: 700; color: #fff; background: #10b981; border-radius: 4px; padding: 2px 8px; margin-bottom: 12px; }

/* ===== 答案页：视觉上必须一眼可辨，避免学生拿到题时把答案一起收走 ===== */
.sheet--answer { border: 2px solid #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.08); }
.answer-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 8px 12px; margin-bottom: 16px;
  background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 10px;
  font-size: 0.75rem; color: #065f46;
}
.answer-badge { font-weight: 700; letter-spacing: 0.04em; font-size: 0.68rem; }
.answer-note { flex: 1 1 auto; min-width: 140px; color: #047857; }
.link-btn {
  background: #fff; border: 1px solid #10b981; color: #047857;
  border-radius: 6px; padding: 4px 10px; font-size: 0.72rem; font-weight: 600;
}
.link-btn:hover { background: #10b981; color: #fff; }
.link-btn:disabled { opacity: 0.6; cursor: wait; }

/* ===== 拼音改正弹层 ===== */
.py-pop {
  position: absolute; z-index: 200; width: 230px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.25);
  padding: 12px;
}
.py-pop-label { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 6px; }
.py-pop-label strong { color: var(--ink); font-size: 0.9rem; }
.py-pop-input {
  width: 100%; padding: 7px 9px; font-size: 0.95rem;
  font-family: "Times New Roman", Times, serif;
  border: 1px solid var(--line); border-radius: 8px;
}
.py-pop-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.py-pop-select {
  width: 100%; margin-top: 8px; padding: 7px 9px; font-size: 0.85rem;
  font-family: "Times New Roman", Times, serif;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.py-pop-actions { display: flex; gap: 6px; margin-top: 8px; }
.py-pop-hint { margin: 8px 0 0; font-size: 0.68rem; color: var(--muted); line-height: 1.4; }
.py-pop-actions button {
  flex: 1; padding: 6px 0; font-size: 0.72rem; font-weight: 600;
  border-radius: 6px; border: 1px solid var(--line); background: #f9fafb; color: #374151;
}
.py-pop-save { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.py-pop-hint { margin: 8px 0 0; font-size: 0.68rem; color: var(--muted); line-height: 1.4; }

/* ===== 四线三格（pinyin-band）：每个字列自己的顶带，与格子逐列对齐 ===== */
/* 字号按 Times New Roman 度量校准（x-height≈0.448em, ascent≈0.891em）：
   x 高度≈中格高、升部≈顶到第一线、基线落在第三线上（top:-0.15em 微调），声调符号收在带内 */
.pinyin-band {
  position: relative;
  /* 堆叠上下文：中间两条辅助线（z-index:-1）垫在拼音字母下面，打印时不压字 */
  z-index: 0;
  /* 向两侧各伸入列间 gap 的 3px：相邻列的四线首尾相接，整行连成连续四线三格；
     负边距 + 加宽正好抵消，不改变列的布局宽度 */
  width: calc(100% + 6px);
  margin-left: -3px;
  margin-right: -3px;
  height: calc(var(--cell, 40px) * 0.65);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #cfd4da;
  border-bottom: 1px solid #cfd4da;
}
/* 中间两条线，把带子分成标准的三格。
   必须用 border 而不是 background：浏览器打印默认不输出背景（「背景图形」未勾选时），
   background 画的线在打印预览里会整条消失 */
.pinyin-band::before, .pinyin-band::after {
  content: ""; position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid #e4e7ec; z-index: -1;
}
.pinyin-band::before { top: 33.3%; }
.pinyin-band::after  { top: 66.6%; }

/* 带高与字号都从 --cell 推导；字号 ≈ 带内高 ÷ 1.55，保证 x 高度落在中格、声调收在带内。
   原来的三档硬编码已并入变量，改格子大小不再需要同步改字号 */
.pinyin-letter {
  font-family: "Times New Roman", Times, serif;
  font-size: calc(var(--cell, 40px) * 0.42);
  line-height: 1;
  position: relative;
  top: -0.15em;             /* 让基线落在第三线上，而不是悬在带中央 */
  color: #111827;
}
.pinyin-letter.tracing { color: #b9c0ca; }   /* Copy 页描灰：比辅助线深，仍可覆盖书写 */
/* Color-Code Tones 勾选时覆盖描灰/实色（0,3,0 特异度压过上面的 .tracing/.solid） */
.pinyin-letter.tracing.tone-1, .pinyin-letter.solid.tone-1 { color: var(--tone1); }
.pinyin-letter.tracing.tone-2, .pinyin-letter.solid.tone-2 { color: var(--tone2); }
.pinyin-letter.tracing.tone-3, .pinyin-letter.solid.tone-3 { color: var(--tone3); }
.pinyin-letter.tracing.tone-4, .pinyin-letter.solid.tone-4 { color: var(--tone4); }
.pinyin-letter.tracing.tone-5, .pinyin-letter.solid.tone-5 { color: var(--tone5); }
.pinyin-letter.blank { color: transparent !important; }

/* 带高与字号已由上面的 --cell 变量统一推导，这里不再需要逐档硬编码 */

.ruby-container { line-height: 2.5; font-size: 1.5rem; padding: 20px; }
ruby { margin-right: 8px; }
rt { font-size: 0.8rem; color: #6b7280; font-family: "Times New Roman", Times, serif; }

/* ===== How to 折叠面板：原生 <details>，无需 JS，细节内的文字仍会被搜索引擎收录 ===== */
details.how-to-section {
  max-width: 760px; margin: 40px auto 0; padding: 0; color: #374151;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
}
details.how-to-section > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; cursor: pointer; list-style: none;
  transition: background 0.15s;
}
details.how-to-section > summary::-webkit-details-marker { display: none; }
details.how-to-section > summary:hover { background: #f9fafb; }
details.how-to-section > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
details.how-to-section > summary h2 { margin: 0; font-size: 1rem; font-weight: 600; text-align: left; }
.summary-meta {
  flex: 0 0 auto; font-size: 0.75rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.summary-meta::after {
  content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform 0.2s;
}
details[open] .summary-meta::after { transform: rotate(-135deg) translateY(-2px); }
details.how-to-section > ol {
  margin: 0; padding: 4px 24px 20px 44px;
  border-top: 1px solid var(--line);
}
details.how-to-section > ol { padding-top: 18px; }
details.how-to-section li { font-size: 0.95rem; line-height: 1.65; margin-bottom: 12px; }
details.how-to-section li:last-child { margin-bottom: 0; }
details.how-to-section em { font-style: normal; font-weight: 600; color: var(--ink); white-space: nowrap; }

.article-section, .faq-section { max-width: 1000px; margin: 40px auto; padding: 0 40px; color: #374151; }
.article-section h2, .faq-section h2 { text-align: center; font-size: 1.5rem; margin-bottom: 24px; }
.article-section p { font-size: 1rem; line-height: 1.6; }
.faq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.faq-item { background: #fff; padding: 20px; border-radius: 12px; border: 1px solid var(--line); }
.faq-item h3 { margin: 0 0 8px; font-size: 1rem; }
.faq-item p { margin: 0; font-size: 0.9rem; color: var(--muted); line-height: 1.5; }
@media (max-width: 768px) { .faq-grid { grid-template-columns: 1fr; } }

/* 内链区域：导向内容页 / 长尾页 */
.links-section { max-width: 1000px; margin: 40px auto; padding: 0 40px; color: #374151; }
.links-section h2 { text-align: center; font-size: 1.5rem; margin-bottom: 24px; }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.link-list li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; font-size: 0.9rem; line-height: 1.55; color: var(--muted); }
.link-list a { color: var(--accent); text-decoration: none; }
.link-list a strong { color: var(--ink); }
.link-list a:hover strong { color: var(--accent); text-decoration: underline; }
@media (max-width: 768px) { .links-section { padding: 0 20px; } .link-list { grid-template-columns: 1fr; } }

.footer { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); margin-top: 40px; }
.footer a { color: var(--accent); text-decoration: none; margin: 0 8px; }
.footer a:hover { text-decoration: underline; }
.footer-links { margin: 0 0 10px; line-height: 2; }
.footer-links .sep { color: var(--line); }

@media print {
  @page { size: letter; margin: 14mm; }
  body { background: #fff; }
  .no-print, .faq-section, .footer, .how-to-section, .article-section { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .preview { min-height: 0; }
  .sheet { border: none; box-shadow: none; border-radius: 0; padding: 0; margin: 0; page-break-after: always; }
  .sheet:last-child { page-break-after: auto; }
  .sheet-title { font-size: 1.1rem; margin-bottom: 4px; break-after: avoid; page-break-after: avoid; }
  .sheet-subtitle { margin-bottom: 14px; padding-bottom: 8px; break-after: avoid; page-break-after: avoid; }
  /* 词组不跨页拆分：band 和格子必须待在同一页，否则练习纸无法使用。
     同时禁掉 flex 容器内部的孤行——Chrome 对 flex 的 break-inside 支持不稳，
     额外给 grid-line 也上一道保险 */
  .word-item { break-inside: avoid; page-break-inside: avoid; border-color: #999; border-radius: 0; padding: 8px 12px; }
  .grid-line { break-inside: avoid; page-break-inside: avoid; }
  .words { gap: 12px 16px; }
  /* 一张纸最多两列，列内词组按整行分页；orphans/widows 防止页尾只剩半行 */
  .word-item { orphans: 2; widows: 2; }
  .grid-tian .cell::before, .grid-tian .cell::after, .grid-mi .cell::before, .grid-mi .cell::after { border-color: #bbb; }
  .pinyin-band { border-color: #999; }
  .pinyin-band::before, .pinyin-band::after { border-color: #ccc; }
  /* 答案页在纸上是普通一页（绿框只在屏幕上做识别），但保留 ANSWER KEY 标题 */
  .sheet--answer { border: none; box-shadow: none; }

  /* 只打印答案 / 只打印练习：由 body 上的 class 控制窗口内可见范围 */
  body.print-only-answers .sheet:not(.sheet--answer) { display: none !important; }
  body.print-only-worksheet .sheet--answer { display: none !important; }
  body.print-only-answers .sheet--answer { page-break-after: auto; }
}

/* 完美对齐每一列 */
.char-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

/* 拼音绝对悬浮在汉字格子上方 */
.pinyin-above {
  font-size: calc(var(--cell, 40px) * 0.4);
  font-family: "Times New Roman", Times, serif;
  white-space: nowrap;
  margin-bottom: 4px;
  height: calc(var(--cell, 40px) * 0.5); /* 占位，防止没拼音时塌陷 */
  display: flex;
  align-items: center;
}