:root {
  --bg: #040713;
  --panel: rgba(8, 14, 32, 0.84);
  --panel-strong: rgba(5, 10, 24, 0.94);
  --panel-border: rgba(82, 255, 199, 0.14);
  --panel-border-strong: rgba(82, 255, 199, 0.28);
  --text: #dcfff7;
  --muted: #8cbcb4;
  --green: #52ffc7;
  --cyan: #4cd8ff;
  --violet: #a377ff;
  --legacy: #948bff;
  --ghost: #95a5c0;
  --danger: #ff8aab;
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.42);
  --soft-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(76, 216, 255, 0.14), transparent 30%),
    radial-gradient(circle at 84% 12%, rgba(163, 119, 255, 0.16), transparent 26%),
    radial-gradient(circle at 50% 95%, rgba(82, 255, 199, 0.08), transparent 30%),
    linear-gradient(180deg, #07101e, #030510 72%);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
.toggle,
.node,
.tab-button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1920px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.hero,
.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(540px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  min-height: 0;
}

.hero-copy-block {
  max-width: 680px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
}

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

h1 {
  font-size: clamp(1rem, 1.9vw, 1.7rem);
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: 0 0 28px rgba(82, 255, 199, 0.08);
}

h2 {
  font-size: clamp(1.25rem, 1.6vw, 1.7rem);
  letter-spacing: -0.035em;
}

.hero-copy {
  margin-top: 8px;
  color: var(--muted);
  max-width: 620px;
  font-size: clamp(0.8rem, 0.95vw, 0.96rem);
  line-height: 1.35;
}

.hero-console {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.hero-status-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(82, 255, 199, 0.18);
  background: rgba(2, 8, 18, 0.54);
  box-shadow: var(--soft-shadow);
}

.hero-status-card strong,
.hero-status-card span:not(.status-dot) {
  display: block;
}

.hero-status-card span:not(.status-dot) {
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.graph-panel {
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.map-head {
  align-items: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.dot.core {
  background: var(--violet);
  box-shadow: 0 0 18px var(--violet);
}

.dot.active {
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
}

.dot.passive {
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(76, 216, 255, 0.72);
}

.dot.ghost {
  background: var(--ghost);
}

.map-control-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 220px) minmax(180px, 220px);
  gap: 12px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(76, 216, 255, 0.18);
  background: rgba(3, 9, 20, 0.94);
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input:focus,
.field select:focus {
  border-color: rgba(82, 255, 199, 0.45);
  box-shadow: 0 0 0 3px rgba(82, 255, 199, 0.08);
}

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

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toggle,
.toolbar-actions button,
.tab-button {
  border: 1px solid rgba(82, 255, 199, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(6, 11, 26, 0.86);
  color: var(--text);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  accent-color: var(--green);
}

.toolbar-actions button,
.tab-button {
  padding: 9px 12px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.toolbar-actions button:hover,
.tab-button:hover,
.tab-button.active {
  transform: translateY(-1px);
  border-color: rgba(82, 255, 199, 0.32);
  background: rgba(82, 255, 199, 0.08);
}

.graph-status {
  margin: 8px 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.graph-root {
  position: relative;
  height: clamp(560px, 66vh, 820px);
  min-height: 520px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at center, rgba(76, 216, 255, 0.08), transparent 58%),
    radial-gradient(circle at center, rgba(163, 119, 255, 0.06), transparent 72%),
    rgba(2, 8, 18, 0.95);
  user-select: none;
  cursor: grab;
}

.graph-root::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(82, 255, 199, 0.03), transparent 20%, rgba(163, 119, 255, 0.035));
  mix-blend-mode: screen;
}

.graph-root svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.public-toggles {
  gap: 8px;
}

.graph-root.is-panning,
.graph-root.is-panning svg {
  cursor: grabbing;
}

.bg-grid-line {
  stroke: rgba(82, 255, 199, 0.06);
  stroke-width: 1;
}

.orbit-ring {
  fill: none;
  stroke: rgba(76, 216, 255, 0.1);
  stroke-width: 1;
  stroke-dasharray: 6 10;
}

.edge {
  transition: opacity 120ms ease, stroke-width 120ms ease;
}

.edge.is-dimmed {
  opacity: 0.16;
}

.node {
  cursor: pointer;
}

.node-label {
  fill: #dcfff7;
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(2, 8, 18, 0.94);
  stroke-width: 4px;
  stroke-linejoin: round;
  text-anchor: middle;
}

.node-badge {
  fill: #ffd9e6;
  font-size: 10px;
  text-anchor: middle;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cluster-count {
  fill: rgba(220, 255, 247, 0.88);
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
}

.pulse-ring {
  fill: none;
  stroke: rgba(82, 255, 199, 0.5);
  stroke-width: 1.4;
  stroke-dasharray: 4 7;
}

.graph-tooltip {
  position: absolute;
  pointer-events: none;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(82, 255, 199, 0.22);
  background: rgba(2, 8, 18, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 5;
  font-size: 13px;
}

.hidden,
.tab-panel:not(.active) {
  display: none;
}

.sidebar {
  display: grid;
  gap: 12px;
  align-content: start;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(8, 14, 32, 0.7);
  backdrop-filter: blur(16px);
}

.tab-button {
  width: 100%;
  padding: 10px 8px;
  font-size: 13px;
}

.sidebar .panel {
  max-height: calc(100vh - 116px);
  overflow: auto;
  scrollbar-color: rgba(82, 255, 199, 0.32) rgba(2, 8, 18, 0.3);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-card,
.leaderboard,
.block-row,
.profile-stat,
.downstream-row {
  border: 1px solid rgba(82, 255, 199, 0.14);
  border-radius: 16px;
  background: rgba(6, 11, 26, 0.86);
}

.summary-card {
  padding: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}

.profile-content {
  display: grid;
  gap: 12px;
}

.profile-content.empty {
  color: var(--muted);
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(82, 255, 199, 0.1);
  color: var(--text);
}

.pill.status-core {
  box-shadow: inset 0 0 0 1px rgba(163, 119, 255, 0.36);
}

.pill.status-active {
  box-shadow: inset 0 0 0 1px rgba(82, 255, 199, 0.32);
}

.pill.status-passive,
.pill.status-idle,
.pill.status-inactive,
.pill.status-legacy {
  box-shadow: inset 0 0 0 1px rgba(127, 186, 178, 0.18);
}

.pill.status-ghost,
.pill.status-departed {
  box-shadow: inset 0 0 0 1px rgba(149, 165, 192, 0.28);
}

.pill.status-bot {
  box-shadow: inset 0 0 0 1px rgba(123, 132, 176, 0.28);
}

.pill.invite-core,
.pill.invite-legacy {
  box-shadow: inset 0 0 0 1px rgba(148, 139, 255, 0.28);
}

.pill.invite-resolved {
  box-shadow: inset 0 0 0 1px rgba(82, 255, 199, 0.28);
}

.pill.invite-unknown,
.pill.invite-ambiguous,
.pill.invite-inferred {
  box-shadow: inset 0 0 0 1px rgba(255, 138, 171, 0.28);
}

.stats-grid,
.downstream-list,
.leaderboards,
.recent-blocks,
.profile-group {
  display: grid;
  gap: 10px;
}

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

.profile-stat,
.downstream-row,
.block-row {
  padding: 12px;
}

.profile-stat strong,
.downstream-row strong,
.block-row strong,
.leaderboard strong {
  overflow-wrap: anywhere;
}

.leaderboard {
  padding: 14px;
}

.leaderboard h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.leaderboard ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.leaderboard li,
.downstream-row,
.block-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.block-row {
  display: grid;
  gap: 8px;
}

.block-row .muted.debug-id {
  font-size: 11px;
  opacity: 0.72;
  word-break: break-all;
}

.leaderboard li span:first-child,
.downstream-row div:first-child,
.block-row div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

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

  .sidebar {
    position: static;
    max-height: none;
  }

  .sidebar .panel {
    max-height: none;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-status-card {
    width: 100%;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 12px;
  }

  .map-control-bar {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .map-head {
    display: grid;
  }

  .legend {
    justify-content: flex-start;
  }

  .graph-root {
    height: 62vh;
    min-height: 480px;
  }

  .graph-toolbar {
    align-items: stretch;
  }
}

@media (max-width: 620px) {
  .hero,
  .panel {
    border-radius: 18px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 14px;
  }

  h1 {
    font-size: clamp(1.05rem, 4.6vw, 1.32rem);
  }

  .hero-copy {
    margin-top: 6px;
    font-size: 0.82rem;
  }

  .hero-console {
    justify-content: flex-start;
  }

  .hero-status-card {
    padding: 11px 12px;
  }

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

  .summary-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions button,
  .toggle {
    flex: 1 1 auto;
    justify-content: center;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .map-control-bar {
    grid-template-columns: 1fr;
  }

  .map-control-bar .compact-field {
    width: 100%;
  }

  .graph-root {
    height: 64vh;
    min-height: 430px;
  }
}
