:root {
  --paper: #f2efe8;
  --paper-deep: #e7e1d6;
  --ink: #17211d;
  --muted: #667069;
  --line: #c8c3b8;
  --green: #174f3b;
  --green-soft: #dce8df;
  --red: #9b3f2f;
  --yellow: #dfb757;
  --white: #fbfaf6;
  --mono: "SFMono-Regular", "Menlo", "PingFang SC", monospace;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 33, 29, .025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
  font-family: var(--serif);
  line-height: 1.75;
}
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--ink);
  background: rgba(242, 239, 232, .94);
  backdrop-filter: blur(12px);
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; font-weight: 700; }
.brand-mark { padding: 4px 7px; color: var(--white); background: var(--green); font-family: var(--mono); font-size: 12px; }
.course-status { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; }

.course-intro {
  min-height: 420px;
  padding: 88px max(5vw, calc((100vw - 1240px) / 2));
  color: var(--white);
  background: var(--green);
}
.eyebrow, .index-heading p, .section-kicker, .source-label {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.course-intro h1 { margin: 0; max-width: 800px; font-size: clamp(42px, 7vw, 84px); line-height: 1.13; letter-spacing: -.04em; }
.intro-copy { max-width: 720px; margin: 28px 0; font-size: 17px; color: #d9e1dc; }
.course-route { display: flex; align-items: center; gap: 12px; max-width: 760px; font-family: var(--mono); font-size: 11px; }
.course-route i { flex: 1; height: 1px; background: rgba(255,255,255,.42); }

.course-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); max-width: 1240px; margin: 0 auto; }
.course-index { position: sticky; top: 62px; align-self: start; height: calc(100vh - 62px); padding: 42px 28px 30px 0; border-right: 1px solid var(--line); }
.index-heading { display: flex; justify-content: space-between; align-items: baseline; padding: 0 18px 18px; }
.index-heading p { margin: 0; }
.index-heading span { font-size: 12px; color: var(--muted); }
.lesson-link { width: 100%; display: grid; grid-template-columns: 32px 1fr; gap: 10px; text-align: left; padding: 16px 18px; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--ink); }
.lesson-link:last-child { border-bottom: 1px solid var(--line); }
.lesson-link.active { color: var(--white); background: var(--ink); }
.lesson-number { font-family: var(--mono); font-size: 11px; }
.lesson-link-copy { display: flex; flex-direction: column; }
.lesson-link-copy small { font-family: var(--mono); font-size: 10px; opacity: .65; }
.lesson-link-copy strong { margin-top: 4px; font-size: 14px; line-height: 1.4; }
.lesson-state { grid-column: 2; width: fit-content; font-family: var(--mono); font-size: 9px; opacity: .65; }
.future-note { margin: 32px 18px; padding-top: 18px; border-top: 4px solid var(--yellow); font-size: 12px; color: var(--muted); }
.future-note strong { color: var(--ink); }

.lesson { min-width: 0; padding: 54px clamp(28px, 5vw, 78px) 120px; background: rgba(251, 250, 246, .62); }
.reading-progress { position: sticky; z-index: 20; top: 62px; width: 100%; height: 3px; background: var(--paper-deep); }
.reading-progress span { display: block; width: 0; height: 100%; background: var(--red); transition: width .15s linear; }
.lesson-header { padding: 38px 0 58px; border-bottom: 1px solid var(--ink); }
.lesson-meta { display: flex; gap: 12px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.lesson-meta span + span::before { content: "/"; margin-right: 12px; }
.lesson-header h2 { max-width: 780px; margin: 24px 0 18px; font-size: clamp(34px, 5vw, 60px); line-height: 1.18; letter-spacing: -.035em; }
.lesson-summary { max-width: 720px; margin: 0; font-size: 17px; color: var(--muted); }
.lesson-map { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 36px; border: 1px solid var(--ink); }
.map-step { position: relative; padding: 18px; min-height: 100px; border-right: 1px solid var(--ink); }
.map-step:last-child { border-right: 0; }
.map-step small { display: block; font-family: var(--mono); color: var(--red); }
.map-step strong { display: block; margin-top: 8px; line-height: 1.4; }

.quick-nav { display: flex; flex-wrap: wrap; gap: 8px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.quick-nav button { padding: 6px 10px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-family: var(--mono); font-size: 10px; color: var(--ink); }
.quick-nav button:hover { border-color: var(--green); color: var(--green); }

.lesson-section { scroll-margin-top: 76px; padding: 66px 0; border-bottom: 1px solid var(--line); opacity: .35; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
.lesson-section.visible { opacity: 1; transform: none; }
.section-kicker { color: var(--red); }
.lesson-section h3 { max-width: 760px; margin: 0 0 28px; font-size: clamp(27px, 3.4vw, 42px); line-height: 1.3; }
.lesson-section h4 { margin: 36px 0 12px; font-size: 19px; }
.lesson-section p, .lesson-section li { max-width: 760px; }
.lesson-section ul, .lesson-section ol { padding-left: 22px; }
.lesson-section li { margin: 7px 0; }

.explain { padding: 22px 24px; margin: 28px 0; border-left: 5px solid var(--green); background: var(--green-soft); }
.explain strong { display: block; margin-bottom: 6px; }
.formula {
  max-width: 760px;
  margin: 22px 0;
  padding: 22px 24px;
  overflow-x: auto;
  border: 1px solid var(--ink);
  background: var(--white);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
}
.formula b { color: var(--red); }
.source-note { display: flex; flex-wrap: wrap; gap: 8px 18px; max-width: 760px; margin-top: 30px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.source-item { display: inline-flex; align-items: baseline; gap: 5px; }
.source-label { display: inline; margin-right: 8px; color: var(--ink); }
.tag { display: inline-block; margin-right: 6px; padding: 2px 6px; border: 1px solid var(--line); font-family: var(--mono); font-size: 9px; color: var(--muted); }
.slide-figure { max-width: 760px; margin: 28px 0; padding: 10px; border: 1px solid var(--line); background: var(--white); }
.slide-open { position: relative; display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.slide-open img { display: block; width: 100%; height: auto; }
.slide-open > span { position: absolute; right: 10px; bottom: 10px; padding: 5px 8px; color: var(--white); background: rgba(23,33,29,.86); font-family: var(--mono); font-size: 9px; opacity: 0; transition: opacity .2s ease; }
.slide-open:hover > span, .slide-open:focus-visible > span { opacity: 1; }
.slide-figure figcaption { padding: 9px 4px 2px; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.table-scroll { max-width: 100%; overflow-x: auto; }

.balance-sheet { display: grid; grid-template-columns: 1fr 1fr; max-width: 760px; margin: 28px 0; border: 1px solid var(--ink); background: var(--white); }
.balance-column { padding: 22px; }
.balance-column:first-child { border-right: 1px solid var(--ink); }
.balance-column h5 { margin: 0 0 14px; font-family: var(--mono); font-size: 11px; }
.balance-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dotted var(--line); }
.balance-row.total { margin-top: 8px; border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 700; }

.split-visual { display: grid; grid-template-columns: 70fr 50fr; max-width: 760px; margin: 26px 0; border: 1px solid var(--ink); }
.split-visual div { min-height: 110px; padding: 18px; }
.split-visual div:first-child { color: var(--white); background: var(--green); }
.split-visual div:last-child { background: var(--yellow); }
.split-visual small { display: block; font-family: var(--mono); }
.split-visual strong { display: block; margin-top: 10px; font-size: 26px; }

.before-after { display: grid; grid-template-columns: 1fr 46px 1fr; align-items: stretch; max-width: 760px; margin: 28px 0; }
.state-box { padding: 20px; border: 1px solid var(--ink); background: var(--white); }
.state-box h5 { margin: 0 0 14px; font-size: 15px; }
.state-box dl { margin: 0; }
.state-box div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dotted var(--line); }
.state-box dt, .state-box dd { margin: 0; }
.state-box dd { font-family: var(--mono); }
.change-arrow { display: grid; place-items: center; font-family: var(--mono); font-size: 24px; color: var(--red); }

.teaching-step { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 18px; max-width: 760px; margin: 28px 0; padding-top: 20px; border-top: 1px solid var(--line); }
.teaching-step > span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--white); background: var(--green); font-family: var(--mono); font-size: 12px; }
.teaching-step h4 { margin: 2px 0 8px; }
.teaching-step p { margin: 0; }

.stakeholders { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 760px; margin: 28px 0; border: 1px solid var(--ink); }
.stakeholder { min-height: 190px; padding: 20px; border-right: 1px solid var(--ink); }
.stakeholder:last-child { border-right: 0; }
.stakeholder small { font-family: var(--mono); color: var(--red); }
.stakeholder h5 { margin: 8px 0 12px; font-size: 18px; }
.stakeholder p { margin: 0; font-size: 13px; }

.check { max-width: 760px; margin: 32px 0; padding: 24px; border: 1px solid var(--line); background: var(--paper-deep); }
.check h4 { margin-top: 0; }
.answer-button { padding: 8px 13px; border: 1px solid var(--ink); background: var(--ink); color: var(--white); cursor: pointer; font-family: var(--mono); font-size: 10px; }
.answer { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.answer[hidden] { display: none; }

.closing { padding-top: 74px; }
.conclusion-list { counter-reset: conclusion; max-width: 760px; padding: 0; list-style: none; }
.conclusion-list li { counter-increment: conclusion; display: grid; grid-template-columns: 42px 1fr; padding: 14px 0; border-bottom: 1px solid var(--line); }
.conclusion-list li::before { content: counter(conclusion, decimal-leading-zero); font-family: var(--mono); color: var(--red); }
.glossary { width: 100%; border-collapse: collapse; font-size: 13px; }
.glossary th, .glossary td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.glossary th { font-family: var(--mono); font-size: 10px; }

footer { display: flex; justify-content: space-between; padding: 28px 4vw; color: var(--paper); background: var(--ink); font-size: 11px; }

.image-modal { width: min(96vw, 1500px); max-width: none; max-height: 94vh; padding: 54px 18px 18px; border: 1px solid var(--ink); background: var(--white); }
.image-modal::backdrop { background: rgba(10, 16, 13, .82); backdrop-filter: blur(3px); }
.image-modal figure { margin: 0; overflow: auto; max-height: calc(94vh - 72px); }
.image-modal img { display: block; width: max-content; min-width: 100%; max-width: none; height: auto; }
.image-modal figcaption { position: sticky; left: 0; padding: 10px 2px 2px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.modal-close { position: absolute; top: 12px; right: 16px; padding: 6px 10px; border: 1px solid var(--ink); color: var(--white); background: var(--ink); cursor: pointer; font-family: var(--mono); font-size: 10px; }

@media (max-width: 880px) {
  .course-intro { min-height: auto; padding: 62px 24px; }
  .course-route { display: none; }
  .course-shell { display: block; }
  .course-index { position: static; height: auto; padding: 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .future-note { display: none; }
  .lesson { padding: 30px 24px 90px; }
  .lesson-map { grid-template-columns: 1fr 1fr; }
  .map-step:nth-child(2) { border-right: 0; }
  .map-step:nth-child(-n+2) { border-bottom: 1px solid var(--ink); }
  .before-after { grid-template-columns: 1fr; }
  .change-arrow { min-height: 42px; transform: rotate(90deg); }
  .stakeholders { grid-template-columns: 1fr; }
  .stakeholder { border-right: 0; border-bottom: 1px solid var(--ink); }
  .stakeholder:last-child { border-bottom: 0; }
}

@media (max-width: 540px) {
  .topbar { padding: 0 18px; }
  .course-intro h1 { font-size: 40px; }
  .lesson-map { grid-template-columns: 1fr; }
  .map-step { border-right: 0; border-bottom: 1px solid var(--ink); }
  .map-step:last-child { border-bottom: 0; }
  .balance-sheet, .split-visual { grid-template-columns: 1fr; }
  .balance-column:first-child { border-right: 0; border-bottom: 1px solid var(--ink); }
  footer { flex-direction: column; gap: 6px; }
  .lesson { padding-right: 18px; padding-left: 18px; }
  .formula { padding: 17px; font-size: 12px; }
  .quick-nav { gap: 6px; }
  .quick-nav button { min-height: 38px; }
  .teaching-step { grid-template-columns: 34px minmax(0, 1fr); gap: 12px; }
  .teaching-step > span { width: 30px; height: 30px; }
}

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