/* sambandh-viz.css — Generation-aware path visualizer styles
   New page only — zero impact on route-finder.html or shrotriya.html.
   Three modes: Flat list · Direction-aware · Generation lanes            */

/* ── Page overrides (undo main.css lock) ─────────────────────────────────── */
body {
  overflow-y: auto !important;
  height: auto !important;
}

.app {
  height: auto !important;
  min-height: 100vh;
  overflow: visible !important;
}

.app-main {
  overflow-y: auto !important;
  position: static !important;
  background: #f5f6fa !important;
  flex: none !important;
}

/* ── Header ─────────────────────────────────────────────────────────────────
   Reuse .app-header from main.css but add the hamburger + nav styles needed */
.viz-header h1 {
  font-size: 1rem;
}

/* ── Mode tab strip ──────────────────────────────────────────────────────── */
.viz-tabs {
  display: flex;
  background: #fff;
  border-bottom: 2px solid #e5e7eb;
  /* no gap — tabs flush */
}

.viz-tab {
  flex: 1;
  padding: 0.7rem 0.25rem;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.3;
  text-align: center;
}

.viz-tab.active {
  color: #1a1a2e;
  border-bottom-color: #1a1a2e;
}

.viz-tab:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: -2px;
}

/* ── Search panel ────────────────────────────────────────────────────────── */
.viz-search-panel {
  background: #f8f9fa;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.viz-search-inner {
  max-width: 560px;
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  padding: 0.875rem 1rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .07);
}

.viz-search-inner h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 0.75rem;
  text-align: center;
}

.person-select-group {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 0.625rem 0.75rem;
  margin-bottom: 0.625rem;
}

.person-select-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 0.3rem;
}

/* ── Person typeahead (pst-*) ────────────────────────────────────────────────── */
.pst-wrap {
  position: relative;
}

.pst-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.46rem 0.7rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pst-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .12);
}

.pst-spinner {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: #9ca3af;
  pointer-events: none;
}

.pst-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}

.pst-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}

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

.pst-item:hover {
  background: #f5f3ff;
}

.pst-item-text {
  flex: 1;
  min-width: 0;
}

.pst-item-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #111827;
}

.pst-item-meta {
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 0.1rem;
}

.pst-no-results {
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  color: #9ca3af;
  font-style: italic;
}

/* Selected person chip */
.selected-chip {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-top: 0.5rem;
  padding: 0.45rem 0.625rem;
  background: #fff;
  border: 1.5px solid #6366f1;
  border-radius: 7px;
  min-height: 40px;
}

.chip-av {
  position: relative;
  overflow: hidden;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* Uploaded photo covers the initials inside the avatar circle */
.sv-avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chip-av.male {
  background: #dbeafe;
  color: #1d4ed8;
}

.chip-av.female {
  background: #fce7f3;
  color: #be185d;
}

.chip-av.unknown {
  background: #e5e7eb;
  color: #374151;
}

.chip-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #111827;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-meta {
  font-size: 0.7rem;
  color: #6b7280;
}

.chip-remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.15s;
}

.chip-remove:hover {
  background: #fca5a5;
}

.no-selection {
  font-size: 0.8rem;
  color: #9ca3af;
  font-style: italic;
}

/* Action row */
.viz-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.625rem;
  border-top: 1px solid #f3f4f6;
}

.btn-find {
  flex: 1;
  padding: 0.625rem;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-find:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-find:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

.btn-reset {
  padding: 0.625rem 0.875rem;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* Search results modal (full-screen overlay) */
.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-modal-inner {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  width: 90%;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
}

.search-modal-header .count {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.btn-close-modal {
  padding: 0.4rem 0.875rem;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.search-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem;
}

.search-result-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: box-shadow 0.15s;
}

.search-result-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.src-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  flex-shrink: 0;
}

.src-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.src-info {
  flex: 1;
  min-width: 0;
}

.src-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
}

.src-meta {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 0.2rem;
}

.btn-select {
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.btn-select:hover {
  opacity: 0.88;
}

.search-error {
  color: #dc2626;
  font-size: 0.82rem;
  padding: 0.5rem;
}

/* ── Collapsed summary bar (after result found) ──────────────────────────── */
.viz-summary-bar {
  display: none;
  /* shown by JS */
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  min-height: 48px;
}

.viz-summary-names {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #111827;
  flex-wrap: wrap;
  min-width: 0;
}

.viz-summary-names .arrow {
  color: #9ca3af;
  font-size: 0.8rem;
}

.btn-edit-search {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  background: transparent;
  color: #6366f1;
  border: 1px solid #6366f1;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-edit-search:hover {
  background: #6366f1;
  color: #fff;
}

/* ── Result area ─────────────────────────────────────────────────────────── */
.viz-result {
  max-width: 560px;
  margin: 0.75rem auto 3rem;
  padding: 0 1rem;
}

.viz-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.875rem;
  background: #eff6ff;
  border-radius: 8px;
  font-size: 0.82rem;
}

.viz-result-header .hop-count {
  font-weight: 700;
  color: #1d4ed8;
}

.btn-search-again {
  background: transparent;
  color: #6366f1;
  border: 1px solid #6366f1;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-search-again:hover {
  background: #6366f1;
  color: #fff;
}

.viz-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #9ca3af;
  font-size: 0.9rem;
  font-style: italic;
}

.viz-loading {
  text-align: center;
  padding: 2rem 1rem;
  color: #6b7280;
  font-size: 0.9rem;
}

/* ════════════════════════════════════════════════════════════════════════════
   MODE 1 — Flat card list
   ════════════════════════════════════════════════════════════════════════════ */
.mode-flat {
  display: flex;
  flex-direction: column;
}

.flat-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 0.875rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  border-left: 4px solid #9ca3af;
  position: relative;
}

.flat-card.male {
  border-left-color: #3b82f6;
}

.flat-card.female {
  border-left-color: #ec4899;
}

.flat-card.start {
  border-left-color: #22c55e;
}

.flat-card.end {
  border-left-color: #f59e0b;
}

.flat-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.05rem 0;
  margin: 0 auto;
  width: 100%;
  max-width: 200px;
}

.flat-line {
  width: 2px;
  height: 12px;
  background: #d1d5db;
}

.flat-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.5rem;
  background: #f3f4f6;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════════════════
   MODE 2 — Direction-aware list
   ════════════════════════════════════════════════════════════════════════════ */
.mode-dir {
  display: flex;
  flex-direction: column;
}

.dir-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 0.875rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  border-left: 4px solid #9ca3af;
  position: relative;
}

.dir-card.male {
  border-left-color: #3b82f6;
}

.dir-card.female {
  border-left-color: #ec4899;
}

.dir-card.start {
  border-left-color: #22c55e;
  box-shadow: 0 2px 8px rgba(34, 197, 94, .18);
}

.dir-card.end {
  border-left-color: #f59e0b;
  box-shadow: 0 2px 8px rgba(245, 158, 11, .18);
}

.dir-card.peak {
  border-left-color: #7c3aed;
  background: #faf5ff;
}

.purvaj-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #7c3aed;
  background: #f3e8ff;
  border: 1px solid #ddd6fe;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dir-connector {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.2rem 0.5rem;
  margin: 0.1rem 0;
}

.dir-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  margin-left: 0.875rem;
  /* align with card left-border */
}

.dir-arrow.up {
  background: #ecfdf5;
  color: #059669;
}

.dir-arrow.down {
  background: #fef9c3;
  color: #b45309;
}

.dir-arrow.lat {
  background: #fdf4ff;
  color: #7c3aed;
}

.dir-conn-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dir-conn-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #374151;
}

.dir-conn-sub {
  font-size: 0.65rem;
  color: #9ca3af;
  margin-top: 0.05rem;
}

/* ════════════════════════════════════════════════════════════════════════════
   MODE 3 — Generation lane layout (CSS Grid, L-shaped connectors, no SVG)
   ════════════════════════════════════════════════════════════════════════════ */
.gen-scroll-outer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}

/* Row = one generation level */
.gen-row {
  display: grid;
  /* col 0: axis label (36px), col 1…N: node slots */
  grid-template-columns: 36px repeat(var(--col-count, 6), var(--node-col-w, 130px));
  align-items: center;
  position: relative;
  min-height: var(--row-h, 88px);
}

.gen-axis {
  grid-column: 1;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.2;
  padding-right: 4px;
  user-select: none;
}

/* faint alternating row bands */
.gen-row:nth-child(odd) {
  background: rgba(0, 0, 0, .015);
}

.gen-row:nth-child(even) {
  background: transparent;
}

/* Node card placed at a specific grid column */
.gen-node {
  grid-row: 1;
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.625rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
  border-top: 3px solid #9ca3af;
  margin: 4px 8px;
  position: relative;
  z-index: 2;
  min-width: 100px;
}

.gen-node.male {
  border-top-color: #3b82f6;
}

.gen-node.female {
  border-top-color: #ec4899;
}

.gen-node.start {
  border-top-color: #22c55e;
  box-shadow: 0 2px 8px rgba(34, 197, 94, .25);
}

.gen-node.end {
  border-top-color: #f59e0b;
  box-shadow: 0 2px 8px rgba(245, 158, 11, .25);
}

.gen-node.peak {
  border-top-color: #7c3aed;
  background: #faf5ff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, .18);
}

.gen-node-av {
  position: relative;
  overflow: hidden;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.gen-node-name {
  font-size: 0.7rem;
  font-weight: 800;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gen-node-sub {
  font-size: 0.6rem;
  color: #6b7280;
  white-space: nowrap;
}

.gen-node-badge {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.56rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.gen-node-badge.start {
  background: #dcfce7;
  color: #166534;
}

.gen-node-badge.end {
  background: #fef3c7;
  color: #92400e;
}

.gen-node-badge.peak {
  background: #f3e8ff;
  color: #6d28d9;
}

/* ── L-shaped connectors between gen-nodes ──────────────────────────────────
   Each connector is a <div class="gen-conn"> placed in the grid between rows.
   It contains two children: .conn-h (horizontal segment) and .conn-v (vertical).
   The JS sets CSS custom properties for sizing; no SVG needed.              */
.gen-conn-layer {
  /* spans full width of all node columns, sits between node rows */
  grid-column: 1 / -1;
  position: relative;
  height: var(--conn-h, 24px);
  margin: 0;
}

.gen-conn {
  position: absolute;
  /* JS sets: --x1, --x2, top/bottom for direction */
}

/* Vertical segment */
.conn-v {
  position: absolute;
  width: 2px;
  background: var(--conn-color, #d1d5db);
}

/* Horizontal segment */
.conn-h {
  position: absolute;
  height: 2px;
  background: var(--conn-color, #d1d5db);
}

/* Connector label pill */
.conn-label {
  position: absolute;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--conn-text, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fff;
  border: 1px solid var(--conn-color, #d1d5db);
  border-radius: 8px;
  padding: 0.08rem 0.4rem;
  white-space: nowrap;
  transform: translateX(-50%);
  z-index: 3;
}

/* ── Shared card avatar + info ─────────────────────────────────────────────── */
.p-av {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.male .p-av {
  background: #dbeafe;
  color: #1d4ed8;
}

.female .p-av {
  background: #fce7f3;
  color: #be185d;
}

.peak .p-av {
  background: #f3e8ff;
  color: #6d28d9;
}

.start .p-av {
  background: #dcfce7;
  color: #166534;
}

.end .p-av {
  background: #fef3c7;
  color: #92400e;
}

.p-info {
  flex: 1;
  min-width: 0;
}

.p-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-meta {
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 0.1rem;
}

/* ── Gen layout legend ─────────────────────────────────────────────────────── */
.gen-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.7rem;
  color: #6b7280;
  border-top: 1px solid #f3f4f6;
  margin-top: 0.5rem;
}

.gen-legend span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.leg-line {
  width: 16px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .viz-result {
    padding: 0 0.5rem;
  }

  .viz-result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .flat-card,
  .dir-card {
    padding: 0.625rem 0.75rem;
  }

  .p-name {
    font-size: 0.82rem;
  }
}

/* ════════════════════════════════════════════════════════════════════════════
   MODE 4 — Sabhi Raaste (multi-path two-pane layout)
   ════════════════════════════════════════════════════════════════════════════ */

/* Wide result container — overrides the 560px cap used by modes 1-3 */
.viz-result--wide {
  max-width: none;
  margin: 0.75rem 0.75rem 3rem;
  padding: 0;
}

/* ── Two-pane layout ─────────────────────────────────────────────────────── */
.mp-layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
  min-height: 400px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

/* ── Left sidebar: path index list ──────────────────────────────────────── */
.mp-sidebar {
  width: 220px;
  min-width: 180px;
  max-width: 240px;
  flex-shrink: 0;
  border-right: 1px solid #e5e7eb;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.mp-sidebar-header {
  padding: 0.6rem 0.75rem 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.mp-sidebar-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: #1a1a2e;
}

.mp-sidebar-sub {
  display: block;
  font-size: 0.68rem;
  color: #6b7280;
  margin-top: 0.1rem;
}

.mp-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.375rem 0.375rem;
}

/* ── Path index card ─────────────────────────────────────────────────────── */
.mp-path-card {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 7px;
  padding: 0.5rem 0.625rem;
  margin-bottom: 0.375rem;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
}

.mp-path-card:hover {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .12);
}

.mp-path-card.selected {
  border-color: #6366f1;
  background: #eef2ff;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .18);
}

.mp-path-card.has-spouse.selected {
  border-color: #ec4899;
  background: #fdf2f8;
  box-shadow: 0 0 0 2px rgba(236, 72, 153, .18);
}

.mp-card-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.mp-hop-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  border-radius: 11px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  flex-shrink: 0;
  padding: 0 0.35rem;
}

.mp-path-card.has-spouse .mp-hop-badge {
  background: #be185d;
}

.mp-path-card.selected .mp-hop-badge {
  background: #4f46e5;
}

.mp-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #374151;
  line-height: 1.3;
}

/* ── Edge-type pill row ──────────────────────────────────────────────────── */
.mp-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.et-pill {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.08rem 0.35rem;
  border-radius: 8px;
  white-space: nowrap;
}

.et-child {
  background: #dbeafe;
  color: #1d4ed8;
}

.et-parent {
  background: #dcfce7;
  color: #166534;
}

.et-spouse {
  background: #fce7f3;
  color: #be185d;
}

.et-more {
  background: #f3f4f6;
  color: #6b7280;
}

/* ── Right detail pane ───────────────────────────────────────────────────── */
.mp-detail {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: 80vh;
  padding: 0.75rem 0.875rem 1rem;
}

/* Sub-mode toggle row */
.mp-submode-row {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 0.625rem;
}

.mp-submode-btn {
  padding: 0.3rem 0.7rem;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #6b7280;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  font-family: inherit;
}

.mp-submode-btn.active {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #eef2ff;
}

/* Path detail header */
.mp-detail-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.625rem;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.mp-detail-index {
  font-size: 0.75rem;
  font-weight: 800;
  color: #1a1a2e;
}

.mp-diverge-note {
  font-size: 0.68rem;
  color: #7c3aed;
  background: #f3e8ff;
  border: 1px solid #ddd6fe;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

/* ── Advanced controls (tolerance + maxPaths) ────────────────────────────── */
.mp-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.625rem;
}

.mp-ctrl-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #374151;
  cursor: default;
}

.mp-ctrl-select {
  padding: 0.25rem 0.4rem;
  border: 1px solid #c7d2fe;
  border-radius: 5px;
  font-size: 0.75rem;
  background: #fff;
  color: #1a1a2e;
  cursor: pointer;
}

.mp-ctrl-range {
  width: 80px;
  accent-color: #6366f1;
  cursor: pointer;
}

.mp-ctrl-val {
  min-width: 22px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #4f46e5;
  text-align: right;
}

.mp-refetch-btn {
  padding: 0.3rem 0.75rem;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s;
  flex-shrink: 0;
}

.mp-refetch-btn:hover:not(:disabled) {
  background: #3730a3;
}

.mp-refetch-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* ── Responsive: stack to single column on narrow screens ────────────────── */
@media (max-width: 600px) {
  .mp-layout {
    flex-direction: column;
  }

  .mp-sidebar {
    width: 100%;
    max-width: none;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }

  .mp-detail {
    max-height: none;
  }

  .mp-sidebar-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.375rem;
    padding: 0.375rem;
  }

  .mp-path-card {
    min-width: 150px;
    margin-bottom: 0;
  }
}