:root {
  --forest: #1B4332;
  --forest-2: #2D6A4F;
  --forest-3: #D8E8DE;
  --terra: #C97A56;
  --terra-d: #A85F3F;
  --sand: #F2DDB5;
  --cream: #FBF6EC;
  --paper: #FFFDF8;
  --ink: #22302A;
  --muted: #667a70;
  --line: #E6DCC8;
  --radius: 14px;
  --mono: "JetBrains Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font: 16px/1.7 Inter, system-ui, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--forest-2); }
a:hover { color: var(--terra-d); }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; color: var(--forest); line-height: 1.25; }
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 16px 64px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px;
  padding: 12px max(16px, calc((100vw - 1120px) / 2)); background: var(--forest); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; letter-spacing: .04em; }
.brand:hover { color: #fff; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: var(--terra); position: relative; }
.logo::before, .logo::after { content: ""; position: absolute; left: 6px; height: 3px; border-radius: 2px; background: var(--forest); }
.logo::before { top: 9px; width: 16px; } .logo::after { top: 16px; width: 10px; }
nav { display: flex; gap: 4px; margin-left: auto; }
nav a { color: #e8efe9; text-decoration: none; padding: 6px 14px; border-radius: 999px; font-size: 15px; }
nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
nav a.on { background: var(--terra); color: #fff; }
.burger { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px;
  padding: 18px max(16px, calc((100vw - 1120px) / 2)); background: var(--forest); color: #bcd0c4; font-size: 13.5px;
}

/* hero */
.hero {
  background: var(--forest); color: #fff; border-radius: 22px; padding: 48px 40px; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px; border-radius: 50%;
  background: var(--terra); opacity: .9;
}
.hero::before {
  content: ""; position: absolute; right: 120px; bottom: -110px; width: 200px; height: 200px; border-radius: 50%;
  background: var(--sand); opacity: .22;
}
.hero > * { position: relative; z-index: 1; max-width: 640px; }
.hero .tag { display: inline-block; background: var(--sand); color: var(--forest); padding: 3px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.hero h1 { color: #fff; font-size: clamp(28px, 5vw, 44px); margin: 14px 0 10px; }
.hero p { color: #d3e3d9; margin: 0 0 20px; }
.author { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--sand); color: var(--forest); display: grid; place-items: center; font: 700 17px Fraunces, serif; flex: none; }
.author b { display: block; line-height: 1.3; } .author small { color: #bcd0c4; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 24px; }
.card {
  display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(27,67,50,.12); border-color: var(--terra); color: var(--ink); }
.card .ic { width: 42px; height: 42px; border-radius: 11px; background: var(--forest-3); color: var(--forest); display: grid; place-items: center; font-size: 20px; margin-bottom: 12px; }
.card:nth-child(even) .ic { background: var(--sand); color: var(--terra-d); }
.card h3 { margin: 0 0 4px; font-size: 20px; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.stat { flex: 1 1 130px; background: var(--sand); border-radius: var(--radius); padding: 14px 18px; }
.stat b { display: block; font: 700 28px Fraunces, serif; color: var(--forest); }
.stat span { font-size: 13.5px; color: #5b4a2e; }

/* page head */
.pagehead { margin-bottom: 24px; }
.pagehead h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 36px); }
.pagehead p { margin: 0; color: var(--muted); }
.pagehead::after { content: ""; display: block; width: 56px; height: 4px; border-radius: 2px; background: var(--terra); margin-top: 14px; }

/* lists */
.list { display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 16px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 18px; text-decoration: none; color: var(--ink); transition: border-color .15s, background .15s;
}
.row:hover { border-color: var(--terra); background: #fff; color: var(--ink); }
.row .num { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--forest); color: #fff; display: grid; place-items: center; font: 700 17px Fraunces, serif; }
.row .t { flex: 1; font-weight: 500; }
.row .go { color: var(--terra-d); font-weight: 600; font-size: 14px; white-space: nowrap; }
.switch { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 8px 18px; border-radius: 999px; border: 1.5px solid var(--forest); background: transparent;
  color: var(--forest); text-decoration: none; font: 500 14.5px Inter, sans-serif; cursor: pointer;
}
.btn:hover { background: var(--forest); color: #fff; }
.btn.fill { background: var(--terra); border-color: var(--terra); color: #fff; }
.btn.fill:hover { background: var(--terra-d); border-color: var(--terra-d); }
.btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }

/* syllabus */
.sec { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.sec > h2 { margin: 0 0 14px; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.sec > h2::before { content: ""; width: 8px; height: 22px; border-radius: 3px; background: var(--terra); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.kv div { background: var(--cream); border-radius: 10px; padding: 10px 14px; }
.kv small { display: block; color: var(--muted); font-size: 12.5px; }
.kv b { font-weight: 600; }
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.grade > div { border-radius: 12px; padding: 16px 18px; background: var(--forest-3); }
.grade > div:nth-child(2) { background: var(--sand); }
.grade > div:nth-child(3) { background: #EBC4AE; }
.grade b { font: 700 34px Fraunces, serif; color: var(--forest); } .grade b small { font-size: 16px; }
.grade h3 { margin: 0; font-size: 18px; } .grade p { margin: 4px 0 0; font-size: 14px; color: #3d4b44; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; background: var(--sand); color: var(--forest); padding: 9px 12px; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td:first-child { width: 48px; font-weight: 700; color: var(--terra-d); }
.tbl ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.tbl-wrap { overflow-x: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--cream); border: 1px solid var(--line); border-radius: 999px; padding: 4px 13px; font-size: 14px; }
.chip i { font-style: normal; font-weight: 700; color: var(--terra-d); margin-right: 6px; }
.refs { margin: 0; padding-left: 20px; }

/* reader */
.reader { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; align-items: start; }
.toc { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow: auto; font-size: 14px; border-left: 3px solid var(--line); padding-left: 14px; }
.toc b { display: block; margin-bottom: 8px; font-family: Fraunces, serif; color: var(--forest); font-size: 16px; }
.toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--terra-d); }
.doc { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 4vw, 44px); min-width: 0; }
.md > :first-child { margin-top: 0; }
.md h1 { font-size: clamp(26px, 4vw, 34px); border-bottom: 3px solid var(--terra); padding-bottom: 10px; }
.md h2 { font-size: 25px; margin-top: 2em; }
.md h3 { font-size: 19px; margin-top: 1.6em; color: var(--forest-2); }
.md p, .md li { text-align: justify; hyphens: auto; }
.md li::marker { color: var(--terra); }
.md img, .md svg { max-width: 100%; height: auto; display: block; margin: 16px auto; }
.md code { font: 0.9em var(--mono); background: var(--sand); color: #5a2e19; padding: 1px 6px; border-radius: 5px; }
.md pre { background: #FAF3E3; border: 1px solid var(--line); border-left: 4px solid var(--forest); border-radius: 10px; padding: 14px 16px; overflow-x: auto; line-height: 1.55; }
.md pre code { background: none; color: inherit; padding: 0; font-size: 13.5px; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; margin: 16px 0; }
.md th { background: var(--sand); color: var(--forest); text-align: left; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 12px; }
.md blockquote { margin: 16px 0; padding: 4px 18px; border-left: 4px solid var(--terra); background: var(--cream); color: #4b5a52; border-radius: 0 10px 10px 0; }
.md hr { border: 0; border-top: 1px dashed var(--line); margin: 28px 0; }
.md pre.mermaid { background: #fff; border-left-color: var(--terra); text-align: center; }
.hljs { background: none !important; padding: 0 !important; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; flex-wrap: wrap; }

/* slides */
body.show { overflow: hidden; }
body.show .top, body.show .foot, body.show main { display: none; }
#deck { position: fixed; inset: 0; height: 100dvh; touch-action: pan-y; background: #0f2a20; display: none; z-index: 50; user-select: none; }
body.show #deck { display: block; }
#stage { position: absolute; left: 50%; top: 50%; width: 1280px; height: 720px; transform-origin: 0 0; background: var(--paper); overflow: hidden; border-radius: 6px; }
.slide { position: absolute; inset: 0; padding: 56px 72px 64px; font-size: 27px; line-height: 1.5; display: none; }
.slide.on { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.slide::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 14px; background: var(--forest); }
.slide::after { content: ""; position: absolute; left: 0; top: 0; width: 14px; height: 120px; background: var(--terra); }
.slide h2 { font-size: 44px; margin: 0 0 18px; }
.slide h2::after { content: ""; display: block; width: 64px; height: 5px; border-radius: 3px; background: var(--terra); margin-top: 10px; }
.slide ul, .slide ol { padding-left: 34px; margin: 0 0 12px; }
.slide li { margin: 8px 0; } .slide li::marker { color: var(--terra); }
.slide code { font: .85em var(--mono); background: var(--sand); padding: 0 8px; border-radius: 6px; color: #5a2e19; }
.slide pre { font-size: 21px; line-height: 1.45; background: #FAF3E3; border-left: 5px solid var(--forest); border-radius: 10px; padding: 14px 20px; overflow: hidden; }
.slide pre code { background: none; padding: 0; color: inherit; }
.slide table { border-collapse: collapse; margin: 10px auto; width: 92%; font-size: 24px; }
.slide th { background: var(--sand); color: var(--forest); } .slide th, .slide td { border: 1px solid var(--line); padding: 7px 14px; text-align: left; }
.slide img, .slide svg { display: block; margin: 12px auto; max-width: 100%; max-height: 340px; width: auto; height: auto; }
.slide.title { background: var(--forest); color: #fff; padding: 0; }
.slide.title::before { display: none; }
.slide.title::after { left: auto; top: -110px; right: -110px; width: 440px; height: 440px; border-radius: 50%; background: var(--terra); }
.slide.title .in { position: absolute; left: 90px; right: 360px; top: 50%; transform: translateY(-50%); }
.slide.title .tag { display: inline-block; background: var(--sand); color: var(--forest); padding: 2px 16px; border-radius: 999px; font-size: 21px; font-weight: 600; }
.slide.title h1 { color: #fff; font-size: 56px; margin: 20px 0 22px; }
.slide.title p { margin: 0; color: #cfe0d6; font-size: 24px; line-height: 1.5; }
.slide.title p b { color: var(--sand); }
.hud { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 14px; padding: 10px 18px; color: #bcd0c4; font-size: 14px; background: linear-gradient(transparent, rgba(0,0,0,.4)); opacity: 0; transition: opacity .2s; }
#deck:hover .hud, .hud:focus-within { opacity: 1; }
.hud button, .hud a { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; text-decoration: none; font: inherit; }
.hud button:hover, .hud a:hover { background: var(--terra); }
.hud .sp { flex: 1; }
.bar { position: absolute; left: 0; top: 0; height: 4px; background: var(--terra); transition: width .2s; }

@media (max-width: 860px) {
  .reader { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; border: 0; padding: 0; background: var(--paper); border-radius: 12px; padding: 12px 16px; }
  .toc.fold:not(.open) a { display: none; }
  .toc b { cursor: pointer; margin: 0; }
}
@media (max-width: 700px) {
  .burger { display: block; }
  nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--forest); padding: 8px 16px 14px; }
  nav.open { display: flex; }
  .hero { padding: 32px 22px; } .hero::after { width: 200px; height: 200px; right: -70px; top: -70px; opacity: .6; }
  .row .go { display: none; }
}
.rot { display: none; position: absolute; left: 0; right: 0; top: 8px; text-align: center; color: #F2DDB5; font-size: 13px; padding: 0 12px; z-index: 2; }
@media (hover: none) { .hud { opacity: 1; } }
@media (orientation: portrait) and (max-width: 700px) { .rot { display: block; } }
@media (max-width: 700px) {
  html { font-size: 15.5px; }
  main { padding: 20px 14px 48px; }
  .top { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  nav a { padding: 12px 14px; font-size: 16px; }
  .hero { border-radius: 16px; }
  .hero > * { max-width: 100%; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card { padding: 16px; } .card h3 { font-size: 17px; } .card p { font-size: 13px; }
  .stat { flex: 1 1 42%; }
  .sec { padding: 16px; }
  .row { padding: 12px; gap: 12px; } .row .num { width: 34px; height: 34px; font-size: 15px; }
  .doc { padding: 16px 14px; border-radius: 12px; }
  .md h2 { font-size: 21px; } .md p, .md li { text-align: left; hyphens: none; }
  .md pre { padding: 10px 12px; margin-left: -4px; margin-right: -4px; } .md pre code { font-size: 12.5px; }
  .pager .btn { flex: 1; text-align: center; }
  .hud { gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); font-size: 13px; }
  .hud #dFull, .hud #dRead { display: none; }
  .hud button, .hud a { padding: 10px 14px; }
  .foot { font-size: 12.5px; }
}
@media (max-width: 380px) { .cards { grid-template-columns: 1fr; } }
@media print { .top, .foot, .toc, .pager { display: none; } body { background: #fff; } .doc { border: 0; padding: 0; } }

.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #0f2a20; border: 1px solid var(--line); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
nav a { white-space: nowrap; }
@media (min-width: 701px) and (max-width: 1000px) { nav a { padding: 6px 9px; font-size: 14px; } .top { gap: 12px; } }

.tl > div { display: grid; grid-template-columns: 130px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.tl > div:last-child { border: 0; }
.tl .y { font-weight: 700; color: var(--terra-d); font-size: 14.5px; }
.tl p { margin: 2px 0 0; color: #3d4b44; }
@media (max-width: 600px) { .tl > div { grid-template-columns: 1fr; gap: 2px; } }
