:root {
  color-scheme: dark;
  --bg: #071018;
  --bg-2: #0a141d;
  --panel: rgba(13, 24, 34, 0.94);
  --panel-strong: rgba(15, 28, 40, 0.98);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #e6edf3;
  --muted: #91a4b7;
  --muted-2: #65788c;
  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --warning: #f5c451;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button, input, select { font: inherit; }

.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 58px 1fr;
  background: #071018;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 16, 24, 0.95);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.brand-block { min-width: 260px; }

.eyebrow {
  margin-bottom: 1px;
  color: #7dd3fc;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.title-row { display: flex; align-items: center; gap: 10px; }

h1 { margin: 0; font-size: 18px; line-height: 1; letter-spacing: -0.02em; }

.status-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(15, 28, 40, 0.65);
  font-size: 11px;
  white-space: nowrap;
}

.top-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 1; min-width: 0; }

.search-input, .control-select, .control-button, .menu-button, .ghost-button, .zoom-button {
  border: 1px solid var(--line-strong);
  background: rgba(9, 19, 28, 0.88);
  color: var(--text);
  border-radius: 10px;
  outline: none;
}

.search-input {
  width: min(380px, 30vw);
  height: 36px;
  padding: 0 12px;
}

.control-select { height: 36px; padding: 0 34px 0 11px; }
.control-select.full-width { width: 100%; }

.control-button {
  height: 36px;
  padding: 0 13px;
  cursor: pointer;
  white-space: nowrap;
}

.control-button:hover, .menu-button:hover, .ghost-button:hover, .zoom-button:hover, .edge-row:hover {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(15, 36, 52, 0.96);
}

.graph-shell { position: relative; min-height: 0; }

.graph-card {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 45% 35%, rgba(59, 130, 246, 0.055), transparent 34%),
    radial-gradient(circle at 76% 78%, rgba(167, 139, 250, 0.045), transparent 28%),
    #071018;
}

#graph { width: 100%; height: 100%; display: block; cursor: grab; }
#graph:active { cursor: grabbing; }

.graph-caption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: min(680px, calc(100vw - 28px));
  padding: 9px 12px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  background: rgba(6, 13, 20, 0.72);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.zoom-controls {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  gap: 6px;
  z-index: 8;
}

.zoom-button { min-width: 34px; height: 34px; padding: 0 9px; cursor: pointer; }
.zoom-button.wide { min-width: 62px; }

.path-strip {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(760px, calc(100vw - 280px));
  padding: 8px 12px;
  border: 1px solid rgba(245, 196, 81, 0.38);
  border-radius: 999px;
  background: rgba(36, 26, 10, 0.88);
  color: #f8e7aa;
  font-size: 12px;
  z-index: 8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover, .details-drawer {
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.popover {
  position: absolute;
  z-index: 12;
  width: min(380px, calc(100vw - 28px));
  padding: 13px;
  border-radius: var(--radius);
}

.filters-popover { top: 14px; right: 14px; }
.legend-popover { left: 14px; top: 60px; }
.more-popover { top: 14px; right: 14px; }

.popover-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.ghost-button {
  padding: 5px 8px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.field-label {
  display: block;
  margin: 10px 0 6px;
  color: #c8d6e3;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.field-hint { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.divider { height: 1px; margin: 12px 0; background: var(--line); }

.checkbox-grid { display: grid; gap: 6px; }
.checkbox-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.toggle-row, .check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  justify-content: space-between;
  padding: 7px 8px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
}

.check-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.check-count { color: var(--muted-2); font-size: 11px; }

.color-dot { width: 10px; height: 10px; border-radius: 999px; flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28); }

.legend-list { display: grid; gap: 6px; }
.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
}
.legend-item-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.legend-details { margin-top: 10px; color: var(--muted); }
.legend-details summary { cursor: pointer; font-size: 12px; }
.legend-details .legend-list { margin-top: 8px; }

.menu-button {
  display: block;
  width: 100%;
  min-height: 36px;
  margin-top: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.details-drawer {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 15;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 82px);
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
}

.drawer-close {
  position: sticky;
  top: 0;
  float: right;
  margin-left: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(9, 19, 28, 0.92);
  color: var(--muted);
  padding: 5px 9px;
  cursor: pointer;
}

.feature-meta { color: #7dd3fc; font-size: 11px; font-weight: 850; letter-spacing: 0.12em; text-transform: uppercase; }
.feature-summary h2 { margin: 6px 0 6px; font-size: 22px; line-height: 1.1; }
.feature-summary p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 13px; }

.feature-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 14px 0; }
.feature-actions button, .edge-row {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(8, 17, 26, 0.72);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
}
.feature-actions button { min-height: 35px; padding: 7px 9px; font-size: 12px; }
.feature-actions button.full-span { grid-column: 1 / -1; }

.details-section { margin-top: 16px; }
.details-section h3 { margin: 0 0 8px; font-size: 12px; color: #c8d6e3; letter-spacing: 0.04em; text-transform: uppercase; }
.edge-list { display: grid; gap: 7px; }
.edge-row { width: 100%; display: grid; gap: 3px; padding: 8px 9px; text-align: left; }
.edge-row strong { font-size: 13px; }
.edge-row span { color: #7dd3fc; font-size: 11px; font-family: var(--mono); }
.edge-row small { color: var(--muted); line-height: 1.35; }

.raw-adjacency { margin-top: 16px; color: var(--muted); }
.raw-adjacency summary { cursor: pointer; font-size: 12px; }
.raw-adjacency pre {
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border-radius: 12px;
  background: #030a10;
  color: #d6e5f4;
  font: 11px/1.45 var(--mono);
}

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

.graph-link {
  fill: none;
  stroke: rgba(148, 163, 184, 0.58);
  stroke-linecap: round;
  transition: stroke-opacity 130ms ease, stroke-width 130ms ease;
}
.graph-link.is-backbone { stroke-opacity: 0.38; stroke-width: 1.35px; }
.graph-link.is-muted { stroke-opacity: 0.025; stroke-width: 0.8px; }
.graph-link.is-focus { stroke-opacity: 0.8; stroke-width: 1.9px; }
.graph-link.is-path { stroke: #f5c451; stroke-opacity: 0.95; stroke-width: 2.7px; }

.edge-label {
  fill: rgba(222, 235, 247, 0.78);
  font: 9px var(--mono);
  paint-order: stroke;
  stroke: rgba(5, 12, 17, 0.92);
  stroke-width: 3px;
  pointer-events: none;
}

.node-group { cursor: pointer; }
.node-circle {
  stroke: rgba(255, 255, 255, 0.58);
  stroke-width: 1.2px;
  transition: opacity 130ms ease, stroke-width 130ms ease;
}
.node-group.is-selected .node-circle { stroke: #ffffff; stroke-width: 3px; }
.node-group.is-neighbor .node-circle { stroke: #dbeafe; stroke-width: 2px; }
.node-group.is-muted { opacity: 0.22; }
.node-group.is-path .node-circle { stroke: #f5c451; stroke-width: 3px; }

.node-label {
  fill: rgba(238, 246, 255, 0.94);
  font: 760 11px var(--font);
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(5, 12, 18, 0.93);
  stroke-width: 4px;
  pointer-events: none;
}
.node-kind {
  fill: rgba(209, 222, 234, 0.62);
  font: 8px var(--font);
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(5, 12, 18, 0.93);
  stroke-width: 3px;
  pointer-events: none;
}

.hidden { display: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

@media (max-width: 920px) {
  .app-shell { grid-template-rows: auto 1fr; }
  .app-bar { align-items: stretch; flex-direction: column; }
  .top-controls { justify-content: stretch; flex-wrap: wrap; }
  .search-input { width: 100%; flex: 1 1 100%; }
  .graph-caption { display: none; }
}
