:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #f2f4f7;
  --brand: #0b62c1;
  --brand-hover: #094e9b;
  --brand-soft: #ebf4fd;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --bad: #b42318;
  --bad-soft: #fef3f2;
  --warn: #93370d;
  --warn-soft: #fffaeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.65 "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-underline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 20px; }
main { padding-block: 28px 56px; min-height: 72vh; outline: none; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 500; white-space: nowrap; }
.brand b { font-weight: 700; }
.logo { width: 30px; height: 30px; display: block; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 7px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a:hover { color: var(--ink); background: var(--line-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.foot { color: var(--muted); font-size: 13px; padding-block: 20px calc(20px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }

/* type */
h1 { font-size: 26px; line-height: 1.3; margin: 0 0 8px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; line-height: 1.4; margin: 0 0 8px; font-weight: 700; }
h3 { font-size: 16px; margin: 24px 0 8px; font-weight: 700; }
.page-head { margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.muted { color: var(--muted); }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: stretch; }
.grid > .card { display: flex; flex-direction: column; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; min-width: 150px; padding: 9px 18px; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.plain { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn.plain:hover { background: var(--line-2); }
.btn.block { width: 100%; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.space { justify-content: space-between; }
.push { margin-top: auto; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.callout { background: var(--brand-soft); border: 1px solid #d1e0ff; padding: 12px 16px; border-radius: 10px; margin: 16px 0; color: var(--ink-2); }
.callout.warn { background: var(--warn-soft); border-color: #fedf89; color: var(--warn); }

/* progress */
.bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.stat { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 14px; }
.stat b { font-size: 14px; }

/* home */
.hero { padding: 40px; background: #062b52; color: #fff; border-radius: 16px; margin-bottom: 16px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(10,132,255,.45), transparent 70%); }
.hero h1 { font-size: 30px; max-width: 620px; position: relative; }
.hero p { color: #bcd7f5; max-width: 600px; margin: 0 0 24px; position: relative; }
.hero .row { position: relative; }
.hero .btn { background: #fff; color: #062b52; border-color: #fff; }
.hero .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 12px; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; color: var(--ink-2); }
.steps li::before { content: counter(s); flex: 0 0 24px; height: 24px; margin-top: 1px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px; display: grid; place-items: center; }

/* lesson list (shared) */
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list a { display: grid; grid-template-columns: 26px 1fr; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); }
.lesson-list a:hover { background: var(--line-2); }
.lesson-list .num { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #d0d5dd; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--muted); background: #fff; }
.lesson-list .done .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.lesson-list .txt { min-width: 0; display: flex; flex-direction: column; }
.lesson-list .lbl { font-size: 12px; color: var(--muted); line-height: 1.3; }
.lesson-list .ttl { font-size: 14px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-list a.current { background: var(--brand-soft); color: var(--brand); }
.lesson-list a.current .ttl { font-weight: 600; }
.lesson-list a.current .num { border-color: var(--brand); color: var(--brand); }
.lesson-list .done a.current .num { color: #fff; }

/* academy */
.course-card .meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.course-card h2 { font-size: 18px; margin-bottom: 6px; }
.course-card .summary { color: var(--muted); margin: 0 0 20px; min-height: 3.3em; }
.course-card .lesson-list { margin: 18px -12px 0; padding-top: 14px; border-top: 1px solid var(--line); }

/* lesson page */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.lesson-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: stretch; }
.side { padding: 18px 12px; align-self: start; position: sticky; top: calc(80px + env(safe-area-inset-top, 0px)); }
.side-head { padding: 0 12px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.side-head b { display: block; font-size: 14px; line-height: 1.4; margin-bottom: 10px; }
.lesson-body { display: flex; flex-direction: column; min-height: 100%; padding: 32px 40px; }
.lesson-body .content { color: var(--ink-2); font-size: 15.5px; }
.lesson-body .content > :first-child { margin-top: 0; }
.lesson-body figure { margin: 16px 0; }
.lesson-body figure img { border-radius: 8px; border: 1px solid var(--line); display: block; max-height: 480px; width: auto; }
.lesson-body .figs { display: flex; gap: 12px; flex-wrap: wrap; }
.lesson-body .figs figure { flex: 1 1 220px; }
.lesson-body ol, .lesson-body ul { padding-left: 22px; }
.lesson-body li { margin: 8px 0; }
.lesson-body li::marker { color: var(--muted); }
.lesson-title { padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.doc-head { text-align: center; margin-bottom: 20px; padding: 16px; background: var(--line-2); border-radius: 10px; font-size: 14px; }
.doc-head p { margin: 4px 0; }
.doc-title { font-weight: 700; font-size: 17px; color: var(--ink); }
.source { font-size: 13px; color: var(--muted); margin: 28px 0 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
th { background: var(--line-2); font-weight: 600; }
.lesson-nav { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.lesson-nav .btn { min-width: 0; width: 100%; }
.lesson-nav.push { margin-top: auto; }
.lesson-body .source { margin-bottom: 32px; }
.lesson-nav .spacer { visibility: hidden; }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.field input { font: inherit; min-height: 44px; padding: 10px 14px; border-radius: 8px; border: 1px solid #d0d5dd; background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.field input:focus { outline: 4px solid #d1e0ff; border-color: var(--brand); }
.field.err input { border-color: #fda29b; }
.field.err input:focus { outline-color: #fee4e2; }
.field .msg { color: var(--bad); font-size: 13px; }
.form-error { color: var(--bad); font-weight: 600; margin: 8px 0; font-size: 14px; }
.narrow { max-width: 680px; margin: 0 auto; }
.rules { margin: 0; padding-left: 20px; color: var(--ink-2); }
.rules li { margin: 6px 0; }

/* exam */
.exam-head { position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); z-index: 10; background: var(--bg); padding: 12px 0; margin-bottom: 4px; }
.qcard { padding: 28px; }
.qnum { color: var(--brand); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.qtext { font-size: 17px; font-weight: 600; line-height: 1.5; margin: 8px 0 6px; }
.hint { font-size: 13px; color: var(--warn); background: var(--warn-soft); display: inline-block; padding: 2px 10px; border-radius: 6px; }
.opts { display: grid; gap: 10px; margin-top: 18px; }
.opt { display: grid; grid-template-columns: 20px 1fr; gap: 12px; align-items: start; min-height: 52px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; color: var(--ink-2); transition: border-color .15s, background .15s; }
.opt:hover { border-color: #b2c7ff; }
.opt input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--brand); }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); box-shadow: 0 0 0 1px var(--brand); }
.exam-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.exam-nav .btn { min-width: 0; width: 100%; }
.qgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-top: 14px; }
.qgrid button { aspect-ratio: 1; min-height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.qgrid button.ans { background: var(--brand-soft); color: var(--brand); border-color: #d1e0ff; }
.qgrid button.cur { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.confirm { margin-top: 14px; }

/* result */
.result-card { text-align: center; padding: 36px 28px; }
.score { font-size: 56px; font-weight: 700; line-height: 1; margin: 12px 0; letter-spacing: -.02em; }
.score small { font-size: 22px; color: var(--muted); font-weight: 600; }
.score.ok { color: var(--ok); }
.score.bad { color: var(--bad); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 420px; margin: 20px auto 0; }
.result-actions .btn { min-width: 0; width: 100%; }
.review { display: grid; gap: 12px; margin-top: 14px; }
.review .item { border-left: 3px solid var(--bad); }
.review .item.ok { border-left-color: var(--ok); }
.review dl { margin: 12px 0 0; display: grid; grid-template-columns: 120px 1fr; gap: 6px 16px; font-size: 14px; }
.review dt { font-weight: 600; color: var(--muted); }
.review dd { margin: 0; color: var(--ink-2); }

@media (max-width: 900px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .side { position: static; order: 2; }
  .lesson-body { padding: 24px 20px; }
}
@media (max-width: 600px) {
  .wrap { padding-inline: 16px; }
  main { padding-block: 20px 40px; }
  h1, .hero h1 { font-size: 22px; }
  .hero { padding: 28px 22px; }
  .hero .row .btn { flex: 1 1 140px; }
  .card { padding: 18px; }
  .qcard { padding: 20px; }
  .qgrid { grid-template-columns: repeat(6, 1fr); }
  .lesson-nav { grid-template-columns: 1fr 1fr; }
  .lesson-nav .mark { grid-column: 1 / -1; order: -1; }
  .lesson-nav .spacer { display: none; }
  .review dl { grid-template-columns: 1fr; gap: 2px; }
  .review dd { margin-bottom: 8px; }
  .nav a { padding: 7px 10px; }
  .course-card .summary { min-height: 0; }
}
