.textbook-lesson,
.textbook-catalog {
  --textbook-ink: #292722;
  --textbook-muted: #575955;
  --textbook-accent: #345973;
  --textbook-rule: #dcd8cf;
  --textbook-paper: #fdfcf8;
  --textbook-wash: #f2efe8;
  --textbook-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Heiti SC", sans-serif;
  --textbook-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif;
  color: var(--textbook-ink);
  font-family: var(--textbook-sans);
}

body:has(.textbook-lesson, .textbook-catalog) {
  background: #fdfcf8;
}

.textbook-lesson {
  width: min(49rem, calc(100% - 3rem));
  padding-block: 22px 64px;
}

.textbook-lesson .hand,
.textbook-lesson :is(button, summary),
.textbook-lesson :is(.depth-content h2, .depth-content h3, .map-branch > summary) {
  font-family: var(--textbook-sans);
}

.textbook-masthead {
  margin-bottom: 20px;
}

.textbook-context {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  column-gap: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--textbook-rule);
  font-size: 13px;
  color: var(--textbook-muted);
}

.textbook-lesson .lesson-back {
  min-height: 42px;
  margin: 0;
  color: var(--textbook-accent);
}

.textbook-context p {
  margin: 0;
}

.textbook-chapter {
  margin: 0 0 8px;
  color: var(--textbook-muted);
  font-size: 13px;
  line-height: 1.65;
}

.textbook-chapter span {
  margin-inline-start: .4em;
}

.textbook-lesson .lesson-heading {
  align-items: baseline;
  margin: 0 0 10px;
}

.textbook-lesson .lesson-heading h1 {
  margin: 0;
  font: 650 clamp(26px, 4.4vw, 36px)/1.4 var(--textbook-sans);
  letter-spacing: normal;
  color: var(--textbook-ink);
  overflow-wrap: anywhere;
}

.textbook-section-number {
  margin-inline-end: .14em;
  color: var(--textbook-ink);
  font-variant-numeric: lining-nums tabular-nums;
}

.textbook-lesson .textbook-favorite {
  flex: none;
  min-height: 38px;
  margin: 0;
  padding: 4px 12px;
  border: 1px solid var(--textbook-rule);
  border-radius: 2px;
  color: var(--textbook-accent);
  background: transparent;
  font-size: 13px;
}

.textbook-lesson .textbook-favorite:hover,
.textbook-lesson .textbook-favorite[aria-pressed="true"] {
  background: var(--textbook-wash);
}

.textbook-location {
  font-size: 12px;
  line-height: 1.75;
  color: var(--textbook-muted);
}

.lesson-tabs-shell {
  scroll-margin-top: var(--site-header-height);
}

.textbook-lesson .lesson-tabs {
  padding-top: 0;
  gap: clamp(14px, 4vw, 36px);
  background: var(--textbook-paper);
  border-color: var(--textbook-rule);
}

.textbook-lesson .lesson-tabs button {
  min-height: 46px;
  padding: 10px 1px;
  color: var(--textbook-muted);
  line-height: 1.35;
  font-size: 14px;
}

.textbook-lesson .lesson-tabs button[aria-selected="true"] {
  color: var(--textbook-accent);
  border-bottom-color: var(--textbook-accent);
  font-weight: 700;
}

.textbook-lesson [data-lesson-panel] {
  padding-top: 24px;
}

.textbook-opening {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 42px);
}

.textbook-figure {
  margin: 0;
  min-width: 0;
}

.textbook-figure svg {
  display: block;
  width: 100%;
  height: auto;
}

.textbook-figure text {
  fill: var(--textbook-ink);
  font: 17px Georgia, var(--textbook-serif);
}

.textbook-figure :is(.diagram-axis, .diagram-outline, .diagram-grid, .diagram-guide, .diagram-curve, .diagram-secondary) {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.textbook-figure :is(.diagram-axis, .diagram-outline) {
  stroke: #54534e;
  stroke-width: 1.4;
}

.textbook-figure .diagram-guide {
  stroke: #737c84;
  stroke-width: 1.2;
  stroke-dasharray: 4 4;
}

.textbook-figure .diagram-grid {
  stroke: #8ba0ad;
  stroke-width: 1;
}

.textbook-figure .diagram-curve {
  stroke: var(--textbook-accent);
  stroke-width: 2;
}

.textbook-figure .diagram-secondary {
  stroke: #736351;
  stroke-width: 1.7;
  stroke-dasharray: 5 4;
}

.textbook-figure .diagram-region {
  fill: #7cacc938;
  stroke: var(--textbook-accent);
  stroke-width: 1.5;
}

.textbook-figure .diagram-fill {
  fill: #e8edf1;
}

.textbook-figure .diagram-point {
  fill: var(--textbook-accent);
}

.textbook-figure .diagram-open {
  fill: var(--textbook-paper);
  stroke: var(--textbook-accent);
  stroke-width: 1.7;
}

.textbook-figure figcaption {
  color: var(--textbook-muted);
  font: 400 13px/1.75 var(--textbook-sans);
}

.textbook-figure figcaption b {
  margin-inline-end: .4em;
  color: var(--textbook-accent);
  white-space: nowrap;
}

.textbook-lesson :is(.textbook-section, .homework-panel, .lesson-exams, .chapter-map) {
  color: var(--textbook-ink);
  font-family: var(--textbook-serif);
  font-size: clamp(17px, 1.5vw, 18px);
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.textbook-lesson .textbook-section {
  margin: 0 0 38px;
  scroll-margin-top: calc(var(--site-header-height) + 64px);
}

.textbook-lesson .deep-definitions {
  scroll-margin-top: calc(var(--site-header-height) + 64px);
}

.textbook-lesson .textbook-section h2 {
  margin: 0 0 10px;
  color: var(--textbook-ink);
  font: 650 21px/1.5 var(--textbook-sans);
}

.textbook-lesson .textbook-section h3 {
  margin: 0 0 6px;
  color: var(--textbook-ink);
  font: 700 17px/1.6 var(--textbook-sans);
}

.textbook-lesson .textbook-section p {
  margin: 0 0 .75em;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.textbook-opening p {
  text-indent: 2em;
}

.textbook-lesson .textbook-section ol,
.textbook-lesson .textbook-section ul {
  padding-inline-start: 1.55em;
  margin: .5em 0 .9em;
}

.textbook-lesson .textbook-section li + li {
  margin-top: .5em;
}

.textbook-lesson .depth-definition {
  display: flow-root;
  margin: 0;
  padding: 0 0 14px;
  border: 0;
}

.textbook-lesson .depth-definition + .depth-definition {
  margin-top: 22px;
}

.textbook-lesson .depth-definition h3 {
  display: block;
}

.textbook-lesson .definition-parts {
  margin: 8px 0 12px;
}

.textbook-lesson .definition-parts > div {
  display: grid;
  grid-template-columns: 4em minmax(0, 1fr);
  gap: .45em;
  padding-block: 3px;
}

.textbook-lesson .definition-parts dt {
  font: 600 15px/2.12 var(--textbook-sans);
  color: var(--textbook-accent);
}

.textbook-lesson .definition-parts dd {
  margin: 0;
}

.textbook-lesson .depth-definition .depth-conditions {
  margin: 10px 0 0;
  padding: 0;
  border: 0;
}

.textbook-lesson .textbook-section .depth-conditions b {
  color: var(--textbook-muted);
  font: 700 14px/1.6 var(--textbook-sans);
}

.textbook-lesson .depth-conditions ul {
  margin-block: 3px 0;
}

.textbook-lesson .depth-conditions li {
  color: var(--textbook-ink);
  font-size: 16px;
  line-height: 1.8;
}

.textbook-lesson .depth-formula {
  padding: 8px 2px 12px;
  font-size: clamp(15px, 1.6vw, 19px);
  color: var(--textbook-ink);
  line-height: 1.45;
}

.textbook-lesson .concept-compare {
  margin: 18px 0 0;
  padding: 12px 0 8px;
  background: transparent;
  border-color: var(--textbook-rule);
}

.textbook-lesson .concept-compare h4 {
  font: 700 16px/1.5 var(--textbook-sans);
  color: var(--textbook-accent);
}

.textbook-lesson .concept-compare :is(.compare-context, .compare-takeaway, .compare-note, dd p) {
  font: 400 16px/1.8 var(--textbook-serif);
  color: var(--textbook-ink);
}

.textbook-lesson .concept-compare :is(dl, .compare-row, .compare-check) {
  border-color: var(--textbook-rule);
}

.textbook-lesson .compare-row dt {
  color: var(--textbook-accent);
}

.textbook-lesson .textbook-example {
  display: grid;
  grid-template-columns: 2.8em minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  padding: 15px 0 4px;
  border-top: 1px solid var(--textbook-rule);
}

.textbook-lesson .textbook-example h2 {
  font-size: 16px;
  color: var(--textbook-accent);
}

.textbook-lesson .textbook-problem {
  font-weight: 700;
}

.textbook-example-solution strong {
  color: var(--textbook-accent);
}

.textbook-example-solution > .depth-formula {
  display: flex;
  justify-content: safe center;
}

.textbook-example-solution .depth-formula > .katex {
  flex: none;
}

.textbook-lesson .textbook-counterexamples :is(dt, dd) {
  margin: 0;
}

.textbook-counterexamples dt {
  font-weight: 700;
}

.textbook-counterexamples > div + div {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--textbook-rule);
}

.textbook-note {
  padding-top: 14px;
  border-top: 1px solid var(--textbook-rule);
}

.textbook-lesson :is(.lesson-extra, .bridge) {
  border-color: var(--textbook-rule);
  color: var(--textbook-ink);
}

.textbook-lesson .lesson-extra {
  padding: 4px 0;
}

.textbook-lesson .lesson-extra > summary {
  min-height: 42px;
  padding: 8px 0;
  font-size: 15px;
  color: var(--textbook-accent);
}

.textbook-lesson .lesson-extra[open] > summary {
  margin-bottom: 6px;
}

.textbook-lesson .textbook-visual {
  margin-top: 10px;
}

.textbook-lesson .textbook-visual .learning-paper {
  margin: 0 0 16px;
  padding: clamp(10px, 2.2vw, 18px);
  min-width: 0;
  background: var(--textbook-paper);
  border: 1px solid var(--textbook-rule);
  box-shadow: none;
}

.textbook-lesson .textbook-observations strong {
  font-family: var(--textbook-sans);
  color: var(--textbook-accent);
}

.textbook-lesson .textbook-practice-link {
  padding: 8px 0;
  min-height: 44px;
  font-size: 14px;
  color: var(--textbook-accent);
}

.textbook-lesson .textbook-practice-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.textbook-lesson .lesson-bottom {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--textbook-rule);
}

.textbook-lesson .chapter-finish {
  font-size: 16px;
  color: var(--textbook-accent);
}

.textbook-lesson :is(.lesson-sequence, .point-sequence) {
  flex-wrap: wrap;
  border-color: var(--textbook-rule);
}

.textbook-lesson :is(.lesson-sequence, .point-sequence) > a {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--textbook-accent);
}

.textbook-lesson :is(.panel-heading h2, .quiz h3, .depth-content h2, .depth-content h3, .exam-question-heading h3) {
  font-weight: 700;
  color: var(--textbook-accent);
}

.textbook-lesson :is(.homework-panel .depth-content h2, .exam-question-heading h3, .panel-heading h2) {
  font-size: clamp(20px, 2.6vw, 25px);
}

.textbook-lesson :is(.quiz, .depth-content, .lesson-exams) :is(p, li, .quiz-option) {
  line-height: 1.85;
}

.textbook-lesson .point-start {
  font: 400 13px/1.7 var(--textbook-sans);
  color: var(--textbook-accent);
}

.textbook-lesson .point-start:empty {
  margin: 0;
}

.textbook-catalog {
  max-width: 55rem;
  margin-inline: auto;
}

.textbook-catalog .catalog-level-heading h2 {
  margin: 0;
  color: var(--textbook-ink);
  font: 700 clamp(24px, 3.2vw, 32px)/1.4 var(--textbook-sans);
}

.textbook-catalog .catalog-level-heading p {
  color: var(--textbook-muted);
  font: 400 16px/1.85 var(--textbook-serif);
}

.textbook-catalog :is(.catalog-back, .catalog-secondary) {
  color: var(--textbook-accent);
}

.textbook-contents {
  margin: 0 0 32px;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--textbook-rule);
}

.textbook-contents-row {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) minmax(8rem, 9.5rem) 5.5rem;
  align-items: center;
  gap: 16px;
  padding: 6px 8px;
  border-top: 1px solid var(--textbook-rule);
  color: var(--textbook-ink);
}

.textbook-contents-row:hover {
  background: var(--textbook-wash);
}

.textbook-contents-row .catalog-number {
  font: 600 14px/1.5 var(--textbook-sans);
  color: var(--textbook-accent);
  font-variant-numeric: tabular-nums;
}

.textbook-contents-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.textbook-contents-figure {
  min-width: 0;
}

.textbook-contents-figure .catalog-cover {
  max-width: 100%;
  height: auto;
}

.textbook-contents-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  column-gap: 8px;
  color: var(--textbook-muted);
  font-size: 13px;
  line-height: 1.6;
}

.textbook-contents-meta span {
  white-space: nowrap;
}

.textbook-lesson :is(a, button, summary, [tabindex]):focus-visible,
.textbook-catalog a:focus-visible {
  outline: 2px solid var(--textbook-accent);
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .textbook-lesson {
    width: calc(100% - 2rem);
    padding-top: 8px;
  }

  .textbook-context {
    margin-bottom: 17px;
    font-size: 11px;
  }

  .textbook-lesson .lesson-heading {
    gap: 6px 12px;
    flex-wrap: wrap;
  }

  .textbook-lesson .lesson-heading h1 {
    flex: 1 1 200px;
  }

  .textbook-lesson .textbook-favorite {
    min-height: 34px;
    padding-inline: 8px;
    font-size: 12px;
  }

  .textbook-masthead {
    margin-bottom: 16px;
  }

  .textbook-lesson .lesson-tabs {
    gap: 8px;
  }

  .textbook-opening {
    display: block;
  }

  .textbook-figure {
    max-width: 24rem;
    margin: 10px auto 0;
  }

  .textbook-lesson .textbook-section {
    margin-bottom: 30px;
  }

  .textbook-lesson .textbook-section h3 {
    font-size: 16px;
  }

  .textbook-lesson .textbook-example {
    display: block;
  }

  .textbook-catalog .catalog-level-heading {
    display: block;
  }

  .textbook-catalog :is(.catalog-back, .catalog-secondary) {
    display: inline-block;
    margin-top: 8px;
  }

  .textbook-catalog .catalog-level-heading p {
    font-size: 15px;
  }

  .textbook-contents-row {
    grid-template-columns: 3.4rem minmax(0, 1fr) 4.8rem;
    grid-template-areas: "number title figure" "number meta figure";
    gap: 2px 8px;
    padding: 8px 2px;
  }

  .textbook-contents-row .catalog-number {
    grid-area: number;
  }

  .textbook-contents-figure {
    grid-area: figure;
  }

  .textbook-contents-row .catalog-number,
  .textbook-contents-meta {
    font-size: 12px;
  }

  .textbook-contents-meta {
    grid-area: meta;
    justify-content: start;
  }

  .textbook-contents-title {
    grid-area: title;
    font-size: 15px;
  }
}
