/* ---------- Tokens ---------- */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --text: #1f1d18;
  --muted: #6b665b;
  --line: #e3ddd0;
  --accent: #4338ca;
  --accent-2: #6d5efc;
  --accent-soft: #ebe9fe;
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(30, 25, 10, .05), 0 6px 20px rgba(30, 25, 10, .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131a; --surface: #1d1c25; --surface-2: #262532; --text: #ecebf3; --muted: #a09eb0; --line: #34323f;
    --accent: #8b83ff; --accent-2: #a79fff; --accent-soft: #2a2750; --on-accent: #12111a;
    --ok: #4ade80; --ok-soft: #173a26; --bad: #f87171; --bad-soft: #451d1d; --warn: #fbbf24; --warn-soft: #3d3215;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14131a; --surface: #1d1c25; --surface-2: #262532; --text: #ecebf3; --muted: #a09eb0; --line: #34323f;
  --accent: #8b83ff; --accent-2: #a79fff; --accent-soft: #2a2750; --on-accent: #12111a;
  --ok: #4ade80; --ok-soft: #173a26; --bad: #f87171; --bad-soft: #451d1d; --warn: #fbbf24; --warn-soft: #3d3215;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 'Be Vietnam Pro', system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 .6em; }
kbd { font: 600 .75em/1 ui-monospace, monospace; padding: 2px 5px; border: 1px solid currentColor; border-radius: 4px; opacity: .7; }
textarea { width: 100%; min-height: 120px; resize: vertical; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--accent); margin-bottom: .3em; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 60ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width .4s; }
.bar.low i { background: var(--warn); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 12px; padding: 10px 18px; font: 600 .95rem/1.2 inherit; font-family: inherit;
  background: var(--accent); color: var(--on-accent); cursor: pointer; transition: transform .15s, opacity .15s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btn.lg { padding: 14px 26px; font-size: 1.05rem; }
.btn.good { background: var(--ok); color: #fff; }
.btn.bad { background: var(--surface); color: var(--bad); border: 1px solid var(--bad); }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1080px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { padding: 12px 0; display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.reset-btn { font: 600 .75rem/1 inherit; font-family: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.reset-btn:hover { color: var(--bad); border-color: var(--bad); }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: .8rem; font-weight: 800; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: end; margin: 16px 0 24px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin-bottom: 24px; }
.phase { margin: 32px 0; }
.phase-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lesson-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.lesson-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.lesson-card .num { font-size: .75rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.lesson-card h3 { margin: 0; }
.lesson-card p { font-size: .9rem; margin: 0; flex: 1; }
.steps { display: flex; gap: 4px; margin: 6px 0 2px; }
.steps span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font-size: .85rem; filter: grayscale(1); opacity: .5; }
.steps span.on { filter: none; opacity: 1; background: var(--accent-soft); }
.lesson-card.pending { box-shadow: none; background: transparent; border-style: dashed; opacity: .7; }
.lesson-card.pending:hover { transform: none; border-color: var(--line); }
.lesson-card.pending .badge { align-self: flex-start; }
.test-card.locked { opacity: .55; pointer-events: none; }
.test-card { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border-style: dashed; }
.test-card .badge { align-self: flex-start; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Lesson ---------- */
.crumb { display: flex; gap: 8px; font-size: .85rem; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.lesson-head { margin-bottom: 18px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 20px; scrollbar-width: thin; }
.tab { position: relative; display: flex; align-items: center; gap: 6px; white-space: nowrap; padding: 9px 14px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: .92rem; border: 1px solid transparent; }
.tab:hover { background: var(--surface); }
.tab.active { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow); }
.tick { font-style: normal; font-size: .7rem; color: #fff; background: var(--ok); width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
.pane { min-height: 300px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; flex-wrap: wrap; }

/* ---------- Video player ---------- */
.player { background: #0f0d24; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.player:fullscreen { display: flex; flex-direction: column; justify-content: center; border-radius: 0; }
.stage { position: relative; aspect-ratio: 16 / 9; overflow: hidden; color: #fff; background: radial-gradient(120% 120% at 0% 0%, #312e81 0%, #1e1b4b 45%, #0f0d24 100%); }
.player:fullscreen .stage { aspect-ratio: auto; flex: 1; }
.bg i { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .55; animation: float 14s ease-in-out infinite alternate; }
.bg i:nth-child(1) { width: 40%; height: 55%; background: #7c3aed; left: -8%; top: -10%; }
.bg i:nth-child(2) { width: 35%; height: 50%; background: #0ea5e9; right: -6%; bottom: -15%; animation-delay: -5s; }
.bg i:nth-child(3) { width: 22%; height: 30%; background: #f59e0b; right: 25%; top: 10%; opacity: .25; animation-delay: -9s; }
@keyframes float { to { transform: translate(8%, 10%) scale(1.15); } }
.scene { position: absolute; inset: 0; display: grid; place-items: center; padding: 5% 7%; container-type: inline-size; }
.sc { width: 100%; }
.scene.in .a { animation: rise .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * .55s + .1s); }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.97); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.sc-h { font-size: clamp(1rem, 3.6cqi, 2rem); margin-bottom: 3cqi; color: #fff; }
.sc-title { text-align: center; }
.sc-title .sc-kicker { color: #c4b5fd; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: clamp(.7rem, 1.8cqi, 1rem); }
.sc-title h2 { font-size: clamp(1.4rem, 6cqi, 3.6rem); font-weight: 800; letter-spacing: -.02em; }
.sc-title .sub { font-size: clamp(.85rem, 2.4cqi, 1.3rem); color: #cbd5e1; }
.sc-bullets ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.6cqi; }
.sc-bullets li { display: flex; gap: 2cqi; align-items: center; font-size: clamp(.85rem, 2.6cqi, 1.45rem); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); padding: 1.4cqi 2.2cqi; border-radius: 1.6cqi; }
.sc-bullets .ico { font-size: 1.3em; }
.letters { display: flex; gap: 1.6cqi; justify-content: center; flex-wrap: wrap; }
.sc-acronym .sc-h { text-align: center; }
.sc-acronym .letter { flex: 1 1 0; min-width: 0; text-align: center; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: 2cqi; padding: 2cqi 1cqi; display: flex; flex-direction: column; gap: .5cqi; }
.sc-acronym .letter b { font-size: clamp(1.6rem, 8cqi, 5rem); line-height: 1; background: linear-gradient(135deg, #fde68a, #f472b6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sc-acronym .letter strong { font-size: clamp(.7rem, 2.2cqi, 1.2rem); }
.sc-acronym .letter small { font-size: clamp(.6rem, 1.6cqi, .9rem); color: #cbd5e1; line-height: 1.35; }
.sc-compare .cols { display: grid; grid-template-columns: 1fr auto 1fr; gap: 2cqi; align-items: stretch; }
.sc-compare .col { border-radius: 2cqi; padding: 2.2cqi; }
.sc-compare .col.left { background: rgba(148,163,184,.15); border: 1px solid rgba(148,163,184,.3); }
.sc-compare .col.right { background: rgba(167,139,250,.2); border: 1px solid rgba(167,139,250,.5); }
.sc-compare h4 { font-size: clamp(.85rem, 2.6cqi, 1.4rem); margin-bottom: 1cqi; }
.sc-compare ul { margin: 0; padding-left: 1.2em; font-size: clamp(.7rem, 2cqi, 1.1rem); display: grid; gap: .6cqi; }
.sc-compare .vs { align-self: center; font-size: clamp(1.2rem, 5cqi, 3rem); color: #fde68a; }
.flow { display: flex; gap: 1.4cqi; align-items: stretch; }
.flow .step { flex: 1; position: relative; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: 1.8cqi; padding: 1.8cqi 1.4cqi; text-align: center; }
.flow .step span { display: inline-grid; place-items: center; width: 5cqi; height: 5cqi; min-width: 22px; min-height: 22px; border-radius: 50%; background: #a78bfa; color: #1e1b4b; font-weight: 800; font-size: clamp(.7rem, 2cqi, 1.1rem); margin-bottom: 1cqi; }
.flow .step p { margin: 0; font-size: clamp(.62rem, 1.8cqi, 1.05rem); line-height: 1.35; }
.sc-quote { text-align: center; }
.sc-quote blockquote { margin: 0; font-size: clamp(1.1rem, 4.4cqi, 2.6rem); font-weight: 700; line-height: 1.3; }
.sc-quote .by { color: #c4b5fd; margin-top: 2cqi; font-size: clamp(.8rem, 2cqi, 1.1rem); }
.sc-stat { text-align: center; }
.sc-stat .big { font-size: clamp(3rem, 16cqi, 9rem); font-weight: 800; line-height: 1; background: linear-gradient(135deg, #fde68a, #f472b6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sc-stat p { font-size: clamp(.9rem, 2.6cqi, 1.4rem); color: #e2e8f0; }
.pbar { height: 4px; background: rgba(255,255,255,.12); }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a78bfa, #f472b6); }
.controls { display: flex; align-items: center; gap: 6px; padding: 10px 12px; color: #fff; }
.icon-btn { background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 10px; width: 38px; height: 38px; font-size: 1rem; cursor: pointer; }
.icon-btn.big { width: 46px; height: 46px; font-size: 1.1rem; background: #fff; color: #1e1b4b; border-radius: 50%; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.dots { flex: 1; display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.dots button { width: 9px; height: 9px; padding: 0; border-radius: 99px; border: 0; background: rgba(255,255,255,.3); cursor: pointer; transition: width .25s; }
.dots button.on { width: 26px; background: #fff; }
.caption { margin: 0; padding: 4px 18px 16px; color: #cbd5e1; font-size: .95rem; min-height: 3.2em; }
#vnote { margin-top: 10px; }

/* ---------- Chips (mục lục, chủ đề, bài ghép cặp) ---------- */
.chips, .toc { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; }
.toc { position: sticky; top: 58px; z-index: 4; flex-wrap: nowrap; overflow-x: auto; padding: 8px 0; background: var(--bg); scrollbar-width: thin; }
.chip { flex: none; font: 600 .82rem/1.2 inherit; font-family: inherit; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip span { opacity: .7; font-weight: 500; margin-left: 2px; }

/* ---------- Summary: mỗi phần là 1 hàng ngang ---------- */
.sections { display: grid; gap: 12px; margin: 8px 0 20px; }
.sec { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; scroll-margin-top: 120px; }
.sec-head { position: relative; padding-left: 38px; }
.sec-head .kp-n { position: absolute; left: 0; top: 0; }
.sec-head h3 { margin-bottom: 6px; }
.sec-head { cursor: pointer; }
.sec-head h3::after { content: '▾'; margin-left: 8px; font-size: .8em; color: var(--muted); display: inline-block; transition: transform .2s; }
.sec.open .sec-head h3::after { transform: rotate(180deg); }
.sec-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.sec-tools { display: flex; gap: 8px; justify-content: flex-end; margin: 4px 0 -2px; }
/* Trạng thái đóng: chỉ tiêu đề + ý chính; mở: nội dung chi tiết */
.sec-brief { min-width: 0; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.sec-keys { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sec-keys li { background: var(--accent-soft); border-radius: 999px; padding: 4px 12px; font-size: .86rem; font-weight: 600; }
.sec-more { border: 0; background: none; padding: 0; color: var(--accent); font: 600 .88rem/1.2 inherit; font-family: inherit; cursor: pointer; }
.sec-body .sec-more { margin-top: 4px; }
.sec .sec-body, .sec.open .sec-brief { display: none; }
.sec.open .sec-body { display: block; }
.sec-body { font-size: .95rem; min-width: 0; }
.sec-body > :last-child { margin-bottom: 0; }
.sec-body ul { margin: 0 0 .6em; padding-left: 1.2em; display: grid; gap: 4px; }
.sec-body ul ul { margin: 4px 0 0; color: var(--muted); }
.ex { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; font-size: .9rem; }
.note { background: var(--warn-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; font-size: .9rem; }
.tbl { overflow-x: auto; margin: 0 0 .6em; border: 1px solid var(--line); border-radius: 10px; }
.tbl table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { background: var(--accent-soft); text-align: left; font-weight: 700; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }

/* ---------- Gạch đầu dòng có phần "Kiến thức đi kèm" ---------- */
.sec-body ul.pts { list-style: none; padding-left: 0; gap: 8px; }
.pts > li { position: relative; padding-left: 18px; }
.pts > li::before { content: ''; position: absolute; left: 4px; top: .65em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.pts > li.has-more::before { display: none; }
.pts details { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); margin-left: -18px; }
.pts summary { list-style: none; cursor: pointer; padding: 8px 12px 8px 34px; position: relative; }
.pts summary::-webkit-details-marker { display: none; }
.pts summary::before { content: '+'; position: absolute; left: 10px; top: 8px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font: 700 12px/16px ui-monospace, monospace; text-align: center; }
.pts details[open] summary::before { content: '−'; }
.pts summary:hover { color: var(--accent); }
.pts summary ul { margin: 4px 0 0; color: var(--muted); }
.more { padding: 4px 14px 10px 34px; border-top: 1px dashed var(--line); font-size: .9rem; }
.more-h { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 8px 0 4px; }
.more ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; }

/* ---------- Video file ---------- */
.player.file video { display: block; width: 100%; max-height: 75vh; background: #000; }

/* ---------- Summary ---------- */
.intro { font-size: 1.08rem; background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 14px 18px; border-radius: 0 12px 12px 0; }
.kp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 18px 0; }
.kp { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 14px; }
.kp-n { position: absolute; top: -10px; left: 14px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: .8rem; }
.kp h3 { margin-top: 4px; }
.kp p { color: var(--muted); font-size: .93rem; margin: 0; }
.mnemonic { background: linear-gradient(135deg, #1e1b4b, #312e81); color: #fff; border-radius: 18px; padding: 22px; margin: 22px 0; }
.mnemonic .kicker { color: #c4b5fd; }
.mnemonic .letters { gap: 10px; }
.mnemonic .letter { flex: 1 1 120px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: 14px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.mnemonic .letter b { font-size: 2.2rem; line-height: 1; background: linear-gradient(135deg, #fde68a, #f472b6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mnemonic .letter small { color: #cbd5e1; line-height: 1.4; }
.mnemonic .hook { margin: 14px 0 0; color: #fde68a; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }

/* ---------- Flashcards ---------- */
.cards { max-width: 620px; margin: 0 auto; }
.flash { position: relative; height: 300px; perspective: 1200px; cursor: pointer; margin: 10px 0 16px; }
.flash .face { position: absolute; inset: 0; border-radius: 20px; padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  backface-visibility: hidden; transition: transform .55s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow); }
.flash .front { background: var(--surface); border: 1px solid var(--line); }
.flash .front p { font-size: 1.35rem; font-weight: 700; }
.flash .front small { color: var(--muted); position: absolute; bottom: 16px; }
.flash .back { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; transform: rotateY(180deg); }
.flash .back p { font-size: 1.08rem; }
.flash.flipped .front { transform: rotateY(-180deg); }
.flash.flipped .back { transform: rotateY(0); }
.tag { position: absolute; top: 16px; left: 16px; font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.grade { display: flex; justify-content: center; gap: 12px; transition: opacity .2s; }
.grade.hide { opacity: 0; pointer-events: none; }
.boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 24px; }
.bx { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: 8px 4px; }
.bx b { display: block; font-size: 1.2rem; color: var(--accent); }
.bx.new b { color: var(--warn); }
.bx span { font-size: .7rem; color: var(--muted); }
.empty { max-width: 620px; margin: 0 auto; }

/* ---------- Matching ---------- */
.match-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; margin: 12px 0; }
.mcol { display: grid; gap: 8px; align-content: start; }
.mcell { text-align: left; font: inherit; font-size: .93rem; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; transition: all .15s; }
.mcell:hover { border-color: var(--accent); }
.mcell.sel { border-color: var(--accent); background: var(--accent-soft); }
.mcell.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); opacity: .75; cursor: default; }
.mcell.bad { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.done-box { background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; justify-content: space-between; font-weight: 600; }

/* ---------- Options (scenario + quiz) ---------- */
.opts { display: grid; gap: 8px; margin: 12px 0 4px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; font: inherit; font-size: .95rem; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .key { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: .8rem; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .key { background: var(--accent); color: var(--on-accent); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .key { background: var(--ok); color: #fff; }
.opt.incorrect { border-color: var(--bad); background: var(--bad-soft); }
.opt.incorrect .key { background: var(--bad); color: #fff; }
.opt.dim { opacity: .55; }
.opt:disabled { cursor: default; }
.scens { display: grid; gap: 16px; }
.situ { font-size: 1.02rem; }
.ask { font-weight: 700; }
.fb { border-radius: 12px; padding: 12px 16px; margin-top: 10px; font-size: .93rem; }
.fb.good { background: var(--ok-soft); }
.fb.warn { background: var(--warn-soft); }
.take { font-weight: 600; }

/* ---------- Quiz ---------- */
.quiz { display: grid; gap: 14px; max-width: 780px; margin: 0 auto; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.q h4 { font-size: 1.05rem; }
.q.right { border-color: var(--ok); }
.q.wrong { border-color: var(--bad); }
.q-n { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.explain { margin: 10px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); font-size: .92rem; }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.result-line { margin: 0; font-size: 1.05rem; }
.result-line.ok { color: var(--ok); }
.result-line.warn { color: var(--warn); }

/* ---------- Phase test ---------- */
.test-intro { max-width: 680px; margin: 0 auto; }
.rules { list-style: none; padding: 0; margin: 16px 0 22px; display: grid; gap: 8px; }
.hist { width: 100%; border-collapse: collapse; font-size: .9rem; }
.hist td { padding: 8px 4px; border-top: 1px solid var(--line); }
.test { max-width: 780px; margin: 0 auto; display: grid; gap: 14px; }
.test-bar { position: sticky; top: 60px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); }
.clock { font: 700 1.2rem/1 ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.clock.low { color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .4; } }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; }
.qnav button { width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: 600 .85rem inherit; font-family: inherit; cursor: pointer; }
.qnav button.done { background: var(--accent-soft); border-color: var(--accent-soft); }
.qnav button.cur { border-color: var(--accent); }
.test-nav { display: flex; justify-content: space-between; }
.result { max-width: 780px; margin: 0 auto 24px; text-align: center; }
.score-ring { --p: 0; width: 160px; height: 160px; margin: 12px auto 16px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring, var(--accent)) calc(var(--p) * 1%), var(--surface-2) 0); }
.result.pass .score-ring { --ring: var(--ok); }
.result.fail .score-ring { --ring: var(--warn); }
.score-ring > div { width: 128px; height: 128px; border-radius: 50%; background: var(--surface); display: grid; place-content: center; }
.score-ring b { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.score-ring span { font-size: .85rem; color: var(--muted); }
.breakdown { display: grid; gap: 10px; margin: 12px 0 20px; text-align: left; }
.br { display: grid; grid-template-columns: minmax(0, 1.5fr) 1fr auto 70px; gap: 12px; align-items: center; font-size: .92rem; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.review-h { max-width: 780px; margin: 0 auto 12px; }
.result ~ .q { max-width: 780px; margin: 0 auto 12px; }

/* ---------- Cheat sheet ---------- */
.cheat-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.cheat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cheat-item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; break-inside: avoid; }
.cheat-item h2 { font-size: 1.05rem; display: flex; gap: 8px; align-items: center; }
.cheat-item h2 span { min-width: 24px; padding: 0 6px; height: 24px; border-radius: 99px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: .8rem; flex: none; }
.cheat-item ul { margin: 0; padding-left: 1.1em; font-size: .88rem; display: grid; gap: 4px; }
.cheat-mn { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .85rem; padding-top: 8px; border-top: 1px dashed var(--line); }
.cheat-mn b { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .phase-head, .cheat-head { flex-direction: column; align-items: flex-start; }
  .two-col, .match-grid, .sec { grid-template-columns: 1fr; }
  .sec { gap: 10px; padding: 16px; }
  .boxes { grid-template-columns: repeat(3, 1fr); }
  .flash { height: 260px; }
  .br { grid-template-columns: 1fr auto; }
  .br .bar { grid-column: 1 / -1; grid-row: 2; }
  .controls { flex-wrap: wrap; }
  .dots { order: 5; flex-basis: 100%; }
  .lesson-nav .btn { flex: 1; justify-content: center; }
}

/* ---------- Print (cheat sheet) ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #bbb; }
  .no-print, .topbar { display: none !important; }
  body { font-size: 11pt; }
  .wrap { padding: 0; max-width: none; }
  .cheat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cheat-item { box-shadow: none; padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
