:root{--green:#174f39;--green-dark:#0d3425;--paper:#fbfaf6;--ink:#22302a;--muted:#68736d;--line:#d9ddd9;--blue-bg:#e8f2fb;--blue-line:#4d82aa;--orange-bg:#fff1df;--orange-line:#bb8144;--header-height:142px}
*{box-sizing:border-box}
html,body{height:100%;width:100%;max-width:none;margin:0;font-family:Arial,Helvetica,sans-serif;color:var(--ink);background:var(--paper)}
body{min-height:100dvh;display:flex;flex-direction:column;overflow:hidden}
button,input,a{font:inherit}
button,input,.header-btn{border:1px solid #c9cec9;border-radius:8px;background:#fff;color:#26342e;padding:9px 11px;font-size:13px}
button,.header-btn{cursor:pointer;white-space:nowrap}
a.header-btn{text-decoration:none;display:inline-flex;align-items:center;gap:6px;line-height:1.2}
button:hover,.header-btn:hover{background:#f0f4f1}
button:focus-visible,input:focus-visible,a:focus-visible,.node:focus-visible,.family-action:focus-visible{outline:3px solid #d7a629;outline-offset:2px}
button.primary{background:var(--green);color:#fff;border-color:var(--green)}
header{flex:0 0 auto;display:grid;grid-template-columns:minmax(260px,max-content) max-content minmax(0,1fr);align-items:center;column-gap:12px;padding:8px 14px;background:#fff;border-bottom:1px solid var(--line);box-shadow:0 2px 10px rgba(0,0,0,.05);z-index:20}
.header-top{display:contents}
.title-wrap{min-width:0;max-width:390px}
h1{font-size:21px;margin:0 0 2px;color:var(--green);white-space:nowrap}
.subtitle{font-size:12px;color:var(--muted);line-height:1.3;white-space:nowrap}
.header-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:nowrap}
.header-btn.active{border-color:var(--green);box-shadow:inset 0 0 0 1px var(--green);background:#f0f6f2;font-weight:700}
.diagram-home-button{display:inline-flex;align-items:center;justify-content:center;text-decoration:none;flex:0 0 auto;border-radius:50%}
.diagram-home-circle{width:58px;height:58px;background:#c9a46d;border-radius:50%;border:2px solid transparent;box-shadow:0 0 4px rgba(0,0,0,.30);display:flex;align-items:center;justify-content:center;transition:all .15s ease}
.diagram-home-button:hover .diagram-home-circle{border-color:#d4af37;background:#d3b07a}
.diagram-home-button:focus-visible{outline:3px solid rgba(155,107,0,.35);outline-offset:2px}
.diagram-home-svg{width:27px;height:27px}
.lang-icon{width:42px;height:28px;padding:3px!important;display:inline-flex!important;align-items:center;justify-content:center}
.lang-icon img{display:block;width:32px;height:20px;object-fit:cover;border-radius:2px}
#printDiagram{width:52px;height:46px;padding:2px 4px;line-height:1;display:inline-flex;align-items:center;justify-content:center}
#printDiagram .print-icon{width:43px;height:auto;max-height:40px;display:block;object-fit:contain}
.header-tools{border-top:0;padding-top:0;min-width:0}
.toolbar-scroll{min-width:0;overflow-x:auto;padding:1px 2px 3px;scrollbar-width:thin}
.toolbar{display:flex;align-items:center;gap:6px;width:max-content;min-width:max-content}
.search-wrap{display:flex;gap:6px;position:relative;margin-left:2px}
#search{width:245px}
#workspace{position:relative;flex:1 1 auto;width:100%;max-width:none;min-height:0;overflow:hidden;background:linear-gradient(180deg,#fbfaf6,#f5f3ec)}
#treeSvg{width:100%;height:100%;display:block;cursor:grab;user-select:none;touch-action:none}
#treeSvg.dragging{cursor:grabbing}
.connector{fill:none;stroke:#a9ada8;stroke-width:2}
.marriage-line,.daughter-line{fill:none;stroke:#9b8a8e;stroke-width:1.8}
.node,.family-action{cursor:pointer}
.node rect,.family-action rect{stroke-width:2;filter:drop-shadow(0 2px 2px rgba(0,0,0,.07));transition:stroke-width .15s,filter .15s}
.node:hover rect,.node:focus-visible rect,.family-action:hover rect,.family-action:focus-visible rect{stroke-width:3;filter:drop-shadow(0 3px 4px rgba(0,0,0,.14))}
.node text,.family-action text{pointer-events:none}.node .code{font-size:12px;font-weight:700;letter-spacing:.4px}.node .label{font-size:14px;font-weight:600}.node .hint{font-size:12px}
.node.selected rect{stroke:#c63030!important;stroke-width:4}.node.match rect{stroke:#be8b00!important;stroke-width:4}
.spouse-node rect{fill:#fff3f4;stroke:#a45c68}.spouse-node{filter:drop-shadow(0 2px 2px rgba(0,0,0,.04))}
.marriage-label{font-size:9.5px;letter-spacing:.35px;text-transform:uppercase;fill:#8b6a72}
.daughter-node rect{fill:#f4effa;stroke:#8064a0}
.family-title{font-size:12.5px;font-weight:700;fill:#4b2930}.family-meta{font-size:11.5px;font-weight:600;fill:#67545a}
.daughter-title{font-size:12px;font-weight:700;fill:#4d3864}.daughter-meta{font-size:11px;font-weight:600;fill:#625273}
#details{position:absolute;right:14px;top:14px;width:min(430px,calc(100% - 28px));max-height:calc(100% - 28px);overflow:auto;background:rgba(255,255,255,.97);border:1px solid #d3d7d2;border-radius:12px;box-shadow:0 10px 35px rgba(0,0,0,.16);padding:16px;display:none;z-index:30}
#details.open{display:block}#details h2{font-size:17px;margin:0 32px 3px 0;color:var(--green)}#details .detail-code{font-size:12px;font-weight:700;color:#6c756f;margin-bottom:12px}#details p{font-size:14px;line-height:1.5;white-space:pre-line;margin:0}
#closeDetails{position:absolute;right:10px;top:9px;border:0;background:transparent;font-size:20px;padding:3px 7px}
.legend{position:absolute;left:14px;bottom:14px;background:rgba(255,255,255,.94);border:1px solid #d3d7d2;border-radius:10px;padding:9px 12px;font-size:12px;display:flex;flex-wrap:wrap;gap:9px 14px;max-width:min(760px,calc(100% - 28px));box-shadow:0 4px 18px rgba(0,0,0,.08);z-index:5}
.legend span{display:flex;align-items:center;gap:6px}.swatch{width:14px;height:14px;border-radius:4px;border:2px solid}.help{position:absolute;right:15px;bottom:12px;color:#6d756f;font-size:12px;background:rgba(251,250,246,.92);padding:5px 8px;border-radius:6px;z-index:5}
#searchResults{position:absolute;left:14px;top:14px;width:min(520px,calc(100% - 28px));max-height:calc(100% - 28px);overflow:auto;background:rgba(255,255,255,.98);border:1px solid #d3d7d2;border-radius:12px;box-shadow:0 10px 35px rgba(0,0,0,.16);padding:16px;display:none;z-index:40}
#searchResults.open{display:block}#searchResults h2{font-size:18px;margin:0 36px 5px 0;color:var(--green)}#searchSummary{font-size:13px;color:var(--muted);margin-bottom:12px}
#closeResults{position:absolute;right:10px;top:9px;border:0;background:transparent;font-size:20px;padding:3px 7px}
#resultList{display:grid;gap:8px}.result-item{display:block;width:100%;text-align:left;padding:10px 12px;border:1px solid #d6dbd7;border-radius:9px;background:#fff}.result-item:hover{background:#f0f4f1}.result-code{display:block;font-size:11px;font-weight:700;color:#6c756f;margin-bottom:3px}.result-name{display:block;font-size:15px;font-weight:700;color:var(--green)}.result-meta{display:block;font-size:12px;line-height:1.4;color:#536059;margin-top:3px}
.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
@media(max-width:980px){
 header{display:flex;flex-direction:column;align-items:stretch;gap:7px;padding:8px 10px}.header-top{display:flex;align-items:flex-start;flex-wrap:wrap;gap:7px}.title-wrap{min-width:0;width:100%;max-width:none}h1{font-size:19px;white-space:normal}.subtitle{font-size:12px;white-space:normal}
 .header-actions{width:100%;justify-content:flex-start;flex-wrap:nowrap;overflow-x:auto;padding-bottom:2px}
 .header-tools{border-top:1px solid #edf0ed;padding-top:7px}.toolbar-scroll{overflow-x:auto}.toolbar{min-width:max-content}#search{width:190px}
 .legend,.help{display:none}
 #details{left:8px;right:8px;top:auto;bottom:8px;width:auto;max-height:52%;border-radius:13px}
}
@media(max-width:560px){button,input,.header-btn{padding:8px 9px;font-size:12px}#search{width:165px}.diagram-home-circle{width:52px;height:52px}.diagram-home-svg{width:25px;height:25px}.lang-icon{width:40px;height:36px;padding:3px!important}.lang-icon img{width:30px;height:19px}#printDiagram{width:48px;height:42px;padding:2px 4px}#printDiagram .print-icon{width:39px;max-height:36px}#searchResults{left:7px;top:7px;width:calc(100% - 14px);max-height:calc(100% - 14px)}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important}}
@media print{header,#details,#searchResults,.legend,.help{display:none!important}body{display:block;overflow:visible}#workspace{height:auto;overflow:visible}#treeSvg{width:100%;height:auto;min-height:1100px}}
