/* Hán Việt Ơi. Ý tưởng: vở ô ly của học trò Việt, bút đỏ thầy cô, bút dạ quang; màu theo thương hiệu DucIT.vn. */
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 400; font-display: swap; src: url(../fonts/be-vietnam-pro-vietnamese-400-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 400; font-display: swap; src: url(../fonts/be-vietnam-pro-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 400; font-display: swap; src: url(../fonts/be-vietnam-pro-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 600; font-display: swap; src: url(../fonts/be-vietnam-pro-vietnamese-600-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 600; font-display: swap; src: url(../fonts/be-vietnam-pro-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 600; font-display: swap; src: url(../fonts/be-vietnam-pro-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Bricolage Grotesque'; font-weight: 800; font-display: swap; src: url(../fonts/bricolage-grotesque-vietnamese-800-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Bricolage Grotesque'; font-weight: 800; font-display: swap; src: url(../fonts/bricolage-grotesque-latin-ext-800-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+1E00-1E9F; }
@font-face { font-family: 'Bricolage Grotesque'; font-weight: 800; font-display: swap; src: url(../fonts/bricolage-grotesque-latin-800-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+2000-206F; }
@font-face { font-family: 'Patrick Hand'; font-weight: 400; font-display: swap; src: url(../fonts/patrick-hand-vietnamese-400-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Patrick Hand'; font-weight: 400; font-display: swap; src: url(../fonts/patrick-hand-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+1E00-1E9F; }
@font-face { font-family: 'Patrick Hand'; font-weight: 400; font-display: swap; src: url(../fonts/patrick-hand-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+2000-206F; }

:root {
  --paper: #f6f9f6;
  --grid: #E3ECE4;
  --margin: #BFDCC4;
  --ink: #0f1a12;
  --ink-2: #56645a;
  --green: #017114;
  --green-d: #01540F;
  --green-soft: #e6f3e8;
  --orange: #f77e2d;
  --orange-d: #a8470c;
  --orange-soft: #fff1e7;
  --red: #c62828;
  --marker: #FFDF7E;
  --ok: #017114;
  --ok-soft: #d8efdc;
  --bad-soft: #fdecec;
  --card: #fff;
  --line: #dde6de;
  --han: 'KaiTi', 'STKaiti', 'Kaiti SC', 'BiauKai', 'Noto Serif CJK SC', 'Source Han Serif SC', 'Songti SC', 'SimSun', serif;
  --body: 'Be Vietnam Pro', 'Segoe UI', system-ui, sans-serif;
  --display: 'Bricolage Grotesque', 'Be Vietnam Pro', system-ui, sans-serif;
  --hand: 'Patrick Hand', 'Comic Sans MS', cursive;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 400 16px/1.55 var(--body);
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 800; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .7em; }
a { color: var(--green); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 6px; }
.han { font-family: var(--han); }
.muted { color: var(--ink-2); }
.tiny { font-size: .8rem; }
.block { display: block; }
.center { text-align: center; justify-content: center; }
.row { display: flex; gap: .5rem; align-items: center; }
.wrap { flex-wrap: wrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 50; background: #fff; padding: .5rem 1rem; }
.ico { display: inline-flex; width: 1.3em; height: 1.3em; }
.ico svg { width: 100%; height: 100%; }

/* Khung */
#shell { min-height: 100dvh; }
#main { padding: 1rem 1rem 6.5rem; max-width: 760px; margin: 0 auto; outline: none; }
.page > * + * { margin-top: 1rem; }
#nav { position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; background: #fff; border-top: 2px solid var(--ink); padding-bottom: env(safe-area-inset-bottom); }
.brand { display: none; }
.nav-items { display: grid; grid-template-columns: repeat(5, 1fr); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .4rem .1rem .45rem; text-decoration: none; color: var(--ink-2); font-size: .72rem; font-weight: 600; }
.nav-han { position: relative; width: 32px; height: 32px; display: grid; place-items: center; font-size: 22px; line-height: 1; border: 1.5px dashed var(--line); border-radius: 3px; background: linear-gradient(var(--grid), var(--grid)) center/100% 1px no-repeat, linear-gradient(var(--grid), var(--grid)) center/1px 100% no-repeat; }
.nav-item.active { color: var(--green); }
.nav-item.active .nav-han { border: 2px solid var(--green); color: #fff; background: var(--green); }
.nav-badge { position: absolute; top: -7px; right: -11px; background: var(--red); color: #fff; font: 600 .65rem/1 var(--body); padding: 3px 5px; border-radius: 9px; }
body.no-nav #nav, body.focus-mode #nav { display: none; }
body.no-nav #main, body.focus-mode #main { padding-bottom: 1rem; }
@media (min-width: 900px) {
  #nav { top: 0; right: auto; bottom: 0; width: 200px; border-top: 0; border-right: 2px solid var(--margin); padding: 1.1rem .7rem; }
  .brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); margin-bottom: 1.5rem; padding: 0 .4rem; }
  .brand-box { width: 34px; height: 34px; display: grid; place-items: center; background: var(--green); color: #fff; font-size: 24px; border-radius: 3px; }
  .brand-name { font: 800 1.05rem/1.1 var(--display); }
  .nav-items { display: flex; flex-direction: column; gap: .25rem; }
  .nav-item { flex-direction: row; gap: .65rem; font-size: .95rem; padding: .45rem .4rem; border-radius: 8px; }
  .nav-item:hover { background: var(--green-soft); }
  #main { margin-left: max(200px, calc(50vw - 280px)); padding: 2rem 1.5rem 3rem; }
  body.no-nav #main, body.focus-mode #main { margin-left: auto; }
}

/* Nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.05rem; border-radius: 10px; border: 2px solid transparent; font-weight: 600; text-decoration: none; transition: transform .08s; }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-d); }
.btn-primary:active { box-shadow: 0 1px 0 var(--green-d); }
.btn-ghost { background: #fff; color: var(--green); border-color: var(--green); }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn-full { width: 100%; }
.btn-link { display: block; margin: .9rem auto 0; background: none; border: 0; color: var(--ink-2); text-decoration: underline; min-height: 40px; }
.btn-audio { display: inline-flex; align-items: center; gap: .3rem; min-width: 44px; min-height: 44px; justify-content: center; padding: 0 .55rem; border-radius: 22px; background: var(--green-soft); border: 0; color: var(--green); vertical-align: middle; }
.btn-audio .lbl { font-size: .8rem; font-weight: 600; }
.btn-audio.playing { background: var(--green); color: #fff; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; background: none; border: 0; color: var(--ink-2); flex: none; }
.mic { width: 52px; height: 52px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--orange); color: var(--ink); font-size: 1.05rem; box-shadow: 0 3px 0 #C85F17; }
.mic.big { width: 76px; height: 76px; font-size: 1.6rem; margin: .5rem; }
.mic.on { animation: pulse 1s infinite; background: var(--ink); color: #fff; box-shadow: none; }
.btn-speak { background: var(--orange); color: var(--ink); box-shadow: 0 3px 0 #C85F17; }
.btn-orange { background: var(--orange); color: var(--ink); box-shadow: 0 3px 0 #C85F17; }
.btn-speak.on { background: var(--ink); color: #fff; box-shadow: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(247, 126, 45, .3); } }

/* Trang chính */
.hero { font-size: clamp(2rem, 7vw, 3rem); letter-spacing: -.02em; line-height: 1.08; margin-bottom: .6rem; }
.hero-mark { background: linear-gradient(transparent 58%, var(--marker) 58%, var(--marker) 92%, transparent 92%); padding: 0 .1em; }
.compose-box { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: .6rem; }
.compose-box textarea { display: block; width: 100%; border: 0; resize: none; background: none; font: 400 1.5rem/1.3 var(--hand); color: var(--green-d); padding: .25rem .35rem .5rem; outline: none; }
.compose-box textarea::placeholder { color: #8A968D; }
.compose-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; }
.seg { display: inline-flex; background: var(--green-soft); border-radius: 10px; padding: 3px; }
.seg-b { border: 0; background: none; padding: .35rem .6rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); border-radius: 8px; min-height: 36px; }
.seg-b.on { background: #fff; color: var(--green); }
.listen-status { color: var(--orange-d); font-weight: 600; margin: .5rem 0 0; min-height: 1.4em; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.chip { background: #fff; border: 1.5px solid var(--line); border-radius: 18px; padding: .35rem .75rem; font-size: .85rem; color: var(--ink); min-height: 36px; text-align: left; }
.chip:hover { border-color: var(--green); }

/* Thẻ */
.card { display: block; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 1rem; }
.card-link { text-decoration: none; color: var(--ink); }
.card-link:hover { border-color: var(--green); }
.card-link b { display: block; }
.eyebrow { display: block; font: 400 1.05rem/1.2 var(--hand); color: var(--orange-d); }
.notice { background: var(--orange-soft); border: 1.5px solid #F9C9A6; border-radius: 12px; padding: .75rem 1rem; font-size: .9rem; }
.note-pen { font: 400 1.14rem/1.32 var(--hand); color: var(--red); margin: .5rem 0; }
.hv-mark { font-family: var(--hand); color: var(--green-d); background: linear-gradient(transparent 55%, var(--marker) 55%); padding: 0 .12em; }
.false-box { background: var(--bad-soft); border-left: 4px solid var(--red); padding: .55rem .75rem; border-radius: 4px; margin: .6rem 0; font-size: .92rem; }

/* Ô chữ ba tầng */
.cells { display: flex; flex-wrap: wrap; gap: .55rem .35rem; align-items: flex-end; }
.cells.center { justify-content: center; }
.cell { display: inline-flex; gap: 0; background: none; border: 0; padding: 2px; border-radius: 6px; color: inherit; }
button.cell:hover .cell-box { background-color: var(--green-soft); }
.cell-col { display: inline-flex; flex-direction: column; align-items: center; }
.cell-py { font-size: .72rem; color: var(--ink-2); min-height: 1.15em; line-height: 1.2; white-space: nowrap; }
.cell-box { display: grid; place-items: center; width: 42px; height: 42px; background: #fff; border: 1.5px solid var(--green); margin-left: -1.5px;
  background-image: linear-gradient(#CFE3D3, #CFE3D3), linear-gradient(#CFE3D3, #CFE3D3); background-size: 100% 1px, 1px 100%; background-position: center; background-repeat: no-repeat; }
.cell-col:first-child .cell-box { margin-left: 0; }
.cell-han { font-family: var(--han); font-size: 32px; line-height: 1; }
.cell-hv { font: 400 .92rem/1.2 var(--hand); color: var(--green-d); min-height: 1.15em; white-space: nowrap; }
.cell-sm .cell-box { width: 34px; height: 34px; } .cell-sm .cell-han { font-size: 26px; } .cell-sm .cell-py { font-size: .66rem; } .cell-sm .cell-hv { font-size: .82rem; }
.cell-lg .cell-box { width: 54px; height: 54px; } .cell-lg .cell-han { font-size: 42px; } .cell-lg .cell-py { font-size: .85rem; } .cell-lg .cell-hv { font-size: 1.05rem; }
.cell-xl .cell-box { width: 96px; height: 96px; } .cell-xl .cell-han { font-size: 76px; } .cell-xl .cell-py { font-size: 1.15rem; } .cell-xl .cell-hv { font-size: 1.4rem; }
.cell-punct { font-family: var(--han); font-size: 1.5rem; align-self: center; padding: 0 2px; }
.is-false .cell-box { border-color: var(--red); }

/* Kết quả */
.result-area:empty { display: none; }
.result { border: 2.5px solid var(--green); }
.res-vi { font: 400 1.25rem/1.3 var(--hand); color: var(--ink-2); }
.res-hint { font-size: .78rem; margin-top: .6rem; }
.res-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin: .7rem 0; }
.res-alt { background: var(--green-soft); padding: .5rem .7rem; border-radius: 10px; }
.res-words { border-top: 1.5px dashed var(--line); padding-top: .8rem; margin-top: .8rem; }
.word-list, .phrase-list, .plain-list, .ex-list, .lesson-list, .quests, .sound-list, .mistakes { list-style: none; padding: 0; margin: 0; }
.plain-list li { margin-bottom: .55rem; }
.word-list > li { display: flex; align-items: center; gap: .25rem; }
.word-row { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(3.2rem, auto) minmax(4.4rem, auto) minmax(4.2rem, auto) 1fr; column-gap: .55rem; align-items: baseline; background: none; border: 0; border-bottom: 1px solid var(--grid); padding: .5rem .15rem; text-align: left; }
.word-row:hover { background: var(--green-soft); }
.word-row .hv-mark { justify-self: start; }
.word-han { font-size: 1.4rem; line-height: 1.2; }
.word-py { font-size: .85rem; }
.word-m { font-size: .88rem; }
@media (max-width: 520px) { .word-row { grid-template-columns: auto 1fr; row-gap: 0; } .word-m { grid-column: 1 / -1; } }
.speak-panel { border-top: 1.5px dashed var(--line); margin-top: .8rem; padding-top: .8rem; }
.speak-out { margin-top: .6rem; }
.speak-score b { font: 800 1.6rem var(--display); }
.speak-score.good b { color: var(--ok); } .speak-score.try b { color: var(--red); }
.speak-chars { font-size: 1.9rem; letter-spacing: .1em; margin: .2rem 0; }
.hit { color: var(--ok); } .miss { color: var(--red); text-decoration: underline wavy; text-underline-offset: 4px; }
.rec-box { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.rec-box audio { max-width: 100%; height: 40px; }
.fail { border-color: var(--red); }
.loading { color: var(--ink-2); }

/* Tiến độ hôm nay */
.today { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 1rem; }
.today-stats { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-bottom: .5rem; font-size: .9rem; }
.stat-flame { color: var(--red); vertical-align: -4px; display: inline-flex; margin-right: .15rem; }
.bar { height: 10px; background: var(--green-soft); border-radius: 5px; overflow: hidden; flex: 1; }
.bar span { display: block; height: 100%; background: var(--green); border-radius: 5px; transition: width .3s; }
.today-cards { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .8rem; }
.today-cards .card { padding: .7rem .8rem; }
@media (max-width: 480px) { .today-cards { grid-template-columns: 1fr; } }
.book summary { cursor: pointer; font-weight: 600; padding: .55rem 0; }
.book-group { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: .1rem .8rem; margin-bottom: .4rem; }
.book-group summary { cursor: pointer; font-weight: 600; padding: .55rem 0; }
.phrase-list li { display: flex; align-items: center; gap: .25rem; border-top: 1px solid var(--grid); }
.phrase { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: .5rem 0; display: flex; flex-direction: column; }

/* Lộ trình */
.page-head { display: flex; gap: .5rem; align-items: flex-start; }
.back { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; color: var(--ink); margin-left: -.5rem; }
.unit { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 1rem; }
.unit-head { display: flex; gap: .7rem; align-items: center; margin-bottom: .55rem; }
.unit-head h2 { margin: 0; }
.unit-head p { margin: 0; font-size: .85rem; }
.unit-icon { flex: none; width: 50px; height: 50px; display: grid; place-items: center; font-size: 36px; background-color: #fff; border: 2px solid var(--green); background-image: linear-gradient(#CFE3D3, #CFE3D3), linear-gradient(#CFE3D3, #CFE3D3); background-size: 100% 1px, 1px 100%; background-position: center; background-repeat: no-repeat; }
.lesson-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .5rem; color: var(--ink); text-decoration: none; border-top: 1px solid var(--grid); min-height: 52px; }
.lesson-row:hover { background: var(--green-soft); }
.lesson-row.next { background: #fff1e7; }
.lesson-title { font-weight: 600; display: flex; flex-direction: column; }
.lesson-sample { font-weight: 400; font-size: .95rem; }
.mini-grade { font: 400 1.5rem/1 var(--hand); color: var(--red); border: 2px solid var(--red); border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; transform: rotate(-6deg); flex: none; }
.pill { background: var(--green); color: #fff; border-radius: 12px; padding: .15rem .6rem; font-size: .78rem; font-weight: 600; flex: none; }
.unit-extra { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.unit-extra .btn { flex: 1 1 auto; font-size: .88rem; }
.story { position: relative; }

/* Phiên bài tập */
.session { max-width: 620px; margin: 0 auto; min-height: calc(100dvh - 2rem); display: flex; flex-direction: column; }
.session-head { display: flex; align-items: center; gap: .4rem; }
.stage { flex: 1; padding: 1rem 0 8rem; }
.step { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 1.1rem; }
.step > * + * { margin-top: .8rem; }
.ask { font-family: var(--display); font-weight: 800; font-size: 1.1rem; margin: 0; }
.prompt-vi { font: 400 1.3rem/1.3 var(--hand); color: var(--green-d); }
.intro-m { text-align: center; font-size: 1.25rem; font-weight: 600; }
.options { display: grid; gap: .5rem; }
.option { text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: .7rem .9rem; min-height: 50px; }
.option:hover:not(:disabled) { border-color: var(--green); }
.han-opt { font-family: var(--han); font-size: 1.6rem; line-height: 1.2; }
.option.right { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--red); background: var(--bad-soft); }
.foot { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .6rem; padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom)); }
.foot:empty { display: none; }
.foot.ok { background: var(--ok-soft); border-top: 2px solid var(--ok); }
.foot.bad { background: var(--bad-soft); border-top: 2px solid var(--red); }
.foot-msg { flex: 1 1 240px; }
.foot-msg p { margin: 0; font-size: .92rem; }
.foot.ok .foot-msg b { color: var(--ok); } .foot.bad .foot-msg b { color: var(--red); }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.match-col { display: grid; gap: .5rem; align-content: start; }
.tile { background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: .55rem .6rem; min-height: 50px; }
.tile.sel { border-color: var(--green); background: var(--green-soft); }
.tile.gone { opacity: .35; border-style: dashed; }
.tile.shake { border-color: var(--red); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.order-line { min-height: 66px; border-bottom: 2.5px solid var(--green); display: flex; flex-wrap: wrap; gap: .4rem; padding: .4rem 0; align-items: flex-end; }
.order-bank { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; min-height: 58px; }
.big-z { font-size: 1.45rem; }
.ex-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; padding: .35rem 0; border-top: 1px solid var(--grid); }
.finish { text-align: center; padding: 1.5rem .5rem; }
.finish > * + * { margin-top: .6rem; }
.red-grade { position: relative; width: 130px; height: 130px; margin: 0 auto; color: var(--red); transform: rotate(-7deg); animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1); }
.red-num { position: absolute; inset: 0; display: grid; place-items: center; font: 400 4.6rem/1 var(--hand); }
.red-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
@keyframes stamp { from { transform: rotate(-7deg) scale(1.8); opacity: 0; } }
.big-num { font: 800 3.4rem/1 var(--display); color: var(--green); margin: 0; }

/* Ôn tập */
.review-home { text-align: center; }
.flash { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 1.1rem; }
.flash > * + * { margin-top: .7rem; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.grade { display: flex; flex-direction: column; align-items: center; padding: .5rem .1rem; border-radius: 10px; border: 2px solid var(--line); background: #fff; min-height: 56px; }
.grade.g0 { border-color: var(--red); color: var(--red); }
.grade.g3 { border-color: var(--ok); color: var(--ok); }
.mistakes { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }

/* Khám phá */
.explore { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .7rem; }
.explore-item { display: flex; gap: .75rem; align-items: flex-start; }
.explore-item.wide { grid-column: 1 / -1; border: 2.5px solid var(--green); }
.explore-han { flex: none; width: 52px; height: 52px; display: grid; place-items: center; font-size: 38px; line-height: 1; background-color: #fff; border: 1.5px solid var(--green); background-image: linear-gradient(#CFE3D3, #CFE3D3), linear-gradient(#CFE3D3, #CFE3D3); background-size: 100% 1px, 1px 100%; background-position: center; background-repeat: no-repeat; }
.tabs { display: flex; gap: .3rem; overflow-x: auto; border-bottom: 2px solid var(--line); scrollbar-width: none; }
.tab { flex: none; padding: .55rem .8rem; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.on { color: var(--green); border-color: var(--green); }
.bridge-body > * + * { margin-top: .9rem; }
.guess-input, .dict-input, .field input, .field select, select { width: 100%; padding: .65rem .8rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.guess-input:focus, .dict-input:focus, .field input:focus { border-color: var(--green); outline: none; }
.guess-out { margin-top: .6rem; min-height: 1.6em; }
.rule-table { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; }
.rule-row { display: grid; grid-template-columns: 1.5fr .7fr .5fr 2.6fr; gap: .5rem; padding: .6rem .8rem; border-top: 1px solid var(--grid); align-items: center; font-size: .92rem; }
.rule-row.head { border-top: 0; background: var(--green-soft); font-weight: 600; font-size: .8rem; }
@media (max-width: 620px) {
  .rule-row { grid-template-columns: 1fr auto auto; }
  .rule-row.head { display: none; }
  .rule-ex { grid-column: 1 / -1; }
}
.tone-tag { font-weight: 600; border-radius: 8px; padding: .1rem .5rem; text-align: center; white-space: nowrap; }
.t1 { --tone: #0B6FB8; } .t2 { --tone: #017114; } .t3 { --tone: #B9770E; } .t4 { --tone: #c62828; } .t0 { --tone: #56645a; }
.tone-tag, .tone .tone-curve, .tone-btn .tone-curve { color: var(--tone); }
.tone-tag { background: color-mix(in srgb, var(--tone) 14%, #fff); }
.pct { font: 800 1rem var(--display); }
.rule-ex { display: flex; flex-wrap: wrap; gap: .35rem; }
.sample { display: inline-flex; flex-direction: column; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: .2rem .5rem; line-height: 1.25; }
.sample .han { font-size: 1.25rem; font-weight: 400; }
.sound-list li { display: grid; grid-template-columns: minmax(7rem, auto) 3rem 1fr; gap: .5rem; padding: .55rem 0; border-top: 1px solid var(--grid); align-items: center; }
@media (max-width: 480px) { .sound-list li { grid-template-columns: 1fr auto; } .sound-list .rule-ex { grid-column: 1 / -1; } }
.ff-grid, .story-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: .7rem; }
.ff p { margin: .2rem 0; }
.ff-han { font-size: 2.3rem; line-height: 1.1; background: none; border: 0; padding: 0; color: var(--ink); }
.ff-no { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--red); font-size: .9rem; }
.ff-yes b { color: var(--green-d); }
.ff-ex .han { font-size: 1.1rem; }
.same-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .45rem; }
.same { display: flex; flex-direction: column; align-items: center; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: .45rem .2rem; }
.same:hover { border-color: var(--green); }
.same-z { font-size: 1.45rem; line-height: 1.2; }
.compare { margin: .25rem 0; }

/* Phát âm */
.tone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem; }
.tone-curve { width: 100%; max-width: 110px; height: 40px; display: block; }
.tone-mark { font-weight: 400; color: var(--tone); }
.tone p { font-size: .9rem; margin: .2rem 0; }
.sound-group { margin-bottom: 1rem; }
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .45rem; }
.sound-tile { display: flex; flex-direction: column; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: .45rem .55rem; text-align: left; min-height: 96px; }
.sound-tile:hover { border-color: var(--green); }
.sound-py { font: 800 1.2rem var(--display); }
.sound-ex { margin-top: auto; }
.sound-ex .han { font-size: 1.15rem; }

/* Tập viết */
.write-layout { display: grid; gap: 1rem; }
@media (min-width: 760px) { .write-layout { grid-template-columns: minmax(320px, 1fr) 1fr; align-items: start; } }
.write-main { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 1rem; }
.write-main > * + * { margin-top: .7rem; }
.write-info .han { font-size: 1.5rem; font-weight: 400; }
.write-stage { display: flex; justify-content: center; }
.write-hold { display: flex; justify-content: center; }
.stroke-box { position: relative; touch-action: none; }
.stroke-box .tian { position: absolute; inset: 0; }
.stroke-target { position: absolute; inset: 0; }
.write-msg { text-align: center; color: var(--ok); font-weight: 600; min-height: 1.5em; }
.write-input { font-size: 1.5rem !important; }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: .25rem; padding-bottom: .6rem; }
.char-btn { aspect-ratio: 1; background: #fff; border: 1.5px solid var(--line); border-radius: 6px; font-size: 1.45rem; line-height: 1; padding: 0; min-height: 44px; }
.char-btn.done { border-color: var(--ok); background: var(--ok-soft); }

/* Truyện, hội thoại */
.story-title { font-size: 1.7rem; line-height: 1.2; display: block; }
.reader { display: grid; gap: .7rem; }
.reader-line { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: .7rem; }
.reader-line.now { border-color: var(--green); background: #fff1e7; }
.reader-foot { display: flex; gap: .4rem; align-items: center; margin-top: .3rem; }
.reader-vi { display: none; margin: 0; color: var(--ink-2); font-size: .92rem; }
.reader.show-vi .reader-vi { display: block; }
.reader.no-py .cell-py { visibility: hidden; height: 0; min-height: 0; }
.reader.no-hv .cell-hv { display: none; }
.reader-tools { justify-content: space-between; }
.chat { display: flex; flex-direction: column; gap: .6rem; }
.bubble { max-width: 92%; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: .6rem .75rem; }
.bubble p { margin: .3rem 0 .2rem; font-size: .9rem; }
.bubble.right { align-self: flex-end; background: var(--green-soft); border-color: #BFDCC4; }
.rp-choices { margin-top: 1rem; }
.rp-choices > * + * { margin-top: .6rem; }
.rp-opt .han { font-size: 1.3rem; }
.rp-fb { min-height: 1.4em; }

/* Trò chơi */
.game { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 1rem; }
.game > * + * { margin-top: .8rem; }
.tone-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 620px) { .tone-buttons { grid-template-columns: repeat(4, 1fr); } }
.tone-btn { display: flex; flex-direction: column; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: .5rem; font-weight: 600; min-height: 80px; }
.tone-btn.right { border-color: var(--ok); background: var(--ok-soft); }
.tone-btn.wrong { border-color: var(--red); background: var(--bad-soft); }
.game-answer { min-height: 2.2em; }
.hv-big { font-size: 3rem; line-height: 1.2; margin: .4rem 0; }
.memory { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
@media (min-width: 560px) { .memory { grid-template-columns: repeat(4, 1fr); } }
.mem { aspect-ratio: 5 / 4; border: 2px solid var(--green); border-radius: 10px; background: var(--green); color: var(--ink); padding: .2rem; font: 400 1.1rem/1.15 var(--hand); }
.mem.open { background: #fff; }
.mem.found { background: var(--ok-soft); border-color: var(--ok); }
.mem .han { font-size: 1.5rem; }
.race-head { display: flex; justify-content: space-between; font-weight: 600; }
.race-clock, .race-score { font: 800 1.4rem var(--display); color: var(--red); }
.race-score { color: var(--green); }

/* Từ điển */
.dict-input { font-size: 1.05rem; }
.dict-out { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: .5rem .8rem; }
.dict-out p { margin: .5rem 0; }

/* Của tôi */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.stat-box { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: .55rem; display: flex; flex-direction: column; align-items: center; text-align: center; }
.stat-box b { font: 800 1.4rem var(--display); color: var(--green); }
.quests li { display: flex; justify-content: space-between; padding: .4rem 0; border-top: 1px solid var(--grid); }
.quests li.done { color: var(--ok); }
.quests li.done span:first-child { text-decoration: line-through; }
.quest-num { font-weight: 600; }
.attend { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; max-width: 340px; }
.att { aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--grid); font-size: .78rem; color: var(--ink-2); }
.att.on { background: var(--green); color: #fff; border-color: var(--green); }
.att.today { outline: 2px solid var(--red); outline-offset: 1px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .45rem; }
.badge { border: 1.5px dashed var(--line); border-radius: 10px; padding: .45rem .6rem; display: flex; flex-direction: column; color: var(--ink-2); }
.badge.got { border: 2px solid var(--red); color: var(--red); transform: rotate(-1deg); }
.set-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem 0; border-top: 1px solid var(--grid); margin: 0; }
.set-row select { width: auto; max-width: 100%; }
.settings .row { margin-top: .7rem; }

/* Lần đầu */
.onboard { max-width: 480px; margin: 0 auto; padding-top: .5rem; }
.onboard > * + * { margin-top: 1rem; }
.onboard-demo { display: flex; justify-content: center; }
.onboard-demo .cell-xl .cell-box { width: 88px; height: 88px; }
.onboard-demo .cell { padding: 0; }
.onboard-demo .cell + .cell .cell-box { margin-left: -1.5px; }
.lead { font-size: 1.02rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; font-weight: 400; }
.goal { display: flex; flex-direction: column; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: .5rem .7rem; text-align: left; }
.goal.on { border-color: var(--green); background: var(--green-soft); }

/* Bảng tra từ */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(15, 26, 18, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; width: min(560px, 100%); max-height: 88dvh; overflow: auto; background: #fff; border-radius: 16px 16px 0 0; padding: 1.2rem 1rem calc(1.2rem + env(safe-area-inset-bottom)); outline: none; }
@media (min-width: 640px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 16px; } }
.sheet-x { position: absolute; top: .4rem; right: .4rem; width: 44px; height: 44px; background: none; border: 0; color: var(--ink-2); display: grid; place-items: center; }
.word-sheet > * + * { margin-top: .7rem; }
.word-mean { font-size: 1.05rem; font-weight: 600; text-align: center; }
.parts { border-top: 1px dashed var(--line); padding-top: .6rem; }
.part { display: grid; grid-template-columns: 2rem 5rem 1fr; gap: .4rem; width: 100%; background: none; border: 0; border-top: 1px solid var(--grid); padding: .4rem 0; text-align: left; align-items: center; }
.part .han { font-size: 1.4rem; font-weight: 400; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 5.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .55rem 1rem; border-radius: 10px; transition: opacity .3s; max-width: 90%; text-align: center; }
.toast.out { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Thương hiệu, cài đặt */
.brand-name { display: flex; flex-direction: column; }
.brand-by { font: 600 .7rem/1.3 var(--body); color: var(--green); }
.install-cta { border: 2px solid var(--orange); background: var(--orange-soft); }
.steps-list { margin: .3rem 0 0; padding-left: 1.3rem; }
.steps-list li { margin-bottom: .45rem; }
.ok-line { color: var(--ok); font-weight: 600; }

/* Tài khoản */
.auth-form { display: grid; gap: .8rem; }
.field input { font-weight: 400; }
.field-hint { font-weight: 400; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-size: .92rem; }
.check input { width: 20px; height: 20px; flex: none; margin-top: .15rem; accent-color: var(--green); }
.form-err { color: var(--red); margin: 0; font-size: .92rem; }
.form-err:empty { display: none; }
.form-ok { color: var(--ok); font-weight: 600; margin: 0; }
.auth-links { font-size: .92rem; }
.account .book-group { margin-top: .6rem; }
.account .book-group .auth-form { padding-bottom: .8rem; }
.account-actions { margin-top: .8rem; }
.account-keep { margin-top: .5rem; }
.sync-row { font-size: .9rem; }
