.understand-body {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.understand-shell {
  display: grid;
  grid-template-columns: minmax(320px, 42vw) 1fr;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.chapter-hidden {
  display: none !important;
}

.understand-canvas-pane {
  position: sticky;
  top: 0;
  align-self: start;
  min-width: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--bg0);
}

#understandCanvas {
  width: 100%;
  max-width: 100%;
  height: 100%;
  display: block;
}

.understand-angle-switcher {
  position: absolute;
  z-index: 12;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  left: 16px;
  display: flex;
  justify-content: center;
  gap: 5px;
  overflow-x: auto;
  pointer-events: auto;
  scrollbar-width: none;
}

.understand-angle-switcher::-webkit-scrollbar {
  display: none;
}

.understand-angle-switcher a {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid rgba(153, 217, 239, 0.2);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(8, 20, 30, 0.76);
  font-size: 0.66rem;
  font-weight: 700;
  text-decoration: none;
}

.understand-angle-switcher a:hover,
.understand-angle-switcher a:focus-visible {
  border-color: rgba(94, 234, 212, 0.65);
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.understand-stage-label {
  position: absolute;
  left: 24px;
  bottom: 68px;
  max-width: calc(100% - 170px);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.understand-motion-toggle {
  position: absolute;
  z-index: 6;
  right: 18px;
  bottom: 68px;
  width: auto;
  min-width: 112px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.chapter-edge-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  width: 48px;
  height: 140px;
  border: 1px solid var(--line);
  background: rgba(8, 20, 30, 0.55);
  color: var(--ink);
  font-size: 1.3rem;
  cursor: pointer;
}

.chapter-edge-prev {
  left: 0;
  border-left: none;
  border-radius: 0 12px 12px 0;
}

.chapter-edge-next {
  right: 0;
  border-right: none;
  border-radius: 12px 0 0 12px;
}

.chapter-edge-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

.chapter-edge-btn:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(8, 20, 30, 0.85);
}

.understand-chapter-rail {
  position: fixed;
  left: 56px;
  right: 56px;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 10px 16px;
  background: rgba(8, 20, 30, 0.9);
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.chapter-rail-item {
  flex: 0 0 auto;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  opacity: 0.55;
  font-size: 0.72rem;
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: center;
  touch-action: manipulation;
}

.chapter-rail-item:hover {
  opacity: 0.85;
}

.chapter-rail-item.is-active {
  color: var(--accent);
  border-color: var(--accent);
  opacity: 1;
  font-weight: 700;
}

.chapter-rail-item[data-lens="geometry"].is-active {
  color: #5eead4;
  border-color: rgba(94, 234, 212, 0.72);
  background: rgba(94, 234, 212, 0.08);
}

.chapter-rail-item[data-lens="matrix"].is-active {
  color: #c4b5fd;
  border-color: rgba(196, 181, 253, 0.72);
  background: rgba(167, 139, 250, 0.09);
}

.chapter-rail-item[data-lens="manifestation"].is-active {
  color: #fdba74;
  border-color: rgba(253, 186, 116, 0.72);
  background: rgba(251, 146, 60, 0.08);
}

.understand-text-pane {
  padding: 8vh 6vw 40vh;
  max-width: 62ch;
  min-width: 0;
  overflow-wrap: break-word;
}

.understand-text-pane code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.understand-intro h1 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin: 0 0 12px;
}

.version-badge,
.lens-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid rgba(94, 234, 212, 0.38);
  border-radius: 999px;
  color: #9ff3e5;
  background: rgba(94, 234, 212, 0.07);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1;
  text-transform: uppercase;
}

.version-badge {
  margin-bottom: 18px;
  padding: 8px 11px;
}

.lens-label {
  margin: 0 0 16px;
  padding: 6px 9px;
}

.understand-section[data-lens="matrix"] .lens-label {
  color: #d8ccff;
  border-color: rgba(196, 181, 253, 0.42);
  background: rgba(167, 139, 250, 0.08);
}

.understand-section[data-lens="manifestation"] .lens-label {
  color: #fed7aa;
  border-color: rgba(253, 186, 116, 0.42);
  background: rgba(251, 146, 60, 0.08);
}

.claim-label {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 14px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.claim-established {
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.07);
}

.claim-bridge {
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.3);
  background: rgba(96, 165, 250, 0.07);
}

.claim-canonical {
  color: #ddd6fe;
  border: 1px solid rgba(167, 139, 250, 0.32);
  background: rgba(167, 139, 250, 0.08);
}

.lens-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 30px 0 20px;
  padding: 0;
  list-style: none;
  counter-reset: lens;
}

.lens-map li {
  position: relative;
  min-width: 0;
  padding: 18px 14px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(9, 29, 41, 0.58);
  counter-increment: lens;
}

.lens-map li::before {
  content: counter(lens, decimal-leading-zero);
  display: block;
  margin-bottom: 22px;
  color: var(--muted);
  font: 700 0.7rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
}

.lens-map li[data-lens="geometry"] {
  border-color: rgba(94, 234, 212, 0.32);
}

.lens-map li[data-lens="matrix"] {
  border-color: rgba(196, 181, 253, 0.32);
}

.lens-map li[data-lens="manifestation"] {
  border-color: rgba(253, 186, 116, 0.32);
}

.lens-map strong,
.lens-map span {
  display: block;
}

.lens-map strong {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.25;
}

.lens-map span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.comparison-link {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-left: 2px solid rgba(94, 234, 212, 0.52);
  background: rgba(94, 234, 212, 0.045);
  font-size: 0.82rem;
}

.comparison-link a {
  color: var(--accent);
}

.understand-intro p,
.understand-section p,
.understand-prelude p,
.understand-outro p {
  color: var(--muted);
  line-height: 1.6;
}

.understand-prelude {
  border-top: 1px solid var(--line);
  padding: 4vh 0;
}

.understand-prelude .beat-kicker {
  font-size: 0.64rem;
  opacity: 0.75;
}

.prelude-subhead {
  display: block;
  color: var(--accent);
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.66rem;
  font-weight: 700;
  margin: 26px 0 8px;
}

.beat-kicker + .prelude-subhead {
  margin-top: 10px;
}

.understand-prelude p {
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  line-height: 1.7;
}

.understand-section {
  min-height: 58vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-top: 1px solid var(--line);
  padding: 4vh 0;
}

.understand-section p {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.understand-section h3 {
  max-width: 22ch;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  line-height: 1.18;
  text-wrap: balance;
}

.understand-section[data-lens="geometry"] {
  border-top-color: rgba(94, 234, 212, 0.22);
}

.understand-section[data-lens="matrix"] {
  border-top-color: rgba(196, 181, 253, 0.22);
}

.understand-section[data-lens="manifestation"] {
  border-top-color: rgba(253, 186, 116, 0.22);
}

.understand-section-final {
  min-height: 70vh;
}

.understand-section-final p {
  font-size: 1rem;
  color: var(--muted);
}

.understand-section-final .recap-line {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-left: 2px solid var(--line);
  background: rgba(9, 29, 41, 0.46);
}

.understand-section-final .recap-line[data-lens="geometry"] {
  border-left-color: rgba(94, 234, 212, 0.7);
}

.understand-section-final .recap-line[data-lens="matrix"] {
  border-left-color: rgba(196, 181, 253, 0.7);
}

.understand-section-final .recap-line[data-lens="manifestation"] {
  border-left-color: rgba(253, 186, 116, 0.7);
}

.beat-kicker {
  display: block;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 14px;
  margin-top: 0;
}

.understand-outro {
  border-top: 1px solid var(--line);
  padding-top: 6vh;
}

.understand-outro a {
  color: var(--accent);
}

.domain-reference {
  display: block;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.domain-reference a {
  color: var(--accent);
}

@media (max-width: 860px) {
  .understand-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .understand-canvas-pane {
    position: sticky;
    top: 0;
    z-index: 10;
    height: clamp(280px, 44vh, 380px);
    height: clamp(280px, 44svh, 380px);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .understand-angle-switcher {
    justify-content: flex-start;
  }
  .understand-text-pane {
    width: 100%;
    max-width: 100%;
    padding: clamp(28px, 5vh, 44px) clamp(18px, 6vw, 42px) calc(104px + env(safe-area-inset-bottom));
  }
  .understand-outline {
    display: none;
  }
  .chapter-edge-btn {
    top: auto;
    bottom: calc(5px + env(safe-area-inset-bottom));
    transform: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    touch-action: manipulation;
  }
  .chapter-edge-prev {
    left: 5px;
    border-left: 1px solid var(--line);
  }
  .chapter-edge-next {
    right: 5px;
    border-right: 1px solid var(--line);
  }
  .understand-chapter-rail {
    left: 0;
    right: 0;
    min-width: 0;
    min-height: calc(54px + env(safe-area-inset-bottom));
    padding: 8px 58px calc(8px + env(safe-area-inset-bottom));
    background: rgba(5, 16, 25, 0.97);
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .understand-chapter-rail::-webkit-scrollbar {
    display: none;
  }
  .chapter-rail-item {
    max-width: calc(100vw - 124px);
    min-height: 44px;
    padding: 7px 11px;
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lens-map {
    grid-template-columns: 1fr;
  }
  .lens-map li {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    column-gap: 10px;
    padding: 14px;
  }
  .lens-map li::before {
    grid-row: 1 / span 2;
    margin: 3px 0 0;
  }
  .lens-map span {
    margin-top: 5px;
  }
  .understand-stage-label {
    left: 10px;
    bottom: 64px;
    max-width: calc(100% - 150px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .understand-motion-toggle {
    right: 10px;
    bottom: 64px;
    min-width: 104px;
  }
}

@media (max-width: 600px) {
  .understand-canvas-pane {
    height: clamp(300px, 42vh, 340px);
    height: clamp(300px, 42svh, 340px);
  }
  .understand-stage-label {
    left: 8px;
    right: 120px;
    bottom: 10px;
    max-width: none;
    padding: 6px 10px;
    font-size: 0.76rem;
  }
  .understand-motion-toggle {
    right: 8px;
    bottom: 10px;
    min-width: 96px;
    min-height: 44px;
    padding: 6px 9px;
    font-size: 0.8125rem;
    touch-action: manipulation;
  }
  .understand-intro h1 {
    font-size: clamp(1.55rem, 7vw, 2rem);
    line-height: 1.16;
  }
  .understand-prelude p,
  .understand-section p {
    font-size: 1rem;
    line-height: 1.65;
  }
  .understand-section {
    min-height: 42vh;
    min-height: 42svh;
    padding: 44px 0;
  }
  .understand-section-final {
    min-height: 52vh;
    min-height: 52svh;
  }
}

@media (max-width: 360px) {
  .understand-text-pane {
    padding-right: 18px;
    padding-left: 18px;
  }
  .understand-stage-label {
    right: 106px;
    font-size: 0.72rem;
  }
  .understand-motion-toggle {
    min-width: 90px;
    font-size: 0.68rem;
  }
}

/* Short landscape phones need a readable narration strip between the sticky
 * visual and the fixed chapter rail.  The portrait minimums above are too
 * tall for a 320–520px viewport. */
@media (max-width: 860px) and (max-height: 520px) {
  .understand-canvas-pane {
    height: min(42svh, 210px);
    min-height: 140px;
    max-height: 210px;
  }
  .understand-text-pane {
    padding-top: 24px;
  }
  .understand-section {
    min-height: max(180px, 48svh);
    padding: 30px 0;
  }
}
