:root {
  color-scheme: light;
  --paper: #f8f7f2;
  --ink: #212722;
  --muted: #4d574e;
  --green: #194833;
  --green-dark: #13392a;
  --line: #d5d8ce;
  --soft: #e9eee3;
  --white: #fffef9;
  --serif: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 16px/1.85 var(--sans); }
h1, h2, h3, p, figure { margin: 0; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.22; }
h1 { font-size: clamp(3rem, 5.9vw, 5.5rem); letter-spacing: -.035em; }
h2 { font-size: clamp(2rem, 3.3vw, 3.1rem); color: var(--green-dark); }
h3 { font-size: clamp(1.4rem, 2.3vw, 1.98rem); color: var(--green-dark); }
h4 { margin: 24px 0 8px; font-size: 1.05rem; line-height: 1.6; }
p + p { margin-top: 12px; }
strong { font-weight: 650; }
a { color: var(--green); text-underline-offset: .24em; }
a:hover { color: var(--green-dark); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid #815320; outline-offset: 4px; }
:target { scroll-margin-top: 90px; }
.skip { position: fixed; top: 8px; left: 8px; z-index: 5; transform: translateY(-200%); background: var(--white); padding: 6px 12px; }
.skip:focus { transform: none; }
.top { position: sticky; z-index: 3; top: 0; background: var(--paper); border-bottom: 1px solid #bfc6b9; }
.bar { max-width: 1560px; min-height: 70px; padding: 10px clamp(20px, 3.3vw, 54px); margin: auto; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; font: 700 clamp(1.2rem, 2.5vw, 2rem)/1.2 var(--serif); white-space: nowrap; }
.brand svg { width: 38px; height: 34px; color: var(--green); flex: none; }
.button { display: inline-flex; justify-content: center; align-items: center; border: 1px solid var(--green); border-radius: 6px; background: transparent; padding: 8px 16px; color: var(--green-dark); font: 600 .92rem/1.45 var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.button:hover { background: var(--soft); }
.primary, .primary:hover { background: var(--green); color: #fff; }
.primary:hover { background: var(--green-dark); }
.layout { display: grid; grid-template-columns: minmax(165px, .215fr) minmax(0, 1fr); gap: clamp(24px, 2.6vw, 40px); max-width: 1560px; padding: 34px clamp(20px, 2.25vw, 36px) 90px; margin: auto; }
aside { border-right: 1px solid var(--line); padding-right: 19px; min-width: 0; }
.contents { position: sticky; top: 107px; }
.contents h2 { font-size: 1.85rem; padding: 5px 12px 16px; }
.contents ul { list-style: none; padding: 0; margin: 0; }
.contents li { border-top: 1px solid var(--line); }
.contents li:last-child { border-bottom: 1px solid var(--line); }
.contents a { display: block; text-decoration: none; color: var(--ink); font: 600 1.13rem/1.4 var(--serif); padding: 14px 10px; border-left: 4px solid transparent; }
.contents a:hover { background: #f0f1e9; }
.contents a[aria-current] { border-left-color: var(--green); background: var(--soft); color: var(--green-dark); }
main { min-width: 0; }
.hero { display: grid; grid-template-columns: 1fr 1.08fr; align-items: center; gap: clamp(20px, 2.7vw, 42px); padding: 8px 0 32px; min-height: 304px; }
.hero p { margin: 17px 0 23px; max-width: 31em; color: var(--ink); font: 600 clamp(1.06rem, 1.69vw, 1.45rem)/1.64 var(--serif); }
.hero .primary { padding: 12px 21px; font: 700 clamp(1rem, 1.65vw, 1.42rem)/1.45 var(--serif); }
.hero canvas { display: block; width: 100%; height: clamp(180px, 20vw, 280px); }
.chapter { padding: 50px 0 54px; border-bottom: 1px solid #bfc6b9; }
.chapter > header { margin-bottom: 29px; }
.chapter > header p { margin-top: 12px; font-size: 1.04rem; }
.reading { max-width: 820px; }
.lesson { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--line); }
.lesson > h3 { margin-bottom: 15px; }
.lesson p { margin: 11px 0; }
.lesson + .lesson { margin-top: 44px; }
.subnav { display: flex; flex-wrap: wrap; gap: 7px 18px; margin: 16px 0 0; padding: 0; list-style: none; font-size: .9rem; }
.flow { display: inline-block; padding: 5px 13px; margin-top: 14px; background: var(--soft); border-radius: 5px; color: var(--green-dark); font-weight: 650; }
.formula { margin-block: 13px; padding: 10px 14px; overflow-x: auto; background: var(--soft); border-radius: 6px; font-size: 1.12rem; }
.formula math { display: block; width: max-content; min-width: 0; margin: 5px auto; }
.formula math + math { margin-top: 11px; }
math { font-size: 1.05em; }
math[display="block"] { min-width: max-content; }
.note { margin: 16px 0; padding: 10px 14px; border-left: 3px solid #7f9c79; background: #efefe6; }
.note p { margin: 0; }
.note p + p { margin-top: 8px; }
.content-list, .steps { padding-left: 1.5em; }
.content-list li, .steps li { margin-block: 7px; }
.steps li::marker { color: var(--green); font-weight: 650; }
.table-wrap { overflow-x: auto; margin: 15px 0; }
table { width: 100%; min-width: 465px; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--soft); color: var(--green-dark); }
tbody th { background: transparent; }
.example { margin: 23px 0; padding: 5px 16px 12px; border-left: 3px solid #a38b58; background: #f4f0e5; }
.example h4 { margin-top: 9px; color: #46391c; }
details { margin: 11px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
details > summary { padding: 11px 14px; cursor: pointer; font-weight: 600; color: var(--green-dark); }
details > summary:hover { background: var(--soft); }
details > div { padding: 1px 15px 13px; }
details > div > p:first-child { margin-top: 0; }
.lab { margin: 22px 0; padding: 15px; background: var(--white); border: 1px solid var(--line); border-radius: 7px; min-width: 0; }
.lab h4 { margin-top: 0; }
.lab canvas { display: block; width: 100%; height: clamp(175px, 30vw, 248px); }
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 9px 22px; margin: 12px 0; }
.controls label { display: grid; gap: 3px; flex: 1 1 145px; min-width: 0; font-size: .88rem; font-weight: 600; line-height: 1.5; }
.controls select { width: 100%; min-height: 32px; padding: 3px 6px; font: inherit; background: var(--paper); color: var(--ink); border: 1px solid #929e92; border-radius: 4px; }
.controls input[type="range"] { width: 100%; margin: 0; min-height: 32px; accent-color: var(--green); }
output { font-variant-numeric: tabular-nums; }
.lab figcaption { color: var(--muted); font-size: .88rem; line-height: 1.65; }
.lab .reading-output { font-weight: 600; color: var(--green-dark); }
.legend { display: flex; flex-wrap: wrap; gap: 3px 15px; margin: 6px 0; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 19px; border-top: 3px solid var(--swatch, var(--green)); }
.legend .dashed::before { border-top-style: dashed; }
.sources { padding-top: 29px; color: var(--muted); font-size: .9rem; }
.sources h2 { font-size: 1.45rem; }
.sources ul { padding-left: 1.3em; margin: 9px 0; }
.sources a { overflow-wrap: anywhere; }
@media (max-width: 870px) {
  .layout { display: block; padding-top: 12px; }
  aside { border: 0; padding: 0; margin-bottom: 14px; }
  .contents { position: static; }
  .contents h2 { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; padding: 0; }
  .contents ul { display: flex; flex-wrap: wrap; gap: 3px 7px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .contents li, .contents li:last-child { border: 0; }
  .contents a { font: 600 .88rem/1.4 var(--sans); padding: 7px 5px; border-left-width: 3px; }
  .bar { min-height: 60px; }
  :target { scroll-margin-top: 74px; }
}
@media (max-width: 580px) {
  body { font-size: 15.5px; }
  .layout { padding-inline: 18px; }
  .bar { padding-inline: 18px; }
  .brand { gap: 7px; }
  .brand svg { width: 28px; }
  .button { padding: 6px 9px; }
  .hero { grid-template-columns: 1fr; gap: 6px; padding: 12px 0 12px; }
  .hero canvas { height: 160px; }
  .hero p { margin: 11px 0 17px; }
  .chapter { padding: 36px 0; }
  .formula { padding-inline: 9px; font-size: .97rem; }
  .lab { padding: 10px; }
}
@page { size: A4; margin: 16mm; }
@media print {
  :root { --paper: #fff; }
  body { font-size: 10.5pt; line-height: 1.65; }
  .top, aside, .skip, .hero .primary, .hero canvas, .controls, .subnav { display: none; }
  .layout { display: block; max-width: none; padding: 0; }
  .hero { display: block; min-height: 0; padding: 0 0 14px; }
  h1 { font-size: 29pt; }
  h2 { font-size: 23pt; }
  h3 { font-size: 16pt; }
  h2, h3, h4, summary { break-after: avoid; }
  .chapter { padding: 20px 0; }
  .lesson { padding-top: 16px; margin-top: 20px; }
  .lab, .formula, tr { break-inside: avoid; }
  .formula { overflow: visible; background: #f0f1eb; }
  a { color: inherit; text-decoration: none; }
}

.chapter > header h1 {
  max-width: 820px;
  font-size: clamp(2.2rem, 4.4vw, 3.75rem);
  letter-spacing: -.025em;
  color: var(--green-dark);
}
.chapter > header h1 + p { margin-top: 15px; }
.chapter .lesson > h2 {
  margin-bottom: 15px;
  font-size: clamp(1.4rem, 2.3vw, 1.98rem);
}
.chapter .lesson h3 {
  margin: 24px 0 8px;
  font: 650 1.05rem/1.5 var(--sans);
  color: var(--ink);
}
.chapter .example h3 { margin-top: 9px; color: #46391c; }
.chapter { padding-top: 8px; }
.index-section { border-block: 1px solid #bfc6b9; padding-top: 24px; max-width: 960px; }
.index-section h2 { font-size: clamp(1.65rem, 2.55vw, 2.2rem); }
.index-chapters { list-style: none; margin: 0; padding: 0; }
.index-chapters > li { padding: 18px 0 22px; }
.index-chapters > li + li { border-top: 1px solid var(--line); }
.index-chapters h3 { font-size: clamp(1.36rem, 2vw, 1.76rem); margin-bottom: 8px; }
.index-chapters h3 a { text-decoration: none; }
.index-chapters h3 a:hover { text-decoration: underline; }
.index-chapters p { color: var(--muted); }
.index-chapters .subnav { margin-top: 8px; }
.index-links { list-style: none; padding: 0 0 0 14px; margin: 12px 0 0; border-left: 2px solid var(--line); }
.index-links li + li { margin-top: 5px; }
.topic-level, .topic-detail { color: var(--muted); font-size: .88rem; }
.topic-level { margin-inline-start: 8px; }
.topic-detail { margin-inline-start: 14px; }
.index-extra { max-width: 960px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; padding: 20px 0 12px; }
.index-extra a { display: grid; gap: 5px; text-decoration: none; }
.index-extra a:hover strong { text-decoration: underline; }
.index-extra span { color: var(--muted); font-size: .9rem; }
.chapter-next { max-width: 820px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding-block: 25px 8px; }
.chapter-next a { display: inline-block; line-height: 1.45; padding-block: 5px; }
.chapter-next a[rel="next"] { margin-inline-start: auto; }
.wave-compare { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px 18px; margin: 18px 0; padding: 15px 12px; background: var(--white); border: 1px solid var(--line); border-radius: 7px; text-align: center; }
.wave-compare p { margin: 4px 0; }
.wave-compare figcaption { grid-column: 1 / -1; font-size: .88rem; color: var(--muted); }
.wave-disc { width: min(28vw,100px); aspect-ratio: 1; margin: 8px auto 12px; border-radius: 50%; position: relative; }
.wave-disc::after { content: ""; position: absolute; inset: 0; margin: auto; width: 5px; height: 5px; border-radius: 50%; background-color: var(--green-dark); }
.wave-disc.shell { border: 12px solid #789884; }
.wave-disc.filled { border: 2px solid #789884; background: radial-gradient(circle, #e9eee3 8%, #d4e1d2 64%, #a1b9a5 99%); }
@media (max-width: 580px) {
  .chapter { padding-top: 3px; }
  .topic-detail { display: block; margin: 0; }
  .index-extra { grid-template-columns: 1fr; }
}
@media print {
  .chapter-next { display: none; }
  .chapter > header h1 { font-size: 26pt; }
  .chapter .lesson > h2 { font-size: 17pt; }
  .wave-compare { break-inside: avoid; print-color-adjust: exact; }
}
.section-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-bottom: 15px;
  font-size: .85rem;
}
.section-links a { padding: 3px 8px; }
.section-links a[aria-current="page"] {
  background: var(--soft);
  text-decoration: none;
  border-radius: 4px;
  font-weight: 650;
}
@media print { .section-links { display: none; } }

/* Formula-driven figures in the wave and mixed-boundary lessons. */
.workflow-table { min-width: 565px; }
.workflow-table th[scope="row"] { min-width: 8em; }
.workflow-table ol { margin: 0; padding-inline-start: 1.2em; }
.workflow-table li + li { margin-top: 4px; }
.coefficient-table { min-width: 0; }

.lesson .study-lab > h3 { margin: 0 0 8px; }
.study-lab .plot-title { margin: 0 0 2px; font-size: .88rem; font-weight: 650; }
.study-lab .play-button { flex: none; min-width: 64px; margin-bottom: 2px; }
.study-lab .lab-plots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.lab-panel { min-width: 0; padding: 8px 7px 6px; border: 1px solid var(--line); border-radius: 5px; }
.lab-panel canvas { height: clamp(173px, 25vw, 216px); }
.study-lab figcaption output { display: block; margin-top: 5px; }
.study-lab .legend { gap: 4px 10px; }
.study-lab .legend span::before { width: 14px; }
.study-lab details { margin-bottom: 0; }

.mode-picker { display: flex; flex-wrap: wrap; gap: 4px 17px; margin: 6px 0 12px; padding: 3px 9px 8px; border: 1px solid var(--line); border-radius: 5px; }
.mode-picker legend { padding: 0 4px; font-size: .87rem; font-weight: 650; }
.mode-picker label { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; font-size: .88rem; cursor: pointer; }
.mode-picker input { accent-color: var(--green); }
.coefficient-meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px 14px; margin: 10px 0 0; }
.coefficient-meters label { display: grid; gap: 2px; min-width: 0; font-size: .84rem; }
.coefficient-meters meter { width: 100%; }

@media (max-width: 640px) {
  .study-lab .lab-plots { grid-template-columns: 1fr; }
}
@media print {
  .study-lab { break-inside: auto; }
  .study-lab .mode-picker { display: none; }
  .study-lab .lab-plots { grid-template-columns: repeat(2, minmax(0, 1fr)); break-inside: avoid; }
  .workflow-table { min-width: 0; }
}
