:root {
  --bg: #ffffff;
  --bg-wash: #fafafb;
  --panel: #ffffff;
  --panel-2: #f6f7fb;
  --line: #ececf1;
  --line-strong: #d8d9e3;
  --text: #0b0b12;
  --muted: #6b6d7a;
  --soft: #2a2b36;
  --accent: #7433ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(116, 51, 255, 0.08);
  --accent-soft-2: rgba(116, 51, 255, 0.14);
  --peach: #ffe8df;
  --peach-2: #ffd6c8;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -200px, var(--peach), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, var(--peach-2), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  height: 100%;
}

body { min-height: 100vh; }

/* ── Status strip ── */
.status-strip {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 10px 28px;
  display: flex;
  gap: 18px;
  align-items: center;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.status-strip .sep { opacity: 0.4; }
.status-strip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(116, 51, 255, 0.18);
  display: inline-block;
}
.status-strip .live { color: var(--accent); }
.status-strip .spacer { flex: 1; }

/* ── Page shell ── */
.page-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 41px);
}

/* ── Topbar ── */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
}
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 30px rgba(116, 51, 255, 0.24);
  text-decoration: none;
}
.eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
  color: var(--accent);
  margin: 0;
}
.brand-copy h1 {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--soft);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.nav-link {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--accent-soft-2);
  border-radius: 8px;
  background: var(--accent-soft);
  transition: background .15s, border-color .15s;
}
.nav-link:hover {
  background: var(--accent-soft-2);
  border-color: var(--accent);
}

/* ── Layout ── */
.graph-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}
.graph-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
}
.graph-main {
  min-height: 0;
}

/* ── Panels ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 0 rgba(16, 18, 27, 0.02), 0 24px 60px -30px rgba(16, 18, 27, 0.10);
}
.panel-header {
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
}
.panel-header .rule {
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Stats ── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.stat-value {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--mono);
  margin-top: 4px;
}

/* ── Filters ── */
.filter-group {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.filter-btn {
  flex: 1;
  padding: 7px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: center;
  transition: all .12s;
}
.filter-btn:hover {
  border-color: var(--accent-soft-2);
  color: var(--accent);
}
.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Legend ── */
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--soft);
  padding: 4px 0;
  cursor: pointer;
  transition: opacity .12s;
}
.legend-item:hover { opacity: 0.7; }
.legend-item.dimmed { opacity: 0.3; }
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

/* ── Node detail ── */
.node-detail-panel h3 {
  font-size: 0.95rem;
  word-break: break-word;
}
.node-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.node-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.node-meta-key {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.node-meta span:last-child {
  font-size: 0.82rem;
  color: var(--soft);
  font-weight: 500;
}
.node-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}
.node-tag {
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}
.node-connections {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.node-connections-title {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.node-conn-item {
  font-size: 0.8rem;
  color: var(--accent);
  padding: 3px 0;
  cursor: pointer;
}
.node-conn-item:hover { text-decoration: underline; }

/* ── Graph ── */
.graph-panel {
  height: 100%;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.graph-panel svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Tooltip ── */
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 4px 16px rgba(16, 18, 27, 0.12);
  font-size: 0.82rem;
  color: var(--text);
  z-index: 10;
  max-width: 240px;
  display: none;
}
.graph-tooltip .tt-name {
  font-weight: 600;
  margin-bottom: 4px;
}
.graph-tooltip .tt-meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Search ── */
.search-panel { padding: 12px 16px; }
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color .15s;
}
.search-row:focus-within { border-color: var(--accent); }
.search-icon { color: var(--muted); flex-shrink: 0; }
.graph-search {
  border: none;
  background: none;
  outline: none;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text);
  width: 100%;
}
.graph-search::placeholder { color: var(--muted); }

/* ── Analysis ── */
.analysis-section { margin-bottom: 14px; }
.analysis-section:last-child { margin-bottom: 0; }
.analysis-title {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.analysis-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.8rem;
  color: var(--soft);
  transition: color .12s;
}
.analysis-item:hover { color: var(--accent); }
.analysis-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.analysis-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analysis-count {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  flex-shrink: 0;
}
.analysis-more {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 2px 0;
}

@media (max-width: 960px) {
  .graph-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .graph-panel { min-height: 500px; }
  .page-shell { height: auto; padding: 18px; }
  .status-strip .sep, #statusGenerated { display: none; }
}

/* ── Raven KB brand mark ── */
.brand-mark.logo-brand {
  background: #ffffff;
  border: 1px solid rgba(62, 89, 120, 0.12);
  box-shadow: 0 12px 30px rgba(12, 31, 48, 0.12);
  overflow: hidden;
  padding: 3px;
}
.brand-mark.logo-brand img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.brand-mark.logo-brand img { transform: scale(1.62); }

/* ── Borderless angular Einstein logo ── */
.brand-mark.logo-brand.angular-logo {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  overflow: visible;
}
.brand-mark.logo-brand.angular-logo img {
  transform: scale(1.22);
}
