:root {
  color-scheme: light;
  --paper: #fcfbf8;
  --ink: #211e1b;
  --muted: #726b64;
  --link: #793229;
  --rule: #ded9d1;
  --stripe: #f5f2ec;
  --code-paper: #fffefa;
  --site-width: min(79vw, 64rem);
  --article-gap: clamp(2rem, 5.6vw, 4.5rem);
  --body-copy: "Minion 3", Georgia, serif;
  --code-copy: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body-copy);
  font-size: 1rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

img,
iframe,
video,
svg {
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: var(--link);
  text-decoration-color: rgba(121, 50, 41, 0.35);
  text-underline-offset: 0.14em;
  text-decoration-thickness: 0.055em;
}

a:hover,
a:focus-visible {
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

button,
summary {
  font: inherit;
}

.wrapper {
  width: var(--site-width);
  max-width: none;
  margin-inline: auto;
  padding-inline: 0;
}

.site-header {
  min-height: 0;
  margin: 0;
  padding: 1.35rem 0 1.7rem;
  border: 0;
}

.site-header .wrapper {
  position: relative;
}

.blog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

@media (min-width: 701px) {
  .blog-header {
    min-height: 3.4rem;
  }
}

.header-left h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
}

.site-wordmark {
  color: var(--link);
  font-family: var(--body-copy);
  font-size: 0.84rem;
  letter-spacing: 0.18em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.site-navigation details > summary {
  display: none;
}

.site-navigation {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 1.8vw, 1.45rem);
}

.site-nav-links,
.site-navigation details:not([open]) > .site-nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(0.8rem, 1.8vw, 1.45rem);
}

.site-nav-about,
.site-nav-links a {
  color: var(--link);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.site-nav-links a:hover,
.site-nav-links a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.page-content {
  padding: 1.4rem 0 4rem;
}

.page-content > .wrapper {
  width: var(--site-width);
}

.post,
.page {
  margin: 0;
}

.page {
  width: 100%;
  max-width: 48rem;
  margin-inline: auto;
}

.page-title,
.post-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.8rem, 3vw, 2.3rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.08;
}

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  min-width: 0;
}

.post-layout--sidenotes {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  column-gap: var(--article-gap);
}

.post-layout:not(.post-layout--sidenotes) .post {
  width: 100%;
  max-width: 48rem;
  margin-inline: auto;
}

.post-header {
  margin: 0 0 1.2rem;
}

.post-description {
  margin: 0.85rem 0 1rem;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.4;
}

.post-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin: clamp(1.5rem, 2.5vw, 2rem) 0 0.45rem;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.post-action-link,
.post-toc summary {
  display: inline-flex;
  align-items: center;
  min-height: 1.25rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid #c9c3ba;
  border-radius: 3px;
  background: #f5f2ec;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1.2;
  text-decoration: none;
}

.post-action-link:hover,
.post-toc summary:hover {
  background: #ece7de;
  text-decoration: none;
}

.post-date {
  color: var(--ink);
  font-size: 1rem;
  white-space: nowrap;
}

.post-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.post-meta-footer {
  margin: 1.5rem 0 0;
}

.post-tags {
  display: inline;
}

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

.post-tags a:hover {
  color: var(--link);
  text-decoration: underline;
}

.post-toc {
  position: relative;
  margin: 0;
}

.post-toc summary {
  list-style: none;
}

.post-toc summary::-webkit-details-marker {
  display: none;
}

.post-toc ul {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.45rem);
  left: 0;
  width: min(34rem, 78vw);
  max-height: min(60vh, 32rem);
  overflow: auto;
  margin: 0;
  padding: 0.85rem 1rem 0.85rem 2rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  box-shadow: 0 0.4rem 1.4rem rgba(28, 22, 16, 0.12);
}

.post-toc li {
  margin: 0.3rem 0;
  color: var(--ink);
  font-size: 0.88rem;
}

.post-toc li.toc-level-3 {
  margin-left: 0.8rem;
  list-style-type: circle;
}

.post-toc a {
  text-decoration: none;
}

.post-toc a:hover {
  text-decoration: underline;
}

.post-content {
  min-width: 0;
  color: var(--ink);
  font-size: 1.125rem;
  line-height: 1.47;
}

.post-content p {
  margin: 0 0 1.18rem;
  text-align: justify;
}

.page-content-body p {
  text-align: left;
}

.post-content li,
.post-content blockquote {
  font-size: 1.04rem;
  line-height: 1.48;
}

.post-content li {
  margin-block: 0.25rem;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--ink);
  font-weight: 400;
  line-height: 1.2;
  scroll-margin-top: 1.5rem;
}

.post-content h2 {
  margin: 2rem 0 0.7rem;
  font-size: 1.65rem;
}

.post-content h3 {
  margin: 1.65rem 0 0.55rem;
  font-size: 1.3rem;
}

.post-content h4 {
  margin: 1.35rem 0 0.5rem;
  font-size: 1.12rem;
}

.heading-link {
  color: inherit;
  text-decoration: none;
}

.heading-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--rule);
}

.post-content blockquote {
  margin: 1.2rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid #b9a89a;
  color: #504942;
  font-style: normal;
  letter-spacing: normal;
}

.post-content code,
.post-content kbd {
  font-family: var(--code-copy);
  font-size: 0.82em;
}

.post-content p code,
.post-content li code,
.post-content td code,
.post-content th code {
  padding: 0.05em 0.2em;
  background: #f1eee8;
  overflow-wrap: anywhere;
}

.post-content pre,
.post-content .highlight {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #c9c3ba;
  border-radius: 4px;
  background: var(--code-paper);
}

.post-content pre {
  margin: 1rem 0 1.2rem;
  padding: 0.9rem 1rem;
  line-height: 1.4;
  tab-size: 2;
  white-space: pre;
}

.post-content .highlight pre {
  margin: 0;
  border: 0;
  background: transparent;
}

.post-content pre code {
  padding: 0;
  background: transparent;
  font-size: 0.8em;
  overflow-wrap: normal;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  margin: 1.1rem 0 1.35rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: #b9b1a6 transparent;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 0.89rem;
  line-height: 1.35;
  text-align: left;
}

.post-content th,
.post-content td {
  min-width: 0;
  padding: 0.42rem 0.55rem;
  border-bottom: 1px solid #e4e0d8;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table-scroll:not(.table-scroll--wide) table {
  table-layout: fixed;
}

.post-content th {
  font-weight: 500;
}

.post-content tbody tr:nth-child(even) {
  background: var(--stripe);
}

.table-scroll--wide table {
  width: max-content;
  min-width: 100%;
}

.post-content img {
  display: block;
  width: auto;
  max-width: 100%;
  margin: 1.35rem auto;
  height: auto;
}

.post-content figure {
  max-width: 100%;
  margin: 1.35rem 0;
}

.post-content figure img {
  margin: 0 auto;
}

.post-content figcaption,
.post-content p > em:only-child {
  display: block;
  margin: 0.55rem auto 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  text-align: center;
}

.post-content .twitter-tweet,
.post-content .twitter-tweet-rendered {
  max-width: 100% !important;
  margin-inline: auto !important;
}

.post-content .twitter-tweet iframe,
.post-content .twitter-tweet-rendered iframe {
  width: 100% !important;
  max-width: 100% !important;
}

.post-content .mermaid,
.post-content svg {
  max-width: 100%;
}

.post-content .mermaid {
  overflow-x: auto;
}

.post-clap {
  display: flex;
  justify-content: center;
  margin: 2.2rem 0 1rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}

.clap-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.clap-btn:active {
  transform: scale(1.12);
}

.clap-btn.clapped {
  cursor: default;
}

.clap-btn svg {
  width: 36px;
  height: 36px;
}

.clap-count {
  color: var(--muted);
  font-family: var(--code-copy);
  font-size: 0.8rem;
}

.post-comments {
  margin: 1.6rem 0 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 1.5rem;
}

.post-comments iframe {
  max-width: 100%;
}

.define {
  position: relative;
  border-bottom: 1px dotted var(--link);
  cursor: help;
}

.define-tooltip {
  position: absolute;
  z-index: 1000;
  bottom: calc(100% + 0.6rem);
  left: 50%;
  width: max-content;
  max-width: min(20rem, 80vw);
  padding: 0.7rem 0.9rem;
  transform: translateX(-50%);
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  color: var(--ink);
  font-family: var(--body-copy);
  font-size: 0.92rem;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.define-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.define-tooltip.is-flipped {
  top: calc(100% + 0.6rem);
  bottom: auto;
}

.define-tooltip::after,
.define-tooltip::before {
  position: absolute;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  content: "";
}

.define-tooltip::after {
  bottom: -7px;
  border: 7px solid transparent;
  border-top-color: var(--rule);
}

.define-tooltip::before {
  z-index: 1;
  bottom: -6px;
  border: 6px solid transparent;
  border-top-color: var(--paper);
}

.define-tooltip.is-flipped::after {
  top: -7px;
  bottom: auto;
  border-color: transparent;
  border-bottom-color: var(--rule);
}

.define-tooltip.is-flipped::before {
  top: -6px;
  bottom: auto;
  border-color: transparent;
  border-bottom-color: var(--paper);
}

.define-tooltip-term {
  margin-bottom: 0.2rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
}

.define-tooltip-body {
  max-height: 11rem;
  overflow-y: auto;
  color: #39342f;
}

.define-tooltip-close {
  display: none;
}

.excalidraw-embed {
  position: relative;
  max-width: 100%;
  margin: 1.35rem 0;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.excalidraw-embed iframe {
  display: block;
  width: 100%;
  max-width: 100%;
}

.excalidraw-fullscreen-btn {
  position: absolute;
  z-index: 10;
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.35rem 0.8rem;
  border: 0;
  border-radius: 4px;
  background: #302c28;
  color: #fff;
  cursor: pointer;
  font-family: var(--code-copy);
  font-size: 0.75rem;
  opacity: 0.86;
}

.excalidraw-fullscreen-btn:hover {
  opacity: 1;
}

.excalidraw-embed .collapse-label {
  display: none;
}

.excalidraw-embed.is-fullscreen {
  position: fixed;
  z-index: 9999;
  inset: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
}

.excalidraw-embed.is-fullscreen iframe {
  height: 100vh !important;
}

.excalidraw-embed.is-fullscreen .expand-label {
  display: none;
}

.excalidraw-embed.is-fullscreen .collapse-label {
  display: inline;
}

.post-layout--sidenotes .post-content .sidenote {
  float: right;
  clear: right;
  width: 50%;
  margin-top: 0.08em;
  margin-right: calc(0px - 50% - var(--article-gap));
  margin-bottom: 0.9rem;
  color: #39342f;
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: left;
}

.sidenote-toggle[aria-expanded="false"] + .sidenote {
  display: none;
}

.sidenote-paragraph {
  display: block;
  margin-bottom: 0.35rem;
}

.sidenote-toggle {
  display: inline;
  margin: 0;
  padding: 0 0.08em;
  border: 0;
  background: transparent;
  color: var(--link);
  cursor: pointer;
  font-family: var(--body-copy);
  font-size: 0.72em;
  line-height: 1;
  vertical-align: super;
}

.sidenote-toggle:hover {
  text-decoration: underline;
}

.footnotes {
  margin-top: 2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.88rem;
}

.post-content.has-enhanced-sidenotes .footnotes {
  display: none;
}

.home .post-list-heading {
  display: none;
}

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

.home .post-list > li {
  margin: 0 0 1.45rem;
}

.home .post-list .post-meta {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.home .post-list h3 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 400;
  line-height: 1.3;
}

.home .post-list .post-link {
  color: var(--link);
  text-decoration: none;
}

.home .post-list .post-link:hover {
  text-decoration: underline;
}

.home .rss-subscribe {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.tag-cloud {
  margin-bottom: 2rem;
}

.tag-cloud a {
  display: inline-block;
  margin: 0.2rem 0.35rem 0.2rem 0;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--link);
  font-size: 0.82rem;
  text-decoration: none;
}

.tag-cloud a:hover {
  background: var(--stripe);
}

.tag-section h2 {
  margin: 1.8rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1.4rem;
  font-weight: 400;
}

.tag-section ul {
  padding-left: 0;
  list-style: none;
}

.tag-section li {
  margin: 0.4rem 0;
}

.tag-section .post-date {
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer {
  border-top: 1px solid var(--rule);
}

.site-footer .wrapper {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 700px) {
  :root {
    --site-width: 80.5vw;
  }

  .site-header {
    padding: 2.25rem 0 1.2rem;
  }

  .blog-header {
    gap: 1rem;
  }

  .site-navigation details > summary {
    display: block;
    padding: 0.25rem 0;
    color: var(--link);
    cursor: pointer;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    list-style: none;
    text-transform: uppercase;
  }

  .site-navigation details > summary::-webkit-details-marker {
    display: none;
  }

  .site-nav-links,
  .site-navigation details:not([open]) > .site-nav-links {
    display: none;
  }

  .site-navigation details[open] > .site-nav-links {
    position: absolute;
    z-index: 30;
    top: calc(100% + 0.8rem);
    right: 0;
    display: grid;
    min-width: 10rem;
    gap: 0;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--rule);
    background: var(--paper);
    box-shadow: 0 0.4rem 1rem rgba(28, 22, 16, 0.12);
  }

  .site-nav-links a {
    padding: 0.55rem 0;
  }

  .site-nav-about {
    font-size: 0.75rem;
  }

  .page-content {
    padding-top: 2.1rem;
  }

  .post-header {
    margin-bottom: 1.5rem;
  }

  .post-title {
    font-size: 1.65rem;
    line-height: 1.12;
  }

  .post-layout--sidenotes {
    display: block;
  }

  .post-layout--sidenotes .post-content .sidenote {
    display: none;
    float: none;
    width: auto;
    margin: 0.55rem 0 1rem;
    padding: 0.55rem 0.65rem;
    border-left: 2px solid #b78b7f;
    background: var(--stripe);
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .post-layout--sidenotes .sidenote-toggle[aria-expanded="true"] + .sidenote {
    display: block;
  }

  .post-content {
    font-size: 1.08rem;
  }

  .post-content p {
    hyphens: none;
  }

  .post-content th,
  .post-content td {
    padding: 0.34rem 0.38rem;
    font-size: 0.84rem;
  }

  .table-scroll:not(.table-scroll--wide) table {
    table-layout: fixed;
  }

  .table-scroll--wide table {
    width: max-content;
    min-width: 38rem;
    table-layout: auto;
  }

  .post-content pre {
    padding: 0.7rem 0.75rem;
  }

  .post-content pre code {
    font-size: 0.76em;
  }

  .post-action-row {
    align-items: flex-start;
  }

  .post-date {
    margin-left: auto;
    max-width: 4.2rem;
    font-size: 0.92rem;
    line-height: 1.15;
    text-align: right;
    white-space: normal;
  }

  .post-action-row {
    margin-top: 1rem;
  }

  .post-toc ul {
    width: min(82vw, 23rem);
  }

  .define-tooltip-close {
    display: block;
    position: absolute;
    top: 0.25rem;
    right: 0.35rem;
    padding: 0.1rem 0.35rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
  }
}

@media (min-width: 701px) and (max-width: 999px) {
  .post-title {
    font-size: 2rem;
  }

  .post-header {
    margin-bottom: 1.2rem;
  }

  .post-action-row {
    margin-top: 0.7rem;
  }
}

@media (min-width: 1000px) {
  .site-header {
    padding-top: 2.15rem;
  }

  .page-content {
    padding-top: 2.8rem;
  }

  .post-header {
    margin-bottom: 1.6rem;
  }
}

@media (max-width: 360px) {
  .post-title,
  .page-title {
    font-size: 1.85rem;
  }

  .post-actions {
    gap: 0.35rem;
  }

  .post-action-link,
  .post-toc summary {
    padding-inline: 0.4rem;
    font-size: 0.72rem;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
