/* Briney Family Tree — styles
   Light/dark theming via data-theme on <html>. Print CSS at bottom. */

:root {
  --bg: #fbfaf7;
  --bg-elev: #ffffff;
  --bg-sunken: #f3f0e8;
  --fg: #1c1a17;
  --fg-muted: #5e5a52;
  --fg-faint: #8a857c;
  --border: #e2ddd0;
  --border-strong: #c9c1ad;
  --accent: #7a2e1a;
  --accent-hover: #9a3a22;
  --link: #2a5c8f;

  /* Confidence tier colors */
  --t-a: #2f8a3e;
  --t-b: #3872c2;
  --t-c: #c79a26;
  --t-d: #8a857c;
  --t-e: #b24a3a;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --font-serif: "Iowan Old Style", "Hoefler Text", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #1a1916;
  --bg-elev: #23211d;
  --bg-sunken: #15140f;
  --fg: #ece8dd;
  --fg-muted: #a39d8f;
  --fg-faint: #6c6759;
  --border: #35322b;
  --border-strong: #4a463c;
  --accent: #e08166;
  --accent-hover: #f09a83;
  --link: #7cb0e0;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ===== Header ===== */
.site-header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.primary-nav {
  display: flex;
  gap: 1.25rem;
  margin-left: auto;
}
.primary-nav a {
  color: var(--fg-muted);
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
.primary-nav a.active,
.primary-nav a:hover {
  color: var(--fg);
  border-color: var(--accent);
  text-decoration: none;
}
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
}
.theme-toggle:hover { background: var(--bg-sunken); }

/* Hamburger toggle (hidden by default, shown on narrow screens) */
.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.nav-toggle span {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: var(--fg);
  border-radius: 1px;
  transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Collapse nav to hamburger when items don't fit (~900px) */
@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  .primary-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-left: 0;
    padding: 0.5rem 0;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 99;
  }
  .primary-nav.open { display: flex; }
  .primary-nav a {
    padding: 0.75rem 1.25rem;
    border-bottom: none;
    border-left: 3px solid transparent;
  }
  .primary-nav a.active,
  .primary-nav a:hover {
    border-bottom: none;
    border-left-color: var(--accent);
    background: var(--bg-sunken);
  }
  .nav-random-btn {
    align-self: flex-start;
    margin: 0.25rem 1rem;
  }
  .site-header .wrap { position: relative; }
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 1rem 0;
  color: var(--fg-muted);
  font-size: 0.85rem;
}
.tier-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin: 0 0.15rem 0 0.5rem;
  vertical-align: middle;
}
.t-A { background: var(--t-a); }
.t-B { background: var(--t-b); }
.t-C { background: var(--t-c); }
.t-D { background: var(--t-d); }
.t-E { background: var(--t-e); }
.tier-count { font-size: 0.8em; opacity: 0.75; }
.footer-links { margin: 0.4rem 0 0; font-size: 0.78rem; opacity: 0.8; }
.footer-links a { color: var(--fg-muted); text-decoration: none; border-bottom: 1px dotted var(--border); }
.footer-links a:hover { color: var(--fg); border-bottom-color: var(--fg-muted); }
.footer-sep { margin: 0 0.5rem; opacity: 0.5; }

.archives-view .card { max-width: 820px; }
.archive-entry { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.archive-entry h2 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.archive-meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; font-size: 0.9rem; }
.archive-meta dt { font-weight: 600; color: var(--fg-muted); }
.archive-meta dd { margin: 0; }

.lines-view .card { max-width: 1100px; }
.lines-table-wrap { overflow-x: auto; margin-top: 1rem; }
.lines-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.lines-table th, .lines-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.lines-table th { font-weight: 600; color: var(--fg-muted); position: sticky; top: 0; background: var(--bg); }
.lines-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.lines-table tr:hover { background: var(--bg-elev); }
.lines-table .line-tag { font-size: 0.8rem; color: var(--fg-muted); }
.lines-table .faint { color: var(--fg-muted); font-size: 0.85em; }
.lines-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.lines-table th.sortable:hover { color: var(--fg); }
.lines-table th.sortable.sorted { color: var(--fg); }
.lines-table th.sortable:focus { outline: 2px solid var(--accent, #4a90e2); outline-offset: -2px; }
.line-summary { font-size: 0.95rem; color: var(--fg-muted); }

/* ===== Famous Cousins ===== */
.cousins-view .card { max-width: 1200px; }
.cousin-card { margin: 1.75rem 0; padding: 1.25rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); }
.cousin-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.cousin-header h2 { margin: 0 0 0.25rem; font-size: 1.3rem; }
.cousin-meta { margin: 0; font-size: 0.85rem; color: var(--fg-muted); }
.cousin-rel { background: var(--accent, #5c6bc0); color: white; padding: 0.35rem 0.75rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.cousin-summary { margin: 0.75rem 0 1rem; font-size: 0.95rem; line-height: 1.5; }
.cousin-chains { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: stretch; }
.cousin-side h3 { margin: 0 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); font-weight: 600; }
.cousin-common { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 180px; }
.common-marker { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); margin-bottom: 0.4rem; }
.chain { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.chain-step { padding: 0.35rem 0.6rem; margin-bottom: 0.25rem; border-left: 2px solid var(--border); background: var(--bg); border-radius: 0 4px 4px 0; }
.chain-step a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--fg-muted); }
.chain-step a:hover { border-bottom-style: solid; }
.chain-step .chain-years { display: block; font-size: 0.75rem; color: var(--fg-muted); margin-top: 0.1rem; }
.chain-step.common { border-left-color: gold; background: rgba(255, 215, 0, 0.12); border-radius: 6px; padding: 0.6rem 0.8rem; text-align: center; }
.chain-step.ellipsis { font-style: italic; color: var(--fg-muted); border-left-style: dashed; }
@media (max-width: 800px) {
  .cousin-chains { grid-template-columns: 1fr; }
  .cousin-common { min-width: 0; padding: 0.5rem 0; }
}

/* ===== Main ===== */
#app {
  flex: 1;
  padding: 1.5rem 1.25rem 3rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Loading spinner */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 0;
  color: var(--fg-muted);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Generic cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

h1, h2, h3 { font-family: var(--font-serif); margin-top: 0; }
h1 { font-size: 1.9rem; margin-bottom: 0.4rem; }
h2 { font-size: 1.3rem; margin-bottom: 0.6rem; color: var(--fg); }
h3 { font-size: 1.05rem; margin-bottom: 0.35rem; }

.muted { color: var(--fg-muted); font-size: 0.95rem; }
.faint { color: var(--fg-faint); font-size: 0.85rem; }

/* ===== Tier badges ===== */
.tier-badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  vertical-align: middle;
}
/* Relationship badge */
.rel-badge {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  vertical-align: middle;
  margin-left: 0.4rem;
}
.rel-badge.ancestor { background: rgba(47,138,62,0.1); border-color: var(--t-a); color: var(--t-a); }
.rel-badge.cousin { background: rgba(56,114,194,0.1); border-color: var(--t-b); color: var(--t-b); }
.rel-badge.family { background: rgba(122,46,26,0.08); border-color: var(--accent); color: var(--accent); }
.rel-badge.self { background: rgba(199,154,38,0.12); border-color: var(--t-c); color: var(--t-c); }

.age-text { color: var(--fg-muted); font-size: 0.9rem; }

/* Relationship trace — shows the chain of connections from Matt to this person */
.rel-trace-card { padding-bottom: 0.75rem; }
.rel-trace-heading {
  margin: 0 0 0.85rem 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg-muted);
}
.rel-trace-heading strong { color: var(--fg); font-weight: 600; }
.rel-trace-hops { color: var(--fg-muted); font-weight: 400; font-size: 0.88rem; }
.rel-trace-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}
.rel-trace-item {
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sunken);
  transition: border-color 0.15s;
}
.rel-trace-item:hover { border-color: var(--accent); }
.rel-trace-item.is-matt {
  background: rgba(199,154,38,0.12);
  border-color: var(--t-c);
}
.rel-trace-item.is-target {
  background: rgba(56,114,194,0.12);
  border-color: var(--t-b);
}
.rel-trace-name { font-weight: 600; font-size: 0.95rem; }
.rel-trace-name a { color: var(--fg); text-decoration: none; }
.rel-trace-name a:hover { color: var(--accent); text-decoration: underline; }
.rel-trace-life {
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin-top: 0.1rem;
}
.rel-trace-you {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-weight: 400;
  margin-left: 0.25rem;
}
.rel-trace-edge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0 0.25rem 0.85rem;
  color: var(--fg-muted);
  font-size: 0.8rem;
  position: relative;
}
.rel-trace-edge::before {
  content: "";
  position: absolute;
  left: 1.35rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.rel-trace-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  line-height: 1;
  color: var(--fg-muted);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.rel-trace-edge-label {
  font-style: italic;
  background: var(--bg);
  padding: 0 0.25rem;
  z-index: 1;
  position: relative;
}
/* A very long chain can get tall — cap height & allow scroll so the profile page isn't dominated by it. */
.rel-trace-card .rel-trace-list {
  max-height: 28rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}


.tier-badge.A { background: var(--t-a); }
.tier-badge.B { background: var(--t-b); }
.tier-badge.C { background: var(--t-c); color: #2a230a; }
.tier-badge.D { background: var(--t-d); }
.tier-badge.E { background: var(--t-e); }

/* ===== Pedigree chart ===== */
.pedigree-view h1 { margin-bottom: 0.25rem; }
.pedigree-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.btn {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.btn:hover { background: var(--bg-sunken); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.pedigree-scroll {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  overflow-x: auto;
}
.pedigree-tree {
  display: flex;
  gap: 0.5rem;
  min-height: 600px;
  align-items: stretch;
}
.pedigree-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 0.5rem;
  min-width: 180px;
}
.pedigree-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--fg-faint);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
  min-height: 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.pedigree-box:hover { transform: translateX(2px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.pedigree-box.focus { border-left-color: var(--accent); background: var(--bg-elev); outline: 2px solid var(--accent); }
.pedigree-box .name { font-weight: 600; color: var(--fg); }
.pedigree-box .dates { font-size: 0.75rem; color: var(--fg-muted); }
.pedigree-box.empty {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--fg-faint);
  cursor: default;
  box-shadow: none;
  font-style: italic;
  font-size: 0.8rem;
}
.pedigree-box.empty:hover { transform: none; border-color: var(--border); }
.pedigree-box.tier-A { border-left-color: var(--t-a); }
.pedigree-box.tier-B { border-left-color: var(--t-b); }
.pedigree-box.tier-C { border-left-color: var(--t-c); }
.pedigree-box.tier-D { border-left-color: var(--t-d); }
.pedigree-box.tier-E { border-left-color: var(--t-e); }

/* Pedigree family panel (siblings, spouses, children) */
.pedigree-family-panel {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.pedigree-family-panel h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}
.pedigree-family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.family-group h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin: 0 0 0.4rem;
}
.family-group h3 .count { font-weight: 400; }
.family-list { display: flex; flex-direction: column; gap: 0.25rem; }
.family-member {
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.5rem;
  border-left: 2px solid var(--border);
  cursor: pointer;
  border-radius: 0 0.25rem 0.25rem 0;
  transition: background 0.15s, border-color 0.15s;
}
.family-member:hover { background: var(--bg); border-left-color: var(--accent); }
.family-member .name { font-weight: 500; font-size: 0.9rem; color: var(--fg); }
.family-member .dates { font-size: 0.75rem; color: var(--fg-muted); }

/* ===== Migration Timeline ===== */
/* Migration Map */
.migration-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.migration-header h2 { margin: 0; }
.migration-play-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.migration-play-btn.playing {
  background: var(--t-e);
  color: #fff;
}
.migration-map {
  height: 280px;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 0;
}
.migration-map .leaflet-control-layers { font-size: 0.75rem; }

/* Active timeline stop during animation */
.migration-stop.active-stop {
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 2px var(--accent);
  transition: box-shadow 0.3s ease;
}

/* Global map animation status */
.map-anim-status {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.map-anim-bar {
  display: inline-block;
  width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
}
.map-anim-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.migration-marker { background: none !important; border: none !important; }
.migration-marker-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border: 2.5px solid;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  line-height: 1;
}
.migration-arrow { background: none !important; border: none !important; }

/* Traveling dot animation */
.travel-dot-icon { background: none !important; border: none !important; }
.travel-dot-pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ff6f00;
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(255, 111, 0, 0.6), 0 1px 4px rgba(0,0,0,0.4);
  animation: dot-pulse 1s ease-in-out infinite;
}
.global-travel-dot .travel-dot-pulse {
  width: 10px;
  height: 10px;
  border-width: 1.5px;
}
@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 111, 0, 0.6), 0 1px 4px rgba(0,0,0,0.4); }
  50%  { box-shadow: 0 0 0 8px rgba(255, 111, 0, 0), 0 1px 4px rgba(0,0,0,0.4); }
  100% { box-shadow: 0 0 0 0 rgba(255, 111, 0, 0.6), 0 1px 4px rgba(0,0,0,0.4); }
}

.migration-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 0.25rem;
}
.migration-stop {
  display: flex;
  align-items: flex-start;
  position: relative;
  padding-left: 1.5rem;
  min-height: 2.5rem;
}
.migration-dot {
  position: absolute;
  left: 0;
  top: 0.35rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  box-shadow: 0 0 0 1px var(--accent);
  z-index: 1;
}
.migration-stop.birth .migration-dot { background: var(--t-a); box-shadow: 0 0 0 1px var(--t-a); }
.migration-stop.death .migration-dot { background: var(--t-e); box-shadow: 0 0 0 1px var(--t-e); }
.migration-stop.burial .migration-dot { background: var(--fg-muted); box-shadow: 0 0 0 1px var(--fg-muted); }
.migration-line {
  position: absolute;
  left: 0.27rem;
  top: 1rem;
  bottom: -0.5rem;
  width: 2px;
  background: var(--border);
}
.migration-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  padding-bottom: 0.5rem;
}
.migration-year {
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 2.5rem;
  color: var(--fg);
}
.migration-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  min-width: 3rem;
}
.migration-place {
  font-size: 0.9rem;
  color: var(--fg);
}
.migration-modern {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--fg-muted);
}
.migration-modern::before { content: "(now "; }
.migration-modern::after { content: ")"; }

/* ===== Profile ===== */
.profile-view h1 { font-family: var(--font-serif); }
.profile-meta {
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
.profile-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 800px) { .profile-grid { grid-template-columns: 1fr; } }

.external-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.external-link {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}
.external-link:hover { opacity: 0.8; }
.external-wikipedia {
  background: #f0f0f0;
  color: #36c;
}
.external-wikitree {
  background: #e8f5e9;
  color: #2e7d32;
}
@media (prefers-color-scheme: dark) {
  .external-wikipedia { background: #1a1a2e; color: #8ab4f8; }
  .external-wikitree { background: #1b2e1b; color: #81c784; }
}

.bio-text {
  font-family: var(--font-serif);
  font-size: 1.03rem;
  line-height: 1.7;
  color: var(--fg);
}
.bio-text p { margin: 0 0 1rem 0; }
.bio-text a { color: var(--link); word-break: break-all; }
.bio-section-head {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg);
  margin: 1.75rem 0 .65rem;
  padding: .35rem 0 .35rem .7rem;
  border-left: 3px solid var(--link);
  border-bottom: 1px solid var(--border);
  line-height: 1.3;
}
.bio-section-head:first-child { margin-top: .25rem; }
/* First-child paragraph after a section head should hug the head */
.bio-section-head + p { margin-top: 0; }
/* SUMMARY gets a slightly brighter accent since it's the lead */
.bio-section-summary { border-left-color: var(--accent, #f6b93b); }

.relations-list { list-style: none; padding: 0; margin: 0; }
.relations-list li {
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
}
.relations-list li:last-child { border-bottom: none; }
.relation-label {
  display: inline-block;
  width: 90px;
  color: var(--fg-faint);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.research-box {
  background: rgba(199,154,38,0.08);
  border-left: 3px solid var(--t-c);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

/* ===== Family Group Sheet ===== */
.fgs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}
.fgs-table th,
.fgs-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.fgs-table th {
  background: var(--bg-sunken);
  font-weight: 600;
  color: var(--fg-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Search ===== */
.search-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}
.search-mode-btn {
  padding: 0.45rem 1.1rem;
  border: none;
  background: var(--bg-elev);
  color: var(--fg-muted);
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.search-mode-btn:not(:last-child) {
  border-right: 1px solid var(--border-strong);
}
.search-mode-btn.active {
  background: var(--accent);
  color: #fff;
}
.search-mode-btn:hover:not(.active) {
  background: var(--bg-sunken);
}

.search-controls {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 700px) { .search-controls { grid-template-columns: 1fr; } }

.search-controls input,
.search-controls select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
}
.search-results {
  display: grid;
  gap: 0.5rem;
}
.search-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--fg);
}
.search-result:hover {
  border-color: var(--accent);
  background: var(--bg-sunken);
  text-decoration: none;
}
.search-result .name { font-weight: 600; flex: 1; }
.search-result .dates { color: var(--fg-muted); font-size: 0.85rem; }
.search-snippet {
  width: 100%;
  font-size: 0.82rem;
  color: var(--fg-muted);
  font-style: italic;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Map ===== */
.map-view .card { padding: 1rem 1.25rem; }
#leaflet-map {
  width: 100%;
  height: 560px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}
.map-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.map-controls label { font-size: 0.85rem; color: var(--fg-muted); }
.map-controls select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg);
  font-family: inherit;
}
.map-legend {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--fg-muted);
}
.map-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}
.map-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.map-popup { font-family: var(--font-sans); font-size: 0.85rem; max-width: 240px; }
.map-popup h4 { margin: 0 0 0.3rem 0; font-size: 0.95rem; }
.map-popup ul { margin: 0.25rem 0 0 0; padding-left: 1.1rem; max-height: 160px; overflow-y: auto; }
.map-popup li { margin-bottom: 0.15rem; }
.map-popup a { color: var(--link); }
.map-popup strong a { font-size: 0.95rem; }
.map-rel { font-size: 0.8rem; font-style: italic; color: var(--fg-muted); }
/* MarkerCluster overrides */
.marker-cluster-small { background-color: rgba(122, 174, 130, 0.5); }
.marker-cluster-small div { background-color: rgba(46, 107, 58, 0.6); }
.marker-cluster-medium { background-color: rgba(130, 156, 174, 0.5); }
.marker-cluster-medium div { background-color: rgba(46, 86, 122, 0.6); }
.marker-cluster-large { background-color: rgba(174, 140, 100, 0.5); }
.marker-cluster-large div { background-color: rgba(122, 70, 26, 0.6); }
.marker-cluster div { width: 28px; height: 28px; margin: 6px; border-radius: 50%; text-align: center; }
.marker-cluster span { line-height: 28px; font-size: 12px; font-weight: 600; color: #fff; }

/* ===== Notable People ===== */
.notable-view { max-width: 900px; margin: 0 auto; }
.notable-view > .card { margin-bottom: 1.5rem; }
.notable-section { margin-bottom: .75rem; }

/* Accordion button */
.notable-accordion {
  display: flex;
  align-items: center;
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  cursor: pointer;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--fg);
  transition: background .15s, border-color .15s;
  gap: .6rem;
}
.notable-accordion:hover { background: var(--bg-sunken); border-color: var(--border-strong); }
.notable-accordion-icon { font-size: 1.25rem; flex-shrink: 0; }
.notable-accordion-label { font-weight: 600; flex: 1; text-align: left; }
.notable-accordion-count {
  font-size: .78rem;
  font-weight: 600;
  background: var(--bg-sunken);
  color: var(--fg-muted);
  padding: .15rem .5rem;
  border-radius: 10px;
  min-width: 1.4rem;
  text-align: center;
}
.notable-accordion-chevron {
  width: 10px; height: 10px;
  border-right: 2px solid var(--fg-muted);
  border-bottom: 2px solid var(--fg-muted);
  transform: rotate(45deg);
  transition: transform .2s;
  flex-shrink: 0;
}
.notable-accordion[aria-expanded="true"] .notable-accordion-chevron {
  transform: rotate(-135deg);
}

/* Grid + collapse */
.notable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  padding-top: 1rem;
  transition: max-height .3s ease, opacity .2s ease;
  overflow: hidden;
}
.notable-collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  pointer-events: none;
}
.notable-grid:not(.notable-collapsed) {
  max-height: none;
  opacity: 1;
}
.notable-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.notable-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.notable-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.notable-card-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.notable-card-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.notable-card-header h3 a {
  color: var(--fg);
  text-decoration: none;
}
.notable-card-header h3 a:hover {
  color: var(--accent);
}
.notable-life {
  font-size: 0.8rem;
  color: var(--fg-faint);
}
.notable-relation {
  margin-bottom: 0.35rem;
}
.notable-relation .rel-badge {
  font-size: 0.75rem;
}
.notable-desc {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--fg-muted);
  margin: 0 0 0.5rem 0;
  flex: 1;
}
.notable-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}
.notable-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
}
.notable-card-footer {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.notable-link {
  font-size: 0.8rem;
  color: var(--link);
  text-decoration: none;
}
.notable-link:hover { text-decoration: underline; }
.notable-subtitle { font-size: .82rem; color: var(--accent); font-weight: 600; margin: .25rem 0 .5rem; font-style: italic; }
.notable-link-wiki {
  color: var(--accent);
  font-weight: 500;
}
@media (max-width: 600px) {
  .notable-grid { grid-template-columns: 1fr; }
}

/* ===== Discoveries ===== */
.discoveries-view { max-width: 800px; margin: 0 auto; }
.discoveries-intro { margin-bottom: 1.5rem; }
.discoveries-intro h1 { margin-top: 0; }
.disc-stats { font-size: 0.9rem; color: var(--fg-muted); margin-top: 0.75rem; }

.disc-session { margin-bottom: 2rem; }
.disc-session-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
}
.disc-session-date {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
}
.disc-session-count {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.disc-card-hidden { display: none !important; }
.disc-loadmore-row {
  display: flex;
  justify-content: center;
  margin: 1rem 0 2rem;
}
.disc-loadmore {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.disc-loadmore:hover {
  border-color: var(--accent);
  background: var(--bg);
}
.disc-card {
  display: flex;
  gap: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.disc-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}
.disc-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.disc-card-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
  width: 2.5rem;
  text-align: center;
  padding-top: 0.15rem;
}
.disc-card-body { flex: 1; min-width: 0; }

.disc-card-top { margin-bottom: 0.3rem; }
.disc-category {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.disc-title {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--fg);
}

.disc-person {
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}
.disc-person a {
  color: var(--link);
  font-weight: 500;
  text-decoration: none;
}
.disc-person a:hover { text-decoration: underline; }
.disc-life {
  color: var(--fg-faint);
  margin-left: 0.4rem;
}

.disc-summary {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--fg-muted);
  margin: 0 0 0.75rem;
}

/* Changes table */
.disc-changes {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.disc-changes td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.disc-changes tr:last-child td { border-bottom: none; }
.disc-field {
  font-weight: 600;
  text-transform: capitalize;
  color: var(--fg);
  white-space: nowrap;
  width: 1%;
}
.disc-old {
  color: var(--fg-faint);
  text-decoration: line-through;
}
.disc-arrow {
  color: var(--accent);
  text-align: center;
  width: 1%;
}
.disc-new {
  color: var(--fg);
  font-weight: 500;
}

/* Tags and sources */
.disc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}
.disc-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
}
.disc-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.disc-source-link {
  font-size: 0.78rem;
  color: var(--link);
  text-decoration: none;
}
.disc-source-link:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .disc-card { flex-direction: column; gap: 0.5rem; }
  .disc-card-icon { width: auto; text-align: left; }
}

/* ===== Sidebar ===== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.open { opacity: 1; }

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0,0,0,0.12);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
.sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-family: var(--font-serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-close:hover { background: var(--bg-sunken); }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  -webkit-overflow-scrolling: touch;
}

/* Inside sidebar: flatten cards, tighten spacing */
.sidebar-body .card {
  box-shadow: none;
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.85rem;
}
.sidebar-body h1 { font-size: 1.45rem; }
.sidebar-body h2 { font-size: 1.1rem; }
.sidebar-body .profile-grid {
  grid-template-columns: 1fr;
}
.sidebar-body .bio-text { font-size: 0.95rem; }
.sidebar-body .sidebar-nav-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

/* Pedigree box selected state when sidebar is open */
.pedigree-box.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: var(--bg-sunken);
}

/* ===== About ===== */
.about-view .card { max-width: 780px; }
.about-view p { margin-top: 0; }

/* ===== Random Relative ===== */
.nav-random-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  padding: .2rem .45rem;
  line-height: 1;
  transition: background .15s, border-color .15s;
}
.nav-random-btn:hover { background: var(--bg-sunken); border-color: var(--border-strong); }

.random-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.random-overlay.random-visible { opacity: 1; pointer-events: auto; }

.random-card {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  padding: 2rem 2rem 1.5rem;
  max-width: 440px;
  width: 90vw;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  text-align: center;
  animation: randomSlideIn .25s ease-out;
}
@keyframes randomSlideIn {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.random-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--fg-faint);
  cursor: pointer;
  line-height: 1;
  padding: .2rem .4rem;
}
.random-close:hover { color: var(--fg); }

.random-dice { font-size: 2rem; margin-bottom: .5rem; }

.random-name { margin: 0 0 .25rem; font-size: 1.3rem; }
.random-name a { color: var(--fg); text-decoration: none; }
.random-name a:hover { color: var(--accent); }

.random-life { font-size: .9rem; color: var(--fg-muted); margin-bottom: .2rem; }
.random-occ { font-size: .82rem; color: var(--fg-faint); font-style: italic; margin-bottom: .5rem; }

.random-rel {
  display: inline-block;
  font-size: .82rem;
  font-weight: 600;
  padding: .25rem .75rem;
  border-radius: 12px;
  margin-bottom: .75rem;
}
.random-rel.self { background: var(--accent); color: #fff; }
.random-rel.ancestor { background: #e8f5e9; color: #2e7d32; }
.random-rel.cousin { background: #e3f2fd; color: #1565c0; }
.random-rel.spouse { background: #fff3e0; color: #e65100; }
.random-rel.unknown { background: var(--bg-sunken); color: var(--fg-muted); }
[data-theme="dark"] .random-rel.ancestor { background: #1b3a1e; color: #81c784; }
[data-theme="dark"] .random-rel.cousin { background: #0d2137; color: #64b5f6; }
[data-theme="dark"] .random-rel.spouse { background: #3e2723; color: #ffb74d; }

.random-snippet {
  font-size: .88rem;
  color: var(--fg-muted);
  line-height: 1.55;
  text-align: left;
  margin: 0 0 1rem;
  max-height: 5.5em;
  overflow: hidden;
}

.random-actions {
  display: flex;
  gap: .75rem;
  justify-content: center;
}
.random-btn-profile { background: var(--accent); color: #fff !important; text-decoration: none; }
.random-btn-profile:hover { background: var(--accent-hover); }
.random-btn-again { background: var(--bg-sunken); color: var(--fg); border: 1px solid var(--border); }
.random-btn-again:hover { background: var(--border); }

/* ===== DNA Explorer ===== */
.dna-view { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.dna-header { text-align: center; margin-bottom: 2rem; }
.dna-header h1 { margin: 0 0 .25rem; font-size: 1.8rem; color: var(--fg); }
.dna-subtitle { color: var(--fg-muted); margin: 0; }

.dna-section { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow-sm); }
.dna-section h2 { margin: 0 0 1rem; font-size: 1.3rem; color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: .5rem; }

/* Explainer text */
.dna-explainer { font-size: .92rem; color: var(--fg-muted); line-height: 1.6; margin: 0 0 1.25rem; }

/* Category cards (What's in your DNA) */
.dna-category-grid { display: flex; flex-direction: column; gap: .75rem; }
.dna-category-card { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem; background: var(--bg-sunken); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.dna-category-icon { width: 6px; border-radius: 3px; flex-shrink: 0; align-self: stretch; }
.dna-category-body { flex: 1; }
.dna-category-body strong { font-size: .95rem; }
.dna-category-num { font-size: .78rem; font-weight: 600; color: var(--fg-faint); font-family: monospace; margin-left: .4rem; }
.dna-category-body p { margin: .25rem 0 0; font-size: .85rem; color: var(--fg-muted); line-height: 1.5; }

/* Migration map legend */
.dna-map-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: .75rem; font-size: .82rem; color: var(--fg-muted); }
.dna-map-legend-item { display: flex; align-items: center; gap: .4rem; }
.dna-map-legend-line { display: inline-block; width: 20px; height: 3px; border-radius: 2px; }

/* Haplogroup cards */
.dna-haplo-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.dna-haplo-card { background: var(--bg-sunken); border-radius: var(--radius-md); padding: 1.25rem; border: 1px solid var(--border); }
.dna-haplo-badge { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: .2rem .6rem; border-radius: 10px; margin-bottom: .5rem; }
.dna-haplo-y { background: #e8f5e9; color: #2e7d32; }
.dna-haplo-mt { background: #fff3e0; color: #e65100; }
[data-theme="dark"] .dna-haplo-y { background: #1b3a1e; color: #66bb6a; }
[data-theme="dark"] .dna-haplo-mt { background: #3e2723; color: #ffb74d; }
.dna-haplo-call { font-size: 2rem; font-weight: 800; color: var(--fg); margin-bottom: .5rem; }
.dna-haplo-desc { font-size: .88rem; color: var(--fg-muted); line-height: 1.5; margin: 0 0 .5rem; }
.dna-haplo-migration { font-size: .82rem; color: var(--fg-faint); font-style: italic; margin: 0 0 .75rem; }
.dna-haplo-details { font-size: .82rem; }
.dna-haplo-details summary { cursor: pointer; color: var(--link); font-weight: 600; }
.dna-marker-table { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: .8rem; }
.dna-marker-table th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); padding: .35rem .5rem; color: var(--fg-muted); }
.dna-marker-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
.dna-pos { color: var(--t-a); }
.dna-neg { color: var(--t-e); }

/* Trait groups and cards */
.dna-trait-group { margin-bottom: 1.25rem; }
.dna-trait-group:last-child { margin-bottom: 0; }
.dna-trait-group-title { font-size: 1rem; font-weight: 600; color: var(--fg); margin: 0 0 .75rem; }
.dna-trait-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem; }
.dna-trait-card { display: flex; gap: .75rem; padding: .75rem; background: var(--bg-sunken); border-radius: var(--radius-sm); border: 1px solid var(--border); transition: border-color .15s, box-shadow .15s; }
.dna-trait-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.dna-trait-icon { font-size: 1.5rem; flex-shrink: 0; width: 2rem; text-align: center; line-height: 2rem; }
.dna-trait-info { flex: 1; min-width: 0; }
.dna-trait-label { font-weight: 600; font-size: .88rem; color: var(--fg); }
.dna-trait-pred { font-size: .85rem; color: var(--fg-muted); margin-top: .15rem; }
.dna-trait-detail { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; font-size: .72rem; }
.dna-geno { background: var(--accent); color: #fff; padding: .1rem .4rem; border-radius: 3px; font-family: monospace; font-weight: 600; }
.dna-snp { color: var(--fg-faint); font-family: monospace; }
.dna-conf { padding: .1rem .35rem; border-radius: 3px; font-weight: 600; }
.dna-conf-high { background: #e8f5e9; color: #2e7d32; }
.dna-conf-mod { background: #fff8e1; color: #f57f17; }
.dna-conf-low { background: #fce4ec; color: #c62828; }
[data-theme="dark"] .dna-conf-high { background: #1b3a1e; color: #81c784; }
[data-theme="dark"] .dna-conf-mod { background: #3e3210; color: #ffd54f; }
[data-theme="dark"] .dna-conf-low { background: #3b1a1a; color: #ef9a9a; }

.dna-disclaimer { font-size: .82rem; color: var(--fg-faint); font-style: italic; margin: 0 0 1.25rem; }
.dna-footer-note { background: transparent; border: none; box-shadow: none; padding: .5rem 0; }
.dna-footer-note p { font-size: .78rem; color: var(--fg-faint); text-align: center; margin: 0; }

/* Ancestry Informative Markers (AIM) table */
.dna-aim-wrap { overflow-x: auto; margin: .75rem 0 1rem; }
.dna-aim-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.dna-aim-table th { text-align: left; font-weight: 600; border-bottom: 2px solid var(--border); padding: .5rem .6rem; color: var(--fg-muted); background: var(--bg-sunken); }
.dna-aim-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.dna-aim-table td:first-child { white-space: nowrap; }
.dna-aim-table .dna-geno { font-family: var(--font-mono, monospace); font-weight: 700; text-align: center; color: var(--fg); }
.dna-aim-ancestral { color: #2e7d32; font-weight: 600; }
.dna-aim-derived { color: #c62828; font-weight: 600; }
.dna-aim-het { color: #e65100; font-weight: 600; }
[data-theme="dark"] .dna-aim-ancestral { color: #81c784; }
[data-theme="dark"] .dna-aim-derived { color: #ef9a9a; }
[data-theme="dark"] .dna-aim-het { color: #ffb74d; }
.dna-aim-note { font-size: .78rem; color: var(--fg-muted); line-height: 1.45; }
.dna-aim-conclusion { margin-top: 1rem; padding: 1rem 1.25rem; background: var(--bg-sunken); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.dna-aim-conclusion p { margin: 0 0 .6rem; font-size: .9rem; line-height: 1.55; }
.dna-aim-conclusion p:last-child { margin-bottom: 0; }

@media (max-width: 600px) {
  .dna-haplo-row { grid-template-columns: 1fr; }
  .dna-trait-grid { grid-template-columns: 1fr; }
  .dna-stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Print ===== */
@media print {
  .sidebar, .sidebar-overlay { display: none !important; }
  .site-header, .site-footer, .pedigree-controls, .theme-toggle, .primary-nav, #theme-toggle { display: none !important; }
  body, #app { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none; border: 1px solid #999; page-break-inside: avoid; }
  .bio-text { font-size: 11pt; }
  a { color: #000; text-decoration: underline; }
}

/* -------------------------------------------------------------------------
   Nationality flag chips + Nations view
   ------------------------------------------------------------------------- */
.flag-chips {
  display: inline-flex;
  gap: 0.25rem;
  vertical-align: middle;
  margin-left: 0.35rem;
  font-size: 0.9em;
  line-height: 1;
}
.flag-chip {
  text-decoration: none;
  font-size: 1.1em;
  line-height: 1;
  padding: 0.1rem 0.15rem;
  border-radius: 4px;
  transition: background 0.12s;
}
a.flag-chip:hover { background: var(--bg); }
.notable-card-header .flag-chips { margin-left: 0; }

.nations-view .nations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.nation-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 1rem 0.5rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nation-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.nation-flag { font-size: 2rem; line-height: 1; }
.nation-name { font-weight: 600; font-size: 0.95rem; text-align: center; }
.nation-count {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
}
.nations-people {
  list-style: none;
  padding: 0;
  margin: 0;
}
.nations-people li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.nations-people li:last-child { border-bottom: none; }
.nations-people .nations-life {
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 6rem;
}

/* ---------- Nations/States tab strip ---------- */
.nations-tabs-card { padding: 0.25rem 0.5rem; }
.nations-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.nations-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nations-tab:hover {
  color: var(--text);
  background: var(--bg);
}
.nations-tab.active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- US state tiles ---------- */
.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.state-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  padding: 0.9rem 0.5rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.state-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.state-tile-flag {
  width: 72px;
  height: 48px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
}
.state-tile-name {
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.15;
}
.state-tile-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.state-tile-abbr {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.05rem 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ---------- Inline state chips (list rows, profile-style) ---------- */
.state-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem 0.1rem 0.2rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: border-color 0.15s, background 0.15s;
}
.state-chip:hover {
  border-color: var(--accent);
  background: var(--bg-elev);
}
.state-chip img {
  width: 18px;
  height: 12px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #fff;
}

/* ---------- Single-state header flag ---------- */
.state-header-flag {
  width: 96px;
  height: auto;
  vertical-align: middle;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  margin-right: 0.5rem;
}
.state-header-abbr {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
  color: var(--muted);
  padding: 0.1rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 0.35rem;
}

/* Small state-flag badge (used by renderStateFlag helper) */
.state-flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.state-flag-badge .state-flag-img {
  width: 20px;
  height: 14px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #fff;
}
.state-flag-badge .state-abbr {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.state-flag-badge.size-lg .state-flag-img { width: 36px; height: 24px; }
.state-flag-badge.size-lg .state-abbr { font-size: 0.9rem; }
