/* ============================================================
   THE JOSHUA FINIS SCOTT FAMILY TREE — modern family record
   Clean white, vibrant accents (23andMe-inspired). Elder-first.
   ============================================================ */

:root {
  /* Surfaces — crisp modern white */
  --paper: #FFFFFF;          /* app background */
  --canvas: #F5F7FA;         /* subtle cool section wash */
  --card: #FFFFFF;
  --card-border: #E7EBF0;

  /* Text */
  --ink: #16202C;            /* near-black, 15:1 on white */
  --ink-soft: #5A6875;       /* secondary (7:1) */

  /* Vibrancy — teal/violet 23andMe energy */
  --pine: #0E9C86;           /* primary action (vibrant teal-green) */
  --pine-dark: #0B7D6C;
  --violet: #6C5CE7;         /* secondary accent */
  --violet-soft: #EEEBFD;
  --sky: #2D9CDB;            /* link / info accent */
  --gold: #E08A2B;           /* root/anchor accent (warm, still) */
  --gold-deco: #F0B45E;      /* rings, borders */
  --gold-tint: #FFF4E4;

  /* Feedback */
  --flag-bg: #FFF6E6;
  --flag-ink: #8A5A1A;
  --flag-border: #FBE0B0;
  --danger: #E5484D;
  --success: #0E9C86;
  --focus: #6C5CE7;

  --serif: 'Fraunces', 'Libre Caslon Text', Georgia, serif;
  --sans: 'Inter', 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  --shadow: 0 1px 2px rgba(16, 32, 44, 0.04), 0 4px 16px rgba(16, 32, 44, 0.06);
  --shadow-lift: 0 4px 12px rgba(16, 32, 44, 0.08), 0 12px 32px rgba(16, 32, 44, 0.10);
  --shadow-color: 0 6px 20px rgba(14, 156, 134, 0.18);

  --radius: 16px;
  --radius-sm: 12px;
  --maxw: 820px;
}

* { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.25rem;        /* 20px minimum body */
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}

/* Soft vibrant aura — modern, not paper texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(60vw 40vh at 78% -5%, rgba(108,92,231,0.06), transparent 60%),
    radial-gradient(55vw 40vh at 12% 8%, rgba(14,156,134,0.06), transparent 60%);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; color: var(--ink); letter-spacing: -0.01em; }

a { color: var(--sky); }

img { max-width: 100%; display: block; }

/* ---------- Focus (always visible) ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Layout shell ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--card-border);
}
.app-header .bar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
  margin-right: auto;
  text-decoration: none;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand .mark {
  color: #fff; font-size: 1rem;
  background: linear-gradient(135deg, var(--pine), var(--violet));
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-color);
}

.header-btn {
  min-height: 46px;
  min-width: 46px;
  padding: 8px 16px;
  border: 1.5px solid var(--card-border);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.header-btn:hover { border-color: var(--pine); box-shadow: var(--shadow); }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 96px;
}

/* ---------- Buttons & pills ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 12px 26px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--pine), #12b39a); color: #fff; box-shadow: var(--shadow-color); }
.btn-primary:hover { background: linear-gradient(135deg, var(--pine-dark), var(--pine)); box-shadow: 0 8px 26px rgba(14,156,134,0.28); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--card-border); }
.btn-ghost:hover { border-color: var(--pine); color: var(--pine); box-shadow: var(--shadow); }
.btn-gold { background: var(--gold-tint); color: var(--gold); border-color: var(--gold-deco); }
.btn-violet { background: linear-gradient(135deg, var(--violet), #8574f0); color:#fff; box-shadow: 0 6px 20px rgba(108,92,231,0.22); }
.btn-violet:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- Home ---------- */
.home-title { text-align: center; margin: 8px 0 4px; }
.home-title h1 { font-size: 2.4rem; margin: 0; }
.home-sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.15rem;
  margin: 0 0 24px;
  letter-spacing: 0.01em;
}

.photo-frame {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lift);
  background: #fff;
}
.photo-frame img { width: 100%; }
.photo-caption {
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 10px 0 26px;
}

.anchor-card {
  position: relative;
  border: 1px solid var(--card-border);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(240,180,94,0.14), transparent 60%),
    #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 26px;
  text-align: center;
  cursor: pointer;
  display: block;
  width: 100%;
  font-family: var(--sans);
  color: var(--ink);
  margin-bottom: 30px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.anchor-card::before {
  content: ""; position:absolute; inset:0; border-radius: var(--radius);
  padding:1.5px; background: linear-gradient(135deg, var(--gold-deco), var(--violet));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events:none; opacity:0.5;
}
.anchor-card:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(16,32,44,0.13); }
.anchor-card .home-mark { font-size: 1.6rem; color: var(--gold); }
.anchor-card h2 { font-size: 1.9rem; margin: 6px 0 2px; color: var(--ink); }
.anchor-card .dates { color: var(--ink-soft); font-size: 1.1rem; }
.anchor-card .amp { color: var(--gold); font-family: var(--serif); font-size: 1.5rem; margin: 6px 0; }
.anchor-card .cta { color: var(--pine); font-weight: 700; margin-top: 14px; }

.section-label {
  font-family: var(--serif);
  font-size: 1.5rem;
  text-align: center;
  margin: 12px 0 6px;
}
.section-note { text-align: center; color: var(--ink-soft); font-size: 1.05rem; margin: 0 0 18px; }

.ten-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.ten-tile {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-height: 132px;
  justify-content: center;
  font-family: var(--sans);
  color: var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.ten-tile:hover { border-color: transparent; box-shadow: var(--shadow-lift); transform: translateY(-3px); }
.ten-num {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), #8574f0);
  color: #fff;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(108,92,231,0.28);
}
.ten-name { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; line-height: 1.15; }
.ten-meta { color: var(--ink-soft); font-size: 0.95rem; }

.home-actions { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
.home-actions .row { display: flex; gap: 10px; flex-wrap: wrap; }
.home-actions .row .btn { flex: 1; min-width: 140px; }

.spine-link {
  text-align: center;
  margin: 18px 0 0;
  font-size: 1.05rem;
  color: var(--ink-soft);
}
.spine-link a { font-weight: 600; }

/* ---------- Search overlay ---------- */
.search-input-wrap { position: relative; }
.search-input {
  width: 100%;
  min-height: 60px;
  font-size: 1.5rem;
  font-family: var(--sans);
  padding: 12px 16px;
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
}
.search-input:focus { border-color: var(--pine); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(250, 246, 236, 0.98);
  display: flex;
  flex-direction: column;
  padding: 16px;
}
.overlay-head {
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
}
.overlay-head .search-input-wrap { flex: 1; }
.overlay-close {
  min-height: 60px; min-width: 60px;
  border: 2px solid var(--card-border);
  background: var(--card);
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 16px;
}
.overlay-results {
  max-width: var(--maxw);
  margin: 12px auto 0;
  width: 100%;
  overflow-y: auto;
  flex: 1;
}

/* ---------- Result / list rows ---------- */
.person-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: var(--sans);
  color: var(--ink);
  transition: box-shadow 130ms ease, border-color 130ms ease, transform 130ms ease;
}
.person-row:hover { border-color: transparent; box-shadow: var(--shadow); transform: translateX(2px); }
.person-row .row-name { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; }
.person-row .row-meta { color: var(--ink-soft); font-size: 1rem; }
.person-row .row-body { flex: 1; }

/* ---------- Monogram medallion ---------- */
.medallion {
  width: 52px; height: 52px;
  border-radius: 50%;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  color: #fff;
  background: linear-gradient(135deg, var(--pine), var(--violet));
  border: none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35);
}
.medallion.lg { width: 96px; height: 96px; font-size: 2rem; }

/* ---------- Lineage Strip ---------- */
.lineage-wrap {
  position: sticky;
  top: 62px;
  z-index: 40;
  background: var(--paper);
  padding: 8px 0 4px;
  margin: -4px 0 8px;
}
.lineage {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 2px;
  scrollbar-width: thin;
}
.lineage::-webkit-scrollbar { height: 6px; }
.lineage::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 3px; }

.pill {
  min-height: 44px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--card-border);
  background: var(--card);
  color: var(--pine);
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  flex: none;
  transition: box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}
.pill:hover { border-color: var(--pine); box-shadow: var(--shadow); }
.pill.root { border-color: transparent; background: var(--gold-tint); color: var(--gold); }
.pill.current {
  background: linear-gradient(135deg, var(--pine), var(--violet));
  color: #fff;
  cursor: default;
  border-color: transparent;
}
.pill.current::before { content: "● "; }
.lineage-sep { color: var(--gold-deco); flex: none; font-weight: 700; padding: 0 1px; }
.lineage-arrow {
  flex: none;
  min-width: 40px; min-height: 40px;
  border-radius: 20px;
  border: 1.5px solid var(--card-border);
  background: var(--card);
  color: var(--pine);
  font-size: 1.2rem;
  cursor: pointer;
}

.relation-sentence {
  font-size: 1.2rem;
  color: var(--ink);
  margin: 4px 2px 20px;
  line-height: 1.5;
}
.relation-sentence strong { color: var(--pine); }
.relation-sentence .via { color: var(--ink-soft); }

/* ---------- Person page ---------- */
.person-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 6px; }
.person-head .titles { flex: 1; }
.person-name { font-size: 2.1rem; margin: 0; line-height: 1.15; }
.gen-id {
  font-family: 'Courier New', ui-monospace, monospace;
  color: var(--ink-soft);
  font-size: 1rem;
  margin-top: 4px;
  letter-spacing: 0.02em;
}
.person-photo {
  width: 120px; flex: none;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gold-deco);
  box-shadow: var(--shadow);
}
.person-photo img { filter: sepia(0.18) saturate(1.02); }

.facts { list-style: none; padding: 0; margin: 16px 0 8px; }
.facts li {
  position: relative;
  padding: 6px 0 6px 28px;
  font-size: 1.2rem;
  line-height: 1.5;
  border-bottom: 1px solid rgba(228,220,200,0.5);
}
.facts li::before {
  content: "•";
  position: absolute;
  left: 8px;
  color: var(--gold);
  font-size: 1.3rem;
  top: 4px;
}
.facts li.honor { }
.facts li.honor::before { content: "★"; color: var(--gold); font-size: 1.1rem; top: 8px; }
.facts li .lbl { color: var(--ink-soft); font-weight: 600; }
.facts li .tap-name {
  color: var(--pine);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gold-deco);
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Family diagram ---------- */
.family-block { margin: 22px 0; }
.family-block h3 {
  font-size: 1.15rem;
  color: var(--ink-soft);
  font-variant: small-caps;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--card-border);
  padding-bottom: 6px;
  margin: 0 0 14px;
  font-family: var(--sans);
  font-weight: 700;
}
.rel-label {
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 6px;
}
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.rel-card {
  min-height: 64px;
  padding: 12px 16px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--sans);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 130ms ease, box-shadow 130ms ease, border-color 130ms ease;
}
.rel-card:hover { border-color: transparent; box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.rel-card .rc-name { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; line-height: 1.15; }
.rel-card .rc-meta { color: var(--ink-soft); font-size: 0.95rem; }
.rel-card .arrow { margin-left: auto; color: var(--gold); font-size: 1.3rem; flex: none; }
.rel-card .medallion { width: 44px; height: 44px; font-size: 1rem; }
.rel-card.spouse { border-color: var(--violet); background: var(--violet-soft); }
.marriage-meta { font-size: 1rem; color: var(--ink-soft); margin: 2px 2px 10px; }
.marriage-label { font-size: 0.9rem; color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin: 12px 0 6px; }

/* ---------- Flag box ---------- */
.flag-box {
  background: var(--flag-bg);
  color: var(--flag-ink);
  border: 1px solid var(--flag-border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin: 18px 0;
  font-size: 1.1rem;
  line-height: 1.5;
}
.flag-box .flag-title { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.flag-box .flag-type { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.75; }
.flag-box a { color: var(--flag-ink); font-weight: 700; }

/* ---------- Page footers / nav buttons ---------- */
.page-nav { display: flex; gap: 12px; margin: 28px 0 8px; }
.page-nav .btn { flex: 1; }
.back-to-joshua {
  position: sticky;
  bottom: 12px;
  margin-top: 24px;
}
.source-line { text-align: center; color: var(--ink-soft); font-size: 0.95rem; margin: 20px 0 0; font-style: italic; }

/* ---------- Family Map ---------- */
.map-spine { margin-bottom: 20px; }
.spine-node {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-left: 3px solid var(--gold-deco);
  padding-left: 16px;
  margin-left: 8px;
}
.spine-node .sp-name { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; color: var(--pine); cursor: pointer; }
.spine-node .sp-year { color: var(--ink-soft); font-size: 1rem; }
.war-badge { color: var(--gold); font-size: 0.95rem; font-weight: 700; white-space: nowrap; }
.spine-indent-1 { margin-left: 24px; }
.spine-indent-2 { margin-left: 44px; }
.spine-indent-3 { margin-left: 64px; }

.branch {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.branch.viewing { border-color: var(--pine); box-shadow: 0 0 0 2px rgba(14,156,134,0.25); }
.branch-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  width: 100%;
  background: none;
  border: none;
  font-family: var(--sans);
  color: var(--ink);
  text-align: left;
  min-height: 56px;
}
.branch-head:hover { background: #FBF6EA; }
.branch-head .caret { color: var(--gold); font-size: 1.1rem; width: 18px; flex: none; }
.branch-head .b-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), #8574f0); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; flex: none;
  box-shadow: 0 3px 10px rgba(108,92,231,0.28);
}
.branch-head .b-name { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; }
.branch-head .b-meta { color: var(--ink-soft); font-size: 0.95rem; margin-left: auto; }
.branch-body { padding: 4px 16px 14px 46px; }
.tree-node {
  padding: 8px 0 8px 18px;
  border-left: 2px solid var(--card-border);
  margin-left: 6px;
}
.tree-node .tn-name {
  font-weight: 600; color: var(--pine); cursor: pointer;
  font-size: 1.1rem;
  min-height: 44px; display: inline-flex; align-items: center;
}
.tree-node .tn-year { color: var(--ink-soft); font-size: 0.95rem; margin-left: 6px; }

/* ---------- A–Z ---------- */
.toggle-row { display: flex; gap: 10px; margin-bottom: 16px; }
.toggle-row .btn { flex: 1; }
.toggle-row .btn.active { background: var(--pine); color: #fff; border-color: var(--pine); }
.az-layout { display: flex; gap: 12px; }
.az-list { flex: 1; }
.letter-head {
  font-family: var(--serif);
  font-size: 1.8rem;
  color: var(--pine);
  border-bottom: 2px solid var(--card-border);
  margin: 22px 0 10px;
  padding-bottom: 4px;
}
.az-rail {
  position: sticky;
  top: 70px;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.9rem;
}
.az-rail button {
  min-width: 32px; min-height: 30px;
  border: none; background: none;
  color: var(--pine); font-weight: 700;
  cursor: pointer; border-radius: 4px;
}
.az-rail button:hover { background: var(--card); }

/* ---------- About ---------- */
.about-section { margin: 24px 0; }
.about-section h2 { font-size: 1.6rem; margin-bottom: 10px; }
.about-list { padding-left: 0; list-style: none; }
.about-list li { padding: 8px 0 8px 28px; position: relative; font-size: 1.15rem; border-bottom: 1px solid rgba(228,220,200,0.5); }
.about-list li::before { content: "•"; position: absolute; left: 8px; color: var(--gold); }
.legend-item { display: flex; gap: 10px; padding: 6px 0; align-items: baseline; }
.legend-item .sym { color: var(--gold); font-weight: 700; min-width: 90px; }

/* ---------- Loading / error ---------- */
.center-msg { text-align: center; padding: 60px 20px; color: var(--ink-soft); font-size: 1.2rem; }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  main { padding: 16px 12px 96px; }
  .home-title h1 { font-size: 1.9rem; }
  .person-name { font-size: 1.7rem; }
  .card-row { grid-template-columns: 1fr; }
  .person-photo { width: 92px; }
  .az-rail { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
.view-fade { animation: fade 150ms ease; }
@keyframes fade { from { opacity: 0.4; } to { opacity: 1; } }

/* ---------- Print (a Person Page on one letter page) ---------- */
@media print {
  .app-header, .lineage-arrow, .page-nav, .back-to-joshua, .header-btn, .overlay { display: none !important; }
  body { background: #fff; }
  body::before { display: none; }
  main { max-width: 100%; padding: 0; }
  .lineage-wrap { position: static; }
  .card, .rel-card, .flag-box { box-shadow: none; }
  a { color: var(--ink); text-decoration: none; }
}

/* ============================================================
   EDIT MODE (Phase 2)
   ============================================================ */
.header-btn.edit-toggle.active {
  background: linear-gradient(135deg, var(--pine), #12b39a);
  color: #fff; border-color: transparent;
  box-shadow: var(--shadow-color);
}

/* subtle "editing" tint on the whole page */
body.edit-on .lineage-wrap { background: var(--paper); }

/* edit pills inline on facts / meta */
.edit-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; min-height: 34px;
  margin-left: 8px; padding: 0 8px;
  border-radius: 999px;
  border: 1.5px solid var(--violet);
  background: var(--violet-soft);
  color: var(--violet);
  font-size: 0.95rem; cursor: pointer;
  vertical-align: middle;
  transition: background 130ms ease, transform 100ms ease;
}
.edit-pill:hover { background: #e3ddfb; }
.edit-pill:active { transform: scale(0.95); }

.btn-sm { min-height: 42px; padding: 8px 16px; font-size: 1rem; }

/* edit-actions block on person page */
.edit-actions {
  border: 1px solid var(--violet);
  background: linear-gradient(180deg, #fbfaff, #fff);
  margin: 18px 0;
}
.edit-actions-title { font-weight: 700; color: var(--violet); margin-bottom: 12px; font-size: 1.1rem; }
.edit-actions-row { display: flex; flex-wrap: wrap; gap: 10px; }
.edit-actions-row .btn { flex: 1; min-width: 160px; min-height: 50px; font-size: 1.05rem; }
.change-editor {
  margin-top: 12px; background: none; border: none;
  color: var(--ink-soft); text-decoration: underline; cursor: pointer;
  font-family: var(--sans); font-size: 1rem;
}

/* ---- Modal / sheet ---- */
.modal-back {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(16,32,44,0.42);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: fade 150ms ease;
}
@media (min-width: 640px) { .modal-back { align-items: center; padding: 20px; } }
.modal {
  background: #fff;
  width: 100%; max-width: 560px;
  border-radius: 24px 24px 0 0;
  padding: 26px 22px calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lift);
  max-height: 92vh; overflow-y: auto;
  animation: sheetUp 220ms cubic-bezier(0.16,1,0.3,1);
}
@media (min-width: 640px) { .modal { border-radius: 24px; } }
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } .modal-back { animation: none; } }

.modal-title { font-size: 1.55rem; margin: 0 0 6px; }
.modal-sub { color: var(--ink-soft); font-size: 1.05rem; margin: 0 0 14px; }
.old-value {
  background: var(--canvas); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 1.2rem; margin-bottom: 16px; color: var(--ink);
}
.edit-label { display: block; font-weight: 600; margin: 14px 0 8px; font-size: 1.05rem; }
.edit-field, .why-field { width: 100%; }
textarea.edit-field { min-height: 90px; resize: vertical; line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* name picker */
.name-picker { display: flex; flex-wrap: wrap; gap: 8px; max-height: 200px; overflow-y: auto; margin-bottom: 4px; }
.name-chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--card-border); background: #fff; color: var(--ink);
  cursor: pointer; font-family: var(--sans); font-size: 1.05rem;
}
.name-chip:hover { border-color: var(--pine); color: var(--pine); }

/* photo upload */
.file-input { display: none; }
.photo-preview { margin: 14px 0; }
.photo-preview img { border-radius: var(--radius-sm); max-height: 260px; margin: 0 auto; border: 1px solid var(--card-border); }

/* photo strip on person page */
.photo-strip { display: flex; gap: 12px; overflow-x: auto; margin: 4px 0 18px; padding-bottom: 6px; }
.photo-strip-item { position: relative; margin: 0; flex: none; width: 150px; }
.photo-strip-item img { width: 150px; height: 150px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--card-border); }
.photo-strip-item figcaption { font-size: 0.9rem; color: var(--ink-soft); margin-top: 6px; line-height: 1.3; }
.photo-del {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(16,32,44,0.6); color: #fff;
  cursor: pointer; font-size: 0.9rem;
}

/* change history */
.history-list { max-height: 60vh; overflow-y: auto; }
.history-row {
  padding: 12px 0; border-bottom: 1px solid var(--card-border);
  display: grid; gap: 3px;
}
.history-row.undone { opacity: 0.55; }
.h-field { font-weight: 700; color: var(--ink); }
.h-change { color: var(--ink); font-size: 1.05rem; }
.h-meta { color: var(--ink-soft); font-size: 0.95rem; }
.history-row .btn-sm { justify-self: start; margin-top: 6px; }
.h-undone-tag { color: var(--ink-soft); font-size: 0.85rem; font-style: italic; }

/* resolved flag */
.flag-box.resolved { background: #EAF7EF; border-color: #BFE6CE; color: #256b45; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff;
  padding: 14px 22px; border-radius: 999px;
  font-size: 1.1rem; font-weight: 600;
  box-shadow: var(--shadow-lift); z-index: 300;
  opacity: 0; transition: opacity 250ms ease, transform 250ms ease;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* keep edit pills from breaking print */
@media print { .edit-pill, .edit-actions, .edit-toggle, .photo-del { display: none !important; } }

/* ============================================================
   ILLUSTRATED FAMILY TREE (poster view)
   ============================================================ */
.tree-view { max-width: 100%; }
.tree-controls { margin-bottom: 14px; }
.tree-title-row { text-align: center; margin-bottom: 14px; }
.tree-heading { font-size: 2.1rem; margin: 0 0 4px; }
.tree-sub { color: var(--ink-soft); font-size: 1.05rem; margin: 0; }
.tree-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; justify-content: center; }
.tree-chip-label { color: var(--ink-soft); font-weight: 600; font-size: 0.95rem; margin-right: 2px; }
.tree-chip {
  min-height: 40px; padding: 6px 16px; border-radius: 999px;
  border: 1.5px solid var(--card-border); background: #fff; color: var(--ink);
  cursor: pointer; font-family: var(--sans); font-size: 1rem; font-weight: 600;
  transition: all 130ms ease;
}
.tree-chip:hover { border-color: var(--pine); color: var(--pine); }
.tree-chip.active { background: #1E3A54; color: #fff; border-color: #1E3A54; }

.tree-canvas {
  margin-top: 10px;
  border: 1px solid #D9CFBB;
  border-radius: var(--radius);
  overflow: auto;
  background: #F4F0E7;
  box-shadow: inset 0 2px 8px rgba(30,58,84,0.06), var(--shadow);
  max-height: 74vh;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
}
.tree-canvas.grabbing { cursor: grabbing; }
.tree-svg { display: block; }
.tree-svg text { user-select: none; }
.tree-svg g[role="button"]:hover rect:first-of-type { stroke-width: 2.6; }
.tree-svg g[role="button"]:focus-visible { outline: none; }
.tree-svg g[role="button"]:focus-visible rect:first-of-type { stroke: var(--violet); stroke-width: 2.6; }

.tree-hint { text-align: center; color: var(--ink-soft); font-size: 0.95rem; margin: 10px 0 0; }

@media (max-width: 700px) {
  .tree-canvas { max-height: 68vh; }
  .tree-heading { font-size: 1.7rem; }
}
