/* Architecture Maps — dark technical map renderer */
:root {
  --bg: #0f0f0f;
  --card: #171717;
  --muted: #262626;
  --fg: #fafafa;
  --fg-dim: #a1a1a1;
  --edge: #363636;
  --border: rgba(255, 255, 255, 0.1);
  --group-bg: rgba(255, 255, 255, 0.018);
  --group-border: rgba(255, 255, 255, 0.06);
  --shadow:
    inset 0 0.75px 0 0 #ffffff08,
    inset 0 0 0 0.75px #ffffff08,
    0 0 0 0.75px #0000001a,
    0 2px 2px 0 #0000001a,
    0 4px 4px 0 #0000001a,
    0 8px 8px 0 #0000001a;

  --k-entry: #fafafa;
  --k-cron: #ffb900;
  --k-agent: #ff8904;
  --k-model: #a78bfa;
  --k-tool: #a1a1a1;
  --k-service: #fb64b6;
  --k-store: #00d492;
  --k-external: #51a2ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#stage { position: fixed; inset: 0; overflow: hidden; cursor: grab; }
#stage.dragging { cursor: grabbing; }
#viewport { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
#edges { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }

/* ---------- chrome ---------- */
.brandpill {
  position: fixed; top: 20px; left: 20px; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 22px 13px 17px;
  background: var(--card); border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--fg); text-decoration: none;
}
.brandpill .dots { display: inline-flex; }
.brandpill .dots i { width: 15px; height: 15px; border-radius: 50%; display: block; }
.brandpill .dots i:first-child { background: #ff6200; }
.brandpill .dots i:last-child { background: #2b7fff; margin-left: -6px; }
.brandpill .muted { color: var(--fg-dim); font-weight: 500; }

.topright { position: fixed; top: 20px; right: 20px; z-index: 20; display: flex; align-items: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 13px 20px; background: var(--card); border: 0; border-radius: 999px;
  box-shadow: var(--shadow); color: var(--fg);
  font-size: 14.5px; font-weight: 500; font-family: inherit; cursor: pointer;
}
.btn:hover { background: #1f1f1f; }
.btn.icon { padding: 13px; border-radius: 50%; }

/* ---------- side panel ---------- */
.sidepanel {
  position: fixed; top: 86px; left: 20px; z-index: 15;
  width: 301px; max-height: calc(100vh - 156px); overflow-y: auto;
  padding: 24px 22px; background: var(--card); border-radius: 30px;
  box-shadow: var(--shadow);
  scrollbar-width: thin; scrollbar-color: #2e2e2e transparent;
}
.sidepanel::-webkit-scrollbar { width: 6px; }
.sidepanel::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 3px; }
.sidepanel h4 {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 15px; font-size: 14px; font-weight: 500; color: var(--fg-dim);
}
.sidepanel h4:not(:first-child) { margin-top: 28px; }
.sidepanel h4 svg { width: 15px; height: 15px; flex: none; }
.sidepanel .row {
  display: flex; align-items: center; gap: 13px;
  padding: 8px 0; font-size: 16px; font-weight: 500; letter-spacing: -0.011em;
}
.sidepanel .row .ico { width: 20px; height: 20px; flex: none; display: block; border-radius: 5px; object-fit: cover; }
.sidepanel .row svg.ico { border-radius: 0; }

/* ---------- legend ---------- */
.legend {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px; background: var(--card); border-radius: 999px;
  box-shadow: var(--shadow);
}
.legend span {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.085em; color: var(--fg-dim);
}
.legend svg { width: 14px; height: 14px; }

/* ---------- nodes ---------- */
.node {
  position: absolute;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 120ms ease, opacity 160ms ease;
}
.node:hover { background: #1d1d1d; }
.node-head { display: flex; align-items: center; gap: 10px; height: 56px; flex: none; padding: 0 14px; }
.chip {
  width: 28px; height: 28px; flex: none; border-radius: 9px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: var(--muted);
}
.chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip svg { width: 16px; height: 16px; }
.node-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.nl { font-size: 14px; font-weight: 500; line-height: 19px; color: var(--fg); white-space: nowrap; }
.ns { font-size: 11.5px; font-weight: 400; line-height: 15px; color: var(--fg-dim); white-space: nowrap; }
.node-rows { padding: 2px 14px 11px; display: flex; flex-direction: column; gap: 2px; }
.nrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; line-height: 17px; color: var(--fg-dim); white-space: nowrap;
}
.nrow .ri { width: 13px; height: 13px; flex: none; border-radius: 3px; object-fit: cover; display: block; }

/* ---------- groups ---------- */
.group {
  position: absolute; border-radius: 16px;
  background: var(--group-bg); border: 1px solid var(--group-border);
}
.group b {
  position: absolute; top: 11px; left: 15px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.11em; color: #6f6f6f;
}

/* ---------- edges ---------- */
.epath { fill: none; stroke: var(--edge); stroke-width: 1.4; }
.ehead { fill: none; stroke: var(--edge); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.elabel { fill: var(--fg-dim); font-size: 11.5px; font-family: inherit; }
.dim { opacity: 0.14; }
.hot .epath, .hot .ehead { stroke: #7a7a7a; }

/* ---------- detail card ---------- */
.detail {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); z-index: 25;
  width: min(560px, calc(100vw - 48px));
  padding: 18px 20px; background: var(--card); border-radius: 18px;
  box-shadow: var(--shadow); display: none;
}
.detail.open { display: block; }
.detail .t { font-size: 15px; font-weight: 600; margin-bottom: 6px; padding-right: 22px; }
.detail .d { font-size: 13.5px; color: var(--fg-dim); line-height: 1.55; }
.detail .r { font-size: 12px; color: #6f6f6f; margin-top: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail .x { position: absolute; top: 13px; right: 15px; color: #6f6f6f; cursor: pointer; font-size: 19px; line-height: 1; background: none; border: 0; }

@media (max-width: 900px) {
  .sidepanel { display: none; }
  .legend { gap: 13px; padding: 11px 16px; }
  .legend span { font-size: 10px; }
}
