:root {
    --bg: #f2f4f8;
    --surface: #ffffff;
    --surface-2: #f8fbff;
    --text: #1e2430;
    --muted: #5f6b7a;
    --border: #d6deea;
    --accent: #0a67d0;
    --accent-hover: #084f9f;
    --shadow: 0 10px 28px rgba(16, 29, 61, 0.08);

    --parent-bg: #bfe3f6;
    --parent-border: #0a67d0;
    /* --child-bg: #9ddc90;
    --child-border: #0a67d0; */
    --child-bg: #bfe3f6;
    --child-border: #0a67d0;

    --node-border: var(--parent-border);

    /* Horizontal view spacing */
    --h-node-gap-x: 60px;
    --h-node-gap-y: 20px;

    /* Vertical view spacing */
    --v-node-gap-x: 18px;
    --v-node-gap-y: 44px;
}


html[data-theme="dark"] {
    --bg: #121212;
    --surface: #1e1e1e;
    --surface-2: #232a33;
    --text: #eeeeee;
    --muted: #a8b0ba;
    --border: #333a44;
    --accent: #4da6ff;
    --accent-hover: #2f8ef3;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.35);

    --parent-bg: #1f4d67;
    --parent-border: #63b7ff;
    /* --child-bg: #2e5f3b;
    --child-border: #74d08b; */
    --child-bg: #1f4d67;
    --child-border: #63b7ff;

    --node-border: var(--parent-border);
}

html[data-theme="dark"] .page-header {
    background: rgba(30, 30, 30, 0.92);
}

html[data-theme="dark"] .tree-viewport {
    background:
        linear-gradient(to right, rgba(18, 18, 18, 0.58), rgba(18, 18, 18, 0.58)),
        var(--bg);
}

html[data-theme="dark"] .button-link--view:hover,
html[data-theme="dark"] .tree-zoom-button:hover:not(:disabled),
html[data-theme="dark"] .node-context-menu__action:hover,
html[data-theme="dark"] .home-overlay-link:hover {
    background: #243244;
    border-color: rgba(77, 166, 255, 0.38);
}

html[data-theme="dark"] .button-link {
    color: #fff;
}

html[data-theme="dark"] .button-link--view {
    color: var(--text);
}

html[data-theme="dark"] 
.button-link--tree-toggle {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0 0.85rem;
    white-space: nowrap;
    font-size: 0.9rem;
    line-height: 1;
}

.tree-family-switch {
    min-width: 130px;
    max-width: 180px;
    height: 38px;
}

.button-link--view.is-active {
    background: #203246;
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px rgba(77, 166, 255, 0.2);
}

html[data-theme="dark"] .home-overlay-link,
html[data-theme="dark"] .tree-zoom-strip,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .nav-toggle {
    background: rgba(26, 30, 37, 0.94);
    border-color: rgba(77, 166, 255, 0.28);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
}

html[data-theme="dark"] .home-overlay-link,
html[data-theme="dark"] .tree-zoom-button,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .nav-toggle {
    color: #eef5ff;
}

html[data-theme="dark"] .tree-zoom-button,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .nav-toggle {
    background: #232a33;
    border-color: rgba(77, 166, 255, 0.24);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .nav-toggle:hover,
html[data-theme="dark"] .home-overlay-link:hover {
    background: #2a3543;
    border-color: rgba(77, 166, 255, 0.42);
}

html[data-theme="dark"] .nav-toggle__line {
    background: #eef5ff;
}

html[data-theme="dark"] .tree-zoom-button {
    border-color: rgba(77, 166, 255, 0.2);
}

html[data-theme="dark"] .node-context-menu {
    background: #1b2027;
    border-color: rgba(77, 166, 255, 0.22);
    box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .node-context-menu__header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .node-context-menu__title {
    color: #f2f7ff;
}

html[data-theme="dark"] .node-context-menu__subtitle {
    color: #aeb8c4;
}

html[data-theme="dark"] .node-context-menu__action {
    background: #232a33;
    border-color: rgba(77, 166, 255, 0.14);
    color: #eef5ff;
}

html[data-theme="dark"] .node-context-menu__action:hover {
    background: #2b3644;
    border-color: rgba(77, 166, 255, 0.36);
}

html[data-theme="dark"] .node-context-menu__action.is-disabled,
html[data-theme="dark"] .node-context-menu__action[aria-disabled="true"] {
    background: #1c2128;
    color: #7f8c99;
    border-color: rgba(77, 166, 255, 0.1);
}

html[data-theme="dark"] .v-node-meta {
    color: #c7d3df;
}

html[data-theme="dark"] .h-node,
html[data-theme="dark"] .v-node {
    color: #eef5ff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.38);
}

html[data-theme="dark"] .h-node,
html[data-theme="dark"] .v-node {
    background: var(--parent-bg);
    border-color: var(--parent-border);
}

html[data-theme="dark"] .node-name,
html[data-theme="dark"] .v-node-name,
html[data-theme="dark"] .node-mother-line__name {
    color: #f4f9ff;
}

html[data-theme="dark"] .node-meta,
html[data-theme="dark"] .v-node-meta,
html[data-theme="dark"] .node-mother-line__label {
    color: #d3deea;
}

html[data-theme="dark"] .tree-person-node:hover {
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.44);
    border-color: #8acaff;
}

html[data-theme="dark"] .person-block-left {
    background: #1d2732;
}

html[data-theme="dark"] .person-block-right {
    background: #2c2518;
}

html[data-theme="dark"] .person-block-notes {
    background: #1d2a1d;
}

html[data-theme="dark"] .person-row {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .page-actions {
    background: transparent;
}

html[data-theme="dark"] .page-nav.is-open .page-actions,
html[data-theme="dark"] .page-nav.page-nav--static.is-open .page-actions {
    background: rgba(30, 30, 30, 0.98);
}

html[data-theme="dark"] .person-page-shell,
html[data-theme="dark"] .person-shell,
html[data-theme="dark"] .person-block,
html[data-theme="dark"] .person-history {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
}

html[data-theme="dark"] .person-block {
    border-color: rgba(77, 166, 255, 0.12);
}

html[data-theme="dark"] .person-block-left {
    background: #1f2934;
}

html[data-theme="dark"] .person-block-right {
    background: #2b2418;
}

html[data-theme="dark"] .person-block-notes {
    background: #1f2c20;
}

html[data-theme="dark"] .person-history {
    background: #1c232c;
    border-color: rgba(77, 166, 255, 0.14);
}

html[data-theme="dark"] .person-row {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .person-label {
    color: #b7c1cc;
}

html[data-theme="dark"] .person-value,
html[data-theme="dark"] .person-notes {
    color: #eef5ff;
}

html[data-theme="dark"] .person-detail__headline {
    background: rgba(35, 42, 51, 0.92);
    border-color: rgba(77, 166, 255, 0.16);
}

html[data-theme="dark"] .person-detail__headline h2 {
    color: #f2f7ff;
}

html[data-theme="dark"] .person-detail__years {
    color: #b7c1cc;
}

html[data-theme="dark"] .person-detail-card {
    background: linear-gradient(135deg, rgba(77, 166, 255, 0.08), rgba(77, 166, 255, 0.03));
    border-color: rgba(77, 166, 255, 0.14);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}

html[data-theme="dark"] .person-detail-card h2 {
    color: #f2f7ff;
}

html[data-theme="dark"] .person-inline-note {
    color: #9eacb9;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
}

.page-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.page-header__inner {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0.8rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.page-header__title-wrap {
    min-width: 0;
    flex: 1 1 auto;
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.page-nav {
    flex: 0 0 auto;
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 0 0 auto;
}

.view-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding-left: 0.65rem;
    margin-left: 0.1rem;
    border-left: 1px solid var(--border);
}

.view-actions__group {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.view-actions__divider {
    display: inline-block;
    width: 1px;
    height: 30px;
    background: var(--border);
    border-radius: 999px;
    opacity: 0.95;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.nav-toggle {
    display: none;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.nav-toggle__line {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow);
    font-size: 1.05rem;
    line-height: 1;
}

.theme-toggle:hover {
    border-color: var(--accent);
}

.page-main {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0.45rem 1.25rem 3.5rem;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
}

.button-link:hover {
    background: var(--accent-hover);
}

.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;
}

.button-link--icon-home {
    position: relative;
    width: 46px;
    min-width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 12px;
    justify-self: start;
}

.page-actions .button-link--icon-home {
    width: 46px;
    min-width: 46px;
    padding: 0;
}

.home-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.home-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.button-link.is-active {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.95);
}

.button-link--primary {
    min-width: 92px;
}

.button-link--view {
    gap: 0;
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(16, 29, 61, 0.06);
}

.button-link--view:hover {
    background: #eef4fb;
    color: var(--text);
}

.button-link {
    color: #fff;
}

.button-link--view {
    color: var(--text);
}

.button-link--view.is-active {
    background: #e6f1ff;
    color: var(--accent-hover);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px rgba(10, 103, 208, 0.18);
}

.view-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 20px;
    min-width: 20px;
    height: 16px;
}

.view-icon span {
    display: block;
    background: currentColor;
    border-radius: 999px;
}

.view-icon--horizontal {
    flex-direction: column;
}

.view-icon--horizontal span {
    width: 16px;
    height: 2px;
}

.view-icon--vertical {
    flex-direction: row;
}

.view-icon--vertical span {
    width: 2px;
    height: 14px;
}

.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.tree-viewport {
    overflow: auto;
    min-height: calc(100vh - 150px);
    padding: 1rem 1rem 2rem;
    background:
        linear-gradient(to right, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.55)),
        var(--bg);
    scrollbar-width: none;
}

.tree-viewport::-webkit-scrollbar {
    height: 0;
    width: 0;
}

.tree-scale-box {
    position: relative;
    display: inline-block;
    min-width: 100%;
}

.tree-stage {
    position: relative;
    display: inline-block;
    min-width: 0;
    padding-right: 140px;
    padding-bottom: 28px;
    transform-origin: top left;
    will-change: transform;
}

.tree-content {
    position: relative;
    z-index: 10;
    display: inline-block;
    min-width: 0;
    padding-right: 40px;
}

#connectionLayer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}

#connectionLayer path,
#connectionLayer line {
    stroke-linecap: round;
    stroke-linejoin: round;
}

.h-root {
    display: flex;
    align-items: flex-start;
    min-width: max-content;
}

.h-branch {
    display: flex;
    align-items: center;
}

.h-children {
    display: flex;
    flex-direction: column;
    gap: var(--h-node-gap-y);
    margin-left: var(--h-node-gap-x);
}

.h-node,
.v-node {
    width: 220px;
    max-width: 220px;
    min-width: 220px;
    padding: 10px 12px 8px;
    border-radius: 10px;
    border: 2px solid var(--parent-border);
    background: var(--parent-bg);
    text-align: center;
    position: relative;
    z-index: 10;
    box-shadow: var(--shadow);
    color: var(--text);
    word-wrap: normal;
    overflow-wrap: normal;
}

.node-name,
.v-node-name {
    font-weight: 700;
    padding-right: 28px;
}

.node-meta,
.v-node-meta {
    margin-top: 0.2rem;
}

.v-tree-root {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-width: max-content;
    padding: 0.5rem 0;
}

.v-branch {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: max-content;
}

.v-children {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: var(--v-node-gap-x);
    margin-top: var(--v-node-gap-y);
    min-width: max-content;
}

.v-node-name {
    line-height: 1.25;
}

.node-meta,
.v-node-meta {
    overflow-wrap: normal;
}

.node-mother-line {
    text-align: left;
    font-weight: 600;
}

.node-mother-line__label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.82;
}

.node-mother-line__name {
    font-weight: 700;
}

.tree-person-node {
    position: relative;
    overflow: visible;
    isolation: isolate;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.tree-person-node:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 34px rgba(16, 29, 61, 0.13);
}

.tree-person-node.is-node-selected {
    outline: 3px solid rgba(10, 103, 208, 0.28);
    outline-offset: 3px;
}

.tree-person-node.is-deceased {
    opacity: 0.9;
    filter: saturate(0.82);
}

.node-options-trigger {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(10, 103, 208, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0a67d0;
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 3px 10px rgba(16, 29, 61, 0.08);
}

.node-options-trigger:hover {
    background: #eef5ff;
    border-color: rgba(10, 103, 208, 0.34);
}

.node-options-trigger.is-trigger-active {
    background: #dcecff;
    border-color: rgba(10, 103, 208, 0.5);
}

.node-context-menu {
    position: fixed;
    z-index: 1000;
    min-width: 260px;
    max-width: 320px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(10, 24, 52, 0.2);
    padding: 0.75rem;
}

.node-context-menu[hidden] {
    display: none !important;
}

.node-context-menu__header {
    padding-bottom: 0.65rem;
    margin-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
}

.node-context-menu__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.node-context-menu__subtitle {
    margin-top: 0.25rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.node-context-menu__actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.node-context-menu__action {
    display: block;
    text-decoration: none;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font-weight: 600;
}

.node-context-menu__action:hover {
    background: #eef5ff;
    border-color: #b9d3f3;
}

.node-context-menu__action.is-disabled,
.node-context-menu__action[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: auto;
}

.sticky-x-scroll {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    overflow-x: auto;
    overflow-y: hidden;
    height: 18px;
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid var(--border);
    display: none;
}

.sticky-x-scroll.is-visible {
    display: block;
}

.sticky-x-scroll__inner {
    height: 1px;
}









.home-overlay-link {
    display: none !important;
}

.home-overlay-link:hover {
    display: none !important;
}

.tree-nav-float {
    display: none !important;
}

.tree-zoom-strip {
    display: none !important;
}

.tree-zoom-strip__buttons {
    display: none !important;
}

.tree-zoom-button {
    display: none !important;
}



.tree-zoom-button--value {
    min-width: 72px;
    display: none !important;
    font-size: 0.95rem;
}


.tree-person-node {
    padding-top: 2.55rem;
}

.node-collapse-trigger,
.node-options-trigger {
    position: absolute;
    z-index: 25;
    pointer-events: auto;
    top: 6px;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(10, 103, 208, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0a67d0;
    line-height: 1;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 3px 10px rgba(16, 29, 61, 0.08);
}

.node-collapse-trigger {
    left: 6px;
    font-size: 18px;
}

.node-options-trigger {
    right: 6px;
    font-size: 22px;
}

.node-collapse-trigger:hover,
.node-options-trigger:hover {
    background: #eef5ff;
    border-color: rgba(10, 103, 208, 0.34);
}

.node-collapse-trigger.is-collapsed,
.node-options-trigger.is-trigger-active {
    background: #dcecff;
    border-color: rgba(10, 103, 208, 0.5);
}

.node-collapse-trigger.is-disabled,
.node-collapse-trigger[disabled] {
    opacity: 0.35;
    cursor: default;
}

.h-branch.is-collapsed > .h-children,
.v-branch.is-collapsed > .v-children {
    display: none !important;
}





.node-spouses-inline {
    margin-top: 0.28rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.18rem;
    width: 100%;
}

.node-spouses-inline.has-groups .node-spouse-line.is-former:first-of-type,
.node-spouses-inline.has-groups .node-spouse-line.is-deceased:first-of-type {
    margin-top: 0.24rem;
    padding-top: 0.22rem;
    border-top: 1px solid rgba(255, 255, 255, 0.28);
}

html[data-theme="dark"] .node-spouses-inline.has-groups .node-spouse-line.is-former:first-of-type,
html[data-theme="dark"] .node-spouses-inline.has-groups .node-spouse-line.is-deceased:first-of-type {
    border-top-color: rgba(255, 255, 255, 0.18);
}

.node-spouse-line {
    display: block;
    width: 100%;
    line-height: 1.18;
}

.node-spouse-name {
    display: block;
}

.node-spouse-label {
    display: block;
    margin-left: 0;
    opacity: 0.88;
    font-size: 0.92em;
}

.person-detail-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(10, 24, 52, 0.08);
    padding: 1.2rem 1.25rem;
    max-width: 980px;
    margin: 0 auto;
}

.person-detail__headline {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.65rem;
    padding: 0.95rem 1rem;
    margin: 0 0 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
}

.person-detail__headline h2 {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1.2;
    color: var(--text);
}

.person-detail__years {
    color: var(--muted);
    font-weight: 600;
}

.person-detail-card {
    background:
        linear-gradient(135deg, rgba(10, 103, 208, 0.06), rgba(10, 103, 208, 0.02));
}

/* ===== PERSON VIEW PAGE ===== */
.page-main {
    padding: 1rem 0 1.5rem;
}

.page-shell {
    width: 100%;
}

.page-nav--static {
    margin-left: auto;
}

.person-page-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

.person-detail-card {
    background: linear-gradient(135deg, rgba(10, 103, 208, 0.06), rgba(10, 103, 208, 0.02));
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(10, 24, 52, 0.08);
    padding: 1.2rem 1.25rem;
}

.person-detail__headline,

.person-detail__headline h2,
.person-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.person-detail__years,

.person-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.2rem;
}

.person-block {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.person-block-left {
    background: #f8fbff;
}

.person-block-right {
    background: #fffaf2;
}

.person-block-notes {
    grid-column: 1 / -1;
    background: #f6fff6;
}

.person-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.75rem;
    padding: 0.42rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.person-row:last-child {
    border-bottom: none;
}

.person-label {
    font-weight: 600;
    color: var(--muted);
}

.person-value {
    color: var(--text);
}

.person-notes {
    white-space: pre-wrap;
    line-height: 1.5;
}

.person-detail__empty {
    color: var(--muted);
    margin: 0;
}



.person-inline-link{
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.person-inline-link:hover{
    color: var(--accent-hover);
    text-decoration: underline;
}

.person-inline-note{
    color: var(--muted);
    font-weight: 500;
}


.person-history{
    margin:10px 0 16px;
    padding:8px 10px;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:10px;
}

.person-history-link{
    text-decoration:none;
    color:var(--accent);
    font-weight:600;
}

.person-history-link:hover{
    text-decoration:underline;
}









/* 7.8.13: compact segmented view toggle + single-row narrow header */
.view-icon span {
    display: none;
}

.view-icon::before {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
}

.view-icon--horizontal::before {
    content: "↔";
}

.view-icon--vertical::before {
    content: "↕";
}

/* V8.0.27: single mobile breakpoint for header/menu/home-link only */


@media (max-width: 768px) {
    .tree-viewport {
        padding: 0.75rem 0.5rem 1.5rem;
    }

    .v-node,
    .h-node {
        min-width: 180px;
        width: 180px;
        max-width: 180px;
        padding: 0.8rem 0.65rem 0.6rem;
    }

    .tree-stage {
        padding-right: 100px;
    }

    .v-node-id {
        font-size: 0.84rem;
    }

    .node-context-menu {
        min-width: 220px;
        max-width: min(92vw, 320px);
    }

    .node-options-trigger {
        width: 34px;
        height: 34px;
        top: 5px;
        right: 5px;
    }
}

/* ===== FINAL CONSISTENCY POLISH ===== */

a:not(.button-link):not(.node-context-menu__action):not(.admin-link) {
    color: var(--accent);
    text-decoration: none;
}

a:not(.button-link):not(.node-context-menu__action):not(.admin-link):hover {
    text-decoration: underline;
}

html[data-theme="dark"] a:not(.button-link):not(.node-context-menu__action):not(.admin-link) {
    color: #6fb7ff;
}

html[data-theme="dark"] a:not(.button-link):not(.node-context-menu__action):not(.admin-link):hover {
    color: #9ed0ff;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

html[data-theme="dark"] :focus-visible {
    outline-color: #6fb7ff;
}

.small-muted,
.person-meta-muted {
    color: var(--muted);
}

html[data-theme="dark"] .small-muted,
html[data-theme="dark"] .person-meta-muted {
    color: #a8b4c2;
}



.person-finder-trigger {
    min-width: 52px;
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.person-finder-trigger__icon {
    font-size: 1.2rem;
    line-height: 1;
}

.person-finder-modal-open {
    overflow: hidden;
}

.person-finder-modal {
    position: fixed;
    inset: 0;
    z-index: 1300;
}

.person-finder-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
}

.person-finder-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(560px, calc(100vw - 2rem));
    margin: min(12vh, 4rem) auto 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 28px 70px rgba(10, 24, 52, 0.28);
    padding: 1.25rem;
}

.person-finder-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.person-finder-modal__title {
    margin: 0;
    font-size: 1.25rem;
}

.person-finder-modal__subtitle,
.person-finder-form__hint {
    margin: 0.45rem 0 0;
    color: var(--muted);
}

.person-finder-modal__close {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(10, 103, 208, 0.18);
    background: rgba(255, 255, 255, 0.92);
    color: var(--accent);
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}

.person-finder-form {
    display: grid;
    gap: 1rem;
}

.person-finder-form__field {
    display: grid;
    gap: 0.45rem;
}

.person-finder-form__field label {
    font-weight: 700;
}

.person-finder-form__field select {
    width: 100%;
    min-height: 50px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: 0.7rem 0.85rem;
    font: inherit;
}

.person-finder-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tree-person-node.is-search-focus {
    outline: 4px solid rgba(10, 103, 208, 0.5);
    outline-offset: 4px;
    box-shadow: 0 0 0 8px rgba(10, 103, 208, 0.14), 0 18px 42px rgba(16, 29, 61, 0.18);
}

html[data-theme="dark"] .person-finder-modal__dialog {
    background: #1b2027;
    border-color: rgba(77, 166, 255, 0.24);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.52);
}

html[data-theme="dark"] .person-finder-modal__close,
html[data-theme="dark"] .person-finder-form__field select {
    background: #232a33;
    color: #eef5ff;
    border-color: rgba(77, 166, 255, 0.24);
}

html[data-theme="dark"] .person-finder-modal__close:hover,
html[data-theme="dark"] .person-finder-form__field select:focus {
    background: #2a3543;
    border-color: rgba(77, 166, 255, 0.42);
}

@media (max-width: 640px) {
    .person-finder-modal__dialog {
        width: calc(100vw - 1rem);
        margin-top: 1rem;
        padding: 1rem;
        border-radius: 16px;
    }

    .person-finder-form__actions {
        justify-content: stretch;
    }

    .person-finder-form__actions .button-link {
        flex: 1 1 100%;
        justify-content: center;
    }
}


/* ===== RESPONSIVE FAMILY TREE HEADER ===== */
@media (max-width: 980px) {
    .page-header__inner {
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem 0.9rem;
    }

    .page-header__title-wrap {
        flex: 1 1 calc(100% - 60px);
        min-width: 0;
    }

    .page-header h1 {
        font-size: 1.05rem;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .nav-toggle {
        display: inline-flex;
        margin-left: auto;
        flex: 0 0 auto;
    }

    .page-header__actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: start;
        gap: 0.65rem;
    }

    .page-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        display: none;
    }

    .page-nav.is-open {
        display: block;
    }

    .page-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .page-actions .button-link {
        min-width: 0;
        width: 100%;
        padding: 0.72rem 0.8rem;
        font-size: 0.95rem;
    }

    .view-actions {
        grid-column: 2;
        grid-row: 1;
        margin-left: auto;
        padding-left: 0.6rem;
    }

    .page-main {
        padding: 0.45rem 0.75rem 3.5rem;
    }
}

@media (max-width: 640px) {
    .page-header__actions {
        grid-template-columns: 1fr;
    }

    .view-actions {
        grid-column: 1;
        grid-row: 3;
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        border-left: 0;
        border-top: 1px solid var(--border);
        padding-top: 0.65rem;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .view-actions__divider {
        height: 24px;
    }

    .view-actions .button-link,
    .view-actions .theme-toggle {
        flex: 0 0 auto;
    }

    .button-link--tree-toggle {
        height: 38px;
        padding: 0 0.7rem;
        font-size: 0.85rem;
    }

    .page-actions {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .tree-zoom-strip {
        display: none !important;
    }

    .tree-zoom-button {
        display: none !important;
    }

    .tree-zoom-button--value {
        min-width: 68px;
    }
}

.person-flash {
    max-width: 980px;
    margin: 0 auto 1rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(10, 103, 208, 0.08);
    color: var(--text);
}

.person-flash--success {
    background: rgba(33, 150, 83, 0.12);
    border-color: rgba(33, 150, 83, 0.28);
}

.person-flash--error {
    background: rgba(181, 31, 46, 0.10);
    border-color: rgba(181, 31, 46, 0.22);
}

.person-block-media {
    grid-column: 1 / -1;
    background: #fff;
}

.person-media__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.person-media__header h3 {
    margin: 0 0 0.2rem;
}

.person-media__intro {
    margin: 0;
    color: var(--muted);
}

.person-media__upload {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: rgba(10, 103, 208, 0.04);
}

.person-media__filelabel {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.person-media__fileinput {
    display: block;
    width: 100%;
    max-width: 520px;
}

.person-media__upload-hint {
    margin-top: 0.45rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.person-media__upload-actions {
    margin-top: 0.75rem;
}

.person-media__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.person-media__item {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.8rem;
    background: rgba(255,255,255,0.72);
}

.person-media__preview {
    display: block;
}

.person-media__thumb-link {
    display: block;
}

.person-media__thumb,
.person-media__video {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    background: rgba(0,0,0,0.08);
}

.person-media__video {
    aspect-ratio: 16 / 10;
}

.person-media__missing {
    display: flex;
    min-height: 150px;
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: rgba(190, 18, 60, 0.06);
    color: var(--text);
}

.person-media__missing span {
    color: var(--muted);
    font-size: 0.92rem;
}

.person-media__title {
    margin-top: 0.5rem;
    font-weight: 600;
    word-break: break-word;
}

.person-media__badge {
    display: inline-block;
    margin-top: 0.45rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(10, 103, 208, 0.10);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
}

.person-media__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.7rem;
}

.person-media__action-form {
    margin: 0;
}

html[data-theme="dark"] .person-block-media {
    background: rgba(22, 31, 45, 0.92);
}

html[data-theme="dark"] .person-media__upload {
    background: rgba(10, 103, 208, 0.08);
}

html[data-theme="dark"] .person-media__item {
    background: rgba(10, 18, 28, 0.55);
}

@media (max-width: 720px) {
    .person-media__grid {
        grid-template-columns: 1fr;
    }

    .person-media__thumb,
    .person-media__video {
        aspect-ratio: 4 / 3;
    }
}

.button-link--danger {
    background: #b51f2e;
    color: #fff;
}

.button-link--danger:hover {
    background: #8f1824;
}

.node-context-menu__action--danger {
    color: #b51f2e;
    border-color: rgba(181, 31, 46, 0.35);
    background: rgba(181, 31, 46, 0.06);
}

.node-context-menu__action--danger:hover {
    color: #fff;
    background: #b51f2e;
    border-color: #b51f2e;
}

html[data-theme="dark"] .node-context-menu__action--danger {
    color: #ff9aa5;
    border-color: rgba(255, 154, 165, 0.42);
    background: rgba(181, 31, 46, 0.18);
}

html[data-theme="dark"] .node-context-menu__action--danger:hover {
    color: #fff;
    background: #b51f2e;
    border-color: #b51f2e;
}

.delete-person-card {
    max-width: 980px;
    margin: 0 auto;
}

.delete-person-warning,
.delete-person-blocked {
    border: 1px solid rgba(181, 31, 46, 0.28);
    background: rgba(181, 31, 46, 0.08);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.delete-person-warning h2,
.delete-person-blocked h3 {
    margin-top: 0;
}

.delete-person-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem;
    margin-top: 1rem;
}

.delete-person-confirm-input {
    min-width: 220px;
    padding: 0.72rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

/* ==========================================================================
   FAMILY TREE NODE CARD INFO
   ========================================================================== */

:root {
    --famtree-node-text-indent: 16px;
}

.node-name,
.node-meta,
.v-node-name,
.v-node-meta,
.node-life-years,
.node-spouse-line,
.node-spouse-name,
.node-spouse-years,
.node-spouse-label {
    text-align: left;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}

.node-name,
.node-meta,
.v-node-name,
.v-node-meta,
.node-spouse-line {
    padding-left: var(--famtree-node-text-indent);
    box-sizing: border-box;
}

.node-life-years,
.node-spouse-name,
.node-spouse-years,
.node-spouse-label {
    display: block;
}

.node-spouses-inline {
    text-align: left;
}

/* ===========================================================================
   FAMILY TREE NODE CARD NAME WRAPPING
   ---------------------------------------------------------------------------
   Long person/spouse names must stay inside the fixed-width card.  Names wrap
   naturally at spaces; dates stay on one line for readability.
   =========================================================================== */
.node-name,
.v-node-name,
.node-spouse-name {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
    max-width: 100%;
}

.node-life-years,
.node-spouse-years,
.node-spouse-label {
    white-space: nowrap;
}

/* v2.0.9: readable female-line children toggle in light/dark and wide/narrow headers */
.view-actions {
    flex-wrap: nowrap;
}

.tree-family-switch-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.tree-family-switch {
    height: 42px;
    min-width: 140px;
    max-width: 220px;
    padding: 0 2.1rem 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    line-height: 1;
}

.button-link--tree-toggle,
html[data-theme="dark"] .button-link--tree-toggle {
    width: auto;
    min-width: 168px;
    max-width: none;
    height: 42px;
    padding: 0 0.9rem;
    gap: 0.48rem;
    white-space: nowrap;
    line-height: 1;
    justify-content: center;
    border-radius: 12px;
}

.tree-toggle__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    background: rgba(10, 103, 208, 0.12);
    color: var(--accent-hover);
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1;
    flex: 0 0 auto;
}

.tree-toggle__label {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tree-toggle__label--short {
    display: none;
}

html[data-theme="dark"] .tree-family-switch {
    background: #232a33;
    color: #eef5ff;
    border-color: rgba(77, 166, 255, 0.24);
}

html[data-theme="dark"] .tree-toggle__icon {
    background: rgba(77, 166, 255, 0.16);
    color: #b9dcff;
}

html[data-theme="dark"] .button-link--tree-toggle.is-active .tree-toggle__icon {
    background: rgba(77, 166, 255, 0.24);
    color: #eef8ff;
}

@media (max-width: 900px) {
    .button-link--tree-toggle,
    html[data-theme="dark"] .button-link--tree-toggle {
        min-width: 112px;
        padding: 0 0.72rem;
    }

    .tree-toggle__label--full {
        display: none;
    }

    .tree-toggle__label--short {
        display: inline-block;
    }
}

@media (max-width: 640px) {
    .view-actions {
        align-items: center;
        row-gap: 0.55rem;
    }

    .tree-family-switch {
        width: 100%;
        max-width: none;
    }

    .button-link--tree-toggle,
    html[data-theme="dark"] .button-link--tree-toggle {
        height: 38px;
        min-width: 106px;
        padding: 0 0.65rem;
    }

    .tree-toggle__label {
        font-size: 0.84rem;
    }
}

@media (max-width: 430px) {
    .button-link--tree-toggle,
    html[data-theme="dark"] .button-link--tree-toggle {
        min-width: 42px;
        width: 42px;
        padding: 0;
    }

    .button-link--tree-toggle .tree-toggle__label {
        display: none;
    }
}

/* v2.1.1: restore clean tree-page header layout after i18n expansion.
   The translated page title must not collapse into a narrow multi-line block
   in front of the navigation controls. */
@media (min-width: 981px) {
    .page-header__inner {
        justify-content: flex-start;
    }

    .page-header__title-wrap {
        flex: 0 0 auto;
        max-width: 26rem;
    }

    .page-header h1 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.15;
    }

    .page-header__actions {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: flex-end;
    }

    .page-nav {
        flex: 0 0 auto;
    }

    .view-actions {
        flex: 0 1 auto;
        min-width: 0;
    }
}

@media (min-width: 981px) and (max-width: 1280px) {
    .page-header__inner {
        gap: 0.65rem;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .page-header__title-wrap {
        max-width: 18rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .page-actions .button-link {
        padding-left: 0.78rem;
        padding-right: 0.78rem;
    }

    .view-actions {
        gap: 0.45rem;
        padding-left: 0.45rem;
    }

    .view-actions__group {
        gap: 0.35rem;
    }
}

.node-spouse-family-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.14em;
}

.node-spouse-family-link:hover,
.node-spouse-family-link:focus-visible {
    text-decoration-thickness: 2px;
}
