:root {
  color-scheme: light;
  --bg: #f8f7f4;
  --fg: #181817;
  --muted: #686762;
  --line: #d8d5ce;
  --link: #145ea8;
  --code: #ece9e1;
  --hl-comment: #6d6c66;
  --hl-keyword: #a8326e;
  --hl-string: #1f7a4d;
  --hl-number: #9a5b00;
  --hl-function: #5b3fb8;
  --hl-tag: #1d5fa8;
  --hl-attribute: #8a5a00;
  --hl-punctuation: #77766f;
  --burgundy: #7b1f3a;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111210;
  --fg: #ecece7;
  --muted: #aaa9a1;
  --line: #3b3c38;
  --link: #86bdf4;
  --code: #20221f;
  --hl-comment: #8f8e86;
  --hl-keyword: #f08bb9;
  --hl-string: #8fd19e;
  --hl-number: #f0b86e;
  --hl-function: #b9a6ff;
  --hl-tag: #82b8f5;
  --hl-attribute: #e3b36a;
  --hl-punctuation: #9c9b93;
  --burgundy: #e7a1b0;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.65 ui-sans-serif, system-ui, sans-serif; }
main { width: min(920px, calc(100% - 40px)); margin: 72px auto 120px; }
h1 { margin: 0 0 1.4rem; font-size: clamp(2.1rem, 6vw, 4.2rem); line-height: 1.04; letter-spacing: -.045em; }
h2 { margin: 3.2rem 0 1rem; font-size: 1.65rem; line-height: 1.2; }
h3 { margin: 2.2rem 0 .7rem; font-size: 1.2rem; }
p, li { max-width: 75ch; }
header { margin-bottom: 2.4rem; }
header h1 { margin-bottom: 1rem; }
.subtitle { margin: 0 0 1rem; font: 1.3rem/1.5 Georgia, "Iowan Old Style", serif; }
.contents { margin: 0 0 2.4rem; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 8px; }
.contents summary { color: var(--muted); cursor: pointer; }
.contents ul { margin: .6rem 0 .2rem; padding-left: 1.2rem; }
.contents li { margin: .2rem 0; }
.contents .sub { margin-left: 1.2rem; list-style: circle; }
.byline { margin: 0; color: var(--muted); font-size: .95rem; }
a { color: var(--link); text-underline-offset: 3px; }
blockquote { margin: 1.6rem 0; padding: .1rem 1.2rem; border-left: 3px solid var(--fg); color: var(--muted); }
pre, code { background: var(--code); font-family: ui-monospace, SFMono-Regular, monospace; }
code { padding: .12em .3em; border-radius: 4px; }
:not(pre) > code, main p a, main li a { overflow-wrap: anywhere; }
pre { overflow: auto; padding: 1rem; border-radius: 8px; }
pre code { padding: 0; }
table { width: 100%; margin: 1.6rem 0; border: 1px solid var(--line); border-radius: 8px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: .62rem .72rem; border-bottom: 1px solid var(--line); text-align: right; overflow-wrap: anywhere; }
th { line-height: 1.3; }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }
nav { position: fixed; top: 18px; right: 18px; display: flex; gap: 8px; }
#theme, #posts { height: 42px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--fg); cursor: pointer; }
#theme { width: 42px; font-size: 20px; }
#posts { display: flex; align-items: center; padding: 0 16px; font-size: 15px; text-decoration: none; }
.posts { padding: 0; list-style: none; }
.posts li { display: flex; gap: 1.2rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.posts time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
img { max-width: 100%; }
main img { cursor: zoom-in; }
#lightbox { max-width: none; max-height: none; width: 100vw; height: 100vh; margin: 0; padding: 0; border: 0; background: rgb(0 0 0 / .85); cursor: zoom-out; }
#lightbox[open] { display: flex; align-items: center; justify-content: center; }
#lightbox::backdrop { background: transparent; }
#lightbox img { max-width: 96vw; max-height: 96vh; object-fit: contain; }
p:has(> img:only-child) { margin: 2rem 0 0; }
p:has(> img:only-child) + p:has(> em:only-child) { margin: .5rem 0 2rem; color: var(--muted); font-size: .85rem; line-height: 1.45; }
.chart { margin: 2rem 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font: 13px ui-sans-serif, system-ui, sans-serif; }
.chart .axis { stroke: var(--line); }
.chart .point { fill: var(--link); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  main { width: min(100% - 28px, 920px); margin-top: 64px; }
}

.timeline-widget { --tl-0: #b74742; --tl-1: #287a84; --tl-2: #8661a2; --tl-3: #ad751f; --tl-plate-0: #f9eae7; --tl-plate-1: #e8f3f1; --tl-plate-2: #f1eafa; --tl-plate-3: #faf0df; margin: 1.5rem 0 2.5rem; }
:root[data-theme="dark"] .timeline-widget { --tl-0: #f3988d; --tl-1: #80d2d2; --tl-2: #c4a2e0; --tl-3: #e6b65a; --tl-plate-0: #382523; --tl-plate-1: #1c3434; --tl-plate-2: #30283c; --tl-plate-3: #3b3121; }
.timeline-color-0 { --tl-color: var(--tl-0); --tl-plate: var(--tl-plate-0); }
.timeline-color-1 { --tl-color: var(--tl-1); --tl-plate: var(--tl-plate-1); }
.timeline-color-2 { --tl-color: var(--tl-2); --tl-plate: var(--tl-plate-2); }
.timeline-color-3 { --tl-color: var(--tl-3); --tl-plate: var(--tl-plate-3); }
.timeline-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.3rem; font-size: .78rem; color: var(--muted); }
.timeline-key { display: inline-flex; gap: .4rem; align-items: center; }
.timeline-key i { width: .62rem; height: .62rem; border-radius: 50%; background: var(--tl-color); }
.timeline-track { --tl-date: 6.7rem; display: grid; grid-template-columns: repeat(var(--timeline-lanes), .65rem) var(--tl-date) 1rem minmax(0, 1fr); column-gap: .45rem; grid-template-rows: repeat(var(--timeline-rows), minmax(3.8rem, auto)); position: relative; padding: .55rem 0; margin: .6rem 0; list-style: none; background: linear-gradient(var(--line), var(--line)) no-repeat calc(var(--timeline-lanes) * 1.1rem + var(--tl-date) + .5rem) center / 1px calc(100% - 1.5rem); }
.timeline-track li { max-width: none; }
.timeline-bar { z-index: 1; position: relative; width: .4rem; justify-self: center; margin: .8rem 0 1.8rem; border-radius: 99px; background: var(--tl-color); opacity: .85; }
.timeline-bar::before, .timeline-bar::after { content: ""; position: absolute; left: -.18rem; width: .76rem; height: .76rem; border-radius: 50%; background: var(--tl-color); }
.timeline-bar::before { top: -.18rem; }
.timeline-bar::after { bottom: -.18rem; }
.timeline-item { display: grid; grid-column: calc(var(--timeline-lanes) + 1) / -1; grid-template-columns: var(--tl-date) 1rem minmax(0, 1fr); gap: .45rem; align-items: start; position: relative; padding: .3rem 0; line-height: 1.42; }
.timeline-item::before { content: ""; grid-column: 2; grid-row: 1; width: .64rem; height: .64rem; margin: .55rem auto 0; border-radius: 50%; background: var(--tl-color); box-shadow: 0 0 0 3px var(--bg); z-index: 1; }
.timeline-item time { grid-column: 1; grid-row: 1; justify-self: end; margin-top: .25rem; padding: .06rem .3rem; border-radius: 3px; color: var(--tl-color); background: var(--tl-plate); font: .75rem/1.4 ui-monospace, SFMono-Regular, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline-body { grid-column: 3; grid-row: 1; min-width: 0; padding: .3rem .6rem; border-radius: 4px; background: var(--tl-plate); font-size: .94rem; }
.timeline-body a { display: inline-block; margin-left: .15rem; color: var(--tl-color); font-weight: 700; text-decoration: none; }
.timeline-body a:hover, .timeline-body a:focus-visible { text-decoration: underline; }
.timeline-item:hover .timeline-body, .timeline-item:focus-within .timeline-body { outline: 1px solid var(--tl-color); }
.timeline-end .timeline-body { background: none; color: var(--muted); font-size: .85rem; font-style: italic; }
.timeline-end::before { background: var(--bg); box-shadow: 0 0 0 2px var(--tl-color); }
@media (max-width: 600px) {
  .timeline-track { grid-template-columns: repeat(var(--timeline-lanes), .45rem) .9rem minmax(0, 1fr); column-gap: .3rem; grid-template-rows: repeat(var(--timeline-rows), minmax(2.4rem, auto)); background-position: calc(var(--timeline-lanes) * .75rem + .45rem) center; }
  .timeline-item { grid-template-columns: .9rem minmax(0, 1fr); gap: .1rem .3rem; padding: .25rem 0; }
  .timeline-item::before { grid-column: 1; grid-row: 1; margin-top: .3rem; }
  .timeline-item time { grid-column: 2; grid-row: 1; justify-self: start; margin-top: 0; font-size: .7rem; }
  .timeline-body { grid-column: 2; grid-row: 2; padding: .25rem .45rem; font-size: .9rem; }
  .timeline-bar { width: .28rem; margin: .45rem 0 1rem; }
  .timeline-bar::before, .timeline-bar::after { left: -.14rem; width: .56rem; height: .56rem; }
}
.smalto-comment { color: var(--hl-comment); font-style: italic; }
.smalto-keyword, .smalto-builtin { color: var(--hl-keyword); }
.smalto-string, .smalto-regex, .smalto-template-string { color: var(--hl-string); }
.smalto-number, .smalto-boolean, .smalto-constant { color: var(--hl-number); }
.smalto-function, .smalto-class-name { color: var(--hl-function); }
.smalto-tag, .smalto-property, .smalto-selector { color: var(--hl-tag); }
.smalto-attribute { color: var(--hl-attribute); }
.smalto-punctuation, .smalto-operator { color: var(--hl-punctuation); }
.footnotes { margin-top: 3.5rem; padding-top: .6rem; border-top: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
.footnotes h2 { margin: .4rem 0 .8rem; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; }
.footnotes ol { padding-left: 1.4rem; }
.footnotes li { margin: .5rem 0; }
.footnotes li:target, .footnote-ref a:target { background: var(--code); border-radius: 3px; }
.footnote-back { text-decoration: none; }
.footnote-ref a { text-decoration: none; padding: 0 .1rem; }
[data-headings="burgundy"] :is(h1, h2, h3, h4) { color: var(--burgundy); }
