:root {
  --navy: #14213d; --navy2: #1f3057; --navy3: #2b3f6b;
  --gold: #d4a63a; --gold2: #b98b22; --goldbg: #f6eed8;
  --paper: #fbfaf6; --card: #ffffff; --ink: #14213d; --muted: #5b6475; --line: #e6e2d6;
  --green: #1f7a4d; --greenbg: #e8f5ee; --red: #b03a2e; --redbg: #fbecea;
  --blue: #2559a7; --bluebg: #eaf1fb;
  --radius: 14px; --shadow: 0 10px 30px rgba(20, 33, 61, .08);
  --serif: "Lora", "Noto Serif", Georgia, "Times New Roman", serif;
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.55; }
a { color: var(--blue); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(30px, 6vw, 48px); }
h2 { font-size: clamp(24px, 4.2vw, 32px); }
h3 { font-size: 19px; }
p { margin: 0 0 1em; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Bilingual pairs: English first, Vietnamese directly underneath */
.vi { display: block; color: var(--muted); font-size: .94em; margin-top: 2px; }
.en { display: block; }
.inline .en, .inline .vi { display: inline; }
.inline .vi::before { content: " · "; }
body.hide-vi .vi { display: none !important; }

/* Layout */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
main { min-height: 70vh; padding: 28px 0 64px; }

/* Header */
.topbar { background: var(--navy); color: #fff; }
/* Whole header sticks; it slides away while scrolling down and returns on scroll up. */
#header { position: sticky; top: 0; z-index: 30; transition: transform .25s ease; }
#header.hide { transform: translateY(-100%); }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--gold); color: var(--navy); padding: 10px 14px; border-radius: 10px; font-weight: 700; }
.skip:focus { top: 8px; }
.totop { position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 25; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--navy); color: #fff; font-size: 22px; box-shadow: 0 8px 22px rgba(20,33,61,.3); display: grid; place-items: center; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .2s, transform .2s; }
.totop.show { opacity: 1; pointer-events: auto; transform: none; }
@media (max-width: 760px) { .totop { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { font-family: var(--serif); font-size: 21px; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand b { color: var(--gold); font-weight: 600; }
.brand .seal { width: 32px; height: 32px; display: block; flex: none; }
.brand .seal svg { width: 100%; height: 100%; display: block; }
.nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.hdr-end { display: flex; align-items: center; gap: 8px; flex: none; }
.pill .ls { display: none; }
.nav a.link { color: #cfd6e6; text-decoration: none; font-size: 14px; padding: 8px 10px; border-radius: 8px; }
.nav a.link:hover, .nav a.link.active { color: #fff; background: rgba(255,255,255,.08); }
.pill { border: 1px solid var(--gold); color: var(--gold); background: transparent; border-radius: 99px; padding: 5px 11px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.on { background: var(--gold); color: var(--navy); }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--gold); background: var(--navy2); color: #fff; display: grid; place-items: center; font-size: 13px; overflow: hidden; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 24px; padding: 4px 8px; }
@media (max-width: 760px) {
  .nav a.link { display: none; }
  .menu-btn { display: block; }
  .nav.open { position: absolute; top: 60px; left: 0; right: 0; background: var(--navy); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav.open a.link { display: block; padding: 12px; }
}

.accessbar { background: var(--gold); color: var(--navy); font-size: 14px; }
.accessbar .wrap { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 8px; padding-bottom: 8px; }
.accessbar a { color: var(--navy); font-weight: 700; white-space: nowrap; }
.accessbar.expired { background: var(--red); color: #fff; }
.accessbar.expired a { color: #fff; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 20px; font-weight: 700; font-size: 16px; text-decoration: none; transition: transform .05s, background .15s; min-height: 48px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy2); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: #ddb24c; }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-light { background: rgba(255,255,255,.1); color: #fff; border: 1.5px solid rgba(255,255,255,.3); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; min-height: 36px; font-size: 14px; border-radius: 9px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-google { background: #fff; color: #1f1f1f; border: 1.5px solid #dadce0; }
.btn-google:hover { background: #f8f9fa; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.section { margin: 48px 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; color: #7d5c12; margin-bottom: 8px; display: block; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--goldbg); color: #7a5a10; }
.badge.green { background: var(--greenbg); color: var(--green); }
.badge.red { background: var(--redbg); color: var(--red); }
.badge.navy { background: var(--navy); color: #fff; }
.hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* Hero */
.hero { background: var(--navy); color: #fff; border-radius: 22px; padding: clamp(28px, 6vw, 56px); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -120px; top: -120px; width: 380px; height: 380px; border-radius: 50%; border: 1px solid rgba(212,166,58,.35); box-shadow: 0 0 0 50px rgba(212,166,58,.05), 0 0 0 110px rgba(212,166,58,.03); pointer-events: none; }
.hero h1 { color: #fff; max-width: 700px; }
.hero h1 em { color: var(--gold); font-style: normal; }
.hero .lead { color: #cfd6e6; font-size: 18px; max-width: 620px; }
.hero .vi { color: #aab4cb; }
.hero-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 26px; }
.hero-stats div { border-left: 2px solid var(--gold); padding-left: 12px; }
.hero-stats b { display: block; font-family: var(--serif); font-size: 26px; color: #fff; }
.hero-stats span { font-size: 13px; color: #aab4cb; }

/* Feature list */
.feature .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--goldbg); display: grid; place-items: center; font-size: 20px; margin-bottom: 10px; }

/* Pricing */
.plans { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); align-items: stretch; }
.plan { position: relative; display: flex; flex-direction: column; }
.plan.popular { border: 2px solid var(--gold); }
.plan .ribbon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); }
.plan .price { font-family: var(--serif); font-size: 40px; font-weight: 600; }
.plan .price small { font-size: 15px; color: var(--muted); font-family: var(--sans); font-weight: 500; }
.plan ul { padding-left: 18px; margin: 12px 0 18px; flex: 1; }
.plan li { margin: 4px 0; }
.ticks { list-style: none; padding: 0 !important; }
.ticks li::before { content: "✓"; color: var(--green); font-weight: 800; margin-right: 8px; }

/* Quiz */
.qhead { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 8px; gap: 8px; }
.progress { height: 6px; background: #e8e6de; border-radius: 9px; overflow: hidden; margin-bottom: 18px; }
.progress i { display: block; height: 100%; background: var(--navy); transition: width .2s; }
.qtext { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 0 0 4px; }
.qtext-vi { color: var(--muted); margin: 0 0 18px; }
.opt { width: 100%; text-align: left; background: #fff; border: 1.5px solid #cdc6b3; border-radius: 12px; padding: 13px 14px; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; min-height: 56px; }
.opt:hover:not([disabled]) { border-color: var(--navy3); }
.opt .key { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #eef0f5; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.opt .en { font-weight: 600; }
.opt.selected { border-color: var(--navy); background: #f3f5fa; }
.opt.selected .key { background: var(--navy); color: #fff; }
.opt.correct { border-color: var(--green); background: var(--greenbg); }
.opt.correct .key { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--redbg); }
.opt.wrong .key { background: var(--red); color: #fff; }
.opt[disabled] { cursor: default; }
.explain { border-radius: 12px; padding: 12px 14px; margin: 6px 0 14px; background: var(--goldbg); }
.explain.ok { background: var(--greenbg); }
.explain.bad { background: var(--redbg); }
.speak { background: none; border: 0; padding: 0; width: 40px; height: 40px; display: inline-grid; place-items: center; font-size: 18px; vertical-align: middle; opacity: .8; border-radius: 50%; }
.speak:hover { opacity: 1; }
.qnav { display: flex; gap: 10px; margin-top: 10px; }
.qnav .btn { flex: 1; }
.qwrap { max-width: 1040px; }
.qlayout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.qside { margin-top: 8px; }
.qside-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.qside-head { margin-bottom: 10px; gap: 8px; }
.qlegend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.qlegend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line); background: #fff; }
.lg { border-color: #b9b2a0; }
.lg.ans { background: var(--navy3); border-color: var(--navy3); }
.lg.val { box-shadow: inset 0 -4px 0 #a87b14; }
@media (min-width: 900px) {
  .qlayout { grid-template-columns: minmax(0, 1fr) 236px; gap: 28px; align-items: start; }
  .qside { margin-top: 0; position: sticky; top: 16px; }
}
/* Question grid: always 5 per row (20 questions = 4 even rows), buttons stretch to fill. */
.qside .dots { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.qside .dots button { width: 100%; height: 40px; }
@media (min-width: 900px) { .qside .dots button { height: 36px; } }
.dots { display: flex; flex-wrap: wrap; gap: 6px; }
.dots button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #b9b2a0; background: #fff; font-size: 14px; color: var(--navy); }
.dots button.ans { background: var(--navy3); border-color: var(--navy3); color: #fff; }
.dots button.cur { border: 2px solid var(--navy); font-weight: 700; }
.dots button.val { box-shadow: inset 0 -4px 0 #a87b14; }
.dots button.ans.val { box-shadow: inset 0 -4px 0 var(--gold); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--navy); }
.timer.low { color: var(--red); }
.valtag { font-size: 11px; font-weight: 700; color: #7a5a10; background: var(--goldbg); border-radius: 6px; padding: 2px 7px; }

/* Results */
.result-hero { text-align: center; padding: 28px 20px; border-radius: 18px; color: #fff; background: var(--navy); }
.result-hero.fail { background: #5b2a26; }
.scorebox { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.scorebox div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.scorebox b { font-family: var(--serif); font-size: 28px; display: block; }
.review-item { border-left: 4px solid var(--green); }
/* Results: one clear primary action, secondary actions share a row. */
.res-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 24px; }
.res-actions .btn { width: 100%; white-space: normal; min-height: 48px; }
.res-actions .primary { grid-column: 1 / -1; }
.res-actions .btn-ghost { background: #fff; }
.res-actions.two .btn-ghost { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .res-actions { grid-template-columns: 1.3fr 1fr 1fr; }
  .res-actions.two { grid-template-columns: 1.3fr 1fr; }
  .res-actions .primary, .res-actions.two .btn-ghost { grid-column: auto; }
}
.seg { display: inline-flex; background: #ece8dc; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 10px 16px; border-radius: 9px; font-weight: 600; color: var(--muted); min-height: 44px; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(20,33,61,.15); }
.review-item.bad { border-left-color: var(--red); }

/* Mock grid */
.mockgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.mock { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; text-decoration: none; color: var(--ink); position: relative; }
.mock b { display: block; font-family: var(--serif); font-size: 22px; }
.mock.passed { border-color: var(--green); background: var(--greenbg); }
.mock.tried { border-color: var(--gold); }
.mock.locked { opacity: .55; }
.mock .lock { position: absolute; top: 6px; right: 8px; font-size: 12px; }
/* Phones: 4 compact tiles per row (40 mocks = 10 rows). Untried tiles show just the number. */
@media (max-width: 600px) {
  .mockgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .mock { padding: 8px 2px 7px; border-radius: 10px; min-height: 60px; display: flex; flex-direction: column; justify-content: center; }
  .mock .mk-de { display: none; }
  .mock b { font-size: 20px; line-height: 1.15; }
  .mock .mk-st { font-size: 12px; }
  .mock:not(.passed):not(.tried) .mk-st { display: none; }
  .mock .lock { top: 2px; right: 4px; font-size: 10px; }
}
/* Account + logout appear only inside the opened phone menu (desktop uses the avatar). */
.nav .m-only { display: none; }
.nav.open .m-only { display: contents; }
.nav .logout { background: none; border: 0; text-align: left; font: inherit; font-size: 14px; color: #f3c9c0; padding: 12px; border-radius: 8px; border-top: 1px solid rgba(255,255,255,.12); margin-top: 4px; }

/* Lessons */
.lesson-sec { margin-bottom: 26px; }
.sent { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.sent:last-child { border-bottom: 0; }
.remember { background: var(--goldbg); border-left: 4px solid var(--gold); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.remember h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: #7a5a10; }
.remember ul { margin: 0; padding-left: 18px; }
.vocab { width: 100%; border-collapse: collapse; }
.vocab td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vocab td:first-child { font-weight: 700; width: 42%; }
.flash { perspective: 900px; height: 210px; cursor: pointer; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16px; display: grid; place-items: center; text-align: center; padding: 20px; font-size: 24px; font-family: var(--serif); }
.flash-front { background: var(--navy); color: #fff; }
.flash-back { background: #fff; border: 2px solid var(--gold); transform: rotateY(180deg); font-size: 21px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; border-bottom: 3px solid transparent; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--gold); }

.bar { height: 8px; background: #ebe8de; border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=number], input[type=search], textarea, select { width: 100%; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
textarea { min-height: 130px; resize: vertical; }

/* Legal */
.legal h2 { margin-top: 28px; font-size: 22px; }
.legal .blk { margin-bottom: 14px; }
.legal li { margin-left: 18px; list-style: disc; display: list-item; }
.faq-q { font-weight: 700; margin-top: 18px; }

/* Footer */
footer { background: var(--navy); color: #aab4cb; padding: 36px 0 28px; font-size: 14px; }
footer a { color: #dfe4ef; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .cols { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
footer h4 { color: var(--gold); font-family: var(--serif); font-weight: 600; margin: 0 0 8px; }
footer ul { list-style: none; margin: 0; padding: 0; }
footer li { margin: 6px 0; }

/* Admin */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: 12px; text-transform: uppercase; color: var(--muted); }
.scroll-x { overflow-x: auto; }
.stat b { display: block; font-family: var(--serif); font-size: 28px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
.locked-box { text-align: center; padding: 36px 20px; }
.locked-box .big { font-size: 42px; }

/* Compact header on phones */
@media (max-width: 760px) {
  .brand { font-size: 18px; }
  .brand .seal { width: 28px; height: 28px; }
  .pill { padding: 4px 8px; font-size: 11px; }
  .hdr-end .btn-sm { white-space: nowrap; padding: 7px 11px; }
}
.btn { white-space: nowrap; }
@media (max-width: 420px) { .btn { white-space: normal; } }
@media (max-width: 400px) {
  .brand { font-size: 16px; gap: 7px; }
  .brand .seal { width: 26px; height: 26px; }
  .topbar .nav { gap: 6px; }
  .menu-btn { padding: 4px 4px 4px 6px; }
}
/* Phones: brand + EN/VI toggle + login/avatar + a large ☰ — the language toggle is always one tap away. */
@media (max-width: 600px) {
  .topbar .wrap { gap: 8px; }
  .brand { min-width: 0; }
  .brand > span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .nav:not(.open) { display: none; }
  .hdr-end { gap: 6px; }
  .hdr-end .btn-sm { padding: 7px 10px; font-size: 13px; }
  .pill { min-height: 34px; padding: 4px 10px; font-size: 12px; }
  .pill .lf { display: none; }
  .pill .ls { display: inline; }
  .menu-btn { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; margin-right: -6px; flex: none; font-size: 26px; line-height: 1; }
}

/* Pre-rendered static pages (SEO) */
.seo-static { padding-top: 28px; padding-bottom: 40px; }
.seo-static h1 { font-size: 30px; }
.seo-static h2 { font-size: 21px; margin-top: 24px; }
.seo-static ul, .seo-static ol { padding-left: 20px; }
.seo-qs { list-style: decimal; }
.seo-qs > li.card { padding: 16px; }
.seo-qs details { margin-top: 8px; }
.seo-qs summary { cursor: pointer; font-weight: 600; color: var(--navy); min-height: 44px; display: flex; align-items: center; }
.seo-qs ul { list-style: none; padding-left: 0; }
.seo-qs ul li { margin: 8px 0; }
