/* ══════════════════════════════════════════════════════
   DEA Metamodel Explorer — viewer.css
   Matches technehub-labs dark theme (var(--accent) = #2dd4bf)
   ══════════════════════════════════════════════════════ */

:root {
  /* ── Brand ─────────────────────────────────────── */
  --accent:      #2dd4bf;
  --accent-dim:  rgba(45, 212, 191, 0.08);
  --accent-glow: rgba(45, 212, 191, 0.18);
  --accent-tint: rgba(45, 212, 191, 0.05);

  /* ── Material Design 3 surface roles ──────────── */
  --bg:             #080b10;
  --surface:        #0d1117;
  --surface-2:      #161b22;
  --surface-3:      #21262d;
  --surface-tint:   var(--accent);

  --text:           #e6edf3;
  --text-2:         #8b949e;
  --text-3:         #484f58;

  --outline:        rgba(230, 237, 243, 0.12);
  --outline-2:      rgba(230, 237, 243, 0.22);
  --outline-variant: rgba(230, 237, 243, 0.06);

  /* ── Harmonised layer palette (OpenDEAM v0.2.0 authoritative colors) ── */
  --l1: #2dd4bf; /* Ecosystem & Value Network — brand teal */
  --l2: #fbbf24; /* Strategic & Governance    — warm amber */
  --l3: #38bdf8; /* Business Operating Model  — cyan-blue  */
  --l4: #a78bfa; /* Digital & Intelligence    — soft violet */
  --l5: #fb7185; /* Technology & Execution    — rose-red   */
  --dim: #9ca3af; /* Measurement Dimension    — neutral gray (cross-cutting, not a layer) */

  /* ── MD3 shape tokens ──────────────────────────── */
  --radius-sm: 8px;     /* chips, badges, small buttons */
  --radius-md: 12px;    /* cards, dialogs, containers   */
  --radius-lg: 16px;    /* sheets, panels               */
  --radius-xl: 28px;    /* FAB, extended chips          */
  --radius:    var(--radius-md); /* legacy alias — points to MD3 medium */

  /* ── Typography ────────────────────────────────── */
  --font-display: 'Rajdhani', 'Montserrat', sans-serif;
  --font-heading: 'Montserrat', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* ── Motion (MD3 standard easing) ─────────────── */
  --ease-standard:    cubic-bezier(0.4, 0, 0.2, 1);
  --ease-decelerate:  cubic-bezier(0,   0, 0.2, 1);
  --ease-accelerate:  cubic-bezier(0.4, 0,   1, 1);

  /* ── Spacing scale ─────────────────────────────── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
:root {
  /* ── Layout offsets (computed from banner + nav + layer-bar heights) ── */
  --banner-h: 64px;
  --nav-h: 48px;
  --layerbar-h: 42px;
  --top-fixed: calc(var(--banner-h) + var(--nav-h)); /* 112px */
  --top-sticky: calc(var(--banner-h) + var(--nav-h) + var(--layerbar-h)); /* 154px */
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-top: var(--top-fixed); /* banner(64) + nav(48) — added slim banner */
}

/* ── Brand Banner (slim, above nav) ─────────────────── */
.brand-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--banner-h);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--outline);
  z-index: 110; /* above nav so the border line is the unifying edge */
  display: flex;
  align-items: center;
}
.brand-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  width: 100%;
  min-width: 0;
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid var(--outline-2);
  flex-shrink: 0;
}
.brand-mark-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.brand-mark-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.brand-text {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 12px;
  overflow: hidden;
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-tagline {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-2);
  margin: 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
@media (max-width: 768px) {
  .brand-banner { height: auto; min-height: var(--banner-h); padding: 8px 0; }
  .brand-inner { flex-wrap: wrap; gap: 8px 12px; }
  .brand-text { flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: 2px; }
  .brand-tagline { white-space: normal; }
}

/* ── Page Intro ──────────────────────────────────────── */
.page-intro {
  padding: 16px 16px 8px;
}
.page-intro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.intro-block {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.intro-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}
.intro-heading {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 4px 0;
  line-height: 1.3;
}
.intro-text {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0;
}

/* ── Section divider ─────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 8px;
}
.section-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--outline), transparent);
}
.section-divider-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
}

/* ── Diagram Section (collapsible precursor) ───────── */
.diagram-section {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  margin: 16px 16px 0; /* tighter per audit */
  overflow: hidden;
  position: relative;
  z-index: 2;
  /* Subtle gradient sheen on the top edge to integrate with the page */
  box-shadow: 0 1px 0 rgba(45, 212, 191, 0.08);
}
.diagram-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px; /* tighter per audit */
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  /* MD3 standard: 150ms background */
  transition: background 150ms var(--ease-standard);
  position: relative;
}
.diagram-toggle::before {
  /* Left accent stripe — visual integration with the page accents */
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.6;
}
.diagram-toggle:hover { background: var(--surface-2); }
.diagram-toggle .diagram-chevron {
  /* MD3 standard: 200ms rotate */
  transition: transform 200ms var(--ease-standard);
  color: var(--text-2);
  flex-shrink: 0;
}
.diagram-section.open .diagram-toggle .diagram-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}
.diagram-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 8px;
  display: none; /* hide on mobile to keep toggle compact */
}
@media (min-width: 768px) {
  .diagram-meta { display: block; }
}
.diagram-body {
  max-height: 0;
  overflow: hidden;
  /* MD3 standard: 300ms expand */
  transition: max-height 300ms var(--ease-standard);
  background: var(--bg);
}
.diagram-section.open .diagram-body {
  max-height: 80vh; /* allows ~70vh of SVG + chrome */
}
.diagram-canvas {
  padding: 12px 16px;
  overflow-x: auto;
  background: var(--bg);
  border-top: 1px solid var(--outline);
  /* Aspect-ratio container so the SVG (viewBox 1878x1152 ≈ 1.63:1)
     fits any viewport without distortion. xMidYMid meet on the SVG
     ensures circles stay circular. */
  display: flex;
  align-items: center;
  justify-content: center;
}
.diagram-canvas svg {
  display: block;
  margin: 0 auto;
  width: 100%;
  height: auto;
  max-width: 1878px;     /* never render larger than native */
  max-height: 70vh;      /* cap vertical height — scroll if taller */
  background: var(--bg);
}

/* ── Top Nav ─────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: var(--banner-h); /* sits below the brand banner */
  left: 0; right: 0;
  height: var(--nav-h); /* compact per audit */
  background: rgba(8, 11, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--outline);
  display: flex;
  align-items: center;
  gap: 12px; /* tighter per audit, allows nav-room on small screens */
  padding: 0 16px; /* tighter per audit */
  z-index: 100;
  overflow-x: auto; /* mobile: allow horizontal scroll rather than wrapping */
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.nav-home {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap; /* mobile: don't wrap "TechNeHub Labs" */
  /* MD3 standard: 100ms color */
  transition: color 100ms linear;
}
.nav-home:hover { color: var(--accent); }
.nav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-left: 8px;
  white-space: nowrap; /* mobile: don't wrap "Metamodel Explorer" */
}
.nav-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0; /* keep badges from being squeezed on small screens */
}
.badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--outline-2);
  letter-spacing: 0.02em;
}
.light-dark-badge {
  background: rgba(45, 212, 191, 0.10);
  border-color: rgba(45, 212, 191, 0.3);
}

/* ── Layer Filter Bar ─────────────────────────────── */
.layer-bar {
  position: sticky;
  top: var(--top-fixed); /* banner(64) + nav(48) — sits below both */
  z-index: 90;
  background: rgba(8, 11, 16, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--outline);
  display: flex;
  align-items: center;
  gap: 4px;        /* tighter per audit */
  padding: 8px 16px; /* tighter per audit */
  overflow-x: auto;
  scrollbar-width: none;
}
.layer-bar::-webkit-scrollbar { display: none; }
.layer-bar-label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-3);
  white-space: nowrap;
  margin-right: 4px;
}
.layer-btn {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px; /* tighter per audit */
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-2);
  background: var(--surface-2);
  cursor: pointer;
  /* MD3 standard: 150ms hover (color + border + background) */
  transition: color 150ms var(--ease-standard),
              background-color 150ms var(--ease-standard),
              border-color 150ms var(--ease-standard);
  white-space: nowrap;
}
.layer-btn:hover { color: var(--text); border-color: var(--outline-2); }
.layer-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--outline-2);
}
.layer-btn[data-layer="L1"].active { color: var(--l1); background: rgba(45,212,191,0.10); border-color: rgba(45,212,191,0.30); }
.layer-btn[data-layer="L2"].active { color: var(--l2); background: rgba(251,191,36,0.10); border-color: rgba(251,191,36,0.30); }
.layer-btn[data-layer="L3"].active { color: var(--l3); background: rgba(56,189,248,0.10); border-color: rgba(56,189,248,0.30); }
.layer-btn[data-layer="L4"].active { color: var(--l4); background: rgba(167,139,250,0.10); border-color: rgba(167,139,250,0.30); }
.layer-btn[data-layer="L5"].active { color: var(--l5); background: rgba(251,113,133,0.10); border-color: rgba(251,113,133,0.30); }
.layer-btn[data-layer="DIM"].active { color: var(--dim); background: rgba(156,163,175,0.10); border-color: rgba(156,163,175,0.30); }
.layer-bar-spacer { flex: 1; }
.legend-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px; /* tighter per audit */
  border-radius: var(--radius-sm);
  border: 1px solid var(--outline);
  color: var(--text-2);
  background: var(--surface-2);
  cursor: pointer;
  /* MD3 standard: 150ms hover */
  transition: color 150ms var(--ease-standard),
              background-color 150ms var(--ease-standard),
              border-color 150ms var(--ease-standard);
  white-space: nowrap;
}
.legend-toggle:hover { color: var(--text); border-color: var(--outline-2); }

/* ── Canvas ──────────────────────────────────────── */
.canvas-wrapper {
  position: relative;
  min-height: calc(100vh - var(--top-fixed));
  padding: 12px 16px 24px; /* tighter per audit */
}

.rel-overlay {
  position: fixed;
  top: var(--top-sticky); /* banner(64) + nav(48) + layer-bar(42) — matches sticky */
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: calc(100vh - var(--top-sticky));
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

/* ── Entity Grid ─────────────────────────────────── */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* tighter per audit */
  gap: 12px; /* tighter per audit */
  position: relative;
  z-index: 2;
}

/* ── Entity Card ─────────────────────────────────── */
.entity-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-md); /* MD3 medium */
  padding: 12px; /* tighter per audit */
  cursor: pointer;
  /* MD3 standard: 150ms surface-tint on hover/active */
  transition: background 150ms var(--ease-standard),
              border-color 150ms var(--ease-standard);
  position: relative;
  overflow: hidden;
}
.entity-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px; /* slimmer per audit */
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  opacity: 0.8;
}
.entity-card:hover {
  border-color: var(--outline-2);
  /* MD3 dark-mode elevation: surface tint overlay (no shadows on dark) */
  background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--surface-2);
}
.entity-card.active {
  border-color: var(--accent);
  /* Active: stronger tint + layer-color dot on the top accent bar */
  background: linear-gradient(rgba(45, 212, 191, 0.10), rgba(45, 212, 191, 0.10)), var(--surface-2);
}
.entity-card.hidden-card { display: none; }

.entity-card[data-layer="L1"]::before { background: var(--l1); }
.entity-card[data-layer="L2"]::before { background: var(--l2); }
.entity-card[data-layer="L3"]::before { background: var(--l3); }
.entity-card[data-layer="L4"]::before { background: var(--l4); }
.entity-card[data-layer="L5"]::before { background: var(--l5); }
.entity-card[data-layer="DIM"]::before { background: var(--dim); }
/* Per-entity color override (set inline by viewer.js when entity-graph.json
   provides an explicit `color` field that differs from the layer default). */
.entity-card[style*="--card-accent"]::before { background: var(--card-accent); }

/* Layer colour accent on border */
.entity-card[data-layer="L1"] { --layer-color: var(--l1); }
.entity-card[data-layer="L2"] { --layer-color: var(--l2); }
.entity-card[data-layer="L3"] { --layer-color: var(--l3); }
.entity-card[data-layer="L4"] { --layer-color: var(--l4); }
.entity-card[data-layer="L5"] { --layer-color: var(--l5); }
.entity-card[data-layer="DIM"] { --layer-color: var(--dim); }

.card-layer-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--layer-color, var(--accent));
  text-transform: uppercase;
  margin-bottom: 6px;
  /* Allow longer layer names like 'L3 · DIGITAL ECOSYSTEM & INTELLIGENCE' to wrap */
  padding-right: 56px;
  line-height: 1.3;
  max-height: 2.6em;       /* cap at 2 lines */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-alias {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
  margin-bottom: 4px;
}
.card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
}
.card-repo {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}
.card-repo-link {
  color: var(--accent);
  opacity: 0.7;
  /* MD3 standard: 150ms opacity */
  transition: opacity 150ms var(--ease-standard);
}
.entity-card:hover .card-repo-link { opacity: 1; }

/* Status pill */
.card-status {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.card-status.planned {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.card-status.existing,
.card-status.existing-extended {
  /* Subtle: dimmed neutral that doesn't compete with selection state */
  background: rgba(230, 237, 243, 0.06);
  color: var(--text-2);
  border: 1px solid var(--outline);
}

/* ── Legend Panel ────────────────────────────────── */
.legend-panel {
  position: fixed;
  top: var(--top-sticky); /* below banner+nav+layer-bar */
  right: 0;
  width: 320px;
  height: calc(100vh - var(--top-sticky));
  background: var(--surface);
  border-left: 1px solid var(--outline);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  /* MD3 standard: 250ms slide */
  transition: transform 250ms var(--ease-standard);
  overflow: hidden;
}
.legend-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}
.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--outline);
  flex-shrink: 0;
}
.legend-header h3 {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
}
.legend-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  /* MD3 standard: 100ms hover */
  transition: color 100ms linear, background-color 100ms linear;
}
.legend-close:hover { background: var(--surface-2); color: var(--text); }
.legend-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}
.rel-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--outline);
}
.rel-item:last-child { border-bottom: none; }
.rel-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  white-space: nowrap;
  min-width: 80px;
}
.rel-text {
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.4;
}

/* ── Detail Panel ────────────────────────────────── */
.detail-panel {
  /* Mobile-first: bottom-sheet (default) */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: var(--surface);
  border-top: 1px solid var(--outline-2);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  /* MD3 standard: 250ms slide (bottom-sheet) */
  transition: transform 250ms var(--ease-standard),
              background 250ms var(--ease-standard);
  /* Box-shadow moved to .detail-panel:not(.hidden) — MD3 dark-mode uses
     surface-tint overlay + reduced shadow only when visible. */
}
.detail-panel:not(.hidden) {
  transform: translateY(0);
  /* MD3 dark-mode elevation: surface-tint overlay instead of heavy shadow */
  background: linear-gradient(rgba(45, 212, 191, 0.04), rgba(45, 212, 191, 0.04)), var(--surface);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.35);
}
.detail-panel.hidden { pointer-events: none; }

/* ── Detail panel: desktop ≥1024px = right-sheet ── */
@media (min-width: 1024px) {
  .detail-panel {
    /* Override bottom-sheet defaults */
    position: fixed;
    top: var(--top-fixed); /* below banner + nav */
    right: 0;
    left: auto;
    bottom: auto;
    width: 400px;
    height: calc(100vh - var(--top-fixed));
    max-height: none;
    border-top: none;
    border-left: 1px solid var(--outline);
    border-radius: 0;
    /* Right-sheet slide */
    transform: translateX(100%);
  }
  .detail-panel:not(.hidden) {
    transform: translateX(0);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.35);
  }
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--outline);
  flex-shrink: 0;
}
.detail-layer {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.detail-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.detail-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  /* MD3 standard: 100ms hover */
  transition: color 100ms linear, background-color 100ms linear;
  flex-shrink: 0;
}
.detail-close:hover { background: var(--surface-2); color: var(--text); }
.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.detail-desc {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.7;
}
.detail-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.detail-link-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent-dim);
  border: 1px solid var(--outline-2);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  /* MD3 standard: 150ms hover */
  transition: background-color 150ms var(--ease-standard),
              color 150ms var(--ease-standard);
}
.detail-link-card:hover {
  background: var(--accent);
  color: var(--bg);
}
.detail-link-card.secondary {
  background: var(--surface-2);
  border-color: var(--outline);
  color: var(--text-2);
}
.detail-link-card.secondary:hover {
  background: var(--surface-3);
  color: var(--text);
}
.detail-relationships {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-rel-heading {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.detail-rel-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
  margin-right: 6px;
  margin-bottom: 4px;
}
.detail-rel-chip strong { color: var(--text); }
.detail-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--outline);
}
.detail-status-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
}
.detail-status-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.detail-status-badge.planned {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.detail-status-badge.existing,
.detail-status-badge.existing-extended {
  background: rgba(230, 237, 243, 0.06);
  color: var(--text-2);
  border: 1px solid var(--outline);
}

/* ── Reduced motion ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  .entity-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* tighter on mobile */
  }
  .legend-panel {
    width: 280px;
  }
  /* Below 1024px: detail panel is bottom-sheet (default) — already in effect */
}
