:root {
  color-scheme: light dark;
  --bg: #f5f2e9;
  --surface: #ebe7dc;
  --text: #20221f;
  --muted: #6c7068;
  --line: #d7d2c5;
  --accent: #236c52;
  --accent-soft: #dce9df;
  --code: #171916;
  --measure: 70rem;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme='dark'] {
  --bg: #171816;
  --surface: #222420;
  --text: #e9e8e1;
  --muted: #a1a49b;
  --line: #353831;
  --accent: #78c9a4;
  --accent-soft: #243b31;
  --code: #0f100f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #171816;
    --surface: #222420;
    --text: #e9e8e1;
    --muted: #a1a49b;
    --line: #353831;
    --accent: #78c9a4;
    --accent-soft: #243b31;
    --code: #0f100f;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: .18em; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
img, video { display: block; max-width: 100%; }
button { font: inherit; }

.site-shell { width: min(calc(100% - 2rem), var(--measure)); margin-inline: auto; }
.site-header { min-height: 5.25rem; display: flex; align-items: center; gap: 1.4rem; border-bottom: 1px solid var(--line); }
.wordmark { margin-right: auto; font-weight: 800; letter-spacing: -.04em; text-decoration: none; font-size: 1.18rem; }
.wordmark span, .eyebrow { color: var(--accent); }
.site-header nav { display: flex; gap: 1rem; font-size: .9rem; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a:hover, .site-header nav a[aria-current='page'] { color: var(--text); }
.theme-toggle { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--text); background: transparent; cursor: pointer; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

main { min-height: calc(100vh - 11rem); }
.intro { padding: clamp(5rem, 12vw, 10rem) 0 clamp(4rem, 9vw, 7rem); max-width: 58rem; }
.intro h1, .page-header h1, .post-header h1, .not-found h1 { margin: .35rem 0 1.4rem; font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.045em; line-height: .98; }
.intro h1 { font-size: clamp(3.1rem, 8vw, 6.6rem); }
.intro > p:last-child { max-width: 43rem; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.25rem); }
.eyebrow { margin: 0; font-size: .76rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; text-decoration: none; }

.listing-section { padding: 2.2rem 0 4.5rem; border-top: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; }
.section-heading > a { color: var(--muted); font-size: .88rem; }
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { display: grid; grid-template-columns: minmax(9rem, .38fr) 1fr; gap: .35rem 2rem; padding: 1.35rem 0; border-top: 1px solid var(--line); }
.post-list li:first-child { border-top: 0; }
.post-list__meta { display: flex; flex-direction: column; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.post-list li > a { font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.15; text-decoration: none; }
.post-list li > p { grid-column: 2; margin: 0; color: var(--muted); }

.page-header { padding: clamp(4rem, 9vw, 7rem) 0 3rem; max-width: 48rem; }
.page-header h1, .not-found h1 { font-size: clamp(3rem, 8vw, 5.5rem); }
.page-header > p:last-child { max-width: 42rem; color: var(--muted); font-size: 1.18rem; }
.page { max-width: 46rem; padding-bottom: 5rem; }

.post { max-width: 48rem; margin-inline: auto; padding-bottom: 6rem; }
.post-header { padding: clamp(4rem, 9vw, 7rem) 0 2.5rem; }
.post-header h1 { font-size: clamp(3rem, 8vw, 5.6rem); }
.lede { max-width: 42rem; color: var(--muted); font-size: 1.25rem; }
.post-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; color: var(--muted); font-size: .86rem; }
.tag-row, .tag-cloud { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag-row { margin-top: 1.3rem; }
.tag-row a, .tag-cloud a { padding: .22rem .62rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; text-decoration: none; }
.tag-cloud--large { padding-bottom: 5rem; }
.tag-cloud--large a { font-size: 1rem; padding: .4rem .8rem; }
.notice { padding: .8rem 1rem; border-left: .2rem solid var(--accent); background: var(--accent-soft); }
.toc { margin: 2rem 0; padding: 1rem 1.2rem; border: 1px solid var(--line); }
.toc summary { cursor: pointer; font-weight: 700; }
.toc ol { margin-bottom: 0; padding-left: 1.2rem; }
.toc .depth-3 { margin-left: 1rem; }

.prose { font-family: Georgia, "Times New Roman", serif; font-size: 1.12rem; }
.prose h2, .prose h3, .prose h4 { margin: 2.5em 0 .7em; line-height: 1.2; scroll-margin-top: 2rem; }
.prose h2 { font-size: 1.85rem; }
.prose h3 { font-size: 1.4rem; }
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 1.25em 0; }
.prose blockquote { margin-left: 0; padding: .15rem 1.2rem; border-left: .2rem solid var(--accent); color: var(--muted); }
.prose code:not(pre code) { padding: .12em .32em; border-radius: .2rem; background: var(--surface); font-size: .88em; }
.prose pre { overflow-x: auto; padding: 1.1rem 1.2rem; border-radius: .3rem; background: var(--code) !important; font-size: .86rem; line-height: 1.5; }
.prose hr { margin: 3rem 0; border: 0; border-top: 1px solid var(--line); }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; }
.prose th, .prose td { padding: .45rem .7rem; border: 1px solid var(--line); }

.prose img, .prose video { border-radius: .35rem; margin-inline: auto; }
.prose .footnotes { margin-top: 3rem; font-size: .92rem; color: var(--muted); }
.qm { padding: 0 .3em; border-radius: .2rem; background: #f3c969; color: #3b2f0b; font-family: ui-monospace, monospace; font-size: .8em; }
.preview-banner { margin: 1rem 0 0; padding: .6rem 1rem; border: 1px dashed var(--accent); color: var(--accent); font-size: .9rem; }
.empty-state, .not-found { padding: 4rem 0 7rem; color: var(--muted); }
.not-found h1 { color: var(--text); }

.site-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 2rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }

@media (max-width: 720px) {
  .site-header { align-items: flex-start; flex-wrap: wrap; padding: 1.15rem 0; gap: .7rem 1rem; }
  .wordmark { width: calc(100% - 3rem); }
  .theme-toggle { position: absolute; right: 1rem; top: 1rem; }
  .site-header nav { order: 2; width: 100%; overflow-x: auto; gap: .8rem; }
  .post-list li { grid-template-columns: 1fr; }
  .post-list li > p { grid-column: 1; }
  .post-list__meta { flex-direction: row; gap: .75rem; }
  .intro { padding-top: 4rem; }
}

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