:root {
  --bg: #f6f9f6;
  --surface: #ffffff;
  --ink: #0f1a12;
  --muted: #56645a;
  --line: #dde6de;
  --green: #017114;
  --green-soft: #e6f3e8;
  --orange: #f77e2d;
  --orange-soft: #fff1e7;
  --red: #c62828;
  --red-soft: #fdecec;
  --gold: #f5b400;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 26, 18, .06), 0 6px 20px rgba(15, 26, 18, .06);
  --han: "Noto Serif SC", "KaiTi", "STKaiti", "Songti SC", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--green); }
button { font: inherit; color: inherit; }
.han { font-family: var(--han); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: rgba(246, 249, 246, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--green); color: #fff;
  font-family: var(--han); font-size: 24px; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: var(--muted); font-size: 12px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 8px 12px; border-radius: 999px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: 15px;
}
.nav a.active { background: var(--green-soft); color: var(--green); }
.chips { display: flex; gap: 6px; }
.chip {
  padding: 6px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}

main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }

/* ---------- Common ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 0; cursor: pointer; font-weight: 700; text-decoration: none;
  background: var(--green); color: #fff;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn.orange { background: var(--orange); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.eyebrow {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--orange-soft); color: #a8470c; font-weight: 700; font-size: 13px;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: clamp(28px, 5vw, 44px); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 24px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; margin-bottom: 12px; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: stretch; margin-bottom: 28px; }
.hero h1 { margin-top: 12px; }
.hero p { font-size: 17px; color: var(--muted); max-width: 56ch; }
.hero-eq {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 20px;
}
.eq {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.eq .han { font-size: 28px; font-weight: 700; }
.eq b { color: var(--green); }
.progress { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #34a853); border-radius: inherit; transition: width .4s ease; }

.daily { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; background: linear-gradient(160deg, #fff 0%, var(--orange-soft) 100%); }
.daily-top { display: flex; align-items: center; gap: 18px; }
.daily-char {
  display: grid; place-items: center; flex: none;
  width: 112px; height: 112px; border-radius: 22px;
  background: #fff; border: 2px dashed #f6b48a;
  font-family: var(--han); font-size: 72px; font-weight: 700; line-height: 1;
}
.daily .hv { font-size: 26px; font-weight: 800; color: var(--orange); text-transform: capitalize; }

.chapter { margin-bottom: 18px; }
.chapter-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.chapter-badge {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: 16px; color: #fff;
  font-family: var(--han); font-size: 26px; font-weight: 700;
}
.chapter-head p { margin: 0; color: var(--muted); font-size: 15px; }
.chapter-meta { margin-left: auto; text-align: right; font-weight: 700; font-size: 14px; white-space: nowrap; }
.chapter.locked .tiles { opacity: .45; filter: grayscale(.6); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 10px 6px 8px; border-radius: 16px; cursor: pointer;
  background: var(--bg); border: 2px solid transparent; text-decoration: none; color: var(--ink);
  transition: transform .1s ease, border-color .15s ease;
}
.tile:hover { transform: translateY(-2px); border-color: var(--line); }
.tile .han { font-size: 40px; font-weight: 700; line-height: 1.2; }
.tile .hv { font-size: 13px; font-weight: 700; color: var(--muted); }
.tile .stars { font-size: 11px; letter-spacing: 1px; min-height: 16px; }
.tile.done { background: var(--green-soft); }
.lock-note { font-size: 14px; color: var(--muted); margin: 10px 0 0; }

/* ---------- Character view ---------- */
.learn { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 24px; align-items: start; }
.pad-card { position: sticky; top: 84px; text-align: center; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.step {
  min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  font-weight: 700; font-size: 14px; cursor: pointer; padding: 6px 4px;
}
.step.active { background: var(--green); color: #fff; border-color: var(--green); }
.step.done:not(.active) { background: var(--green-soft); color: var(--green); border-color: #bfe0c4; }
.pad {
  position: relative; margin: 0 auto; width: 100%; max-width: 340px; aspect-ratio: 1;
  border-radius: 16px; background: #fffdf8; border: 2px solid #e9c9a8; touch-action: none;
}
.pad svg.grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pad .target { position: absolute; inset: 0; }
.pad .target svg { display: block; }
.pad-hint { min-height: 48px; margin: 12px 0 8px; font-weight: 600; }
.pad-hint.good { color: var(--green); }
.pad-hint.oops { color: var(--red); }
.pad-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.info { display: flex; flex-direction: column; gap: 16px; }
.id-card { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.id-card .big-han { font-family: var(--han); font-size: 88px; font-weight: 700; line-height: 1; }
.id-card .hv-big { font-size: 34px; font-weight: 800; color: var(--green); text-transform: uppercase; letter-spacing: .02em; }
.id-card .py { font-size: 22px; font-weight: 600; }
.id-card .meaning { font-size: 18px; }
.speak {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--orange-soft); cursor: pointer; font-size: 20px; vertical-align: middle;
}
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.story { font-size: 17px; }
.parts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-weight: 700; }
.parts a {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 12px;
  background: var(--green-soft); text-decoration: none; color: var(--ink);
}
.parts a .han { font-size: 22px; }
.known { border: 2px solid #bfe0c4; background: linear-gradient(160deg, #fff, var(--green-soft)); }
.known h3::before { content: "💡 "; }
.word-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.word-list li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.word-list .w { font-weight: 800; font-size: 18px; }
.word-list mark { background: #ffe08a; border-radius: 4px; padding: 0 2px; color: inherit; }
.word-list .han { font-size: 22px; font-weight: 700; }
.trap { border: 2px dashed #f2a3a3; background: var(--red-soft); }
.story a.han, .trap a.han {
  font-size: 1.25em; font-weight: 700; text-decoration: none; color: var(--green);
  border-bottom: 2px dotted currentColor; padding: 0 1px;
}
.trap h3::before { content: "⚠️ "; }
.nav-chars { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- Games ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.game-card { display: flex; flex-direction: column; gap: 10px; }
.game-card .icon { font-size: 40px; }
.game-card p { margin: 0; color: var(--muted); flex: 1; }
.play { max-width: 640px; margin: 0 auto; text-align: center; }
.play-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.play-top .progress { flex: 1; }
.question .q-han { font-family: var(--han); font-size: 120px; font-weight: 700; line-height: 1.1; }
.question .q-word { font-size: 34px; font-weight: 800; margin: 16px 0 4px; }
.question .q-word mark { background: #ffe08a; border-radius: 6px; padding: 0 6px; }
.question .q-sub { color: var(--muted); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.option {
  min-height: 72px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface);
  font-size: 22px; font-weight: 800; cursor: pointer; text-transform: capitalize;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
.option.han { font-size: 44px; font-weight: 700; }
.option:hover:not([disabled]) { border-color: var(--green); }
.option:active:not([disabled]) { transform: scale(.97); }
.option.right { background: var(--green-soft); border-color: var(--green); }
.option.wrong { background: var(--red-soft); border-color: var(--red); }
.feedback { min-height: 56px; margin-top: 16px; font-weight: 600; font-size: 17px; }
.feedback.good { color: var(--green); }
.feedback.oops { color: var(--red); }

/* ---------- Parent ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { text-align: center; }
.stat b { display: block; font-size: 34px; font-weight: 800; color: var(--green); }
.chapter-row { display: grid; grid-template-columns: 180px 1fr 70px; gap: 12px; align-items: center; margin: 10px 0; }
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: #fff7d6; border: 1px solid #f3d36b; font-weight: 700;
}
.badge.off { background: var(--bg); border-color: var(--line); color: var(--muted); filter: grayscale(1); }
.review-list { display: flex; flex-wrap: wrap; gap: 8px; }
.review-list a { font-family: var(--han); font-size: 30px; font-weight: 700; text-decoration: none; color: var(--ink); padding: 4px 12px; border-radius: 12px; background: var(--orange-soft); }

/* ---------- Celebration ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(15, 26, 18, .45);
}
.overlay .card { max-width: 380px; width: 100%; text-align: center; animation: pop .3s ease; }
.overlay .big-stars { font-size: 44px; letter-spacing: 4px; margin: 8px 0; }
.overlay .big-stars .off { filter: grayscale(1); opacity: .3; }
.overlay .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 600; text-align: center;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.footer { max-width: 1080px; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.footer p { margin: 4px 0; }

/* ---------- Nav badge, home call-to-action ---------- */
.nav-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; padding: 0 6px;
  border-radius: 999px; background: var(--orange); color: #fff; font-size: 12px; font-weight: 800; vertical-align: 1px;
}
.nav-badge[hidden] { display: none; }
.cta-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
  text-decoration: none; color: inherit; border: 2px solid #f6c39f; background: var(--orange-soft);
}
.cta-row.soft { border-color: var(--line); background: var(--surface); }
.cta-row > span:nth-child(2) { flex: 1; }
.cta-icon { font-size: 34px; flex: none; }

/* ---------- Basic strokes ---------- */
.glyph { display: inline-block; width: 1em; height: 1em; color: var(--ink); vertical-align: middle; }
.glyph svg { display: block; width: 100%; height: 100%; }
.tile .glyph { width: 48px; height: 48px; }
.id-card .big-han.glyph { width: 88px; height: 88px; }
.overlay .glyph { width: 72px; height: 72px; }
.warmup { border: 2px dashed #e2b6d9; background: linear-gradient(160deg, #fff, #fbf1f9); }
.rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.rules li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; background: var(--bg); font-weight: 600; }
.rules a.han { font-size: 28px; font-weight: 700; text-decoration: none; color: var(--green); }

/* ---------- Review ---------- */
.review-hero { text-align: center; margin: 16px 0; }
.due-big { font-size: 72px; font-weight: 800; color: var(--orange); line-height: 1; }
.review-preview { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.review-preview span { padding: 2px 10px; border-radius: 999px; background: var(--orange-soft); font-weight: 700; text-transform: capitalize; }
.boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.box { display: flex; flex-direction: column; align-items: center; padding: 12px 6px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); text-align: center; }
.box b { font-size: 28px; line-height: 1.1; }
.box span { font-weight: 700; font-size: 14px; }
.box small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.box-chars { margin-top: 6px; font-size: 18px; word-break: break-all; }
.box.b1 b { color: var(--red); } .box.b2 b, .box.b3 b { color: var(--orange); } .box.b4 b, .box.b5 b, .box.b6 b { color: var(--green); }
.play-top { max-width: 1080px; }
.recall-ask { font-size: 22px; margin: 14px 0 4px; }
.recall-ask b { font-size: 40px; color: var(--green); text-transform: uppercase; letter-spacing: .02em; }
.recall .q-word { font-size: 30px; font-weight: 800; }
.recall .q-word mark { background: #ffe08a; border-radius: 6px; padding: 0 6px; }
.review-result { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0; }
.review-result a { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 12px; text-decoration: none; font-weight: 800; }
.review-result a .han { font-size: 28px; }
.review-result .ok { background: var(--green-soft); color: var(--green); }
.review-result .no { background: var(--red-soft); color: var(--red); }

/* ---------- Parent tools ---------- */
.parent-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.steps-list { margin: 0 0 12px; padding-left: 20px; }
.steps-list li { margin: 4px 0; }
.ok-line { font-weight: 700; color: var(--green); }
label.btn { cursor: pointer; }

/* ---------- Worksheet ---------- */
.sheet-form { margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 16px 0; }
.form-grid label, .seg legend { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }
.form-grid label[hidden] { display: none; }
.form-grid select, .form-grid input[type=text] {
  min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line);
  font: inherit; font-weight: 500; background: #fff;
}
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.seg legend { padding: 0; margin-bottom: 6px; }
.seg label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; font-size: 15px; }
.sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; color: #111; }
.ws-empty { text-align: center; margin: 24px 0; }
.ws-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 14px; }
.ws-head b { display: block; font-size: 20px; }
.ws-head span { font-size: 12px; color: #555; }
.ws-name { font-size: 14px; }
.ws-missing { color: var(--red); font-weight: 600; }
.ws-block { margin-bottom: 18px; break-inside: avoid; page-break-inside: avoid; }
.ws-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 6px; font-size: 14px; }
.ws-hv { font-size: 18px; text-transform: uppercase; color: var(--green); }
.ws-count { margin-left: auto; color: #555; }
.ws-order { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; }
.ws-step { width: 34px; height: 34px; color: #111; }
.ws-step svg, .ws-cell svg { display: block; width: 100%; height: 100%; }
.ws-row { display: grid; grid-template-columns: repeat(10, 1fr); }
.ws-cell { aspect-ratio: 1; color: #111; margin: 0 -0.5px -1px 0; }

/* ---------- Levels and search ---------- */
.search-box { margin: 12px 0 14px; }
.search-box input { width: 100%; min-height: 48px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font: inherit; }
.search-box input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
#search-results:not(:empty) { margin-top: 12px; }
#search-results .stars { font-size: 11px; letter-spacing: 0; color: var(--muted); text-align: center; line-height: 1.2; min-height: 0; }
.caps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.cap-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 64px; padding: 8px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; font-size: 13px; line-height: 1.25; }
.cap-tab b { font-size: 15px; }
.cap-tab small { color: var(--muted); font-size: 12px; }
.cap-tab.active { background: var(--green); border-color: var(--green); color: #fff; }
.cap-tab.active small { color: #d8efdc; }
.cap-note { margin: 0 0 14px; }
.cap-detail summary { cursor: pointer; list-style: none; }
.cap-detail summary::-webkit-details-marker { display: none; }
.cap-detail summary .chapter-row > span:first-child { font-weight: 700; }
.cap-detail[open] > .chapter-row { padding-left: 12px; font-size: 14px; }

/* ---------- Account ---------- */
.nav a[hidden] { display: none; }
.chip-account { text-decoration: none; color: var(--ink); max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.auth { max-width: 460px; margin: 0 auto; }
.auth h1 { font-size: 28px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; font-weight: 600; font-size: 15px; }
.field input { min-height: 46px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 400; }
.field input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.form-err { min-height: 1.4em; margin: 8px 0; color: var(--red); font-weight: 600; }
.form-ok { color: var(--green); font-weight: 600; }
.auth-links { margin: 14px 0 0; font-size: 15px; color: var(--muted); }
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kid p { margin: 4px 0 10px; }
.kid.on { border: 2px solid #bfe0c4; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; max-width: 460px; margin-bottom: 16px; }
.inline-form .field { margin: 0; }
.inline-form .form-err { grid-column: 1 / -1; margin: 0; }
.block { margin-bottom: 16px; }
details.block summary { cursor: pointer; }
.danger { border-color: #f2a3a3; }
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.day { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.day.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.adm-tools { display: grid; grid-template-columns: 1fr 180px; gap: 8px; margin-bottom: 12px; }
.adm-tools input, .adm-tools select { min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.adm-table th, .adm-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.adm-table th { font-weight: 700; color: var(--muted); white-space: nowrap; }
.adm-table tr:last-child td { border-bottom: 0; }
.tag.off { background: var(--red-soft); color: var(--red); border-color: #f2a3a3; }
.copy-link { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); font: inherit; font-size: 14px; }

/* ---------- Touch devices ---------- */
.pad, .pad * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html { overscroll-behavior-y: contain; }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }
/* Máy tính bảng nằm ngang: bảng viết to hơn. */
@media (min-width: 861px) and (pointer: coarse) {
  .learn { grid-template-columns: minmax(360px, 480px) 1fr; }
  .pad { max-width: 440px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero, .learn { grid-template-columns: 1fr; }
  .pad-card { position: static; }
  .review-layout .recall { order: -1; }
  .parent-tools { grid-template-columns: 1fr; }
  .boxes { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .nav a { flex: 1; text-align: center; padding: 8px 6px; font-size: 14px; }
  .chips { margin-left: auto; }
  main { padding-top: 16px; }
  .chapter-head { flex-wrap: wrap; }
  .chapter-meta { margin-left: 0; text-align: left; width: 100%; }
  .tiles { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .tile .han { font-size: 32px; }
  .id-card .big-han { font-size: 72px; }
  .question .q-han { font-size: 96px; }
  .chapter-row { grid-template-columns: 1fr 60px; }
  .chapter-row .progress { grid-column: 1 / -1; grid-row: 2; }
  .tile .glyph { width: 38px; height: 38px; }
  .pad { max-width: 100%; }
  .nav a { padding: 8px 2px; font-size: 13.5px; }
  .cta-row { flex-wrap: wrap; }
  .cta-row .btn { width: 100%; }
  .review-layout { gap: 12px; }
  .review-layout .recall { padding: 12px 16px; }
  .review-layout .recall p { margin: 4px 0; font-size: 15px; }
  .recall-ask { font-size: 18px; }
  .recall-ask b { font-size: 28px; }
  .recall .q-word { font-size: 22px; }
  .review-layout .pad-card { padding: 12px; }
  .review-layout .pad { max-width: min(100%, 50vh); }
  .review-layout .pad-hint { min-height: 0; margin: 8px 0; }
  .chip-account { max-width: 104px; }
  .brand-text small { display: none; }
  .chips { flex-wrap: nowrap; }
  .chip { padding: 5px 8px; }
  .adm-tools { grid-template-columns: 1fr; }
  .days { gap: 2px; }
  .day { font-size: 10px; border-radius: 6px; }
  .caps { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .cap-tab { flex: none; min-width: 118px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 12px 6px; font-size: 13px; line-height: 1.3; }
  .stat b { font-size: 24px; }
  .sheet { padding: 12px; }
  .ws-step { width: 28px; height: 28px; }
}
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .topbar, .footer, .toast, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .sheet { border: 0; border-radius: 0; padding: 0; }
  .ws-step { width: 9mm; height: 9mm; }
  .ws-hv { color: #000; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* Điện thoại hẹp: bỏ chữ cạnh logo để giữ thanh trên cùng thấp, nhường chỗ cho bảng viết. */
@media (max-width: 430px) {
  .brand-text { display: none; }
}
@media (max-width: 640px) {
  .nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav a { flex: 1 0 auto; white-space: nowrap; padding: 8px 6px; }
}
