/* understand-quickly — dark, knowledge-graph-product theme.
 * Inspired by understand-anything.com. Single dark scheme, mobile-first,
 * no framework. Tokens drive every surface; per-page sheets extend these. */

:root {
  color-scheme: dark;

  /* Surfaces */
  --color-root: #0a0a0a;
  --color-surface: #141414;
  --color-elevated: #1a1a1a;

  /* Text */
  --color-text-primary: #f5f0eb;
  --color-text-secondary: #a39787;
  --color-text-muted: #6b5f53;

  /* Brand accents (warm tan) */
  --color-accent: #d4a574;
  --color-accent-dim: #c9a96e;
  --color-accent-bright: #e8c49a;

  /* Borders */
  --color-border-subtle: rgba(212, 165, 116, 0.10);
  --color-border-medium: rgba(212, 165, 116, 0.25);
  --color-border-strong: rgba(212, 165, 116, 0.45);

  /* Status */
  --color-success: #5a9e6f;
  --color-warning: #fcbb00;
  --color-error: #c97070;

  /* Node-type palette (also exposed for the legend / per-card pills) */
  --node-file:      #4a7c9b;
  --node-function:  #5a9e6f;
  --node-class:     #8b6fb0;
  --node-module:    #c9a06c;
  --node-concept:   #b07a8a;
  --node-service:   #a78bfa;
  --node-table:     #6ee7b7;
  --node-schema:    #fcd34d;
  --node-endpoint:  #fdba74;
  --node-pipeline:  #fda4af;
  --node-entity:    #7ba4c9;
  --node-config:    #5eead4;
  --node-document:  #7dd3fc;
  --node-resource:  #a5b4fc;
  --node-claim:     #6fb07a;
  --node-article:   #d4a574;
  --node-topic:     #c9b06c;
  --node-source:    #8a8a8a;

  /* Geometry */
  --radius-button: 6px;
  --radius-card: 10px;
  --radius-panel: 14px;

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

  /* Shadows */
  --shadow-elevated: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-serif: "DM Serif Display", "Iowan Old Style", "Apple Garamond", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-root);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 120ms ease;
}
a:hover { color: var(--color-accent-bright); }

:focus-visible {
  outline: 2px solid var(--color-accent-bright);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: rgba(212, 165, 116, 0.30); color: var(--color-text-primary); }

button { font-family: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh; /* fallback for browsers without dvh */
  min-height: 100dvh;
}

/* Top bar */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-root);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text-primary);
}
.brand-mark {
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand-mark .brand-emoji {
  font-family: var(--font-sans);
  margin-right: 4px;
  font-size: 20px;
}
.brand-tag {
  color: var(--color-text-secondary);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.brand:hover { color: var(--color-accent-bright); }

.topbar-search {
  justify-self: center;
  width: min(560px, 100%);
}
.topbar-search input[type="search"] {
  width: 100%;
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-button);
  padding: 9px 12px 9px 34px;
  font: inherit;
  font-size: 13px;
  height: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a39787' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 10px center;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.topbar-search input[type="search"]::placeholder { color: var(--color-text-muted); }
.topbar-search input[type="search"]:focus {
  border-color: var(--color-border-medium);
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.12);
  outline: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.topbar-actions a { font-size: 13px; color: var(--color-text-secondary); }
.topbar-actions a:hover { color: var(--color-accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-button);
  border: 1px solid var(--color-border-medium);
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 120ms ease;
}
.btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
  text-decoration: none;
}
.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #1a1208;
}
.btn-primary:hover {
  background: var(--color-accent-bright);
  border-color: var(--color-accent-bright);
  color: #1a1208;
  filter: none;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
}
.btn-ghost:hover { border-color: var(--color-border-medium); color: var(--color-text-primary); }
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.cta-add-repo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--color-accent);
  color: #1a1208;
  border-radius: var(--radius-button);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}
.cta-add-repo:hover {
  background: var(--color-accent-bright);
  color: #1a1208;
  text-decoration: none;
}
/* Default: text label shown, icon-only fallback hidden. The icon is
 * surfaced on narrow phones (handled at the mobile breakpoint). */
.cta-add-repo .cta-add-repo-icon { display: none; }

/* ---------- Main 3-pane layout ---------- */
.workspace {
  display: grid;
  grid-template-columns: 320px 1fr 0;
  min-height: 0;
  height: 100%;
  position: relative;
}
.workspace.has-detail {
  grid-template-columns: 320px 1fr 360px;
}
@media (max-width: 1100px) {
  .workspace,
  .workspace.has-detail {
    grid-template-columns: 280px 1fr 0;
  }
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar-head {
  padding: var(--space-3) var(--space-4) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border-subtle);
}
.sidebar-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 0;
  margin: 0;
  padding: 0;
}
.status-filter label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  padding: 3px 8px;
  cursor: pointer;
  user-select: none;
  background: var(--color-elevated);
  transition: border-color 120ms ease, color 120ms ease;
}
.status-filter input[type="checkbox"] {
  appearance: none;
  width: 8px; height: 8px;
  margin: 0;
  border-radius: 999px;
  background: var(--color-text-muted);
  border: 0;
  flex-shrink: 0;
}
.status-filter input[type="checkbox"]:checked { background: var(--color-accent); }
.status-filter label:has(input:checked) {
  border-color: var(--color-border-medium);
  color: var(--color-text-primary);
}

.sidebar-format {
  background: var(--color-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-button);
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  width: 100%;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-medium) transparent;
}
.sidebar-list::-webkit-scrollbar { width: 8px; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--color-border-medium); border-radius: 4px; }

.sidebar-empty {
  padding: var(--space-5) var(--space-3);
  color: var(--color-text-muted);
  font-size: 12px;
  text-align: center;
}

.entry-card {
  background: var(--color-elevated);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.entry-card:hover {
  transform: translateY(-1px);
  border-color: rgba(212, 165, 116, 0.30);
}
.entry-card.is-selected {
  border-color: var(--color-accent-bright);
  box-shadow: 0 0 0 1px var(--color-accent-bright);
  background: linear-gradient(180deg, rgba(212, 165, 116, 0.06) 0%, var(--color-elevated) 60%);
}
.entry-card-id {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-primary);
  word-break: break-word;
  line-height: 1.35;
}
.entry-card-desc {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.format-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  background: rgba(212, 165, 116, 0.08);
  color: var(--color-accent-dim);
  border: 1px solid var(--color-border-subtle);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.status-chip[data-status="ok"]                 { color: var(--color-success); }
.status-chip[data-status="pending"]            { color: var(--color-warning); }
.status-chip[data-status="invalid"],
.status-chip[data-status="dead"],
.status-chip[data-status="missing"]            { color: var(--color-error); }
.status-chip[data-status="oversize"]           { color: var(--color-warning); }
.status-chip[data-status="transient_error"]    { color: var(--color-warning); }
.status-chip[data-status="renamed"]            { color: var(--color-accent); }

/* ---------- Main / graph ---------- */
.main-pane {
  position: relative;
  background: var(--color-root);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.graph-host {
  position: relative;
  flex: 1;
  min-height: 360px;
  overflow: hidden;
}
/* Inset the canvas inside the host so vis-network nodes near the edge
 * don't bleed past the visible area. Floating chrome (legend, minimap,
 * zoom-controls, tour) is positioned relative to .graph-host so it
 * floats in the inset margin. */
#graph-canvas {
  position: absolute;
  top: 12px;
  right: 16px;
  bottom: 12px;
  left: 16px;
  width: auto;
  height: auto;
}

/* ---------- Main pane state machine ---------------------------------------
 * The main pane carries `data-main-state="empty|loading|graph|error"`.
 * Each child surface is tagged with one or more `graph-state-<name>` classes
 * indicating which states it should appear in. Anything not matching the
 * current state is forced to display:none, regardless of its `hidden`
 * attribute, so the states are *mutually exclusive* in the layout.
 *
 * Why a state attribute (not per-element `hidden`)? Earlier code juggled
 * `hidden` on each block independently and drifted — nodes rendered on top
 * of the empty hero. One attribute, one source of truth.
 *
 * `display: none` overrides the per-element class display rules. We then
 * use specific `display: <value>` for each element in its active state so
 * the layout (flex / block) is preserved.
 * ---------------------------------------------------------------------- */
.graph-host > .graph-state-empty,
.graph-host > .graph-state-loading,
.graph-host > .graph-state-graph,
.graph-host > .graph-state-error { display: none !important; }

/* Empty state: hero block is flex (centered). */
.main-pane[data-main-state="empty"] .graph-host > #graph-empty {
  display: flex !important;
}

/* Loading/error states: status overlay is flex (centered spinner+text). */
.main-pane[data-main-state="loading"] .graph-host > #graph-status,
.main-pane[data-main-state="error"]   .graph-host > #graph-status {
  display: flex !important;
}

/* Graph state: canvas + chrome. Each element retains its native display
 * type; `[hidden]` from JS still wins so we can toggle individual chips. */
.main-pane[data-main-state="graph"] .graph-host > #graph-canvas {
  display: block !important;
}
.main-pane[data-main-state="graph"] .graph-host > #graph-minimap:not([hidden]) {
  display: block !important;
}
.main-pane[data-main-state="graph"] .graph-host > #graph-legend:not([hidden]) {
  display: flex !important;
}
.main-pane[data-main-state="graph"] .graph-host > #zoom-controls:not([hidden]) {
  display: flex !important;
}
.main-pane[data-main-state="graph"] .graph-host > #tour-start:not([hidden]) {
  display: inline-flex !important;
}
.main-pane[data-main-state="graph"] .graph-host > #legend-toggle:not([hidden]) {
  display: inline-flex !important;
}
.graph-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: 13px;
  text-align: center;
  padding: var(--space-5);
  pointer-events: none;
}
.graph-status.error { color: var(--color-error); }
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border-subtle);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  * { transition: none !important; }
}

/* Empty state for the graph pane */
.graph-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6);
  text-align: center;
  pointer-events: auto;
}
.graph-empty h2 {
  font-family: var(--font-serif);
  font-size: 32px;
  margin: 0;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
  font-weight: 400;
}
.graph-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-secondary);
  max-width: 520px;
  line-height: 1.6;
}
.graph-empty .endpoint-card {
  margin-top: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
  text-align: left;
  max-width: 560px;
  line-height: 1.7;
}
.graph-empty .endpoint-card strong {
  display: block;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  font-weight: 500;
}
.graph-empty .endpoint-card a { color: var(--color-accent); }
.graph-empty .actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; justify-content: center; }

/* Legend (xyflow-style chips) */
.graph-legend {
  position: absolute;
  bottom: var(--space-4);
  left: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: 60%;
  z-index: 4;
  pointer-events: none;
}
.graph-legend[hidden] { display: none; }

/* Legend collapse/expand toggle. Always rendered alongside the legend on
 * mobile (the toggle controls whether .graph-legend is visible). On
 * desktop the legend is shown by default and the toggle stays hidden. */
.legend-toggle {
  display: none;
  position: absolute;
  bottom: var(--space-3);
  left: var(--space-3);
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-primary);
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  cursor: pointer;
  z-index: 5;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow-card);
  transition: border-color 120ms ease, color 120ms ease;
}
.legend-toggle:hover { border-color: var(--color-accent); color: var(--color-accent-bright); }
.legend-toggle[hidden] { display: none; }
.legend-toggle-icon {
  display: inline-flex;
  font-size: 11px;
  line-height: 1;
}
.legend-chip {
  --c: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-primary);
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.legend-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35) inset;
}
.legend-chip .count {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  font-weight: 400;
}
/* Legacy fallback (kept so older saved markup still renders sanely) */
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 11px;
  color: var(--color-text-secondary);
}
.legend-swatch {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-count {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

/* Minimap (bottom-right, above zoom-controls) */
#graph-minimap {
  position: absolute;
  bottom: calc(var(--space-4) + 32px * 3 + 4px * 2 + var(--space-2));
  right: var(--space-4);
  width: 140px;
  height: 100px;
  border-radius: var(--radius-button);
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid var(--color-border-subtle);
  z-index: 4;
  pointer-events: none;
  box-shadow: var(--shadow-card);
}
#graph-minimap[hidden] { display: none; }
/* Phones: minimap is more clutter than help; hide entirely. The state-
 * machine rule above only adds display:block for non-hidden #graph-minimap,
 * so we override with display:none !important to win against it. */
@media (max-width: 699.98px) {
  #graph-minimap,
  .main-pane[data-main-state="graph"] .graph-host > #graph-minimap:not([hidden]) {
    display: none !important;
  }
}

/* Zoom controls */
.zoom-controls {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}
.zoom-controls button {
  width: 32px; height: 32px;
  border: 1px solid var(--color-border-subtle);
  background: rgba(20, 20, 20, 0.85);
  color: var(--color-text-primary);
  border-radius: var(--radius-button);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  transition: border-color 120ms ease, color 120ms ease;
}
.zoom-controls button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
}
.zoom-controls[hidden] { display: none; }

/* Error banner above graph */
.error-banner {
  margin: var(--space-3) var(--space-4);
  padding: 10px 14px;
  border-radius: var(--radius-button);
  border: 1px solid var(--color-error);
  background: rgba(201, 112, 112, 0.12);
  color: var(--color-error);
  font-size: 13px;
}

/* ---------- Detail pane ---------- */
.detail-pane {
  border-left: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.detail-pane[hidden] { display: none; }
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
}
.detail-head .detail-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin: 0;
  word-break: break-word;
  line-height: 1.4;
}
.detail-head .detail-sub {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}
.detail-close {
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
  border-radius: var(--radius-button);
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: border-color 120ms ease, color 120ms ease;
}
.detail-close:hover { border-color: var(--color-accent); color: var(--color-accent-bright); }

.detail-body {
  padding: var(--space-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-medium) transparent;
}
.detail-body::-webkit-scrollbar { width: 8px; }
.detail-body::-webkit-scrollbar-thumb { background: var(--color-border-medium); border-radius: 4px; }

.detail-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.detail-section h3 {
  margin: 0;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--color-text-muted);
}
.detail-section p,
.detail-section .kv {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-primary);
  line-height: 1.55;
}
.detail-section .kv-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
  word-break: break-all;
}
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.detail-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(212, 165, 116, 0.08);
  color: var(--color-accent-dim);
  border: 1px solid var(--color-border-subtle);
}
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.detail-actions .btn { justify-content: center; }
.copy-status {
  font-size: 12px;
  color: var(--color-success);
  margin: 0;
  min-height: 1em;
}
.copy-status.error { color: var(--color-error); }

/* ---------- Footer ---------- */
.site-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
  font-size: 11px;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  background: var(--color-root);
}
.site-footer a { color: var(--color-text-secondary); }
.site-footer a:hover { color: var(--color-accent); }

/* ---------- vis-network overrides ---------- */
.vis-tooltip {
  background: var(--color-elevated) !important;
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border-medium) !important;
  border-radius: var(--radius-button) !important;
  font-family: var(--font-mono) !important;
  font-size: 11px !important;
  box-shadow: var(--shadow-elevated) !important;
}
/* vis-network's built-in nav buttons sit on the inner canvas; tone them down. */
.vis-navigation .vis-button {
  filter: brightness(0.85) saturate(0.6);
}

/* Friendly inline fallback notice in the empty state. */
.fallback-notice {
  margin-top: var(--space-3);
  padding: 10px 14px;
  border: 1px dashed var(--color-border-medium);
  border-radius: var(--radius-button);
  color: var(--color-text-secondary);
  background: rgba(212, 165, 116, 0.04);
  font-size: 13px;
  max-width: 520px;
}

/* Diagnostics overlay (?diag=1) */
#diag {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: rgba(10, 10, 10, 0.96);
  border-top: 1px solid var(--color-accent);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  padding: 8px 12px;
  max-height: 30vh;
  overflow-y: auto;
}
#diag[hidden] { display: none; }
#diag .diag-title {
  font-weight: 600;
  color: var(--color-accent-bright);
  margin-bottom: 4px;
}

/* ---------- Detail-pane raw-link (demoted secondary action) ---------- */
.detail-raw-link {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 4px;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.detail-raw-link:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* ---------- Details pill (floats over the graph pane on mobile) ---------- */
.details-pill {
  position: absolute;
  top: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary);
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid var(--color-border-medium);
  border-radius: 999px;
  cursor: pointer;
  z-index: 6;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  transition: border-color 120ms ease, color 120ms ease;
}
.details-pill[hidden] { display: none; }
.details-pill:hover { border-color: var(--color-accent); color: var(--color-accent-bright); }
.details-pill .details-pill-icon {
  display: inline-flex;
  font-size: 14px;
  line-height: 1;
}

/* ---------- Bottom-sheet scrim ---------- */
.detail-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  z-index: 199;
  transition: opacity 220ms ease;
  -webkit-tap-highlight-color: transparent;
}
.detail-scrim[hidden] { display: none; }
.detail-scrim.is-open { opacity: 1; }

/* ---------- Drag handle (only visible in sheet mode) ---------- */
.detail-drag-handle {
  display: none;
  width: 100%;
  padding: 8px 0 4px;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}
.detail-drag-handle::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  margin: 0 auto;
  background: var(--color-text-muted);
  border-radius: 2px;
  opacity: 0.5;
}

/* ---------- Mobile (<800px) ----------
 * Topbar stacks into two rows:
 *   Row 1: brand + nav (About / GitHub / + Add icon)
 *   Row 2: full-width search input
 * Sidebar collapses into a short horizontal-scroll strip beneath the
 * topbar (~96px tall, 240px-min cards). Legend docks to the bottom of
 * the graph pane behind a "Show legend" toggle (collapsed by default
 * so it never covers the canvas). Minimap is hidden on phones via the
 * <700px rule above. */
@media (max-width: 799.98px) {
  /* Two-row topbar (matches the "stack into two rows" spec):
   *   Row 1 = brand on the left, nav (About, GitHub, + Add) on the right
   *   Row 2 = full-width search input
   * The "+ Add your repo" CTA collapses to a single "+" icon under 480px
   * (further down in this stylesheet). */
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "search search";
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
    row-gap: var(--space-2);
  }
  .brand { grid-area: brand; }
  .topbar-actions {
    grid-area: actions;
    gap: var(--space-3);
    justify-self: end;
    flex-wrap: nowrap;
  }
  .topbar-search {
    grid-area: search;
    width: 100%;
    justify-self: stretch;
  }
  .topbar-search input[type="search"] {
    width: 100%;
    min-width: 0;
  }

  /* Stack: graph fills viewport; sidebar becomes a horizontal strip below. */
  .workspace,
  .workspace.has-detail {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  /* Sidebar above main on mobile so users see the entries strip first
   * (matches the "horizontal-scroll strip below the topbar" spec). */
  .main-pane { order: 2; min-height: 0; }
  .sidebar {
    order: 1;
    border-right: 0;
    border-top: 0;
    border-bottom: 1px solid var(--color-border-subtle);
    /* ~96px tall: ~22px head + ~70px scroll strip. */
    max-height: 96px;
    min-height: 96px;
    background: var(--color-surface);
  }
  .sidebar-head {
    /* On mobile the head row is a single-line meta strip; full filter
     * controls would chew up vertical space. */
    padding: 4px var(--space-3);
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    border-bottom: 0;
  }
  .sidebar-head .sidebar-format,
  .sidebar-head .status-filter { display: none; }
  .sidebar-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px var(--space-3) var(--space-2);
    gap: var(--space-2);
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .entry-card {
    min-width: 240px;
    flex-shrink: 0;
    scroll-snap-align: start;
    /* Compact cards inside the 96px strip. */
    padding: 8px var(--space-3);
    gap: 4px;
  }
  .entry-card-desc {
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  .graph-host {
    min-height: 0;
    height: 100%;
  }

  .graph-empty h2 { font-size: 22px; }
  .graph-empty p { font-size: 13px; }
  .graph-empty .endpoint-card { display: none; }
  .graph-empty .actions { display: none; }

  /* Show the floating "Details" pill */
  .details-pill:not([hidden]) { display: inline-flex; }

  /* Legend on mobile: hidden by default; toggle reveals a single-line,
   * horizontally scrollable strip docked to the bottom of the graph pane. */
  .graph-legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: calc(100% - var(--space-4) * 2);
    left: var(--space-3);
    right: var(--space-3);
    bottom: 56px; /* clear the legend-toggle pill */
    padding: 6px 0;
    /* Allow horizontal scroll touch even though chips are pointer-events:none */
    pointer-events: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .graph-legend::-webkit-scrollbar { display: none; }
  .legend-chip { flex-shrink: 0; pointer-events: auto; }
  /* The legend-toggle is only meaningful on mobile. */
  .legend-toggle:not([hidden]) {
    display: inline-flex;
  }

  /* Mobile detail-pane = bottom sheet (~70vh) */
  .detail-pane.is-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 70dvh;
    max-height: 70dvh;
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--color-border-medium);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-elevated);
    z-index: 200;
    transform: translateY(100%);
    transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    overscroll-behavior: contain;
    /* iOS Safari: keep content above home-indicator */
    padding-bottom: env(safe-area-inset-bottom);
  }
  .detail-pane.is-sheet.is-open {
    transform: translateY(0);
  }
  .detail-pane.is-sheet .detail-drag-handle {
    display: block;
  }
  .detail-pane.is-sheet .detail-head {
    padding-top: 4px;
  }

}

/* Narrow phones (<480px): collapse the "+ Add your repo" CTA to an icon-
 * only button so the row-1 actions strip (About, GitHub, +) doesn't crowd
 * the brand mark. The hidden text remains in the DOM for accessibility
 * (aria-label is set on the anchor itself). */
@media (max-width: 479.98px) {
  .cta-add-repo {
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    min-width: 32px;
    justify-content: center;
  }
  .cta-add-repo .cta-add-repo-text { display: none; }
  .cta-add-repo .cta-add-repo-icon { display: inline-flex; }
  /* Tighten brand spacing so the topbar doesn't wrap on a 320px viewport. */
  .brand-mark { font-size: 18px; }
  .brand-mark .brand-emoji { font-size: 16px; }
}

/* "Pick an entry below" CTA — only painted into the DOM on mobile, but
 * leaving safe defaults here in case the breakpoint shifts. */
.pick-entry-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: var(--space-3);
  padding: 10px 16px;
  border: 1px dashed var(--color-border-medium);
  border-radius: 999px;
  color: var(--color-text-secondary);
  font-size: 13px;
  background: rgba(212, 165, 116, 0.04);
}
.pick-entry-arrow {
  font-size: 16px;
  line-height: 1;
  color: var(--color-accent);
  animation: bounce-down 1.4s ease-in-out infinite;
}
@keyframes bounce-down {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .pick-entry-arrow { animation: none; }
}

/* ---------- Guided tour ---------------------------------------------------
 * Surfaces:
 *   • #tour-start       — primary "Start tour" button, bottom-right of
 *                         graph pane. Sits above the zoom-controls stack.
 *   • #tour-panel       — the tour itself.
 *   • #tour-step-strip  — desktop-only thin row of step thumbnails below
 *                         the graph canvas.
 *
 * Desktop (>=800px): panel is a tall sticky side panel on the right edge
 * of the graph pane (~380px wide), full graph-host height. The
 * detail-pane is hidden while a tour runs (via body[data-tour-running]).
 * Mobile (<800px): panel becomes a full-width sheet anchored to bottom,
 * slides up on activation, has a drag handle, and uses icon-only controls.
 * ---------------------------------------------------------------------- */

/* Tour-start button: bottom-right, stacked above zoom-controls + minimap.
 * Uses a generous fixed offset (240px) that comfortably clears both. */
.tour-start-btn {
  position: absolute;
  right: var(--space-4);
  bottom: 240px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #1a1208;
  background: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: 999px;
  cursor: pointer;
  z-index: 6;
  box-shadow: var(--shadow-card);
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.tour-start-btn:hover {
  background: var(--color-accent-bright);
  border-color: var(--color-accent-bright);
  transform: translateY(-1px);
}
.tour-start-btn[hidden] { display: none; }
/* While a tour is in progress, keep the "Start tour" button hidden
 * regardless of state-machine class rules. The tour controller in
 * app.js sets/unsets data-tour-running on <body>. */
body[data-tour-running="true"] .tour-start-btn,
body[data-tour-running="true"] .main-pane[data-main-state="graph"] .graph-host > #tour-start {
  display: none !important;
}
.tour-start-icon {
  display: inline-flex;
  font-size: 11px;
  line-height: 1;
}
@media (max-width: 799.98px) {
  .tour-start-btn {
    right: var(--space-3);
    bottom: 210px;
  }
}

/* Tour panel — desktop default: tall sticky right-side panel */
.tour-panel {
  position: absolute;
  top: 12px;
  right: 16px;
  bottom: 60px; /* clear step strip */
  width: 380px;
  max-width: calc(100% - 32px);
  background: rgba(18, 18, 18, 0.96);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-medium);
  border-radius: 14px;
  box-shadow: var(--shadow-elevated);
  z-index: 7;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  transform: translateX(8px);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
}
.tour-panel.is-open {
  transform: translateX(0);
  opacity: 1;
}
.tour-panel[hidden] { display: none; }
.tour-panel:focus { outline: none; }

.tour-panel-handle { display: none; }

.tour-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.tour-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.tour-personas { order: 99; flex-basis: 100%; margin-left: 0 !important; }
@media (max-width: 799.98px) {
  .tour-personas { order: 0; flex-basis: auto; }
}
.tour-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px;
  border-bottom: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
}
.tour-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.tour-progress {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.tour-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--color-accent);
  transition: width 200ms ease;
}
@media (prefers-reduced-motion: reduce) {
  .tour-progress-bar { transition: none; }
}
.tour-kind-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(212, 165, 116, 0.10);
  color: var(--color-accent-dim);
  border: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tour-kind-chip[data-kind=""]        { color: var(--color-text-muted); }
.tour-kind-chip[data-kind="file"]      { color: var(--node-file); }
.tour-kind-chip[data-kind="function"]  { color: var(--node-function); }
.tour-kind-chip[data-kind="class"]     { color: var(--node-class); }
.tour-kind-chip[data-kind="module"]    { color: var(--node-module); }
.tour-kind-chip[data-kind="concept"]   { color: var(--node-concept); }
.tour-kind-chip[data-kind="service"]   { color: var(--node-service); }
.tour-kind-chip[data-kind="table"]     { color: var(--node-table); }
.tour-kind-chip[data-kind="schema"]    { color: var(--node-schema); }
.tour-kind-chip[data-kind="endpoint"]  { color: var(--node-endpoint); }
.tour-kind-chip[data-kind="pipeline"]  { color: var(--node-pipeline); }
.tour-kind-chip[data-kind="entity"]    { color: var(--node-entity); }
.tour-kind-chip[data-kind="config"]    { color: var(--node-config); }
.tour-kind-chip[data-kind="document"]  { color: var(--node-document); }
.tour-kind-chip[data-kind="resource"]  { color: var(--node-resource); }
.tour-kind-chip[data-kind="claim"]     { color: var(--node-claim); }
.tour-kind-chip[data-kind="article"]   { color: var(--node-article); }
.tour-kind-chip[data-kind="topic"]     { color: var(--node-topic); }
.tour-kind-chip[data-kind="source"]    { color: var(--node-source); }

.tour-exit {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
  border-radius: var(--radius-button);
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: border-color 120ms ease, color 120ms ease;
}
.tour-exit:hover { border-color: var(--color-accent); color: var(--color-accent-bright); }

.tour-panel-body {
  padding: 10px 14px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-medium) transparent;
}
.tour-panel-body::-webkit-scrollbar { width: 6px; }
.tour-panel-body::-webkit-scrollbar-thumb {
  background: var(--color-border-medium);
  border-radius: 3px;
}

.tour-active-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.tour-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-accent-bright);
  word-break: break-word;
  line-height: 1.35;
}
.tour-text {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-primary);
  line-height: 1.55;
  word-break: break-word;
}
.tour-why {
  margin: 0;
  font-size: 12px;
  font-style: italic;
  color: var(--color-text-secondary);
  line-height: 1.5;
  border-left: 2px solid var(--color-accent-dim);
  padding-left: 8px;
}
.tour-why[hidden] { display: none; }
.tour-github-link {
  font-size: 12px;
  color: var(--color-accent);
  text-decoration: none;
  align-self: flex-start;
}
.tour-github-link:hover { color: var(--color-accent-bright); text-decoration: underline; }
.tour-github-link[hidden] { display: none; }

.tour-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tour-section[hidden] { display: none; }
.tour-section-title {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.tour-neighbors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tour-neighbor {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-button);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--color-border-subtle);
  font-size: 12px;
}
.tour-neighbor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex-shrink: 0;
}
.tour-neighbor-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tour-neighbor-jump {
  font: inherit;
  font-size: 11px;
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-button);
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.tour-neighbor-jump:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
  background: rgba(212, 165, 116, 0.10);
}

.tour-related {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tour-related-chip {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-accent);
  background: rgba(212, 165, 116, 0.06);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.tour-related-chip:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
  background: rgba(212, 165, 116, 0.15);
}

.tour-outline-section {
  flex: 1;
  min-height: 0;
}
.tour-outline-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 4px 0;
  cursor: pointer;
}
.tour-outline-toggle:hover { color: var(--color-text-primary); }
.tour-outline-caret {
  font-size: 10px;
  transition: transform 120ms ease;
}
.tour-outline-toggle[aria-expanded="false"] .tour-outline-caret {
  transform: rotate(-90deg);
}
.tour-outline {
  list-style: none;
  margin: 0;
  padding: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-medium) transparent;
}
.tour-outline::-webkit-scrollbar { width: 6px; }
.tour-outline::-webkit-scrollbar-thumb {
  background: var(--color-border-medium);
  border-radius: 3px;
}
.tour-outline-toggle[aria-expanded="false"] + .tour-outline { display: none; }
.tour-outline-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-button);
  cursor: pointer;
  font-size: 11px;
  color: var(--color-text-secondary);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: var(--font-mono);
}
.tour-outline-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-text-primary);
}
.tour-outline-item[aria-selected="true"] {
  background: rgba(212, 165, 116, 0.10);
  border-color: var(--color-accent-dim);
  color: var(--color-accent-bright);
}
.tour-outline-item-index {
  font-size: 10px;
  color: var(--color-text-muted);
  flex-shrink: 0;
  min-width: 22px;
  text-align: right;
}
.tour-outline-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex-shrink: 0;
}
.tour-outline-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tour-live {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.tour-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--color-border-subtle);
  background: rgba(0, 0, 0, 0.20);
  flex-shrink: 0;
}
.tour-controls-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tour-controls-secondary {
  justify-content: space-between;
  flex-wrap: wrap;
}
.tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius-button);
  border: 1px solid var(--color-border-subtle);
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.tour-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
}
.tour-btn.tour-next {
  margin-left: auto;
  background: var(--color-accent);
  color: #1a1208;
  border-color: var(--color-accent);
}
.tour-btn.tour-next:hover {
  background: var(--color-accent-bright);
  color: #1a1208;
  border-color: var(--color-accent-bright);
}
.tour-btn.tour-pause .tour-pause-icon {
  font-size: 11px;
  letter-spacing: 1px;
}

.tour-speed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.tour-speed-label { font-weight: 600; }
.tour-speed-select {
  font: inherit;
  font-size: 11px;
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-button);
  padding: 3px 6px;
  cursor: pointer;
}
.tour-voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.tour-voice-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
}
.tour-voice-btn[aria-pressed="true"] {
  background: var(--color-accent);
  color: #1a1208;
  border-color: var(--color-accent);
}
.tour-voice-icon {
  font-size: 12px;
  line-height: 1;
}
.tour-voice-btn[hidden] { display: none; }

/* While a tour is running on desktop, hide the detail-pane (the tour
 * panel takes its place). The body data attribute is set by the Tour
 * controller in app.js. */
@media (min-width: 800px) {
  body[data-tour-running="true"] .workspace.has-detail .detail-pane {
    display: none;
  }
  body[data-tour-running="true"] .workspace.has-detail {
    grid-template-columns: 320px 1fr 0;
  }
}

/* Step strip — desktop only, below the graph host inside .graph-host */
.tour-step-strip {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  height: 44px;
  max-height: 56px;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid var(--color-border-subtle);
  border-radius: 10px;
  z-index: 6;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-medium) transparent;
}
.tour-step-strip[hidden] { display: none; }
.tour-step-strip:not([hidden]) { display: flex; }
.tour-step-strip::-webkit-scrollbar { height: 4px; }
.tour-step-strip::-webkit-scrollbar-thumb {
  background: var(--color-border-medium);
  border-radius: 2px;
}
.tour-step-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border-subtle);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.tour-step-tile:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
}
.tour-step-tile[aria-current="true"] {
  border-color: var(--color-accent);
  background: rgba(212, 165, 116, 0.18);
  color: var(--color-accent-bright);
  box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.18);
}
.tour-step-tile-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  margin-right: 6px;
}

@media (max-width: 799.98px) {
  /* Mobile: panel becomes a bottom-anchored full-width sheet that slides up.
   * The desktop-only enrichments (progress bar, why, neighbors, related,
   * outline, step strip, secondary controls) are hidden so the sheet stays
   * the compact prev/next/auto-play surface mobile users have today. */
  .tour-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    max-height: 50dvh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    z-index: 210;
    transform: translateY(100%);
    opacity: 1;
    transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior: contain;
  }
  .tour-panel.is-open { transform: translateY(0); }
  .tour-panel-handle {
    display: block;
    width: 100%;
    padding: 8px 0 4px;
    flex-shrink: 0;
    cursor: grab;
    touch-action: none;
  }
  .tour-panel-handle::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto;
    background: var(--color-text-muted);
    border-radius: 2px;
    opacity: 0.5;
  }
  /* Mobile sheet hides the desktop enrichments — keep the original
   * compact tour exactly as it was. */
  .tour-panel .tour-title,
  .tour-panel .tour-progress-row .tour-progress,
  .tour-panel .tour-why,
  .tour-panel .tour-github-link,
  .tour-panel .tour-neighbors-section,
  .tour-panel .tour-related-section,
  .tour-panel .tour-outline-section,
  .tour-panel .tour-controls-secondary {
    display: none !important;
  }
  .tour-panel .tour-progress-row {
    border-bottom: 0;
    padding: 8px 12px 4px;
  }
  .tour-panel .tour-active-card {
    border-bottom: 0;
    padding-bottom: 0;
  }
  .tour-step-strip { display: none !important; }
  /* Compact: hide control labels (keep glyph + pause-icon for clarity) */
  .tour-btn .tour-btn-label { display: none; }
  .tour-btn.tour-pause .tour-pause-icon { font-size: 10px; }
  .tour-btn.tour-next { padding: 7px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .tour-panel { transition: none; }
  .tour-step-tile { transition: none; }
  .tour-outline-item { transition: none; }
}

/* ---------- About page (markdown body) ---------- */
.about-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}
.about-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: var(--space-4);
  font-size: 13px;
  color: var(--color-text-secondary);
}
.about-back:hover { color: var(--color-accent); }
.markdown-body {
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  font-weight: 600;
  letter-spacing: -0.01em;
  border-bottom: 0;
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  padding-bottom: 0;
}
.markdown-body h1 { font-size: 32px; line-height: 1.2; font-weight: 600; }
.markdown-body h2 { font-size: 24px; }
.markdown-body h3 { font-size: 18px; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
}
.markdown-body p,
.markdown-body li { color: var(--color-text-primary); }
.markdown-body a { color: var(--color-accent); }
.markdown-body a:hover { color: var(--color-accent-bright); }
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--color-elevated);
  color: var(--color-accent-bright);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--color-border-subtle);
}
.markdown-body pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
}
.markdown-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--color-text-primary);
  font-size: 13px;
}
.markdown-body blockquote {
  border-left: 2px solid var(--color-border-medium);
  margin: var(--space-3) 0;
  padding: 4px var(--space-4);
  color: var(--color-text-secondary);
  background: rgba(212, 165, 116, 0.04);
}
.markdown-body table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: var(--space-3) 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
  font-size: 13px;
}
.markdown-body th, .markdown-body td {
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
}
.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body th {
  background: var(--color-elevated);
  color: var(--color-text-primary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}
.markdown-body td { color: var(--color-text-primary); background: var(--color-surface); }
.markdown-body tr:nth-child(even) td { background: rgba(20, 20, 20, 0.55); }
.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--color-border-subtle);
  margin: var(--space-5) 0;
}
.markdown-body img { max-width: 100%; }

/* ====================================================================
 * Interactivity upgrades (v=20260507f)
 *   • search counter (graph-aware search)
 *   • compare cart (topbar) + per-card compare button
 *   • compare-mode split canvas
 *   • layout segmented control
 *   • spotlight + min-degree controls
 *   • path-finder banner / result + crosshair cursor
 *   • right-click context menu
 *   • cheatsheet + command palette overlays
 *   • restore-hidden CTA
 *   • tour persona segmented control
 *   • per-format flair (community ring is on the canvas; tool_version chip)
 * ==================================================================== */

/* --- topbar search: counter ------------------------------------------ */
.topbar-search { position: relative; }
.search-counter {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  pointer-events: none;
  background: var(--color-elevated);
  border: 1px solid var(--color-border-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}
.search-counter[hidden] { display: none; }

/* --- compare cart (topbar) ------------------------------------------- */
.compare-cart {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--color-elevated);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-button);
  font-size: 12px;
  color: var(--color-text-secondary);
  max-width: 260px;
}
.compare-cart[hidden] { display: none; }
.compare-cart-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}
.compare-cart-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 4px;
  align-items: center;
  overflow: hidden;
}
.compare-cart-list li {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(212, 165, 116, 0.10);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  padding: 2px 6px;
  max-width: 110px;
}
.compare-cart-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-cart-x,
.compare-cart-clear {
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.compare-cart-x:hover,
.compare-cart-clear:hover { color: var(--color-accent); }
.compare-cart-go {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: #1a1208;
  padding: 3px 8px;
  border-radius: var(--radius-button);
  cursor: pointer;
}
.compare-cart-go:hover { background: var(--color-accent-bright); border-color: var(--color-accent-bright); }
.compare-cart-go[hidden] { display: none; }

/* --- entry card: in-cart marker + compare button --------------------- */
.entry-card-compare {
  margin-left: auto;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  border: 1px dashed var(--color-border-subtle);
  border-radius: var(--radius-button);
  color: var(--color-text-secondary);
  padding: 2px 8px;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}
.entry-card-compare:hover { border-color: var(--color-accent); color: var(--color-accent); }
.entry-card-compare[aria-pressed="true"] {
  border-style: solid;
  border-color: var(--color-accent);
  color: var(--color-accent-bright);
}
.entry-card.is-in-cart {
  border-color: var(--color-accent);
}

/* --- compare mode: split canvas -------------------------------------- */
.compare-canvas-b {
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: auto;
  height: auto;
}
.graph-host.is-compare > #graph-canvas {
  right: 50%;
  margin-right: 6px;
}
.graph-host.is-compare > #graph-canvas-b {
  display: block !important;
  left: 50%;
  right: 16px;
  margin-left: 6px;
  background: rgba(20, 20, 20, 0.30);
  border-left: 1px dashed var(--color-border-subtle);
}
.graph-host.is-compare > #graph-canvas {
  border-right: 1px dashed var(--color-border-subtle);
}
@media (max-width: 799.98px) {
  .graph-host.is-compare > #graph-canvas {
    right: 16px;
    bottom: 50%;
    margin-right: 0;
    margin-bottom: 6px;
    border-right: 0;
    border-bottom: 1px dashed var(--color-border-subtle);
  }
  .graph-host.is-compare > #graph-canvas-b {
    left: 16px;
    right: 16px;
    top: 50%;
    bottom: 12px;
    margin-left: 0;
    margin-top: 6px;
    border-left: 0;
    border-top: 1px dashed var(--color-border-subtle);
  }
}

/* --- layout segmented control ---------------------------------------- */
.layout-toggle {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: inline-flex;
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  padding: 2px;
  gap: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow-card);
}
.layout-toggle[hidden] { display: none; }
.layout-toggle button {
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  border: 0;
  color: var(--color-text-secondary);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.layout-toggle button:hover { color: var(--color-text-primary); }
.layout-toggle button[aria-pressed="true"] {
  background: var(--color-accent);
  color: #1a1208;
}
@media (max-width: 799.98px) {
  .layout-toggle { top: var(--space-2); right: var(--space-2); }
  .layout-toggle button { padding: 3px 8px; font-size: 10px; }
}

/* --- spotlight + min-degree controls --------------------------------- */
.spotlight-control,
.degree-control {
  position: absolute;
  top: calc(var(--space-3) + 32px + 6px);
  right: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--color-text-secondary);
  z-index: 5;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow-card);
}
.degree-control {
  top: calc(var(--space-3) + 32px + 6px + 32px + 6px);
}
.spotlight-control[hidden], .degree-control[hidden] { display: none; }
.spotlight-toggle, .degree-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.spotlight-toggle input[type="checkbox"] {
  appearance: none;
  width: 26px;
  height: 14px;
  border-radius: 999px;
  background: var(--color-text-muted);
  position: relative;
  cursor: pointer;
  transition: background 120ms ease;
}
.spotlight-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 120ms ease;
}
.spotlight-toggle input[type="checkbox"]:checked { background: var(--color-accent); }
.spotlight-toggle input[type="checkbox"]:checked::after { transform: translateX(12px); }
.spotlight-hops[hidden] { display: none; }
.spotlight-hops {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
}
.spotlight-hops input[type="range"],
.degree-label input[type="range"] {
  width: 80px;
  accent-color: var(--color-accent);
}
.degree-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.degree-value {
  font-family: var(--font-mono);
  min-width: 14px;
  text-align: right;
  color: var(--color-text-primary);
}
.degree-hidden-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
}
@media (max-width: 799.98px) {
  .spotlight-control,
  .degree-control {
    right: var(--space-2);
  }
  .spotlight-control { top: calc(var(--space-2) + 28px + 6px); padding: 2px 8px; }
  .degree-control { top: calc(var(--space-2) + 28px + 6px + 28px + 6px); padding: 2px 8px; }
  .spotlight-hops input[type="range"],
  .degree-label input[type="range"] { width: 60px; }
}

/* --- restore hidden CTA (above legend) ------------------------------- */
.restore-hidden-btn {
  position: absolute;
  bottom: calc(var(--space-4) + 36px);
  left: var(--space-4);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-primary);
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid var(--color-border-medium);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  z-index: 5;
  backdrop-filter: blur(6px);
}
.restore-hidden-btn:hover { border-color: var(--color-accent); color: var(--color-accent-bright); }
.restore-hidden-btn[hidden] { display: none; }
.main-pane[data-main-state="graph"] .graph-host > #restore-hidden:not([hidden]) {
  display: inline-flex !important;
}

/* --- legend chips: aria-pressed style ---------------------------------- */
.graph-legend { pointer-events: auto; }
.legend-chip {
  cursor: pointer;
  pointer-events: auto;
  font: inherit;
  user-select: none;
}
.legend-chip[aria-pressed="false"],
.legend-chip.is-off {
  opacity: 0.45;
  text-decoration: line-through;
}
.legend-chip:focus-visible {
  outline: 2px solid var(--color-accent-bright);
  outline-offset: 2px;
}
.legend-chip.is-community {
  cursor: default;
  pointer-events: auto;
  border-style: dashed;
}
.legend-chip.is-community .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--c);
  box-shadow: none;
}
.legend-reset {
  font: inherit;
  font-size: 11px;
  background: transparent;
  border: 1px dashed var(--color-border-subtle);
  color: var(--color-text-secondary);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  pointer-events: auto;
}
.legend-reset:hover { border-color: var(--color-accent); color: var(--color-accent-bright); }

/* --- path-finder banner + result ------------------------------------- */
.path-banner,
.path-result {
  position: absolute;
  top: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(20, 20, 20, 0.96);
  color: var(--color-text-primary);
  border: 1px solid var(--color-accent);
  border-radius: 999px;
  font-size: 12px;
  z-index: 7;
  box-shadow: var(--shadow-card);
}
.path-banner[hidden], .path-result[hidden] { display: none; }
.path-banner-icon { color: var(--color-accent); }
.path-banner-cancel,
.path-result-clear,
.path-result-copy {
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.path-banner-cancel:hover,
.path-result-clear:hover,
.path-result-copy:hover { color: var(--color-accent); border-color: var(--color-accent); }
.path-result {
  border-color: var(--color-accent-bright);
}
.main-pane[data-main-state="graph"] .graph-host > #path-banner:not([hidden]),
.main-pane[data-main-state="graph"] .graph-host > #path-result:not([hidden]) {
  display: inline-flex !important;
}

/* While in path-finder phase, set crosshair-ish cursor over canvas */
body.path-cursor #graph-canvas,
body.path-cursor #graph-canvas-b {
  cursor: crosshair !important;
}

/* --- right-click context menu ---------------------------------------- */
.ctx-menu {
  position: fixed;
  z-index: 300;
  min-width: 200px;
  background: rgba(20, 20, 20, 0.98);
  border: 1px solid var(--color-border-medium);
  border-radius: 8px;
  box-shadow: var(--shadow-elevated);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu-item {
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-primary);
  text-align: left;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.ctx-menu-item:hover {
  background: rgba(212, 165, 116, 0.15);
  color: var(--color-accent-bright);
}

/* --- command palette ------------------------------------------------- */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 400;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.palette-overlay[hidden] { display: none; }
.palette {
  width: min(640px, calc(100% - 32px));
  background: var(--color-elevated);
  border: 1px solid var(--color-border-medium);
  border-radius: 12px;
  box-shadow: var(--shadow-elevated);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow: hidden;
}
.palette-head {
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-border-subtle);
}
.palette-input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--color-text-primary);
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
}
.palette-input::placeholder { color: var(--color-text-muted); }
.palette-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.palette-section {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 10px 4px;
}
.palette-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.palette-row:hover, .palette-row.is-active {
  background: rgba(212, 165, 116, 0.12);
}
.palette-row-label {
  font-size: 13px;
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  word-break: break-word;
}
.palette-row-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  word-break: break-word;
}
.palette-foot {
  border-top: 1px solid var(--color-border-subtle);
  padding: 6px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 10px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.palette-foot kbd {
  font-family: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: 3px;
  padding: 0 5px;
  margin-right: 3px;
  font-size: 10px;
}

/* --- cheatsheet overlay ---------------------------------------------- */
.cheatsheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.cheatsheet-overlay[hidden] { display: none; }
.cheatsheet {
  width: min(520px, 100%);
  background: var(--color-elevated);
  border: 1px solid var(--color-border-medium);
  border-radius: 12px;
  box-shadow: var(--shadow-elevated);
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cheatsheet:focus { outline: none; }
.cheatsheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
}
.cheatsheet-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--color-text-primary);
}
.cheatsheet-close {
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
  border-radius: var(--radius-button);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.cheatsheet-close:hover { color: var(--color-accent); border-color: var(--color-accent); }
.cheatsheet-body {
  padding: var(--space-4);
  overflow-y: auto;
}
.cheatsheet-body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  margin: 0;
}
.cheatsheet-body dt { margin: 0; }
.cheatsheet-body dd {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-primary);
}
.cheatsheet-body kbd {
  font-family: var(--font-mono);
  background: var(--color-surface);
  border: 1px solid var(--color-border-medium);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--color-accent-bright);
  margin-right: 3px;
}

/* --- tour persona segmented control ---------------------------------- */
.tour-personas {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  padding: 2px;
  margin-left: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
}
.tour-persona-btn {
  font: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: transparent;
  border: 0;
  color: var(--color-text-secondary);
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.tour-persona-btn:hover { color: var(--color-text-primary); }
.tour-persona-btn[aria-pressed="true"] {
  background: var(--color-accent);
  color: #1a1208;
}
@media (max-width: 799.98px) {
  .tour-personas { margin-left: 4px; }
  .tour-persona-btn { padding: 2px 6px; font-size: 9px; }
}

/* --- detail-pane: selected-node card + view-on-github ---------------- */
.detail-node-card .view-on-github {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-accent);
  text-decoration: none;
  margin-top: 4px;
}
.detail-node-card .view-on-github:hover {
  color: var(--color-accent-bright);
  text-decoration: underline;
}

/* --- understand-anything@1 tool_version chip ------------------------- */
.tool-version-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(212, 165, 116, 0.10);
  color: var(--color-accent-dim);
  border: 1px solid var(--color-border-subtle);
  border-radius: 4px;
  padding: 2px 8px;
}

/* --- prefers-reduced-motion: kill pulse / animation defaults --------- */
@media (prefers-reduced-motion: reduce) {
  .palette-row.is-active,
  .legend-chip,
  .layout-toggle button,
  .ctx-menu-item { transition: none !important; }
  .restore-hidden-btn,
  .compare-cart,
  .layout-toggle,
  .spotlight-control,
  .degree-control { transition: none !important; }
}

/* --- mobile: hide compare cart on narrow viewports ------------------- */
@media (max-width: 599.98px) {
  .compare-cart { display: none; }
}
