:root {
  --canvas: #f3f1eb;
  --surface: #e9e7df;
  --surface-raised: #fbfaf6;
  --text: #1d2928;
  --text-soft: #52605d;
  --muted: #74807d;
  --accent: #087f78;
  --accent-strong: #05625d;
  --border: #ced6d2;
  --code-bg: #171b24;
  --code-text: #f1f4f3;
  --inline-code-bg: #e0e7e3;
  --selection: #9ce3da;
  --shadow: 0 24px 80px rgba(24, 42, 39, 0.08);
  --sans: "Fira Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #101516;
    --surface: #171e1f;
    --surface-raised: #1b2324;
    --text: #e5ece9;
    --text-soft: #b8c3bf;
    --muted: #879590;
    --accent: #58c7bd;
    --accent-strong: #83ded5;
    --border: #2a3838;
    --code-bg: #151923;
    --code-text: #f1f4f3;
    --inline-code-bg: #263435;
    --selection: #215f5a;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  }
}

html {
  background: var(--canvas);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  scroll-behavior: smooth;
}

body {
  background: var(--canvas);
  color: var(--text);
  font-family: var(--sans);
  margin: 0;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

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

.content {
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 clamp(1.15rem, 4vw, 3rem);
}

p {
  font-family: var(--sans);
  line-height: 1.72;
}

a {
  border: 0;
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 72%, transparent);
  text-decoration-line: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
  transition: color 140ms ease, text-decoration-color 140ms ease;
}

a:hover {
  background: transparent;
  color: var(--accent-strong);
  text-decoration-color: currentColor;
}

.site-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  line-height: 1;
  margin: 0 0 clamp(3.5rem, 7vw, 6rem);
  padding: 1.35rem 0;
}

.site-brand {
  align-items: baseline;
  display: inline-flex;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-decoration: none;
}

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

.site-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.72rem;
  gap: clamp(0.8rem, 2.5vw, 1.5rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.site-nav a:hover,
.site-nav a.is-active {
  color: var(--text);
}

.site-nav a.is-active {
  box-shadow: inset 0 -2px var(--accent);
  padding-bottom: 0.35rem;
}

.article-header {
  display: block;
  line-height: normal;
  margin: 0 0 clamp(3rem, 7vw, 5rem);
  max-width: 930px;
}

.article-kicker {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 0 0 1.25rem;
  text-transform: uppercase;
}

.article-title {
  color: var(--text);
  font-family: var(--mono);
  font-size: clamp(2.15rem, 5.7vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}

.article-description {
  color: var(--text-soft);
  font-size: clamp(1.05rem, 2vw, 1.22rem);
  line-height: 1.55;
  margin: 1.5rem 0 0;
  max-width: 720px;
}

.article-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.72rem;
  gap: 0.55rem;
  letter-spacing: 0.02em;
  margin-top: 1.65rem;
}

.article-meta-separator {
  color: var(--border);
}

.article-layout {
  align-items: start;
  display: grid;
  gap: clamp(3rem, 6vw, 5rem);
  grid-template-columns: minmax(0, 760px) minmax(180px, 1fr);
}

.body {
  min-width: 0;
}

.body > p:first-child {
  color: var(--text-soft);
  font-size: 1.16rem;
  line-height: 1.65;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text);
  font-family: var(--mono);
  line-height: 1.25;
}

h1::before,
h2::before,
h3::before,
h4::before,
h5::before,
h6::before {
  content: none;
}

.body h2 {
  font-size: clamp(1.45rem, 3vw, 1.8rem);
  letter-spacing: -0.035em;
  margin: 4.25rem 0 1.35rem;
  scroll-margin-top: 2rem;
}

.body h2::after {
  background: var(--accent);
  content: "";
  display: block;
  height: 2px;
  margin-top: 0.8rem;
  width: 2.5rem;
}

.body h3 {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  margin: 3rem 0 1rem;
  scroll-margin-top: 2rem;
}

.body p {
  margin: 1.15rem 0;
}

ul,
ol {
  padding-left: 1.4rem;
}

ul {
  list-style: disc;
}

ul li {
  text-indent: 0;
}

ul > li::before {
  content: none;
}

li::marker {
  color: var(--accent);
}

code {
  background: var(--inline-code-bg);
  border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  border-radius: 0.3rem;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.08em 0.28em;
}

pre {
  background: var(--code-bg) !important;
  border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  border-radius: 0.65rem;
  box-shadow: var(--shadow);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.65;
  margin: 1.8rem 0;
  overflow-x: auto;
  padding: 1.35rem 1.45rem;
}

pre code {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: inherit;
  padding: 0;
}

.highlight {
  background: transparent;
}

.highlight pre code[class*="language-"]::before {
  background: color-mix(in srgb, var(--accent) 18%, var(--code-bg));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 0 0.4rem 0 0.4rem;
  color: var(--accent-strong);
  font-size: 0.62rem;
  right: 0;
  top: 0;
}

blockquote {
  background: var(--surface);
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 0 0.5rem 0.5rem 0;
  color: var(--text-soft);
  margin: 2rem 0;
  padding: 0.8rem 1.35rem;
}

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

figure {
  display: block;
  margin: 3rem 50%;
  max-width: none;
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 2rem));
}

figure img,
img {
  border: 0;
  border-radius: 0.65rem;
  display: block;
  height: auto;
  max-height: none;
  max-width: 100%;
}

figure img {
  box-shadow: var(--shadow);
  width: 100%;
}

figure figcaption,
figure h4 {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  margin: 0.85rem auto 0;
  max-width: 680px;
  text-align: center;
}

figure figcaption p {
  margin: 0;
}

math[display="block"] {
  font-size: 1.05em;
  margin: 2rem 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0;
}

table {
  border-collapse: collapse;
  display: block;
  margin: 2rem 0;
  max-width: 100%;
  overflow-x: auto;
}

table th,
table td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.8rem;
}

table th {
  background: var(--surface);
  font-size: 0.85rem;
}

.article-toc {
  position: sticky;
  top: 2rem;
}

.toc-inner {
  border-left: 1px solid var(--border);
  padding-left: 1.15rem;
}

.toc-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 0 0 0.9rem;
  text-transform: uppercase;
}

#TableOfContents ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#TableOfContents ul ul {
  border-left: 1px solid var(--border);
  margin: 0.45rem 0 0.45rem 0.2rem;
  padding-left: 0.8rem;
}

#TableOfContents li {
  line-height: 1.35;
  margin: 0.55rem 0;
}

#TableOfContents a {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.76rem;
  text-decoration: none;
}

#TableOfContents a:hover {
  color: var(--accent-strong);
}

.article-footer {
  border-top: 1px solid var(--border);
  margin-top: 5rem;
  padding-top: 2rem;
}

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

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

.post-tags .tags a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.7rem;
  text-decoration: none;
}

.post-tags .tags a:hover {
  background: var(--inline-code-bg);
  color: var(--accent-strong);
}

.draft-label {
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  margin-left: 0.15rem;
  padding: 0.15rem 0.42rem;
  text-transform: uppercase;
}

.post-navigation {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 2.5rem;
}

.post-navigation a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  display: block;
  padding: 1rem;
  text-decoration: none;
}

.post-navigation a:hover {
  background: var(--surface-raised);
}

.post-navigation-label {
  color: var(--muted);
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.post-navigation-title {
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.35;
}

.post-navigation-next {
  text-align: right;
}

.site-description {
  display: block;
  margin: 0 0 4rem;
  max-width: 720px;
}

.site-description p {
  color: var(--text-soft);
  font-size: clamp(1.35rem, 4vw, 2.25rem);
  letter-spacing: -0.035em;
  line-height: 1.3;
}

.list-item {
  border-top: 1px solid var(--border);
  padding: 2.2rem 0;
}

.list-item .title {
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

.list-item .title a {
  text-decoration: none;
}

.list-item time,
.posts .meta,
time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.page-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  letter-spacing: -0.05em;
  margin-bottom: 3rem;
}

.posts {
  list-style: none;
  padding: 0;
}

.posts .post {
  align-items: baseline;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1.2rem 0;
}

.posts .post > a {
  text-decoration: none;
}

.site-footer {
  align-items: center;
  border-top: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  font-family: var(--mono);
  font-size: 0.68rem;
  justify-content: space-between;
  margin-top: clamp(5rem, 10vw, 8rem);
  padding: 2rem 0 2.5rem;
}

.site-footer p {
  font-family: inherit;
  margin: 0;
}

.site-footer-nav {
  display: flex;
  gap: 1rem;
}

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

.site-footer a:hover {
  color: var(--accent-strong);
}

@media (min-width: 900px) {
  .body > pre,
  .body > .highlight {
    margin-left: -1rem;
    margin-right: -1rem;
  }

  .body > .highlight pre {
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 1040px) {
  .article-layout {
    display: block;
    max-width: 760px;
  }

  .article-toc {
    display: none;
  }
}

@media (max-width: 620px) {
  html {
    font-size: 16px;
  }

  .content {
    padding: 0 1rem;
  }

  .site-header {
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 3.5rem;
  }

  .site-nav {
    gap: 0.7rem;
    justify-content: flex-end;
  }

  .article-title {
    font-size: clamp(2rem, 10.5vw, 2.8rem);
  }

  .article-header {
    margin-bottom: 3rem;
  }

  .body h2 {
    margin-top: 3.5rem;
  }

  pre {
    border-left: 0;
    border-radius: 0.45rem;
    border-right: 0;
    font-size: 0.78rem;
    margin-left: -0.35rem;
    margin-right: -0.35rem;
    padding: 1.1rem;
  }

  .post-navigation {
    grid-template-columns: 1fr;
  }

  .post-navigation-next {
    text-align: left;
  }

  .posts .post,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}
