:root{color-scheme:light;--bg:#f4f1e9;--paper:#fffdf8;--ink:#232e28;--muted:#56645c;--border:#dedace;--green:#234a3e;--focus:#9f493c;--m:#dcece4;--mt:#21584b;--f:#f3e0e1;--ft:#883e52;--s:#f4e7c6;--st:#77521b;--o:#ece4f3;--ot:#644775}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);font-family:system-ui,"PingFang SC","Microsoft YaHei",sans-serif}
button,input{font:inherit;color:inherit}
button{cursor:pointer}
[hidden]{display:none!important}
:focus-visible{outline:2px solid #a34e3c;outline-offset:3px}
.masthead{background:#203f34;color:#fff8e9;border-bottom:4px solid #ae7750}
.masthead-inner,main{max-width:1880px;margin:auto}
.masthead-inner{display:flex;align-items:center;gap:19px;padding:26px clamp(16px,3vw,48px) 25px}
.seal{display:grid;place-items:center;width:58px;height:58px;flex:none;border:1px solid #dd8b70;border-radius:9px;color:#ffe9dd;background:#934d40;font-family:"Songti SC",SimSun,serif;font-weight:700;font-size:20px;letter-spacing:.04em}
h1{font-family:"Songti SC","Noto Serif CJK SC",SimSun,serif;font-size:clamp(34px,4vw,53px);letter-spacing:.04em;margin:0;line-height:1.12}
h1 span{font-family:system-ui,sans-serif;display:inline-block;font-size:clamp(17px,2vw,25px);margin-left:.5em;vertical-align:middle;color:#e1e7d9;font-weight:570;letter-spacing:.06em}
.masthead p{margin:8px 0 0;color:#d4dfd0;font-size:14px;letter-spacing:.05em}
main{padding:24px clamp(12px,2vw,32px) 16px}
.workbench{background:var(--paper);border:1px solid var(--border);border-radius:14px;box-shadow:0 6px 24px #4435200b}
.toolbar{display:flex;align-items:center;gap:18px;flex-wrap:wrap;padding:14px 17px;border-bottom:1px solid var(--border)}
.search{position:relative;display:flex;align-items:center;gap:9px}
.search label,.toggle{font-size:14px;font-weight:650;white-space:nowrap}
.search-field{display:flex;align-items:center;gap:7px;color:var(--muted);background:#f9f7f0;border:1px solid var(--border);border-radius:8px;padding:0 8px}
.search-field input{width:clamp(145px,20vw,230px);height:38px;background:none;border:0;outline:none}
.search-field:focus-within{outline:2px solid #688c7a;outline-offset:1px}
.matches{position:absolute;z-index:5;top:calc(100% + 6px);right:0;width:max(210px,75%);max-height:280px;overflow:auto;background:var(--paper);border:1px solid var(--border);border-radius:8px;box-shadow:0 10px 26px #1d3d3029;padding:5px}
.matches button{width:100%;text-align:left;background:none;border:0;border-radius:5px;padding:8px 9px}
.matches button:hover,.matches button:focus-visible{background:var(--m)}
.matches small{display:block;padding:8px 9px;color:var(--muted)}
.filters,.view-controls,.zoom-controls,.legend{display:flex;align-items:center;gap:12px}
.view-controls{margin-left:auto}
.toggle{display:inline-flex;align-items:center;gap:7px;position:relative;cursor:pointer}
.toggle input{position:absolute;width:34px;height:24px;opacity:0;margin:0}
.switch{display:inline-block;width:35px;height:21px;background:#aaada5;border-radius:20px;position:relative}
.switch::before{content:"";position:absolute;width:15px;height:15px;border-radius:50%;background:white;left:3px;top:3px;transition:transform .16s}
.toggle input:checked+.switch{background:#2f6652}
.toggle input:checked+.switch::before{transform:translateX(14px)}
.toggle input:focus-visible+.switch{outline:2px solid var(--focus);outline-offset:3px}
.zoom-controls{border:1px solid var(--border);gap:0;border-radius:8px;overflow:hidden}
.zoom-controls button,#reset{height:37px;padding:0 11px;background:none;border:0;font-size:14px;font-weight:620}
.zoom-controls button+button{border-left:1px solid var(--border)}
.zoom-controls button:focus-visible{outline-offset:-3px}
.zoom-controls button:hover,#reset:hover{background:#ebece1}
#fit{min-width:58px}
#reset{border:1px solid var(--border);border-radius:8px}
.body-grid{display:grid;grid-template-columns:minmax(0,1fr) 260px;align-items:start}
.diagram{min-width:0}
.legend{min-height:43px;gap:10px 16px;flex-wrap:wrap;padding:9px 15px;color:var(--muted);font-size:13px;border-bottom:1px solid var(--border)}
.legend span{display:inline-flex;align-items:center;gap:6px;white-space:nowrap}
.legend i:not(.link-line){width:12px;height:12px;background:var(--tone);border:1px solid var(--tone-ink);border-radius:3px}
.legend i.servant{border-radius:50%}
.male,.kind-m{--tone:var(--m);--tone-ink:var(--mt)}
.female,.kind-f{--tone:var(--f);--tone-ink:var(--ft)}
.servant,.kind-s{--tone:var(--s);--tone-ink:var(--st)}
.other,.kind-o{--tone:var(--o);--tone-ink:var(--ot)}
.link-line{width:20px;border-top:2px solid #61796d}
.link-line.spouse{border-top:3px solid #965a35}
.link-line.second-wife{border-top:3px dotted #965a35}
.link-line.concubine{border-top:1px solid #965a35}
.link-line.betrothal{border-top:2px dashed #965a35}
.link-line.kin{border-top:2px dotted #695279}
.link-line.identity{border-top:3px dashed #376c9a}
.viewport{position:relative;overflow:auto;background:#f6f3eb;min-height:220px;border-radius:0 0 0 13px;scrollbar-color:#a7a99b #eeebe1}
#frame{position:relative;margin-inline:auto}
#map{position:absolute;transform-origin:top left;overflow:hidden}
#grid,#links,#nodes{position:absolute;inset:0}
#links{width:100%;height:100%;overflow:hidden;pointer-events:none}
.lane{position:absolute;top:13px;bottom:16px;border:1px solid #ded8c9;border-radius:10px;background:#fdfbf5;overflow:hidden}
.lane strong{display:block;background:#e8e4d6;padding:8px 14px;font-family:"Songti SC",SimSun,serif;font-size:26px;line-height:1.2}
.lane strong small{font:500 15px system-ui,sans-serif;color:var(--muted);margin-left:12px}
.row-mark{position:absolute;left:9px;right:5px;border-top:1px dashed #e9e3d5;pointer-events:none}
.row-label{position:absolute;left:12px;color:#485b50;font-size:16px;font-weight:650}
.branch-label{position:absolute;color:#66756a;font-size:15px;font-weight:650}
.branch-divider{position:absolute;top:69px;bottom:18px;left:280px;border-left:1px dashed #ded8c9}
.edge{fill:none;stroke:#6f8579;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;opacity:.75}
.edge.marriage{stroke:#965a35;opacity:.94}
.edge.marriage.spouse{stroke-width:3.7}
.edge.marriage.second-wife{stroke-width:3;stroke-dasharray:1 5}
.edge.marriage.concubine{stroke-width:1.5}
.edge.marriage.betrothal{stroke-width:2.2;stroke-dasharray:4 3}
.edge.kin{stroke:#7b638d;stroke-dasharray:2 6}
.edge.identity{stroke:#2e6595;stroke-width:2.5;stroke-dasharray:9 4 2 4;opacity:.95}
.identity-port{fill:#2e6595;stroke:var(--paper);stroke-width:1}
.identity-port.is-dim{opacity:.22}
.edge.service{stroke:#b08448;stroke-width:1.55;stroke-dasharray:2 4}
.edge.ancillary-edge{opacity:.55}
.edge.is-dim{opacity:.16}
.edge.is-active{stroke-width:3;opacity:1}
.edge.marriage.is-active.spouse{stroke-width:4.5}
.edge.marriage.is-active.second-wife{stroke-width:3.8}
.edge.marriage.is-active.concubine{stroke-width:2}
.edge.marriage.is-active.betrothal{stroke-width:2.7}
.edge.identity.is-active{stroke-width:3.6}
.person{position:absolute;display:grid;place-items:center;transform:translate(-50%,-50%);min-height:39px;padding:2px 1px;background:var(--tone);color:var(--tone-ink);border:1px solid color-mix(in srgb,var(--tone-ink) 33%,transparent);border-radius:7px;line-height:1.12;font-size:16px;font-weight:670;white-space:nowrap;transition:opacity .15s,box-shadow .15s}
.person[data-long="true"]{font-size:14px}
.person[data-compact="true"]{font-size:12px;white-space:normal;padding-inline:2px}
.person.kind-s{width:39px;min-height:39px;border-radius:50%;font-size:14px;white-space:normal}
.person.kind-s[data-long="true"]{font-size:12px;line-height:1.06}
.person.is-dim{opacity:.37}
.person:hover,.person:focus-visible{opacity:1;z-index:3;box-shadow:0 0 0 2px var(--tone-ink)}
.person.is-related{box-shadow:0 0 0 1px var(--tone-ink)}
.person.is-selected{z-index:2;box-shadow:0 0 0 2px var(--paper),0 0 0 4px var(--focus)}
.inspector{border-left:1px solid var(--border);position:sticky;top:0;min-height:380px}
.inspector-top{display:flex;justify-content:space-between;align-items:center;padding:13px 15px;border-bottom:1px solid var(--border);min-height:43px}
.inspector h2{font-size:15px;margin:0}
#clear{border:0;background:none;font-size:20px;line-height:1;padding:0 5px}
#details{padding:14px}
#details h3{font-family:"Songti SC",SimSun,serif;font-size:29px;margin:5px 0 8px}
#details p{font-size:14px;color:var(--muted);line-height:1.65;margin:0 0 12px}
#details .family-mark{font-size:13px;color:#53695c;margin-bottom:0}
.detail-group{margin:15px 0 0}
.detail-group h4{font-size:13px;color:var(--muted);margin:0 0 4px}
.relation{display:flex;align-items:baseline;justify-content:space-between;gap:5px;text-align:left;width:100%;background:none;border:0;border-bottom:1px solid #ece9e0;padding:7px 3px;font-size:14px}
.relation:hover{background:var(--bg)}
.relation strong{color:var(--tone-ink);flex:none}
.relation span{font-size:13px;color:var(--muted);text-align:right}
footer{font-size:13px;color:var(--muted);padding:12px 2px}
footer a{color:var(--green);text-underline-offset:3px}
@media(max-width:1050px){.body-grid{grid-template-columns:minmax(0,1fr) 213px}.toolbar{gap:12px}}
@media(max-width:740px){.body-grid{display:block}.viewport{border-radius:0}.inspector{position:static;border-left:0;border-top:1px solid var(--border);min-height:0}.toolbar{padding:10px}.masthead-inner{padding:18px 14px}.seal{width:44px;height:44px;font-size:17px}.legend{gap:8px 10px}#details:not(:has(.family-mark)){padding-block:11px}.view-controls{margin-left:0}}
@media(max-width:400px){h1 span{display:block;margin:7px 0 0}.masthead p{font-size:12px}}
@media(prefers-reduced-motion:reduce){*,*::before{transition:none!important}}
