/* ================================================================
   FAMILY TREE — "Warm Family Glow" Design
   A cozy, inviting visual experience for the family tree page.
   ================================================================ */

/* ---- Page-level custom properties ---- */
.family-main {
    --warm-gold: #d4a574;
    --warm-amber: #c4956a;
    --warm-rose: #d4878f;
    --warm-lavender: #a89cc8;
    --warm-sage: #8faa8f;
    --warm-cream: #faf7f2;
    --warm-cream-deep: #f3ede4;
    --glass-white: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.45);
    --glass-shadow: rgba(180, 160, 130, 0.12);
    --glow-gold: rgba(212, 165, 116, 0.35);
    --glow-blue: rgba(52, 152, 219, 0.25);
    --glow-purple: rgba(155, 89, 182, 0.25);
    --glow-rose: rgba(212, 135, 143, 0.25);
    --connector-gradient: linear-gradient(180deg, var(--accent-cool), var(--warm-lavender));
    --connector-h-gradient: linear-gradient(90deg, var(--accent-cool), var(--warm-lavender));
}


/* ================================================================
   KEYFRAME ANIMATIONS
   ================================================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes floatParticle {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: var(--p-opacity, 0.25);
    }
    25% {
        transform: translate(var(--drift-x, 40px), var(--drift-y, -60px)) scale(1.1);
        opacity: calc(var(--p-opacity, 0.25) * 1.3);
    }
    50% {
        transform: translate(calc(var(--drift-x, 40px) * -0.5), calc(var(--drift-y, -60px) * 1.5)) scale(0.9);
        opacity: var(--p-opacity, 0.25);
    }
    75% {
        transform: translate(calc(var(--drift-x, 40px) * 0.8), calc(var(--drift-y, -60px) * -0.7)) scale(1.05);
        opacity: calc(var(--p-opacity, 0.25) * 0.8);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 4px 1px var(--glow-blue);
        transform: translateX(-50%) scale(1);
    }
    50% {
        box-shadow: 0 0 10px 3px var(--glow-blue);
        transform: translateX(-50%) scale(1.3);
    }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes gentleBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes ringRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bgShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}


/* ================================================================
   PAGE BACKGROUND & AMBIENT EFFECTS
   ================================================================ */

.family-main {
    padding-top: 100px;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(212, 165, 116, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(168, 156, 200, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(212, 135, 143, 0.04) 0%, transparent 60%),
        linear-gradient(160deg, var(--warm-cream) 0%, #f7f3ee 30%, #f2eee8 60%, #efeae4 100%);
    background-size: 200% 200%, 200% 200%, 100% 100%, 100% 100%;
    animation: bgShift 30s ease-in-out infinite;
}

/* Ambient floating particles container */
.family-ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: floatParticle var(--p-duration, 25s) var(--p-delay, 0s) ease-in-out infinite;
    filter: blur(var(--p-blur, 1px));
    will-change: transform, opacity;
}


/* ================================================================
   PAGE HEADER
   ================================================================ */

.family-header {
    text-align: left;
    margin-bottom: 2rem;
    padding-left: 1.5rem;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.8s ease forwards;
}

.family-header h1 {
    font-size: 2.8rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 300;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--warm-amber) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.family-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 550px;
    margin-bottom: 1.5rem;
    line-height: 1.7;
    opacity: 0;
    animation: fadeInUp 0.6s 0.2s ease forwards;
}

.add-family-btn {
    background: linear-gradient(135deg, var(--accent-cool), var(--warm-lavender));
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
    opacity: 0;
    animation: fadeInUp 0.6s 0.35s ease forwards;
}

.add-family-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(52, 152, 219, 0.3);
}


/* ================================================================
   AUTH NOTICE
   ================================================================ */

.auth-notice {
    text-align: center;
    padding: 5rem 2rem;
    margin-top: 40px;
    position: relative;
    z-index: 1;
}

.auth-notice h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 300;
    font-size: 1.6rem;
}

.auth-notice p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}


/* ================================================================
   LOADING & EMPTY STATES
   ================================================================ */

.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(212, 165, 116, 0.2);
    border-top-color: var(--warm-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.2rem;
}

.no-results {
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}


/* ================================================================
   TREE CONTROLS (Zoom toolbar)
   ================================================================ */

.tree-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    position: sticky;
    top: 80px;
    z-index: 100;
    justify-content: flex-end;
    padding: 0 1.5rem;
    margin-bottom: -20px;
    opacity: 0;
    animation: fadeIn 0.6s 0.5s ease forwards;
}

.tree-controls button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass-white);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 2px 10px var(--glass-shadow);
}

.tree-controls button:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--glass-shadow);
}

.tree-controls button:active {
    transform: scale(0.95);
}

.zoom-level-indicator {
    font-size: 0.72rem;
    color: var(--text-secondary);
    min-width: 38px;
    text-align: center;
    padding: 0 4px;
    user-select: none;
}


/* ================================================================
   TREE CONTAINER & CUSTOM SCROLLBAR
   ================================================================ */

.family-tree-container {
    overflow-x: auto;
    overflow-y: visible;
    padding: 1.5rem 0 3rem;
    margin: 1rem;
    border-radius: 20px;
    position: relative;
    z-index: 1;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(212, 165, 116, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 60%, rgba(168, 156, 200, 0.05) 0%, transparent 50%),
        rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Custom scrollbar */
.family-tree-container::-webkit-scrollbar {
    height: 6px;
}

.family-tree-container::-webkit-scrollbar-track {
    background: transparent;
    margin: 0 20px;
}

.family-tree-container::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, var(--warm-gold), var(--warm-lavender));
    border-radius: 10px;
    opacity: 0.5;
}

.family-tree-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, var(--warm-amber), var(--accent-purple));
}

.family-tree {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 80px;
    padding: 3rem 3rem 2rem;
    min-width: min-content;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center top;
}


/* ================================================================
   TREE LAYOUT — Family units & structural containers
   ================================================================ */

.family-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.parents-row {
    display: flex;
    align-items: center;
    position: relative;
}

/* ================================================================
   LINEAGE COLUMNS — Ancestry above each person
   ================================================================ */

.lineage-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}

.lineage-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.lineage-couple-line {
    align-self: flex-end;
    margin-bottom: 77px; /* Align with center of node cards */
}

/* Ancestry block - parents above the current member */
.ancestry-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0;
}

.ancestry-parents-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.ancestry-parents-row.couple {
    gap: 0;
}

.ancestry-couple-line {
    align-self: flex-end;
    margin-bottom: 77px;
}

/* Descent line from ancestry to descendant */
.ancestry-descent-line {
    width: 2px;
    height: 36px;
    background: var(--connector-gradient);
    flex-shrink: 0;
    position: relative;
    opacity: 0.5;
}

/* Pulsing junction dot at top of ancestry descent line */
.ancestry-descent-line::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warm-gold);
    border: 2px solid var(--warm-cream);
    box-shadow: 0 0 8px var(--glow-gold);
    animation: pulseGlow 3s ease-in-out infinite;
    z-index: 2;
}

/* Junction dot at bottom of ancestry descent line */
.ancestry-descent-line::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warm-cream);
    border: 2px solid var(--warm-lavender);
    box-shadow: 0 0 6px var(--glow-purple);
    z-index: 2;
}


/* ================================================================
   TREE CONNECTORS — Lines between family members
   ================================================================ */

/* Couple connector with heart */
.couple-line {
    width: 48px;
    height: 2px;
    background: linear-gradient(90deg, var(--warm-gold), var(--warm-rose));
    flex-shrink: 0;
    position: relative;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.couple-line::before {
    content: '\2665';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    color: var(--warm-rose);
    background: var(--warm-cream);
    padding: 3px 5px;
    border-radius: 50%;
    line-height: 1;
    transition: all 0.3s ease;
}

.parents-row:hover .couple-line {
    opacity: 1;
}

.parents-row:hover .couple-line::before {
    transform: translate(-50%, -50%) scale(1.2);
    color: #e74c3c;
}

/* Descent line from parents to children */
.descent-line {
    width: 2px;
    height: 36px;
    background: var(--connector-gradient);
    flex-shrink: 0;
    position: relative;
    opacity: 0.5;
}

/* Pulsing junction dot at top of descent line */
.descent-line::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warm-gold);
    border: 2px solid var(--warm-cream);
    box-shadow: 0 0 8px var(--glow-gold);
    animation: pulseGlow 3s ease-in-out infinite;
    z-index: 2;
}

/* ---- Children row with connecting branches ---- */
.children-row {
    display: flex;
    justify-content: center;
    position: relative;
    padding-top: 0;
}

/* Each child gets vertical connector */
.children-row > .family-unit {
    padding: 36px 24px 0 24px;
    position: relative;
}

/* Vertical drop from horizontal bar to child */
.children-row > .family-unit::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 36px;
    background: linear-gradient(180deg, var(--warm-lavender), rgba(168, 156, 200, 0.3));
    z-index: 1;
}

/* Horizontal bar connecting siblings */
.children-row > .family-unit::after {
    content: '';
    position: absolute;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--warm-lavender), var(--warm-gold), var(--warm-lavender));
    opacity: 0.5;
}

/* First child: bar from center to right */
.children-row > .family-unit:first-child::after {
    left: 50%;
    right: 0;
}

/* Last child: bar from left to center */
.children-row > .family-unit:last-child::after {
    left: 0;
    right: 50%;
}

/* Middle children: full-width bar */
.children-row > .family-unit:not(:first-child):not(:last-child)::after {
    left: 0;
    right: 0;
}

/* Only child: no horizontal bar needed */
.children-row > .family-unit:only-child::after {
    display: none;
}


/* Junction dot where vertical line meets child - for lineage-row */
.children-row > .family-unit > .lineage-row::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warm-cream);
    border: 2px solid var(--warm-lavender);
    box-shadow: 0 0 6px var(--glow-purple);
    z-index: 2;
}

/* Legacy support for parents-row (if used without lineage-row) */
.children-row > .family-unit > .parents-row::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warm-cream);
    border: 2px solid var(--warm-lavender);
    box-shadow: 0 0 6px var(--glow-purple);
    z-index: 2;
}

.children-row > .family-unit > .parents-row.couple::before {
    left: 50%;
}

.children-row > .family-unit > .parents-row.single::before {
    display: none;
}

/* ---- Family unit with lineage ancestry ----
   When a child has ancestry (grandparents shown above), the family-unit
   naturally centers on the lineage-row which contains both lineage columns.
   No manual offset needed since ancestry is rendered within each lineage column.
*/

/* Ensure children with ancestry are properly centered */
.children-row > .family-unit.has-partner {
    /* No special offset needed - lineage columns handle centering */
}


/* Subtle generation background band */
.family-unit > .children-row::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 5%;
    right: 5%;
    bottom: -8px;
    background: rgba(212, 165, 116, 0.025);
    border-radius: 16px;
    pointer-events: none;
    z-index: -1;
}


/* ================================================================
   TREE NODE CARDS — Glassmorphism family member cards
   ================================================================ */

.tree-node {
    background: var(--glass-white);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.4rem 1rem 1.1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 140px;
    min-height: 155px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 4px 16px var(--glass-shadow),
        0 1px 3px rgba(0, 0, 0, 0.04);
    /* Entrance animation - driven by JS-set --delay */
    opacity: 0;
    animation: fadeInUp 0.65s var(--delay, 0s) cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Accent gradient bar at top - visible on hover */
.tree-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--node-accent, var(--warm-gold)), var(--warm-lavender));
    border-radius: 20px 20px 0 0;
    opacity: 0;
    transition: opacity 0.35s ease, height 0.35s ease;
}

.tree-node:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow:
        0 16px 40px rgba(180, 160, 130, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.06),
        0 0 24px -4px var(--node-accent, var(--warm-gold));
    border-color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.85);
}

.tree-node:hover::before {
    opacity: 1;
    height: 4px;
}

/* ---- Node photo ---- */
.tree-node-photo {
    position: relative;
    margin-bottom: 6px;
}

/* Rotating gradient ring around photo */
.tree-node-photo::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: conic-gradient(
        var(--node-accent, var(--warm-gold)),
        var(--warm-lavender),
        var(--warm-rose),
        var(--node-accent, var(--warm-gold))
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: ringRotate 6s linear infinite;
    z-index: 0;
}

.tree-node:hover .tree-node-photo::before {
    opacity: 0.7;
}

.tree-node-photo img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.tree-node:hover .tree-node-photo img {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.tree-node-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warm-cream-deep) 0%, var(--warm-cream) 100%);
    border: 3px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--warm-amber);
    font-weight: 600;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.tree-node:hover .tree-node-placeholder {
    transform: scale(1.08);
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.15) 0%, var(--warm-cream) 100%);
    color: var(--warm-gold);
}

/* ---- Node info ---- */
.tree-node-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.tree-node-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.3;
    word-break: break-word;
    max-width: 120px;
    transition: color 0.3s ease;
}

.tree-node:hover .tree-node-name {
    color: var(--warm-amber);
}

.tree-node-relation {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: capitalize;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 12px;
    border-radius: 12px;
    margin-top: 2px;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}

/* ---- Relation-type accent colors ---- */
.tree-node[data-relation="self"] {
    --node-accent: var(--accent-cool);
}
.tree-node[data-relation="self"] .tree-node-relation {
    background: linear-gradient(135deg, var(--accent-cool), var(--accent-purple));
    color: #fff;
    font-weight: 500;
}

.tree-node[data-relation="father"],
.tree-node[data-relation="grandfather"] {
    --node-accent: #5b8cb8;
}

.tree-node[data-relation="mother"],
.tree-node[data-relation="grandmother"] {
    --node-accent: var(--warm-rose);
}

.tree-node[data-relation="brother"],
.tree-node[data-relation="sister"] {
    --node-accent: var(--warm-sage);
}

.tree-node[data-relation="spouse"] {
    --node-accent: var(--warm-gold);
}

.tree-node[data-relation="son"],
.tree-node[data-relation="daughter"] {
    --node-accent: var(--warm-lavender);
}

.tree-node[data-relation="uncle"],
.tree-node[data-relation="aunt"],
.tree-node[data-relation="cousin"] {
    --node-accent: #7fb3b3;
}

/* ---- Admin action buttons on nodes ---- */
.tree-node-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.25s ease;
}

.tree-node:hover .tree-node-actions {
    opacity: 1;
    transform: translateY(0);
}

.tree-node-actions button {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 0.66rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
}

.tree-node-actions .btn-edit:hover {
    background: rgba(52, 152, 219, 0.12);
    border-color: rgba(52, 152, 219, 0.3);
    color: var(--accent-cool);
}

.tree-node-actions .btn-delete:hover {
    background: rgba(231, 76, 60, 0.1);
    border-color: rgba(231, 76, 60, 0.3);
    color: var(--accent-warm);
}


/* ================================================================
   HOVER TOOLTIP
   ================================================================ */

.member-tooltip {
    position: fixed;
    z-index: 10001;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 14px;
    padding: 12px 16px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
    max-width: 280px;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

.member-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

.tooltip-photo img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--glass-border);
}

.tooltip-photo .tooltip-initials {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warm-cream-deep), var(--warm-cream));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--warm-amber);
    border: 2px solid var(--glass-border);
}

.tooltip-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tooltip-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.3;
}

.tooltip-relation {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.tooltip-meta {
    font-size: 0.68rem;
    color: var(--warm-amber);
    margin-top: 1px;
}


/* ================================================================
   DETAIL MODAL — Beautiful member profile overlay
   ================================================================ */

.modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3vh 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        background-color 0.4s ease,
        backdrop-filter 0.4s ease,
        -webkit-backdrop-filter 0.4s ease,
        visibility 0s 0.4s;
}

.modal.active {
    background-color: rgba(30, 25, 20, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    visibility: visible;
    pointer-events: auto;
    transition:
        background-color 0.4s ease,
        backdrop-filter 0.4s ease,
        -webkit-backdrop-filter 0.4s ease,
        visibility 0s 0s;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 82vh;
    overflow-y: auto;
    position: relative;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.12),
        0 8px 24px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transform: translateY(40px) scale(0.96);
    transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.active .modal-content {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Custom scrollbar inside modal */
.modal-content::-webkit-scrollbar {
    width: 4px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(212, 165, 116, 0.3);
    border-radius: 4px;
}

.modal-close {
    color: var(--text-secondary);
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    position: absolute;
    right: 1.2rem;
    top: 1rem;
    transition: all 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
    line-height: 1;
}

.modal-close:hover {
    color: var(--accent-warm);
    background: rgba(231, 76, 60, 0.08);
}


/* ---- Detail modal specifics ---- */
.family-detail-modal {
    max-width: 680px;
}

.member-profile {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1.8rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    animation: fadeInUp 0.5s ease;
}

.member-profile-photo {
    flex-shrink: 0;
}

.member-profile-photo img {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(212, 165, 116, 0.2);
}

.member-profile-photo .detail-placeholder {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warm-cream-deep), var(--warm-cream));
    border: 4px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--warm-amber);
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.member-profile-info h2 {
    color: var(--text-primary);
    font-weight: 400;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    letter-spacing: -0.3px;
}

.member-profile-info .relation-badge {
    display: inline-block;
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.15), rgba(168, 156, 200, 0.15));
    color: var(--warm-amber);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    text-transform: capitalize;
    margin-bottom: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.member-profile-info .member-meta {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 2;
}

.member-profile-info .member-meta span {
    display: block;
}

.member-profile-info .member-meta span::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--warm-gold);
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    opacity: 0.6;
}

.member-bio {
    margin-bottom: 2rem;
    animation: fadeInUp 0.5s 0.1s ease both;
}

.member-bio h3 {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.member-bio p {
    color: var(--text-secondary);
    line-height: 1.9;
    white-space: pre-wrap;
}


/* ---- Events timeline in detail modal ---- */
.member-events {
    margin-top: 1.5rem;
    animation: fadeInUp 0.5s 0.15s ease both;
}

.member-events h3 {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 1.2rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.member-events-timeline {
    border-left: 2px solid;
    border-image: linear-gradient(180deg, var(--warm-gold), var(--warm-lavender)) 1;
    padding-left: 1.5rem;
    margin-left: 8px;
}

.event-item {
    position: relative;
    margin-bottom: 1.5rem;
    padding: 1rem 1.2rem;
    background: rgba(250, 247, 242, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.25s ease;
}

.event-item:hover {
    background: rgba(250, 247, 242, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.event-item::before {
    content: '';
    position: absolute;
    left: -1.85rem;
    top: 1.1rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warm-gold), var(--warm-lavender));
    border: 2px solid #fff;
    box-shadow: 0 0 6px var(--glow-gold);
}

.event-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.4rem;
}

.event-item-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.88rem;
}

.event-item-date {
    font-size: 0.72rem;
    color: var(--warm-amber);
    opacity: 0.8;
}

.event-item-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.7;
}

.event-delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 2px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.event-delete-btn:hover {
    color: var(--accent-warm);
    background: rgba(231, 76, 60, 0.08);
}

.no-events {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-size: 0.88rem;
    background: rgba(250, 247, 242, 0.4);
    border-radius: 12px;
}

.add-event-btn {
    background: none;
    border: 1px solid var(--warm-gold);
    color: var(--warm-amber);
    padding: 5px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.add-event-btn:hover {
    background: linear-gradient(135deg, var(--warm-gold), var(--warm-amber));
    color: #fff;
    border-color: transparent;
}

/* Admin detail actions */
.member-detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 1.8rem;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    animation: fadeInUp 0.5s 0.2s ease both;
}

.member-detail-actions button {
    padding: 9px 20px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.3s ease;
}


/* ================================================================
   FORMS & ADD/EDIT MODALS
   ================================================================ */

.add-family-modal {
    max-width: 580px;
}

.add-family-modal h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    margin-top: 0;
    padding-right: 2rem;
    font-weight: 400;
    font-size: 1.3rem;
}

.form-group {
    margin-bottom: 1.4rem;
}

.form-group label {
    display: block;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--warm-gold);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.12);
    background: #fff;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cool), var(--warm-lavender));
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: none;
    color: var(--text-secondary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 10px 24px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    border-color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.02);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-warm), #c0392b);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.2);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.3);
}

.photo-preview {
    margin-top: 10px;
}

.photo-preview img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

#memberParents {
    min-height: 80px;
    padding: 6px;
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.8;
}


/* ================================================================
   RESPONSIVE — Mobile-friendly layout
   ================================================================ */

@media (max-width: 900px) {
    .family-tree-container {
        margin: 0.5rem;
        border-radius: 16px;
    }

    .family-tree {
        gap: 50px;
        padding: 2rem 1.5rem;
    }

    .tree-node {
        width: 115px;
        min-height: 135px;
        padding: 1rem 0.75rem 0.8rem;
        border-radius: 16px;
    }

    .tree-node-photo img,
    .tree-node-placeholder {
        width: 50px;
        height: 50px;
        font-size: 1.15rem;
    }

    .tree-node-name {
        font-size: 0.78rem;
    }

    .children-row > .family-unit {
        padding: 30px 14px 0 14px;
    }

    /* Adjust couple line for smaller screens */
    .lineage-couple-line,
    .ancestry-couple-line {
        margin-bottom: 67px;
    }
}

@media (max-width: 768px) {
    .family-main {
        padding-top: 80px;
    }

    .family-header {
        padding-left: 0.5rem;
    }

    .family-header h1 {
        font-size: 2rem;
    }

    .tree-controls {
        padding: 0 0.5rem;
        top: 65px;
    }

    .family-tree-container {
        background: transparent;
        border: none;
        backdrop-filter: none;
        padding: 1rem 0;
    }

    /* Vertical tree layout on mobile */
    .family-tree {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 1rem;
        min-width: auto;
    }

    .family-unit {
        align-items: flex-start;
        width: 100%;
        margin-bottom: 8px;
    }

    .parents-row,
    .lineage-row,
    .ancestry-parents-row {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .couple-line {
        width: 20px;
        height: 2px;
    }

    .couple-line::before {
        font-size: 9px;
        padding: 1px 3px;
    }

    .descent-line,
    .ancestry-descent-line {
        display: none;
    }

    /* Lineage columns become horizontal on mobile */
    .lineage-column {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .ancestry-block {
        flex-direction: row;
        flex-wrap: wrap;
        margin-bottom: 0;
        margin-right: 12px;
        padding-right: 12px;
        border-right: 2px solid var(--warm-gold);
    }

    .lineage-couple-line,
    .ancestry-couple-line {
        margin-bottom: 0;
        align-self: center;
    }

    /* Indented children with left border */
    .children-row {
        flex-direction: column;
        align-items: stretch;
        padding-left: 24px;
        border-left: 2px solid var(--warm-gold);
        margin-left: 28px;
        margin-top: 12px;
        gap: 8px;
    }

    .children-row::before {
        display: none;
    }

    /* Reset tree connectors on mobile */
    .children-row > .family-unit::after {
        display: none !important;
    }

    .children-row > .family-unit {
        padding: 0;
        margin-bottom: 0;
        position: relative;
    }

    .children-row > .family-unit > .parents-row::before,
    .children-row > .family-unit > .lineage-row::before {
        display: none;
    }

    /* Horizontal dash from border to child */
    .children-row > .family-unit::before {
        content: '';
        position: absolute;
        top: 50%;
        left: -24px;
        width: 24px;
        height: 2px;
        background: linear-gradient(90deg, var(--warm-gold), var(--warm-lavender));
        transform: translateY(-50%);
    }

    /* Dot at connection point */
    .children-row > .family-unit::after {
        content: '' !important;
        display: block !important;
        position: absolute;
        top: 50%;
        left: -28px;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--warm-gold);
        transform: translateY(-50%);
        border: 2px solid #fff;
        box-shadow: 0 0 6px var(--glow-gold);
    }

    /* Horizontal card layout on mobile */
    .tree-node {
        width: 100%;
        max-width: 320px;
        flex-direction: row;
        min-height: auto;
        padding: 0.75rem 1rem;
        gap: 0.85rem;
        text-align: left;
        border-radius: 14px;
    }

    .tree-node::before {
        display: none;
    }

    .tree-node::after {
        border-radius: 16px;
    }

    .tree-node-photo {
        margin-bottom: 0;
    }

    .tree-node-photo::before {
        inset: -3px;
    }

    .tree-node-photo img,
    .tree-node-placeholder {
        width: 44px;
        height: 44px;
        font-size: 1rem;
        border-width: 2px;
    }

    .tree-node-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        flex: 1;
    }

    .tree-node-name {
        max-width: none;
    }

    .tree-node-relation {
        padding: 2px 8px;
    }

    .tree-node-actions {
        margin-top: 0;
        margin-left: auto;
        opacity: 1;
        transform: none;
        flex-direction: column;
        gap: 4px;
    }

    /* Modal responsive */
    .member-profile {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1.2rem;
    }

    .member-profile-info .member-meta span::before {
        display: none;
    }

    .modal {
        padding: 1.5vh 0;
    }

    .modal-content {
        max-height: 92vh;
        padding: 1.5rem;
        border-radius: 16px;
    }

    .member-detail-actions {
        flex-direction: column;
    }

    .member-detail-actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .family-header h1 {
        font-size: 1.7rem;
    }

    .children-row {
        padding-left: 20px;
        margin-left: 22px;
    }

    .children-row > .family-unit::before {
        left: -20px;
        width: 20px;
    }

    .children-row > .family-unit::after {
        left: -24px !important;
    }

    .tree-node {
        padding: 0.6rem 0.85rem;
        gap: 0.65rem;
    }

    .tree-node-photo img,
    .tree-node-placeholder {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }

    .tree-node-name {
        font-size: 0.78rem;
    }

    .tree-node-relation {
        font-size: 0.62rem;
    }
}

/* ================================================================
   PREFERS REDUCED MOTION
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .family-main {
        animation: none;
    }

    .ambient-particle {
        display: none;
    }

    .tree-node {
        opacity: 1;
    }
}

/* Coordinate-based tree: cards and SVG share one canvas and one scale. */
.family-main { animation: none; background: #f7f5ef; }
.family-main .container { max-width: 1440px; }
.family-ambient-bg { display: none; }
.family-header { padding: 0; margin-bottom: 32px; }
.family-header h1 { font: 400 clamp(32px, 4vw, 50px)/1.15 Georgia, serif; color: #293c35; background: none; -webkit-text-fill-color: initial; }
.family-header p { color: #62665f; max-width: none; }
.family-header .family-eyebrow { font: 600 11px/1.5 system-ui, sans-serif; letter-spacing: .16em; color: #6b745f; margin-bottom: 12px; }
.family-tree-heading { display: flex; gap: 20px; justify-content: space-between; align-items: center; font-size: 14px; color: #505c51; }
.family-find select { background: #fffefb; color: #3c493f; border: 1px solid #cecfc3; border-radius: 8px; min-height: 44px; max-width: 100%; padding: 8px 12px; font: inherit; }
.family-main .tree-controls { justify-content: flex-start; gap: 6px; margin: 16px 0 0; padding: 10px 14px; border: 1px solid #d4d6c9; border-bottom: 0; border-radius: 12px 12px 0 0; background: #fffefa; box-shadow: none; }
.family-main .tree-controls button { color: #384b40; min-width: 44px; min-height: 44px; padding: 6px 12px; width: auto; white-space: nowrap; background: #f1f2e9; border: 1px solid #dbded0; border-radius: 7px; font: 500 14px system-ui, sans-serif; box-shadow: none; }
.family-main .tree-controls .zoom-level-indicator { color: #4f5d51; font-size: 12px; min-width: 45px; }
.family-main .family-tree-container { height: 610px; overflow: auto; padding: 0; margin: 0; border: 1px solid #d4d6c9; border-radius: 0 0 12px 12px; background-color: #fbfbf6; background-image: radial-gradient(#dde1d4 .75px, transparent .75px); background-size: 18px 18px; cursor: grab; touch-action: pan-x pan-y; overscroll-behavior: contain; backdrop-filter: none; }
.family-main .family-tree-container.is-panning { cursor: grabbing; user-select: none; }
.family-tree-space { position: relative; margin: 0 auto; }
.family-main .family-tree { position: absolute; top: 0; left: 0; display: block; padding: 0; min-width: 0; transform-origin: 0 0; transition: none; }
.family-connections { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.family-connection { fill: none; stroke: #859681; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.family-connection.is-highlighted { stroke: #426947; stroke-width: 3; }
.generation-label { position: absolute; left: 48px; color: #69755f; font: 600 9px/1 system-ui, sans-serif; letter-spacing: .12em; }
.family-main .family-tree .tree-node { position: absolute; width: 176px; height: 112px; min-height: 0; padding: 0; display: block; border: 1px solid #d2d7c7; background: #fffefa; border-radius: 10px; box-shadow: 0 3px 7px #3b46340a; animation: none; opacity: 1; transition: border-color .15s, box-shadow .15s; overflow: hidden; backdrop-filter: none; }
.family-main .family-tree .tree-node:hover, .family-main .family-tree .tree-node.is-selected { transform: none; border-color: #618461; box-shadow: 0 0 0 2px #61846125; }
.family-main .family-tree .tree-node::before, .family-main .family-tree .tree-node::after { display: none; }
.family-main .family-tree .tree-node[data-relation="self"] { border-color: #6c8965; background: #eef2e7; }
.tree-member-open { display: flex; align-items: center; flex-direction: column; width: 100%; height: 100%; padding: 12px 8px 8px; border: 0; background: transparent; cursor: pointer; color: #2e4136; font: inherit; }
.family-main .family-tree .tree-node-photo { margin: 0 0 6px; flex-shrink: 0; }
.family-main .family-tree .tree-node-photo::before { display: none; }
.family-main .family-tree .tree-node-photo img, .family-main .family-tree .tree-node-placeholder { width: 38px; height: 38px; border: 1px solid #d6d9cb; border-radius: 50%; object-fit: cover; background: #ecebdf; color: #56654d; font: 400 16px Georgia, serif; box-shadow: none; transform: none; display: grid; place-items: center; }
.family-main .family-tree .tree-node-info { display: block; width: 100%; }
.family-main .family-tree .tree-node-name { color: #2e4136; font: 600 15px/1.25 system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.family-main .family-tree .tree-node-relation { display: block; margin-top: 4px; padding: 0; color: #66735d; background: none; font: 12px/1.2 system-ui, sans-serif; letter-spacing: 0; text-transform: none; }
.family-main .family-tree .tree-node-actions { position: absolute; right: 0; top: 0; bottom: auto; left: auto; opacity: 1; transform: none; display: flex; flex-direction: row; gap: 0; }
.family-main .family-tree .tree-node-actions button { font-size: 10px; min-width: 44px; min-height: 44px; padding: 0; background: #fffefa; border: 0; border-radius: 0; color: #56664d; }
.family-main .family-tree .tree-node:has(.tree-node-actions) .tree-member-open { padding-top: 46px; align-items: flex-start; text-align: left; }
.family-main .family-tree .tree-node:has(.tree-node-actions) .tree-node-photo { position: absolute; top: 5px; left: 8px; }
.family-tree-hint { color: #646d5c; font: 12px/1.7 system-ui, sans-serif; padding: 10px 0; margin: 0; }
.family-tree-warning { color: #774b18; background: #fff1d8; border: 1px solid #dabb89; padding: 12px; border-radius: 8px; }
.family-relationship-list { margin: 20px 0 32px; color: #4d5c4c; font-size: 14px; }
.family-relationship-list summary { cursor: pointer; min-height: 44px; padding: 12px 0; }
.family-relationship-list ul { padding-left: 20px; }
.family-relationship-list li { margin: 6px 0; line-height: 1.7; }
.family-relationship-list button { background: transparent; border: 0; color: #315f41; text-decoration: underline; cursor: pointer; min-height: 44px; font: inherit; padding: 0 4px; }
.family-main button:focus-visible, .family-main select:focus-visible, .family-main summary:focus-visible, .family-main .family-tree-container:focus-visible { outline: 3px solid #436b48; outline-offset: 3px; }
.family-main .tree-member-open:focus-visible { outline-offset: -4px; }
.family-main .modal-close { min-width: 44px; min-height: 44px; border: 0; background: #f1f0e8; }
@media (max-width: 600px) {
    .family-tree-heading { align-items: stretch; flex-direction: column; gap: 12px; }
    .family-find select { width: 100%; }
    .family-main .family-tree-container { height: 520px; }
    .family-main .tree-controls { gap: 4px; flex-wrap: wrap; padding: 8px; }
    .family-main .tree-controls button { flex-shrink: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .family-main *, .family-main *::before, .family-main *::after { animation: none !important; transition: none !important; }
}

.family-header { background: transparent; border: 0; }

.family-connection-bridge { fill: none; stroke: #fbfbf6; stroke-width: 6; stroke-linejoin: round; }

.family-main .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.family-header, .family-main .tree-controls { animation: none; opacity: 1; transform: none; }

.family-header *, .family-main .tree-controls * { animation: none; opacity: 1; transform: none; }
.family-header p, .family-header h1, .family-header button { animation: none; opacity: 1; transform: none; }
