/* ===== HSK Grammar — style chung ===== */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --bd: #e3e7ee;
  --txt: #1f2328;
  --muted: #6b7280;
  --brand: #c8102e;       /* đỏ Trung Quốc */
  --brand-soft: #fdecef;
  --accent: #1f6feb;
  --accent-soft: #eaf1fd;
  --ok: #15803d;
  --ok-soft: #eafaf0;
  --warn: #b45309;
  --warn-soft: #fff7e6;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", -apple-system, "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

.zh { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", serif; }
.muted { color: var(--muted); }
.hidden, .is-hidden { display: none !important; }

/* ================= HEADER CHUNG (site-header.js) ================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 22px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--bd);
  backdrop-filter: saturate(160%) blur(8px);
  transition: transform .28s ease, box-shadow .2s ease;
  will-change: transform;
}
.site-header.is-hide {
  transform: translateY(-110%);
  box-shadow: none;
}
.site-header.hdr-solid { box-shadow: 0 4px 18px rgba(15, 23, 42, .07); }

/* nút ☰ */
.hdr-burger {
  flex: 0 0 auto;
  width: 46px;
  height: 42px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.hdr-burger span {
  display: block;
  width: 26px;
  height: 6px;
  border-radius: 99px;
  background: var(--brand);
  transition: transform .18s, opacity .18s;
}
.hdr-burger:hover span:nth-child(2) { transform: scaleX(.78); }
.hdr-burger:active span:nth-child(1) { transform: translateY(1px); }

/* Logo (thay chữ "Home" ở header) */
.hdr-home {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 8px;
  text-decoration: none;
  line-height: 0;
}
.hdr-home:hover { background: var(--brand-soft); }
.hdr-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
  border-radius: 6px;
}

.hdr-main { min-width: 0; }
.hdr-main h1 { font-size: 17px; margin: 0; font-weight: 700; color: var(--txt); }
.hdr-crumb { font-size: 12px; color: var(--muted); }
.site-header .spacer { flex: 1 1 auto; }

/* ---- khung tài khoản ---- */
.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--bd);
  background: #fff;
  color: var(--txt);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.account-btn:hover { background: var(--bg); border-color: #cbd5e1; }
.account-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.account-avatar--big { width: 42px; height: 42px; font-size: 20px; background: var(--brand-soft); color: var(--brand); }
.account-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-caret { font-size: 10px; color: var(--muted); }

.account-menu {
  position: absolute;
  right: 18px;
  top: 62px;
  width: 280px;
  background: #fff;
  color: var(--txt);
  border: 1px solid var(--bd);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .18);
  padding: 14px;
  z-index: 60;
}
.account-head { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--bd); }
.account-title { font-weight: 700; font-size: 14px; }
.account-sub { font-size: 12px; color: var(--muted); }
.account-list { list-style: none; margin: 10px 0; padding: 0; font-size: 13px; }
.account-list li { display: flex; justify-content: space-between; padding: 4px 0; color: #374151; }
.account-list em { font-style: normal; color: var(--brand); font-weight: 600; }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.account-actions .btn[disabled] { opacity: .55; cursor: not-allowed; }
.account-note { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }

/* ---- drawer "Mục chính" ---- */
.sh-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .42);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 90;
}
.sh-mask.is-open { opacity: 1; pointer-events: auto; }
.sh-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 322px; max-width: 88vw;
  background: #fff;
  border-right: 1px solid var(--bd);
  box-shadow: 8px 0 30px rgba(15, 23, 42, .16);
  transform: translateX(-104%);
  transition: transform .26s cubic-bezier(.3, .9, .3, 1);
  z-index: 95;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sh-drawer.is-open { transform: none; }
body.sh-lock { overflow: hidden; }
.sh-din { padding: 16px; }
.sh-dhd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sh-dhd b { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.sh-x {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--bd); background: #fff; cursor: pointer;
  font-size: 14px; color: var(--muted);
}
.sh-x:hover { background: var(--bg); }
.sh-dhome {
  display: block;
  padding: 11px 13px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.sh-dhome:hover { background: #fbdde3; }
.sh-dnav { display: flex; flex-direction: column; gap: 2px; }
.sh-ditem {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "zh em" "vi em";
  align-items: center;
  gap: 0 8px;
  padding: 10px 12px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--txt);
  font-size: 14px;
}
.sh-ditem:hover { background: var(--bg); }
.sh-ditem .sh-dzh { grid-area: zh; font-size: 15px; font-weight: 700; color: var(--brand); }
.sh-ditem > span:nth-child(2) { grid-area: vi; font-size: 12.5px; color: var(--muted); }
.sh-ditem em { grid-area: em; font-style: normal; font-size: 12px; color: var(--muted); }
.sh-ditem em.ok { color: var(--brand); font-weight: 700; font-size: 15px; }
.sh-ditem.is-on { background: var(--brand-soft); }
.sh-ditem.is-soon { opacity: .62; }
.sh-dnote { margin: 16px 4px 4px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ---------- MÀN HÌNH CHÍNH ---------- */
.home { max-width: 1120px; margin: 0 auto; padding: 24px 24px 70px; }

.intro {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.intro h2 { margin: 0 0 6px; font-size: 22px; }
.intro p { margin: 0; color: var(--muted); font-size: 14px; }
.intro p b { color: var(--txt); }
.intro .zh { color: var(--brand); font-weight: 600; }
.intro .stats { display: flex; gap: 22px; margin-top: 14px; flex-wrap: wrap; }
.intro .stat { font-size: 13px; color: var(--muted); }
.intro .stat b { display: block; font-size: 22px; color: var(--brand); line-height: 1.2; }

.home-tools { margin-top: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.home-tools input[type="search"] {
  flex: 1 1 320px;
  padding: 10px 14px;
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.home-tools input[type="search"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search-stats { font-size: 13px; color: var(--muted); }

/* lưới bài học */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.lesson-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  text-decoration: none;
  color: var(--txt);
  transition: transform .12s, box-shadow .12s, border-color .12s;
  border-left: 4px solid var(--brand);
}
.lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
  border-color: #cfd6e2;
  border-left-color: var(--brand);
}
.lesson-card--empty { border-left-color: #c9ced8; }

/* Thẻ ĐỀ THI THỬ (đặt cuối danh sách bài học HSK 1) */
.lesson-card--exam {
  border-left-color: #7c3aed;
  background: linear-gradient(135deg, #faf5ff 0%, #ffffff 60%);
}
.lesson-card--exam:hover { border-left-color: #7c3aed; }
.lesson-card--exam .lesson-no { background: #7c3aed; }
.lesson-card--exam .lesson-code { color: #7c3aed; }
.pill--exam {
  background: #f3e8ff; color: #6d28d9; border-color: #e0d0fb; font-weight: 700;
}

.card-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.lesson-no {
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 1px 8px;
  font-weight: 700;
  font-size: 12px;
}
.lesson-code { font-weight: 600; color: var(--brand); }
.lesson-page { margin-left: auto; font-variant-numeric: tabular-nums; }

.card-title { margin: 8px 0 10px; display: flex; flex-direction: column; gap: 1px; }
.card-title .zh { font-size: 20px; font-weight: 700; color: #111827; line-height: 1.35; }
.card-title .py { font-size: 13px; color: var(--accent); font-style: italic; }
.card-title .vi { font-size: 14px; color: #374151; }
.card-title .en { font-size: 12.5px; color: var(--muted); }

.card-foot { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--bd);
}
.pill--grammar { background: var(--brand-soft); color: var(--brand); border-color: #f6c9d2; font-weight: 600; }
.pill--muted { background: #f1f3f6; }

.card-points { list-style: none; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--bd); }
.card-points li { font-size: 13px; color: var(--muted); padding: 2px 0; }
.card-points li.hit { color: var(--brand); font-weight: 600; }
.card-points li.hit .muted { color: var(--brand); opacity: .8; font-weight: 400; }

.source-note { margin-top: 26px; font-size: 12.5px; color: var(--muted); }
.source-note a { color: var(--accent); }

/* ---------- chọn cấp độ ---------- */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.level-card {
  display: block;
  text-decoration: none;
  color: var(--txt);
  background: var(--card);
  border: 1px solid var(--bd);
  border-left: 5px solid var(--level-accent, var(--brand));
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform .12s, box-shadow .12s;
}
.level-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.1); }
.level-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.level-badge {
  background: var(--level-accent, var(--brand));
  color: #fff;
  border-radius: 7px;
  padding: 2px 10px;
  font-weight: 700;
  font-size: 13px;
}
.level-book { font-size: 12px; color: var(--muted); }
.level-card h3 { margin: 10px 0 4px; font-size: 18px; }
.level-meta { font-size: 13px; color: #374151; }
.level-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.breadcrumb { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13px; }
.bc-sep { color: var(--muted); }
.breadcrumb b { color: var(--brand); }

.pill--dialog { background: #eef2ff; color: #4338ca; border-color: #d5daf6; }
.pill--pron { background: var(--brand-soft); color: var(--brand); border-color: #f3c2cc; text-decoration: none; font-weight: 600; }
.pill--pron:hover { background: var(--brand); color: #fff; }

/* ---------- MỤC LỤC BÀI HỌC (danh mục chức năng) ---------- */
.lesson-toc {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 18px;
}
.toc-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.toc-sub { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.toc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.toc-grid--3 { grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); }
.toc-card {
  position: relative;
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--bd); border-radius: 10px;
  padding: 11px 12px; background: #fff; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.toc-card .toc-icon { font-size: 20px; line-height: 1.1; }
.toc-card .toc-name { font-size: 13.5px; }
.toc-card .toc-name b { font-weight: 700; }
.toc-card .toc-desc { font-size: 11.5px; color: var(--muted); line-height: 1.35; min-height: 30px; }
.toc-card .toc-go { font-size: 11.5px; font-weight: 600; color: var(--brand); margin-top: 2px; }

.toc-ready { border-left: 3px solid var(--brand); cursor: pointer; }
.toc-ready:hover { box-shadow: 0 6px 18px rgba(200,16,46,.14); transform: translateY(-2px); border-color: var(--brand); }
.toc-soon, .toc-empty { opacity: .55; border-left: 3px solid #c9ced8; cursor: not-allowed; background: #fafbfc; }
.toc-soon .toc-go, .toc-empty .toc-go { color: var(--muted); }
.toc-active { background: var(--brand-soft); border-color: var(--brand); border-left-width: 4px; }
.toc-active .toc-go { color: var(--ok); }
.lesson-toc-back { margin: 0 0 12px; }
.lesson-toc-back .btn { display: inline-block; }



.pill--seen { background: var(--ok-soft); color: var(--ok); border-color: #bfe8cd; }

.data-note {
  background: var(--warn-soft);
  border: 1px solid #f2dfb4;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #7c4a03;
  margin: 0 0 16px;
}

/* ---------- hội thoại cuối bài ---------- */
.dialogue {
  background: var(--card);
  border: 1px solid var(--bd);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  margin-top: 22px;
}
.dialogue-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.dialogue-head h3 { margin: 0; font-size: 17px; }
.dialogue-sub { font-size: 12.5px; color: var(--muted); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat-row { display: flex; flex-direction: column; max-width: 88%; transition: transform .2s ease; }
.chat-row.is-speaking { transform: scale(1.02); }
.chat-row.is-speaking .chat-bubble {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* nút “Nghe cả đoạn” ở đầu khung hội thoại */
.dl-playall {
  margin-left: auto; white-space: nowrap; font-weight: 600;
}
.dl-playall.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chat-row.left { align-self: flex-start; align-items: flex-start; }
.chat-row.right { align-self: flex-end; align-items: flex-end; }
.chat-who { font-size: 12px; font-weight: 700; color: var(--brand); margin: 0 0 3px 4px; }
.chat-bubble {
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 9px 13px;
  background: #fcfdff;
}
.chat-row.right .chat-bubble { background: var(--accent-soft); border-color: #c7dbfb; }
.chat-row.cont .chat-bubble { border-top-left-radius: 4px; }
.chat-bubble .zh { font-size: 17px; line-height: 1.7; color: #111827; }
.chat-bubble .py { font-size: 12.5px; color: var(--accent); font-style: italic; }
.chat-bubble .vi { font-size: 13.5px; color: #4b5563; margin-top: 2px; }
.chat-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--brand);
  background: #fff;
  border: 1px dashed #f0b9c3;
  border-radius: 7px;
  padding: 3px 8px;
  display: inline-block;
}
.dialogue-note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- MÀN HÌNH BÀI HỌC ---------- */
.lesson-view { max-width: 900px; margin: 0 auto; padding: 20px 24px 90px; }

.lesson-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.lesson-nav .spacer { flex: 1; }
.nav-count { font-size: 12.5px; color: var(--muted); }

.btn {
  display: inline-block;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--bd);
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.btn:hover { background: var(--bg); border-color: #cbd5e1; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #a10d25; }

/* tiêu đề bài */
.lesson-hero {
  background: linear-gradient(135deg, var(--brand-soft), #fff 70%);
  border: 1px solid var(--bd);
  border-left: 5px solid var(--brand);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
}
.hero-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.hero-extra { background: #fff; border: 1px solid var(--bd); border-radius: 999px; padding: 1px 9px; }
.lesson-hero h2 { margin: 8px 0 2px; font-size: 26px; color: #111827; }
.lesson-hero h2 .zh { color: var(--brand); }
.hero-py { font-size: 14px; color: var(--accent); font-style: italic; }
.hero-vi { font-size: 15px; color: #374151; }
.hero-vi .en { font-size: 13px; color: var(--muted); }

.objective {
  margin-top: 12px;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 10px 14px;
}
.objective-label { font-size: 12.5px; font-weight: 700; color: var(--brand); }
.objective ul { margin: 6px 0 0; padding-left: 20px; font-size: 14px; color: #374151; }
.objective li { margin: 1px 0; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding-left: 2px;
}
.section-head h3 { margin: 0; font-size: 17px; }
.section-meta { font-size: 12.5px; color: var(--muted); }

/* ================= TRANG CHỦ (7 mục chính) ================= */
.home--main { padding-top: 26px; }

.mh-hero {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 24px 26px;
  border-radius: 16px;
  margin-bottom: 22px;
  color: #fff;
  background:
    radial-gradient(120% 130% at 100% 0%, #ff9a6b 0%, transparent 52%),
    linear-gradient(135deg, #c8102e 0%, #8b0d20 58%, #40102c 100%);
  box-shadow: 0 12px 30px rgba(139, 13, 32, .2);
}
.mh-hero-tx { min-width: 0; }
.mh-kicker {
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(255, 255, 255, .78);
}
.mh-hero h2 {
  margin: 5px 0 4px;
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.16;
}
.mh-hero p { margin: 0; font-size: 13.5px; color: rgba(255, 255, 255, .84); }
.mh-hero-badges { display: flex; gap: 10px; flex-wrap: wrap; }
.mh-hero-badges div {
  min-width: 92px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .26);
  text-align: center;
}
.mh-hero-badges b { display: block; font-size: 21px; line-height: 1.15; }
.mh-hero-badges span { font-size: 11px; color: rgba(255, 255, 255, .8); }
/* dòng phụ: con số gồm những phần nào (HSK 1–4 · chủ đề HSK 7-9) */
.mh-hero-badges em.mh-stat-note {
  display: block; margin-top: 3px; font-style: normal;
  font-size: 9.5px; line-height: 1.35; letter-spacing: .01em;
  color: rgba(255, 255, 255, .62);
}

/* lưới 7 ô */
.main-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 16px;
}
.mm-card {
  --tone: #c8102e;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 172px;
  padding: 20px 20px 18px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--bd);
  text-decoration: none;
  color: var(--txt);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.mm-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--tone);
}
.mm-card::after {
  content: "";
  position: absolute;
  right: -38px; bottom: -52px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: var(--tone);
  opacity: .07;
}
a.mm-card:hover {
  transform: translateY(-3px);
  border-color: var(--tone);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .12);
}
.mm-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "PingFang SC", "Microsoft YaHei", serif;
  font-size: 23px;
  font-weight: 700;
  color: #fff;
  background: var(--tone);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .16);
}
.mm-zh {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  color: #111827;
  letter-spacing: -.005em;
}
.mm-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.mm-go {
  margin-top: auto;
  padding-top: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--tone);
}
.mm-card.is-soon { opacity: .58; cursor: default; }
.mm-card.is-soon .mm-go { color: var(--muted); }

.mm-card--brand  { --tone: #c8102e; }
.mm-card--blue   { --tone: #1f6feb; }
.mm-card--amber  { --tone: #b45309; }
.mm-card--green  { --tone: #15803d; }
.mm-card--purple { --tone: #7c3aed; }
.mm-card--teal   { --tone: #0f766e; }
.mm-card--slate  { --tone: #475569; }

/* ô HSK 3.0 nổi bật hơn (mục đang dùng được) */
.mm-card--brand:not(.is-soon) {
  background: linear-gradient(140deg, #fff 0%, #fff5f7 100%);
  border-color: #f3c6cf;
}


/* ---------- thẻ lớn "Học Phát âm" (chỉ HSK 1) ---------- */
.pron-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 210px;
  padding: 20px 20px 18px;
  border-radius: 14px;
  text-decoration: none;
  color: #fff;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 100% 0%, #ff9a6b 0%, transparent 55%),
    linear-gradient(135deg, #c8102e 0%, #8b0d20 60%, #4a1230 100%);
  box-shadow: 0 8px 22px rgba(139, 13, 32, .22);
  transition: transform .14s, box-shadow .14s;
}
.pron-hero:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(139, 13, 32, .3); }
.pron-hero::after {
  content: "";
  position: absolute;
  right: -46px; bottom: -60px;
  width: 190px; height: 190px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .28);
}
.pron-hero-deco {
  position: absolute;
  right: 12px; top: 6px;
  font-family: "PingFang SC", "Microsoft YaHei", serif;
  font-size: 62px;
  font-weight: 700;
  letter-spacing: .06em;
  color: rgba(255, 255, 255, .14);
  line-height: 1;
  user-select: none;
}
.pron-hero-icon {
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .25));
}
.pron-hero-t {
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.15;
}
.pron-hero-zh { font-size: 14px; color: rgba(255, 255, 255, .82); letter-spacing: .04em; }
.pron-hero-d { font-size: 12.5px; color: rgba(255, 255, 255, .78); line-height: 1.45; max-width: 30ch; }
.pron-hero-go {
  margin-top: 8px;
  align-self: flex-start;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
}


/* ---------- thẻ điểm ngữ pháp ---------- */
.lesson {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
  scroll-margin-top: 76px;
}
.lesson-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--bd);
  background: linear-gradient(to right, var(--brand-soft), #fff 60%);
}
.lesson-head .kicker { font-size: 12px; color: var(--brand); font-weight: 600; letter-spacing: .03em; }
.lesson-head h3 { margin: 4px 0 0; font-size: 19px; line-height: 1.45; }
.lesson-head h3 .zh { font-size: 22px; color: var(--brand); margin-right: 8px; }
.badges { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--bd);
}
.badge.lv1 { background: var(--ok-soft); color: var(--ok); border-color: #bfe8cd; }
.badge.lv2 { background: var(--accent-soft); color: var(--accent); border-color: #c7dbfb; }
.badge.lv3 { background: var(--warn-soft); color: var(--warn); border-color: #f2dfb4; }

.lesson-body { padding: 18px 22px 22px; }

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 700;
  margin: 18px 0 8px;
}
.section-label:first-child { margin-top: 0; }

.rule-box {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 15px;
  color: #0b3d91;
  white-space: pre-wrap;
  word-break: break-word;
}

.explain p { margin: 0 0 9px; }
.explain p:last-child { margin-bottom: 0; }

.notes { margin: 0; padding: 0; list-style: none; }
.notes li {
  position: relative;
  padding: 8px 12px 8px 34px;
  background: var(--warn-soft);
  border-radius: 7px;
  margin-bottom: 7px;
  font-size: 14px;
  color: #7c4a03;
}
.notes li::before {
  content: "!";
  position: absolute;
  left: 12px;
  top: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* ---------- ví dụ (có nút 🔊) ---------- */
.examples { display: flex; flex-direction: column; gap: 10px; }
.ex {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fcfdff;
}
.ex-tx { flex: 1 1 auto; min-width: 0; }
.ex .zh { font-size: 18px; line-height: 1.8; color: #111827; }
.ex .py { font-size: 13px; color: var(--accent); font-style: italic; }
.ex .vi { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* nút loa dùng chung cho ví dụ / bong bóng hội thoại */
.dt-spk {
  flex: 0 0 auto; cursor: pointer; line-height: 1; white-space: nowrap;
  border: 1px solid var(--bd); background: #fff; border-radius: 10px;
  padding: 6px 9px; font-size: 14px; transition: background .15s, border-color .15s, transform .12s;
}
.dt-spk:hover { background: var(--accent-soft); border-color: #c9dcfb; }
.dt-spk.is-playing { animation: dtpulse .9s ease; }
@keyframes dtpulse {
  0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); }
}
.dt-spk--ex { align-self: flex-start; font-size: 15px; }
.dt-spk--bubble {
  float: right; margin: -6px -6px 0 8px;
  border: 0; background: transparent; padding: 2px 4px; font-size: 13px; opacity: .6;
}
.dt-spk--bubble:hover { opacity: 1; background: transparent; transform: scale(1.15); }

/* ==========================================================================
   BÀI TẬP NGỮ PHÁP (HSK 1–4) — cùng khung với HSK 7-9
   ========================================================================== */
.ex-count {
  margin-left: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0;
  text-transform: none; color: #123a5c;
  background: #eef6ff; border: 1px solid #cde1fb; border-radius: 99px; padding: 1px 9px;
}
.ex-wrap { display: flex; flex-direction: column; gap: 12px; }
.ex-box {
  padding: 14px 16px 16px; border-radius: 12px;
  background: #fbfcfe; border: 1px dashed #c7d3e3;
}
.ex-box.is-done { border-style: solid; border-color: #bbe7cc; background: #f7fdf9; }
.ex-hd { font-size: 14px; margin-bottom: 6px; }
.ex-type {
  margin-left: 8px; font-size: 11.5px; font-weight: 600; color: #475569;
  background: #f1f5f9; border-radius: 99px; padding: 1px 8px;
}
.ex-prompt { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.ex-list { margin: 0; padding-left: 22px; }
.ex-q { margin: 10px 0; font-size: 14px; }
.ex-qtx { font-size: 15.5px; line-height: 1.6; margin-bottom: 4px; }
.ex-qpy { font-size: 13px; color: var(--accent); font-style: italic; line-height: 1.5; margin-bottom: 3px; }
.ex-qvi { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.ex-opts { display: flex; gap: 7px; flex-wrap: wrap; }
.ex-opt {
  cursor: pointer; font-family: inherit; font-size: 14px; text-align: left;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--bd); background: #fff;
}
.ex-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.ex-opt.is-ok { border-color: #15803d; background: #e8f8ee; }
.ex-opt.is-bad { border-color: #c8102e; background: #fdecef; }
.ex-opt-py {
  display: block; font-size: 11.5px; font-style: italic;
  color: var(--accent); opacity: .85; margin-top: 1px;
}
.ex-write { display: flex; gap: 8px; align-items: flex-start; }
.ex-write textarea {
  flex: 1 1 auto; min-height: 52px; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--bd); border-radius: 8px; font-family: inherit; resize: vertical;
}
.ex-write textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.ex-fb { font-size: 13px; margin-top: 6px; }
.ex-fb .ok { color: var(--ok); }
.ex-fb .bad { color: #c8102e; }
.ex-fb .warn { color: #b45309; }
.ex-act { margin-top: 10px; }
.ex-ans {
  margin-top: 10px; padding: 10px 12px; border-radius: 9px;
  background: #eef6ff; border: 1px solid #cde1fb; font-size: 13.5px; line-height: 1.7;
}
.ex-ans-vi { margin-top: 4px; color: #334155; }


/* ---------- trạng thái ---------- */
.empty {
  background: var(--card);
  border: 1px dashed var(--bd);
  border-radius: var(--radius);
  padding: 30px 24px;
  text-align: center;
  color: var(--muted);
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .home { padding: 18px 14px 60px; }
  .lesson-view { padding: 16px 14px 70px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .level-grid { grid-template-columns: 1fr; }
  .toc-grid--3 { grid-template-columns: 1fr; }
  .main-menu { grid-template-columns: 1fr; }
  .mh-hero { padding: 18px 18px 16px; }
  .mh-hero-badges { width: 100%; }
  .mh-hero-badges div { flex: 1 1 0; min-width: 0; }
  .mm-card { min-height: 0; }
  .site-header { padding: 8px 12px; gap: 8px; }
  .hdr-burger { width: 40px; height: 38px; }
  .hdr-home { font-size: 17px; }
  .hdr-logo { height: 32px; max-width: 130px; }
  .hdr-main h1 { font-size: 15px; }
  .hdr-main .hdr-crumb { display: none; }
  .account-name { display: none; }
  .account-btn { padding: 4px 8px 4px 4px; }
  .lesson-hero h2 { font-size: 22px; }
  .account-menu { right: 8px; left: 8px; width: auto; top: auto; position: fixed; margin-top: 8px; }
  .chat-row { max-width: 96%; }
  .g-wrap { padding: 14px 14px 70px; }
}

/* ---------- print ---------- */
@media print {
  .site-header, .lesson-nav, .home-tools, .source-note { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .lesson { break-inside: avoid; border-color: #999; margin-bottom: 10px; }
  .lesson-view { max-width: none; padding: 0; }
  .lesson-hero { border-color: #999; }
}

/* ---------- PHIÊN ÂM trong trang ngữ pháp ---------- */
/* phiên âm dưới tên điểm ngữ pháp */
.point-py {
  margin-top: 3px;
  font-size: 14.5px;
  font-style: italic;
  color: var(--accent);
  letter-spacing: .01em;
  line-height: 1.45;
}
/* phiên âm dưới khung cấu trúc (rule-box) */
.rule-py {
  margin-top: 6px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-style: italic;
  color: #0b3d91;
  background: #f3f7ff;
  border-left: 4px solid #b9d0f5;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
/* phiên âm nhỏ nội tuyến (kicker, mục lục) */
.py {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  opacity: .9;
}
.kicker .py { font-size: 11px; }
.g-toc-tx .py { font-size: 12.5px; }
.g-toc-tx { display: block; }



/* ================= TRANG NGỮ PHÁP RIÊNG (grammar.html) ================= */
.g-wrap { max-width: 940px; margin: 0 auto; padding: 18px 24px 90px; }
.g-crumb { flex-wrap: wrap; }
.g-crumb .spacer { flex: 1 1 auto; }
.g-crumb b { white-space: nowrap; }

.g-toc {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 0 0 20px;
}
.g-toc-h { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.g-toc-h b { color: var(--brand); }
.g-toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.g-toc li a {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: #374151;
  font-size: 14px;
}
.g-toc li a:hover { background: var(--brand-soft); color: var(--brand); }
.g-toc-n {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.g-toc li a .zh { font-size: 15.5px; font-weight: 600; color: #111827; }

.g-foot-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px dashed var(--bd);
}
.g-foot-nav .btn.is-off { opacity: .45; cursor: default; }
