:root {
  color-scheme: light dark;
  --background: #f4f2eb;
  --text: #171a18;
  --muted: #59615b;
  --link: #126437;
  --rule: #c6cbc5;
  --code-background: #e8e7e1;
  --selection: #b9e9c6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0c0f0d;
    --text: #e4e9e5;
    --muted: #a1aaa3;
    --link: #75d991;
    --rule: #354039;
    --code-background: #171c18;
    --selection: #245d35;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  color: var(--text);
  font-size: 16px;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.5;
}

::selection {
  background: var(--selection);
}

a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

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

a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: 0.45rem 0.65rem;
  background: var(--background);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-shell {
  width: min(74rem, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.6rem 0 1.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
}

.site-name {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.site-name::before {
  color: var(--link);
  content: "> ";
}

.primary-nav,
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.1rem;
}

main {
  min-height: calc(100vh - 12rem);
  padding: clamp(3rem, 8vw, 6.5rem) 0;
}

h1,
h2 {
  margin-top: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  letter-spacing: -0.04em;
}

.home,
.listing,
.tools,
.standalone {
  max-width: 45rem;
}

.home h1 {
  margin-bottom: 2.4rem;
}

.directory-list,
.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.directory-list li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1.2rem;
  align-items: baseline;
  padding: 0.8rem 0;
  border-top: 1px solid var(--rule);
}

.directory-list li:last-child {
  border-bottom: 1px solid var(--rule);
}

.directory-list span,
.empty-state,
time {
  color: var(--muted);
}

.page-header {
  margin-bottom: 2.2rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.page-header h1 {
  margin-bottom: 0;
}

.post-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: baseline;
  padding: 0.8rem 0;
  border-top: 1px solid var(--rule);
}

.post-list time {
  font-size: 0.82rem;
}

.tools-content h2 {
  margin: 2.1rem 0 0.35rem;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.tools-content h2:first-child {
  margin-top: 0;
}

.tools-content p {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

.prose {
  max-width: 68ch;
  font-family: ui-serif, Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  font-size: clamp(1.05rem, 2vw, 1.16rem);
  line-height: 1.72;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre {
  margin: 0 0 1.35em;
}

.prose h2 {
  margin: 2.4em 0 0.7em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.prose h3 {
  margin: 2em 0 0.65em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
}

.prose code,
.prose pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.prose code {
  padding: 0.12em 0.28em;
  background: var(--code-background);
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--code-background);
  line-height: 1.55;
}

.prose pre code {
  padding: 0;
  background: transparent;
}

.prose blockquote {
  margin-left: 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

.article-layout {
  max-width: 72rem;
}

.article-header {
  max-width: 68ch;
  margin-bottom: 2.4rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.article-header h1 {
  margin: 0 0 0.7rem;
}

.article-header time {
  font-size: 0.83rem;
}

.section-path {
  margin: 0 0 1rem;
  font-size: 0.83rem;
}

.sidenote {
  margin: 1.5rem 0;
  padding: 0.15rem 0 0.15rem 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.86rem;
  line-height: 1.55;
}

.sidenote p:last-child {
  margin-bottom: 0;
}

.site-footer {
  padding: 1.3rem 0 2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
}

@media (min-width: 66rem) {
  .article-body {
    margin-right: 19rem;
  }

  .article-body .sidenote {
    float: right;
    clear: right;
    width: 16rem;
    margin: 0.2rem -19rem 1.5rem 2rem;
  }
}

@media (max-width: 36rem) {
  .site-shell {
    width: min(100% - 1.4rem, 74rem);
  }

  .site-header {
    display: block;
  }

  .primary-nav {
    margin-top: 0.8rem;
  }

  main {
    padding: 2.8rem 0 4rem;
  }

  .directory-list li {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .post-list li {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
