/* style.css —— iPad 优先的触屏样式：大按钮、大字体、防误触 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f4f8; color: #2c3e50;
  -webkit-user-select: none; user-select: none;
}
#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 760px; margin: 0 auto; }
/* iPad 横屏：解除限宽，给书写区最大空间 */
@media (orientation: landscape) and (min-width: 900px) {
  #app { max-width: 1160px; }
}

/* ---------- 头部 ---------- */
.app-header {
  padding: 14px 20px 10px; padding-top: calc(14px + env(safe-area-inset-top));
  background: #fff; border-bottom: 1px solid #e8edf2;
}
.logo { font-size: 20px; font-weight: 700; }
.warn-bar {
  background: #fff7e0; color: #9a6b00; font-size: 13px;
  padding: 8px 14px; text-align: center; border-bottom: 1px solid #f0e0b0;
}

/* ---------- 主区 ---------- */
#app-main { flex: 1; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.page { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- 首页 ---------- */
.home-card {
  background: #fff; border-radius: 18px; padding: 28px 22px; text-align: center;
  box-shadow: 0 2px 12px rgba(44,62,80,.06); margin-top: 8vh;
}
.hello { font-size: 24px; font-weight: 700; margin-bottom: 10px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: none; border-radius: 14px; cursor: pointer;
  font-size: 16px; padding: 13px 26px; min-height: 48px; min-width: 88px;
  transition: transform .08s ease, opacity .15s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; }
.btn-primary { background: #4a90d9; color: #fff; }
.btn-primary:active { background: #3a7bc0; }
.btn-ghost { background: #eef3f8; color: #4a90d9; }
.btn-danger { background: #fdecea; color: #e74c3c; }
.btn-big { font-size: 19px; padding: 16px 40px; border-radius: 16px; }

/* ---------- 刷题页 ---------- */
.quiz-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 16px; color: #7f8c8d; margin-bottom: 8px; font-weight: 600;
}
.timer { font-variant-numeric: tabular-nums; color: #4a90d9; }
.progress-bar { height: 6px; background: #e4ebf2; border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.progress-fill { height: 100%; background: #4a90d9; border-radius: 3px; transition: width .25s; }
.review-flag {
  display: inline-block; background: #fef3e2; color: #c07b00; font-size: 13px;
  padding: 4px 12px; border-radius: 10px; margin-bottom: 10px; font-weight: 600;
}
.question-card {
  background: #fff; border-radius: 18px; padding: 30px 20px;
  text-align: center; box-shadow: 0 2px 12px rgba(44,62,80,.06); margin-bottom: 14px;
}
.q-topic { font-size: 13px; color: #95a5a6; margin-bottom: 14px; }
.q-expr { font-size: 34px; font-weight: 700; line-height: 1.35; word-break: break-all; font-variant-numeric: tabular-nums; }
.q-eq { font-size: 22px; color: #4a90d9; margin-top: 10px; font-weight: 600; }

/* ---------- 教材式数学渲染（MathRender） ---------- */
.mexpr { white-space: nowrap; display: inline-block; }
.mexpr.sz1 { font-size: .82em; }
.mexpr.sz2 { font-size: .68em; }
.mfrac {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; margin: 0 3px;
}
.mfrac .mnum {
  font-size: .72em; padding: 0 5px 3px;
  border-bottom: 2.5px solid currentColor; line-height: 1.15;
}
.mfrac .mden { font-size: .72em; padding: 3px 5px 0; line-height: 1.15; }
.mop { margin: 0 5px; }
.mneg { margin-right: 1px; }
.msup { font-size: .58em; vertical-align: super; margin-left: 1px; }
.mbracket { font-size: 1.08em; font-weight: 400; }
.mabs { font-size: 1.12em; font-weight: 400; }
.quit-link { color: #7f8c8d; font-size: 15px; padding: 4px 10px 4px 0; cursor: pointer; user-select: none; }
.quit-link:active { color: #4a90d9; }
.retry-first { margin-top: 16px; font-size: 14px; color: #95a5a6; }
.retry-first b { color: #e74c3c; }
.hint { font-size: 13px; color: #b2bec3; }

/* ---------- 键盘 ---------- */
.kb-preview {
  background: #fff; border: 2px dashed #d5dde5; border-radius: 14px;
  min-height: 60px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.kb-preview span { min-height: 40px; min-width: 30px; }
.kb-preview span.kb-cursor::after { content: '|'; color: #b2bec3; animation: none; }
.kb-grid { background: #dde5ee; border-radius: 18px; padding: 8px; }
.kb-row { display: flex; gap: 8px; margin: 8px 0; }
.kb-key {
  flex: 1; height: 62px; border-radius: 12px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 3px rgba(44,62,80,.12); transition: transform .06s;
}
.kb-key:active { transform: scale(.95); background: #f0f4f8; }
.kb-blank { background: transparent; box-shadow: none; }
.kb-back { background: #e8edf2; font-size: 22px; }
.kb-ok { background: #4a90d9; color: #fff; }
.kb-ok:active { background: #3a7bc0; }

.quiz-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }

/* ---------- 判卷/完成 ---------- */
.judge-card {
  background: #fff; border-radius: 18px; padding: 28px 22px; text-align: center;
  box-shadow: 0 2px 12px rgba(44,62,80,.06); margin-top: 5vh;
}
.judge-title { font-size: 22px; font-weight: 700; margin-bottom: 14px; }
.judge-big { font-size: 40px; font-weight: 800; color: #4a90d9; margin-bottom: 8px; }
.judge-big b { font-size: 56px; }
.judge-sub { font-size: 15px; color: #7f8c8d; margin-bottom: 18px; }
.judge-topics { border-top: 1px solid #eef2f6; padding-top: 14px; margin-bottom: 18px; }
.judge-topic { display: flex; justify-content: space-between; padding: 6px 10px; font-size: 15px; color: #57606f; }
.judge-wrong { font-size: 16px; margin-bottom: 20px; color: #e74c3c; }
.judge-wrong.ok { color: #27ae60; font-size: 19px; font-weight: 700; }
.done-types { font-size: 14px; color: #7f8c8d; margin-bottom: 22px; line-height: 1.7; }

/* ---------- 重算结果 ---------- */
.retry-outcome { font-size: 20px; font-weight: 700; margin-top: 18px; }
.retry-outcome.ok { color: #27ae60; }
.retry-outcome.bad { color: #e74c3c; }
.retry-outcome small { font-size: 14px; color: #7f8c8d; font-weight: 400; }
.answer-compare {
  display: flex; flex-direction: column; gap: 6px; margin: 16px auto 0;
  background: #f7fafc; border-radius: 12px; padding: 14px; font-size: 17px; max-width: 360px;
}
.answer-compare b.bad { color: #e74c3c; }
.answer-compare b.good { color: #27ae60; }
.steps { margin-top: 16px; text-align: left; font-size: 15px; color: #57606f; background: #f7fafc; border-radius: 12px; padding: 12px 16px; }
.step { padding: 3px 0; }
.step-expr { font-variant-numeric: tabular-nums; }
.diag { margin-top: 12px; font-size: 14px; color: #c07b00; }
.final-type { margin-top: 8px; font-size: 14px; color: #e74c3c; font-weight: 600; }

/* ---------- 错题本/家长页 ---------- */
.stat-cards { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 140px; background: #fff; border-radius: 14px; padding: 14px 8px;
  text-align: center; box-shadow: 0 2px 8px rgba(44,62,80,.05);
}
.stat-card b { display: block; font-size: 24px; color: #4a90d9; margin-bottom: 2px; }
.stat-card span { font-size: 12px; color: #95a5a6; }
/* 执行统计条：五卡一行紧凑版（今日/本周/累计/连续/待复习） */
.stat-strip .stat-card { flex: 1 1 18%; min-width: 0; padding: 12px 4px; }
.stat-strip .stat-card b { font-size: 17px; white-space: nowrap; }
.stat-strip .stat-card span { font-size: 11px; }
.sec-title { font-size: 16px; margin: 20px 0 10px; color: #2c3e50; }
.empty { background: #fff; border-radius: 14px; padding: 24px; text-align: center; color: #95a5a6; font-size: 14px; }

.wrong-list { display: flex; flex-direction: column; gap: 10px; }
.wrong-item { background: #fff; border-radius: 14px; padding: 14px 16px; }
.w-expr { font-size: 19px; font-weight: 700; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.w-meta { font-size: 13px; color: #7f8c8d; margin-bottom: 4px; }
.w-date { font-size: 12px; color: #b2bec3; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.tag-bad { background: #fdecea; color: #e74c3c; }
.tag-warn { background: #fef3e2; color: #c07b00; }
.tag-mild { background: #eef2f6; color: #7f8c8d; }
.tag-ok { background: #e8f8f0; color: #27ae60; }

/* ---------- 设置 ---------- */
.data-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.note { font-size: 13px; color: #95a5a6; line-height: 1.7; margin-top: 14px; }

/* ---------- 学科广场 ---------- */
.plaza-top { text-align: center; margin: 20px 0 18px; }
.plaza-top .hello { font-size: 22px; font-weight: 700; }
.plaza-sub { font-size: 13px; color: #95a5a6; margin-top: 6px; }
.subject-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.subject-card {
  background: #fff; border-radius: 18px; padding: 22px 16px; text-align: center;
  box-shadow: 0 2px 12px rgba(44,62,80,.06); border-top: 4px solid var(--sc, #ccc);
  cursor: pointer; transition: transform .1s;
}
.subject-card:active { transform: scale(.97); }
.subject-card .s-ico { font-size: 38px; margin-bottom: 8px; }
.subject-card .s-name { font-size: 19px; font-weight: 700; }
.subject-card .s-chapter { font-size: 12px; color: #95a5a6; margin-top: 6px; }
.subject-card .s-todo { font-size: 12px; color: var(--sc); font-weight: 600; margin-top: 10px; }
.subject-card .s-done { font-size: 12px; color: #27ae60; margin-top: 10px; }
.subject-card.locked { opacity: .5; }
.subject-card.locked .s-lock { font-size: 12px; color: #95a5a6; margin-top: 10px; }

/* ---------- 学科首页 ---------- */
.subject-top {
  display: flex; align-items: center; gap: 12px; background: #fff;
  border-radius: 16px; padding: 16px; margin-bottom: 14px; border-left: 5px solid var(--sc);
}
.st-ico { font-size: 32px; }
.st-name { font-size: 22px; font-weight: 700; flex: 1; }
.btn-intro { padding: 8px 14px; font-size: 13px; min-height: 40px; }
.chapter-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.chapter-item { background: #fff; border-radius: 14px; padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px; }
.chapter-item .ch-ico { flex: none; width: 26px; font-size: 20px; line-height: 22px; text-align: center; }
.chapter-item .ch-body { flex: 1; min-width: 0; }
.chapter-item.active { border-left: 4px solid var(--sc); }
.chapter-item.open { cursor: pointer; }
.chapter-item.locked { opacity: .55; }
.chapter-empty { background: #fff; border-radius: 14px; padding: 48px 16px; text-align: center; font-size: 17px; font-weight: 700; color: #7f8c8d; }
.chapter-empty-sub { text-align: center; font-size: 13px; color: #95a5a6; margin-top: 8px; }
.ch-name { font-size: 16px; font-weight: 700; }
.ch-meta { font-size: 12px; color: #95a5a6; margin: 4px 0 8px; }
.ch-bar { height: 6px; background: #eef2f6; border-radius: 3px; overflow: hidden; }
.ch-bar div { height: 100%; background: var(--sc); border-radius: 3px; }
.subject-done { background: #e8f8f0; color: #27ae60; border-radius: 14px; padding: 16px; text-align: center; font-size: 15px; margin-bottom: 12px; }
.draft-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fef7e0; color: #8a6d1a; border-radius: 12px; padding: 12px 14px;
  font-size: 14px; margin-bottom: 12px;
}
.btn-start { display: block; margin: 0 auto; }

/* ---------- 语文练习项入口行（小学字词/初中字词/错字/病句…后续在此扩展） ---------- */
.entry-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.entry-row {
  background: #fff; border-radius: 14px; padding: 16px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(44,62,80,.05); transition: transform .08s;
}
.entry-row:active { transform: scale(.98); }
.entry-row.locked { opacity: .5; }
.entry-row .e-ico { font-size: 26px; }
.entry-row .e-name { font-size: 16px; font-weight: 700; flex: 1; }
.entry-row .e-meta { font-size: 12px; color: #95a5a6; }
.entry-row .e-arrow { color: #b2bec3; font-size: 20px; font-weight: 700; }

/* ---------- 课本解读页 ---------- */
.intro-back { font-size: 15px; color: var(--sc); padding: 6px 0 10px; cursor: pointer; display: inline-block; }
.intro-head { font-size: 13px; color: #95a5a6; margin-bottom: 6px; }
.intro-title { font-size: 24px; margin: 6px 0 18px; line-height: 1.4; }
.intro-h { font-size: 18px; margin: 20px 0 10px; }
.intro-p { font-size: 15px; line-height: 1.9; color: #57606f; margin-bottom: 10px; }
.intro-li { padding-left: 22px; }
.intro-li li { font-size: 15px; line-height: 1.9; color: #57606f; margin-bottom: 8px; }
.intro-end { text-align: center; font-size: 12px; color: #b2bec3; margin: 30px 0 10px; }

/* ---------- 语文：默写 ---------- */
.word-card { background: #fff; border-radius: 18px; padding: 26px 20px; text-align: center; box-shadow: 0 2px 12px rgba(44,62,80,.06); margin-bottom: 14px; }
/* 默写页窄版词卡：压缩高度，把空间让给手写区 */
.word-card-slim { padding: 10px 14px; margin-bottom: 10px; }
.word-card-slim .w-pinyin { font-size: 26px; margin: 0; }
.word-card-slim .w-meaning { font-size: 13px; margin-top: 4px; }
.word-card-slim .w-lesson { font-size: 11px; color: #b2bec3; }
.w-pinyin { font-size: 32px; font-weight: 700; letter-spacing: 2px; }
.w-meaning { font-size: 15px; color: #7f8c8d; margin-top: 10px; line-height: 1.6; }
.w-lesson { font-size: 12px; color: #b2bec3; margin-top: 10px; }
/* 返回按钮（语文默写页顶部） */
.btn-back { color: #7f8c8d; font-size: 16px; cursor: pointer; padding: 4px 10px; }
.w-answer-big { margin-top: 14px; }
.big-char {
  display: inline-block; font-size: 54px; font-weight: 700; margin: 0 8px;
  border: 2px solid #eef2f6; border-radius: 12px; padding: 6px 10px; line-height: 1.2;
}
.hw-wrap { flex: 1; min-height: 0; display: flex; }
/* 默写页整页 flex：书写区占满剩余高度 */
.page.cn-dict { display: flex; flex-direction: column; height: calc(100vh - 95px); height: calc(100dvh - 95px); overflow: hidden; }
.page.cn-dict .quiz-top { flex: none; }
.page.cn-dict .word-card-slim { flex: none; }
.page.cn-dict #hw-box { flex: 1; min-height: 0; display: flex; }
/* 底部单行：橡皮擦左、写好了右 */
.page.cn-dict .cn-nav { flex: none; margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hw-wrap { flex: 1; display: flex; flex-direction: column; background: #fff; border-radius: 16px; padding: 8px 10px; box-shadow: 0 2px 12px rgba(44,62,80,.06); }
.hw-grid { flex: 1; display: grid; gap: 8px; justify-content: center; align-content: center; min-height: 0; }
/* 田字格：外框实线 + 中线虚线（画在 CSS 层，不进笔迹图） */
.hw-cell-canvas {
  touch-action: none; background: #fff; border-radius: 8px; cursor: crosshair;
  border: 2px solid #9db2c7;
  background-image:
    linear-gradient(to right, transparent calc(50% - 0.5px), #cdd9e5 calc(50% - 0.5px), #cdd9e5 calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), #cdd9e5 calc(50% - 0.5px), #cdd9e5 calc(50% + 0.5px), transparent calc(50% + 0.5px));
}
.check-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 14px; }
.ocr-line { text-align: center; font-size: 14px; color: #7f8c8d; margin-bottom: 16px; }
.char-checks { display: flex; justify-content: center; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.char-check { text-align: center; border-radius: 14px; padding: 10px 14px; background: #fff; box-shadow: 0 2px 8px rgba(44,62,80,.05); }
.char-check.ok { border: 2px solid #27ae60; }
.char-check.bad { border: 2px solid #e74c3c; }
.cc-char { font-size: 44px; font-weight: 700; margin-bottom: 8px; }
.cc-mark { font-size: 24px; font-weight: 700; text-align: center; }
.char-check.ok .cc-mark { color: #27ae60; }
.char-check.bad .cc-mark { color: #e74c3c; }
.parent-check { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- 语文：辨析 ---------- */
.quiz-card { background: #fff; border-radius: 18px; padding: 26px 20px; box-shadow: 0 2px 12px rgba(44,62,80,.06); }
.w-question { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 22px; line-height: 1.5; }
.opt-list { display: flex; flex-direction: column; gap: 12px; }
.opt-btn {
  border: 2px solid #e4ebf2; background: #fff; border-radius: 14px; padding: 16px;
  font-size: 20px; font-weight: 600; cursor: pointer; font-family: inherit; min-height: 56px;
}
.opt-btn:active { transform: scale(.98); }
.opt-btn.right { border-color: #27ae60; background: #e8f8f0; color: #27ae60; }
.opt-btn.wrong { border-color: #e74c3c; background: #fdecea; color: #e74c3c; }
.opt-result { text-align: center; margin-top: 16px; min-height: 40px; }
.wrong-chars { text-align: center; margin: 8px 0; }
.wc { display: inline-block; font-size: 26px; margin: 0 4px; color: #e74c3c; font-weight: 700; }

/* ---------- 错字榜 ---------- */
.wc-board { display: flex; flex-wrap: wrap; gap: 10px; background: #fff; border-radius: 14px; padding: 14px; }
.wc-board .wc { position: relative; font-size: 30px; color: #e74c3c; background: #fdecea; border-radius: 10px; padding: 6px 10px; margin: 0; }
.wc i { font-style: normal; font-size: 11px; color: #fff; background: #e74c3c; border-radius: 8px; padding: 1px 6px; position: absolute; top: -8px; right: -8px; }

/* ---------- 错题页：按周分组（折叠式：最新周展开、往周收起） ---------- */
.week-block { background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(44,62,80,.05); }
.week-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; cursor: pointer; }
.week-label { font-size: 15px; font-weight: 700; }
.wk-arrow { display: inline-block; width: 20px; color: #b2bec3; font-weight: 700; }
.week-block.folded .week-body { display: none; }
.week-block.folded .week-head { margin-bottom: 0; }
.week-block .wc-board { margin-bottom: 10px; }
.week-block .wrong-list { display: flex; flex-direction: column; gap: 8px; }

.app-nav {
  display: flex; background: #fff; border-top: 1px solid #e8edf2;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; text-align: center; padding: 8px 0 10px; font-size: 12px; color: #95a5a6;
  cursor: pointer;
}
.nav-item.active { color: #4a90d9; }
.nav-ico { display: block; font-size: 22px; margin-bottom: 2px; }
