:root {
  --bg: #fbfaf7; --surface: #ffffff; --text: #1f2328; --muted: #5b636d;
  --border: #d9d5cc; --accent: #1f6b45; --accent-soft: #e9f2ec;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513; --surface: #181d1a; --text: #e6e8e6; --muted: #9aa39e;
    --border: #2f3833; --accent: #5fc28f; --accent-soft: #1d2d24;
  }
}
:root[data-theme="dark"] {
  --bg: #111513; --surface: #181d1a; --text: #e6e8e6; --muted: #9aa39e;
  --border: #2f3833; --accent: #5fc28f; --accent-soft: #1d2d24;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
a { color: var(--accent); }
strong { font-weight: 650; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 820px; margin: 0 auto; padding: .8rem 16px; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text); text-decoration: none; }
.print-btn, .button {
  display: inline-block; padding: .45rem 1rem; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--surface); color: var(--accent); font: inherit; font-size: .95rem;
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.print-btn:hover, .button:hover { background: var(--accent-soft); }

main { max-width: 820px; margin: 0 auto; padding: 2rem 16px 4rem; }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 1rem; }
.eyebrow {
  margin: 0 0 .3rem; color: var(--accent); font-size: .85rem;
  font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
}
.lead { color: var(--muted); font-size: 1.05rem; }
.footnote { margin-top: 2.5rem; color: var(--muted); font-size: .95rem; }

.chapter + .chapter { margin-top: 4rem; padding-top: 2rem; border-top: 3px double var(--border); }

article h2 {
  font-size: 1.35rem; line-height: 1.3; margin: 2.2rem 0 .7rem; padding-bottom: .25rem;
  border-bottom: 2px solid var(--accent);
}
article h3 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
ul, ol { padding-left: 1.4rem; }
li { margin: .2rem 0; }
li > ul, li > ol { margin: .2rem 0; }
code { font-size: .9em; }
pre {
  overflow-x: auto; margin: 1rem 0; padding: .7rem 1rem; line-height: 1.45;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
pre code { font-size: .88rem; }

.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .94rem; background: var(--surface); }
th, td { text-align: left; vertical-align: top; padding: .45rem .65rem; border: 1px solid var(--border); }
th { background: var(--accent-soft); font-weight: 650; }

/* Boxed notes: > [!NOTE] and friends. A left rule and a border (not only a
   background colour) so they still stand out when printed in black and white. */
.callout {
  margin: 1rem 0; padding: .6rem .9rem; border: 1px solid var(--border);
  border-left: 4px solid var(--c-edge); border-radius: 4px; background: var(--surface);
}
.callout p { margin: .2rem 0; }
.callout ul, .callout ol { margin: .3rem 0; }
.note      { --c-edge: #2f6fdb; }
.tip       { --c-edge: #2c9a5a; }
.important { --c-edge: #7a4fd0; }
.warning   { --c-edge: #c9820a; }
.fun       { --c-edge: #d4537e; }

article blockquote {
  margin: 1rem 0; padding: .5rem 1rem; border-left: 3px solid var(--accent); font-size: 1.05rem;
}
article blockquote p { margin: 0; }

/* Home page chapter list */
.unit h2 { font-size: 1.1rem; margin: 2rem 0 .7rem; color: var(--muted); }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cards li { margin: 0; }
.card {
  display: flex; gap: .8rem; align-items: center; height: 100%; padding: .8rem 1rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card .num {
  flex: none; display: grid; place-items: center; width: 2.2rem; height: 2.2rem;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.card .title { font-weight: 600; line-height: 1.35; }

/* ---- Printing on A4 ---- */
@page { size: A4; margin: 16mm 15mm 18mm; }
@media print {
  :root, :root:not([data-theme="light"]) {
    --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --border: #999;
    --accent: #000; --accent-soft: #eee;
  }
  body { font: 10.5pt/1.45 "Noto Serif", Georgia, "Times New Roman", serif; background: #fff; color: #000; }
  .site-header, .button, .footnote { display: none; }
  main { max-width: none; padding: 0; }
  a { color: #000; text-decoration: none; }
  h1 { font-size: 20pt; margin-bottom: 8pt; }
  .eyebrow { font-size: 9pt; color: #333; }
  article h2 { font-size: 14pt; margin: 14pt 0 6pt; border-bottom: 1.5pt solid #000; }
  article h3 { font-size: 12pt; margin: 10pt 0 4pt; }
  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
  p, li { orphans: 3; widows: 3; }
  table { font-size: 9.5pt; }
  th, td { padding: 3pt 5pt; border: .6pt solid #777; }
  th { background: #eee; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr, .callout, pre, blockquote { break-inside: avoid; page-break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .callout { border: .6pt solid #777; border-left: 3pt solid #000; padding: 4pt 8pt; margin: 8pt 0; }
  pre { white-space: pre-wrap; }
  /* On the all-notes page, start every chapter on a new sheet. */
  .chapter + .chapter { break-before: page; page-break-before: always; margin-top: 0; padding-top: 0; border-top: 0; }
}
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
