/* Engineering blog. Dark by default, light via [data-theme="light"]. */
:root {
  --bg: #0b0c0e; --bg-2: #111317; --surface: #15181d; --surface-2: #1b1f26;
  --ink: #eceef2; --ink-2: #c3c8d2; --muted: #8b93a1; --line: #242932; --line-2: #313744;
  --accent: #8b95ff; --accent-ink: #0b0c0e; --accent-soft: rgb(139 149 255 / .12);
  --code-bg: #07080a; --code-ink: #e6e9ef; --code-line: #232830; --code-head: #0f1115;
  --font: "Mona Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --head-h: 64px; --wrap: 1240px; --measure: 70ch;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --bg-2: #eef0f3; --surface: #ffffff; --surface-2: #f0f2f5;
  --ink: #0b0c0e; --ink-2: #2c3139; --muted: #5d6470; --line: #dde0e6; --line-2: #c9ced7;
  --accent: #1f2de6; --accent-ink: #ffffff; --accent-soft: rgb(31 45 230 / .08);
  --code-bg: #0d0f13; --code-ink: #e6e9ef; --code-line: #232830; --code-head: #14171c;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--head-h) + 20px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.7 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.wrap { width: min(100% - 40px, var(--wrap)); margin-inline: auto; }

/* header */
.site-head { position: sticky; top: 0; z-index: 50; height: var(--head-h); background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--line); }
.site-head .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--line-2); }
.brand__name { font-weight: 640; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__name span { color: var(--muted); font-weight: 450; }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a, .theme-btn { color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 520; padding: 8px 12px; border-radius: 8px; transition: background .2s, color .2s; }
.site-nav a:hover, .theme-btn:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); }
.theme-btn { background: none; border: 0; cursor: pointer; font-family: inherit; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .i-sun { display: none; }
:root[data-theme="light"] .theme-btn .i-sun { display: block; }
:root[data-theme="light"] .theme-btn .i-moon { display: none; }
@media (max-width: 680px) {
  .brand__name span { display: none; }
  .site-nav a { padding: 8px 8px; font-size: 13px; }
  .site-nav .hide-sm { display: none; }
}
@media (max-width: 400px) { .brand__name { display: none; } }

/* index */
.hero { padding: clamp(48px, 8vw, 96px) 0 clamp(28px, 4vw, 48px); border-bottom: 1px solid var(--line); }
.eyebrow { font: 500 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0 0 18px; }
.hero h1 { font: 620 clamp(36px, 6vw, 68px)/1.04 var(--font); letter-spacing: -.035em; margin: 0 0 18px; max-width: 18ch; font-stretch: 104%; }
.hero p { margin: 0; max-width: 58ch; color: var(--ink-2); font-size: clamp(17px, 2vw, 20px); line-height: 1.55; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 24px; padding: clamp(32px, 5vw, 56px) 0 clamp(56px, 8vw, 96px); }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; color: inherit; text-decoration: none; transition: transform .35s cubic-bezier(.2,.7,.2,1), border-color .25s, box-shadow .35s; }
.card:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: 0 18px 40px -22px rgb(0 0 0 / .55); }
.card__cover { aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; border-bottom: 1px solid var(--line); }
.card__cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.card:hover .card__cover img { transform: scale(1.03); }
.card__cover--none { display: grid; place-items: center; background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface-2); }
.card__cover--none span { font: 600 40px/1 var(--mono); color: var(--accent); opacity: .6; }
.card__body { display: flex; flex-direction: column; gap: 10px; padding: 22px 22px 20px; flex: 1; }
.card h2 { font: 600 clamp(20px, 2vw, 23px)/1.22 var(--font); letter-spacing: -.02em; margin: 0; }
.card p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; flex: 1; }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font: 500 12px/1.4 var(--mono); color: var(--muted); margin-top: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag { font: 500 11.5px/1 var(--mono); letter-spacing: .02em; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface-2); }
.card.is-featured { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .card.is-featured { flex-direction: row; }
  .card.is-featured .card__cover { flex: 1.15; aspect-ratio: auto; border-bottom: 0; border-right: 1px solid var(--line); min-height: 280px; }
  .card.is-featured .card__body { flex: 1; padding: 36px; justify-content: center; }
  .card.is-featured h2 { font-size: clamp(26px, 2.6vw, 34px); }
  .card.is-featured p { font-size: 17px; flex: none; }
}

/* post header */
.post-head { padding: clamp(36px, 6vw, 72px) 0 clamp(24px, 3vw, 36px); }
.post-head .inner { max-width: 820px; }
.crumbs { font: 500 13px/1 var(--mono); color: var(--muted); margin: 0 0 22px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.post-head h1 { font: 640 clamp(32px, 5.2vw, 58px)/1.06 var(--font); letter-spacing: -.035em; margin: 18px 0 20px; text-wrap: balance; font-stretch: 104%; }
.post-head .lede { font-size: clamp(18px, 2vw, 21px); line-height: 1.55; color: var(--ink-2); margin: 0 0 26px; max-width: 62ch; }
.byline { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; padding-top: 22px; border-top: 1px solid var(--line); }
.byline__who { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.byline__who img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-2); }
.byline__who strong { display: block; font-size: 15px; font-weight: 620; line-height: 1.25; }
.byline__who small { display: block; color: var(--muted); font-size: 13px; line-height: 1.25; }
.byline__facts { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 500 13px/1.4 var(--mono); color: var(--muted); margin-left: auto; }
.byline__facts a { color: var(--muted); }
.post-cover { margin: 8px 0 0; }
.post-cover img { width: 100%; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); aspect-ratio: 16 / 9; object-fit: cover; }

/* post layout */
.post-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 56px; padding-bottom: 40px; }
@media (min-width: 1080px) { .post-grid { grid-template-columns: minmax(0, 760px) minmax(250px, 330px); justify-content: center; } }
@media (min-width: 1280px) { .post-grid { gap: 0 64px; } }
.toc { display: none; }
@media (min-width: 1080px) {
  .toc { display: block; position: sticky; top: calc(var(--head-h) + 28px); align-self: start; max-height: calc(100vh - var(--head-h) - 56px); overflow-y: auto; order: 2; font-size: 14px; padding-left: 20px; border-left: 1px solid var(--line); }
}
.toc h2 { font: 600 11.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 5px 0; color: var(--muted); text-decoration: none; line-height: 1.35; transition: color .15s; }
.toc a:hover { color: var(--ink); }
.toc a.is-active { color: var(--accent); font-weight: 560; }
.toc .l3 a { padding-left: 14px; font-size: 13px; }

/* article body */
.post { min-width: 0; font-size: 18px; line-height: 1.75; color: var(--ink-2); }
.post > * { max-width: var(--measure); }
.post > figure, .post > .table-wrap, .post > .code, .post > .callout, .post > aside { max-width: none; }
.post p { margin: 0 0 1.25em; }
.post > p:first-child { font-size: 1.08em; color: var(--ink); }
.post h2 { font: 620 clamp(26px, 3.2vw, 34px)/1.15 var(--font); letter-spacing: -.028em; color: var(--ink); margin: 2.1em 0 .6em; text-wrap: balance; }
.post h3 { font: 600 clamp(20px, 2.4vw, 24px)/1.25 var(--font); letter-spacing: -.018em; color: var(--ink); margin: 1.8em 0 .5em; }
.post h2 .anchor, .post h3 .anchor { color: var(--muted); text-decoration: none; margin-left: .4em; opacity: 0; font-weight: 400; transition: opacity .15s; }
.post h2:hover .anchor, .post h3:hover .anchor, .post .anchor:focus { opacity: 1; }
.post ul, .post ol { padding-left: 1.4em; margin: 0 0 1.3em; }
.post li { margin: .35em 0; padding-left: .2em; }
.post li::marker { color: var(--muted); }
.post strong { color: var(--ink); font-weight: 640; }
.post hr { border: 0; border-top: 1px solid var(--line); margin: 2.6em 0; }
.post a { text-decoration-thickness: 1px; }
.post :not(pre) > code { font: 500 .86em var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: .12em .4em; border-radius: 6px; color: var(--ink); overflow-wrap: anywhere; }
.post blockquote { margin: 1.8em 0; padding: .3em 0 .3em 1.2em; border-left: 3px solid var(--accent); color: var(--ink); font-size: 1.04em; }
.post blockquote p:last-child { margin-bottom: 0; }
.post img { border-radius: 12px; border: 1px solid var(--line); }
.post figure:not(.fig-wrap):not(.code) { margin: 2em 0; }
.post figure:not(.fig-wrap):not(.code) figcaption { margin-top: 12px; font-size: 14.5px; line-height: 1.55; color: var(--muted); max-width: 68ch; }
.post figure:not(.fig-wrap):not(.code) figcaption strong { color: var(--ink); }

/* callout */
.callout { margin: 2em 0; padding: 20px 24px; border: 1px solid var(--line-2); border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 12px; color: var(--ink); font-size: 17px; line-height: 1.65; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child, .callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout h2, .callout h3, .callout h4, .callout .callout__title, .callout > strong:first-child { font: 600 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; display: block; }
.callout p { max-width: none; }

/* tables */
.table-wrap { margin: 2em 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); -webkit-overflow-scrolling: touch; }
.post table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; min-width: 520px; }
.post th, .post td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.post th { font: 600 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.post tr:last-child td { border-bottom: 0; }
.post td { color: var(--ink-2); }

/* code */
.code { margin: 2em 0; border: 1px solid var(--code-line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.code__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 16px; background: var(--code-head); border-bottom: 1px solid var(--code-line); }
.code__lang { font: 500 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #8b93a1; }
.code__copy { font: 500 12px/1 var(--mono); color: #c3c8d2; background: transparent; border: 1px solid #313744; border-radius: 7px; padding: 7px 11px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.code__copy:hover { background: #1b1f26; color: #fff; }
.code__copy.is-done { color: #3ddc97; border-color: #3ddc97; }
.code pre { margin: 0; padding: 18px 20px; overflow-x: auto; font: 400 14px/1.65 var(--mono); color: var(--code-ink); tab-size: 2; -webkit-overflow-scrolling: touch; }
.code pre code { font: inherit; background: none; border: 0; padding: 0; color: inherit; }
.post > pre { margin: 2em 0; padding: 18px 20px; overflow-x: auto; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--code-line); border-radius: 12px; font: 400 14px/1.65 var(--mono); max-width: none; }

/* figures: theme-aware captions (the figure cards themselves stay dark) */
figcaption.fig__cap { color: var(--ink-2); }
figcaption.fig__cap strong { color: var(--ink); }
figcaption.fig__cap em { color: var(--muted); }
:root[data-theme="light"] .post figure.fig-wrap .fig { box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 14px 32px -20px rgb(0 0 0 / .4); }

/* prev / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0 0; padding-top: 40px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-decoration: none; color: var(--ink); transition: border-color .2s, transform .3s; min-width: 0; }
.pager a:hover { border-color: var(--accent); transform: translateY(-2px); }
.pager small { font: 500 11.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pager strong { font-weight: 600; font-size: 16px; line-height: 1.3; letter-spacing: -.01em; }
.pager .next { text-align: right; grid-column: 2; }
.pager .prev { grid-column: 1; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } .pager .next, .pager .prev { grid-column: 1; text-align: left; } }

/* footer */
.site-foot { margin-top: clamp(48px, 8vw, 96px); border-top: 1px solid var(--line); padding: 36px 0 48px; color: var(--muted); font-size: 14px; background: var(--bg-2); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: center; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.site-foot a { color: var(--ink-2); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

/* 404 */
.nf { padding: clamp(80px, 14vw, 180px) 0; }
.nf h1 { font: 640 clamp(40px, 7vw, 84px)/1 var(--font); letter-spacing: -.04em; margin: 0 0 16px; }
.nf p { color: var(--ink-2); font-size: 19px; margin: 0 0 28px; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); padding: 12px 20px; border-radius: 10px; font-weight: 600; text-decoration: none; }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .post { font-size: 17px; }
  .wrap { width: min(100% - 32px, var(--wrap)); }
  .callout { padding: 16px 18px; }
  .byline__facts { margin-left: 0; width: 100%; }
}
@media print { .site-head, .toc, .pager, .site-foot, .code__copy { display: none; } body { background: #fff; color: #000; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
