:root {
  --paper: #faf9fb;
  --ink: #1a1c1d;
  --accent: #00459a;
  --muted: #727785;
  --border: #c2c6d5;
  --code-bg: #f4f3f5;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --caps: "Inter", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1c1d;
    --ink: #e8e6ea;
    --accent: #7ab0ee;
    --muted: #9a9eab;
    --border: #3a3c43;
    --code-bg: #252729;
  }

  /* Pandoc tango palette is unreadable on dark — remap to material-palenight-ish */
  pre code span { color: #d4d4d4; }
  pre code span.kw,
  pre code span.cf { color: #c792ea; font-weight: normal; }
  pre code span.dt,
  pre code span.at,
  pre code span.bu { color: #82aaff; }
  pre code span.fu { color: #82aaff; }
  pre code span.st,
  pre code span.ss,
  pre code span.ch { color: #c3e88d; }
  pre code span.sc { color: #ffcb6b; }
  pre code span.dv,
  pre code span.bn,
  pre code span.fl,
  pre code span.cn { color: #f78c6c; }
  pre code span.co,
  pre code span.do { color: #717cb4; font-style: italic; }
  pre code span.op { color: #89ddff; }
  pre code span.va { color: #d4d4d4; }
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.6;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
}

body > header,
body > main,
body > footer {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

body > header {
  padding-top: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

body > header nav a {
  font-family: var(--caps);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

body > header nav a:hover { color: var(--accent); }

body > main { padding-top: 2.5rem; padding-bottom: 3rem; }

body > footer {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--caps);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

body > footer a { color: var(--muted); text-decoration: none; }
body > footer a:hover { color: var(--accent); }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 0.18em; }
a:hover { text-decoration: none; }

article > header { margin-bottom: 2rem; }

article > header time {
  display: block;
  font-family: var(--caps);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

article > header h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

article > header p.subtitle {
  font-size: 1.15rem;
  line-height: 1.4;
  color: var(--muted);
  margin: 0.5rem 0 0;
  font-weight: 400;
  font-style: italic;
}

article h2 {
  font-size: 1.35rem;
  line-height: 1.3;
  margin: 2.5rem 0 0.8rem;
  font-weight: 600;
}

article h3 {
  font-size: 1.1rem;
  margin: 1.8rem 0 0.6rem;
  font-weight: 600;
}

article p {
  margin: 0 0 1.1rem;
  text-align: justify;
  hyphens: auto;
}

article ul, article ol { margin: 0 0 1.1rem 1.2rem; padding: 0; }
article li { margin-bottom: 0.3rem; }

article blockquote {
  margin: 1.5rem 0;
  padding: 0 0 0 1.2rem;
  border-left: 1px solid var(--muted);
  color: var(--muted);
  font-style: italic;
}

article code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
}

article pre {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--code-bg);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-left: 2px solid var(--border);
}

article pre > code { background: none; padding: 0; font-size: inherit; }

article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

article img { max-width: 100%; height: auto; display: block; margin: 1.5rem 0; }

article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}

article th, article td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

article th {
  font-family: var(--caps);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--ink);
}

article section.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--muted);
}

article section.footnotes ol { margin-left: 1rem; }

/* Index page: body content rendered by pandoc inside section.level1 */
main > section.level1 > h1 {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
}

main > section.level1 > p:first-of-type { color: var(--muted); margin-bottom: 1.5rem; }

/* Index page: article list (structural class on <section>) */
section.article-list { margin-top: 2.5rem; }

section.article-list > h2 {
  font-family: var(--caps);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 1.2rem;
}

section.article-list > ul { list-style: none; margin: 0; padding: 0; }

section.article-list > ul > li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

section.article-list > ul > li:last-child { border-bottom: none; }

section.article-list > ul > li > a {
  display: block;
  text-decoration: none;
  color: var(--ink);
}

section.article-list > ul > li > a:hover h3 { color: var(--accent); }

section.article-list > ul > li time {
  font-family: var(--caps);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

section.article-list > ul > li h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.3rem 0;
}

section.article-list > ul > li p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
