/* Családfa: a painted tree on old paper */
:root {
  --header-h: 76px;
  --paper: #efe5d1;
  --paper-2: #e6d8bd;
  --ink: #3a2a1d;
  --ink-soft: #6d5843;
  --ink-faint: #9a8569;
  --leaf: #5f7a45;
  --leaf-deep: #3f5a32;
  --bark: #8a5a35;
  --gold: #b8862f;
  --card: #f7f0e1;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden; color: var(--ink); font: 16px/1.55 "Manrope", sans-serif; -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(120% 90% at 50% 40%, #f4ecdb 0%, #efe5d1 45%, #e2d2b4 100%);
}
body::before { /* paper grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .36 0 0 0 0 .25 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; left: 16px; top: -70px; z-index: 200; padding: 12px 16px; color: var(--paper); background: var(--ink); transition: top .2s; }
.skip-link:focus { top: 12px; }

/* Header (same structure as the other pages, inked for a light page) */
.site-header { position: fixed; inset: 0 0 auto; z-index: 80; height: var(--header-h); padding: 0 3.2vw; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: var(--ink); background: linear-gradient(#efe5d1f2, #efe5d100); pointer-events: none; }
.site-header > * { pointer-events: auto; }
.monogram { font: 700 28px/1 "Cormorant Garamond", serif; letter-spacing: -.08em; justify-self: start; }
.monogram span { color: var(--leaf); }
.main-nav { display: flex; gap: clamp(44px,5vw,80px); align-items: center; font-weight: 700; text-transform: uppercase; }
.main-nav a { position: relative; padding: 18px 0 14px; color: var(--ink-soft); }
.main-nav a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: 4px; height: 1px; background: var(--leaf); transition: right .38s ease; }
.main-nav a:hover, .main-nav a:focus-visible { color: var(--ink); }
.main-nav a:hover::after, .main-nav a:focus-visible::after { right: 0; }
.roll-label { display: inline-flex; white-space: nowrap; }
.letter-window { display: inline-block; height: 1.15em; overflow: hidden; }
.letter-track { display: flex; flex-direction: column; height: 2.3em; }
.letter-track > span { display: block; height: 1.15em; line-height: 1.15em; }

/* Stage */
.tree-stage { position: fixed; inset: 0; z-index: 1; touch-action: none; }
#treeCanvas { display: block; width: 100%; height: 100%; cursor: grab; outline: none; }
#treeCanvas.is-dragging { cursor: grabbing; }
#treeCanvas.is-pointing { cursor: pointer; }
.tree-loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); margin: 0; font: 28px/1 "Caveat", cursive; color: var(--ink-soft); transition: opacity .6s; }
.tree-loading.is-done { opacity: 0; pointer-events: none; }
.tree-noscript { position: fixed; inset: 40% 16px auto; text-align: center; z-index: 5; }

/* Floating paper panels share one look */
.tree-intro, .tree-search input, .tree-results, .tree-tools button, .branch-bar, .record {
  border: 1px solid #6d584333; background: #f7f0e1ee; box-shadow: 0 14px 40px #4a361f26, 0 1px 0 #fff8 inset; backdrop-filter: blur(4px);
}

/* Intro */
.tree-intro { position: fixed; z-index: 40; left: clamp(16px, 3.2vw, 48px); bottom: clamp(16px, 4vh, 40px); width: min(380px, calc(100vw - 32px)); padding: 22px 24px 20px; border-radius: 14px; transition: opacity .4s; }
.tree-kicker { margin: 0 0 10px; font: 14px/1 "Special Elite", serif; letter-spacing: .08em; color: var(--leaf-deep); }
.tree-intro h1 { margin: 0; font: 600 clamp(36px, 3.4vw, 50px)/.95 "Cormorant Garamond", serif; letter-spacing: -.035em; }
.tree-intro h1 em { font-style: italic; color: var(--leaf-deep); }
.tree-lead { margin: 14px 0 0; color: var(--ink-soft); font-size: 15px; }
.tree-lead b { color: var(--ink); font-weight: 700; }
.tree-stats { margin: 10px 0 0; font: 22px/1.1 "Caveat", cursive; color: var(--bark); }
.tree-intro-toggle { position: absolute; right: 14px; top: 14px; padding: 6px 10px; border: 1px solid #6d584340; border-radius: 999px; background: transparent; color: var(--ink-faint); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.tree-intro-toggle:hover, .tree-intro-toggle:focus-visible { color: var(--ink); border-color: #6d584380; }
.tree-intro.is-collapsed { width: auto; padding: 12px 16px; }
.tree-intro.is-collapsed > :not(.tree-kicker, .tree-intro-toggle) { display: none; }
.tree-intro.is-collapsed .tree-kicker { margin: 0 90px 0 0; }
.tree-intro.is-collapsed .tree-intro-toggle { top: 50%; transform: translateY(-50%); }
.in-branch .tree-intro { opacity: 0; pointer-events: none; }

/* Search */
.tree-search { position: fixed; z-index: 60; right: clamp(16px, 3.2vw, 48px); top: calc(var(--header-h) + 4px); width: min(320px, calc(100vw - 32px)); }
.tree-search input { width: 100%; height: 44px; padding: 0 16px 0 40px; border-radius: 999px; font: 500 15px "Manrope", sans-serif; color: var(--ink); outline: none;
  background: #f7f0e1ee url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%236d5843' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m12.5 12.5 4 4'/%3E%3C/svg%3E") no-repeat 14px 50%; }
.tree-search input:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px #5f7a4533, 0 14px 40px #4a361f26; }
.tree-search input::placeholder { color: var(--ink-faint); }
.tree-results { position: absolute; left: 0; right: 0; top: 50px; margin: 0; padding: 6px; list-style: none; border-radius: 14px; max-height: min(420px, 60vh); overflow: auto; }
.tree-results li { display: grid; gap: 1px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.tree-results li[aria-selected="true"], .tree-results li:hover { background: #5f7a4524; }
.tree-results b { font: 600 18px/1.15 "Cormorant Garamond", serif; }
.tree-results small { color: var(--ink-faint); font-size: 12px; }
.tree-results .empty { cursor: default; color: var(--ink-faint); }

/* Zoom tools */
.tree-tools { position: fixed; z-index: 50; right: clamp(16px, 3.2vw, 48px); bottom: clamp(16px, 4vh, 40px); display: flex; gap: 8px; }
.tree-tools button { min-width: 44px; height: 44px; padding: 0 14px; border-radius: 999px; cursor: pointer; font-weight: 700; color: var(--ink); }
.tree-tools button:not(.wide) { font-size: 20px; padding: 0; }
.tree-tools .wide { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.tree-tools button:hover, .tree-tools button:focus-visible { border-color: var(--leaf); color: var(--leaf-deep); }

/* Branch view bar */
.branch-bar { position: fixed; z-index: 55; left: clamp(16px, 3.2vw, 48px); top: calc(var(--header-h) + 4px); display: flex; align-items: center; gap: 16px; max-width: calc(100vw - 32px - min(320px, 100vw) - 24px); padding: 10px 18px 10px 10px; border-radius: 14px; }
.branch-bar[hidden] { display: none; }
.branch-bar button { flex: none; height: 40px; padding: 0 14px; border: 1px solid #6d584340; border-radius: 999px; background: var(--leaf-deep); color: #f7f0e1; font-size: 13px; font-weight: 700; cursor: pointer; }
.branch-bar button:hover, .branch-bar button:focus-visible { background: var(--leaf); }
.branch-kicker { margin: 0; font: 12px/1 "Special Elite", serif; letter-spacing: .06em; color: var(--ink-faint); }
.branch-bar h2 { margin: 2px 0 0; font: 600 24px/1.05 "Cormorant Garamond", serif; }

/* Register card */
.record { position: fixed; z-index: 70; right: clamp(16px, 3.2vw, 48px); top: calc(var(--header-h) + 60px); bottom: calc(clamp(16px, 4vh, 40px) + 56px); width: min(380px, calc(100vw - 32px)); padding: 0; border-radius: 6px; overflow: hidden;
  background: #f5ecd8; box-shadow: 0 24px 60px #4a361f40, 0 0 0 6px #f5ecd8 inset; transform-origin: 100% 0; animation: record-in .35s cubic-bezier(.2,.8,.2,1); }
.record[hidden] { display: none; }
@keyframes record-in { from { opacity: 0; transform: translateY(-8px) rotate(-1deg); } }
.record::before { content: ""; position: absolute; inset: 10px; border: 1px solid #6d584355; border-radius: 2px; pointer-events: none; }
.record-body { height: 100%; overflow: auto; padding: 28px 30px 26px; }
.record-close { position: absolute; z-index: 2; right: 16px; top: 14px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; font-size: 24px; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.record-close:hover, .record-close:focus-visible { background: #6d58431a; color: var(--ink); }
.rec-head { margin: 0 0 4px; font: 12px/1.3 "Special Elite", serif; letter-spacing: .08em; color: var(--ink-faint); text-transform: uppercase; }
.rec-name { margin: 6px 36px 2px 0; font: 700 30px/1.02 "Cormorant Garamond", serif; letter-spacing: -.02em; }
.rec-rel { margin: 6px 0 16px; font: 22px/1.1 "Caveat", cursive; color: var(--bark); }
.rec-table { width: 100%; border-collapse: collapse; font: 14px/1.4 "Special Elite", serif; }
.rec-table th { width: 96px; padding: 7px 10px 7px 0; vertical-align: top; text-align: left; font: 600 11px/1.6 "Manrope", sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.rec-table td { padding: 7px 0; border-bottom: 1px dashed #6d584340; }
.rec-table td small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.rec-sec { margin: 18px 0 6px; font: 600 11px/1 "Manrope", sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.rec-list { margin: 0; padding: 0; list-style: none; }
.rec-list li { padding: 4px 0; }
.rec-link { padding: 0; border: 0; background: none; text-align: left; font: 600 18px/1.2 "Cormorant Garamond", serif; color: var(--ink); border-bottom: 1px dotted #6d584399; cursor: pointer; }
.rec-link:hover, .rec-link:focus-visible { color: var(--leaf-deep); border-bottom-color: var(--leaf-deep); }
.rec-list small { color: var(--ink-faint); font-size: 12px; margin-left: 6px; }
.rec-private { margin: 4px 0 0; padding: 12px 14px; border: 1px dashed #6d584366; border-radius: 4px; font-size: 13.5px; color: var(--ink-soft); }
.rec-branch { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--leaf-deep); color: #f7f0e1; font-size: 13px; font-weight: 700; cursor: pointer; }
.rec-branch:hover, .rec-branch:focus-visible { background: var(--leaf); }
.rec-stamp { float: right; margin: 4px 0 0 12px; width: 74px; height: 74px; border: 2px solid #8f3b2e88; border-radius: 50%; display: grid; place-items: center; text-align: center; font: 10px/1.15 "Special Elite", serif; color: #8f3b2eaa; transform: rotate(-12deg); }

/* Season line, story head, kinship */
.tree-season { margin: 2px 0 0; font: 20px/1.15 "Caveat", cursive; color: var(--leaf-deep); }
[data-season="osz"] .tree-season { color: #a0572a; }
.rec-story { color: #a0572a; }
.rec-kin { display: inline-flex; align-items: center; gap: 6px; margin: 14px 0 2px; padding: 8px 14px; border: 1px solid #b8862f88; border-radius: 999px; background: #f3e2b4; color: #5a3d25; font: 700 13px "Manrope", sans-serif; cursor: pointer; }
.rec-kin:hover, .rec-kin:focus-visible { background: #efd393; border-color: #b8862f; }
.kin-amp { color: var(--gold); font-style: italic; }
.kin-text { margin: 0 0 6px; font-size: 14.5px; color: var(--ink-soft); }
.kin-chain { margin: 0; padding: 0 0 0 4px; list-style: none; border-left: 2px dashed #b8862f88; }
.kin-chain li { position: relative; padding: 5px 0 5px 16px; }
.kin-chain li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: #e8c46a; border: 1.5px solid #8a5a35; }
.kin-chain li.is-root::before { background: #8f3b2e; }
.kin-chain li.is-root .rec-link { color: #8f3b2e; }
.kin-step { display: block; margin: 0 0 1px !important; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.kin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; }
.kin-actions .rec-branch { margin-top: 0; }
.tree-search input.is-picking { border-color: var(--gold); box-shadow: 0 0 0 3px #b8862f40, 0 14px 40px #4a361f26; }

/* Family map */
.map-btn { background: #3f5a32 !important; color: #f7f0e1 !important; border-color: #3f5a32 !important; }
.map-btn:hover, .map-btn:focus-visible { background: #5f7a45 !important; }
.map-view { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: calc(var(--header-h) + 8px) clamp(16px, 3vw, 40px) 24px; background: #2a1d12a6; backdrop-filter: blur(5px); animation: map-in .35s ease; }
.map-view[hidden] { display: none; }
@keyframes map-in { from { opacity: 0; } }
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; width: min(1500px, 100%); max-height: 100%; align-items: center; }
.map-sheet { position: relative; margin: 0; aspect-ratio: 2528 / 1696; max-height: calc(100vh - var(--header-h) - 40px); justify-self: center; width: 100%; max-width: calc((100vh - var(--header-h) - 40px) * 1.4906); box-shadow: 0 30px 70px #0007; transform: rotate(-.4deg); }
.map-sheet img { display: block; width: 100%; height: 100%; }
.map-sheet svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-title { position: absolute; left: 6.5%; top: 11.6%; width: 27%; margin: 0; text-align: center; font: 700 clamp(16px, 2.3vw, 34px)/1 "Caveat", cursive; color: #4a3220; transform: rotate(-2deg); pointer-events: none; }
.map-water path { fill: none; stroke: #6f93a6; stroke-width: 3.2; stroke-linecap: round; opacity: .75; }
.map-river { font: italic 600 19px "Cormorant Garamond", serif; fill: #4c7284; letter-spacing: .08em; }
.map-lake { fill: #a7c3cf; fill-opacity: .75; stroke: #6f93a6; stroke-width: 1.5; }
.map-place { cursor: pointer; outline: none; }
.map-place circle { fill: #b8862f; fill-opacity: .88; stroke: #3b2414; stroke-width: 1.4; transition: fill .2s; }
.map-place text { font-family: "Caveat", cursive; font-weight: 700; fill: #3b2414; paint-order: stroke; stroke: #f2e6cccc; stroke-width: 4px; stroke-linejoin: round; }
.map-place:hover circle, .map-place:focus-visible circle, .map-place.is-on circle { fill: #8f3b2e; }
.map-place:focus-visible circle { stroke-width: 3; }
.map-list { max-height: calc(100vh - var(--header-h) - 60px); overflow: auto; padding: 24px 24px 22px; border-radius: 6px; background: #f5ecd8; box-shadow: 0 24px 60px #0006; }
.map-top { margin: 6px 0 0; padding: 0 0 0 18px; }
.map-top li { padding: 4px 0; }
.map-top small, .map-list .rec-list small { display: block; margin: 0; color: var(--ink-faint); font-size: 12px; }
.map-off { margin: 16px 0 0; font-size: 13px; color: var(--ink-soft); }
.map-off .rec-link { font-size: 16px; }
.map-back { margin: 0 0 12px; padding: 0; border: 0; background: none; color: var(--leaf-deep); font: 700 13px "Manrope", sans-serif; cursor: pointer; }
.map-close { position: fixed; z-index: 2; right: clamp(16px, 3vw, 40px); top: calc(var(--header-h) - 34px); width: 44px; height: 44px; border: 1px solid #f7f0e166; border-radius: 50%; background: #2a1d12cc; color: #f7f0e1; font-size: 26px; line-height: 1; cursor: pointer; }
.map-close:hover, .map-close:focus-visible { background: #3f5a32; }
.map-open .tree-search, .map-open .tree-tools, .map-open .record { visibility: hidden; }

@media (max-width: 1000px) {
  .map-view { place-items: start center; overflow: auto; }
  .map-wrap { grid-template-columns: 1fr; }
  .map-sheet { max-width: 100%; }
  .map-list { max-height: none; }
}

@media (max-width: 720px) {
  :root { --header-h: 64px; }
  .tree-tools { flex-wrap: wrap; }
  .tree-tools .wide { padding: 0 12px; font-size: 11px; }
  .site-header { padding: 0 16px; }
  .tree-search { left: 16px; right: 16px; width: auto; top: calc(var(--header-h) + 2px); }
  .tree-intro { bottom: 128px; } /* the tool row wraps to two lines on phones */
  .tree-tools { left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); justify-content: center; }
  .branch-bar { top: calc(var(--header-h) + 56px); max-width: calc(100vw - 32px); }
  .branch-bar h2 { font-size: 20px; }
  .record { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 72vh; border-radius: 16px 16px 0 0; }
  .record-body { max-height: 72vh; padding: 24px 22px calc(22px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .record { animation: none; }
}
