:root {
  --bg: #fcfaf6;
  --bg-2: #f1ebdf;
  --panel: rgba(255, 252, 247, 0.9);
  --panel-2: rgba(252, 248, 242, 0.96);
  --line: rgba(86, 101, 124, 0.18);
  --text: #1d2a38;
  --muted: #667689;
  --entities: #4ad7c2;
  --resolution: #6bb7ff;
  --cobras: #ffb25f;
  --external: #b4c0cf;
  --call: #7dd3fc;
  --data: #7ee787;
  --config: #f7c75d;
  --event: #df8cff;
  --shadow: 0 24px 56px rgba(60, 63, 72, 0.14);
  --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 88% 14%, rgba(232, 196, 146, 0.22), transparent 24%),
    radial-gradient(circle at 10% 84%, rgba(137, 190, 206, 0.2), transparent 28%),
    linear-gradient(180deg, #fcfaf6 0%, #f1ebdf 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(255, 252, 247, 0.92), rgba(247, 241, 233, 0.82));
  border-bottom: 1px solid rgba(86, 101, 124, 0.12);
  backdrop-filter: blur(12px);
}

.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, #2f7bd0, #1e67ba);
  border-color: #4f9cf0;
  color: #f5fbff;
}

.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(99, 141, 192, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(247, 241, 233, 0.96));
  color: var(--text);
  border-radius: 11px;
  padding: 0 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.54),
    0 10px 24px rgba(60, 64, 78, 0.12);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.search-shell:focus-within {
  border-color: rgba(82, 130, 192, 0.56);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    0 0 0 1px rgba(82, 130, 192, 0.14),
    0 14px 30px rgba(70, 74, 92, 0.15);
  transform: translateY(-1px);
}

.search-icon {
  color: rgba(57, 118, 188, 0.92);
  font-size: 0.9rem;
  line-height: 1;
}

.search-hint {
  justify-self: end;
  min-width: 0;
  border: 1px solid rgba(129, 147, 169, 0.24);
  border-radius: 999px;
  padding: 2px 6px;
  color: rgba(104, 119, 139, 0.8);
  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(104, 118, 136, 0.7);
}

#suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  background: rgba(255, 252, 247, 0.98);
  border: 1px solid rgba(116, 138, 164, 0.24);
  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(87, 132, 196, 0.14), rgba(255, 255, 255, 0.48));
}

#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.56);
  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: 16px;
  width: 168px;
  height: 114px;
  z-index: 10;
  background: rgba(255, 252, 247, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: crosshair;
}

#tooltip {
  position: absolute;
  z-index: 20;
  display: none;
  max-width: 320px;
  background: rgba(255, 252, 247, 0.98);
  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(255, 252, 247, 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;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  color: #18507f;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(97, 137, 182, 0.28);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.69rem;
  text-decoration: none;
}

.detail-link:hover {
  border-color: rgba(54, 109, 170, 0.46);
  background: rgba(255, 255, 255, 0.9);
}

.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(99, 197, 207, 0.34);
}

.fact-chip.is-warn {
  border-color: rgba(210, 162, 76, 0.42);
  background: rgba(250, 240, 214, 0.82);
}

.fact-chip.is-thin {
  border-color: rgba(174, 126, 76, 0.32);
  background: rgba(248, 238, 226, 0.8);
}

.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.66);
  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(74, 118, 178, 0.34);
  background: rgba(255, 255, 255, 0.82);
  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: #18507f;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.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(97, 137, 182, 0.28);
  background: rgba(255, 255, 255, 0.82);
  color: #18507f;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.69rem;
  line-height: 1.2;
  cursor: pointer;
}

.edge-endpoint:hover {
  border-color: rgba(54, 109, 170, 0.46);
  background: rgba(255, 255, 255, 0.94);
}

.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(112, 128, 151, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  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.68);
  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;
  }
}
