/* ==========================================================================
   Todd & Robinson Family Tree - Interactive Genealogy Web Application
   High-performance, standalone, responsive stylesheet
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Playfair Display', 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Color Palette - Warm Parchment & High-Contrast Archival System */
  --bg-app: #ede5d8;               /* Rich warm tactile oatmeal parchment */
  --bg-surface: #ffffff;           /* Crisp archival paper white */
  --bg-surface-warm: #f4eee2;      /* Oat / stone warm surface */
  --bg-card: #ffffff;              /* Pure white card surface */
  --bg-card-hover: #ffffff;
  --bg-input: #f7f3eb;             /* Warm parchment input */
  --border-color: rgba(90, 70, 45, 0.2); /* Defined antique border */
  --border-card: rgba(90, 70, 45, 0.22);
  --border-card-hover: #b45309;

  --text-main: #0f172a;            /* Deep ink slate for high legibility */
  --text-muted: #475569;           /* Sharp medium slate */
  --text-dim: #64748b;             /* Clear caption slate */

  /* High-Contrast Heritage Accent Colors */
  --accent-primary: #b45309;       /* Heritage Amber Bronze */
  --accent-primary-hover: #92400e;
  --accent-gold: #d97706;
  --accent-gold-glow: rgba(217, 119, 6, 0.25);
  --accent-emerald: #059669;       /* Archival Emerald */
  --accent-purple: #7e22ce;        /* Royal Purple */
  --accent-rose: #be123c;          /* Deep Crimson */
  --accent-indigo: #1d4ed8;        /* Bold Oxford Blue */

  /* High-Contrast Distinct Branch Colors */
  --branch-todd: #1d4ed8;       /* Deep Royal/Navy Blue */
  --branch-roche: #d97706;      /* Vivid Warm Amber */
  --branch-lais: #059669;       /* Deep Emerald Pine */
  --branch-robinson: #7e22ce;   /* Regal Purple */
  --branch-gassett: #e11d48;    /* Crimson Rose */
  --branch-mcfarland: #0284c7;  /* Sky Slate Blue */
  --branch-evans: #16a34a;      /* Leaf Green */
  --branch-asher: #b45309;      /* Burnt Bronze */
  --branch-dearduff: #0d9488;   /* Deep Teal */
  --branch-bonham: #4338ca;     /* Royal Indigo */
  --branch-wallace: #dc2626;    /* Vivid Heritage Red */
  --branch-floyd: #ea580c;      /* Russet Orange */
  --branch-central: #b45309;    /* Gold Bronze */

  --card-width: 252px;
  --card-height: 106px;

  --header-height: 98px;
  --drawer-width: 490px;

  --shadow-sm: 0 1px 3px rgba(60, 45, 25, 0.06);
  --shadow-md: 0 4px 14px rgba(60, 45, 25, 0.1);
  --shadow-lg: 0 12px 30px rgba(60, 45, 25, 0.15);
  --shadow-card: 0 3px 10px rgba(60, 45, 25, 0.09), 0 1px 3px rgba(60, 45, 25, 0.05);
  --shadow-gold: 0 0 15px rgba(217, 119, 6, 0.3);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-drawer: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Adapt header height and hide tree toolbar when browsing other views */
body.non-tree-view {
  --header-height: 52px;
}

body.non-tree-view .tree-toolbar {
  display: none !important;
}

/* ==========================================================================
   Header & Navbar (Two-Tier Layout)
   ========================================================================== */

.app-header {
  position: relative;
  z-index: 100;
  width: 100%;
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow: 0 2px 14px rgba(44, 32, 20, 0.06);
}

/* Tier 1: Main App Bar (Brand, View Navigation Tabs, Auth) */
.header-main {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  border-bottom: 1px solid rgba(68, 54, 38, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-crest {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #b47a28, #94611b);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(180, 122, 40, 0.35);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  white-space: nowrap;
  line-height: 1.2;
}

.brand-subtitle {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Navigation Tabs */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #efe9df;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: #faf7f2;
}

.tab-btn.active {
  background: #b47a28;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(68, 54, 38, 0.2);
}

/* Tier 2: Interactive Tree Toolbar */
.tree-toolbar {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  background: rgba(247, 243, 235, 0.95);
}

.tree-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.tree-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 4px;
}

.nav-branch-select {
  height: 32px;
  max-width: 270px;
  padding: 0 10px;
  background: var(--bg-card);
  border: 1px solid rgba(180, 122, 40, 0.35);
  border-radius: var(--radius-md);
  color: #8f5e1b;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-branch-select:hover, .nav-branch-select:focus {
  border-color: #b47a28;
  color: #1f2224;
  background: #ffffff;
}

.btn-center {
  height: 32px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(180, 122, 40, 0.12);
  border: 1px solid rgba(180, 122, 40, 0.35);
  color: #8f5e1b;
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.btn-center:hover {
  background: #b47a28;
  border-color: #8f5e1b;
  color: #ffffff;
}

/* Search Box */
.search-box {
  position: relative;
  width: 240px;
  max-width: 280px;
  flex-shrink: 0;
}

.search-box input {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 30px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 11.5px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(180, 122, 40, 0.2);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  background: #efe9df;
  border: 1px solid rgba(68, 54, 38, 0.1);
  border-radius: 4px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
}

.search-clear-btn:hover {
  color: #fff;
}

/* Search Dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: 380px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  padding: 6px;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-result-item:hover, .search-result-item.highlighted {
  background: var(--bg-card-hover);
}

.search-result-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.search-result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.search-result-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  white-space: nowrap;
}

.search-result-badge.patriot {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Filter Controls */
.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group select {
  height: 32px;
  padding: 0 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  max-width: 135px;
  text-overflow: ellipsis;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.filter-group select:hover, .filter-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #b47a28, #94611b);
  color: #ffffff;
  border: 1px solid #855513;
  box-shadow: 0 1px 3px rgba(68, 54, 38, 0.15);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #94611b, #7d4907);
  box-shadow: 0 2px 6px rgba(180, 122, 40, 0.35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
}

.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.canvas-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Main App Container & View Panels
   ========================================================================== */

.main-container {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.view-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  overflow: hidden;
}

.view-panel.active {
  display: block;
}

/* ==========================================================================
   VIEW 1: Interactive Tree Canvas
   ========================================================================== */

#tree-view {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: var(--bg-app);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(90, 70, 45, 0.18) 1.2px, transparent 0);
  background-size: 28px 28px;
  user-select: none;
  -webkit-user-select: none;
}

/* Header Branch Selector */
.nav-branch-select {
  background: #ffffff;
  border: 1.5px solid rgba(90, 70, 45, 0.22);
  border-radius: var(--radius-sm);
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
  max-width: 260px;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.05);
}

.nav-branch-select:hover,
.nav-branch-select:focus {
  outline: none;
  border-color: #b45309;
  color: #b45309;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.15);
}

/* Floating Focus Pill (Single slim pill on canvas only when focused) */
.focus-pill {
  position: absolute;
  top: 14px;
  left: 18px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 4px 16px rgba(44, 32, 20, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  color: #ffffff;
  pointer-events: auto;
  animation: fadeInPill 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInPill {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.focus-pill-icon {
  font-size: 13px;
}

.focus-pill-name {
  font-weight: 700;
  color: #1a1d20;
}

.focus-pill-reset {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.focus-pill-reset:hover {
  background: rgba(239, 68, 68, 0.5);
  color: #ffffff;
  border-color: #ef4444;
}

/* Discrete Bottom-Left Legend Strip */
.tree-legend-strip {
  position: absolute;
  bottom: 14px;
  left: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 12px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 2px 8px rgba(44, 32, 20, 0.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  pointer-events: none;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-pill.proven .dot { background: var(--accent-emerald); }
.legend-pill.memory .dot { background: var(--accent-purple); }
.legend-pill.lead .dot { background: var(--accent-gold); }
.legend-pill.patriot .dot.gold {
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.8);
}

/* Tree Viewport & Canvas */
.tree-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.tree-canvas {
  touch-action: none;
}

.tree-viewport.panning {
  cursor: grabbing;
}

.tree-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* Generation Column Guides */
.tree-generation-guides {
  position: absolute;
  top: -4000px;
  bottom: -4000px;
  left: -8000px;
  right: -8000px;
  pointer-events: none;
}

.gen-column-header {
  position: absolute;
  top: -80px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
  white-space: nowrap;
}

.gen-row-header {
  position: absolute;
  left: -1450px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: rgba(56, 189, 248, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px dashed rgba(56, 189, 248, 0.2);
  padding-bottom: 3px;
  white-space: nowrap;
}

.branch-col-header {
  position: absolute;
  top: 155px;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: #b45309;
  background: #ffffff;
  border: 1.5px solid rgba(180, 83, 9, 0.3);
  border-radius: 999px;
  padding: 3px 14px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.06);
}

.gen-column-line {
  position: absolute;
  top: -4000px;
  height: 8000px;
  width: 1px;
  border-left: 1px dashed rgba(255, 255, 255, 0.04);
}

/* SVG Links Layer - Perfectly aligned with tree-canvas origin (0, 0) */
.tree-svg-links {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}

.tree-link {
  fill: none;
  stroke: #64748b;
  stroke-width: 2.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease, stroke-width 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

/* Left wing lines (Travis's lineage: Luminous Cyan / Sky Blue) */
.tree-link.left-wing {
  stroke: #38bdf8;
  stroke-opacity: 0.85;
  filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.45));
}

/* Right wing lines (Sonya's lineage: Luminous Purple / Violet) */
.tree-link.right-wing {
  stroke: #c084fc;
  stroke-opacity: 0.85;
  filter: drop-shadow(0 0 2px rgba(192, 132, 252, 0.45));
}

/* Marriage link between Travis & Sonya (Bright Gold Glow) */
.tree-link.marriage-link {
  stroke: #fbbf24;
  stroke-width: 3.5px;
  stroke-opacity: 1;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.7));
}

/* Children connecting lines (Bright Cyan) */
.tree-link.child-link {
  stroke: #38bdf8;
  stroke-width: 2.5px;
  stroke-opacity: 0.9;
  filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.4));
}

/* Hover & Selected Line Highlight (Glowing Amber Gold) */
.tree-link.highlighted {
  stroke: #f59e0b !important;
  stroke-width: 4.5px !important;
  stroke-opacity: 1 !important;
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.9)) !important;
  z-index: 15;
}

/* Connection Junction Dots */
.tree-dot {
  fill: #38bdf8;
  stroke: #090d16;
  stroke-width: 1.5px;
  filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.6));
}

.tree-dot.right-wing {
  fill: #c084fc;
  filter: drop-shadow(0 0 2px rgba(192, 132, 252, 0.6));
}

.tree-dot.gold {
  fill: #fbbf24;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.8));
}

/* Tree Nodes Container */
.tree-nodes-container {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10;
}

/* Individual Person Card */
.person-card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 10px 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s ease,
              border-color 0.2s ease,
              opacity 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
  border-left: 4px solid var(--accent-primary);
}

.person-card:hover {
  transform: translateY(-3px) scale(1.02);
  background: #ffffff;
  box-shadow: var(--shadow-lg), 0 0 12px rgba(180, 122, 40, 0.15);
  border-color: var(--border-card-hover);
  z-index: 20;
}

.person-card.active-selected {
  border-color: #b47a28;
  box-shadow: 0 0 0 3px rgba(180, 122, 40, 0.25), var(--shadow-lg);
  z-index: 30;
}

.person-card.dimmed {
  opacity: 0.25;
}

/* Branch Specific Stripe Colors */
.person-card.branch-Todd { border-left-color: var(--branch-todd); }
.person-card.branch-Roche { border-left-color: var(--branch-roche); }
.person-card.branch-Lais { border-left-color: var(--branch-lais); }
.person-card.branch-Robinson { border-left-color: var(--branch-robinson); }
.person-card.branch-Gassett { border-left-color: var(--branch-gassett); }
.person-card.branch-McFarland { border-left-color: var(--branch-mcfarland); }
.person-card.branch-Evans { border-left-color: var(--branch-evans); }
.person-card.branch-Asher { border-left-color: var(--branch-asher); }
.person-card.branch-Dearduff { border-left-color: var(--branch-dearduff); }
.person-card.branch-Bonham { border-left-color: var(--branch-bonham); }
.person-card.branch-Wallace { border-left-color: var(--branch-wallace); }
.person-card.branch-Floyd { border-left-color: var(--branch-floyd); }
.person-card.branch-Central {
  border-left-color: var(--branch-central);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.2), var(--shadow-card);
}

/* Card Header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.card-title-group {
  overflow: hidden;
}

.card-name {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  color: #1a1d20;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-lifespan {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
}

.card-location {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Card Badges Row */
.card-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge.proven {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.memory {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge.lead {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge.patriot,
.badge.veteran {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.3));
  color: #fde047;
  border: 1px solid rgba(251, 191, 36, 0.5);
  font-weight: 700;
}

.badge.dar-eligible {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
  font-weight: 600;
}

.search-result-badge.dar-eligible {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tag-pill.dar {
  color: #93c5fd !important;
  border-color: rgba(59, 130, 246, 0.4) !important;
}

.badge.story {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Branch Expand/Collapse Toggle Button */
.branch-toggle-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid var(--accent-primary);
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(44, 32, 20, 0.1);
  transition: all var(--transition-fast);
  z-index: 10;
}

.branch-toggle-btn::after {
  content: '';
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: -10px;
  right: -10px;
}

.branch-toggle-btn:hover {
  background: var(--accent-primary);
  color: #ffffff;
  transform: translateY(-50%) scale(1.1);
}

.branch-toggle-btn.left {
  left: -13px;
}

.branch-toggle-btn.right {
  right: -13px;
}

.branch-toggle-btn.collapsed {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  font-size: 9px;
  width: auto;
  min-width: 24px;
  padding: 0 5px;
  border-radius: var(--radius-full);
}

/* Central Marriage Ring Hub */
.marriage-hub {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 5px 14px;
  background: #ffffff;
  border: 2px solid #d97706;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #92400e;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
  z-index: 15;
  white-space: nowrap;
  pointer-events: auto;
  cursor: default;
}

/* Daughters Section Hub */
.daughters-hub {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 14px;
  background: #ffffff;
  border: 2px solid #0d9488;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0f766e;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
  z-index: 15;
  white-space: nowrap;
  pointer-events: none;
}

/* ==========================================================================
   VIEW 2: Directory Table
   ========================================================================== */

#directory-view {
  overflow-y: auto;
  background: var(--bg-app);
  padding: 24px 32px;
}

.directory-container {
  max-width: 1400px;
  margin: 0 auto;
}

.directory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.directory-title h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.directory-title p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.directory-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-pill {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.stat-pill strong {
  color: var(--text-main);
  font-weight: 700;
}

.directory-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-input {
  flex: 1;
  min-width: 240px;
  height: 38px;
  padding: 0 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.filter-select {
  height: 38px;
  padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.directory-table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.directory-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.directory-table th {
  background: #1e293b;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.directory-table th.sortable {
  cursor: pointer;
}

.directory-table th.sortable:hover {
  color: var(--accent-primary);
}

.directory-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.directory-table tbody tr {
  transition: background var(--transition-fast);
  cursor: pointer;
}

.directory-table tbody tr:hover {
  background: var(--bg-card);
}

.table-person-name {
  font-weight: 600;
  color: var(--text-main);
}

.table-person-dates {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.table-actions {
  display: flex;
  gap: 6px;
}

/* ==========================================================================
   VIEW 3: Patriots & Veterans Roll of Honor
   ========================================================================== */

#patriots-view {
  overflow-y: auto;
  background: var(--bg-app);
  padding: 28px 36px;
}

.patriots-container {
  max-width: 1400px;
  margin: 0 auto;
}

.patriots-header {
  margin-bottom: 24px;
}

.patriots-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.patriots-title h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
}

.patriots-title p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.patriots-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: #ffffff;
  border: 1.5px solid rgba(80, 60, 40, 0.18);
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.04);
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pill-btn:hover {
  background: #f7f2ea;
  border-color: #b45309;
  color: #b45309;
}

.pill-btn.active {
  background: #b45309;
  color: #ffffff;
  border-color: #92400e;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25);
}

.patriots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.patriot-card {
  background: var(--bg-surface);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.patriot-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.patriot-card:hover {
  transform: translateY(-4px);
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: var(--shadow-gold), var(--shadow-lg);
}

.patriot-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.patriot-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: #1a1d20;
}

.patriot-lifespan {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.patriot-service-banner {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 12px;
}

.patriot-service-text {
  font-size: 13px;
  font-weight: 600;
  color: #b45309;
  line-height: 1.4;
}

.patriot-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.patriot-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

/* ==========================================================================
   VIEW 4: Family Research Discoveries & Heritage Chronicles
   ========================================================================== */

#discoveries-view {
  overflow-y: auto;
  background: var(--bg-app);
  padding: 28px 36px;
}

.discoveries-container {
  max-width: 1400px;
  margin: 0 auto;
}

.discoveries-header {
  margin-bottom: 28px;
}

.discoveries-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.discoveries-crest {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: #f4eee2;
  border: 1.5px solid rgba(180, 83, 9, 0.35);
  color: #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.05);
  flex-shrink: 0;
}

.patriots-crest {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  color: #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.05);
  flex-shrink: 0;
}

.discoveries-title h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
}

.discoveries-title p {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
}

.discoveries-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.discoveries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 24px;
}

.discovery-card {
  background: #ffffff;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.discovery-card:hover {
  transform: translateY(-4px);
  border-color: rgba(180, 83, 9, 0.45);
  box-shadow: var(--shadow-lg), 0 4px 20px rgba(60, 45, 25, 0.12);
}

.discovery-card-top {
  margin-bottom: 16px;
}

.discovery-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  background: #f0fdf4;
  color: #047857;
  border: 1px solid #bbf7d0;
}

.discovery-badge.gemes {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.discovery-badge.mancuso {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.discovery-badge.pinero {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.discovery-badge.manson {
  background: #faf5ff;
  color: #6b21a8;
  border-color: #e9d5ff;
}

.discovery-badge.nola {
  background: #fdf2f8;
  color: #be185d;
  border-color: #fbcfe8;
}

.discovery-badge.military {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.discovery-badge.mills {
  background: #f0fdfa;
  color: #0f766e;
  border-color: #99f6e4;
}

.discovery-badge.mayflower {
  background: #fefce8;
  color: #854d0e;
  border-color: #fef08a;
}

.discovery-badge.lothrop {
  background: #f5f3ff;
  color: #5b21b6;
  border-color: #ddd6fe;
}

.discovery-badge.lawmen {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

.discovery-badge.sheriff {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.discovery-badge.brethren {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.discovery-badge.wallace {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.discovery-badge.edgley {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}

.discovery-badge.wedding {
  background: #fdf2f8;
  color: #9d174d;
  border-color: #fbcfe8;
}

.discovery-badge.cinema {
  background: #fdf4ff;
  color: #a21caf;
  border-color: #f0abfc;
}

.discovery-badge.hughes {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.discovery-badge.mabry {
  background: #f0fdf4;
  color: #15803d;
  border-color: #86efac;
}

.discovery-badge.edgley-cavalry {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.discovery-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 6px;
}

.discovery-subtitle {
  font-size: 13.5px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 14px;
  line-height: 1.45;
}

.discovery-story {
  font-size: 13.5px;
  line-height: 1.65;
  color: #1e293b;
  margin-bottom: 16px;
}

.discovery-lineage-box {
  background: #fcf9f2;
  border: 1.5px solid rgba(90, 70, 45, 0.22);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.discovery-lineage-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #92400e;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.discovery-chain {
  font-size: 12.5px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.6;
}

.discovery-relatives {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.discovery-relative-pill {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.discovery-relative-pill:hover {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0369a1;
}

/* Direct Lineage Breadcrumb Trail in Detail Drawer */
.lineage-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lineage-step-pill:hover {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #15803d;
  transform: translateY(-1px);
}

.lineage-step-pill.current {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.lineage-step-pill.target-me {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
  font-weight: 700;
}

.lineage-arrow {
  color: #b45309;
  font-weight: bold;
  font-size: 12px;
  margin: 0 2px;
  user-select: none;
}

.person-card.lineage-path-node {
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4), var(--shadow-card);
}

.tree-link.lineage-link {
  stroke: #10b981 !important;
  stroke-width: 3.5px !important;
  stroke-opacity: 0.95 !important;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.6)) !important;
}

.tree-dot.lineage-dot {
  fill: #10b981 !important;
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.8)) !important;
}

.discovery-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  margin-top: auto;
}

.discovery-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.discovery-actions .btn {
  flex: 1 1 calc(50% - 4px);
  min-width: 120px;
  text-align: center;
  justify-content: center;
}

/* Discovery Community Contributions & Additions */
.discovery-contributions-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(148, 163, 184, 0.2);
}

.discovery-contrib-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #38bdf8;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.discovery-contrib-item {
  background: #ffffff;
  border: 1.5px solid rgba(90, 70, 45, 0.18);
  border-left: 3.5px solid #059669;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 12px;
}

.discovery-contrib-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 11px;
}

.discovery-contrib-author {
  font-weight: 700;
  color: #b45309;
}

.discovery-contrib-date {
  color: var(--text-dim);
}

.discovery-contrib-text {
  color: #0f172a;
  line-height: 1.5;
}

.discovery-contrib-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #065f46;
  background: #dcfce7;
  border: 1px solid #86efac;
  padding: 1px 7px;
  border-radius: 8px;
}

.discovery-add-container {
  margin-top: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1.5px dashed rgba(180, 83, 9, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(60, 45, 25, 0.05);
}

/* Detail Drawer Callout for Special Discoveries */
.discovery-drawer-callout {
  margin: 14px 0;
  padding: 14px 16px;
  background: #ffffff;
  border: 1.5px solid rgba(90, 70, 45, 0.18);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(60, 45, 25, 0.06);
}

.discovery-drawer-callout.gemes {
  border-color: rgba(180, 83, 9, 0.45);
}

.discovery-drawer-callout.mancuso {
  border-color: rgba(16, 185, 129, 0.45);
}

.discovery-drawer-callout.cuban {
  border-color: rgba(245, 158, 11, 0.45);
}

.discovery-drawer-callout.manson {
  border-color: rgba(168, 85, 247, 0.45);
}

.discovery-drawer-callout.mayflower {
  border-color: rgba(234, 179, 8, 0.5);
}

.discovery-drawer-callout.lothrop {
  border-color: rgba(147, 51, 234, 0.5);
}

.discovery-drawer-callout.lawmen {
  border-color: rgba(59, 130, 246, 0.5);
}

.discovery-drawer-callout.sheriff {
  border-color: rgba(239, 68, 68, 0.5);
}

.discovery-drawer-callout.brethren {
  border-color: rgba(16, 185, 129, 0.5);
}

.discovery-drawer-callout.wallace {
  border-color: rgba(249, 115, 22, 0.5);
}

.discovery-drawer-callout.edgley {
  border-color: rgba(244, 63, 94, 0.5);
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.callout-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.callout-header strong {
  font-size: 14px;
  color: #0f172a;
}

.discovery-drawer-callout p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 10px;
}

.callout-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   VIEW 5: Biographical Lore & Stories
   ========================================================================== */

#stories-view {
  overflow-y: auto;
  background: var(--bg-app);
  padding: 28px 36px;
}

.stories-container {
  max-width: 1400px;
  margin: 0 auto;
}

.stories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.stories-header h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
}

.stories-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stories-search-box input {
  width: 320px;
  height: 38px;
  padding: 0 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13px;
}

.stories-search-box input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.stories-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stories-filter-pills .pill-btn {
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: #ffffff;
  border: 1.5px solid rgba(80, 60, 40, 0.18);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.04);
}

.stories-filter-pills .pill-btn:hover {
  background: #f7f2ea;
  border-color: #b45309;
  color: #b45309;
}

.stories-filter-pills .pill-btn.active {
  background: #b45309;
  color: #ffffff;
  border-color: #92400e;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25);
  font-weight: 700;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 22px;
}

.story-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.story-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-lg), 0 4px 20px rgba(60, 45, 25, 0.12);
}

.story-card-top {
  margin-bottom: 14px;
}

.story-card-name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.story-card-branch {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.story-card-excerpt {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-main);
  margin-bottom: 16px;
}

.story-card-highlights {
  list-style: none;
  margin-bottom: 16px;
}

.story-card-highlights li {
  font-size: 12.5px;
  color: var(--text-muted);
  padding-left: 14px;
  position: relative;
  margin-bottom: 4px;
}

.story-card-highlights li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent-primary);
}

.story-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  font-size: 12px;
  color: var(--accent-primary);
  font-weight: 600;
}

/* ==========================================================================
   Detail Drawer (Sliding Panel)
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-drawer);
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Detail Drawer (Sliding Panel - Warm Archival Theme)
   ========================================================================== */

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--drawer-width);
  max-width: 100vw;
  height: 100vh;
  background: #fbf9f4 !important;
  border-left: 1.5px solid rgba(80, 60, 40, 0.22) !important;
  box-shadow: -10px 0 35px rgba(50, 35, 20, 0.16) !important;
  z-index: 300;
  transform: translateX(100%);
  transition: transform var(--transition-drawer);
  display: flex;
  flex-direction: column;
}

.detail-drawer.open {
  transform: translateX(0);
}

/* Drawer Header */
.drawer-header {
  padding: 16px 20px;
  border-bottom: 1.5px solid rgba(80, 60, 40, 0.18) !important;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f3ede2 !important;
}

.drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(80, 60, 40, 0.1) !important;
  border: 1px solid rgba(80, 60, 40, 0.18) !important;
  color: #0f172a !important;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.drawer-close-btn:hover {
  background: rgba(190, 18, 60, 0.15) !important;
  color: #be123c !important;
  border-color: #be123c !important;
}

.drawer-badges-top {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Drawer Body */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: #fbf9f4 !important;
}

/* Person Hero Section */
.drawer-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  background: #ffffff !important;
  border: 1.5px solid rgba(80, 60, 40, 0.18) !important;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(60, 45, 25, 0.06);
}

.drawer-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: #f4eee2 !important;
  border: 2.5px solid var(--accent-primary) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-primary) !important;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.drawer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(90, 70, 45, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
  margin-right: 8px;
}

.badge.photo {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}

/* Archival Photographs & Historical Artifacts Gallery */
.gallery-section {
  margin-top: 18px;
}

.drawer-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.drawer-gallery-item {
  margin: 0;
  background: #ffffff;
  border: 1.5px solid rgba(90, 70, 45, 0.18);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.drawer-gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

.drawer-gallery-link {
  display: block;
  height: 135px;
  background: #f1f5f9;
  overflow: hidden;
  position: relative;
}

.drawer-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}

.drawer-gallery-item img:hover {
  transform: scale(1.05);
}

.drawer-gallery-item figcaption {
  padding: 8px 10px;
  font-size: 11px;
  color: #334155;
  line-height: 1.45;
  border-top: 1px solid rgba(90, 70, 45, 0.12);
  background: #faf8f5;
  flex-grow: 1;
}

.drawer-hero-info {
  flex: 1;
}

.drawer-name {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 800;
  color: #0f172a !important;
  line-height: 1.25;
}

.drawer-lifespan {
  font-size: 13.5px;
  color: #b45309 !important;
  font-weight: 700;
  margin-top: 4px;
}

.drawer-meta-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Drawer Sections */
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #b45309 !important;
  border-bottom: 1.5px solid rgba(80, 60, 40, 0.15) !important;
  padding-bottom: 6px;
}

/* Vitals Card */
.vitals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #ffffff !important;
  border: 1.5px solid rgba(80, 60, 40, 0.18) !important;
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.05);
}

.vital-item dt {
  font-size: 11px;
  color: #64748b !important;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.vital-item dd {
  font-size: 13px;
  color: #0f172a !important;
  font-weight: 700;
  margin-top: 3px;
  line-height: 1.35;
}

/* Military / Patriot Box */
.patriot-callout {
  background: #fffbeb !important;
  border: 1.5px solid #fcd34d !important;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.12);
}

.patriot-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.patriot-title {
  font-size: 12px;
  font-weight: 800;
  color: #78350f !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.patriot-text {
  font-size: 13px;
  color: #92400e !important;
  line-height: 1.45;
  font-weight: 600;
}

/* Relationships */
.relation-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.rel-label {
  font-size: 12px;
  font-weight: 700;
  color: #475569 !important;
  width: 75px;
  flex-shrink: 0;
  padding-top: 6px;
}

.rel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

/* HIGH-CONTRAST RELATIONSHIP PILLS - GUARANTEED VISIBLE NAMES */
.rel-chip {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 7px 14px !important;
  background: #ffffff !important;
  border: 1.5px solid rgba(80, 60, 40, 0.25) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  cursor: pointer !important;
  transition: all var(--transition-fast) !important;
  box-shadow: 0 1px 4px rgba(60, 45, 25, 0.06) !important;
}

.rel-chip span,
.rel-chip .rel-chip-name {
  color: #0f172a !important;
  font-weight: 700 !important;
  display: inline-block !important;
}

.rel-chip:hover {
  background: #f7f2ea !important;
  border-color: #b45309 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 3px 8px rgba(180, 83, 9, 0.16) !important;
}

.rel-chip:hover span,
.rel-chip:hover .rel-chip-name {
  color: #b45309 !important;
}

.rel-chip-sub {
  font-size: 11.5px !important;
  color: #64748b !important;
  font-weight: 600 !important;
}

/* Highlights List */
.highlights-list {
  list-style: none;
  background: #ffffff !important;
  border: 1.5px solid rgba(80, 60, 40, 0.18) !important;
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.05);
}

.highlights-list li {
  font-size: 13.5px;
  color: #0f172a !important;
  line-height: 1.55;
  padding-left: 20px;
  position: relative;
  margin-bottom: 8px;
}

.highlights-list li:last-child {
  margin-bottom: 0;
}

.highlights-list li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--accent-primary);
  font-size: 12px;
  top: 2px;
}

/* Story Narrative */
.story-content {
  font-size: 14.5px;
  line-height: 1.75;
  color: #1e293b !important;
  background: #ffffff !important;
  border: 1.5px solid rgba(80, 60, 40, 0.18) !important;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.05);
}

.story-content p {
  margin-bottom: 12px;
}

.story-content p:last-child {
  margin-bottom: 0;
}

.story-empty {
  font-style: italic;
  color: var(--text-dim);
  font-size: 13px;
}

/* Sources List */
.sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sources-list li {
  font-size: 12.5px;
  background: #ffffff !important;
  border: 1.5px solid rgba(80, 60, 40, 0.18) !important;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.45;
  color: #0f172a !important;
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.04);
}

.sources-list li:hover {
  border-color: #b45309 !important;
}

.sources-list li:has(.source-link):hover {
  border-color: #1d4ed8 !important;
  background: #f8fafc !important;
}

.sources-list li:has(.source-archival-item) {
  border-style: dashed !important;
  border-color: rgba(90, 70, 45, 0.3) !important;
  background: #fbf8f2 !important;
}

.sources-list a {
  color: #1d4ed8 !important;
  text-decoration: none;
  font-weight: 600;
  word-break: break-all;
}

.sources-list a:hover {
  text-decoration: underline;
}

/* Tags Cloud */
.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: #f2ece2;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 1200px) {
  .search-box {
    width: 200px;
  }
  .nav-branch-select {
    max-width: 210px;
  }
  .filter-group select {
    max-width: 115px;
    font-size: 10.5px;
  }
}

@media (max-width: 900px) {
  .header-main {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 10px;
  }

  .tree-toolbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }

  .tree-toolbar-left, .tree-toolbar-right {
    flex-wrap: wrap;
    width: 100%;
  }

  .detail-drawer {
    width: 100vw;
  }

  .focus-pill {
    top: 8px;
    left: 8px;
    font-size: 11px;
    padding: 4px 10px;
  }

  .tree-legend-strip {
    display: none;
  }
}

/* ==========================================================================
   Firebase Authentication & User State
   ========================================================================== */

.auth-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--border-color);
}

.btn-auth {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(2, 132, 199, 0.25));
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  font-weight: 600;
}

.btn-auth:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(2, 132, 199, 0.4));
  color: #fff;
  border-color: #38bdf8;
}

.auth-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  flex-shrink: 0;
}

/* ==========================================================================
   Authentication Modal Dialog
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-modal {
  width: 100%;
  max-width: 420px;
  background: #fbf9f4; border: 1.5px solid rgba(90, 70, 45, 0.25); box-shadow: 0 20px 45px rgba(50, 35, 20, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(56, 189, 248, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(90, 70, 45, 0.18);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: #f3ede2;
}

.modal-title-group h3 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid rgba(90, 70, 45, 0.18);
  background: #ede5d8;
}

.auth-tab-btn {
  flex: 1;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-tab-btn:hover {
  color: #fff;
}

.auth-tab-btn.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
  background: rgba(56, 189, 248, 0.05);
}

.auth-alert {
  margin: 16px 20px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.4;
}

.auth-alert.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.auth-alert.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.auth-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(180, 122, 40, 0.2);
}

.btn-block {
  width: 100%;
  height: 38px;
  margin-top: 4px;
  font-size: 13px;
}

/* ==========================================================================
   Drawer Memories Section (Firestore Live)
   ========================================================================== */

.section-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.section-header-flex .section-title {
  border-bottom: none;
  padding-bottom: 0;
}

.memories-login-prompt {
  background: #f4eee2; border: 1.5px dashed rgba(90, 70, 45, 0.25);
  border: 1px dashed var(--border-card);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.memories-login-prompt a {
  color: var(--accent-primary);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.add-memory-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-card-hover);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

.memory-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.ancestor-memories-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.memory-item {
  background: #ffffff;
  border: 1.5px solid rgba(90, 70, 45, 0.18);
  border-left: 4px solid var(--accent-primary);
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.05);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.memory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.memory-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.memory-author-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-memory-action {
  background: #f4eee2;
  border: 1px solid rgba(90, 70, 45, 0.2);
  color: #475569;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
  line-height: 1.35;
  font-family: inherit;
}

.btn-memory-action:hover {
  background: #ede5d8;
  color: #0f172a;
  border-color: #b45309;
}

.btn-memory-edit:hover,
.btn-disc-contrib-edit:hover {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.12);
}

.btn-memory-delete:hover,
.btn-disc-contrib-delete:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
}

.memory-author {
  font-weight: 700;
  color: #b45309;
  display: flex;
  align-items: center;
  gap: 5px;
}

.memory-author::before {
  content: '👤';
  font-size: 10px;
}

.memory-date {
  color: var(--text-dim);
}

.memory-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: #0f172a;
  white-space: pre-line;
}

.memory-edit-box {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-edit-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  border: 1.5px solid rgba(90, 70, 45, 0.25);
  border-radius: 6px;
  color: #0f172a;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
}

.memory-edit-textarea:focus {
  outline: none;
  border-color: #b45309;
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.15);
}

.memory-edit-actions {
  display: flex;
  gap: 8px;
}

.memory-item.verified-memory {
  border-left: 4px solid #059669 !important;
  background: #f0fdf4 !important;
  border: 1.5px solid #bbf7d0 !important;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.08) !important;
}

.memory-item.verified-memory .memory-text {
  color: #0f172a !important;
}

.memory-item.verified-memory .memory-author {
  color: #047857 !important;
}

.memory-verified-bar {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(5, 150, 105, 0.25);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memory-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #dcfce7 !important;
  border: 1.5px solid #86efac !important;
  color: #065f46 !important;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
  width: fit-content;
  transition: all var(--transition-fast);
}

.memory-verified-badge:hover {
  background: #bbf7d0 !important;
  border-color: #059669 !important;
  color: #064e3b !important;
  transform: translateY(-1px);
}

.memory-verified-note {
  font-size: 11.5px;
  color: #166534 !important;
  font-style: italic;
  margin-left: 2px;
}

/* Distinct Verified Family Addition in Narrative Area */
.verified-narrative-line {
  background: #ecfdf5 !important;
  border: 1.5px solid #a7f3d0 !important;
  border-left: 4px solid #059669 !important;
  border-radius: 8px;
  padding: 13px 16px;
  margin: 14px 0;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.06);
  transition: all 0.3s ease;
}

.verified-line-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #065f46 !important;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

.verified-line-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: #064e3b !important;
  font-weight: 500;
  margin: 0 !important;
}

@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    border-color: #10b981;
  }
  70% {
    box-shadow: 0 0 0 12px rgba(16, 185, 129, 0);
    border-color: #34d399;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.highlight-pulse {
  animation: highlightPulse 2s ease-out;
}

/* ==========================================================================
   VIEW 6: Ask AI Family Archivist
   ========================================================================== */

#archivist-view {
  overflow-y: auto;
  background: var(--bg-app);
  padding: 24px 32px;
  display: none;
  height: calc(100vh - var(--header-height));
}

#archivist-view.active {
  display: block;
}

.archivist-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: calc(100vh - var(--header-height) - 48px);
}

.archivist-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.archivist-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}

.archivist-title-group h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.archivist-title-group p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 620px;
}

.archivist-guardrail-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Chat Box Container */
.archivist-chat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  min-height: 0;
}

/* Suggestions bar */
.archivist-suggestions {
  padding: 12px 20px;
  background: #f7f2ea;
  border-bottom: 1px solid rgba(90, 70, 45, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.suggestion-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
}

.chip-btn:hover {
  background: var(--bg-card-hover);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

/* Scrollable Messages Container */
.archivist-messages {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 88%;
  animation: messageFadeIn 0.25s ease-out;
}

@keyframes messageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.assistant-message {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f4eee2;
  border: 1.5px solid #b45309;
  color: #b45309;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.08);
}

.user-message .message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f4eee2;
  border: 1.5px solid #b45309;
  color: #b45309;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.08);
}

.message-bubble {
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
}

.assistant-message .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  border-top-left-radius: 4px;
}

.user-message .message-bubble {
  background: #b47a28;
  color: #ffffff;
  border-top-right-radius: 4px;
}

.message-bubble p {
  margin-bottom: 8px;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble ul, .message-bubble ol {
  margin: 6px 0 8px 18px;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble strong {
  color: var(--accent-gold);
}

.assistant-message .message-bubble a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Typing / Loading Indicator */
.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
}

.loading-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Form */
.archivist-input-wrapper {
  padding: 14px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.archivist-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.archivist-form textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  line-height: 1.4;
  outline: none;
  transition: border-color var(--transition-fast);
}

.archivist-form textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(180, 122, 40, 0.2);
}

.archivist-form button {
  height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.archivist-footer-note {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Floating AI Button */
.floating-ai-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 850;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #b47a28 0%, #8f5e1b 100%);
  color: #ffffff;
  border: 1px solid rgba(180, 122, 40, 0.4);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4), 0 2px 6px rgba(0,0,0,0.3);
  transition: all var(--transition-normal);
}

.floating-ai-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(2, 132, 199, 0.6), 0 4px 10px rgba(0,0,0,0.4);
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
}

.floating-ai-icon {
  font-size: 17px;
}

/* ==========================================================================
   Floating AI Chat Widget (Corner Window)
   ========================================================================== */

.ai-chat-widget {
  position: fixed;
  bottom: 82px;
  right: 24px;
  width: 410px;
  height: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 110px);
  background: rgba(255, 253, 248, 0.98);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  z-index: 890;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: widgetSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes widgetSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f5efe4;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.ai-widget-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  margin-bottom: 2px;
}

.ai-widget-title-group h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-sans);
}

.ai-widget-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-widget-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-widget-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.ai-widget-guardrail-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  padding: 6px 14px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
  flex-shrink: 0;
}

.ai-widget-suggestions {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding: 8px 12px;
  background: #f7f2ea;
  border-bottom: 1px solid rgba(90, 70, 45, 0.12);
  flex-shrink: 0;
  scrollbar-width: none;
}

.ai-widget-suggestions::-webkit-scrollbar {
  display: none;
}

.widget-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  font-family: inherit;
  flex-shrink: 0;
}

.widget-chip:hover {
  background: var(--bg-card-hover);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.ai-widget-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-widget-messages .chat-message {
  max-width: 92%;
}

.ai-widget-messages .message-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
}

.ai-widget-input-wrapper {
  padding: 10px 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.ai-widget-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-widget-form textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  min-height: 38px;
  max-height: 80px;
  line-height: 1.4;
  outline: none;
}

.ai-widget-form textarea:focus {
  border-color: var(--accent-primary);
}

.ai-widget-form button {
  height: 38px;
  width: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .ai-chat-widget {
    bottom: 74px;
    right: 12px;
    left: 12px;
    width: auto;
    height: calc(100vh - 90px);
  }
}

@media (max-width: 768px) {
  #archivist-view {
    padding: 16px;
  }
  .archivist-header {
    flex-direction: column;
    padding: 14px;
  }
  .floating-ai-btn {
    bottom: 16px;
    right: 16px;
    padding: 8px 14px;
    font-size: 12px;
  }
}

/* ==========================================================================
   Print Stylesheet
   ========================================================================== */

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
  }

  .app-header, .focus-pill, .tree-legend-strip, .canvas-actions, .drawer-backdrop, .drawer-actions {
    display: none !important;
  }

  .detail-drawer {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  .story-content, .vitals-grid, .highlights-list {
    color: #000000 !important;
  }
}


/* ==========================================================================
   Mobile & iPad Tablet Enhancements (Warm Archival Layout)
   ========================================================================== */

/* Mobile Bottom Navigation Bar (Hidden on desktop, visible on <= 768px) */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body {
    padding-bottom: 60px; /* Space for bottom nav */
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    z-index: 280;
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(44, 32, 20, 0.08);
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 4px 0;
  }

  .mobile-nav-btn svg {
    stroke-width: 2.2;
    transition: transform var(--transition-fast);
  }

  .mobile-nav-btn.active {
    color: var(--accent-primary);
  }

  .mobile-nav-btn.active svg {
    transform: scale(1.1);
  }

  /* Compact Header on Mobile: Hide large tabs in header */
  .view-tabs {
    display: none !important;
  }

  .header-main {
    height: 48px;
    padding: 0 12px;
  }

  .brand-text h1 {
    font-size: 13.5px;
  }

  .brand-subtitle {
    display: none;
  }

  .tree-toolbar {
    height: auto;
    padding: 8px 12px;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .search-box {
    width: 170px;
  }

  /* Detail Drawer as Mobile Bottom Sheet */
  .detail-drawer {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -8px 30px rgba(44, 32, 20, 0.2);
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom, 14px);
  }

  .detail-drawer.open {
    transform: translateY(0);
  }

  .drawer-drag-handle {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 9999px;
    background: rgba(68, 54, 38, 0.25);
    margin: 8px auto 2px auto;
    flex-shrink: 0;
  }

  .floating-ai-btn {
    bottom: 72px;
    right: 14px;
    padding: 8px 14px;
    font-size: 12px;
  }
}

/* iPad / Tablet Specific Optimizations (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .detail-drawer {
    width: 400px;
    max-width: 85vw;
    border-radius: 16px 0 0 16px;
    box-shadow: -10px 0 35px rgba(44, 32, 20, 0.16);
  }

  .view-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 6px 10px;
    font-size: 11.5px;
  }

  /* Generous 44px Touch Targets */
  .btn, .tab-btn, .filter-select, .nav-branch-select {
    min-height: 38px;
  }
}

/* ==========================================================================
   FASCINATING ARCHIVAL DISCOVERY & MILESTONES
   ========================================================================== */
.discovery-section {
  margin-bottom: 20px;
}

.discovery-card {
  background: linear-gradient(135deg, rgba(254, 252, 246, 0.98), rgba(249, 245, 235, 0.95));
  border: 1.5px solid #d4af37;
  border-left: 5px solid #d4af37;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.12);
  position: relative;
  overflow: hidden;
}

.discovery-card::after {
  content: "★";
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 48px;
  color: rgba(212, 175, 55, 0.08);
  pointer-events: none;
  line-height: 1;
}

.discovery-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.discovery-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #d4af37;
  color: #1a160d;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 12px;
}

.discovery-title {
  font-size: 15px;
  font-weight: 700;
  color: #5c4418;
  margin: 0;
  font-family: var(--font-heading, inherit);
}

.discovery-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: #332a1e;
  margin: 0;
}

/* Enhanced Milestone Tag Pills */
.tag-pill.milestone-veteran {
  background: rgba(30, 58, 138, 0.12);
  color: #1e3a8a;
  border: 1px solid rgba(30, 58, 138, 0.3);
  font-weight: 600;
}

.tag-pill.milestone-heirloom {
  background: rgba(180, 83, 9, 0.12);
  color: #b45309;
  border: 1px solid rgba(180, 83, 9, 0.3);
  font-weight: 600;
}

.tag-pill.milestone-record {
  background: rgba(13, 148, 136, 0.12);
  color: #0d9488;
  border: 1px solid rgba(13, 148, 136, 0.3);
  font-weight: 600;
}

.tag-pill.milestone-maritime {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border: 1px solid rgba(2, 132, 199, 0.3);
  font-weight: 600;
}

/* ==========================================================================
   Full story in the drawer: lead line, How we know, Still open, chronicles
   ========================================================================== */
.story-content .story-lead {
  font-family: var(--font-serif);
  font-size: 16px;
  font-style: italic;
  color: var(--accent-primary-hover);
  border-left: 3px solid var(--accent-gold);
  padding-left: 12px;
}

.story-subhead {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin: 18px 0 8px;
}

.story-list {
  margin: 0 0 4px 18px;
  padding: 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.story-list li {
  margin-bottom: 6px;
}

.drawer-chronicles-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-chronicle {
  background: #ffffff;
  border: 1.5px solid rgba(80, 60, 40, 0.18);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: 0 2px 6px rgba(60, 45, 25, 0.05);
}

.drawer-chronicle-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.drawer-chronicle-title {
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--text-main);
  line-height: 1.35;
}

.drawer-chronicle-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.drawer-chronicle-hook {
  font-size: 13.5px;
  line-height: 1.6;
  color: #334155;
  margin: 8px 0 10px;
}

.drawer-chronicle-body {
  font-size: 14px;
  line-height: 1.75;
  color: #1e293b;
  border-top: 1px solid var(--border-color);
  margin-top: 12px;
  padding-top: 12px;
}

.drawer-chronicle-body p {
  margin-bottom: 12px;
}

.drawer-chronicle-people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drawer-chronicle-person {
  cursor: pointer;
  font: inherit;
}

.chronicle-grade {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}

.chronicle-grade.grade-proven { background: #dcfce7; color: #166534; }
.chronicle-grade.grade-probable { background: #dbeafe; color: #1e40af; }
.chronicle-grade.grade-possible { background: #fef3c7; color: #92400e; }
.chronicle-grade.grade-lead { background: #fee2e2; color: #991b1b; }
.chronicle-grade.grade-family-memory { background: #f3e8ff; color: #6b21a8; }

/* Discoveries built from chronicles: paragraphs and a "Read the full story" fold */
.discovery-story p { margin: 0 0 10px; }
.discovery-story p:last-child { margin-bottom: 0; }
.discovery-more { margin-top: 6px; }
.discovery-more summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 10px;
}
.discovery-more[open] summary { margin-bottom: 12px; }

/* ==========================================================================
   PERSPECTIVE / "VIEWING AS" CONTROLS
   ========================================================================== */
.viewing-as-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-viewing-as {
  height: 32px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1.5px solid rgba(180, 83, 9, 0.35);
  border-radius: var(--radius-sm);
  color: #0f172a;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.05);
}

.btn-viewing-as:hover, .btn-viewing-as.open {
  border-color: #b45309;
  color: #b45309;
  background: #fffdfa;
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.15);
}

.viewing-as-icon {
  font-size: 13px;
  line-height: 1;
}

.viewing-as-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.viewing-as-name {
  font-weight: 600;
  color: #b45309;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewing-as-arrow {
  transition: transform var(--transition-fast);
  color: #b45309;
}

.btn-viewing-as.open .viewing-as-arrow {
  transform: rotate(180deg);
}

.viewing-as-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 350px;
  max-height: 480px;
  background: #ffffff;
  border: 1.5px solid rgba(180, 83, 9, 0.35);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 10px 25px rgba(60, 45, 25, 0.12);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
}

.viewing-as-header {
  border-bottom: 1px solid rgba(68, 54, 38, 0.1);
  padding-bottom: 8px;
}

.viewing-as-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.viewing-as-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.viewing-as-search-wrap {
  position: relative;
}

.viewing-as-search-wrap input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.viewing-as-search-wrap input:focus {
  border-color: #b45309;
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.15);
}

.viewing-as-search-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 190px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgba(180, 83, 9, 0.3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 1010;
  padding: 4px;
}

.viewing-as-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 11.5px;
  transition: background var(--transition-fast);
}

.viewing-as-search-item:hover {
  background: rgba(180, 83, 9, 0.08);
}

.viewing-as-quick-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.viewing-as-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.viewing-as-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.viewing-as-chip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid rgba(68, 54, 38, 0.12);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.viewing-as-chip:hover {
  background: rgba(180, 83, 9, 0.06);
  border-color: rgba(180, 83, 9, 0.3);
}

.viewing-as-chip.active {
  background: rgba(180, 83, 9, 0.12);
  border-color: #b45309;
  color: #92400e;
  font-weight: 600;
}

.viewing-as-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(68, 54, 38, 0.1);
  padding-top: 8px;
  font-size: 11px;
}

.viewing-as-persist-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.viewing-as-persist-check input {
  cursor: pointer;
}

/* Relationship Badge */
.badge-relation {
  background: rgba(180, 83, 9, 0.12) !important;
  color: #b45309 !important;
  border: 1px solid rgba(180, 83, 9, 0.3) !important;
  font-weight: 600 !important;
  letter-spacing: 0.2px;
}

#drawer-set-home-btn.active {
  background: rgba(180, 83, 9, 0.12);
  color: #b45309;
  border-color: #b45309;
  font-weight: 600;
}

/* Global Floating Toast */
#app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   PERSONAL WELCOME BANNER & GOLDEN PATH
   ========================================================================== */
.personal-welcome-banner {
  background: linear-gradient(135deg, rgba(254, 243, 199, 0.95), rgba(255, 255, 255, 0.98));
  border-bottom: 1.5px solid rgba(180, 83, 9, 0.25);
  box-shadow: 0 4px 12px rgba(60, 45, 25, 0.06);
  padding: 10px 18px;
  position: relative;
  z-index: 40;
  transition: all 0.3s ease;
}

.welcome-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.welcome-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.welcome-banner-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #b45309;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #92400e;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.2);
}

.welcome-banner-greeting {
  font-size: 14px;
  font-weight: 700;
  color: #78350f;
  line-height: 1.25;
}

.welcome-banner-stats {
  font-size: 12px;
  color: #92400e;
  margin-top: 2px;
  line-height: 1.35;
}

.welcome-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-golden-path {
  background: #ffffff;
  border: 1.5px solid #b45309 !important;
  color: #b45309 !important;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-golden-path:hover, .btn-golden-path.active {
  background: #b45309 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.25);
}

.welcome-banner-close {
  background: none;
  border: none;
  font-size: 16px;
  color: #92400e;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: background 0.2s;
  line-height: 1;
}

.welcome-banner-close:hover {
  background: rgba(180, 83, 9, 0.15);
}

/* Golden Path Lineage Highlights */
.dimmed-lineage-node {
  opacity: 0.15 !important;
  filter: grayscale(85%) !important;
  transition: opacity 0.35s ease, filter 0.35s ease;
}

.dimmed-lineage-node:hover {
  opacity: 0.75 !important;
  filter: grayscale(10%) !important;
}

.golden-lineage-node {
  border-color: #b45309 !important;
  box-shadow: 0 0 0 2.5px rgba(180, 83, 9, 0.5), 0 8px 24px rgba(180, 83, 9, 0.2) !important;
  transform: translateZ(0);
}

.tree-link.dimmed-link {
  opacity: 0.08 !important;
  transition: opacity 0.35s ease;
}

.tree-link.golden-link {
  stroke: #b45309 !important;
  stroke-width: 2.5px !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 3px rgba(180, 83, 9, 0.3));
}

/* Personal badge on discovery cards */
.discovery-personal-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(180, 83, 9, 0.12);
  color: #b45309;
  border: 1px solid rgba(180, 83, 9, 0.3);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}

/* Pedigree Keepsake Modal */
.pedigree-modal {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 960px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
  display: flex;
  flex-direction: column;
}

.pedigree-chart-printable {
  padding: 24px 32px;
  color: #0f172a;
}

.pedigree-print-header {
  text-align: center;
  border-bottom: 2px solid #b45309;
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.pedigree-print-title {
  font-size: 22px;
  font-weight: 800;
  color: #78350f;
  margin: 0;
}

.pedigree-print-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.pedigree-tree-grid {
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.pedigree-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
  gap: 10px;
}

.pedigree-col-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b45309;
  text-align: center;
  margin-bottom: 4px;
}

.pedigree-box {
  background: #fffdfa;
  border: 1.5px solid rgba(180, 83, 9, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.35;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.pedigree-box.focus-person {
  border: 2px solid #b45309;
  background: #fef3c7;
}

.pedigree-box-name {
  font-weight: 700;
  color: #1e293b;
  font-size: 12px;
}

.pedigree-box-dates {
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
}

.pedigree-box-branch {
  font-size: 9.5px;
  color: #92400e;
  font-weight: 600;
  margin-top: 2px;
}

/* Gallery Modal */
.gallery-modal {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
  display: flex;
  flex-direction: column;
}

.gallery-modal-body {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.gallery-photo-card {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fffdfa;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-photo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.gallery-photo-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f1f5f9;
}

.gallery-photo-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gallery-photo-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
}

.gallery-photo-rel {
  font-size: 10.5px;
  font-weight: 600;
  color: #b45309;
}

.gallery-photo-caption {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}

/* Print CSS */
@media print {
  body * {
    visibility: hidden;
  }
  #pedigree-modal-backdrop, #pedigree-chart-printable, #pedigree-chart-printable * {
    visibility: visible;
  }
  #pedigree-modal-backdrop {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: none !important;
    display: block !important;
  }
  .no-print {
    display: none !important;
  }
  .pedigree-modal {
    max-width: 100%;
    box-shadow: none;
    border: none;
  }
}


