/* ============================================================
   视觉系统 v2
   配色：宣纸白 / 墨 / 朱砂 / 竹青
   原则：适老不意味着简陋 —— 高对比靠明度差，不靠粗边框和饱和色块
   ============================================================ */

:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --surface-2: #F2F0EA;
  --surface-3: #EAE7DF;

  --ink: #1B1A18;
  --ink-2: #57544E;
  --ink-3: #8B867C;

  --line: #E6E3DB;
  --line-2: #D6D2C8;

  --brand: #A8452F;
  --brand-2: #8C3623;
  --brand-weak: #FAEFEC;

  --ok: #2F6B54;
  --ok-weak: #E9F1ED;

  --warn: #96600F;
  --warn-weak: #FBF2E1;
  --warn-line: #E4CFA8;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow-1: 0 1px 2px rgba(27, 26, 24, .04), 0 2px 6px rgba(27, 26, 24, .035);
  --shadow-2: 0 2px 4px rgba(27, 26, 24, .05), 0 14px 32px rgba(27, 26, 24, .07);

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-kai: "Kaiti SC", "STKaiti", KaiTi, "楷体", "楷体_GB2312", "Noto Serif CJK SC", serif;
  --font-py: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  --scale: 1;
}

html[data-fs="2"] { --scale: 1.2; }
html[data-fs="3"] { --scale: 1.45; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: calc(18px * var(--scale));
  line-height: 1.7;
  letter-spacing: .01em;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 18px 8px; }

h1 { font-size: calc(27px * var(--scale)); font-weight: 600; margin: 2px 0 4px; letter-spacing: .015em; }
h2 { font-size: calc(21px * var(--scale)); font-weight: 600; margin: 30px 0 12px; letter-spacing: .015em; }
h3 { font-size: calc(18px * var(--scale)); font-weight: 600; margin: 22px 0 10px; letter-spacing: .015em; }
p  { margin: 0 0 12px; }

.muted { color: var(--ink-2); font-size: calc(16px * var(--scale)); }
.center { text-align: center; }
.small { font-size: calc(14px * var(--scale)); color: var(--ink-3); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(247, 246, 242, .88);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .title {
  flex: 1; font-size: calc(19px * var(--scale));
  font-weight: 600; letter-spacing: .04em;
}
.icon-btn {
  width: 46px; height: 46px; flex: 0 0 46px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); transition: background .15s, border-color .15s;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 21px; height: 21px; stroke: var(--ink); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.off svg { stroke: var(--ink-3); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 20px;
  margin-bottom: 14px;
}
.card-soft { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.card-quiet { background: var(--surface); border: 1px dashed var(--line-2); box-shadow: none; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 58px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: calc(18px * var(--scale));
  font-weight: 600; letter-spacing: .02em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.985); background: var(--surface-2); box-shadow: none; }
.btn-primary { background: var(--ink); color: #FBF9F5; border-color: var(--ink); }
.btn-primary:active { background: #2E2C28; }
.btn-accent { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-accent:active { background: var(--brand-2); }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-huge { min-height: 74px; font-size: calc(20px * var(--scale)); width: 100%; border-radius: var(--radius-lg); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 190px; }
.btn[disabled] { opacity: .38; pointer-events: none; box-shadow: none; }
.btn.sel { background: var(--ink); color: #FBF9F5; border-color: var(--ink); }
.btn svg {
  width: 19px; height: 19px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.big-ico { margin-bottom: 12px; }
.big-ico svg {
  width: 54px; height: 54px; fill: none; stroke: var(--ok);
  stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
}
.big-ico.warn svg { stroke: var(--brand); }

/* ---------- 底部导航 ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  position: relative;
  border: 0; background: transparent; cursor: pointer;
  padding: 10px 4px 12px; min-height: 74px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font-family: inherit; font-weight: 600;
  font-size: calc(14px * var(--scale));
  color: var(--ink-3); letter-spacing: .04em;
  transition: color .15s;
}
.nav button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav button.on { color: var(--ink); }
.nav button.on::before {
  content: ''; position: absolute; top: 7px;
  width: 22px; height: 2px; border-radius: 2px; background: var(--brand);
}

/* ---------- 大字教学区 ---------- */
.tian {
  position: relative;
  width: min(258px, 68vw); aspect-ratio: 1 / 1;
  margin: 4px auto 10px;
  display: flex; align-items: center; justify-content: center;
}
.tian::before, .tian::after {
  content: ''; position: absolute; inset: 0;
  border: 1px dashed var(--line-2); border-radius: 6px;
}
.tian::after {
  inset: 0; border: 0;
  background:
    linear-gradient(to right, transparent calc(50% - .5px), var(--line-2) calc(50% - .5px), var(--line-2) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), var(--line-2) calc(50% - .5px), var(--line-2) calc(50% + .5px), transparent calc(50% + .5px));
  opacity: .85;
}
.hanzi {
  position: relative; z-index: 1;
  font-family: var(--font-kai);
  font-size: calc(132px * var(--scale));
  font-weight: 400; line-height: 1;
}
.hanzi-sm { font-family: var(--font-kai); font-size: calc(44px * var(--scale)); font-weight: 400; line-height: 1.1; }
.pinyin {
  font-family: var(--font-py);
  font-size: calc(30px * var(--scale));
  color: var(--brand); font-weight: 600;
  letter-spacing: .09em;
}
.pinyin-sm { font-family: var(--font-py); font-size: calc(21px * var(--scale)); color: var(--brand); font-weight: 600; letter-spacing: .06em; }
.pinyin-xl { font-family: var(--font-py); font-size: calc(52px * var(--scale)); color: var(--brand); font-weight: 600; letter-spacing: .1em; }

/* ---------- 列表项 ---------- */
.tile {
  position: relative;
  display: block; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  padding: 16px 42px 16px 18px; margin-bottom: 10px; text-align: left;
  font-family: inherit; font-size: calc(18px * var(--scale)); color: var(--ink);
  cursor: pointer; min-height: 70px;
  transition: background .15s, border-color .15s;
}
.tile:active { background: var(--surface-2); }
.tile::after {
  content: ''; position: absolute; right: 18px; top: 50%;
  width: 8px; height: 8px; margin-top: -5px;
  border-right: 1.6px solid var(--line-2); border-top: 1.6px solid var(--line-2);
  transform: rotate(45deg);
}
.tile.done { border-color: var(--ok); }
.tile.done::after { border-color: var(--ok); }
.tile .sub { display: block; color: var(--ink-2); font-size: calc(15px * var(--scale)); margin-top: 3px; font-weight: 400; }
.tile-plain::after { display: none; }
.tile-say { padding-right: 18px; text-align: center; }
.tile-say::after { display: none; }
.tile-say .hanzi-sm, .tile-say .pinyin-sm { vertical-align: middle; }
.tile-say .pinyin-sm { margin-left: 8px; }

.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- 拼音格 ---------- */
.py-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 9px; }
.py-cell {
  position: relative;
  aspect-ratio: 1 / .88;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-family: inherit; padding: 4px;
  transition: border-color .15s, background .15s;
}
.py-cell:active { background: var(--surface-2); }
.py-cell .l {
  font-family: var(--font-py);
  font-size: calc(29px * var(--scale)); font-weight: 600;
  color: var(--brand); letter-spacing: .04em; line-height: 1.15;
}
.py-cell .z { font-family: var(--font-kai); font-size: calc(23px * var(--scale)); color: var(--ink); line-height: 1.15; }
.py-cell .p { font-family: var(--font-py); font-size: calc(13px * var(--scale)); color: var(--ink-3); letter-spacing: .04em; }
.py-cell.done { border-color: var(--ok); background: var(--ok-weak); }
.py-cell.done::after {
  content: '✓'; position: absolute; top: 5px; right: 8px;
  font-size: calc(12px * var(--scale)); color: var(--ok); font-weight: 700;
}
.py-cell.done .p { color: var(--ok); }

/* ---------- 声调 ---------- */
.tone-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 10px; }
.tone-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 10px 16px; text-align: center; background: var(--surface);
  box-shadow: var(--shadow-1); cursor: pointer; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.tone-card:active { background: var(--surface-2); }
.tone-card .mk {
  font-family: var(--font-py);
  font-size: calc(44px * var(--scale)); line-height: 1; font-weight: 600; color: var(--brand);
}
.tone-card .nm { font-weight: 600; font-size: calc(17px * var(--scale)); margin-top: 4px; }
.tone-card.done { border-color: var(--ok); background: var(--ok-weak); }
svg.tone-curve { display: block; margin: 2px auto 6px; }

/* ---------- 拼读 ---------- */
.spell-stage {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-py);
  font-size: calc(46px * var(--scale)); font-weight: 600;
  padding: 14px 0 18px; letter-spacing: .04em;
}
.spell-stage .s { color: var(--brand); }
.spell-stage .plus { color: var(--ink-3); font-size: .58em; }
.spell-stage .out { color: var(--ok); min-width: 1.5em; }
.spell-stage .out.pop { animation: pop .42s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes pop { 0% { transform: scale(.5); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }

/* ---------- 描红 ---------- */
.trace-box {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); overflow: hidden; touch-action: none;
}
.trace-box canvas { display: block; width: 100%; height: 300px; }
.trace-hint {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  color: var(--ink-3); font-size: calc(14px * var(--scale)); pointer-events: none;
}

/* ---------- 选项 ---------- */
.opt {
  width: 100%; min-height: 84px; margin-bottom: 10px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-1); cursor: pointer;
  font-family: inherit; font-size: calc(22px * var(--scale)); color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: background .15s, border-color .15s;
}
.opt.right { border-color: var(--ok); background: var(--ok-weak); }
.opt.wrong { border-color: var(--warn-line); background: var(--warn-weak); }

/* ---------- 发音按钮 ---------- */
.fab-speak {
  width: 100%; min-height: 68px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; border-radius: var(--radius);
  font-family: inherit; font-size: calc(19px * var(--scale)); font-weight: 600; letter-spacing: .03em;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: var(--shadow-1);
  transition: transform .08s, background .15s;
}
.fab-speak:active { transform: scale(.985); background: var(--brand-2); }
.fab-speak svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 进度 ---------- */
.bar { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .5s ease; }

.ring { display: block; margin: 0 auto; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke: var(--ok); transition: stroke-dashoffset .6s ease; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: calc(13px * var(--scale)); font-weight: 600; letter-spacing: .02em;
  background: var(--surface-2); color: var(--ink-2);
}
.tag.ok { background: var(--ok-weak); color: var(--ok); }
.tag.now { background: var(--brand-weak); color: var(--brand); }

/* ---------- 提示条 ---------- */
.tipbar {
  background: var(--brand-weak);
  border-left: 3px solid var(--brand);
  border-radius: 4px var(--radius) var(--radius) 4px;
  padding: 14px 16px; margin-bottom: 16px;
  font-size: calc(17px * var(--scale)); color: var(--ink);
}
.tipbar.ok { background: var(--ok-weak); border-left-color: var(--ok); }

.sep { height: 1px; background: var(--line); margin: 26px 0; }
.sep-lg { height: 1px; background: var(--line); margin: 34px 0; }

.kv {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }

/* ---------- 首页 ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 26px 22px 24px;
  margin-bottom: 16px;
}
.hero .date { font-size: calc(14px * var(--scale)); color: var(--ink-3); letter-spacing: .1em; }
.hero .hi { font-size: calc(26px * var(--scale)); font-weight: 600; margin: 6px 0 2px; letter-spacing: .02em; }
.hero-stats { display: flex; gap: 22px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.hero-stats div { flex: 1; }
.hero-stats .n { font-family: var(--font-py); font-size: calc(30px * var(--scale)); font-weight: 600; line-height: 1.1; }
.hero-stats .k { font-size: calc(13px * var(--scale)); color: var(--ink-3); margin-top: 3px; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.steps li:last-child { border-bottom: 0; }
.steps .dot {
  flex: 0 0 24px; height: 24px; border-radius: 99px;
  background: var(--surface-2); color: var(--ink-2);
  font-family: var(--font-py); font-size: calc(13px * var(--scale)); font-weight: 600;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.steps li.now .dot { background: var(--brand); color: #fff; }
.steps li.past .dot { background: var(--ok-weak); color: var(--ok); }
.steps .t { font-weight: 600; }
.steps .d { font-size: calc(14px * var(--scale)); color: var(--ink-3); }

.entry {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  padding: 16px 18px; margin-bottom: 10px; cursor: pointer;
  font-family: inherit; font-size: calc(18px * var(--scale)); color: var(--ink);
  text-align: left; min-height: 76px;
  transition: background .15s;
}
.entry:active { background: var(--surface-2); }
.entry .ico {
  flex: 0 0 46px; height: 46px; border-radius: 12px;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
}
.entry .ico svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.entry .txt { flex: 1; }
.entry .txt b { font-weight: 600; display: block; }
.entry .txt span { font-size: calc(14px * var(--scale)); color: var(--ink-3); }

.view { display: none; }
.view.on { display: block; animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

@media (max-width: 480px) {
  .hanzi { font-size: calc(112px * var(--scale)); }
  .hero-stats { gap: 14px; }
}
