:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-soft: #eef5f4;
  --text: #17201f;
  --muted: #61706d;
  --line: #d8e2df;
  --accent: #0f766e;
  --accent-strong: #075d57;
  --accent-soft: #dff1ef;
  --blue: #315f9a;
  --red: #b64b4b;
  --amber: #a66d1f;
  --green: #3c7a48;
  --violet: #6a5b9a;
  --shadow: 0 16px 42px rgba(31, 48, 45, 0.1);
  --radius: 8px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111716;
  --surface: #18211f;
  --surface-soft: #202c2a;
  --text: #edf4f2;
  --muted: #aab8b4;
  --line: #31413e;
  --accent: #40b9aa;
  --accent-strong: #7bd7cb;
  --accent-soft: #173c39;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body,
button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.reading-progress {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 100;
  width: 0;
  height: 4px;
  background: var(--accent);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  padding: 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 210px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.top-nav a {
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  padding: 10px 12px;
}

.top-nav a:hover,
.top-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.theme-toggle,
.dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.section,
.section-band {
  padding: 72px max(28px, calc((100vw - 1180px) / 2));
}

.muted-band {
  background: var(--surface-soft);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(420px, 1.14fr);
  gap: 34px;
  align-items: center;
  min-height: calc(100vh - 68px);
  padding-top: 38px;
  padding-bottom: 38px;
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  max-width: 720px;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.16;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: 0;
}

p,
li {
  color: var(--muted);
  line-height: 1.75;
}

.hero-lead {
  max-width: 720px;
  font-size: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 24px;
}

.primary-action,
.secondary-action,
.chapter-card button,
.route-tab,
.case-filter button,
.quiz-option,
.complete-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 700;
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.primary-action:hover,
.complete-button:hover {
  background: var(--accent-strong);
}

.secondary-action:hover,
.chapter-card button:hover,
.route-tab:hover,
.case-filter button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 640px;
}

.quick-stats div,
.progress-card,
.score-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.quick-stats strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.quick-stats span,
.progress-card span,
.score-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.hero-media {
  margin: 0;
  min-width: 0;
}

.hero-media img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-head {
  max-width: 900px;
  margin-bottom: 28px;
}

.split-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: none;
}

.frame-grid,
.chapter-grid,
.systems-grid,
.case-grid,
.source-grid,
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.frame-card,
.chapter-card,
.system-card,
.case-card,
.source-card,
.glossary-card,
.route-panel,
.chip-note,
.workflow-step,
.timeline-item,
.quiz-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.frame-card,
.chapter-card,
.system-card,
.case-card,
.source-card,
.glossary-card,
.route-panel,
.chip-note,
.quiz-card {
  padding: 20px;
}

.frame-index,
.tag,
.chapter-meta,
.source-type,
.term-category {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
}

.frame-card ul,
.chapter-dialog ul,
.route-panel ul {
  padding-left: 20px;
  margin-bottom: 0;
}

.route-tabs,
.case-filter,
.glossary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.route-tab,
.case-filter button,
.glossary-filters button {
  min-height: 38px;
  padding: 0 14px;
}

.route-tab.is-active,
.case-filter button.is-active,
.glossary-filters button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.route-panel {
  min-height: 230px;
}

.route-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.route-steps span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--muted);
}

.progress-card,
.score-card {
  width: 180px;
  flex: 0 0 auto;
}

.progress-card strong,
.score-card strong {
  display: block;
  font-size: 24px;
}

.mini-progress {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.mini-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.chapter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chapter-card {
  display: grid;
  min-height: 310px;
  align-content: space-between;
  gap: 18px;
}

.chapter-card h3 {
  min-height: 54px;
}

.chapter-card button {
  width: 100%;
  min-height: 42px;
  font-weight: 700;
}

.chapter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tag {
  background: var(--surface-soft);
  color: var(--muted);
}

.chapter-card.is-done {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent);
}

.systems-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.system-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.system-card p {
  margin-bottom: 0;
  font-size: 14px;
}

.comparison-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.comparison-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 14px;
  text-align: left;
  vertical-align: top;
}

.comparison-table th {
  background: var(--surface-soft);
  color: var(--text);
}

.comparison-table tr:last-child td {
  border-bottom: 0;
}

.chip-lab {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.chip-visual {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.chip-body {
  position: absolute;
  inset: 72px 70px;
  border: 2px solid color-mix(in srgb, var(--blue) 45%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(49, 95, 154, 0.08), transparent 31%, rgba(182, 75, 75, 0.06) 32%, transparent 60%),
    var(--surface);
}

.flow-line {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 28px;
  border-radius: 999px;
}

.flow-line.top {
  top: 36px;
  background: repeating-linear-gradient(90deg, rgba(49, 95, 154, 0.22) 0 34px, rgba(49, 95, 154, 0.42) 34px 48px);
}

.flow-line.bottom {
  bottom: 36px;
  background: repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.2) 0 34px, rgba(15, 118, 110, 0.4) 34px 48px);
}

.cells {
  position: absolute;
  left: 14%;
  right: 14%;
  top: 124px;
  height: 34px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 12px 18px, #db7777 0 8px, transparent 9px),
    radial-gradient(circle at 40px 16px, #d95e67 0 8px, transparent 9px);
  background-size: 52px 34px;
}

.porous-line {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 164px;
  height: 10px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--amber) 0 9px, transparent 9px 18px);
  opacity: 0.78;
}

.matrix {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 188px;
  height: 54px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 20px 22px, rgba(60, 122, 72, 0.42) 0 4px, transparent 5px),
    linear-gradient(135deg, rgba(166, 109, 31, 0.18), rgba(106, 91, 154, 0.14));
  background-size: 42px 42px, auto;
}

.electrodes {
  position: absolute;
  top: 48px;
  right: 34px;
  width: 54px;
  height: 240px;
  border-left: 3px solid var(--amber);
  border-right: 3px solid var(--amber);
}

.electrodes::before,
.electrodes::after {
  content: "";
  position: absolute;
  left: -12px;
  right: -12px;
  height: 3px;
  background: var(--amber);
}

.electrodes::before {
  top: 42px;
}

.electrodes::after {
  bottom: 42px;
}

.hotspot {
  position: absolute;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 7px 11px;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.hotspot.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.top-flow {
  top: 38px;
  left: 12%;
}

.cell-layer {
  top: 184px;
  left: 34%;
}

.membrane {
  top: 214px;
  left: 50%;
}

.lower-flow {
  bottom: 46px;
  left: 18%;
}

.sensor {
  top: 106px;
  right: 10%;
}

.chip-note {
  display: grid;
  align-content: center;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.workflow-step {
  padding: 18px;
}

.workflow-step span,
.timeline-item span {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  margin-bottom: 12px;
}

.case-filter {
  margin-bottom: 18px;
}

.case-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.case-card h3 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.case-card h3 small {
  color: var(--muted);
  font-size: 13px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.timeline-item span {
  width: auto;
  height: 36px;
}

.search-box {
  display: grid;
  gap: 6px;
  width: min(360px, 100%);
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.glossary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.glossary-card h3 {
  margin-top: 10px;
}

.glossary-card .english {
  color: var(--blue);
  font-weight: 700;
}

:root[data-theme="dark"] .glossary-card .english {
  color: #95bff5;
}

.quiz-list {
  display: grid;
  gap: 16px;
}

.quiz-card h3 {
  font-size: 18px;
}

.quiz-options {
  display: grid;
  gap: 9px;
}

.quiz-option {
  display: block;
  width: 100%;
  min-height: 46px;
  text-align: left;
  padding: 10px 12px;
}

.quiz-option.is-correct {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
}

.quiz-option.is-wrong {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
}

.quiz-explain {
  display: none;
  margin: 12px 0 0;
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

.quiz-card.is-answered .quiz-explain {
  display: block;
}

.source-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.source-card a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.source-card a:hover {
  text-decoration: underline;
}

.mobile-nav {
  display: none;
}

.chapter-dialog {
  width: min(1120px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}

.chapter-dialog::backdrop {
  background: rgba(10, 18, 16, 0.58);
}

.dialog-close {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px;
  z-index: 2;
}

#chapterDialogContent {
  padding: 28px;
}

.chapter-dialog h2 {
  max-width: 880px;
}

.chapter-reader-head {
  max-width: 900px;
  margin-bottom: 18px;
}

.chapter-reader-head p:last-child {
  font-size: 17px;
}

.chapter-layout,
.dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.34fr);
  gap: 18px;
  align-items: start;
}

.chapter-main {
  display: grid;
  gap: 14px;
}

.chapter-sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.lesson-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}

.lesson-block h3 {
  margin-bottom: 10px;
}

.lesson-block p:last-child,
.dialog-aside p:last-child,
.lesson-block ul:last-child,
.dialog-aside ul:last-child {
  margin-bottom: 0;
}

.focus-block,
.case-block {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 46%, var(--surface));
}

.analogy-block {
  border-color: color-mix(in srgb, var(--amber) 32%, var(--line));
  background: color-mix(in srgb, var(--amber) 9%, var(--surface));
}

.hint-block {
  border-color: color-mix(in srgb, var(--blue) 32%, var(--line));
}

.checkpoint-block {
  border-color: color-mix(in srgb, var(--green) 34%, var(--line));
}

.full-lessons {
  display: grid;
  gap: 26px;
}

.full-lesson {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.full-lesson-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.36fr);
  gap: 18px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 22px;
}

.full-lesson-head h3 {
  font-size: clamp(24px, 3vw, 34px);
}

.full-lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.32fr);
  gap: 18px;
  align-items: start;
  background: var(--bg);
  padding: 18px;
}

.inline-sidebar {
  top: 88px;
}

.dialog-aside {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 16px;
}

.dialog-aside ul,
.lesson-block ul {
  padding-left: 20px;
}

.dialog-aside li,
.lesson-block li {
  margin-bottom: 8px;
}

.warning-aside {
  border-color: color-mix(in srgb, var(--red) 26%, var(--line));
}

.complete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 800;
  padding: 0 16px;
}

@media (max-width: 1080px) {
  .top-nav {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero-media {
    max-height: 440px;
    overflow: hidden;
  }

  .chapter-grid,
  .systems-grid,
  .case-grid,
  .glossary-grid,
  .source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header {
    min-height: 60px;
    padding: 0 14px;
  }

  .brand {
    min-width: 0;
  }

  .brand small {
    display: none;
  }

  .section,
  .section-band {
    padding: 48px 16px;
  }

  .hero {
    min-height: auto;
    padding-top: 28px;
  }

  h1 {
    font-size: 38px;
  }

  h2 {
    font-size: 29px;
  }

  .quick-stats,
  .frame-grid,
  .chapter-grid,
  .systems-grid,
  .case-grid,
  .glossary-grid,
  .source-grid,
  .workflow,
  .chip-lab,
  .full-lesson-head,
  .full-lesson-layout,
  .chapter-layout,
  .dialog-grid {
    grid-template-columns: 1fr;
  }

  .chapter-sidebar {
    position: static;
  }

  .quick-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-head {
    display: grid;
  }

  .progress-card,
  .score-card {
    width: 100%;
  }

  .chip-visual {
    min-height: 360px;
  }

  .chip-body {
    inset: 76px 24px;
  }

  .hotspot {
    font-size: 12px;
    padding: 6px 9px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .mobile-nav {
    position: sticky;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
  }

  .mobile-nav a {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    text-decoration: none;
    padding: 10px 4px;
  }

  .mobile-nav a.is-active {
    color: var(--accent-strong);
    font-weight: 800;
  }

  body {
    padding-bottom: 44px;
  }
}
