:root {
  --ink: #111c2d;
  --muted: #65748b;
  --line: #d7e1ea;
  --paper: #f5f8fb;
  --panel: #ffffff;
  --nav: #102238;
  --nav-2: #183451;
  --blue: #2364aa;
  --blue-deep: #183f73;
  --orange: #d96c2c;
  --yellow: #f2b43f;
  --green: #15887a;
  --shadow: 0 16px 36px rgba(20, 34, 55, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(16,34,56,.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(16,34,56,.04) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .22s ease;
}
.shell.nav-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}
.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  color: #e7f0fa;
  background: linear-gradient(180deg, var(--nav), #0b1727);
  border-right: 1px solid rgba(255,255,255,.12);
  padding: 18px 16px;
  transition: padding .22s ease;
}
.nav-toggle {
  position: sticky;
  top: 8px;
  z-index: 10;
  float: right;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  margin: -4px -2px 10px 8px;
}
.nav-toggle:hover { background: rgba(255,255,255,.18); }
.nav-toggle:focus-visible {
  outline: 2px solid #8bd8ff;
  outline-offset: 2px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.22);
  background: linear-gradient(135deg, #235e9a, #1a887e);
  border-radius: 8px;
  font-weight: 800;
}
.brand h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.brand p { margin: 4px 0 0; color: #aabbd0; font-size: 13px; }
.shell.nav-collapsed .nav {
  padding: 14px 8px;
  overflow: visible;
}
.shell.nav-collapsed .nav-toggle {
  float: none;
  margin: 0 auto 12px;
}
.shell.nav-collapsed .nav-toggle span {
  transform: rotate(180deg);
}
.shell.nav-collapsed .brand {
  justify-content: center;
  padding-bottom: 0;
  border-bottom: 0;
}
.shell.nav-collapsed .brand-mark {
  width: 44px;
  height: 44px;
  font-size: 13px;
}
.shell.nav-collapsed .brand-copy,
.shell.nav-collapsed .stats,
.shell.nav-collapsed .search-panel,
.shell.nav-collapsed .filters,
.shell.nav-collapsed .nav section:not(:first-of-type),
.shell.nav-collapsed .question-index {
  display: none;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.stats div {
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(255,255,255,.07);
  border-radius: 8px;
  padding: 9px 8px;
}
.stats b { display: block; font-size: 20px; }
.stats span { color: #aabbd0; font-size: 11px; }

.search-panel {
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(255,255,255,.055);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}
.search-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
}
.clear-search {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: #dfeaf7;
  line-height: 1;
}
.search-box { position: relative; }
.search-box::before {
  content: "⌕";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: #9fb0c6;
  font-weight: 800;
}
.filters { display: grid; gap: 9px; margin-bottom: 16px; }
.search-box input, .filters select {
  width: 100%;
  color: #f8fbff;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  padding: 10px 11px;
  outline: none;
}
.search-box input { padding-left: 34px; }
.search-box input::placeholder { color: #9fb0c6; }
.filters option { color: #17243a; background: #fff; }
.search-hint {
  margin-top: 7px;
  color: #9fb0c6;
  font-size: 12px;
  line-height: 1.45;
}
.search-result {
  margin-top: 8px;
  min-height: 20px;
  color: #dfeaf7;
  font-size: 13px;
}
.search-result strong { color: #fff; }
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.segmented button {
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color: #dfeaf7;
  border-radius: 8px;
  padding: 8px;
}
.segmented .active { background: #fff; color: #122640; }
.nav-title {
  margin: 14px 0 8px;
  color: #9fb0c6;
  font-size: 12px;
}
.category-list, .question-index-list { display: grid; gap: 7px; }
.cat-btn, .q-btn {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #edf5ff;
  border-radius: 8px;
  padding: 9px 10px;
  text-align: left;
}
.cat-btn {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.cat-btn.active, .q-btn.active {
  color: #102238;
  background: #fff;
  border-color: #fff;
}
.question-index-list {
  max-height: 330px;
  overflow: auto;
  padding-right: 4px;
}
.q-btn small {
  display: block;
  color: inherit;
  opacity: .7;
  margin-bottom: 3px;
}

.stage { padding: 22px; min-width: 0; }
.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.crumb { color: var(--blue-deep); font-weight: 800; }
.progress { color: var(--muted); font-size: 13px; margin-top: 4px; }
.nav-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost, .primary {
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: #193251;
}
.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.question-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 34vw);
  gap: 18px;
  align-items: start;
}
.textbook-panel {
  grid-column: 1 / -1;
  margin-top: 0;
}
.question-panel, .visual-panel {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.question-panel { padding: 20px 22px; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef5fb;
  color: #294760;
  font-size: 13px;
}
.badge.type { background: var(--blue); color: #fff; }
.question-panel h2 {
  margin: 0 0 16px;
  font-size: 28px;
  line-height: 1.38;
  letter-spacing: 0;
}
.options { display: grid; gap: 9px; margin-bottom: 12px; }
.option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 18px;
  line-height: 1.55;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

@media (min-width: 1081px) {
  .shell.nav-collapsed .stage {
    padding: 28px 34px;
  }
  .shell.nav-collapsed .question-layout {
    grid-template-columns: minmax(0, 1fr) minmax(460px, 32vw);
    gap: 22px;
  }
  .shell.nav-collapsed .question-panel {
    padding: 28px 32px;
  }
  .shell.nav-collapsed .question-panel h2 {
    font-size: 34px;
    line-height: 1.42;
    margin-bottom: 20px;
  }
  .shell.nav-collapsed .options {
    gap: 12px;
  }
  .shell.nav-collapsed .option {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    padding: 13px 16px;
    font-size: 22px;
    line-height: 1.58;
  }
  .shell.nav-collapsed .letter {
    width: 40px;
    height: 40px;
  }
  .shell.nav-collapsed .drawer {
    font-size: 18px;
    line-height: 1.78;
  }
  .shell.nav-collapsed .drawer h3 {
    font-size: 20px;
  }
}
.option.correct-answer {
  border-color: #f09a43;
  background: linear-gradient(90deg, #fff1dd 0%, #fffaf4 100%);
  box-shadow: 0 0 0 2px rgba(240, 122, 50, .2), 0 10px 24px rgba(157, 86, 30, .14);
}
.option.correct-answer .letter {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(240, 122, 50, .18);
}
.letter {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--blue-deep);
  font-weight: 800;
}
.essay-note {
  border: 1px dashed #a8bfd2;
  background: #f7fbff;
  border-radius: 8px;
  padding: 14px;
  color: #35506a;
  line-height: 1.8;
}
.reveal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 0;
}
.reveal {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  color: #fff;
  font-weight: 800;
}
.reveal.knowledge { background: var(--green); }
.reveal.answer { background: var(--orange); }
.drawer {
  margin-top: 10px;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.68;
}
.drawer h3 { margin: 0 0 6px; font-size: 17px; }
.knowledge-drawer { border: 1px solid #afd9d1; background: #eefaf7; }
.answer-drawer { border: 1px solid #edc082; background: #fff7e8; }
#answerText {
  margin: 0;
}
.answer-summary {
  font-weight: 800;
  color: #703c0e;
}
.answer-main {
  margin-top: 8px;
  white-space: pre-wrap;
}
.lesson-section {
  margin-top: 12px;
  border-top: 1px solid rgba(174, 123, 55, .22);
  padding-top: 10px;
}
.lesson-section h4 {
  margin: 0 0 6px;
  color: #7c4a14;
  font-size: 15px;
}
.lesson-section p {
  margin: 6px 0 0;
  color: #4d3516;
  line-height: 1.72;
}
.option-analysis-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.option-analysis {
  border: 1px solid rgba(174, 123, 55, .28);
  background: rgba(255,255,255,.62);
  border-radius: 8px;
  padding: 9px 10px;
}
.option-analysis.correct {
  border-color: rgba(217, 108, 44, .55);
  background: #fff0dc;
}
.option-analysis-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #5f3911;
}
.option-analysis-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
.option-analysis-letter {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #8c5c22;
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}
.option-analysis.correct .option-analysis-letter {
  background: var(--orange);
}
.option-analysis-head em {
  margin-left: auto;
  color: #8b5a18;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  flex: 0 0 auto;
}
.option-analysis p {
  margin: 7px 0 0;
  color: #4d3516;
}
#knowledgeText {
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.78;
}
.textbook-evidence {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(174, 123, 55, .26);
}
.textbook-evidence[hidden] { display: none; }
.textbook-evidence h4 {
  margin: 0;
  color: #7c4a14;
  font-size: 16px;
}
.textbook-card {
  border: 1px solid #e5c08d;
  background: #fffdf8;
  border-radius: 8px;
  padding: 10px;
  margin: 0;
  overflow: hidden;
}
.textbook-card strong {
  display: block;
  margin-bottom: 8px;
  color: #5c3a15;
}
.textbook-card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: scale-down;
  border: 1px solid #ead9bf;
  border-radius: 6px;
  background: #fff;
}
.textbook-card small {
  display: block;
  margin-top: 7px;
  color: #75562d;
  line-height: 1.55;
}

.visual-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
  position: relative;
}
.visual-frame {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 22% 16%, rgba(49,198,212,.24), transparent 30%),
    linear-gradient(135deg, #08182a, #132e4a 58%, #0d2037);
  height: clamp(240px, 24vw, 330px);
  width: 100%;
  min-width: 0;
}
.visual-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
  opacity: 1;
  filter: none;
  cursor: zoom-in;
}
.zoomable-image:focus-visible {
  outline: 3px solid rgba(240, 122, 50, .9);
  outline-offset: 3px;
}
.visual-frame img.textbook-source {
  object-fit: contain;
  background: #fff;
}
.visual-frame img.hidden { display: none; }
#demoCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  display: none;
}
.visual-frame[data-three="ready"] #demoCanvas { z-index: 1; }
.visual-frame[data-three="ready"] .visual-fallback.show { display: none; }
.visual-fallback {
  display: none;
  position: absolute;
  inset: 0;
  height: 100%;
  padding: 20px;
  place-items: center;
  text-align: center;
  background: linear-gradient(135deg, #eff6fb, #dceaf3);
  color: var(--blue-deep);
  font-weight: 800;
  z-index: 0;
}
.visual-fallback.show { display: grid; }
.demo-badge {
  display: none;
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  border: 1px solid rgba(255,255,255,.42);
  background: rgba(15, 34, 56, .72);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  backdrop-filter: blur(6px);
}
.visual-label {
  display: none;
  position: absolute;
  z-index: 3;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: rgba(10, 24, 42, .86);
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
}
.visual-label span { display: block; font-weight: 800; }
.visual-label small { display: block; margin-top: 3px; color: #bfd2e5; }
.visual-brief {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfe;
  padding: 8px;
}
.brief-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.brief-head span {
  color: var(--muted);
  font-size: 12px;
}
.brief-head strong {
  color: var(--blue-deep);
  font-size: 15px;
  text-align: right;
}
.visual-steps {
  display: grid;
  gap: 8px;
}
.visual-step {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid #dbe5ee;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
}
.visual-step.active {
  border-color: #f09a43;
  background: #fff7e8;
  box-shadow: 0 0 0 2px rgba(240, 122, 50, .14);
}
.visual-step b {
  color: var(--blue-deep);
  font-size: 13px;
}
.visual-step.active b { color: #9b4f12; }
.visual-step span {
  color: #24384f;
  line-height: 1.55;
  font-size: 13px;
}
.term-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.term {
  border: 1px solid var(--line);
  background: #f8fbfe;
  border-radius: 999px;
  padding: 7px 10px;
  color: #28455f;
  font-size: 13px;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  gap: 12px;
  padding: 24px;
  background: rgba(4, 13, 24, .88);
}
.image-lightbox[hidden] {
  display: none;
}
.image-lightbox img {
  max-width: min(96vw, 1400px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0,0,0,.42);
}
.image-lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: #10243a;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.image-lightbox-caption {
  max-width: min(92vw, 1000px);
  color: #e9f2fb;
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
}
body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; }
  .shell.nav-collapsed { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; }
  .nav-toggle { display: none; }
  .shell.nav-collapsed .nav {
    padding: 14px;
    overflow: auto;
  }
  .shell.nav-collapsed .brand-copy,
  .shell.nav-collapsed .stats,
  .shell.nav-collapsed .search-panel,
  .shell.nav-collapsed .filters,
  .shell.nav-collapsed .nav section:not(:first-of-type),
  .shell.nav-collapsed .question-index {
    display: grid;
  }
  .shell.nav-collapsed .brand {
    justify-content: flex-start;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,.12);
  }
  .shell.nav-collapsed .brand-mark {
    width: 54px;
    height: 54px;
    font-size: 16px;
  }
  .question-index-list { max-height: 220px; }
  .question-layout { grid-template-columns: 1fr; }
  .textbook-panel { grid-column: auto; }
  .visual-frame { height: clamp(240px, 52vw, 340px); }
}
@media (max-width: 640px) {
  .stage { padding: 10px; }
  .nav { padding: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stage-toolbar { align-items: stretch; flex-direction: column; }
  .nav-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-actions #resetBtn { grid-column: 1 / -1; }
  .question-panel { padding: 16px; }
  .question-panel h2 { font-size: 21px; }
  .option { font-size: 16px; grid-template-columns: 30px minmax(0, 1fr); }
  .letter { width: 30px; height: 30px; }
  .reveal-actions { display: grid; grid-template-columns: 1fr; }
  .textbook-card { padding: 8px; }
  .visual-frame { height: 240px; }
  .visual-step { grid-template-columns: 1fr; }
}
