:root {
  --ink: #16373a;
  --muted: #617a7b;
  --teal: #0d7377;
  --teal-dark: #07575a;
  --aqua: #dff5f2;
  --aqua-strong: #bce9e3;
  --sun: #f4bf4f;
  --paper: #ffffff;
  --canvas: #f4fbfb;
  --line: #d9e8e7;
  --soft-line: #eaf2f1;
  --shadow: 0 18px 48px rgba(25, 72, 74, .09);
  --sidebar: 282px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 94px; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 86% 5%, rgba(188, 233, 227, .52), transparent 25rem),
    linear-gradient(180deg, #f7fdfc 0, var(--canvas) 28rem, #eef8f7 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); }
button, input { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 1000; transform: translateY(-150%); padding: 8px 14px; color: white; background: var(--teal); border-radius: 8px; }
.skip-link:focus { transform: translateY(0); }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: 74px;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(280px, 640px) auto;
  align-items: center;
  gap: 28px;
  padding: 0 28px 0 24px;
  background: rgba(250, 254, 253, .88);
  border-bottom: 1px solid rgba(205, 225, 223, .78);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; line-height: 1.15; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 12px 12px 12px 4px; color: white; background: var(--teal); font-family: "Songti SC", serif; font-size: 21px; font-weight: 700; box-shadow: 0 7px 18px rgba(13, 115, 119, .2); }
.brand strong { display: block; font-size: 16px; letter-spacing: .03em; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: .04em; }

.search-shell { position: relative; width: 100%; }
.search-shell input { width: 100%; height: 44px; padding: 0 62px 0 42px; color: var(--ink); background: #eef7f6; border: 1px solid transparent; border-radius: 12px; outline: none; transition: .2s ease; }
.search-shell input:focus { background: white; border-color: var(--aqua-strong); box-shadow: 0 0 0 4px rgba(13, 115, 119, .08); }
.search-shell input::placeholder { color: #7f9697; }
.search-icon { position: absolute; z-index: 1; top: 6px; left: 14px; color: var(--teal); font-size: 25px; transform: rotate(-18deg); }
kbd { position: absolute; right: 12px; top: 10px; padding: 2px 7px; color: #6f8585; background: white; border: 1px solid #dce9e8; border-bottom-width: 2px; border-radius: 6px; font-family: inherit; font-size: 12px; }
.search-results { position: absolute; top: 52px; left: 0; right: 0; max-height: min(520px, 68vh); overflow: auto; padding: 8px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.search-summary { padding: 8px 10px 6px; color: var(--muted); font-size: 13px; }
.search-result { display: block; width: 100%; padding: 10px 12px; text-align: left; background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.search-result:hover, .search-result:focus { background: var(--aqua); outline: none; }
.search-result strong { display: block; color: var(--ink); font-size: 14px; }
.search-result small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reading-mode { justify-self: end; padding: 8px 14px; color: var(--teal); background: white; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.reading-mode:hover { border-color: var(--teal); }
.icon-button { background: none; border: 0; cursor: pointer; }
.menu-button, .close-menu { display: none; }
.progress-track { position: fixed; z-index: 101; top: 73px; left: 0; right: 0; height: 2px; background: transparent; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), #31aaa6, var(--sun)); }

.sidebar { position: fixed; z-index: 90; top: 74px; bottom: 0; left: 0; width: var(--sidebar); padding: 34px 22px 28px; overflow-y: auto; background: rgba(240, 249, 248, .84); border-right: 1px solid var(--line); }
.sidebar-head { position: relative; padding: 0 8px 18px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 11px; font-weight: 750; letter-spacing: .14em; }
.sidebar h2 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 23px; }
.toc { display: flex; flex-direction: column; gap: 2px; }
.toc-group { margin-bottom: 7px; }
.toc a { display: block; color: #5e7475; text-decoration: none; border-radius: 8px; transition: .15s ease; }
.toc .toc-h1 { padding: 8px 10px; font-size: 14px; font-weight: 650; }
.toc .toc-h2 { position: relative; padding: 5px 10px 5px 25px; font-size: 12px; line-height: 1.45; }
.toc .toc-h2::before { content: ""; position: absolute; left: 12px; top: 12px; width: 4px; height: 4px; border-radius: 50%; background: #a8c2c1; }
.toc a:hover { color: var(--teal); background: rgba(255,255,255,.65); }
.toc a.active { color: var(--teal-dark); background: white; box-shadow: 0 3px 14px rgba(25,72,74,.06); }
.toc .toc-h1.active { font-weight: 750; }
.sidebar-note { display: flex; gap: 10px; margin: 24px 7px 0; padding: 14px; color: #607777; background: rgba(255,255,255,.7); border: 1px solid var(--soft-line); border-radius: 12px; font-size: 12px; line-height: 1.55; }
.sidebar-note p { margin: 0; }
.sidebar-note strong { color: var(--ink); }
.note-dot { flex: 0 0 8px; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 4px rgba(244,191,79,.18); }

.page-shell { margin-left: var(--sidebar); padding: 112px clamp(28px, 5vw, 78px) 60px; }
.course-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(290px, .75fr); gap: clamp(40px, 7vw, 110px); max-width: 1180px; margin: 0 auto 40px; padding: clamp(36px, 6vw, 78px); overflow: hidden; background: var(--paper); border: 1px solid rgba(210, 230, 228, .9); border-radius: 28px 28px 28px 8px; box-shadow: var(--shadow); }
.course-hero::after { content: ""; position: absolute; width: 280px; height: 280px; right: -120px; top: -130px; border: 52px solid rgba(188,233,227,.36); border-radius: 50%; }
.hero-copy { position: relative; z-index: 1; }
.hero-copy h1 { margin: 8px 0 22px; font-family: "Songti SC", "STSong", serif; font-size: clamp(38px, 5.1vw, 68px); font-weight: 650; line-height: 1.14; letter-spacing: -.035em; }
.hero-copy h1 em { color: var(--teal); font-style: normal; }
.hero-intro { max-width: 650px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.85; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 12px 26px; margin-top: 32px; color: var(--muted); font-size: 13px; }
.hero-stats span { display: flex; align-items: baseline; gap: 5px; }
.hero-stats strong { color: var(--ink); font-size: 25px; font-family: Georgia, serif; }
.hero-map { position: relative; align-self: center; padding: 25px 24px 22px 34px; background: linear-gradient(150deg, #0b666a, #0b7e7e); border-radius: 20px 20px 20px 5px; box-shadow: 0 16px 32px rgba(13,115,119,.2); }
.hero-map > p { margin: 0 0 16px; color: rgba(255,255,255,.66); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
.hero-map ol { position: relative; list-style: none; margin: 0; padding: 0; }
.hero-map ol::before { content: ""; position: absolute; top: 14px; bottom: 14px; left: 13px; width: 1px; background: rgba(255,255,255,.25); }
.hero-map li { position: relative; display: flex; align-items: center; gap: 13px; padding: 7px 0; color: white; font-size: 14px; }
.hero-map li span { position: relative; z-index: 1; display: grid; place-items: center; width: 27px; height: 27px; color: var(--teal-dark); background: #ddf5f1; border-radius: 50%; font-family: Georgia, serif; font-size: 10px; font-weight: 700; }
.loop-label { margin: 15px 0 0 40px; padding-top: 12px; color: #ffe09c; border-top: 1px solid rgba(255,255,255,.17); font-size: 12px; letter-spacing: .12em; }

.day-strip { display: grid; grid-template-columns: 120px 1fr; max-width: 1180px; margin: 0 auto 40px; padding: 14px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 16px; }
.strip-label { display: flex; flex-direction: column; justify-content: center; padding-left: 8px; border-right: 1px solid var(--line); }
.strip-label span { font-weight: 700; font-size: 14px; }
.strip-label small { color: var(--muted); font-size: 11px; }
.lesson-links { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; padding-left: 14px; }
.lesson-link { padding: 8px 6px; color: var(--ink); text-align: left; text-decoration: none; border-radius: 10px; }
.lesson-link:hover { background: var(--aqua); }
.lesson-link b { display: block; color: var(--teal); font-family: Georgia, serif; font-size: 15px; }
.lesson-link span { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.document-shell { max-width: 1000px; margin: 0 auto; }
.document-meta { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 0 16px; padding: 0 4px; }
.document-meta h2 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 30px; }
.meta-actions { display: flex; align-items: center; gap: 12px; }
.meta-actions button { padding: 8px 12px; color: var(--teal); background: transparent; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.meta-actions button:hover { background: white; border-color: var(--teal); }
.checklist-progress { color: var(--muted); font-size: 13px; }
.course-document { counter-reset: chapter; }
.loading-state { display: grid; place-items: center; min-height: 320px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 18px; }
.loading-state span { width: 36px; height: 36px; margin-bottom: -110px; border: 3px solid var(--aqua); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chapter { position: relative; margin: 0 0 24px; padding: clamp(28px, 4.5vw, 48px); background: var(--paper); border: 1px solid var(--line); border-radius: 20px 20px 20px 6px; box-shadow: 0 8px 28px rgba(25,72,74,.045); }
.chapter > h1 { position: relative; margin: 0 0 30px; padding: 0 48px 18px 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(26px, 3.3vw, 38px); line-height: 1.35; letter-spacing: -.02em; border-bottom: 1px solid var(--line); }
.chapter > h1::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 72px; height: 3px; background: linear-gradient(90deg, var(--teal), var(--sun)); border-radius: 3px; }
.topic { position: relative; padding: 7px 0 16px 25px; border-left: 1px solid var(--soft-line); }
.topic + .topic { margin-top: 10px; }
.topic::before { content: ""; position: absolute; left: -4px; top: 23px; width: 7px; height: 7px; background: white; border: 2px solid var(--aqua-strong); border-radius: 50%; }
.topic > h2 { margin: 0 0 13px; color: var(--ink); font-size: 20px; line-height: 1.45; }
.topic.collapsed > :not(h2):not(.heading-action) { display: none; }
.topic.collapsed { padding-bottom: 3px; }
.topic h3 { margin: 20px 0 9px; color: var(--teal-dark); font-size: 17px; }
.topic p, .chapter > p { margin: 10px 0; }
.course-document ul, .course-document ol { margin: 10px 0 16px; padding-left: 1.45em; }
.course-document li { margin: 6px 0; padding-left: .2em; }
.course-document li::marker { color: var(--teal); }
.course-document strong { color: #102f31; font-weight: 720; }
.course-document blockquote { position: relative; margin: 18px 0; padding: 15px 18px 15px 48px; color: var(--teal-dark); background: linear-gradient(90deg, var(--aqua), rgba(223,245,242,.48)); border: 0; border-radius: 12px; font-size: 16px; }
.course-document blockquote::before { content: "“"; position: absolute; left: 17px; top: 3px; color: var(--teal); font-family: Georgia, serif; font-size: 42px; opacity: .55; }
.course-document pre { overflow-x: auto; padding: 22px; color: #e8ffff; background: #123f42; border-radius: 14px; font-size: 14px; line-height: 1.65; }
.course-document code { padding: .12em .35em; color: var(--teal-dark); background: var(--aqua); border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.course-document pre code { padding: 0; color: inherit; background: none; }
.course-document hr { height: 1px; margin: 30px 0; background: var(--line); border: 0; }
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: 12px; }
.course-document table { width: 100%; border-collapse: collapse; font-size: 14px; }
.course-document th { color: white; background: var(--teal); font-weight: 650; }
.course-document th, .course-document td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--line); }
.course-document tr:last-child td { border-bottom: 0; }
.course-document tbody tr:nth-child(even) { background: #f7fbfa; }
.course-document a { text-underline-offset: 3px; }
.heading-action { position: absolute; right: 0; top: 7px; width: 32px; height: 30px; color: #7a9393; background: white; border: 1px solid var(--soft-line); border-radius: 8px; opacity: 0; cursor: pointer; transition: .15s; }
.topic:hover .heading-action, .topic:focus-within .heading-action, .chapter > .heading-action { opacity: 1; }
.chapter > .heading-action { right: clamp(28px, 4.5vw, 48px); top: 38px; }
.heading-action:hover { color: var(--teal); border-color: var(--aqua-strong); }
.diagnostic-list { list-style: none; padding-left: 0 !important; }
.diagnostic-list li { position: relative; padding: 10px 12px 10px 44px; background: #f7fbfa; border: 1px solid var(--soft-line); border-radius: 9px; }
.diagnostic-list input { position: absolute; left: 14px; top: 14px; width: 17px; height: 17px; accent-color: var(--teal); }
.diagnostic-list li:has(input:checked) { color: #718686; background: #edf6f4; text-decoration: line-through; }

footer { display: grid; grid-template-columns: 1fr auto auto; gap: 24px; align-items: center; max-width: 1000px; margin: 36px auto 0; padding: 24px 2px 0; color: var(--muted); border-top: 1px solid var(--line); font-size: 13px; }
footer span { color: var(--ink); font-weight: 700; }
footer p { margin: 0; }
footer a { text-decoration: none; }
.toast { position: fixed; z-index: 300; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 9px 15px; color: white; background: #143d40; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

body.focus-mode .sidebar { transform: translateX(-100%); }
body.focus-mode .page-shell { margin-left: 0; }
body.focus-mode .topbar { grid-template-columns: 282px minmax(280px, 640px) auto; }

@media (max-width: 1050px) {
  :root { --sidebar: 250px; }
  .topbar { gap: 18px; }
  .course-hero { grid-template-columns: 1fr; }
  .hero-map { max-width: 460px; }
  .lesson-links { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  html { scroll-padding-top: 82px; }
  .topbar { height: 66px; grid-template-columns: 40px minmax(0, 1fr) 42px; gap: 8px; padding: 0 14px; }
  .brand, .reading-mode, kbd { display: none; }
  .search-shell { grid-column: 2; }
  .search-shell input { height: 40px; padding-left: 36px; font-size: 14px; }
  .search-icon { left: 11px; top: 5px; }
  .menu-button { display: block; width: 36px; height: 36px; font-size: 20px; }
  .progress-track { top: 65px; }
  .sidebar { top: 0; z-index: 210; width: min(320px, 86vw); transform: translateX(-102%); background: #f2fbfa; box-shadow: 18px 0 45px rgba(20,61,64,.16); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .close-menu { display: block; position: absolute; right: 0; top: 0; width: 34px; height: 34px; font-size: 25px; }
  .scrim { position: fixed; z-index: 200; inset: 0; display: block; width: 100%; background: rgba(14,47,49,.3); border: 0; backdrop-filter: blur(2px); }
  .scrim[hidden] { display: none; }
  .page-shell { margin-left: 0; padding: 92px 16px 38px; }
  .course-hero { padding: 30px 24px; border-radius: 20px 20px 20px 6px; }
  .hero-copy h1 { font-size: clamp(37px, 11vw, 55px); }
  .hero-intro { font-size: 16px; }
  .day-strip { grid-template-columns: minmax(0, 1fr); }
  .strip-label { min-width: 0; flex-direction: row; align-items: baseline; justify-content: space-between; padding: 2px 5px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .lesson-links { min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 9px 0 0; }
  .lesson-link { min-width: 0; }
  .chapter { padding: 25px 21px; }
  .chapter > h1 { padding-right: 34px; font-size: 27px; }
  .topic { padding-left: 18px; }
  .document-meta { align-items: start; }
  .document-meta h2 { font-size: 27px; }
  .checklist-progress { display: none !important; }
  footer { grid-template-columns: 1fr auto; }
  footer p { display: none; }
  body.focus-mode .topbar { grid-template-columns: 40px minmax(0, 1fr) 42px; }
}

@media (max-width: 520px) {
  .topbar { grid-template-columns: 40px 1fr; }
  .search-shell { grid-column: 2; }
  .hero-copy h1 { font-size: 39px; }
  .hero-stats { gap: 10px 16px; }
  .hero-map { padding-left: 23px; }
  .lesson-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-meta { flex-direction: column; }
  .meta-actions { align-self: stretch; }
  .meta-actions button { width: 100%; }
  .chapter { border-radius: 15px 15px 15px 5px; }
  .chapter > .heading-action { right: 20px; top: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
