:root {
  --bg: #1f1633;
  --bg-deep: #150f26;
  --panel: #2a1f42;
  --panel-2: #332650;
  --line: rgba(194, 239, 78, 0.18);
  --line-soft: rgba(239, 233, 255, 0.10);
  --lime: #c2ef4e;
  --violet: #9d7fe0;
  --amber: #f2a65a;
  --coral: #ff7a59;
  --magenta: #e26fd0;
  --ink: #efe9ff;
  --muted: #a99fc4;
  --dim: #6f6489;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Rubik', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#stage { position: fixed; inset: 0; }
#gl { display: block; width: 100%; height: 100%; }

.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(194, 239, 78, 0.07), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(157, 127, 224, 0.14), transparent 65%),
    radial-gradient(100% 100% at 50% 50%, transparent 40%, rgba(21, 15, 38, 0.85) 100%);
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  z-index: 10;
  font-family: var(--sans);
}

.brand {
  top: 22px; left: 26px;
  max-width: 430px;
}
.brand .eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lime);
  display: flex; align-items: center; gap: 8px;
}
.brand .eyebrow::after {
  content: ''; height: 1px; flex: 1;
  background: linear-gradient(90deg, var(--line), transparent);
}
.brand h1 {
  margin: 10px 0 6px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.brand h1 em {
  font-style: normal;
  color: var(--lime);
}
.brand p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 400px;
}

.timer {
  top: 22px; right: 26px;
  text-align: right;
}
.timer .badge {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 13px;
  border: 1px solid rgba(194, 239, 78, 0.32);
  border-radius: 999px;
  background: rgba(31, 22, 51, 0.78);
  backdrop-filter: blur(9px);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--lime);
}
.timer .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.28} }
.timer .sub {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.08em;
}

/* ---------- toolbar ---------- */

.toolbar {
  position: fixed; z-index: 10;
  left: 26px; bottom: 24px;
  display: flex; gap: 7px; flex-wrap: wrap;
  align-items: center;
}
button.tool {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(31, 22, 51, 0.8);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px 11px;
  cursor: pointer;
  transition: all .16s ease;
  backdrop-filter: blur(9px);
}
button.tool:hover { color: var(--ink); border-color: rgba(194,239,78,.45); }
button.tool.on {
  color: var(--bg-deep);
  background: var(--lime);
  border-color: var(--lime);
}
.themebar {
  display: inline-flex; align-items: center; gap: 5px;
  padding-left: 8px; margin-left: 3px;
  border-left: 1px solid var(--line-soft);
}
.themebar .tool { display: inline-flex; align-items: center; gap: 6px; padding: 8px 9px; }
.tchip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--pip, var(--lime));
  box-shadow: 0 0 6px var(--pip, var(--lime));
}
.hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.07em;
  margin-left: 4px;
}

/* ---------- legend ---------- */

.legend {
  position: fixed; z-index: 10;
  left: 26px; bottom: 74px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(31, 22, 51, 0.7);
  backdrop-filter: blur(9px);
}
.legend .row {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.legend .legend-title {
  color: var(--lime); opacity: .62;
  letter-spacing: .02em; margin-bottom: 3px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}

/* ---------- part index ---------- */

.index {
  position: fixed; z-index: 10;
  right: 26px; top: 108px;
  width: 218px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(31, 22, 51, 0.72);
  backdrop-filter: blur(9px);
  transition: opacity .2s ease, transform .25s ease;
}
.index h2 {
  margin: 0 0 9px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--lime);
  font-weight: 500;
}
.index button {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 6px 7px;
  border: 0; border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
  transition: all .14s ease;
}
.index button:hover { background: rgba(194,239,78,.08); color: var(--ink); }
.index button.active { background: rgba(194,239,78,.14); color: var(--lime); }
.index .pip { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.index::-webkit-scrollbar { width: 5px; }
.index::-webkit-scrollbar-thumb { background: rgba(194,239,78,.25); border-radius: 9px; }
body.panel-open .index { opacity: 0; pointer-events: none; transform: translateX(14px); }

/* ---------- info panel ---------- */

.panel {
  position: fixed; z-index: 20;
  top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 92vw;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 70px rgba(0,0,0,.45);
  transform: translateX(102%);
  transition: transform .32s cubic-bezier(.22,.9,.28,1);
  display: flex; flex-direction: column;
}
body.panel-open .panel { transform: translateX(0); }

.panel-head {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head .kind {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  margin-bottom: 12px;
}
.panel-head h3 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.panel-head .where {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.panel-head .tag {
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.close {
  position: absolute; top: 16px; right: 16px;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--muted);
  font-size: 16px; line-height: 1;
  cursor: pointer;
}
.close:hover { color: var(--ink); border-color: rgba(194,239,78,.5); }

.panel-body {
  padding: 18px 22px 26px;
  overflow-y: auto;
  flex: 1;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(194,239,78,.25); border-radius: 9px; }

.specs {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.specs .k, .specs .v {
  background: var(--panel);
  padding: 8px 11px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.4;
}
.specs .k { color: var(--dim); letter-spacing: 0.04em; }
.specs .v { color: var(--lime); text-align: right; }

.panel-body ul { margin: 0 0 18px; padding: 0; list-style: none; }
.panel-body li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 13px;
  font-size: 13.5px;
  line-height: 1.72;
  color: #ded7f0;
}
.panel-body li::before {
  content: '';
  position: absolute; left: 2px; top: 9px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--lime);
  opacity: .8;
}
.ref {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.06em;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; gap: 10px;
}
.nav {
  display: flex; gap: 8px; padding: 14px 22px 20px;
  border-top: 1px solid var(--line-soft);
}
.nav button {
  flex: 1;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 11px 8px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.nav button:hover { color: var(--lime); border-color: rgba(194,239,78,.45); }

/* ---------- tooltip ---------- */

.tip {
  position: fixed; z-index: 15;
  pointer-events: none;
  transform: translate(-50%, -140%);
  padding: 6px 10px;
  border-radius: 7px;
  background: rgba(21, 15, 38, 0.92);
  border: 1px solid rgba(194,239,78,.35);
  color: var(--lime);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .13s ease;
}
.tip.show { opacity: 1; }

/* ---------- loader / shutdown ---------- */

.veil {
  position: fixed; inset: 0; z-index: 40;
  background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  transition: opacity .6s ease;
}
.veil.gone { opacity: 0; pointer-events: none; }
.veil .ring {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(194,239,78,.18);
  border-top-color: var(--lime);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.veil .msg {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
}
.veil .err { color: var(--coral); max-width: 420px; text-align: center; line-height: 1.6; }

.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 14px;
  background: rgba(21, 15, 38, 0.94);
  text-align: center; padding: 30px;
}
.overlay.show { display: flex; }
.overlay h2 { margin: 0; font-size: 26px; font-weight: 600; }
.overlay p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.7; max-width: 480px; }
.overlay .code {
  font-family: var(--mono); font-size: 11px; color: var(--lime);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 13px;
}

/* ---------- 3D projected labels ---------- */

#labels { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
.lbl {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 7px;
  border-radius: 999px;
  border: 1px solid rgba(239, 233, 255, 0.14);
  background: rgba(21, 15, 38, 0.62);
  backdrop-filter: blur(5px);
  color: #cdc3e8;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.045em;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  opacity: .92;
  transition: opacity .18s ease, border-color .18s ease, color .18s ease, background .18s ease;
}
.lbl .lbl-dot {
  width: 6px; height: 6px; border-radius: 50%;
  box-shadow: 0 0 7px currentColor;
}
.lbl:hover, .lbl.hot {
  opacity: 1; color: var(--ink);
  border-color: rgba(194, 239, 78, 0.55);
  background: rgba(31, 22, 51, 0.9);
}
.lbl.sel {
  opacity: 1;
  color: var(--bg-deep);
  background: var(--lime);
  border-color: var(--lime);
}
.lbl.dim { opacity: .16; }
@media (max-width: 860px) { .lbl { font-size: 8.5px; padding: 3px 7px 3px 6px; } }

@media (max-width: 860px) {
  .brand h1 { font-size: 22px; }
  .brand p { display: none; }
  .index { display: none; }
  .legend { display: none; }
  .panel { width: 100%; max-width: 100%; top: auto; height: 62vh; border-left: 0;
           border-top: 1px solid var(--line); transform: translateY(102%); border-radius: 16px 16px 0 0; }
  body.panel-open .panel { transform: translateY(0); }
  .toolbar { left: 14px; bottom: 14px; }
  .brand { left: 14px; top: 14px; }
  .timer { right: 14px; top: 14px; }
}