:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --ink: #1c2230;
  --muted: #5d6678;
  --line: #e2ded2;
  --primary: #2d2a4a;
  --on-primary: #ffffff;
  --accent: #a51931;
  --ok: #1d7a4b;
  --ok-bg: #e5f4ec;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --warn-bg: #fff6cc;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 6px 20px rgba(20, 20, 40, .05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11131b;
    --surface: #1a1d28;
    --surface-2: #232736;
    --ink: #eceef4;
    --muted: #98a1b4;
    --line: #2c3144;
    --primary: #9b98ea;
    --on-primary: #14152a;
    --accent: #ff7a8f;
    --ok: #5fd39a;
    --ok-bg: #16332a;
    --bad: #ff8a80;
    --bad-bg: #3a1e1f;
    --warn-bg: #3a3413;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 750; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr { position: absolute; left: -9999px; }

/* header */
#site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 18px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary); color: var(--on-primary); font-size: .8rem; font-weight: 800;
  border-bottom: 3px solid var(--accent);
}
#nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
#nav a {
  padding: 8px 9px; border-radius: 9px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .9rem; white-space: nowrap;
}
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.menu-btn {
  display: none; margin-left: auto; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
@media (max-width: 860px) {
  .menu-btn { display: block; }
  #nav { display: none; width: 100%; margin: 0 0 12px; flex-direction: column; }
  #nav.open { display: flex; }
  #nav a { padding: 12px; }
}

main { padding: 36px 0 70px; min-height: 70vh; }
.page-head { margin-bottom: 28px; max-width: 760px; }
.eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.lead { font-size: 1.15rem; color: var(--muted); }

/* hero */
.hero { padding: 24px 0 8px; display: grid; gap: 28px; grid-template-columns: 1.3fr 1fr; align-items: center; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.hero .btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.glance {
  background: var(--primary); color: var(--on-primary); border-radius: 20px; padding: 26px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.glance::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 8px;
  background: linear-gradient(90deg, var(--accent) 0 20%, #fff 20% 40%, #2a4fa8 40% 60%, #fff 60% 80%, var(--accent) 80%);
  opacity: .9;
}
.glance h3 { opacity: .8; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; }
.glance .big { font-size: 3.4rem; font-weight: 800; line-height: 1; }
.glance .row { display: flex; gap: 26px; margin: 14px 0 18px; flex-wrap: wrap; }
.glance .row div small { display: block; opacity: .75; font-size: .82rem; }
.glance .row div b { font-size: 1.6rem; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 11px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: transform .08s, background .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.1); background: var(--primary); }
.btn.danger { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 8px 14px; font-size: .9rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: 2px; }

/* cards & grids */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
a.card { text-decoration: none; color: inherit; display: block; transition: transform .12s, border-color .12s; }
a.card:hover { transform: translateY(-3px); border-color: var(--primary); }
.card .num { font-size: .8rem; font-weight: 800; color: var(--accent); letter-spacing: .1em; }
.card h3 { margin-top: 6px; }
.card p:last-child { margin-bottom: 0; }
.section { margin-top: 48px; }
.section > h2 { margin-bottom: 16px; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-size: 1.9rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

.callout {
  border-left: 5px solid var(--accent); background: var(--surface); border-radius: 0 12px 12px 0;
  padding: 14px 18px; margin: 20px 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.callout.tip { border-left-color: var(--ok); }
.callout.warn { border-left-color: #d9a400; background: var(--warn-bg); }
.callout p:last-child { margin: 0; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 650; }

/* chips */
.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.chip-toggle { cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; }
.chip-toggle span {
  display: inline-block; padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 650; font-size: .92rem;
}
.chip-toggle input:checked + span { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip-toggle input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: 2px; }
.chip-toggle small { opacity: .7; margin-left: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.field { margin: 22px 0; }
.field > label, .field > .lab { display: block; font-weight: 700; margin-bottom: 10px; }
select, input[type="search"] {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink);
}

/* quiz */
.quiz { max-width: 760px; margin: 0 auto; }
.session-top { margin-bottom: 14px; }
.session-info { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; font-weight: 600; margin-top: 6px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .25s; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); }
.q-meta { margin-bottom: 12px; }
.q-text { font-size: 1.3rem; font-weight: 700; margin-bottom: 18px; }
.sign-frame {
  width: 150px; height: 150px; margin: 4px 0 16px; padding: 14px; border-radius: 16px;
  background: #e9eef3; display: grid; place-items: center;
}
.sign-frame svg { width: 100%; height: 100%; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; width: 100%;
  padding: 13px 16px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: var(--primary); background: var(--surface-2); }
.opt-l {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface-2); font-weight: 800; font-size: .85rem; color: var(--muted);
}
.opt.sel { border-color: var(--primary); background: var(--surface-2); }
.opt.sel .opt-l { background: var(--primary); color: var(--on-primary); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.right .opt-l { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .opt-l { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.feedback { margin-top: 18px; padding: 16px 18px; border-radius: 12px; }
.feedback.ok { background: var(--ok-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback strong { display: block; margin-bottom: 4px; }
.feedback.ok strong { color: var(--ok); }
.feedback.bad strong { color: var(--bad); }
.feedback p { margin: 0 0 12px; }
.kbd { font-size: .78rem; color: var(--muted); margin-top: 14px; text-align: center; }

.score-card { text-align: center; padding: 34px 24px; }
.score-card .big { font-size: 4rem; font-weight: 800; line-height: 1; }
.verdict { display: inline-block; margin-bottom: 10px; padding: 5px 16px; border-radius: 99px; font-weight: 800; letter-spacing: .06em; }
.verdict.pass { background: var(--ok-bg); color: var(--ok); }
.verdict.fail { background: var(--bad-bg); color: var(--bad); }
.bars { display: grid; gap: 12px; text-align: left; margin-top: 22px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 56px; gap: 12px; align-items: center; font-size: .92rem; }
.bar-row .track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.bar-row .track i.low { background: var(--accent); }
.bar-row b { text-align: right; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 1fr 70px; } .bar-row .track { grid-column: 1 / -1; order: 3; } }

.exam-bar {
  position: sticky; top: 60px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; margin-bottom: 16px;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.25rem; }
.timer.low { color: var(--bad); }
.qnav { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin-top: 20px; }
.qnav button {
  height: 40px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-weight: 700; cursor: pointer;
}
.qnav button.done { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }
.qnav button.cur { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.nav-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }

.review-item { margin-top: 14px; }
.review-item .opt { cursor: default; padding: 9px 14px; }
.review-item .q-text { font-size: 1.05rem; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--ink); font: inherit; font-weight: 650; padding: 8px 16px; cursor: pointer; }
.seg button.on { background: var(--primary); color: var(--on-primary); }

/* signs */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.toolbar input[type="search"] { flex: 1; min-width: 180px; }
.sign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.sign-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.sign-card .sign-frame { margin: 0 auto 12px; width: 120px; height: 120px; }
.sign-card h3 { font-size: 1rem; margin-bottom: 4px; }
.sign-card p { font-size: .88rem; color: var(--muted); margin: 0; }
.sign-card.flash { cursor: pointer; }
.sign-card.flash .answer { display: none; }
.sign-card.flash.shown .answer { display: block; }
.sign-card.flash:not(.shown)::after { content: "Tap to reveal"; display: block; font-size: .8rem; color: var(--muted); }
.group-title { margin: 34px 0 6px; display: flex; align-items: center; gap: 10px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* long-form */
.layout { display: grid; grid-template-columns: 210px 1fr; gap: 40px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; gap: 10px; } }
.toc { position: sticky; top: 84px; font-size: .92rem; }
.toc a { display: block; padding: 6px 12px; color: var(--muted); text-decoration: none; border-left: 2px solid var(--line); font-weight: 600; }
.toc a:hover { color: var(--ink); border-left-color: var(--primary); }
@media (max-width: 860px) { .toc { position: static; display: flex; flex-wrap: wrap; gap: 6px; } .toc a { border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; } }
.prose section { margin-bottom: 46px; scroll-margin-top: 90px; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .45em; }
.numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.numbers .stat b { font-size: 1.5rem; }
.line-demo { display: inline-block; vertical-align: middle; width: 56px; height: 0; margin-right: 8px; }
.ld-wd { border-top: 4px dashed #bbb; }
.ld-ws { border-top: 4px solid #bbb; }
.ld-ys { border-top: 4px solid #e8b800; }
.ld-yd { border-top: 4px double #e8b800; height: 4px; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps > li {
  counter-increment: s; position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px 20px 70px; box-shadow: var(--shadow);
}
.steps > li::before {
  content: counter(s); position: absolute; left: 20px; top: 20px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 800;
}
.steps h3 { margin-bottom: 4px; }
.steps p:last-child, .steps ul:last-child { margin-bottom: 0; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); cursor: pointer; }
.checklist input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.checklist input:checked + span { text-decoration: line-through; color: var(--muted); }

footer { border-top: 1px solid var(--line); padding: 28px 0 44px; color: var(--muted); font-size: .88rem; }
footer p { max-width: 760px; }

@media print { #site-header, footer, .btn { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* vehicle switch + vehicle-specific content */
.vswitch { display: inline-flex; border: 1.5px solid var(--line); border-radius: 99px; overflow: hidden; background: var(--surface); }
.vswitch button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 700; font-size: .85rem; padding: 6px 14px; cursor: pointer; }
.vswitch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
html[data-vehicle="moto"] .v-car, html[data-vehicle="car"] .v-moto { display: none !important; }
.vpick { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .vpick { grid-template-columns: 1fr; } }
.vpick button { text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.vpick button:hover { border-color: var(--primary); }
.vpick button[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-2); }
.vpick h3 { margin: 0 0 4px; }
.vpick p { margin: 0; color: var(--muted); font-size: .92rem; }
.vtag { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--accent); border-radius: 6px; padding: 2px 8px; margin-right: 6px; vertical-align: middle; }

/* donation box */
.donate { padding: 10px 0 40px; }
.donate-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); display: grid; gap: 16px; border-top: 5px solid var(--accent); }
.donate-card h2 { margin-bottom: 4px; }
.donate-card p { margin: 0; }
.amounts { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.amounts > button { min-width: 74px; padding: 12px 18px; border-radius: 11px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer; }
.amounts > button:hover { border-color: var(--primary); }
.amounts > button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.amt-custom { display: flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 11px; padding: 0 12px; background: var(--surface); }
.amt-custom:focus-within { border-color: var(--primary); }
.amt-custom span { font-weight: 800; color: var(--muted); }
.amt-custom input { border: 0; background: none; color: var(--ink); font: inherit; width: 130px; padding: 11px 0; outline: none; }
.donate-act { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.qr-box { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; padding-top: 6px; }
@media (max-width: 560px) { .qr-box { grid-template-columns: 1fr; } }
.qr { background: #fff; padding: 8px; border-radius: 12px; width: 220px; max-width: 100%; }
.qr svg { display: block; width: 100%; height: auto; }
.bank { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 12px; font-size: .92rem; }
.bank dt { color: var(--muted); }
.bank dd { margin: 0; font-weight: 700; user-select: all; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
