:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #23211d;
  --muted: #6b665c;
  --accent: #2f6f6a;
  --accent-soft: #e6f0ee;
  --rule: #e6e1d6;
  --hero-a: #e9f2f0;
  --hero-b: #f6efe6;
  --code-bg: #f1eee6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141513;
    --surface: #1c1e1b;
    --text: #e9e6df;
    --muted: #a39e93;
    --accent: #7cc0b9;
    --accent-soft: #1d2b29;
    --rule: #2f312c;
    --hero-a: #18211f;
    --hero-b: #1f1b16;
    --code-bg: #22231f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--accent); z-index: 10; transition: width .1s linear;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
  border-bottom: 1px solid var(--rule);
}
.hero-inner { max-width: 44rem; margin: 0 auto; padding: 4.5rem 1rem 3.5rem; }
.mark { width: 2.4rem; height: 2.4rem; fill: var(--accent); opacity: .9; margin-bottom: 1rem; }
.hero h1 {
  font-family: var(--sans); font-weight: 750; letter-spacing: -0.02em;
  font-size: clamp(2rem, 5.5vw, 3.1rem); line-height: 1.1; margin: 0 0 .6rem;
}
.subtitle {
  font-family: var(--serif); font-style: italic; font-size: clamp(1.2rem, 3vw, 1.5rem);
  color: var(--accent); margin: 0 0 1.4rem;
}
.byline { font-family: var(--sans); font-size: .9rem; color: var(--muted); margin: 0; }

/* Body */
main { max-width: 44rem; margin: 0 auto; padding: 2.5rem 1rem 4rem; }
main > p:first-of-type em, .standfirst { color: var(--muted); }
.standfirst { font-size: 1.25rem; line-height: 1.6; font-style: italic; margin-bottom: 1.6rem; }

h2, h3, h4 { font-family: var(--sans); line-height: 1.25; letter-spacing: -0.01em; }
h2 {
  font-size: 1.65rem; margin: 3.2rem 0 1rem; padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}
h3 { font-size: 1.3rem; margin: 2.4rem 0 .7rem; }
h4 { font-size: 1.08rem; margin: 1.8rem 0 .5rem; text-transform: none; color: var(--muted); }
p { margin: 0 0 1.15em; }
strong { font-weight: 700; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
ul, ol { padding-left: 1.4em; margin: 0 0 1.2em; }
li { margin: .35em 0; }
li::marker { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }
blockquote {
  margin: 0 0 1.2em; padding: .8em 1.1em;
  border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0;
}
blockquote p:last-child { margin-bottom: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--code-bg); padding: .1em .3em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 1rem; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; font-size: .85rem; line-height: 1.5; }
pre code { background: none; padding: 0; }
table { border-collapse: collapse; width: 100%; margin: 0 0 1.4em; font-size: .95rem; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--rule); padding: .5em .7em; text-align: left; vertical-align: top; }
th { font-family: var(--sans); font-size: .85rem; color: var(--muted); }

/* Task lists (kit list) */
li:has(> input[type="checkbox"]) { list-style: none; position: relative; padding-left: 1.7em; }
ul:has(> li > input[type="checkbox"]) { padding-left: .2em; }
li > input[type="checkbox"] {
  appearance: none; position: absolute; left: 0; top: .38em; width: 1.05em; height: 1.05em; margin: 0;
  border: 1.5px solid var(--accent); border-radius: 4px; background: var(--surface);
}

/* Cards: short version, contents */
.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  padding: 1.2rem 1.4rem; box-shadow: var(--shadow); margin: 0 0 1.6rem;
}
.card > :last-child { margin-bottom: 0; }
.card-label {
  font-family: var(--sans); font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 .7rem;
}

ul.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
ul.timeline::before { content: ""; position: absolute; left: .32rem; top: .5rem; bottom: .5rem; width: 2px; background: var(--rule); }
ul.timeline li { position: relative; padding-left: 1.6rem; margin: .55em 0; font-size: 1.02rem; }
ul.timeline li::before {
  content: ""; position: absolute; left: 0; top: .55em; width: .7rem; height: .7rem;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
}
ul.timeline li:last-child::before { background: var(--accent); }

.contents h2 { border: 0; padding: 0; margin: 0 0 .8rem; font-size: 1.2rem; }
.contents p { margin: .9rem 0 .3rem; font-family: var(--sans); font-size: .95rem; }
.contents ol { margin: 0 0 .4rem; font-size: 1rem; }
.contents li { margin: .2em 0; }
.contents a { text-decoration: none; }
.contents a:hover { text-decoration: underline; }

.loading, .notice { color: var(--muted); font-family: var(--sans); font-size: .95rem; }
.notice { padding: 1rem; background: var(--accent-soft); border-radius: 8px; }

/* Footer */
footer { border-top: 1px solid var(--rule); background: var(--surface); }
.footer-inner { max-width: 44rem; margin: 0 auto; padding: 2rem 1rem 3rem; color: var(--muted); font-family: var(--sans); font-size: .9rem; line-height: 1.6; }
.footer-inner strong { color: var(--text); }

#to-top {
  position: fixed; right: 1rem; bottom: 1rem; width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: #fff; text-decoration: none; font-family: var(--sans); font-size: 1.15rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s;
}
#to-top.show { opacity: .9; pointer-events: auto; }
@media (prefers-color-scheme: dark) { #to-top { color: #10201e; } }

@media (max-width: 540px) {
  body { font-size: 1.06rem; }
  .hero-inner { padding: 3rem 1rem 2.4rem; }
  h2 { font-size: 1.45rem; }
  .card { padding: 1rem 1.1rem; }
}

@media print {
  #progress, #to-top, .hero .mark { display: none; }
  .hero { background: none; }
  .card { box-shadow: none; }
}
