.graph-stage, .graph-view, .chapter {
  position: relative;
  min-height: 620px;
  height: 100svh;
  isolation: isolate;
}
.graph-stage { position: absolute; inset: 0; z-index: 0; }
.graph-stage.is-chapter { position: fixed; }
.graph-view, .chapter { z-index: 1; pointer-events: none; }
.graph-chrome, .chapter-content, .chapter-header { pointer-events: auto; }
.graph-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.graph-stage.over-node .graph-canvas { cursor: pointer; }
.graph-chrome { position: absolute; z-index: 3; left: 40px; right: 40px; display: flex; align-items: center; justify-content: space-between; }
.graph-header { top: 28px; }
.graph-name { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.graph-role { color: var(--muted); font-size: 12px; }
.graph-footer { bottom: 25px; gap: 20px; }
.graph-footer p { color: var(--muted); font-size: 12px; margin: 0; }
.graph-utility { background: transparent; border: 0; padding: 12px 0; color: var(--muted); text-decoration: none; font: inherit; font-size: 12px; min-height: 44px; }
.graph-utility:hover, .graph-utility:active { color: var(--text); }
a:focus-visible { outline: 2px solid var(--focus); outline-offset: 6px; }
.graph-nodes { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.graph-node {
  position: absolute;
  left: 0; top: 0;
  display: block;
  padding: 12px 8px;
  min-height: 46px;
  color: var(--text);
  background: var(--background);
  text-decoration: none;
  white-space: nowrap;
  font-size: clamp(16px, 1.7vw, 23px);
  font-weight: 500;
  letter-spacing: -0.035em;
  pointer-events: auto;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 160ms, border-color 160ms;
}
.graph-node::after { content: '↗'; margin-left: 10px; color: var(--primary); font-size: 0.7em; vertical-align: middle; }
.graph-node:hover, .graph-node.is-hovered, .graph-node:focus-visible { border-bottom-color: var(--primary); color: var(--dot-bright); }
.graph-node:active { color: var(--focus); }
.graph-view[aria-busy='true'] .graph-node { pointer-events: none; }
.graph-view[aria-busy='true'] .graph-chrome { pointer-events: none; }
.screen-reader-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chapter { display: grid; place-items: center; padding: 100px 24px; }
.chapter-header { position: absolute; top: 34px; left: 40px; color: var(--muted); font-size: 14px; }
.chapter-content { text-align: center; text-shadow: 0 0 12px var(--background), 0 0 24px var(--background); }
.chapter-kicker { color: var(--primary); font-size: 12px; margin: 0 0 22px; }
.chapter h1 { margin: 0; font-size: clamp(44px, 8vw, 100px); line-height: 1.03; letter-spacing: -0.06em; font-weight: 500; }
.chapter h1:focus { outline: none; }
.chapter-message { color: var(--muted); font-size: 15px; margin: 26px 0 40px; }
.chapter-back { display: inline-flex; align-items: center; gap: 14px; min-height: 44px; padding: 10px 0; color: var(--text); font-size: 14px; text-decoration: none; border-bottom: 1px solid var(--primary); }
.chapter-back:hover { color: var(--dot-bright); }
.chapter-back:active { color: var(--focus); }

/* Real links remain available before WebGL starts or if the GPU context is lost. */
.graph-view:is(:not([data-state]), [data-state='fallback']) .graph-nodes { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 35px; }
.graph-view:is(:not([data-state]), [data-state='fallback']) .graph-node { position: relative; transform: none !important; }


@media (max-width: 600px) {
  .graph-chrome { left: 22px; right: 22px; }
  .graph-header { top: 22px; }
  .graph-footer { bottom: 18px; flex-wrap: wrap; gap: 0; }
  .graph-footer p { order: -1; width: 100%; text-align: center; margin-bottom: 12px; }
  .graph-role { font-size: 11px; }
  .chapter-header { left: 24px; top: 28px; }
}
@media (max-height: 540px) and (min-width: 601px) {
  .graph-stage, .graph-view, .chapter { min-height: 560px; }
  .graph-node { font-size: 16px; padding-top: 6px; }
  .graph-header { top: 15px; }
  .graph-footer { bottom: 8px; }
}
@media (forced-colors: active) {
  .graph-canvas, .motion-button { display: none; }
  .graph-nodes { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 35px; }
  .graph-node { position: relative; transform: none !important; color: LinkText; }
  .graph-node::after, .chapter-kicker { color: LinkText; }
  .graph-utility, .chapter-back { color: LinkText; }
}
