:root {
  color-scheme: light dark;
  --text: #1f1f1f;
  --muted: #666;
  --bg: #fff;
  --link: #0b57b0;
  --rule: #e2e2e2;
  --code-bg: #f5f5f5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #dcdcdc;
    --muted: #999;
    --bg: #161616;
    --link: #7fb5ff;
    --rule: #333;
    --code-bg: #232323;
  }
}

html { font-size: 18px; -webkit-text-size-adjust: 100%; }
@media (max-width: 30rem) { html { font-size: 17px; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}
header.site, main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

header.site {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  font-size: 0.9rem;
}
header.site a { color: var(--muted); text-decoration: none; }
header.site a:hover { color: var(--text); }
header.site .name { color: var(--text); font-weight: 600; }
header.site nav a { margin-left: 1.25rem; }

main { padding-bottom: 4rem; overflow-wrap: break-word; }

h1, h2, h3, h4 { line-height: 1.25; margin: 2rem 0 0.5rem; }
h1, h2 { font-size: 1.35rem; }
h1.title { font-size: 1.9rem; margin-top: 1rem; }
h1.title + :not(.date) { margin-top: 1.5rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
p, ul, ol, pre, blockquote, table { margin: 0 0 1.1rem; }
li { margin: 0.2rem 0; }

a { color: var(--link); text-underline-offset: 2px; }
.date { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }

img, svg, video, iframe { max-width: 100%; }
img { height: auto; }
@media (prefers-color-scheme: dark) {
  /* Plots and diagrams are drawn for a white page; some have transparent backgrounds. */
  main img { background: #fff; }
}
/* A small portrait beside the opening paragraphs of a page. */
img.portrait { float: right; width: 8.5rem; margin: 0.3rem 0 0.8rem 1.25rem; border-radius: 50%; }
@media (max-width: 30rem) { img.portrait { width: 6.5rem; margin-left: 1rem; } }
h2 { clear: both; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
blockquote { margin-left: 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--muted); }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { font-size: 0.85em; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; }
code.nowrap { white-space: nowrap; }
pre {
  box-sizing: border-box;
  background: var(--code-bg);
  padding: 0.8rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.75rem;
  line-height: 1.5;
}
pre code { background: none; padding: 0; font-size: inherit; }
@media (min-width: 48rem) {
  /* A code block with long lines may extend past the text column, up to the right margin. */
  pre { width: max-content; min-width: 100%; max-width: min(48rem, calc(50vw + 17rem - 1.25rem)); }
}

table { border-collapse: collapse; border: 0; display: block; width: fit-content; max-width: 100%; overflow-x: auto; font-size: 0.9rem; }
th, td { padding: 0.3rem 0.7rem; border: 0; border-bottom: 1px solid var(--rule); text-align: left; }
/* Definition lists are dated lists: a muted year column on the left, the entry on the right.
   An entry can have several ": " lines; they stack in the right column with no gap between them. */
dl { display: grid; grid-template-columns: 5.3rem 1fr; column-gap: 1rem; margin: 0.8rem 0 1.4rem; }
dt { grid-column: 1; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
dd { grid-column: 2; margin: 0; }
dd p { margin: 0; }
dt:not(:first-child), dt:not(:first-child) + dd { margin-top: 0.75rem; }

/* A table whose cells hold images: fills the column and shrinks with it instead of scrolling. */
table.image-grid { display: table; table-layout: fixed; width: 100%; }
table.image-grid td { padding: 0.3rem; }
table.image-grid td:first-child { width: 24%; }
table.image-grid img { display: block; width: 100%; }
sup { line-height: 0; }
mjx-container[display="true"] { max-width: 100%; overflow-x: auto; overflow-y: hidden; }

.footnotes { font-size: 0.9rem; }
.footnotes-sep { margin-top: 3rem; }

ul.posts { list-style: none; padding: 0; }
ul.posts li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 0.9rem 0; }
ul.posts a { text-decoration: none; }
ul.posts a:hover { text-decoration: underline; }
ul.posts p { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
ul.posts time { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.feed { font-size: 0.9rem; margin-top: 2rem; }
