/* MindResearch Graph Workbench — Archival Institutional Slate-Navy System */
:root {
  /* Relationship semantic colors (strictly separate from L1-L5 layer colors) */
  --rel-supply: #1d5b68;
  --rel-supply-soft: oklch(95.5% 0.008 252);
  --rel-depends: #256472;
  --rel-partner: #3b4f78;
  --rel-partner-soft: oklch(95.5% 0.008 252);
  --rel-compete: #983b4a;
  --rel-compete-soft: oklch(95.5% 0.008 252);
  --rel-invest: #7a5718;
  --rel-invest-soft: oklch(95.5% 0.008 252);

  --verified-bg: transparent;
  --verified-fg: #1d6243;
  --verified-bd: rgba(29, 98, 67, 0.34);

  --inspector-w: 400px;
}

html, body {
  height: 100%;
}

body.graph-page {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

/* Keep nav-header aligned to site canonical width while canvas stays full-bleed */
body.graph-page .nav-header {
  flex-shrink: 0;
}

/* ── Workbench Shell ── */
.wb-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Top Control Bar (strictly above canvas, never overlapping lane titles) ── */
.wb-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  z-index: 30;
}

.wb-tabs {
  display: inline-flex;
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.wb-tab {
  border: none;
  background: transparent;
  color: var(--color-muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease, color 140ms ease;
}

.wb-tab:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.03);
}

.wb-tab.active {
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(24, 20, 14, 0.08);
}

.wb-tab .tab-cnt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-dim);
  margin-left: 4px;
}

.wb-tab.active .tab-cnt {
  color: var(--color-accent-strong);
}

.wb-sep {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* Relation filter pills */
.wb-rel-filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.rel-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.rel-pill:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.rel-pill.active {
  color: var(--color-text);
  font-weight: 600;
  border-color: var(--color-text);
  background: var(--color-bg-soft);
}

.rel-pill[data-rel="supply"].active {
  border-color: var(--rel-supply);
  background: var(--rel-supply-soft);
  color: var(--rel-supply);
}

.rel-pill[data-rel="partners_with"].active {
  border-color: var(--rel-partner);
  background: var(--rel-partner-soft);
  color: var(--rel-partner);
}

.rel-pill[data-rel="competes_with"].active {
  border-color: var(--rel-compete);
  background: var(--rel-compete-soft);
  color: var(--rel-compete);
}

.rel-pill[data-rel="invested_in"].active {
  border-color: var(--rel-invest);
  background: var(--rel-invest-soft);
  color: var(--rel-invest);
}

.rel-swatch {
  width: 14px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
  flex-shrink: 0;
}

.rel-swatch.supply { background: var(--rel-supply); }
.rel-swatch.partner { background: var(--rel-partner); }
.rel-swatch.compete {
  background: repeating-linear-gradient(90deg, var(--rel-compete) 0 4px, transparent 4px 7px);
}
.rel-swatch.invest {
  background: repeating-linear-gradient(90deg, var(--rel-invest) 0 2px, transparent 2px 5px);
}

/* Compact toggle / action controls */
.wb-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.wb-select {
  height: 29px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-size: 12px;
  cursor: pointer;
}

.wb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 29px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 140ms ease;
}

.wb-btn:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text);
  background: var(--color-bg-soft);
}

.wb-btn.active,
.wb-btn.primary {
  border-color: var(--color-accent-strong);
  background: var(--color-accent);
  color: oklch(99% 0.005 82);
}

.wb-btn.primary:hover {
  background: var(--color-accent-strong);
}

/* Search with live suggestions */
.wb-search-wrap {
  position: relative;
  width: 210px;
}

.wb-search {
  width: 100%;
  height: 29px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-size: 12.5px;
}

.wb-search:focus {
  border-color: var(--color-accent);
  outline: none;
}

.wb-search-kbd {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-dim);
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  padding: 0 4px;
  line-height: 16px;
  pointer-events: none;
}

.wb-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 260px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px -4px oklch(19% 0.022 256 / 0.14);
  z-index: 60;
  display: none;
}

.wb-suggest.open {
  display: block;
}

.wb-suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--color-text);
}

.wb-suggest-item:last-child {
  border-bottom: none;
}

.wb-suggest-item:hover,
.wb-suggest-item.active {
  background: var(--color-bg-soft);
}

.wb-suggest-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 52px;
}

.wb-suggest-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-muted);
}

.wb-suggest-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-dim);
}

/* ── Path Finder Docked Bar ── */
.path-bar {
  flex-shrink: 0;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  z-index: 25;
}

.path-bar.open {
  display: flex;
}

.path-bar-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--color-accent-strong);
  letter-spacing: 0.04em;
}

.path-input-wrap {
  position: relative;
}

.path-input {
  width: 168px;
  height: 29px;
  padding: 0 9px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-size: 12.5px;
}

.path-arrow {
  color: var(--color-accent-strong);
  font-weight: 700;
  font-family: var(--font-mono);
}

.path-presets {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  flex-wrap: wrap;
}

.path-preset-lbl {
  font-size: 11.5px;
  color: var(--color-muted);
}

.path-preset {
  border: 1px dashed var(--color-border-strong);
  background: var(--color-surface-raised);
  color: var(--color-text-soft);
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.path-preset:hover {
  border-style: solid;
  border-color: var(--color-accent);
  color: var(--color-accent-strong);
}

/* ── Main Workspace Area (Canvas + Right Inspector) ── */
.wb-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

.wb-stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Graph Canvas View (Layered Flow / Hubs / Force) ── */
.graph-canvas-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.graph-canvas-wrap[hidden] {
  display: none;
}

/* Dedicated Lane Header Strip for Layered Flow (never obscured by toolbar!) */
.lane-header-bar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
}

.lane-header-bar[hidden] {
  display: none;
}

.lane-hdr {
  padding: 7px 12px;
  border-right: 1px solid var(--color-border);
  border-top: 2px solid transparent;
  background: var(--color-surface);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.lane-hdr:last-child {
  border-right: none;
}

.lane-hdr[data-layer="1"] { border-top-color: var(--layer-1); }
.lane-hdr[data-layer="2"] { border-top-color: var(--layer-2); }
.lane-hdr[data-layer="3"] { border-top-color: var(--layer-3); }
.lane-hdr[data-layer="4"] { border-top-color: var(--layer-4); }
.lane-hdr[data-layer="5"] { border-top-color: var(--layer-5); }

.lane-hdr-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.lane-hdr-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.lane-hdr[data-layer="1"] .lane-hdr-code { color: var(--layer-1); }
.lane-hdr[data-layer="2"] .lane-hdr-code { color: var(--layer-2); }
.lane-hdr[data-layer="3"] .lane-hdr-code { color: var(--layer-3); }
.lane-hdr[data-layer="4"] .lane-hdr-code { color: var(--layer-4); }
.lane-hdr[data-layer="5"] .lane-hdr-code { color: var(--layer-5); }

.lane-hdr-name {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.lane-hdr-sub {
  font-size: 11px;
  color: var(--color-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lane-hdr-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Hub Leaderboard Banner (shown only in Hubs mode) */
.hub-strip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.hub-strip[hidden] {
  display: none;
}

.hub-strip-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--color-muted);
  white-space: nowrap;
  margin-right: 4px;
}

.hub-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--color-text);
  transition: border-color 140ms ease;
}

.hub-chip:hover,
.hub-chip.active {
  border-color: var(--color-accent-strong);
  background: var(--color-bg-soft);
}

.hub-chip .hub-deg {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-dim);
}

/* SVG Container */
.svg-stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  user-select: none;
}

#graph-svg:active {
  cursor: grabbing;
}

/* SVG styling */
.lane-band {
  pointer-events: none;
}

.lane-divider {
  stroke: oklch(86% 0.010 252);
  stroke-width: 1;
  stroke-dasharray: 3, 4;
  pointer-events: none;
}

.edge-vis {
  fill: none;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 12px;
  cursor: pointer;
}

.edge-group.dimmed .edge-vis {
  opacity: 0.05 !important;
}

.edge-group.highlighted .edge-vis {
  opacity: 0.92 !important;
}

.edge-group.selected .edge-vis {
  opacity: 1 !important;
  stroke-width: 3px !important;
}

.edge-group.path-edge .edge-vis {
  opacity: 1 !important;
  stroke-width: 3px !important;
}

.node-group {
  cursor: pointer;
  transition: opacity 150ms ease;
}

.node-group.dimmed {
  opacity: 0.16;
}

.node-circle {
  stroke: var(--color-surface);
  stroke-width: 1.5px;
  transition: opacity 150ms ease;
}

.node-group:hover .node-circle,
.node-group.selected .node-circle,
.node-group.path-node .node-circle {
  stroke: var(--color-text);
  stroke-width: 2.5px;
}

.node-halo {
  fill: none;
  stroke-width: 2px;
  opacity: 0;
  pointer-events: none;
}

.node-group.selected .node-halo,
.node-group.path-node .node-halo {
  opacity: 0.55;
}

.node-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  fill: var(--color-text);
  pointer-events: none;
  paint-order: stroke;
  stroke: oklch(98.7% 0.010 82 / 0.92);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}

.node-label-ticker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.node-label.muted-lbl {
  font-weight: 500;
  fill: var(--color-muted);
  font-size: 10px;
}

/* Canvas Floating Controls (Zoom + Focus Banner) */
.canvas-controls {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 15;
}

.zoom-group {
  display: inline-flex;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.zoom-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-right: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:last-child {
  border-right: none;
  width: auto;
  padding: 0 9px;
  font-size: 11px;
}

.zoom-btn:hover {
  background: var(--color-bg-soft);
}

.canvas-hint {
  background: oklch(100% 0 0 / 0.94);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--color-muted);
  backdrop-filter: blur(4px);
}

/* Hover Tooltip */
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  max-width: 300px;
  padding: 8px 10px;
  background: oklch(100% 0 0 / 0.97);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px -4px oklch(19% 0.022 256 / 0.14);
  font-size: 12px;
  color: var(--color-text);
  display: none;
}

.graph-tooltip.visible {
  display: block;
}

.tt-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.tt-ticker {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
}

.tt-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-muted);
}

/* ── Right Inspector Drawer ── */
.wb-inspector {
  width: var(--inspector-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 20;
  transition: transform 180ms ease;
}

.wb-inspector[hidden] {
  display: none;
}

.insp-head {
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.insp-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-dim);
  margin-bottom: 4px;
}

.insp-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
  margin: 0;
}

.insp-close {
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.insp-close:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.insp-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px 20px;
  font-size: 13px;
}

/* Badges & Pills — restrained editorial typography over colored boxes */
.layer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
}

.layer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.l1-bg { background: var(--layer-1); }
.l2-bg { background: var(--layer-2); }
.l3-bg { background: var(--layer-3); }
.l4-bg { background: var(--layer-4); }
.l5-bg { background: var(--layer-5); }
.l0-bg { background: var(--color-dim); }

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
}

.verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  background: var(--verified-bg);
  color: var(--verified-fg);
  border: 1px solid var(--verified-bd);
}

.rel-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--color-border-strong);
}

.rel-type-badge.supply { color: var(--rel-supply); border-color: rgba(29, 91, 104, 0.35); }
.rel-type-badge.partner { color: var(--rel-partner); border-color: rgba(74, 87, 125, 0.35); }
.rel-type-badge.compete { color: var(--rel-compete); border-color: rgba(152, 59, 74, 0.35); }
.rel-type-badge.invest { color: var(--rel-invest); border-color: rgba(134, 95, 25, 0.35); }

.reverse-notice {
  margin: 0 0 8px;
  padding: 5px 8px;
  border-left: 2px solid var(--rel-compete);
  background: var(--color-bg-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-soft);
}

.insp-disclosure {
  margin-bottom: 12px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 6px 0;
}

.insp-disclosure summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}

.insp-disclosure summary::-webkit-details-marker { display: none; }
.insp-disclosure[open] summary { color: var(--color-text); margin-bottom: 8px; }

.insp-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.insp-cta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.insp-cta {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface-raised);
  color: var(--color-text);
  cursor: pointer;
}

.insp-cta:hover {
  border-color: var(--color-accent-strong);
  background: var(--color-bg-soft);
}

.insp-cta.primary {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-surface-raised);
}

.insp-cta.primary:hover {
  background: var(--color-accent-strong);
  border-color: var(--color-accent-strong);
}

/* Stat grid inside Node Inspector */
.insp-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 14px;
}

.insp-stat {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  text-align: center;
}

.insp-stat-v {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.insp-stat-l {
  font-size: 10px;
  color: var(--color-dim);
  margin-top: 2px;
}

/* Evidence Card (in Edge Inspector & Path Inspector) */
.ev-card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

.ev-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ev-pair {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  flex-wrap: wrap;
}

.ev-endpoint-btn {
  border: none;
  background: var(--color-bg-soft);
  border-radius: 3px;
  padding: 2px 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ev-endpoint-btn:hover {
  background: oklch(92% 0.018 82);
}

.ev-quote {
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-text-soft);
  margin: 0 0 10px;
}

.ev-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.ev-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-muted);
}

.src-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

.src-tag.sec { color: #8c2c1d; border-color: rgba(140, 44, 29, 0.32); }
.src-tag.call { color: #543285; border-color: rgba(84, 50, 133, 0.28); }
.src-tag.news { color: #26508a; border-color: rgba(38, 80, 138, 0.26); }
.src-tag.ir { color: #195d4c; border-color: rgba(25, 93, 76, 0.28); }

.ev-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ev-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-bg);
  color: var(--color-accent-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  text-decoration: none;
}

.ev-link:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-raised);
}

/* Ego network groups */
.ego-group {
  margin-bottom: 14px;
}

.ego-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
}

.ego-group-cnt {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-dim);
}

.ego-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  margin-bottom: 5px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.ego-row:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-soft);
}

.ego-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.ego-row-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--color-text);
}

.ego-row-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-muted);
}

.ego-row-date {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-dim);
}

.ego-row-ctx {
  font-size: 11.5px;
  color: var(--color-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ego-more-btn {
  width: 100%;
  padding: 5px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  font-size: 11.5px;
  cursor: pointer;
}

.ego-more-btn:hover {
  color: var(--color-text);
  border-style: solid;
}

/* Path Stepper */
.path-summary {
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 12px;
}

.path-chain-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
}

.path-hop-num {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--color-accent-strong);
  background: oklch(55% 0.125 78 / 0.12);
  padding: 1px 6px;
  border-radius: 2px;
}

/* ── Concepts View & Layer Directory View (scroll cleanly inside .wb-stage) ── */
.wb-scroll-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 28px;
  background: var(--color-bg);
}

.wb-scroll-view[hidden] {
  display: none;
}

.view-intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.view-intro h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  margin: 0;
  color: var(--color-text);
}

.view-intro p {
  margin: 0;
  font-size: 13px;
  color: var(--color-muted);
}

/* Concepts layout */
.concept-cat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.cat-btn {
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-muted);
  font-size: 12px;
  cursor: pointer;
}

.cat-btn:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.cat-btn.active {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-surface-raised);
  font-weight: 600;
}

.concept-section {
  margin-bottom: 22px;
}

.concept-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--color-border);
}

.concept-section-head h3 {
  font-family: var(--font-serif);
  font-size: 15.5px;
  margin: 0;
  color: var(--color-text);
}

.concept-section-cnt {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-dim);
}

.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 10px;
}

.concept-card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.concept-card:hover,
.concept-card.selected {
  border-color: var(--color-accent-strong);
  box-shadow: var(--shadow-sm);
}

.concept-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.concept-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--color-text);
  line-height: 1.3;
}

.concept-en {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-dim);
}

.concept-tagline {
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.concept-tickers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
}

.mini-ticker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 2px;
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-soft);
}

/* Layer Directory View */
.dir-columns {
  display: grid;
  grid-template-columns: repeat(5, minmax(200px, 1fr));
  gap: 12px;
  align-items: start;
}

.dir-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 2px solid var(--color-border);
  border-radius: 0;
  padding: 12px;
}

.dir-col[data-layer="1"] { border-top-color: var(--layer-1); }
.dir-col[data-layer="2"] { border-top-color: var(--layer-2); }
.dir-col[data-layer="3"] { border-top-color: var(--layer-3); }
.dir-col[data-layer="4"] { border-top-color: var(--layer-4); }
.dir-col[data-layer="5"] { border-top-color: var(--layer-5); }

.dir-col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.dir-col-head h3 {
  font-family: var(--font-serif);
  font-size: 14px;
  margin: 0;
}

.dir-chip-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dir-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  text-decoration: none;
  color: var(--color-text);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 120ms ease;
}

.dir-chip:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-soft);
}

.dir-chip-t {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  min-width: 48px;
}

.dir-chip-n {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-muted);
}

.dir-chip-deg {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-dim);
}

/* ── Bottom Status & Legend Bar ── */
.wb-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  font-size: 11.5px;
  color: var(--color-muted);
  flex-wrap: wrap;
  z-index: 30;
}

.legend-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.legend-cnt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-dim);
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-muted);
  white-space: nowrap;
}

/* ── Concept Markdown Reader Modal ── */
.md-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 20, 14, 0.42);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.md-modal-backdrop.open {
  display: flex;
}

.md-modal {
  width: min(920px, 94vw);
  max-height: 86vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 14px -4px oklch(19% 0.022 256 / 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.md-modal-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.md-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 26px 28px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--color-text);
}

.md-modal-body h1,
.md-modal-body h2,
.md-modal-body h3 {
  font-family: var(--font-serif);
  margin-top: 1.2em;
  margin-bottom: 0.4em;
}

.md-modal-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 2px solid var(--color-border-strong);
  background: var(--color-bg);
  color: var(--color-text-soft);
}

.md-modal-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.md-modal-body th,
.md-modal-body td {
  border: 1px solid var(--color-border);
  padding: 6px 8px;
  text-align: left;
}

/* ── Mobile Responsive (390px must never break!) ── */
@media (max-width: 960px) {
  body.graph-page {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
  }

  .wb-shell {
    min-height: calc(100dvh - 54px);
    max-width: 100vw;
    overflow-x: hidden;
  }

  .wb-toolbar {
    padding: 8px 10px;
    gap: 6px;
    max-width: 100%;
  }

  .wb-tabs {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wb-sep {
    display: none;
  }

  .wb-search-wrap {
    width: 100%;
    order: 10;
  }

  .wb-actions {
    margin-left: 0;
    width: 100%;
  }

  .wb-main {
    min-height: 62vh;
  }

  .svg-stage {
    min-height: 460px;
  }

  .lane-header-bar {
    overflow: hidden;
  }

  .lane-hdr {
    padding: 5px 4px;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
  }

  .lane-hdr-title {
    flex-wrap: wrap;
    gap: 2px;
  }

  .lane-hdr-name {
    font-size: 10.5px;
  }

  .lane-hdr-sub {
    display: none;
  }

  .wb-inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 76dvh;
    border-left: none;
    border-top: 2px solid var(--color-border-strong);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -10px 30px rgba(24, 20, 14, 0.18);
    z-index: 80;
  }

  .dir-columns {
    grid-template-columns: 1fr;
  }

  .canvas-hint {
    display: none;
  }

  .wb-footer {
    padding: 8px 10px;
    gap: 6px;
  }

  .footer-meta {
    white-space: normal;
    line-height: 1.45;
  }
}
