:root {
  color-scheme: light;
  --page: #faf9f6;
  --text: #292e2a;
  --muted: #626960;
  --quiet: #70776e;
  --line: #dedfd7;
  --line-strong: #c8cdc1;
  --surface: #f0f1ea;
  --active: #e2e7dc;
  --accent: #4c654f;
  --blue: #e9f1f5;
  --red: #f5e8e8;
  --green: #e9f0e5;
  --yellow: #f5f0dc;
  --orange: #f4eddf;
  --gray: #eeeee7;
  --purple: #eee9f3;
  --code-comment: #697363;
  --code-string: #885e25;
  --code-number: #246b65;
  --code-name: #4d5d91;
  --code-function: #8b3e4b;
  --diagram-paper: #fdfbf7;
  --diagram-ink: #343b3c;
  --diagram-muted: #64706c;
  --diagram-blue: #4263b5;
  --diagram-teal: #247b72;
  --diagram-orange: #a8682d;
  --diagram-purple: #8252a4;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #191d1a;
  --text: #e1e5dc;
  --muted: #adb5a7;
  --quiet: #9ba795;
  --line: #343e32;
  --line-strong: #485443;
  --surface: #232a22;
  --active: #364231;
  --accent: #afc89f;
  --blue: #24363d;
  --red: #3e2b2d;
  --green: #2b3927;
  --yellow: #3b3826;
  --orange: #3c3224;
  --gray: #30352d;
  --purple: #332e3f;
  --code-comment: #a6b39d;
  --code-string: #dfbd86;
  --code-number: #8ecac0;
  --code-name: #b7c0e6;
  --code-function: #e6abb3;
  --diagram-paper: #202720;
  --diagram-ink: #e3e9dd;
  --diagram-muted: #a6b6a4;
  --diagram-blue: #9db9f7;
  --diagram-teal: #88cbbb;
  --diagram-orange: #e2b37a;
  --diagram-purple: #c9a8e7;
}

/* System is the default, and keeps following the OS without JavaScript. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --page: #191d1a;
    --text: #e1e5dc;
    --muted: #adb5a7;
    --quiet: #9ba795;
    --line: #343e32;
    --line-strong: #485443;
    --surface: #232a22;
    --active: #364231;
    --accent: #afc89f;
    --blue: #24363d;
    --red: #3e2b2d;
    --green: #2b3927;
    --yellow: #3b3826;
    --orange: #3c3224;
    --gray: #30352d;
    --purple: #332e3f;
    --code-comment: #a6b39d;
    --code-string: #dfbd86;
    --code-number: #8ecac0;
    --code-name: #b7c0e6;
    --code-function: #e6abb3;
    --diagram-paper: #202720;
    --diagram-ink: #e3e9dd;
    --diagram-muted: #a6b6a4;
    --diagram-blue: #9db9f7;
    --diagram-teal: #88cbbb;
    --diagram-orange: #e2b37a;
    --diagram-purple: #c9a8e7;
  }
}

* { box-sizing: border-box; }
html { background: var(--page); color: var(--text); -webkit-text-size-adjust: 100%; scroll-padding-top: 28px; }
body { margin: 0; font-family: var(--sans); font-size: 16px; line-height: 1.7; }
body, button { -webkit-font-smoothing: antialiased; }
main { min-height: 60vh; padding-bottom: 64px; }
main:focus { outline: none; }
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 4px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; border-radius: 3px; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.2; }
h1 { font-size: clamp(38px, 5.5vw, 56px); letter-spacing: -0.035em; margin: 0; text-wrap: balance; }
h2 { font-size: 30px; letter-spacing: -0.02em; }
h3 { font-size: 24px; }
p { margin: 0 0 1.25em; }
strong { font-weight: 600; }
[hidden] { display: none !important; }
.accent { color: var(--accent); }
.skip-link { position: absolute; left: 20px; top: -80px; z-index: 10; background: var(--text); color: var(--page); padding: 8px 16px; }
.skip-link:focus { top: 10px; }
.page, .header-inner { width: min(740px, calc(100% - 56px)); margin-inline: auto; }
.reading-page { max-width: 740px; }
.site-header { padding: 30px 0 24px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.header-actions { display: flex; width: 100%; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
.header-actions nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.header-actions nav[aria-label="Elsewhere"] { gap: 12px 14px; }
.header-actions nav a { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); text-decoration: none; padding: 5px 0; white-space: nowrap; }
.header-actions nav a[aria-current="page"] { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 8px; }
.header-actions nav a:hover { color: var(--text); }
.nav-icon, .social-icon, .section-icon { width: 15px; height: 15px; flex: 0 0 15px; }
.nav-icon, .section-icon { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.social-icon { display: inline-block; vertical-align: -2px; }
.page-heading { padding: 58px 0 34px; }
.page-heading .lead { margin: 18px 0 0; max-width: 540px; }
.eyebrow, .section-label { font-family: var(--sans); font-size: 10px; font-weight: 600; line-height: 1.5; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.eyebrow { margin-bottom: 18px; }
.lead { font-size: 20px; line-height: 1.6; color: var(--muted); font-weight: 400; }
.text-link { font-size: 13px; text-decoration: none; color: var(--accent); }
.text-link span { display: inline-block; margin-left: 5px; }
.home-intro { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 64px; align-items: center; padding: 68px 0 64px; }
.home-intro .eyebrow { font-size: 13px; letter-spacing: 0.12em; }
.home-intro h1 { font-size: clamp(38px, 5.2vw, 54px); line-height: 1.08; }
.home-intro .lead { margin: 22px 0; }
.home-company { margin: 0 0 18px; font-size: 15px; color: var(--muted); }
.home-company a { color: var(--accent); }
.portrait { width: 200px; height: 200px; object-fit: contain; }
.home-books { border-top: 1px solid var(--line); padding-top: 28px; }
.home-books .section-label { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.book-link { display: flex; min-width: 0; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.book-link > span:first-child { display: flex; flex-direction: column; align-self: stretch; }
.book-link strong { display: block; font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1.4; }
.book-link small { display: block; color: var(--muted); font-size: 11px; margin-top: auto; padding-top: 12px; }
.recent-writing { margin-top: 54px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 8px; }
.section-heading h2 { margin: 0; }
.contact { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-top: 40px; overflow-wrap: anywhere; }
.topic-links { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 28px; }
.topic-links a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); font-size: 11px; text-decoration: none; }
.topic-links a:hover { color: var(--accent); border-color: var(--accent); }
.post-card { padding: 28px 0 32px; border-top: 1px solid var(--line); }
.post-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; font-family: var(--sans); font-size: 10px; line-height: 1.6; letter-spacing: 0.025em; color: var(--muted); }
.post-meta time { white-space: nowrap; }
.post-meta a { text-decoration: none; }
.post-card h2 { font-size: 28px; line-height: 1.28; margin: 12px 0; }
.post-card h2 a { text-decoration: none; }
.post-summary { color: var(--muted); font-size: 14px; line-height: 1.8; }
.post-card-compact { padding: 22px 0; }
.post-card-compact:first-of-type { border-top: 0; }
.post-card-compact h2 { font-size: 24px; margin-bottom: 0; }
.archive-group { border-top: 1px solid var(--line); padding: 22px 0 36px; scroll-margin-top: 30px; }
.archive-group h2 { font-size: 26px; margin: 0 0 20px; }
.archive-group ul { list-style: none; padding: 0; margin: 0; }
.archive-group li { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 14px 0; }
.archive-group li a { font-size: 15px; text-decoration: none; }
.archive-group time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.article-header { padding: 40px 0 36px; border-bottom: 1px solid var(--line); margin-bottom: 38px; }
.back-link { display: inline-block; color: var(--muted); font-size: 12px; text-decoration: none; margin-bottom: 30px; }
.article-header h1 { margin: 18px 0 22px; font-size: clamp(34px, 5vw, 48px); }
.article-summary { color: var(--muted); font-size: 16px; line-height: 1.8; }
.article-summary:empty { display: none; }
.article-body { font-family: var(--serif); font-size: 18px; line-height: 1.85; overflow-wrap: break-word; }
.article-body h2 { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin: 52px 0 22px; }
.article-body h3 { margin-top: 36px; }
.article-body h4 { font-family: var(--sans); font-size: 16px; margin: 28px 0 12px; }
.article-body ul, .article-body ol { padding-left: 24px; }
.article-body li { margin: 8px 0; }
.article-body li > p { margin: 0; }
.article-body li li { margin: 5px 0; }
.article-body img { display: block; max-width: 100%; height: auto; margin: 24px auto; border-radius: 4px; }
.article-body blockquote { margin: 28px 0; border-left: 2px solid var(--accent); padding: 0 24px; color: var(--muted); }
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body .figure { margin: 32px 0; padding: 24px 0; border-block: 1px solid var(--line); }
.caption { font-family: var(--sans); font-size: 13px; line-height: 1.7; color: var(--muted); }
.caption-label { font-weight: 600; }
.sketch-figure { margin: 36px 0; max-width: 100%; }
.sketch-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--diagram-paper); scrollbar-width: thin; }
.sketch-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.sketch-diagram { display: block; width: 100%; min-width: 660px; height: auto; max-width: none; }
.sketch-figure figcaption { margin-top: 12px; font-family: var(--sans); font-size: 13px; line-height: 1.7; color: var(--muted); }
.sketch-open { display: inline-block; margin-left: 6px; white-space: nowrap; font-size: 11px; }
.sketch-scroll-hint { display: none; margin-top: 5px; font-size: 11px; }
.article-body hr { width: 80px; margin: 48px auto; border: 0; border-top: 1px solid var(--line-strong); }
.article-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-family: var(--sans); font-size: 14px; }
.article-body td, .article-body th { padding: 10px 14px; border: 1px solid var(--line); }
.article-body th, .article-body tr:nth-child(even) { background: var(--surface); }
.profile-body { font-family: var(--sans); font-size: 15px; line-height: 1.85; }
.profile-body > :first-child { margin-top: 0; }
.profile-body h2 { font-size: 28px; }
.profile-nav { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 24px; font-size: 12px; color: var(--muted); }
.profile-nav a { text-decoration: none; }
.profile-nav a:hover { color: var(--accent); }
.profile-intro { font-size: 16px; }
.profile-intro .profile-opening { font-family: var(--serif); font-size: clamp(24px, 3.5vw, 29px); line-height: 1.5; margin-bottom: 24px; }
.profile-intro a { color: var(--accent); }
.profile-intro .profile-background { color: var(--muted); font-size: 14px; }
.profile-philosophy { margin: 36px 0 40px; padding: 28px 0; border-block: 1px solid var(--line); }
.profile-philosophy .eyebrow { margin-bottom: 16px; }
.profile-philosophy blockquote { margin: 0; padding: 0; border: 0; color: var(--text); }
.profile-philosophy blockquote p { font-family: var(--serif); font-size: clamp(21px, 3vw, 25px); font-style: italic; line-height: 1.6; }
.profile-translation { color: var(--muted); font-size: 14px; margin: 14px 0 8px; }
.profile-philosophy figcaption { font-size: 12px; color: var(--muted); }
.profile-books { margin-bottom: 44px; }
.profile-books h2 { margin-top: 0; }
.references { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.references h2 { font-size: 24px; margin-top: 0; }
.bibliography { font-size: 12px; line-height: 1.8; color: var(--muted); padding-left: 20px; }
.bibliography li { padding-left: 6px; margin-bottom: 14px; }
code, pre { font-family: var(--mono); font-size: 0.8em; }
code { background: var(--surface); border-radius: 3px; padding: 2px 5px; }
pre { overflow: auto; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; line-height: 1.7; }
pre code { font-size: inherit; padding: 0; background: transparent; }
.highlight pre { margin: 0; }
.highlight { margin: 24px 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 10px 0; }
.katex { font-size: 1.1em; }
[class^="callout-"] { margin: 28px 0; padding: 22px 26px; border-left: 2px solid var(--accent); border-radius: 3px; }
.with-margin { margin: 0; }
[class^="callout-"] p:last-child, [class^="callout-"] .with-margin > :last-child { margin-bottom: 0; }
.callout-blue { background: var(--blue); }
.callout-red { background: var(--red); }
.callout-green { background: var(--green); }
.callout-yellow { background: var(--yellow); }
.callout-orange { background: var(--orange); }
.callout-gray { background: var(--gray); }
.callout-purple { background: var(--purple); }
.highlight .c, .highlight .ch, .highlight .cm, .highlight .cp, .highlight .cpf, .highlight .c1, .highlight .cs, .highlight .gh, .highlight .go, .highlight .gu, .highlight .nb, .highlight .bp, .highlight .nn, .highlight .gp { color: var(--code-comment); }
.highlight .s, .highlight .sa, .highlight .sb, .highlight .sc, .highlight .dl, .highlight .sd, .highlight .s2, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .s1, .highlight .ss { color: var(--code-string); }
.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .mo, .highlight .il, .highlight .na, .highlight .no, .highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .vm { color: var(--code-number); }
.highlight .kt, .highlight .nc, .highlight .ni, .highlight .nt { color: var(--code-name); }
.highlight .ne, .highlight .nf, .highlight .fm, .highlight .gr, .highlight .gt { color: var(--code-function); }
.highlight .k, .highlight .o, .highlight .kc, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .ow { font-weight: 600; }
.highlight .c, .highlight .ch, .highlight .cm, .highlight .c1, .highlight .ge { font-style: italic; }
.highlight .err, .highlight .gd { color: var(--text); background: var(--red); }
.highlight .gi { color: var(--text); background: var(--green); }
.highlight .hll { background: var(--yellow); }
.theme-control, .theme-switch { display: inline-flex; }
.theme-control { margin-left: auto; }
.theme-switch { gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 20px; }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--quiet); cursor: pointer; touch-action: manipulation; }
.theme-switch button:hover { color: var(--text); background: var(--surface); }
.theme-switch button[aria-pressed="true"] { color: var(--text); background: var(--active); }
.theme-switch button:focus-visible { outline-offset: 3px; border-radius: 50%; }
.theme-switch svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 680px) {
  .page, .header-inner { width: calc(100% - 40px); }
  .site-header { padding-top: 22px; }
  .header-inner { flex-wrap: wrap; gap: 16px; padding-bottom: 20px; }
  .header-actions { width: 100%; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
  .header-actions nav { gap: 20px; }
  .page-heading { padding-top: 34px; }
  .home-intro { padding: 36px 0 40px; gap: 24px; grid-template-columns: minmax(0, 1fr) 128px; }
  .home-intro h1 { font-size: 38px; }
  .home-intro .lead { font-size: 17px; }
  .portrait { width: 128px; height: 128px; align-self: start; margin-top: 34px; }
  .desktop-break { display: none; }
  .book-grid { grid-template-columns: 1fr; gap: 0; }
  .book-link strong { font-size: 20px; }
  .post-card h2 { font-size: 25px; }
  .article-body { font-size: 17px; }
  .profile-body { font-size: 15px; }
  .article-header { padding-top: 22px; }
  .article-header h1 { font-size: 36px; }
  .article-summary { font-size: 15px; }
  .sketch-scroll-hint { display: block; }
}

@media (max-width: 420px) {
  .home-intro { grid-template-columns: 1fr; gap: 24px; }
  .portrait { grid-row: 1; width: 96px; height: 96px; margin-top: 0; }
  .home-intro h1 { font-size: 40px; }
  .archive-group li { display: block; }
  .archive-group time { display: block; margin-top: 4px; }
}

@media (pointer: coarse) {
  .theme-switch button { width: 36px; height: 36px; }
  .header-actions nav a { min-height: 40px; }
}

@media print {
  :root { color-scheme: light; }
  body { color: #111; background: #fff; }
  .site-header, .skip-link, .back-link { display: none; }
  .page { width: 100%; max-width: none; }
  .article-body { font-size: 11pt; }
  .article-header { padding-top: 0; }
  a { color: inherit; }
  pre, [class^="callout-"] { background: #f5f5f5; color: #111; }
  .sketch-figure { break-inside: avoid; --diagram-paper: #fff; --diagram-ink: #343b3c; --diagram-muted: #64706c; --diagram-blue: #4263b5; --diagram-teal: #247b72; --diagram-orange: #a8682d; --diagram-purple: #8252a4; }
  .sketch-diagram { min-width: 0; }
  .sketch-open, .sketch-scroll-hint { display: none; }
  .sketch-figure figcaption { color: #444; }
}
