:root {
  --bg: #09111f;
  --bg-2: #0f1830;
  --panel: rgba(9, 18, 31, 0.92);
  --panel-2: rgba(18, 31, 50, 0.96);
  --line: rgba(154, 177, 201, 0.18);
  --text: #eef8ff;
  --muted: #96b1c7;
  --entities: #4ad7c2;
  --resolution: #6bb7ff;
  --cobras: #ffb25f;
  --external: #b4c0cf;
  --call: #7dd3fc;
  --data: #7ee787;
  --config: #f7c75d;
  --event: #df8cff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --font-sans: "Avenir Next", "Segoe UI Variable", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(circle at top left, rgba(74, 215, 194, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 178, 95, 0.16), transparent 28%),
    radial-gradient(circle at bottom center, rgba(107, 183, 255, 0.14), transparent 34%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
}

#app { position: fixed; inset: 0; }
#stage { display: block; width: 100%; height: 100%; cursor: grab; }
#stage.panning { cursor: grabbing; }

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 12;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(9, 17, 31, 0.96), rgba(9, 17, 31, 0.68));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.title-wrap h1 {
  margin: 0;
  font-size: 0.94rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.title-wrap p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.73rem;
}

.btn:hover { border-color: var(--resolution); }
.btn-primary {
  background: linear-gradient(180deg, #1c7dd8, #175eb4);
  border-color: #3ea0ff;
}

.search-wrap {
  position: relative;
  min-width: 0;
}

.search-shell {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 8px;
  width: 340px;
  min-width: 0;
  border: 1px solid rgba(107, 183, 255, 0.32);
  background:
    linear-gradient(180deg, rgba(17, 31, 54, 0.98), rgba(10, 19, 34, 0.96));
  color: var(--text);
  border-radius: 11px;
  padding: 0 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 10px 28px rgba(4, 10, 18, 0.28);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.search-shell:focus-within {
  border-color: rgba(107, 183, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(107, 183, 255, 0.18),
    0 14px 36px rgba(7, 20, 37, 0.42);
  transform: translateY(-1px);
}

.search-icon {
  color: rgba(125, 211, 252, 0.94);
  font-size: 0.9rem;
  line-height: 1;
}

.search-hint {
  justify-self: end;
  min-width: 0;
  border: 1px solid rgba(154, 177, 201, 0.22);
  border-radius: 999px;
  padding: 2px 6px;
  color: rgba(198, 217, 234, 0.78);
  font-size: 0.62rem;
  line-height: 1;
}

#search {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  border-radius: 0;
  padding: 9px 0;
  font-size: 0.74rem;
}

#search::placeholder {
  color: rgba(180, 192, 207, 0.68);
}

#suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  background: rgba(8, 15, 27, 0.98);
  border: 1px solid rgba(107, 183, 255, 0.22);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

#suggest .suggest-row {
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  min-width: 0;
  font-size: 0.75rem;
  border-top: 1px solid rgba(154, 177, 201, 0.08);
}

#suggest .suggest-row:first-child {
  border-top: 0;
}

#suggest .suggest-row:hover,
#suggest .suggest-row.active {
  background:
    linear-gradient(90deg, rgba(34, 89, 154, 0.3), rgba(255, 255, 255, 0.04));
}

#suggest .suggest-row span,
#suggest .suggest-row small {
  min-width: 0;
}

#suggest .suggest-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#suggest small {
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#legend,
#minimap,
#tooltip,
#detail-panel {
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

#legend {
  position: absolute;
  left: 16px;
  top: 68px;
  width: 268px;
  max-height: calc(100vh - 88px);
  overflow: auto;
  z-index: 11;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.legend-block + .legend-block {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.legend-block h2 {
  margin: 0 0 10px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.legend-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.71rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-line {
  width: 18px;
  height: 0;
  border-top: 3px solid currentColor;
}

#minimap {
  position: absolute;
  top: 68px;
  right: 12px;
  width: 176px;
  height: 112px;
  z-index: 10;
  background: rgba(9, 18, 31, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: crosshair;
}

#tooltip {
  position: absolute;
  z-index: 20;
  display: none;
  max-width: 320px;
  background: rgba(4, 9, 18, 0.97);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  pointer-events: none;
  font-size: 0.72rem;
}

#tooltip strong { display: block; margin-bottom: 4px; }
#tooltip span { color: var(--muted); }

#detail-panel {
  position: absolute;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 392px;
  background: rgba(8, 15, 27, 0.98);
  border-left: 1px solid var(--line);
  z-index: 14;
  transform: translateX(100%);
  transition: transform 180ms ease;
  overflow: auto;
}

#detail-panel.open { transform: translateX(0); }

.close-btn {
  position: sticky;
  top: 12px;
  margin: 12px 12px 0 auto;
  display: block;
  z-index: 2;
}

#detail-body {
  padding: 7px 14px 18px;
  overflow: auto;
}

.panel-head h2 {
  margin: 4px 0 2px;
  font-size: 1.04rem;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.34;
}

.service-badges,
.fact-chip-row,
.detail-list-inline,
.coverage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.service-badge,
.fact-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.67rem;
  line-height: 1.2;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fact-chip.is-empty {
  opacity: 0.58;
}

.fact-chip.is-good {
  border-color: rgba(74, 215, 194, 0.32);
}

.fact-chip.is-warn {
  border-color: rgba(247, 199, 93, 0.44);
  background: rgba(247, 199, 93, 0.12);
}

.fact-chip.is-thin {
  border-color: rgba(255, 178, 95, 0.34);
  background: rgba(255, 178, 95, 0.08);
}

.section {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  min-width: 0;
  max-width: 100%;
}

.section h3 {
  margin: 0 0 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.section p,
.section li,
.item-card span {
  color: var(--text);
  line-height: 1.42;
  font-size: 0.74rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.section ul {
  margin: 0;
  padding-left: 18px;
}

.coverage-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.7rem;
}

.coverage-block {
  margin-top: 10px;
}

.compact-list {
  display: grid;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 9px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.item-card.is-action {
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.item-card.is-action:hover {
  border-color: rgba(107, 183, 255, 0.38);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.item-card strong {
  font-size: 0.74rem;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  min-width: 0;
  max-width: 100%;
}

.item-card code {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-size: 0.67rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.item-card-action {
  margin-top: 8px;
  color: #7dd3fc;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(107, 183, 255, 0.34);
  background: linear-gradient(180deg, rgba(28, 125, 216, 0.22), rgba(23, 94, 180, 0.18));
  color: #dff2ff;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
}

.detail-link:hover {
  border-color: rgba(107, 183, 255, 0.62);
  background: linear-gradient(180deg, rgba(28, 125, 216, 0.34), rgba(23, 94, 180, 0.26));
}

.edge-route {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.edge-route-arrow {
  color: var(--muted);
  font-size: 0.82rem;
}

.edge-endpoint {
  border: 1px solid rgba(107, 183, 255, 0.34);
  background: rgba(255, 255, 255, 0.07);
  color: #aee3ff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.69rem;
  line-height: 1.2;
  cursor: pointer;
}

.edge-endpoint:hover {
  border-color: rgba(107, 183, 255, 0.58);
  background: rgba(255, 255, 255, 0.12);
}

.edge-endpoint-static {
  cursor: default;
  color: var(--muted);
}

.edge-chip-row {
  margin: 6px 0 0;
}

.edge-op-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  min-width: 0;
  max-width: 100%;
}

.edge-op-card {
  border: 1px solid rgba(154, 177, 201, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  padding: 7px 8px;
  min-width: 0;
  max-width: 100%;
}

.edge-op-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.71rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.edge-op-card span {
  display: block;
  font-size: 0.71rem;
  line-height: 1.38;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.edge-gap-list {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.edge-evidence-row {
  margin-top: 6px;
}

.fact-group {
  margin-top: 10px;
}

.fact-group h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fact-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  margin-bottom: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.fact-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.74rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.fact-card small {
  color: var(--muted);
  display: block;
  margin-bottom: 3px;
  font-size: 0.67rem;
}

.fact-card em,
.detail-list-inline em {
  color: var(--muted);
  display: block;
  font-style: normal;
  font-size: 0.66rem;
  margin-top: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-list-inline code,
.section code {
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

.empty-note {
  color: var(--muted);
  font-style: italic;
  font-size: 0.7rem;
}

#detail-panel,
#detail-body,
.panel-head,
.service-badges,
.fact-chip-row,
.detail-list-inline,
.coverage-row,
.coverage-block,
.compact-list,
.fact-group {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 960px) {
  #legend {
    width: 250px;
  }
  #detail-panel {
    top: 56px;
    width: 100%;
  }
  .search-shell {
    width: 236px;
  }
}
