:root {
  --bg: #0b0e13;
  --panel: #12161d;
  --card: #161c26;
  --line: #263042;
  --text: #e8edf4;
  --muted: #9aa6b8;
  --accent: #4cc9f0;
  --accent2: #f72585;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.55;
}

code {
  background: #0e1420;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.85em;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px 7px;
  background: rgba(11, 14, 19, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 12px rgba(76, 201, 240, 0.8);
}
.brand h1 { font-size: 0.95rem; margin: 0; letter-spacing: 0.4px; line-height: 1.3; }

.top-actions { display: flex; align-items: center; gap: 10px; }
#reset-view {
  border: 1px solid var(--line);
  background: #18202d;
  color: var(--text);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.75rem;
}
#reset-view:hover { border-color: var(--accent); color: var(--accent); }
#autorotate {
  border: 1px solid var(--line);
  background: #18202d;
  color: var(--text);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.75rem;
  white-space: nowrap;
}
#autorotate:hover { border-color: var(--accent); color: var(--accent); }
#autorotate.off {
  color: var(--muted);
  border-style: dashed;
}

/* Section nav: horizontal buttons, scrollable when narrow */
#section-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 46vw;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
#section-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 0.72rem;
  white-space: nowrap;
}
.nav-btn:hover { color: var(--text); border-color: var(--line); }
.nav-btn.active {
  color: #0b0e13;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

#progress {
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 3px;
  background: #1a2230;
}
#progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  align-items: start;
}

/* Sticky 3D stage (canvas fills the whole left column) */
.stage {
  position: sticky;
  top: 36px;
  height: calc(100vh - 36px);
  border-right: 1px solid var(--line);
  background: radial-gradient(1200px 700px at 40% 35%, #141c2a 0%, var(--bg) 65%);
}

#canvas-holder { position: relative; height: 100%; min-height: 0; }
#scene { width: 100%; height: 100%; display: block; touch-action: none; }

#loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center;
  background: rgba(11, 14, 19, 0.72);
  transition: opacity 0.4s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
#loader-text { color: var(--muted); font-size: 0.9rem; }
.spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #263042;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scroll steps */
.steps { padding: 0 14px 40px; }
.step {
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  max-width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  opacity: 0.45;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease, border-color 0.35s ease;
}
.step.active .card { opacity: 1; transform: none; border-color: var(--accent); }
.eyebrow {
  margin: 0 0 4px;
  font-size: 0.66rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
}
.card h2 { margin: 0 0 6px; font-size: 1.15rem; }
.card p.ms { margin: 0 0 6px; font-size: 0.82rem; }
.card p.en { margin: 0 0 10px; color: var(--muted); font-size: 0.76rem; }
.chip {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

/* Floating mesh label (click a structure) */
#mesh-label {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  display: none;
  pointer-events: none;
}
#mesh-label span {
  display: block;
  transform: translate(-50%, -135%);
  background: rgba(10, 14, 20, 0.9);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* Zoom buttons overlay */
.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zoom-controls button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(24, 32, 45, 0.92);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.zoom-controls button:hover { border-color: var(--accent); color: var(--accent); }

.endnote { padding: 30px 6px 60px; color: var(--muted); font-size: 0.85rem; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stage {
    top: 36px;
    height: 62vh;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .step { min-height: 78vh; }
  .topbar { flex-wrap: wrap; }
  #section-nav { max-width: 100%; order: 3; flex-basis: 100%; }
}
