:root {
  color-scheme: dark;
  --bg: #05090f;
  --panel: rgba(9, 15, 24, 0.78);
  --panel-strong: rgba(11, 18, 29, 0.92);
  --line: rgba(126, 173, 210, 0.15);
  --line-strong: rgba(126, 173, 210, 0.28);
  --text: #e8eef7;
  --muted: #7d90a6;
  --muted-2: #5d6e83;
  --mint: #5ff2c9;
  --blue: #5ad1ff;
  --pink: #ff6b93;
  --amber: #ffd166;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

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

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(2, 5, 9, 0.55) 100%),
    linear-gradient(180deg, rgba(3, 7, 12, 0.7) 0%, transparent 16%, transparent 82%, rgba(3, 7, 12, 0.65) 100%);
}

/* ---------- top bar ---------- */

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 30px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4, 8, 14, 0.75), transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(95, 242, 201, 0.18), rgba(90, 209, 255, 0.06));
  border: 1px solid rgba(95, 242, 201, 0.28);
  box-shadow: 0 0 24px rgba(95, 242, 201, 0.12);
}

.mark svg {
  width: 22px;
  height: 22px;
  fill: var(--mint);
  filter: drop-shadow(0 0 6px rgba(95, 242, 201, 0.55));
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.brand-text p {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.badges {
  display: flex;
  gap: 8px;
}

.badge {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(9, 15, 24, 0.72);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.badge.live {
  color: var(--mint);
  border-color: rgba(95, 242, 201, 0.28);
}

.badge.live.paused {
  color: var(--amber);
  border-color: rgba(255, 209, 102, 0.3);
}

.badge.lock {
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  line-height: normal;
}

.badge.lock:hover {
  color: var(--pink);
  border-color: rgba(255, 107, 147, 0.32);
  background: rgba(255, 107, 147, 0.08);
}

.badge.lock:focus-visible {
  outline: 2px solid rgba(95, 242, 201, 0.65);
  outline-offset: 1px;
}

/* ---------- panels ---------- */

.panel {
  position: absolute;
  top: 86px;
  width: 272px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(12, 20, 31, 0.94), rgba(8, 14, 23, 0.92));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
  scrollbar-color: rgba(126, 173, 210, 0.22) transparent;
}

.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: rgba(126, 173, 210, 0.22); border-radius: 99px; }

.panel-left { left: 20px; }
.panel-right { right: 20px; }

.panel section + section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.h2-note {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  text-transform: none;
}

/* ---------- telemetry ---------- */

.hero-stat {
  position: relative;
  margin-bottom: 14px;
  padding: 12px 13px 11px;
  border-radius: 12px;
  border: 1px solid rgba(95, 242, 201, 0.16);
  background: radial-gradient(120% 140% at 0% 0%, rgba(95, 242, 201, 0.12), rgba(95, 242, 201, 0.015) 60%);
  overflow: hidden;
}

.hero-stat::after {
  content: "";
  position: absolute;
  inset: auto -30% -70% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(95, 242, 201, 0.16), transparent 70%);
}

.hero-label {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(95, 242, 201, 0.75);
}

.hero-stat strong {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #f2fffb;
  text-shadow: 0 0 24px rgba(95, 242, 201, 0.35);
}

.hero-sub {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin: 0;
}

.stat-grid div {
  padding: 8px 9px;
  border-radius: 9px;
  border: 1px solid rgba(126, 173, 210, 0.09);
  background: rgba(126, 173, 210, 0.035);
}

.stat-grid dt {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.stat-grid dd {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 13px;
  color: #dbe6f3;
  white-space: nowrap;
}

.episode { margin-top: 12px; }

.episode-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

#stat-episode { color: var(--muted); letter-spacing: 0; text-transform: none; }

.bar {
  height: 4px;
  border-radius: 99px;
  background: rgba(126, 173, 210, 0.12);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue), var(--mint));
  box-shadow: 0 0 10px rgba(95, 242, 201, 0.4);
  transition: width 0.12s linear;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}

/* ---------- controls ---------- */

.controls .btn,
.speed button {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #cfdaea;
  border: 1px solid var(--line);
  background: rgba(126, 173, 210, 0.055);
  border-radius: 9px;
  padding: 9px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}

.controls .btn:hover,
.speed button:hover {
  border-color: var(--line-strong);
  background: rgba(126, 173, 210, 0.11);
}

.controls .btn:active,
.speed button:active { transform: translateY(1px); }

.controls .btn:focus-visible,
.speed button:focus-visible {
  outline: 2px solid rgba(95, 242, 201, 0.65);
  outline-offset: 1px;
}

.btn.primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-color: rgba(95, 242, 201, 0.35);
  background: linear-gradient(180deg, rgba(95, 242, 201, 0.2), rgba(95, 242, 201, 0.08));
  color: #d8fff4;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.btn.primary:hover {
  background: linear-gradient(180deg, rgba(95, 242, 201, 0.28), rgba(95, 242, 201, 0.12));
  border-color: rgba(95, 242, 201, 0.55);
}

.ico { font-size: 9px; letter-spacing: -0.1em; }

.speed {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 8px;
}

.speed button {
  padding: 7px 0;
  text-align: center;
  color: var(--muted);
}

.speed button.on {
  color: #06110e;
  border-color: transparent;
  background: var(--mint);
  box-shadow: 0 0 16px rgba(95, 242, 201, 0.25);
  font-weight: 700;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

.btn.toggle.on {
  color: var(--blue);
  border-color: rgba(90, 209, 255, 0.3);
  background: rgba(90, 209, 255, 0.1);
}

.btn.ghost { color: var(--muted); }

/* ---------- right panel ---------- */

.panel-right section canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 9px;
  background: rgba(4, 9, 15, 0.5);
  border: 1px solid rgba(126, 173, 210, 0.07);
}

#brain { height: 150px; }
#chart { height: 108px; }
#minimap { height: 150px; }

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--muted-2);
}

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend .pos { background: var(--mint); box-shadow: 0 0 6px rgba(95, 242, 201, 0.6); }
.legend .neg { background: var(--pink); box-shadow: 0 0 6px rgba(255, 107, 147, 0.5); margin-left: 8px; }

/* ---------- overlays ---------- */

.hints {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(7, 12, 19, 0.72);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted-2);
  white-space: nowrap;
}

.hints span { display: inline-flex; align-items: center; gap: 5px; }

.hint-sep {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: rgba(95, 242, 201, 0.55);
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(126, 173, 210, 0.07);
  font-family: var(--mono);
  font-size: 8.5px;
  color: #b7c6d8;
}

.banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -12px);
  padding: 10px 22px;
  border-radius: 12px;
  border: 1px solid rgba(95, 242, 201, 0.25);
  background: rgba(6, 12, 18, 0.72);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.28em;
  color: var(--mint);
  opacity: 0;
  pointer-events: none;
}

.banner.show {
  animation: banner 1.4s ease forwards;
}

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 6px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translate(-50%, 6px);
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 22, 0.9);
  font-family: var(--mono);
  font-size: 10px;
  color: #cbd8e8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 70vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.paused-flag {
  position: absolute;
  top: 114px;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.4em;
  color: rgba(255, 209, 102, 0.85);
  text-shadow: 0 0 20px rgba(255, 209, 102, 0.4);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.paused-flag.show { opacity: 1; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .panel-right { display: none; }
}

@media (max-width: 760px) {
  .panel-left {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 42vh;
    display: flex;
    flex-direction: column;
  }
  .panel-left .controls {
    order: -1;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
  .panel-left .meta,
  .panel-left .episode,
  .panel-left .controls .btn-row:last-child { display: none; }
  .panel-left .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .hints { display: none; }
  .brand-text p { display: none; }
  .topbar { padding: 12px 14px; }
  .badges .badge:first-child { display: none; }
}
