:root {
  --bg: #ffffff;
  --card: #eeeeee;
  --code-bg: #f4f4f4;
  --ink: #1c1c1c;
  --line-no: #999999;
  --link: #2a52be;
  --mark-bg: #fff3b0;
  --media-filter: none;
  --muted: #666666;
  --panel: #f7f7f7;
  --panel-2: #e8e8e8;
  --reading-scale: 1;
  --reading-width: clamp(32em, 90vw, 44em);
  --rule: #bbbbbb;
  --shadow-button: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-overlay: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-panel: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-popover: 0 2px 8px rgba(0, 0, 0, 0.15);
  --tok-comment: #888888;
  --tok-keyword: #0033cc;
  --tok-literal: #7700aa;
  --tok-number: #aa5500;
  --tok-string: #008800;
  color-scheme: light dark;
}

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: Crimson Text, serif;
  font-size: calc(11pt * var(--reading-scale));
  line-height: 1.45;
  margin: 0;
}

main {
  margin: 0 auto;
  max-width: var(--reading-width);
  padding: 0 clamp(1em, 4vw, 2em) 4em;
  position: relative;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
  font-family: Crimson Text, serif;
  line-height: 1.2;
}

h1 {
  font-size: 22pt;
}

h2 {
  font-size: 16pt;
  margin-bottom: 0.5em;
  margin-top: 1.6em;
}

h3 {
  font-size: 13pt;
  margin-bottom: 0.4em;
  margin-top: 1.3em;
}

p {
  margin: 0 0 6pt;
}

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

a:focus-visible, button:focus-visible, summary:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

code {
  font-family: Space Mono, monospace;
  font-size: 0.85em;
}

pre code {
  font-size: 1em;
}

pre {
  background-color: var(--code-bg);
  border-left: 3pt solid var(--link);
  font-family: Space Mono, monospace;
  font-size: 0.85em;
  margin: 0 0 8pt;
  overflow-x: auto;
  padding: 6pt 6pt 6pt 8pt;
}

.line-no {
  color: var(--line-no);
  user-select: none;
}

.file-bar {
  background-color: var(--panel-2);
  font-family: Space Mono, monospace;
  font-size: 0.75em;
  font-weight: bold;
  padding: 3pt 6pt;
}

.annotations {
  font-size: 0.85em;
  margin: 4pt 0 8pt;
}

.annotation-mark {
  background-color: #555555;
  border-radius: 2px;
  color: #ffffff;
  font-family: sans-serif;
  font-size: 0.7em;
  font-weight: bold;
  padding: 0 0.35em;
}

blockquote {
  border-left: 3pt solid var(--rule);
  color: var(--muted);
  font-style: italic;
  margin: 0 0 6pt;
  padding-left: 10pt;
}

.admonition {
  background-color: var(--panel);
  border: 0.75pt solid var(--rule);
  margin: 8pt 0;
  padding: 6pt;
}

.admonition-title {
  font-weight: bold;
}

.sidebar {
  background-color: var(--panel);
  border: 0.75pt solid var(--rule);
  margin: 8pt 0;
  padding: 6pt;
}

.sidebar-title {
  font-weight: bold;
}

.overview {
  background-color: var(--panel);
  border-left: 3pt solid var(--rule);
  margin: 8pt 0 12pt;
  padding: 8pt 10pt;
}

.overview-title {
  font-weight: bold;
}

.example {
  border-left: 3pt solid var(--rule);
  margin: 8pt 0;
  padding: 6pt 10pt;
}

.example-title {
  font-weight: bold;
}

details {
  border-left: 1pt solid var(--rule);
  margin: 8pt 0;
  padding-left: 10pt;
}

summary {
  cursor: pointer;
  font-weight: bold;
}

kbd {
  background-color: var(--card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: Space Mono, monospace;
  font-size: 0.85em;
  padding: 0 0.3em;
}

.menu-sep {
  color: var(--muted);
}

.button {
  background-color: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 0.4em;
}

mark {
  background-color: var(--mark-bg);
  color: var(--ink);
}

.epigraph {
  border-left: none;
  color: var(--ink);
  font-style: italic;
  margin-left: 24pt;
}

.attribution {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

figure {
  margin: 10pt 0;
  text-align: center;
}

figure.listing {
  text-align: left;
}

figure img {
  max-width: 100%;
}

figcaption {
  color: var(--muted);
  font-size: 0.85em;
  margin-top: 4pt;
}

.caption-label {
  font-weight: bold;
}

table {
  border-collapse: collapse;
  margin: 0 0 8pt;
  width: 100%;
}

th, td {
  border: 0.5pt solid var(--rule);
  padding: 4pt;
}

caption {
  caption-side: bottom;
  color: var(--muted);
  font-size: 0.85em;
  padding-top: 4pt;
}

.chapter-label {
  color: var(--muted);
  margin-bottom: 0;
}

.chapter-header h1 {
  border-bottom: 1pt solid var(--rule);
  margin-top: 0.25em;
  padding-bottom: 6pt;
}

.book-author {
  color: var(--muted);
}

.book-header {
  text-align: center;
}

.book-header.cover {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72vh;
}

.book-header.cover h1 {
  font-size: clamp(2em, 6vw, 3.2em);
  line-height: 1.1;
  margin: 0 0 0.5em;
}

.book-header.cover .book-author {
  font-size: 1.15em;
}

.page-nav {
  display: flex;
  font-size: 0.9em;
  gap: 1em;
  justify-content: center;
  margin: 1em auto;
  max-width: var(--reading-width);
  padding: 0 1em;
}

.page-footer {
  font-size: 0.85em;
  margin: 1em auto 0;
  max-width: var(--reading-width);
  padding: 0 1em;
}

.toc a, .page-nav a, .page-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.toc a:hover, .page-nav a:hover, .page-footer a:hover {
  color: var(--ink);
}

.edge-nav {
  position: sticky;
  top: 50vh;
  z-index: 15;
}

.edge-link {
  color: var(--muted);
  font-family: Crimson Text, serif;
  font-size: 1.6em;
  line-height: 1;
  opacity: 0.3;
  position: absolute;
  text-decoration: none;
  top: 0;
  transform: translateY(-50%);
  transition: opacity 0.15s, color 0.15s;
}

.edge-link:hover {
  color: var(--ink);
  opacity: 0.9;
}

.edge-prev {
  margin-right: 1.75em;
  right: 100%;
}

.edge-next {
  left: 100%;
  margin-left: 1.75em;
}

.edit-page {
  color: var(--muted);
}

details.fold > summary {
  cursor: pointer;
  font-weight: bold;
}

.toc-list {
  list-style: none;
  padding-left: 0;
}

.toc-list .toc-level-1 {
  padding-left: 1.5em;
}

.toc-list .toc-level-2 {
  padding-left: 3em;
}

.footnotes {
  border-top: 0.5pt solid var(--rule);
  font-size: 0.85em;
  margin-top: 2em;
}

.noteref {
  text-decoration: none;
}

.index-entry {
  margin: 0 0 2pt;
}

.float-list {
  list-style: none;
  padding-left: 0;
}

.book-layout {
  display: flex;
  flex-wrap: wrap;
  min-height: 100vh;
}

.book-sidebar {
  background-color: var(--panel);
  border-right: 1px solid var(--rule);
  flex: 1 1 15em;
}

.book-sidebar-inner {
  font-size: 0.9em;
  max-height: 100vh;
  overflow-y: auto;
  padding: 2.5em 1.5em;
  position: sticky;
  top: 0;
}

.book-sidebar-title {
  color: var(--ink);
  display: block;
  font-family: Crimson Text, serif;
  font-size: 1.05em;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 1.5em;
  text-decoration: none;
}

.book-sidebar-list {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.book-sidebar-list li {
  margin: 0.1em 0;
}

.book-sidebar-list .toc-level-1 {
  padding-left: 0.75em;
}

.book-sidebar-list .toc-level-2 {
  padding-left: 1.75em;
}

.book-sidebar a {
  border-radius: 6px;
  color: var(--muted);
  display: block;
  padding: 0.25em 0.6em;
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}

.book-sidebar a:hover {
  background-color: var(--card);
  color: var(--ink);
}

.book-sidebar .part-heading {
  color: var(--muted);
  font-family: Crimson Text, serif;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.07em;
  margin: 1.6em 0 0.4em;
  text-transform: uppercase;
}

.book-sidebar .current {
  background-color: var(--card);
  color: var(--link);
  font-weight: 700;
}

.book-content {
  flex: 999 1 28em;
  min-width: 0;
  padding: 2em 2em 0;
}

.book-content main {
  margin: 0 auto;
}

.book-mobile-contents {
  background-color: var(--panel);
  border-bottom: 1px solid var(--rule);
  display: none;
  position: sticky;
  top: 0;
  z-index: 15;
}

.book-mobile-summary {
  color: var(--ink);
  cursor: pointer;
  font-family: Crimson Text, serif;
  font-size: 0.9em;
  font-weight: 700;
  padding: 0.8em 1em;
}

.book-mobile-contents[open] .book-mobile-summary {
  border-bottom: 1px solid var(--rule);
}

.book-mobile-contents .book-sidebar-list {
  padding: 0.5em 1em 1em;
}

.book-mobile-contents form.search {
  margin: 0.5em 1em;
}

.downloads {
  margin: 8pt 0;
}

.downloads .default {
  font-size: 1.15em;
  font-weight: bold;
}

.downloads .note {
  color: var(--muted);
  margin: 0 0 8pt;
}

.downloads ul {
  list-style: none;
  padding-left: 0;
}

.downloads li {
  margin: 0 0 4pt;
}

form.search {
  margin: 0 0 1em;
  position: relative;
}

form.search input {
  border: 1px solid var(--rule);
  box-sizing: border-box;
  font: inherit;
  padding: 0.4em 0.6em;
  width: 100%;
}

.search-island {
  position: relative;
}

.search-popover {
  background: var(--bg);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-popover);
  left: 0;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5em;
  position: absolute;
  right: 0;
  text-align: left;
  z-index: 10;
}

.search-cat h4 {
  color: var(--muted);
  font-family: Crimson Text, serif;
  font-size: 0.8em;
  margin: 0.5em 0 0.25em;
  text-transform: uppercase;
}

.search-cat ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-cat li a {
  display: block;
  padding: 0.25em 0.4em;
  text-decoration: none;
}

.search-cat li.active a {
  background: var(--code-bg);
}

.search-hit-snippet {
  color: var(--muted);
  display: block;
  font-size: 0.85em;
}

.search-fallback-note {
  color: var(--muted);
}

pre.mermaid {
  background: none;
  border-left: none;
  overflow-x: auto;
  text-align: center;
}

svg.math {
  vertical-align: middle;
}

.math-display {
  margin: 8pt 0;
  text-align: center;
}

.diagram {
  margin: 8pt 0;
  text-align: center;
}

.page-break {
  break-before: page;
}

.keep-together {
  break-inside: avoid;
}

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

@media (max-width: 48em) {
.book-sidebar {
  display: none;
}

.book-mobile-contents {
  display: block;
  flex: 1 1 100%;
}

.edge-nav {
  display: none;
}
}

.tok-comment {
  color: var(--tok-comment);
}

.tok-keyword {
  color: var(--tok-keyword);
}

.tok-literal {
  color: var(--tok-literal);
}

.tok-number {
  color: var(--tok-number);
}

.tok-string {
  color: var(--tok-string);
}

@media (prefers-color-scheme: dark) {
:root {
  --bg: #1a1a1a;
  --card: #333333;
  --code-bg: #2a2a2a;
  --ink: #e6e6e6;
  --line-no: #8b949e;
  --link: #6ea8fe;
  --mark-bg: #5c4d20;
  --media-filter: invert(1) hue-rotate(180deg);
  --muted: #9aa0a6;
  --panel: #242424;
  --panel-2: #2d2d2d;
  --rule: #444444;
  --shadow-button: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-overlay: 0 8px 32px rgba(0, 0, 0, 0.75);
  --shadow-panel: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-popover: 0 2px 8px rgba(0, 0, 0, 0.55);
  --tok-comment: #8b949e;
  --tok-keyword: #ff7b72;
  --tok-literal: #d2a8ff;
  --tok-number: #79c0ff;
  --tok-string: #a5d6ff;
}
}

html[data-theme="dark"] {
  --bg: #1a1a1a;
  --card: #333333;
  --code-bg: #2a2a2a;
  --ink: #e6e6e6;
  --line-no: #8b949e;
  --link: #6ea8fe;
  --mark-bg: #5c4d20;
  --media-filter: invert(1) hue-rotate(180deg);
  --muted: #9aa0a6;
  --panel: #242424;
  --panel-2: #2d2d2d;
  --rule: #444444;
  --shadow-button: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-overlay: 0 8px 32px rgba(0, 0, 0, 0.75);
  --shadow-panel: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-popover: 0 2px 8px rgba(0, 0, 0, 0.55);
  --tok-comment: #8b949e;
  --tok-keyword: #ff7b72;
  --tok-literal: #d2a8ff;
  --tok-number: #79c0ff;
  --tok-string: #a5d6ff;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --card: #eeeeee;
  --code-bg: #f4f4f4;
  --ink: #1c1c1c;
  --line-no: #999999;
  --link: #2a52be;
  --mark-bg: #fff3b0;
  --media-filter: none;
  --muted: #666666;
  --panel: #f7f7f7;
  --panel-2: #e8e8e8;
  --rule: #bbbbbb;
  --shadow-button: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-overlay: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-panel: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-popover: 0 2px 8px rgba(0, 0, 0, 0.15);
  --tok-comment: #888888;
  --tok-keyword: #0033cc;
  --tok-literal: #7700aa;
  --tok-number: #aa5500;
  --tok-string: #008800;
  color-scheme: light;
}

.theme-toggle {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 999px;
  box-shadow: var(--shadow-button);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.8em;
  line-height: 1;
  padding: 0.45em 0.85em;
  position: fixed;
  right: 1em;
  top: 1em;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
  z-index: 20;
}

.theme-toggle:hover {
  border-color: var(--muted);
  color: var(--ink);
}

html[data-contrast="high"] {
  --ink: #000000;
  --muted: #2b2b2b;
  --rule: #767676;
}

@media (prefers-color-scheme: dark) {
html[data-contrast="high"] {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #d0d0d0;
  --rule: #909090;
}
}

html[data-theme="dark"][data-contrast="high"] {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #d0d0d0;
  --rule: #909090;
}

html[data-theme="light"][data-contrast="high"] {
  --ink: #000000;
  --muted: #2b2b2b;
  --rule: #767676;
}

.reader-controls {
  position: fixed;
  right: 1em;
  top: 1em;
  z-index: 20;
}

.reader-button {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 999px;
  box-shadow: var(--shadow-button);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.8em;
  line-height: 1;
  padding: 0.45em 0.85em;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.reader-button:hover {
  border-color: var(--muted);
  color: var(--ink);
}

.reader-panel {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow-panel);
  color: var(--ink);
  column-gap: 1.5em;
  display: grid;
  grid-template-columns: auto auto;
  min-width: 15em;
  padding: 1em 1.1em;
  position: absolute;
  right: 0;
  row-gap: 0.7em;
  top: calc(100% + 0.5em);
}

.reader-panel[hidden] {
  display: none;
}

.reader-label {
  color: var(--muted);
  font-size: 0.85em;
  justify-self: start;
}

.reader-pair {
  display: inline-flex;
  gap: 0.4em;
  justify-self: end;
}

.reader-pair button {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  min-width: 2.6em;
  padding: 0.25em 0;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}

.reader-pair button:hover {
  border-color: var(--muted);
}

.reader-switch {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  height: 1.5em;
  justify-self: end;
  padding: 0;
  position: relative;
  transition: background-color 0.15s, border-color 0.15s;
  width: 2.8em;
}

.reader-switch::after {
  background: var(--muted);
  border-radius: 50%;
  content: "";
  height: 1.05em;
  left: 0.18em;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.15s, background-color 0.15s;
  width: 1.05em;
}

.reader-switch[aria-pressed="true"] {
  background: var(--link);
  border-color: var(--link);
}

.reader-switch[aria-pressed="true"]::after {
  background: var(--bg);
  transform: translate(1.3em, -50%);
}

.reader-reset {
  background: none;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
  grid-column: 1 / -1;
  margin-top: 0.4em;
  padding: 0.5em 0 0;
  transition: color 0.15s;
}

.reader-reset:hover {
  color: var(--ink);
}

.breadcrumb {
  color: var(--muted);
  font-family: Crimson Text, serif;
  font-size: 0.8em;
  margin: 0 0 1.5em;
}

.breadcrumb-sep {
  margin: 0 0.5em;
}

html[data-focus] .book-sidebar {
  display: none;
}

html[data-focus] .book-mobile-contents {
  display: none;
}

html[data-focus] .page-nav {
  display: none;
}

html[data-focus] .page-footer {
  display: none;
}

html[data-focus] .edge-nav {
  display: none;
}

html[data-focus] .theme-toggle {
  display: none;
}

.reading-progress {
  background: transparent;
  height: 3px;
  left: 0;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 30;
}

.reading-progress-bar {
  background: var(--link);
  height: 100%;
  transform: scaleX(0);
  transform-origin: left;
  width: 100%;
}

.kbd-help {
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 40;
}

.kbd-help[hidden] {
  display: none;
}

.kbd-help-panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-overlay);
  color: var(--ink);
  max-width: 24em;
  padding: 1.5em 1.75em;
  width: 90%;
}

.kbd-help-panel h2 {
  font-size: 1.1em;
  margin-top: 0;
}

.kbd-help-panel dl {
  display: grid;
  gap: 0.5em 1.25em;
  grid-template-columns: auto 1fr;
  margin: 0 0 1.25em;
}

.kbd-help-panel dt {
  margin: 0;
}

.kbd-help-panel dt kbd {
  margin-right: 0.2em;
}

.kbd-help-panel dd {
  color: var(--muted);
  margin: 0;
}

svg.diagram {
  filter: var(--media-filter);
}

svg.math {
  filter: var(--media-filter);
}
