:root {
  color-scheme: light;
  --font-serif: "Hanken Grotesk";
  --font-mono: "Ubuntu Mono";
  --measure: 68ch;
  --gutter: 2.5rem;
  --lh-base: 1.6;
  --hairline: 0.5px;
  --bg: #ffffff;
  --bg-soft: #f5f5f4;
  --fg: #14181d;
  --fg-soft: #3a4350;
  --fg-mute: #6e7785;
  --rule: #e2e2e0;
  --rule-soft: #ededeb;
  --link: #2c5fde;
  --link-hover: #1d4ed8;
  --code-bg: #f7f7f6;
  --code-fg: #2a2a2a;
  --mark: #fdf3c0;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: var(--lh-base);
  font-variation-settings: "opsz" 14;
  color: var(--fg);
  background: var(--bg);
  font-feature-settings: "kern", "liga", "onum";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; }

a {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 0.2em;
  transition: color 120ms ease;
}
a:hover { color: var(--link-hover); text-decoration: underline; text-decoration-thickness: 1px; }
a:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--mark); color: var(--fg); }

.site-header, .site-footer {
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--fg-mute);
}
.site-header {
  font-size: 0.94rem;
  border-bottom: var(--hairline) solid var(--rule);
  padding: 0.9rem 0;
  margin-bottom: 2.5rem;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.site-header__inner, .site-footer__inner {
  max-width: 90rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.site-footer__inner { justify-content: center; text-align: center; }
.site-brand {
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--fg);
}
.site-nav { margin-left: auto; display: flex; gap: 1.25rem; }
.site-nav a { color: var(--fg-mute); }
.site-nav a:hover { color: var(--link); }
.site-nav a[aria-current="page"] { color: var(--fg); border-bottom: var(--hairline) solid currentColor; }
.site-footer { padding: 1.5rem 0 2rem; margin-top: 5rem; font-size: 0.8rem; }

.article {
  --toc-width: 12rem;
  --sidenote-width: 14rem;
  --sidenote-gap: 2.4rem;
  max-width: 90rem;
  margin: 0 auto;
  padding: 0 var(--gutter) 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: var(--gutter);
  row-gap: 2rem;
}
.article__main {
  min-width: 0;
  max-width: var(--measure);
  counter-reset: sidenote-counter;
}
.article__toc { font-size: 0.8rem; color: var(--fg-soft); min-width: 0; }
.article__toc-marker { display: none; }
.article__toc:empty { border: 0; padding: 0; }

@media (min-width: 1100px) {
  .article {
    grid-template-columns:
      minmax(0, var(--toc-width))
      minmax(0, calc(var(--measure) + var(--sidenote-width) + var(--sidenote-gap)));
    justify-content: center;
    row-gap: 0;
  }
  .article__toc {
    position: sticky;
    top: 15vh;
    align-self: start;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: visible;
    padding: 0 1rem 0 0.85rem;
    border-right: var(--hairline) solid var(--rule-soft);
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
  }
  .article__toc::-webkit-scrollbar { width: 4px; }
  .article__toc::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }
  .article__toc::-webkit-scrollbar-track { background: transparent; }
  .article__toc-marker {
    --toc-marker-size: 5px;
    --toc-marker-gap: 0.5rem;
    display: block;
    position: absolute;
    left: calc(var(--toc-marker-x, 0.85rem) - var(--toc-marker-gap) - var(--toc-marker-size));
    top: 0;
    width: var(--toc-marker-size);
    height: var(--toc-marker-size);
    background: var(--link);
    border-radius: 50%;
    opacity: 0;
    transform: translate3d(0, calc(var(--toc-marker-y, 0px) - 50%), 0);
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      left 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.16s ease-in-out;
    pointer-events: none;
  }
  .article__toc.has-active-marker .article__toc-marker { opacity: 1; }
  .sidenote {
    float: right;
    clear: right;
    width: var(--sidenote-width);
    margin: 0.3rem calc(-1 * (var(--sidenote-width) + var(--sidenote-gap))) 1rem var(--sidenote-gap);
    position: relative;
  }
}

.sidenote-number {
  counter-increment: sidenote-counter;
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
  color: var(--link);
  cursor: pointer;
}
.sidenote-number::after { content: counter(sidenote-counter); }
.sidenote {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--fg-soft);
}
.sidenote::before {
  content: counter(sidenote-counter) " ";
  color: var(--link);
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
  margin-right: 0.25em;
}
@media (max-width: 1099px) {
  .article__toc { display: none; }
  .sidenote {
    display: block;
    margin: 0.6rem 0;
    padding-left: 0.85rem;
    border-left: var(--hairline) solid var(--rule);
  }
}

.post-header { margin: 1rem 0 2.5rem; }
.post-title {
  font-weight: 600;
  font-size: clamp(1.4rem, 1rem + 1.4vw, 1.9rem);
  font-variation-settings: "opsz" 32;
  line-height: 1.2;
  letter-spacing: -0.012em;
  margin: 0 0 0.6rem;
  color: var(--fg);
}
.post-title em { font-style: italic; font-variation-settings: "opsz" 32; }
.post-authors {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
  font-variation-settings: "opsz" 18;
  font-size: inherit;
}
.post-byline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  margin: 0 0 1.4rem;
  font-variation-settings: "opsz" 16;
  font-size: 0.95rem;
  color: var(--fg-soft);
}
.post-byline__sep { color: var(--fg-mute); }
.post-byline time { color: var(--fg-mute); font-variant-numeric: tabular-nums; }
.post-authors li { color: var(--fg-soft); }

.article__toc ol { list-style: none; padding-left: 0; margin: 0; }
.article__toc ol ol { padding-left: 0.7rem; }
.article__toc li { line-height: 1.35; margin: 0.15rem 0; padding: 0.05rem 0 0.05rem 0.5rem; }
.article__toc a { color: var(--fg-mute); transition: color 120ms ease; }
.article__toc a:hover { color: var(--fg); }
.article__toc a[aria-current="location"] { color: var(--fg); }

.prose { color: var(--fg); }
.prose > * + * { margin-top: 1rem; }
.prose h2, .prose h3, .prose h4 {
  font-weight: 600;
  font-variation-settings: "opsz" 28;
  letter-spacing: -0.005em;
  color: var(--fg);
  scroll-margin-top: 6rem;
}
.prose h2 { font-size: 1.55rem; margin: 2.6rem 0 0.8rem; padding-bottom: 0.35rem; border-bottom: var(--hairline) solid var(--rule); }
.prose h3 { font-size: 1.22rem; margin: 1.9rem 0 0.5rem; }
.prose h4 { font-size: 1.05rem; margin: 1.4rem 0 0.3rem; font-style: italic; }
.prose p { margin: 0.9rem 0; max-width: var(--measure); }
.prose strong { font-weight: 700; color: var(--fg); }
.prose em { font-style: italic; }
.prose ul, .prose ol { margin: 0.9rem 0; padding-left: 1.5rem; max-width: var(--measure); }
.prose li { margin: 0.3rem 0; }
.prose li > p { margin: 0.4rem 0; }
.prose ul ul, .prose ol ol, .prose ul ol, .prose ol ul { margin: 0.2rem 0; }
.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.5rem 1.2rem;
  border-left: 2px solid var(--rule);
  color: var(--fg-soft);
  font-style: italic;
  max-width: var(--measure);
}
.prose hr { border: none; border-top: var(--hairline) solid var(--rule); margin: 2.4rem 0; }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--fg);
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  padding: 0.08em 0.32em;
  border-radius: 3px;
}
.prose pre {
  margin: 1.2rem 0;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
  position: relative;
}
.prose pre code {
  font-size: inherit;
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
  white-space: pre;
}
.code-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 0.18rem 0.55rem;
  background: var(--bg);
  color: var(--fg-mute);
  border: var(--hairline) solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}
.prose pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: var(--link); border-color: var(--link); }

.prose math {
  color: var(--link-hover);
  font-size: 1.05em;
  font-family: "STIX Two Math", "Cambria Math", "Noto Sans Math", math, serif;
  font-feature-settings: normal;
  font-variation-settings: normal;
}
.prose math, .prose math * { box-sizing: content-box; }
.prose math[display="block"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.4rem 0;
  margin: 1.4rem 0;
}

.prose figure { margin: 1.8rem 0; text-align: center; }
.prose figure img, .prose figure svg, .prose figure video {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  background: var(--bg);
}
.prose figure figcaption {
  margin-top: 0.6rem;
  font-style: italic;
  font-variation-settings: "opsz" 16;
  font-size: 0.92rem;
  color: var(--fg-mute);
  line-height: 1.55;
}
.prose figure figcaption .label {
  font-family: var(--font-mono);
  font-style: normal;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg);
  margin-right: 0.5em;
}

.prose table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-variation-settings: "opsz" 16;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.prose th, .prose td {
  padding: 0.45rem 0.7rem;
  text-align: left;
  border-bottom: var(--hairline) solid var(--rule-soft);
  vertical-align: top;
  white-space: normal;
}
.prose thead th {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--rule);
}
.prose tbody tr:hover { background: var(--bg-soft); }
.prose table caption {
  caption-side: bottom;
  margin-top: 0.6rem;
  font-style: italic;
  font-variation-settings: "opsz" 16;
  font-size: 0.88rem;
  color: var(--fg-mute);
  text-align: left;
}

.callout {
  margin: 1.2rem 0;
  padding: 0.7rem 1rem;
  background: var(--code-bg);
  border-radius: 6px;
  max-width: var(--measure);
}
.callout__title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--fg-mute);
  margin: 0 0 0.2rem;
}
.callout > p { margin: 0.15rem 0; line-height: 1.5; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.listing, .home { max-width: 50rem; margin: 0 auto; padding: 0 var(--gutter) 4rem; }
.listing__title, .listing__year, .home__section-title {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--fg-mute);
}
.listing__title { margin: 0 0 0.4rem; }
.listing__year { margin: 2.2rem 0 0.5rem; }
.listing > section:first-of-type .listing__year { margin-top: 1.4rem; }
.listing__items { list-style: none; padding: 0; margin: 0; }
.listing__item {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1.1rem;
  align-items: baseline;
  padding: 0.38rem 0;
}
.listing__date {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--fg-mute);
  font-variant-numeric: tabular-nums;
}
.listing__link {
  font-variation-settings: "opsz" 22;
  font-size: 1rem;
  color: var(--link);
}
@media (max-width: 540px) {
  .listing__item { grid-template-columns: 1fr; gap: 0.1rem; padding: 0.5rem 0; }
}

.home__hero { margin: 1rem 0 2.5rem; }
.home__hero:has(.home__avatar) {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1.5rem 2rem;
  align-items: start;
}
.home__avatar img { width: 100%; height: auto; border-radius: 50%; background: var(--bg-soft); }
.home__bio h1 {
  font-style: normal;
  font-weight: 400;
  font-variation-settings: "opsz" 16;
  font-size: 1.05rem;
  letter-spacing: 0;
  line-height: var(--lh-base);
  margin: 0 0 0.5rem;
  color: var(--fg);
}
.home__bio p { margin: 0.5rem 0; }
.home__bio .home__contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
@media (max-width: 600px) {
  .home__hero:has(.home__avatar) { grid-template-columns: 6rem 1fr; gap: 1rem 1.2rem; }
}
.home__section { margin: 2.5rem 0; }
.home__section-title {
  margin: 0 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: var(--hairline) solid var(--rule);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.home__section details summary {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--link);
  transition: color 120ms ease;
}
.home__section details summary:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
.home__section ul { list-style: none; padding: 0; margin: 0; }
.home__section li {
  padding: 0.4rem 0;
  font-variation-settings: "opsz" 18;
  font-size: 1rem;
  line-height: 1.55;
}
.news-date {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85em;
  letter-spacing: 0.04em;
  color: var(--fg);
  margin-right: 0.4rem;
}
.home__section--news a { color: var(--link); }
.home__section details {
  font-variation-settings: "opsz" 18;
  font-size: 1rem;
  margin-top: 0.6rem;
}
.home__section details summary {
  list-style: none;
  cursor: pointer;
  display: inline-block;
  padding: 0.3rem 0;
}
.home__section details summary::-webkit-details-marker { display: none; }
.home__section details summary::marker { content: ""; }
.home__section details ul { margin-top: 0.5rem; }

.text-spotlight { color: #a4161a; font-weight: 600; }

.to-top {
  position: fixed;
  bottom: 1.5rem;
  right: max(1rem, calc((100vw - var(--measure)) / 2 - 3.2rem));
  z-index: 20;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  background: var(--bg);
  color: var(--fg-soft);
  border: var(--hairline) solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  font-size: 1rem;
  line-height: 1;
  transition: opacity 200ms ease, transform 200ms ease, color 120ms ease, border-color 120ms ease;
}
.to-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.to-top:hover { color: var(--link); border-color: var(--link); }

@media print {
  :root { --bg: #fff; --rule: #999; --fg: #000; --fg-soft: #333; --fg-mute: #555; }
  .site-header, .site-footer, .article__toc, .code-copy, .to-top { display: none !important; }
  body { background: white; color: black; background-image: none; }
  .article { display: block; max-width: none; padding: 0; }
  a { color: black; text-decoration: none; }
  .prose pre, .prose code { background: #f4f4f4 !important; color: #111 !important; }
}
