:root {
  --serif: "Source Serif 4 Variable", ui-serif, serif;
  --sans-serif: "Inter Variable", ui-sans-serif, sans-serif;
  --monospace: "Spline Sans Mono Variable", Menlo, Consolas, monospace;
  --monospace-font: 14px/1.5 var(--monospace);
  --max-width: calc(1024px - 4 * 16px); /* max-w-5xl p-4 */
}

html {
  font: 17px/1.5 var(--serif);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--theme-background);
  color: var(--theme-foreground);
  margin: 16px 0;
  padding: 16px 24px;
}

main {
  margin: auto;
  max-width: var(--max-width);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--theme-foreground-alt);
  font-weight: 700;
  line-height: 1.15;
  margin-top: 0;
  margin-bottom: 0.25rem;
  text-wrap: balance;
}

h2 + p,
h3 + p,
h4 + p,
h2 + table,
h3 + table,
h4 + table {
  margin-top: 0;
}

.observablehq:first-of-type h1 + h2 {
  color: var(--theme-foreground);
  font-size: 20px;
  font-style: italic;
  font-weight: normal;
  margin-bottom: 1rem; /* see h2 ~ p */
}

a[href] {
  color: var(--theme-foreground-focus);
  text-decoration: none;
}

a[href]:hover,
a[href]:focus {
  text-decoration: underline;
}

pre,
code,
tt {
  font-family: var(--monospace);
  font-size: 82.35294117%; /* from 17px to 14px */
}

pre code,
figcaption code {
  font-size: inherit;
}

pre[data-language] {
  position: relative;
}

pre[data-language]::before {
  content: attr(data-language);
  position: sticky;
  top: 0;
  left: 0;
  height: 0;
  display: block;
  text-align: right;
  margin-right: -4px;
  pointer-events: none;
  font-size: 12px;
  line-height: 21px;
  color: var(--theme-foreground-muted);
}

h1 code,
h2 code,
h3 code,
h4 code,
h5 code,
h6 code {
  font-size: 88.235294117%; /* from 17px to 15px */
}

h2[id] a[href],
h3[id] a[href] {
  color: inherit;
}

pre {
  line-height: 1.5;
}

img {
  max-width: 100%;
}

p,
table,
figure,
figcaption,
h1,
h2,
h3,
h4,
h5,
h6,
.katex-display {
  max-width: 640px;
}

blockquote,
ol,
ul {
  max-width: 600px;
}

blockquote {
  margin: 1rem 1.5rem;
}

ul,
ol {
  padding-left: 28px;
}

hr {
  height: 1px;
  margin: 1rem 0;
  padding: 1rem 0;
  border: none;
  background: no-repeat center/100% 1px
    linear-gradient(to right, var(--theme-foreground-faintest), var(--theme-foreground-faintest));
}

pre {
  background-color: var(--theme-background-alt);
  border-radius: 4px;
  margin: 1rem -1rem;
  min-height: 1.5em;
  padding: 4px 1rem;
  overflow-x: auto;
  overscroll-behavior-x: none;
  box-sizing: border-box;
}

pre > code:only-child {
  display: block;
  width: fit-content;
}

input:not([type]),
input[type="email"],
input[type="number"],
input[type="password"],
input[type="range"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="url"] {
  width: 240px;
}

input,
canvas,
button {
  vertical-align: middle;
}

button,
input,
textarea {
  accent-color: var(--theme-foreground-focus);
}

table {
  width: 100%;
  border-collapse: collapse;
  font: 13px/1.2 var(--sans-serif);
}

table pre,
table code,
table tt {
  font-size: inherit;
  line-height: inherit;
}

th > pre:only-child,
td > pre:only-child {
  margin: 0;
  padding: 0;
}

th {
  color: var(--theme-foreground);
  text-align: left;
  vertical-align: bottom;
}

td {
  color: var(--theme-foreground-alt);
  vertical-align: top;
}

th,
td {
  padding: 3px 6.5px 3px 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

tr:not(:last-child) {
  border-bottom: solid 1px var(--theme-foreground-faintest);
}

thead tr {
  border-bottom: solid 1px var(--theme-foreground-fainter);
}

figure,
table {
  margin: 1rem 0;
}

figure img {
  max-width: 100%;
}

figure > h2,
figure > h3 {
  font-family: var(--sans-serif);
}

figure > h2 {
  font-size: 20px;
}

figure > h3 {
  font-size: 16px;
  font-weight: normal;
}

figcaption {
  font: small var(--sans-serif);
  color: var(--theme-foreground-muted);
}
