@font-face { font-family: Inter; font-weight: 400; src: url(fonts/Inter-Regular.ttf) format("truetype"); }
@font-face { font-family: Inter; font-weight: 500; src: url(fonts/Inter-Medium.ttf) format("truetype"); }
@font-face { font-family: Inter; font-weight: 600; src: url(fonts/Inter-SemiBold.ttf) format("truetype"); }
@font-face { font-family: Inter; font-weight: 700; src: url(fonts/Inter-Bold.ttf) format("truetype"); }
@font-face { font-family: "Liberation Serif"; font-weight: 400; src: url(fonts/LiberationSerif-Regular.ttf) format("truetype"); }
@font-face { font-family: "Liberation Serif"; font-weight: 400; font-style: italic; src: url(fonts/LiberationSerif-Italic.ttf) format("truetype"); }
@font-face { font-family: "Liberation Serif"; font-weight: 700; src: url(fonts/LiberationSerif-Bold.ttf) format("truetype"); }

:root {
  --bg: #ffffff;
  --fg: #1d2129;
  --muted: #5d6573;
  --line: #e3e6eb;
  --code-bg: #f5f6f8;
  --accent: #0b63b6;
  --refused: #b3261e;
  --figure-bg: #ffffff;
  /* The code's colours, by what highlight.fsx says each token is: Visual Studio Code's Light+ and
     Dark+, as Tambour's editor has them, with a colour of their own for modules and units. */
  --code-keyword: #0000ff;
  --code-type: #22748c;
  --code-struct: #237a52;
  --code-module: #6f42c1;
  --code-function: #795e26;
  --code-value: #001080;
  --code-case: #0070c1;
  --code-unit: #ad5300;
  --code-string: #a31515;
  --code-number: #077a50;
  --code-comment: #008000;
  --code-operator: #5d6573;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --fg: #e4e7ec;
    --muted: #9aa3b0;
    --line: #2a3038;
    --code-bg: #1c2027;
    --accent: #6cb4ff;
    --refused: #ff8a80;
    --figure-bg: #ffffff;
    --code-keyword: #569cd6;
    --code-type: #4ec9b0;
    --code-struct: #86c691;
    --code-module: #b392f0;
    --code-function: #dcdcaa;
    --code-value: #9cdcfe;
    --code-case: #4fc1ff;
    --code-unit: #f0a050;
    --code-string: #ce9178;
    --code-number: #b5cea8;
    --code-comment: #6a9955;
    --code-operator: #a3adbb;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar .brand { font-weight: 700; font-size: 18px; color: var(--fg); text-decoration: none; }
.bar nav { display: flex; gap: 18px; flex-wrap: wrap; }
.bar nav a { color: var(--muted); text-decoration: none; }
.bar nav a[aria-current="page"], .bar nav a:hover { color: var(--fg); }

.layout { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }
.layout.with-toc { max-width: 1160px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; }

.toc { position: sticky; top: 64px; align-self: start; font-size: 14px; max-height: calc(100vh - 80px); overflow-y: auto; }
.toc ul { list-style: none; padding-left: 0; margin: 8px 0; }
.toc li { margin: 4px 0; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a[aria-current="page"], .toc a:hover { color: var(--fg); }

main { min-width: 0; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 2em; margin-top: 0.4em; }
h2 { margin-top: 2em; padding-bottom: 0.2em; border-bottom: 1px solid var(--line); }

code { font: 0.88em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 14px 16px; border-radius: 6px; overflow-x: auto; }
pre code { padding: 0; background: none; }
pre.refused { border-left: 3px solid var(--refused); }
pre .kw { color: var(--code-keyword); }
pre .ty { color: var(--code-type); }
pre .st { color: var(--code-struct); }
pre .mod { color: var(--code-module); }
pre .fn { color: var(--code-function); }
pre .val, pre .prop { color: var(--code-value); }
pre .case { color: var(--code-case); }
pre .unit { color: var(--code-unit); }
pre .str { color: var(--code-string); }
pre .num { color: var(--code-number); }
pre .com { color: var(--code-comment); font-style: italic; }
pre .op { color: var(--code-operator); }

table { border-collapse: collapse; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }

figure.marey { margin: 20px 0; }
.stage { background: var(--figure-bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; display: inline-block; max-width: 100%; }
.stage img, .stage canvas { display: block; max-width: 100%; height: auto !important; }
.stage [hidden] { display: none; }
.control { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; font-size: 14px; }
.control label { display: flex; align-items: center; gap: 8px; }
.control input { width: min(320px, 50vw); }
.control output { font-variant-numeric: tabular-nums; color: var(--muted); }

img { max-width: 100%; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); }
.pager .next { text-align: right; margin-left: auto; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { display: block; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; text-decoration: none; color: var(--muted); }
.tile img { display: block; width: 100%; height: auto; background: var(--figure-bg); }
.tile span { display: block; padding: 8px 10px; font-size: 14px; }

@media (max-width: 900px) {
  .layout.with-toc { display: block; }
  .toc { position: static; max-height: none; margin-bottom: 24px; }
}
