:root{--ink:#222;--muted:#5b5b55;--line:#c9c9c0;--bg:#fafaf6;--main:#8a3a12;--mainbg:#fbeee3;--accent:#b4531f;--ok:#2d6a3e;--okbg:#e4f2e8;--warn:#8a5a00;--warnbg:#fff1d6;--info:#2a4f7a;--infobg:#e3ecf7;--grey:#666;--greybg:#eeeeea}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--ink:#eee;--muted:#aaa;--line:#555;--bg:#1b1b19;--main:#f0a57a;--mainbg:#33241b;--accent:#e0824f;--ok:#9fd8ad;--okbg:#20352a;--warn:#f2c46b;--warnbg:#3a2f15;--info:#9fc1e8;--infobg:#1d2a3a;--grey:#bbb;--greybg:#2a2a28}}
:root[data-theme="dark"]{--ink:#eee;--muted:#aaa;--line:#555;--bg:#1b1b19;--main:#f0a57a;--mainbg:#33241b;--accent:#e0824f;--ok:#9fd8ad;--okbg:#20352a;--warn:#f2c46b;--warnbg:#3a2f15;--info:#9fc1e8;--infobg:#1d2a3a;--grey:#bbb;--greybg:#2a2a28}
body{margin:0;padding:24px 28px 60px;background:var(--bg);color:var(--ink);font:16px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
a{color:var(--accent)}
h1{font-size:22px;margin:0 0 4px}
h2{font-size:17px;margin:28px 0 8px;border-bottom:1px solid var(--line);padding-bottom:4px}
.intro,.life,.muted{color:var(--muted)}
.intro{max-width:820px;margin:0 0 12px}
.toolbar{display:flex;gap:8px;align-items:center;margin:12px 0 14px;flex-wrap:wrap}
.toolbar button{font:inherit;padding:4px 10px;border:1px solid var(--line);background:transparent;color:var(--ink);border-radius:4px;cursor:pointer}
ul.tree,ul.kids,ul.plain{list-style:none;margin:0;padding:0}
ul.kids{margin:2px 0 4px 10px;padding-left:16px;border-left:1px solid var(--line)}
ul.plain{list-style:disc;padding-left:22px}
.p{margin:2px 0;border-radius:4px;border-left:3px solid transparent}
.p>summary,.p>div.row{display:block;padding:7px 8px 7px 6px;cursor:pointer;list-style:none}
summary::-webkit-details-marker{display:none}
summary::before{content:"\25B8";display:inline-block;width:12px;color:var(--muted);font-size:11px;margin-right:2px}
details[open]>summary::before{content:"\25BE"}
.p.leaf{padding:7px 8px 7px 20px}
.p.main{border-left-color:var(--accent);background:var(--mainbg)}
.nm{font-weight:600}
.nm a{color:inherit;text-decoration:none}
.nm a:hover{text-decoration:underline}
.life{font-size:14px;margin-left:8px}
.sp{color:var(--muted);font-size:12px;margin-left:8px;font-style:italic}
.body{padding:2px 0 4px 14px}
.flag{font-size:11px;color:var(--warn);background:var(--warnbg);border-radius:3px;padding:0 5px;margin-left:8px}
.badge{font-size:11px;border-radius:3px;padding:0 5px;white-space:nowrap}
.Confirmed{color:var(--ok);background:var(--okbg)}
.Probable{color:var(--info);background:var(--infobg)}
.Locked-hit{color:var(--warn);background:var(--warnbg)}
.Unsourced{color:var(--grey);background:var(--greybg)}
.banner{border:1px solid var(--warn);background:var(--warnbg);color:var(--ink);border-radius:4px;padding:8px 12px;margin:12px 0;max-width:820px}
table{border-collapse:collapse;width:100%;max-width:980px;font-size:15px}
th,td{text-align:left;vertical-align:top;padding:5px 8px;border-bottom:1px solid var(--line)}
th{color:var(--muted);font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.03em}
dl.rel{display:grid;grid-template-columns:max-content 1fr;gap:4px 14px;margin:8px 0;max-width:820px}
dl.rel dt{color:var(--muted)}
dl.rel dd{margin:0}
.wide{overflow-x:auto;max-width:100%}
.photos{display:flex;flex-wrap:wrap;gap:12px}
.photos figure{margin:0;max-width:260px}
.photos img{max-width:100%;height:auto;border:1px solid var(--line);border-radius:4px}
.photos figcaption{font-size:12.5px;color:var(--muted)}
#notes ol{padding-left:22px;max-width:920px}
#notes li{margin:6px 0}
footer{margin-top:32px;color:var(--muted);font-size:15px}
details.ev{margin:10px 0}details.ev>summary{cursor:pointer;color:var(--accent);padding:6px 0}
.key{max-width:820px}.key dt{font-weight:600}.key dd{margin:0 0 6px}
#find{font:inherit;font-size:18px;padding:12px 14px;border:1px solid var(--line);border-radius:4px;background:var(--bg);color:var(--ink);width:100%;max-width:420px;box-sizing:border-box;max-width:560px}
ul.az{list-style:none;margin:0;padding:0;columns:2 320px}ul.az li{padding:5px 0;break-inside:avoid}
form.fix{max-width:560px;display:grid;gap:10px;margin-top:8px}form.fix label{display:grid;gap:4px;color:var(--muted)}form.fix textarea,form.fix input{font:inherit;padding:8px 10px;border:1px solid var(--line);border-radius:4px;background:var(--bg);color:var(--ink)}form.fix button{justify-self:start;font:inherit;padding:8px 16px;border:1px solid var(--accent);border-radius:4px;background:var(--mainbg);color:var(--ink);cursor:pointer;min-height:40px}
.lead{font-size:18px;max-width:760px;margin:4px 0 18px}
.azbox{max-height:min(55vh,480px);overflow-y:auto;border:1px solid var(--line);border-radius:6px;padding:4px 12px;margin:10px 0 4px;max-width:980px;box-sizing:border-box}
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin:24px 0;max-width:980px}
.card{display:block;padding:14px 16px;border:1px solid var(--line);border-radius:6px;background:var(--mainbg);color:var(--ink);text-decoration:none}
.card strong{display:block;color:var(--accent);font-size:17px;margin-bottom:4px}.card span{color:var(--muted);font-size:14px}
.card:hover strong{text-decoration:underline}
ol.srcs{padding-left:0;list-style:none;max-width:920px}ol.srcs li{margin:4px 0}
@media (max-width:640px){body{padding:16px}h1{font-size:20px}h2{font-size:16px}.lead{font-size:16px}.life{display:block;margin-left:0}dl.rel{grid-template-columns:1fr}td,dd,li,figcaption,.intro{overflow-wrap:anywhere}ul.kids{margin-left:2px;padding-left:10px}.body{padding-left:6px}.toolbar button{padding:8px 12px;min-height:40px}.toolbar label{padding:6px 0}.photos figure{max-width:100%;flex:1 1 100%}table.facts td:nth-child(3),table.facts td:nth-child(4){display:inline-block;margin-right:10px}table.facts,table.facts tbody,table.facts tr,table.facts td{display:block;width:auto}table.facts thead{display:none}table.facts tr{border-bottom:1px solid var(--line);padding:6px 0}table.facts td{border:0;padding:2px 0}table.facts td:first-child{font-weight:600;color:var(--muted)}}
#chart{display:block;width:100%;height:calc(100vh - 200px);min-height:340px;border:1px solid var(--line);border-radius:4px;background:var(--bg);cursor:grab;touch-action:none;user-select:none}
.ln{fill:none;stroke:var(--line);stroke-width:1.5}
.ln.mar{stroke-width:5}
.ln.mar2{stroke:var(--bg);stroke-width:1.6}
.ln.par{stroke:var(--accent);stroke-width:2.5;stroke-dasharray:0.1 5;stroke-linecap:round}
.zoom{display:inline-flex;gap:8px;white-space:nowrap}
details.help{margin:4px 0 8px;max-width:820px}details.help>summary{cursor:pointer;color:var(--accent);padding:4px 0}
@media (max-width:640px){#chart{border-radius:0;margin:0 -16px;width:calc(100% + 32px);border-left:0;border-right:0}.toolbar{gap:6px;margin:6px 0}.toolbar #focus{flex-basis:100%}}
.box rect{fill:var(--bg);stroke:var(--line)}
.box.focus rect{fill:var(--mainbg);stroke:var(--accent);stroke-width:2}
.box a{text-decoration:none}
.box text{font-size:13px}
.box text.nm{fill:var(--ink);font-weight:600}
.box text.lf{fill:var(--muted);font-size:11.5px}
.box text.fl{fill:var(--warn);font-size:11px}
.box .ring{fill:none;stroke:var(--line);stroke-width:2}
.topnav{display:flex;align-items:center;gap:2px;flex-wrap:wrap;margin:-12px 0 16px;padding:0 0 6px;border-bottom:1px solid var(--line)}
.topnav>a{padding:8px 12px;border-radius:4px;text-decoration:none;color:var(--ink)}
.topnav>a:hover{background:var(--mainbg)}.topnav>a.on{color:var(--accent);font-weight:600}
@media (max-width:640px){.topnav{position:fixed;left:0;right:0;bottom:0;z-index:2000;margin:0;flex-wrap:nowrap;background:var(--bg);border-bottom:0;border-top:1px solid var(--line);padding:4px 6px calc(4px + env(safe-area-inset-bottom));box-shadow:0 -1px 6px rgba(0,0,0,.12)}.topnav>a{flex:1;text-align:center;padding:10px 2px;font-size:14px}body{padding-bottom:calc(76px + env(safe-area-inset-bottom))}}
.welcome{font-size:18px;max-width:760px}.welcome p{margin:0 0 10px}
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;max-width:980px;margin:10px 0}
.stat{border:1px solid var(--line);border-radius:6px;padding:10px 12px}.stat b{display:block;font-size:22px;color:var(--main)}.stat span{color:var(--muted);font-size:14px}
.feat{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px;max-width:980px}
.fcard{display:flex;gap:12px;align-items:flex-start;border:1px solid var(--line);border-radius:6px;padding:12px;color:var(--ink);text-decoration:none}
.fcard img{width:72px;height:72px;object-fit:cover;object-position:top;border-radius:50%;flex:none;border:1px solid var(--line)}
.fcard strong{color:var(--accent)}.fcard .life{margin-left:6px}.fcard p{margin:4px 0 0;font-size:14px;color:var(--muted)}
.fcard:hover strong{text-decoration:underline}
ul.recent{list-style:none;padding:0;margin:0;max-width:820px}ul.recent li{padding:6px 0;border-bottom:1px solid var(--line)}
ul.recent .d{color:var(--muted);font-size:14px;display:inline-block;min-width:8em}

/* ---- Käytettävyys ja ilme (UI/UX) ---- */
:root{color-scheme:light dark;--radius:8px;--ctl:38px}
:root[data-theme="light"]{color-scheme:light}:root[data-theme="dark"]{color-scheme:dark}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}*{transition:none!important;animation:none!important}}
body{line-height:1.6;text-rendering:optimizeLegibility}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}
a{text-underline-offset:2px;text-decoration-thickness:1px}
a:hover{text-decoration-thickness:2px}
h1{font-size:26px;line-height:1.25;margin:4px 0 8px}
h2{font-size:18px;margin:32px 0 10px}
::selection{background:var(--mainbg)}

/* hyppylinkki ja valikko */
.skip{position:absolute;left:-9999px;top:8px;background:var(--bg);color:var(--ink);border:2px solid var(--accent);border-radius:var(--radius);padding:8px 14px;z-index:3000}
.skip:focus{left:12px}
@media (min-width:641px){
  .topnav{position:sticky;top:0;z-index:1500;margin:-24px -28px 20px;padding:6px 28px;background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:saturate(1.4) blur(8px);-webkit-backdrop-filter:saturate(1.4) blur(8px)}
}
.topnav>a{border-radius:var(--radius);transition:background .15s,color .15s;position:relative}
.topnav>a.on::after{content:"";position:absolute;left:12px;right:12px;bottom:2px;height:2px;border-radius:2px;background:var(--accent)}

/* lomakkeen osat: samannäköiset napit, valinnat ja kentät */
button,select,input[type=search],input:not([type]),textarea{font:inherit;color:var(--ink)}
.toolbar button,.mapbar button,.toolbar select,.mapbar select{min-height:var(--ctl);padding:0 14px;border:1px solid var(--line);border-radius:var(--radius);background:var(--bg);cursor:pointer;transition:background .15s,border-color .15s}
.toolbar button:hover,.mapbar button:hover,.toolbar select:hover,.mapbar select:hover{background:var(--mainbg);border-color:var(--accent)}
.toolbar button:active,.mapbar button:active{transform:translateY(1px)}
.toolbar select,.mapbar select{padding:0 10px}
.toolbar label,.mapbar label{display:inline-flex;align-items:center;gap:8px;min-height:var(--ctl)}
.toolbar input[type=checkbox]{width:18px;height:18px;accent-color:var(--accent);cursor:pointer;margin:0}
.toolbar{gap:10px 12px}
.zoom{gap:6px}
.zoom button:nth-child(1),.zoom button:nth-child(2){min-width:var(--ctl);padding:0;font-size:18px;font-weight:600}
#focus{font-weight:600}
#find{border-radius:var(--radius);padding:14px 16px;box-shadow:0 1px 2px rgba(0,0,0,.08)}
#find:focus{border-color:var(--accent);outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 30%,transparent)}
form.fix textarea:focus,form.fix input:focus{border-color:var(--accent);outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 30%,transparent)}
form.fix button{border-radius:var(--radius);transition:background .15s}
form.fix button:hover{background:var(--main);color:var(--bg)}

/* kortit ja luettelot */
.card,.fcard,.stat,.tales li{border-radius:var(--radius);transition:transform .15s,box-shadow .15s,border-color .15s}
.card:hover,.fcard:hover,.tales li:hover{transform:translateY(-2px);box-shadow:0 4px 14px rgba(0,0,0,.15);border-color:var(--accent)}
.tales li{background:color-mix(in srgb,var(--bg) 94%,var(--ink))}
ul.az li{border-radius:6px}
ul.az li:hover{background:var(--mainbg)}
ul.az li a{display:inline-block;padding:2px 6px}
.azbox{border-radius:var(--radius)}
.stat b{font-variant-numeric:tabular-nums}
ul.recent li:hover{background:var(--mainbg)}

/* sukupuun lista */
.p{border-radius:var(--radius)}
.p>summary:hover,.p>div.row:hover{background:var(--mainbg)}
.p>summary{border-radius:var(--radius)}

/* henkilösivu: taulukot */
table.facts{border:1px solid var(--line);border-radius:var(--radius);border-collapse:separate;border-spacing:0;overflow:hidden}
table.facts th{background:var(--greybg)}
table.facts tr:last-child td{border-bottom:0}
table.facts tbody tr:hover td{background:var(--mainbg)}
table.facts td:first-child{white-space:nowrap;color:var(--muted)}
.badge{padding:1px 7px;border-radius:10px}
dl.rel dt{font-size:14px;padding-top:1px}
.photos img{transition:transform .15s}
.photos a:hover img{transform:scale(1.02)}
details.ev>summary,details.help>summary{border-radius:6px}
details.help{border:1px solid var(--line);border-radius:var(--radius);padding:2px 12px;background:color-mix(in srgb,var(--bg) 94%,var(--ink))}
details.help[open]{padding-bottom:6px}
.banner{border-radius:var(--radius)}

/* kaavio ja kartta */
#chart{border-radius:var(--radius)}
.box rect{transition:stroke .15s,fill .15s}
.box:hover rect{stroke:var(--accent)}
.box{cursor:pointer}
#map,.chron{border-radius:var(--radius)}
.chron li{border-radius:6px;transition:background .15s}
.mapbar input[type=range]{height:28px}
footer{border-top:1px solid var(--line);padding-top:16px}

@media (max-width:640px){
  body{padding-top:14px}
  .toolbar button,.mapbar button,.toolbar select,.mapbar select{min-height:44px}
  .toolbar label{min-height:44px}
  .card:hover,.fcard:hover,.tales li:hover{transform:none;box-shadow:none}
  table.facts{border:0}
  table.facts td:first-child{white-space:normal}
}
@media print{.topnav,.toolbar,.mapbar,.skip,footer form{display:none}body{padding:0}}
.un{fill:var(--muted)}

/* Relationship calculator (relation.html) and ancestor fan chart (fan.html) */
.pick{display:flex;gap:10px 16px;align-items:end;flex-wrap:wrap;margin:14px 0}
.pick label{display:flex;flex-direction:column;gap:4px;font-size:14px;color:var(--muted)}
.pick select,.pick button{min-height:var(--ctl);padding:0 10px;border:1px solid var(--line);border-radius:var(--radius);background:var(--bg);cursor:pointer;max-width:100%}
.pick select{min-width:260px}
.pick button:hover,.pick select:hover{background:var(--mainbg);border-color:var(--accent)}
#rel-result{max-width:820px;margin:18px 0}
#rel-result .verdict{font-size:22px;line-height:1.35;margin:0 0 6px}
#rel-result .verdict b.rel{color:var(--main)}
#rel-result .how{color:var(--muted);margin:0 0 16px}
ol.rpath{list-style:none;margin:0;padding:0;max-width:520px;position:relative}
ol.rpath li{position:relative;padding:8px 12px;border:1px solid var(--line);border-radius:var(--radius);background:var(--bg);margin:0}
ol.rpath li.end{border-color:var(--accent);background:var(--mainbg)}
ol.rpath li.top{border-style:dashed;border-color:var(--ok);background:var(--okbg)}
ol.rpath li .y{color:var(--muted);margin-left:6px;font-size:14px}
ol.rpath li .tag{float:right;font-size:12px;color:var(--ok);padding-top:2px}
ol.rpath li.step{border:0;background:none;padding:2px 0 2px 22px;color:var(--muted);font-size:13px;display:flex;align-items:center;gap:6px}
ol.rpath li.step::before{content:"";width:2px;height:20px;background:var(--line);margin-right:10px}
.fanwrap{overflow-x:auto;border:1px solid var(--line);border-radius:4px;background:var(--bg)}
#fan{display:block;width:100%;min-width:760px;height:auto}
#fan .w{cursor:pointer;stroke:var(--bg);stroke-width:1.5;transition:filter .12s,stroke-width .12s;animation:fanin .45s ease both}
#fan .w:hover{filter:brightness(1.12) saturate(1.3);stroke-width:2.5}
#fan .w.gap{fill:none;stroke:var(--line);stroke-dasharray:4 4;cursor:default}
#fan text{pointer-events:none;fill:var(--ink);font-family:inherit;animation:fanin .45s ease both}
#fan text.q{fill:var(--muted)}
#fan .root{fill:var(--mainbg);stroke:var(--accent);stroke-width:2}
#fan path,#fan circle{vector-effect:non-scaling-stroke}  /* lines and dashes stay the same on screen when zooming in */
@keyframes fanin{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion:reduce){#fan .w,#fan text{animation:none}}
#fan.twin,#fan .w.twin{filter:brightness(1.3) saturate(1.5)}
.fanwrap.fit{overflow:hidden;height:calc(100vh - 250px);min-height:420px;cursor:grab;touch-action:none;user-select:none}
.fanwrap.fit.drag{cursor:grabbing}
.fanwrap.fit #fan{width:100%;height:100%;min-width:0}
.zoombtns{display:inline-flex;gap:4px}
.zoombtns button{min-width:2.2em}
.repchip{display:inline-block;border:2px solid;border-radius:4px;padding:0 6px;margin:2px 2px;color:var(--ink)}
#fan.hl-unc .w:not(.prob):not(.guess):not(.gap),#fan.hl-unc text.lbl:not(.prob){filter:grayscale(1) opacity(.28)}
#fan.hl-unc .w.prob{stroke:#ff9f1a;stroke-width:2.5;stroke-dasharray:6 4;filter:brightness(1.2) saturate(1.4)}
#fan.hl-unc .w.guess{stroke:#ff2d87;stroke-width:3;stroke-dasharray:2 5;stroke-linecap:round;fill:rgba(255,45,135,.34);filter:saturate(1.5)}
#fan.hl-unc text.lbl.guess{fill:#ffd0e4;font-weight:700;filter:none}
.guesschip{display:inline-block;border:2px dotted #ff2d87;border-radius:4px;padding:0 6px;margin:2px 2px;color:var(--ink)}
#chart.hl-unc .ln:not(.dash){opacity:.22}
#chart.hl-unc .ln.dash{stroke:#ff9f1a;stroke-width:3.5;stroke-dasharray:7 4}
label.unc,.pick label.unc{display:inline-flex;flex-direction:row;min-height:var(--ctl);align-items:center;gap:6px;cursor:pointer}
#fan-info{height:5.4em;overflow:hidden;margin:10px 0;line-height:1.35}
#fan-cover{display:flex;flex-direction:column;gap:4px;color:var(--muted);font-size:14px;margin:8px 0 20px}
#fan-cover b{color:var(--ink)}
.byear{font-weight:400;color:var(--muted);font-size:.6em}
.sbs{display:grid;grid-template-columns:1fr 1fr;gap:8px 28px;align-items:start}.sbs>section{min-width:0}.sbs-fan .fanwrap,.sbs-map #pmap{height:480px!important;box-sizing:border-box;max-width:none}@media(max-width:900px){.sbs{grid-template-columns:1fr}}
.fanwrap.small #fan{min-width:0;width:100%;height:100%}.sbs-fan .pick select{min-width:0;flex:1}.sbs-fan .pick label:not(.unc){flex:1 1 140px}
.count{font-size:.5em;font-weight:400;color:var(--muted);margin-left:.6em;white-space:nowrap}
.topnav .updated{margin-left:auto;padding:0 6px;color:var(--muted);font-size:13px;white-space:nowrap}
@media (max-width:640px){.topnav .updated{display:none}}

/* Family explorer */
.tree-search{flex:1;min-width:240px}.tree-search input{width:100%;min-width:150px;padding:10px 12px;font:inherit;color:var(--ink);background:var(--bg);border:1px solid var(--line);border-radius:8px}
.tree-options{position:relative}.tree-options summary{cursor:pointer}.tree-options>div{position:absolute;right:0;top:36px;width:290px;padding:16px;background:var(--bg);border:1px solid var(--line);border-radius:10px;z-index:5;box-shadow:0 8px 24px #0002}.tree-options label{display:flex;margin:8px 0}
.tree-selection{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:10px 0;font-size:14px}#tree-count{color:var(--muted)}
.tree-canvas{position:relative}#chart{background-color:var(--bg);background-image:radial-gradient(var(--line) .7px,transparent .7px);background-size:22px 22px;border-radius:12px;min-height:400px}
.tree-navigation{position:absolute;top:14px;left:14px;display:flex;align-items:center;gap:4px;max-width:calc(100% - 28px);flex-wrap:wrap;padding:5px;background:var(--bg);border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 10px #0001}.tree-navigation button{font:inherit;color:var(--ink);background:var(--bg);border:0;border-radius:6px;min-height:38px;padding:6px 12px;cursor:pointer}.tree-navigation button:hover{background:var(--mainbg)}#tree-zoom{font-size:12px;min-width:44px;text-align:center}
#tree-overview{position:absolute;right:14px;bottom:14px;width:200px;height:120px;background:var(--bg);border:1px solid var(--line);border-radius:8px;cursor:crosshair;box-shadow:0 2px 10px #0001}
#chart .box.distant{opacity:.5}#chart .box.relative rect{stroke:var(--info);stroke-width:2;fill:var(--infobg)}#chart .box.focus rect{stroke-width:3}#chart .box:hover,#chart .box:focus{opacity:1}#chart .box:focus rect{stroke:var(--accent);stroke-width:3}#chart .family-edge{stroke:var(--accent);stroke-width:2.5}#chart .partner{stroke:var(--accent);stroke-dasharray:2 5}.tree-help{font-size:13px;color:var(--muted);margin:10px 0;line-height:1.8}
@media(max-width:640px){.tree-search{flex-basis:100%}#tree-overview{width:120px;height:80px;right:8px;bottom:8px}.tree-navigation{left:8px;top:8px}.tree-navigation button{padding:6px 8px}#tree-count{font-size:12px}#chart{margin:0;width:100%;border:1px solid var(--line)}}
#chart .box text.nm{font-size:14px}#chart .box text.lf{font-size:12px}
/* Hover tracing keeps the viewport still and follows parent links only. */
#chart [data-branch="1"]{--path-color:#378cdb}#chart [data-branch="2"]{--path-color:#b477df}#chart [data-branch="3"]{--path-color:#30a382}
#chart.tracing .ln:not(.path-active){opacity:.16}#chart.tracing .box:not(.path-active){opacity:.35}
#chart.tracing .box.path-active{opacity:1}#chart.tracing .box.path-active rect{stroke:var(--path-color);stroke-width:3}
#chart.tracing .ln.path-active{stroke:var(--path-color);stroke-width:3.5;opacity:1}
/* A fixed-height explorer: only the graph pans, the page never scrolls. */
body.tree-page{height:100dvh;box-sizing:border-box;overflow:hidden;padding:0 16px 12px;display:flex;flex-direction:column;gap:6px}
.tree-page .topnav{position:relative;top:auto;flex:none;margin:0 -16px;padding:4px 16px;flex-wrap:nowrap;overflow:hidden}
.tree-page .topnav .updated{overflow:hidden;text-overflow:ellipsis;min-width:0}
.tree-page main{display:flex;flex-direction:column;flex:1;min-height:0;gap:6px}.tree-page h1{font-size:18px;margin:0}
.tree-page .toolbar{margin:0;gap:6px;flex:none}.tree-page .toolbar label{font-size:13px;min-height:34px;padding:0}.tree-page .toolbar select{min-height:34px;max-width:160px;font-size:13px;padding:0 6px}.tree-page .tree-search input{padding:6px 8px;font-size:14px;min-width:0}.tree-page .tree-search{min-width:170px}
.tree-page .tree-selection{margin:0;gap:4px;flex:none;font-size:13px}.tree-page #focus{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}.tree-page #tree-count{font-size:12px}
.tree-page .tree-canvas{flex:1;min-height:0;overflow:hidden}.tree-page #chart{height:100%;min-height:0;box-sizing:border-box;margin:0;width:100%}
.tree-page .tree-options{font-size:13px;margin-left:auto}.tree-page .tree-options>div,.kin-legend>div{position:fixed;top:110px;right:16px;max-width:calc(100vw - 48px);max-height:calc(100dvh - 180px);overflow:auto;z-index:2001;background:var(--bg);border:1px solid var(--line);padding:12px;border-radius:8px;box-shadow:0 4px 20px #0003}.tree-page .tree-help{font-size:12px;line-height:1.5}
.kin-legend{flex:none;font-size:12px}.kin-legend summary{display:flex;flex-wrap:wrap;gap:4px 10px;cursor:pointer;list-style:none}.kin-legend summary::before{display:none}.kin-legend summary span{border-bottom:3px solid var(--kin-color);white-space:nowrap}.kin-legend>div{width:420px;line-height:1.6}
[data-kin="0"]{--kin-color:var(--accent)}[data-kin="1"]{--kin-color:#349f81}[data-kin="2"]{--kin-color:#4c9cdf}[data-kin="3"]{--kin-color:#b487df}[data-kin="4"]{--kin-color:#de9d40}[data-kin="5"]{--kin-color:#d9779c}[data-kin="affinity"]{--kin-color:#91999f}
#chart .box[data-kin] rect{stroke:var(--kin-color);stroke-width:2}#chart .box.relative rect{fill:var(--bg);stroke-width:3}#chart .box.focus rect{fill:var(--mainbg);stroke-width:3}#chart .box.distant{opacity:.8}#chart .box text.kin-label{fill:var(--kin-color);font-size:11px;font-weight:600}
#chart.tracing .box.path-active rect{stroke:var(--path-color);stroke-width:3}#chart.tracing .box:not(.path-active){opacity:.45}
@media(max-width:640px){body.tree-page{padding:8px 10px 0;gap:4px}.tree-page .topnav{order:2;margin:0 -10px;padding:2px 3px calc(2px + env(safe-area-inset-bottom));border-top:1px solid var(--line);border-bottom:0}.tree-page .topnav>a{font-size:11px;padding:8px 2px}.tree-page main{gap:5px}.tree-page .tree-search{flex-basis:100%}.tree-page .tree-selection{display:block}.tree-page #focus{display:block}.tree-page #tree-count{display:none}.tree-page .toolbar select{max-width:125px}.tree-page .tree-options>div,.kin-legend>div{top:90px;right:10px}.tree-page .tree-navigation{top:6px;left:6px;padding:2px;gap:0}.tree-page .tree-navigation button{font-size:12px;min-height:30px;padding:4px 7px}.tree-page #tree-overview{width:100px;height:65px}.kin-legend{font-size:10px}.kin-legend summary{gap:2px 8px}}
@media(max-height:500px){.tree-page h1{display:none}.tree-page .toolbar{flex-wrap:nowrap}.tree-page .tree-search{flex-basis:auto;min-width:130px}.tree-page .tree-search>input{width:100px}.tree-page .tree-navigation{top:4px}.tree-page .tree-selection{line-height:1.2}}
#chart.tracing .box.relative{opacity:1}

/* ---- Mobile (phone) tuning ---- */
@media (max-width:640px){
  html{-webkit-tap-highlight-color:transparent}
  body:not(.tree-page){overflow-x:hidden}
  select,input,textarea,button{max-width:100%}
  select,input[type=search],input:not([type]),textarea{font-size:16px}  /* 16px stops iOS zooming into a field on focus */
  h1{font-size:22px}
  /* bottom bar: seven short labels must fit without clipping; scroll sideways if the phone is very narrow */
  .topnav{overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}
  .topnav::-webkit-scrollbar{display:none}
  .topnav>a{flex:1 0 auto;font-size:11.5px;padding:12px 3px;white-space:nowrap}
  .topnav>a.on::after{left:6px;right:6px}
  /* fan page: two-column control grid, the chart gets the screen */
  .pick{display:grid;grid-template-columns:1fr 1fr;gap:8px 10px;align-items:end;margin:8px 0}
  .pick label{min-width:0}
  .pick:has(#who) label:first-child{grid-column:1/-1}
  .pick:has(#a) label,.pick:has(#a) button{grid-column:1/-1;min-height:44px}
  .pick:has(#a) select{min-height:44px}
  .pick select{min-width:0;width:100%}
  .pick label.unc{grid-column:1;min-height:44px}
  .pick #home{grid-column:2;min-height:44px}
  .pick .zoombtns{grid-column:1/-1;display:flex}
  .pick .zoombtns button{flex:1;min-height:44px}
  #fan-info{height:auto;min-height:3.4em;max-height:6em;font-size:15px;margin:6px 0}
  .fanwrap.fit{height:auto;aspect-ratio:var(--fan-ar,1/1);max-height:75dvh;min-height:0;border-radius:var(--radius)}
  /* person page: side-by-side fan and map become a stack of shorter boxes */
  .sbs-fan .fanwrap,.sbs-map #pmap{height:340px!important}
  /* map page */
  #map{height:62dvh;min-height:320px}
  .chron{max-height:45dvh}
  .mapbar{gap:8px}
  .mapbar button{flex:1 1 40%}
  .mapbar label{flex:1 1 100%;display:flex;align-items:center;gap:10px}
  .mapbar label select{flex:1;min-width:0}
  #year{top:6px}
  /* wide tables scroll instead of widening the page */
  table:not(.facts){display:block;overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
  /* lists and forms */
  ul.az{columns:1}
  .azbox{max-height:50dvh}
  .stats{grid-template-columns:repeat(2,1fr)}
  .welcome{font-size:17px}
  .fcard img{width:56px;height:56px}
  #find{max-width:none}
  .tales li{padding:12px}
  .pick select{min-width:0}
  #rel-result .verdict{font-size:19px}
  ol.rpath{max-width:none}
  details.help{padding:2px 10px}
  footer{margin-top:24px}
}
@media (max-width:640px) and (orientation:landscape){
  .fanwrap.fit{max-height:85dvh}
  #map{height:75dvh}
}
