/* Shared family interface: clear type, quiet colour and readable person cards. */
:root {
  --paper: #f6f8f7;
  --paper-deep: #edf2ef;
  --navy: #263a43;
  --navy-soft: #60716f;
  --gold: #658478;
  --line: #dce5e0;
  --portuguese: #759182;
  --dutch: #7e96a6;
  --family: #a39782;
  --shadow: 0 6px 24px #263a4307;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--navy); background: var(--paper); font: 18px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .55; }
a { color: #3d6c5a; text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid #719285; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.account-header, .heritage-nav, .heritage-shell { width: min(1240px, calc(100% - 3rem)); margin-inline: auto; }
.account-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.3rem; margin-top: 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.family-brand { font-size: 1rem; font-weight: 650; color: var(--navy); text-decoration: none; }
.account-controls { display: flex; align-items: center; justify-content: flex-end; gap: .8rem; min-width: 0; }
.account-controls strong { min-width: 0; font-size: .9rem; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-profile { display: inline-flex; flex-shrink: 0; border-radius: 50%; }
.account-controls .member-avatar { width: 40px; height: 40px; flex-basis: 40px; font-size: .84rem; }
.signout-button { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; padding: 8px; border: 0; border-radius: 9px; background: transparent; color: var(--navy-soft); text-decoration: none; }
.signout-button:hover { background: var(--paper-deep); }
.signout-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.heritage-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 0; }
.heritage-nav-links { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.heritage-nav-links a { display: inline-block; border: 1px solid transparent; border-radius: 8px; color: var(--navy-soft); padding: .55rem .75rem; text-decoration: none; font-size: .88rem; font-weight: 550; }
.heritage-nav-links a:hover { background: #eaf0ec; color: var(--navy); }
.heritage-nav-links .heritage-link { color: #426551; background: #edf3ee; border-color: #cbdace; }
.heritage-nav-links .heritage-link:hover, .heritage-nav-links .heritage-link.active { color: #315c49; background: #e2ece4; border-color: #b9cfbf; }
.heritage-nav-links .calendar-link { color: #476477; background: #edf2f5; border-color: #cbd7df; }
.heritage-nav-links .calendar-link:hover, .heritage-nav-links .calendar-link.active { color: #38576b; background: #e1eaf0; border-color: #b9cbd7; }
.heritage-nav > .button { flex-shrink: 0; }
.heritage-nav .nav-label-short, .heritage-nav .action-label-short { display: none; }
.heritage-hero { padding: 2rem 0 1.5rem; max-width: 920px; }
h1, h2, h3, h4 { font-family: inherit; line-height: 1.25; letter-spacing: -.025em; font-weight: 600; }
h1 { margin: 0; font-size: clamp(2rem, 3.7vw, 2.8rem); text-wrap: balance; }
h2 { font-size: 1.5rem; }
.heritage-subtitle { margin: .8rem 0 .6rem; color: #4f7163; font-size: 1.12rem; }
.heritage-intro { margin: .7rem 0; max-width: 850px; color: var(--navy-soft); white-space: pre-line; font-size: .97rem; }
.hero-actions { margin-top: .5rem; }
.text-button { border: 0; padding: .35rem .1rem; color: #3d6c5a; background: transparent; font-size: .88rem; text-decoration: underline; text-underline-offset: 4px; }
.draft-notice { display: flex; align-items: baseline; gap: .4rem 1rem; flex-wrap: wrap; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 9px; color: var(--navy-soft); background: #eef3ef; font-size: .84rem; }
.draft-notice strong { color: #4c6659; font-weight: 600; }
.access-notice { margin: .9rem 0 0; padding: .8rem 1rem; border-left: 3px solid #9ab0a5; color: var(--navy-soft); background: #f0f4f1; border-radius: 0 7px 7px 0; font-size: .9rem; }
.heritage-dialog [data-access-locked] { cursor: default; }
.notice { margin: 1rem 0; padding: .9rem 1rem; border: 1px solid #c5d9ce; border-radius: 9px; color: #375d48; background: #edf5ef; font-size: .95rem; }
.notice.error { color: #874f40; background: #fbefeb; border-color: #e7cfc6; }
.load-error { margin: 1.4rem 0; padding: 1.4rem; border: 1px solid #e7cfc6; border-radius: 10px; background: #fff; }
.load-error h2 { margin: 0; }
.heritage-records { padding-top: 1.7rem; }
.records-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.records-heading h2 { margin: 0; }
.records-heading .muted { margin: .35rem 0 0; font-size: .88rem; }
.records-actions, .detail-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: .65rem 1rem; border: 1px solid #476d59; border-radius: 9px; background: #476d59; color: #fff; text-decoration: none; font-size: .88rem; font-weight: 550; }
.button:hover:not(:disabled) { background: #365b47; }
.button-light { color: #3f6051; border-color: var(--line); background: #fff; }
.button-light:hover:not(:disabled) { background: #eaf1ec; }
.tree-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin: 1.2rem 0; }
.search-label { flex: 1; max-width: 500px; min-width: 200px; }
.search-label input { width: 100%; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--navy); font-size: .94rem; }
.view-switch { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #eaf0ec; }
.view-switch button { padding: .5rem .8rem; border: 0; border-radius: 7px; color: var(--navy-soft); background: transparent; font-size: .88rem; }
.view-switch button[aria-pressed=true] { background: #fff; color: var(--navy); box-shadow: 0 1px 4px #263a4310; }
.tree-toolbar > .text-button { margin-left: auto; }
.branch-legend { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem 1rem; margin: .5rem 0 1rem; font-size: .82rem; color: var(--navy-soft); }
.branch-dot { display: inline-flex; align-items: center; gap: .4rem; }
.branch-dot:before { content: ""; width: 8px; height: 8px; background: var(--family); border-radius: 50%; }
.branch-dot.portuguese:before { background: var(--portuguese); }
.branch-dot.dutch:before { background: var(--dutch); }
.line-key:before { content: ""; display: inline-block; width: 20px; border-top: 1px solid #9aaea4; margin-right: .4rem; vertical-align: middle; }
.ancestry-key:before { border-top-style: dashed; }
.family-workbench { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.tree-area { min-width: 0; }
.tree-view { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.family-list-view { min-width: 0; }
.zoom-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; padding: .7rem .9rem; background: #f0f4f1; border-bottom: 1px solid var(--line); }
.zoom-toolbar button { min-width: 40px; min-height: 38px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--navy); font-size: .88rem; }
.zoom-toolbar span { min-width: 48px; text-align: center; color: var(--navy-soft); font-size: .84rem; }
.tree-help { margin: .7rem 1rem; color: var(--navy-soft); font-size: .86rem; }
.tree-viewport { height: 620px; max-height: 72vh; min-height: 340px; overflow: auto; overscroll-behavior: contain; background: #f8faf9; scrollbar-color: #bccbc2 #f1f5f2; }
.tree-canvas { position: relative; transform-origin: top left; }
.tree-connectors { position: absolute; inset: 0; pointer-events: none; }
.tree-connectors path { fill: none; stroke: #aabbb0; stroke-width: 1.8; }
.tree-connectors path.ancestry { stroke-dasharray: 6 4; }
.tree-connectors path.partner { stroke: #7d9887; stroke-width: 2; }
.person-node { position: absolute; display: flex; align-items: center; gap: .8rem; overflow: hidden; border: 1px solid #d3dfd7; border-left: 4px solid var(--family); border-radius: 12px; padding: 1rem; text-align: left; color: var(--navy); background: #fff; box-shadow: 0 3px 12px #263a4307; }
.person-node.portuguese { border-left-color: var(--portuguese); }
.person-node.dutch { border-left-color: var(--dutch); }
.person-node.other { border-left-color: #a6aeb5; }
.person-node:hover { border-color: #8da697; box-shadow: 0 4px 16px #263a4310; }
.person-node.selected { outline: 3px solid #789b88; outline-offset: 3px; z-index: 2; }
.person-node.search-dim { opacity: .3; }
.person-node.search-match { box-shadow: 0 0 0 3px #a7c5b5; }
.node-copy { display: grid; gap: .5rem; min-width: 0; }
.node-name { font-size: 1.125rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.node-period { font-size: .9375rem; color: var(--navy-soft); line-height: 1.4; overflow-wrap: anywhere; }
.member-avatar { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 52px; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: #dce7df; color: #3f6450; font-size: 1rem; font-weight: 600; }
.member-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.people-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 1rem; }
.list-person { display: flex; align-items: center; flex-direction: column; gap: 1rem; width: 100%; min-width: 0; min-height: 228px; padding: 1.4rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--navy); text-align: center; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.list-person:hover { border-color: #9bb5a5; box-shadow: 0 5px 18px #263a4310; }
.list-person.selected { border-color: #6e9681; box-shadow: 0 0 0 2px #c1d8c9; }
.list-person .member-avatar { width: 76px; height: 76px; flex: 0 0 76px; font-size: 1.35rem; }
.list-person-copy { display: grid; gap: .45rem; min-width: 0; }
.list-person-name { font-size: 1.125rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.list-person-meta { font-size: .9375rem; line-height: 1.5; color: var(--navy-soft); overflow-wrap: anywhere; }
.person-details { scroll-margin-top: 1.5rem; padding: 1.7rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 0; }
.person-details h3 { margin: .6rem 0 .8rem; font-size: 1.65rem; overflow-wrap: anywhere; }
.person-details .person-branch { margin: 0 0 .8rem; color: #607b6b; font-size: .88rem; font-weight: 550; }
.person-detail-avatar { float: left; margin: 0 1rem .6rem 0; }
.person-detail-avatar .member-avatar { width: 64px; height: 64px; flex-basis: 64px; font-size: 1.15rem; }
.muted { color: var(--navy-soft); }
.person-details p { color: #516361; font-size: 1rem; white-space: pre-line; overflow-wrap: anywhere; }
.detail-facts { display: grid; gap: .4rem; margin: 1rem 0; font-size: .94rem; }
.detail-facts > div { display: grid; grid-template-columns: 65px minmax(0, 1fr); gap: .75rem; }
.detail-facts dt { color: var(--navy-soft); }
.detail-facts dd { margin: 0; overflow-wrap: anywhere; }
.detail-source { padding: .8rem 1rem; border-radius: 8px; color: var(--navy-soft); background: #f1f5f2; font-size: .86rem !important; }
.profile-link { display: inline-block; padding: .7rem 1rem; border: 1px solid #cfddd4; border-radius: 8px; background: #f0f6f2; font-size: .94rem; text-decoration: none; }
.detail-actions { margin: 1rem 0 0; }
.danger-button { padding: .65rem .1rem; border: 0; color: #985747; background: transparent; font-size: .86rem; text-decoration: underline; text-underline-offset: 3px; }
.connections-title { clear: both; margin: 1.4rem 0 .8rem; padding-top: 1.2rem; border-top: 1px solid var(--line); font-size: 1.08rem; }
.connection-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr)); gap: .8rem; margin: 0; padding: 0; list-style: none; }
.connection-list li { min-width: 0; padding: 1rem; border: 1px solid #e2e9e4; border-radius: 9px; background: #f7faf8; font-size: .94rem; line-height: 1.5; }
.connection-person { padding: 0; border: 0; background: none; color: #3e6651; font-size: .96rem; font-weight: 600; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.connection-kind { display: block; margin-bottom: .3rem; color: var(--navy-soft); font-size: .84rem; }
.connection-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .6rem; }
.connection-actions button { padding: .1rem 0; border: 0; color: #5d7b6a; background: none; font-size: .83rem; text-decoration: underline; }
.connection-note { display: block; margin-top: .5rem; color: var(--navy-soft); white-space: pre-line; }
.empty-state { padding: 1rem; color: var(--navy-soft); }
.heritage-footer { padding: 2rem 0; color: var(--navy-soft); font-size: .86rem; }
.heritage-footer p { margin: .35rem 0; }
.heritage-dialog { width: min(650px, calc(100% - 2rem)); max-height: 90vh; padding: 1.7rem; color: var(--navy); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 80px #223b4330; }
.heritage-dialog::backdrop { background: #223b4370; }
.heritage-dialog form { display: grid; gap: .9rem; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog-heading h2 { margin: 0; font-size: 1.4rem; }
.dialog-close { width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: 8px; color: var(--navy-soft); background: #f0f4f1; font-size: 1.5rem; }
.heritage-dialog label { display: grid; gap: .4rem; min-width: 0; font-size: .94rem; font-weight: 550; }
.heritage-dialog input, .heritage-dialog select, .heritage-dialog textarea { width: 100%; min-width: 0; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 8px; color: var(--navy); background: #fff; font-size: .96rem; font-weight: 400; }
.heritage-dialog textarea { resize: vertical; }
.portrait-editor { display: flex; align-items: flex-start; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: #f7faf8; }
.portrait-preview .member-avatar { width: 76px; height: 76px; flex-basis: 76px; font-size: 1.3rem; }
.portrait-controls { min-width: 0; flex: 1; }
.portrait-controls .text-button { display: block; margin: .35rem 0; }
.portrait-controls input[type=file] { padding: .45rem; font-size: .85rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.field-help { margin: 0; color: var(--navy-soft); font-size: .84rem; }
.form-error { margin: 0; padding: .8rem 1rem; border: 1px solid #e2c6bc; border-radius: 8px; color: #8d4f3f; background: #fcf0eb; font-size: .94rem; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
@media (max-width: 760px) {
  .account-header, .heritage-nav, .heritage-shell { width: calc(100% - 1.6rem); }
  .account-header { padding: .8rem .9rem; gap: .65rem; }
  .family-brand { font-size: .88rem; }
  .account-controls { gap: .5rem; }
  .account-controls strong { max-width: 110px; font-size: .82rem; }
  .account-controls .member-avatar { width: 35px; height: 35px; flex-basis: 35px; }
  .heritage-nav { align-items: center; gap: .4rem; flex-wrap: nowrap; }
  .heritage-nav-links { gap: .3rem; flex-wrap: nowrap; }
  .heritage-nav-links a { display: inline-flex; align-items: center; min-height: 40px; padding: .45rem .55rem; font-size: .75rem; line-height: 1.25; white-space: nowrap; }
  .heritage-nav > .button { font-size: .75rem; padding: .5rem .6rem; min-height: 40px; border-radius: 999px; gap: .25rem; }
  .heritage-nav .nav-label-full, .heritage-nav .action-label-full { display: none; }
  .heritage-nav .nav-label-short, .heritage-nav .action-label-short { display: inline; }
  .heritage-hero { padding: 1.3rem 0 1rem; }
  h1 { font-size: 1.9rem; }
  .heritage-subtitle { font-size: 1rem; }
  .heritage-intro { font-size: .92rem; }
  .draft-notice { font-size: .8rem; }
  .records-actions { width: 100%; }
  .tree-toolbar { gap: .65rem; }
  .search-label { max-width: none; flex-basis: 100%; }
  .tree-toolbar > .text-button { margin-left: auto; }
  .people-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .list-person { padding: 1.1rem .7rem; min-height: 225px; }
  .list-person-name { font-size: 1.0625rem; }
  .list-person-meta { font-size: .9375rem; }
  .tree-viewport { min-height: 350px; height: 65vh; max-height: 620px; }
  .person-details { padding: 1.2rem; }
  .heritage-dialog { padding: 1.2rem; }
}
@media (max-width: 390px) {
  .family-brand { max-width: 80px; line-height: 1.3; }
  .account-controls strong { max-width: 92px; }
  .heritage-nav { flex-wrap: nowrap; }
  .heritage-nav > .button { margin-left: auto; }
  .people-list { grid-template-columns: 1fr; }
  .list-person { min-height: 0; flex-direction: row; text-align: left; padding: 1.1rem; }
  .list-person .member-avatar { width: 64px; height: 64px; flex-basis: 64px; }
  .form-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
