:root {
  color-scheme: dark;
  --bg: #03070d;
  --panel: rgba(8, 14, 24, 0.78);
  --panel-strong: rgba(9, 16, 28, 0.92);
  --line: rgba(125, 247, 255, 0.18);
  --line-strong: rgba(125, 247, 255, 0.38);
  --text: #f5f8ff;
  --muted: rgba(224, 232, 246, 0.74);
  --cyan: #76e8ff;
  --cyan-soft: rgba(118, 232, 255, 0.26);
  --green: #86f28e;
  --green-soft: rgba(134, 242, 142, 0.22);
  --gold: #efbf4d;
  --gold-soft: rgba(239, 191, 77, 0.24);
  --violet: #bb8fff;
  --violet-soft: rgba(187, 143, 255, 0.24);
  --danger: #ff9f80;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 12%, rgba(22, 122, 166, 0.18), transparent 24rem),
    radial-gradient(circle at 82% 14%, rgba(22, 97, 52, 0.2), transparent 21rem),
    linear-gradient(180deg, #05101c, #03070d 56%, #02050a);
  color: var(--text);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

body {
  overflow-x: hidden;
}

.page-shell {
  position: relative;
  min-height: 100vh;
}

.ambient,
.ambient-grid {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.ambient-a {
  background: radial-gradient(circle at 20% 20%, rgba(95, 229, 255, 0.12), transparent 22rem);
  filter: blur(24px);
  animation: driftA 16s ease-in-out infinite;
}

.ambient-b {
  background: radial-gradient(circle at 78% 28%, rgba(135, 255, 176, 0.08), transparent 20rem);
  filter: blur(26px);
  animation: driftB 19s ease-in-out infinite;
}

.ambient-grid {
  background-image:
    linear-gradient(rgba(111, 212, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 212, 255, 0.055) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent 92%);
  opacity: 0.38;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1520px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 28px;
  display: grid;
  gap: 18px;
}

.panel,
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.02), rgba(118, 232, 255, 0.04) 52%, rgba(0, 0, 0, 0.05)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  padding: clamp(22px, 3vw, 34px);
}

.eyebrow-row,
.hero-grid,
.metric-strip,
.content-grid,
.legend-grid,
.panel-badges,
.stage-facts,
.waypoint-list,
.control-stack,
.feed {
  display: grid;
  gap: 12px;
}

.eyebrow-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.eyebrow,
.panel-kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan);
}

.status-chip,
.tiny-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid rgba(118, 232, 255, 0.24);
  border-radius: 999px;
  background: rgba(118, 232, 255, 0.08);
  color: #ebfbff;
  font-size: 12px;
}

.hero-grid {
  margin-top: 12px;
  grid-template-columns: minmax(0, 1.4fr) auto;
  align-items: end;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 15ch;
  font-size: clamp(2.8rem, 6vw, 5.4rem);
  line-height: 0.93;
  letter-spacing: -0.08em;
}

.hero-copy {
  max-width: 66ch;
  margin-top: 16px;
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  line-height: 1.65;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.glass-button {
  appearance: none;
  border: 1px solid rgba(118, 232, 255, 0.2);
  border-radius: 16px;
  background: rgba(5, 14, 25, 0.74);
  color: var(--text);
  font: inherit;
  padding: 12px 16px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.glass-button:hover,
.glass-button:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(118, 232, 255, 0.48);
  box-shadow: 0 0 32px rgba(118, 232, 255, 0.16);
}

.glass-button.primary {
  background: linear-gradient(135deg, rgba(118, 232, 255, 0.16), rgba(134, 242, 142, 0.12));
}

.metric-strip {
  margin-top: 18px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-card {
  padding: 14px 16px;
  border: 1px solid rgba(118, 232, 255, 0.14);
  border-radius: 18px;
  background: rgba(3, 10, 18, 0.78);
}

.metric-card span {
  display: block;
}

.metric-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(230, 237, 246, 0.64);
}

.metric-value {
  margin-top: 8px;
  font-size: 1.6rem;
  font-weight: 700;
}

.metric-note {
  margin-top: 6px;
  color: rgba(223, 232, 244, 0.74);
  font-size: 0.92rem;
}

.content-grid {
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  align-items: start;
}

.panel-left,
.panel-right,
.legend-panel,
.diagram-stage {
  padding: 18px;
}

.panel-head {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 1.4rem;
  letter-spacing: -0.04em;
}

.waypoint-button {
  appearance: none;
  width: 100%;
  padding: 14px;
  text-align: left;
  border-radius: 18px;
  border: 1px solid rgba(118, 232, 255, 0.12);
  background: rgba(4, 10, 18, 0.72);
  color: inherit;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.waypoint-button:hover,
.waypoint-button:focus-visible,
.waypoint-button.is-hovered,
.waypoint-button.is-active {
  transform: translateX(4px);
  border-color: var(--line-strong);
  box-shadow: 0 0 28px rgba(118, 232, 255, 0.12);
}

.waypoint-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-weight: 700;
  line-height: 1.35;
}

.waypoint-title span:first-child {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  word-break: break-word;
}

.waypoint-title span:last-child {
  flex-shrink: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--cyan);
  opacity: 0.85;
  margin-top: 1px;
}

.waypoint-copy,
.event-copy,
.runtime-card p,
.legend-item p,
#focusCopy {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.96rem;
}

.waypoint-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.waypoint-meta span:first-child {
  flex: 1;
  min-width: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(230, 237, 246, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: rgba(230, 237, 246, 0.62);
}

.control-card,
.runtime-card {
  padding: 14px;
  border: 1px solid rgba(118, 232, 255, 0.12);
  border-radius: 18px;
  background: rgba(3, 10, 18, 0.76);
}

.control-card span,
.runtime-card span {
  display: block;
  margin-bottom: 8px;
}

.control-card strong,
.runtime-card strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  word-wrap: break-word;
  word-break: break-word;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.panel-head-stage {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.panel-badges {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: flex-end;
}

.diagram-frame {
  position: relative;
  margin-top: 10px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(118, 232, 255, 0.18);
  background:
    radial-gradient(circle at 50% 18%, rgba(118, 232, 255, 0.14), transparent 20rem),
    #02060b;
}

.reference-image {
  display: block;
  width: 100%;
  height: auto;
}

.flow-overlay,
.hotspot-layer,
.scanline {
  position: absolute;
  inset: 0;
}

.flow-overlay {
  width: 100%;
  height: 100%;
}

.flow-overlay path {
  fill: none;
  stroke-linecap: round;
  stroke-width: 0.38;
  stroke-dasharray: 2.6 2.8;
  opacity: 0.88;
  animation: routePulse linear infinite;
}

.flow-overlay path.flow-cyan {
  stroke: rgba(118, 232, 255, 0.86);
}

.flow-overlay path.flow-green {
  stroke: rgba(134, 242, 142, 0.84);
}

.flow-overlay path.flow-gold {
  stroke: rgba(239, 191, 77, 0.84);
}

.flow-overlay path.flow-violet {
  stroke: rgba(187, 143, 255, 0.82);
}

.flow-overlay circle.flow-anchor {
  fill: rgba(245, 248, 255, 0.92);
  filter: drop-shadow(0 0 10px rgba(118, 232, 255, 0.45));
}

.scanline {
  background:
    linear-gradient(180deg, transparent, rgba(118, 232, 255, 0.12), transparent),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 5px);
  mix-blend-mode: screen;
  opacity: 0.5;
  animation: scanline 8s linear infinite;
}

.hotspot-layer {
  pointer-events: none;
}

.hotspot {
  --accent: var(--cyan);
  --glow: var(--cyan-soft);
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  transform: translate(-50%, -50%) scale(1);
  width: 18px;
  height: 18px;
  border: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow:
    0 0 0 0 var(--glow),
    0 0 24px var(--glow);
  pointer-events: auto;
  cursor: pointer;
  transition:
    transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 220ms cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 220ms ease;
}

.hotspot::before,
.hotspot::after {
  content: "";
  position: absolute;
  inset: 50%;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hotspot::before {
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--accent) 82%, white 18%);
  opacity: 0.55;
  transition:
    transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 220ms ease,
    opacity 220ms ease;
}

.hotspot::after {
  width: 72px;
  height: 72px;
  border: 1px solid var(--glow);
  opacity: 0;
  transition: opacity 220ms ease;
}

/* Hover and Active Hover states */
.hotspot:hover,
.hotspot.is-hovered {
  transform: translate(-50%, -50%) scale(1.35);
  box-shadow:
    0 0 0 6px var(--glow),
    0 0 32px var(--accent);
  background: color-mix(in srgb, var(--accent) 80%, white 20%);
}

.hotspot:hover::before,
.hotspot.is-hovered::before {
  transform: translate(-50%, -50%) scale(1.2);
  border-color: #ffffff;
  opacity: 0.9;
}

.hotspot.is-active {
  animation: hotspotPulse 2.5s ease-out infinite;
}

.hotspot.is-active::after {
  animation: ringBurst 2.5s ease-out infinite;
}

/* If active is hovered, keep pulse but scale it up nicely */
.hotspot.is-active:hover,
.hotspot.is-active.is-hovered {
  animation: hotspotPulseHover 2.5s ease-out infinite;
}

.hotspot-label {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1% + 2.5%);
  transform: translate(-50%, 0) scale(0.95);
  min-width: 156px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(3, 9, 17, 0.92);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  color: #f8fbff;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0;
  transition:
    opacity 220ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 10;
}

/* Hovering over hotspot OR waypoint highlights the label */
.hotspot-label.is-active,
.hotspot-label.is-hovered,
.hotspot:hover + .hotspot-label {
  opacity: 1;
  transform: translate(-50%, 8px) scale(1);
}

.stage-footer {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.stage-summary h3 {
  margin-top: 6px;
  font-size: 1.6rem;
  letter-spacing: -0.05em;
}

.fact-chip {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(118, 232, 255, 0.12);
  background: rgba(3, 10, 18, 0.72);
}

.fact-label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(230, 237, 246, 0.62);
}

.fact-value {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
}

.feed {
  max-height: 840px;
  overflow: auto;
}

.feed::-webkit-scrollbar {
  width: 10px;
}

.feed::-webkit-scrollbar-thumb {
  background: rgba(118, 232, 255, 0.14);
  border-radius: 999px;
}

.event-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(118, 232, 255, 0.1);
  background: rgba(4, 10, 18, 0.74);
}

.event-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.event-status.live {
  background: rgba(118, 232, 255, 0.1);
  color: var(--cyan);
}

.event-status.boundary {
  background: rgba(239, 191, 77, 0.12);
  color: #ffd88d;
}

.event-status.memory {
  background: rgba(239, 191, 77, 0.12);
  color: #ffe2a4;
}

.event-status.edge {
  background: rgba(187, 143, 255, 0.12);
  color: #d7c1ff;
}

.legend-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.2fr);
  gap: 22px;
  align-items: start;
}

.legend-copy p {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.legend-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(118, 232, 255, 0.1);
  background: rgba(4, 10, 18, 0.72);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 4px;
}

.swatch-cyan {
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(118, 232, 255, 0.48);
}

.swatch-green {
  background: var(--green);
  box-shadow: 0 0 18px rgba(134, 242, 142, 0.42);
}

.swatch-gold {
  background: var(--gold);
  box-shadow: 0 0 18px rgba(239, 191, 77, 0.42);
}

.swatch-violet {
  background: var(--violet);
  box-shadow: 0 0 18px rgba(187, 143, 255, 0.42);
}

@keyframes routePulse {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -24;
  }
}

@keyframes hotspotPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 0 var(--glow),
      0 0 24px var(--glow);
  }
  50% {
    box-shadow:
      0 0 0 9px rgba(255, 255, 255, 0.03),
      0 0 36px var(--glow);
  }
}

@keyframes ringBurst {
  0% {
    width: 26px;
    height: 26px;
    opacity: 0.72;
  }
  100% {
    width: 92px;
    height: 92px;
    opacity: 0;
  }
}

@keyframes scanline {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

@keyframes driftA {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(24px, -18px, 0);
  }
}

@keyframes driftB {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-28px, 20px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-a,
  .ambient-b,
  .flow-overlay path,
  .scanline,
  .hotspot.is-active,
  .hotspot.is-active::after,
  .hotspot.is-active:hover,
  .hotspot.is-active.is-hovered {
    animation: none !important;
  }

  .scanline {
    opacity: 0.12;
  }

  .glass-button,
  .waypoint-button,
  .hotspot-label,
  .hotspot,
  .hotspot::before,
  .accent-badge {
    transition: none !important;
  }

  .waypoint-button:hover,
  .waypoint-button:focus-visible,
  .waypoint-button.is-hovered,
  .waypoint-button.is-active,
  .glass-button:hover,
  .glass-button:focus-visible {
    transform: none !important;
  }

  .hotspot:hover,
  .hotspot.is-hovered {
    transform: translate(-50%, -50%) scale(1) !important;
  }

  .hotspot-label.is-active,
  .hotspot-label.is-hovered,
  .hotspot:hover + .hotspot-label {
    transform: translate(-50%, 8px) scale(1) !important;
  }
}

/* Highly premium custom styles and hover dynamics */
.accent-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  transition: all 180ms ease;
}

.accent-badge.badge-cyan {
  color: var(--cyan);
  border-color: rgba(118, 232, 255, 0.22);
  background: rgba(118, 232, 255, 0.04);
}

.accent-badge.badge-green {
  color: var(--green);
  border-color: rgba(134, 242, 142, 0.22);
  background: rgba(134, 242, 142, 0.04);
}

.accent-badge.badge-gold {
  color: var(--gold);
  border-color: rgba(239, 191, 77, 0.22);
  background: rgba(239, 191, 77, 0.04);
}

.accent-badge.badge-violet {
  color: var(--violet);
  border-color: rgba(187, 143, 255, 0.22);
  background: rgba(187, 143, 255, 0.04);
}

/* Highlight matching badge on waypoint active/hovered */
.waypoint-button:hover .accent-badge.badge-cyan,
.waypoint-button.is-hovered .accent-badge.badge-cyan,
.waypoint-button.is-active .accent-badge.badge-cyan {
  background: rgba(118, 232, 255, 0.16);
  border-color: rgba(118, 232, 255, 0.5);
  box-shadow: 0 0 10px rgba(118, 232, 255, 0.15);
}

.waypoint-button:hover .accent-badge.badge-green,
.waypoint-button.is-hovered .accent-badge.badge-green,
.waypoint-button.is-active .accent-badge.badge-green {
  background: rgba(134, 242, 142, 0.16);
  border-color: rgba(134, 242, 142, 0.5);
  box-shadow: 0 0 10px rgba(134, 242, 142, 0.15);
}

.waypoint-button:hover .accent-badge.badge-gold,
.waypoint-button.is-hovered .accent-badge.badge-gold,
.waypoint-button.is-active .accent-badge.badge-gold {
  background: rgba(239, 191, 77, 0.16);
  border-color: rgba(239, 191, 77, 0.5);
  box-shadow: 0 0 10px rgba(239, 191, 77, 0.15);
}

.waypoint-button:hover .accent-badge.badge-violet,
.waypoint-button.is-hovered .accent-badge.badge-violet,
.waypoint-button.is-active .accent-badge.badge-violet {
  background: rgba(187, 143, 255, 0.16);
  border-color: rgba(187, 143, 255, 0.5);
  box-shadow: 0 0 10px rgba(187, 143, 255, 0.15);
}

@keyframes hotspotPulseHover {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1.35);
    box-shadow:
      0 0 0 6px var(--glow),
      0 0 32px var(--accent);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.42);
    box-shadow:
      0 0 0 12px rgba(255, 255, 255, 0.06),
      0 0 44px var(--accent);
  }
}

@media (max-width: 1260px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .panel-left,
  .panel-right {
    order: 2;
  }

  .diagram-stage {
    order: 1;
  }

  .stage-footer,
  .legend-panel,
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-badges,
  .hero-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 18px, 1520px);
    padding-top: 10px;
    gap: 14px;
  }

  .hero,
  .panel-left,
  .panel-right,
  .diagram-stage,
  .legend-panel {
    padding: 14px;
    border-radius: 20px;
  }

  h1 {
    font-size: clamp(2.35rem, 14vw, 3.6rem);
  }

  .metric-strip,
  .legend-grid {
    grid-template-columns: 1fr;
  }

  .hotspot-label {
    min-width: 132px;
    font-size: 0.82rem;
  }
}
