/* 字帖 · 界面样式
   两块内容：屏幕上的 UI（卡片、圆角、阴影、暗色）与打印用的 A4 版面。
   打印规则在最后，只允许 A4 版面出现，UI 全部隐藏。 */
:root {
  --bg: #f4f6fb;
  --bg-soft: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e4e8f0;
  --line-soft: #eef1f6;
  --text: #1b2330;
  --text-2: #5a6679;
  --text-3: #8d98aa;
  --accent: #4f6ef7;
  --accent-2: #17b8a6;
  --accent-soft: #eef1ff;
  --warn: #e2564d;
  --shadow-sm: 0 1px 2px rgba(20, 32, 52, .05), 0 2px 8px rgba(20, 32, 52, .04);
  --shadow: 0 4px 12px rgba(20, 32, 52, .06), 0 16px 40px rgba(20, 32, 52, .07);
  --shadow-lg: 0 24px 60px rgba(20, 32, 52, .16);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
}

html.dark {
  --bg: #10141c;
  --bg-soft: #151b25;
  --surface: #1a212c;
  --surface-2: #202833;
  --line: #2a3341;
  --line-soft: #232b37;
  --text: #e8edf6;
  --text-2: #9fabbf;
  --text-3: #71809a;
  --accent: #7d94ff;
  --accent-2: #3ed0bd;
  --accent-soft: #232c47;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }
[v-cloak] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }

/* ---------------- 字体 ----------------
   中文字体一个 1MB 起步，6 个就是 11MB，首屏全下太亏。
   这里只声明首屏要用的两款，其余在用户真的选中时才由
   Zu.ensureFont() 用 FontFace 注入（见 utils.js）。

   「楷体」那条不在这里：中文字体目录随 IS_LITE 切换（fonts/zh 或 fonts/zh_lite），
   地址没法写死在 CSS 里，由 utils.js 按当前模式注入同一条 @font-face。

   族名一律用字体自己的名字（楷体 / 手写体 / 拼音体），别写成 kaiti 这种内部键。
   后面的 font-family 列表（Zu.fontStack）里还排着系统同名字体，
   所以这份 woff2 没到、或者下失败了，页面上写的和看到的也还是同一款字。 */
@font-face { font-family: '拼音体'; src: url('./fonts/pinyin/pinyinok.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: '手写体'; src: url('./fonts/en/shouxieti.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: pencontrol; src: url('./fonts/pen/PenControl.woff2') format('woff2'); font-display: block; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-in {
  max-width: 1440px;
  margin: 0 auto;
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; border-radius: var(--r); padding: 4px 8px 4px 4px; }
.brand:hover { background: var(--surface-2); }
.brand-logo {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
  color: #fff; font-weight: 700; font-size: 18px;
}
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: 1.4px; text-transform: uppercase; }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-item {
  padding: 8px 14px; border-radius: 999px; color: var(--text-2);
  white-space: nowrap; transition: background .18s, color .18s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-soft); font-size: 15px;
  transition: transform .15s, box-shadow .15s;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ---------------- 布局 ---------------- */
.wrap { max-width: 1440px; margin: 0 auto; padding: 22px 20px 80px; }
.split { display: grid; grid-template-columns: 372px minmax(0, 1fr); gap: 22px; align-items: start; }
/* 折成一栏时必须 minmax(0, 1fr)：1fr 的默认最小宽度是 min-content，
   而预览里那张 210mm 的纸 min-content 就有 700 多像素 —— 平板竖屏（768）
   会把整栏撑得比屏幕还宽，页面横向溢出。 */
@media screen and (max-width: 1080px) { .split { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-hd {
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-hd h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: .2px; }
.card-bd { padding: 16px 18px; }
.card-bd + .card-bd { border-top: 1px dashed var(--line-soft); }

.side { position: sticky; top: 82px; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 4px; }
.side::-webkit-scrollbar { width: 8px; }
.side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
@media screen and (max-width: 1080px) { .side { position: static; max-height: none; } }

/* ---------------- 控件 ---------------- */
.field { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 10px; align-items: start; }
.field + .field { margin-top: 14px; }
.field > label { color: var(--text-2); font-size: 13px; padding-top: 7px; }
.field-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  padding: 6px 12px; border-radius: 9px; color: var(--text-2); font-size: 13px;
  transition: background .16s, color .16s, box-shadow .16s;
}
.seg button:hover { color: var(--text); }
.seg button.on {
  background: var(--surface); color: var(--accent); font-weight: 600;
  box-shadow: var(--shadow-sm);
}
/* 用不了的那个档位：压暗成禁用态，别让人点了没反应还猜原因 */
.seg button.off { opacity: .38; cursor: not-allowed; }
.seg button.off:hover { color: var(--text-2); }
html.dark .seg button.on { background: var(--accent-soft); }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px; border-radius: 10px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; transition: all .16s;
}
.chip:hover { border-color: var(--line); color: var(--text); transform: translateY(-1px); }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chip i { width: 12px; height: 12px; border-radius: 4px; display: block; }
/* 字体按钮上写的是字体名本身（仿宋就是「仿宋」），字号不放大 ——
   名字自己就是字，用不着再排样张；6 个名字一行还得放得下 */
.chip.font-chip { font-size: 14px; padding: 5px 11px; }

.input {
  width: 100%; padding: 9px 12px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  transition: border .16s, box-shadow .16s, background .16s;
}
.input:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
textarea.input { resize: vertical; min-height: 96px; line-height: 1.9; letter-spacing: 2px; font-size: 15px; }
.num { display: inline-flex; align-items: center; gap: 6px; }
.num .input { width: 64px; text-align: center; padding: 7px 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text);
  transition: transform .14s, box-shadow .18s, background .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent-2)));
  color: #fff; border-color: transparent;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn-primary:hover { box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 42%, transparent); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; border-radius: 10px; font-size: 13px; }

/* 逐字注音：一堆小格子，一个汉字配一个拼音输入框。
   一行放两三个，多了挤成一条缝，手机上不好点 */
.fix-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fix-item {
  display: flex; align-items: center; gap: 5px; padding: 4px 6px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 9px;
}
.fix-item b { font-family: '楷体', 'KaiTi', 'STKaiti', serif; font-size: 16px; font-weight: 500; }
.fix-input { width: 74px; padding: 3px 6px; font-size: 13px; text-align: center; letter-spacing: 0; }

.hint { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* 控笔：输入框里也直接用线条字体显示，所见即所得 ——
   textarea.input 那条规则的特异性比单个类高，所以这里连着元素一起写。
   描边是因为字体本身的线条只有 0.9% em 粗，小字号下会消失。 */
textarea.pen-input {
  font-family: pencontrol, ui-monospace, monospace;
  font-size: 20px; line-height: 1.5; letter-spacing: 6px;
  -webkit-text-stroke: 0.06mm currentColor;
}

/* 控笔图形选择器：按钮里直接是字体画的线条，点一下插到输入框光标处 */
.pen-picks { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; width: 100%; }
.pen-pick {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 0 3px; border-radius: 9px; background: var(--surface-2);
  border: 1px solid var(--line-soft); color: var(--text-2); overflow: hidden;
  transition: border-color .16s, background .16s, transform .16s, color .16s;
}
.pen-pick:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); }
.pen-pick:active { transform: translateY(0) scale(.97); }
.pen-pick-g {
  font-family: pencontrol; font-size: 20px; line-height: 1;
  -webkit-text-stroke: 0.06mm currentColor; /* 线条本身太细，屏幕上会消失 */
}
.pen-pick-n { font-size: 9.5px; transform: scale(.92); white-space: nowrap; }
@media screen and (max-width: 420px) { .pen-picks { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* ---------------- 首页 ---------------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl);
  padding: 46px 40px; margin-bottom: 22px;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 16%, var(--surface)) 0%, var(--surface) 55%);
  border: 1px solid var(--line-soft); box-shadow: var(--shadow);
}
.hero::after {
  content: ''; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px;
  border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent 68%);
  filter: blur(6px);
}
.hero h1 { margin: 0 0 12px; font-size: 34px; line-height: 1.25; letter-spacing: -.5px; }
/* 说明页那种「一句话 + 几条规则」的抬头：比首页矮一档 */
.hero-slim { padding: 34px 32px; }
.hero-slim h1 { font-size: 27px; }
.hero h1 em { font-style: normal; background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0 0 24px; color: var(--text-2); max-width: 620px; font-size: 15px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.hero-tags span { font-size: 12px; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--line-soft); padding: 4px 10px; border-radius: 999px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile {
  text-align: left;
  padding: 20px; border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--line-soft); box-shadow: var(--shadow-sm);
  display: block; transition: transform .2s, box-shadow .2s, border-color .2s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.tile-ico {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  font-size: 19px; margin-bottom: 12px;
  background: var(--accent-soft); color: var(--accent);
}
.tile h4 { margin: 0 0 6px; font-size: 15px; }
.tile p { margin: 0; font-size: 12.5px; color: var(--text-3); }

/* ---- 首页功能卡：比说明页的卡片大一档，顶上带一张缩略图 ---- */
.cards.feat { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.tile.feat {
  padding: 0; overflow: hidden; display: flex; flex-direction: column;
}
.tile.feat:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
.tile.feat .tile-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.tile.feat .tile-hd { display: flex; align-items: center; gap: 10px; }
.tile.feat .tile-ico {
  width: 32px; height: 32px; border-radius: 11px; margin: 0; flex: 0 0 auto; font-size: 16px;
}
.tile.feat h4 { margin: 0; font-size: 16px; letter-spacing: .2px; }
.tile.feat p { font-size: 13px; line-height: 1.65; }
.tile-go { margin-left: auto; color: var(--text-3); font-size: 15px; transition: transform .2s, color .2s; }
.tile.feat:hover .tile-go { color: var(--accent); transform: translateX(3px); }

/* ---- 卡片上的缩略图：一张按真实比例画的迷你字帖 ----
   纸画到画布外面一点，底部被裁掉 —— 暗示「底下还有一整页」。 */
.thumb {
  height: 200px; overflow: hidden; padding: 0; margin: 0 auto;
  /* background: radial-gradient(120% 130% at 18% 0%, color-mix(in srgb, var(--accent) 12%, var(--surface-2)) 0%, var(--surface-2) 62%); */
  border-bottom: 1px solid var(--line-soft);
}
.thumb svg { display: block; width: 100%; height: 100%; }
/* 暗色下纸本身还是纸，但别把屏幕照得刺眼 */
html.dark .thumb svg { filter: brightness(.93); }
.th-title { font-size: 9px; font-weight: 600; fill: #2b3340; letter-spacing: .6px; }
.th-glyph { font-family: '楷体', 'KaiTi', serif; font-size: 22px; }
.th-glyph.en { font-family: '拼音体', serif; font-size: 18px; }
.th-glyph.en.small { font-size: 13px; }
.th-glyph.small { font-size: 12px; }
.th-glyph.head { fill: #2b3340; }
.th-glyph.trace { fill: #eaa6a6; }
.th-math { font-size: 11px; fill: #55606f; letter-spacing: .5px; }
/* 控笔缩略图：字体的线条是细长矩形，缩到卡片上会细得看不见，
   补一道同色描边当「加粗」，跟纸上那 0.07mm 的 stroke 是一个意思 */
.th-pen { font-family: pencontrol; font-size: 34px; fill: #96b4d7; stroke: #96b4d7; stroke-width: 1.1; }

/* ---------------- A4 预览 ---------------- */
.preview { padding: 0; }
.preview-hd {
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
  position: sticky; top: 60px; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px); border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.preview-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.preview-body {
  padding: 26px 20px 40px;
  background:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg-soft);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  min-height: 520px;
}
.empty { text-align: center; color: var(--text-3); padding: 90px 20px; }

.empty-ico { font-size: 40px; margin-bottom: 12px; opacity: .7; }
/* 纸张缩放：--sheet-zoom 由 index.js 量完「210mm = 多少 px」再按视口反算。
   桌面够宽时算出来是 1（不缩），768 这类平板宽度会自动收到 0.9 左右，
   360/414 的手机宽度刚好一张纸铺满。只作用于屏幕 —— 打印必须是 1:1。 */
@media screen { .sheet { zoom: var(--sheet-zoom, 1); } }

/* A4 纸张 */
.sheet {
  /* 高度锁死 297mm：预览与打印用同一套尺寸，才不会「屏幕看着对、纸上差一截」 */
  width: 210mm; height: 297mm; overflow: hidden; background: #fff; color: #111;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .12), 0 24px 50px rgba(16, 24, 40, .12);
  border-radius: 4px; padding: 10mm 13mm 8mm;
  display: flex; flex-direction: column; position: relative;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.sheet-hd { height: 13mm; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sheet-title {
  font-size: 17px; font-weight: 600; color: #2b3340; letter-spacing: 1px;
  padding: 0 12px 3px; border-bottom: 2px solid currentColor;
}
.sheet-bd { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.sheet-ft {
  /* 14mm 而不是 8mm：姓名那行离格区太近，孩子没地方落笔。
     高度加上去的是「格区到横线之间的空白」，横线仍贴着纸底 8mm 的位置。 */
  position: relative; height: 14mm; flex: 0 0 auto;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 10px; color: #98a2b3; letter-spacing: .5px;
}
/* 页脚那几栏：姓名 / 班级 / 日期，横线上给孩子填。
   没开页脚时页码还是居中（跟以前一样），开了就压到右边，别跟姓名挤 */
.foot-fields { display: flex; gap: 7mm; color: #56637a; font-size: 11px; }
.foot-fields i { display: inline-block; width: 22mm; border-bottom: 1px solid #c6cfdc; height: 3.2mm; }
/* 全局设置里填了姓名 / 开了自动日期，就直接印字；字比横线长的时候别把后一栏挤跑 */
.foot-fields b { font-weight: 500; color: #3b4658; border-bottom: 1px solid #dbe2ec; padding: 0 2mm; max-width: 46mm; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.foot-page { position: absolute; right: 0; bottom: 0; }

/* 订正格：每页尾巴上一行「改错」区。
   左边一个标签，右边两条横线，孩子把写错的字抄一遍。
   高度由 gen* 从版心里扣出来（doc.fixH），所以整页照样是满的；
   上内边距当它跟格区之间的空隙，不另加 margin —— 加了就溢出版心。 */
.fix-row {
  width: 100%; flex: 0 0 auto;
  display: flex; align-items: center; gap: 3mm;
  border: 1px solid var(--cell-line, #3898db); border-radius: 1mm;
  padding: 2.6mm 2mm 1.4mm; color: var(--cell-line, #3898db);
}
.fix-tag { font-size: 10px; letter-spacing: 1px; flex: 0 0 auto; color: #6b7688; }
.fix-row i { flex: 1 1 0; border-bottom: 1px dashed color-mix(in srgb, currentColor 45%, #fff); height: 60%; }

/* ---------------- 格子 ---------------- */
.grid-cn {
  display: grid; border-top: 1px solid currentColor; border-left: 1px solid currentColor;
  color: var(--cell-line, #3898db);
}
.cell-cn {
  position: relative; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor;
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff;
}
.cell-py {
  height: 7.4mm; border-bottom: 1px dashed color-mix(in srgb, currentColor 55%, #fff);
  display: grid; place-items: center; position: relative;
}
.cell-py span { font-family: '拼音体', serif; font-size: 16px; line-height: 1; color: #444; letter-spacing: .5px; }
/* 拼音行样式四档。作业本上见过的就这几种，格子本身不动，只换那条线的画法：
   grid 虚线格（默认，整行一条虚线当底）；under 下划线（离字远一点）；
   paren 小括号（左右各一撇，一音节一组）；box 长方格（左右各一条竖线）。 */
.cell-py.py-under { border-bottom-style: solid; border-bottom-color: color-mix(in srgb, currentColor 60%, #fff); }
.cell-py.py-paren { border-bottom: 0; }
.cell-py.py-paren::before, .cell-py.py-paren::after {
  content: ''; position: absolute; top: 18%; bottom: 18%; width: 2.4mm;
  border: 1px solid color-mix(in srgb, currentColor 40%, #fff);
}
.cell-py.py-paren::before { left: 1.6mm; border-right: 0; border-radius: 1.4mm 0 0 1.4mm; }
.cell-py.py-paren::after { right: 1.6mm; border-left: 0; border-radius: 0 1.4mm 1.4mm 0; }
.cell-py.py-box { border-bottom: 0; }
/* 长方格的内框上下各留 1mm，不然内框上下边跟格子本来的边框叠成一条粗线 */
.cell-py.py-box::before {
  content: ''; position: absolute; left: 1.2mm; right: 1.2mm; top: 1mm; bottom: 1mm;
  border: 1px solid color-mix(in srgb, currentColor 34%, #fff); border-radius: .6mm;
}
.cell-ch { position: relative; flex: 1 1 auto; }
.cell-guide { position: absolute; inset: 0; pointer-events: none; }
/* 田字格：十字虚线；米字格再加对角线；回宫格加内框。
   对角线用 background 的 linear-gradient 画，比旋转伪元素稳 —— 
   旋转的元素宽度是盒子对角线以外的长度，45° 一转就短一截。
   伪元素一律先写 content:''，否则不生成盒子，格子里的十字线全不见。 */
.cell-guide::before, .cell-guide::after { content: ''; position: absolute; }
.cell-guide.tian::before { left: 50%; top: 0; bottom: 0; border-left: 1px dashed color-mix(in srgb, currentColor 55%, #fff); }
.cell-guide.tian::after { top: 50%; left: 0; right: 0; border-top: 1px dashed color-mix(in srgb, currentColor 55%, #fff); }
.cell-guide.mi { background-image:
    linear-gradient(to bottom right, transparent calc(50% - 0.4px), color-mix(in srgb, currentColor 42%, #fff) 50%, transparent calc(50% + 0.4px)),
    linear-gradient(to top right, transparent calc(50% - 0.4px), color-mix(in srgb, currentColor 42%, #fff) 50%, transparent calc(50% + 0.4px)); }
.cell-guide.mi::before { left: 50%; top: 0; bottom: 0; border-left: 1px dashed color-mix(in srgb, currentColor 55%, #fff); }
.cell-guide.mi::after { top: 50%; left: 0; right: 0; border-top: 1px dashed color-mix(in srgb, currentColor 55%, #fff); }
.cell-guide.hui { border: 1px dashed color-mix(in srgb, currentColor 55%, #fff); inset: 6%; }
.cell-guide.hui::before { left: 50%; top: 0; bottom: 0; border-left: 1px dashed color-mix(in srgb, currentColor 40%, #fff); }
.cell-guide.hui::after { top: 50%; left: 0; right: 0; border-top: 1px dashed color-mix(in srgb, currentColor 40%, #fff); }

/* 交叉格：只有对角线，没有十字 —— 「米」里那两笔斜的才看得出撇捺的走向 */
.cell-guide.cross { background-image:
    linear-gradient(to bottom right, transparent calc(50% - 0.4px), color-mix(in srgb, currentColor 42%, #fff) 50%, transparent calc(50% + 0.4px)),
    linear-gradient(to top right, transparent calc(50% - 0.4px), color-mix(in srgb, currentColor 42%, #fff) 50%, transparent calc(50% + 0.4px)); }

/* 笔顺条的字头行：整字 + 拼音 + 一溜笔顺小图，跨整行（grid-column: 1 / -1）。
   它自己不画格线，只压在上下两条横线中间 —— 跟下面那排描红格分开就行。 */
.cell-cn.headbar {
  grid-column: 1 / -1;
  flex-direction: row; align-items: center; gap: 1.6mm;
  padding: 1mm 2mm; overflow: hidden;
}
.hb-head { display: flex; align-items: center; gap: 1.2mm; flex: 0 0 auto; }
/* 字和笔顺小图都得 relative：ZGlyph 内部是 absolute inset 定位，
   最近的有定位的祖先是 .cell-cn，不加这一层，小图会撑到整行上去 */
.hb-ch { position: relative; display: block; flex: 0 0 auto; }
.hb-py {
  font-family: '拼音体', serif; font-size: 15px; line-height: 1;
  color: #444; letter-spacing: .5px; white-space: nowrap;
}
/* 笔顺小图：能排一行就一行，排不下让它自己换行（一页宽也就 12~13 格） */
.hb-strokes { display: flex; flex-wrap: wrap; align-items: center; gap: .4mm; flex: 1 1 auto; min-width: 0; }
.hb-stroke { position: relative; display: block; flex: 0 0 auto; }

/* 方格：一个字一块，什么都不画 —— 练结构的时候线越少越好 */
.cell-guide.fang { display: none; }

/* 九宫格：三条线切九块，四笔都用 background 画，
   不用伪元素（只有两个，不够用） */
.cell-guide.jiu { background-image:
    linear-gradient(to right, transparent calc(33.333% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(33.333% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(33.333% + .45px), transparent calc(33.333% + .45px)),
    linear-gradient(to right, transparent calc(66.666% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(66.666% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(66.666% + .45px), transparent calc(66.666% + .45px)),
    linear-gradient(to bottom, transparent calc(33.333% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(33.333% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(33.333% + .45px), transparent calc(33.333% + .45px)),
    linear-gradient(to bottom, transparent calc(66.666% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(66.666% - .45px), color-mix(in srgb, currentColor 38%, #fff) calc(66.666% + .45px), transparent calc(66.666% + .45px)); }

/* 双横线：抄写本那种横线页 —— 每行上下两条实线，中间一条虚的中线当基线参考。
   竖线全去掉，格间距也归零；一排字横着连着写下去才是横线本的样子 */
.grid-cn.guide-shuang { border-left: 0; }
.grid-cn.guide-shuang .cell-cn { border-right: 0; }
.cell-guide.shuang::after { top: 50%; left: 0; right: 0; border-top: 1px dashed color-mix(in srgb, currentColor 40%, #fff); }

/* 无格：一片白纸，只剩字 */
.grid-cn.guide-wu, .grid-cn.guide-wu .cell-cn { border: 0; }

/* 笔画轮廓的 viewBox 已经自带留白，容器再内缩 1.1mm 让它不顶格；
   字体整字不用缩 —— 字号是按墨迹量到格子的 94% 算的，再内缩就瘦一圈。 */
.glyph { position: absolute; inset: 1.1mm; display: grid; place-items: center; }
.glyph.text { inset: 0; }
.glyph svg { width: 100%; height: 100%; display: block; }
.glyph-text { font-size: 11mm; line-height: 1; }

/* 四线三格（英文） */
.grid-en { display: grid; border-top: 1px solid currentColor; border-left: 1px solid currentColor; color: var(--cell-line, #3898db); }
.cell-en { position: relative; height: 9mm; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; background: #fff; }
/* 两条内线的位置由组件按字体度量给（top: %），不写死在这里 */
.cell-en .rule { position: absolute; left: 0; right: 0; border-top: 1px dashed color-mix(in srgb, currentColor 45%, #fff); }
/* 字走 SVG：viewBox 用 mm 建，基线就精确落在第三条线上，字号也随度量走。
   overflow 收一下，万一某个字形伸出格也不至于糊到隔壁格。 */
.cell-en .word { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }

/* 控笔练习：格子里就是字体字形，不需要田字格线。
   格线跟田字格一样画：外框由容器出上/左边，格子出下/右边，
   相邻两格共用一条线，不会叠成双倍粗。有行间距时改成每格四边都有框。 */
.grid-pen {
  display: grid;
  border-top: 1px solid var(--cell-line, #3898db);
  border-left: 1px solid var(--cell-line, #3898db);
}
.grid-pen.gapped { border-top: 0; border-left: 0; }
.cell-pen {
  /* 边框走格线色，字形颜色由行内 color 决定 —— 两者不能共用一个 currentColor，
     否则描红色的格子连框都跟着变红 */
  position: relative;
  border-right: 1px solid var(--cell-line);
  border-bottom: 1px solid var(--cell-line);
  display: grid; place-items: center; overflow: hidden; background: #fff;
  font-family: pencontrol; line-height: 1;
  /* 这个字体的线条是「细长矩形」，横线只有 0.9% em 高，
     12mm 的格子算下来不到 0.02mm —— 屏幕上直接消失，纸上也会被打印机吃掉。
     补 0.07mm 描边，落在纸面上约一根细线粗，正好适合描。 */
  -webkit-text-stroke: 0.07mm currentColor;
}
.grid-pen.gapped .cell-pen { border-left: 1px solid var(--cell-line); border-top: 1px solid var(--cell-line); }
.cell-pen span { display: block; }

/* 数学题 */
.math-wrap { display: flex; flex-wrap: wrap; width: 100%; padding: 0 2mm; }
.math-item {
  width: 33.333%; height: 12.4mm; display: flex; align-items: center; gap: 6px;
  font-size: 19px; color: #1f2733; padding-left: 4mm; white-space: nowrap;
}
.math-item.half { width: 50%; }
.math-item .blank { min-width: 14mm; border-bottom: 1px solid #9aa5b8; height: 8mm; display: inline-block; }
.math-item .bracket { color: #5a6679; }
.math-item .op { margin: 0 3px; color: #4a5568; }

/* ---------------- 打印 ---------------- */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  .topbar, .side, .preview-hd, .no-print, .hero, .empty { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .split { display: block; }
  .card { border: 0; box-shadow: none; border-radius: 0; }
  .preview-body { padding: 0; background: none; gap: 0; display: block; min-height: 0; }
  /* 手机上可能正停在「设置」Tab，打印得照样出纸（.side 仍隐藏） */
  .split > .preview { display: block !important; }
  .mbar { display: none !important; }
  .sheet { zoom: 1 !important; }
  .sheet {
    width: 210mm; height: 297mm; box-shadow: none; border-radius: 0;
    margin: 0; page-break-after: always; break-after: page; overflow: hidden;
  }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
  .cell-cn, .cell-en, .cell-pen, .glyph, .math-item { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* 移动端：只作用于屏幕。若不加 screen，打印预览的宽度也算窄屏，
   页面会被 zoom 缩到 46%，打出来只有半页大。

   这一块分三件事：
   1. 适配层 —— 手指按得准（触控目标 ≥44px）、iOS 聚焦不抬页（输入 16px）、
      刘海机不贴边（env(safe-area-inset-*)）、纸张按屏宽铺满。
   2. 设置 / 预览 双 Tab —— .split 的两栏在手机上轮流显示，底部固定一条操作栏，
      改参数和看纸不用来回滑（见 ui.js 的 ZMbar）。
   3. 多行选项横滑 —— 选项多的控件带 .opt-many，不折成几行，横着滑。 */
@media screen and (max-width: 760px) {
  /* 手机上一屏就那么大，桌面那套留白全部收一档：
     边距 12→10、卡片内边距 16/18→11/12、区块间距 16→10。
     触控目标也从 44 收到 36~38 —— 仍然好按，但一屏能多看两行设置。 */
  .wrap { padding: 10px 10px calc(66px + env(safe-area-inset-bottom)); }
  /* 手机上首页抬头只留标题 + 三个按钮：那段「纯前端生成 A4 字帖…」
     两行变六行，一屏就被它吃掉，用户是来找入口的，不是来读介绍的。 */
  .hero { padding: 16px 14px; margin-bottom: 10px; border-radius: var(--r); }
  .hero h1 { font-size: 21px; margin-bottom: 10px; display: none; }
  /* 只砍首页那段介绍，说明页的 hero-slim 里那句话是有用的 */
  .hero:not(.hero-slim) p { display: none; }
  .hero-tags { margin-top: 12px; }
  .hero-slim { padding: 18px 16px; }
  .hero-slim h1 { font-size: 19px; }
  .tile { padding: 13px 14px; border-radius: var(--r); }
  .tile-ico { width: 32px; height: 32px; border-radius: 10px; font-size: 16px; margin-bottom: 8px; }
  .tile.feat .tile-ico { width: 28px; height: 28px; font-size: 14px; }
  .tile h4 { font-size: 14px; }
  .tile p { font-size: 12px; line-height: 1.55; }
  .empty { padding: 50px 16px; }
  .hero-actions { gap: 8px; }
  .hero-tags { margin-top: 14px; gap: 6px; display: none; }
  .hero-tags span { padding: 3px 8px; font-size: 11px; }
  .preview-body { padding: 10px 6px 18px; gap: 14px; min-height: 0; }
  .preview-hd { padding: 9px 12px; }
  .card { border-radius: var(--r); }
  .card + .card { margin-top: 10px; }
  .card-hd { padding: 9px 12px; }
  .card-hd h3 { font-size: 13px; }
  .card-bd { padding: 11px 12px; }
  .card-bd + .card-bd { padding-top: 10px; }
  .field { grid-template-columns: 52px minmax(0, 1fr); gap: 8px; }
  .field + .field { margin-top: 9px; }
  .field > label { font-size: 12px; padding-top: 8px; }
  .field-body { gap: 6px; }
  /* 首页功能卡在手机上排两列：八张卡一列铺下来要滑四五屏，
     两列一屏半就能看全，缩略图里那点字样也还认得出是哪种字帖。 */
  .cards.feat { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile.feat .tile-body { padding: 9px 10px 11px; gap: 4px; }
  .tile.feat .tile-hd { gap: 7px; }
  .tile.feat .tile-ico { width: 22px; height: 22px; border-radius: 8px; font-size: 12px; }
  .tile.feat h4 { font-size: 13px; }
  .tile.feat p { font-size: 11.5px; line-height: 1.45; }
  .tile-go { font-size: 13px; }
  /* 两列时卡片只有一百多像素宽，固定 150 高就成了竖长框，
     slice 会把左右两列格子裁掉 —— 直接按画布比例定高，图完整不出血。 */
  .thumb { height: auto; aspect-ratio: 8 / 5; }
  .hint { font-size: 11.5px; line-height: 1.5; }

  /* 顶栏两行：品牌 + 图标按钮占一行，导航独占一行。
     一行硬塞下去 nav 会被挤成一条缝（390px 宽里 brand 要 130、四个按钮要 190），
     8 个入口只剩几十像素，等于全藏了。 */
  .topbar-in {
    height: auto; flex-wrap: wrap; gap: 4px 6px; padding: 4px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .nav { order: 3; flex: 1 0 100%; gap: 2px; padding-bottom: 1px; }
  .nav-item { padding: 5px 9px; font-size: 13px; }
  .topbar-right { margin-left: auto; gap: 3px; }
  .brand { padding: 2px 6px 2px 2px; gap: 8px; }
  .brand-logo { width: 28px; height: 28px; font-size: 15px; border-radius: 9px; }
  .brand-name { font-size: 15px; }
  .brand-sub { display: none; }
  .btn-collection { padding: 5px 8px; font-size: 12px; }
  .btn-collection .col-ico { font-size: 15px; }
  /* 320 宽（iPhone SE 一代）品牌 + 四个按钮刚好塞不下，收一档尺寸挤回一行，
     别让顶栏占掉三行 */
  @media screen and (max-width: 360px) {
    .brand-logo { width: 26px; height: 26px; font-size: 14px; }
    .brand-name { font-size: 14px; }
    .topbar-in { gap: 3px 4px; padding: 3px 8px; }
    .topbar-right { gap: 2px; }
    .icon-btn { width: 34px; height: 34px; font-size: 13px; }
    .btn-collection { padding: 4px 6px; }
  }

  /* 导航 8 个入口本来就滑不完，右边渐隐一下，暗示「后面还有」 */
  .nav {
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
  }
  .nav-item { scroll-snap-align: center; }

  /* 触控目标：桌面那档 33px 太矮，但 44 也铺张 —— 36~38 之间好按、也省地方 */
  .seg { padding: 2px; border-radius: 10px; }
  .seg button { min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 8px; }
  .chip { min-height: 34px; padding: 4px 10px; font-size: 13px; }
  .chip.font-chip { min-height: 36px; padding: 2px 10px; font-size: 13px; }
  .icon-btn { width: 36px; height: 36px; border-radius: 9px; font-size: 14px; }
  .btn { min-height: 34px; padding: 6px 8px; border-radius: 10px; font-size: 13px; }
  .btn-sm { min-height: 32px; padding: 5px 10px; }
  .fix-item { padding: 2px 4px; border-radius: 8px; }
  .fix-input { min-height: 30px; }
  .pen-pick { min-height: 38px; }
  .pen-pick-g { font-size: 17px; }
  .input { padding: 7px 10px; border-radius: 9px; }
  textarea.input { min-height: 68px; line-height: 1.7; }
  /* 输入框不到 16px，iOS Safari 聚焦就整页放大且退不回来 */
  .input, textarea.input, .fix-input, .num .input { font-size: 16px; }
  .fix-input { width: 78px; font-size: 15px; }
  .num .input { width: 66px; }

  /* 双 Tab：默认只看设置，点「预览」才看纸。桌面端两条规则不生效 */
  html[data-mpane="form"] .split > .preview,
  html[data-mpane="preview"] .split > .side { display: none; }
  /* 预览头在手机上不吸顶（顶栏已经两行了），操作按钮也交给底部栏 —— 别重复两套 */
  .preview-hd { position: static; }
  .preview-hd .row-between { display: none; }

  /* 选项多到一行放不下，就横着滑，别折成三行把设置区拉长。
     右边一道渐隐当「后面还有」的暗示，否则看着像被切掉。 */
  .opt-many {
    max-width: 100%; width: 100%; flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }
  /* 末项后留出跟渐隐一样宽的空位：滑到最右时最后一个选项正好落在遮罩外，
     不至于永远「看着像被切了半截」 */
  .opt-many::after { content: ''; flex: 0 0 26px; }
  .opt-many::-webkit-scrollbar { display: none; }
  .opt-many > * { flex: 0 0 auto; scroll-snap-align: start; }
}

/* ---------------- 手机底部操作栏 ----------------
   只在窄屏出现：左边切「设置 / 预览」，右边常驻打印。
   打印入口不再被长表单埋在最底下。 */
.mbar { display: none; }
@media screen and (max-width: 760px) {
  .mbar {
    display: flex; align-items: center; gap: 7px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    padding: 5px 10px calc(5px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); border-top: 1px solid var(--line-soft);
    box-shadow: 0 -6px 20px rgba(20, 32, 52, .08);
  }
  .mbar-tabs {
    display: flex; gap: 2px; padding: 2px;
    background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px;
  }
  .mbar-tab {
    min-height: 36px; padding: 6px 11px; border-radius: 8px;
    font-size: 13px; color: var(--text-2); white-space: nowrap;
    display: inline-flex; align-items: center; gap: 4px;
  }
  .mbar-tab.on { background: var(--surface); color: var(--accent); font-weight: 650; box-shadow: var(--shadow-sm); }
  html.dark .mbar-tab.on { background: var(--accent-soft); }
  .mbar-n { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
  /* 底部栏只有一行预算（360 宽约 336px），三个按钮谁都不许换行 */
  .mbar .btn { white-space: nowrap; padding: 0 12px; min-height: 36px; }
  .mbar .btn-primary { flex: 1 1 auto; padding: 0 10px; }
  .mbar-print-short { display: none; }
  /* 太窄时打印按钮退成「打印」，省下 60px 给左边三个 */
  @media screen and (max-width: 380px) {
    .mbar-print-long { display: none; }
    .mbar-print-short { display: inline; }
    .mbar-tab { padding: 6px 9px; font-size: 12px; }
    .mbar-gen { padding: 0 9px !important; }
  }
}

/* ---------------- 轻提示 ---------------- */
.toasts {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg);
  box-shadow: var(--shadow-lg); animation: toast-in .22s ease-out;
}
.toast.warn { background: var(--warn); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 数学页顶栏跟随、侧栏滚动时别被挡住 */
.side .card:first-child { position: relative; z-index: 1; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; border: 1px solid var(--line-soft); }

/* ---------------- 素材合集 ----------------
   顶栏右边一个入口，弹窗里按年级分页签。整个弹窗只有一个滚动区
   （列表区自己滚），页头页脚的按钮永远在手边。 */
.btn-collection { padding: 7px 14px; border-radius: 11px; font-size: 13px; font-weight: 600; white-space: nowrap; }

.modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, #0b1020 42%, transparent);
  backdrop-filter: blur(3px);
  animation: modal-fade .16s ease-out;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  /* 素材弹窗要摊开一册课文的所有字块，窄了根本排不开 —— 给到 1120px、88vh */
  width: min(1120px, 100%); max-height: min(88vh, 940px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modal-pop .2s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes modal-pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-hd {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 20px 12px;
}
.modal-title { font-size: 17px; font-weight: 650; }
/* 页头 / 页签 / 页脚都不许被列表挤扁：.modal-body 是 flex:1 的滚动区，
   这三块一旦可收缩，长列表会把页签压成一条 12px 的缝。 */
.modal-hd, .modal-tabs, .modal-ft { flex: 0 0 auto; }
.modal-tabs {
  display: flex; gap: 4px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line-soft);
}
.modal-tabs::-webkit-scrollbar { display: none; }
.modal-tab {
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  font-size: 13px; color: var(--text-2);
}
.modal-tab:hover { background: var(--surface-2); color: var(--text); }
.modal-tab.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.modal-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 20px; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  align-content: start;
}
.col-item {
  /* min-width:0 不能省：卡片里的单行预览是 nowrap 的，
     grid 项默认 min-width:auto 会被这行字撑破容器，手机上横向溢出 */
  min-width: 0; text-align: left; padding: 12px 14px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.col-item:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.col-item-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col-item-hd b { font-size: 14px; }
.col-tag {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-soft); color: var(--text-3);
}
.col-item-desc { font-size: 12px; color: var(--text-3); line-height: 1.55; margin-top: 3px; }
/* 预览用汉字间距拉开 —— 生字表挤成一坨看不清是哪些字 */
.col-item-text {
  margin-top: 8px; font-size: 13px; line-height: 1.9; color: var(--text-2);
  letter-spacing: 1.5px; font-family: '楷体', 'KaiTi', 'STKaiti', serif;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 方格视图：正文摊成一个个紧凑小方格，点一下高亮、再点取消。
   字间距靠 gap 撑，不用 letter-spacing —— 那样点选区域会歪。 */
.grid-view { display: block; }
/* 年级页：课文平铺 + 素材卡片，两段各占一整行，所以不用 grid 而是一列往下排 */
.list-view { display: block; }
.col-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.sec-title {
  margin: 18px 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-3); text-transform: uppercase;
}

/* 上册 / 下册切换：一个年级一页，册换了但字块不出页面 */
.bk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.bk-chip {
  display: flex; align-items: baseline; gap: 8px; padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.bk-chip:hover { border-color: var(--accent); color: var(--text); }
.bk-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.bk-num { font-size: 11px; font-weight: 400; color: var(--text-3); }
.bk-chip.on .bk-num { color: var(--accent); opacity: .8; }
.bk-picked { font-size: 12px; color: var(--accent); }

/* 整册课文平铺：一课一块，块里字块自动换行。
   用网格横向铺 —— 跟读课文一样从左往右扫；块各自高度不一，
   所以 align-items:start，让矮的块自己收着，别被同一行拉高。 */
.lesson-grid {
  display: grid; gap: 10px; align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.lesson-block {
  min-width: 0; padding: 8px 10px 9px;
  border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line-soft);
}
.lesson-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; margin-bottom: 6px; padding: 2px 4px; border-radius: 6px; text-align: left;
}
.lesson-hd:hover { background: var(--surface); }
.lesson-name {
  min-width: 0; font-size: 12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lesson-hd.on .lesson-name { color: var(--accent); font-weight: 600; }
.lesson-cnt { flex: 0 0 auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.lesson-hd.on .lesson-cnt { color: var(--accent); }

.gx-back {
  display: block; margin-bottom: 10px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; color: var(--text-3); background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.gx-back:hover { color: var(--text); border-color: var(--line); }
.gx-line { display: flex; flex-wrap: wrap; gap: 4px; }
.gx-cell {
  /* 定宽定高才排得整齐：楷体各字宽不一样，flex 一撑就参差 */
  width: 30px; height: 30px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-family: '楷体', 'KaiTi', 'STKaiti', serif; font-size: 19px; line-height: 1;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: 6px;
  transition: background .12s, border-color .12s, color .12s;
}
.gx-cell:hover { border-color: var(--accent); }
.gx-cell.on {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.modal-ft {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2);
}
@media screen and (max-width: 620px) {
  .modal { padding: 0; }
  .modal-panel { width: 100%; max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; align-self: end; }
  .modal-body { grid-template-columns: 1fr; }
  /* 手机上顶栏挤，入口退成图标按钮；按钮文字和页脚那行说明都先让位 */
  .btn-collection { padding: 7px 10px; }
  .col-txt, .modal-ft .hint { display: none; }
  .modal-ft { justify-content: flex-end; }
  /* 手机上弹窗的页头页脚也收一档，把高度让给列表 */
  .modal-hd { padding: 12px 14px 8px; gap: 10px; }
  .modal-title { font-size: 15px; }
  .modal-tabs { padding: 0 10px 6px; gap: 3px; }
  .modal-tab { padding: 5px 11px; font-size: 12.5px; }
  .modal-body { padding: 10px 12px; gap: 8px; }
  .modal-ft { padding: 9px 12px; }
  .col-item { padding: 9px 11px; }
  .col-item-hd b { font-size: 13px; }
  .col-item-desc { font-size: 11.5px; }
  .col-item-text { margin-top: 5px; font-size: 12.5px; line-height: 1.7; }
  .lesson-grid, .col-grid { gap: 8px; }
  .lesson-block { padding: 6px 8px 7px; }
  .bk-bar { gap: 6px; margin-bottom: 9px; }
  .bk-chip { padding: 5px 11px; font-size: 13px; }
  .sec-title { margin: 12px 0 7px; }
  .gx-line { gap: 3px; }
  .gx-cell { width: 27px; height: 27px; font-size: 17px; }
  /* 手机上一栏到底，别硬凑多栏 */
  .lesson-grid { grid-template-columns: 1fr; }
  .col-grid { grid-template-columns: 1fr; }
}

/* ---------------- 设置弹窗 ----------------
   顶栏齿轮进来的那个：一边列「哪些页面在存配置」，一边是导出/导入/恢复。
   内容比素材合集少得多，所以面板窄一点、不滚动。 */
.set-panel { width: min(520px, 100%); }
.set-body { display: block; overflow: visible; }
.set-list { display: grid; gap: 6px; margin-bottom: 12px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line-soft); font-size: 13px;
}
.set-row .hint { font-size: 12px; }
/* 设置弹窗分两段：上面是跨页共用的全局项，下面是各页参数的清单 */
.set-group-t {
  font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .6px;
  margin: 0 0 6px 2px;
}
.set-form { display: grid; gap: 6px; margin-bottom: 8px; }
.set-input { width: 132px; text-align: left; padding: 6px 10px; font-size: 13px; }
/* 开关：一个圆角槽 + 一颗会走的圆点，比原生 checkbox 在这排里好看点 */
.switch {
  width: 42px; height: 24px; flex: 0 0 auto; border-radius: 999px; padding: 2px;
  background: var(--line-soft); border: 1px solid var(--line-soft);
  display: flex; align-items: center; transition: background .16s, border-color .16s;
}
.switch i {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .24);
  transform: translateX(0); transition: transform .18s cubic-bezier(.3, .8, .4, 1);
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on i { transform: translateX(18px); }
