/* ---------- Màu sắc & chữ ---------- */
:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --border: #e3ddd0;
  --text: #1c2321;
  --muted: #66706b;
  --primary: #0f766e;
  --primary-hover: #0b5f58;
  --primary-ink: #ffffff;
  --primary-soft: #dcefeb;
  --accent: #d0602a;
  --accent-soft: #fbe7dc;
  --ok: #15803d;
  --ok-soft: #dcf2e2;
  --bad: #c2410c;
  --bad-soft: #fde3d5;
  --gold: #b7791f;
  --lv-nhap-mon: #0f766e;
  --lv-a1: #15803d;
  --lv-a2: #0369a1;
  --lv-b1: #6d28d9;
  --lv-b2: #be185d;
  --lv-c1: #c2410c;
  --lv-c2: #a16207;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 32, 28, 0.06), 0 6px 18px rgba(20, 32, 28, 0.05);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-zh: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', 'Heiti TC', sans-serif;
  --sidebar-w: 264px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #111615;
    --surface: #18201e;
    --surface-2: #1f2926;
    --border: #2c3833;
    --text: #e7ece9;
    --muted: #9aa7a1;
    --primary: #2bb3a3;
    --primary-hover: #45c7b8;
    --primary-ink: #04201c;
    --primary-soft: #16352f;
    --accent: #f08a55;
    --accent-soft: #3a2418;
    --ok: #4ade80;
    --ok-soft: #12301d;
    --bad: #fb8b5b;
    --bad-soft: #3a1d10;
    --gold: #e0b252;
    --lv-nhap-mon: #2bb3a3;
    --lv-a1: #4ade80;
    --lv-a2: #38bdf8;
    --lv-b1: #a78bfa;
    --lv-b2: #f472b6;
    --lv-c1: #fb923c;
    --lv-c2: #facc15;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #111615;
  --surface: #18201e;
  --surface-2: #1f2926;
  --border: #2c3833;
  --text: #e7ece9;
  --muted: #9aa7a1;
  --primary: #2bb3a3;
  --primary-hover: #45c7b8;
  --primary-ink: #04201c;
  --primary-soft: #16352f;
  --accent: #f08a55;
  --accent-soft: #3a2418;
  --ok: #4ade80;
  --ok-soft: #12301d;
  --bad: #fb8b5b;
  --bad-soft: #3a1d10;
  --gold: #e0b252;
  --lv-nhap-mon: #2bb3a3;
  --lv-a1: #4ade80;
  --lv-a2: #38bdf8;
  --lv-b1: #a78bfa;
  --lv-b2: #f472b6;
  --lv-c1: #fb923c;
  --lv-c2: #facc15;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ---------- Nền tảng ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--primary);
}
h1,
h2,
h3 {
  line-height: 1.3;
  margin: 0 0 0.5em;
}
h1 {
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 1.6em;
}
h3 {
  font-size: 1.05rem;
  font-weight: 700;
}
p {
  margin: 0 0 0.8em;
}
button {
  font: inherit;
  color: inherit;
}
[lang|='zh'],
.zh {
  font-family: var(--font-zh);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus {
  left: 8px;
}
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 2px;
}
svg.i {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Khung trang ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 1.35rem;
  font-weight: 700;
  flex: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-text small {
  color: var(--muted);
  font-size: 0.75rem;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.side-nav a:hover {
  background: var(--surface-2);
}
.side-nav a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.nav-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 12px 10px 4px;
  font-weight: 700;
}
.nav-glyph {
  width: 20px;
  text-align: center;
  font-weight: 700;
  flex: none;
}
.side-progress {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.85rem;
}
.main-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand,
.topbar .menu-btn {
  display: none;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 24px 40px;
  outline: none;
}
.app-footer {
  margin-top: auto;
  padding: 20px 24px 28px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}
.app-footer p {
  margin: 0.2em 0;
}
.bottom-nav,
.drawer-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 50;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: none;
  }
  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .drawer-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
  .topbar {
    padding: 8px 12px;
  }
  .topbar .brand,
  .topbar .menu-btn {
    display: flex;
  }
  .topbar .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 1.15rem;
  }
  .topbar .brand-text small {
    display: none;
  }
  .container {
    padding: 18px 16px 96px;
  }
  .app-footer {
    padding-bottom: 92px;
  }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.68rem;
    color: var(--muted);
    text-decoration: none;
    padding: 4px 0;
  }
  .bottom-nav a .nav-glyph {
    font-size: 1.05rem;
    line-height: 20px;
  }
  .bottom-nav a.active {
    color: var(--primary);
    font-weight: 700;
  }
}

/* ---------- Nút & điều khiển ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-sm {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 0.875rem;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
  flex: none;
}
.icon-btn.ghost {
  border-color: transparent;
  background: transparent;
}
.icon-btn:hover {
  background: var(--surface-2);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.seg-btn {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.seg-btn + .seg-btn {
  border-left: 1px solid var(--border);
}
.seg-btn[aria-pressed='true'] {
  background: var(--primary-soft);
  color: var(--primary);
}
.speak {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--primary);
  flex: none;
  vertical-align: middle;
}
.speak:hover {
  background: var(--primary-soft);
}
.speak svg.i {
  width: 17px;
  height: 17px;
}
.speak.lg {
  width: 48px;
  height: 48px;
}
.speak.lg svg.i {
  width: 22px;
  height: 22px;
}
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}
.tab {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--muted);
  text-decoration: none;
}
.tab[aria-selected='true'],
.tab.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* ---------- Khối nội dung ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card {
  margin-top: 14px;
}
.card h2:first-child,
.card h3:first-child {
  margin-top: 0;
}
a.card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
a.card:hover {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
  transform: translateY(-1px);
}
.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
}
.grid > .card + .card {
  margin-top: 0;
}
.grid-2 {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}
.grid-2 > .card + .card {
  margin-top: 0;
}
.page-head {
  margin-bottom: 20px;
}
.page-head p {
  color: var(--muted);
  max-width: 68ch;
}
.crumbs {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.crumbs a {
  color: var(--muted);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.chip.open {
  background: var(--primary-soft);
  color: var(--primary);
}
.chip.tw {
  background: var(--accent-soft);
  color: var(--accent);
}
.notice {
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
}
.notice.warn {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.notice p:last-child {
  margin: 0;
}
ul.clean {
  margin: 0;
  padding-left: 1.2em;
}
ul.clean li + li {
  margin-top: 4px;
}
.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--bar, var(--primary));
  transition: width 0.3s;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
table.t th,
table.t td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.t th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-2);
}
table.t tr:last-child td {
  border-bottom: 0;
}
.empty {
  text-align: center;
  padding: 40px 16px;
}
.empty .big {
  font-size: 3rem;
  font-family: var(--font-zh);
}

/* ---------- Chữ Hán & phiên âm ---------- */
ruby {
  ruby-position: over;
}
rt.zy {
  font-family: var(--font-zh);
  font-size: 0.42em;
  color: var(--muted);
  letter-spacing: 0;
  font-weight: 400;
}
.hide-zy rt.zy {
  display: none;
}
.hide-py .py {
  display: none;
}
.zh-line {
  font-family: var(--font-zh);
  font-size: 1.35rem;
  line-height: 2.1;
}
.zh-big {
  font-family: var(--font-zh);
  font-size: 2.2rem;
  line-height: 1.9;
  font-weight: 500;
}
.py {
  color: var(--primary);
  font-weight: 500;
}
.hv {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
}
.vi {
  color: var(--text);
}
.sent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
}
.sent + .sent {
  border-top: 1px dashed var(--border);
}
.sent .zh-line {
  font-size: 1.2rem;
}
.sent-body {
  min-width: 0;
}
.sent-body .py,
.sent-body .vi {
  display: block;
  font-size: 0.92rem;
}
.sent-body .vi {
  color: var(--muted);
}

/* ---------- Trang chủ: lộ trình ---------- */
.hero {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: center;
  padding: 24px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface) 70%);
  border: 1px solid var(--border);
  margin-bottom: 26px;
}
.hero p {
  color: var(--muted);
  font-size: 1.02rem;
}
.hero-art {
  font-family: var(--font-zh);
  font-size: clamp(3.4rem, 2rem + 5vw, 5.4rem);
  line-height: 1;
  text-align: center;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.hero-art small {
  display: block;
  font-size: 1rem;
  letter-spacing: 0.3em;
  color: var(--muted);
  font-weight: 500;
  margin-top: 8px;
}
@media (max-width: 700px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 18px;
  }
  .hero-art {
    order: -1;
    text-align: left;
  }
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.stat {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat b {
  display: block;
  font-size: 1.3rem;
}
.stat span {
  color: var(--muted);
  font-size: 0.8rem;
}
.path {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-left: 34px;
}
.path::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--border);
}
.lv-card {
  position: relative;
  --lv: var(--primary);
}
.lv-card::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 22px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--surface);
  border: 4px solid var(--lv);
}
.lv-card.done::before {
  background: var(--lv);
}
.lv-card .lv-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.lv-badge {
  flex: none;
  min-width: 58px;
  height: 58px;
  padding: 0 8px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--lv) 14%, var(--surface));
  color: var(--lv);
  font-weight: 800;
  font-size: 1.15rem;
  text-align: center;
  line-height: 1.1;
}
.lv-badge small {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  opacity: 0.85;
}
.lv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 4px 0 8px;
}
.lv-card h3 {
  margin: 0;
}
.lv-card .progress {
  margin-top: 10px;
  --bar: var(--lv);
}
.lv-card .lv-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.lv-nhap-mon { --lv: var(--lv-nhap-mon); }
.lv-a1 { --lv: var(--lv-a1); }
.lv-a2 { --lv: var(--lv-a2); }
.lv-b1 { --lv: var(--lv-b1); }
.lv-b2 { --lv: var(--lv-b2); }
.lv-c1 { --lv: var(--lv-c1); }
.lv-c2 { --lv: var(--lv-c2); }

/* Danh sách bài trong một cấp */
.lessons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lesson {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
a.lesson:hover {
  border-color: color-mix(in srgb, var(--lv, var(--primary)) 55%, var(--border));
}
.lesson.soon {
  opacity: 0.62;
  background: transparent;
  border-style: dashed;
}
.lesson .tick {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  flex: none;
  color: transparent;
}
.lesson .tick svg.i {
  width: 15px;
  height: 15px;
  stroke-width: 3;
}
.lesson.done .tick {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.lesson-body {
  min-width: 0;
  flex: 1;
}
.lesson-body small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- Bảng chú âm ---------- */
.zy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
}
.zy-cell {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 6px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.zy-cell:hover,
.zy-cell[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.zy-cell .sym {
  display: block;
  font-family: var(--font-zh);
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 500;
}
.zy-cell .lat {
  display: block;
  font-weight: 700;
  color: var(--primary);
  font-size: 0.9rem;
}
.zy-detail {
  position: sticky;
  top: 70px;
}
.zy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 1000px) {
  .zy-layout {
    grid-template-columns: 1fr;
  }
  .zy-detail {
    position: static;
    order: -1;
  }
}
.group-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 22px 0 10px;
}
.group-title h2 {
  margin: 0;
  font-size: 1.05rem;
}

/* Thanh điệu */
.tone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
  gap: 12px;
}
.tone-card {
  text-align: center;
}
.tone-card svg.contour {
  width: 100%;
  height: 70px;
  display: block;
  margin: 4px 0 6px;
}
.tone-card .zh-big {
  line-height: 1.4;
}

/* ---------- Từ vựng ---------- */
.topic-card {
  display: flex !important;
  gap: 14px;
  align-items: center;
}
.topic-glyph {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-zh);
  font-size: 1.7rem;
  font-weight: 700;
  flex: none;
}
.topic-card .progress {
  margin-top: 8px;
}
.word-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.word {
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: center;
}
.word .zh-line {
  font-size: 1.7rem;
  line-height: 1.8;
}
.word .meaning b {
  font-size: 1.02rem;
}
.word .meaning .py {
  display: block;
}
.word .ex {
  grid-column: 1 / -1;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.word .note {
  display: block;
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 2px;
}
@media (max-width: 560px) {
  .word {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .word .meaning {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
.flash-wrap {
  max-width: 520px;
  margin: 0 auto;
}
.flashcard {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.flashcard .zh-big {
  font-size: 3.2rem;
}
.flashcard .back {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.flash-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

/* ---------- Bài luyện ---------- */
.quiz {
  max-width: 620px;
  margin: 0 auto;
}
.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}
.quiz .prompt {
  text-align: center;
  padding: 18px 10px;
}
.quiz .prompt .zh-big {
  font-size: 3rem;
}
.quiz .prompt .sym-big {
  font-family: var(--font-zh);
  font-size: 4rem;
  line-height: 1.2;
}
.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 480px) {
  .options.wide-1 {
    grid-template-columns: 1fr;
  }
}
.opt {
  min-height: 58px;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  text-align: center;
}
.opt.zh {
  font-size: 1.5rem;
  font-weight: 500;
}
.opt:hover:not([disabled]) {
  border-color: var(--primary);
}
.opt.right {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}
.opt.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}
.opt[disabled] {
  cursor: default;
}
.feedback {
  min-height: 1.6em;
  margin: 12px 0 0;
  text-align: center;
  font-weight: 600;
}
.feedback.ok {
  color: var(--ok);
}
.feedback.bad {
  color: var(--bad);
}
.result {
  text-align: center;
  padding: 28px 16px;
}
.result .score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
}

/* ---------- Mẫu câu ---------- */
.formula {
  display: inline-block;
  font-family: var(--font-zh);
  font-size: 1.25rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  margin: 6px 0 12px;
}
.exercise {
  padding: 14px 0;
}
.exercise + .exercise {
  border-top: 1px dashed var(--border);
}
.exercise .q {
  font-family: var(--font-zh);
  font-size: 1.35rem;
  margin-bottom: 10px;
}
.exercise .options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---------- Tiếng Đài ---------- */
.phrase {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 14px;
  padding: 12px 0;
}
.phrase + .phrase {
  border-top: 1px dashed var(--border);
}
.phrase .han {
  font-family: var(--font-zh);
  font-size: 1.3rem;
  font-weight: 500;
}
.phrase .tl {
  color: var(--accent);
  font-weight: 600;
}
.phrase .vi {
  display: block;
}
.phrase .hoa {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.phrase .tip {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Thông báo nhỏ ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 90;
  max-width: calc(100vw - 32px);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (max-width: 900px) {
  .toast {
    bottom: 84px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
