/* Pretendard v1.3.9, JuliaMono v0.63.2, Source Serif 4 v4.005, and Noto Serif KR v2.003. */
@font-face {
  font-family: "Pretendard Variable";
  src: url("../fonts/pretendard/PretendardVariable.woff2") format("woff2");
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: JuliaMono;
  src: url("../fonts/juliamono/JuliaMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: JuliaMono;
  src: url("../fonts/juliamono/JuliaMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif/SourceSerif4-Regular.ttf.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif/SourceSerif4-It.ttf.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* Body copy uses Serif only for Latin letters and their combining marks. */
@font-face {
  font-family: "Source Serif 4 Latin";
  src: url("../fonts/source-serif/SourceSerif4-Regular.ttf.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0041-005A, U+0061-007A, U+00AA, U+00BA, U+00C0-00D6,
    U+00D8-00F6, U+00F8-024F, U+0300-036F, U+1E00-1EFF, U+FB00-FB06;
}

@font-face {
  font-family: "Source Serif 4 Latin";
  src: url("../fonts/source-serif/SourceSerif4-It.ttf.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0041-005A, U+0061-007A, U+00AA, U+00BA, U+00C0-00D6,
    U+00D8-00F6, U+00F8-024F, U+0300-036F, U+1E00-1EFF, U+FB00-FB06;
}

@font-face {
  font-family: "Source Serif 4 Latin";
  src: url("../fonts/source-serif/SourceSerif4-Bold.ttf.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0041-005A, U+0061-007A, U+00AA, U+00BA, U+00C0-00D6,
    U+00D8-00F6, U+00F8-024F, U+0300-036F, U+1E00-1EFF, U+FB00-FB06;
}

@font-face {
  font-family: "Noto Serif KR";
  src: url("../fonts/noto-serif-kr/NotoSerifKR-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --textbook-paper: #ffffff;
  --textbook-ink: #263238;
  --textbook-heading: #243b53;
  --textbook-muted: #64748b;
  --textbook-link: #3567a5;
  --textbook-surface: #f7f8fa;
  --textbook-current: #eaf0f8;
  --textbook-code-surface: #f5f7fa;
  --textbook-border: #e2e8f0;
  --verso-link-color: var(--textbook-link);
  --verso-toc-background-color: var(--textbook-surface);
  --verso-toc-border-color: var(--textbook-border);
  --textbook-prose-font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans CJK KR", system-ui, sans-serif;
  --verso-text-font-family: var(--textbook-prose-font);
  --verso-structure-font-family: var(--textbook-prose-font);
  --verso-code-font-family: JuliaMono, "Pretendard Variable", "DejaVu Sans Mono",
    ui-monospace, monospace;
  --verso-text-color: var(--textbook-ink);
  --verso-structure-color: var(--textbook-heading);
  --verso-content-max-width: 42rem;
  --verso-header-height: 3.5rem;
}

body {
  background-color: var(--textbook-paper);
  color: var(--textbook-ink);
}

body > header:has(.header-title) {
  --textbook-header-gutter: clamp(1rem, 3vw, 2.75rem);
  box-sizing: border-box;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  padding-inline: var(--textbook-header-gutter);
  background: var(--textbook-paper);
  border-block-end: 1px solid var(--textbook-border);
  box-shadow: none;
}

body > header .header-logo-wrapper {
  flex-basis: auto;
  padding-inline-start: 0;
}

body > header .header-logo-wrapper:empty {
  display: none;
}

body > header .header-title-wrapper {
  container-type: normal;
  min-inline-size: 0;
}

body > header .header-title {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  max-inline-size: 100%;
  margin: 0;
  color: var(--textbook-heading);
  font-size: clamp(1.125rem, 1.7vw, 1.5rem);
  font-weight: 650;
}

body > header .header-title::before {
  content: "";
  flex: 0 0 0.1875rem;
  block-size: 1.15em;
  border-radius: 1rem;
  background-color: var(--textbook-link);
}

body > header .header-title h1 {
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-wrap: balance;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

body > header .header-title:hover {
  color: var(--textbook-link);
}

body > header .header-title:focus-visible {
  outline: 2px solid var(--textbook-link);
  outline-offset: 0.25rem;
  border-radius: 0.125rem;
}

body > header > #search-wrapper {
  position: static;
  display: block;
  flex: none;
  inline-size: clamp(10rem, 19vw, 17rem);
  padding: 0;
  background: transparent;
}

body > header #search-wrapper .group {
  position: relative;
}

body > header #search-wrapper .group::before,
body > header #search-wrapper .group::after {
  content: "";
  position: absolute;
  z-index: 1;
  pointer-events: none;
  color: var(--textbook-muted);
}

body > header #search-wrapper .group::before {
  inset-inline-start: 0.6875rem;
  inset-block-start: calc(50% - 0.375rem);
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

body > header #search-wrapper .group::after {
  inset-inline-start: 1.25rem;
  inset-block-start: calc(50% + 0.25rem);
  inline-size: 0.3125rem;
  block-size: 1.5px;
  border-radius: 1rem;
  background-color: currentColor;
  transform: rotate(45deg);
}

body > header #search-wrapper .combobox .cb_edit {
  inline-size: 100%;
  padding: 0.5625rem 0.625rem 0.5625rem 1.9375rem;
  border: 1px solid var(--textbook-border);
  border-radius: 0.5rem;
  font-family: var(--textbook-prose-font);
  font-size: 0.875rem;
  line-height: 1.25;
  white-space: pre;
  overflow: auto hidden;
  scrollbar-width: none;
  cursor: text;
}

body > header #search-wrapper .cb_edit:empty::before {
  color: var(--textbook-muted);
  font-family: inherit;
}

body > header #search-wrapper .combobox .group .cb_edit:hover {
  border-color: var(--textbook-link);
  background-color: var(--textbook-paper);
  outline: none;
}

body > header #search-wrapper .combobox .group.focus .cb_edit,
body > header #search-wrapper .combobox .group .cb_edit:focus {
  border-color: var(--textbook-link);
  background-color: var(--textbook-paper);
  outline: 2px solid var(--textbook-link);
  outline-offset: 2px;
}

body > header #search-wrapper ul[role="listbox"] {
  inset-inline-end: 0;
  inset-block-start: calc(100% + 0.5rem);
  inline-size: min(24rem, calc(100vw - 2 * var(--textbook-header-gutter)));
  max-block-size: min(20rem, calc(100dvh - var(--verso-header-height) - 0.75rem));
  border: 1px solid var(--textbook-border);
  border-radius: 0.5rem;
  background-color: var(--textbook-paper);
  box-shadow: none;
  overflow-y: auto;
}

@media screen and (max-width: 700px) {
  :root {
    --verso-header-height: 3.75rem;
    --verso-mobile-burger-line-width: 0.125rem;
    --verso-burger-toc-hidden-color: var(--textbook-heading);
    --verso-burger-toc-visible-color: var(--textbook-link);
  }

  body > header:has(.header-title) {
    --textbook-header-gutter: 0.75rem;
    gap: 0.625rem;
    padding-inline-start: 3.25rem;
  }

  body > header .header-title {
    font-size: clamp(0.9375rem, 3.6vw, 1.125rem);
  }

  body > header .header-title::before {
    display: none;
  }

  body > header > #search-wrapper {
    inline-size: clamp(6.125rem, 24vw, 9rem);
  }

  body > header #search-wrapper .combobox .cb_edit {
    font-size: 0.8125rem;
  }

  #toggle-toc-click {
    inset-inline-start: 0.375rem;
    background: transparent;
    border: 0;
  }

  #toggle-toc-click:focus-visible {
    outline: 2px solid var(--textbook-link);
    outline-offset: 2px;
  }
}

#toc .textbook-toc {
  color: var(--textbook-ink);
  font-family: var(--textbook-prose-font);
  font-size: 0.875rem;
  line-height: 1.45;
  margin-block-start: 1.5rem;
  padding-inline: 0.5rem;
}

#toc .textbook-toc-heading {
  color: var(--textbook-muted);
  font-weight: 650;
  margin: 0 0 0.375rem;
  padding-inline: 0.375rem;
}

#toc .textbook-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#toc .textbook-toc details > ul {
  padding-inline-start: 0.75rem;
}

#toc .textbook-toc li {
  position: relative;
}

#toc .textbook-toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  color: var(--textbook-ink);
  font-weight: 650;
  margin-inline-start: 1.5rem;
  padding: 0.3125rem 0.375rem;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

#toc .textbook-toc details .textbook-toc-link {
  font-weight: 500;
}

#toc .textbook-toc details details .textbook-toc-link {
  color: var(--textbook-muted);
  font-weight: 400;
}

#toc .textbook-toc-number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#toc .textbook-toc .textbook-toc-link[aria-current="page"] {
  background-color: var(--textbook-current);
  box-shadow: inset 2px 0 var(--textbook-link);
  color: var(--textbook-link);
  font-weight: 650;
}

#toc .textbook-toc summary {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  display: grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: calc(1lh + 0.625rem);
  color: var(--textbook-muted);
  cursor: pointer;
  list-style: none;
}

#toc .textbook-toc summary::-webkit-details-marker {
  display: none;
}

#toc .textbook-toc summary::before {
  content: "";
  inline-size: 0.4rem;
  block-size: 0.4rem;
  border-block-start: 1.5px solid currentColor;
  border-inline-end: 1.5px solid currentColor;
  transform: rotate(45deg);
}

#toc .textbook-toc details[open] > summary::before {
  transform: rotate(135deg);
}

#toc .textbook-toc summary:hover {
  color: var(--textbook-link);
}

#toc .textbook-toc :is(a, summary):focus-visible {
  outline: 2px solid var(--textbook-link);
  outline-offset: -2px;
}

main {
  --textbook-code-size: 1rem;
  font-family: var(--textbook-prose-font);
  font-size: 1.125rem;
  line-height: 1.75;
}

main :is(p, dt, dd) {
  line-height: inherit;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

main .content-wrapper > section :is(p, li, dt, dd):where(:not(:is(
  .titlepage, .section-toc, .textbook-index, .textbook-bibliography,
  figure, table, .textbook-equation, .textbook-code, .hover-info, .tactic-state
) *)) {
  font-family: "Source Serif 4 Latin", var(--textbook-prose-font);
}

main #preface ~ p:nth-last-child(-n + 2) {
  text-align: right;
}

main .textbook-index {
  container: textbook-index / inline-size;
  margin-block-start: 1.25rem;
}

main .textbook-index nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

main .textbook-index :is(nav, .textbook-index-entries) li {
  margin-block: 0;
}

main .textbook-index > nav {
  padding: 0.625rem;
  background-color: var(--textbook-surface);
  border: 1px solid var(--textbook-border);
  border-radius: 0.375rem;
}

main .textbook-index nav a {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  min-inline-size: 2rem;
  min-block-size: 2.25rem;
  padding-inline: 0.375rem;
  border-radius: 0.25rem;
  color: var(--textbook-link);
  font-size: 0.9375rem;
  font-weight: 650;
  text-decoration: none;
}

main .textbook-index nav a:hover {
  background-color: var(--textbook-current);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

main .textbook-index a:focus-visible {
  outline: 2px solid var(--textbook-link);
  outline-offset: -2px;
}

main .textbook-index h2 {
  margin-block: 2rem 0.625rem;
  padding-block-end: 0.375rem;
  border-block-end: 1px solid var(--textbook-border);
  font-size: 1.375rem;
}

main .textbook-index h3 {
  margin-block: 1.375rem 0.375rem;
  color: var(--textbook-muted);
  font-size: 1.125rem;
}

main .textbook-index :is(h2, h3):target {
  color: var(--textbook-link);
}

main .textbook-index .textbook-index-entries {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

main .textbook-index-entries li {
  border-block-end: 1px solid var(--textbook-border);
}

main .textbook-index-entries a {
  display: block;
  box-sizing: border-box;
  min-block-size: 2.375rem;
  padding: 0.4375rem 0.375rem;
  font-size: 1rem;
  line-height: 1.5;
  text-decoration: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

main .textbook-index-entries a:is(:hover, :focus-visible) {
  background-color: var(--textbook-surface);
}

main .textbook-index-term {
  color: var(--textbook-link);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

main .textbook-index-gloss {
  margin-inline-start: 0.3em;
  color: var(--textbook-muted);
  font-size: 0.9em;
}

@container textbook-index (min-width: 38rem) {
  main .textbook-index .textbook-index-entries {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  main .textbook-index-entries a {
    min-block-size: 0;
    padding-block: 0.28125rem;
    font-size: 0.9375rem;
    line-height: 1.2;
  }

  main .textbook-index h2 {
    margin-block: 1rem 0.3125rem;
    padding-block-end: 0.1875rem;
    font-size: 1.25rem;
  }

  main .textbook-index h3 {
    margin-block: 0.6875rem 0.1875rem;
    font-size: 1rem;
  }
}

@media (min-height: 35rem) {
  @container textbook-index (min-width: 40rem) {
    main .textbook-index > nav {
      position: sticky;
      z-index: 1;
      inset-block-start: calc(var(--verso-header-height) + 0.25rem);
    }

    main .textbook-index :is(h2, h3)[id] {
      scroll-margin-top: calc(var(--verso-header-height) + 4.5rem);
    }
  }
}

@media (max-width: 700px) {
  main .textbook-index nav a {
    min-inline-size: 2.75rem;
    min-block-size: 2.75rem;
  }

  main .textbook-index-entries a {
    min-block-size: 2.75rem;
  }
}

.textbook-footer {
  margin-block: 3rem 1rem;
  padding-block-start: 0.75rem;
  border-block-start: 1px solid var(--textbook-border);
  color: var(--textbook-muted);
  font-size: 0.875rem;
}

@media screen and (min-width: 701px) {
  main:not(:has(.titlepage)) {
    --verso-content-max-width: 52.5rem;
  }

  main:not(:has(.titlepage)) > .content-wrapper {
    padding-inline: clamp(2.5rem, 4vw, 4rem);
  }
}

main img {
  max-inline-size: 100%;
  block-size: auto;
}

main .textbook-figure {
  margin: 1.5rem 0;
  text-align: center;
}

main .textbook-figure img {
  display: block;
  margin-inline: auto;
}

main .textbook-figure > svg {
  display: block;
  margin-inline: auto;
  max-inline-size: 100%;
  block-size: auto;
}

.textbook-recursion-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.375rem 0.5rem;
  margin-block-start: 0.5rem;
  font-size: 0.875em;
}

.textbook-recursion-controls button {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--textbook-border);
  border-radius: 0.375rem;
  color: var(--textbook-ink);
  background: white;
  font: inherit;
}

.textbook-recursion-controls button[aria-pressed="true"] {
  background: var(--textbook-current);
  border-color: var(--textbook-link);
}

.textbook-recursion-controls button:disabled {
  opacity: 0.55;
}

.textbook-recursion-controls :is(button, input):focus-visible {
  outline: 2px solid var(--textbook-link);
  outline-offset: 2px;
}

.textbook-recursion-controls input[type="range"] {
  inline-size: min(9rem, 100%);
  accent-color: var(--textbook-link);
}

.textbook-recursion-controls label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
}

.textbook-recursion-controls label input[type="range"] {
  inline-size: 7rem;
}

.textbook-fin-ticks {
  display: flex;
  justify-content: space-between;
  inline-size: 7rem;
  color: var(--textbook-muted);
  font-size: 0.8em;
}

.textbook-boolean-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.textbook-boolean-choice span {
  font-family: var(--verso-code-font-family);
  margin-inline-end: 0.125rem;
}

.textbook-recursion-controls output {
  flex-basis: 100%;
  color: var(--textbook-muted);
  font-variant-numeric: tabular-nums;
}

main .textbook-figure .recursion-highlight > rect {
  fill: #d7edff;
  stroke: #2563a6;
  stroke-width: 2;
}

main #fig-lean-rewrite-order [data-rewrite-live] {
  font-family: var(--verso-code-font-family), var(--textbook-prose-font);
}

main .textbook-figure :is([data-fin-value], [data-vector-index]):not(.recursion-highlight) > rect {
  fill: #f4f7f9;
  stroke: #a7b7c1;
  stroke-width: 1;
}

main .textbook-caption {
  color: var(--textbook-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: center;
}

main figcaption.textbook-caption {
  margin-block-start: 0.5rem;
}

main caption.textbook-caption {
  caption-side: top;
  padding-block-end: 0.5rem;
  text-align: start;
}

main .textbook-caption-label {
  font-weight: 700;
}

main caption.textbook-caption > .textbook-caption-label {
  color: var(--textbook-link);
}

main table.tabular {
  --textbook-table-scale: 0.875;
  --textbook-inline-code-size: calc(var(--textbook-code-size) * var(--textbook-table-scale));
  font-size: calc(1em * var(--textbook-table-scale));
  inline-size: 100%;
  margin-block: 1.25rem;
  margin-inline: 0;
  border-collapse: collapse;
  border-spacing: 0;
}

main table.tabular :is(th, td) {
  padding: 0.4375rem 0.75rem;
  border-block-end: 1px solid var(--textbook-border);
  text-align: start;
  line-height: 1.5;
}

main table.tabular th {
  background-color: var(--textbook-current);
  border-block-end-color: var(--textbook-border);
  color: var(--textbook-heading);
  font-weight: 650;
}

main table.tabular[id^="table-appendix-c-problems-"],
main #appendix-c-theorems ~ table.tabular {
  table-layout: fixed;
}

main table.tabular[id^="table-appendix-c-problems-"] thead th {
  box-sizing: border-box;
}

main table.tabular[id^="table-appendix-c-problems-"] thead th:first-child {
  inline-size: 22%;
}

main table.tabular[id^="table-appendix-c-problems-"] thead th:nth-child(n + 3) {
  inline-size: 18%;
}

main #appendix-c-theorems ~ table.tabular thead th:last-child {
  box-sizing: border-box;
  inline-size: 25%;
}

main :is(#table-appendix-b-tactics, #table-appendix-b-error-messages,
  #table-lean-pair-structures, #table-lean-sized-data, #table-lean-equality-comparison,
  #table-lean-equality-tactic-roles, #table-lean-equality-proof-inputs,
  #table-lean-nat-rewrite-theorems, #table-lean-nat-induction-and-recursion,
  #table-lean-add-assoc-induction-targets, #table-lean-natural-addition-properties)
  :is(th, td):first-child > p {
  overflow-wrap: normal;
}

main :is(#table-lean-rewrite-locations, #table-lean-simp-rule-selection,
  #table-lean-using-proof, #table-lean-automation-tactics) td:first-child code,
main #table-lean-equality-methods td:nth-child(2) code,
main #table-lean-equality-methods :is(th, td):last-child {
  white-space: nowrap;
}

main #table-lean-arithmetic-operators :is(th, td):last-child {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

main #table-lean-boolean-truth {
  max-inline-size: 28rem;
}

main #table-lean-boolean-truth :is(th, td) {
  text-align: center;
}

main .textbook-equation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  margin-block: 1rem;
}

main .textbook-equation-math {
  overflow-x: auto;
  text-align: center;
}

main .textbook-equation-number {
  white-space: nowrap;
}

main :is(h1, h2, h3, h4, h5, h6) {
  color: var(--textbook-heading);
  font-weight: 700;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

main h1 { font-size: 2rem; }
main h2 { font-size: 1.5rem; }
main h3 { font-size: 1.25rem; }

/* Verso renders the page title as h1 at every book depth, including appendices. */
main section > h1 {
  line-height: 1.4;
}

body:has(.textbook-toc details [aria-current="page"]) main section > h1 {
  font-size: 1.625rem;
  font-weight: 650;
  line-height: 1.5;
  margin-block-start: 2.75rem;
}

body:has(.textbook-toc details details [aria-current="page"]) main section > h1 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-block-start: 1.875rem;
}

main dt:has(> .textbook-exercise-label),
main dt:has(> .textbook-exercise-label) + dd {
  margin-inline: 0;
  padding-inline: 1rem;
  background-color: var(--textbook-paper);
  border-inline-start: 2px solid var(--textbook-link);
}

main dt:has(> .textbook-exercise-label) {
  margin-block-start: 1rem;
  padding-block: 0.75rem 0.25rem;
}

main dt:has(> .textbook-exercise-label) + dd {
  display: flow-root;
  padding-block-end: 0.75rem;
}

main dt:has(> .textbook-exercise-label) + dd > :last-child {
  margin-block-end: 0;
}

main .textbook-exercise-label,
main dt > a[href*="#exercise-"] {
  color: var(--textbook-link);
}

main dt > a[href*="#exercise-"] {
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.1em;
}

main a:not(.prev-next-buttons a, .permalink-widget a, .hl.lean a, .textbook-chapter-card) {
  color: var(--textbook-link);
  text-underline-offset: 0.16em;
}

main :is(p, li, dt, dd) a:not(.hl.lean a, .textbook-index a, .textbook-chapter-card) {
  text-decoration: underline;
}

main .content-wrapper :where(p, li, dt, dd, th, td)
  code:not(pre *, .textbook-code *, code *) {
  font-size: var(--textbook-inline-code-size, var(--textbook-code-size));
}

main .content-wrapper
  p:not(:is(li, dl, table, figure, .textbook-code, .hover-info, .tactic-state) *)
  code:not(pre *, code *) {
  background-color: #eff2f5;
  padding-inline: 0.15em;
  border-radius: 2px;
}

main pre,
main .hl.lean.block,
main .lean-output,
main pre.hl.lean:is(.lean-output, .syntax-error),
main details.lean-output > pre.hl.lean {
  font-size: var(--textbook-code-size);
  line-height: 1.55;
}

main pre,
main .hl.lean.block {
  max-inline-size: 100%;
  overflow-x: auto;
}

.textbook-code {
  background-color: var(--textbook-code-surface);
  border: 1px solid var(--textbook-border);
  border-radius: 0.375rem;
  color: var(--textbook-ink);
  margin-block: 1rem;
  min-inline-size: 0;
  position: relative;
}

main .textbook-code-title {
  color: var(--textbook-muted);
  font-size: 0.8125rem;
  font-weight: 650;
  margin: 0;
}

.textbook-code > .textbook-code-title {
  padding: 0.5rem 0.75rem 0;
}

.textbook-code-copy {
  position: absolute;
  inset-block-start: 0.25rem;
  inset-inline-end: 0.25rem;
  display: grid;
  place-items: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  background-color: var(--textbook-code-surface);
  border: 1px solid transparent;
  border-radius: 0.25rem;
  color: var(--textbook-muted);
  cursor: pointer;
  padding: 0;
}

.textbook-code-copy::before,
.textbook-code-copy::after {
  content: "";
  grid-area: 1 / 1;
  inline-size: 0.55rem;
  block-size: 0.7rem;
  border: 1px solid currentColor;
  border-radius: 0.12rem;
}

.textbook-code-copy::before {
  transform: translate(0.13rem, -0.13rem);
}

.textbook-code-copy::after {
  transform: translate(-0.13rem, 0.13rem);
  background-color: inherit;
}

.textbook-code-copy:hover {
  background-color: var(--textbook-current);
  border-color: var(--textbook-border);
}

.textbook-code-copy:focus-visible {
  outline: 2px solid var(--textbook-link);
  outline-offset: 2px;
}

.textbook-code-status {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-end: 2.75rem;
  background-color: var(--textbook-heading);
  border-radius: 0.25rem;
  color: white;
  font-size: 0.75rem;
  line-height: 1.4;
  pointer-events: none;
}

.textbook-code-status:not(:empty) {
  padding: 0.25rem 0.5rem;
}

.textbook-code:has(> .textbook-code-copy) > :is(.textbook-code-title, .textbook-code-content) {
  padding-inline-end: 2.5rem;
}

.textbook-code-content > :is(pre, code.hl.lean.block, details.lean-output, .example-file) {
  box-sizing: border-box;
  display: block;
  margin: 0;
  padding: 0.75rem 1rem;
}

.textbook-code-content > .example-file {
  max-inline-size: 100%;
  overflow-x: auto;
}

.textbook-code-content > details.lean-output > pre {
  margin-block-end: 0;
}

/* Night Owl Light (No Italics) by Sarah Drasner, mapped to Verso's Lean tokens. */
.night-owl-light > .textbook-code-content > .hl.lean.block {
  --verso-code-color: #403f53;
  --verso-code-keyword-color: #994cc3;
  --verso-code-keyword-style: normal;
  --verso-code-const-color: var(--verso-code-color);
  --verso-code-var-color: var(--verso-code-color);
  --verso-code-var-style: normal;
  color: var(--verso-code-color);
}

.night-owl-light .hl.lean.block :is(.hover-info, .tactic-state, .verso-message) {
  --verso-code-color: var(--textbook-ink);
  --verso-code-keyword-color: var(--textbook-ink);
  --verso-code-const-color: var(--textbook-ink);
  --verso-code-var-color: var(--textbook-ink);
  --verso-code-hover-bg-color: #eeeeee;
}

.night-owl-light .hl.lean.block :is(.comment, .doc-comment):not(:is(.hover-info, .tactic-state, .verso-message) *) {
  color: #989fb1;
  font-style: normal;
}

/* Verso puts an ID on the declaration token, while references use only its binding. */
.night-owl-light .hl.lean.block :is(
  .const.token[id],
  [data-binding="const-Bool.true"],
  [data-binding="const-Bool.false"],
  .string.interpolation
):not(:is(.hover-info, .tactic-state, .verso-message) *) {
  color: #4876d6;
}

.night-owl-light .hl.lean.block .sort:not(:is(.hover-info, .tactic-state, .verso-message) *) {
  color: var(--verso-code-keyword-color);
}

.night-owl-light .hl.lean.block :is(.string:not(.interpolation), .char):not(:is(.hover-info, .tactic-state, .verso-message) *) {
  color: #c96765;
}

.night-owl-light .hl.lean.block .number:not(:is(.hover-info, .tactic-state, .verso-message) *) {
  color: #aa0982;
}

main:has(.textbook-cover-content) {
  --verso-content-max-width: 52.5rem;
}

main .titlepage:has(> .textbook-subtitle) {
  display: flex;
  flex-direction: column;
  margin-block-end: 1.5rem;
  padding: clamp(2.25rem, 3.05vw, 2.75rem);
  border: 1px solid var(--textbook-border);
  border-inline-start-color: var(--textbook-link);
  border-radius: 0.5rem;
  background-color: var(--textbook-surface);
}

main .titlepage > .textbook-english-title {
  order: -3;
  color: var(--textbook-muted);
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

main .titlepage:has(> .textbook-subtitle) > h1 {
  order: -2;
  color: var(--textbook-heading);
  font-size: clamp(2.5rem, 3.1vw, 2.75rem);
  line-height: 1.35;
  margin-block-start: 0.5rem;
  margin-block-end: 0.5rem;
}

main .titlepage > .textbook-subtitle {
  order: -1;
  color: var(--textbook-muted);
  text-align: center;
  font-size: clamp(1.125rem, 2.2vw, 1.375rem);
  margin-block-end: 0.625rem;
}

main .titlepage > .textbook-subtitle > p {
  margin: 0;
}

main .titlepage > .authors {
  color: var(--textbook-muted);
  font-size: 0.9rem;
}

main .titlepage > p {
  margin-block: 1.5rem 0;
}

main .textbook-cover-content {
  container-type: inline-size;
}

main .textbook-cover-intro {
  margin: 0 0 1.5rem;
}

main .textbook-cover-toc-heading {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

main .textbook-cover-preface {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--textbook-muted);
  font-size: 0.95rem;
}

main .textbook-cover-preface a {
  text-decoration: underline;
}

main :is(.textbook-chapter-grid, .textbook-cover-references) {
  margin: 0;
  padding: 0;
  list-style: none;
}

main .textbook-cover-content :is(.textbook-chapter-grid, .textbook-cover-references) > li {
  margin: 0;
}

main .textbook-chapter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.875rem;
}

main .textbook-chapter-grid > li {
  display: flex;
  min-inline-size: 0;
}

main a.textbook-chapter-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1rem;
  border: 1px solid var(--textbook-border);
  border-radius: 0.375rem;
  color: var(--textbook-heading);
  text-decoration: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

main a.textbook-chapter-card:hover {
  border-color: var(--textbook-link);
  background-color: var(--textbook-current);
}

main .textbook-chapter-card:is(:hover, :focus-visible) .textbook-chapter-title {
  color: var(--textbook-link);
  text-decoration: underline;
}

main .textbook-chapter-card:focus-visible {
  outline: 2px solid var(--textbook-link);
  outline-offset: 3px;
}

main .textbook-chapter-number {
  color: var(--textbook-link);
  font-size: 0.82rem;
  font-weight: 700;
}

main .textbook-chapter-title {
  font-size: 1.13rem;
  font-weight: 700;
  line-height: 1.35;
}

main .textbook-chapter-summary {
  color: var(--textbook-muted);
  font-size: 0.93rem;
  line-height: 1.5;
}

main .textbook-cover-references {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.125rem;
  margin-block-start: 1.25rem;
  font-size: 0.95rem;
}

@container (min-width: 29rem) {
  main .textbook-chapter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (min-width: 43rem) {
  main .textbook-chapter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media screen and (max-width: 700px) {
  main {
    --textbook-code-size: 0.9375rem;
    font-size: 1.0625rem;
  }
  main .titlepage:has(> .textbook-subtitle) {
    padding: clamp(1.25rem, 5vw, 1.5rem);
  }
  main .titlepage:has(> .textbook-subtitle) > h1 {
    font-size: clamp(1.75rem, 5vw, 2rem);
  }
  main table.tabular :is(th, td) {
    padding: 0.4rem 0.5rem;
  }
  .content-wrapper { padding-inline: 1rem; }
}

main ol.textbook-bibliography {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

main ol.textbook-bibliography > li {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.875rem;
  margin: 0;
  padding: 0.3125rem 0.875rem 0.3125rem 0.5rem;
  border-inline-start: 0.1875rem solid transparent;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

main ol.textbook-bibliography > li > div {
  font-family: "Source Serif 4", "Noto Serif KR", "Noto Serif CJK KR", serif;
}

main ol.textbook-bibliography > li:target {
  border-inline-start-color: var(--textbook-link);
  background-color: var(--textbook-current);
}

main .textbook-reference-number {
  color: var(--textbook-muted);
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}

main :target > .textbook-reference-number {
  color: var(--textbook-link);
  font-weight: 650;
}

main .textbook-reference-link {
  display: inline-grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1em;
  margin-inline-start: 0.25rem;
  border-radius: 0.25rem;
  vertical-align: -0.15em;
}

main .textbook-reference-link svg {
  inline-size: 0.875rem;
  block-size: 0.875rem;
  pointer-events: none;
}

main .textbook-reference-link:hover {
  background-color: var(--textbook-current);
}

main .textbook-reference-link:focus-visible {
  outline: 2px solid var(--textbook-link);
  outline-offset: 1px;
}

@media screen and (max-width: 700px) {
  main ol.textbook-bibliography > li {
    grid-template-columns: 2.125rem minmax(0, 1fr);
    gap: 0.625rem;
    padding-inline: 0.125rem 0.375rem;
  }
}
