:root {
  color-scheme: dark;
  --font-serif: "Source Serif 4", "Source Serif Pro", "Iowan Old Style", Charter, Cambria, Georgia, serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", "SF Mono", Menlo, Consolas, ui-monospace, monospace;

  --bg: #0e0e10;
  --bg-elev: #16161a;
  --text: #ddd7c7;
  --text-muted: #8d8676;
  --text-faint: #4a463d;
  --rule: #25231f;
  --accent: #e9a86a;
  --accent-dim: #b07e47;

  --measure: 64ch;
  --gutter: 1.5rem;
  --rhythm: 1.35rem;

  --t-meta: 0.8125rem;
  --t-body: 1.0625rem;
  --t-h3: 1.25rem;
  --t-h2: 1.625rem;
  --t-h1: 2.375rem;

  --lh-body: 1.72;
  --lh-tight: 1.2;
}

@media (min-width: 720px) {
  :root {
    --t-body: 1.125rem;
    --t-h1: 2.75rem;
    --t-h2: 1.75rem;
  }
}

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

html {
  background: var(--bg);
}

body {
  margin: 0 auto;
  padding: 2.25rem var(--gutter) 4rem;
  max-width: var(--measure);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}

.site-header .brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
}

.site-header .brand:hover {
  color: var(--accent);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  color: var(--accent);
  line-height: 1;
  text-decoration: none;
}

.social-link img {
  display: block;
  width: 1em;
  height: 1em;
  transform: translateY(0.04em);
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.012em;
  text-wrap: balance;
  margin: 2.5rem 0 0.9rem;
  color: var(--text);
}

h1 {
  font-size: var(--t-h1);
  font-weight: 700;
  letter-spacing: -0.022em;
  margin-top: 0;
}

h2 {
  font-size: var(--t-h2);
  margin-top: 2.75rem;
}

h3 {
  font-size: var(--t-h3);
}

p {
  margin: 0 0 var(--rhythm);
  text-wrap: pretty;
  hyphens: manual;
}

strong {
  font-weight: 600;
  color: #f3eee0;
}

em {
  font-style: italic;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 80ms ease;
}

a:hover {
  color: #f5c189;
  text-decoration-thickness: 2px;
}

a:visited {
  color: var(--accent-dim);
}

time,
.meta {
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  color: var(--text-muted);
  font-feature-settings: "tnum";
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.tags a,
.tag {
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px dotted var(--rule);
}

.post-list li:last-child {
  border-bottom: none;
}

.post-list-title {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.post-list-title:hover {
  color: #f5c189;
}

.post-list-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-shrink: 0;
}

.post-list-meta time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.post-list-meta .tags {
  margin: 0;
  padding: 0;
  gap: 0.65rem;
  align-items: baseline;
}

.post-list-meta .tags a {
  color: var(--text-muted);
  text-decoration: underline;
}

.post-list-meta .tags a:hover {
  color: var(--accent);
}

@media (max-width: 520px) {
  .post-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 0.9rem 0;
  }

  .post-list-meta {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding-top: 0;
  }
}

article.post > header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

article.post > header h1 {
  margin: 0;
  flex: 1;
}

article.post > header time {
  display: inline-block;
}

.post-meta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  text-align: right;
  padding-top: 0.55rem;
}

.post-meta .tags {
  margin: 0;
}

@media (max-width: 600px) {
  article.post > header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
  }

  .post-meta {
    align-items: flex-start;
    text-align: left;
    padding-top: 0;
  }
}

.post-layout {
  position: relative;
}

.toc {
  display: none;
}

@media (min-width: 1360px) {
  .toc {
    position: fixed;
    top: 6.25rem;
    left: calc((100vw - var(--measure)) / 2 - 24rem);
    display: block;
    width: 15rem;
    max-height: calc(100vh - 7.5rem);
    overflow: auto;
    padding-right: 1rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    scrollbar-width: thin;
  }

  .toc p {
    margin: 0 0 0.55rem;
    color: var(--text-faint);
    font-size: var(--t-meta);
  }

  .toc ol {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .toc li {
    margin: 0 0 0.35rem;
  }

  .toc-title {
    margin-bottom: 0.6rem;
  }

  .toc-level-3 {
    padding-left: 0.9rem;
  }

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

  .toc-title a {
    color: var(--text);
  }

  .toc a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
  }
}

blockquote {
  margin: 1.75rem 0;
  padding: 0.1rem 0 0.1rem 1.4rem;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote cite {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: var(--t-meta);
  color: var(--text-faint);
}

blockquote cite::before {
  content: "\2014 ";
}

blockquote blockquote {
  margin-top: 1rem;
  border-left-color: var(--text-faint);
}

.example {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1.4rem;
  row-gap: 0.5rem;
  margin: 1.75rem 0;
  padding: 0.15rem 0 0.15rem 1.4rem;
  border-left: 2px solid var(--rule);
}

.example dt {
  font-style: italic;
  color: var(--text-muted);
  line-height: var(--lh-body);
}

.example dd {
  margin: 0;
  color: var(--text);
}

@media (max-width: 520px) {
  .example {
    grid-template-columns: 1fr;
    row-gap: 0.1rem;
  }

  .example dt {
    margin-top: 0.8rem;
  }

  .example dt:first-child {
    margin-top: 0;
  }
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:not(pre) > code {
  background: var(--bg-elev);
  color: #f0d6a8;
  padding: 0.1em 0.38em;
  border-radius: 2px;
  border: 1px solid var(--rule);
}

pre {
  margin: 1.75rem 0;
  padding: 0.95rem 1.1rem;
  background: var(--bg-elev);
  border-left: 2px solid var(--rule);
  border-radius: 2px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

kbd {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  padding: 0.05em 0.4em;
  border-radius: 3px;
  font-size: 0.85em;
}

.lang-note {
  margin-left: 0.12em;
  color: var(--accent-dim);
  font-family: var(--font-mono);
  font-size: 0.58em;
  font-style: normal;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  text-decoration: none;
  vertical-align: super;
}

ul,
ol {
  padding-left: 1.4rem;
  margin: 0.4rem 0 var(--rhythm);
}

li {
  margin-bottom: 0.35rem;
}

li::marker {
  color: var(--text-faint);
}

ul {
  list-style: square;
}

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

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 2px;
}

figure {
  margin: 1.75rem 0;
}

figcaption {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  color: var(--text-muted);
  text-align: center;
}

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

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

th {
  font-weight: 600;
  color: var(--text);
}

tr:hover td {
  background: var(--bg-elev);
}

.footnotes {
  margin-top: 2.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--text-muted);
  font-size: 0.95em;
}

.footnotes p {
  margin-bottom: 0.65rem;
}

.footnote-ref,
.footnote-backref {
  font-family: var(--font-mono);
  font-size: var(--t-meta);
}

.footnote-ref-wrap {
  position: relative;
  display: inline-block;
}

.footnote-popover {
  position: absolute;
  z-index: 10;
  bottom: calc(100% + 0.45rem);
  left: 50%;
  width: min(24rem, 80vw);
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  border-radius: 2px;
  background: var(--bg-elev);
  box-shadow: 0 0.8rem 1.8rem rgb(0 0 0 / 0.35);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, 0.2rem);
  transition: opacity 80ms ease, transform 80ms ease;
  visibility: hidden;
  white-space: normal;
}

.footnote-popover a {
  font-family: inherit;
  font-size: inherit;
}

.footnote-ref-wrap:hover .footnote-popover,
.footnote-ref-wrap:focus-within .footnote-popover {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}

.footnote-backref {
  text-decoration: none;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

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

@media (prefers-reduced-motion: reduce) {
  a {
    transition: none;
  }
}
