/* Contact relationships — aligned with site-wide controls. */
.hub-relationship-editor { margin-top:12px; }
.hub-relationship-editor h3 { margin-bottom:8px; }
.hub-relationship-list { display:flex; flex-direction:column; gap:10px; margin:12px 0; }
.hub-relationship-row { display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.4fr) auto; align-items:end; gap:9px; }
.hub-relationship-row label { min-width:0; }
.hub-relationship-row select { width:100%; min-width:0; }
.hub-relationship-remove { align-self:end; }
.hub-relationship-add { margin-top:4px; }
.hub-relationship-status { margin-top:8px; }
.hub-relationship-view-list { display:grid;gap:7px; }
.hub-relationship-view-item { display:flex;justify-content:space-between;align-items:center;gap:12px;width:100%;padding:10px 12px;background:var(--panel,#ffffff08);border:1px solid var(--border,#8884);border-radius:10px;color:inherit;text-align:left;font:inherit;cursor:pointer; }
.hub-relationship-view-item:disabled { opacity:.55;cursor:default; }
.hub-relationship-view-item:hover:not(:disabled) { border-color:var(--accent,#b89e57); }
@media(max-width:600px){.hub-relationship-row{grid-template-columns: minmax(0,1fr) minmax(0,1fr)}.hub-relationship-remove{grid-column:1 / -1;justify-self:start;}}

.hub-relationship-view-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}
.hub-relationship-view-heading h3{margin:0}
.hub-family-tree-button{white-space:nowrap}
.hub-relationship-view-item.is-inferred{border-style:dashed}
.hub-family-tree-dialog{width:min(960px,calc(100vw - 20px));max-width:960px;max-height:min(92dvh,950px);padding:0;background:var(--panel,#20242b);color:inherit;border:1px solid var(--border,#8885);border-radius:16px;overflow:hidden}
.hub-family-tree-dialog::backdrop{background:rgba(0,0,0,.68)}
.hub-family-tree-header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:16px 20px;border-bottom:1px solid var(--border,#8885)}
.hub-family-tree-header h2{margin:0;font-size:1.2rem}
.hub-family-tree-content{padding:16px 20px 24px;max-height:calc(92dvh - 75px);overflow:auto;display:flex;flex-direction:column;gap:16px}
.hub-family-tree-content>p{margin:0}
.hub-family-tree-generation{position:relative;text-align:center}
.hub-family-tree-generation h3{margin:0 0 8px;font-size:.85rem;font-weight:600;opacity:.85}
.hub-family-tree-people{display:flex;justify-content:center;gap:10px;flex-wrap:wrap}
.hub-family-tree-person{display:flex;flex-direction:column;align-items:center;gap:4px;text-align:center;min-width:140px;max-width:240px;padding:12px 16px;border-radius:12px;background:var(--panel2,#3335);border:1px solid var(--border,#8885);color:inherit;cursor:pointer;font:inherit}
.hub-family-tree-person:hover{border-color:var(--accent,#b89e57)}
.hub-family-tree-person.is-focus{border:2px solid var(--accent,#b89e57);background:color-mix(in srgb,var(--accent,#b89e57) 12%,transparent)}
.hub-family-tree-person.is-inferred{border-style:dashed}
.hub-family-tree-generation:not(:last-of-type)::after{content:'';display:block;margin:12px auto 0;height:17px;width:2px;background:var(--border,#8885)}
.hub-family-tree-open{align-self:center}
@media(max-width:600px){.hub-family-tree-content{padding:12px}.hub-family-tree-person{min-width:125px;max-width:200px}.hub-relationship-view-heading{flex-wrap:wrap}}

/* Family tree v654: three-generation branching, adjacent spouses, individual children. */
.hub-family-tree-dialog{width:min(1200px,calc(100vw - 14px));max-width:1200px}
.hub-family-tree-content{overflow:auto;align-items:stretch}
.hub-family-tree-stage{position:relative;display:flex;flex-direction:column;align-items:center;gap:92px;width:max-content;min-width:100%;padding:24px 28px 36px;isolation:isolate}
.hub-family-tree-cables{position:absolute;left:0;top:0;z-index:0;pointer-events:none;overflow:visible}
.hub-family-tree-cables path{fill:none;stroke:var(--accent,#b89e57);stroke-width:2;stroke-linecap:round}
.hub-family-tree-parents,.hub-family-tree-families{position:relative;z-index:1}
.hub-family-tree-parents h3,.hub-family-tree-families h3{margin:0 0 13px;text-align:center;font-size:.86rem}
.hub-family-tree-parent-row{display:flex;align-items:start;justify-content:center;gap:12px}
.hub-family-tree-families{display:flex;gap:55px;align-items:flex-start;justify-content:center}
.hub-family-tree-families h3{display:none}
.hub-family-tree-unit{display:flex;flex-direction:column;align-items:center;min-width:max-content;gap:88px}
.hub-family-tree-unit:not(:has(.hub-family-tree-kids)){gap:0}
.hub-family-tree-couple{display:flex;gap:10px;align-items:start;justify-content:center}
.hub-family-tree-kids{display:flex;gap:12px;justify-content:center;align-items:flex-start}
.hub-family-tree-person{width:118px;min-width:118px;max-width:118px;min-height:140px;padding:10px 7px;gap:2px;flex-shrink:0;border-radius:12px;background:var(--panel,#292d35);position:relative;z-index:1}
.hub-family-tree-person.is-focus{border-width:2px}
.hub-family-tree-avatar{width:56px;height:56px;border-radius:50%;overflow:hidden;display:flex;align-items:center;justify-content:center;background:var(--panel2,#5556);margin-bottom:5px}
.hub-family-tree-avatar img{width:100%;height:100%;object-fit:cover;display:block}
.hub-family-tree-avatar-fallback{font-size:25px;font-weight:650}
.hub-family-tree-first,.hub-family-tree-last{display:block;max-width:100%;font-weight:600;font-size:.78rem;line-height:1.2;overflow-wrap:anywhere;text-align:center}
.hub-family-tree-role{color:var(--accent,#b89e57);font-size:.63rem;margin-top:3px}
.hub-family-tree-generation::after{display:none!important}
@media(max-width:600px){.hub-family-tree-stage{padding:16px 20px 30px;gap:85px}.hub-family-tree-families{gap:36px}.hub-family-tree-person{width:110px;min-width:110px;max-width:110px}}

/* v655: all connected relatives, scrollable zoomable network */
.hub-family-tree-header{flex-wrap:wrap}
.hub-family-tree-controls{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.hub-family-tree-controls [data-tree-zoom-label]{min-width:46px;text-align:center;font-size:.85rem;font-variant-numeric:tabular-nums}
.hub-family-tree-viewport{overflow:auto;min-height:270px;height:min(68dvh,700px);border:1px solid var(--border,#8885);border-radius:12px;overscroll-behavior:contain;touch-action:pan-x pan-y}
.hub-family-tree-content{max-height:calc(92dvh - 110px);overflow:auto}
.hub-family-tree-scale-frame{position:relative;flex:none}
.hub-family-tree-network{position:relative;transform-origin:top left;isolation:isolate}
.hub-family-tree-network .hub-family-tree-person{box-sizing:border-box;width:118px;height:145px;min-height:145px;min-width:118px;max-width:118px}
.hub-family-tree-network .hub-family-tree-cables{z-index:0}
.hub-family-tree-network .hub-family-tree-cables .is-other-line{stroke-dasharray:4 5;opacity:.45}
.hub-family-tree-network .hub-family-tree-person{z-index:1}
@media(max-width:600px){.hub-family-tree-header{padding:10px}.hub-family-tree-controls{gap:5px}.hub-family-tree-controls .btn{padding:7px 10px}.hub-family-tree-viewport{height:65dvh}}
.hub-family-tree-viewport{width:100%;min-width:0;max-width:100%}

/* v656: drag to pan, pinch to zoom and mouse-wheel zoom inside the family tree */
.hub-family-tree-viewport{touch-action:none;cursor:grab;user-select:none;-webkit-user-select:none}
.hub-family-tree-viewport:active{cursor:grabbing}
.hub-family-tree-person{touch-action:none}

/* v657 family generation branches: connectors remain beneath cards. */
.hub-family-tree-network .hub-family-tree-cables{pointer-events:none}

/* The tree fills the visible viewport, with room for phone safe areas. */
.hub-family-tree-dialog {
 position:fixed;
 inset:0;
 width:100%;
 height:100%;
 height:100dvh;
 max-width:none;
 max-height:none;
 margin:0;
 padding:env(safe-area-inset-top) env(safe-area-inset-right)
  env(safe-area-inset-bottom) env(safe-area-inset-left);
 border:0;
 border-radius:0;
 box-sizing:border-box;
}
.hub-family-tree-dialog[open] {display:flex;flex-direction:column}
.hub-family-tree-header {flex:none;gap:4px 12px;padding:6px 12px}
.hub-family-tree-controls .btn {min-width:44px;min-height:44px}
.hub-family-tree-content {
 flex:1;
 min-height:0;
 max-height:none;
 padding:0;
 gap:0;
 overflow:hidden;
}
.hub-family-tree-content > p {padding:6px 12px}
.hub-family-tree-open {
 flex:none;
 max-width:calc(100% - 24px);
 margin:6px 12px;
 min-height:44px;
}
.hub-family-tree-viewport {
 flex:1;
 min-height:0;
 height:auto;
 border:0;
 border-radius:0;
 overflow:hidden;
}
.hub-family-tree-viewport.is-dragging,
.hub-family-tree-viewport.is-dragging .hub-family-tree-person {cursor:grabbing}
.hub-family-tree-scale-frame {
 width:calc(100% + var(--tree-width, 0px));
 height:calc(100% + var(--tree-height, 0px));
}
.hub-family-tree-canvas {
 position:absolute;
 left:calc((100% - var(--tree-width, 0px))/2);
 top:calc((100% - var(--tree-height, 0px))/2);
 width:var(--tree-width, 0px);
 height:var(--tree-height, 0px);
 overflow:hidden;
}
.hub-family-tree-network {position:absolute;top:0;left:0}
