/**
 * ZillRadar - Graph Explorer View (Twenty-Inspired Compact CRM Theme)
 *
 * Scope strictly bounded to:
 *   .bt-graph-explorer
 *   .graph-workspace.bt-graph-upgraded
 *
 * Fully conforms to:
 * - G01: Concise scene title & help styling, 2D/3D segmented button chrome.
 * - G02: Fallback message container with WCAG status styling.
 * - G03: Layer chips with state badges and origin indicators.
 * - G04: Dynamic counts tabular numbers styling.
 * - G05: High-contrast focus rings and keyboard group visual states.
 * - G06: Text-first scene status indicators (not color alone).
 * - G07: Compact Twenty CRM workspace chrome for filters/main/inspector.
 * - G08: Responsive WebGL canvas fit without toolbar clipping (390px - 1440px).
 * - G09: Light/Dark theme token bridges and prefers-reduced-motion rules.
 * - G10: Independent mounting layout and zero DOM disruption.
 */

/* ==========================================================================
   Design Tokens & Foundations (Scoped)
   ========================================================================== */

.bt-graph-explorer,
.graph-workspace.bt-graph-upgraded {
  /* Surface Tokens */
  --surface: var(--bt-surface-panel, #ffffff);
  --surface-2: var(--bt-surface-subtle, #f3f5f8);
  --surface-hover: var(--bt-surface-hover, #eef1f5);
  --surface-active: var(--bt-surface-active, #e6effd);

  /* Text & Border Tokens */
  --text: var(--bt-text-primary, #121620);
  --text-secondary: var(--bt-text-secondary, #485265);
  --muted: var(--bt-text-muted, #5e6b82);
  --border: var(--bt-surface-border, #e2e5ec);
  --border-subtle: var(--bt-surface-border-subtle, #eceff4);
  --border-strong: var(--bt-surface-border-strong, #cfd5e2);

  /* Accent Tokens */
  --accent: var(--bt-accent, #0f62fe);
  --accent-text: var(--bt-accent-text, #0b57d0);
  --accent-hover: var(--bt-accent-hover, #054ada);
  --accent-subtle: var(--bt-accent-subtle, #edf4fe);
  --accent-border: var(--bt-accent-border, #bcd3fb);
  --accent-contrast: var(--bt-accent-contrast, #ffffff);

  /* Semantic Status Tokens */
  --status-warning: var(--bt-status-warning, #b45309);
  --status-warning-subtle: var(--bt-status-warning-subtle, #fffbeb);
  --status-warning-border: var(--bt-status-warning-border, #fde68a);
  --status-info: var(--bt-status-info, #0369a1);
  --status-info-subtle: var(--bt-status-info-subtle, #f0f9ff);
  --status-info-border: var(--bt-status-info-border, #bae6fd);

  /* Radii */
  --radius-xs: var(--bt-radius-xs, 3px);
  --radius-sm: var(--bt-radius-sm, 4px);
  --radius-md: var(--bt-radius-md, 6px);
  --radius-lg: var(--bt-radius-lg, 8px);
  --radius-full: var(--bt-radius-full, 9999px);

  /* Shadows */
  --shadow-sm: var(--bt-shadow-sm, 0 1px 2px rgba(16, 24, 40, 0.04));
  --shadow-md: var(--bt-shadow-md, 0 3px 6px rgba(16, 24, 40, 0.05), 0 1px 2px rgba(16, 24, 40, 0.03));
  --shadow-popover: var(--bt-shadow-popover, 0 12px 32px rgba(16, 24, 40, 0.12));

  /* Typography */
  --font-family: var(--bt-font-family, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 15px;

  /* Restrained Motion */
  --duration-fast: var(--bt-duration-fast, 0.12s);
  --duration-base: var(--bt-duration-base, 0.18s);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme Overrides (G09) */
:root[data-theme="dark"] .bt-graph-explorer,
:root[data-theme="dark"] .graph-workspace.bt-graph-upgraded,
body[data-theme="dark"] .bt-graph-explorer,
body[data-theme="dark"] .graph-workspace.bt-graph-upgraded,
body[data-studio-page="graph"] .bt-graph-explorer,
body[data-studio-page="graph"] .graph-workspace.bt-graph-upgraded {
  --surface: var(--bt-surface-panel, #131722);
  --surface-2: var(--bt-surface-subtle, #181d2b);
  --surface-hover: var(--bt-surface-hover, #1f2537);
  --surface-active: var(--bt-surface-active, #1d2c47);

  --text: var(--bt-text-primary, #f2f5fb);
  --text-secondary: var(--bt-text-secondary, #9daac2);
  --muted: var(--bt-text-muted, #8593ac);
  --border: var(--bt-surface-border, #242c3d);
  --border-subtle: var(--bt-surface-border-subtle, #1c2230);
  --border-strong: var(--bt-surface-border-strong, #333d52);

  --accent: var(--bt-accent, #2563eb);
  --accent-text: var(--bt-accent-text, #93c5fd);
  --accent-hover: var(--bt-accent-hover, #1d4ed8);
  --accent-subtle: var(--bt-accent-subtle, #19273f);
  --accent-border: var(--bt-accent-border, #284470);
  --accent-contrast: #ffffff;

  --status-warning: var(--bt-status-warning, #fbbf24);
  --status-warning-subtle: var(--bt-status-warning-subtle, #2e1d05);
  --status-warning-border: var(--bt-status-warning-border, #78350f);
  --status-info: var(--bt-status-info, #38bdf8);
  --status-info-subtle: var(--bt-status-info-subtle, #0c2536);
  --status-info-border: var(--bt-status-info-border, #075985);

  --shadow-sm: var(--bt-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.35));
  --shadow-md: var(--bt-shadow-md, 0 3px 6px rgba(0, 0, 0, 0.45));
  --shadow-popover: var(--bt-shadow-popover, 0 12px 32px rgba(0, 0, 0, 0.65));
}

/* Contract Safeguard: Strict [hidden] */
.bt-graph-explorer[hidden],
.bt-graph-explorer [hidden],
.graph-workspace.bt-graph-upgraded[hidden],
.graph-workspace.bt-graph-upgraded [hidden] {
  display: none !important;
}

/* ==========================================================================
   Motion System (120ms - 180ms & Reduced Motion) (G09)
   ========================================================================== */

.bt-graph-explorer,
.bt-graph-explorer *,
.graph-workspace.bt-graph-upgraded,
.graph-workspace.bt-graph-upgraded * {
  transition-property: background-color, border-color, color, box-shadow, opacity, transform;
  transition-duration: var(--duration-fast, 0.12s);
  transition-timing-function: var(--ease, ease);
}

@media (prefers-reduced-motion: reduce) {
  .bt-graph-explorer,
  .bt-graph-explorer *,
  .graph-workspace.bt-graph-upgraded,
  .graph-workspace.bt-graph-upgraded * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Graph Explorer View Component (.bt-graph-explorer) (G01 - G06, G10)
   ========================================================================== */

.bt-graph-explorer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: var(--font-size-base, 14px);
  line-height: 1.5;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

/* Accessible focus visible on all interactive elements */
.bt-graph-explorer button:focus-visible,
.bt-graph-explorer [tabindex]:focus-visible,
.graph-workspace.bt-graph-upgraded button:focus-visible,
.graph-workspace.bt-graph-upgraded input:focus-visible,
.graph-workspace.bt-graph-upgraded select:focus-visible,
.graph-workspace.bt-graph-upgraded summary:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px !important;
}

/* Base button reset within module */
.bt-graph-explorer .bt-ge-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: var(--font-size-sm, 12px);
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  text-decoration: none;
}

.bt-graph-explorer .bt-ge-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

/* Coarse pointer adaptation (>= 44px) */
@media (pointer: coarse) {
  .bt-graph-explorer .bt-ge-btn,
  .bt-graph-explorer .bt-ge-chip,
  .bt-graph-explorer .bt-ge-dimension-btn,
  .bt-graph-explorer .bt-ge-help-toggle,
  .graph-workspace.bt-graph-upgraded button,
  .graph-workspace.bt-graph-upgraded select,
  .graph-workspace.bt-graph-upgraded input[type="search"],
  .graph-workspace.bt-graph-upgraded input[type="number"],
  .graph-workspace.bt-graph-upgraded .network-check {
    min-height: 44px !important;
    min-width: 44px;
  }
}

/* Header row (G01, G10) */
.bt-graph-explorer .bt-ge-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 36px;
}

/* Title & concise help (G01) */
.bt-graph-explorer .bt-ge-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bt-graph-explorer .bt-ge-title {
  margin: 0;
  font-size: var(--font-size-base, 14px);
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.bt-graph-explorer .bt-ge-help-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--font-size-xs, 11px);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.bt-graph-explorer .bt-ge-help-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.bt-graph-explorer .bt-ge-help-toggle[aria-expanded="true"] {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

/* Concise help message panel (G01) */
.bt-graph-explorer .bt-ge-help {
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: var(--font-size-sm, 12px);
  line-height: 1.5;
}

.bt-graph-explorer .bt-ge-help-text {
  margin: 0;
}

/* Segmented Dimension Switcher 2D/3D (G01, G02, G05) */
.bt-graph-explorer .bt-ge-dimension-group {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 2px;
  box-sizing: border-box;
}

.bt-graph-explorer .bt-ge-dimension-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  min-width: 44px;
  padding: 4px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--font-size-sm, 12px);
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
}

.bt-graph-explorer .bt-ge-dimension-btn:hover:not(.is-active) {
  background: var(--surface-hover);
  color: var(--text);
}

.bt-graph-explorer .bt-ge-dimension-btn.is-active,
.bt-graph-explorer .bt-ge-dimension-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-strong);
}

/* Live Dynamic Counts (G04) - Tabular Numbers */
.bt-graph-explorer .bt-ge-counts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-sm, 12px);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.bt-graph-explorer .bt-ge-count-item {
  font-weight: 500;
  color: var(--text-secondary);
}

.bt-graph-explorer .bt-ge-count-sep {
  color: var(--border-strong);
}

/* Scene Status (G06) - Text labels not color alone */
.bt-graph-explorer .bt-ge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm, 12px);
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.bt-graph-explorer .bt-ge-status-key {
  color: var(--muted);
}

.bt-graph-explorer .bt-ge-status-val {
  color: var(--text);
  font-weight: 600;
}

.bt-graph-explorer .bt-ge-status-sep {
  color: var(--border-strong);
}

/* Fallback Banner (G02) - Truthful role status */
.bt-graph-explorer .bt-ge-fallback {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: var(--font-size-sm, 12px);
  line-height: 1.45;
  color: var(--status-warning);
  background: var(--status-warning-subtle);
  border: 1px solid var(--status-warning-border);
  border-radius: var(--radius-md);
  box-sizing: border-box;
}

/* Layer Chips Section (G03, G04, G05, G10) */
.bt-graph-explorer .bt-ge-layers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

.bt-graph-explorer .bt-ge-layers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bt-graph-explorer .bt-ge-layers-title {
  font-size: var(--font-size-xs, 11px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.bt-graph-explorer .bt-ge-reset-btn {
  font-size: var(--font-size-xs, 11px);
  padding: 3px 8px;
  min-height: 28px;
  color: var(--muted);
  border-color: var(--border-subtle);
}

.bt-graph-explorer .bt-ge-reset-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* Horizontal scrollable chips bar */
.bt-graph-explorer .bt-ge-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  -webkit-overflow-scrolling: touch;
}

/* Layer Chip Button */
.bt-graph-explorer .bt-ge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-size-sm, 12px);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-sizing: border-box;
}

.bt-graph-explorer .bt-ge-chip:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

/* Enabled Chip State */
.bt-graph-explorer .bt-ge-chip.is-enabled,
.bt-graph-explorer .bt-ge-chip[aria-pressed="true"] {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 500;
}

.bt-graph-explorer .bt-ge-chip.is-enabled:hover,
.bt-graph-explorer .bt-ge-chip[aria-pressed="true"]:hover {
  background: var(--surface-active);
  border-color: var(--accent);
}

/* Disabled Chip State */
.bt-graph-explorer .bt-ge-chip.is-disabled,
.bt-graph-explorer .bt-ge-chip[aria-pressed="false"] {
  opacity: 0.72;
  background: var(--surface-2);
  color: var(--muted);
}

.bt-graph-explorer .bt-ge-chip-indicator {
  font-size: 11px;
  line-height: 1;
}

.bt-graph-explorer .bt-ge-chip-label {
  line-height: 1.25;
}

/* Chip dynamic count badge (G04) */
.bt-graph-explorer .bt-ge-chip-count {
  font-size: var(--font-size-xs, 11px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.bt-graph-explorer .bt-ge-chip.is-enabled .bt-ge-chip-count {
  background: var(--surface);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

/* Origin Badge (G03) - Truthful non-verified indicators */
.bt-graph-explorer .bt-ge-origin-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: 0.25px;
}

.bt-graph-explorer .bt-ge-chip.is-enabled .bt-ge-origin-badge {
  background: var(--surface);
  border-color: var(--accent-border);
  color: var(--accent-text);
}


/* ==========================================================================
   Existing Graph Workspace Upgrades (.graph-workspace.bt-graph-upgraded) (G07, G08)
   ========================================================================== */

/* Upgraded workspace chrome layout */
.graph-workspace.bt-graph-upgraded {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  height: 100%;
  min-height: 520px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-sizing: border-box;
}

.graph-workspace.bt-graph-upgraded:has(>.network-filters[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}

.graph-workspace.bt-graph-upgraded:has(>.network-inspector:not([hidden])) {
  grid-template-columns: 220px minmax(0, 1fr) 300px;
}

.graph-workspace.bt-graph-upgraded:has(>.network-filters[hidden]):has(>.network-inspector:not([hidden])) {
  grid-template-columns: minmax(0, 1fr) 300px;
}

/* Compact Twenty-style Filters Sidebar (G07) */
.graph-workspace.bt-graph-upgraded .network-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 10px;
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.graph-workspace.bt-graph-upgraded .network-filters h3 {
  font-size: var(--font-size-sm, 12px);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 2px;
}

.graph-workspace.bt-graph-upgraded .network-filters label {
  display: grid;
  gap: 4px;
  font-size: var(--font-size-xs, 11px);
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.graph-workspace.bt-graph-upgraded .network-filters input,
.graph-workspace.bt-graph-upgraded .network-filters select {
  font-family: inherit;
  font-size: var(--font-size-sm, 12px);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 9px;
  min-height: 36px;
  margin: 0;
  box-sizing: border-box;
}

.graph-workspace.bt-graph-upgraded .network-filters input:focus,
.graph-workspace.bt-graph-upgraded .network-filters select:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.graph-workspace.bt-graph-upgraded .network-filters fieldset {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  padding: 8px 0 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.graph-workspace.bt-graph-upgraded .network-filters legend {
  font-size: var(--font-size-xs, 11px);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 4px;
  margin-bottom: 2px;
}

.graph-workspace.bt-graph-upgraded .network-check {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  font-size: var(--font-size-xs, 11px);
  color: var(--text);
  cursor: pointer;
  min-height: 32px;
  padding: 0 4px;
}

.graph-workspace.bt-graph-upgraded .network-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Compact Main Section (G07, G08) */
.graph-workspace.bt-graph-upgraded .network-main {
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface-2);
}

/* Compact Toolbar Header (G07, G08) */
.graph-workspace.bt-graph-upgraded .network-toolbar {
  position: relative;
  inset: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  box-sizing: border-box;
}

.graph-workspace.bt-graph-upgraded .network-toolbar button.secondary {
  min-height: 36px;
  padding: 6px 10px;
  font-size: var(--font-size-sm, 12px);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.graph-workspace.bt-graph-upgraded .network-toolbar button.secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

/* WebGL & SVG Canvas Area (G08) */
.graph-workspace.bt-graph-upgraded .network-canvas {
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 280px;
  overflow: hidden;
  background: transparent;
}

/* Ensures WebGL canvas fits cleanly without collapsing or blowing out */
.graph-workspace.bt-graph-upgraded .network-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}

.graph-workspace.bt-graph-upgraded .network-canvas svg {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Compact Twenty-style Inspector (G07) */
.graph-workspace.bt-graph-upgraded .network-inspector {
  position: relative;
  inset: auto;
  width: auto;
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 14px 12px;
  background: var(--surface);
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  overflow-y: auto;
  color: var(--text);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.graph-workspace.bt-graph-upgraded .network-inspector h3 {
  font-size: var(--font-size-base, 14px);
  font-weight: 600;
  color: var(--text);
  margin: 8px 0;
  line-height: 1.45;
}

.graph-workspace.bt-graph-upgraded .network-inspector h4 {
  font-size: var(--font-size-sm, 12px);
  font-weight: 600;
  color: var(--text-secondary);
  margin: 12px 0 6px;
}

.graph-workspace.bt-graph-upgraded .network-inspector p,
.graph-workspace.bt-graph-upgraded .network-inspector li {
  font-size: var(--font-size-sm, 12px);
  color: var(--text-secondary);
  line-height: 1.6;
}

.graph-workspace.bt-graph-upgraded .network-inspector .source-badge {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent-text);
  border-radius: var(--radius-xs);
  font-size: var(--font-size-xs, 11px);
  font-weight: 600;
  padding: 2px 6px;
}

.graph-workspace.bt-graph-upgraded .network-inspector .network-strength {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin: 6px 0;
}

.graph-workspace.bt-graph-upgraded .network-inspector .network-connection {
  border-top: 1px solid var(--border-subtle);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.graph-workspace.bt-graph-upgraded .network-inspector .network-connection blockquote {
  background: var(--surface-2);
  border: 0;
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  margin: 4px 0 0;
  font-size: var(--font-size-sm, 12px);
  color: var(--text);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Keep Existing Popovers Functional & Above Canvas (G08) */
.graph-workspace.bt-graph-upgraded .graph-drawers {
  z-index: 20;
}

.graph-workspace.bt-graph-upgraded .graph-drawers>details[open]>.graph-drawer-body {
  z-index: 25;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-popover);
  border-radius: var(--radius-lg);
  max-height: calc(100vh - 180px);
  overscroll-behavior: contain;
}

.graph-workspace.bt-graph-upgraded .graph-legend-details {
  z-index: 15;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Do Not Suppress Source Data or Accessibility Lists (G08) */
.graph-workspace.bt-graph-upgraded .network-summary,
.graph-workspace.bt-graph-upgraded .network-suggestions,
.graph-workspace.bt-graph-upgraded .network-accessible,
.graph-workspace.bt-graph-upgraded .hint {
  display: block;
}


/* ==========================================================================
   Responsive Viewport Fits (390px - 1440px) (G08)
   No horizontal page overflow, clean wraps, protected toolbars
   ========================================================================== */

@media (max-width: 1100px) {
  .graph-workspace.bt-graph-upgraded:has(>.network-inspector:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) 285px;
  }

  .graph-workspace.bt-graph-upgraded:has(>.network-inspector:not([hidden]))>.network-filters:not([hidden]) {
    position: absolute;
    left: 0;
    top: 48px;
    bottom: 0;
    width: 230px;
    height: auto;
    z-index: 18;
    box-shadow: var(--shadow-popover);
  }
}

@media (max-width: 960px) {
  .graph-workspace.bt-graph-upgraded,
  .graph-workspace.bt-graph-upgraded:has(>.network-inspector:not([hidden])),
  .graph-workspace.bt-graph-upgraded:has(>.network-filters[hidden]):has(>.network-inspector:not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
  }

  .graph-workspace.bt-graph-upgraded .network-filters {
    position: absolute;
    left: 8px;
    top: 56px;
    bottom: 8px;
    width: min(280px, calc(100% - 16px));
    height: auto;
    z-index: 22;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-popover);
  }

  .graph-workspace.bt-graph-upgraded .network-inspector:not([hidden]) {
    position: absolute;
    left: auto !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: min(340px, 100%) !important;
    height: 60%;
    z-index: 22;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg) 0 0 0;
    box-shadow: var(--shadow-popover);
  }
}

@media (max-width: 600px) {
  .bt-graph-explorer .bt-ge-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .bt-graph-explorer .bt-ge-title-group {
    justify-content: space-between;
  }

  .bt-graph-explorer .bt-ge-dimension-group {
    width: 100%;
    display: flex;
  }

  .bt-graph-explorer .bt-ge-dimension-btn {
    flex: 1;
    min-height: 36px;
  }

  .bt-graph-explorer .bt-ge-counts,
  .bt-graph-explorer .bt-ge-status {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }

  .graph-workspace.bt-graph-upgraded .network-inspector:not([hidden]) {
    width: 100% !important;
    height: 70%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* 390px Standard Mobile Viewport Fit (No horizontal page overflow) */
@media (max-width: 420px) {
  .bt-graph-explorer {
    padding: 6px 8px;
    overflow-x: clip;
    max-width: 100%;
  }

  .bt-graph-explorer .bt-ge-chips {
    gap: 4px;
  }

  .bt-graph-explorer .bt-ge-chip {
    padding: 4px 8px;
    font-size: var(--font-size-xs, 11px);
  }

  .graph-workspace.bt-graph-upgraded .network-toolbar {
    padding: 6px 8px;
    gap: 4px;
  }
}
