:root {
  --green: #36c97c;
  --green-dark: #1f9a5b;
  --amber: #f6c343;
  --graphite: #2a2e34;
  --clay: #eef0f3;
  --scene-top: #eef1f4;
  --scene-bottom: #f7f8fa;
  --text: #22262b;
  --muted: #6b727c;
  --line: #dde1e6;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--scene-bg, linear-gradient(180deg, var(--scene-top), var(--scene-bottom))); background-attachment: fixed; }

/* ---- the 3D scene fills the window */
.world { position: fixed; inset: 0; }
.world-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; opacity: 0; transition: opacity 0.6s ease; }
.world.loaded .world-canvas { opacity: 1; }
.world.dragging .world-canvas { cursor: grabbing; }
.world-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.node-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--graphite);
  background: rgba(255, 255, 255, 0.86); backdrop-filter: blur(6px);
  border: 1px solid rgba(42, 46, 52, 0.08); border-radius: 999px; padding: 5px 12px;
  box-shadow: 0 6px 18px rgba(30, 38, 50, 0.08); transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.node-label::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 1px; height: 5px; background: rgba(42, 46, 52, 0.25); }
.node-label:hover, .node-label.hover { background: #fff; box-shadow: 0 8px 22px rgba(30, 38, 50, 0.14); }
.node-label.active { background: var(--graphite); color: #fff; }
.node-label.missing { opacity: 0.5; }
.node-label:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- overlays */
/* ---- left column: title + process list */
.left-col { position: fixed; top: 28px; left: 32px; bottom: 60px; width: 310px; display: flex; flex-direction: column; gap: 18px; z-index: 2; pointer-events: none; }
.overlay-title { pointer-events: none; }
body.process-mode .overlay-title .intro { display: none; }
.explore {
  pointer-events: auto; overflow: auto; min-height: 0;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px); border: 1px solid rgba(42, 46, 52, 0.08);
  border-radius: 18px; padding: 12px; box-shadow: 0 14px 40px rgba(20, 26, 34, 0.14);
}
.explore-head { margin: 2px 6px 8px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cat-list a { display: flex; gap: 10px; padding: 8px; border-radius: 12px; text-decoration: none; color: var(--graphite); align-items: flex-start; }
.cat-list a:hover { background: #f2f4f6; }
.cat-list a.active { background: var(--graphite); color: #fff; }
.cat-list a:focus-visible, .free-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.cat-list .num { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; background: #eef1f4; color: var(--graphite); }
.cat-list a.active .num { background: var(--flow, var(--amber)); color: #2a2400; }
.cat-list .txt { display: flex; flex-direction: column; min-width: 0; }
.cat-list strong { font-size: 0.88rem; line-height: 1.25; }
.cat-list small { font-size: 0.74rem; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.cat-list a.active small { color: rgba(255, 255, 255, 0.7); }
.free-btn { margin-top: 8px; width: 100%; font: inherit; font-size: 0.82rem; padding: 7px; border-radius: 10px; border: 1px dashed #c9cfd6; background: none; color: var(--muted); cursor: pointer; }
.free-btn.active { border-style: solid; color: var(--graphite); background: #f2f4f6; }

/* ---- step bar */
.stepbar {
  position: fixed; left: 366px; right: 24px; bottom: 20px; margin: 0 auto; max-width: 760px; z-index: 3;
  background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(12px); border: 1px solid rgba(42, 46, 52, 0.08);
  border-radius: 20px; padding: 14px 18px 0; box-shadow: 0 20px 50px rgba(20, 26, 34, 0.18); overflow: hidden;
}
body.panel-open .stepbar { right: 464px; }
.step-meta { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.step-cat { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--green-dark); }
.badge-draft { font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #fff6dc; color: #8a6400; cursor: help; }
.step-title { margin: 4px 0 4px; font-size: 1.15rem; color: var(--graphite); letter-spacing: -0.01em; }
.step-text { margin: 0 0 8px; font-size: 0.92rem; color: #454b53; }
.step-route { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 0.78rem; }
.step-route .node { background: #f1f3f5; color: var(--graphite); padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.step-route .arrow { color: var(--muted); }
.step-route .payload { margin-left: 4px; background: var(--flow, var(--amber)); color: #2a2400; padding: 3px 10px; border-radius: 999px; font-weight: 700; }
.step-route .payload::before { content: "◆ "; font-size: 0.7em; }
.caveat-chip { background: #fde8e7; color: #a33a36; padding: 3px 9px; border-radius: 999px; font-weight: 600; cursor: help; }
.step-controls { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; }
.ctrl { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--graphite); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.ctrl.play { background: var(--graphite); color: #fff; border-color: var(--graphite); font-size: 0.9rem; }
.ctrl:disabled { opacity: 0.35; cursor: default; }
.ctrl:focus-visible, .terms-btn:focus-visible, .dots button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.dots { display: flex; gap: 6px; margin-left: 6px; flex-wrap: wrap; }
.dots button { width: 10px; height: 10px; border-radius: 50%; border: 0; padding: 0; background: #d5dae0; cursor: pointer; }
.dots button.done { background: #9aa3ad; }
.dots button.current { background: var(--flow, var(--amber)); transform: scale(1.35); }
.step-count { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; }
.terms-btn { margin-left: auto; font: inherit; font-size: 0.82rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--graphite); cursor: pointer; }
.progress { height: 3px; margin: 0 -18px; background: #eef1f4; }
.progress i { display: block; height: 100%; width: 0; background: var(--flow, var(--amber)); }

/* ---- labels: role line, involvement */
.node-label { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.node-label strong { font-weight: 600; }
.node-label small { font-size: 0.68rem; font-weight: 500; opacity: 0.72; margin-top: 1px; }
.node-label small[hidden] { display: none; }
.node-label.dim { opacity: 0.45; }
.node-label.involved { box-shadow: 0 0 0 2px var(--flow, var(--amber)), 0 8px 22px rgba(30, 38, 50, 0.16); opacity: 1; }
.flow-tag {
  position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  background: var(--flow, var(--amber)); color: #2a2400; font-size: 0.74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  box-shadow: 0 6px 16px rgba(30, 38, 50, 0.2);
}

/* ---- glossary terms in the panel */
.role-line { margin: 0 0 14px; font-weight: 600; color: var(--graphite); }
.section { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 22px 0 10px; }
.terms { display: flex; flex-direction: column; gap: 10px; }
.term { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; }
.term h4 { margin: 0 0 4px; font-size: 0.98rem; color: var(--graphite); }
.term p { margin: 0; font-size: 0.9rem; color: #454b53; }
.term.has-caveat { border-color: #f0c2c0; background: #fffafa; }
.term-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 0.72rem; color: var(--muted); align-items: center; }
.term-meta em { font-style: normal; font-weight: 600; color: var(--green-dark); }
.term-meta .roles { display: flex; flex-wrap: wrap; gap: 4px; }
.term-meta .roles span { background: #f1f3f5; padding: 2px 8px; border-radius: 999px; }
.caveat-flag { margin: 8px 0 0 !important; font-size: 0.82rem !important; color: #a33a36 !important; font-weight: 600; }
.tech-note { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: #fff8e1; color: #5c4600; font-size: 0.86rem; }
.tech-note strong { display: block; margin-bottom: 4px; }
.tech-note p { margin: 0; }
.link-btn { margin-top: 18px; font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--green-dark); background: none; border: 0; padding: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.overlay-title h1 { font-size: clamp(1.8rem, 3.4vw, 2.8rem); line-height: 1.05; letter-spacing: -0.03em; margin: 0 0 10px; color: var(--ink, var(--graphite)); }
.eyebrow { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--green-dark); margin: 0 0 6px; }
.overlay-title .eyebrow { color: var(--ink-accent, var(--green-dark)); }
.intro { color: var(--ink-muted, var(--muted)); margin: 0; font-size: 1rem; }
.world-hint { position: fixed; left: 0; right: 0; bottom: 18px; margin: 0; text-align: center; font-size: 0.8rem; color: var(--ink-muted, var(--muted)); pointer-events: none; z-index: 2; }
.world-loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: var(--ink-muted, var(--muted)); pointer-events: none; }
.overlay-footer { position: fixed; left: 36px; bottom: 18px; font-size: 0.8rem; color: var(--ink-muted, var(--muted)); z-index: 2; }
body.panel-open .world-hint, body.process-mode .world-hint { opacity: 0; }
.overlay-title, .overlay-footer { transition: opacity 0.3s ease; }
body.process-mode .overlay-footer { opacity: 0; }

/* ---- info panel */
.info-panel {
  position: fixed; top: 20px; right: 20px; bottom: 20px; width: min(420px, calc(100vw - 40px)); z-index: 3;
  display: flex; flex-direction: column; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px);
  border: 1px solid rgba(42, 46, 52, 0.08); border-radius: 22px; box-shadow: 0 24px 60px rgba(20, 26, 34, 0.16);
  animation: slide-in 0.35s ease;
}
.info-panel[hidden] { display: none; }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.panel-bar { display: flex; align-items: center; gap: 6px; padding: 12px 14px 0; }
.counter { font-size: 0.8rem; color: var(--muted); min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--graphite); }
.icon-btn:hover { border-color: #c3c9d1; }
.icon-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.icon-btn.close { margin-left: auto; font-size: 1.4rem; }
.panel-content { padding: 14px 28px 30px; overflow: auto; }
.panel-content h2 { margin: 0 0 10px; font-size: 1.7rem; letter-spacing: -0.02em; line-height: 1.15; color: var(--graphite); }
.lead { font-size: 1.02rem; color: var(--muted); margin: 0 0 16px; }
.draft { display: inline-block; font-size: 0.75rem; font-weight: 600; background: #fff6dc; color: #8a6400; padding: 3px 8px; border-radius: 6px; margin: 0 0 12px; }
.prose h2, .prose h3 { margin: 1.3em 0 0.4em; font-size: 1.05rem; color: var(--graphite); }
.prose p, .prose ul, .prose ol { margin: 0 0 0.9em; }
.prose a { color: var(--green-dark); }
.prose code { background: var(--clay); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.extra { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 18px 0; font-size: 0.95rem; }
.extra dt { color: var(--muted); }
.extra dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.tags span { background: #e8f8ef; color: #1d7a4a; font-size: 0.8rem; padding: 3px 10px; border-radius: 999px; }

/* ---- fallback list when 3D can't run */
.fallback { position: fixed; top: 32px; right: 36px; display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.fallback a { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--graphite); text-decoration: none; font-weight: 600; min-width: 260px; }
.fallback a small { display: block; font-size: 0.7rem; color: var(--green-dark); text-transform: uppercase; letter-spacing: 0.06em; }

@media (max-width: 760px) {
  .left-col { top: 14px; left: 12px; right: 12px; bottom: auto; width: auto; gap: 8px; }
  .overlay-title h1 { font-size: 1.5rem; margin-bottom: 4px; }
  .explore { padding: 6px; border-radius: 14px; overflow-x: auto; display: flex; align-items: center; gap: 4px; }
  .explore-head { display: none; }
  .cat-list { flex-direction: row; gap: 4px; }
  .cat-list a { padding: 5px 8px; white-space: nowrap; align-items: center; }
  .cat-list small { display: none; }
  .cat-list strong { font-size: 0.78rem; }
  .cat-list .num { width: 20px; height: 20px; font-size: 0.7rem; }
  .free-btn { margin: 0; width: auto; white-space: nowrap; padding: 5px 10px; }
  .stepbar, body.panel-open .stepbar { left: 8px; right: 8px; bottom: 8px; padding: 10px 12px 0; border-radius: 16px; }
  .step-title { font-size: 1rem; }
  .step-text { font-size: 0.84rem; max-height: 4.2em; overflow: auto; }
  .progress { margin: 0 -12px; }
  .info-panel { z-index: 4; }
  .overlay-title .intro { display: none; }
  .overlay-footer { display: none; }
  .info-panel { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 55vh; border-radius: 18px; }
  .world-hint { font-size: 0.72rem; padding: 0 12px; }
  .node-label { font-size: 0.7rem; padding: 3px 9px; }
  .fallback { top: auto; bottom: 18px; left: 18px; right: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .info-panel { animation: none; }
}
