@font-face {
  font-family: "FA Noto Sans SC";
  src: url("fonts/noto-sans-sc-400.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "FA Noto Sans SC";
  src: url("fonts/noto-sans-sc-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
}

@font-face {
  font-family: "FA Noto Serif SC";
  src: url("fonts/noto-serif-sc-700.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
}

:root {
  --ink: #18211d;
  --ink-soft: #455049;
  --paper: #f4f0e6;
  --paper-deep: #e9e1d0;
  --white: #fffdf7;
  --teal: #176b63;
  --teal-light: #cbe1da;
  --rust: #c76538;
  --rust-light: #f2d4c3;
  --gold: #d6a638;
  --gold-light: #f0e2af;
  --blue: #315c72;
  --blue-light: #d5e3e9;
  --line: #c9c0ae;
  --muted: #786f62;
  --focus: #9a3f22;
  --display: "FA Noto Serif SC", "Songti SC", STSong, serif;
  --ui: "FA Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(24, 33, 29, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 33, 29, .025) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: var(--display);
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(199, 101, 56, .45);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: .7rem 1rem;
  color: var(--white);
  background: var(--ink);
}

.skip-link:focus {
  top: 1rem;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(330px, 1.25fr) minmax(300px, .75fr) auto;
  align-items: end;
  min-height: 170px;
  padding: 26px 32px 18px;
  border-bottom: 1px solid var(--ink);
  background:
    radial-gradient(circle at 82% 8%, rgba(214, 166, 56, .18), transparent 28%),
    rgba(244, 240, 230, .94);
}

.title-block {
  position: relative;
}

.title-block::before {
  position: absolute;
  left: -32px;
  top: 27px;
  width: 15px;
  height: 74px;
  content: "";
  background: var(--rust);
}

.kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--teal);
  font: 700 11px/1.2 var(--ui);
  letter-spacing: .16em;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 500;
  line-height: .92;
  letter-spacing: -.045em;
}

h1 span {
  color: var(--rust);
  font-size: .46em;
  letter-spacing: .025em;
}

.course-note {
  max-width: 490px;
  padding: 0 28px 5px;
  border-left: 1px solid var(--line);
}

.course-note p {
  margin-bottom: 14px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
}

.metric-strip {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font: 11px/1.2 var(--ui);
  letter-spacing: .05em;
}

.metric-strip strong {
  color: var(--ink);
  font-size: 18px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 248px;
  border: 1px solid var(--ink);
}

.mode {
  min-height: 39px;
  padding: 8px 11px;
  border: 0;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font: 700 12px/1 var(--ui);
}

.mode:nth-child(2n) {
  border-right: 0;
}

.mode:nth-child(n+3) {
  border-bottom: 0;
}

.mode:hover,
.mode.active {
  color: var(--white);
  background: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: 292px minmax(500px, 1fr) 360px;
  height: min(760px, calc(100vh - 170px));
  min-height: 590px;
  border-bottom: 1px solid var(--ink);
}

.control-rail,
.detail-panel {
  min-width: 0;
  overflow: auto;
  background: rgba(255, 253, 247, .78);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.control-rail {
  border-right: 1px solid var(--ink);
}

.control-section {
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.control-section label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font: 700 10px/1.2 var(--ui);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
  color: var(--teal);
  font: 700 10px/1 var(--ui);
  letter-spacing: .15em;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 17px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.7;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  font: 13px/1.2 var(--ui);
}

.search-wrap input {
  padding-left: 36px;
  border-color: var(--ink);
}

select {
  margin-bottom: 12px;
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--rust);
  background: transparent;
  font: 700 10px/1 var(--ui);
}

.search-results {
  display: grid;
  gap: 3px;
  max-height: 166px;
  margin-top: 7px;
  overflow: auto;
}

.search-hit {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 7px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-left: 2px solid var(--rust);
  text-align: left;
  background: rgba(233, 225, 208, .66);
}

.search-hit small {
  color: var(--teal);
  font: 700 9px/1.3 var(--ui);
}

.search-hit span {
  font-size: 12px;
  line-height: 1.25;
}

.chain-section {
  display: grid;
  gap: 6px;
}

.chain-section .section-label {
  margin-bottom: 5px;
}

.chain-button {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  min-height: 38px;
  padding: 0;
  border: 1px solid transparent;
  text-align: left;
  background: transparent;
}

.chain-button b {
  display: grid;
  place-items: center;
  align-self: stretch;
  color: var(--white);
  background: var(--teal);
  font: 700 10px/1 var(--ui);
}

.chain-button span {
  padding: 8px 9px;
  font-size: 12px;
  line-height: 1.25;
}

.chain-button:hover,
.chain-button.active {
  border-color: var(--teal);
  background: var(--teal-light);
}

.chain-button.proof-chain b {
  background: var(--gold);
}

.chain-button.application-chain b {
  background: var(--rust);
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 6px;
  font: 10px/1.2 var(--ui);
}

.legend-grid span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-shape {
  display: inline-block;
  width: 19px;
  height: 14px;
  border: 2px solid var(--ink);
  background: var(--white);
}

.legend-shape.theorem {
  border-radius: 7px;
  background: var(--teal-light);
}

.legend-shape.concept {
  border-radius: 50%;
  background: var(--gold-light);
}

.legend-shape.space {
  clip-path: polygon(15% 0, 85% 0, 100% 50%, 85% 100%, 15% 100%, 0 50%);
  background: var(--blue-light);
}

.legend-shape.counter {
  width: 14px;
  transform: rotate(45deg);
  background: var(--rust-light);
}

.legend-section p {
  margin: 12px 0 0;
  color: var(--muted);
  font: 10px/1.5 var(--ui);
}

.output-studio {
  background: rgba(24, 33, 29, .035);
}

.output-studio .section-label strong {
  color: var(--ink);
  font: 700 9px/1 var(--ui);
  letter-spacing: 0;
}

.output-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.output-actions button,
.print-button {
  min-height: 38px;
  padding: 8px 7px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: var(--white);
  font: 700 10px/1.25 var(--ui);
}

.output-actions button:hover,
.print-button:hover {
  color: var(--white);
  background: var(--teal);
}

.output-rule {
  height: 1px;
  margin: 14px 0 12px;
  background: var(--line);
}

.print-fields select {
  margin-bottom: 8px;
  font-size: 10px;
}

.print-button {
  width: 100%;
  color: var(--white);
  background: var(--ink);
}

.output-note,
.export-status {
  margin: 10px 0 0;
  color: var(--muted);
  font: 9px/1.5 var(--ui);
}

.export-status {
  min-height: 14px;
  color: var(--teal);
  font-weight: 700;
}

.export-status[data-state="error"] {
  color: var(--rust);
}

.print-root {
  display: none;
}

.graph-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(24, 33, 29, .035) 50%, transparent 50.2%),
    rgba(244, 240, 230, .52);
}

.graph-stage::after {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 0;
  width: 170px;
  height: 170px;
  content: "";
  border-left: 1px solid rgba(24, 33, 29, .12);
  border-top: 1px solid rgba(24, 33, 29, .12);
  transform: translate(70px, 70px) rotate(45deg);
  pointer-events: none;
}

.graph-toolbar {
  position: absolute;
  z-index: 4;
  left: 16px;
  top: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 38px;
  padding: 4px;
  border: 1px solid var(--ink);
  background: rgba(255, 253, 247, .94);
}

.graph-toolbar button {
  display: grid;
  width: 30px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
}

.graph-toolbar button:hover {
  color: var(--white);
  background: var(--teal);
}

.graph-toolbar svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: var(--line);
}

.canvas-status {
  min-width: 130px;
  padding: 0 8px;
  color: var(--muted);
  font: 10px/1.2 var(--ui);
}

.module-ruler {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  height: 8px;
  pointer-events: none;
}

.module-ruler i {
  flex: 1;
  background: var(--teal);
}

.module-ruler i:nth-child(2n) {
  background: var(--gold);
}

.module-ruler i:nth-child(3n) {
  background: var(--rust);
}

#graphSvg {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

#arrow path {
  fill: var(--ink-soft);
}

.graph-edge {
  fill: none;
  stroke: #7f887f;
  stroke-width: 1.35;
  opacity: .58;
  marker-end: url(#arrow);
}

.graph-edge.semantic {
  stroke-dasharray: 5 4;
  opacity: .42;
}

.graph-edge.chain-highlight {
  stroke: var(--rust);
  stroke-width: 3.6;
  stroke-dasharray: none;
  opacity: 1;
}

.graph-edge.neighbor-highlight {
  stroke: var(--teal);
  stroke-width: 2.8;
  opacity: 1;
}

.graph-node {
  cursor: grab;
  filter: url(#paperLift);
}

.graph-node:active {
  cursor: grabbing;
}

.graph-node .node-shape {
  fill: var(--white);
  stroke: var(--ink);
  stroke-width: 1.15;
  transition: stroke-width .15s, fill .15s;
}

.graph-node .node-accent {
  fill: var(--gold);
}

.graph-node.type-Theorem .node-shape,
.graph-node.type-Lemma .node-shape {
  fill: var(--teal-light);
}

.graph-node.type-Theorem .node-accent,
.graph-node.type-Lemma .node-accent {
  fill: var(--teal);
}

.graph-node.type-Space .node-shape {
  fill: var(--blue-light);
}

.graph-node.type-Space .node-accent {
  fill: var(--blue);
}

.graph-node.type-Counterexample .node-shape,
.graph-node.type-Misconception .node-shape {
  fill: var(--rust-light);
}

.graph-node.type-Counterexample .node-accent,
.graph-node.type-Misconception .node-accent {
  fill: var(--rust);
}

.graph-node.type-ProofTool .node-shape {
  fill: var(--gold-light);
}

.graph-node.type-Application .node-shape {
  fill: #e7d8cb;
}

.graph-node:hover .node-shape,
.graph-node.selected .node-shape,
.graph-node.chain-highlight .node-shape {
  stroke: var(--rust);
  stroke-width: 3;
}

.graph-node.dimmed {
  opacity: .17;
}

.node-title {
  fill: var(--ink);
  font: 600 11px/1 var(--display);
  pointer-events: none;
}

.node-subtitle {
  fill: var(--muted);
  font: 8.3px/1 var(--ui);
  pointer-events: none;
}

.node-type-label {
  fill: var(--white);
  font: 700 8px/1 var(--ui);
  letter-spacing: .04em;
  pointer-events: none;
}

.node-difficulty {
  fill: var(--ink-soft);
  font: 700 7.5px/1 var(--ui);
  pointer-events: none;
}

.mobile-graph {
  display: none;
}

.empty-state {
  position: absolute;
  z-index: 5;
  inset: 0;
  place-content: center;
  text-align: center;
  background: rgba(244, 240, 230, .92);
}

.empty-state:not([hidden]) {
  display: grid;
}

.empty-state button {
  margin: 14px auto;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  background: var(--white);
}

.detail-panel {
  border-left: 1px solid var(--ink);
}

.detail-empty {
  padding: 34px 28px;
}

.detail-index {
  color: var(--rust);
  font: 700 10px/1 var(--ui);
  letter-spacing: .14em;
}

.detail-empty h2 {
  margin: 52px 0 15px;
  font-size: 30px;
  font-weight: 500;
}

.detail-empty p {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.detail-prompt-lines {
  display: grid;
  gap: 14px;
  margin-top: 50px;
}

.detail-prompt-lines i {
  display: block;
  height: 1px;
  background: var(--line);
}

.detail-prompt-lines i:nth-child(2) {
  width: 82%;
}

.detail-prompt-lines i:nth-child(3) {
  width: 92%;
}

.detail-prompt-lines i:nth-child(4) {
  width: 64%;
}

#detailContent {
  padding: 0 0 30px;
}

.detail-head {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 22px 25px 19px;
  color: var(--white);
  background: var(--ink);
}

.detail-head .eyebrow {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--gold-light);
  font: 700 9px/1 var(--ui);
  letter-spacing: .08em;
}

.detail-head h2 {
  margin-bottom: 5px;
  font-size: 27px;
  font-weight: 500;
  line-height: 1.12;
}

.detail-head .english-name {
  margin: 0;
  color: #d6d7d2;
  font-size: 13px;
  font-style: italic;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 15px;
}

.tag {
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, .35);
  color: var(--white);
  font: 700 9px/1 var(--ui);
}

.detail-section {
  padding: 19px 24px;
  border-bottom: 1px solid var(--line);
}

.detail-section h3 {
  margin-bottom: 10px;
  color: var(--teal);
  font: 700 10px/1.2 var(--ui);
  letter-spacing: .13em;
  text-transform: uppercase;
}

.detail-section p,
.detail-section li {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.68;
}

.detail-section p:last-child {
  margin-bottom: 0;
}

.intuition-callout {
  padding: 14px 15px;
  border-left: 4px solid var(--gold);
  color: var(--ink) !important;
  background: var(--gold-light);
  font-size: 14px !important;
}

.formula {
  display: block;
  overflow-wrap: anywhere;
  padding: 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--white);
  font: 13px/1.5 Cambria, Georgia, serif;
  white-space: pre-wrap;
}

.theorem-grid {
  display: grid;
  gap: 10px;
}

.theorem-grid div {
  padding-left: 10px;
  border-left: 2px solid var(--teal);
}

.theorem-grid b {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font: 700 10px/1.2 var(--ui);
}

.evidence-pair {
  display: grid;
  gap: 9px;
}

.evidence-pair p {
  padding: 11px;
  background: rgba(233, 225, 208, .58);
}

.evidence-pair p:last-child {
  border-left: 3px solid var(--rust);
  background: var(--rust-light);
}

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

.node-chip {
  padding: 5px 7px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--white);
  font: 10px/1.25 var(--ui);
}

.node-chip:hover {
  border-color: var(--teal);
  background: var(--teal-light);
}

.teacher-only {
  border-left: 4px solid var(--rust);
}

body[data-mode="student"] .teacher-only {
  display: none;
}

.path-finder {
  display: grid;
  grid-template-columns: .72fr 1.05fr;
  gap: 22px 54px;
  padding: 42px 6vw 38px;
  color: var(--white);
  background:
    linear-gradient(115deg, rgba(214, 166, 56, .09), transparent 48%),
    var(--ink);
}

.path-finder h2 {
  max-width: 600px;
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 41px);
  font-weight: 500;
  line-height: 1.12;
}

.path-controls {
  display: grid;
  grid-template-columns: 1fr 22px 1fr auto;
  align-items: end;
  gap: 12px;
}

.path-controls label {
  color: #c9cec9;
  font: 10px/1.2 var(--ui);
  letter-spacing: .08em;
}

.path-controls select {
  margin: 7px 0 0;
  color: var(--ink);
}

.path-controls button {
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--gold);
  color: var(--ink);
  background: var(--gold);
  font: 700 12px/1 var(--ui);
}

.path-arrow {
  padding-bottom: 11px;
  color: var(--gold);
  font-size: 22px;
}

.path-result {
  grid-column: 1 / -1;
  min-height: 68px;
  padding-top: 18px;
  border-top: 1px solid #58605b;
}

.path-result p {
  margin-bottom: 0;
  color: #c9cec9;
  font-size: 13px;
}

.path-steps {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 6px;
}

.path-node {
  min-width: 155px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--paper);
}

.path-node b {
  display: block;
  font-size: 13px;
}

.path-node small {
  color: var(--muted);
  font: 9px/1.2 var(--ui);
}

.path-relation {
  display: grid;
  min-width: 110px;
  place-items: center;
  padding: 7px;
  color: var(--gold-light);
  font: 9px/1.25 var(--ui);
  text-align: center;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 17px 32px;
  color: var(--muted);
  background: var(--paper-deep);
  font: 10px/1.3 var(--ui);
}

footer p {
  margin: 0;
}

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

  .course-note {
    display: none;
  }

  .workspace {
    grid-template-columns: 260px minmax(420px, 1fr) 320px;
  }
}

@media (max-width: 900px) {
  .masthead {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 22px 20px;
  }

  .mode-switch {
    width: 100%;
  }

  .workspace {
    display: block;
    height: auto;
    min-height: 0;
    border-bottom: 0;
  }

  .control-rail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .chain-section,
  .legend-section {
    display: none;
  }

  .output-studio {
    grid-column: 1 / -1;
  }

  .graph-stage {
    min-height: 680px;
    overflow: visible;
    border-bottom: 1px solid var(--ink);
  }

  .graph-stage::after {
    display: none;
  }

  #graphSvg,
  .module-ruler,
  .graph-toolbar {
    display: none;
  }

  .mobile-graph {
    display: grid;
    gap: 0;
    padding: 0;
  }

  .mobile-module {
    border-bottom: 1px solid var(--ink);
  }

  .mobile-module h2 {
    position: sticky;
    z-index: 2;
    top: 0;
    margin: 0;
    padding: 12px 18px;
    color: var(--white);
    background: var(--ink);
    font: 700 11px/1.2 var(--ui);
    letter-spacing: .07em;
  }

  .mobile-node {
    display: grid;
    grid-template-columns: 44px 1fr;
    width: 100%;
    min-height: 88px;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
    background: rgba(255, 253, 247, .84);
  }

  .mobile-node .mobile-index {
    display: grid;
    place-items: center;
    align-self: stretch;
    color: var(--white);
    background: var(--teal);
    font: 700 9px/1 var(--ui);
  }

  .mobile-node.type-Counterexample .mobile-index,
  .mobile-node.type-Misconception .mobile-index {
    background: var(--rust);
  }

  .mobile-node.type-Space .mobile-index {
    background: var(--blue);
  }

  .mobile-node.type-ProofTool .mobile-index {
    color: var(--ink);
    background: var(--gold);
  }

  .mobile-copy {
    padding: 13px 15px;
  }

  .mobile-copy strong {
    display: block;
    margin-bottom: 3px;
    font-size: 15px;
  }

  .mobile-copy em {
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
  }

  .mobile-copy p {
    margin: 8px 0 0;
    color: var(--ink-soft);
    font: 11px/1.45 var(--ui);
  }

  .mobile-copy small {
    display: block;
    margin-top: 7px;
    color: var(--teal);
    font: 9px/1.35 var(--ui);
  }

  .detail-panel {
    max-height: none;
    border-left: 0;
    border-bottom: 1px solid var(--ink);
  }

  .detail-empty {
    display: none;
  }

  .path-finder {
    grid-template-columns: 1fr;
    padding: 34px 20px;
  }

  .path-controls {
    grid-template-columns: 1fr;
  }

  .path-arrow {
    display: none;
  }

  .path-result {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .masthead {
    min-height: 0;
  }

  h1 {
    font-size: 39px;
  }

  .metric-strip {
    flex-wrap: wrap;
  }

  .control-rail {
    grid-template-columns: 1fr;
  }

  .control-section:nth-child(2) {
    padding-bottom: 7px;
  }

  .graph-stage {
    min-height: 520px;
  }

  .path-steps {
    display: grid;
    gap: 3px;
  }

  .path-relation {
    min-width: 0;
    min-height: 30px;
  }

  footer {
    display: grid;
    gap: 7px;
    padding: 17px 20px;
  }
}

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

/* Interface v1.1 — editorial course-atlas composition */
.masthead {
  grid-template-columns: minmax(350px, 1.1fr) minmax(320px, .78fr) minmax(310px, auto);
  min-height: 144px;
  padding: 20px 28px 16px;
  background:
    linear-gradient(90deg, rgba(20, 107, 98, .08), transparent 22%),
    radial-gradient(circle at 78% 0, rgba(193, 138, 27, .18), transparent 30%),
    rgba(243, 238, 226, .97);
}

.title-block::before {
  left: -28px;
  top: 24px;
  height: 67px;
  background: #c95534;
}

.title-block h1 {
  font-size: clamp(38px, 3.35vw, 52px);
}

.header-actions {
  display: grid;
  gap: 8px;
  min-width: 310px;
}

.export-launch {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  min-height: 47px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  color: var(--white);
  text-align: left;
  background: var(--teal);
}

.export-launch:hover {
  color: var(--ink);
  background: var(--gold-light);
}

.export-launch svg,
.dialog-close svg,
.detail-close svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-launch span,
.export-launch b,
.export-launch small {
  display: block;
}

.export-launch b {
  font: 700 13px/1.2 var(--ui);
}

.export-launch small {
  margin-top: 3px;
  opacity: .78;
  font: 10px/1 var(--ui);
  letter-spacing: .06em;
}

.mode-switch {
  min-width: 0;
}

.workspace {
  position: relative;
  grid-template-columns: 254px minmax(0, 1fr);
  height: min(820px, calc(100vh - 144px));
  min-height: 650px;
  overflow: hidden;
}

.control-rail {
  border-right: 1px solid var(--ink);
}

.module-section {
  padding: 14px 14px 16px;
}

.module-navigator {
  display: grid;
  gap: 3px;
}

.module-nav-button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0;
  border: 1px solid transparent;
  text-align: left;
  background: transparent;
}

.module-nav-button:hover,
.module-nav-button.active {
  border-color: var(--teal);
  background: rgba(203, 225, 218, .58);
}

.module-nav-button > span:first-child {
  display: grid;
  align-self: stretch;
  place-items: center;
  color: var(--rust);
  background: rgba(233, 225, 208, .72);
  font: 800 10px/1 var(--ui);
}

.module-nav-button strong {
  overflow: hidden;
  padding: 6px 8px;
  font: 600 11px/1.2 var(--ui);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-nav-button small {
  padding-right: 7px;
  color: var(--muted);
  font: 9px/1 var(--ui);
}

.control-rail > .output-studio {
  display: none;
}

.dialog-output-studio {
  display: block;
}

.atlas-section-label {
  margin-top: 2px;
}

.graph-stage {
  display: grid;
  grid-template-rows: auto 8px minmax(0, 1fr);
  background:
    linear-gradient(rgba(20, 34, 41, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 34, 41, .025) 1px, transparent 1px),
    radial-gradient(circle at 92% 82%, rgba(20, 107, 98, .1), transparent 24%),
    var(--paper);
  background-size: 28px 28px, 28px 28px, auto, auto;
}

.canvas-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  min-height: 126px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, .88);
  backdrop-filter: blur(9px);
}

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

.view-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--rust);
  font: 800 9px/1 var(--ui);
  letter-spacing: .14em;
}

.view-copy h2 {
  overflow: hidden;
  margin-bottom: 6px;
  font-size: clamp(22px, 2vw, 31px);
  font-weight: 700;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-copy > p {
  max-width: 760px;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font: 12px/1.5 var(--ui);
}

.view-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  color: var(--muted);
  font: 9px/1 var(--ui);
  letter-spacing: .04em;
}

.view-stats b {
  margin-right: 3px;
  color: var(--ink);
  font-size: 13px;
}

.canvas-tools {
  display: grid;
  align-content: start;
  justify-items: end;
  gap: 7px;
}

.graph-toolbar {
  position: static;
  min-height: 36px;
}

.canvas-status {
  min-width: 0;
  padding: 0;
  text-align: right;
}

.canvas-export {
  padding: 7px 10px;
  border: 1px solid var(--teal);
  color: var(--teal);
  background: transparent;
  font: 700 10px/1 var(--ui);
}

.canvas-export:hover {
  color: var(--white);
  background: var(--teal);
}

.node-title {
  font: 600 11px/1 var(--display);
}

.node-subtitle {
  font: 8.3px/1 var(--ui);
}

.module-ruler {
  position: static;
  grid-row: 2;
}

#graphSvg {
  grid-row: 3;
  min-height: 0;
}

.mobile-graph,
.empty-state {
  grid-row: 3;
}

.detail-panel {
  position: absolute;
  z-index: 30;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, calc(100vw - 30px));
  border-left: 1px solid var(--ink);
  background: rgba(255, 253, 247, .985);
  box-shadow: -22px 0 60px rgba(20, 34, 41, .2);
  transform: translateX(0);
  transition: transform .24s ease, visibility .24s;
}

.detail-panel.is-closed {
  visibility: hidden;
  transform: translateX(102%);
}

.detail-close {
  position: absolute;
  z-index: 5;
  top: 13px;
  right: 13px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .55);
  color: var(--white);
  background: rgba(20, 34, 41, .7);
}

.detail-close:hover {
  color: var(--ink);
  background: var(--gold-light);
}

.detail-head {
  padding-top: 58px;
}

.formula {
  overflow-x: auto;
  overflow-wrap: normal;
  padding: 16px 12px;
  text-align: center;
  white-space: normal;
}

.formula .katex {
  font-size: 1.04em;
}

.detail-module-brief {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, .23);
  color: #d8dfdb;
  font: 10px/1.45 var(--ui);
}

.detail-export-module {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--gold);
  color: var(--gold-light);
  background: transparent;
  font: 700 10px/1 var(--ui);
}

.export-dialog {
  width: min(1320px, 95vw);
  max-width: none;
  height: min(880px, 92vh);
  max-height: none;
  padding: 0;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 28px 90px rgba(20, 34, 41, .35);
}

.export-dialog::backdrop {
  background: rgba(20, 34, 41, .72);
  backdrop-filter: blur(5px);
}

.export-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.export-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 30px;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--ink);
  background:
    radial-gradient(circle at 86% 0, rgba(193, 138, 27, .2), transparent 32%),
    var(--paper);
}

.export-head h2 {
  margin-bottom: 7px;
  font-size: clamp(27px, 3vw, 41px);
  line-height: 1.08;
}

.export-head p {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font: 12px/1.55 var(--ui);
}

.dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--ink);
  background: transparent;
}

.dialog-close:hover {
  color: var(--white);
  background: var(--rust);
}

.export-body {
  display: grid;
  grid-template-columns: 365px minmax(0, 1fr);
  min-height: 0;
}

.export-controls {
  overflow: auto;
  padding: 20px;
  border-right: 1px solid var(--ink);
  background: rgba(255, 253, 247, .72);
}

.scope-picker {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.scope-picker legend {
  margin-bottom: 9px;
  color: var(--teal);
  font: 800 10px/1 var(--ui);
  letter-spacing: .13em;
}

.scope-picker label {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 7px;
  align-items: center;
  min-height: 53px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: var(--white);
}

.scope-picker label:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-light);
}

.scope-picker input,
.export-option input,
.export-chapter-checklist input {
  width: 15px;
  min-height: 15px;
  accent-color: var(--teal);
}

.scope-picker b,
.scope-picker small,
.export-option b,
.export-option small {
  display: block;
}

.scope-picker b,
.export-option b {
  font: 700 12px/1.25 var(--ui);
}

.scope-picker small,
.export-option small {
  margin-top: 3px;
  color: var(--muted);
  font: 9px/1.3 var(--ui);
}

.export-subcontrol {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.export-subcontrol > label,
.export-subhead {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--teal);
  font: 800 10px/1 var(--ui);
  letter-spacing: .08em;
}

.export-chapter-checklist {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.export-chapter-checklist label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  background: var(--white);
  font: 9px/1.2 var(--ui);
}

.export-option {
  display: grid;
  grid-template-columns: 21px 1fr;
  gap: 7px;
  align-items: start;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(233, 225, 208, .52);
}

.export-summary {
  margin-top: 14px;
  padding: 12px;
  border-left: 4px solid var(--gold);
  background: var(--gold-light);
  font: 11px/1.5 var(--ui);
}

.advanced-export {
  margin-top: 15px;
  border-top: 1px solid var(--line);
}

.advanced-export summary {
  padding: 12px 0 8px;
  color: var(--teal);
  font: 700 11px/1.2 var(--ui);
  cursor: pointer;
}

.advanced-export p {
  color: var(--muted);
  font: 10px/1.5 var(--ui);
}

.advanced-actions {
  display: grid;
  gap: 6px;
}

.advanced-actions button {
  padding: 9px;
  border: 1px solid var(--ink);
  background: var(--white);
  font: 700 10px/1.2 var(--ui);
}

.export-preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.export-preview-label {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--teal);
  font: 800 9px/1 var(--ui);
  letter-spacing: .12em;
}

.export-preview-label small {
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
}

.export-preview {
  min-height: 0;
  padding: 18px;
  overflow: auto;
  background:
    linear-gradient(45deg, rgba(20, 34, 41, .035) 25%, transparent 25%, transparent 75%, rgba(20, 34, 41, .035) 75%),
    linear-gradient(45deg, rgba(20, 34, 41, .035) 25%, transparent 25%, transparent 75%, rgba(20, 34, 41, .035) 75%),
    #ded9cd;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

.export-preview svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  margin: auto;
  border: 1px solid rgba(20, 34, 41, .18);
  box-shadow: 0 14px 34px rgba(20, 34, 41, .18);
}

.export-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 20px;
  border-top: 1px solid var(--ink);
  background: var(--ink);
}

.export-footer p {
  margin: 0;
  color: #cad0cc;
  font: 10px/1.4 var(--ui);
}

.export-footer > div {
  display: flex;
  gap: 8px;
}

.export-footer button {
  min-height: 38px;
  padding: 9px 15px;
  font: 700 11px/1 var(--ui);
}

.secondary-action {
  border: 1px solid #74807a;
  color: var(--white);
  background: transparent;
}

.primary-action {
  border: 1px solid var(--gold);
  color: var(--ink);
  background: var(--gold);
}

@media (max-width: 1180px) {
  .masthead {
    grid-template-columns: 1fr minmax(300px, auto);
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

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

@media (max-width: 900px) {
  .masthead {
    grid-template-columns: 1fr;
  }

  .header-actions {
    grid-column: auto;
    grid-row: auto;
  }

  .workspace {
    overflow: visible;
    display: block;
    height: auto;
  }

  .control-rail {
    display: block;
  }

  .module-navigator {
    grid-template-columns: 1fr 1fr;
  }

  .canvas-header {
    grid-template-columns: 1fr;
  }

  .canvas-tools {
    justify-items: start;
  }

  .canvas-status {
    text-align: left;
  }

  .graph-stage {
    grid-template-rows: auto 8px auto;
  }

  .detail-panel {
    position: fixed;
    left: 0;
    width: 100%;
  }

  .export-dialog {
    width: 96vw;
    height: 94vh;
  }

  .export-body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .export-controls {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .export-preview-panel {
    min-height: 480px;
  }
}

@media (max-width: 560px) {
  .module-navigator {
    grid-template-columns: 1fr;
  }

  .view-copy h2 {
    white-space: normal;
  }

  .export-head {
    padding: 18px;
  }

  .export-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .export-footer > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media print {
  html,
  body {
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    color: #18211d;
    background: #ffffff !important;
  }

  body > *:not(.print-root) {
    display: none !important;
  }

  .print-root {
    display: block !important;
    width: 100%;
    min-width: 0;
    color: #18211d;
    background: #ffffff;
    font-family: "Graph Publisher", "Graph Publisher Latin", "Graph Publisher Symbols", "Graph Publisher Math", "Microsoft YaHei", sans-serif;
  }

  .print-sheet {
    width: 100%;
    min-width: 0;
  }

  .print-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 8mm;
    margin: 0 0 4mm;
    padding: 0 0 3mm;
    border-bottom: .35mm solid #18211d;
  }

  .print-header h1 {
    margin: 0;
    color: #18211d;
    font-size: 17pt;
    line-height: 1;
    letter-spacing: -.02em;
  }

  .print-header p {
    margin: 0;
    color: #455049;
    font-size: 7.5pt;
    line-height: 1.35;
    text-align: right;
  }

  .print-graph-wrap {
    display: flex;
    width: 100%;
    min-width: 0;
    height: 246mm;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    break-inside: avoid;
  }

  .print-root[data-paper="a4"] .print-graph-wrap {
    height: 161mm;
  }

  .print-root[data-content="graphLegend"] .print-graph-wrap {
    height: 224mm;
  }

  .print-root[data-paper="a4"][data-content="graphLegend"] .print-graph-wrap {
    height: 143mm;
  }

  .print-graph-svg {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: visible;
  }

  .print-root .graph-node {
    filter: none !important;
  }

  .print-legend {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2.2mm 4mm;
    margin-top: 3mm;
    padding: 3mm 4mm;
    border: .25mm solid #c9c0ae;
    font-size: 7pt;
    line-height: 1.35;
    break-inside: avoid;
  }

  .print-legend b {
    color: #176b63;
  }

  .print-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5mm;
  }

  .print-detail-card {
    padding: 3.5mm;
    border: .25mm solid #c9c0ae;
    break-inside: avoid;
  }

  .print-detail-card h2 {
    margin: 0 0 1mm;
    color: #176b63;
    font-size: 10pt;
    line-height: 1.2;
  }

  .print-detail-card h3 {
    margin: 0 0 1.2mm;
    color: #18211d;
    font-size: 8pt;
    line-height: 1.2;
  }

  .print-detail-card p {
    margin: 0;
    color: #455049;
    font-size: 7pt;
    line-height: 1.45;
  }

  .print-detail-graph {
    grid-column: 1 / -1;
    height: 82mm;
  }

  .print-detail-graph .print-graph-svg {
    width: 100%;
    height: 100%;
  }

  .print-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 3mm;
    padding-top: 2mm;
    border-top: .2mm solid #c9c0ae;
    color: #786f62;
    font-size: 6.5pt;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
