/* Pi Study player. Cùng một "bàn tay" với video và các template: trang vở ô li có người chấm bài.
     mực bút bi xanh #1b3a8c   chữ và nét của bài
     cam #d9480f               đang học, nhấn mạnh        dạ quang vàng: ý chính
     xanh lá                   đúng, đạt                  hồng đỏ #c2255c: sai, nhánh ôn (bút đỏ chấm bài)
     đỏ #bd2b27 của logo       chỉ dành cho logo và đường lề đỏ
   Hai kiểu chữ, hai vai:
     Be Vietnam Pro (400 · 600/700 · 800)  mọi thứ phải đọc kĩ
     Patrick Hand (--hand)                 nét viết tay: tên trang, tên chương, ghi chú ngắn, lời phê. Chỉ có độ đậm 400.
   Nét vẽ tay = nét bút thật bằng SVG vector (các biến --i-*: dấu tích, dấu gạch, vòng khoanh, ô vuông, mũi tên): đường cong
   liền một nét, đầu tròn, bề dày không đổi. Không dùng filter làm méo điểm ảnh — viền và chữ luôn sắc nét.
   Dùng có chừng mực — mỗi màn một hai nét, còn lại là giấy trống. Ít khung, ít bóng đổ.

   Mục lục file:  nền tảng · thanh trên · trang mục lục và trang bài học · trang Pi Lesson · sân khấu (box) ·
                  bìa và kết quả · lộ trình · bảng duyệt · màn hẹp · điện thoại ngang · toàn màn hình.
   Không dùng light-dark() / color-mix(): điện thoại đời cũ chưa hỗ trợ, cả trang sẽ mất màu. */
:root { color-scheme: light dark;
  --bg: #ffffff; --panel: #f4f7fd; --line: #d6dff0; --line-2: #a9b9df;
  --ink: #1b3a8c; --soft: #4a5d8f; --on-ink: #ffffff;
  --co: #d9480f; --co-ink: #c5400c; --red: #c2255c; --red-ink: #b01f52; --ok: #2b8a3e; --ok-ink: #237a35; --teal: #0b7a75; --brand: #bd2b27;
  --grid: rgba(64,110,190,.10); --night: #0e1630; --frame: transparent;
  --sb: rgba(27,58,140,.22); --sb-on: rgba(27,58,140,.36); --sb-hi: rgba(27,58,140,.58);
  /* mặt giấy của sân khấu: luôn sáng như video, kể cả khi trang ở chế độ tối */
  --paper: #fdfdfb; --p-ink: #1b3a8c; --p-soft: #4a5d8f; --p-line: #d6dff0;
  --hand: 'Patrick Hand', 'Be Vietnam Pro', cursive;
  --top-h: 52px; --foot-h: 48px; --gut: max(3vw, 16px);
  --i-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3.6 13.2c2.3 1.7 4 4 5.1 6.8C11.4 13.6 15.7 7.8 21 3.6' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --i-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 4.6c4.4 4.7 9.1 9.7 14.2 15.1M19.4 4.2C14.2 9 9.4 14.2 4.8 19.8' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --i-ring: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'%3E%3Cpath d='M22 3.6C11 2.4 3.4 9.8 3.6 20.4 3.8 30.8 12 37.4 22 36.4c9.6-1 15.4-9 14.4-18.6C35.4 8.6 27.6 3 17.4 5.2' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --i-box: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.6 4.3c5-.7 10.1-.6 15.2-.1.5 5 .6 10.1.1 15.4-5.2.6-10.3.5-15.5 0-.6-5.2-.5-10.3.2-15.3c1.2-.3 2.2-.4 3.2-.4' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --i-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 28'%3E%3Cpath d='M3 4c3 12 12 18 27 16M23 13.5l7.5 6.5-9 4.5' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --swipe-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M5 8C32 5.2 64 9.6 115 6' fill='none' stroke='%23ffe27a' stroke-width='11' stroke-linecap='round'/%3E%3C/svg%3E");
  --swipe-co-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M5 8C32 5.2 64 9.6 115 6' fill='none' stroke='%23ffd3a3' stroke-width='11' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-swipe: var(--swipe-light); --i-swipe-co: var(--swipe-co-light); }
@media (prefers-color-scheme: dark) { :root {
  --bg: #0b1430; --panel: #111c3c; --line: #26345e; --line-2: #4a5b92;
  --ink: #e3e9ff; --soft: #9fb0dc; --on-ink: #0b1430;
  --co: #ff8a4c; --co-ink: #ff9a62; --red: #ff6b9a; --red-ink: #ff7da6; --ok: #69db7c; --ok-ink: #69db7c; --teal: #3fd0c0; --brand: #f0625a;
  --grid: rgba(140,170,255,.07); --night: #060b1c; --frame: #26345e;
  --sb: rgba(170,190,255,.22); --sb-on: rgba(170,190,255,.36); --sb-hi: rgba(170,190,255,.6);
  --i-swipe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M5 8C32 5.2 64 9.6 115 6' fill='none' stroke='%23ffd84d' stroke-opacity='.3' stroke-width='11' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-swipe-co: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M5 8C32 5.2 64 9.6 115 6' fill='none' stroke='%23ff8a4c' stroke-opacity='.32' stroke-width='11' stroke-linecap='round'/%3E%3C/svg%3E"); } }

* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
/* ── Thanh cuộn ──────────────────────────────────────────────────────────────────────────────────────────────
   Máy có chuột: thanh mảnh, bo tròn, màu mực nhạt, rãnh trong suốt; đậm dần khi trỏ vào vùng cuộn, rồi khi trỏ vào chính thanh.
   Máy cảm ứng: giữ thanh nổi của hệ điều hành (không chiếm chỗ), nên các luật ::-webkit-scrollbar nằm trong (hover) and (pointer: fine).
   Chromium và Safari vẽ bằng ::-webkit-scrollbar (chỉnh được bề rộng, bo góc). Firefox dùng scrollbar-width / scrollbar-color.
   Không đặt scrollbar-width cho Chromium: có nó thì Chromium bỏ qua ::-webkit-scrollbar.
   Trang luôn chừa sẵn rãnh cuộn (scrollbar-gutter) để bố cục không giật ngang khi nội dung dài ra hay ngắn lại. */
html { scrollbar-gutter: stable; }
@supports (-moz-appearance: none) { * { scrollbar-width: thin; scrollbar-color: var(--sb-on) transparent; } }
@media (hover: hover) and (pointer: fine) {
  ::-webkit-scrollbar { width: 12px; height: 12px; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb { min-height: 40px; min-width: 40px; border: 3px solid transparent; border-radius: 99px; background: var(--sb-on) padding-box; }
  ::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { border-width: 2px; background-color: var(--sb-hi); }
  /* thanh cuộn của trang chạy bên dưới thanh trên, không vắt qua nó: rãnh lùi xuống đúng chiều cao thanh trên;
     đoạn rãnh nằm cạnh thanh trên tô cùng nền và nối tiếp đường kẻ đáy, nên thanh trên trông liền hết bề ngang */
  html::-webkit-scrollbar-track, body::-webkit-scrollbar-track { margin-top: var(--top-h); }   /* body: overflow-x của body truyền lên khung nhìn, nên Chromium lấy kiểu thanh cuộn trang từ body */
  html::-webkit-scrollbar, body::-webkit-scrollbar { background: linear-gradient(var(--bg) calc(var(--top-h) - 1px), var(--line) calc(var(--top-h) - 1px), var(--line) var(--top-h), transparent var(--top-h)); }
  /* vùng cuộn con (mục lục, lộ trình, nhật ký): thanh nhỏ hơn, mờ khi không dùng tới */
  .toc::-webkit-scrollbar, .rail::-webkit-scrollbar, .route::-webkit-scrollbar, .log::-webkit-scrollbar, pre::-webkit-scrollbar, .stage::-webkit-scrollbar { width: 10px; height: 10px; }
  .toc::-webkit-scrollbar-thumb, .rail::-webkit-scrollbar-thumb, .route::-webkit-scrollbar-thumb, .log::-webkit-scrollbar-thumb, pre::-webkit-scrollbar-thumb { background-color: var(--sb); }
  .toc:hover::-webkit-scrollbar-thumb, .rail:hover::-webkit-scrollbar-thumb, .route:hover::-webkit-scrollbar-thumb, .log:hover::-webkit-scrollbar-thumb, pre:hover::-webkit-scrollbar-thumb { background-color: var(--sb-on); }
  .toc::-webkit-scrollbar-thumb:hover, .rail::-webkit-scrollbar-thumb:hover, .route::-webkit-scrollbar-thumb:hover, .log::-webkit-scrollbar-thumb:hover, pre::-webkit-scrollbar-thumb:hover { background-color: var(--sb-hi); }
}
/* cuộn tới đáy vùng con thì dừng ở đó, không kéo cả trang cuộn theo */
.toc, .rail, .log, pre { overscroll-behavior: contain; }

body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 'Be Vietnam Pro', system-ui, sans-serif; overflow-x: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
h1, h2, p, ul { margin: 0; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--co); outline-offset: 2px; }
/* vệt dạ quang dưới chữ: một nét bút hơi lượn, không phải dải màu thẳng tắp */
.hl { padding: 0 .16em; margin: 0 -.16em; background: var(--i-swipe) 0 84% / 100% .5em no-repeat; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
@keyframes draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 -10% 0 0); } }

/* ---------- thanh trên ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; height: var(--top-h);
  padding: 0 max(var(--gut), env(safe-area-inset-right)) 0 max(var(--gut), env(safe-area-inset-left)); background: var(--bg); border-bottom: 1px solid var(--line); }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--co); transform: scaleX(0); transform-origin: 0 50%; }
.is-loading .top::after { animation: load 1.4s .3s ease-in-out infinite; }   /* chỉ thấy khi tải chậm (nguồn API) */
@keyframes load { 0% { transform: scaleX(0); } 60% { transform: scaleX(.8); } 100% { transform: scaleX(1); opacity: 0; } }
.brand { flex: none; display: inline-flex; align-items: center; gap: 9px; min-height: 44px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; text-decoration: none; }
.logo { display: block; width: 32px; height: 32px; border-radius: 14%; }
@media (prefers-color-scheme: dark) { .logo, .hlogo { background: #fff; } }   /* logo PNG nền trong, một màu đỏ: nền tối thì đặt lên ô trắng như biểu tượng ứng dụng */
.crumb { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--soft); white-space: nowrap; overflow: hidden; }
.crumb a, .crumb .here { overflow: hidden; text-overflow: ellipsis; }
.crumb a { text-decoration: none; padding: 12px 0; } .crumb a:hover { text-decoration: underline; }
.crumb .sep { flex: none; opacity: .5; }
.review { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; font-weight: 600; color: var(--soft); cursor: pointer; white-space: nowrap; }
.review input { -webkit-appearance: none; appearance: none; position: relative; width: 34px; height: 18px; margin: 0; border-radius: 9px; background: var(--line-2); cursor: pointer; transition: background-color .15s; }
.review input::before { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.review input:checked { background: var(--co); } .review input:checked::before { transform: translateX(16px); }

/* ---------- trang mục lục, trang bài học ---------- */
.page { padding-bottom: 48px; }
/* chân trang: một dải cao cố định (--foot-h) có đường kẻ trên, ghi dòng bản quyền. Chỉ hiện khi đã có trang
   (lúc đang tải thì ẩn, khỏi nháy lên sát thanh trên). Trang ngắn thì dải nằm sát đáy màn hình. */
.page, .lesson { min-height: calc(100vh - var(--top-h) - var(--foot-h)); min-height: calc(100dvh - var(--top-h) - var(--foot-h)); }
.foot { display: none; align-items: center; justify-content: center; height: calc(var(--foot-h) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); font-size: 13px; color: var(--soft); text-align: center;
  padding: 0 max(var(--gut), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--gut), env(safe-area-inset-left)); }
main:not([hidden]) ~ .foot { display: flex; }
.page > * { width: min(1040px, 100% - 2 * max(var(--gut), env(safe-area-inset-left), env(safe-area-inset-right))); margin-left: auto; margin-right: auto; }
/* đầu trang: một mảnh giấy ô li có đường lề đỏ, tràn hết bề ngang */
.page > .hero { width: auto; border-bottom: 1px solid var(--line);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; background-position: 50% 0; }
.hin { position: relative; display: flex; align-items: center; gap: 32px; max-width: calc(1040px + 2 * var(--gut)); margin: 0 auto;
  padding: clamp(22px, 4vw, 46px) max(var(--gut), env(safe-area-inset-right)) clamp(24px, 4vw, 44px) calc(max(var(--gut), env(safe-area-inset-left)) + 28px); }
.hin::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(max(var(--gut), env(safe-area-inset-left)) + 8px); width: 2px; background: var(--brand); opacity: .5; }
.htext { flex: 1; }
.hlogo { flex: none; display: block; width: 112px; height: 112px; border-radius: 14%; }
.kicker { font-size: 14.5px; font-weight: 600; color: var(--soft); }
h1 { font-family: var(--hand); font-weight: 400; font-size: clamp(40px, 6.4vw, 68px); line-height: 1.1; margin: 2px 0 12px; }
.lede { max-width: 58ch; color: var(--soft); font-size: clamp(15.5px, 1.4vw, 17px); }
.facts { display: flex; flex-wrap: wrap; gap: 2px 18px; font-size: 15px; color: var(--soft); }
.hero .pbar { max-width: 380px; margin-top: 12px; }
.pbar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.ctarow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-top: 22px; }
/* nút chính: một khối mực, chữ trắng. Không viên thuốc, không bóng đổ màu. */
.cta, .big, .pbtn { display: inline-flex; align-items: center; gap: 10px; min-height: 50px; padding: 8px 24px; border: 2px solid var(--ink); border-radius: 12px; background: var(--ink); color: var(--on-ink); font-weight: 700; line-height: 1.25; text-decoration: none; transition: transform .1s, filter .15s; }
@media (hover: hover) { .cta:hover, .big:hover, .pbtn:hover { filter: brightness(1.12); } }
.cta:active, .big:active, .pbtn:active { transform: translateY(1px) scale(.985); }
.cta svg, .big svg { flex: none; width: 18px; height: 18px; }
.ctanote { position: relative; padding-left: 38px; font-family: var(--hand); font-size: 21px; line-height: 1.1; color: var(--co-ink); }
.ctanote::before { content: ""; position: absolute; left: 0; top: -6px; width: 30px; height: 24px; background: currentColor; transform: scaleX(-1) rotate(-12deg); -webkit-mask: var(--i-arrow) center / contain no-repeat; mask: var(--i-arrow) center / contain no-repeat; }
.err { padding-top: 48px; } .err .cta { margin-top: 20px; }

/* mục lục: tên chương viết tay; mỗi bài một dòng kẻ như trang mục lục của cuốn vở */
.chapter { margin-top: 40px; }
.chapter > h2 { font-family: var(--hand); font-weight: 400; font-size: clamp(27px, 3.2vw, 34px); line-height: 1.15; margin-bottom: 4px; }
.lessons { list-style: none; padding: 0; }
.lessons li { border-bottom: 1px solid var(--line); }
.lrow, .lessons .soon { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: baseline; column-gap: 28px; min-height: 60px; padding: 16px 2px 14px; text-decoration: none; }
.lt { font-size: 18.5px; font-weight: 700; line-height: 1.3; }
.lm { display: flex; gap: 14px; font-size: 14px; color: var(--soft); white-space: nowrap; }
.ln { min-width: 118px; font-family: var(--hand); font-size: 20px; line-height: 1; color: var(--soft); text-align: right; white-space: nowrap; }
.ln.on { color: var(--co-ink); } .ln.fin { color: var(--ok-ink); }
.ln.fin::before { content: ""; display: inline-block; width: 18px; height: 18px; margin-right: 6px; vertical-align: -2px; background: currentColor; -webkit-mask: var(--i-tick) center / contain no-repeat; mask: var(--i-tick) center / contain no-repeat; }
@media (hover: hover) { .lrow:hover .lt { background: var(--i-swipe) 0 88% / 100% .5em no-repeat; } }
.lessons .soon { color: var(--soft); min-height: 50px; padding: 12px 2px 11px; }
.soon .lt { font-size: 16px; font-weight: 400; }
.soon .ln { grid-column: 3; opacity: .8; }
/* ---------- trang chủ ----------
   Đầu trang lớn: chữ bên trái, bên phải là ảnh chụp một hoạt động thật, đặt hơi nghiêng như tờ giấy kẹp vào vở. */
.hero.grand .hin { max-width: calc(1240px + 2 * var(--gut)); gap: clamp(28px, 4vw, 64px); padding-top: clamp(34px, 6vw, 76px); padding-bottom: clamp(36px, 6vw, 80px); }
.hero.grand h1 { font-size: clamp(42px, 5.6vw, 78px); line-height: 1.12; margin-bottom: 18px; }
.hero.grand .lede { font-size: clamp(16px, 1.5vw, 19px); max-width: 52ch; }
.hero.grand .ctarow { margin-top: 28px; }
.shot { flex: none; width: min(46%, 560px); margin: 0; transform: rotate(-1.6deg); }
.shot img { display: block; width: 100%; height: auto; filter: drop-shadow(0 16px 26px rgba(14,22,48,.2)); }
.shot figcaption { margin-top: 10px; padding-right: 6px; font-family: var(--hand); font-size: 19px; line-height: 1.1; color: var(--soft); text-align: right; }
/* ba bước học. Màn rộng: một hình vẽ tay liền mạch (.sk: màn video → bảng đáp án → tờ ghi chú ôn, mũi tên "nếu sai" và vòng quay lại),
   ba cột chữ nằm ngay dưới ba trạm của hình. Màn hẹp: ẩn hình, ba bước xếp dọc với vòng số nối nhau bằng nét bút. */
.skwrap { margin-top: 12px; }
.sk { display: block; width: 100%; height: auto; overflow: visible; }
.sk path, .sk rect, .sk circle { fill: none; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.sk .i { stroke: var(--ink); } .sk .r { stroke: var(--red); } .sk .f { fill: var(--bg); } .sk .t { stroke-width: 2.2; } .sk .d { stroke-dasharray: 9 10; }
.sk .o { fill: var(--co); stroke: var(--co); } .sk .ob { stroke: var(--co); stroke-width: 4; } .sk .l { stroke: var(--line-2); stroke-width: 4; }
.sk .g { fill: rgba(43,138,62,.14); stroke: var(--ok); stroke-width: 2.2; } .sk .gs { stroke: var(--ok); stroke-width: 3; }
.sk .s { stroke: var(--soft); stroke-width: 2.4; } .sk .y { stroke: #ffe27a; stroke-width: 15; }
.sk text { font-family: var(--hand); font-size: 26px; }
.sk text.i { fill: var(--ink); stroke: none; } .sk text.r { fill: var(--red-ink); stroke: none; }
.how { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.how li { position: relative; padding: 0 16px; text-align: center; }
.how .dot { display: none; }
.how b { display: block; font-size: 19px; line-height: 1.3; }
.how li:last-child b { color: var(--red-ink); }
.how p { margin: 4px auto 0; max-width: 30ch; font-size: 15.5px; line-height: 1.5; color: var(--soft); text-wrap: balance; }
/* chọn lớp: mỗi lớp một cuốn vở + các bài đã có của lớp đó.
   Cuốn vở: bìa mực xanh in ô li mờ, gáy lò xo, mép giấy lộ ra ở cạnh phải và đáy, nhãn vở dán hơi nghiêng. Viền sắc, không bóng mờ. */
.klass { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; align-items: start; margin-top: 22px; padding-left: 10px; }
.klass + .klass { margin-top: 40px; }
.cover { position: relative; display: flex; flex-direction: column; min-height: 312px; padding: 26px 20px 20px 38px; border-radius: 8px 12px 12px 8px; color: #fff; text-decoration: none;
  background-color: #1b3a8c;
  background-image: linear-gradient(rgba(255,255,255,.065) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.065) 1px, transparent 1px); background-size: 18px 18px;
  box-shadow: 4px 4px 0 -1px #fdfdfb, 4px 4px 0 0 #a9b9df, 8px 8px 0 -1px #fdfdfb, 8px 8px 0 0 #a9b9df;
  transition: transform .22s cubic-bezier(.3,1.4,.5,1); }
.cover::before { content: ""; position: absolute; left: -10px; top: 16px; bottom: 16px; width: 26px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 22'%3E%3Ccircle cx='19' cy='11' r='3.6' fill='%230b1a4a'/%3E%3Crect x='1.5' y='8' width='19' height='6' rx='3' fill='%23dfe5f5' stroke='%237f90c6' stroke-width='1.2'/%3E%3Cpath d='M4.5 9.8h12' stroke='white' stroke-width='1.2' stroke-linecap='round' opacity='.9'/%3E%3C/svg%3E") 0 0 / 26px 22px repeat-y; }
.cover .label { position: relative; z-index: 1; display: block; padding: 10px 14px 14px; border-radius: 5px; background: #fdfdfb; color: #1b3a8c; transform: rotate(-1.6deg); box-shadow: 0 0 0 1px rgba(8,16,48,.18); }
.kc { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; margin-bottom: 8px; border-bottom: 1.5px solid #bd2b27; font-size: 12px; font-weight: 700; color: #bd2b27; }
.kc::before { content: ""; flex: none; width: 17px; height: 17px; background: url(img/logo-96.png) center / contain no-repeat; }
.kn { display: block; font-family: var(--hand); font-size: 44px; line-height: 1.05; }
.kn span { padding: 0 .1em; margin: 0 -.1em; background: var(--swipe-light) 0 84% / 100% .5em no-repeat; }
.kb { display: block; margin-top: 6px; font-size: 12.5px; font-weight: 500; line-height: 1.4; color: #4a5d8f; }
.ks { position: relative; z-index: 1; margin-top: auto; font-family: var(--hand); font-size: 23px; line-height: 1.1; }
.cover .pbar { position: relative; z-index: 1; height: 5px; margin-top: 9px; background: rgba(255,255,255,.24); } .cover .pbar i { background: #fff; }
.km { position: relative; z-index: 1; margin-top: 9px; font-size: 12.5px; line-height: 1.45; color: rgba(255,255,255,.8); }
.cover.off { background: var(--panel); color: var(--soft); box-shadow: none; } .cover.off::before { display: none; }
@media (hover: hover) { a.cover:hover { transform: translateY(-5px) rotate(-1.4deg); } }
a.cover:active { transform: scale(.985); }
a.cover:focus-visible { outline: 3px solid var(--co); outline-offset: 10px; }
.page.wide > :not(.hero) { width: min(1240px, 100% - 2 * max(var(--gut), env(safe-area-inset-left), env(safe-area-inset-right))); }
.lrow.all .lt { font-size: 16px; font-weight: 600; color: var(--soft); }
.lrow.all .lt::after { content: ""; display: inline-block; width: 26px; height: 20px; margin-left: 8px; vertical-align: -5px; background: currentColor; -webkit-mask: var(--i-arrow) center / contain no-repeat; mask: var(--i-arrow) center / contain no-repeat; }
@media (max-width: 899px) {
  .hero.grand .hin { flex-direction: column; align-items: stretch; }
  .shot { width: 100%; max-width: 560px; transform: none; }
}
@media (max-width: 699px) {
  .skwrap { display: none; }
  .how { grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 18px; }
  .how li { display: flex; gap: 14px; align-items: flex-start; padding: 0; text-align: left; }
  .how li:not(:last-child)::before { content: ""; position: absolute; left: 18px; top: 46px; bottom: -22px; width: 8px; background: var(--line-2); -webkit-mask: var(--i-vline) center / 100% 100% no-repeat; mask: var(--i-vline) center / 100% 100% no-repeat; }
  .how .dot { display: grid; width: 44px; height: 44px; font-size: 25px; color: var(--ink); } .how .dot::before { background: var(--ink); }
  .how li:last-child .dot { color: var(--red-ink); } .how li:last-child .dot::before { background: var(--red); }
  .how b { margin-top: 8px; } .how p { margin: 4px 0 0; max-width: none; }
  .klass { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .klass { padding: 0 8px 8px 10px; }
  .cover { min-height: 0; padding: 22px 18px 18px 36px; } .cover .ks { margin-top: 20px; } .kn { font-size: 40px; }
}
details.chapter { margin-top: 0; border-bottom: 1px solid var(--line); }
.chapter + details.chapter { margin-top: 44px; }
details.chapter + details.chapter { margin-top: 0; }
details.chapter > summary { display: flex; align-items: baseline; gap: 12px; min-height: 56px; padding: 13px 2px 9px; font-family: var(--hand); font-size: 24px; line-height: 1.2; color: var(--soft); cursor: pointer; list-style: none; }
details.chapter[open] > summary { color: var(--ink); }
summary::-webkit-details-marker { display: none; }
summary .cnt { flex: none; margin-left: auto; font-family: 'Be Vietnam Pro', sans-serif; font-size: 13.5px; white-space: nowrap; }
details > summary::after { content: ""; flex: none; align-self: center; width: 8px; height: 8px; margin: -4px 4px 0 2px; border-right: 2px solid var(--soft); border-bottom: 2px solid var(--soft); transform: rotate(45deg); transition: transform .15s; }
details[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
details.chapter .lessons { padding: 0 0 8px 18px; } details.chapter .lessons li:last-child { border-bottom: 0; }

/* mục tiêu: hai cột thẳng hàng — mức độ (chấm màu + tên mức) · câu mục tiêu. Đọc như mục lục chương trình, không như phiếu bài tập. */
.objs { list-style: none; padding: 0; display: grid; gap: 10px; }
.objs li { display: grid; grid-template-columns: 6.6em minmax(0, 1fr); column-gap: 12px; align-items: baseline; font-size: 16px; line-height: 1.45; }
.lv { display: inline-flex; align-items: center; gap: .55em; font-size: .8em; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.lv::before { content: ""; flex: none; width: .55em; height: .55em; border-radius: 50%; background: currentColor; }
.b-nb { color: var(--soft); } .b-th { color: var(--teal); } .b-vd, .b-vdc { color: var(--co-ink); }
.page .objs { grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); column-gap: 40px; margin-top: 12px; }
.why { display: none; font-size: 14px; color: var(--soft); margin: 6px 0 10px; max-width: 80ch; }
body.is-review .why { display: block; }

/* tên mục: chữ cái khoanh tròn bằng bút, rồi tên mục viết tay */
.sech { display: flex; align-items: center; gap: 14px; }
.code { position: relative; flex: none; display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 6px; font-size: .92em; }
.code::after { content: ""; position: absolute; inset: -2px -4px; background: var(--co); -webkit-mask: var(--i-ring) center / 100% 100% no-repeat; mask: var(--i-ring) center / 100% 100% no-repeat; }
.pllist { margin-top: 2px; }
.plrow { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; column-gap: 14px; min-height: 62px; padding: 12px 2px; text-decoration: none; border-bottom: 1px solid var(--line); }
.plrow .st { position: relative; width: 22px; height: 22px; background: var(--line-2); -webkit-mask: var(--i-box) center / contain no-repeat; mask: var(--i-box) center / contain no-repeat; }
.plrow.pass .st { background: var(--ok); -webkit-mask-image: var(--i-tick); mask-image: var(--i-tick); width: 24px; height: 24px; }
.plrow.done .st { background: var(--red); -webkit-mask-image: var(--i-ring); mask-image: var(--i-ring); }   /* học xong nhưng chưa đạt: khoanh lại để làm lại */
.plrow.part .st { background: var(--co); }
.plrow .tt { display: block; }
.plrow .tn { font-size: 16.5px; font-weight: 700; line-height: 1.3; }
.plrow small { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 2px; font-size: 13.5px; line-height: 1.45; color: var(--soft); }
.plrow small b { font-weight: 600; }
.rv { display: none; } body.is-review .rv { display: inline; }
.pn { font-family: var(--hand); font-size: 20px; line-height: 1; white-space: nowrap; color: var(--ok-ink); }
.plrow.done .pn { color: var(--red-ink); } .plrow.part .pn { color: var(--co-ink); }
@media (hover: hover) { a.plrow:hover .tn { background: var(--i-swipe) 0 88% / 100% .5em no-repeat; } }
.plrow.off { color: var(--soft); }
.plrow.cur .tn { padding: 0 .16em; margin: 0 -.16em; background: var(--i-swipe-co) 0 86% / 100% .56em no-repeat; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* ---------- trang Pi Lesson ---------- */
.lesson { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 1480px; margin: 0 auto; align-items: start; align-content: start;
  padding: 14px max(var(--gut), env(safe-area-inset-right)) 40px max(var(--gut), env(safe-area-inset-left)); }
.main { display: grid; grid-template-columns: minmax(0, 1fr); }
.plhead { margin-bottom: 10px; }
.plhead h1 { font-size: clamp(30px, 3.2vw, 40px); line-height: 1.12; margin: 0; }
.plhead .why { margin: 8px 0 0; }

.toc > summary { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 2px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-family: var(--hand); font-size: 23px; cursor: pointer; list-style: none; }
.toc > summary::after { margin-left: auto; }
.tsec { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--soft); margin: 20px 0 2px; }
.tsec:first-child { margin-top: 10px; }
.toc .plrow { grid-template-columns: 20px minmax(0, 1fr); column-gap: 10px; min-height: 52px; padding: 9px 2px; }
.toc .plrow .st { width: 19px; height: 19px; } .toc .plrow.pass .st { width: 21px; height: 21px; }
.toc .plrow .tn { font-size: 14.5px; font-weight: 600; } .toc .plrow small { font-size: 13px; }
@media (min-width: 1024px) {
  .lesson { grid-template-columns: 236px minmax(0, 1fr); gap: 36px; }
  .main { grid-column: 2; grid-row: 1; }
  .toc { grid-column: 1; grid-row: 1; position: sticky; top: calc(var(--top-h) + 14px); max-height: calc(100vh - var(--top-h) - 28px); overflow: auto; padding: 0 6px 24px 0;
    -webkit-mask-image: linear-gradient(#000 calc(100% - 24px), transparent); mask-image: linear-gradient(#000 calc(100% - 24px), transparent); }   /* mép dưới mờ dần: còn mục ở dưới */
  .toc > summary { display: none; }
  .tsec:first-child { margin-top: 0; }
}

/* ---------- sân khấu ----------
   box = khung tối quanh mặt giấy: [bhead: node hiện tại · bước · toàn màn hình · vạch tiến độ] [stage] [capband: phụ đề] [ctl: điều khiển].
   Chiều cao khung không đổi giữa các node trên màn rộng: video và storyboard = 16:9 + dải phụ đề + thanh điều khiển;
   các chế độ khác (bìa, hoạt động, kết quả) cho mặt giấy chiếm luôn phần của hai dải đó (--band + --ctlh).
   .stage::before là "cái nêm" giữ chiều cao tối thiểu; bìa và kết quả nằm trong dòng chảy nên nội dung dài thì khung tự cao thêm. */
.box { --band: 58px; --ctlh: 54px; display: grid; grid-template-columns: minmax(0, 1fr); max-width: max(560px, calc((100vh - 342px) * 16 / 9));
  padding: 0 8px 8px; border-radius: 18px; border: 1px solid var(--frame); background: var(--night); color: #e3e9ff; }
.bhead { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; column-gap: 12px; padding: 0 0 8px 8px; }
.bnow { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bnow svg { flex: none; width: 16px; height: 16px; color: #ff8a4c; } .bnow.br svg { color: #ff6b9a; }
.bstep { font-size: 13px; color: #9fb0dc; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bstep:last-of-type { padding-right: 8px; }
.segs { grid-column: 1 / -1; display: flex; gap: 3px; height: 4px; margin-right: 8px; }
.segs i { flex: 1; border-radius: 2px; background: #26345e; }
.segs .done { background: #8fa3dd; } .segs .cur { background: #ff8a4c; } .segs .br { background: #ff6b9a; }
.ib { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0; background: #1f2b52; color: #e3e9ff; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.ib:hover:not(:disabled) { background: #2a3a6c; } .ib svg { width: 20px; height: 20px; }
.ib:disabled { opacity: .35; cursor: default; }
.ib[aria-pressed=false] { opacity: .55; text-decoration: line-through; }
.bhead .ib { background: none; } .bhead .ib:hover { background: #1f2b52; }

.stage { --sb: rgba(27,58,140,.22); --sb-on: rgba(27,58,140,.36); --sb-hi: rgba(27,58,140,.58);
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr); border-radius: 10px; overflow: hidden; background: var(--paper); color: var(--p-ink); color-scheme: light;
  --i-swipe: var(--swipe-light); --i-swipe-co: var(--swipe-co-light); --co-ink: #c5400c; --red-ink: #b01f52; --ok-ink: #237a35; --teal: #0b7a75; --soft: #4a5d8f; --ink: #1b3a8c; --co: #d9480f; --line: #d6dff0; --line-2: #a9b9df; --on-ink: #fff; }
.stage::before { content: ""; grid-area: 1 / 1; box-sizing: content-box; width: 100%; aspect-ratio: 16 / 9; pointer-events: none; }
.box:not([data-mode=video]) .stage::before { padding-bottom: calc(var(--band) + var(--ctlh)); }
.box:not([data-mode=video]) .capband, .box:not([data-mode=video]) .ctl { display: none; }
.stage video, .stage > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.stage video { object-fit: contain; background: var(--paper); cursor: pointer; }
.overlay { position: absolute; inset: 0; z-index: 2; background: rgba(14,22,48,.55); animation: fade .18s ease-out; }
.overlay iframe { position: absolute; left: 4%; top: 4%; width: 92%; height: 92%; border: 0; border-radius: 12px; background: var(--paper); box-shadow: 0 20px 50px rgba(10,20,50,.45); animation: pop .22s ease-out; }
/* Câu hỏi nằm trong video (cue có nhánh video, #box[data-live]): không phủ mờ, không thẻ. iframe trong suốt phủ cả khung hình,
   khay đáp án do trang hoạt động vẽ ở mép dưới (kp/base.css: html.live). */
.box[data-live] .overlay { background: none; animation: none; }
.box[data-live] .overlay iframe { left: 0; top: 0; width: 100%; height: 100%; border-radius: 0; background: transparent; box-shadow: none; animation: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* phụ đề nằm DƯỚI khung hình, không che nội dung video */
.capband { display: flex; align-items: center; justify-content: center; height: var(--band); padding: 6px 14px 0; }
.caption { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; max-width: 76ch; margin: 0; font-size: 16.5px; font-weight: 600; line-height: 1.38; text-align: center; text-wrap: balance; color: #fff; }
.ctl { display: flex; align-items: center; gap: 10px; height: var(--ctlh); padding: 6px 0 0; }
.track { position: relative; flex: 1; height: 44px; display: flex; align-items: center; }
/* thanh tua: cam = đang phát tới đâu, xanh nhạt = đã xem tới đâu (chỉ tua được trong phần này) */
.track input { --f: 0; --m: 0; --at: calc(8px + (100% - 16px) * var(--f)); --seen: calc(8px + (100% - 16px) * var(--m)); -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: none; cursor: pointer; }
.track input::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #ff8a4c var(--at), #6f82bd var(--at), #6f82bd var(--seen), #26345e var(--seen)); }
.track input::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #ff8a4c var(--at), #6f82bd var(--at), #6f82bd var(--seen), #26345e var(--seen)); }
.track input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.track input::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.track input:disabled { opacity: .35; cursor: default; }
.cue { --f: 0; position: absolute; top: 50%; left: calc(8px + (100% - 16px) * var(--f)); width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #ff8a4c; border: 2px solid var(--night); pointer-events: none; }
.cue.done { background: #69db7c; }
.time { font-size: 13.5px; white-space: nowrap; font-variant-numeric: tabular-nums; color: #9fb0dc; min-width: 84px; text-align: right; }

/* ---------- bìa và kết quả: viết trên giấy ô li, canh theo đường lề đỏ như khung hoạt động ---------- */
.start, .summary { grid-area: 1 / 1; position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center;
  padding: clamp(22px, 4.5%, 44px) clamp(16px, 5%, 52px) clamp(24px, 4.5%, 44px) clamp(36px, 9.5%, 96px);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; }
.start::before, .summary::before { content: ""; position: absolute; top: 0; bottom: 0; left: clamp(16px, 5.6%, 58px); width: 2px; background: #bd2b27; opacity: .42; }
.start h2 { font-family: var(--hand); font-weight: 400; font-size: clamp(27px, 3.1vw, 36px); line-height: 1.15; margin: 0 0 16px; }
.start .objs li { font-size: clamp(16px, 1.55vw, 17.5px); }
.stamp { position: absolute; top: clamp(14px, 4%, 30px); right: clamp(14px, 4%, 30px); width: 44px; height: 44px; }
/* ghi chú ngoài lề đỏ, như số bài viết ở lề vở */
.mnote { position: absolute; left: 0; top: clamp(24px, 5%, 46px); width: clamp(16px, 5.6%, 58px); font-family: var(--hand); font-size: 19px; line-height: 1.05; text-align: center; color: var(--red-ink); }
.gorow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; margin-top: 26px; }
.big { min-height: 56px; padding: 8px 30px; font-size: clamp(17px, 1.9vw, 20px); text-align: left; }
.big svg { width: 20px; height: 20px; }
.start .facts { font-size: 15px; }
.meta { margin-top: 14px; font-family: var(--hand); font-size: 20px; line-height: 1.25; color: var(--co-ink); }

.summary { justify-content: flex-start; font-size: 15.5px; }
.summary h2 { font-family: var(--hand); font-weight: 400; font-size: clamp(34px, 4.4vw, 48px); line-height: 1.15; margin: 4px 0 6px; }
/* điểm khoanh tròn bằng bút đỏ, như điểm trên bài kiểm tra */
.score { position: relative; display: inline-block; margin-left: .2em; padding: 0 .16em; color: var(--red-ink); }
.score::after { content: ""; position: absolute; inset: -.1em -.34em -.06em; background: currentColor; -webkit-mask: var(--i-ring) center / 100% 100% no-repeat; mask: var(--i-ring) center / 100% 100% no-repeat; animation: draw .5s .15s ease-out both; }
.remark { position: relative; max-width: 46ch; padding-left: 40px; margin: 4px 0 14px; font-family: var(--hand); font-size: clamp(21px, 2.3vw, 25px); line-height: 1.25; color: var(--red-ink); }
.remark::before { content: ""; position: absolute; left: 2px; top: -2px; width: 30px; height: 24px; background: currentColor; -webkit-mask: var(--i-arrow) center / contain no-repeat; mask: var(--i-arrow) center / contain no-repeat; }
.summary table { width: 100%; border-collapse: collapse; margin: 14px 0 4px; }
.summary th { font-size: 13.5px; font-weight: 400; color: var(--p-soft); }
.summary th, .summary td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--p-line); }
.summary td:first-child { font-weight: 600; }
.summary .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.summary td.ok { color: var(--ok-ink); } .summary td.bad { color: var(--red-ink); }
.summary td.ok::before, .summary td.bad::before { content: ""; display: inline-block; width: 17px; height: 17px; margin-right: 7px; vertical-align: -2px; background: currentColor; -webkit-mask: var(--i-tick) center / contain no-repeat; mask: var(--i-tick) center / contain no-repeat; }
.summary td.bad::before { -webkit-mask-image: var(--i-cross); mask-image: var(--i-cross); }
.tag { font-family: var(--hand); font-size: 18px; font-weight: 400; line-height: 1; color: var(--p-soft); white-space: nowrap; }
.summary .note { font-size: 13.5px; color: var(--p-soft); margin: 6px 0 0; max-width: none; }
.acts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 22px; }
.nextup { flex-basis: 100%; font-size: 15px; color: var(--p-soft); }
.pbtn { min-height: 48px; padding: 6px 22px; font-size: 15.5px; }
.pbtn svg { width: 16px; height: 16px; }
/* nút phụ: cùng dáng, nền giấy viền mực */
.pbtn.ghost { background: #fff; color: var(--ink); }

/* ---------- lộ trình ----------
   Mỗi bước là một nút bấm nên vòng tròn là hình tròn thật, viền liền và sắc (quy tắc: ô bấm không vẽ tay).
   Vẽ như đánh số bước trong vở: vòng khoanh bằng bút, số viết tay, đường nối là nét bút hơi lượn. Mọi nét là đường SVG thật (dùng làm mask), không có bộ lọc.
   Ba trạng thái đọc được ngay: chưa học = vòng khoanh rỗng có số · đã học = tô mực kín có dấu tích · đang học = tô cam, khoanh thêm một vòng ngoài.
   Đường nối: nét nhạt, đoạn đã đi qua tô mực; đoạn dẫn tới bước đang học chạy dần tới nơi.
   Nhánh ôn: một mũi tên bút màu hồng đỏ rẽ ra từ câu của nó, ghi chú "nếu sai" viết tay phía trên tên bước ôn.
   Chỉ hai kiểu chữ: tên bước dùng chữ thường của trang; số, ghi chú, điểm dùng chữ viết tay.
   Chuyển động chỉ gắn vào thứ vừa đổi (.intro: lần đầu hiện · .now: bước vừa tới · .fresh: bước vừa xong),
   vì cả lộ trình được dựng lại mỗi lần sang node. --off: hướng "chưa chạy" của đường nối (ngang hay dọc). */
.sec { font-family: var(--hand); font-weight: 400; font-size: 27px; line-height: 1.2; margin: 26px 0 6px; }
.rail, .how {
  --i-blob: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20.4 2.5C30 2.2 37.9 9.8 37.6 19.6 37.3 29.6 29.6 37.8 19.7 37.5 9.8 37.2 2.2 30 2.5 20.5 2.8 10.6 10.4 2.8 20.4 2.5z'/%3E%3C/svg%3E");
  --i-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 26'%3E%3Cpath d='M11.4 2.5c-.9 5.2.5 10.4-.3 17M5.4 14.6l5.6 6.6 5.8-6.9' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --i-hline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8' preserveAspectRatio='none'%3E%3Cpath d='M0 4C16 2.2 33 5.6 50 4 67 2.5 84 5.4 100 4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --i-vline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 100' preserveAspectRatio='none'%3E%3Cpath d='M4 0C2.2 16 5.6 33 4 50 2.5 67 5.4 84 4 100' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E"); }
.route { --tint: rgba(27,58,140,.07); --ln: var(--i-hline); --br: var(--i-down);
  position: relative; display: flex; align-items: flex-start; overflow-x: auto; padding: 10px 2px 10px; }
.rstep { position: relative; flex: 1 1 0; min-width: 72px; display: flex; flex-direction: column; align-items: center; }
.rstep::before, .rstep::after { content: ""; position: absolute; top: 18px; left: -50%; width: 100%; height: 8px; background: var(--line-2); transform-origin: left top;
  -webkit-mask: var(--ln) center / 100% 100% no-repeat; mask: var(--ln) center / 100% 100% no-repeat; }
.rstep::after { background: var(--ink); transform: var(--off, scaleX(0)); }
.rstep.past::after { transform: none; }
.rstep.now::after { animation: grow .5s cubic-bezier(.3,.7,.2,1) both; }
.rstep:first-child::before, .rstep:first-child::after { display: none; }
.route.intro .rstep { animation: rise .4s ease-out both; animation-delay: calc(var(--i, 0) * 45ms); }

.pill { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; width: 100%; padding: 4px 4px 6px; border: 0; border-radius: 14px; background: none; text-align: center; color: var(--soft);
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color .16s, color .16s; }
.dot { position: relative; isolation: isolate; flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--bg) 80%, transparent 83%);   /* che đường nối chạy dưới vòng */
  font-family: var(--hand); font-size: 21px; font-weight: 400; line-height: 1;
  transition: transform .18s cubic-bezier(.3,1.5,.5,1), color .16s; }
.dot::before { content: ""; position: absolute; inset: -1px; z-index: -1; background: var(--line-2); transition: background-color .16s;
  -webkit-mask: var(--i-ring) center / 100% 100% no-repeat; mask: var(--i-ring) center / 100% 100% no-repeat; }
.dot svg { width: 16px; height: 16px; }
.ptx { display: block; font-size: 13px; line-height: 1.3; }
.pt { font-weight: 600; transition: color .16s; }
.ph { display: none; font-size: 12px; line-height: 1.3; margin-top: 2px; }
.ph.strong { display: block; font-family: var(--hand); font-size: 17px; line-height: 1.1; }
body.is-review .ph { display: block; }

/* rê chuột, nhấn, bàn phím */
@media (hover: hover) {
  .pill:hover { background: var(--tint); color: var(--ink); }
  .pill:hover .dot { transform: scale(1.08) rotate(-6deg); }
  .pill:hover .dot::before { background: var(--ink); }
  .pill.cur:hover .dot::before { background: var(--co); } .pill.branch:hover .dot::before { background: var(--red); }
}
.pill:active .dot { transform: scale(.9); transition-duration: .06s; }
.pill:active { background: var(--tint); }
.pill:focus-visible { outline: 3px solid var(--co); outline-offset: 2px; }
/* chờ bấm lần hai (đang học dở mà bấm sang bước khác): nền cam nhạt, lời nhắc viết tay */
.pill.arm { background: rgba(217,72,15,.1); color: var(--co-ink); }
.pill.arm .ph.strong { color: var(--co-ink); font-size: 16px; line-height: 1.2; margin-top: 3px; }
.pill.arm .dot::before { background: var(--co); }

/* đã học: tô mực kín, dấu tích viết tay thay cho số */
.pill.done { color: var(--ink); }
.pill.done .dot { color: transparent; }
.pill.done .dot::before { background: var(--ink); -webkit-mask-image: var(--i-blob); mask-image: var(--i-blob); }
.pill.done .dot::after { content: ""; position: absolute; inset: 8px 7px 9px 8px; background: var(--on-ink); -webkit-mask: var(--i-tick) center / contain no-repeat; mask: var(--i-tick) center / contain no-repeat; }
.pill.done.fresh .dot { animation: stamp .4s cubic-bezier(.3,1.5,.5,1) both; }
.pill.done.fresh .dot::after { animation: tick .3s .12s ease-out both; }
/* đang học: tô cam, bút khoanh thêm một vòng ngoài (thở chậm); tên bước gạch dạ quang */
.pill.cur { color: var(--co-ink); }
.pill.cur .dot { color: #fff; animation: stamp .4s cubic-bezier(.3,1.5,.5,1) both; }
.pill.cur .dot::before { background: var(--co); -webkit-mask-image: var(--i-blob); mask-image: var(--i-blob); }
.pill.cur .dot::after { content: ""; position: absolute; inset: -6px; background: var(--co); opacity: .5; transform: rotate(150deg);
  -webkit-mask: var(--i-ring) center / 100% 100% no-repeat; mask: var(--i-ring) center / 100% 100% no-repeat; animation: breathe 2.6s .5s ease-in-out infinite; }
.pill.cur .pt { font-weight: 700; padding: 0 .16em; background: var(--i-swipe-co) 0 86% / 100% .56em no-repeat; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
/* nhánh ôn: mũi tên bút rẽ ra từ đường chính (--br: rẽ ngang hay chỉ xuống, --bw: bề rộng hình), ghi chú "nếu sai" phía trên tên bước.
   Đã ghé qua: mũi tên thành chấm đỏ có dấu tích. Đang ở đó: chấm đỏ có vòng khoanh ngoài. */
.pill.branch { color: var(--red-ink); }
.pill.branch .dot { width: var(--bw, 22px); height: 26px; border-radius: 0; background: none; }
.pill.branch .dot svg { display: none; }
.pill.branch .dot::before { inset: 0; background: var(--red); -webkit-mask-image: var(--br); mask-image: var(--br); }
.if { display: block; font-family: var(--hand); font-size: 15px; font-weight: 400; line-height: 1.15; }
.pill.branch.done .dot, .pill.branch.cur .dot { width: 26px; }
.pill.branch.done .dot::before, .pill.branch.cur .dot::before { -webkit-mask-image: var(--i-blob); mask-image: var(--i-blob); }
.pill.branch.done .dot::after { inset: 6px 5px 6px 6px; }
.pill.branch.cur .dot::after { inset: -5px; background: var(--red); }   /* cùng kiểu "đang học" của đường chính: chấm đặc + một vòng khoanh ngoài */
.pill.branch.cur .pt { background-image: none; }

@keyframes grow { from { transform: var(--off, scaleX(0)); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes stamp { from { transform: scale(.55); } }
@keyframes tick { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes breathe { 50% { opacity: .14; transform: rotate(150deg) scale(1.14); } }

.legend { display: flex; gap: 8px 22px; flex-wrap: wrap; font-size: 13px; color: var(--soft); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 9px; }
.lg { flex: none; width: 16px; height: 16px; background: var(--line-2); -webkit-mask: var(--i-ring) center / 100% 100% no-repeat; mask: var(--i-ring) center / 100% 100% no-repeat; }
.lg.done { background: var(--ink); -webkit-mask-image: var(--i-blob); mask-image: var(--i-blob); }
.lg.cur { background: var(--co); -webkit-mask-image: var(--i-blob); mask-image: var(--i-blob); }
.lg.br { width: 20px; height: 15px; background: var(--red); -webkit-mask-image: var(--i-arrow); mask-image: var(--i-arrow); }

/* ---------- bảng duyệt (công cụ của người soạn bài: gọn, không trang trí) ---------- */
.panel { display: none; margin-top: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
body.is-review .panel { display: block; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; height: 44px; padding: 0 10px; border-radius: 10px; border: 1.5px solid var(--line); background: transparent; font-size: 14px; font-weight: 600; }
.tab[aria-selected=true] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.log { list-style: none; margin: 0; padding: 0; max-height: min(46vh, 520px); overflow: auto; font-size: 13px; }
.log li { display: grid; grid-template-columns: 38px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log:empty::after { content: "Bấm “Bắt đầu học”. Mọi tin nhắn giữa player và hoạt động hiện ở đây."; color: var(--soft); font-size: 14px; }
.log .t { color: var(--soft); font-variant-numeric: tabular-nums; }
.log .k { font-weight: 700; margin-right: 6px; }
.k.in { color: var(--teal); } .k.out { color: var(--co-ink); } .k.sys { color: var(--soft); } .k.x { color: var(--red); }
.log code { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--soft); overflow-wrap: anywhere; }
pre { margin: 0; overflow: auto; max-height: min(46vh, 520px); font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.copy { height: 44px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--ink); background: transparent; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--soft); margin-top: 10px; }
@media (min-width: 1400px) {
  body.is-review .main { grid-template-columns: minmax(0, 1fr) 340px; column-gap: 24px; }
  body.is-review .main > * { grid-column: 1; }
  body.is-review .main > .panel { grid-column: 2; grid-row: 1 / span 5; align-self: start; position: sticky; top: calc(var(--top-h) + 14px); margin-top: 0; }
  body.is-review .log, body.is-review pre { max-height: calc(100vh - 260px); }
}

/* ---------- màn rộng, nằm ngang (laptop, màn rời) ----------
   Áp dụng cho mọi màn ngang từ 1200 px, kể cả 16:10 và 4:3: cả trang học nằm gọn trong một màn hình, không phải cuộn xuống mới thấy lộ trình.
   Khung học bị giới hạn theo chiều cao (để cả khung nằm gọn trong màn hình), nên bên phải dư chỗ.
   Dùng chỗ đó cho "Lộ trình": danh sách dọc cạnh khung học, luôn thấy khi đang học, không phải cuộn xuống.
   Cột trái của lưới rộng đúng bằng bề rộng tối đa của khung (.box), cột phải nhận phần còn lại.
   Chế độ duyệt giữ bố cục riêng ở trên: cột phải dành cho bảng duyệt, lộ trình nằm ngang bên dưới.
   Các luật "lộ trình dọc" lặp lại của màn hẹp (bên dưới) vì ở đây phải gắn điều kiện không ở chế độ duyệt. */
@media (min-width: 1200px) and (orientation: landscape) {
  /* Cột lộ trình rộng cố định 220 px; phần còn lại cho khung học, tới mức khung cao vừa màn hình thì dừng.
     Bề ngang cả trang = mục lục 236 + 36 + khung học + 34 + lộ trình 220: màn nào cũng canh giữa, không dư một dải trống bên phải. */
  body:not(.is-review) .lesson { max-width: calc((100vh - 342px) * 16 / 9 + 526px + 2 * var(--gut)); }
  body:not(.is-review) .main { grid-template-columns: minmax(0, max(560px, calc((100vh - 342px) * 16 / 9))) 220px; grid-template-rows: auto auto auto 1fr; column-gap: 34px; }
  body:not(.is-review) .main > .plhead { grid-column: 1 / -1; }
  /* mục lục bên trái không được cao hơn phần còn lại của màn hình (14 px trên + 40 px lề đáy + chân trang), kẻo cả trang phải cuộn */
  body:not(.is-review) .toc { max-height: calc(100vh - var(--top-h) - 54px - var(--foot-h)); }
  body:not(.is-review) .main > .box { grid-column: 1; grid-row: 2 / span 3; align-self: start; }   /* start: không để cột lộ trình kéo khung học cao lên */
  /* cột lộ trình luôn đi cùng khung học: cao đúng bằng khung (contain: size → không tự đội chiều cao của hàng),
     dài hơn thì tự cuộn bên trong, bước đang học được player đưa vào giữa. Trang không phải cuộn để xem hết lộ trình. */
  body:not(.is-review) .main > .rail { grid-column: 2; grid-row: 2 / span 3; align-self: stretch; contain: size; max-width: 360px;
    overflow-y: auto; padding: 0 8px 24px 4px; margin-left: -4px;
    /* còn bước ở dưới thì mép dưới mờ dần thay vì bị cắt ngang */
    -webkit-mask-image: linear-gradient(#000 calc(100% - 24px), transparent); mask-image: linear-gradient(#000 calc(100% - 24px), transparent); }
  @media (prefers-reduced-motion: no-preference) { body:not(.is-review) .main > .rail { scroll-behavior: smooth; } }
  body:not(.is-review) .rail .sec { margin: 2px 0 0; }
  body:not(.is-review) .rail .route { flex-direction: column; align-items: stretch; overflow: visible; padding: 6px 0 0; }
  body:not(.is-review) .rail .legend { flex-direction: column; margin-top: 14px; }
  body:not(.is-review) .route { --off: scaleY(0); --ln: var(--i-vline); --br: var(--i-arrow); --bw: 32px; }
  body:not(.is-review) .rstep { flex: none; min-width: 0; align-items: stretch; }
  body:not(.is-review) .rstep { --dc: 22px; }
  body:not(.is-review) .rstep::before { top: 0; bottom: 0; left: 14px; width: 8px; height: auto; }
  body:not(.is-review) .rstep::after { top: 0; bottom: auto; left: 14px; width: 8px; height: var(--dc); }
  body:not(.is-review) .rstep.thru::after { height: auto; bottom: 0; }
  body:not(.is-review) .rstep:first-child::before, body:not(.is-review) .rstep:first-child::after { display: block; top: var(--dc); }
  body:not(.is-review) .rstep:first-child:not(.thru)::after { height: 0; }
  body:not(.is-review) .rstep:last-child::before { bottom: auto; height: var(--dc); }
  body:not(.is-review) .pill { flex-direction: row; gap: 12px; min-height: 44px; padding: 4px 10px 4px 0; text-align: left; }
  body:not(.is-review) .ptx { font-size: 14.5px; }
  body:not(.is-review) .pill.branch { width: auto; margin-left: 24px; gap: 9px; }
}
/* màn từ 16:9 trở lên: khung học cao gần hết màn hình, nên bớt lề đáy, ẩn chân trang và nâng trần mục lục để cả trang vừa khít */
@media (min-width: 1200px) and (min-aspect-ratio: 16/9) {
  body:not(.is-review) .lesson { padding-bottom: 22px; }
  body:not(.is-review) .lesson:not([hidden]) ~ .foot { display: none; }
  body:not(.is-review) .toc { max-height: calc(100vh - var(--top-h) - 36px); }
}
/* màn rất rộng: nới bề ngang trang để khung học to mà vẫn còn cột lộ trình */
@media (min-width: 1700px) { .lesson { max-width: 1780px; } }

/* ---------- màn hẹp ---------- */
@media (max-width: 699px) {
  :root { --top-h: 48px; }
  .top { gap: 8px; }
  .top.deep .bn { display: none; }
  .crumb .sep, .crumb .here, .crumb a.far { display: none; }   /* màn hẹp chỉ giữ một nút quay lại cấp ngay trên */
  .crumb a { display: flex; align-items: center; gap: 6px; font-size: 14.5px; color: var(--ink); }
  .crumb a::before { content: ""; flex: none; width: 8px; height: 8px; margin-left: 4px; border-left: 2.2px solid; border-bottom: 2.2px solid; transform: rotate(45deg); }
  .review .rl { font-size: 0; } .review .rl::after { content: "Duyệt"; font-size: 13px; }
  .hlogo { display: none; }
  .hin { padding-left: calc(var(--gut) + 18px); } .hin::before { left: calc(var(--gut) - 2px); }
  .chapter { margin-top: 32px; }
  .lrow { grid-template-columns: minmax(0, 1fr) auto; row-gap: 3px; padding: 14px 2px 13px; }
  .lrow > .lt { grid-column: 1 / -1; } .lrow .ln { min-width: 0; }
  .lrow .lm { flex-wrap: wrap; gap: 0 12px; }   /* ba ghi chú không vừa một dòng thì xuống dòng, không đè lên nhau */
  .lessons .soon { grid-template-columns: minmax(0, 1fr) auto; } .soon .ln { grid-column: 2; min-width: 0; }
  details.chapter > summary { font-size: 22px; } summary .cnt .x { display: none; }
  details.chapter .lessons { padding-left: 8px; }
  .plrow { grid-template-columns: 22px minmax(0, 1fr); column-gap: 12px; }
  .pn { grid-column: 2; justify-self: start; margin-top: 2px; }
  .stamp, .mnote { display: none; }
  .gorow { margin-top: 22px; } .big { width: 100%; justify-content: center; }
  .acts > .pbtn { flex: 1 1 auto; justify-content: center; }
  /* bảng kết quả → mỗi hoạt động một cụm dòng: tên ở trên, ba số liệu ở dưới */
  .summary thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .summary tr { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 16px; padding: 10px 0; border-bottom: 1px solid var(--p-line); }
  .summary td { padding: 0; border: 0; }
  .summary td:first-child { grid-column: 1 / -1; }
  .summary td.n { font-size: 13.5px; color: var(--p-soft); }
  .summary td.n::before { content: attr(data-l) " "; }
  /* lộ trình → danh sách dọc, mỗi node một dòng chạm được */
  .route { --off: scaleY(0); --ln: var(--i-vline); --br: var(--i-arrow); --bw: 32px; flex-direction: column; align-items: stretch; overflow: visible; padding: 4px 0 0; }
  .rstep { flex: none; min-width: 0; align-items: stretch; }
  /* dọc: mỗi bước giữ một đoạn đường nối chạy suốt chiều cao của nó (kể cả nhánh ôn bên dưới).
     Mực chỉ tô tới tâm vòng tròn (--dc) khi bước này đã tới; tô suốt (.thru) khi bước kế tiếp cũng đã tới. */
  .rstep { --dc: 24px; }
  .rstep::before { top: 0; bottom: 0; left: 14px; width: 8px; height: auto; }
  .rstep::after { top: 0; bottom: auto; left: 14px; width: 8px; height: var(--dc); }
  .rstep.thru::after { height: auto; bottom: 0; }
  .rstep:first-child::before, .rstep:first-child::after { display: block; top: var(--dc); }
  .rstep:first-child:not(.thru)::after { height: 0; }
  .rstep:last-child::before { bottom: auto; height: var(--dc); }
  .pill { flex-direction: row; gap: 14px; min-height: 50px; padding: 6px 10px 6px 0; text-align: left; }
  .ptx { font-size: 15.5px; } .ph { font-size: 13px; } .ph.strong { font-size: 18px; }
  .pill.branch { width: auto; margin-left: 24px; gap: 10px; }
}
/* điện thoại dọc: sân khấu tràn hết bề ngang; hoạt động và câu hỏi chen giữa video cao gần hết màn hình */
@media (max-width: 699px) and (orientation: portrait) {
  .lesson { padding-top: 8px; }
  .box { --band: 84px; margin: 0 calc(-1 * var(--gut)); padding: 0 0 6px; border-radius: 0; border: 0; }
  .bhead { padding: 0 2px 8px 14px; } .segs { margin-right: 12px; }
  .stage { border-radius: 0; }
  .box[data-mode=cover] .stage::before, .box[data-mode=summary] .stage::before { padding-bottom: 0; }
  .box[data-mode=html] .stage::before, .box[data-cue] .stage::before { aspect-ratio: auto; padding: 0; height: clamp(420px, calc(100vh - 106px), 660px); height: clamp(420px, calc(100svh - 106px), 660px); }
  .box[data-cue] .capband, .box[data-cue] .ctl { display: none; }
  /* câu hỏi trong video: khung hình vẫn 16:9 ở trên (đang dừng ở khung câu hỏi), khay đáp án nằm ngay dưới */
  .box[data-live] .stage::before { height: calc(56.25vw + var(--tray, 206px)); }
  .box[data-live] .stage video { bottom: auto; height: auto; aspect-ratio: 16 / 9; }
  /* storyboard: khung hình là chữ dàn lại theo bề ngang, nên cho cao hơn 16:9 để đọc được; phụ đề và điều khiển vẫn như video */
  .box[data-story]:not([data-cue]) .stage::before { aspect-ratio: auto; height: clamp(250px, calc(100vh - 262px), 430px); height: clamp(250px, calc(100svh - 262px), 430px); }
  .overlay iframe { left: 0; top: 0; width: 100%; height: 100%; border-radius: 0; }
  .capband { height: auto; min-height: var(--band); padding: 10px 14px 4px; }
  .caption { -webkit-line-clamp: 4; font-size: 15.5px; }
  .ctl { padding: 4px 8px 0; }
  .time { min-width: 0; } .time .of { display: none; }
}
/* máy tính bảng dọc: màn hình còn nhiều chỗ theo chiều cao → hoạt động được mặt giấy cao hơn 16:9 (video vẫn 16:9) */
@media (min-width: 700px) and (max-width: 1023px) and (orientation: portrait) {
  .box[data-mode=html] .stage::before { aspect-ratio: auto; padding: 0; height: clamp(520px, calc(100vh - 330px), 740px); height: clamp(520px, calc(100svh - 330px), 740px); }
}
/* điện thoại ngang: thanh trên cuộn theo trang, sân khấu cao bằng màn hình; phụ đề sang cột bên phải video */
@media (max-height: 520px) and (orientation: landscape) and (max-width: 1023px) {
  .top { position: static; }
  .lesson { padding-top: 8px; }
  .plhead { margin-bottom: 6px; } .plhead h1 { font-size: 28px; }
  .box { --ctlh: 50px; max-width: none; grid-template-columns: auto minmax(0, 1fr); margin: 0 calc(-1 * max(var(--gut), env(safe-area-inset-left))) 0 calc(-1 * max(var(--gut), env(safe-area-inset-right)));
    padding: 0 max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left)); border-radius: 0; border: 0; }
  .bhead, .ctl { grid-column: 1 / -1; }
  .ctl { padding-top: 2px; }
  .box[data-mode=video]:not([data-cue]) .stage { height: calc(100vh - 56px - var(--ctlh) - 4px); height: calc(100svh - 56px - var(--ctlh) - 4px); aspect-ratio: 16 / 9; }
  .box[data-mode=video]:not([data-cue]) .stage::before { display: none; }
  .capband { height: auto; align-self: center; justify-content: flex-start; padding: 0 4px 0 16px; }
  .caption { -webkit-line-clamp: 9; font-size: 16px; text-align: left; }
  .box:not([data-mode=video]) .stage, .box[data-cue] .stage { grid-column: 1 / -1; }
  .box[data-mode=cover] .stage::before, .box[data-mode=summary] .stage::before { padding-bottom: 0; }
  .box[data-mode=html] .stage::before, .box[data-cue] .stage::before { aspect-ratio: auto; padding: 0; height: max(300px, calc(100vh - 60px)); height: max(300px, calc(100svh - 60px)); }
  .box[data-cue] .capband, .box[data-cue] .ctl { display: none; }
  .overlay iframe { left: 0; top: 0; width: 100%; height: 100%; border-radius: 0; }
}

/* ---------- toàn màn hình ---------- */
.box:fullscreen { width: 100%; height: 100%; max-width: none; margin: 0; border: 0; border-radius: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: 0 max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); }
.box:fullscreen .stage { grid-column: 1; height: auto; aspect-ratio: auto; overflow: auto; }
.box:fullscreen .stage::before { display: none; }
.box:fullscreen[data-mode=video] .stage, .box:fullscreen video { background: var(--night); }
.box:fullscreen .capband { grid-column: 1; height: var(--band); align-self: auto; justify-content: center; padding: 6px 14px 0; }
.box:fullscreen .caption { -webkit-line-clamp: 2; text-align: center; font-size: clamp(16.5px, 1.35vw, 26px); max-width: 60ch; }
.box:fullscreen { --band: clamp(58px, 7.5vh, 96px); }
/* bìa và kết quả khi toàn màn hình: nội dung nằm trong một cột giữa trang (tối đa 1040px), chữ lớn theo màn hình.
   Không để một khối chữ nhỏ dạt về góc trái của cả màn hình. Đường lề đỏ đi theo cột đó. */
.box:fullscreen .bhead { padding: 8px 2px 12px 10px; }
.box:fullscreen .bnow { font-size: clamp(15px, 1.15vw, 20px); } .box:fullscreen .bstep { font-size: clamp(13px, 1vw, 17px); }
.box:fullscreen .segs { height: 6px; gap: 4px; }
.box:fullscreen .start, .box:fullscreen .summary { padding-left: max(9.5%, calc((100% - 1040px) / 2)); padding-right: max(5%, calc((100% - 1040px) / 2)); }
.box:fullscreen .start::before, .box:fullscreen .summary::before { left: max(5.6%, calc((100% - 1040px) / 2 - 40px)); }
.box:fullscreen .mnote { display: none; }
.fname { display: none; }   /* tên bài: ngoài toàn màn hình đã có ở tiêu đề trang */
.box:fullscreen .fname { display: block; margin: 0 0 .9em; font-size: clamp(15px, 1.2vw, 21px); font-weight: 600; color: var(--red-ink); }
.box:fullscreen .stamp { width: clamp(44px, 4vw, 72px); height: clamp(44px, 4vw, 72px); }
.box:fullscreen .start h2 { font-size: clamp(30px, 3.1vw, 58px); margin-bottom: .55em; }
.box:fullscreen .start .objs { gap: clamp(10px, 1.2vh, 18px); }
.box:fullscreen .start .objs li { font-size: clamp(17px, 1.45vw, 26px); }
.box:fullscreen .gorow { margin-top: clamp(26px, 4vh, 48px); }
.box:fullscreen .big { min-height: clamp(56px, 6.5vh, 76px); padding: 10px clamp(30px, 2.4vw, 46px); font-size: clamp(18px, 1.55vw, 27px); }
.box:fullscreen .start .facts { font-size: clamp(15px, 1.15vw, 20px); }
.box:fullscreen .meta { font-size: clamp(20px, 1.6vw, 29px); }
.box:fullscreen .summary { font-size: clamp(15.5px, 1.15vw, 20px); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
