:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --paper: #fffdf8;
  --text: #20211e;
  --muted: #6f6a60;
  --faint: #78736b;
  --soft: #ebe5da;
  --line: #d9d1c4;
  --accent: #934127;
  --accent-soft: #f1ded6;
  --cool: #3b687a;
  --cool-soft: #e6eef1;
  --max: 1120px;
  --article: 720px;
  --article-wide: 880px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--accent);
  z-index: 1000;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: opacity 200ms var(--ease-out);
  will-change: transform;
}

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern";
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 34%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease), background-color 160ms var(--ease), border-color 160ms var(--ease);
}

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

a:active {
  opacity: 0.7;
}

a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 62%, transparent);
  outline-offset: 4px;
  border-radius: 3px;
}

::selection {
  background: color-mix(in srgb, var(--accent-soft) 78%, white);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.page-shell {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 34px 0 72px;
}

.brand {
  display: grid;
  gap: 2px;
  text-decoration: none;
}

.brand span {
  font-size: 1.02rem;
  font-weight: 720;
  line-height: 1.2;
}

.brand span::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 0.42em;
  margin-bottom: 0.1em;
  background: var(--accent);
  border-radius: 1px;
  vertical-align: middle;
}

.brand small,
.site-nav,
.section-label,
.muted,
.site-footer {
  color: var(--muted);
  font-size: 0.84rem;
}

.archive-list time,
.featured-year {
  font-variant-numeric: tabular-nums;
}

.brand small {
  line-height: 1.35;
  transition: color 160ms var(--ease);
}

.site-nav {
  display: flex;
  gap: 20px;
  line-height: 1.2;
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
}

.intro-section,
.content-section {
  display: grid;
  grid-template-columns: minmax(118px, 0.255fr) minmax(0, 1fr);
  gap: 40px;
  padding: 0 0 84px;
}

.content-section {
  border-top: 1px solid var(--line);
  padding-top: 44px;
}

.section-label {
  padding-top: 0.5rem;
  color: var(--faint);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
  text-wrap: balance;
}

h1 {
  max-width: 900px;
  font-size: clamp(3.35rem, 10.2vw, 6rem);
  font-weight: 780;
  line-height: 0.98;
}

.intro-section h1::after {
  content: '';
  display: block;
  width: 2.6em;
  height: 1px;
  margin-top: 0.22em;
  background: var(--accent);
  opacity: 0.5;
}

h2 {
  margin-bottom: 30px;
  max-width: 760px;
  font-size: clamp(2.4rem, 5.7vw, 4.7rem);
  font-weight: 700;
  line-height: 0.98;
}

h3 {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 680;
}

.site-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
}

.intro-copy {
  max-width: 740px;
  margin: 28px 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.16rem, 2.25vw, 1.62rem);
  line-height: 1.52;
}

.intro-links {
  display: flex;
  gap: 20px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.home-image {
  width: min(100%, var(--article-wide));
  margin: 42px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.home-image img {
  width: 100%;
  aspect-ratio: 3 / 1;
  border-radius: 3px;
  object-fit: cover;
  object-position: center 58%;
  filter: saturate(0.88) contrast(0.96) brightness(1.02);
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.featured-empty {
  grid-column: 1 / -1;
  padding: 36px 26px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.featured-empty p {
  margin: 0;
}

.featured-empty code {
  border-radius: 3px;
  padding: 0.1em 0.32em;
  background: var(--accent-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.featured-item {
  background: var(--bg);
}

.featured-item + .featured-item {
  border-left: 1px solid var(--line);
}

.featured-item a {
  position: relative;
  display: flex;
  min-height: 214px;
  padding: 24px 26px 22px;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  transition: transform 320ms var(--ease-out), background 280ms var(--ease);
}

.featured-item a:hover {
  background: color-mix(in srgb, var(--paper) 76%, var(--accent-soft));
  transform: translateY(-2px);
}

.featured-title {
  font-size: clamp(1.34rem, 2.2vw, 1.85rem);
  font-weight: 720;
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.featured-desc {
  max-width: 34em;
  margin-top: 22px;
  color: var(--muted);
  line-height: 1.45;
}

.featured-year {
  display: block;
  margin-top: 18px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 680;
}

.archive {
  display: grid;
  gap: 30px;
}

.archive-year {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 24px;
  padding-top: 2px;
}

.archive-year h3 {
  position: relative;
  padding-left: 14px;
}

.archive-year h3::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.38em;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 1px;
}

.archive-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 18px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  transition: background 200ms var(--ease-out);
}

.archive-list li:first-child {
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.archive-list li:hover {
  background: color-mix(in srgb, var(--accent-soft) 18%, transparent);
}

.archive-list a {
  overflow-wrap: anywhere;
}

.archive-list time {
  color: var(--faint);
  font-size: 0.82rem;
  text-align: right;
}

.site-footer {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 42px 0 38px;
  border-top: 1px solid var(--line);
}

.site-footer::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  width: 2rem;
  height: 2px;
  background: var(--accent);
}

.site-footer p {
  margin: 0;
}

.site-footer p:first-child {
  display: flex;
  gap: 10px;
}

.article-shell {
  display: block;
}

.article {
  width: 100%;
  max-width: var(--article-wide);
  margin: 0 auto;
  min-width: 0;
}


.article {
  width: 100%;
  max-width: var(--article-wide);
  margin: 0 auto;
  min-width: 0;
}

.article-header {
  padding-bottom: 42px;
}

.article-rule {
  width: 3rem;
  height: 2px;
  margin: 28px 0 0;
  background: var(--accent);
}

.article-header h1 {
  margin-top: 24px;
  max-width: var(--article-wide);
  font-size: clamp(2.24rem, 4.7vw, 3.9rem);
  line-height: 1.14;
  font-weight: 740;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.article-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45em;
  margin-top: 20px;
  max-width: var(--article);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.article-meta-sep {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 0.35em;
  vertical-align: middle;
  opacity: 0.6;
}

.article-meta-desc {
  color: var(--muted);
}

.back-link {
  color: var(--muted);
  font-size: 0.86rem;
}

.back-link + h1 {
  margin-top: 36px;
}

.back-link::before {
  content: "←";
  margin-right: 0.35em;
}

.article-desc {
  margin: 20px 0 0;
  width: 100%;
  max-width: var(--article);
  color: var(--muted);
  font-size: clamp(1.08rem, 1.8vw, 1.25rem);
  line-height: 1.58;
}

.article-footer {
  max-width: var(--article);
  padding-top: 32px;
  padding-bottom: 32px;
  border-top: 1px solid var(--line);
}

.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 280ms var(--ease-out), transform 280ms var(--ease-out), color 160ms var(--ease), border-color 160ms var(--ease), background-color 160ms var(--ease);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 6%, transparent);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.back-to-top:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 62%, transparent);
  outline-offset: 3px;
}

/* ── Table of contents (sidebar) ── */
.toc {
  display: none;
}

@media (min-width: 1100px) {
  .article-shell:has(.toc) {
    display: grid;
    grid-template-columns: minmax(0, var(--article)) 220px;
    gap: 56px;
    align-items: start;
  }

  .toc {
    display: block;
    position: sticky;
    top: 96px;
    max-height: calc(100vh - 144px);
    overflow: hidden;
  }

  .toc-label {
    display: block;
    margin-bottom: 14px;
    color: var(--faint);
    font-size: 0.72rem;
    font-weight: 680;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .toc-nav {
    max-height: calc(100vh - 208px);
    overflow-y: auto;
    scrollbar-width: none;
  }

  .toc-nav::-webkit-scrollbar {
    display: none;
  }

  .toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-left: 1px solid var(--line);
  }

  .toc-list li {
    margin: 0;
  }

  .toc-list a {
    display: block;
    padding: 4px 0 4px 14px;
    border-left: 2px solid transparent;
    margin-left: -1px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
    text-decoration: none;
    transition: color 200ms var(--ease), border-color 200ms var(--ease);
  }

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

  .toc-list a.active {
    color: var(--accent);
    border-left-color: var(--accent);
  }

  .toc-level-3 a {
    padding-left: 28px;
    font-size: 0.78rem;
  }

  .toc-level-4 a {
    padding-left: 40px;
    font-size: 0.74rem;
  }

  .toc-level-5 a,
  .toc-level-6 a {
    padding-left: 50px;
    font-size: 0.72rem;
  }
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  transition: border-color 160ms var(--ease), color 160ms var(--ease);
}

.tags a {
  text-decoration: none;
}

.tags a:hover span,
.tags a:focus-visible span {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.article-body {
  width: 100%;
  max-width: var(--article);
  padding-bottom: 80px;
  font-family: Georgia, "Iowan Old Style", "Charter", "Source Serif Pro", serif;
}

.article-body::after {
  content: '◆';
  display: block;
  margin-top: 2.6rem;
  color: var(--accent);
  font-size: 0.52rem;
  letter-spacing: 0.3em;
  opacity: 0.45;
  text-align: center;
}

.article-body > p:first-of-type {
  font-size: 1.1rem;
  color: color-mix(in srgb, var(--text) 85%, var(--muted));
  line-height: 1.7;
}

.article-body > * + * {
  margin-top: 1em;
}

.article-body > .table-scroll + *,
.article-body > pre + *,
.article-body > blockquote + *,
.article-body > figure + * {
  margin-top: 1.35em;
}

.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  margin-top: 2.1em;
  line-height: 1.22;
}

.article-body h2 {
  font-size: clamp(1.5rem, 2.4vw, 1.78rem);
}

.article-body h3 {
  color: var(--text);
  font-size: 1.28rem;
}

.article-body h4,
.article-body h5,
.article-body h6 {
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 720;
}

.article-body p,
.article-body li,
.article-body th,
.article-body td {
  font-size: 1.05rem;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.article-body ul,
.article-body ol {
  padding-left: 1.35rem;
}

.article-body li + li {
  margin-top: 0.32em;
}

.article-body li > ul,
.article-body li > ol {
  margin-top: 0.32em;
  padding-left: 1.2rem;
}

.article-body li > p {
  margin: 0.45em 0;
}

.article-body .task-list-item {
  list-style: none;
  margin-left: -1.35rem;
}

.task-list-item-checkbox {
  width: 0.95em;
  height: 0.95em;
  margin: 0 0.55em 0 0;
  vertical-align: -0.12em;
  accent-color: var(--accent);
}

.article-body a {
  overflow-wrap: anywhere;
}

.article-body blockquote {
  margin-right: 0;
  margin-left: 0;
  padding: 0.75rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in srgb, var(--cool-soft) 60%, transparent);
  color: var(--muted);
}

.article-body blockquote > :first-child {
  margin-top: 0;
}

.article-body blockquote > :last-child {
  margin-bottom: 0;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.article-body table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.article-body th,
.article-body td {
  padding: 0.7rem 0.85rem 0.72rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  text-align: left;
  vertical-align: top;
}

.article-body th {
  color: var(--text);
  font-weight: 720;
  line-height: 1.42;
  white-space: nowrap;
}

.article-body td {
  color: color-mix(in srgb, var(--text) 92%, var(--muted));
}

.article-body tr:last-child td {
  border-bottom: 0;
}

.article-body th[style*="right"],
.article-body td[style*="right"] {
  text-align: right;
  white-space: nowrap;
}

.article-body pre ::selection {
  background: color-mix(in srgb, var(--cool) 18%, transparent);
}

.article-body pre {
  position: relative;
  overflow-x: auto;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--cool-soft);
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}

.article-body pre .hljs {
  background: transparent;
  padding: 0;
}

/* custom highlight.js theme — brand-matched, WCAG AA on cool-soft */
.article-body .hljs-keyword,
.article-body .hljs-selector-tag,
.article-body .hljs-selector-class,
.article-body .hljs-selector-id { color: #9a3e20; }       /* deep warm amber, 5.79:1 */

.article-body .hljs-string,
.article-body .hljs-regexp,
.article-body .hljs-tag .hljs-name,
.article-body .hljs-template-tag { color: #3b687a; }      /* cool teal, 5.18:1 */

.article-body .hljs-comment,
.article-body .hljs-quote { color: #6a665e; font-style: italic; }  /* darker muted, 4.86:1 */

.article-body .hljs-number { color: #934127; }            /* accent rust, 5.90:1 */

.article-body .hljs-literal,
.article-body .hljs-symbol,
.article-body .hljs-bullet { color: #6f6a60; }            /* muted, distinct from number */

.article-body .hljs-title,
.article-body .hljs-function .hljs-title,
.article-body .hljs-section { color: #20211e; font-weight: 680; }

.article-body .hljs-type,
.article-body .hljs-class .hljs-title { color: #3d5a28; } /* deep olive, 6.64:1 */

.article-body .hljs-built_in,
.article-body .hljs-params { color: #5c564e; }            /* slightly darker muted, 5.24:1 */

.article-body .hljs-meta,
.article-body .hljs-meta .hljs-keyword { color: #634a2e; } /* deep brown, 7.01:1 */

.article-body .hljs-tag,
.article-body .hljs-name { color: #3b687a; }

.article-body .hljs-attr,
.article-body .hljs-attribute { color: #9a3e20; }

.article-body .hljs-selector-attr,
.article-body .hljs-selector-pseudo { color: #3d5a28; }

.article-body .hljs-variable,
.article-body .hljs-template-variable { color: #20211e; }

.article-body .hljs-addition { color: #3d5a28; }
.article-body .hljs-deletion { color: #934127; }

.article-body .hljs-emphasis { font-style: italic; }
.article-body .hljs-strong { font-weight: 680; }

.article-body .hljs-link { color: #3b687a; text-decoration: underline; }
.article-body .hljs-link:hover { color: var(--accent); }

.code-lang {
  position: absolute;
  top: 0;
  left: 12px;
  padding: 1px 6px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 680;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 160ms var(--ease);
  pointer-events: none;
}

.article-body pre:hover .code-lang {
  opacity: 1;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms var(--ease), transform 120ms var(--ease-out);
}

.copy-btn:active {
  transform: scale(0.92);
}

.copy-btn:focus-visible {
  opacity: 1;
  outline: 2px solid color-mix(in srgb, var(--accent) 62%, transparent);
  outline-offset: 2px;
}

.article-body pre:hover .copy-btn {
  opacity: 1;
}

.article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.article-body strong {
  font-weight: 700;
}

.article-body del {
  opacity: 0.6;
}

.article-body ins {
  text-decoration: none;
  background: color-mix(in srgb, var(--cool-soft) 52%, transparent);
  padding: 0.05em 0.15em;
  border-radius: 2px;
}

.article-body mark {
  background: color-mix(in srgb, var(--accent-soft) 62%, transparent);
  color: inherit;
  padding: 0.05em 0.15em;
  border-radius: 2px;
}

.article-body kbd {
  display: inline-block;
  padding: 0.08em 0.4em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in srgb, var(--paper) 82%, var(--bg));
  box-shadow: 0 1px 0 var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
  line-height: 1.45;
  vertical-align: 0.1em;
}

.article-body sub {
  font-size: 0.76em;
  line-height: 0;
  vertical-align: sub;
}

.article-body details {
  margin: 1.35em 0;
  padding: 0.85rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.article-body summary {
  font-weight: 680;
  cursor: pointer;
  margin: -0.85rem -1.05rem;
  padding: 0.85rem 1.05rem;
  border-radius: 6px;
  transition: background 160ms var(--ease);
}

.article-body summary:hover {
  background: color-mix(in srgb, var(--accent-soft) 28%, transparent);
}

.article-body summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 62%, transparent);
  outline-offset: -2px;
}

.article-body details[open] summary {
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.85rem;
}

.article-body abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 0.18em;
  cursor: help;
}

.article-body dl {
  margin: 1.35em 0;
}

.article-body dt {
  margin-top: 0.85em;
  font-weight: 680;
}

.article-body dd {
  margin-left: 1.35rem;
  margin-top: 0.25em;
}

.article-body :not(pre) > code {
  border-radius: 4px;
  padding: 0.1em 0.32em;
  background: var(--accent-soft);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article-body sup {
  font-size: 0.72em;
  line-height: 0;
}

.article-body a code {
  color: inherit;
}

.article-body sup a {
  text-decoration: none;
}

.article-body img {
  margin: 1.55rem 0;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.article-body hr {
  margin: 2.4rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.footnotes {
  margin-top: 2.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.footnotes ol {
  margin-bottom: 0;
  padding-left: 1.25rem;
}

.footnotes li,
.footnotes p {
  font-size: 0.92rem;
  line-height: 1.68;
}

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

.article-body .katex-display {
  margin: 1.55rem 0;
  padding: 1.05rem 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  overflow-x: auto;
  overflow-y: hidden;
}

.article-body .katex {
  font-size: 1.05em;
}

@media (prefers-color-scheme: dark) {
  .article-body .katex-display {
    border-color: color-mix(in srgb, var(--line) 70%, transparent);
  }
}

.heading-anchor {
  margin-left: 0.35em;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 160ms var(--ease);
}

h2:hover .heading-anchor,
h3:hover .heading-anchor {
  opacity: 1;
}

.js .home-section-animate,
.js .reveal-on-scroll {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out);
}

.home-section-animate.visible,
.reveal-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

.home-section-animate:nth-child(1) { transition-delay: 60ms; }
.home-section-animate:nth-child(2) { transition-delay: 140ms; }
.home-section-animate:nth-child(3) { transition-delay: 220ms; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
  }

  .js .home-section-animate,
  .js .reveal-on-scroll {
    opacity: 1;
    transform: none;
  }

  .back-to-top {
    opacity: 0;
    transform: none;
  }

  .back-to-top.visible {
    opacity: 1;
  }
}

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

  .page-shell {
    width: min(100% - 30px, var(--max));
  }

  .site-header,
  .site-footer {
    display: grid;
  }

  .site-header {
    padding: 34px 0 58px;
  }

  .intro-section,
  .content-section,
  .archive-year {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .intro-section,
  .content-section {
    padding-bottom: 58px;
  }

  h1 {
    font-size: clamp(3.15rem, 17vw, 4.9rem);
    line-height: 1;
  }

  h2 {
    margin-bottom: 26px;
    font-size: clamp(2.15rem, 12vw, 3.35rem);
  }

  .article-header h1 {
    font-size: clamp(1.86rem, 7.35vw, 2.32rem);
    line-height: 1.18;
    text-wrap: auto;
    word-break: break-word;
  }

  .intro-copy {
    margin-top: 22px;
    padding-top: 0.5rem;
    font-size: 1.12rem;
    line-height: 1.56;
  }

  .intro-links {
    margin-top: 24px;
  }

  .home-image {
    margin-top: 34px;
    padding: 8px 0;
  }

  .home-image img {
    aspect-ratio: 3 / 1;
  }

  .featured-grid {
    grid-template-columns: 1fr;
  }

  .featured-item + .featured-item {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .featured-item a {
    min-height: 172px;
    padding: 22px;
  }

  .featured-title {
    font-size: clamp(1.35rem, 7vw, 1.8rem);
  }

  .archive-list li {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 13px 0;
  }

  .archive-list time {
    text-align: left;
    font-size: 0.78rem;
  }

  .article-header {
    padding-bottom: 34px;
  }

  .article-rule {
    width: 2.4rem;
    margin-top: 24px;
  }

  .article-body p,
  .article-body li {
    line-height: 1.62;
  }

  .article-body ul,
  .article-body ol {
    padding-left: 1.16rem;
  }

  .article-body .task-list-item {
    margin-left: -1.16rem;
  }

  .table-scroll {
    margin-right: -15px;
    padding-right: 15px;
  }

  .article-body table {
    min-width: 560px;
  }

  .article-body th,
  .article-body td {
    padding-top: 0.62rem;
    padding-bottom: 0.64rem;
  }

  .article-body pre {
    padding: 16px 18px;
  }

  .site-footer {
    padding-bottom: 32px;
  }

  .back-to-top {
    bottom: 24px;
    right: 20px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --paper: #1d1a17;
    --text: #c7c1b7;
    --muted: #a0988e;
    --faint: #928a82;
    --soft: #282420;
    --line: #332e28;
    --accent: #c47455;
    --accent-soft: #2a1d17;
    --cool: #6b9ab0;
    --cool-soft: #192227;
  }

  body::before {
    opacity: 0.025;
  }

  .home-image img {
    filter: saturate(0.78) contrast(0.92) brightness(0.82);
  }

  .featured-item a:hover {
    background: color-mix(in srgb, var(--paper) 76%, var(--accent-soft));
  }

  .article-body p,
  .article-body li,
  .article-body th,
  .article-body td {
    line-height: 1.72;
  }

  .article-body {
    letter-spacing: 0.002em;
  }

  .article-body > p:first-of-type {
    color: color-mix(in srgb, var(--text) 88%, var(--muted));
  }

  .article-body pre {
    background: color-mix(in srgb, var(--cool-soft) 85%, var(--bg));
  }

  .article-body pre ::selection {
    background: color-mix(in srgb, var(--cool) 24%, transparent);
  }

  .article-body :not(pre) > code {
    background: color-mix(in srgb, var(--accent-soft) 75%, var(--bg));
  }

  .article-body blockquote {
    background: color-mix(in srgb, var(--cool-soft) 40%, transparent);
  }

  .tags span {
    background: color-mix(in srgb, var(--paper) 72%, transparent);
  }

  .taxonomy-item {
    background: color-mix(in srgb, var(--paper) 72%, transparent);
  }

  .copy-btn {
    border-color: var(--line);
    background: color-mix(in srgb, var(--paper) 85%, var(--bg));
  }

  .back-to-top {
    background: var(--paper);
    border-color: var(--line);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 12%, transparent);
  }

  .archive-list li:hover {
    background: color-mix(in srgb, var(--accent-soft) 24%, transparent);
  }

  .intro-links a,
  .site-nav a,
  .back-link {
    color: var(--muted);
  }

  a:focus-visible {
    outline-color: color-mix(in srgb, var(--accent) 56%, transparent);
  }

  .article-body .hljs-keyword,
  .article-body .hljs-selector-tag,
  .article-body .hljs-selector-class,
  .article-body .hljs-selector-id { color: #d4896a; }

  .article-body .hljs-string,
  .article-body .hljs-regexp,
  .article-body .hljs-tag .hljs-name,
  .article-body .hljs-template-tag { color: #7eb8cc; }

  .article-body .hljs-comment,
  .article-body .hljs-quote { color: #8e867d; }

  .article-body .hljs-number { color: #d4896a; }

  .article-body .hljs-literal,
  .article-body .hljs-symbol,
  .article-body .hljs-bullet { color: #9e978c; }

  .article-body .hljs-title,
  .article-body .hljs-function .hljs-title,
  .article-body .hljs-section { color: #c7c1b7; }

  .article-body .hljs-type,
  .article-body .hljs-class .hljs-title { color: #9bbf7a; }

  .article-body .hljs-built_in,
  .article-body .hljs-params { color: #9e978c; }

  .article-body .hljs-meta,
  .article-body .hljs-meta .hljs-keyword { color: #b8a088; }

  .article-body .hljs-tag,
  .article-body .hljs-name { color: #7eb8cc; }

  .article-body .hljs-attr,
  .article-body .hljs-attribute { color: #d4896a; }

  .article-body .hljs-selector-attr,
  .article-body .hljs-selector-pseudo { color: #9bbf7a; }

  .article-body .hljs-variable,
  .article-body .hljs-template-variable { color: #c7c1b7; }

  .article-body .hljs-addition { color: #9bbf7a; }
  .article-body .hljs-deletion { color: #d4896a; }

  .article-body .hljs-link { color: #7eb8cc; }

  .article-body ins {
    background: color-mix(in srgb, var(--cool-soft) 60%, var(--bg));
  }

  .article-body mark {
    background: color-mix(in srgb, var(--accent-soft) 55%, var(--bg));
  }

  .article-body kbd {
    background: color-mix(in srgb, var(--paper) 80%, var(--bg));
    box-shadow: 0 1px 0 var(--line);
  }

  .article-body details {
    border-color: var(--line);
  }

  .article-body details[open] summary {
    border-color: var(--line);
  }

}

/* ── Taxonomy (tags) pages ── */
.taxonomy-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: var(--article);
  padding-bottom: 80px;
}

.taxonomy-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
  line-height: 1.4;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  transition: border-color 160ms var(--ease), color 160ms var(--ease), background-color 160ms var(--ease);
}

.taxonomy-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.taxonomy-count {
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 680;
}

.term-posts {
  max-width: var(--article);
}

@media print {
  .site-header,
  .site-nav,
  .site-footer,
  .reading-progress,
  .back-to-top,
  .section-label {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  body::before {
    display: none;
  }

  .page-shell {
    width: 100%;
    max-width: none;
  }

  .article,
  .article-body,
  .article-header h1 {
    max-width: none;
  }

  .article-body {
    font-family: Georgia, "Iowan Old Style", "Charter", serif;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  pre,
  blockquote {
    border: 1px solid #ccc;
    background: none;
  }

  .article-body pre {
    background: none;
  }
}
