:root {
  --reader-font-family: Calibri, Arial, sans-serif;
  --reader-font-min-size: 16px;
  --ink: #222;
  --muted: #666;
  --line: #cfcfcf;
  --unir: #007fad;
  color-scheme: light;
  background: #fff;
  color: var(--ink);
  font-family: var(--reader-font-family);
  font-size: max(var(--reader-font-min-size), clamp(19px, 5vw, 22px));
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0.8rem 4rem;
  overflow-wrap: anywhere;
  line-height: 1.62;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 0.8rem;
  top: 0.8rem;
  padding: 0.4rem;
  background: #fff;
  outline: 2px solid var(--ink);
}

.site-header,
.toc,
.content,
.page-footer {
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

.site-header {
  padding: 2.2rem 0 1.4rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.edition,
.source-note,
.page-footer {
  color: var(--muted);
  font-size: 0.84rem;
}

.site-header h1 {
  max-width: 24ch;
  margin: 0.3rem 0 0.6rem;
  color: var(--ink);
  font-size: clamp(2rem, 9vw, 3.4rem);
  font-weight: 400;
  line-height: 1.08;
}

.subtitle {
  max-width: 48rem;
  margin: 0;
}

.toc {
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.toc > nav,
.toc ol,
.toc ul {
  margin: 0;
}

.content { padding-top: 1.2rem; }

h2,
h3,
h4 {
  color: var(--ink);
  font-weight: 500;
  line-height: 1.25;
}

h2 {
  margin: 3rem 0 0.9rem;
  padding-top: 0.2rem;
  font-size: 1.65rem;
  border-top: 1px solid var(--line);
}

h3 {
  margin: 2rem 0 0.6rem;
  font-size: 1.28rem;
}

h4 { font-size: 1.08rem; }

.lead { font-size: 1.08rem; }

.callout,
.exercise,
.resource {
  margin: 1.35rem 0;
  padding: 0.15rem 0 0.15rem 0.9rem;
  border-left: 2px solid var(--line);
}

.callout-title,
.exercise-title,
.resource-title {
  margin: 0 0 0.25rem;
  font-weight: 700;
}

.callout.definition { border-left-color: var(--unir); }
.callout.theorem { border-left-color: var(--ink); }
.callout.example { border-left-style: dashed; }

.resource a { font-weight: 600; }

details {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

summary {
  color: var(--unir);
  font-weight: 600;
  cursor: pointer;
}

math[display="block"] {
  display: block;
  max-width: 100%;
  margin: 1.15rem 0;
  padding: 0.15rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

figure {
  max-width: 100%;
  margin: 2rem 0;
  overflow-x: auto;
  text-align: center;
}

figure svg,
figure img,
figure video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 51.99rem) {
  .scheme figure { text-align: left; }

  .scheme figure img {
    width: 32rem;
    max-width: none;
    margin-left: 0;
  }

  .scheme figcaption {
    position: sticky;
    left: 0;
    width: min(100%, 34rem);
  }
}

li { margin: 0.35rem 0; }

.page-footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.page-footer p { margin: 0.15rem 0; }

@media (min-width: 52rem) {
  :root { font-size: max(var(--reader-font-min-size), 16px); }

  body { padding: 0 1.5rem 5rem; }

  .site-header,
  .toc,
  .content,
  .page-footer {
    max-width: 82ch;
  }

  .site-header { padding-top: 3.5rem; }
  h2 { font-size: 1.9rem; }
}
