html {
  color-scheme: light dark;
  scrollbar-width: thin;
}

:root {
  --bg: #fafafa;
  --fg: #222;
  --muted: #666;
  --surface: rgba(0, 0, 0, 0.03);
  --border: rgba(0, 0, 0, 0.06);
  --dot: rgba(0, 0, 0, 0.035);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --fg: #eaeaea;
  --muted: #999;
  --surface: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --dot: rgba(255, 255, 255, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --fg: #eaeaea;
    --muted: #999;
    --surface: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.08);
    --dot: rgba(255, 255, 255, 0.05);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: row;
  justify-items: center;

  font-family: system-ui, sans-serif;
  line-height: 1.6;
  color: var(--fg);
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 1rem 1rem;
}

main {
  display: flex;
  flex-direction: column;
  width: min(960px, 100% - 3rem);
  max-width: 800px;
  margin: auto;
}

article {
  width: 100%;
  margin: 3rem 0;
}

nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
}

nav nav {
  padding: 0;
}

nav a {
  color: var(--muted);
  text-decoration: none;
}

nav .brand,
nav a[aria-current="page"] {
  color: var(--fg);
}

nav .name {
  font-weight: bold;
}

nav button {
  padding: 0;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-underline-offset: 2px;
}

a:hover {
  opacity: 0.7;
}

p, li {
  color: var(--muted);
}

h1, h2, h3 {
  position: relative;
  line-height: 1.25;
}

h1 {
  margin: 0;
  font-size: 2.5rem;
  letter-spacing: -0.02em;
}

h2 {
  margin-top: 2.5rem;
  font-size: 1.75rem;
}

h3 {
  margin-top: 1.25rem;
  font-size: 1.25rem;
}

h1::before,
h2::before,
h3::before {
  position: absolute;
  right: 100%;
  margin-right: 0.65rem;
  color: var(--muted);
  opacity: 0.35;
}

h1::before { content: "#"; }
h2::before { content: "##"; }
h3::before { content: "###"; }

pre {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;

  font: 0.85rem/1.6 ui-monospace, monospace;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

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

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;

  width: 100%;
  margin: 8rem 0 0rem;
}

.intro > div {
  min-width: 0;
  max-width: 45%;
}

.intro pre {
  width: max-content;
  max-width: 100%;
  padding-inline: 0.75rem;
  overflow-x: auto;
}

footer {
  margin-top: auto;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.skip-link {
  position: absolute;
  top: -5rem;
}

.skip-link:focus {
  top: 0;
  z-index: 1;
  padding: 0.5rem;
  background: var(--bg);
}

@media (max-width: 700px) {
  main {
    width: calc(100% - 2rem);
  }

  nav {
    gap: 0.75rem;
  }

  article {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .intro {
    flex-direction: column;
    align-items: stretch;
    margin-top: 4rem;
    gap: 0;
  }

  .intro > div {
    max-width: 100%;
  }

  .intro pre {
    width: 100%;
  }

  p {
    margin: 1rem 0;
  }

  h1::before,
  h2::before,
  h3::before {
    position: static;
    margin-right: 0.4rem;
  }
}
