:root {
  --bg: #070b18;
  --panel: #11172c;
  --text: #e8edff;
  --muted: #a8b2d3;
  --border: #273050;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at 20% 0%, #1d2a55 0%, var(--bg) 45%);
  color: var(--text);
}

.page {
  width: min(1280px, 94vw);
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 2rem);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  text-decoration: none;
  color: #051022;
  background: linear-gradient(120deg, #6ea8fe, #9fc5ff);
  border-radius: 10px;
  font-weight: 700;
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
}

.btn.secondary {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.legend-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.viewport {
  background: rgba(17, 23, 44, 0.78);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  height: min(74vh, 860px);
  min-height: 520px;
  position: relative;
}

#graph {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.edge {
  stroke: rgba(164, 179, 220, 0.55);
  stroke-width: 1.3;
}

.node circle {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1;
}

.node text {
  font-size: 11px;
  text-anchor: middle;
  fill: var(--text);
  pointer-events: none;
}

.node { cursor: pointer; }
.node:hover circle { stroke: #ffffff; stroke-width: 2; }
.node { cursor: pointer; outline: none; }
.node:hover circle { stroke: #ffffff; stroke-width: 2; }
.node:focus-visible circle { stroke: #6ea8fe; stroke-width: 2.5; filter: drop-shadow(0 0 4px rgba(110, 168, 254, 0.6)); }

.tooltip {
  position: absolute;
  max-width: 280px;
  background: rgba(7, 12, 24, 0.97);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.tooltip.show {
  opacity: 1;
  transform: translateY(0);
}
