:root {
  color-scheme: light;
  --bg: #ffffff; --fg: #1c1f23; --muted: #5a626c; --line: #dfe2e6; --subtle: #f5f6f7;
  --accent: #1f5fbf; --accent-fg: #ffffff; --ok: #1a6b3a; --warn: #8a5a00; --focus: #1f5fbf;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161a; --fg: #e6e8eb; --muted: #a2aab4; --line: #30353c; --subtle: #1c1f24;
    --accent: #7fb0f5; --accent-fg: #10131a; --ok: #6fcf97; --warn: #e3b866; --focus: #7fb0f5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a; --fg: #e6e8eb; --muted: #a2aab4; --line: #30353c; --subtle: #1c1f24;
  --accent: #7fb0f5; --accent-fg: #10131a; --ok: #6fcf97; --warn: #e3b866; --focus: #7fb0f5;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .5em; font-weight: 600; }
h1 { font-size: 1.9rem; margin-top: .4em; }
h2 { font-size: 1.4rem; padding-top: .6em; border-top: 1px solid var(--line); }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
p, ul, ol, dl, blockquote { margin: 0 0 1em; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--subtle); padding: .1em .3em; border-radius: 3px; overflow-wrap: anywhere; }
pre.code { position: relative; background: var(--subtle); border: 1px solid var(--line); border-radius: 6px; padding: .8em 1em; overflow-x: auto; margin: 0 0 1em; }
pre.code code { background: none; padding: 0; overflow-wrap: normal; font-size: .85rem; line-height: 1.5; }
button, select, input[type="search"], .button { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: .3em .7em; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { background: var(--subtle); }
html:not(.js) .js-only { display: none !important; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: var(--bg); padding: .5em 1em; z-index: 10; }
.site-header { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; padding: .8rem 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--fg); text-decoration: none; margin-right: auto; }
.site-header nav { display: flex; gap: 1rem; }
.theme-control { color: var(--muted); font-size: .9rem; display: inline-flex; gap: .4em; align-items: center; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 1rem 16px; margin-top: 3rem; }
.site-footer p { max-width: 1100px; margin: 0 auto; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem 16px; }
.tagline { font-size: 1.25rem; max-width: 70ch; margin-bottom: 0.5rem; }
.lede { color: var(--muted); max-width: 70ch; }
.muted { color: var(--muted); }
.tag { font-size: .75rem; border: 1px solid var(--line); border-radius: 3px; padding: .05em .4em; color: var(--muted); white-space: nowrap; }

/* Catalog */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin: 1rem 0; }
.stat { border-top: 2px solid var(--line); padding-top: .4rem; }
.stat b { display: block; font-size: 1.4rem; font-weight: 600; }
.stat span { color: var(--muted); font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: 1rem 0; }
.filters label:first-child { grid-column: 1 / -1; }
.filters label { display: grid; font-size: .8rem; color: var(--muted); gap: .15rem; }
.filters input, .filters select { width: 100%; color: var(--fg); }
.domain { border-top: 1px solid var(--line); }
.domain > summary { cursor: pointer; padding: .7rem 0; font-weight: 600; display: flex; flex-wrap: wrap; gap: .25rem 1rem; justify-content: space-between; }
.domain > summary .domain-meta { font-weight: 400; color: var(--muted); font-size: .85rem; }
.rows { list-style: none; margin: 0 0 1rem; padding: 0; }
.row { display: grid; grid-template-columns: 1fr auto; gap: .1rem 1rem; padding: .35rem 0; border-top: 1px solid var(--subtle); }
.row .meta { color: var(--muted); font-size: .8rem; text-align: right; white-space: nowrap; }
.row .pending-title { color: var(--muted); }
.row-status { font-size: .8rem; grid-column: 1 / -1; color: var(--muted); }
.row-status:empty { display: none; }
.row[data-progress="complete"] .row-status { color: var(--ok); }
.row[data-progress="in-progress"] .row-status { color: var(--warn); }
[hidden] { display: none !important; }

/* Topic pages */
.topic-layout { max-width: 1180px; margin: 0 auto; padding: 1rem 16px; display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1fr); }
.topic-main { min-width: 0; max-width: 74ch; }
@media (min-width: 1000px) {
  .topic-layout { grid-template-columns: minmax(0, 1fr) 230px; }
  .toc { position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow: auto; order: 2; }
}
.toc { font-size: .88rem; }
.toc ol { margin: .4rem 0 0; padding-left: 1.4rem; }
.toc summary { cursor: pointer; font-weight: 600; }
.breadcrumb { font-size: .85rem; color: var(--muted); }
.meta-line { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; vertical-align: top; padding: .4em .6em; border: 1px solid var(--line); }
th { background: var(--subtle); font-weight: 600; }
blockquote { border-left: 3px solid var(--line); padding-left: 1em; color: var(--muted); }
.checklist { list-style: none; padding-left: 0; }
.checklist li { padding-left: 1.6em; position: relative; }
.checklist li::before { content: "☐"; position: absolute; left: 0; }
.diagram { margin: 1.2em 0; border: 1px solid var(--line); border-radius: 6px; padding: .8em; }
.diagram figcaption { font-weight: 600; margin-bottom: .6em; }
.diagram pre.mermaid { overflow-x: auto; margin: 0 0 .6em; font-size: .8rem; text-align: center; }
.diagram-alt { color: var(--muted); font-size: .85rem; margin: 0; }
.failure, .challenge { border-top: 1px dashed var(--line); margin-top: 1em; }
.failure dl { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: .25em 1em; }
.failure dt { font-weight: 600; font-size: .9rem; }
.failure dd { margin: 0; }
details.disclosure, details.qa { border: 1px solid var(--line); border-radius: 5px; padding: .5em .8em; margin: 0 0 .6em; }
details > summary { cursor: pointer; }
details[open] > summary { margin-bottom: .5em; }
.note { background: var(--subtle); border-left: 3px solid var(--accent); padding: .6em 1em; margin: 0 0 1em; }
.note-label { font-weight: 600; margin: 0 0 .3em; font-size: .9rem; }
.quiz fieldset { border: 1px solid var(--line); border-radius: 5px; margin: 0 0 1em; }
.quiz legend { font-weight: 600; padding: 0 .3em; }
.quiz label { display: block; padding: .15em 0; }
.quiz-feedback { font-weight: 600; margin: .4em 0; }
.quiz-feedback:empty { display: none; }
.progress-controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
.copy-button { position: absolute; top: .4em; right: .4em; font-size: .75rem; padding: .1em .5em; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
@media print {
  .site-header nav, .theme-control, .toc, .copy-button, .progress-controls, .filters, .actions, .skip-link, .site-footer { display: none !important; }
  body { font-size: 11pt; background: #fff; color: #000; }
  a { color: #000; }
  pre.code { white-space: pre-wrap; }
  h2 { break-after: avoid; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
label.button:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
