* {
  box-sizing: border-box;
}

:root {
  --ink: #263142;
  --muted: #6c778b;
  --line: #dde4ef;
  --bg: #eef3f8;
  --paper: #ffffff;
  --coral: #ef6351;
  --coral-soft: #ffe7e2;
  --sun: #f2a93b;
  --sun-soft: #fff2d9;
  --mint: #189b8b;
  --mint-soft: #ddf3ee;
  --violet: #7c5cd6;
  --violet-soft: #ece6fc;
  --blue: #3d7fd0;
  --blue-soft: #e3eefc;
  --green: #2c9a63;
  --green-soft: #e1f5e9;
  --danger: #d94846;
  --shadow: 0 2px 10px rgba(38, 49, 66, 0.07);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 74px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.68;
}

button,
input,
textarea {
  font: inherit;
}

button,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(150px, 230px);
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  color: #fff;
  font-weight: 800;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--violet), var(--coral));
  box-shadow: 0 4px 10px rgba(124, 92, 214, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.brand-text strong {
  font-size: 14px;
  letter-spacing: 0;
}

.brand-text small {
  color: var(--muted);
  font-size: 11px;
}

.lesson-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.lesson-chip span {
  color: var(--muted);
  font-size: 11px;
}

.lesson-chip b {
  font-size: 15px;
}

.top-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.top-progress > span {
  min-width: 34px;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bar {
  width: 100px;
  height: 8px;
  overflow: hidden;
  background: #e7ecf3;
  border-radius: 999px;
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sun), var(--coral));
  transition: width 0.35s ease;
}

.layout {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  width: min(1280px, calc(100% - 24px));
  margin: 16px auto 30px;
}

.rail {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.rail-title {
  margin: 0 8px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}

.rail-link {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  color: #4f5b6d;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.3;
  transition: background 0.15s, color 0.15s;
}

.rail-link i {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafd;
}

.rail-link:hover,
.rail-link.is-active {
  color: var(--ink);
  background: var(--sun-soft);
}

.rail-link.is-done i {
  color: #fff;
  background: var(--mint);
  border-color: var(--mint);
}

.rail-note {
  margin: 10px 5px 2px;
  padding: 10px;
  border: 1px dashed #b9c7da;
  border-radius: 8px;
  background: #f8fbff;
}

.rail-note span {
  color: var(--muted);
  font-size: 11px;
}

.rail-note b {
  display: block;
  margin: 2px 0;
  font-size: 13px;
}

.rail-note p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.sheet {
  min-width: 0;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.module {
  position: relative;
  padding: 16px 18px 18px;
  border-bottom: 1px solid #edf1f6;
  scroll-margin-top: 76px;
}

.module:last-child {
  border-bottom: 0;
}

.module-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: -16px -18px 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone, var(--mint)) 13%, #fff), #fff 70%);
  border-bottom: 1px solid #edf1f6;
}

.module-head .step {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border-radius: 8px;
  background: var(--tone, var(--mint));
}

.module-head h1,
.module-head h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: 0;
}

.module-head h1 {
  font-size: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.status-chip {
  align-self: center;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}

.tone-sun {
  --tone: var(--sun);
}

.tone-coral {
  --tone: var(--coral);
}

.tone-mint {
  --tone: var(--mint);
}

.tone-violet {
  --tone: var(--violet);
}

.tone-blue {
  --tone: var(--blue);
}

.tone-grape {
  --tone: #a84a94;
}

.module-body {
  min-width: 0;
}

.module-body > p,
.lead {
  margin: 7px 0;
}

.module-body > p:first-child {
  margin-top: 0;
}

.lead {
  font-weight: 600;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(270px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.split .draw-box {
  margin-top: 2px;
}

.map-lead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 2px 0 10px;
}

.map-lead p {
  margin: 0;
}

.map-stats {
  display: flex;
  gap: 8px;
}

.map-stats div {
  min-width: 64px;
  padding: 8px 10px;
  text-align: center;
  border-radius: 8px;
  background: var(--sun-soft);
}

.map-stats b {
  display: block;
  color: #9a6510;
  font-size: 20px;
  line-height: 1.1;
}

.map-stats span {
  color: var(--muted);
  font-size: 11px;
}

.chapter-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  margin: 8px 0 10px;
  padding: 8px 10px;
  border: 1px solid #e7eef6;
  border-radius: 8px;
  background: #fbfdff;
  scrollbar-width: thin;
}

.ch {
  flex: none;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}

.ch.is-current {
  color: #fff;
  border-color: var(--coral);
  background: var(--coral);
}

.ch.is-locked {
  cursor: not-allowed;
  opacity: 0.7;
}

.chapter-strip .arrow {
  flex: none;
  color: #b3c0d1;
}

.fold {
  margin-top: 10px;
  border-top: 1px dashed #d8e0eb;
}

.fold > summary,
.exercise > summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
  list-style: none;
}

.fold > summary {
  padding: 8px 0 2px;
  font-size: 13px;
}

.fold > summary::before,
.exercise > summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 8px 2px 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
  transition: transform 0.15s;
}

.fold[open] > summary::before,
.exercise[open] > summary::before {
  transform: rotate(45deg) translateY(0);
}

.fold > summary::-webkit-details-marker,
.exercise > summary::-webkit-details-marker {
  display: none;
}

.chapter-list {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  padding: 0 0 0 18px;
}

.chapter-list li {
  font-size: 13px;
}

.chapter-list b {
  display: inline-block;
  min-width: 116px;
}

.chapter-list span {
  color: #5c687b;
}

.relation {
  display: grid;
  gap: 4px;
  margin: 8px 0 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--blue-soft);
}

.relation p {
  margin: 0;
  font-size: 12px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.task-grid p {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #dce9f7;
  border-radius: 8px;
  background: var(--blue-soft);
  font-size: 13px;
}

.start-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.start-row > span {
  color: var(--muted);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 13px;
  cursor: pointer;
  color: #fff;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--blue);
  font-weight: 700;
  transition: filter 0.15s, transform 0.1s;
}

.btn:hover {
  filter: brightness(0.95);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: var(--coral);
  background: var(--coral);
}

.btn.ghost {
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.draw-box {
  margin: 0;
  padding: 10px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #fbfdff;
}

.draw-box svg {
  display: block;
  width: 100%;
  height: auto;
}

.draw-box figcaption,
.lab-figure figcaption,
.proof-figure figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.ground {
  fill: #f2f5f8;
  stroke: #a8b4c5;
  stroke-width: 1.5;
}

.edge-thick,
.edge-strong {
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
}

.edge-thin {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.edge-mint {
  stroke: var(--mint);
  stroke-width: 4;
  stroke-linecap: round;
}

.edge-coral {
  stroke: var(--coral);
  stroke-width: 3;
  stroke-linecap: round;
}

.dashed {
  stroke-dasharray: 8 5;
}

.triangle-fill {
  fill: #bce9df;
  stroke: none;
}

.right-mark {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
}

.right-mark.dark {
  stroke: #fff;
}

.dot {
  fill: var(--coral);
  stroke: #fff;
  stroke-width: 1.5;
}

.tag {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.lab-figure svg text,
.proof-figure svg text {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

.dyn-label,
.proof-label,
.proof-dim,
.proof-corner {
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(38, 49, 66, 0.72);
  stroke-width: 3px;
}

.dyn-label {
  fill: #fff;
  font-size: 13px;
}

.proof-label {
  fill: #2a3040;
  font-size: 18px;
}

.proof-dim {
  fill: #344056;
  stroke: #fff;
  stroke-width: 2.5px;
  font-size: 12px;
}

.proof-corner {
  fill: #7a1731;
  stroke: #fff;
  stroke-width: 2px;
  font-size: 13px;
}

.label {
  fill: #3a4657;
  font-size: 11px;
}

.option-group,
.answer-form {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #dfe7f0;
  border-radius: 8px;
  background: #fafcff;
}

.group-question {
  margin: 0 0 8px;
  font-weight: 700;
}

.option-group:has(.is-ok) {
  border-color: #a9ddc8;
  background: #f1fbf5;
}

.option-group:has(.is-bad) {
  border-color: #f2c4c2;
  background: #fff7f6;
}

.option {
  display: block;
  width: 100%;
  margin: 5px 0;
  padding: 7px 10px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 14px;
  line-height: 1.45;
}

.option:hover {
  border-color: #aebfda;
}

.option:disabled {
  cursor: default;
}

.option.is-ok {
  color: #15694a;
  border-color: #5bb68d;
  background: var(--green-soft);
  font-weight: 700;
}

.option.is-bad {
  color: #8f2928;
  border-color: #df8e8c;
  background: #fbe9e8;
}

.option-feedback,
.form-msg {
  min-height: 0;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.option-feedback.is-good,
.form-msg.is-good {
  color: #15694a;
}

.option-feedback.is-bad,
.form-msg.is-bad {
  color: #a63a38;
}

.answer-form label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 700;
}

.inline-input {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-input input {
  width: 180px;
  min-height: 36px;
  padding: 4px 10px;
  color: var(--ink);
  border: 1px solid #c6d2e2;
  border-radius: 7px;
  background: #fff;
  outline: none;
}

.inline-input input:focus,
.free-answer:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(24, 155, 139, 0.14);
}

.free-answer {
  width: 100%;
  margin: 8px 0;
  padding: 8px 10px;
  color: var(--ink);
  resize: vertical;
  border: 1px solid #c6d2e2;
  border-radius: 7px;
  outline: none;
}

.formula-panel {
  margin: 10px 0;
  padding: 10px 12px;
  color: #5a3514;
  border-radius: 8px;
  background: var(--sun-soft);
  font-size: 13px;
}

.formula-panel.small {
  margin-top: 0;
}

.formula {
  margin: 4px 0;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 2px;
  color: #a85a06;
}

sup {
  font-size: 0.65em;
}

.check-list {
  margin: 6px 0;
  padding-left: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  margin: 5px 0;
  padding-left: 22px;
  font-size: 14px;
}

.check-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
}

.lab-shell {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(320px, 1.25fr);
  gap: 10px;
  align-items: start;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid #cfe6e0;
  border-radius: 8px;
  background: #f8fdfb;
}

.lab-controls {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.slider-block {
  display: grid;
  gap: 4px;
}

.slider-block label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--mint);
}

.presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 9px;
  cursor: pointer;
  color: #0e6f63;
  border: 1px solid #a7d9cd;
  border-radius: 999px;
  background: #e6f7f1;
  font-size: 12px;
  font-weight: 700;
}

.chip:hover,
.seg.is-on {
  color: #fff;
  background: var(--mint);
  border-color: var(--mint);
}

.lab-readout {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background: var(--sun-soft);
  grid-column: 1 / -1;
  grid-row: 2;
}

.lab-readout div {
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
}

.lab-readout span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.lab-readout b {
  font-size: 17px;
}

.lab-figure {
  grid-column: 2;
  grid-row: 1 / 3;
  margin: 0;
  min-width: 0;
}

.lab-figure svg,
.proof-figure svg {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid #dce7e3;
  border-radius: 8px;
}

.lab-figure svg {
  background-image:
    linear-gradient(rgba(207, 229, 221, 0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(207, 229, 221, 0.4) 1px, transparent 1px);
  background-size: 16px 16px;
}

.small-note {
  margin-top: 8px;
}

.proof-shell {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(300px, 1.3fr);
  gap: 10px;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid #cfe0f1;
  border-radius: 8px;
  background: #f8fbff;
}

.proof-controls {
  display: grid;
  align-content: start;
  gap: 9px;
}

.proof-controls label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.proof-controls output {
  min-width: 20px;
  color: var(--blue);
}

.proof-figure {
  grid-row: 1 / 3;
  grid-column: 2;
  margin: 0;
}

.segmented {
  display: grid;
  gap: 5px;
}

.seg {
  padding: 6px 9px;
  cursor: pointer;
  text-align: left;
  color: var(--blue);
  border: 1px solid #bdd5ee;
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.seg:hover {
  background: var(--blue-soft);
}

.seg.is-on {
  background: var(--blue);
  border-color: var(--blue);
}

.algebra {
  margin: 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--violet-soft);
  font-size: 12px;
}

.algebra b {
  display: block;
  margin: 2px 0;
  font-size: 14px;
}

.solution-list {
  margin: 6px 0;
  padding-left: 22px;
}

.solution-list li {
  margin: 3px 0;
  font-size: 14px;
}

.exercise-group {
  display: grid;
  gap: 8px;
}

.exercise-group > h3 {
  margin: 2px 0 0;
  padding: 8px 10px;
  color: #fff;
  border-radius: 7px;
  background: var(--coral);
  font-size: 14px;
}

.exercise-group > h3 + h3 {
  margin-top: 8px;
  background: var(--violet);
}

.exercise {
  overflow: hidden;
  border: 1px solid #e1e8f0;
  border-radius: 8px;
  background: #fff;
}

.exercise > summary {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: #fbfcfe;
}

.exercise > summary::before {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
}

.exercise > summary b {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: #fff;
  font-size: 12px;
  border-radius: 7px;
  background: var(--mint);
}

.exercise > summary span {
  grid-column: 2;
  font-weight: 700;
  line-height: 1.35;
}

.exercise > summary em {
  grid-column: 3;
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

.q-body {
  padding: 10px 14px 13px;
  border-top: 1px solid #edf1f5;
}

.q-body > p {
  margin: 6px 0;
}

.complete-line {
  margin: 2px 0;
  border-style: dashed;
}

.wrap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.wrap-grid > div {
  min-width: 0;
}

.wrap-grid h3 {
  margin: 8px 0 4px;
  font-size: 15px;
}

.mastery-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 6px 0 10px;
}

.mastery-options label {
  position: relative;
  cursor: pointer;
}

.mastery-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mastery-options span {
  display: block;
  padding: 7px 4px;
  text-align: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.mastery-options input:checked + span {
  color: #fff;
  border-color: var(--mint);
  background: var(--mint);
}

.summary-card {
  padding: 12px;
  border: 1px solid #cfe6e0;
  border-radius: 8px;
  background: var(--mint-soft);
}

.summary-card p {
  margin: 5px 0;
  font-size: 14px;
}

.mastery-output {
  display: inline-block;
  margin: 2px 0 8px;
  padding: 3px 10px;
  color: #0c5d50;
  font-weight: 800;
  border-radius: 999px;
  background: #fff;
}

.site-footer {
  padding: 12px 18px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid #edf1f6;
  background: #fbfcfe;
}

.site-footer p {
  margin: 3px 0;
}

.is-hidden {
  display: none;
}

@media (max-width: 1020px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 8px;
  }

  .rail-title,
  .rail-note {
    display: none;
  }

  .rail-link {
    flex: none;
    grid-template-columns: auto 1fr;
    padding: 5px 8px;
  }

  .rail-link i {
    width: 22px;
    height: 22px;
    font-size: 9px;
  }

  .lab-readout {
    grid-template-columns: repeat(3, 1fr);
  }

  .lab-readout div:nth-child(4) {
    grid-column: 2;
  }

  .lab-figure {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .lesson-chip {
    display: none;
  }

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

  .split .draw-box {
    max-width: 520px;
  }

  .map-lead {
    grid-template-columns: minmax(0, 1fr);
  }

  .map-stats {
    justify-content: start;
  }

  .proof-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .proof-figure {
    grid-row: auto;
    grid-column: 1;
  }

  .proof-figure svg {
    max-height: 440px;
    object-fit: contain;
  }

  .task-grid,
  .wrap-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  body {
    font-size: 14px;
  }

  .topbar {
    position: sticky;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 7px 10px;
  }

  .brand-text strong {
    font-size: 12px;
  }

  .brand-text small {
    display: none;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .top-progress > span {
    font-size: 10px;
  }

  .bar {
    width: 70px;
    height: 6px;
  }

  .layout {
    width: 100%;
    margin: 0 0 20px;
  }

  .rail {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .sheet {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .module {
    padding: 14px 12px 16px;
  }

  .module-head {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 8px;
    margin: -14px -12px 10px;
    padding: 9px 10px;
  }

  .module-head .step {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .module-head h1,
  .module-head h2 {
    font-size: 18px;
  }

  .module-head h1 {
    font-size: 20px;
  }

  .status-chip {
    display: none;
  }

  .lab-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .lab-readout {
    grid-column: 1;
    grid-row: auto;
  }

  .lab-figure {
    grid-column: 1;
  }

  .lab-figure svg {
    min-height: 260px;
  }

  .lab-readout div {
    padding: 4px 6px;
  }

  .lab-readout b {
    font-size: 15px;
  }

  .map-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .map-stats div {
    min-width: 0;
  }

  .chapter-list li {
    display: grid;
    gap: 1px;
  }

  .chapter-list b {
    min-width: 0;
  }

  .exercise > summary {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    padding: 8px 10px;
  }

  .exercise > summary b {
    width: 24px;
    height: 24px;
  }

  .mastery-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .inline-input input {
    width: 100%;
  }

  .inline-input .btn {
    width: 100%;
  }

  .formula {
    font-size: 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}

/* 1.2 additional components */
.lesson-links { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.lesson-link { display:inline-flex; align-items:center; gap:5px; padding:5px 10px; color:#52607a; border:1px solid #d6e0ed; border-radius:7px; background:#fff; font-size:12px; font-weight:700; }
.lesson-link.is-on { color:#fff; border-color:#7c5cd6; background:#7c5cd6; }
.lesson-link[aria-disabled="true"] { opacity:.65; cursor:not-allowed; }
.tri-flow { display:grid; grid-template-columns:repeat(5,minmax(90px,1fr)); gap:6px; margin:8px 0; }
.tri-flow button { padding:8px 4px; cursor:pointer; color:#175b83; border:1px solid #cfe0f1; border-radius:7px; background:#f7fbff; font-weight:700; }
.tri-flow button.is-on { color:#fff; border-color:#3d7fd0; background:#3d7fd0; }
.relation-card { display:grid; grid-template-columns:auto minmax(0,1fr); gap:2px 12px; margin:8px 0; padding:9px 12px; border-radius:8px; background:#f0f7ff; font-size:13px; }
.relation-card b { text-align:right; color:#235f9e; }
.judge-set { display:grid; grid-template-columns:minmax(130px,1fr) auto auto; align-items:center; gap:10px; margin:5px 0; padding:7px 9px; border:1px solid #e3eaf2; border-radius:7px; }
.judge-set .side-trio { font-weight:700; }
.judge-set .option { width:auto; margin:0; padding:4px 13px; }
.judge-set .opt-note { grid-column:1 / -1; }
.data-scroll { overflow:auto; margin:8px 0; border:1px solid #dbe4ef; border-radius:8px; }
.data-table { width:100%; min-width:440px; border-collapse:collapse; font-size:13px; background:#fff; }
.data-table th,.data-table td { padding:5px 8px; text-align:center; border-bottom:1px solid #edf1f6; }
.data-table th { color:#5d6b80; background:#f4f7fb; }
.data-table tr:nth-child(even) td { background:#fbfcfe; }
.square-figure text { font-family:"Segoe UI","Microsoft YaHei",sans-serif; }
.role-tag { display:inline-block; margin:0 6px 4px 0; padding:2px 7px; border-radius:999px; font-size:11px; font-weight:700; }
.role-tag.forward { color:#0d675b; background:#d9f2eb; }
.role-tag.inverse { color:#8d3f0e; background:#ffe4cf; }
.role-tag.verify { color:#33518f; background:#e2edfc; }
.role-tag.only { color:#7a4a94; background:#f0e5f8; }
@media (max-width:640px){
  .judge-set { grid-template-columns:minmax(0,1fr) auto auto; gap:6px; }
  .tri-flow { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .relation-card { grid-template-columns:minmax(0,1fr); }
  .relation-card b { text-align:left; }
}
/* Fixed learning-position panel for long chapter navigation */
@media (min-width: 1021px) {
  .rail {
    max-height: calc(100vh - 92px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scroll-padding-bottom: 96px;
  }

  .rail-note {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 8px 3px 0;
    padding: 8px 9px;
    background: #f8fbff;
    box-shadow: 0 -9px 16px rgba(38, 49, 66, 0.09);
  }

  .rail-note > span {
    display: block;
    margin-bottom: 2px;
    line-height: 1.2;
  }

  .rail-note b {
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.35;
  }

  .rail-note .lesson-link {
    display: block;
    width: 100%;
    padding: 4px 6px;
    font-size: 11px;
    line-height: 1.3;
    white-space: normal;
  }

  .rail::-webkit-scrollbar {
    width: 6px;
  }

  .rail::-webkit-scrollbar-track {
    background: transparent;
  }

  .rail::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #c8d3e2;
  }

  .rail::-webkit-scrollbar-thumb:hover {
    background: #aab9cc;
  }
}