:root {
  --paper: #f6f3eb;
  --ink: #1b1a17;
  --gray: #5e5b54;
  --light: #9b978d;
  --hair: #cfcabd;
  --serif: "EB Garamond", "Times New Roman", Times, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --col: 34rem;
  --side: 13rem;
  --gutter: 2.2rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 20px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-thickness: 0.06em; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.1em; }
code, pre { font-family: var(--mono); font-size: 0.72rem; font-variant-numeric: normal; }
p code { font-size: 0.78em; }
code { hyphens: none; white-space: nowrap; }
.sc { font-variant-caps: all-small-caps; letter-spacing: 0.06em; font-variant-numeric: lining-nums; }

/* Page: one centered text column; sidenotes hang into the right margin. */
.page {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  box-sizing: content-box;
}
article, .masthead, .colophon { max-width: var(--col); }

/* Masthead */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 2.2rem 0 0.7rem;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 3.2rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; font-size: 1.05rem; }
.logo { width: 1.15rem; height: 1.15rem; color: var(--ink); align-self: center; }

/* Title and abstract */
h1 {
  font-weight: 400;
  font-size: 2.05rem;
  line-height: 1.14;
  letter-spacing: -0.01em;
  margin: 0 0 2rem;
}
.abstract { margin: 0 0 2.8rem; padding: 0 1.6rem; }
.abstract h2 { font-size: 0.95rem; font-weight: 400; margin: 0 0 0.3rem; text-align: center; color: var(--gray); }
.abstract p { margin: 0; font-size: 0.93rem; hyphens: auto; }

/* Sections */
section { margin-bottom: 2.6rem; }
section h2 { font-weight: 400; font-size: 1.3rem; margin: 0 0 0.7rem; }
.sec { display: inline-block; min-width: 2.1rem; color: var(--gray); font-variant-numeric: lining-nums; }
section p { margin: 0 0 1rem; hyphens: auto; }

/* Sidenotes, Tufte style: hung in the right margin on wide screens, inline below the text on narrow ones. */
.sn-ref {
  font-size: 0.65rem;
  vertical-align: super;
  line-height: 0;
  margin-left: 0.08em;
  font-variant-numeric: lining-nums;
}
.sidenote {
  float: right;
  clear: right;
  width: var(--side);
  margin-right: calc(-1 * (var(--side) + var(--gutter)));
  margin-top: 0.2rem;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--gray);
}
.sn-num { font-size: 0.85em; vertical-align: super; line-height: 0; margin-right: 0.2em; font-variant-numeric: lining-nums; }
.sidenote code { font-size: 0.9em; }

/* Figures */
figure { margin: 1.8rem 0 2rem; }
figcaption { margin-top: 0.6rem; font-size: 0.78rem; line-height: 1.45; color: var(--gray); }
figcaption .sc { color: var(--ink); }

/* Sketch: writing the name versus Helm */
.sketch .sk-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.sk-col { padding: 0.7rem 0.9rem 0.9rem 0; min-width: 0; }
.sk-col + .sk-col { padding: 0.7rem 0 0.9rem 0.9rem; border-left: 1px solid var(--hair); }
.sk-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 0.5rem; font-size: 0.92rem; }
.sk-count { font-family: var(--mono); font-size: 0.6rem; color: var(--gray); }
.sk-steps, .sk-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  position: relative;
}
.sk-steps { min-height: 6.6rem; }
.sk-steps li { display: grid; grid-template-columns: 4.8em 1fr; height: 1.35rem; white-space: nowrap; align-items: center; animation: fade-in 0.35s ease both; }
.sk-steps .step { color: var(--light); }
.sk-steps .done { color: var(--light); }
.sk-verdict { margin: 0.4rem 0 0; min-height: 1.3rem; font-size: 0.82rem; font-style: italic; color: var(--gray); }
.sk-verdict.bad { color: var(--ink); }

.sk-rank { height: calc(1.35rem * 7); }
.sk-rank li {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1.35rem;
  display: grid;
  grid-template-columns: 1.4em minmax(0, 1fr) 3rem 3.2em;
  gap: 0.4rem;
  align-items: center;
  color: var(--light);
  transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1), color 0.4s ease;
}
.sk-rank .bar { height: 1px; background: var(--ink); width: 0; transition: width 0.6s ease; }
.sk-rank .p { text-align: right; opacity: 0; transition: opacity 0.4s ease; }
.sk-rank.scored li { color: var(--ink); }
.sk-rank.scored .p { opacity: 1; }
.sk-rank.scored li.first .nm { text-decoration: underline; text-underline-offset: 0.2em; }
.sk-rank .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-rank.no-move li { transition: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Diagram */
.diagram svg { display: block; width: 100%; height: auto; color: var(--ink); overflow: visible; }
.diag-text text { font-family: var(--serif); font-size: 15px; font-style: italic; fill: var(--ink); }
.diag-text .diag-small { font-size: 13px; fill: var(--gray); }

/* Figure 1 */
.code { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 0.7rem 0 0.8rem; }
.code-label { margin: 0 0 0.3rem; font-size: 0.85rem; color: var(--gray); }
.code pre { margin: 0 0 1rem; line-height: 1.6; white-space: pre; overflow-x: auto; }
.code .k { font-weight: 600; }
.code .f { color: var(--gray); }
.resp { border-collapse: collapse; font-family: var(--mono); font-size: 0.72rem; line-height: 1.6; width: 100%; max-width: 24rem; }
.resp thead th { font-weight: 400; color: var(--light); text-align: left; padding: 0 0 0.1rem; }
.resp td { padding: 0; vertical-align: baseline; }
.resp .r, .resp th:first-child { width: 3.4em; color: var(--light); }
.resp .p, .resp th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.resp tbody tr:first-child .n { text-decoration: underline; text-underline-offset: 0.2em; }
.latency { margin: 0.6rem 0 0; font-family: var(--mono); font-size: 0.66rem; color: var(--gray); }

.reveal .resp tbody tr { opacity: 0; transform: translateY(3px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.in .resp tbody tr { opacity: 1; transform: none; }

/* Results table, booktabs style */
.booktabs {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0 0.4rem;
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 0.95rem;
}
.booktabs thead th { border-top: 1.5px solid var(--ink); border-bottom: 0.75px solid var(--ink); font-weight: 400; padding: 0.45rem 0 0.35rem; }
.booktabs tbody tr:last-child th, .booktabs tbody tr:last-child td { border-bottom: 1.5px solid var(--ink); padding-bottom: 0.5rem; }
.booktabs tbody tr:first-child th, .booktabs tbody tr:first-child td { padding-top: 0.45rem; }
.booktabs th, .booktabs td { padding: 0.18rem 0; text-align: right; }
.booktabs th:first-child { text-align: left; font-weight: 400; }
.booktabs td, .booktabs thead th:not(:first-child) { padding-left: 1.2rem; }

.booktabs .diff { font-style: italic; color: var(--gray); }
.table-note { font-size: 0.74rem; color: var(--gray); margin: 0.3rem 0 1.2rem; }

/* Limits */
.limits { margin: 0; padding-left: 1.3rem; }
.limits li { margin-bottom: 0.35rem; padding-left: 0.2rem; }
.limits li::marker { font-variant-numeric: lining-nums; color: var(--gray); }

/* Colophon */
.colophon { margin-top: 3.4rem; padding-top: 0.8rem; border-top: 1px solid var(--ink); font-size: 0.8rem; color: var(--gray); }
.name-note { margin: 0 0 0.8rem; }
.founder { margin: 0 0 0.3rem; }
.name-note .sc { color: var(--ink); }
.foot-line { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin: 0; }

/* Narrow screens: sidenotes drop into the text column. */
/* Below this width there is no room for the margin, so sidenotes drop into the text column. */
@media (max-width: 1400px) {
  .sidenote {
    float: none;
    display: block;
    width: auto;
    margin: 0.6rem 0 0.6rem 1rem;
    padding-left: 0.7rem;
    border-left: 1px solid var(--hair);
  }
}

@media (max-width: 560px) {
  html { font-size: 18px; }
  .page { padding: 0 1.1rem 2rem; }
  .masthead { padding-top: 1.4rem; margin-bottom: 2.2rem; flex-direction: column; gap: 0.2rem; }
  h1 { font-size: 1.7rem; }
  .abstract { padding: 0 0.4rem; }
  .sketch .sk-cols { grid-template-columns: 1fr; }
  .sk-col { padding-right: 0; }
  .sk-col + .sk-col { border-left: 0; border-top: 1px solid var(--hair); padding-left: 0; }
  .code pre { font-size: 0.64rem; }
  .booktabs { font-size: 0.78rem; }
  .booktabs td, .booktabs thead th:not(:first-child) { padding-left: 0.6rem; }
  .diag-text text { font-size: 19px; }
  .diag-text .diag-small { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
