:root {
  --bg: #fdf6e3;
  --surface: #fefcf5;
  --surface-strong: #fffdf8;
  --accent: #2d6cdf;
  --accent-soft: rgba(45, 108, 223, .12);
  --text: #1b1d22;
  --text-dim: #3a3d44;
  --text-muted: #6c707b;
  --border: #d6cfb8;
  --shadow: rgba(30, 24, 12, .08);
  --grid-line: rgba(61, 52, 34, .06);
  --code-bg: #f7f4e9;
  --code-keyword: #b42335;
  --code-name: #24292e;
  --code-function: #6f42c1;
  --code-class: #005cc5;
  --code-string: #034f74;
  --code-comment: #6a737d;
  --code-number: #005cc5;
  --code-tag: #22863a;
  --code-attribute: #6f42c1;
  --code-error: #a61717;
  --code-error-bg: #f1dede;
  --font-sans: "IBM Plex Sans", "Fira Sans", "Work Sans", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "Fira Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background-color: var(--bg);
  background-image: linear-gradient(0deg, var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: var(--font-sans);
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: absolute;
  top: -4rem;
  left: 1rem;
  z-index: 100;
  padding: .5rem .75rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
}
.skip-link:focus { top: 1rem; }
.page-shell { display: flex; flex-direction: column; min-height: 100vh; }
.site-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.2rem 6vw 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 24px var(--shadow);
}
.brand { display: flex; flex-direction: column; gap: .25rem; }
.brand-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -.025em; }
.brand-subtitle { color: var(--text-muted); font-size: .95rem; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1.2rem; }
.nav-link { color: var(--text-dim); font-size: .9rem; letter-spacing: .08em; text-transform: uppercase; }
.nav-link:hover { color: var(--accent); }
.page-main { flex: 1; padding: 5rem 6vw; }

/* The home page keeps the notebook primary and the latest note close at hand. */
.home-grid {
  display: grid;
  grid-template-areas: "recent latest";
  grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
  align-items: start;
  gap: clamp(2.5rem, 6vw, 6rem);
  max-width: 1160px;
  margin: 0 auto;
}
.recent-log { grid-area: recent; min-width: 0; padding: 0; border: 0; }
.latest-lead { grid-area: latest; position: sticky; top: 2rem; min-width: 0; }
.eyebrow, .stream-type, .feature-label {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.text-link, .feature-read { color: var(--accent); text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .15em; }
.feature-note {
  max-width: 330px;
  margin: 0;
  padding: 1.15rem 1.2rem 1.25rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  background: var(--surface);
  box-shadow: 0 14px 30px var(--shadow);
}
.feature-label { color: var(--text-muted); }
.feature-meta { display: flex; flex-wrap: wrap; gap: .8rem; margin: .9rem 0 .7rem; color: var(--text-muted); font-family: var(--font-mono); font-size: .76rem; }
.feature-meta span { color: var(--accent); }
.feature-note h1, .feature-note h2 { margin: 0 0 .55rem; font-size: clamp(1.45rem, 2.6vw, 1.8rem); letter-spacing: -.045em; line-height: 1.1; }
.feature-note > p:not(.feature-label):not(.feature-meta) { margin: 0 0 1rem; color: var(--text-dim); font-size: .9rem; line-height: 1.55; }
.feature-read { font-size: .82rem; font-weight: 600; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.section-heading h1, .section-heading h2 { margin: 0; font-size: clamp(2rem, 3vw, 2.7rem); letter-spacing: -.055em; line-height: 1.05; }
.section-heading > p:last-child { max-width: 340px; margin: 0; color: var(--text-muted); font-size: .9rem; text-align: right; }
.recent-stream { margin: 0; padding: 0; list-style: none; }
.stream-entry { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 1.5rem; padding: 1.2rem 0 1.35rem; border-bottom: 1px dashed var(--border); }
.stream-entry > time { padding-top: .2rem; color: var(--text-muted); font-family: var(--font-mono); font-size: .78rem; }
.stream-copy { max-width: 780px; }
.stream-type { margin-bottom: .15rem; color: var(--text-muted); font-size: .67rem; }
.stream-copy h2 { margin: 0 0 .25rem; font-size: 1.25rem; letter-spacing: -.02em; }
.stream-copy h2 a:hover { text-decoration: underline; text-underline-offset: .15em; }
.stream-copy > p:last-child { margin: 0; color: var(--text-muted); font-size: .93rem; }

.page-heading { max-width: 860px; margin: 0 auto 2rem; }
.page-heading h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.05em; line-height: 1.1; }
.page-heading .intro-copy { max-width: 640px; color: var(--text-muted); }
.empty-state { max-width: 700px; margin: 0 auto; padding: 4rem 0; }
.empty-state h1 { margin: 0 0 1rem; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.05em; }
.empty-state p:not(.eyebrow) { color: var(--text-muted); }
.list-plain { display: grid; gap: .9rem; max-width: 860px; margin: 0 auto; padding: 0; list-style: none; }
.list-item { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .7rem 1rem; padding: .8rem 1rem; border-bottom: 1px dashed var(--border); }
.list-item-title { font-weight: 600; }
.list-item-title:hover { color: var(--accent); }
.list-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; color: var(--text-muted); font-size: .85rem; }
.list-item-meta time { font-family: var(--font-mono); font-size: .76rem; }
.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-chip { display: inline-flex; align-items: center; padding: .25rem .5rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); font-size: .75rem; line-height: 1.2; }
.tag-chip--type { border-color: var(--accent); color: var(--accent); }
.taxonomy-page { max-width: 860px; margin: 0 auto; }
.taxonomy-page h1 { margin: .2rem 0 .45rem; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.055em; line-height: 1.1; }
.taxonomy-intro { max-width: 620px; margin: 0 0 2rem; color: var(--text-muted); }
.taxonomy-back { margin: 1.3rem 0 .5rem; font-size: .88rem; }
.taxonomy-back a { color: var(--accent); text-decoration: underline; text-underline-offset: .15em; }
.taxonomy-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 2rem; margin: 2rem 0 0; padding: 0; list-style: none; }
.taxonomy-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px dashed var(--border); }
.taxonomy-list a { font-weight: 600; }
.taxonomy-list a:hover { color: var(--accent); }
.taxonomy-list span { color: var(--text-muted); font-family: var(--font-mono); font-size: .75rem; }
.taxonomy-notes { margin-top: 1.8rem; }

.post { max-width: 860px; margin: 0 auto; }
.post-header { margin-bottom: 2.8rem; }
.post-header h1 { max-width: 18ch; margin: 0 0 .4rem; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.055em; line-height: 1.1; }
.meta { margin: .4rem 0 .8rem; color: var(--text-muted); font-family: var(--font-mono); font-size: .8rem; }
.post-description { max-width: 640px; margin: 1rem 0 0; color: var(--text-muted); }
.post-content { max-width: 760px; color: var(--text-dim); line-height: 1.75; }
.post-content h2, .post-content h3, .post-content h4 { color: var(--text); line-height: 1.2; }
.post-content h2 { margin-top: 2.5rem; }
.post-content h3 { margin-top: 2rem; }
.post-content a { color: var(--accent); text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .15em; }
.post-content img { display: block; max-width: 100%; height: auto; margin: 1.2rem 0; border-radius: 10px; }
.post-content figure { margin: 1.2rem 0; }
.post-content blockquote { margin: 1.5rem 0; padding: 1rem 1.5rem; border-left: 4px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--surface); color: var(--text-dim); font-style: italic; overflow-wrap: break-word; }
.post-content blockquote > :first-child { margin-top: 0; }
.post-content blockquote > :last-child { margin-bottom: 0; }
.post-content code { font-family: var(--font-mono); font-size: .9em; }
.post-content :not(pre) > code { padding: .12em .3em; border-radius: 5px; background: var(--accent-soft); color: var(--text); }
.post-content pre { margin: 0; overflow: auto; padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--code-bg); font-family: var(--font-mono); font-size: .88rem; line-height: 1.6; }
.post-content .highlight { position: relative; margin: 1.35rem 0; border: 1px solid var(--border); border-radius: 12px; background: var(--code-bg); box-shadow: 0 10px 22px var(--shadow); }
.post-content .highlight pre { border: 0; border-radius: 0 0 10px 10px; background: transparent; box-shadow: none; }
.post-content .highlight code .line { display: block; width: max-content; min-width: 100%; padding: .08rem .3rem .08rem .1rem; border-radius: 5px; }
.post-content .highlight code .cl { display: inline-block; }
.post-content .highlight .ln { display: inline-block; min-width: 2.6rem; margin-right: .4rem; padding: 0 .4rem; color: var(--text-muted); text-align: right; user-select: none; }
.post-content table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; }
.post-content th, .post-content td { padding: .55rem .75rem; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.post-content th { background: var(--accent-soft); color: var(--text); font-family: var(--font-mono); font-size: .78rem; }
.post-content details { margin: 1.2rem 0; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.post-content summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* Before/after comparisons use aligned layers and a direct reveal scrubber. */
.code-slider-block { position: relative; margin: 1.35rem 0; border: 1px solid var(--border); border-radius: 10px; background: var(--code-bg); box-shadow: 0 8px 18px var(--shadow); overflow: hidden; }
.code-slider-render { position: relative; }
.diff-slider { --reveal: 50%; --diff-before: #a45b55; --diff-before-bg: #f1ece5; --diff-after: #4f8764; --diff-after-bg: #edf1e8; color: var(--code-name); }
.diff-slider-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem .8rem; padding: .55rem .75rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.diff-slider-caption, .diff-slider-status { color: var(--text-muted); font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.diff-slider-endpoints, .diff-slider-copy-actions { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.diff-slider-copy-actions { margin-left: auto; }
.diff-slider-endpoint, .diff-slider-copy, .diff-slider-collapse { padding: .25rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-strong); color: var(--text-muted); font: .72rem var(--font-mono); cursor: pointer; }
.diff-slider-endpoint[aria-pressed="true"], .diff-slider-endpoint:hover, .diff-slider-copy:hover, .diff-slider-collapse:hover { border-color: var(--accent); color: var(--accent); }
.diff-slider-stage { position: relative; overflow: hidden; background: var(--diff-after-bg); }
.diff-slider-layer { position: relative; width: 100%; }
.diff-slider-layer--after { z-index: 1; background: var(--diff-after-bg); }
.diff-slider-layer--before { position: absolute; inset: 0; z-index: 2; clip-path: inset(0 calc(100% - var(--reveal)) 0 0); background: var(--diff-before-bg); }
.diff-slider--animating .diff-slider-layer--before { transition: clip-path .32s cubic-bezier(.2, .75, .25, 1); }
.diff-slider-code, .post-content .diff-slider-code { width: 100%; min-width: 0; max-width: 100%; margin: 0; overflow: auto; padding: .8rem .7rem 1rem; border: 0; border-radius: 0; background: transparent; font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; }
.code-slider-block .diff-line { display: grid; grid-template-columns: 2.6rem max-content; gap: .55rem; width: max-content; min-width: 100%; padding: .08rem .3rem; }
.code-slider-block .diff-line code, .post-content .diff-line > code { padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit; font-size: inherit; white-space: pre; }
.diff-line-number { color: var(--text-muted); font-size: .72rem; text-align: right; user-select: none; }
.diff-slider-scrubber { position: absolute; top: 0; bottom: 0; left: var(--reveal); z-index: 4; width: 1px; padding: 0; border: 0; background: var(--accent); cursor: ew-resize; transform: translateX(-.5px); }
.diff-slider-scrubber::before { position: absolute; top: 0; bottom: 0; left: 50%; width: 20px; content: ""; transform: translateX(-50%); }
.diff-slider-scrubber::after { position: absolute; top: 50%; left: 50%; width: 4px; height: 2.2rem; border-right: 1px solid var(--accent); border-left: 1px solid var(--accent); content: ""; opacity: .8; transform: translate(-50%, -50%); }
.diff-slider--animating .diff-slider-scrubber { transition: left .32s cubic-bezier(.2, .75, .25, 1); }
.diff-slider-scrubber:hover, .diff-slider-scrubber:focus-visible { width: 3px; margin-left: -1px; outline: 0; }
.diff-slider-scrubber:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.diff-slider--long.diff-slider--collapsed .diff-slider-stage { max-height: 18.5rem; }
.diff-slider--long.diff-slider--collapsed .diff-slider-stage::after { position: absolute; right: 0; bottom: 0; left: 0; z-index: 3; height: 3rem; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--code-bg)); content: ""; }
.diff-slider-status { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .45rem .75rem; border-top: 1px solid var(--border); background: var(--surface); text-transform: none; letter-spacing: .02em; }
.code-slider-error { padding: 1rem; color: var(--code-error); }
html.theme-dark .diff-slider { --diff-before: #d18479; --diff-before-bg: #292321; --diff-after: #79c58f; --diff-after-bg: #202a24; }

/* Added by code.js; raw snippets remain fully usable when JavaScript is unavailable. */
.code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .45rem .7rem; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.code-actions { display: flex; gap: .4rem; }
.code-action { padding: .25rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-strong); color: var(--text-muted); font: inherit; letter-spacing: .02em; text-transform: none; cursor: pointer; }
.code-action:hover { border-color: var(--accent); color: var(--accent); }
.code-block--collapsed pre { max-height: calc(1.6em * var(--code-lines-collapsed, 12) + 2rem); overflow: hidden; }
.code-block-fade { position: absolute; right: 0; bottom: 0; left: 0; height: 3.4rem; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--code-bg)); }
.code-block--collapsed .code-block-fade { display: block; }
.code-block-fade { display: none; }

.site-footer { padding: 1.2rem 6vw 1.5rem; border-top: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; max-width: 1160px; margin: 0 auto; }
.footer-inner p { margin: 0; font-size: .9rem; }
.theme-toggle { position: fixed; right: 5vw; bottom: 1.5rem; z-index: 20; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); box-shadow: 0 12px 28px var(--shadow); color: var(--text-dim); cursor: pointer; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

html.theme-dark {
  --bg: #16181d;
  --surface: #1c2128;
  --surface-strong: #242b34;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, .14);
  --text: #c9d1d9;
  --text-dim: #a7b1bc;
  --text-muted: #8b949e;
  --border: #30363d;
  --shadow: rgba(0, 0, 0, .4);
  --grid-line: rgba(240, 246, 252, .045);
  --code-bg: #161b22;
  --code-keyword: #ff7b72;
  --code-name: #c9d1d9;
  --code-function: #d2a8ff;
  --code-class: #f0883e;
  --code-string: #a5d6ff;
  --code-comment: #8b949e;
  --code-number: #79c0ff;
  --code-tag: #7ee787;
  --code-attribute: #79c0ff;
  --code-error: #f85149;
  --code-error-bg: #3e1f1f;
  color-scheme: dark;
}

/* Chroma token palette, adapted from epignosis for both light and dark ink. */
.chroma { display: block; color: var(--code-name); background: transparent; }
.chroma .err { color: var(--code-error); background: var(--code-error-bg); }
.chroma .hl { display: block; width: 100%; background: rgba(255, 220, 90, .22); }
html.theme-dark .chroma .hl { background: rgba(255, 210, 90, .13); }
.chroma .lntd { padding: 0; border: 0; vertical-align: top; }
.chroma .lntable { width: auto; margin: 0; padding: 0; border-spacing: 0; border: 0; }
.chroma .lnt, .chroma .ln { margin-right: .4em; padding: 0 .4em; color: var(--text-muted); user-select: none; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .kt { color: var(--code-keyword); font-weight: 600; }
.chroma .n, .chroma .nx, .chroma .py, .chroma .p { color: var(--code-name); }
.chroma .nf, .chroma .fm { color: var(--code-function); }
.chroma .nc, .chroma .nn, .chroma .ne { color: var(--code-class); font-weight: 600; }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl, .chroma .sd, .chroma .se, .chroma .sh, .chroma .si, .chroma .sx, .chroma .sr, .chroma .s1, .chroma .ss { color: var(--code-string); }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .cp, .chroma .cpf, .chroma .c1, .chroma .cs { color: var(--code-comment); font-style: italic; }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi, .chroma .il, .chroma .mo { color: var(--code-number); }
.chroma .o, .chroma .ow { color: var(--code-keyword); font-weight: 600; }
.chroma .nt { color: var(--code-tag); }
.chroma .na { color: var(--code-attribute); }
.chroma .nv, .chroma .vc, .chroma .vg, .chroma .vi { color: var(--code-name); }
.chroma .no, .chroma .bp { color: var(--code-number); }
.chroma .w, .chroma .x, .chroma .ge, .chroma .go, .chroma .gu { color: var(--code-name); }
.chroma .gd { color: #a11; background: rgba(214, 72, 72, .12); }
.chroma .gi { color: #176d36; background: rgba(55, 188, 115, .12); }
html.theme-dark .chroma .gd { color: #ff7b72; background: rgba(248, 81, 73, .14); }
html.theme-dark .chroma .gi { color: #7ee787; background: rgba(55, 188, 115, .14); }

@media (max-width: 680px) {
  .diff-slider-toolbar { align-items: flex-start; }
  .diff-slider-copy-actions { margin-left: 0; }
  .diff-slider-status { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 900px) {
  .page-main { padding: 4rem 5vw; }
  .home-grid { grid-template-areas: "latest" "recent"; grid-template-columns: 1fr; gap: 3rem; }
  .latest-lead { position: static; }
  .feature-note { max-width: 620px; }
  .site-header, .site-footer { padding-inline: 5vw; }
}
@media (max-width: 600px) {
  .site-header { align-items: flex-start; flex-direction: column; gap: 1.25rem; padding-top: 1.2rem; }
  .site-nav { gap: .6rem 1rem; }
  .nav-link { font-size: .82rem; }
  .page-main { padding-top: 3rem; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p:last-child { text-align: left; }
  .stream-entry { grid-template-columns: 1fr; gap: .35rem; }
  .stream-entry > time { padding-top: 0; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
  .theme-toggle { right: 1rem; bottom: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
