/*
 * Textbook visual system
 * A calm, publication-grade reading experience for long-form mathematics.
 */

:root {
  --book-bg: #f7f7f5;
  --book-surface: #ffffff;
  --book-surface-soft: #f7f8fa;
  --book-surface-raised: #ffffff;
  --book-ink: #1d2433;
  --book-ink-soft: #475166;
  --book-muted: #737c8d;
  --book-faint: #9aa1ad;
  --book-border: #e4e5e7;
  --book-border-strong: #d7d9dd;
  --book-primary: #52649a;
  --book-primary-deep: #3f507f;
  --book-primary-soft: #eff2f8;
  --book-primary-glow: rgb(82 100 154 / 18%);
  --book-teal: #397d78;
  --book-teal-soft: #eef6f4;
  --book-amber: #c27a18;
  --book-amber-soft: #fff7e8;
  --book-rose: #c94f70;
  --book-rose-soft: #fff0f4;
  --book-code: #f5f6fa;
  --book-missing: #c4334d;
  --book-shadow-sm: 0 1px 2px rgb(24 29 40 / 3%), 0 5px 18px rgb(24 29 40 / 3%);
  --book-shadow-md: 0 14px 40px rgb(24 29 40 / 6%);
  --book-shadow-lg: 0 24px 64px rgb(24 29 40 / 9%);
  --book-radius-sm: 0.45rem;
  --book-radius: 0.7rem;
  --book-radius-lg: 0.95rem;
  --book-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --book-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --book-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --book-toc-extra-width: 6rem;
}

html {
  scroll-padding-top: 5rem;
}

body {
  color: var(--book-ink);
  background: var(--book-bg);
  font-family: var(--book-sans);
  font-size: 16.5px;
  line-height: 1.82;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  color: #241a70;
  background: #dcd7ff;
}

a {
  color: var(--book-primary-deep);
  text-decoration-color: rgb(82 100 154 / 35%);
  text-decoration-thickness: 0.075em;
  text-underline-offset: 0.18em;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

a:hover {
  color: var(--book-primary);
  text-decoration-color: currentColor;
}

p,
li {
  text-wrap: pretty;
}

main.content {
  min-width: 0;
  margin-top: 1.4rem;
  margin-bottom: 3rem;
  padding: clamp(1.65rem, 3vw, 3.4rem) clamp(1.25rem, 4vw, 4rem);
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius-lg);
  background: rgb(255 255 255 / 97%);
  box-shadow: var(--book-shadow-md);
}

#title-block-header {
  margin-bottom: 2.6rem;
}

#title-block-header .quarto-title-breadcrumbs {
  margin-bottom: 1.35rem;
  color: var(--book-muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.breadcrumb-item+.breadcrumb-item::before {
  color: var(--book-faint);
}

h1,
h2,
h3,
h4,
h5,
h6,
.sidebar-title {
  color: var(--book-ink);
  font-family: var(--book-sans);
  font-weight: 720;
  letter-spacing: -0.025em;
  line-height: 1.32;
}

h1,
.quarto-title h1.title {
  margin-bottom: 1.4rem;
  font-family: var(--book-serif);
  font-size: clamp(2rem, 4vw, 3.15rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.25;
  text-wrap: balance;
}

.quarto-title h1.title::after {
  display: block;
  width: 3.4rem;
  height: 0.28rem;
  margin-top: 1.1rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--book-primary), #8e7cf2 55%, var(--book-teal));
  content: "";
}

h2 {
  position: relative;
  margin-top: 3.6rem;
  margin-bottom: 1.25rem;
  padding: 0 0 0.72rem;
  border-bottom: 1px solid var(--book-border);
  font-size: clamp(1.5rem, 2.2vw, 1.82rem);
}

h2::after {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 2.6rem;
  height: 2px;
  border-radius: 999px;
  background: var(--book-primary);
  content: "";
}

h3 {
  margin-top: 2.8rem;
  font-size: 1.28rem;
}

h4,
h5 {
  margin-top: 2.2rem;
}

.header-section-number {
  margin-right: 0.26em;
  color: var(--book-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.quarto-title-meta {
  display: flex !important;
  flex-wrap: wrap;
  gap: 0.8rem 2rem;
  margin-top: 1.2rem !important;
  padding: 1rem 1.2rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  background: var(--book-surface-soft);
}

/* Chapter pages do not provide title metadata; avoid rendering an empty card. */
#title-block-header .quarto-title-meta {
  display: none !important;
}

.quarto-title-meta>div {
  min-width: 8rem;
}

.quarto-title-meta-heading {
  margin-bottom: 0.12rem !important;
  color: var(--book-faint) !important;
  font-size: 0.7rem !important;
  font-weight: 750 !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quarto-title-meta-contents,
.quarto-title-meta-contents p {
  margin: 0;
  color: var(--book-ink-soft);
  font-size: 0.9rem;
}

/* Top application bar */
#quarto-header .quarto-secondary-nav {
  border-bottom: 1px solid rgb(226 229 238 / 80%);
  background: rgb(250 250 253 / 82%);
  box-shadow: 0 6px 24px rgb(25 31 60 / 4%);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}

#quarto-header .container-fluid {
  min-height: 3.55rem;
}

.quarto-btn-toggle,
.quarto-search-button {
  display: inline-grid !important;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0 !important;
  border: 1px solid var(--book-border) !important;
  border-radius: 0.72rem !important;
  background: rgb(255 255 255 / 80%) !important;
  color: var(--book-ink-soft) !important;
  box-shadow: var(--book-shadow-sm);
}

.quarto-btn-toggle:hover,
.quarto-search-button:hover {
  border-color: rgb(82 100 154 / 35%) !important;
  color: var(--book-primary) !important;
  transform: translateY(-1px);
}

.quarto-page-breadcrumbs .breadcrumb {
  font-size: 0.86rem;
  font-weight: 620;
}

/* Left book navigation */
#quarto-sidebar {
  border-right: 1px solid var(--book-border);
  background: #f4f4f2;
  box-shadow: none;
}

#quarto-sidebar .sidebar-header {
  margin: 0.75rem 0.85rem 0 !important;
  padding: 0.8rem 0.4rem 1.05rem !important;
  border: 0;
  border-bottom: 1px solid var(--book-border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#quarto-sidebar .sidebar-title {
  display: flex;
  align-items: center;
  gap: 0.68rem;
  font-size: 0.98rem;
  line-height: 1.45;
}

#quarto-sidebar .sidebar-title>a {
  color: var(--book-ink);
  font-weight: 730;
  text-decoration: none;
}

.textbook-brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.05rem;
  height: 2.05rem;
  border: 1px solid #3f507f;
  border-radius: 0.58rem;
  background: #435583;
  color: #fff;
  font-family: var(--book-serif);
  font-size: 1.12rem;
  font-style: italic;
  font-weight: 680;
  letter-spacing: 0;
  box-shadow: none;
}

#quarto-sidebar .sidebar-tools-main {
  display: none;
}

#quarto-sidebar .sidebar-search {
  margin: 0.85rem 0.85rem 0.55rem;
}

#quarto-sidebar .aa-Form {
  height: 2.65rem;
  border: 1px solid var(--book-border) !important;
  border-radius: 0.58rem !important;
  background: rgb(255 255 255 / 72%) !important;
  box-shadow: none !important;
}

#quarto-sidebar .aa-Form:focus-within {
  border-color: rgb(82 100 154 / 50%) !important;
  box-shadow: 0 0 0 3px var(--book-primary-glow) !important;
}

.sidebar-navigation .sidebar-menu-container {
  padding: 0 0.62rem 2rem;
}

.sidebar-navigation .sidebar-item-container {
  margin: 0.08rem 0;
  border-radius: 0.58rem;
  transition: background-color 150ms ease, transform 150ms ease;
}

.sidebar-navigation .sidebar-item-container:hover {
  background: rgb(82 100 154 / 7%);
}

.sidebar-navigation .sidebar-link {
  padding-top: 0.42rem !important;
  padding-bottom: 0.42rem !important;
  color: var(--book-ink-soft);
  font-size: 0.86rem;
  line-height: 1.45;
  text-decoration: none;
}

#quarto-sidebar .sidebar-item a.active {
  background: linear-gradient(90deg, rgb(82 100 154 / 11%), rgb(82 100 154 / 3%));
  color: var(--book-primary-deep);
  font-weight: 720;
}

#quarto-sidebar .sidebar-item a.active::before {
  position: absolute;
  left: 0;
  width: 3px;
  height: 1.15rem;
  border-radius: 0 999px 999px 0;
  background: var(--book-primary);
  content: "";
}

.sidebar-item-section>.sidebar-item-container {
  margin-top: 0.55rem;
}

.sidebar-item-section>.sidebar-item-container>.sidebar-link {
  color: var(--book-ink);
  font-size: 0.75rem;
  font-weight: 780;
  letter-spacing: 0.045em;
}

.sidebar-item-toggle {
  color: var(--book-muted) !important;
}

/* Right on-page navigation */
#quarto-margin-sidebar {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding-top: 1.55rem;
}

#quarto-margin-sidebar #TOC {
  width: 100%;
  min-width: 0;
}

@media (min-width: 992px) {
  #quarto-margin-sidebar {
    width: calc(100% + var(--book-toc-extra-width));
    max-width: none;
  }

  #quarto-margin-sidebar.chapter-progress-sidebar {
    display: flex;
    max-height: calc(100vh - 0.5rem);
    flex-direction: column;
    padding-bottom: 4.5rem;
    overflow: hidden;
  }

  #quarto-margin-sidebar.chapter-progress-sidebar>#TOC {
    min-height: 0;
    flex: 1 1 auto;
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #quarto-margin-sidebar>.chapter-progress--docked {
    position: relative;
    top: auto;
    z-index: auto;
    width: 100%;
    flex: 0 0 auto;
    margin: 0.8rem 0 0;
    padding: 0.8rem 0.85rem 0.85rem;
  }
}

#TOC {
  padding: 0.85rem;
  border: 1px solid rgb(226 229 238 / 85%);
  border-radius: var(--book-radius);
  background: rgb(255 255 255 / 58%);
  box-shadow: var(--book-shadow-sm);
  backdrop-filter: blur(12px);
}

#TOC ul,
#TOC li {
  list-style: none !important;
}

#TOC li::marker {
  content: none;
}

#TOC ul:empty,
#TOC li:empty {
  display: none !important;
}

#TOC #toc-title {
  margin: 0 0 0.65rem;
  padding: 0 0.35rem 0.65rem;
  border-bottom: 1px solid var(--book-border);
  color: var(--book-ink);
  font-size: 0.76rem;
  font-weight: 790;
  letter-spacing: 0.11em;
}

#TOC .nav-link {
  margin: 0.1rem 0;
  padding: 0.33rem 0.58rem;
  border-left: 2px solid transparent;
  border-radius: 0 0.48rem 0.48rem 0;
  color: var(--book-muted);
  font-size: 0.78rem;
  line-height: 1.45;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

#TOC .nav-link:hover {
  background: rgb(82 100 154 / 6%);
  color: var(--book-primary-deep);
}

#TOC .nav-link.active {
  border-left-color: var(--book-primary);
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
  font-weight: 700;
}

#TOC ul[hidden] {
  display: none !important;
}

#TOC>ul>li>ul {
  display: none !important;
  margin-left: 0.35rem;
  padding-left: 0.7rem;
  border-left: 1px solid var(--book-border);
}

#TOC>ul>li>ul.textbook-toc-branch-open {
  display: block !important;
}

#TOC>ul>li>ul>li>ul {
  display: none !important;
}

#TOC .computation-toc-item>.nav-link {
  margin-top: 0.7rem;
  border-top: 1px solid var(--book-border);
  border-left: 0;
  color: var(--book-primary-deep);
  font-weight: 740;
}

/* Theme control, progress, and back-to-top */
.quarto-color-scheme-toggle {
  display: none !important;
}

.textbook-theme-toggle.btn,
.textbook-back-to-top.btn {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid var(--book-border);
  border-radius: 0.76rem;
  background: rgb(255 255 255 / 82%);
  color: var(--book-ink-soft);
  font-size: 0.96rem;
  line-height: 1;
  box-shadow: var(--book-shadow-sm);
  backdrop-filter: blur(12px);
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.textbook-theme-toggle.btn:hover,
.textbook-back-to-top.btn:hover {
  border-color: rgb(82 100 154 / 42%);
  background: #fff;
  color: var(--book-primary);
  box-shadow: 0 7px 18px rgb(41 37 92 / 12%);
  transform: translateY(-2px);
}

.textbook-theme-toggle.btn:focus-visible,
.textbook-back-to-top.btn:focus-visible,
.home-button:focus-visible {
  outline: 3px solid var(--book-primary-glow);
  outline-offset: 2px;
}

.textbook-theme-toggle-floating {
  position: fixed;
  z-index: 1080;
  top: 0.62rem;
  right: 4.15rem;
}

.textbook-toc-title-with-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.textbook-theme-toggle-in-toc.btn {
  width: 2rem;
  height: 2rem;
  margin: -0.22rem 0 -0.1rem auto;
  border-radius: 0.62rem;
  font-size: 0.84rem;
}

.textbook-reading-progress {
  position: fixed;
  z-index: 2000;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: rgb(50 67 122 / 18%);
  box-shadow: inset 0 -1px rgb(255 255 255 / 55%);
  pointer-events: none;
}

.textbook-reading-progress>span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2146b6 0%, #5b43d6 38%, #d23b9a 72%, #079d8b 100%);
  box-shadow: 0 0 5px rgb(33 70 182 / 80%), 0 0 16px rgb(210 59 154 / 38%);
  transform: scaleX(0);
  transform-origin: left center;
}

.quarto-dark .textbook-reading-progress {
  background: rgb(30 38 58 / 82%);
}

.quarto-dark .textbook-reading-progress>span {
  background: linear-gradient(90deg, #00f5ff 0%, #4d7cff 34%, #b84dff 68%, #ff2bd6 100%);
  box-shadow: 0 0 7px #00f5ff, 0 0 18px rgb(184 77 255 / 82%), 0 0 30px rgb(255 43 214 / 42%);
}

.textbook-back-to-top.btn {
  position: fixed;
  z-index: 1060;
  right: 1.25rem;
  bottom: 1.25rem;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.7rem);
}

.textbook-back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Rich textbook components */
span.math.inline {
  margin-inline: 0.12em;
}

span.math.inline.math-inline-overflow {
  display: inline-flex;
  max-width: var(--math-inline-available-width, 100%);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  vertical-align: baseline;
}

span.math.inline.math-inline-overflow::-webkit-scrollbar {
  display: none;
}

span.math.display {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

main.content :where(p, li, dd, .theorem-block, .proof-block) {
  min-width: 0;
}

.todo-note {
  padding: 0.08em 0.42em 0.12em;
  border: 1px solid var(--book-border-strong);
  border-radius: 0.38rem;
  background: var(--book-surface-soft);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  color: var(--book-ink-soft);
  font-size: 0.88em;
  line-height: 1.65;
}

.todo-note::before {
  margin-right: 0.38em;
  font-size: 0.72em;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.todo-info {
  border-color: color-mix(in srgb, var(--book-teal) 38%, transparent);
  background: var(--book-teal-soft);
}

.todo-info::before {
  color: var(--book-teal);
  content: "INFO";
}

.todo-unsure {
  border-color: color-mix(in srgb, var(--book-rose) 38%, transparent);
  background: var(--book-rose-soft);
}

.todo-unsure::before {
  color: var(--book-rose);
  content: "存疑";
}

.todo-change {
  border-color: color-mix(in srgb, var(--book-primary) 38%, transparent);
  background: var(--book-primary-soft);
}

.todo-change::before {
  color: var(--book-primary-deep);
  content: "修改";
}

.todo-improvement {
  border-color: color-mix(in srgb, var(--book-amber) 42%, transparent);
  background: var(--book-amber-soft);
}

.todo-improvement::before {
  color: var(--book-amber);
  content: "改进";
}

.theorem-block,
.proof-block {
  position: relative;
  margin: 1.8rem 0;
  padding: 1.18rem 1.35rem 1.18rem 1.5rem;
  border: 1px solid #dce1eb;
  border-radius: var(--book-radius);
  background: #f6f7fa;
  box-shadow: none;
  overflow: hidden;
}

.theorem-block::before,
.proof-block::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--book-primary);
  content: "";
}

.theorem-block.env-definition {
  border-color: #d5e6e2;
  background: #f3f8f7;
}

.theorem-block.env-definition::before {
  background: var(--book-teal);
}

.theorem-block.env-note,
.theorem-block.env-remark,
.theorem-block.env-method,
.theorem-block.env-derivation {
  border-color: #f0dfbd;
  background: #fffaf0;
}

.theorem-block.env-note::before,
.theorem-block.env-remark::before,
.theorem-block.env-method::before,
.theorem-block.env-derivation::before {
  background: var(--book-amber);
}

.theorem-block>p:first-child,
.proof-block>p:first-child {
  margin-top: 0;
}

.theorem-block> :last-child,
.proof-block> :last-child {
  margin-bottom: 0;
}

.theorem-block>p:first-child>strong:first-child,
.proof-block>p:first-child>strong:first-child {
  color: var(--book-ink);
}

.proof-block {
  border-color: var(--book-border);
  background: #fafafa;
  box-shadow: none;
}

.proof-block::before {
  width: 3px;
  background: #a8b0c0;
}

.algorithm-block {
  margin: 2rem 0;
  border: 1px solid var(--book-border-strong);
  border-radius: var(--book-radius);
  background: var(--book-surface);
  box-shadow: var(--book-shadow-sm);
  overflow: hidden;
}

.algorithm-caption {
  padding: 0.92rem 1.1rem;
  border-bottom: 1px solid var(--book-border);
  background: #f4f5f8;
}

.algorithm-caption>p {
  margin: 0;
}

.algorithm-number {
  display: inline-block;
  margin-right: 0.42rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: #e7eaf2;
  color: var(--book-primary-deep);
  font-size: 0.74rem;
  font-weight: 760;
  letter-spacing: 0.035em;
}

.algorithm-title {
  color: var(--book-ink);
  font-weight: 700;
}

.algorithm-body {
  padding: 0.7rem 0;
  overflow-x: auto;
}

.algorithm-line {
  position: relative;
  min-width: 34rem;
  padding: 0.26rem 1rem 0.26rem 4rem;
  border-left: 3px solid transparent;
}

.algorithm-line:nth-child(even) {
  background: rgb(244 245 250 / 65%);
}

.algorithm-line[data-line]::before {
  position: absolute;
  top: 0.33rem;
  left: 0.9rem;
  width: 2rem;
  color: var(--book-faint);
  content: attr(data-line);
  font-family: var(--book-mono);
  font-size: 0.72rem;
  line-height: 1.8;
  text-align: right;
}

.algorithm-line> :first-child {
  margin-top: 0;
}

.algorithm-line> :last-child {
  margin-bottom: 0;
}

.algorithm-require,
.algorithm-ensure {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  border-left-color: var(--book-primary);
  background: #f7f6ff;
}

.algorithm-statex,
.algorithm-comment {
  color: var(--book-muted);
  font-size: 0.92em;
}

.algorithm-depth-1 {
  padding-left: 5.4rem;
}

.algorithm-depth-2 {
  padding-left: 6.8rem;
}

.algorithm-depth-3 {
  padding-left: 8.2rem;
}

.algorithm-depth-4 {
  padding-left: 9.6rem;
}

.algorithm-depth-5,
.algorithm-depth-6 {
  padding-left: 11rem;
}

.equation-block {
  margin-block: 1.35rem;
  padding-block: 0.3rem;
  overflow-x: auto;
  scroll-margin-top: 5rem;
}

.equation-anchor {
  display: block;
  height: 0;
  scroll-margin-top: 6rem;
}

.term {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.2em;
}

.term:hover {
  text-decoration-style: solid;
}

.term-english {
  color: var(--book-muted);
  font-size: 0.92em;
}

.term-missing,
.reference-missing {
  color: var(--book-missing);
}

.term-missing {
  text-decoration: underline wavy;
}

.reference-missing {
  padding: 0.06em 0.26em;
  border-radius: 0.25rem;
  background: var(--book-rose-soft);
  font-size: 0.9em;
}

pre,
code {
  font-family: var(--book-mono);
}

:not(pre)>code {
  padding: 0.12em 0.36em;
  border: 1px solid var(--book-border);
  border-radius: 0.36rem;
  background: var(--book-code);
  color: #a13658;
  font-size: 0.88em;
}

div.sourceCode,
pre {
  border: 1px solid var(--book-border) !important;
  border-radius: var(--book-radius) !important;
  background: var(--book-code) !important;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 75%);
}

.code-copy-button {
  margin: 0.45rem;
  border: 1px solid var(--book-border) !important;
  border-radius: 0.5rem !important;
  background: rgb(255 255 255 / 76%) !important;
}

.textbook-table-scroll {
  max-width: 100%;
  margin: 1.6rem 0;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  box-shadow: var(--book-shadow-sm);
  overflow-x: auto;
}

.textbook-table-scroll table {
  width: 100%;
  margin: 0;
  font-size: 0.92rem;
}

.textbook-latex-table {
  border-collapse: collapse;
  table-layout: auto;
}

.textbook-latex-table caption {
  padding: 0.8rem 1rem 0.65rem;
  color: var(--book-ink-soft);
  font-weight: 700;
  text-align: center;
}

.textbook-latex-table :is(th, td) {
  min-width: 4.5rem;
  vertical-align: middle;
}

.textbook-latex-table .latex-table-align-left {
  text-align: left;
}

.textbook-latex-table .latex-table-align-center {
  text-align: center;
}

.textbook-latex-table .latex-table-align-right {
  text-align: right;
}

.textbook-latex-table .latex-table-vrule-right {
  border-right: 1.5px solid var(--book-border-strong) !important;
}

.textbook-latex-table tr.latex-table-rule-above > * {
  border-top: 1.5px solid var(--book-border-strong) !important;
}

.textbook-latex-table tr.latex-table-rule-below > * {
  border-bottom: 1.5px solid var(--book-border-strong) !important;
}

.latex-table-diagbox {
  position: relative;
  display: block;
  min-width: 7rem;
  min-height: 3.4rem;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.75px),
    var(--book-border-strong) 50%,
    transparent calc(50% + 0.75px)
  );
}

.latex-table-diagbox-upper,
.latex-table-diagbox-lower {
  position: absolute;
  line-height: 1.2;
  white-space: nowrap;
}

.latex-table-diagbox-upper {
  top: 0.15rem;
  right: 0.2rem;
}

.latex-table-diagbox-lower {
  bottom: 0.15rem;
  left: 0.2rem;
}

table th,
table td {
  padding: 0.72rem 0.85rem !important;
  border-color: var(--book-border) !important;
}

thead {
  background: #f1f2f8;
  color: var(--book-ink);
}

tbody tr:nth-child(even) {
  background: rgb(246 247 250 / 65%);
}

blockquote {
  margin: 1.6rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--book-primary);
  border-radius: 0 var(--book-radius) var(--book-radius) 0;
  background: var(--book-primary-soft);
  color: var(--book-ink-soft);
}

img,
svg {
  max-width: 100%;
  height: auto;
}

img.tikz-image {
  box-sizing: border-box;
  display: block;
  margin: 1.6rem auto;
  padding: 1.15rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  background: #fff;
  box-shadow: var(--book-shadow-sm);
}

.page-navigation .nav-page {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  background: #fff;
  color: var(--book-ink-soft);
  box-shadow: var(--book-shadow-sm);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.page-navigation .nav-page:hover {
  border-color: rgb(82 100 154 / 32%);
  box-shadow: var(--book-shadow-sm);
  transform: translateY(-1px);
}

/* Glossary */
.glossary-summary {
  margin: 1.35rem 0 1.7rem;
  padding: 1.15rem 1.3rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  background: var(--book-surface-soft);
  box-shadow: none;
}

.glossary-summary> :last-child,
.glossary-alphabet> :last-child,
.glossary-navigation> :last-child,
.glossary-entry-main> :last-child,
.glossary-entry-meta> :last-child {
  margin-bottom: 0;
}

.glossary-alphabet>p {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.25rem, 1fr));
  gap: 0.48rem;
}

.glossary-letter-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.9rem;
  padding: 0.52rem 0.68rem;
  border: 1px solid var(--book-border);
  border-radius: 0.5rem;
  background: var(--book-surface);
  color: var(--book-ink);
  text-decoration: none;
  box-shadow: none;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.glossary-letter-link:hover {
  border-color: rgb(82 100 154 / 42%);
  background: var(--book-primary-soft);
}

.glossary-letter-name {
  font-size: 1.08rem;
  font-weight: 760;
}

.glossary-letter-count {
  min-width: 1.75rem;
  padding: 0.1rem 0.44rem;
  border-radius: 999px;
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
}

.glossary-navigation {
  margin: 0.8rem 0 1.45rem;
}

.glossary-navigation>p {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.glossary-nav-link {
  padding: 0.32rem 0.72rem;
  border: 1px solid var(--book-border);
  border-radius: 999px;
  background: var(--book-surface);
  color: var(--book-primary-deep);
  font-size: 0.85rem;
  text-decoration: none;
}

.glossary-nav-link:hover {
  border-color: rgb(82 100 154 / 40%);
  background: var(--book-primary-soft);
}

.glossary-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 0.55fr);
  gap: 0.9rem 1.6rem;
  margin: 0.8rem 0;
  padding: 1.05rem 1.2rem;
  border: 1px solid var(--book-border);
  border-radius: 0.72rem;
  background: var(--book-surface);
  box-shadow: none;
  scroll-margin-top: 5rem;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.glossary-entry:hover {
  border-color: rgb(82 100 154 / 30%);
  background: var(--book-surface-soft);
}

.glossary-term-heading {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--book-primary-deep);
  font-size: 1.04rem;
  font-weight: 740;
  line-height: 1.5;
}

.glossary-chinese {
  margin-left: 0.35rem;
  color: var(--book-ink-soft);
}

.glossary-entry-meta {
  align-self: center;
  color: var(--book-faint);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.glossary-entry-meta code {
  color: var(--book-muted);
  font-size: 0.76rem;
}

.glossary-alias {
  display: block;
  height: 0;
  scroll-margin-top: 5rem;
}

.glossary-empty {
  padding: 2rem;
  border: 1px dashed var(--book-border-strong);
  border-radius: var(--book-radius);
  color: var(--book-muted);
  text-align: center;
}

/* Executed Jupyter/Quarto results appended to textbook chapters. */
.computation-appendix {
  margin-top: 5rem;
  padding-top: 2.8rem;
  border-top: 1px solid var(--book-border-strong);
}

.computation-appendix-header {
  margin-bottom: 1.8rem;
}

.computation-appendix-header>p {
  margin: 0 0 0.4rem;
  color: var(--book-primary);
  font-family: var(--book-mono);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.14em;
}

.computation-appendix-header>h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--book-serif);
  font-size: clamp(1.7rem, 3vw, 2.25rem);
}

.computation-appendix-header>h2::after {
  display: none;
}

.computation-appendix-header>span {
  display: block;
  margin-top: 0.55rem;
  color: var(--book-muted);
  font-size: 0.84rem;
}

.computation-case {
  margin: 2rem 0 3.5rem;
  padding: 0 0 3rem;
  border-bottom: 1px solid var(--book-border);
}

.computation-case-index {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
  color: var(--book-muted);
  font-size: 0.68rem;
  font-weight: 720;
  letter-spacing: 0.09em;
}

.computation-case-index strong {
  display: inline-grid;
  place-items: center;
  min-width: 1.7rem;
  padding: 0.06rem 0.35rem;
  border-radius: 0.35rem;
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
  font-family: var(--book-mono);
  font-size: 0.68rem;
}

.computation-case>h3 {
  margin: 0 0 1.35rem;
  font-family: var(--book-serif);
  font-size: clamp(1.28rem, 2.4vw, 1.65rem);
}

.computation-result {
  margin: 2rem 0 0;
  padding-left: 1.15rem;
  border-left: 2px solid var(--book-primary-soft);
}

.computation-result-label {
  padding: 0 0 0.45rem;
  color: var(--book-primary-deep);
  font-family: var(--book-mono);
  font-size: 0.66rem;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.computation-result-body {
  min-width: 0;
  padding: 0;
  background: transparent;
  overflow-x: auto;
}

.computation-result-body> :first-child,
.computation-result-body .cell> :first-child {
  margin-top: 0;
}

.computation-result-body> :last-child,
.computation-result-body .cell> :last-child {
  margin-bottom: 0;
}

.computation-result-body h3,
.computation-result-body h4,
.computation-result-body h5,
.computation-result-body h6 {
  margin-top: 2rem;
}

.computation-result-body .cell {
  margin: 1.2rem 0;
}

.computation-result-body .cell-code,
.computation-result-body .cell-output {
  margin-top: 0.65rem;
  border-radius: var(--book-radius-sm);
  overflow-x: auto;
}

.computation-result-body .cell-output {
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--book-border);
  background: var(--book-surface-soft);
}

.computation-result-body .cell-output-display:has(img) {
  padding: 0;
  border: 0;
  background: transparent;
}

.computation-result-body img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
  border-radius: var(--book-radius-sm);
}

.computation-result-body table,
.computation-result-body .dataframe {
  width: max-content;
  min-width: 100%;
  margin: 0;
}

.computation-result-body .textbook-dataframe-scroll {
  margin: 0.85rem 0 1.2rem;
  border-color: var(--book-border-strong);
  border-radius: var(--book-radius-sm);
  background: var(--book-surface);
  box-shadow: 0 1px 2px rgb(24 29 40 / 3%);
}

.computation-result-body .textbook-dataframe {
  border: 0 !important;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--book-ink-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.computation-result-body .textbook-dataframe :is(th, td) {
  min-width: 5.25rem;
  padding: 0.62rem 0.8rem !important;
  border: 0 !important;
  border-bottom: 1px solid var(--book-border) !important;
  background: transparent;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  text-align: center !important;
  vertical-align: middle;
  white-space: nowrap;
}

.computation-result-body .textbook-dataframe thead th {
  border-bottom: 1.5px solid var(--book-border-strong) !important;
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.025em;
}

.computation-result-body .textbook-dataframe thead th:first-child,
.computation-result-body .textbook-dataframe tbody th {
  border-right: 1px solid var(--book-border) !important;
}

.computation-result-body .textbook-dataframe tbody th {
  background: var(--book-surface-soft);
  color: var(--book-ink);
  font-weight: 680;
}

.computation-result-body .textbook-dataframe tbody tr:last-child>* {
  border-bottom: 0 !important;
}

.computation-result-body .textbook-dataframe tbody tr:hover>* {
  background: var(--book-teal-soft);
}

.computation-result-body pre {
  max-height: 34rem;
  overflow: auto;
}

/* Restrained editorial home page */
body:has(.textbook-home) main.content,
body.textbook-home-page main.content {
  min-height: 0 !important;
  height: auto !important;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body.textbook-home-page #quarto-content,
body.textbook-home-page .page-columns {
  min-height: 0 !important;
}

body.textbook-home-page .page-navigation {
  display: none !important;
}

body:has(.textbook-home) #title-block-header,
body.textbook-home-page #title-block-header,
body:has(.textbook-home) #quarto-margin-sidebar,
body.textbook-home-page #quarto-margin-sidebar {
  display: none;
}

.textbook-home {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  /* Use the full area beside the left book navigation, not the narrow
     article measure used by chapters. */
  grid-column: body-content-start / screen-end !important;
  min-height: 0 !important;
}

.home-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 22rem);
  min-height: calc(100vh - 8rem);
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius-lg);
  background: #fff;
  box-shadow: 0 18px 52px rgb(24 29 40 / 7%);
  overflow: hidden;
}

.home-intro-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(2rem, 5vw, 5.5rem);
}

.home-eyebrow {
  margin: 0 0 1.25rem;
  color: var(--book-primary);
  font-family: var(--book-mono);
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0.14em;
}

.home-intro h1 {
  max-width: 16ch;
  margin: 0;
  color: var(--book-ink);
  font-family: var(--book-serif);
  font-size: clamp(2.35rem, 5vw, 4.1rem);
  font-weight: 680;
  letter-spacing: -0.05em;
  line-height: 1.16;
  text-wrap: balance;
}

.home-intro h1::after {
  display: none;
}

.home-lead {
  max-width: 42rem;
  margin: 1.5rem 0 0;
  color: var(--book-muted);
  font-size: 1rem;
  line-height: 1.85;
}

.home-lead>span {
  display: block;
}

.home-quote {
  margin: 1.15rem 0 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 2px solid var(--book-primary);
  border-radius: 0;
  background: transparent;
  color: var(--book-ink-soft);
}

.home-quote p {
  margin: 0;
  font-family: var(--book-serif);
  font-size: 0.98rem;
  line-height: 1.75;
  white-space: normal;
}

.home-quote p>span {
  display: block;
  white-space: nowrap;
}

.home-quote cite {
  display: block;
  margin-top: 0.35rem;
  color: var(--book-muted);
  font-family: var(--book-mono);
  font-size: 0.62rem;
  font-style: normal;
  letter-spacing: 0.08em;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.35rem;
}

.home-actions>p {
  display: contents;
  margin: 0;
}

.home-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.8rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--book-border-strong);
  border-radius: 0.52rem;
  background: #fff;
  color: var(--book-ink-soft);
  font-size: 0.86rem;
  font-weight: 680;
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.home-button:hover {
  border-color: var(--book-primary);
  color: var(--book-primary-deep);
  transform: translateY(-1px);
}

.home-button-primary {
  border-color: #435583;
  background: #435583;
  color: #fff;
}

.home-button-primary:hover {
  border-color: #34446f;
  background: #34446f;
  color: #fff;
}

.home-edition {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 2rem;
  border-left: 1px solid var(--book-border);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 50%), transparent 38%),
    #eef0f3;
  overflow: hidden;
}

.home-edition::after {
  position: absolute;
  right: -3.5rem;
  bottom: 5.4rem;
  width: 9rem;
  height: 9rem;
  border: 1px solid rgb(82 100 154 / 10%);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.home-edition-label {
  color: var(--book-muted);
  font-family: var(--book-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.home-edition-symbol {
  display: grid;
  flex: 1;
  place-items: center;
  color: #435583;
  font-family: var(--book-serif);
  font-size: clamp(5rem, 10vw, 7.6rem);
  font-style: italic;
  font-weight: 520;
  letter-spacing: -0.08em;
  line-height: 1;
  text-shadow: 0 1px 0 rgb(255 255 255 / 70%);
}

.home-facts {
  margin: 0;
  border-top: 1px solid var(--book-border-strong);
}

.home-facts>div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--book-border-strong);
}

.home-facts dt {
  color: var(--book-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.home-facts dd {
  margin: 0;
  color: var(--book-ink);
  font-family: var(--book-serif);
  font-size: 1.1rem;
  font-weight: 650;
}

.home-quicklinks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  background: #fff;
  overflow: hidden;
}

.home-quicklinks a {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0 0.85rem;
  padding: 1.1rem 1.25rem;
  color: var(--book-ink);
  text-decoration: none;
  transition: background-color 150ms ease;
}

.home-quicklinks a::after {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  color: var(--book-faint);
  content: "→";
  font-size: 0.9rem;
  transition: color 150ms ease, transform 150ms ease;
}

.home-quicklinks a:hover::after {
  color: var(--book-primary);
  transform: translateX(2px);
}

.home-quicklinks a+a {
  border-left: 1px solid var(--book-border);
}

.home-quicklinks a:hover {
  background: var(--book-surface-soft);
}

.home-quicklinks span {
  grid-row: 1 / 3;
  color: var(--book-faint);
  font-family: var(--book-mono);
  font-size: 0.66rem;
}

.home-quicklinks strong {
  font-size: 0.86rem;
  font-weight: 700;
}

.home-quicklinks small {
  margin-top: 0.08rem;
  color: var(--book-muted);
  font-size: 0.72rem;
}

.home-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.25rem 0 0;
  padding: 0.8rem 0.3rem 0;
  border-top: 1px solid var(--book-border);
  min-width: 0;
}

.home-footer p {
  min-width: 0;
  margin: 0;
  color: var(--book-faint);
  font-size: 0.7rem;
  letter-spacing: 0.025em;
}


.home-contact {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.42rem;
  padding: 0.38rem 0.62rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  color: var(--book-muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.home-contact:hover {
  border-color: var(--book-border);
  background: #fff;
  color: var(--book-primary-deep);
}

.home-contact .bi {
  font-size: 0.82rem;
}

/* Dark mode */
body.quarto-dark {
  --book-bg: #0e1118;
  --book-surface: #171b24;
  --book-surface-soft: #1c212c;
  --book-surface-raised: #202631;
  --book-ink: #edf0f7;
  --book-ink-soft: #c4cad7;
  --book-muted: #9aa4b7;
  --book-faint: #747f93;
  --book-border: #2d3442;
  --book-border-strong: #3a4353;
  --book-primary: #9dadd8;
  --book-primary-deep: #b6c3e5;
  --book-primary-soft: #252b3a;
  --book-primary-glow: rgb(157 173 216 / 20%);
  --book-teal: #54d6c7;
  --book-teal-soft: #153530;
  --book-amber: #efb75f;
  --book-amber-soft: #342918;
  --book-rose: #ff8da9;
  --book-rose-soft: #3b2029;
  --book-code: #12161d;
  --book-missing: #ff8da0;
  --book-shadow-sm: 0 1px 2px rgb(0 0 0 / 18%), 0 7px 18px rgb(0 0 0 / 12%);
  --book-shadow-md: 0 16px 38px rgb(0 0 0 / 22%);
  --book-shadow-lg: 0 28px 75px rgb(0 0 0 / 35%);
  color: var(--book-ink-soft);
  background: var(--book-bg);
}

.quarto-dark ::selection {
  color: #fff;
  background: #52648f;
}

.quarto-dark main.content {
  border-color: rgb(52 60 75 / 85%);
  background: rgb(23 27 36 / 94%);
}

.quarto-dark h1,
.quarto-dark h2,
.quarto-dark h3,
.quarto-dark h4,
.quarto-dark h5,
.quarto-dark h6,
.quarto-dark .sidebar-title {
  color: var(--book-ink);
}

.quarto-dark #quarto-header .quarto-secondary-nav {
  border-bottom-color: rgb(45 52 66 / 80%);
  background: rgb(15 18 25 / 84%);
}

.quarto-dark .quarto-btn-toggle,
.quarto-dark .quarto-search-button,
.quarto-dark .textbook-theme-toggle.btn,
.quarto-dark .textbook-back-to-top.btn {
  border-color: var(--book-border) !important;
  background: rgb(27 32 42 / 82%) !important;
  color: var(--book-ink-soft) !important;
}

.quarto-dark .textbook-theme-toggle.btn {
  color: #ffd272 !important;
}

.quarto-dark #quarto-sidebar {
  border-right-color: var(--book-border);
  background: #12161d;
}

.quarto-dark #quarto-sidebar .sidebar-header {
  border-color: var(--book-border);
  background: transparent;
}

.quarto-dark #quarto-sidebar .sidebar-title>a {
  color: var(--book-ink);
}

.quarto-dark .textbook-brand-mark {
  border-color: #687ba9;
  background: #52648f;
}

.quarto-dark #quarto-sidebar .aa-Form,
.quarto-dark #TOC {
  border-color: var(--book-border) !important;
  background: rgb(27 32 42 / 80%) !important;
}

.quarto-dark .sidebar-navigation .sidebar-item-container:hover,
.quarto-dark #TOC .nav-link:hover {
  background: rgb(157 173 216 / 8%);
}

.quarto-dark #quarto-sidebar .sidebar-item a.active {
  background: linear-gradient(90deg, rgb(157 173 216 / 15%), transparent);
  color: var(--book-primary-deep);
}

.quarto-dark .quarto-title-meta {
  border-color: var(--book-border);
  background: var(--book-surface-soft);
}

.quarto-dark .theorem-block {
  border-color: #353e51;
  background: #202631;
  box-shadow: none;
}

.quarto-dark .theorem-block.env-definition {
  border-color: #28544d;
  background: #1a2b29;
}

.quarto-dark .theorem-block.env-note,
.quarto-dark .theorem-block.env-remark,
.quarto-dark .theorem-block.env-method,
.quarto-dark .theorem-block.env-derivation {
  border-color: #57452b;
  background: #2b261d;
}

.quarto-dark .proof-block {
  border-color: var(--book-border);
  background: #1a1f27;
}

.quarto-dark .algorithm-block,
.quarto-dark .glossary-letter-link,
.quarto-dark .glossary-nav-link,
.quarto-dark .glossary-entry,
.quarto-dark .page-navigation .nav-page {
  border-color: var(--book-border);
  background: var(--book-surface);
  box-shadow: none;
}

.quarto-dark .algorithm-caption {
  border-bottom-color: var(--book-border);
  background: #222834;
}

.quarto-dark .algorithm-line:nth-child(even) {
  background: rgb(255 255 255 / 2.5%);
}

.quarto-dark .algorithm-require,
.quarto-dark .algorithm-ensure {
  background: #242139;
}

.quarto-dark .glossary-summary {
  border-color: var(--book-border);
  background: var(--book-surface-soft);
}

.quarto-dark .glossary-letter-link:hover,
.quarto-dark .glossary-nav-link:hover,
.quarto-dark .glossary-entry:hover {
  border-color: rgb(157 173 216 / 40%);
  background: var(--book-surface-raised);
}

.quarto-dark .glossary-letter-count {
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
}

.quarto-dark .glossary-term-heading {
  color: var(--book-primary-deep);
}

.quarto-dark .computation-appendix {
  border-top-color: var(--book-border-strong);
}

.quarto-dark .computation-case,
.quarto-dark .computation-result,
.quarto-dark .computation-result-body {
  border-color: var(--book-border);
  background: transparent;
  box-shadow: none;
}

.quarto-dark .computation-result-label,
.quarto-dark .computation-result-body .cell-output {
  border-color: var(--book-border);
  background: var(--book-surface-soft);
}

.quarto-dark :not(pre)>code {
  border-color: var(--book-border);
  background: var(--book-code);
  color: #f1a1b9;
}

.quarto-dark div.sourceCode,
.quarto-dark pre {
  border-color: var(--book-border) !important;
  background: var(--book-code) !important;
  box-shadow: none;
}

.quarto-dark .code-copy-button {
  background: rgb(31 37 48 / 86%) !important;
}

.quarto-dark .textbook-table-scroll {
  border-color: var(--book-border);
  box-shadow: none;
}

.quarto-dark thead {
  background: #242a35;
}

.quarto-dark tbody tr:nth-child(even) {
  background: rgb(255 255 255 / 2%);
}

.quarto-dark blockquote {
  background: var(--book-primary-soft);
}

.quarto-dark img.tikz-image {
  border-color: #485162;
  background: #fff;
  box-shadow: 0 12px 30px rgb(0 0 0 / 22%);
}

.quarto-dark .home-intro,
.quarto-dark .home-quicklinks {
  border-color: var(--book-border);
  background: var(--book-surface);
}

.quarto-dark .home-edition {
  border-color: var(--book-border);
  background: #20252e;
}

.quarto-dark .home-edition-symbol {
  color: var(--book-primary);
  text-shadow: none;
}

.quarto-dark .home-facts,
.quarto-dark .home-facts>div,
.quarto-dark .home-quicklinks a+a {
  border-color: var(--book-border);
}

.quarto-dark .home-button {
  border-color: var(--book-border-strong);
  background: var(--book-surface);
  color: var(--book-ink-soft);
}

.quarto-dark .home-button-primary {
  border-color: #687ba9;
  background: #52648f;
  color: #fff;
}

.quarto-dark .home-button-primary:hover {
  border-color: #7b8db6;
  background: #6073a0;
  color: #fff;
}

.quarto-dark .home-quicklinks a {
  color: var(--book-ink);
}

.quarto-dark .home-quicklinks a:hover {
  background: var(--book-surface-soft);
}

.quarto-dark .home-contact:hover {
  border-color: var(--book-border);
  background: var(--book-surface);
}

/* Copyable display mathematics */
.display-math-copy-marker {
  display: none !important;
}

.display-math-source {
  position: relative;
  display: block;
  margin: 0.15rem 0;
  padding-top: 0.15rem;
}

.display-math-copy-button {
  position: absolute;
  z-index: 3;
  top: 0.15rem;
  right: 0.2rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.52rem;
  border: 1px solid var(--book-border-strong);
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--book-surface) 92%, transparent);
  box-shadow: 0 2px 8px rgb(20 30 48 / 8%);
  color: var(--book-muted);
  font: inherit;
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-0.2rem);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.display-math-source:hover .display-math-copy-button,
.display-math-source:focus-within .display-math-copy-button,
.display-math-copy-button--success,
.display-math-copy-button--error {
  opacity: 1;
  transform: translateY(0);
}

.display-math-copy-button:hover,
.display-math-copy-button:focus-visible {
  border-color: var(--book-primary);
  color: var(--book-primary-deep);
  outline: none;
}

.display-math-copy-button--success {
  border-color: #5b9471;
  color: #277347;
}

.display-math-copy-button--error {
  border-color: #c66b62;
  color: #b42318;
}

.quarto-dark .display-math-copy-button {
  background: color-mix(in srgb, var(--book-surface) 94%, transparent);
  box-shadow: 0 2px 8px rgb(0 0 0 / 24%);
}

.quarto-dark .display-math-copy-button--success {
  color: #8bd7a8;
}

.quarto-dark .display-math-copy-button--error {
  color: #ff9b8f;
}

@media (hover: none) {
  .display-math-copy-button {
    opacity: 0.78;
    transform: none;
  }

  .display-math-copy-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Interactive probability density plots */
.density-plot {
  --density-curve: #405f9d;
  --density-area: rgb(64 95 157 / 9%);
  --density-grid: #e8ebf0;
  --density-axis: #596274;
  margin: 1.8rem 0 2.2rem;
  padding: 1.15rem;
  border: 1px solid var(--book-border-strong);
  border-left: 3px solid var(--book-primary);
  border-radius: var(--book-radius);
  background: var(--book-surface);
}

.density-plot:not([data-density-ready="true"]) {
  min-height: 8rem;
}

.density-plot:not([data-density-ready="true"])::before {
  display: grid;
  min-height: 5.5rem;
  place-items: center;
  color: var(--book-muted);
  content: "交互图将在滚动到附近时加载";
  font-size: 0.85rem;
}

.density-plot--load-error {
  color: #b42318;
}

.density-plot__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
  color: var(--book-ink);
}

.density-plot__heading strong {
  font-family: var(--book-serif);
  font-size: 1.08rem;
  letter-spacing: 0;
}

.density-plot__heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.density-plot__fixed-scale {
  padding: 0.18rem 0.5rem;
  border: 1px solid #d9dfeb;
  border-radius: 999px;
  background: #f2f5fa;
  color: var(--book-primary-deep);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.03em;
}

.density-plot__action,
.density-plot__reset,
.density-plot__mode {
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--book-border-strong);
  border-radius: var(--book-radius-sm);
  background: var(--book-surface);
  color: var(--book-ink-soft);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.density-plot__action:hover,
.density-plot__action:focus-visible,
.density-plot__reset:hover,
.density-plot__reset:focus-visible,
.density-plot__mode:hover,
.density-plot__mode:focus-visible {
  border-color: var(--book-primary);
  color: var(--book-primary-deep);
  outline: none;
}

.density-plot__action[aria-pressed="true"] {
  border-color: var(--book-primary);
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
}

.density-plot__action:disabled {
  cursor: default;
  opacity: 0.42;
}

.density-plot__controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.8rem 1.2rem;
  margin-bottom: 1rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius-sm);
  background: #f8f9fb;
}

.density-plot__control {
  display: grid;
  grid-template-columns: 2.3rem minmax(7rem, 1fr) 5.2rem;
  align-items: center;
  gap: 0.65rem;
}

.density-plot__control label {
  margin: 0;
  color: var(--book-ink);
  font-family: "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.density-plot__control input[type="range"] {
  width: 100%;
  accent-color: var(--book-primary);
}

.density-plot__control input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 0.34rem 0.4rem;
  border: 1px solid var(--book-border-strong);
  border-radius: 0.45rem;
  background: var(--book-surface);
  color: var(--book-ink);
  font: inherit;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.density-plot__control input:focus-visible {
  outline: 2px solid var(--book-primary-glow);
  outline-offset: 2px;
}

.density-plot__interval-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: -0.25rem 0 0.9rem;
  color: var(--book-ink-soft);
  font-size: 0.86rem;
}

.density-plot__interval-controls>span:first-child {
  margin-right: 0.15rem;
  color: var(--book-ink);
  font-weight: 700;
}

.density-plot__interval-controls input {
  width: 6.25rem;
  padding: 0.34rem 0.45rem;
  border: 1px solid var(--book-border-strong);
  border-radius: 0.45rem;
  background: var(--book-surface);
  color: var(--book-ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.density-plot__interval-controls input:focus-visible {
  border-color: var(--book-primary);
  outline: 2px solid var(--book-primary-glow);
  outline-offset: 1px;
}

.density-plot__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.density-plot__summary span {
  padding: 0.22rem 0.52rem;
  border: 1px solid var(--book-border);
  border-radius: 999px;
  background: var(--book-surface-soft);
  color: var(--book-ink-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.density-plot__summary strong {
  margin-right: 0.3rem;
  color: var(--book-ink);
}

.density-plot__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  min-height: 1.3rem;
  margin-bottom: 0.5rem;
  color: var(--book-muted);
  font-size: 0.75rem;
}

.density-plot__legend-item::before {
  display: inline-block;
  width: 1.25rem;
  margin-right: 0.35rem;
  border-top: 2px solid var(--density-curve);
  content: "";
  vertical-align: middle;
}

.density-plot__legend-item--1::before {
  border-color: #c26b4a;
}

.density-plot__legend-item--2::before {
  border-color: #65945f;
}

.density-plot__legend-item--3::before {
  border-color: #8c65ad;
}

.density-plot__chart {
  overflow: hidden;
  border: 1px solid #dfe3e9;
  border-radius: var(--book-radius-sm);
  background: #fff;
}

.density-plot__chart svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 17rem;
  max-height: 27rem;
  cursor: crosshair;
}

.density-plot__grid line {
  stroke: var(--density-grid);
  stroke-dasharray: 3 4;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.density-plot__grid text,
.density-plot__axes text {
  fill: var(--book-muted);
  font-family: var(--book-mono);
  font-size: 12px;
}

.density-plot__axes line {
  stroke: var(--density-axis);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}

.density-plot__area {
  fill: var(--density-area);
}

.density-plot__interval-band {
  fill: rgb(206 159 65 / 7%);
}

.density-plot__interval-area {
  fill: rgb(206 159 65 / 28%);
}

.density-plot__interval-boundary {
  stroke: #b48228;
  stroke-dasharray: 5 4;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.density-plot__curve {
  fill: none;
  stroke: var(--density-curve);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
  vector-effect: non-scaling-stroke;
}

.density-plot__curve--comparison {
  stroke: var(--comparison-color);
  stroke-dasharray: 7 4;
  stroke-width: 2.1;
}

.density-plot__probe {
  pointer-events: none;
}

.density-plot__probe-line {
  stroke: var(--book-muted);
  stroke-dasharray: 3 3;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.density-plot__probe-point {
  fill: var(--book-surface);
  stroke: var(--density-curve);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.density-plot__probe-label-bg {
  fill: rgb(255 255 255 / 94%);
  stroke: var(--book-border-strong);
  stroke-width: 1;
}

.density-plot__probe-label {
  fill: var(--book-ink);
  font-family: var(--book-mono);
  font-size: 11px;
}

.density-plot__status {
  margin-top: 0.7rem;
  color: var(--book-ink);
  font-size: 0.9rem;
  font-weight: 650;
}

.density-plot__status--error {
  color: #b42318;
}

.density-plot__note {
  min-height: 1.25rem;
  margin-top: 0.2rem;
  color: var(--book-muted);
  font-size: 0.8rem;
}

.quarto-dark .density-plot {
  --density-curve: #9bafe7;
  --density-area: rgb(155 175 231 / 12%);
  --density-grid: #3a4050;
  --density-axis: #aab2c2;
  background: var(--book-surface);
}

.quarto-dark .density-plot__controls,
.quarto-dark .density-plot__fixed-scale,
.quarto-dark .density-plot__summary span {
  border-color: var(--book-border);
  background: var(--book-surface-soft);
}

.quarto-dark .density-plot__action,
.quarto-dark .density-plot__reset,
.quarto-dark .density-plot__mode,
.quarto-dark .density-plot__interval-controls input {
  background: var(--book-surface-soft);
}

.quarto-dark .density-plot__interval-band {
  fill: rgb(231 183 87 / 9%);
}

.quarto-dark .density-plot__interval-area {
  fill: rgb(231 183 87 / 25%);
}

.quarto-dark .density-plot__fixed-scale {
  color: #b8c7ed;
}

.quarto-dark .density-plot__chart {
  border-color: var(--book-border);
  background: #171a21;
}

.quarto-dark .density-plot__probe-label-bg {
  fill: rgb(23 26 33 / 95%);
}

.quarto-dark .density-plot__status--error {
  color: #ff9b8f;
}

/* Responsive behavior */
@media (max-width: 1199.98px) {
  main.content {
    border-radius: 1.1rem;
  }

}

@media (max-width: 991.98px) {
  body {
    font-size: 16px;
    background: var(--book-bg);
  }

  main.content {
    margin-top: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1.8rem clamp(1rem, 4vw, 2.2rem);
    border-radius: 1rem;
  }

  .textbook-theme-toggle-floating {
    top: 0.61rem;
    right: 4rem;
  }

  .theorem-block,
  .proof-block,
  .algorithm-caption {
    padding: 1rem 1.05rem 1rem 1.2rem;
  }

  .algorithm-line {
    min-width: 28rem;
  }

  .glossary-entry {
    grid-template-columns: 1fr;
  }

  .home-intro {
    grid-template-columns: minmax(0, 1.45fr) minmax(13rem, 0.6fr);
  }

  .home-quote p {
    white-space: normal;
  }
}

@media (max-width: 767.98px) {
  .quarto-title-meta {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-intro {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .home-edition {
    min-height: 16rem;
    border-top: 1px solid var(--book-border);
    border-left: 0;
  }

  .home-edition-symbol {
    min-height: 8rem;
  }

  .home-quote p>span {
    white-space: normal;
  }

  .home-quicklinks {
    grid-template-columns: 1fr;
  }

  .home-quicklinks a+a {
    border-top: 1px solid var(--book-border);
    border-left: 0;
  }
}

@media (max-width: 575.98px) {
  main.content {
    margin-inline: 0.35rem;
    padding: 1.45rem 1rem;
    border-radius: 0.85rem;
  }

  h1,
  .quarto-title h1.title {
    font-size: 2rem;
  }

  h2 {
    margin-top: 2.8rem;
  }

  .quarto-title-meta {
    grid-template-columns: 1fr;
  }

  .textbook-theme-toggle-floating {
    right: 3.8rem;
  }

  .home-intro-copy {
    padding: 2.1rem 1.35rem 2.35rem;
  }

  .home-intro h1 {
    font-size: clamp(2.1rem, 11vw, 3rem);
  }

  .home-actions {
    display: grid;
  }

  .home-button {
    width: 100%;
  }

  .home-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .home-contact {
    margin-left: -0.3rem;
  }

  .computation-case {
    padding-bottom: 2rem;
  }

  .computation-result {
    padding-left: 0.8rem;
  }

  .textbook-back-to-top.btn {
    right: 0.85rem;
    bottom: 0.85rem;
  }

  .density-plot {
    padding: 1rem 0.75rem 0.85rem;
  }

  .density-plot__heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .density-plot__controls {
    grid-template-columns: 1fr;
  }

  .density-plot__chart svg {
    min-height: 14rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  body {
    background: #fff;
  }

  #quarto-header,
  #quarto-sidebar,
  #quarto-margin-sidebar,
  .textbook-theme-toggle,
  .textbook-back-to-top,
  .textbook-reading-progress {
    display: none !important;
  }

  main.content {
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .theorem-block,
  .proof-block,
  .algorithm-block {
    break-inside: avoid;
    box-shadow: none;
  }

  .density-plot__controls,
  .density-plot__interval-controls,
  .density-plot__heading-actions,
  .density-plot__reset,
  .density-plot__note,
  .display-math-copy-button {
    display: none !important;
  }
}

/* Project identity, status pages, and reading interactions */
.textbook-home {
  gap: 1.15rem;
}

.home-intro {
  min-height: min(48rem, calc(100vh - 8rem));
}

.home-proof-promise {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.2rem;
  align-items: center;
  padding: clamp(1.35rem, 3vw, 2rem);
  border: 1px solid rgb(82 100 154 / 24%);
  border-radius: var(--book-radius-lg);
  background:
    linear-gradient(135deg, rgb(82 100 154 / 10%), rgb(131 112 169 / 7%)),
    var(--book-surface);
  box-shadow: var(--book-shadow-sm);
}

.home-proof-promise__mark {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid rgb(82 100 154 / 24%);
  border-radius: 1rem;
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
  font-size: 1.45rem;
  box-shadow: var(--book-shadow-sm);
}

.home-proof-promise p:first-child,
.home-panel>header p,
.status-eyebrow,
.status-kicker {
  margin: 0 0 0.35rem;
  color: var(--book-primary);
  font-family: var(--book-mono);
  font-size: 0.67rem;
  font-weight: 760;
  letter-spacing: 0.13em;
}

.home-proof-promise h2,
.home-panel>header h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: clamp(1.15rem, 2vw, 1.42rem);
}

.home-proof-promise h2::after,
.home-panel>header h2::after {
  display: none;
}

.home-proof-promise p:last-child {
  max-width: 68rem;
  margin: 0.45rem 0 0;
  color: var(--book-ink-soft);
}

.home-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.home-panel {
  min-width: 0;
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius-lg);
  background: var(--book-surface);
  box-shadow: var(--book-shadow-sm);
}

.home-panel>header {
  margin-bottom: 1.2rem;
}

.home-panel-intro {
  margin: -0.45rem 0 1rem;
  color: var(--book-muted);
  font-size: 0.9rem;
}

.site-timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0;
}

.site-timeline>div {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius-sm);
  background: var(--book-surface-soft);
}

.site-timeline dt {
  margin-bottom: 0.28rem;
  color: var(--book-muted);
  font-size: 0.72rem;
}

.site-timeline dd {
  margin: 0;
  color: var(--book-ink);
  font-family: var(--book-mono);
  font-size: clamp(0.74rem, 1.25vw, 0.88rem);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.home-update-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.home-update-heading>a,
.home-section-link {
  color: var(--book-primary-deep);
  font-size: 0.76rem;
  font-weight: 680;
  text-decoration: none;
}

.home-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--book-teal);
  font-size: 0.76rem;
  font-weight: 720;
}

.home-live-badge i {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--book-teal);
  box-shadow: 0 0 0 0.28rem rgb(57 125 120 / 12%);
}

.home-commits {
  display: grid;
  gap: 0.48rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-commits li {
  min-width: 0;
}

.home-commits li>a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.62rem 0.72rem;
  border: 1px solid transparent;
  border-radius: var(--book-radius-sm);
  color: var(--book-ink-soft);
  text-decoration: none;
}

.home-commits li>a:hover {
  border-color: var(--book-border);
  background: var(--book-surface-soft);
}

.home-commits code {
  color: var(--book-primary-deep);
  font-size: 0.68rem;
}

.home-commits span {
  min-width: 0;
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-commits time {
  color: var(--book-faint);
  font-family: var(--book-mono);
  font-size: 0.66rem;
}

.project-snapshot {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.project-snapshot>div {
  display: grid;
  gap: 0.08rem;
  padding: 0.8rem 0.55rem;
  border-radius: var(--book-radius-sm);
  background: var(--book-primary-soft);
  text-align: center;
}

.project-snapshot strong {
  color: var(--book-primary-deep);
  font-family: var(--book-serif);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.project-snapshot span {
  color: var(--book-muted);
  font-size: 0.68rem;
}

.github-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.github-actions>a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  min-height: 3rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius-sm);
  background: var(--book-surface-soft);
  color: var(--book-ink-soft);
  font-size: 0.8rem;
  font-weight: 680;
  text-decoration: none;
}

.github-actions>a:hover {
  border-color: rgb(82 100 154 / 38%);
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
}

.github-actions>a .bi-arrow-up-right {
  color: var(--book-faint);
  font-size: 0.68rem;
}

/* Per-chapter progress */
.chapter-progress {
  position: sticky;
  top: 0.75rem;
  z-index: 8;
  margin: -0.25rem 0 2.4rem;
  padding: 1rem 1.1rem 1.05rem;
  border: 1px solid rgb(82 100 154 / 22%);
  border-radius: var(--book-radius);
  background: rgb(249 250 253 / 96%);
  box-shadow: var(--book-shadow-sm);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.chapter-progress__heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: baseline;
  margin-bottom: 0.72rem;
}

.chapter-progress__eyebrow {
  grid-column: 1 / -1;
  color: var(--book-primary);
  font-family: var(--book-mono);
  font-size: 0.62rem;
  font-weight: 760;
  letter-spacing: 0.1em;
}

.chapter-progress__label {
  color: var(--book-ink-soft);
  font-size: 0.8rem;
  font-weight: 650;
}

.chapter-progress__heading strong {
  color: var(--book-primary-deep);
  font-family: var(--book-mono);
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
}

.chapter-progress__heading a {
  grid-column: 1 / -1;
  color: var(--book-muted);
  font-size: 0.7rem;
  font-weight: 650;
  text-decoration: none;
}

.chapter-progress__track,
.status-progress-row__track {
  display: block;
  height: 0.55rem;
  border: 1px solid rgb(82 100 154 / 13%);
  border-radius: 999px;
  background: rgb(82 100 154 / 9%);
  overflow: hidden;
}

.chapter-progress__track>span,
.status-progress-row__track>i {
  display: block;
  width: var(--chapter-progress);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--book-primary), #7f79c9 60%, #a274ad);
  box-shadow: 0 0 1rem rgb(82 100 154 / 25%);
}

.chapter-progress--unset .chapter-progress__track,
.status-progress-row--unset .status-progress-row__track {
  background: repeating-linear-gradient(135deg,
      rgb(115 124 141 / 7%) 0,
      rgb(115 124 141 / 7%) 0.45rem,
      transparent 0.45rem,
      transparent 0.9rem);
}

.chapter-progress--unset .chapter-progress__heading strong,
.status-progress-row--unset>strong {
  color: var(--book-muted);
}

/* Project status */
.project-status-page,
.notation-page {
  --status-max-width: 74rem;
}

.status-hero,
.notation-hero {
  margin: -0.4rem 0 2.3rem;
  padding: 1.25rem 1.35rem;
  border-left: 3px solid var(--book-primary);
  border-radius: 0 var(--book-radius) var(--book-radius) 0;
  background: var(--book-primary-soft);
  color: var(--book-ink-soft);
}

.status-hero> :last-child,
.notation-hero> :last-child {
  margin-bottom: 0;
}

.status-section {
  margin-top: 3rem;
}

.project-status-page .site-timeline+.home-update-heading {
  margin-top: 1.35rem;
}

.status-section>h2,
.notation-section>h2,
.notation-section-title,
.notation-principles>h2 {
  margin-top: 0.25rem;
}

.status-progress-summary {
  display: inline-flex;
  margin: 0 0 1rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--book-primary-soft);
  color: var(--book-primary-deep);
  font-size: 0.76rem;
  font-weight: 680;
}

.status-progress-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.status-part {
  padding: 1rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  background: var(--book-surface-soft);
}

.status-part h2 {
  margin: 0 0 0.75rem;
  padding: 0 0 0.6rem;
  font-size: 1rem;
  letter-spacing: 0;
}

.status-part h2::after {
  width: 1.75rem;
}

.status-progress-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) minmax(5rem, 1.35fr) 3.2rem;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.45rem;
  border-radius: 0.42rem;
  color: var(--book-ink-soft);
  text-decoration: none;
}

.status-progress-row:hover {
  background: var(--book-surface);
}

.status-progress-row__title {
  min-width: 0;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-progress-row__track {
  height: 0.42rem;
}

.status-progress-row>strong {
  color: var(--book-primary-deep);
  font-family: var(--book-mono);
  font-size: 0.7rem;
  text-align: right;
}

.statistics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.statistic-card {
  display: flex;
  min-height: 6.2rem;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.9rem;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius-sm);
  background: var(--book-surface-soft);
}

.statistic-card span {
  color: var(--book-muted);
  font-size: 0.72rem;
}

.statistic-card strong {
  color: var(--book-primary-deep);
  font-family: var(--book-serif);
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
}

/* Notation catalog */
.notation-math-bootstrap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

h2.notation-section-title {
  margin-top: 2.4rem;
}

.notation-table-wrap {
  width: 100%;
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  box-shadow: var(--book-shadow-sm);
  overflow: auto;
  overscroll-behavior-inline: contain;
}

.notation-table {
  min-width: 62rem;
  margin: 0;
  border: 0;
}

.notation-table th:nth-child(1) {
  width: 19%;
}

.notation-table th:nth-child(2) {
  width: 25%;
}

.notation-table th:nth-child(3) {
  width: 34%;
}

.notation-table th:nth-child(4) {
  width: 22%;
}

.notation-table td {
  vertical-align: top;
  font-size: 0.8rem;
}

.notation-table td p {
  margin: 0.2rem 0 0;
  color: var(--book-ink-soft);
}

.notation-rendered {
  color: var(--book-primary-deep);
  font-weight: 680;
  text-align: center;
}

.notation-rendered mjx-container {
  display: block;
  font-size: 1.05rem;
}

.notation-source code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* Proof folding */
details.proof-block.proof-collapsible {
  padding: 0;
}

details.proof-block.proof-collapsible>.proof-summary {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.05rem 0.75rem 1.25rem;
  color: var(--book-ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 720;
  list-style: none;
  user-select: none;
}

details.proof-block.proof-collapsible>.proof-summary::-webkit-details-marker {
  display: none;
}

.proof-summary>span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.proof-summary .bi {
  color: var(--book-muted);
  transition: transform 160ms ease;
}

details.proof-block[open] .proof-summary .bi {
  transform: rotate(90deg);
}

.proof-summary small {
  color: var(--book-faint);
  font-size: 0.68rem;
  font-weight: 520;
}

.proof-content {
  padding: 0.15rem 1.35rem 1.15rem 1.5rem;
  border-top: 1px solid var(--book-border);
}

.proof-content>p:first-child>.proof-title:first-child {
  display: none;
}

.proof-content> :last-child {
  margin-bottom: 0;
}

.proof-controls {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 1.5rem 0 -0.9rem;
}

.proof-control {
  padding: 0.35rem 0.62rem;
  border: 1px solid var(--book-border);
  border-radius: 999px;
  background: var(--book-surface-soft);
  color: var(--book-muted);
  font-size: 0.68rem;
  font-weight: 650;
}

.proof-control:hover {
  border-color: rgb(82 100 154 / 35%);
  color: var(--book-primary-deep);
}

/* Cross-reference return state and target guidance */
a.textbook-cross-reference {
  border-radius: 0.2em;
  text-decoration-style: solid;
}

a.textbook-cross-reference.is-reference-visited {
  color: #7a568f;
  text-decoration-style: double;
  text-decoration-color: rgb(122 86 143 / 48%);
}

.is-reference-target {
  outline: 2px solid rgb(194 122 24 / 72%);
  outline-offset: 0.28rem;
  box-shadow: 0 0 0 0.55rem rgb(194 122 24 / 11%);
  scroll-margin-top: 6rem;
}

.reference-toast {
  position: fixed;
  z-index: 1090;
  top: 4.5rem;
  left: 50%;
  width: max-content;
  max-width: min(34rem, calc(100vw - 2rem));
  padding: 0.72rem 1rem;
  border: 1px solid rgb(194 122 24 / 35%);
  border-radius: 0.72rem;
  background: rgb(255 250 240 / 96%);
  color: #61451b;
  box-shadow: var(--book-shadow-lg);
  font-size: 0.82rem;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -0.6rem);
  transition: opacity 180ms ease, transform 180ms ease;
}

.reference-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.page-report-issue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: fit-content;
  margin: 3rem 0 1.1rem auto;
  padding: 0.55rem 0.78rem;
  border: 1px solid var(--book-border);
  border-radius: 0.55rem;
  background: var(--book-surface-soft);
  color: var(--book-muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-decoration: none;
}

.page-report-issue:hover {
  border-color: rgb(82 100 154 / 35%);
  color: var(--book-primary-deep);
}

/* Dark variants for new surfaces */
.quarto-dark .home-proof-promise {
  border-color: #3a4353;
  background:
    linear-gradient(135deg, rgb(74 84 112 / 36%), rgb(63 58 84 / 28%)),
    #202631;
  box-shadow: none;
}

.quarto-dark .home-proof-promise__mark {
  border-color: #46536b;
  background: #293244;
  color: #b6c3e5;
  box-shadow: none;
}

.quarto-dark .home-panel,
.quarto-dark .site-timeline>div,
.quarto-dark .status-part,
.quarto-dark .statistic-card,
.quarto-dark .github-actions>a,
.quarto-dark .chapter-progress,
.quarto-dark .page-report-issue,
.quarto-dark .proof-control {
  border-color: var(--book-border);
  background-color: var(--book-surface);
  box-shadow: none;
}

.quarto-dark a.textbook-cross-reference.is-reference-visited {
  color: #d5a6e3;
  text-decoration-color: rgb(213 166 227 / 55%);
}

.quarto-dark .is-reference-target {
  outline-color: rgb(239 183 95 / 78%);
  box-shadow: 0 0 0 0.55rem rgb(239 183 95 / 10%);
}

.quarto-dark .reference-toast {
  border-color: rgb(239 183 95 / 30%);
  background: rgb(43 38 29 / 96%);
  color: #f2cf92;
}

.quarto-dark .github-actions>a:hover,
.quarto-dark .page-report-issue:hover,
.quarto-dark .proof-control:hover {
  border-color: rgb(182 195 229 / 38%);
  background-color: var(--book-primary-soft);
  color: #b6c3e5;
}

@media (max-width: 991.98px) {
  html {
    scroll-padding-top: 8.5rem;
  }

  .chapter-progress {
    top: 3.85rem;
    z-index: 1020;
    margin: 0 0 1.65rem;
    padding: 0.68rem 0.82rem 0.72rem;
  }

  .chapter-progress__heading {
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .chapter-progress__eyebrow {
    display: none;
  }

  .chapter-progress__heading a {
    grid-column: auto;
    justify-self: end;
    white-space: nowrap;
  }

  .chapter-progress__track {
    height: 0.42rem;
  }

  .is-reference-target {
    scroll-margin-top: 8.5rem;
  }

  .home-overview,
  .status-progress-groups {
    grid-template-columns: 1fr;
  }

  .statistics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .home-proof-promise {
    grid-template-columns: 1fr;
  }

  .home-proof-promise__mark {
    width: 2.8rem;
    height: 2.8rem;
  }

  .site-timeline,
  .github-actions {
    grid-template-columns: 1fr;
  }

  .project-snapshot,
  .statistics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-progress-row {
    grid-template-columns: minmax(7rem, 1fr) 3rem;
  }

  .status-progress-row__track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .reference-toast {
    top: 4rem;
  }
}

@media (max-width: 575.98px) {
  .home-overview {
    gap: 0.75rem;
  }

  .home-panel,
  .home-proof-promise {
    padding: 1.05rem;
  }

  .home-commits li>a {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .home-commits time {
    display: none;
  }

  .project-snapshot {
    grid-template-columns: 1fr 1fr;
  }

  .proof-summary small {
    display: none;
  }

  .proof-controls {
    justify-content: stretch;
  }

  .proof-control {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-reference-target {
    transition: none !important;
  }

  .reference-toast {
    transform: translate(-50%, 0);
  }
}

@media print {

  .home-proof-promise,
  .home-panel,
  .chapter-progress,
  .status-part,
  .statistic-card,
  .notation-table-wrap {
    box-shadow: none !important;
  }

  .proof-controls,
  .proof-summary,
  .reference-toast,
  .page-report-issue {
    display: none !important;
  }

  details.proof-block:not([open])>.proof-content {
    display: block !important;
  }

  .proof-content>p:first-child>.proof-title:first-child {
    display: inline;
  }

  .notation-table-wrap {
    overflow: visible;
    border: 0;
  }

  .notation-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .notation-table th,
  .notation-table td {
    padding: 0.35rem;
    font-size: 7.5pt;
    overflow-wrap: anywhere;
  }

  .is-reference-target {
    outline: 0;
    box-shadow: none;
  }
}
