:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #1c1b1f;
  --muted: #6b6760;
  --line: #e8e3db;
  --accent: #d9481f;
  --accent-soft: #fdeee8;
  --note: #2f6fd0;
  --note-soft: #e9f0fc;
  --code-bg: #f2eee8;
  --shadow: 0 1px 2px rgb(30 20 10 / 6%), 0 8px 24px -12px rgb(30 20 10 / 14%);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #131316; --surface: #1b1b20; --text: #ecebe8; --muted: #9a978f; --line: #2a2a31;
  --accent: #ff7a50; --accent-soft: #2c1d18; --note: #7aa7ff; --note-soft: #1a2436;
  --code-bg: #202026; --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131316; --surface: #1b1b20; --text: #ecebe8; --muted: #9a978f; --line: #2a2a31;
    --accent: #ff7a50; --accent-soft: #2c1d18; --note: #7aa7ff; --note-soft: #1a2436;
    --code-bg: #202026; --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 1rem/1.6 var(--sans); min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased; transition: background .2s, color .2s;
}
main { flex: 1; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
img { max-width: 100%; height: auto; border-radius: 10px; }
.wrap { width: min(100% - 2rem, 1080px); margin-inline: auto; }
.narrow { width: min(100% - 2rem, 720px); }
.center { text-align: center; padding-block: 4rem; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 1.5rem; height: 3.75rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; text-decoration: none; }
.logo { height: 2.4rem; width: auto; display: block; }
.nav { display: flex; gap: .25rem; margin-right: auto; }
.nav a { padding: .35rem .75rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .95rem; }
.nav a:hover, .nav a[aria-current] { color: var(--text); background: var(--accent-soft); }
.tools { display: flex; gap: .25rem; }
.icon-btn {
  width: 2.4rem; height: 2.4rem; display: grid; place-items: center; background: none; border: 0;
  border-radius: 50%; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: inline-flex; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: inline-flex; }
}

/* hero */
.hero { padding: clamp(3rem, 8vw, 6rem) 0 2rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 600; color: var(--accent); margin: 0 0 1rem; }
.eyebrow a { text-decoration: none; }
.hero h1 {
  font-family: var(--serif); font-weight: 600; font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.08; letter-spacing: -.025em; margin: 0; max-width: 18ch; text-wrap: balance;
}
.lede { font-size: 1.15rem; color: var(--muted); max-width: 56ch; margin: 1rem 0 0; }

/* featured */
.featured {
  background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px);
  padding: clamp(1.25rem, 4vw, 2.25rem); box-shadow: var(--shadow); margin-bottom: 2rem; position: relative; overflow: hidden;
}
.featured::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.featured[data-type="note"]::before { background: var(--note); }
.featured h2 { font-family: var(--serif); font-size: clamp(1.6rem, 3.6vw, 2.3rem); line-height: 1.15; margin: .75rem 0; letter-spacing: -.015em; }
.featured h2 a { text-decoration: none; }
.featured h2 a::after { content: ""; position: absolute; inset: 0; }
.featured p { color: var(--muted); max-width: 60ch; margin: 0 0 1rem; font-size: 1.05rem; }
.read-more { font-weight: 600; color: var(--accent); }

/* meta, badges, tags */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; font-size: .85rem; color: var(--muted); }
.meta > * + *:not(.badge)::before { content: "·"; margin-right: .75rem; color: var(--line); }
.badge {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .15rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.badge.note { background: var(--note-soft); color: var(--note); }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; position: relative; z-index: 1; }
.tag {
  font-size: .8rem; text-decoration: none; padding: .2rem .65rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface);
}
.tag::before { content: "#"; opacity: .5; }
.tag:hover { border-color: var(--accent); color: var(--accent); }
.topics-line { margin-top: 3rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* filters */
.filters { display: flex; gap: .5rem; margin: 0 0 1.25rem; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: .9rem; padding: .4rem .9rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.chip span { opacity: .6; margin-left: .25rem; }
.chip:hover { color: var(--text); }
.chip[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* grid & cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1.25rem; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card[data-type="note"]:hover { border-color: color-mix(in srgb, var(--note) 40%, var(--line)); }
.card h3 { font-family: var(--serif); font-size: 1.3rem; line-height: 1.25; margin: .7rem 0 .4rem; letter-spacing: -.01em; }
.card h3 a { text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card p { margin: 0; color: var(--muted); font-size: .95rem; flex: 1; }
.card[hidden] { display: none; }
.empty { text-align: center; padding: 2rem 0; }

/* pages */
.page-title { font-family: var(--serif); font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 1.5rem; letter-spacing: -.02em; line-height: 1.1; }
main > section:not(.hero) { padding-block: 2rem 4rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: .75rem; }
.tag.big { font-size: 1rem; padding: .4rem 1rem; }
.tag.big span { margin-left: .5rem; opacity: .55; font-size: .85em; }
.btn { display: inline-block; background: var(--accent); color: #fff; padding: .6rem 1.2rem; border-radius: 999px; text-decoration: none; font-weight: 600; }

/* post */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 50; }
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr); padding-block: clamp(2rem, 6vw, 4rem) 4rem; }
.post-layout.has-toc { grid-template-columns: minmax(0, 68ch) 220px; justify-content: center; gap: 4rem; }
.post-head h1 {
  font-family: var(--serif); font-size: clamp(2rem, 5.5vw, 3.2rem); line-height: 1.1;
  letter-spacing: -.025em; margin: 1rem 0 .75rem; text-wrap: balance;
}
.post:not(:has(+ .toc)) { max-width: 68ch; margin-inline: auto; }
.post-head { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--line); }
.toc { position: sticky; top: 5.5rem; align-self: start; font-size: .88rem; max-height: calc(100vh - 7rem); overflow: auto; }
.toc h2 { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 .75rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: .3rem 0 .3rem .9rem; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; }
.toc .l3 a { padding-left: 1.7rem; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
@media (max-width: 980px) {
  .post-layout.has-toc { grid-template-columns: minmax(0, 1fr); }
  .post-layout.has-toc .post { max-width: 68ch; margin-inline: auto; }
  .toc { display: none; }
}

/* prose */
.prose { font-family: var(--serif); font-size: 1.15rem; line-height: 1.75; }
.prose > * { margin-block: 0 1.4em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--sans); letter-spacing: -.015em; line-height: 1.25; margin-block: 2.2em .6em; position: relative; }
.prose h2 { font-size: 1.6rem; }
.prose h3 { font-size: 1.28rem; }
.prose .anchor { position: absolute; left: -1.2em; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .anchor:focus { opacity: 1; }
@media (max-width: 800px) { .prose .anchor { display: none; } }
.prose a { color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-block: .3em; }
.prose li.task { list-style: none; margin-left: -1.2em; }
.prose blockquote {
  margin-inline: 0; padding: .2em 0 .2em 1.25em; border-left: 3px solid var(--accent);
  font-style: italic; color: var(--muted); font-size: 1.2em;
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { border: 0; text-align: center; margin-block: 2.5em; }
.prose hr::before { content: "· · ·"; color: var(--muted); letter-spacing: .6em; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .15em .4em; border-radius: 6px; }
.prose pre {
  position: relative; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.15rem; overflow-x: auto; font-size: .9rem; line-height: 1.6; tab-size: 2;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose pre[data-lang]::before {
  content: attr(data-lang); position: absolute; top: .5rem; right: 3.9rem; font: .68rem var(--sans);
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
}
.copy-btn {
  position: absolute; top: .4rem; right: .5rem; font: .72rem var(--sans); padding: .2rem .55rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s;
}
pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.prose table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .92rem; }
.prose th, .prose td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--code-bg); font-weight: 600; }

/* pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4rem; }
.pager a {
  display: block; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; font-weight: 600; transition: border-color .2s;
}
.pager a:hover { border-color: var(--accent); }
.pager a span { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; margin-bottom: .2rem; }
.pager .next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { grid-column: auto; } }

/* footer */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; padding-block: 1.5rem; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.site-footer .links { display: flex; gap: 1rem; }

/* search */
dialog#search-dialog {
  margin: 8vh auto auto; width: min(100% - 2rem, 600px); padding: 0; border: 1px solid var(--line);
  border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 24px 64px -16px rgb(0 0 0 / 40%);
}
dialog#search-dialog::backdrop { background: rgb(10 8 6 / 45%); backdrop-filter: blur(3px); }
.search-box { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.search-box svg { width: 1.2rem; height: 1.2rem; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search-box input { flex: 1; border: 0; background: none; font: inherit; font-size: 1.05rem; color: inherit; outline: none; min-width: 0; }
kbd { font: .72rem var(--mono); border: 1px solid var(--line); border-radius: 5px; padding: .1rem .4rem; color: var(--muted); }
.search-results { list-style: none; margin: 0; padding: .4rem; max-height: 55vh; overflow: auto; }
.search-results li a { display: block; padding: .7rem .8rem; border-radius: 10px; text-decoration: none; }
.search-results li a:hover, .search-results li a.sel { background: var(--accent-soft); }
.search-results strong { display: block; font-weight: 600; }
.search-results small { color: var(--muted); display: block; margin-top: .1rem; }
.search-results .none { padding: 1.2rem; text-align: center; color: var(--muted); }
mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 560px) {
  .bar { gap: .5rem; }
  .nav a { padding: .35rem .5rem; font-size: .9rem; }
  .logo { height: 2rem; }
  .nav a:first-child { display: none; }
}
@media print {
  .site-header, .site-footer, .toc, .pager, .progress, .copy-btn { display: none; }
  body { background: #fff; color: #000; }
}
.search-box input::-webkit-search-cancel-button { display: none; }
