:root {
  --bg: #e8eaed;
  --surface: #f4f5f7;
  --surface-elevated: #fafbfc;
  --border: #d8dce2;
  --text: #2c3340;
  --text-muted: #6b7585;
  --accent: #5a7a8f;
  --accent-dark: #3d5a73;
  --green: #6b8f7a;
  --green-btn: #7a9488;
  --blue-egg: #3d4f66;
  --shadow: 0 4px 24px rgba(44, 51, 64, 0.08);
  --shadow-lg: 0 12px 40px rgba(44, 51, 64, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 28px;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.search-wrap {
  flex: 1;
  max-width: 320px;
  margin: 0 auto;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 122, 143, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.topnav {
  display: flex;
  gap: 1.5rem;
  flex-shrink: 0;
}

.topnav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid transparent;
}

.topnav a:hover {
  color: var(--text);
}

.topnav a.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
}

/* Layout */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: 200px;
  flex-shrink: 0;
  padding: 1.25rem 0.75rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
}

.nav-item.active {
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-elevated);
}

.stats-bar strong {
  color: var(--text);
  font-weight: 600;
}

.stats-bar .sep {
  opacity: 0.4;
}

.map-stage {
  position: relative;
  flex: 1;
  min-height: 480px;
  overflow: hidden;
  background: linear-gradient(160deg, #eef0f3 0%, #e4e7eb 50%, #eceef1 100%);
}

.connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.conn {
  fill: none;
  stroke: #c5ccd6;
  stroke-width: 1.2;
  opacity: 0.55;
}

/* Nests */
.nest {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 1.5px solid rgba(200, 208, 218, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 12px rgba(255, 255, 255, 0.5), var(--shadow);
}

.nest-label {
  position: absolute;
  top: -1.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.eggs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  max-width: 90px;
  padding: 0.5rem;
}

.egg {
  width: 22px;
  height: 28px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  display: inline-block;
  box-shadow:
    inset -2px -4px 8px rgba(0, 0, 0, 0.08),
    inset 2px 2px 6px rgba(255, 255, 255, 0.7),
    0 2px 6px rgba(44, 51, 64, 0.12);
  flex-shrink: 0;
}

.egg-white {
  background: linear-gradient(145deg, #fff 0%, #e8ecf0 100%);
}

.egg-blue {
  background: linear-gradient(145deg, #5a6d85 0%, var(--blue-egg) 100%);
}

.egg-green {
  background: linear-gradient(145deg, #8faa9a 0%, var(--green) 100%);
}

.egg-aura {
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.egg-aura:hover,
.egg-aura:focus-visible {
  transform: scale(1.15);
  box-shadow:
    inset -2px -4px 8px rgba(0, 0, 0, 0.08),
    inset 2px 2px 6px rgba(255, 255, 255, 0.7),
    0 4px 14px rgba(90, 122, 143, 0.35);
  outline: none;
}

.egg-logo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: -0.05em;
}

/* Tooltip */
.tooltip {
  position: absolute;
  left: 62%;
  top: 38%;
  width: min(300px, 90vw);
  padding: 1.1rem 1.2rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  animation: fadeIn 0.2s ease;
}

.tooltip[hidden] {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip-head {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.tooltip-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #dce4ec, #b8c9dc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--accent-dark);
  flex-shrink: 0;
}

.tooltip h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.tooltip-meta {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tooltip-tagline {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.tooltip-desc {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tooltip-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--surface);
}

.btn-primary {
  background: var(--green-btn);
  color: #fff;
  border-color: var(--green-btn);
}

.btn-primary:hover {
  background: var(--green);
}

/* Framework sidebar */
.framework {
  width: 260px;
  flex-shrink: 0;
  padding: 1.5rem 1.25rem;
  background: var(--surface-elevated);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.framework h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.framework-lead {
  margin: 0 0 1.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.framework-diagram {
  position: relative;
  height: 200px;
}

.framework-diagram svg {
  width: 100%;
  height: 100%;
}

.tri-line {
  stroke: #c5ccd6;
  stroke-width: 1;
}

.fw-node {
  position: absolute;
  text-align: center;
  max-width: 110px;
}

.fw-node strong {
  display: block;
  font-size: 0.72rem;
  margin-bottom: 0.2rem;
}

.fw-node span:last-child {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.fw-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 0.35rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
}

.fw-icon svg {
  width: 16px;
  height: 16px;
}

.fw-top {
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.fw-left {
  left: 0;
  bottom: 0;
}

.fw-right {
  right: 0;
  bottom: 0;
}

/* Responsive */
@media (max-width: 1100px) {
  .framework {
    display: none;
  }
}

@media (max-width: 900px) {
  .topnav {
    display: none;
  }

  .sidebar {
    width: 64px;
    padding: 1rem 0.5rem;
  }

  .nav-item span,
  .nav-item {
    font-size: 0;
    justify-content: center;
    padding: 0.65rem;
  }

  .nav-item svg {
    margin: 0;
  }
}

@media (max-width: 600px) {
  .search-wrap {
    display: none;
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nest {
    width: 110px;
    height: 110px;
  }

  .egg {
    width: 18px;
    height: 24px;
  }
}
