:root {
  color-scheme: light dark;
  --page-background: #fff;
  --text-color: #171717;
  --code-background: #f4f4f4;
  --divider-color: #ddd;

  --dark-page-background: #111;
  --dark-text-color: #f5f5f5;
  --dark-code-background: #222;
  --dark-divider-color: #414141;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme]) {
    --page-background: var(--dark-page-background);
    --text-color: var(--dark-text-color);
    --code-background: var(--dark-code-background);
    --divider-color: var(--dark-divider-color);
  }
}

:root[data-color-scheme="light"] {
  color-scheme: light;
}

:root[data-color-scheme="dark"] {
  color-scheme: dark;
  --page-background: var(--dark-page-background);
  --text-color: var(--dark-text-color);
  --code-background: var(--dark-code-background);
  --divider-color: var(--dark-divider-color);
}

body {
  margin: 0;
  background: var(--page-background);
  color: var(--text-color);
  font-family: system-ui, sans-serif;
  line-height: 1.75;
}

main {
  box-sizing: border-box;
  max-inline-size: 45rem;
  margin-inline: auto;
  padding: 3rem 1.25rem;
  overflow-wrap: anywhere;
}

h1 {
  margin-block: 0 1rem;
  font-size: clamp(2.5rem, 2rem + 2.5vw, 4rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

h2 {
  margin-block: 2rem 0.75rem;
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--divider-color);
  font-size: 1.25rem;
  line-height: 1.4;
}

p,
pre {
  margin-block: 0 1rem;
}

a {
  color: inherit;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 0.125em;
}

a:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 0.15em;
}

.theme-toggle:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
  margin-inline-start: auto;
  margin-block-end: 0.75rem;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 0.375rem;
  background: var(--page-background);
  color: inherit;
  cursor: pointer;
}

.theme-toggle svg {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle[aria-pressed="true"] {
  background: var(--code-background);
}

.theme-toggle[aria-pressed="false"] .theme-icon-sun,
.theme-toggle[aria-pressed="true"] .theme-icon-moon {
  display: none;
}

pre,
code {
  font-family: ui-monospace, monospace;
}

pre {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  background: var(--code-background);
  white-space: pre-wrap;
}

:not(pre) > code {
  padding: 0.1em 0.25em;
  border-radius: 0.2em;
  background: var(--code-background);
}
