:root {
  --bg: #081225;
  --bg-2: #0e1b33;
  --panel: #111f3c;
  --line: #2b3f66;
  --ink: #ecf5ff;
  --muted: #9ab0d3;
  --accent: #38bdf8;
  --trace: #fb923c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(950px 500px at 8% -15%, #1d4ed8 0%, transparent 55%), var(--bg);
}

.topbar {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #1f3255;
  background: rgba(8, 18, 37, 0.85);
  backdrop-filter: blur(8px);
}

.back-btn,
.view-link {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid #2a4068;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(17, 31, 60, 0.8);
}

.view-nav {
  display: flex;
  gap: 8px;
}

.view-link.active {
  border-color: #7dd3fc;
  background: #0c2d4e;
}

#search-input {
  justify-self: end;
  width: min(360px, 100%);
  border: 1px solid #2a4068;
  border-radius: 10px;
  background: rgba(10, 24, 47, 0.85);
  color: var(--ink);
  padding: 9px 11px;
  font: inherit;
}

#main {
  height: calc(100vh - 62px);
  display: grid;
  grid-template-columns: 1fr 340px;
}

#viewport {
  overflow: hidden;
  position: relative;
  cursor: grab;
}

#canvas {
  position: absolute;
  transform-origin: 0 0;
}

#edges {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}

.edge {
  stroke: #22365b;
  stroke-width: 2;
}

.edge.active {
  stroke: var(--trace);
  stroke-width: 3.5;
}

.node {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #132646;
  border: 1px solid #2d4573;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.node:hover {
  border-color: #7dd3fc;
}

.node.active {
  border-color: var(--trace);
  background: #3d2a1f;
}

#sidebar {
  border-left: 1px solid #1f3255;
  background: linear-gradient(180deg, rgba(17, 31, 60, 0.95) 0%, rgba(8, 18, 37, 0.95) 100%);
  padding: 14px;
  overflow: auto;
}

#sidebar h2 {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.trace-item {
  border: 1px solid #29406a;
  border-left: 4px solid #3b82f6;
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 8px;
  background: rgba(17, 31, 60, 0.7);
}

.trace-item.target {
  border-left-color: var(--trace);
}

.trace-item .name {
  font-size: 14px;
  font-weight: 800;
}

.trace-item .axiom {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 1180px) {
  #main {
    grid-template-columns: 1fr;
  }
  #sidebar {
    height: 42vh;
    border-left: none;
    border-top: 1px solid #1f3255;
  }
}
