:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #18202b;
  --muted: #5d6876;
  --border: #dde2e8;
  --border-strong: #c4ccd6;
  --accent: #0b5cad;
  --accent-hover: #094c8f;
  --accent-soft: #e7f0fa;
  --ok: #1f7a46;
  --ok-soft: #e6f4ec;
  --bad: #b3261e;
  --bad-soft: #fbeceb;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --radius: 8px;
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px;
  --ease: 160ms ease;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #181d25;
    --surface-2: #1f2530;
    --text: #e6eaf0;
    --muted: #9aa5b3;
    --border: #2b323d;
    --border-strong: #3a4350;
    --accent: #5aa2ec;
    --accent-hover: #7cb6f1;
    --accent-soft: #1b2b3e;
    --ok: #4cc283;
    --ok-soft: #15291f;
    --bad: #f0807a;
    --bad-soft: #321a19;
    --warn: #e2b04a;
    --warn-soft: #2e2512;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text); background: var(--bg); overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--s2); }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin-top: var(--s4); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 var(--s3); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img, svg, table { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* layout */
.bar, .container { width: 100%; max-width: 1040px; margin: 0 auto; padding-left: var(--s3); padding-right: var(--s3); }
.container { flex: 1; padding-top: var(--s4); padding-bottom: var(--s6); }
.narrow { max-width: 640px; }
.narrow.center { margin: var(--s6) auto; }
.stack > * + * { margin-top: var(--s3); }
.stack > * { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: var(--s2) var(--s3); flex-wrap: wrap; }
.row p { margin: 0; }
.grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.page-head h1 { margin: 0; }
section + section { margin-top: var(--s4); }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site-header .bar { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); min-height: 56px; flex-wrap: wrap; padding-top: var(--s2); padding-bottom: var(--s2); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -0.01em; }
.nav { display: flex; gap: var(--s1) var(--s3); align-items: center; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: var(--s1) 0; transition: color var(--ease); }
.nav a:hover { color: var(--text); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 0.75rem; line-height: 20px; text-align: center; }
form.inline { display: inline; margin: 0; }
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 0.8125rem; }
.site-footer .bar { padding-top: var(--s3); padding-bottom: var(--s3); }
.site-footer p { margin: 0 0 var(--s1); }
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: var(--s2); }
.crumbs a { color: var(--muted); }

/* controls */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font: inherit; font-weight: 600; font-size: 0.9375rem; line-height: 1.2;
  padding: 10px var(--s3); min-height: 40px; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }
button.secondary, .btn.secondary { background: transparent; color: var(--accent); border-color: var(--border-strong); }
button.secondary:hover, .btn.secondary:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
button.danger { background: var(--bad); border-color: var(--bad); }
button.link { background: none; border: 0; padding: var(--s1) 0; min-height: 0; color: var(--muted); font-weight: 400; font-size: inherit; }
button.link:hover { color: var(--text); background: none; }
.small-btn { min-height: 32px; padding: 6px 12px; font-size: 0.875rem; }
input[type=text], input[type=email], input[type=date], select {
  font: inherit; color: var(--text); background: var(--surface); width: 100%; max-width: 100%;
  padding: 9px 12px; min-height: 40px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.row input, .row select { width: auto; flex: 1 1 200px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { font-weight: 600; font-size: 0.9375rem; }
.code-input { font-family: var(--mono); font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; font-weight: 400; }
.field-row input { width: auto; flex: 0 1 200px; }
.check-row { display: flex; gap: var(--s2); align-items: center; font-weight: 400; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s3); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
@media (min-width: 640px) { .card { padding: var(--s4); } }
.flash { padding: 12px var(--s3); border: 1px solid var(--accent); border-left-width: 4px; border-radius: var(--radius); background: var(--accent-soft); }
.flash.error { border-color: var(--bad); background: var(--bad-soft); }
.tag { display: inline-block; padding: 2px var(--s2); border: 1px solid var(--border-strong); border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.tag.warn, .status-Draft { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.status-Published { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.danger-zone { border-color: var(--bad); }
.empty { text-align: center; padding: var(--s5) var(--s3); }

.price-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.price-list li { display: flex; justify-content: space-between; gap: var(--s3); padding: 12px var(--s3); }
.price-list li + li { border-top: 1px solid var(--border); }
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.price.big { font-size: 1.75rem; }
.list { padding-left: 1.25rem; margin: 0; }
.list li + li { margin-top: var(--s2); }

/* dashboard */
.stats { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 0.875rem; }
.link-card { text-decoration: none; color: var(--text); transition: border-color var(--ease), background-color var(--ease); }
.link-card:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.timer h2 { margin-top: 0; }
.exam-card { display: flex; flex-direction: column; gap: var(--s2); }
.exam-card h3 a { color: var(--text); text-decoration: none; }
.exam-card h3 a:hover { color: var(--accent); }
.exam-card p { margin: 0; }
.exam-card .btn { align-self: flex-start; margin-top: auto; }
.buy-card p { margin: 0 0 var(--s2); }

.progress { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 200ms ease; }
.progress.thin { height: 4px; border: 0; margin: var(--s2) 0 var(--s3); }

/* exam page */
.sections { margin-top: var(--s3); }
.section-card { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s3); text-decoration: none; color: var(--text); transition: border-color var(--ease), background-color var(--ease); }
.section-card:hover { border-color: var(--accent); color: var(--text); }
.section-num { grid-row: span 2; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.section-title { font-weight: 600; }
.checks { display: flex; gap: var(--s2); flex-wrap: wrap; font-size: 0.8125rem; color: var(--muted); }
.check::before { content: "\25CB\00a0"; }
.check.done { color: var(--ok); }
.check.done::before { content: "\2713\00a0"; }
.score { font-variant-numeric: tabular-nums; }

/* tabs */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin: var(--s3) 0 var(--s4); overflow-x: auto; scrollbar-width: none; }
.tabs [role=tab] { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 10px var(--s3); min-height: 44px; white-space: nowrap; font-weight: 600; margin-bottom: -1px; }
.tabs [role=tab]:hover { color: var(--text); background: none; }
.tabs [role=tab][aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.panel:not([hidden]) { animation: fade 180ms ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.panel-foot { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--border); }
.pager { display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s5); flex-wrap: wrap; }

/* imported guide / example content */
.prose { max-width: 760px; }
.prose section { margin: 0 0 var(--s5); }
.prose section + section { margin-top: 0; }
.prose h2 { margin-top: var(--s2); }
.prose h3 { margin-top: var(--s3); color: var(--muted); font-size: 1rem; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: var(--s2); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; margin: 0 0 var(--s3); }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.badge { display: inline-block; margin-bottom: var(--s2); padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.accent-word { color: var(--accent); font-weight: 700; }
.bullets { list-style: none; padding-left: 0 !important; }
.bullets li { position: relative; padding-left: 1.25rem; }
.bullets li::before { content: ""; position: absolute; left: 2px; top: 0.65em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.25rem; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--accent); color: var(--accent); font-size: 0.8125rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.callout { margin: var(--s3) 0; padding: 12px var(--s3); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.callout p:last-child { margin-bottom: 0; }
.callout-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--s1); }
.code { margin: var(--s2) 0 var(--s3); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.code-head { padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.code-label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.code-body { padding: 12px; font-family: var(--mono); font-size: 0.875rem; line-height: 1.55; white-space: pre-wrap; overflow-x: auto; }
.metric { display: inline-flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; margin: var(--s2) var(--s2) var(--s2) 0; padding: var(--s2) 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 0.875rem; }
.metric b { color: var(--text); font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.divider { height: 1px; border: 0; background: var(--border); margin: var(--s4) 0; }

/* quiz + review */
.question .q { font-size: 1.0625rem; font-weight: 600; white-space: pre-wrap; }
.quiz-head { display: flex; justify-content: space-between; gap: var(--s3); }
.choices { display: flex; flex-direction: column; gap: var(--s2); margin: var(--s3) 0; }
.choice {
  justify-content: flex-start; text-align: left; width: 100%; font-weight: 400;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); padding: 12px var(--s3);
}
.choice:hover { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.choice .key { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8125rem; transition: background-color var(--ease), border-color var(--ease), color var(--ease); }
.choice.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice.selected .key { background: var(--accent); border-color: var(--accent); color: #fff; }
.choice:disabled { opacity: 1; cursor: default; }
.choice:disabled:hover { background: var(--surface); border-color: var(--border-strong); }
.choice.correct, .choice.correct:disabled:hover { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.choice.correct .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.wrong, .choice.wrong:disabled:hover { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.choice.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.explain { margin-top: var(--s3); padding: 12px var(--s3); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); background: var(--surface-2); white-space: pre-wrap; }
.explain.is-correct { border-left-color: var(--ok); }
.explain.is-wrong { border-left-color: var(--bad); }
.summary h3 { font-size: 1.25rem; }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 0.8125rem; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table form { margin: 0; }

@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  .tabs [role=tab] { padding: 10px 12px; }
}
