/* ============================================================
   Mathoor Family Tree - styles
   Palette: sandalwood / temple brass / laterite red
   ============================================================ */
:root {
  --brass:      #B8860B;
  --brass-lt:   #D4A537;
  --laterite:   #8C3A2B;
  --deep:       #3B2317;
  --ink:        #2E1D14;
  --muted:      #7A6455;
  --sand:       #FDF6E9;
  --sand-2:     #F5E9D4;
  --surface:    #FFFFFF;
  --line:       #E3D2B6;
  --male:       #2F6F8F;
  --female:     #A0466B;
  --shadow:     0 2px 10px rgba(59,35,23,.10);
  --shadow-lg:  0 12px 40px rgba(59,35,23,.24);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--sand);
  -webkit-text-size-adjust: 100%;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--laterite); }

/* ---------------- Welcome / hero ---------------- */
#welcome {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, #6B4A2F 0%, transparent 60%),
    linear-gradient(170deg, #2A1810 0%, #4A2E1D 45%, #2A1810 100%);
  transition: opacity .5s ease, visibility .5s ease;
}
#welcome.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.hero {
  width: min(880px, 92vw);
  padding: 40px 24px 56px;
  text-align: center;
  color: #F7EAD4;
}
.hero .eyebrow {
  letter-spacing: .32em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--brass-lt);
  margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(30px, 7vw, 60px);
  line-height: 1.08;
  letter-spacing: .01em;
  text-shadow: 0 3px 20px rgba(0,0,0,.5);
}
.hero .ml {
  font-size: clamp(19px, 4.2vw, 30px);
  color: var(--brass-lt);
  margin-top: 12px;
  font-weight: 600;
}
.hero .tagline {
  margin: 20px auto 0;
  max-width: 46ch;
  font-size: 15px;
  line-height: 1.65;
  color: #E2CDAE;
}
.divider {
  width: 190px; height: 20px;
  margin: 26px auto 30px;
  opacity: .95;
}
.hero .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-hero {
  background: linear-gradient(180deg, var(--brass-lt), var(--brass));
  color: #2A1810;
  border: none;
  padding: 14px 30px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(0,0,0,.34);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-hero:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.4); }
.btn-hero.ghost {
  background: transparent;
  color: #F0DEBF;
  border: 1.5px solid rgba(212,165,55,.6);
  box-shadow: none;
}
.btn-hero.ghost:hover { background: rgba(212,165,55,.14); }

/* The illustrated mana (ancestral home) */
.mana-art { width: min(660px, 88vw); margin: 6px auto 0; display: block; }
.hero-stats {
  display: flex; gap: 26px; justify-content: center; flex-wrap: wrap;
  margin-top: 34px; padding-top: 24px;
  border-top: 1px solid rgba(212,165,55,.25);
}
.hero-stats .s { min-width: 78px; }
.hero-stats .n { font-size: 26px; font-weight: 700; color: var(--brass-lt); }
.hero-stats .l { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #C6AE8B; margin-top: 3px; }

/* ---------------- About / heritage ---------------- */
.about {
  margin-top: 44px;
  padding-top: 30px;
  border-top: 1px solid rgba(212,165,55,.25);
  text-align: left;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.about-title {
  color: var(--brass-lt);
  font-size: clamp(19px, 3.4vw, 26px);
  line-height: 1.3;
  text-align: center;
  margin-bottom: 20px;
}
.about p {
  font-size: 14.5px;
  line-height: 1.75;
  color: #E9D8BC;
  margin: 0 0 14px;
}
.about .sect-label {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--brass-lt);
  text-align: center;
  margin-bottom: 14px;
}

/* YouTube video block */
.yt-block { margin-top: 28px; }
.yt-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  background: #000;
}
.yt-frame iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}
.yt-edit {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px;
}
.yt-edit input {
  flex: 1; min-width: 220px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(212,165,55,.4);
  color: #F7EAD4;
  border-radius: 999px;
  padding: 10px 16px;
}
.yt-edit input::placeholder { color: #C6AE8B; }
.btn-hero.ghost.yt-save { padding: 10px 20px; font-size: 13.5px; }
.mini-msg {
  min-height: 18px;
  font-size: 12px;
  color: #C6AE8B;
  margin: 8px 0 0;
  text-align: center;
}

/* Three-line divider ornament */
.ornament {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin: 34px auto 26px;
  width: min(420px, 82vw);
}
.ornament span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--brass-lt), transparent);
  opacity: .85;
}
.ornament span:nth-child(1) { width: 100%; }
.ornament span:nth-child(2) { width: 72%; }
.ornament span:nth-child(3) { width: 44%; }

/* Contact info */
.contact {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  padding: 4px 2px 0;
}
.contact-label {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--brass-lt);
  margin-bottom: 6px;
}
.contact-no {
  display: inline-block;
  font-size: clamp(17px, 3vw, 21px);
  font-weight: 700;
  color: #F7EAD4;
  text-decoration: none;
  border-bottom: 1px dashed rgba(212,165,55,.55);
  padding-bottom: 2px;
}
.contact-no:hover { color: var(--brass-lt); }

/* ---------------- App shell ---------------- */
#app { display: none; min-height: 100vh; flex-direction: column; }
#app.show { display: flex; }

header.bar {
  background: linear-gradient(100deg, var(--deep), #5A3A25);
  color: #F7EAD4;
  padding: 11px 18px;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
header.bar .brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
header.bar h2 { font-size: 16px; letter-spacing: .02em; }
header.bar .sub { font-size: 11px; color: var(--brass-lt); letter-spacing: .12em; text-transform: uppercase; }
header.bar .spacer { flex: 1; }
#status { font-size: 12px; color: #D8BF98; }
/* ghost buttons sit on the dark bar, so recolour them there */
header.bar button.btn.ghost {
  color: #F0DEBF;
  border-color: rgba(212,165,55,.55);
  background: transparent;
}
header.bar button.btn.ghost:hover { background: rgba(212,165,55,.16); }

nav.tabs {
  display: flex; gap: 4px; padding: 0 12px;
  background: var(--sand-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  position: sticky; top: 0; z-index: 15;
}
nav.tabs button {
  background: none; border: none;
  padding: 12px 16px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
nav.tabs button.active { color: var(--laterite); border-bottom-color: var(--laterite); }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px; }
section.view { display: none; }
section.view.active { display: block; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=text], .toolbar select { min-width: 170px; flex: 1; }
input[type=text], input[type=search], select, textarea, input:not([type]) {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass-lt); outline-offset: -1px; }
textarea { min-height: 78px; resize: vertical; }
label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 4px; font-weight: 600; }

button.btn {
  background: var(--laterite); color: #fff;
  border: none; padding: 9px 16px; border-radius: 9px;
  font-weight: 600; cursor: pointer;
}
button.btn:hover { filter: brightness(1.08); }
button.btn.alt { background: var(--deep); }
button.btn.ghost { background: transparent; color: var(--laterite); border: 1.5px solid var(--line); }
button.btn.danger { background: #8B1E1E; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn.sm { padding: 6px 11px; font-size: 13px; }

.empty {
  text-align: center; padding: 54px 20px; color: var(--muted);
}
.empty svg { opacity: .5; margin-bottom: 14px; }
.empty h3 { color: var(--ink); margin-bottom: 8px; }

/* ---------------- Avatars ---------------- */
.av {
  border-radius: 50%;
  object-fit: cover;
  background: var(--sand-2);
  border: 2px solid var(--line);
  flex-shrink: 0;
  display: block;
}
.av.ph {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; border-color: transparent;
}
.av.male   { background: var(--male); }
.av.female { background: var(--female); }
.av.unknown{ background: var(--muted); }

/* ---------------- Tree (DSA style: root on top, children branch
   below, joined by elbow connector lines like a textbook tree) --- */
.tree-scroll {
  overflow: auto;
  background:
    linear-gradient(var(--sand-2) 1px, transparent 1px) 0 0 / 100% 34px,
    var(--sand);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  min-height: 380px;
  text-align: center;
}
ul.tree, ul.tree ul { list-style: none; margin: 0; padding: 0; }
ul.tree {
  display: inline-flex; flex-direction: column; align-items: center;
  padding: 4px 22px 22px;
}
ul.tree ul {
  position: relative;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 26px 0 0;
}
ul.tree li {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  flex: 0 0 auto;
  padding: 26px 7px 0;
}
/* elbow connector: horizontal bar across the top of each child */
ul.tree li::before,
ul.tree li::after {
  content: '';
  position: absolute; top: 0; right: 50%;
  width: 50%; height: 26px;
  border-top: 2px solid var(--line);
}
ul.tree li::after { right: auto; left: 50%; border-left: 2px solid var(--line); }
ul.tree li:only-child { padding-top: 0; }
ul.tree li:only-child::before, ul.tree li:only-child::after { display: none; }
ul.tree li:first-child::before, ul.tree li:last-child::after { border: 0 none; }
ul.tree li:last-child::before {
  border-right: 2px solid var(--line);
  border-radius: 0 8px 0 0;
}
ul.tree li:first-child::after { border-radius: 8px 0 0 0; }
/* vertical drop from a parent card down to its children row */
ul.tree ul::before {
  content: '';
  position: absolute; top: 0; left: 50%;
  width: 0; height: 26px;
  border-left: 2px solid var(--line);
}

/* Pan & zoom canvas (MyHeritage behaviour) */
#viewTree .tree-scroll { cursor: grab; touch-action: none; }
#viewTree .tree-scroll.panning { cursor: grabbing; user-select: none; }
#viewTree .tree-scroll::-webkit-scrollbar { height: 10px; width: 10px; }

/* Fix "can't scroll to the left end": a centred box that is wider than
   its scroller clips its own left side. Making the host hug its content
   (width:max-content) and centre only via auto margins keeps every part
   reachable — scroll position 0 shows the true left edge of the tree. */
#treeHost, #subTreeHost {
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
}

.nwrap {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
}

/* ---- couple row: person ⚭ spouse ---- */
.couple { display: flex; align-items: center; }

.mh-card {
  display: flex; align-items: center; gap: 9px;
  min-width: 158px; max-width: 205px;
  background: #fff;
  border: 1.5px solid #C9D6E2;
  border-radius: 12px;
  padding: 7px 11px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  text-align: left;
}
.mh-card:hover { transform: translateY(-2px); box-shadow: 0 5px 16px rgba(59,35,23,.20); position: relative; z-index: 2; }
.mh-card.male   { background: linear-gradient(180deg, #F2F8FC, #E3EFF8); border-color: #8FB4CE; }
.mh-card.female { background: linear-gradient(180deg, #FCF1F6, #F7E4EE); border-color: #D29AB6; }
.mh-card.unknown{ background: linear-gradient(180deg, #FDF9F0, #F7EFDD); border-color: #D8C9A6; }
.mh-card.root   { outline: 2px solid var(--brass-lt); outline-offset: 1px; }
.mh-card .mtx { min-width: 0; }
.mh-card .nm { font-weight: 600; font-size: 13.5px; line-height: 1.28; color: #22313F; word-break: break-word; }
.mh-card .nm.multi span { display: block; }
.mh-card .mlname { font-size: 11px; color: var(--muted); margin-top: 1px; }
.mh-card .yr { font-size: 11.5px; color: #6B7A88; white-space: nowrap; }

/* marriage link between husband and wife cards */
.mlink {
  flex: 0 0 auto; width: 24px; height: 2px; background: #B9C6D2;
  position: relative; align-self: center;
}
.mlink span {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 1px solid #B9C6D2;
  font-size: 10px; line-height: 16px; text-align: center;
  color: #8A97A5;
}

/* "already shown higher up" tag under a repeated subtree */
.nwrap > .repeat {
  font-size: 10.5px; color: var(--muted); font-style: italic;
  background: var(--sand-2); border-radius: 99px; padding: 1px 8px;
  margin-top: 4px;
}

/* collapse toggle sits half-overlapping the couple row's bottom edge,
   right where the drop line leaves for the children */
.nwrap .twisty {
  position: absolute; left: 50%; bottom: -12px;
  transform: translateX(-50%);
  z-index: 3;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--brass-lt); background: var(--surface); color: var(--deep);
  font-size: 13px; font-weight: 700; line-height: 1;
  cursor: pointer; padding: 0;
  box-shadow: var(--shadow);
}
.nwrap .twisty:hover { background: var(--sand-2); }
li.collapsed > ul { display: none; }

/* zoom controls in the toolbar */
.zoom-group { display: inline-flex; gap: 4px; align-items: center; }
.zoom-group .btn.sm { padding: 6px 10px; }
.zoom-group .zoom-pct { min-width: 58px; font-variant-numeric: tabular-nums; }

/* ============================================================
   FAMILY TREE FULL-BLEED MODE
   When the Family Tree tab is open it uses the ENTIRE app area —
   edge to edge, from just under the tabs down to the bottom of
   the window. No leftover empty space above or below the canvas.
   ============================================================ */
body.tree-fullscreen { overflow: hidden; }
body.tree-fullscreen #app { height: 100vh; height: 100dvh; }
body.tree-fullscreen main {
  max-width: none;
  width: 100%;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
body.tree-fullscreen #viewTree.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#viewTree .tree-scroll {
  flex: 1;
  min-height: 240px;
}
@media (max-width: 640px) {
  body.tree-fullscreen main { padding: 6px 4px 8px; }
}

/* ---------------- People grid ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 12px;
}
.pcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px;
  display: flex; gap: 12px; align-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.pcard:hover { transform: translateY(-2px); }
.pcard .info { min-width: 0; flex: 1; }
.pcard .nm { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------- Detail panel ---------------- */
.detail-head {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--sand-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 18px;
  margin-bottom: 16px;
}
.detail-head .who { flex: 1; min-width: 190px; }
.detail-head h2 { font-size: 22px; }
.detail-head .mlname { color: var(--laterite); font-size: 15px; margin-top: 3px; }
.detail-head .meta { color: var(--muted); font-size: 13px; margin-top: 7px; line-height: 1.6; }

.rel-group { margin-bottom: 18px; }
.rel-group h4 {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 9px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.rel-group h4 .add {
  margin-left: auto; text-transform: none; letter-spacing: 0;
  font-size: 12px; color: var(--laterite); cursor: pointer;
  background: none; border: none; font-weight: 700;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 13px 5px 5px;
  cursor: pointer; font-size: 13px;
}
.chip:hover { border-color: var(--brass); }
.chip .x {
  border: none; background: none; color: var(--muted);
  cursor: pointer; font-size: 15px; padding: 0 2px; line-height: 1;
}
.chip .x:hover { color: #8B1E1E; }
.none { color: var(--muted); font-size: 13px; font-style: italic; }

/* ---------------- Compare ---------------- */
.cmp-wrap { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: start; }
.cmp-slot {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 15px; text-align: center;
}
.cmp-slot .av { margin: 0 auto 10px; }
.cmp-vs {
  align-self: center; font-weight: 700; color: var(--brass);
  font-size: 13px; letter-spacing: .1em;
}
.result {
  margin-top: 16px; padding: 22px;
  background: linear-gradient(135deg, var(--deep), #5A3A25);
  color: #F7EAD4; border-radius: 15px; text-align: center;
}
.result .lbl { font-size: clamp(21px, 4.5vw, 31px); font-weight: 700; color: var(--brass-lt); }
.result .det { font-size: 13px; margin-top: 9px; color: #E2CDAE; line-height: 1.6; }
.path {
  display: flex; gap: 6px; align-items: center; justify-content: center;
  flex-wrap: wrap; margin-top: 15px; padding-top: 14px;
  border-top: 1px solid rgba(212,165,55,.28);
}
.path .step {
  background: rgba(255,255,255,.1); border-radius: 99px;
  padding: 4px 11px; font-size: 12px; color: #F7EAD4;
}
.path .arrow { color: var(--brass-lt); font-size: 13px; }

/* ---------------- Modal ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(43,24,16,.6);
  display: none; overflow-y: auto;
  padding: 16px;
}
.modal.open { display: block; }
.modal .box {
  background: var(--sand);
  border-radius: 16px;
  width: min(660px, 96vw);
  margin: 20px auto 40px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal .box.wide { width: min(860px, 96vw); }
.modal .mhead {
  background: linear-gradient(100deg, var(--deep), #5A3A25);
  color: #F7EAD4; padding: 15px 20px;
  display: flex; align-items: center; gap: 12px;
}
.modal .mhead h3 { font-size: 17px; flex: 1; }
.modal .mhead .x { background: none; border: none; color: #F7EAD4; font-size: 22px; cursor: pointer; line-height: 1; }
.modal .mbody { padding: 20px; }
.modal .mfoot {
  padding: 14px 20px; background: var(--sand-2);
  border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
}
.modal .mfoot .msg { flex: 1; font-size: 13px; text-align: left; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.fld { margin-bottom: 13px; }
@media (max-width: 560px) {
  .f2 { grid-template-columns: 1fr; }
  .cmp-wrap { grid-template-columns: 1fr; }
  .cmp-vs { justify-self: center; }
}

.ok  { color: #1B5E20; }
.err { color: #B71C1C; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* photo picker */
.photo-pick { display: flex; align-items: center; gap: 14px; margin-bottom: 15px; }
.photo-pick .prev {
  width: 76px; height: 76px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--line); background: var(--sand-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px; text-align: center;
}
.photo-pick .ctl { flex: 1; }
#photoFile { display: none; }

/* search dropdown */
.picker { position: relative; }
.picker-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; margin-top: 4px; max-height: 230px; overflow-y: auto;
  box-shadow: var(--shadow-lg); display: none;
}
.picker-list.open { display: block; }
.picker-list .it {
  padding: 9px 12px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid var(--sand-2);
}
.picker-list .it:hover { background: var(--sand-2); }
.picker-list .it .yr { color: var(--muted); font-size: 12px; margin-left: auto; }

.banner {
  background: #FFF3CD; border: 1px solid var(--brass);
  color: #6B4A0F; padding: 12px 15px; border-radius: 10px;
  margin-bottom: 15px; font-size: 13.5px; line-height: 1.6; display: none;
}
.banner.show { display: block; }
.banner code {
  background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px;
  font-size: 12.5px;
}
@media print {
  #welcome, nav.tabs, header.bar, .toolbar { display: none !important; }
  .tree-scroll { border: none; overflow: visible; }
}

/* ---- admin gate: edit controls stay hidden until an admin logs in;
        viewing the tree, people and compare is open to everyone ---- */
[hidden] { display: none !important; }
.admin-link-row { margin-top: 20px; }
.admin-link-row a {
  color: var(--muted); font-size: 12px; text-decoration: none;
  border-bottom: 1px dotted rgba(212,165,55,.45); padding-bottom: 1px;
}
.admin-link-row a:hover { color: var(--brass); }

/* extra admin email rows in the "Manage admins" modal */
.adm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 8px;
  font-size: 14px;
}
.adm-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   TOP BUTTON BAR  (Home · About · Family Tree · Photo Gallery · History)
   ============================================================ */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: flex-start; align-items: center;
  gap: 6px; flex-wrap: nowrap;
  padding: 10px 14px; margin-bottom: 26px;
  background: rgba(20,12,7,.88); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(212,165,55,.35);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
@media (min-width: 720px) { .topnav { justify-content: center; } }
.topnav-admin {
  flex: 0 0 auto; margin-left: 6px; padding: 8px 10px;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--brass-lt); text-decoration: none; opacity: .85;
  border: 1px solid rgba(212,165,55,.35); border-radius: 999px;
  white-space: nowrap;
}
.topnav-admin:hover { opacity: 1; color: #FFD98A; border-color: rgba(212,165,55,.6); }
@media (min-width: 720px) {
  .topnav-admin { margin-left: auto; }
}
.topnav button {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  font-family: inherit; font-size: 13px; letter-spacing: .08em;
  text-transform: uppercase; cursor: pointer; white-space: nowrap;
  color: #E9D9B8; background: transparent;
  border: 1px solid transparent; border-radius: 999px;
  padding: 8px 16px; transition: all .18s ease;
}
.topnav button svg { flex-shrink: 0; }
.topnav button:hover { color: #FFD98A; border-color: rgba(212,165,55,.5); }
.topnav button.tn-accent {
  color: #241505; font-weight: 700;
  background: linear-gradient(135deg, #E9C25B, #D4A537);
}
.topnav button.tn-accent:hover { filter: brightness(1.07); }


/* ============================================================
   CORNER SHAPES - gallery photos as circle / triangle / free forms
   ============================================================ */
.hero { position: relative; }
.corner-shapes { position: absolute; top: 30px; width: 180px; z-index: 1; pointer-events: none; }
.corner-shapes.left  { left: -16px; }
.corner-shapes.right { right: -16px; }
.cs {
  width: 148px; height: 148px; margin: 24px auto; overflow: hidden;
  opacity: .92; box-shadow: 0 10px 26px rgba(0,0,0,.45);
}
.cs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cs.shape-circle { border-radius: 50%; border: 3px solid var(--brass); }
.cs.shape-tri    { clip-path: polygon(50% 0%, 100% 100%, 0% 100%); }
.cs.shape-blob   { border-radius: 58% 42% 55% 45% / 52% 48% 60% 40%; }
.cs.shape-hex    { clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%); }
.cs.shape-diamond{ clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
@media (max-width: 1100px) { .corner-shapes { display: none; } }

/* ============================================================
   MOBILE PHOTO DRAWER - hidden by default (page looks the same);
   on a phone, swiping left/right on the home page slides it up
   and you can slide through the photos sideways.
   ============================================================ */
.mstrip {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  background: rgba(24,14,8,.96);
  border-top: 1px solid rgba(212,165,55,.45);
  box-shadow: 0 -10px 30px rgba(0,0,0,.5);
  padding: 10px 0 16px;
  transform: translateY(110%);
  transition: transform .28s ease;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mstrip::-webkit-scrollbar { display: none; }
.mstrip.open { transform: translateY(0); }
.ms-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 16px 8px; color: var(--brass-lt);
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
}
.ms-head .ms-x { background: none; border: none; color: #F0DEBF; font-size: 20px; cursor: pointer; line-height: 1; }
.ms-row { display: flex; gap: 14px; align-items: center; padding: 0 16px; width: max-content; }
.ms-i { flex: 0 0 auto; width: 118px; height: 118px; overflow: hidden;
  cursor: zoom-in; box-shadow: 0 8px 20px rgba(0,0,0,.5); }
.ms-i img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ms-i.shape-circle  { border-radius: 50%; border: 3px solid var(--brass); }
.ms-i.shape-tri     { clip-path: polygon(50% 0%, 100% 100%, 0% 100%); }
.ms-i.shape-blob    { border-radius: 58% 42% 55% 45% / 52% 48% 60% 40%; }
.ms-i.shape-hex     { clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%); }
.ms-i.shape-diamond { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
@media (min-width: 1101px) { .mstrip { display: none; } }

/* ============================================================
   MOBILE - order on a phone: menu buttons on top, then the
   house picture, then the heritage text, contact at the bottom.
   ============================================================ */
@keyframes galfade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .topnav {
    position: sticky; top: 0; gap: 4px; padding: 7px 5px;
    justify-content: flex-start; margin-bottom: 16px;
  }
  .topnav button { font-size: 10px; padding: 7px 8px; gap: 3px; letter-spacing: .02em; }
  .topnav button svg { width: 13px; height: 13px; }
  .topnav-admin { font-size: 9.5px; padding: 7px 8px; }
  .hero { padding-left: 14px; padding-right: 14px; }
  .mana-art { width: 100%; max-width: 100%; height: auto; display: block; }
  .about-title { font-size: 19px; line-height: 1.45; }
  .about p, .about-lead { text-align: left; font-size: 15px; line-height: 1.85; }
  .g-grid { gap: 18px; }
  .g-item { width: 200px; height: 200px; }
  .yt-frame iframe { width: 100%; }
  .foot { padding-bottom: 26px; }
}

/* ============================================================
   PHOTO GALLERY
   ============================================================ */
/* Each menu button opens its own page; only one is visible at a time. */
.wpage { display: none; }
.wpage.open { display: block; animation: galfade .25s ease; }
.wpad { max-width: 820px; margin: 46px auto 0; padding: 0 20px; min-height: 42vh; }
.about-lead {
  font-size: 17.5px; line-height: 1.9; color: var(--ink, #E9D9B8);
  text-align: center; max-width: 640px; margin: 22px auto 0;
}

.gallery-sec { max-width: 900px; margin: 46px auto 0; padding: 0 20px; }
.g-grid {
  display: flex; flex-wrap: wrap; gap: 28px; justify-content: center;
  margin-top: 24px; min-height: 60px;
}
.g-item { position: relative; width: 250px; height: 250px; overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,.45); cursor: zoom-in; }
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.g-item:hover img { transform: scale(1.06); }
.g-item.shape-circle  { border-radius: 50%; border: 3px solid var(--brass); }
.g-item.shape-tri     { clip-path: polygon(50% 0%, 100% 100%, 0% 100%); }
.g-item.shape-blob    { border-radius: 58% 42% 55% 45% / 52% 48% 60% 40%; }
.g-item.shape-hex     { clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%); }
.g-item.shape-diamond { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.g-item .gx {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 15px; line-height: 1;
  color: #fff; background: rgba(140,30,20,.85);
}
.g-upload { margin-top: 22px; display: flex; justify-content: center; }
.gallery-sec .yt-block, .gallery-sec .yt-edit { margin-top: 30px; }

/* ============================================================
   FOOTER  (ornament · contact · copyright)
   ============================================================ */
.foot {
  margin-top: 56px; padding: 26px 20px 34px;
  border-top: 1px solid rgba(212,165,55,.28);
}
.foot .contact { margin: 18px auto 0; max-width: 900px; }
.copyright {
  margin-top: 20px; text-align: center;
  color: var(--muted); font-size: 12.5px; letter-spacing: .22em;
}
.admin-link-row.center { text-align: center; margin-top: 12px; }
