/* ============================================================================
 * learn.css — GIAO DIỆN TRANG GIÁO TRÌNH /learn/ (một file CSS duy nhất)
 * ----------------------------------------------------------------------------
 * Vai trò:   Style cho landing page khoá học và mọi trang bài học/tài liệu do
 *            tools/learn-site/build.mjs sinh ra.
 * Khái niệm: design token bằng biến CSS (:root) · chế độ tối theo
 *            prefers-color-scheme + ghi đè bằng [data-theme] · mobile-first,
 *            không cuộn ngang (bảng/code cuộn trong khung riêng) · focus rõ ràng.
 * Màu:       lấy từ game (cam #f27a43, vàng #ffc94a, xanh #52c5ee, mực #17233d)
 *            nhưng chỉnh đậm/nhạt để chữ đạt tương phản WCAG AA.
 * ========================================================================== */

/* ---------- 1. Token màu & chữ ---------- */
:root {
  color-scheme: light;
  --bg: #fff8ec;
  --bg-alt: #fdeed6;
  --surface: #ffffff;
  --surface-2: #fff3df;
  --text: #1c2540;
  --muted: #4d5872;
  --border: #ecdcc0;
  --accent: #c2410c;          /* cam đậm: chữ trắng trên nền này đạt 5.2:1 */
  --accent-strong: #9a3412;
  --accent-soft: #ffe2cc;
  --link: #0b5f84;
  --gold: #ffc94a;
  --blue: #0b6f96;
  --ink: #17233d;
  --code-bg: #1c2540;
  --code-text: #e8edf8;
  --inline-code-bg: #f7e6cb;
  --inline-code-text: #7a2a0b;
  --focus: #1d6fe0;
  --shadow: 0 2px 0 #e7cfa5, 0 10px 30px -18px #6b4a1a55;
  --tip: #0f7a4f; --tip-bg: #e3f6ec;
  --warn: #9a5b00; --warn-bg: #fff1cf;
  --try: #6b3fc4; --try-bg: #efe8ff;
  --stop: #b42318; --stop-bg: #ffe7e3;
  --note: #0b5f84; --note-bg: #e4f3fb;
  --hl-kw: #ff9e64; --hl-str: #a5e07a; --hl-num: #ffd36b; --hl-com: #93a1c2;
  --hl-fn: #7cc8ff; --hl-attr: #f7a6d4; --hl-var: #e8edf8;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius: 14px;
  --deco-1: #ffc94a55; --deco-2: #52c5ee44;
  --topbar-h: 60px;
}

/* Chế độ tối: theo hệ điều hành (trừ khi người dùng chọn sáng), hoặc khi chọn tối bằng nút. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #10192b; --bg-alt: #142036; --surface: #17233d; --surface-2: #1d2b49;
    --text: #eef2fb; --muted: #b6c0d8; --border: #2c3b5c;
    --accent: #ff9a5c; --accent-strong: #ffb37f; --accent-soft: #3a2a26; --link: #8fd8f5;
    --blue: #52c5ee; --code-bg: #0b1322; --inline-code-bg: #24314f; --inline-code-text: #ffd0ad;
    --focus: #ffc94a; --shadow: 0 2px 0 #0a1120, 0 10px 30px -18px #000;
    --tip: #6fe0a8; --tip-bg: #12302a; --warn: #ffd36b; --warn-bg: #33291a;
    --try: #c4a8ff; --try-bg: #271f40; --stop: #ff9a8f; --stop-bg: #3a1f22;
    --note: #8fd8f5; --note-bg: #13304a;
    --deco-1: #ffc94a1a; --deco-2: #52c5ee1a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10192b; --bg-alt: #142036; --surface: #17233d; --surface-2: #1d2b49;
  --text: #eef2fb; --muted: #b6c0d8; --border: #2c3b5c;
  --accent: #ff9a5c; --accent-strong: #ffb37f; --accent-soft: #3a2a26; --link: #8fd8f5;
  --blue: #52c5ee; --code-bg: #0b1322; --inline-code-bg: #24314f; --inline-code-text: #ffd0ad;
  --focus: #ffc94a; --shadow: 0 2px 0 #0a1120, 0 10px 30px -18px #000;
  --tip: #6fe0a8; --tip-bg: #12302a; --warn: #ffd36b; --warn-bg: #33291a;
  --try: #c4a8ff; --try-bg: #271f40; --stop: #ff9a8f; --stop-bg: #3a1f22;
  --note: #8fd8f5; --note-bg: #13304a;
  --deco-1: #ffc94a1a; --deco-2: #52c5ee1a;
}

/* ---------- 2. Nền tảng ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 18px; line-height: 1.7;
  overflow-x: hidden; overflow-wrap: break-word;
}
@media (max-width: 640px) { body { font-size: 17px; } }
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
.muted { color: var(--muted); }
.small { font-size: .88em; }
/* "(đã học)": ẩn với mắt thường nhưng trình đọc màn hình đọc được — chỉ khi bài đã học (dấu ✓ là aria-hidden). */
.sr-done { display: none; }
.is-done .sr-done { display: inline; position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700;
}
.skip-link:focus { top: 10px; }

/* ---------- 3. Nút ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4em; justify-content: center;
  font: inherit; font-size: .92em; font-weight: 700; line-height: 1.3;
  padding: 10px 18px; border-radius: 12px; border: 2px solid transparent;
  background: var(--accent); color: #fff; text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--accent-strong);
  transition: transform .08s ease, box-shadow .08s ease;
}
:root[data-theme="dark"] .btn:not(.btn-ghost):not(.btn-alt), :root[data-theme="dark"] .btn-done[aria-pressed="false"] { color: #1a0f08; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:not(.btn-ghost):not(.btn-alt) { color: #1a0f08; } }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-strong); }
.btn-lg { font-size: 1.02em; padding: 13px 24px; border-radius: 14px; }
.btn-alt { background: var(--blue); box-shadow: 0 4px 0 #084e6b; color: #fff; }
:root[data-theme="dark"] .btn-alt { color: #06202c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-alt { color: #06202c; box-shadow: 0 4px 0 #1f7fa3; } }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: 0 3px 0 var(--border); }
.btn-done[aria-pressed="true"] { background: var(--tip-bg); color: var(--tip); border-color: var(--tip); box-shadow: 0 3px 0 var(--tip); }
.icon-btn {
  font: inherit; font-size: 20px; width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--border); background: var(--surface); color: var(--text); flex: none;
}
html:not(.js) #themeBtn, html:not(.js) .copy-btn, html:not(.js) #doneBtn { display: none; }

/* ---------- 4. Thanh trên ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-in { max-width: 1440px; margin: 0 auto; height: 100%; display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; line-height: 1.2; min-width: 0; }
.brand b { color: var(--accent); }
.brand-logo { width: 38px; height: 38px; display: grid; place-items: center; background: var(--gold); border-radius: 12px; font-size: 22px; box-shadow: 0 3px 0 #d9a21f; flex: none; }
.topnav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.topnav a { color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; padding: 8px 12px; border-radius: 10px; }
.topnav a:hover { background: var(--surface-2); }
.topnav-play { background: var(--accent-soft); white-space: nowrap; }
.nav-btn { display: none; }
@media (max-width: 900px) {
  .topbar-in { padding: 0 16px; gap: 8px; }
  .topnav a:not(.topnav-play) { display: none; }
  .nav-btn { display: inline-block; }
}
@media (max-width: 480px) {
  .brand span:last-child { font-size: 15px; }
  .topnav-play { font-size: 20px !important; padding: 6px 10px !important; }
  .tp-text { display: none; }          /* màn rất hẹp: chỉ còn biểu tượng 🎮, tên nút nằm ở aria-label */
}

/* ---------- 5. Bố cục trang tài liệu: thanh bên | nội dung | mục lục ---------- */
.page { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { grid-column: 1; grid-row: 1; border-right: 1px solid var(--border); }
.doc { grid-column: 2; grid-row: 1; }
.sb-in { position: sticky; top: var(--topbar-h); max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 24px 16px 40px 24px; font-size: 15.5px; line-height: 1.45; }
.sb-head { margin: 18px 0 6px; font-size: 12.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sb-head:first-child { margin-top: 0; }
.sidebar ul, .sidebar ol { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.sb-num { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--muted); min-width: 1.6em; }
.sb-title { flex: 1; }
.sb-done { color: var(--tip); font-weight: 900; visibility: hidden; }
.is-done .sb-done { visibility: visible; }
.sb-sub { margin: 2px 0 4px 14px !important; border-left: 2px solid var(--border); padding-left: 6px !important; }
.sb-sub a { font-size: 14.5px; padding: 4px 8px; }
.scrim { display: none; }

.doc {
  display: grid; padding: 32px 48px 56px; column-gap: 48px;
  grid-template-columns: minmax(0, 780px) 230px;
  grid-template-areas: "head toc" "body toc" "foot toc";
  align-content: start;
}
.doc-head { grid-area: head; }
.toc { grid-area: toc; }
.prose { grid-area: body; min-width: 0; }
.doc-foot { grid-area: foot; min-width: 0; }

@media (max-width: 1240px) {
  .doc { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "toc" "body" "foot"; padding: 28px 32px 48px; max-width: 860px; }
}
@media (max-width: 900px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .doc { grid-column: 1; padding: 20px 16px 40px; }
  /* Thanh bên thành ngăn kéo trượt từ trái khi bấm ☰ */
  html.js .sidebar {
    position: fixed; z-index: 40; top: var(--topbar-h); bottom: 0; left: 0; width: min(320px, 86vw);
    background: var(--bg); border-right: 1px solid var(--border); transform: translateX(-105%);
    transition: transform .2s ease; visibility: hidden;
  }
  html.js body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 10px 0 40px #0005; }
  html.js .sb-in { position: static; max-height: none; height: 100%; padding: 16px; }
  html.js body.nav-open .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35; background: #0007; }
  /* Không có JS: thanh bên nằm dưới nội dung */
  html:not(.js) .sidebar { grid-column: 1; grid-row: 2; border-right: 0; border-top: 1px solid var(--border); }
  html:not(.js) .sb-in { position: static; max-height: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- 6. Đầu trang tài liệu ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 10px; padding: 0; font-size: 14.5px; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin: 0 8px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.kicker { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 0 6px; font-size: 15px; color: var(--muted); }
.badge { background: var(--accent); color: #fff; font-weight: 800; padding: 2px 10px; border-radius: 99px; font-size: 13.5px; }
:root[data-theme="dark"] .badge { color: #1a0f08; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge { color: #1a0f08; } }
.badge-sol { background: var(--stop); }
.badge-doc { background: var(--blue); }
.lvl { font-weight: 700; font-size: 13.5px; padding: 1px 9px; border-radius: 99px; border: 1.5px solid currentColor; }
.lvl-1 { color: var(--tip); } .lvl-2 { color: var(--note); } .lvl-3 { color: var(--try); }
.doc-head h1 { font-size: clamp(30px, 4.2vw, 42px); line-height: 1.2; margin: 6px 0 16px; letter-spacing: -.01em; }
.h1-num { color: var(--accent); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; }
.prereq { margin: 4px 0 0; font-size: 15.5px; color: var(--muted); }

/* ---------- 7. Mục lục trong trang ---------- */
.toc details { position: sticky; top: calc(var(--topbar-h) + 20px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow: auto; font-size: 14.5px; line-height: 1.45; }
.toc summary { font-weight: 800; cursor: pointer; padding: 6px 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0 0 0 2px; border-left: 2px solid var(--border); }
.toc li a { display: block; padding: 4px 12px; color: var(--muted); text-decoration: none; }
.toc li a:hover { color: var(--accent-strong); }
.toc .toc-l3 a { padding-left: 26px; font-size: 13.5px; }
@media (max-width: 1240px) {
  .toc { margin: 8px 0 20px; }
  .toc details { position: static; max-height: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 16px; }
  .toc details[open] { padding-bottom: 12px; }
}

/* ---------- 8. Nội dung bài (Markdown đã render) ---------- */
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.55em; line-height: 1.3; margin: 2.1em 0 .6em; padding-top: .4em; border-top: 2px dashed var(--border); }
.prose h3 { font-size: 1.22em; line-height: 1.35; margin: 1.7em 0 .5em; }
.prose h4 { font-size: 1.05em; margin: 1.4em 0 .4em; }
.prose h2:first-child, .prose hr + h2 { border-top: 0; padding-top: 0; }
.anchor { opacity: 0; margin-left: 6px; text-decoration: none; color: var(--muted); font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose li + li { margin-top: .3em; }
.prose li > ul, .prose li > ol { margin: .3em 0 0; }
.prose hr { border: 0; border-top: 2px dashed var(--border); margin: 2.4em 0; }
.prose strong { font-weight: 700; }
.prose :not(pre) > code {
  font-family: var(--mono); font-size: .86em; background: var(--inline-code-bg); color: var(--inline-code-text);
  padding: .12em .38em; border-radius: 6px; overflow-wrap: anywhere;
}
.prose a code { color: inherit; }

/* Bảng: cuộn ngang trong khung riêng, trang không bị cuộn ngang */
.table-wrap { overflow-x: auto; margin: 0 0 1.3em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: .9em; line-height: 1.5; }
.table-wrap th, .table-wrap td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table-wrap th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td { min-width: 7em; }

/* Khối code (đã tô màu lúc build bằng highlight.js) */
.code { margin: 0 0 1.3em; border-radius: var(--radius); background: var(--code-bg); overflow: hidden; border: 1px solid #0003; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 16px; background: #ffffff10; border-bottom: 1px solid #ffffff14; }
.code-lang { font-family: var(--mono); font-size: 12.5px; color: #b9c3dc; text-transform: lowercase; }
.copy-btn { font: inherit; font-size: 13px; font-weight: 700; color: #e8edf8; background: #ffffff18; border: 1px solid #ffffff30; border-radius: 8px; padding: 4px 10px; cursor: pointer; }
.copy-btn:hover { background: #ffffff2a; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 14.5px; line-height: 1.6; }
/* ⚠️ Bẫy: cỡ chữ đặt ở <pre> chứ không chỉ ở <code> — nếu không, dòng của <pre> vẫn cao theo chữ 18px của body. */
.code code { font: inherit; color: var(--code-text); tab-size: 2; }
@media (max-width: 640px) { .code pre { font-size: 13.5px; } }
.hljs-keyword, .hljs-built_in, .hljs-literal, .hljs-selector-tag, .hljs-meta .hljs-keyword { color: var(--hl-kw); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-template-tag { color: var(--hl-str); }
.hljs-number, .hljs-symbol, .hljs-bullet { color: var(--hl-num); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--hl-com); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-name { color: var(--hl-fn); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-selector-class, .hljs-selector-id, .hljs-tag { color: var(--hl-attr); }
.hljs-variable, .hljs-params, .hljs-template-variable { color: var(--hl-var); }
.hljs-deletion { color: #ff9a8f; }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }

/* Sơ đồ Mermaid: chữ nguồn có sẵn trong HTML; JS vẽ thành SVG */
.diagram { margin: 0 0 1.4em; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
pre.mermaid { margin: 0; font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--muted); white-space: pre; text-align: center; }
pre.mermaid:not([data-processed]) { text-align: left; }
pre.mermaid[data-processed] { font-family: var(--font); white-space: normal; }
pre.mermaid svg { height: auto; }
/* Màn rộng: co sơ đồ cho vừa khung. Màn hẹp: giữ cỡ thật (JS đặt width), khung .diagram cuộn ngang để chữ còn đọc được. */
@media (min-width: 901px) { pre.mermaid svg { max-width: 100% !important; } }

/* Callout: khối trích dẫn bắt đầu bằng 💡 ⚠️ 🧪 ✋ */
.callout { margin: 0 0 1.3em; padding: 12px 18px; border-radius: var(--radius); border: 1px solid; border-left-width: 6px; background: var(--note-bg); border-color: var(--note); }
.callout > :last-child { margin-bottom: 0; }
.callout-tip { background: var(--tip-bg); border-color: var(--tip); }
.callout-warn { background: var(--warn-bg); border-color: var(--warn); }
.callout-try { background: var(--try-bg); border-color: var(--try); }
.callout-stop { background: var(--stop-bg); border-color: var(--stop); }
.callout-ok { background: var(--tip-bg); border-color: var(--tip); }
.callout .code { margin-top: .6em; }

/* <details> gợi ý trong bài tập */
details.hint { margin: 0 0 1.3em; border: 2px dashed var(--tip); background: var(--tip-bg); border-radius: var(--radius); padding: 0 18px; }
details.hint > summary { cursor: pointer; font-weight: 700; padding: 10px 0; color: var(--tip); list-style-position: inside; }
details.hint[open] { padding-bottom: 6px; }
details.hint[open] > summary { border-bottom: 1px dashed var(--tip); margin-bottom: 10px; }

/* Cuối trang */
.doc-foot { margin-top: 32px; }
.solution-cta { margin-top: 8px; }
.solution-cta p:last-child { margin: 10px 0 0; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px 0 18px; }
.pn { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.pn:hover { border-color: var(--accent); }
.pn-next { text-align: right; }
.pn-dir { font-size: 14px; color: var(--muted); font-weight: 700; }
.pn-title { font-weight: 700; color: var(--link); }
@media (max-width: 640px) { .prevnext { grid-template-columns: 1fr; } .pn-next { text-align: left; } }
.sol-list { padding-left: 0; list-style: none; }
.sol-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }

/* ---------- 9. Landing page ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 820px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
.band { padding: 64px 0; }
.band-alt { background: var(--bg-alt); }
.band h2 { font-size: clamp(28px, 3.6vw, 38px); line-height: 1.2; margin: 0 0 10px; }
.section-lead { color: var(--muted); max-width: 760px; margin: 0 0 28px; }

.hero {
  background:
    radial-gradient(circle at 12% 18%, var(--deco-1) 0 120px, transparent 121px),
    radial-gradient(circle at 92% 85%, var(--deco-2) 0 160px, transparent 161px),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-alt) 100%);
  border-bottom: 1px solid var(--border);
}
.hero-in { max-width: 1180px; margin: 0 auto; padding: 48px 24px 64px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 48px; align-items: center; }
.eyebrow { display: inline-block; margin: 0 0 12px; font-weight: 700; font-size: 15px; color: var(--accent-strong); background: var(--accent-soft); padding: 4px 12px; border-radius: 99px; }
.hero h1 { font-size: clamp(38px, 6vw, 64px); line-height: 1.08; margin: 0 0 18px; letter-spacing: -.02em; }
.lead { font-size: 1.12em; color: var(--text); margin: 0 0 26px; max-width: 620px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.hero-sub { margin: 0; font-size: 16px; }
.hero-art { margin: 0; transform: rotate(1.5deg); }
.hero-art img { display: block; width: 100%; border-radius: 20px; border: 6px solid #fff; box-shadow: 0 14px 0 #e0b67a, 0 30px 60px -30px #6b4a1a; background: #8adcf4; }
.hero-art figcaption { text-align: center; font-size: 15px; color: var(--muted); margin-top: 22px; transform: rotate(-1.5deg); }
.progress-box { margin-top: 22px; padding: 12px 16px; background: var(--surface); border: 2px solid var(--tip); border-radius: var(--radius); max-width: 520px; }
.progress-box p { margin: 0 0 6px; }
.progress-box progress { width: 100%; height: 12px; accent-color: var(--tip); }
@media (max-width: 900px) {
  .hero-in { grid-template-columns: minmax(0, 1fr); padding: 28px 16px 44px; gap: 32px; }
  .hero-art { transform: none; max-width: 560px; }
  .hero-art figcaption { transform: none; }
  .band { padding: 44px 0; }
}

.stats { padding: 0; background: var(--ink); color: #fff; }
.stat-list { list-style: none; margin: 0 auto; padding: 22px 24px; max-width: 1180px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; text-align: center; }
.stat-list b { display: block; font-size: 30px; line-height: 1.2; color: var(--gold); }
.stat-list span { font-size: 15px; color: #d7def0; }
@media (max-width: 640px) { .stat-list { grid-template-columns: repeat(2, 1fr); padding: 18px 16px; } .stat-list b { font-size: 24px; } }

.learn-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.learn-grid a { display: flex; gap: 12px; align-items: flex-start; height: 100%; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); text-decoration: none; font-size: 16px; line-height: 1.5; }
.learn-grid a:hover { border-color: var(--accent); }
.learn-grid code { font-family: var(--mono); font-size: .88em; background: var(--inline-code-bg); color: var(--inline-code-text); padding: .1em .35em; border-radius: 5px; }
.lc-num { font-family: var(--mono); font-weight: 800; font-size: 18px; color: #fff; background: var(--accent); border-radius: 10px; min-width: 42px; height: 34px; display: inline-grid; place-items: center; flex: none; }
:root[data-theme="dark"] .lc-num { color: #1a0f08; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lc-num { color: #1a0f08; } }
.lc-num.sm { font-size: 14px; min-width: 34px; height: 26px; border-radius: 8px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
.two-col h3 { margin: 1.2em 0 .4em; font-size: 1.2em; }
.two-col h3:first-child { margin-top: 0; }
@media (max-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr); gap: 16px; } }
.band code { font-family: var(--mono); font-size: .88em; }

.lesson-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 18px; }
.lesson-card > a {
  position: relative; display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 18px 18px 16px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; transition: transform .12s ease, border-color .12s ease;
}
.lesson-card > a:hover { transform: translateY(-3px); border-color: var(--accent); }
.lc-top { display: flex; justify-content: space-between; align-items: center; }
.lc-check { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; border: 2px dashed var(--border); color: transparent; }
.lesson-card.is-done .lc-check { background: var(--tip); border: 2px solid var(--tip); color: #fff; }
.lesson-card.is-done > a { border-color: var(--tip); }
.lc-title { font-weight: 800; font-size: 1.05em; line-height: 1.35; }
.lc-desc { color: var(--muted); font-size: 15.5px; line-height: 1.55; flex: 1; }
.lc-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; color: var(--muted); }

.route-more { margin-top: 40px; }
.route-more h3 { font-size: 1.25em; margin: 0 0 14px; }
.tracks { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.track { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.track h3 { margin: 0; font-size: 1.05em; }
.track .muted { margin: 0 0 8px; font-size: 15px; }
.chain { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); }
.chain a { font-family: var(--mono); font-weight: 700; font-size: 15px; padding: 2px 9px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; }
.chain a:hover { background: var(--accent); color: #fff; }
.route-diagram { background: var(--surface); }
.route-diagram .diagram { border: 0; padding: 0; background: transparent; }

.doc-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 18px; }
.doc-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border: 2px solid var(--border); border-radius: 18px; color: var(--text); text-decoration: none; box-shadow: var(--shadow); height: auto; }
.doc-card:hover { border-color: var(--blue); }
.doc-card b { font-size: 1.08em; color: var(--link); }
.doc-card span:last-child { color: var(--muted); font-size: 15.5px; line-height: 1.55; }
.dc-ico { font-size: 30px; line-height: 1; }
.doc-sub { list-style: none; margin: 10px 0 0; padding: 0 0 0 6px; font-size: 15px; line-height: 1.5; }
.doc-sub li { padding: 3px 0; }

.faq { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 12px; padding: 0 20px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; }
.faq p { margin: 0 0 16px; color: var(--muted); }
.cta-end { text-align: center; margin-top: 36px; }

/* ---------- 10. Chân trang ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-alt); font-size: 15.5px; line-height: 1.6; }
.footer-in { max-width: 1180px; margin: 0 auto; padding: 28px 24px 36px; }
.footer-in p { margin: 0 0 8px; }
@media (max-width: 640px) { .footer-in { padding: 24px 16px 32px; } }

@media print {
  .topbar, .sidebar, .toc, .doc-actions, .prevnext, .copy-btn, .site-footer { display: none !important; }
  .page, .doc { display: block; }
}

/* Nút "Đã học xong" giữ màu xanh lá ở mọi theme (ghi đè luật chữ tối cho nút ở chế độ tối). */
.btn.btn-done[aria-pressed="true"] { color: var(--tip) !important; }
