/* 笔顺小字典 H5 · 样式与小程序端 WXSS 保持一致（rpx ÷ 2 = px） */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #1F2933;
  --primary: #B4432B;
  --primary-weak: #FBEDE9;
  --muted: #8A8378;
  --faint: #A39C90;
  --line: #EDE7DC;
  --line-soft: #F4F0E8;
  --bg: #FAF7F0;
  --card: #FFFFFF;
  --chip: #F6F2EA;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; }
input { font-family: inherit; }

/* ---------- 设备外壳 ---------- */
.device {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 56px;
  padding: 40px;
  background: linear-gradient(150deg, #F3EDE2 0%, #FAF7F0 45%, #F6EFE4 100%);
}

.device-frame {
  position: relative;
  /* 含 10px 边框后，内部内容区正好 375 × 812，与小程序的 750rpx 视口一致 */
  width: 395px;
  height: 832px;
  background: var(--bg);
  border-radius: 40px;
  border: 10px solid #1F2933;
  box-shadow: 0 24px 60px rgba(31, 41, 51, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: top left;
}

.side { max-width: 330px; }
.side-title { font-size: 30px; font-weight: 700; letter-spacing: 3px; }
.side-sub { color: var(--primary); font-size: 14px; margin-top: 6px; letter-spacing: 1px; }
.side-text { color: #5C564D; font-size: 14px; line-height: 1.9; margin: 18px 0 0; }
.side-list { color: #5C564D; font-size: 14px; line-height: 2; margin: 14px 0 0; padding-left: 18px; }
.side-links { margin-top: 22px; font-size: 13px; color: #B7B0A4; }
.side-links a { color: var(--primary); text-decoration: none; }
.side-links span { margin: 0 6px; }

@media (max-width: 900px) {
  .side { display: none; }
  .device { padding: 0; gap: 0; display: block; background: var(--bg); }
}

@media (max-width: 479px) {
  .device-frame {
    border: none;
    border-radius: 0;
    width: 375px;
    height: 100vh;
    box-shadow: none;
  }
}

/* ---------- 导航栏 ---------- */
.navbar {
  flex: 0 0 auto;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
}

.nav-title { font-size: 17px; font-weight: 600; }

.nav-back {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.page {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

/* ---------- 底部 tab ---------- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: #FFFFFF;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0 5px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tab img { width: 22px; height: 22px; display: block; }
.tab.on { color: var(--primary); }

/* ---------- 通用容器 ---------- */
.wrap { padding: 12px 14px 30px; }

.card {
  background: var(--card);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(31, 41, 51, 0.05);
  margin-bottom: 12px;
}

.card-tight { padding: 10px 12px; }

.title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.sub { font-size: 13px; color: var(--muted); }
.muted { font-size: 12px; color: var(--faint); }
.primary { color: var(--primary); }

.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 10px 0; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  text-align: center;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  line-height: 1.4;
}

.btn-ghost { background: #FFFFFF; color: var(--primary); border: 1px solid #E5C9C0; }
.btn-plain { background: #F1ECE2; color: var(--ink); }
.btn-block { display: block; width: 100%; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #F1ECE2;
  color: var(--muted);
  margin: 0 6px 4px 0;
}

.tag-primary { background: var(--primary-weak); color: var(--primary); }

.chip-wrap { display: flex; flex-wrap: wrap; }

.chip {
  padding: 5px 14px;
  background: var(--chip);
  border-radius: 999px;
  margin: 4px 8px 4px 0;
  font-size: 15px;
  color: var(--ink);
  border: none;
  cursor: pointer;
}

.chip-on { background: var(--primary-weak); color: var(--primary); }
.chip-sm { padding: 4px 12px; font-size: 13px; border-radius: 10px; }
.chip-tap { border: 1px solid var(--line); background: #FFFFFF; cursor: pointer; }

/* ---------- 字格 ---------- */
.grid-wrap { display: flex; flex-wrap: wrap; margin: 0 -4.5px; }
.grid-wrap-5 { display: flex; flex-wrap: wrap; margin: 0 -3.5px; }

.grid-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border-radius: 8px;
  border: 1px solid var(--line);
  height: 66px;
  font-size: 26px;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

.grid-wrap .grid-cell { width: calc(25% - 9px); margin: 4.5px; }
.grid-wrap-5 .grid-cell { width: calc(20% - 7px); margin: 3.5px; height: 58px; font-size: 23px; }

.grid-cell.active { border-color: var(--primary); color: var(--primary); }
.grid-cell .cell-char { font-size: 26px; line-height: 1.1; }
.grid-wrap-5 .grid-cell .cell-char { font-size: 23px; }
.grid-cell .cell-py {
  font-size: 10px;
  color: var(--faint);
  margin-top: 2px;
  max-width: 92%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.empty { text-align: center; color: var(--faint); font-size: 13px; padding: 40px 0; white-space: pre-line; line-height: 2; }

/* ---------- 首页 ---------- */
.hero { padding: 10px 2px 14px; }
.hero-title { font-size: 26px; font-weight: 700; letter-spacing: 2px; }
.hero-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.search {
  display: flex;
  align-items: center;
  background: #FFFFFF;
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
  box-shadow: 0 2px 10px rgba(31, 41, 51, 0.06);
}

.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  height: 32px;
  color: var(--ink);
  min-width: 0;
}

.search input::placeholder { color: #B7B0A4; }

.search-btn {
  background: var(--primary);
  color: #FFFFFF;
  font-size: 14px;
  padding: 7px 17px;
  border-radius: 999px;
  margin-left: 8px;
  border: none;
  cursor: pointer;
  flex: 0 0 auto;
}

.search-tip {
  margin: 8px 4px 0;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.6;
}

.notice {
  margin-top: 10px;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 7px;
}

.suggest {
  margin-top: 9px;
  background: #FFFFFF;
  border-radius: 8px;
  padding: 9px 11px 5px;
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.05);
}

.suggest-label {
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 3px;
}

.tools { display: flex; flex-wrap: wrap; margin: 12px -4px 2px; }

.tool {
  width: calc(50% - 8px);
  margin: 4px;
  background: #FFFFFF;
  border-radius: 9px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.04);
  border: none;
  cursor: pointer;
  text-align: left;
}

.tool-name { font-size: 15px; font-weight: 600; }
.tool-desc { font-size: 11px; color: var(--faint); margin-top: 3px; }

.foot { padding: 15px 4px 5px; }
.foot-text { font-size: 11px; color: #B7B0A4; text-align: center; line-height: 1.8; }

/* ---------- 详情 ---------- */
.head { display: flex; align-items: center; padding: 10px 4px 15px; }
.head-char { font-size: 66px; line-height: 1.1; font-weight: 600; margin-right: 16px; }
.head-info { flex: 1; min-width: 0; }
.head-py { font-size: 16px; color: var(--primary); margin-bottom: 6px; }
.head-tags { display: flex; flex-wrap: wrap; }

.player canvas {
  display: block;
  margin: 0 auto;
  width: 100%;
  background: #FFFFFF;
  border-radius: 6px;
}
.player-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.stroke-count { font-size: 13px; }
.stroke-speed { font-size: 12px; color: var(--faint); cursor: pointer; }
.player-ctrl { display: flex; margin-top: 9px; }

.ctrl-btn {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  margin: 0 4px;
  border-radius: 7px;
  background: var(--chip);
  color: var(--ink);
  font-size: 13px;
  border: none;
  cursor: pointer;
}

.ctrl-main { background: var(--primary); color: #FFFFFF; flex: 1.4; }
.player-opt { display: flex; margin-top: 9px; flex-wrap: wrap; }

.opt {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  margin: 0 8px 6px 0;
  border: none;
  cursor: pointer;
}

.opt-on { background: var(--primary-weak); color: var(--primary); }

.info-row { display: flex; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.info-row:last-child { border-bottom: none; }
.info-k { width: 70px; color: var(--faint); font-size: 13px; flex: 0 0 auto; }
.info-v { flex: 1; font-size: 14px; word-break: break-all; }

.actions { display: flex; margin-top: 5px; }
.actions .btn { margin: 0 4px; }
.actions-second { margin-top: 8px; }

/* ---------- 列表页 ---------- */
.result-title { font-size: 17px; font-weight: 600; }
.more-btn { margin-top: 12px; }

/* ---------- 生成页 ---------- */
.seg { display: flex; background: var(--chip); border-radius: 7px; padding: 3px; margin-top: 6px; }
.seg-sm { flex: 1; max-width: 160px; margin-top: 0; }
.seg-wrap { flex-wrap: wrap; max-width: 230px; }
.seg-wrap .seg-item { flex: 0 0 50%; }

.seg-item {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  font-size: 13px;
  color: var(--muted);
  border-radius: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.seg-on { background: #FFFFFF; color: var(--primary); font-weight: 600; }

.opt-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.opt-label { font-size: 14px; }

.preview-box {
  display: flex;
  justify-content: center;
  background: var(--chip);
  border-radius: 7px;
  padding: 10px;
  margin-top: 8px;
  overflow: hidden;
}

.sheet-canvas { background: #FFFFFF; box-shadow: 0 2px 10px rgba(31, 41, 51, 0.08); max-width: 100%; }

.page-nav { margin-top: 10px; }
.page-info { margin-top: 10px; text-align: center; }

/* 打印专用容器：平时隐藏，点「直接打印」时临时插入并只打印它 */
.print-area {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 210mm;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html, body {
    background: #FFFFFF !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 只保留打印容器里的内容 */
  body > * {
    display: none !important;
  }

  body .print-area {
    display: block !important;
    position: static !important;
    left: auto !important;
    width: 210mm !important;
  }

  .print-area img {
    display: block;
    width: 210mm;
    height: 297mm;
    page-break-after: always;
    break-after: page;
  }

  .print-area img:last-child {
    page-break-after: auto;
    break-after: auto;
  }
}

.tip {
  margin-top: 8px;
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-weak);
  padding: 7px 10px;
  border-radius: 6px;
  line-height: 1.7;
}

.act-row { display: flex; margin-top: 10px; }
.act-row .btn { margin: 0 4px; }
.tip-sub { margin-top: 9px; text-align: center; }

/* ---------- 关于 ---------- */
.lic-item { font-size: 13px; color: #5C564D; line-height: 1.8; margin-bottom: 4px; }

/* ---------- 生字本分类切换 ---------- */
.tabs {
  display: flex;
  background: #FFFFFF;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 12px;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 14px;
  color: var(--muted);
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.tab-on {
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 600;
}

/* ---------- 笔顺跟写 ---------- */
.train-head { display: flex; align-items: center; padding: 10px 4px 13px; }
.train-head .head-char { font-size: 60px; }
.train-progress { font-size: 14px; margin-top: 3px; }

.train-canvas {
  display: block;
  margin: 0 auto;
  width: 100%;
  background: #FFFFFF;
  border-radius: 6px;
  touch-action: none;
  cursor: crosshair;
}

.msg {
  margin-top: 10px;
  padding: 8px 11px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.6;
}

.msg-ok { background: #E8F3EE; color: #2F7A6B; }
.msg-fail { background: var(--primary-weak); color: var(--primary); }

.ctrl-row { display: flex; margin-top: 10px; }
.ctrl-btn {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  margin: 0 4px;
  border-radius: 7px;
  background: var(--chip);
  color: var(--ink);
  font-size: 13px;
  border: none;
  cursor: pointer;
}
.ctrl-on { background: var(--primary-weak); color: var(--primary); }

.done-card { background: #F3F8F5; }
.done-title { font-size: 17px; font-weight: 600; color: #2F7A6B; }
.done-rate { font-size: 36px; font-weight: 700; color: var(--primary); text-align: center; margin: 4px 0; }
.done-line { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- 抽考 ---------- */
.quiz-py { font-size: 32px; color: var(--primary); letter-spacing: 2px; text-align: center; }

.listen-only { font-size: 13px; color: var(--faint); text-align: center; }

.read-actions { display: flex; justify-content: center; align-items: center; margin-top: 13px; }

.read-main {
  padding: 10px 28px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: 999px;
  font-size: 17px;
  letter-spacing: 1px;
  cursor: pointer;
}

.read-second {
  margin-left: 10px;
  padding: 9px 20px;
  background: var(--chip);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
}

.quiz-toggles { display: flex; justify-content: center; flex-wrap: wrap; margin-top: 11px; }

.read-row { display: flex; flex-wrap: wrap; margin-bottom: 5px; }

.read-btn {
  padding: 3px 9px;
  margin: 0 6px 4px 0;
  background: var(--primary-weak);
  color: var(--primary);
  border: none;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.read-off { background: #F1ECE2; color: var(--faint); }
.quiz-hint { margin-top: 9px; font-size: 16px; text-align: center; letter-spacing: 1px; }
.quiz-extra { margin-top: 6px; text-align: center; }
.quiz-char { font-size: 88px; font-weight: 600; text-align: center; line-height: 1.1; }
.quiz-actions { display: flex; margin-top: 18px; }
.quiz-actions .btn { margin: 0 4px; font-size: 14px; }
.bar { margin-top: 8px; height: 5px; background: #F1ECE2; border-radius: 999px; overflow: hidden; }
.bar-in { height: 100%; background: var(--primary); transition: width 0.25s; }

/* ---------- 文本查字 ---------- */
.ta {
  width: 100%;
  min-height: 100px;
  margin-top: 10px;
  padding: 10px;
  background: #F8F5EF;
  border: none;
  border-radius: 7px;
  font-size: 15px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--ink);
  resize: vertical;
  outline: none;
}

.ta::placeholder { color: #B7B0A4; }
.rare { border-color: #E5C9C0; background: #FFFBF9; }

/* ---------- 字帖标题输入 ---------- */
.title-input {
  flex: 1;
  margin-left: 12px;
  padding: 6px 10px;
  background: #F8F5EF;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  text-align: right;
  color: var(--ink);
  outline: none;
}

.title-input::placeholder { color: #B7B0A4; }

/* ---------- 字单 ---------- */
.list-name {
  font-size: 16px;
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ops { display: flex; flex-wrap: wrap; margin-top: 10px; }

.op {
  padding: 5px 12px;
  margin: 4px 7px 4px 0;
  background: var(--chip);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
  border: none;
  cursor: pointer;
}

.op-danger { color: var(--primary); background: var(--primary-weak); }

/* ---------- 学习报告 ---------- */
.hero-title { font-size: 19px; font-weight: 700; }
.hero-sub { font-size: 12px; margin-top: 3px; }
.hero-nums { display: flex; margin-top: 14px; }
.num-item { flex: 1; text-align: center; }
.num { font-size: 23px; font-weight: 700; }
.num-label { font-size: 11px; color: var(--faint); margin-top: 2px; }

.chart { display: flex; align-items: flex-end; height: 130px; margin-top: 12px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: 20px; min-height: 3px; background: var(--primary); border-radius: 4px 4px 0 0; }
.chart-bar-empty { background: var(--line); }
.chart-num { font-size: 10px; color: var(--muted); height: 13px; line-height: 13px; }
.chart-label { font-size: 10px; color: #B7B0A4; }

/* ---------- 词语页 ---------- */
.char-row {
  display: flex;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}

.char-row:last-child { border-bottom: none; }

.char-box {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 26px;
  margin-right: 12px;
  background: #FFFFFF;
  cursor: pointer;
}

.char-info { flex: 1; min-width: 0; }
.char-py { font-size: 15px; }

.char-go {
  font-size: 13px;
  color: var(--primary);
  padding-left: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.about-link {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}

.about-link:last-child { border-bottom: none; }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(31, 41, 51, 0.88);
  color: #FFFFFF;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
  max-width: 80%;
  text-align: center;
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* ---------- 加载态 ---------- */
.loading { text-align: center; color: var(--faint); font-size: 13px; padding: 30px 0; }
