:root {
  color-scheme: dark;
  --background: #12171d;
  --surface: #1b232d;
  --code: #0c1117;
  --text: #edf0f3;
  --muted: #b2bfcd;
  --line: #394758;
  --link: #9bcbff;
  --sign: #ffc497;
  --exponent: #afd0ff;
  --fraction: #a5e1c7;
  font: 112.5%/1.65 system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
}

main {
  max-width: 51rem;
  margin-inline: auto;
  padding: 2.5rem clamp(1rem, 5vw, 3rem) 4rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  margin-bottom: 2.25rem;
  font-size: 0.86rem;
}

h1, h2, h3 {
  font-family: Georgia, serif;
  line-height: 1.14;
  text-wrap: balance;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 5.7vw, 4.25rem);
  font-weight: 500;
  letter-spacing: -0.045em;
}

h2 {
  margin: 2.4rem 0 0.65rem;
  font-size: clamp(1.55rem, 3.6vw, 2rem);
  font-weight: 500;
}

h3 { margin: 1.4rem 0 0.5rem; font-size: 1.2rem; }

p { margin: 0.65rem 0 0.95rem; }
li + li { margin-top: 0.35rem; }
a { color: var(--link); text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; }
sub, sup { line-height: 0; }

.lede {
  max-width: 40rem;
  margin: 0.9rem 0 1.4rem;
  color: var(--muted);
  font-size: 1.12rem;
}

.source, figcaption {
  color: var(--muted);
  font-size: 0.83rem;
}

code, pre, .equation, .bit-fields b {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

code { font-size: 0.9em; }

pre, .equation {
  overflow: auto;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--code);
}

pre { font-size: 0.86rem; line-height: 1.55; }
pre code { font-size: inherit; }
.equation { font-size: clamp(0.79rem, 2.8vw, 1rem); }

figure { margin: 1.2rem 0; }

.bit-fields {
  display: grid;
  grid-template-columns: max-content max-content minmax(0, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.bit-fields > div {
  display: grid;
  min-width: 0;
  gap: 0.13rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-top: 0.16rem solid currentColor;
  border-radius: 0.25rem;
  background: var(--surface);
}

.bit-fields span { font-size: 0.78rem; }
.bit-fields b { font-size: clamp(0.82rem, 2.5vw, 1.08rem); overflow-wrap: anywhere; }
.sign { color: var(--sign); }
.exponent { color: var(--exponent); }
.fraction { color: var(--fraction); }

.exercise {
  margin-top: 1rem;
  padding: 0.15rem 1.1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface);
}

details { margin-top: 0.75rem; }
summary { width: fit-content; cursor: pointer; color: var(--link); font-weight: 650; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; line-height: 1.4; }
caption { text-align: left; margin-bottom: 0.5rem; }
th, td { padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; }

footer {
  margin-top: 2.5rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

@media screen and (max-width: 34rem) {
  .bit-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }

  .bit-fields .fraction {
    grid-column: 1 / -1;
  }
}

@media print {
  :root {
    color-scheme: light;
    --background: #fff;
    --surface: #f6f7f9;
    --code: #f6f7f9;
    --text: #1b2027;
    --muted: #373f48;
    --line: #a4a9b1;
    --link: #174a7e;
    --sign: #873d06;
    --exponent: #234778;
    --fraction: #1a624b;
    font-size: 10.5pt;
  }

  main { max-width: none; padding: 0; }
  nav { display: none; }
  h1 { font-size: 28pt; }
  h2 { margin-top: 0.9rem; font-size: 17pt; }
  h3 { margin-top: 0.8rem; }
  h2, h3 { break-after: avoid; }
  figure, pre, tr { break-inside: avoid; }
  pre { white-space: pre-wrap; }
  table { line-height: 1.2; }
  th, td { padding-block: 2pt; }
  .lede { max-width: none; margin-block: 0.6rem 0.75rem; font-size: 10.5pt; }
  footer { margin-top: 1rem; }
  @page { margin: 13mm; }
}
