:root {
  --bg: #fbf8f1;
  --bg-alt: #f3ecdf;
  --card: #ffffff;
  --text: #1d231e;
  --muted: #66706a;
  --border: #e5dccd;
  --primary: #245c43;
  --primary-2: #b44735;
  --grad: linear-gradient(90deg, #245c43, #2f7254 56%, #b44735);
  --shadow: 0 1px 2px rgba(36, 92, 67, .06), 0 6px 18px rgba(36, 92, 67, .08);
  --radius: 8px;
}
:root[data-theme="dark"] {
  --bg: #101611;
  --bg-alt: #172019;
  --card: #1b241d;
  --text: #f2eee5;
  --muted: #b1aa9c;
  --border: #334136;
  --shadow: 0 6px 18px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .3s, color .3s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
.container { width: min(1140px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); font-size: .875rem; }
.center { text-align: center; margin-top: 32px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 5px 14px rgba(36, 92, 67, .22); }
.btn-ghost { background: var(--card); border-color: var(--border); }
.btn-youtube { background: var(--primary-2); color: #fff; padding: 8px 14px; font-size: .875rem; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; font-size: 1rem;
}
.menu-btn { display: none; }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-top { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand img { width: 34px; height: 34px; border-radius: 50%; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav { flex: 1; min-width: 0; }
.nav-inner { display: flex; justify-content: center; gap: 18px; align-items: center; overflow-x: auto; font-size: .86rem; color: var(--muted); }
.nav-inner { scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav-inner a { white-space: nowrap; transition: color .2s; }
.nav-inner a:hover { color: var(--primary); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 68px 0 56px; text-align: center; }
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(520px 320px at 18% 18%, rgba(36, 92, 67, .14), transparent 70%),
    radial-gradient(520px 320px at 84% 38%, rgba(180, 71, 53, .12), transparent 70%),
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 48px 48px;
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
  opacity: .9;
}
.pill {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  font-size: .75rem; font-weight: 600; color: var(--muted);
  /* Câu dài xuống dòng trên điện thoại thì chia đều hai dòng, không để một chữ lẻ ở dòng dưới. */
  text-wrap: balance;
}
.hero h1 { font-size: clamp(2.05rem, 5vw, 3.4rem); font-weight: 800; margin: 18px 0 14px; }
.gradient-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { max-width: 640px; margin: 0 auto 26px; color: var(--muted); font-size: 1.05rem; }
.hero-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 720px; margin: auto; }

/* ---------- Sections ---------- */
.section { padding: 56px 0; }
.section.alt { background: var(--bg-alt); }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 30px; }
.section-head h2 { font-size: clamp(1.55rem, 3.2vw, 2.15rem); font-weight: 800; }
.section-head p { color: var(--muted); margin: 0; }
.search {
  margin-top: 24px; width: 100%; max-width: 420px; padding: 12px 18px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit;
}
.search:focus, .contact input:focus, .contact textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.empty { text-align: center; color: var(--muted); }

/* ---------- Grid & Card ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.narrow { max-width: 860px; margin: auto; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); transition: transform .2s, border-color .2s;
}
a.card:hover, .video:hover, .course:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }

/* About */
.about { display: flex; gap: 24px; align-items: flex-start; padding: 28px; }
.about-avatar { width: 96px; height: 96px; border-radius: 50%; flex-shrink: 0; }
.about h2 { font-size: 1.8rem; margin-bottom: 4px; }
.about-role { margin: 0 0 14px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.about p { color: var(--muted); }
.story-head { margin: 22px 0 12px; font-size: 1rem; }
.story { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 12px; position: relative; }
.story::before { content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 2px; background: var(--grad); opacity: .35; }
.story li { display: flex; gap: 14px; align-items: center; position: relative; }
.story-icon { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); font-size: 1rem; }
.story strong { display: block; font-size: .95rem; }
.story small { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.chip { padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .875rem; font-weight: 500; transition: border-color .2s; }
.chip:hover { border-color: var(--primary); }

/* Tool */
.tool { display: flex; align-items: center; gap: 14px; padding: 16px; }
.tool[hidden] { display: none; }
.tool-icon { width: 42px; height: 42px; border-radius: var(--radius); display: grid; place-items: center; background: var(--bg-alt); font-size: 1.35rem; flex-shrink: 0; }
.tool-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tool-text small { color: var(--muted); }
.arrow { color: var(--muted); }

/* Video */
.video { padding: 0; overflow: hidden; }
.video h3 { font-size: 1rem; padding: 16px 18px 20px; margin: 0; }
.thumb { position: relative; width: 100%; aspect-ratio: 16/9; border: 0; padding: 0; cursor: pointer; background: #000; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.play {
  position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center; background: color-mix(in srgb, var(--primary-2) 92%, transparent); color: #fff; font-size: 1.2rem; transition: transform .2s;
}
.thumb:hover .play { transform: scale(1.1); }

/* Course */
.level { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); padding: 4px 10px; border-radius: 999px; margin-bottom: 14px; }
.course h3, .post h3 { font-size: 1.1rem; }
.course p, .post p { color: var(--muted); font-size: .92rem; }

/* Community */
.community { text-align: center; padding: 40px 28px; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 12%, var(--card)), color-mix(in srgb, var(--primary-2) 10%, var(--card))); }
.community h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.community p { color: var(--muted); max-width: 560px; margin: 0 auto 24px; }

/* Donate */
/* Chỉ có chuyển khoản (hoặc chỉ PayPal): một thẻ thì nằm giữa, không lệch trái chừa nửa trống. */
#ung-ho .grid-2 > .card:only-child { grid-column: 1 / -1; justify-self: center; width: min(100%, 460px); }
.bank { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 16px 0 0; }
.donate-qr { margin: 16px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
/* Nền trắng cố định cả ở giao diện tối: app ngân hàng quét mã đen trên nền trắng tốt nhất. */
.donate-qr img { width: 200px; height: 200px; padding: 8px; border-radius: var(--radius); background: #fff; border: 1px solid var(--border); }
.donate-qr figcaption { color: var(--muted); font-size: .85rem; max-width: 300px; }
.donate-qr .copy { margin: 0; text-decoration: none; }
.bank dt { color: var(--muted); }
.bank dd { margin: 0; font-weight: 600; }
.copy { margin-left: 6px; font: inherit; font-size: .75rem; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-alt); color: var(--text); cursor: pointer; }

/* Contact */
.contact { max-width: 620px; margin: auto; display: flex; flex-direction: column; gap: 14px; }
.contact input, .contact textarea { font: inherit; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); color: var(--text); resize: vertical; }
.contact .btn { align-self: flex-start; }
.contact a { color: var(--primary); }

/* Footer & floating */
.footer { padding: 40px 0 88px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border); background: var(--bg-alt); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.footer-about p { max-width: 380px; margin: 12px 0 0; }
.footer h4 { color: var(--text); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; margin: 6px 0 12px; }
.footer-grid > div:not(.footer-about) { display: flex; flex-direction: column; gap: 8px; }
.footer-grid a:hover { color: var(--primary); }
.footer .brand { color: var(--text); }
.footer-bottom { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--border); font-size: .82rem; text-align: center; }
.float-btn {
  border: 0; font-family: inherit; cursor: pointer;
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  padding: 11px 16px; border-radius: var(--radius); font-weight: 600; font-size: .9rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 18px rgba(180, 71, 53, .24);
  transition: transform .2s;
}
.float-btn:hover { transform: translateY(-3px); }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: .72rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

/* ---------- Detail pages ---------- */
.page { padding: 28px 0 64px; min-height: 60vh; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 28px; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--text); }
.narrow-text { max-width: 640px; }
.not-found { text-align: center; padding: 64px 0; }
.lead-sm { color: var(--muted); font-size: 1.1rem; }

.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 48px; align-items: start; }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.article { min-width: 0; max-width: 760px; }
.article h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); font-weight: 800; }
.article-head { padding-bottom: 24px; margin-bottom: 32px; border-bottom: 1px solid var(--border); }
.author { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.author img { width: 44px; height: 44px; border-radius: 50%; }
.author div { display: flex; flex-direction: column; line-height: 1.4; }

/* Nội dung Markdown */
.prose { font-size: 1.05rem; line-height: 1.8; }
.prose h2 { font-size: 1.5rem; margin: 2em 0 .6em; }
.prose h3 { font-size: 1.2rem; margin: 1.6em 0 .5em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose li { margin-bottom: .35em; }
.prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.prose img { border-radius: var(--radius); margin: 1.5em auto; }
.prose blockquote { margin: 1.5em 0; padding: 12px 20px; border-left: 4px solid var(--primary); background: var(--bg-alt); border-radius: 0 var(--radius) var(--radius) 0; color: var(--muted); }
.prose blockquote p:last-child { margin: 0; }
.prose code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--bg-alt); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.prose pre { background: #15151f; color: #e8e8f0; padding: 18px; border-radius: var(--radius); overflow-x: auto; margin: 0 0 1.4em; }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.4em; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.prose th { background: var(--bg-alt); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

/* Mục lục */
.toc { position: sticky; top: 130px; font-size: .88rem; border-left: 1px solid var(--border); padding-left: 18px; }
.toc ul { list-style: none; padding: 0; margin: 12px 0 0; }
.toc li { margin-bottom: 8px; }
.toc li.lv3 { padding-left: 14px; }
.toc a { color: var(--muted); transition: color .2s; }
.toc a:hover, .toc a.active { color: var(--primary); }
.toc a.active { font-weight: 600; }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 40px 0 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.share button { font: inherit; background: none; color: var(--text); cursor: pointer; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.pager .card { display: flex; flex-direction: column; gap: 4px; padding: 18px; }
.pager .next { text-align: right; }

/* Khóa học */
.course-overview { max-width: 900px; }
.course-overview h2 { font-size: 1.4rem; margin: 48px 0 16px; }
.course-hero { padding: 28px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.course-hero h1 { font-size: clamp(1.8rem, 4.5vw, 2.4rem); font-weight: 800; margin: 0; }
.course-hero .lead-sm, .course-hero p { margin: 0; }
.course-hero .progress { width: 100%; max-width: 420px; margin-top: 8px; }
.course-hero .btn { margin-top: 12px; }
.progress { height: 8px; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--border); overflow: hidden; margin-bottom: 6px; }
.progress-bar { height: 100%; background: var(--grad); transition: width .4s; }
.lesson-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.lesson-list a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); transition: border-color .2s; }
.lesson-list a:hover { border-color: var(--primary); }
.lesson-list a.current { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--card)); }
.lesson-list .num { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--bg-alt); }
.lesson-list a.done .num { background: #16a34a; color: #fff; }
.lesson-title { flex: 1; font-weight: 500; }
.sidebar { position: sticky; top: 130px; padding: 20px; max-height: calc(100vh - 150px); overflow-y: auto; }
.sidebar-title { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-bottom: 14px; }
.sidebar-title .level { margin: 0; }
.sidebar .lesson-list { margin-top: 16px; }
.sidebar .lesson-list a { font-size: .9rem; padding: 10px 12px; }
.video-embed { aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; margin: 8px 0 32px; background: #000; }
.video-embed iframe { width: 100%; height: 100%; border: 0; }
.lesson-actions { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
#markDone.is-done { background: #16a34a; border-color: #16a34a; color: #fff; }

/* Nút sao chép code */
.prose pre.has-copy { position: relative; padding-top: 40px; }
.copy-code {
  position: absolute; top: 8px; right: 8px; font: inherit; font-size: .75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 8px; border: 1px solid #3a3a4c; background: #24243a; color: #e8e8f0; cursor: pointer;
}
.copy-code:hover { background: #2f2f4a; }

/* Khối chia sẻ cuối bài */
.share-cta { margin-top: 32px; padding: 24px; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--card)), color-mix(in srgb, var(--primary-2) 8%, var(--card))); }
.share-cta h3 { font-size: 1.15rem; }
.share-cta p { color: var(--muted); margin: 0; }
.share-cta .chips { margin-top: 16px; }
.chips button.chip { font: inherit; font-size: .875rem; background: var(--card); color: var(--text); cursor: pointer; }
a.tag:hover { text-decoration: underline; }

/* Trang tất cả bài viết */
.page-title { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; }
.filter-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 32px; }
.filter-tags .chip { font: inherit; font-size: .875rem; background: var(--card); color: var(--text); cursor: pointer; }
.filter-tags .chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Học online */
.live-perks .card h3 { font-size: 1.05rem; margin-top: 14px; }
.live-perks .card p { color: var(--muted); font-size: .92rem; margin: 0; }
.live-head { text-align: center; margin: 48px 0 20px; }
.live-list { display: flex; flex-direction: column; gap: 14px; max-width: 860px; margin: auto; }
.live-item { display: flex; align-items: center; gap: 20px; padding: 20px; }
.live-date { width: 64px; flex-shrink: 0; text-align: center; border-radius: var(--radius); padding: 8px 0; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; line-height: 1.1; }
.live-date strong { display: block; font-size: 1.6rem; }
.live-date span { font-size: .8rem; }
.live-info { flex: 1; min-width: 0; }
.live-info h3 { font-size: 1.1rem; margin-bottom: 4px; }
.live-info p { color: var(--muted); margin: 0 0 4px; font-size: .92rem; }
.live-empty { max-width: 640px; margin: 32px auto 0; text-align: center; padding: 28px 24px; }
.live-empty p { color: var(--muted); margin: 0 auto 20px; }

/* Trang đăng ký */
.signup { max-width: 820px; }
.steps { list-style: none; padding: 0; margin: 0 0 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; font-size: .9rem; color: var(--muted); }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--bg-alt); border: 1px solid var(--border); color: var(--text); }
.steps li.done { color: var(--text); }
.steps li.done span { background: #16a34a; border-color: #16a34a; color: #fff; }
.gate { margin-bottom: 24px; border-color: color-mix(in srgb, #f59e0b 50%, var(--border)); }
.gate.gate-ok { border-color: color-mix(in srgb, #16a34a 50%, var(--border)); }
.gate h2, .signup-form h2, .signup-done h2 { font-size: 1.25rem; }
.gate p { color: var(--muted); }
.gate-list { padding-left: 0; list-style: none; margin: 0 0 18px; display: flex; flex-direction: column; gap: 6px; }
.gate-list a { color: var(--primary); }
.signup-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.signup-form h2 { margin: 12px 0 0; }
.signup-form.locked { opacity: .45; pointer-events: none; user-select: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.signup-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .95rem; }
.signup-form input, .signup-form select, .signup-form textarea {
  font: inherit; font-weight: 400; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.signup-form textarea { resize: vertical; }
.signup-form input:focus, .signup-form select:focus, .signup-form textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.signup-form label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; cursor: pointer; }
.signup-form label.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); flex-shrink: 0; }
.commit-list { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--bg-alt); }
.pledge { color: var(--primary); }
.counter { color: var(--muted); font-weight: 400; }
.counter.ok { color: #16a34a; }
.hp { position: absolute; left: -9999px; }
.form-error { margin: 0; padding: 12px 14px; border-radius: var(--radius); background: color-mix(in srgb, #dc2626 12%, var(--card)); color: #dc2626; font-weight: 500; }
.btn-lg { padding: 14px 28px; font-size: 1rem; align-self: flex-start; }
.signup-done { text-align: center; padding: 40px 28px; }
.signup-done p { color: var(--muted); }

/* Băng "bản nháp" khi người quản trị xem trước bài / khóa chưa đăng */
.draft-bar { margin-bottom: 20px; padding: 12px 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--primary-2) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--primary-2) 36%, var(--border)); font-size: .9rem; }
.draft-bar a { color: var(--primary); font-weight: 600; margin-left: 6px; }

/* Lỗi máy chủ trả về, hiện ngay dưới ô nhập ở trang đăng ký */
.field-error { color: #dc2626; font-weight: 500; }

/* Thẻ liên hệ cuối trang chủ */
.contact-card { max-width: 640px; margin: auto; text-align: center; padding: 32px 24px; }
.contact-card p { color: var(--muted); }
.filter-tags a.chip { background: var(--card); }
.filter-tags a.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Ảnh tải lên qua /cms */
.post-cover { display: block; width: calc(100% + 40px); max-width: none; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; margin: -20px -20px 16px; border-radius: var(--radius) var(--radius) 0 0; }
.article-cover { width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: var(--radius); margin: 0 0 28px; }
.brand img, .about-avatar, .author img { object-fit: cover; }

/* Tiêu chí lớp online: dành cho ai / không dành cho ai / học xong đạt gì */
.grid-1 { grid-template-columns: 1fr; }
.live-criteria { margin: 24px 0; }
.live-criteria h3 { font-size: 1.05rem; }
.live-criteria ul { margin: 0; padding-left: 20px; color: var(--muted); }
.live-criteria li { margin-bottom: 6px; }
.criteria-yes { border-top: 3px solid #16a34a; }
.criteria-no { border-top: 3px solid #dc2626; }
.criteria-goal { border-top: 3px solid var(--primary); }
.session-table { margin-bottom: 24px; }
.session-table h2 { font-size: 1.15rem; }
.session-table ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.seat { display: inline-block; margin-left: 6px; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, #16a34a 14%, transparent); color: #16a34a; }
.seat-low { background: color-mix(in srgb, var(--primary-2) 14%, transparent); color: var(--primary-2); }
.seat-full { background: color-mix(in srgb, #dc2626 14%, transparent); color: #dc2626; }

/* Trang này dành cho ai, việc thật, cảm nhận */
.audience h3, .case h3 { font-size: 1.05rem; margin-top: 12px; }
.audience p, .case p { color: var(--muted); font-size: .93rem; }
.audience-link { color: var(--primary); font-weight: 600; font-size: .9rem; }
.case-result { display: inline-block; font-size: .8rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--grad); color: #fff; }
.testimonial { margin: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.testimonial blockquote { margin: 0; font-size: .98rem; line-height: 1.7; }
.testimonial figcaption { color: var(--muted); font-size: .88rem; }
.testimonial figcaption strong { color: var(--text); }

/* Khung bài học: kết quả cần đạt, bài tập, bước tiếp theo */
.lesson-box { border-radius: var(--radius); padding: 18px 22px; margin: 8px 0 28px; border: 1px solid var(--border); }
.lesson-box > strong { display: block; margin-bottom: 8px; }
.lesson-box ul { margin: 0; padding-left: 20px; }
.lesson-box li { margin-bottom: 4px; }
.lesson-outcomes { background: color-mix(in srgb, var(--primary) 8%, var(--card)); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.lesson-exercise { margin-top: 32px; background: color-mix(in srgb, var(--primary-2) 8%, var(--card)); border-color: color-mix(in srgb, var(--primary-2) 28%, var(--border)); }
.lesson-exercise .prose { font-size: 1rem; }
.lesson-exercise .prose > :last-child { margin-bottom: 0; }
.lesson-next { margin: 20px 0 0; color: var(--muted); }

/* Trang học viên */
.btn-learner { padding: 8px 14px; font-size: .875rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.learner-auth { max-width: 560px; }
.learner-auth .card { padding: 32px; }
.learner-auth .page-title { font-size: clamp(1.6rem, 4vw, 2.1rem); }
.learner-auth ul { padding-left: 20px; }
.learner-auth-foot { margin: 20px 0 0; }
.learner-auth-foot a, .learner-delete a { color: var(--primary); }
.form-note { padding: 12px 14px; border-radius: var(--radius); background: color-mix(in srgb, var(--primary) 10%, var(--card)); }
.learner-home { max-width: 960px; }
.learner-home > h2 { font-size: 1.35rem; margin: 36px 0 14px; }
.learner-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; }
.learner-head .page-title { margin-bottom: 4px; }
.learner-sessions { margin: 0; max-width: none; }
.live-item.is-past { opacity: .6; }
.learner-empty p { margin: 0; }
.learner-course { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.learner-course .level { margin: 0; }
.learner-course h3 { font-size: 1.1rem; margin: 0; }
.learner-course .progress { width: 100%; margin: 4px 0 0; }
.learner-course .btn { margin-top: 6px; }
.learner-done { display: inline-block; margin-top: 6px; color: #16a34a; font-weight: 600; }
.learner-delete { margin-top: 48px; padding: 18px 24px; box-shadow: none; }
.learner-delete summary { cursor: pointer; color: var(--muted); font-size: .92rem; }
.learner-delete[open] summary { margin-bottom: 12px; }

/* Reveal animation */
/* Chỉ ẩn để hiện dần khi có JS (lớp "js" do đoạn script trong <head> gắn) — tắt JS thì nội dung vẫn hiện. */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .menu-btn { display: inline-block; }
  .nav { display: none; position: absolute; left: 16px; right: 16px; top: calc(100% + 1px); padding: 10px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
  .nav.open { display: block; }
  .nav-inner { flex-direction: column; align-items: flex-start; gap: 12px; padding: 4px 14px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .live-criteria.grid-3 { grid-template-columns: 1fr; }
  .article-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .lesson-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .btn-youtube { display: none; }
  .btn-learner { max-width: 120px; padding: 7px 10px; }
  .learner-auth .card { padding: 24px; }
  .brand { font-size: .95rem; }
  .brand img { width: 30px; height: 30px; }
  .header-top { min-height: 58px; gap: 10px; }
  .about { flex-direction: column; padding: 24px; }
  .hero { padding: 48px 0 44px; }
  .section { padding: 44px 0; }
  .float-btn { font-size: .8rem; padding: 10px 14px; }
  .pager { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .btn-lg { align-self: stretch; justify-content: center; }
  .live-item { flex-wrap: wrap; }
  .live-item .btn { width: 100%; justify-content: center; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
  .course-hero { padding: 24px; }
}

/* ---------- AI Templates ---------- */
/* Trang xếp theo việc cần làm: câu hỏi + ô tìm → 8 ô nhóm việc → mẫu chọn sẵn → danh sách dạng hàng. */
.tpl-intro { max-width: 860px; margin: 8px auto 28px; text-align: center; }
.tpl-eyebrow { margin: 0 0 10px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.tpl-intro h1 { font-size: clamp(2rem, 5.5vw, 3.2rem); font-weight: 800; margin: 0 0 12px; }
.tpl-intro .lead-sm { margin: 0 auto 22px; max-width: 620px; }
.tpl-intro .lead-sm strong { color: var(--text); }
.tpl-search { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 18px; border: 2px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); cursor: text; }
.tpl-search:focus-within { border-color: var(--primary); }
.tpl-search input { flex: 1; min-width: 0; padding: 12px 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 1.05rem; outline: none; }
.tpl-howto { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; margin: 18px 0 0; padding: 0; font-size: .88rem; color: var(--muted); }
.tpl-howto li { display: flex; align-items: center; gap: 8px; }
.tpl-howto span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; font-size: .75rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); }

.tpl-groups { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 36px; }
.tpl-group { display: flex; align-items: center; gap: 12px; padding: 14px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer; transition: border-color .2s, background .2s; }
.tpl-group:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.tpl-group.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--card)); box-shadow: 0 0 0 1px var(--primary) inset; }
.tpl-group:disabled { opacity: .45; cursor: default; }
.tpl-group:focus-visible, .tpl-row:focus-visible, .tpl-starter:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tpl-group-icon { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--radius); font-size: 1.3rem; background: var(--bg-alt); }
.tpl-group-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.tpl-group-text strong { font-size: .95rem; }
.tpl-group-text small { color: var(--muted); font-size: .78rem; }
.tpl-group-count { align-self: flex-start; font-size: .75rem; font-weight: 600; color: var(--muted); }

.tpl-starters { margin-bottom: 40px; }
.tpl-starters h2, .tpl-results-head h2 { font-size: 1.35rem; margin: 0 0 4px; }
.tpl-starters > p { margin: 0 0 16px; }
.tpl-starter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tpl-starter { display: flex; flex-direction: column; gap: 8px; padding: 16px; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.tpl-starter:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.tpl-starter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .8rem; }
.tpl-starter-top code { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; font-weight: 700; color: var(--primary); }
.tpl-starter-use { font-size: .92rem; }

.tpl-results { scroll-margin-top: 84px; }
.tpl-results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tpl-reset { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.tpl-reset:hover { border-color: var(--primary); color: var(--primary); }
.tpl-filters { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.tpl-types { display: flex; flex-wrap: wrap; gap: 8px; }
.tpl-types .chip { font: inherit; font-size: .85rem; padding: 6px 12px; background: var(--card); color: var(--text); cursor: pointer; }
.tpl-types .chip small { color: var(--muted); font-size: .75rem; margin-left: 2px; }
.tpl-types .chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tpl-types .chip.active small { color: rgba(255, 255, 255, .8); }
.tpl-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tpl-filter-row .seg { margin-left: auto; }
.select { padding: 9px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; max-width: 100%; }
.select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.tpl-typehelp summary { cursor: pointer; color: var(--primary); font-size: .88rem; width: fit-content; }
.tpl-typehelp dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 20px; margin: 12px 0 0; padding: 16px; border-radius: var(--radius); background: var(--bg-alt); font-size: .86rem; }
.tpl-typehelp dt { font-weight: 600; }
.tpl-typehelp dt .muted { font-size: .75rem; font-weight: 400; }
.tpl-typehelp dd { margin: 2px 0 0; color: var(--muted); }
.tpl-count { margin: 14px 0 8px; }

.tpl-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.tpl-list > .muted, .tpl-list > .empty { padding: 32px 20px; margin: 0; }
.tpl-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: start; gap: 14px; padding: 14px 18px; text-align: left;
  border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; cursor: pointer; }
.tpl-row:last-child { border-bottom: 0; }
.tpl-row:hover { background: color-mix(in srgb, var(--primary) 5%, var(--card)); }
.tpl-row-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius); background: var(--bg-alt); font-size: 1.05rem; }
.tpl-row-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tpl-row-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.tpl-row-name strong { font-family: ui-monospace, Consolas, monospace; font-size: .93rem; word-break: break-word; }
.tpl-row-name .muted { font-size: .78rem; }
.tpl-row-desc { color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-row-dl { font-size: .8rem; white-space: nowrap; padding-top: 2px; }
.tpl-list .link, .empty .link { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.tpl-results .center { margin-top: 20px; }
.tpl-credit { margin-top: 40px; }
.tpl-credit a { color: var(--primary); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(10, 10, 20, .45); backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 100; width: min(640px, 100%); background: var(--bg);
  border-left: 1px solid var(--border); box-shadow: -12px 0 40px rgba(0, 0, 0, .18); transform: translateX(100%); transition: transform .25s ease; overflow-y: auto; }
.drawer.open { transform: none; }
.drawer-close { position: sticky; top: 16px; float: right; margin: 16px 16px 0 0; z-index: 1; }
.drawer-body { padding: 28px; }
.drawer-body h3 { margin-top: 28px; font-size: 1.05rem; }
.drawer-crumb { margin: 0 0 18px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.drawer-title { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.drawer-title h2 { margin: 0; font-size: 1.5rem; word-break: break-word; }
.drawer-icon { width: 48px; height: 48px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--radius); font-size: 1.4rem; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.cmd { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: #15151f; color: #e8e8f0; }
.cmd code { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: .82rem; overflow-x: auto; white-space: nowrap; }
.drawer-preview { max-height: 520px; overflow: auto; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); font-size: .92rem; }
.drawer-preview h1 { font-size: 1.4rem; }
.drawer-preview pre { margin: 0 0 1em; }

@media (max-width: 960px) {
  .tpl-groups, .tpl-starter-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .tpl-groups { gap: 8px; }
  .tpl-group { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; position: relative; }
  .tpl-group-icon { width: 34px; height: 34px; font-size: 1.1rem; }
  .tpl-group-text small { display: none; }
  .tpl-group-count { position: absolute; top: 12px; right: 12px; }
  .tpl-starter-grid { grid-template-columns: 1fr; }
  .tpl-row { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 12px 14px; }
  .tpl-row-icon { width: 30px; height: 30px; }
  .tpl-row-dl { grid-column: 2; padding: 0; }
  .tpl-filter-row .seg { margin-left: 0; }
  .tpl-types { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .tpl-types .chip { white-space: nowrap; }
}
@media (max-width: 860px) {
  .drawer-body { padding: 20px 16px; }
}

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.seg button { padding: 5px 12px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: inherit; font-size: .82rem; cursor: pointer; }
.seg button.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 600; }
.orig { margin: -4px 0 8px; font-size: .88rem; color: var(--muted); }
.orig summary { cursor: pointer; color: var(--primary); }
.orig p { margin: 8px 0 0; padding: 12px; border-radius: var(--radius); background: var(--bg-alt); }
.link { color: var(--primary); text-decoration: underline; }
