:root {
  --font-latex-serif: "Latin Modern Roman", "CMU Serif", "Computer Modern Serif", "Times New Roman", serif;
  --bg-top: #f3f8f5;
  --bg-bottom: #fffaf2;
  --panel: rgba(255, 255, 255, 0.85);
  --ink: #122432;
  --ink-soft: #325063;
  --accent: #8daf9c;
  --accent-strong: #5d7b6d;
  --line: #d7e2dc;
  --shadow: 0 14px 32px rgba(14, 39, 56, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  color: var(--ink);
  font-family: var(--font-latex-serif);
  line-height: 1.65;
  background:
    radial-gradient(circle at 0% 0%, rgba(141, 175, 156, 0.24), transparent 36%),
    radial-gradient(circle at 100% 20%, rgba(250, 200, 98, 0.16), transparent 34%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(18, 36, 50, 0.1);
  background: rgba(247, 252, 248, 0.82);
}

.header-inner {
  width: min(1200px, calc(100% - 2.2rem));
  margin: 0 auto;
  padding: 1rem 0 0.9rem;
}

.site-title {
  margin: 0;
  font-family: var(--font-latex-serif);
  font-size: clamp(1.05rem, 1.2vw + 0.8rem, 1.6rem);
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: #2a4a40;
}

.site-subtitle {
  margin: 0.28rem 0 0;
  font-family: var(--font-latex-serif);
  font-size: clamp(0.9rem, 0.45vw + 0.78rem, 1.02rem);
  line-height: 1.2;
  color: #35584c;
}

.site-subtitle a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.14s ease, border-color 0.14s ease;
}

.site-subtitle a:hover,
.site-subtitle a:focus-visible {
  color: #1f3c34;
  border-bottom-color: rgba(42, 74, 64, 0.45);
}

.chapter-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding-bottom: 0.2rem;
  overflow-x: auto;
}

.chapter-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.38rem 0.78rem;
  font-family: var(--font-latex-serif);
  font-size: 0.85rem;
  font-weight: 600;
  color: #365a4f;
  transition: transform 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.chapter-nav a:hover {
  transform: translateY(-1px);
  background: #edf5f0;
}

.chapter-nav a.active,
.chapter-nav a.home-link {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgba(141, 175, 156, 0.2);
}

.page-main {
  width: min(960px, calc(100% - 2.2rem));
  margin: 1.35rem auto 2.4rem;
  background: var(--panel);
  border: 1px solid rgba(42, 74, 64, 0.1);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2vw, 2rem);
}

.page-main > :first-child {
  margin-top: 0;
}

.chapter-title-block {
  margin: 0 0 1.2rem;
  padding: 0.1rem 0 0.85rem;
  border-bottom: 1px solid var(--line);
}

.chapter-number {
  margin: 0;
  font-family: var(--font-latex-serif);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #45685c;
}

.chapter-main-title {
  margin: 0.22rem 0 0;
  font-size: clamp(1.85rem, 2.8vw, 2.6rem);
  line-height: 1.2;
}

h1,
h2,
h3,
h4 {
  color: #2a4a40;
  line-height: 1.3;
}

h1,
h2 {
  font-family: var(--font-latex-serif);
}

.page-main h1:not(.chapter-main-title):not(.site-title) {
  font-size: clamp(1.3rem, 1.05vw + 1rem, 1.72rem);
}

.page-main h2 {
  font-size: clamp(1.16rem, 0.78vw + 0.94rem, 1.46rem);
}

h3,
h4 {
  font-family: var(--font-latex-serif);
  font-size: 1.05rem;
}

.page-main h3 {
  font-size: clamp(1.05rem, 0.45vw + 0.94rem, 1.2rem);
}

.page-main h4 {
  font-size: clamp(0.98rem, 0.3vw + 0.9rem, 1.08rem);
}

.section-number {
  font-weight: 700;
  color: #35584c;
  margin-right: 0.38rem;
}

a {
  color: #3f6d63;
}

a:hover {
  color: #2f564e;
}

p,
li,
blockquote,
figcaption,
td,
th {
  font-size: 1.04rem;
}

blockquote {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  border-left: 4px solid rgba(93, 123, 109, 0.55);
  background: rgba(141, 175, 156, 0.14);
}

figure {
  margin: 1.25rem auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #ffffff;
}

figure > figure {
  margin: 0.4rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem;
  background: #ffffff;
  display: inline-block;
  vertical-align: top;
  width: min(100%, calc(50% - 0.85rem));
}

figure > figure:only-of-type {
  width: 100%;
}

figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
}

figure > figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.97rem;
}

figcaption {
  margin-top: 0.65rem;
  color: var(--ink-soft);
}

figure[data-figure-number] > figcaption::before {
  content: "Figure " var(--figure-number) ". ";
  font-weight: 700;
  color: #2a4a40;
}

.math.display.numbered-equation {
  position: relative;
  display: block;
  padding-right: 6rem;
}

.math.display.numbered-equation .equation-number {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  color: #2a4a40;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1;
}

table {
  width: fit-content;
  max-width: 100%;
  border-collapse: collapse;
  margin: 1.05rem auto;
  overflow-x: auto;
  display: block;
}

table > caption {
  caption-side: top;
  margin: 0 auto 0.55rem;
  text-align: left;
  color: var(--ink-soft);
}

table[data-table-number] > caption::before {
  content: "Table " var(--table-number) ". ";
  font-weight: 700;
  color: #2a4a40;
}

figure > table[data-table-number] + figcaption[data-table-number]::before {
  content: "Table " attr(data-table-number) ". ";
  font-weight: 700;
  color: #2a4a40;
}

table[data-table-number] + figcaption[data-table-number]::before {
  content: "Table " attr(data-table-number) ". ";
  font-weight: 700;
  color: #2a4a40;
}

th,
td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
}

th {
  background: #f2f7f3;
  font-family: var(--font-latex-serif);
}

.frontmatter-content {
  margin-top: 1rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.frontmatter-content #title-block-header {
  margin: 0 0 1.1rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.frontmatter-content #title-block-header .title {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  line-height: 1.2;
}

.frontmatter-content .author,
.frontmatter-content .date {
  margin: 0.35rem 0;
  color: var(--ink-soft);
}

.frontmatter-content .author {
  margin-top: 0.6rem;
}

.frontmatter-content .date {
  font-family: var(--font-latex-serif);
  font-weight: 600;
}

.frontmatter-content .abstract {
  margin-top: 0.95rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(93, 123, 109, 0.28);
  border-left: 5px solid rgba(93, 123, 109, 0.65);
  border-radius: 10px;
  background: rgba(141, 175, 156, 0.1);
}

.frontmatter-content .abstract-title {
  margin-bottom: 0.55rem;
  font-family: var(--font-latex-serif);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3a6054;
}

.frontmatter-content h1.unnumbered {
  margin: 1.35rem 0 0.8rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.22rem;
}

.frontmatter-content .declaration-signoff {
  margin-top: 1.05rem;
  padding-top: 0.8rem;
  border-top: 1px dashed rgba(42, 74, 64, 0.35);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-latex-serif);
  font-size: 0.97rem;
  font-weight: 600;
}

.frontmatter-content .signoff-name {
  color: #2f5045;
}

.frontmatter-content .signoff-date {
  white-space: nowrap;
  color: #3d6357;
}

.chapter-list-title {
  margin-top: 1.6rem;
  margin-bottom: 0.75rem;
}

.chapter-list {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.chapter-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  background: #ffffff;
  font-family: var(--font-latex-serif);
  font-weight: 600;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.chapter-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(17, 42, 58, 0.12);
}

.lead {
  font-size: 1.1rem;
  color: #365c50;
}

.pager {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
}

.pager-link {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  background: #fff;
  font-family: var(--font-latex-serif);
  font-size: 0.9rem;
  font-weight: 600;
}

.pager-link:hover {
  border-color: var(--accent);
}

.references-title {
  margin-top: 2.4rem;
  margin-bottom: 0.8rem;
  padding-top: 0.9rem;
  border-top: 2px solid var(--line);
}

#refs.references {
  margin-top: 0.2rem;
}

#refs .csl-entry {
  margin: 0 0 0.9rem;
  padding: 0.35rem 0 0.8rem;
  border-bottom: 1px dashed rgba(42, 74, 64, 0.28);
}

#refs .csl-entry:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

@media (max-width: 760px) {
  .page-main {
    margin-top: 1rem;
    border-radius: 14px;
    padding: 0.9rem;
  }

  figure > figure {
    display: block;
    width: 100%;
    margin: 0.5rem 0;
  }

  p,
  li,
  blockquote,
  figcaption,
  td,
  th {
    font-size: 1rem;
  }

  .chapter-nav {
    gap: 0.25rem;
  }

  .chapter-nav a {
    font-size: 0.78rem;
    padding: 0.34rem 0.58rem;
  }

  .frontmatter-content .abstract {
    padding: 0.8rem;
  }

  .frontmatter-content .declaration-signoff {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}
