:root {
  color-scheme: light dark;
  --text: #1d1d1b;
  --muted: #5c5c57;
  --background: #fbfaf7;
  --surface: #f0eee8;
  --rule: #d6d3ca;
  --link: #1f4f8f;
  --link-visited: #5b3a86;
  --focus: #1f4f8f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e6e4de;
    --muted: #a7a49c;
    --background: #161615;
    --surface: #222220;
    --rule: #3c3b37;
    --link: #8db8f0;
    --link-visited: #c3a6ec;
    --focus: #8db8f0;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem 1.25rem 3rem;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  overflow-wrap: break-word;
}

main,
footer {
  max-width: 42rem;
  margin-inline: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.25;
  margin: 2em 0 0.5em;
  text-wrap: balance;
}

h1 {
  font-size: 2rem;
  margin-top: 0;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4,
h5,
h6 {
  font-size: 1rem;
}

p,
li,
blockquote {
  text-wrap: pretty;
}

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

.meta {
  margin: 0;
  color: var(--muted);
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:visited {
  color: var(--link-visited);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

img,
video,
svg {
  max-width: 100%;
  height: auto;
}

figure {
  margin: 1.5rem 0;
}

figcaption {
  color: var(--muted);
  font-size: 0.9rem;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0 0 0 1.25rem;
  border-inline-start: 4px solid var(--rule);
  color: var(--muted);
}

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

code,
kbd,
samp,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

:not(pre) > code {
  padding: 0.1em 0.3em;
  background: var(--surface);
  border-radius: 3px;
}

pre {
  max-width: 100%;
  padding: 1rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  line-height: 1.45;
}

.code-caption {
  margin: 1.5rem 0 0.25rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.code-caption + pre {
  margin-top: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table {
  border-collapse: collapse;
  min-width: 50%;
}

th,
td {
  overflow-wrap: anywhere;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--rule);
  text-align: start;
  vertical-align: top;
}

th {
  background: var(--surface);
  text-wrap: balance;
}

.align-center {
  text-align: center;
}

.align-right {
  text-align: end;
}

.listing {
  padding-inline-start: 0;
  list-style: none;
}

.listing li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.listing time {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.notice,
.box-info,
.box-hint,
.box-warning {
  padding: 1rem;
  background: var(--surface);
  border-inline-start: 4px solid var(--rule);
}

.box-info,
.box-hint,
.box-warning {
  margin: 1.5rem 0;
}

.box-warning {
  border-inline-start-color: var(--muted);
}

footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-size: 1rem;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  text-decoration-thickness: 2px;
}

@media print {
  :root {
    color-scheme: light;
    --text: #000;
    --muted: #333;
    --background: #fff;
    --surface: #fff;
    --rule: #999;
    --link: #000;
    --link-visited: #000;
  }

  body {
    padding: 0;
    font-size: 11pt;
  }

  main,
  footer {
    max-width: none;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    overflow-wrap: anywhere;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  pre,
  blockquote,
  table,
  figure,
  img {
    break-inside: avoid;
  }

  pre {
    white-space: pre-wrap;
  }

  .table-wrap {
    overflow: visible;
  }

  footer {
    margin-top: 2rem;
  }

  footer nav {
    display: none;
  }
}
