:root {
  --bg: #f7f5f0; --surface: #ffffff; --ink: #14232c; --muted: #5a6872; --line: #e2ddd2;
  --accent: #0d7c66; --accent-ink: #ffffff; --accent-soft: #e2f2ec; --warn: #9a4b00; --warn-soft: #fdf0dc;
  --danger: #a3242b; --danger-soft: #fbe6e6; --code: #f0ece3; --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1a22; --surface: #10242e; --ink: #e5ece9; --muted: #9db0b3; --line: #1f3a45;
    --accent: #3cc4a2; --accent-ink: #062018; --accent-soft: #123a33; --warn: #f2b45c; --warn-soft: #3a2a12;
    --danger: #ff8a8a; --danger-soft: #3a1a1d; --code: #16303b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1a22; --surface: #10242e; --ink: #e5ece9; --muted: #9db0b3; --line: #1f3a45;
  --accent: #3cc4a2; --accent-ink: #062018; --accent-soft: #123a33; --warn: #f2b45c; --warn-soft: #3a2a12;
  --danger: #ff8a8a; --danger-soft: #3a1a1d; --code: #16303b; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); margin: .3em 0 .3em; }
h2 { font-size: 1.5rem; margin: 1.8em 0 .5em; }
h3 { font-size: 1.15rem; margin: 1.4em 0 .4em; font-family: var(--sans); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; padding-top: 40px; padding-bottom: 60px; }
.muted { color: var(--muted); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 68ch; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 9; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1.1rem; }
.logo b { color: var(--accent); }
.logo-mark { width: 26px; height: 26px; fill: var(--accent); }
.logo-mark .tick { fill: none; stroke: var(--surface); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
#nav a { color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
#nav a:hover, #nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.theme svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; }
.theme svg path { fill: currentColor; stroke: none; }
.theme { flex: none; }
.theme, .menu { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; }
.menu { display: none; margin-left: auto; }

/* buttons */
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); padding: 11px 18px; border-radius: 10px; text-decoration: none; font-weight: 600; }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

/* home */
.hero { padding: 56px 0 32px; background: linear-gradient(180deg, var(--accent-soft), var(--bg)); }
.kicker { text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; font-weight: 700; color: var(--accent); margin: 0; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.rule-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; counter-reset: r; }
.rule-grid li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px 50px; position: relative; counter-increment: r; }
.rule-grid li::before { content: counter(r); position: absolute; left: 16px; top: 14px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.rule-grid b { display: block; }
.sec { margin-top: 24px; }
.sec-head h2 { margin-bottom: 0; }
.sec-head h2 a { color: var(--ink); text-decoration: none; }
.sec-head h2 a:hover { color: var(--accent); }
.sec-head p { margin-top: 4px; }
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.card a { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; transition: border-color .15s; }
.card a:hover { border-color: var(--accent); }
.card span { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.card small { color: var(--muted); margin-top: auto; padding-top: 6px; font-size: .8rem; }

/* article */
.crumbs { font-size: .88rem; color: var(--muted); margin-top: 24px; }
.crumbs a { color: var(--muted); }
.art-wrap { display: grid; grid-template-columns: minmax(0, 720px) 280px; gap: 48px; justify-content: center; padding-bottom: 64px; }
.meta { font-size: .88rem; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; margin: 20px 0; }
.toc summary { font-weight: 600; cursor: pointer; }
.toc ol { margin: 8px 0 0; padding-left: 20px; font-size: .95rem; }
.prose { max-width: 70ch; }
.prose li { margin: .3em 0; }
.prose .term strong { font-size: 1.02rem; }
.prose code { background: var(--code); padding: .1em .35em; border-radius: 5px; font-size: .88em; overflow-wrap: anywhere; }
.prose pre { background: var(--code); padding: 14px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .93rem; margin: 1em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface); }
.prose blockquote { margin: 1.2em 0; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.prose blockquote p { margin: .3em 0; }
.prose .warn { border-left-color: var(--warn); background: var(--warn-soft); }
.prose .danger { border-left-color: var(--danger); background: var(--danger-soft); }
.checklist { list-style: none; padding-left: 0; }
.chk label { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.chk input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.chk:has(input:checked) label { background: var(--accent-soft); }
.chk:has(input:checked) span { color: var(--muted); text-decoration: line-through; }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; }
.pn a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink); }
.pn a:hover { border-color: var(--accent); }
.pn small { display: block; color: var(--muted); font-size: .8rem; }
.pn .next { text-align: right; grid-column: 2; }
.related { position: sticky; top: 84px; align-self: start; margin-top: 64px; font-size: .95rem; }
.related h2 { font-size: 1.05rem; font-family: var(--sans); margin-top: 0; }
.related ul { padding-left: 18px; }
.aside-help { background: var(--danger-soft); padding: 12px 14px; border-radius: 10px; }

/* footer */
.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 32px 0 16px; margin-top: 40px; font-size: .92rem; }
.foot-in { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.foot-in > div:first-child { max-width: 420px; }
.foot-links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; align-content: start; }
.fine { color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 24px; }

@media (max-width: 960px) {
  .art-wrap { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .related { position: static; margin-top: 8px; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .menu { display: block; }
  .js #nav { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; background: var(--surface);
    border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  .js #nav.open { display: flex; }
  .top-in { flex-wrap: wrap; }
  .hero { padding-top: 36px; }
  .pn { grid-template-columns: 1fr; }
  .pn .next { grid-column: 1; }
}
@media print {
  .top, .foot, .related, .pn, .toc, .theme { display: none; }
  body { background: #fff; color: #000; }
}
