/* Back to the Database — course stylesheet
   Tokens first (light), dark overrides below. Components use tokens only. */

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #e9edf1;
  --ink: #1a2330;
  --ink-2: #3d4a58;
  --muted: #64717f;
  --line: #d5dce3;
  --line-strong: #b9c3cd;
  --accent: #0e7c86;
  --accent-ink: #ffffff;
  --accent-soft: #dff2f3;
  --amber: #b8730a;
  --amber-soft: #fbf0d8;
  --violet: #5d4fc2;
  --violet-soft: #e8e5f8;
  --red: #b23a3a;
  --red-soft: #f8e2e2;
  --green: #2f7d4a;
  --green-soft: #e0f1e5;
  --mysql: #00758f;
  --mysql-soft: #dbeef2;
  --pg: #336791;
  --pg-soft: #e1eaf3;
  --code-bg: #f6f8fa;
  --code-kw: #7a2e9e;
  --code-str: #1b6b2a;
  --code-num: #a35600;
  --code-cmt: #7a8590;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 8px 24px -12px rgba(20, 30, 40, .18);
  --radius: 10px;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --sidebar-w: 290px;
  --measure: 70ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f141a;
    --surface: #161d25;
    --surface-2: #1f2933;
    --ink: #e7ecf1;
    --ink-2: #c3ccd5;
    --muted: #97a3af;
    --line: #2a353f;
    --line-strong: #3b4854;
    --accent: #3fb7c1;
    --accent-ink: #06272a;
    --accent-soft: #123b3f;
    --amber: #e2a63a;
    --amber-soft: #3a2c10;
    --violet: #a89cff;
    --violet-soft: #272247;
    --red: #f08a8a;
    --red-soft: #3d1d1d;
    --green: #6fcf8f;
    --green-soft: #173324;
    --mysql: #4fb6cc;
    --mysql-soft: #0f3038;
    --pg: #7fa8d3;
    --pg-soft: #182a3c;
    --code-bg: #10161c;
    --code-kw: #c79bff;
    --code-str: #8fd49b;
    --code-num: #f0b36b;
    --code-cmt: #7d8a96;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141a;
  --surface: #161d25;
  --surface-2: #1f2933;
  --ink: #e7ecf1;
  --ink-2: #c3ccd5;
  --muted: #97a3af;
  --line: #2a353f;
  --line-strong: #3b4854;
  --accent: #3fb7c1;
  --accent-ink: #06272a;
  --accent-soft: #123b3f;
  --amber: #e2a63a;
  --amber-soft: #3a2c10;
  --violet: #a89cff;
  --violet-soft: #272247;
  --red: #f08a8a;
  --red-soft: #3d1d1d;
  --green: #6fcf8f;
  --green-soft: #173324;
  --mysql: #4fb6cc;
  --mysql-soft: #0f3038;
  --pg: #7fa8d3;
  --pg-soft: #182a3c;
  --code-bg: #10161c;
  --code-kw: #c79bff;
  --code-str: #8fd49b;
  --code-num: #f0b36b;
  --code-cmt: #7d8a96;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; margin: 0; color: var(--ink); }
h1 { font-size: clamp(2rem, 1.4rem + 2.2vw, 2.9rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.55rem; font-weight: 700; margin-top: 2.6rem; margin-bottom: .8rem; padding-top: .4rem; }
h3 { font-size: 1.18rem; font-weight: 600; margin-top: 1.8rem; margin-bottom: .5rem; }
h4 { font-size: 1rem; font-weight: 600; margin-top: 1.2rem; margin-bottom: .3rem; }
p, ul, ol, dl { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin-bottom: .35rem; }
li > ul, li > ol { margin-top: .35rem; margin-bottom: .2rem; }
strong { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
small, .small { font-size: .875rem; }
.muted { color: var(--muted); }
.eyebrow {
  font-family: var(--font-body);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .6rem;
}
.lead { font-size: 1.15rem; color: var(--ink-2); line-height: 1.55; margin: .9rem 0 0; max-width: var(--measure); }

/* ---------- shell layout ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.content {
  padding-block: 44px 80px;
  padding-inline: clamp(20px, 5vw, 72px);
  min-width: 0;
}
.prose { max-width: var(--measure); }
.prose > *:first-child { margin-top: 0; }
.chapter-head { max-width: var(--measure); margin-bottom: 2rem; padding-bottom: 1.6rem; border-bottom: 1px solid var(--line); }

/* ---------- sidebar internals ---------- */
.brand { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand__sub { font-size: .78rem; color: var(--muted); }
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress__bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.progress__text { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.search { position: relative; }
.search input {
  width: 100%;
  font: inherit;
  font-size: .9rem;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.nav { display: flex; flex-direction: column; gap: 14px; }
.nav__part { display: flex; flex-direction: column; gap: 2px; }
.nav__part-title { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px 10px; }
.nav__link {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: .92rem;
  line-height: 1.3;
}
.nav__link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav__link.is-active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.nav__mark {
  width: 16px; height: 16px; margin-top: 2px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 10px; color: var(--accent-ink);
}
.nav__link.is-done .nav__mark { background: var(--accent); border-color: var(--accent); }
.nav__link.is-done .nav__mark::after { content: "✓"; font-weight: 700; }
.nav__link.is-hidden { display: none; }
.nav__part.is-empty { display: none; }
.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; cursor: pointer; font-size: .85rem; color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-ghost svg { width: 15px; height: 15px; }

/* ---------- mobile topbar ---------- */
.topbar {
  display: none;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar__title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 39; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    width: min(320px, 88vw);
    transform: translateX(-104%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  .content { padding-block: 28px 64px; padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .progress__fill { transition: none; }
}

/* ---------- content components ---------- */
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px 4px;
  margin: 1.4rem 0;
}
.callout__label {
  font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .4rem;
}
.callout p:last-child, .callout ul:last-child, .callout ol:last-child { margin-bottom: .8rem; }
.callout--remember { border-color: var(--amber); background: var(--amber-soft); }
.callout--remember .callout__label { color: var(--amber); }
.callout--dba { border-color: var(--accent); background: var(--accent-soft); }
.callout--ai { border-color: var(--violet); background: var(--violet-soft); }
.callout--ai .callout__label { color: var(--violet); }
.callout--warn { border-color: var(--red); background: var(--red-soft); }
.callout--warn .callout__label { color: var(--red); }
.callout--note { border-color: var(--line-strong); background: var(--surface-2); }
.callout--note .callout__label { color: var(--muted); }

/* the short version box at the top of every chapter */
.tldr {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 14px 18px 16px;
  margin: 0 0 1.8rem;
}
.tldr__label {
  font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .5rem;
}
.tldr ul { margin: 0; padding-left: 1.15rem; }
.tldr li { margin-bottom: .3rem; line-height: 1.45; }
.tldr li:last-child { margin-bottom: 0; }
.tldr strong { color: var(--ink); }

.badge {
  display: inline-block; vertical-align: middle;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; line-height: 1.5;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge--mysql { background: var(--mysql-soft); color: var(--mysql); }
.badge--pg { background: var(--pg-soft); color: var(--pg); }
.badge--both { background: var(--green-soft); color: var(--green); }

/* code */
code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--surface-2);
  padding: .1em .4em;
  border-radius: 5px;
}
pre {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: .86rem;
  line-height: 1.55;
  tab-size: 2;
}
pre code { background: none; padding: 0; font-size: inherit; }
figure.code { margin: 1.2rem 0; position: relative; }
figure.code figcaption {
  font-family: var(--font-body);
  font-size: .74rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.copy-btn {
  position: absolute; top: 28px; right: 8px;
  font-size: .72rem; padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
figure.code:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
figure.code.no-caption .copy-btn { top: 8px; }
.tok-kw { color: var(--code-kw); font-weight: 600; }
.tok-str { color: var(--code-str); }
.tok-num { color: var(--code-num); }
.tok-cmt { color: var(--code-cmt); font-style: italic; }

/* tables */
.table-wrap { overflow-x: auto; margin: 1.2rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
table.data { font-family: var(--font-mono); font-size: .82rem; font-variant-numeric: tabular-nums; }
table.data th { font-family: var(--font-body); }
table.data td.null { color: var(--muted); font-style: italic; }
table.data tr.hl td { background: var(--amber-soft); }
table.cap td:nth-child(2), table.cap td:nth-child(3) { min-width: 160px; }
.yes, .no, .partial { display: inline-block; font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.yes { background: var(--green-soft); color: var(--green); }
.no { background: var(--red-soft); color: var(--red); }
.partial { background: var(--amber-soft); color: var(--amber); }

/* side-by-side example tables */
.tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 1.2rem 0; }
.tables .table-wrap { margin: 0; }
.tables figure { margin: 0; }
.tables figcaption, .table-title { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin: 0 0 6px; }

/* steps (real sequences only) */
ol.steps { list-style: none; padding: 0; margin: 1.2rem 0; counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 12px 16px 12px 56px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 14px; top: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
}
ol.steps > li > p:last-child, ol.steps > li > figure:last-child, ol.steps > li > ul:last-child { margin-bottom: 0; }
ol.steps > li > figure.code { margin: .8rem 0 0; }
ol.steps > li > strong:first-child { display: block; margin-bottom: .2rem; }

/* definitions */
dl.terms { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 1.2rem 0; }
dl.terms > div { display: contents; }
dl.terms > div[hidden] { display: none !important; }
dl.terms dt { font-weight: 600; color: var(--ink); }
dl.terms dt a { color: inherit; text-decoration: none; }
dl.terms dd .where { display: block; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.glossary-group { margin-top: 1.6rem; }
.glossary-group h2 { font-size: 1.1rem; margin-top: 0; color: var(--muted); letter-spacing: .06em; }
dl.terms dd { margin: 0; color: var(--ink-2); }
@media (max-width: 560px) { dl.terms { grid-template-columns: 1fr; gap: 2px 0; } dl.terms dd { margin-bottom: 10px; } }

/* figures / diagrams */
figure.figure { margin: 1.4rem 0; }
figure.figure svg { display: block; width: 100%; height: auto; }
figure.figure figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.diagram-wrap { overflow-x: auto; }

/* key/value grid */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 1.2rem 0; }
.kv > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kv .k { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.kv .v { margin: 0; font-size: .95rem; }

/* comparison two-up */
.twoup { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 1.2rem 0; }
.twoup > div { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.twoup h4 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.twoup > div > :last-child { margin-bottom: 0; }

/* quiz */
.quiz { margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--line); max-width: var(--measure); }
.quiz h2 { margin-top: 0; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; }
.q__text { font-weight: 600; margin: 0 0 10px; }
.q__opts { display: flex; flex-direction: column; gap: 8px; }
.q__opt {
  text-align: left; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); cursor: pointer; line-height: 1.4;
}
.q__opt:hover { border-color: var(--line-strong); }
.q__opt.is-right { border-color: var(--green); background: var(--green-soft); }
.q__opt.is-wrong { border-color: var(--red); background: var(--red-soft); }
.q.is-answered .q__opt { cursor: default; }
.q.is-answered .q__opt:not(.is-right):not(.is-wrong) { opacity: .6; }
.q__why { margin: 10px 0 0; font-size: .92rem; color: var(--ink-2); padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }

/* chapter footer */
.chapter-foot { max-width: var(--measure); margin-top: 3rem; display: flex; flex-direction: column; gap: 16px; }
.done-btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.done-btn.is-done { background: transparent; color: var(--accent); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: var(--ink);
}
.pager a:hover { border-color: var(--accent); }
.pager a.next { text-align: right; align-items: flex-end; }
.pager .pager__label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pager .pager__title { font-weight: 600; font-size: .95rem; }
.pager a.is-empty { visibility: hidden; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager a.next { text-align: left; align-items: flex-start; } }

/* home page */
.home-hero { max-width: 62ch; margin-bottom: 2.4rem; }
.home-hero h1 { font-size: clamp(2.3rem, 1.6rem + 3vw, 3.6rem); }
.home-hero .lead { font-size: 1.2rem; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 1.4rem; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn--secondary { background: transparent; color: var(--accent); }
.parts { display: flex; flex-direction: column; gap: 2rem; max-width: 900px; }
.part h2 { margin-top: 0; }
.part__desc { color: var(--muted); margin: .2rem 0 1rem; max-width: var(--measure); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: var(--ink);
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card__num { font-size: .72rem; font-weight: 600; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; }
.card__title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.card__blurb { font-size: .88rem; color: var(--ink-2); }
.card.is-done .card__num::after { content: "Done ✓"; color: var(--accent); }
.howto { max-width: var(--measure); margin: 2.4rem 0; }
.howto ol { padding-left: 1.3rem; }

/* misc */
.kbd { font-family: var(--font-mono); font-size: .8em; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; background: var(--surface); }
.pill-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list li { margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; background: var(--surface); }
.links { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.links li { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.links li a { font-weight: 600; }
.links li p { margin: 4px 0 0; font-size: .9rem; color: var(--ink-2); }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 1.2rem 0; }
@media (max-width: 640px) { .vs { grid-template-columns: 1fr; } }

/* ============================================================
   Welcome moment, guided walkthrough, final exam, certificate
   ============================================================ */

/* ---------- welcome overlay ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(6px);
  padding: 24px;
}
.welcome__card {
  position: relative; z-index: 2;
  max-width: 520px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 30px 26px;
  text-align: center;
  animation: welcome-in .5s cubic-bezier(.2, .8, .2, 1) both;
}
.welcome__badge {
  width: 62px; height: 62px; margin: 0 auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  animation: badge-pop .6s .15s cubic-bezier(.2, 1.4, .4, 1) both;
}
.welcome__badge svg { width: 30px; height: 30px; color: var(--accent); }
.welcome h2 { font-size: 1.7rem; margin: 0 0 .5rem; }
.welcome p { color: var(--ink-2); margin: 0 auto .5rem; max-width: 42ch; }
.welcome__name { color: var(--accent); }
.welcome__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.welcome canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none;
}
@keyframes welcome-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes badge-pop { from { opacity: 0; transform: scale(.4) rotate(-25deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .welcome__card, .welcome__badge { animation: none; }
}

/* ---------- guided walkthrough ---------- */
.tour-hole {
  position: fixed; z-index: 90;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(8, 12, 16, .62), 0 0 0 3px var(--accent);
  pointer-events: none;
}
.tour-pop {
  position: fixed; z-index: 91;
  width: min(330px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px 18px 14px;
}
.tour-pop__step {
  font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .35rem;
}
.tour-pop h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.tour-pop p { font-size: .92rem; color: var(--ink-2); margin: 0; line-height: 1.5; }
.tour-pop__actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.tour-pop__actions .spacer { flex: 1; }
.tour-btn {
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: .88rem; font-weight: 600;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
.tour-btn--ghost { background: transparent; color: var(--ink-2); border-color: var(--line); font-weight: 500; }
.tour-btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
@media (prefers-reduced-motion: reduce) {
  .tour-hole, .tour-pop { transition: none; }
}

/* ---------- final exam ---------- */
.exam { max-width: 62ch; }
.exam__meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 1.4rem; font-size: .88rem; color: var(--muted); }
.exam__bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 1rem 0 1.6rem; }
.exam__fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.exam__card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px;
}
.exam__chapter {
  font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .5rem;
}
.exam__q { font-size: 1.08rem; font-weight: 600; margin: 0 0 14px; line-height: 1.4; }
.exam__opts { display: flex; flex-direction: column; gap: 9px; }
.exam__opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); cursor: pointer; line-height: 1.45; font-size: .95rem;
}
.exam__opt:hover { border-color: var(--line-strong); }
.exam__opt.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.exam__opt .key {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
  font-size: .78rem; font-weight: 700; font-family: var(--font-mono);
}
.exam__opt.is-picked .key { background: var(--accent); color: var(--accent-ink); }
.exam__nav { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.exam__nav .spacer { flex: 1; }

/* results */
.exam__score { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 1.4rem; }
.exam__dial { flex: none; width: 118px; height: 118px; }
.exam__verdict h2 { margin: 0 0 .3rem; }
.exam__verdict p { margin: 0; color: var(--ink-2); }
.exam__review { display: flex; flex-direction: column; gap: 10px; margin-top: 1.6rem; }
.rev {
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface); padding: 12px 16px;
}
.rev.ok { border-left-color: var(--green); }
.rev.no { border-left-color: var(--red); }
.rev__q { font-weight: 600; margin: 0 0 6px; font-size: .95rem; }
.rev__line { margin: 0; font-size: .88rem; color: var(--ink-2); }
.rev__line .tag { font-weight: 600; }
.rev.ok .tag { color: var(--green); }
.rev.no .tag { color: var(--red); }
.rev__why { margin: 6px 0 0; font-size: .88rem; color: var(--muted); }

/* certificate */
.cert { margin-top: 2rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }
.cert__row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.cert__field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 240px; }
.cert__field label { font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.cert__field input {
  font: inherit; font-size: .95rem; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.cert__preview {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--surface-2); margin-top: 1rem;
}
.cert__preview canvas { display: block; width: 100%; height: auto; }
.cert__note { font-size: .85rem; color: var(--muted); margin-top: .7rem; }
