:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #111;
  --muted: #666;
  --faint: #ddd;
  --soft: #f2f2f2;
  --accent: #444;
  --accent-dark: #111;
  --display: "Arial Black", "Avenir Next", "Segoe UI", sans-serif;
  --body: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --ui: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --measure: 70ch;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --text-small: 0.875rem;
  --text-ui: 1rem;
  --title-page: clamp(2.35rem, 6vw, 4.3rem);
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #111;
    --ink: #f5f5f5;
    --muted: #aaa;
    --faint: #383838;
    --soft: #262626;
    --accent: #bbb;
    --accent-dark: #f5f5f5;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #111;
  --ink: #f5f5f5;
  --muted: #aaa;
  --faint: #383838;
  --soft: #262626;
  --accent: #bbb;
  --accent-dark: #f5f5f5;
}

:root[data-theme='light'] {
  color-scheme: light;
  --paper: #fff;
  --ink: #111;
  --muted: #666;
  --faint: #ddd;
  --soft: #f2f2f2;
  --accent: #444;
  --accent-dark: #111;
}

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 100%;
  line-height: 1.65;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
}

body { min-width: 0; margin: 0; background: var(--paper); }

::selection { background: var(--ink); color: var(--paper); }

a {
  color: var(--accent-dark);
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

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

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

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--ui);
  font-size: var(--text-small);
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }

.site-header,
.site-footer,
main {
  width: min(100% - (2 * var(--gutter)), var(--measure));
  margin-inline: auto;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 6rem;
  border-bottom: 1px solid var(--faint);
  font-family: var(--ui);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.65rem;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.wordmark span:first-child {
  color: var(--accent-dark);
  font-family: var(--display);
  font-size: 1.4rem;
  letter-spacing: -0.08em;
}

.site-header nav a {
  color: var(--ink);
  font-size: var(--text-ui);
  font-weight: 600;
}

.site-header nav { display: flex; align-items: center; gap: var(--space-2); }
.site-header nav a[aria-current="page"] { text-decoration-thickness: 0.14em; }

.theme-toggle {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover { border-color: var(--faint); color: var(--ink); }

.theme-toggle__icon {
  width: 1rem;
  height: 1rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.theme-toggle[data-theme-state='dark'] .theme-toggle__icon { background: currentColor; }
.theme-toggle[data-theme-state='light'] .theme-toggle__icon { background: transparent; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

main { min-height: 58vh; }

.home-intro { padding-block: clamp(2.5rem, 5vw, 3.25rem) clamp(2.5rem, 5vw, 3.25rem); }

h1, h2, h3 {
  margin-block: 0;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  text-wrap: balance;
}

.home-intro h1 {
  max-width: 12ch;
  font-size: clamp(2.55rem, 6vw, 4rem);
}

.home-intro > p {
  max-width: 42ch;
  margin: var(--space-3) 0 0;
  font-size: clamp(1.2rem, 2.3vw, 1.5rem);
  line-height: 1.5;
}

.latest { padding-bottom: var(--space-5); }

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: 0.85rem;
  border-bottom: 2px solid var(--ink);
  font-family: var(--ui);
}

.section-heading h2 { font-size: 1.2rem; letter-spacing: -0.015em; }
.section-heading a { flex: none; font-size: var(--text-small); }

.note-list {
  display: grid;
  gap: 2rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.note-list > li { min-width: 0; }
.note-list .feed-entry {
  padding: clamp(1.15rem, 4vw, 2rem);
  border: 1px solid var(--faint);
  border-radius: 3px;
  background: var(--paper);
}
.feed-entry__header { padding-bottom: 1.1rem; border-bottom: 1px solid var(--faint); }
.archive-list { list-style: none; margin: 0 0 4.5rem; padding: 0; border-top: 2px solid var(--ink); }
.archive-list > li { border-bottom: 1px solid var(--faint); padding-block: 1.25rem; }
.archive-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.75rem 1.5rem; align-items: baseline; }
.archive-entry h2 { font-family: var(--ui); font-weight: 700; font-size: 1.2rem; line-height: 1.3; letter-spacing: -0.02em; }
.archive-entry h2 a { text-decoration: none; }
.archive-entry h2 a:hover { text-decoration: underline; }
.archive-entry time { font-family: var(--ui); color: var(--muted); font-size: var(--text-small); white-space: nowrap; }
@media (max-width: 36rem) {
  .archive-entry { grid-template-columns: 1fr; gap: 0.35rem; }
  .archive-entry time { grid-row: 1; }
}

.feed-entry__header { margin-bottom: 1rem; }
.feed-entry__permalink {
  display: inline-block;
  color: var(--muted);
  font-family: var(--ui);
  font-size: var(--text-small);
  text-decoration: none;
}
.feed-entry__permalink:hover { text-decoration: underline; }
.feed-entry__header h2 {
  margin-top: 0.65rem;
  font-family: var(--ui);
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}
.feed-entry__header h2 a { color: var(--ink); text-decoration: none; }
.feed-entry__header h2 a:hover { text-decoration: underline; }
.feed-entry__summary { font-size: clamp(1.05rem, 1.5vw, 1.16rem); }
.feed-entry__summary p { margin: 0 0 1rem; }
.feed-entry__continue { display: inline-block; margin-top: 0.25rem; font-family: var(--ui); font-size: var(--text-small); }
.prose.feed-entry__body h2 { font-family: var(--ui); font-size: 1.25rem; font-weight: 700; margin-top: 1.5em; }
.prose.feed-entry__body h3 { font-family: var(--ui); font-size: 1.1rem; font-weight: 700; margin-top: 1.5em; }
.feed-entry__body > :first-child { margin-top: 0; }
.feed-entry__body .image-theatre-trigger { width: 100%; max-width: 100%; margin: 1.5rem 0 0; transform: none; }
.note__header time {
  color: var(--muted);
  font-family: var(--ui);
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-state {
  padding-block: 2rem;
  border-bottom: 1px solid var(--faint);
  color: var(--muted);
}

.empty-state p { margin: 0; }
.empty-state p + p { margin-top: 0.2rem; }

.page-heading { padding-block: clamp(3.5rem, 9vw, 6.5rem) var(--space-4); }
.eyebrow { margin: 0 0 0.6rem; color: var(--accent-dark); font-family: var(--ui); font-size: var(--text-small); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.page-heading h1, .not-found h1, .note__header h1 { font-size: var(--title-page); }
.page-heading > p:last-child { max-width: 48ch; margin: var(--space-2) 0 0; color: var(--muted); font-size: 1.15rem; }

.note { padding-block: clamp(3rem, 8vw, 6rem) var(--space-5); }
.note__header { margin-bottom: clamp(1.75rem, 4vw, 2.5rem); }
.back-link { display: inline-block; margin-bottom: var(--space-3); font-family: var(--ui); font-size: var(--text-small); }
.note__header h1 { max-width: 18ch; margin-bottom: var(--space-2); }

.prose { font-size: clamp(1.05rem, 1.5vw, 1.16rem); }
.prose > * { margin-block: 0; }
.prose > * + * { margin-top: 1.35em; }
.prose h1 { margin-top: 2.75em; font-size: clamp(2rem, 5vw, 2.6rem); }
.prose h2 { margin-top: 2.5em; font-size: clamp(1.65rem, 4vw, 2.15rem); }
.prose h3 { margin-top: 2.1em; font-size: clamp(1.3rem, 3vw, 1.55rem); }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: 0.45em; }
.prose blockquote { margin-inline: 0; padding: 0.2rem 0 0.2rem 1.35rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose blockquote > :first-child { margin-top: 0; }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose code { overflow-wrap: anywhere; padding: 0.08em 0.28em; background: var(--soft); border-radius: 2px; font-size: 0.88em; }
.prose pre { max-width: 100%; overflow-x: auto; padding: 1.1rem; background: var(--ink); color: var(--paper); border-radius: 2px; line-height: 1.55; }
.prose pre code { padding: 0; background: transparent; color: inherit; overflow-wrap: normal; }
.prose figure { margin: 2.5rem 0; }
.prose img { display: block; max-width: 100%; height: auto; }
.prose figcaption { margin-top: 0.65rem; color: var(--muted); font-family: var(--ui); font-size: var(--text-small); }
.prose hr { margin-block: 3rem; border: 0; border-top: 1px solid var(--faint); }

.image-theatre-trigger {
  display: block;
  width: min(60rem, calc(100vw - (2 * var(--gutter))));
  max-width: none;
  margin-inline: 50%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  transform: translateX(-50%);
}

.image-theatre-trigger img { width: 100%; }

.image-theatre {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: clamp(1rem, 4vw, 3rem);
  border: 0;
  background: transparent;
  overflow: hidden;
}

.image-theatre[open] {
  display: grid;
  place-items: center;
}

.image-theatre::backdrop { background: rgb(0 0 0 / 92%); }

.image-theatre > img {
  display: block;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-theatre__close {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  cursor: pointer;
  font: 0/0 a;
}

.image-theatre__close::before,
.image-theatre__close::after {
  position: absolute;
  width: 1rem;
  height: 2px;
  background: #fff;
  content: '';
  transform: rotate(45deg);
}

.image-theatre__close::after { transform: rotate(-45deg); }
.image-theatre__close:hover { background: rgb(255 255 255 / 16%); }

.not-found { padding-block: clamp(4rem, 12vw, 9rem); }
.not-found > p:not(.eyebrow) { max-width: 42ch; }

.site-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: 2.5rem 3rem;
  border-top: 1px solid var(--faint);
}

.site-footer > * {
  font-family: var(--ui);
  font-size: var(--text-small);
}
.footer-heading { margin: 0 0 0.55rem; color: var(--muted); font-weight: 700; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.35rem 1.2rem; }
.rss-link { flex: none; }

@media (max-width: 36rem) {
  :root { --gutter: 1.15rem; }
  .site-header__inner { min-height: 4.75rem; }
  .home-intro { padding-top: 2.5rem; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: no-preference) {
  a { transition: color 120ms ease, text-decoration-color 120ms ease; }
  .skip-link { transition: transform 120ms ease; }
}

@media print {
  .skip-link, .site-header, .site-footer, .back-link, .image-theatre { display: none; }
  :root,
  :root[data-theme='light'],
  :root[data-theme='dark'] { color-scheme: light; --paper: #fff; --ink: #000; --muted: #555; --faint: #ccc; --soft: #eee; }
  html { background: #fff; }
  main { width: 100%; }
  a { color: inherit; }
}

@media (max-width: 36rem) {
  .site-header__inner { flex-wrap: wrap; padding-block: 1rem; }
  .site-header nav { flex-wrap: wrap; }
}
