/* Học Nihao — hocnihao.com
   Bảng màu lấy từ ứng dụng Hán Ngữ: nền giấy dó, son đỏ, vàng, ngọc bích. */
:root {
  --bg: #fbf5ea;
  --bg-2: #f4ead9;
  --card: #ffffff;
  --ink: #2a211b;
  --sub: #6f6155;
  --line: #ebdfcc;
  --line-2: #dfcfb6;
  --red: #c8372d;
  --red-dark: #9e241c;
  --red-soft: #f9e3df;
  --gold: #e0a526;
  --gold-ink: #8a5f00;
  --gold-soft: #fbefcb;
  --jade: #2f8f6b;
  --jade-dark: #22714f;
  --jade-soft: #dcf1e7;
  --on-red: #fff;
  --btn: #c8372d;
  --btn-jade: #277a5b;
  --shadow: 0 1px 2px rgb(107 74 43 / 6%), 0 6px 20px -6px rgb(107 74 43 / 18%);
  --shadow-lg: 0 2px 4px rgb(107 74 43 / 6%), 0 18px 40px -12px rgb(107 74 43 / 28%);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-zh: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --tabbar-h: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #17120f;
    --bg-2: #1f1915;
    --card: #241d18;
    --ink: #f3eadf;
    --sub: #b8a898;
    --line: #382e27;
    --line-2: #4a3d33;
    --red: #e25b4f;
    --red-dark: #f07b70;
    --red-soft: #3d1f1b;
    --gold: #e8b54a;
    --gold-ink: #f0c66b;
    --gold-soft: #3a2f17;
    --jade: #4fb58d;
    --jade-dark: #6cc9a3;
    --jade-soft: #173328;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px -8px rgb(0 0 0 / 50%);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / 30%), 0 20px 44px -12px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #17120f;
  --bg-2: #1f1915;
  --card: #241d18;
  --ink: #f3eadf;
  --sub: #b8a898;
  --line: #382e27;
  --line-2: #4a3d33;
  --red: #e25b4f;
  --red-dark: #f07b70;
  --red-soft: #3d1f1b;
  --gold: #e8b54a;
  --gold-ink: #f0c66b;
  --gold-soft: #3a2f17;
  --jade: #4fb58d;
  --jade-dark: #6cc9a3;
  --jade-soft: #173328;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.015em; }
h1 { font-size: clamp(28px, 4.5vw, 40px); font-weight: 800; }
h2 { font-size: clamp(20px, 2.6vw, 26px); font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--red) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.zh { font-family: var(--font-zh); font-weight: 500; letter-spacing: 0; }
.sub { color: var(--sub); font-weight: 500; font-size: .7em; }
.muted { color: var(--sub); }
.nowrap { white-space: nowrap; }
.accent { color: var(--red); }
.hint { color: var(--sub); font-size: 14px; }
.ic { flex: none; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--card); padding: 8px 14px; border-radius: 8px; }

.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
.section { margin-top: 40px; }
@media (min-width: 720px) { .section { margin-top: 56px; } }

/* ---------- Nút ---------- */
.btn {
  --b: var(--btn);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 1.5px solid var(--b); border-radius: 999px;
  background: var(--b); color: var(--on-red);
  font-weight: 700; font-size: 15px; line-height: 1.2; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: transform .12s ease, background-color .15s, border-color .15s, box-shadow .15s;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--b) 80%, transparent);
}
.btn:hover { color: var(--on-red); background: color-mix(in srgb, var(--b) 88%, #000); border-color: color-mix(in srgb, var(--b) 88%, #000); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: 16px; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-jade { --b: var(--btn-jade); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); border-color: var(--line-2); }
.btn-outline { background: transparent; color: var(--red); box-shadow: none; }
.btn-outline:hover { background: var(--red-soft); color: var(--red-dark); }
.btn-light { background: #fff; color: var(--red-dark); border-color: #fff; box-shadow: none; }
.btn-light:hover { background: #fff5f2; color: var(--red-dark); border-color: #fff5f2; }
.btn.danger, .btn-ghost.danger { color: var(--red); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .ic { margin-left: -2px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--sub); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn.speaking, .btn.speaking { color: var(--red); }
.link-btn { border: 0; background: none; padding: 4px 6px; color: var(--red); font-size: 13px; font-weight: 600; cursor: pointer; }
[data-fav].on { color: var(--red); }
[data-fav].on svg path { fill: currentColor; }

/* ---------- Đầu trang ---------- */
.top {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-in { display: flex; align-items: center; gap: 20px; height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.logo:hover { color: var(--ink); }
.seal { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 4px 10px -4px rgb(200 55 45 / 60%); flex: none; }
.wordmark { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.wordmark b { color: var(--red); font-weight: 800; }
.nav { display: none; gap: 2px; }
.nav a {
  position: relative; padding: 8px 12px; border-radius: 10px;
  color: var(--sub); font-weight: 600; font-size: 15px; text-decoration: none;
}
.nav a:hover { color: var(--ink); background: var(--bg-2); }
.nav a[aria-current] { color: var(--ink); }
.nav a[aria-current]::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: -13px; height: 3px; border-radius: 3px 3px 0 0; background: var(--red); }
.due-dot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px; border-radius: 10px; background: var(--red); color: #fff; font: 700 11px/1 var(--font); font-style: normal; vertical-align: 1px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top-search {
  display: none; align-items: center; gap: 8px;
  width: 270px; height: 40px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--card); color: var(--sub);
}
.top-search:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.top-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 14px; color: var(--ink); }
.streak-chip { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); font-weight: 800; font-size: 14px; text-decoration: none; }
.streak-chip:hover { color: var(--gold-ink); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--jade); color: #fff; font-weight: 800; text-decoration: none; }
.avatar:hover { color: #fff; filter: brightness(1.08); }
@media (min-width: 900px) { .nav { display: flex; } }
@media (min-width: 1080px) { .top-search { display: flex; } }
@media (max-width: 899px) { .hide-sm { display: none !important; } }

/* thanh điều hướng dưới cho điện thoại */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--sub); font-size: 11px; font-weight: 600; text-decoration: none; }
.tabbar a[aria-current] { color: var(--red); }
.tabbar .due-dot { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 10px; }
@media (max-width: 899px) { :root { --tabbar-h: 64px; } }
@media (min-width: 900px) { .tabbar { display: none; } }

/* ---------- Thông báo ---------- */
.flash { margin-top: 16px; padding: 12px 16px; border-radius: var(--r-sm); background: var(--jade-soft); color: var(--jade-dark); font-weight: 600; }
.flash-err { background: var(--red-soft); color: var(--red-dark); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Trang chủ ---------- */
.hero { position: relative; overflow: hidden; padding: 36px 0 8px; }
.hero::before {
  content: ''; position: absolute; inset: -40% -10% auto auto; width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--gold) 22%, transparent), transparent);
  pointer-events: none;
}
.hero-in { position: relative; display: grid; gap: 32px; align-items: center; }
@media (min-width: 900px) { .hero { padding: 64px 0 16px; } .hero-in { grid-template-columns: 1.15fr .85fr; gap: 56px; } }
.eyebrow { display: inline-flex; gap: 8px; align-items: baseline; padding: 6px 14px; border-radius: 999px; background: var(--red-soft); color: var(--red-dark); font-weight: 700; font-size: 14px; }
.eyebrow .zh { font-size: 16px; }
.hero h1 { font-size: clamp(34px, 6vw, 58px); line-height: 1.08; margin: 18px 0 16px; letter-spacing: -0.03em; }
.hero h1 em { font-style: normal; color: var(--red); }
.lead { font-size: clamp(16px, 1.8vw, 18px); color: var(--sub); max-width: 34em; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.hero-cta.center { justify-content: center; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 28px 0 0; padding: 0; list-style: none; color: var(--sub); font-size: 14px; }
.hero-facts b { color: var(--ink); font-size: 20px; font-weight: 800; margin-right: 4px; }

.wotd {
  position: relative; padding: 22px; border-radius: var(--r-lg); background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); text-align: center;
}
.wotd::after { content: ''; position: absolute; inset: 10px; border: 1px dashed var(--line-2); border-radius: 18px; pointer-events: none; }
.wotd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; position: relative; z-index: 1; }
.wotd .label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); font-weight: 700; font-size: 13px; }
.wotd-date { color: var(--sub); font-weight: 700; font-size: 13px; }
.wotd .py { margin: 14px 0 2px; color: var(--red); font-weight: 700; font-size: 20px; }
.wotd .vi { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.wotd-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ô chữ điền 田: mỗi chữ một ô */
.tian-link { display: inline-block; color: var(--ink); text-decoration: none; border-radius: 8px; }
.tian-link:hover { color: var(--ink); }
.tian-row { --s: 150px; display: flex; justify-content: center; margin: 0; line-height: 1; font-weight: 500; }
.tian-row.n2 { --s: 118px; }
.tian-row.n3 { --s: 92px; }
.tian-row.n4 { --s: 74px; }
.tian-row.big { --s: min(210px, 56vw); }
.tian-row.big.n2 { --s: min(160px, 40vw); }
.tian-row.big.n3 { --s: min(128px, 28vw); }
.tian-row.big.n4 { --s: min(104px, 21vw); }
.tian-cell {
  --g: color-mix(in srgb, var(--red) 26%, transparent);
  display: grid; place-items: center; width: var(--s); height: var(--s);
  font-size: calc(var(--s) * .7); color: var(--ink);
  border: 2px solid color-mix(in srgb, var(--red) 55%, transparent);
  background:
    linear-gradient(to right, transparent calc(50% - .5px), var(--g) calc(50% - .5px), var(--g) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), var(--g) calc(50% - .5px), var(--g) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--red) 12%, transparent) calc(50% - .5px), color-mix(in srgb, var(--red) 12%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--red) 12%, transparent) calc(50% - .5px), color-mix(in srgb, var(--red) 12%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    var(--card);
}
.tian-cell + .tian-cell { border-left-width: 0; }
.tian-cell:first-child { border-radius: 6px 0 0 6px; }
.tian-cell:last-child { border-radius: 0 6px 6px 0; }
.tian-cell:only-child { border-radius: 6px; }
.tian-row.card { --s: min(170px, 52vw); }
.tian-row.card.n2 { --s: min(140px, 36vw); }
.tian-row.card.n3 { --s: min(110px, 26vw); }
.tian-row.card.n4 { --s: min(88px, 20vw); }
.tian-row.quiz { --s: 108px; margin-bottom: 10px; }
.tian-row.quiz.n2 { --s: 92px; }
.tian-row.quiz.n3 { --s: 76px; }
.tian-row.quiz.n4 { --s: 64px; }
.tian-text { display: block; margin: 0; font-size: clamp(30px, 6vw, 48px); line-height: 1.25; text-align: center; font-weight: 500; }

.today { margin-top: 28px; }
.today-in {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: center;
  padding: 16px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.today-stat { display: flex; align-items: center; gap: 12px; min-width: 0; }
.today-stat b { display: block; font-size: 16px; }
.today-stat small { display: block; color: var(--sub); font-size: 13px; line-height: 1.3; }
.today-stat:first-child { grid-column: 1 / -1; }
.today-in .btn { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .today-in { grid-template-columns: 1.4fr 1fr 1fr auto; padding: 18px 22px; }
  .today-stat:first-child, .today-in .btn { grid-column: auto; }
}
.today-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; }
.today-ic.flame { background: var(--gold-soft); color: var(--gold-ink); }
.today-ic.due { background: var(--red-soft); color: var(--red); }
.ring {
  --p: 0;
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--jade) calc(var(--p) * 1%), var(--line) 0);
}
.ring::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--card); }
.ring b, .ring small { position: relative; }
.ring b { font-size: 18px; }
.ring small { color: var(--sub); font-size: 11px; font-weight: 700; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head p { color: var(--sub); margin: 0; }
.section-head h2 { margin-bottom: 4px; }
.more { display: inline-flex; align-items: center; gap: 4px; flex: none; font-weight: 700; font-size: 15px; text-decoration: none; }

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.deck-card {
  display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.deck-card:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }
.deck-emoji {
  display: grid; place-items: center; width: 54px; height: 54px; flex: none; border-radius: 16px;
  background: color-mix(in srgb, var(--c) 16%, var(--card)); color: var(--c); font-size: 26px; font-weight: 800;
}
.deck-emoji.big { width: 76px; height: 76px; border-radius: 22px; font-size: 38px; }
.deck-body { display: grid; gap: 1px; min-width: 0; flex: 1; }
.deck-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.deck-zh { color: var(--sub); font-size: 14px; }
.deck-meta { color: var(--sub); font-size: 13px; margin-top: 4px; }
.bar { display: block; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--red)); transition: width .4s ease; }
.deck-body .bar { margin-top: 6px; }
.bar.thick { height: 8px; }
.bar.jade i { background: var(--jade); }

.hsk-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .hsk-row { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .hsk-row { grid-template-columns: repeat(6, 1fr); } }
.hsk-pill {
  display: grid; gap: 6px; padding: 16px; border-radius: var(--r); text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--c);
  transition: transform .15s ease, box-shadow .15s;
}
.hsk-pill:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.hsk-n { font-weight: 600; color: var(--sub); }
.hsk-n b { color: var(--c); font-size: 28px; font-weight: 800; margin-left: 2px; }
.hsk-count { color: var(--sub); font-size: 13px; }

.how h2 { text-align: center; margin-bottom: 24px; }
.steps { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
@media (min-width: 820px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li { position: relative; padding: 22px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); counter-increment: s; }
.steps li::after { content: counter(s); position: absolute; top: 16px; right: 20px; font: 800 44px/1 var(--font); color: var(--line); }
.steps p { color: var(--sub); margin: 0; font-size: 15px; }
.step-ic { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 14px; border-radius: 16px; background: var(--red-soft); color: var(--red); }
.steps li:nth-child(2) .step-ic { background: var(--jade-soft); color: var(--jade); }
.steps li:nth-child(3) .step-ic { background: var(--gold-soft); color: var(--gold-ink); }

.cta-band {
  display: grid; gap: 20px; align-items: center; padding: 28px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, #c8372d, #9e241c); color: #fff; box-shadow: var(--shadow-lg);
}
.cta-band p { color: rgb(255 255 255 / 85%); margin: 0; }
@media (min-width: 820px) { .cta-band { grid-template-columns: 1fr auto; padding: 36px 40px; } }

/* ---------- Tiêu đề trang ---------- */
.page-head { padding-top: 32px; }
.page-head p { color: var(--sub); max-width: 46em; font-size: 17px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 20px; color: var(--sub); font-size: 14px; }
.crumbs a { color: var(--sub); text-decoration: none; }
.crumbs a:hover { color: var(--red); }

/* ---------- Trang bộ từ ---------- */
.deck-hero {
  display: grid; gap: 18px; margin-top: 16px; padding: 22px !important;
  border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); max-width: 1084px;
}
@media (min-width: 900px) { .deck-hero { grid-template-columns: auto 1fr auto; align-items: center; padding: 28px 32px !important; } }
.deck-hero h1 { margin-bottom: 6px; }
.deck-hero p { color: var(--sub); margin-bottom: 12px; }
.deck-hero-prog { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--sub); }
.deck-hero-prog .bar { flex: 1; max-width: 280px; }
.deck-hero-cta { display: grid; gap: 10px; }
@media (min-width: 560px) and (max-width: 899px) { .deck-hero-cta { grid-template-columns: 1fr 1fr; } }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.list-head h2 { margin: 0; }

.word-list { margin: 0; padding: 0; list-style: none; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.word-row { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 4px; border-top: 1px solid var(--line); }
.word-row:first-child { border-top: 0; }
.word-main { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; padding: 8px 10px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.word-main:hover { color: var(--ink); background: var(--bg-2); }
.w-hanzi { font-size: 28px; line-height: 1.2; min-width: 2.2em; }
.w-text { display: grid; min-width: 0; }
.w-py { color: var(--red); font-weight: 600; font-size: 15px; }
.w-vi { font-size: 15px; overflow-wrap: anywhere; }
.w-deck { color: var(--sub); font-size: 12px; }
.w-status { display: none; gap: 3px; align-items: flex-end; height: 16px; margin: 0 6px; }
.w-status.show { display: inline-flex; }
.w-status i { width: 4px; border-radius: 2px; background: var(--line); }
.w-status i:nth-child(1) { height: 5px; } .w-status i:nth-child(2) { height: 7px; } .w-status i:nth-child(3) { height: 9px; }
.w-status i:nth-child(4) { height: 11px; } .w-status i:nth-child(5) { height: 13px; } .w-status i:nth-child(6) { height: 16px; }
.w-status i.on { background: var(--jade); }
.w-status.due i.on { background: var(--gold); }
.word-list.compact .w-hanzi { font-size: 22px; }
.word-list.compact .word-row { padding: 2px 4px 2px 0; }

/* ---------- Lộ trình HSK ---------- */
.hsk-path { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.hsk-step {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  transition: transform .15s ease, box-shadow .15s;
}
.hsk-step:hover { color: var(--ink); transform: translateX(3px); box-shadow: var(--shadow); }
.hsk-badge {
  display: grid; place-items: center; width: 64px; height: 64px; flex: none; border-radius: 18px;
  background: var(--c); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.hsk-badge b { font-size: 26px; font-weight: 800; }
.hsk-info { display: grid; gap: 4px; flex: 1; min-width: 0; }
.hsk-title { font-weight: 800; font-size: 18px; }
.hsk-desc { color: var(--sub); font-size: 14px; }
.hsk-prog { display: flex; align-items: center; gap: 10px; color: var(--sub); font-size: 13px; }
.hsk-prog .bar { flex: 1; max-width: 240px; }
.hsk-go { color: var(--sub); }

/* ---------- Trang từ ---------- */
.word-page { display: grid; gap: 18px; margin-top: 16px; }
.word-card {
  display: grid; gap: 24px; padding: 24px; border-radius: var(--r-lg);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
@media (min-width: 760px) { .word-card { grid-template-columns: auto 1fr; align-items: center; padding: 32px; gap: 36px; } }
.word-info .py.big { color: var(--red); font-weight: 700; font-size: 28px; margin: 0 0 4px; }
.word-info .vi.big { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.word-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 14px; }
.word-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--sub)) 12%, var(--card)); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--c, var(--sub)) 22%, transparent);
  font-size: 13px; font-weight: 600; text-decoration: none; line-height: 1.4;
}
.chip:hover { color: var(--ink); background: color-mix(in srgb, var(--c, var(--sub)) 20%, var(--card)); }
.chip-status { --c: var(--jade); }
.panel { padding: 20px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); }
@media (min-width: 720px) { .panel { padding: 24px 28px; } }
.panel > h2 { font-size: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.example .ex-zh { display: flex; align-items: center; gap: 8px; font-size: 24px; margin: 0; }
.example .py { color: var(--red); font-weight: 600; margin: 4px 0 0; }
.example .vi { color: var(--sub); margin: 2px 0 0; }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border: 0; border-radius: 999px; background: transparent; color: var(--sub); font-weight: 700; font-size: 14px; cursor: pointer;
}
.seg button.on, .seg button[aria-checked='true'] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.stroke-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.stroke-box { margin: 0; display: grid; gap: 6px; justify-items: center; }
.stroke-target {
  width: 160px; height: 160px; border-radius: 6px; touch-action: none;
  border: 2px solid color-mix(in srgb, var(--red) 45%, transparent);
  background:
    linear-gradient(to right, transparent calc(50% - .5px), var(--line-2) calc(50% - .5px), var(--line-2) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), var(--line-2) calc(50% - .5px), var(--line-2) calc(50% + .5px), transparent calc(50% + .5px)),
    var(--card);
}
.stroke-target.done { border-color: var(--jade); }
.stroke-box figcaption { display: flex; align-items: center; gap: 8px; }
.stroke-box figcaption .zh { font-size: 22px; text-decoration: none; }
.stroke-fallback { display: grid; place-items: center; height: 100%; font-family: var(--font-zh); font-size: 96px; color: var(--ink); }
.chips-list { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.rel { display: grid; padding: 10px 14px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.rel:hover { color: var(--ink); border-color: var(--red); }
.rel .zh { font-size: 22px; line-height: 1.3; }
.rel small { color: var(--sub); font-size: 13px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.pager a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; max-width: 48%; }
.pager a:hover { border-color: var(--red); color: var(--ink); }
.pager .zh { font-size: 20px; }
.pager small { color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Từ điển ---------- */
.dict-form { display: grid; gap: 14px; }
.dict-input {
  display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 20px;
  border-radius: 999px; background: var(--card); border: 1.5px solid var(--line-2); color: var(--sub);
  box-shadow: var(--shadow);
}
.dict-input:focus-within { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.dict-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 18px; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span { display: inline-block; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--sub); font-weight: 600; font-size: 14px; cursor: pointer; }
.chip-radio input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-radio input:focus-visible + span { outline: 3px solid var(--red-soft); }
.dict-results { margin-top: 20px; }
.dict-count { color: var(--sub); font-size: 14px; font-weight: 600; }
.dict-empty { padding: 28px; text-align: center; border-radius: var(--r-lg); border: 1.5px dashed var(--line-2); color: var(--sub); }
.dict-empty .try { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; align-items: center; margin: 0; }

/* ---------- Học thẻ & kiểm tra ---------- */
.study-shell { max-width: 640px; padding-top: 16px; padding-bottom: 24px; }
.study-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.study-title { flex: 1; min-width: 0; text-align: center; }
.study-title h1 { font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-count { color: var(--sub); font-size: 13px; font-weight: 700; }
.study-stage, .quiz-stage { margin-top: 18px; min-height: 420px; }
.card-skeleton { height: 380px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); }

.flip { perspective: 1400px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.flip-in {
  position: relative; height: clamp(320px, 52vh, 420px);
  transition: transform .5s cubic-bezier(.2, .7, .2, 1); transform-style: preserve-3d;
}
.flip.flipped .flip-in { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; padding: 24px;
  border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; text-align: center;
}
.face::before { content: ''; position: absolute; inset: 12px; border: 1px dashed var(--line-2); border-radius: 18px; pointer-events: none; }
.face-back { transform: rotateY(180deg); }
.face .zh { font-size: clamp(64px, 16vw, 112px); line-height: 1.1; }
.face .zh.long { font-size: clamp(34px, 8vw, 52px); }
.face .py { color: var(--red); font-weight: 700; font-size: 24px; margin: 0; }
.face .vi { font-size: 22px; font-weight: 600; margin: 0; max-width: 18em; }
.face .tap { position: absolute; bottom: 22px; left: 0; right: 0; color: var(--sub); font-size: 13px; font-weight: 600; }
.face .icon-btn { position: absolute; top: 18px; right: 18px; z-index: 2; background: var(--bg-2); }
.face .fav { right: 70px; }
.face-back .zh { font-size: clamp(40px, 10vw, 64px); }
.study-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.study-actions .btn { min-height: 56px; font-size: 16px; }
.new-badge { position: absolute; top: 22px; left: 22px; padding: 3px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); font-size: 12px; font-weight: 700; }
.kbd-hint { margin-top: 20px; text-align: center; color: var(--sub); font-size: 13px; }
kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--card); font: 600 12px/1.4 var(--font); }

.done-card { padding: 36px 24px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); text-align: center; }
.done-card .big-emoji { font-size: 72px; line-height: 1; margin-bottom: 12px; }
.done-card h2 { font-size: 26px; margin-bottom: 4px; }
.done-card p { color: var(--sub); }
.done-card .score { font-size: 56px; font-weight: 800; color: var(--red); line-height: 1; margin: 6px 0; }
.done-actions { display: grid; gap: 10px; margin-top: 22px; }
.done-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.done-words a { padding: 4px 10px; border-radius: 10px; background: var(--red-soft); color: var(--red-dark); text-decoration: none; font-size: 20px; }

.quiz-score { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--jade-soft); color: var(--jade-dark); font-weight: 800; }
.q-prompt { text-align: center; color: var(--sub); font-weight: 700; margin: 0 0 8px; }
.q-box { display: grid; place-items: center; min-height: 170px; margin-bottom: 14px; text-align: center; }
.q-box .zh { font-size: clamp(60px, 14vw, 88px); line-height: 1.15; }
.q-box .zh.long { font-size: clamp(32px, 7vw, 46px); }
.q-box .py { color: var(--red); font-weight: 700; font-size: 18px; margin: 0; }
.q-box .vi { font-size: clamp(22px, 5vw, 30px); font-weight: 800; margin: 0; }
.q-listen { width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--red); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 12px 28px -10px var(--red); transition: transform .15s; }
.q-listen:hover { transform: scale(1.04); }
.q-listen.speaking { animation: pulse 1s ease infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--red) 18%, transparent); } }
.q-opts { display: grid; gap: 10px; }
.q-opt {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 16px;
  border-radius: var(--r); border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 600; font-size: 17px; text-align: left; cursor: pointer; transition: border-color .15s, background-color .15s, transform .1s;
}
.q-opt:hover:not([disabled]) { border-color: var(--line-2); background: var(--bg-2); }
.q-opt .k { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--bg-2); color: var(--sub); font-size: 13px; font-weight: 800; }
.q-opt .zh { font-size: 26px; font-weight: 500; }
.q-opt.right { border-color: var(--jade); background: var(--jade-soft); }
.q-opt.right .k { background: var(--jade); color: #fff; }
.q-opt.wrong { border-color: var(--red); background: var(--red-soft); animation: shake .3s; }
.q-opt.wrong .k { background: var(--red); color: #fff; }
.q-opt[disabled] { cursor: default; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.q-feedback { display: grid; gap: 12px; margin-top: 16px; }
.q-feedback p { margin: 0; text-align: center; font-weight: 700; }
.q-feedback .ok { color: var(--jade-dark); }
.q-feedback .bad { color: var(--red-dark); }

/* ---------- Ôn tập ---------- */
.review-grid { display: grid; gap: 16px; }
@media (min-width: 860px) { .review-grid { grid-template-columns: 1fr 1fr; } }
.review-hero { text-align: center; display: grid; align-content: center; }
.big-num { font-size: 72px; font-weight: 800; color: var(--red); line-height: 1; margin: 0; }
.review-label { font-weight: 700; font-size: 17px; margin: 6px 0 0; }
.review-sample { font-size: 28px; letter-spacing: .2em; margin: 12px 0 18px; min-height: 1.4em; }
.levels { display: grid; gap: 10px; margin: 8px 0 0; padding: 0; list-style: none; }
.levels li { display: grid; grid-template-columns: 96px 1fr 32px; align-items: center; gap: 10px; font-size: 14px; }
.levels .bar { height: 10px; }
.levels .bar i { background: var(--gold); }
.levels li span:first-child { color: var(--sub); }
.levels b { text-align: right; }
.review-more { display: grid; gap: 12px; margin-top: 16px; }
@media (min-width: 760px) { .review-more { grid-template-columns: repeat(3, 1fr); } }
.tile { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); color: var(--red); text-decoration: none; transition: transform .15s, box-shadow .15s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: var(--red); }
.tile span { display: grid; }
.tile b { color: var(--ink); }
.tile small { color: var(--sub); }

/* ---------- Cá nhân ---------- */
.profile-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sync-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px !important; }
.profile-actions { display: flex; gap: 8px; }
.profile-actions form { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { display: grid; justify-items: start; gap: 2px; padding: 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); }
.stat b { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat small { color: var(--sub); font-size: 13px; }
.stat-ic { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 8px; border-radius: 12px; }
.stat-ic.flame, .stat-ic.gold { background: var(--gold-soft); color: var(--gold-ink); }
.stat-ic.jade { background: var(--jade-soft); color: var(--jade); }
.stat-ic.red { background: var(--red-soft); color: var(--red); }
.profile-grid { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 900px) { .profile-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.goal-seg { margin-top: 4px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; margin-top: 22px; }
.week div { display: grid; grid-template-rows: 1fr auto auto; height: 100%; justify-items: center; gap: 4px; font-size: 12px; color: var(--sub); }
.week .col { width: 100%; max-width: 34px; display: flex; align-items: flex-end; height: 100%; }
.week .col i { display: block; width: 100%; min-height: 4px; border-radius: 6px 6px 3px 3px; background: var(--line); }
.week .col i.hit { background: var(--jade); }
.week .col i.some { background: var(--gold); }
.week b { color: var(--ink); font-size: 12px; }
.week .today-col span { color: var(--red); font-weight: 800; }
.danger-zone { border-style: dashed; }
.danger-zone h2 { font-size: 17px; }

/* ---------- Đăng nhập ---------- */
.auth { display: grid; place-items: center; padding-top: 40px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px 24px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); text-align: center; }
.auth-card .seal { width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 13px; }
.auth-card h1 { font-size: 26px; }
.auth-switch { margin: 18px 0 0; color: var(--sub); font-size: 15px; }
.form { display: grid; gap: 14px; text-align: left; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea, .inline-form input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line-2); background: var(--bg); color: var(--ink); font-size: 16px;
}
.field input[type='color'] { padding: 4px; height: 46px; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .inline-form input:focus { outline: 0; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.field input[aria-invalid='true'] { border-color: var(--red); }
.field-err { color: var(--red); font-size: 13px; font-weight: 600; }
.field-help { color: var(--sub); font-size: 13px; }
.field .zh, .field input.zh { font-family: var(--font-zh); font-size: 20px; }
.hp { position: absolute; left: -9999px; }

/* ---------- Quản trị ---------- */
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding-top: 24px; }
.admin-nav strong { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; }
.admin-nav a { padding: 6px 12px; border-radius: 999px; color: var(--sub); font-weight: 600; text-decoration: none; }
.admin-nav a[aria-current] { background: var(--ink); color: var(--bg); }
.admin-nav + .section { margin-top: 20px; }
.section > .panel + .panel, .section > .panel + form, .section > form + form { margin-top: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--sub); font-weight: 600; font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }
.big-cell { font-size: 22px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
.ex-details summary { cursor: pointer; color: var(--sub); font-weight: 600; margin-bottom: 10px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 180px; }
.form .btn { justify-self: start; }
@media (max-width: 700px) { .words-table th:nth-child(3), .words-table td:nth-child(3) { display: none; } }

/* ---------- Trang giới thiệu & lỗi ---------- */
.prose { display: grid; gap: 16px; }
.prose ul { margin: 0; padding-left: 1.2em; }
.prose li { margin: 6px 0; }
.prose p:last-child { margin-bottom: 0; }
.error-page { text-align: center; padding-top: 60px; }
.err-glyph { font-size: 96px; color: var(--red); line-height: 1.1; margin: 0 0 12px; opacity: .85; }
.err-detail { text-align: left; white-space: pre-wrap; font-size: 12px; background: var(--card); border: 1px solid var(--line); padding: 16px; border-radius: 12px; overflow: auto; max-height: 50vh; }

/* ---------- Chân trang ---------- */
.foot { margin-top: 72px; padding: 40px 0 24px; border-top: 1px solid var(--line); background: var(--bg-2); }
.foot-in { display: grid; gap: 28px; }
@media (min-width: 820px) { .foot-in { grid-template-columns: 1.2fr 2fr; } }
.foot-brand p { color: var(--sub); margin-top: 12px; max-width: 26em; font-size: 15px; }
.foot-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; }
.foot-cols h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--sub); margin-bottom: 10px; }
.foot-cols a { display: block; padding: 4px 0; color: var(--ink); text-decoration: none; font-size: 15px; }
.foot-cols a:hover { color: var(--red); }
.foot-bottom { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--sub); font-size: 13px; }

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