:root {
  --bg: #04070d;
  --ink: #e6edf7;
  --ink-2: #a9b6c8;
  --ink-3: #6f7f96;
  --glass: rgba(7, 12, 22, 0.72);
  --glass-2: rgba(10, 17, 30, 0.86);
  --line: rgba(148, 180, 220, 0.16);
  --cyan: #22d3ee;
  --green: #4ade80;
  --orange: #fb923c;
  --violet: #a78bfa;
  --pink: #f472b6;
  --red: #ff4d6d;
  --amber: #fbbf24;
  --r: 16px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; overflow-x: hidden; }
button { font: inherit; color: inherit; }
a { color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-3); }
.c-cyan { color: var(--cyan); } .c-orange { color: var(--orange); } .c-violet { color: var(--violet); } .c-pink { color: var(--pink); }
.c-red { color: var(--red); } .c-amber { color: var(--amber); } .c-green { color: var(--green); }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; outline: none; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }

.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); }

/* loader */
#loader { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--bg); color: var(--ink-2); transition: opacity .8s .2s, visibility .8s .2s; }
#loader .ring { width: 54px; height: 54px; border-radius: 50%; border: 2px dashed var(--cyan); animation: spin 2.4s linear infinite; box-shadow: 0 0 30px rgba(34, 211, 238, .35); }
body.ready #loader { opacity: 0; visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }

/* header */
header.top { position: fixed; top: 12px; left: 16px; right: 16px; z-index: 30; display: flex; align-items: center; gap: 20px; padding: 8px 10px 8px 14px; border-radius: 14px; background: rgba(5, 9, 17, 0.62); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--cyan); flex-shrink: 0; }
.brand svg { width: 30px; height: 30px; filter: drop-shadow(0 0 8px rgba(34, 211, 238, .6)); }
.brand b { color: var(--ink); font-weight: 800; font-size: 15px; letter-spacing: .01em; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--ink-2); font-size: 13.5px; font-weight: 600; padding: 7px 10px; border-radius: 9px; transition: color .2s, background .2s; }
.nav a:hover { color: var(--ink); background: rgba(148, 180, 220, .08); }
.nav a.on { color: var(--cyan); background: rgba(34, 211, 238, .1); }
body.explore .nav { visibility: hidden; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: rgba(148, 180, 220, .06); color: var(--ink); padding: 9px 16px; border-radius: 11px; font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; transition: transform .15s, background .2s, border-color .2s, box-shadow .2s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); border-color: rgba(148, 180, 220, .35); }
.btn.big { padding: 13px 22px; font-size: 15px; border-radius: 13px; }
.btn-glow { background: linear-gradient(135deg, #22d3ee, #3b82f6); border-color: transparent; color: #031018; box-shadow: 0 0 24px rgba(34, 211, 238, .35); }
.btn-glow:hover { box-shadow: 0 0 36px rgba(34, 211, 238, .55); }
.btn.ghost { background: rgba(5, 9, 17, .5); }
header .btn { margin-left: 4px; }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
#phase { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 5px; border-radius: 13px; }
#phase .step { display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 5px; border-radius: 9px; color: var(--ink-3); transition: background .4s, color .4s; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
#phase .step i { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 800; border: 1px solid var(--line); flex-shrink: 0; }
#phase .step.done { color: var(--ink-2); }
#phase .step.done i { background: rgba(74, 222, 128, .15); border-color: rgba(74, 222, 128, .5); color: var(--green); }
#phase .step.active { background: rgba(34, 211, 238, .12); color: var(--ink); }
#phase .step.active i { background: var(--cyan); border-color: var(--cyan); color: #031018; box-shadow: 0 0 14px rgba(34, 211, 238, .7); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 4px rgba(34, 211, 238, .3); } }

#banner { position: absolute; top: 128px; left: 50%; transform: translate(-50%, -10px); padding: 8px 16px; border-radius: 11px; background: rgba(232, 121, 249, .16); border: 1px solid rgba(232, 121, 249, .5); color: #fbe7ff; font-weight: 700; font-size: 13.5px; opacity: 0; transition: opacity .35s, transform .35s; pointer-events: none; white-space: nowrap; box-shadow: 0 0 40px rgba(232, 121, 249, .25); backdrop-filter: blur(10px); }
#banner.show { opacity: 1; transform: translate(-50%, 0); }

#tele { position: absolute; top: 80px; right: 16px; width: 230px; padding: 12px 14px; font-size: 13px; gap: 8px; }
.tele-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tele-head b { color: var(--cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tele-head .mono { margin-left: auto; font-size: 12px; }
.dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.err { display: grid; grid-template-columns: 1fr auto; gap: 3px; align-items: baseline; }
.err > span { color: var(--ink-3); font-size: 12px; }
.err .bar { grid-column: 1 / -1; height: 3px; border-radius: 3px; background: rgba(148, 180, 220, .1); overflow: hidden; }
.err .bar i { display: block; height: 100%; width: 0; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transition: width .3s; }
.err .bar i.o { background: var(--orange); box-shadow: 0 0 8px var(--orange); }

#mini { position: absolute; right: 16px; bottom: 16px; padding: 8px; }
#minimap { width: 256px; height: 160px; display: block; border-radius: 8px; background: #060a12; image-rendering: pixelated; }
.legend { display: flex; gap: 10px; font-size: 11px; color: var(--ink-3); margin-top: 6px; padding-left: 2px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

#layersPanel { position: absolute; left: 16px; top: 80px; width: 230px; padding: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
#layersPanel .chips + .chips { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.chips button, #controls button { border: 1px solid var(--line); background: rgba(148, 180, 220, .06); padding: 5px 10px; border-radius: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); transition: all .15s; }
.chips button:hover, #controls button:hover { color: var(--ink); border-color: rgba(148, 180, 220, .35); }
.chips button.on, #controls button.on { color: #031018; background: var(--cyan); border-color: var(--cyan); }

#log { position: absolute; left: 16px; bottom: 16px; width: 290px; margin: 0; padding: 8px 12px; list-style: none; font-size: 12px; overflow: hidden; }
#log li { display: flex; gap: 8px; padding: 3px 0; color: var(--ink-2); animation: fadein .5s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#log li:nth-child(n+5) { display: none; }
#log time { font-family: var(--mono); color: var(--ink-3); flex-shrink: 0; }
#log li.loop { color: #f5c2ff; } #log li.ok { color: #bbf7d0; } #log li.warn { color: #fed7aa; } #log li.dyn { color: #fecdd3; }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } }

#controls { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); gap: 8px; padding: 6px; align-items: center; border-radius: 13px; }
#controls .grp { display: flex; gap: 3px; }
#controls .grp + .grp { padding-left: 8px; border-left: 1px solid var(--line); }
#controls .exit { color: var(--ink); background: rgba(255, 77, 109, .14); border-color: rgba(255, 77, 109, .4); }

/* видимость HUD: полный набор только в 3D-режиме */
#tele, #layersPanel, #log, #controls { display: none; }
body.explore #tele { display: grid; }
body.explore #layersPanel, body.explore #log { display: block; }
body.explore #controls { display: flex; }
#mini, #phase { transition: opacity .5s, transform .5s; }
body:not([data-chapter="hero"]):not(.explore) #mini { opacity: 0; pointer-events: none; transform: translateY(20px); }
body[data-chapter="pipeline"]:not(.explore) #phase, body[data-chapter="team"]:not(.explore) #phase { opacity: 0; pointer-events: none; }

/* метки в 3D */
.zlabel { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 9px; background: rgba(5, 9, 17, .75); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); color: var(--ink); font-size: 11.5px; font-weight: 700; white-space: nowrap; transition: opacity .25s; will-change: transform; }
.zlabel b { color: var(--c); font-family: var(--mono); }
.zlabel span.ok { color: var(--green); }
.zlabel span.act { color: var(--c); animation: blink .8s infinite; }
.zlabel.active { background: color-mix(in srgb, var(--c) 22%, rgba(5, 9, 17, .85)); }
.zlabel::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 1px; height: 7px; background: var(--c); }
.tag { position: absolute; left: 0; top: 0; padding: 2px 7px; border-radius: 6px; background: rgba(255, 77, 109, .18); border: 1px solid rgba(255, 77, 109, .6); color: #ffe4e9; font-size: 10.5px; font-weight: 700; white-space: nowrap; transition: opacity .25s; will-change: transform; }
.doglabel { position: absolute; left: 0; top: 0; padding: 3px 9px; border-radius: 7px; background: rgba(34, 211, 238, .14); border: 1px solid rgba(34, 211, 238, .55); color: #cffafe; font-size: 11px; font-weight: 700; white-space: nowrap; transition: opacity .25s; will-change: transform; }

/* ============ КОНТЕНТ ============ */
main { position: relative; z-index: 5; pointer-events: none; transition: opacity .5s; }
main .card, main .panel, main a, main button, main .hero-in, footer { pointer-events: auto; }
body.explore main { opacity: 0; visibility: hidden; }

.hero { position: relative; min-height: 100vh; min-height: 100svh; display: flex; align-items: flex-end; padding: 140px 40px 60px; }
.hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(4, 7, 13, .75) 0%, rgba(4, 7, 13, .35) 30%, rgba(4, 7, 13, 0) 50%), linear-gradient(0deg, rgba(4, 7, 13, .5), rgba(4, 7, 13, 0) 35%); }
.hero-in { position: relative; max-width: 560px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; margin: 0 0 14px; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--cyan); background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .3); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: ring 1.8s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, .7); } 70%, 100% { box-shadow: 0 0 0 9px rgba(34, 211, 238, 0); } }
h1 { font-size: clamp(30px, 4vw, 52px); line-height: 1.06; letter-spacing: -0.02em; margin: 0 0 14px; font-weight: 800; text-shadow: 0 2px 30px rgba(0, 0, 0, .65); text-wrap: balance; }
.lead { font-size: 15px; color: #c9d5e5; margin: 0 0 22px; font-family: var(--mono); text-shadow: 0 1px 14px rgba(0, 0, 0, .8); }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 26px; margin-top: 24px; padding: 12px 18px; border-radius: 13px; background: rgba(5, 9, 17, .55); border: 1px solid var(--line); backdrop-filter: blur(10px); width: max-content; max-width: 100%; }
.hero-stats > div > span { display: block; font-size: 11px; color: var(--ink-3); }
.hero-stats b { font-size: 18px; }

.chapter { min-height: 100vh; min-height: 100svh; display: flex; align-items: center; padding: 120px 40px; }
.card { width: 360px; max-width: 100%; padding: 22px 24px; background: var(--glass-2); }
.kicker { margin: 0 0 6px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; color: var(--cyan); text-transform: uppercase; }
h2 { font-size: clamp(24px, 2.4vw, 30px); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.015em; font-weight: 800; text-wrap: balance; }
h3 { font-size: 12.5px; margin: 0 0 4px; color: var(--cyan); font-family: var(--mono); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.card p, .panel p { color: #c3cfdf; margin: 0 0 12px; font-size: 15px; }
.card p:last-child { margin-bottom: 0; }
.link { margin-top: 4px; background: none; border: 0; color: var(--amber); font-weight: 700; font-size: 13.5px; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.trio, .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.nums { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.nums.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }
.nums.one { grid-template-columns: 1fr; }
.trio > div, .nums > div { padding: 10px 12px; border-radius: 11px; background: rgba(148, 180, 220, .05); border: 1px solid var(--line); }
.nums > div { border-color: color-mix(in srgb, currentColor 45%, transparent); background: color-mix(in srgb, currentColor 7%, transparent); }
.trio b { display: block; font-size: 15px; }
.trio span, .nums > div > span { display: block; font-size: 12px; color: var(--ink-3); }
.nums b { display: block; font-size: 22px; line-height: 1.2; }
.nums.three b { font-size: 17px; }

.wide { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 120px 40px; }
.panel { width: min(880px, 100%); padding: 28px 30px; background: rgba(6, 10, 19, .86); }
.flow { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 8px 6px; align-items: center; }
.flow li { padding: 9px 14px; border-radius: 11px; font-weight: 700; font-size: 14.5px; background: linear-gradient(160deg, rgba(34, 211, 238, .12), rgba(148, 180, 220, .03)); border: 1px solid rgba(34, 211, 238, .28); }
.flow li:not(:last-child)::after { content: '→'; margin-left: 10px; color: var(--cyan); }
.stack { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.stack span { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-family: var(--mono); color: var(--ink-2); border: 1px solid var(--line); }

.why { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 20px; }
.why > div { padding: 14px 16px; border-radius: 13px; background: rgba(148, 180, 220, .05); border: 1px solid var(--line); }
.why p { font-size: 14px !important; margin: 0 !important; line-height: 1.45; }

footer { position: relative; display: flex; justify-content: space-between; gap: 8px 20px; padding: 22px 40px 30px; font-size: 12.5px; color: var(--ink-2); background: linear-gradient(transparent, rgba(4, 7, 13, .95) 40%); }

/* ============ АДАПТИВ ============ */
@media (max-width: 1000px) {
  .why { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  header.top { top: 8px; left: 8px; right: 8px; padding: 6px 8px 6px 10px; }
  .nav { display: none; }
  header .btn { margin-left: auto; }
  #phase { top: 62px; left: 8px; right: 8px; transform: none; justify-content: space-between; padding: 4px; }
  #phase .step:not(.active) { font-size: 0; gap: 0; padding: 4px; }
  #banner { top: 104px; font-size: 12.5px; }
  body.explore #tele { top: auto; bottom: 62px; right: 8px; width: 170px; padding: 9px 11px; gap: 6px; }
  #mini { right: 8px; top: 104px; bottom: auto; padding: 5px; }
  #mini .legend { display: none; }
  #minimap { width: 150px; height: 94px; }
  body[data-chapter="hero"]:not(.explore) #mini { display: none; }
  #layersPanel { top: auto; bottom: 62px; left: 8px; width: auto; max-width: calc(100% - 196px); padding: 7px; }
  #layersPanel .chips button { font-size: 11px; padding: 4px 7px; }
  body.explore #log { display: none; }
  #controls { left: 8px; right: 8px; transform: none; bottom: 8px; flex-wrap: wrap; justify-content: center; gap: 5px; padding: 5px; }
  #controls .grp + .grp { padding-left: 5px; }
  #controls button { padding: 5px 7px; font-size: 11.5px; }
  .hero { padding: 120px 16px 28px; }
  h1 { font-size: 30px; }
  .lead { font-size: 13px; }
  .hero-stats { gap: 18px; }
  .chapter { align-items: flex-end; padding: 60vh 12px 28px; min-height: 100vh; }
  .card { width: 100%; padding: 18px; }
  .wide { padding: 90px 10px 40px; }
  .panel { padding: 22px 18px; }
  footer { padding: 20px 16px 28px; }
}
@media (max-width: 400px) {
  .brand b { font-size: 13.5px; }
  header .btn { padding: 8px 12px; }
  .hero-stats b { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* команда */
.crew { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 20px; }
.crew > div { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto auto; column-gap: 12px; align-items: center; padding: 14px 16px; border-radius: 13px; background: rgba(148, 180, 220, .05); border: 1px solid var(--line); }
.crew i { grid-row: 1 / 4; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 18px; color: #031018; background: linear-gradient(135deg, #22d3ee, #a78bfa); box-shadow: 0 0 18px rgba(34, 211, 238, .35); }
.crew b { font-size: 15.5px; }
.crew span { font-size: 13px; font-weight: 700; }
.crew em { font-style: normal; font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
@media (max-width: 860px) { .crew { grid-template-columns: 1fr; } }
