/* ============ 闽打 · 福建拼音练习 ============ */
:root {
  --bg: #fbf7f0;
  --surface: #fffdf8;
  --ink: #2b2620;
  --ink-2: #5f564a;
  --muted: #7c7163;
  --line: #e8ddcd;
  --line-strong: #d9cbb8;
  --red: #b0472f;
  --red-deep: #8f3523;
  --red-soft: #f5e4dc;
  --teal: #2f6f7e;
  --teal-soft: #e2eef0;
  --gold: #8a6620;
  --gold-soft: #f5ecd7;
  --tea: #5b7a63;
  --tea-soft: #e8efe6;
  --green: #2f6b46;
  --green-soft: #e4f1e7;
  --wrong: #a33232;
  --wrong-soft: #f8dede;
  --shadow: 0 14px 34px rgba(63, 45, 28, .09);
  --shadow-sm: 0 4px 14px rgba(63, 45, 28, .06);
  --radius: 18px;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, "Liberation Mono", monospace;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(75, 55, 35, .045) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}
body.is-practice { background-image: none; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--red); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: var(--red-soft); color: var(--red-deep); }
:focus-visible { outline: 3px solid rgba(176, 71, 47, .35); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.icon { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.16em; flex: none; }
kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fff;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: .82em;
  line-height: 1.5;
  text-align: center;
}
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.noscript {
  position: fixed; inset: 24px; z-index: 999;
  padding: 24px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--red); color: #fff8f2;
  box-shadow: 0 8px 20px rgba(176, 71, 47, .22);
}
.btn-primary:hover { background: var(--red-deep); }
.btn-ghost {
  background: var(--surface); border-color: var(--line-strong); color: var(--ink);
}
.btn-ghost:hover { background: #fff; border-color: var(--ink-2); }
.btn-danger { color: var(--wrong); border-color: #e7c9c5; background: #fff8f7; }
.btn-danger:hover { background: var(--wrong-soft); }
.text-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0; border: 0; background: none; color: var(--red);
  font-size: 13px; font-weight: 600;
}
.text-link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  padding: 0; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--ink-2);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: rgba(43, 38, 32, .06); color: var(--ink); }
.icon-btn.is-on { color: var(--red); background: var(--red-soft); }

/* ---------- home header ---------- */
.site-head {
  position: relative; z-index: 5;
  border-bottom: 1px solid rgba(232, 221, 205, .7);
  background: rgba(251, 247, 240, .8);
  backdrop-filter: blur(10px);
}
.head-inner { display: flex; align-items: center; justify-content: space-between; height: 76px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); }
.seal {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--red);
  color: #fff8f2;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 248, 242, .2);
  transform: rotate(-2deg);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: .08em; }
.brand-text small { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .24em; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
  border: 0; background: none; color: var(--ink-2);
  padding: 8px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 500;
}
.nav-link:hover { background: rgba(43, 38, 32, .06); color: var(--ink); }
.nav-menu { position: relative; }
.nav-menu-btn { display: inline-flex; align-items: center; gap: 3px; }
.nav-menu-btn svg { width: 12px; height: 12px; opacity: .7; transition: transform .16s ease; }
.nav-menu-btn[aria-expanded="true"] svg { transform: rotate(90deg); }
.board-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  width: 232px; padding: 6px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; gap: 2px;
}
.board-menu[hidden] { display: none; }
.board-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 9px; background: none;
  color: var(--ink-2); font-size: 12px; text-align: left;
}
.board-item:hover { background: var(--red-soft); color: var(--red-deep); }
.board-item small { color: var(--muted); font-family: var(--mono); font-size: 9px; }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr);
  gap: 56px;
  align-items: center;
  padding-top: 68px;
  padding-bottom: 56px;
}
.eyebrow {
  display: flex; align-items: center; gap: 8px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.hero h1 {
  margin-top: 18px;
  font-family: var(--serif);
  font-size: clamp(42px, 5.1vw, 72px);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -.01em;
}
.hero h1 em { font-style: normal; color: var(--red); position: relative; white-space: nowrap; }
.hero h1 em::after {
  content: ""; position: absolute; left: 2px; right: 2px; bottom: 2px; height: 8px;
  background: var(--red-soft); border-radius: 4px; z-index: -1;
}
.lede { max-width: 530px; margin-top: 20px; color: var(--ink-2); font-size: 16px; line-height: 1.9; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  margin-top: 24px;
  color: var(--muted); font-size: 12px;
}
.hero-meta b { color: var(--ink); font-family: var(--mono); font-size: 13px; }

.hero-card {
  position: relative;
  width: 100%; max-width: 470px; justify-self: end;
  padding: 20px 22px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: rotate(-1.2deg);
  transition: transform .35s ease;
}
.hero-card:hover { transform: rotate(0deg) translateY(-3px); }
.hero-card::before {
  content: ""; position: absolute; inset: 9px; border: 1px dashed rgba(176, 71, 47, .16);
  border-radius: 16px; pointer-events: none;
}
.hero-card-head { display: flex; align-items: center; justify-content: space-between; }
.traffic { display: flex; gap: 5px; }
.traffic i { width: 7px; height: 7px; border-radius: 50%; background: #e3d6c5; }
.traffic i:first-child { background: var(--red); opacity: .65; }
.traffic i:nth-child(2) { background: var(--gold); opacity: .6; }
.traffic i:nth-child(3) { background: var(--tea); opacity: .55; }
.hero-label { color: var(--muted); font-size: 11px; letter-spacing: .1em; }
.hero-line { display: flex; align-items: flex-end; gap: 16px; margin: 26px 0 22px; padding-left: 4px; }
.hero-syl { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hero-py { color: var(--muted); font-family: var(--mono); font-size: 17px; letter-spacing: .04em; }
.hero-hz { font-family: var(--serif); font-size: 46px; line-height: 1.15; color: var(--ink); }
.hero-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 12px 0 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mini-key {
  display: grid; place-items: center;
  width: 30px; height: 28px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: #fff; color: var(--ink-2);
  font-family: var(--mono); font-size: 12px;
  box-shadow: 0 2px 0 #eadfce;
}
.mini-key.active { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 2px 0 #8f3523; }
.mini-space {
  margin-left: auto; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-size: 10px;
}
.hero-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: 11px; }
.hero-pill { padding: 3px 9px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-size: 10px; }

.wave { height: 54px; color: rgba(176, 71, 47, .1); line-height: 0; overflow: hidden; }
.wave svg { width: 100%; height: 100%; }

/* ---------- courses ---------- */
.courses { padding-top: 18px; padding-bottom: 20px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.section-head h2, .note-card h2 { margin-top: 8px; font-family: var(--serif); font-size: clamp(26px, 3.2vw, 36px); line-height: 1.25; }
.section-note { max-width: 330px; color: var(--muted); font-size: 12px; text-align: right; }
.cat {
  --accent: var(--tea);
  --accent-soft: var(--tea-soft);
  margin-top: 30px;
  scroll-margin-top: 18px;
  padding: 22px 22px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, .68);
}
.cat--tea { --accent: var(--tea); --accent-soft: var(--tea-soft); }
.cat--sea { --accent: var(--teal); --accent-soft: var(--teal-soft); }
.cat--brick { --accent: var(--red); --accent-soft: var(--red-soft); }
.cat--gold { --accent: var(--gold); --accent-soft: var(--gold-soft); }
.cat--plum { --accent: #7a5a6e; --accent-soft: #f0e7ee; }
.cat--slate { --accent: #5d6470; --accent-soft: #eceef2; }
.cat-head { display: flex; align-items: center; gap: 14px; }
.cat-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}
.cat-icon svg { width: 22px; height: 22px; }
.cat-title { flex: 1; min-width: 0; }
.cat-title h3 { font-family: var(--serif); font-size: 21px; line-height: 1.2; }
.cat-title p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.cat-meta { color: var(--accent); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.cat-bar { height: 3px; margin: 16px 0 16px; border-radius: 999px; background: var(--line); overflow: hidden; }
.cat-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.hero-art { margin: 30px auto 0; }
.hero-art img, .closing-art img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 16px 34px rgba(78, 52, 36, .13);
}
.hero-art figcaption, .cat-art figcaption, .closing-art figcaption {
  margin: 7px 2px 0; font-size: 11px; letter-spacing: .04em; color: var(--muted); text-align: right;
}
.closing-art { margin: 8px auto 34px; }
.cat-art { margin: 0 0 16px; }
.cat-art img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 14px; }
.culture-card {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  background: linear-gradient(180deg, #fffaf2, var(--surface));
}
.culture-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.culture-head .tag { flex: none; margin-top: 2px; }
.culture-head h4 { font-family: var(--serif); font-size: 17px; line-height: 1.3; }
.culture-head p { flex: 1 1 100%; margin-top: 2px; color: var(--muted); font-size: 10px; }
.culture-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.culture-cols b { display: block; margin-bottom: 5px; color: var(--accent); font-size: 10px; letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips span { padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--ink-2); font-size: 10px; }
.culture-note { margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.lesson-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 12px; }
.lesson-card {
  display: flex; flex-direction: column;
  min-height: 158px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(63, 45, 28, .03);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.lesson-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); border-color: var(--accent); }
.lesson-top { display: flex; align-items: center; justify-content: space-between; }
.lesson-no { color: var(--accent); font-family: var(--mono); font-size: 11px; letter-spacing: .08em; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 10px; line-height: 1.6; }
.lesson-card h4 { margin-top: 12px; font-family: var(--serif); font-size: 18px; line-height: 1.3; }
.lesson-card p { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.lesson-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 14px; color: var(--muted); font-size: 10px; }
.lesson-mins { margin-right: auto; }
.card-stars { color: var(--gold); letter-spacing: 1px; font-size: 11px; }
.best { color: var(--ink-2); font-family: var(--mono); font-size: 10px; }
.card-go { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 600; }
.card-go .icon { width: 12px; height: 12px; }

/* ---------- note / footer ---------- */
.note-wrap { padding-top: 22px; padding-bottom: 54px; }
.note-card {
  position: relative; display: flex; gap: 26px; align-items: flex-start;
  padding: 32px 34px;
  border-radius: 22px;
  background: #2f2a24;
  color: #f7efe3;
  overflow: hidden;
}
.note-card .eyebrow { color: #d8a58e; }
.note-card h2 { color: #fff8ed; }
.note-card p { max-width: 720px; margin-top: 10px; color: #cfc4b4; font-size: 13px; line-height: 1.85; }
.note-card .text-link { margin-top: 16px; color: #e7b9a7; }
.note-mark {
  flex: none; display: grid; place-items: center;
  width: 64px; height: 64px;
  border: 1px solid rgba(247, 239, 227, .25);
  border-radius: 12px;
  color: #e7b9a7;
  font-family: var(--serif); font-size: 36px;
  transform: rotate(-3deg);
}
.site-foot { border-top: 1px solid var(--line); background: rgba(255, 253, 248, .55); }
.foot-inner { display: flex; align-items: center; gap: 18px; min-height: 76px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.foot-inner p { margin-right: auto; }
.brand--small .seal { width: 28px; height: 28px; font-size: 16px; border-radius: 6px; }
.brand--small .brand-text b { font-size: 15px; }
.brand--small .brand-text small { font-size: 7px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 300;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(43, 38, 32, .94);
  color: #fff8ef;
  font-size: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   practice
   ============================================================ */
.is-practice { background-color: #f8f3ea; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(251, 247, 240, .93);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.topbar .back { flex: none; }
.lesson-title { min-width: 0; flex: 1; }
.lesson-title p { color: var(--muted); font-size: 10px; letter-spacing: .06em; }
.lesson-title h1 { font-family: var(--serif); font-size: 18px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-title .dot { opacity: .5; }
.top-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.pct { min-width: 38px; color: var(--muted); font-family: var(--mono); font-size: 11px; text-align: right; }
.progress { height: 3px; background: rgba(217, 203, 184, .45); }
.progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--red), #d98663); transition: width .2s ease; }
.practice-wrap { padding-top: 20px; padding-bottom: 40px; }
.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 252px;
  grid-template-areas:
    "stage stats"
    "keyboard keyboard"
    "tip tip";
  gap: 14px;
  align-items: start;
}
.stage-card { grid-area: stage; }
.stats-card { grid-area: stats; }
.keyboard-card { grid-area: keyboard; }
.tip-card { grid-area: tip; }

.stage-card {
  position: relative;
  display: flex; flex-direction: column;
  height: clamp(320px, 42vh, 380px);
  min-height: 300px;
  padding: 22px 24px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stage-scroll { flex: 1; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; -ms-overflow-style: none; }
.stage-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
.lines {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  flex: 1;
  padding: 4px 2px 18px;
  min-height: 100%;
  align-content: flex-start;
  user-select: none;
}
.phrase {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: flex-start;
  margin: 0 26px 12px 0;
}
.syl {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 1px;
}
.syl .py {
  display: flex; align-items: flex-end;
  height: 46px;
  color: #958878;
  font-family: var(--mono);
  font-size: 30px;
  line-height: 1;
  letter-spacing: .01em;
}
.ltr {
  position: relative;
  display: inline-block;
  line-height: 1;
  transition: color .12s ease, background .12s ease;
}
.sp {
  position: relative;
  display: inline-block;
  width: 7px; height: 38px;
  flex: none;
}
.sp i { display: none; }
.hz {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 38px;
  color: #6b6155;
  transition: color .15s ease;
}
.punct {
  align-self: flex-end;
  padding-left: 2px;
  color: #af9f8c;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 38px;
}
.syl.cur::before, .group--drill.cur::before {
  content: ""; position: absolute; left: -4px; right: -4px; top: -11px; height: 2px;
  border-radius: 2px; background: var(--red);
}
.ltr.cur { color: var(--red); }
.ltr.cur::after {
  content: ""; position: absolute; left: -1px; right: -1px; bottom: -6px; height: 3px;
  border-radius: 2px; background: var(--red);
}
.sp.cur::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 1px; height: 3px;
  border-radius: 2px; background: var(--red);
}
.ltr.ok { color: var(--green); }
.ltr.bad { color: var(--wrong); background: var(--wrong-soft); border-radius: 3px; box-shadow: 0 0 0 2px var(--wrong-soft); }
.syl.done .hz { color: var(--green); }
.syl.mistake .hz { color: var(--wrong); }
.syl.cur .hz { color: var(--ink); }

.lines--drill { align-content: center; padding-top: 12px; }
.group--drill {
  position: relative;
  display: inline-flex;
  margin: 0 24px 12px 0;
  padding: 4px 1px;
}
.group--drill .py {
  display: flex; align-items: flex-end;
  height: 52px;
  color: #958878;
  font-family: var(--mono);
  font-size: 34px;
  line-height: 1;
  letter-spacing: .02em;
}
.group--drill .sp { height: 44px; }
.group--drill.done .py { color: var(--green); }
.group--drill.mistake .py { color: var(--wrong); }
.group--drill.done .ltr.ok { color: var(--green); }
.ltr.shake { animation: shake .3s ease; }

.stage-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 34px; padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--muted); font-size: 11px;
}
.space-hint { color: var(--red); font-weight: 600; }
.space-hint:empty { display: none; }
.stage-tip { margin-left: auto; color: var(--muted); font-size: 10px; }

.pause-mask {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  background: rgba(255, 253, 248, .8);
  backdrop-filter: blur(5px);
}
.pause-card { text-align: center; padding: 20px; }
.pause-card h2 { margin-top: 4px; font-family: var(--serif); font-size: 28px; }
.pause-card p { margin: 6px 0 16px; color: var(--muted); font-size: 12px; }

.stats-card {
  display: flex; flex-direction: column;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat { padding: 11px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
.stat > span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.stat strong { display: inline-block; margin-top: 1px; font-family: var(--mono); font-size: 27px; font-weight: 500; line-height: 1.2; color: var(--ink); }
.stat small { margin-left: 3px; color: var(--muted); font-size: 10px; }

.keyboard-card {
  position: relative;
  padding: 8px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.keyboard-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 4px 7px;
}
.kb-wrap { position: relative; }
.kb { width: 100%; max-width: 790px; margin: 0 auto; user-select: none; }
.kb-row { display: flex; gap: 4px; margin-bottom: 4px; }
.kb-row:last-child { margin-bottom: 0; }
.key {
  position: relative;
  flex: 1 1 0; min-width: 0;
  height: 34px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0;
  border: 1px solid #e2d6c5;
  border-radius: 6px;
  background: #fffdf9;
  color: #5b5247;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 2px 0 #ece2d3;
  touch-action: manipulation;
  transition: background .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}
.key:hover { border-color: var(--line-strong); }
.key:active { transform: translateY(1px); box-shadow: 0 1px 0 #ece2d3; }
.key small {
  position: absolute; top: 3px; right: 5px;
  color: #b3a593; font-family: var(--mono); font-size: 7px; line-height: 1;
}
.key--wide { flex: 1.55; }
.key--dead { background: #f6f0e7; color: #b6a998; box-shadow: none; font-size: 9px; }
.key--space { flex: 6.8; font-size: 10px; }
.key.active {
  background: var(--teal); border-color: var(--teal); color: #fff;
  box-shadow: 0 3px 10px rgba(47, 111, 126, .28);
  transform: translateY(-1px);
}
.key.hit-ok { background: var(--green); border-color: var(--green); color: #fff; }
.key.hit-bad { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.kb-hint { color: var(--muted); font-size: 10px; text-align: right; }
.kb-hint kbd { font-size: 9px; }

.finger-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.finger-label::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.hands-layer {
  position: absolute; inset: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity .2s ease;
}
.hand-svg { position: absolute; overflow: hidden; filter: drop-shadow(0 1px 2px rgba(90, 70, 50, .08)); }
.hand-svg .outline {
  fill: none;
  stroke: #a79a8b;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: .95;
  vector-effect: non-scaling-stroke;
}
.hand-svg .palm-outline { opacity: .9; }
.hand-svg .finger-outline,
.hand-svg .thumb-outline { fill: none; stroke: none; }
.hand-svg .nail {
  fill: rgba(255, 255, 255, .32);
  stroke: #c8bdae;
  stroke-width: 1;
  opacity: .65;
  vector-effect: non-scaling-stroke;
}
.hand-svg .crease {
  fill: none;
  stroke: #c9beb0;
  stroke-width: 1;
  stroke-linecap: round;
  opacity: .55;
  vector-effect: non-scaling-stroke;
}
.hand-svg .finger-outline.on,
.hand-svg .thumb-outline.on { stroke: none; }
.reach-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.reach-path { fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .88; }
.reach-loop { fill: none; stroke: var(--red); stroke-width: 2.4; opacity: .7; }

.tip-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.tip-card .tag { flex: none; margin: 0; }
.tip-card > p { flex: 1; min-width: 200px; margin: 0; color: var(--ink-2); font-size: 11px; line-height: 1.7; }
.tip-card .tip-small { flex: none; max-width: 44%; margin: 0; padding: 0 0 0 12px; border-top: 0; border-left: 1px dashed var(--line); color: var(--muted); font-size: 10px; }

.practice.is-paused .kb,
.practice.is-paused .hands-layer { opacity: .35; pointer-events: none; }
.no-hints .hands-layer { display: none; }
.no-hints .key.active { background: #fffdf9; border-color: #e2d6c5; color: #5b5247; box-shadow: 0 2px 0 #ece2d3; transform: none; }
.no-stats .stats-card { display: none; }
.no-stats .practice-grid {
  grid-template-columns: 1fr;
  grid-template-areas: "stage" "keyboard" "tip";
}
.no-hanzi .hz, .no-hanzi .punct { opacity: 0; }

/* ============================================================
   overlays
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(43, 38, 32, .45);
  backdrop-filter: blur(7px);
  animation: fadeIn .18s ease;
}
.modal-card, .result-card {
  position: relative;
  width: min(560px, calc(100vw - 28px));
  max-height: min(88vh, 760px);
  overflow-y: auto;
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 26px 70px rgba(30, 22, 14, .3);
  animation: fadeUp .22s ease;
}
.modal-close, .result-close { position: absolute; top: 12px; right: 12px; }
.modal-card h2, .result-card h2 { margin-top: 6px; font-family: var(--serif); font-size: 28px; line-height: 1.25; }
.help-body { margin-top: 16px; }
.help-body ol { margin: 0; padding-left: 20px; }
.help-body li { margin-bottom: 12px; color: var(--ink-2); font-size: 13px; line-height: 1.8; }
.help-body li b { color: var(--ink); }
.help-note {
  margin-top: 12px; padding: 10px 12px;
  border-radius: 10px; background: var(--tea-soft);
  color: var(--ink-2); font-size: 11px; line-height: 1.75;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap; margin-top: 20px; }

.set-list { margin-top: 12px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: 0; }
.set-row b { font-size: 13px; }
.set-row p { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.set-row.is-disabled b { color: var(--muted); }
.set-na { color: var(--muted); font-size: 10px; white-space: nowrap; }
.switch {
  flex: none; width: 44px; height: 25px;
  padding: 2px; border: 0; border-radius: 999px;
  background: #ddd2c2;
  transition: background .18s ease;
}
.switch span { display: block; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); transition: transform .18s ease; }
.switch.on { background: var(--red); }
.switch.on span { transform: translateX(19px); }
.set-note { margin-top: 14px; color: var(--muted); font-size: 10px; }
.set-backup {
  margin-top: 16px; padding: 14px;
  border: 1px dashed var(--line-strong); border-radius: 12px;
  background: #fbf5ea;
}
.set-backup b { font-size: 13px; }
.set-backup p { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.progress-text {
  width: 100%; margin-top: 12px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fffdf9; color: var(--ink-2);
  font-family: var(--mono); font-size: 10px; line-height: 1.6;
  resize: vertical; word-break: break-all;
}
.progress-msg { min-height: 1.2em; margin-top: 8px; color: var(--wrong); font-size: 11px; }
.progress-msg.ok { color: var(--green); }

/* result */
.result-card { width: min(590px, calc(100vw - 28px)); text-align: center; padding-top: 30px; }
.result-card .eyebrow { justify-content: center; }
.stars { display: flex; justify-content: center; gap: 4px; margin: 10px 0 2px; }
.star { color: #ddd0bd; font-size: 34px; line-height: 1; opacity: .45; }
.star.on { color: var(--gold); opacity: 1; animation: starPop .45s ease both; }
.result-sub { color: var(--muted); font-size: 11px; }
.result-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 20px 0 16px;
}
.result-metrics > div { padding: 12px 6px; border-radius: 12px; background: #faf4ea; }
.result-metrics strong { display: block; font-family: var(--mono); font-size: 26px; font-weight: 500; line-height: 1.2; }
.result-metrics strong small { font-size: 13px; }
.result-metrics span { color: var(--muted); font-size: 10px; }
.mistakes { text-align: left; padding: 10px 12px; border-radius: 11px; background: #fbf6ed; }
.mistakes > span { color: var(--muted); font-size: 10px; }
.mistake-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.mistake-chips b { padding: 2px 8px; border-radius: 6px; background: var(--red-soft); color: var(--red-deep); font-family: var(--serif); font-size: 15px; font-weight: 400; }
.mistake-chips i { color: var(--muted); font-size: 10px; font-style: normal; align-self: center; }
.mistakes--clean { color: var(--green); background: var(--green-soft); font-size: 11px; }
.mistakes--clean > span { display: flex; align-items: center; gap: 5px; color: var(--green); font-size: 11px; }
.result-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.result-hint { margin-top: 10px; color: var(--muted); font-size: 10px; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes starPop { 0% { transform: scale(.4) rotate(-12deg); opacity: 0; } 70% { transform: scale(1.12) rotate(3deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 1080px) {
  .lesson-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { gap: 36px; }
}

@media (max-width: 980px) {
  .practice-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "stats" "stage" "keyboard" "tip";
  }
  .stats-card {
    flex-direction: row;
    padding: 4px 14px;
    order: 0;
  }
  .stat { flex: 1; padding: 8px 10px; border-bottom: 0; border-right: 1px solid var(--line); }
  .stat:last-child { border-right: 0; }
  .stat > span { font-size: 9px; }
  .stat strong { font-size: 20px; }
  .stat small { display: none; }
  .stage-card { height: 320px; }
}

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 44px; padding-bottom: 42px; }
  .hero-card { justify-self: start; max-width: 460px; transform: none; }
  .hero-card:hover { transform: translateY(-3px); }
  .section-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .section-note { text-align: left; }
  .lesson-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-card { padding: 26px 24px; }
  .note-mark { width: 50px; height: 50px; font-size: 28px; }
}

@media (max-width: 700px) {
  .wrap { padding: 0 16px; }
  .head-inner { height: 64px; }
  .brand-text b { font-size: 18px; }
  .seal { width: 34px; height: 34px; font-size: 19px; }
  .hero h1 { font-size: clamp(38px, 11vw, 54px); }
  .lede { font-size: 14px; }
  .hero-meta { gap: 8px 14px; font-size: 11px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .culture-cols { grid-template-columns: 1fr; }
  .cat { padding: 18px 16px 16px; border-radius: 18px; }
  .lesson-card { min-height: 0; }
  .foot-inner { padding-top: 12px; padding-bottom: 12px; }
  .foot-inner p { width: 100%; margin-right: 0; }

  .practice-wrap { padding-top: 12px; padding-bottom: 22px; }
  .topbar-inner { min-height: 58px; gap: 8px; }
  .lesson-title h1 { font-size: 16px; }
  .top-actions .icon-btn { width: 32px; height: 32px; }
  .top-actions .action-optional { display: none; }
  .pct { display: none; }
  .stage-card { height: 320px; min-height: 320px; padding: 16px 16px 10px; border-radius: 16px; }
  .syl .py { height: 40px; font-size: 24px; }
  .hz { font-size: 24px; line-height: 32px; }
  .punct { font-size: 22px; line-height: 32px; }
  .phrase { margin-right: 20px; margin-bottom: 10px; }
  .group--drill .py { font-size: 28px; height: 44px; }
  .group--drill { margin-right: 18px; margin-bottom: 10px; }
  .stage-foot { font-size: 10px; }
  .stage-tip { display: inline; font-size: 9px; }
  .stage-foot { flex-wrap: wrap; gap: 4px 10px; }
  .stats-card { border-radius: 14px; }
  .keyboard-card { padding: 6px 8px 8px; border-radius: 14px; }
  .keyboard-head { padding-bottom: 6px; }
  .kb-row { gap: 3px; margin-bottom: 3px; }
  .key { height: 28px; font-size: 10px; border-radius: 5px; }
  .key--dead { font-size: 8px; }
  .key small { display: none; }
  .kb-row--numbers { display: none; }
  .tip-card { padding: 10px 12px; border-radius: 14px; }
  .tip-card .tip-small { flex: 1 1 100%; max-width: none; border-left: 0; padding-left: 0; }
  .star { font-size: 30px; }
  .result-card { padding: 24px 18px 20px; }
  .result-metrics strong { font-size: 22px; }
  .result-actions .btn { flex: 1; padding-left: 10px; padding-right: 10px; }
}

@media (max-width: 560px) {
  .site-nav .nav-link { padding: 7px 8px; font-size: 12px; }
  .site-nav .nav-link[data-act="help"] { display: none; }
  .board-menu { width: 208px; }
  .hero { padding-top: 34px; gap: 28px; }
  .hero-actions .btn { width: 100%; }
  .hero-card { padding: 16px 16px 14px; }
  .hero-hz { font-size: 38px; }
  .hero-line { gap: 12px; margin: 20px 0 16px; }
  .mini-key { width: 26px; height: 25px; font-size: 11px; }
  .mini-space { display: none; }
  .cat-head { gap: 10px; }
  .cat-icon { width: 38px; height: 38px; }
  .cat-title h3 { font-size: 19px; }
  .cat-meta { display: none; }
  .note-card { flex-direction: column; gap: 14px; }
  .note-mark { width: 42px; height: 42px; font-size: 24px; }

  .kb-row--space .key--dead { display: none; }
  .kb-row--space .key--space { flex: 1; }
  .key--wide { flex: 1.4; }
  .key { height: 26px; font-size: 9px; }
  .key--space { font-size: 9px; }
  .finger-label { font-size: 9px; padding: 2px 8px; }
  .kb-hint { font-size: 9px; }
  .stats-card { padding: 2px 8px; }
  .stat { padding: 7px 4px; }
  .stat strong { font-size: 18px; }
  .result-metrics { gap: 6px; }
  .result-metrics > div { padding: 9px 3px; }
  .result-metrics strong { font-size: 20px; }
  .modal-card { padding: 22px 18px; }
  .modal-actions .btn { flex: 1; }
}

@media (max-width: 379px) {
  .wrap { padding: 0 12px; }
  .hero h1 { font-size: 36px; }
  .syl .py { font-size: 22px; }
  .hz { font-size: 22px; }
  .key { height: 24px; font-size: 8px; }
  .key--dead { font-size: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .hero-card { transform: none; }
}
