body {
    font-family: 'Nunito Sans', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: white;
    color: black;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background-color: #1a1a1a;
    color: white;
}


#password-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.85));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#password-card {
    background: #ffffff;
    color: #111;
    padding: 28px 24px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
    width: min(420px, 90vw);
    border: 1px solid #e1e1e1;
}

body.dark-mode #password-card {
    background: #1f1f1f;
    color: #f7f7f7;
    border-color: #353535;
}

#password-card h1 {
    margin: 0 0 8px 0;
    font-size: 24px;
    letter-spacing: 0.2px;
}

.password-subtitle {
    margin: 0 0 18px 0;
    color: #666;
}

body.dark-mode .password-subtitle {
    color: #b9b9b9;
}

#password-form {
    display: grid;
    gap: 10px;
}

#password-form input {
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid #d0d0d0;
    font-family: 'Nunito Sans', sans-serif;
}

body.dark-mode #password-form input {
    background: #2a2a2a;
    color: #f7f7f7;
    border-color: #3a3a3a;
}

#password-form button {
    padding: 12px 14px;
    font-size: 13px;
    border: none;
    background: #333;
    color: #fff;
    cursor: pointer;
    font-family: 'Nunito Sans', sans-serif;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#password-form button:hover {
    box-shadow: 0 6px 16px rgba(63, 63, 63, 0.25);
}

.demo-action-btn {
    background: #6c757d !important;
    border: 1px solid #5a6268 !important;
    margin-top: 8px;
}

.demo-action-btn:hover {
    background: #5a6268 !important;
    box-shadow: 0 6px 16px rgba(108, 117, 125, 0.25) !important;
}

body.dark-mode .demo-action-btn {
    background: #7c7c84 !important;
    border-color: #6c7077 !important;
}

body.dark-mode .demo-action-btn:hover {
    background: #6c7077 !important;
}

body.password-locked {
    overflow: hidden;
}

#password-error {
    min-height: 18px;
    font-size: 14px;
    color: #d32f2f;
}

.password-badge {
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 8px 12px;
    background: rgba(63, 116, 255, 0.1);
    color: #333;
    font-weight: 600;
}

body.dark-mode .password-badge {
    background: rgba(0, 198, 255, 0.12);
    color: #8dd8ff;
}

#password-card .password-lang-btn {
    position: static;
    width: 100%;
    margin-top: 12px;
    text-align: center;
}

body.dark-mode #password-card .password-lang-btn {
    background: #7c7c84;
    color: #f5f5f5;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
}

#search-header {
    position: absolute;
    top: 10px;
    left: 10px;
    width: min(300px, calc(100vw - 24px));
    box-sizing: border-box;
    padding: 10px;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    z-index: 10;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode #search-header {
    background: #2a2a2a;
    border-color: #555;
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

#search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 8px 8px 8px;
    font-size: 16px;
    font-family: 'Nunito Sans', sans-serif;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    color: black;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode #search-input {
    background: #333;
    color: white;
    border-color: #555;
}

#results-counter {
    margin-top: 5px;
    font-size: 14px;
    color: #666;
    text-align: center;
    transition: color 0.3s ease;
}

body.dark-mode #results-counter {
    color: #ccc;
}

#tree-container {
    flex: 1;
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

/* Prevent page scrolling when using mouse wheel over SVG */
#tree-container svg {
    overflow: hidden;
    touch-action: none; /* Disable touch gestures that might interfere */
    -ms-touch-action: none;
    -moz-user-select: none; /* Firefox: Disable text selection during drag */
    -webkit-user-select: none; /* Safari: Disable text selection during drag */
    user-select: none; /* Standard: Disable text selection during drag */
}

/* Ensure smooth zooming on mouse wheel */
#tree-container svg g {
    cursor: grab;
}

#tree-container svg g:active {
    cursor: grabbing;
}

/* Middle mouse button drag feedback */
#tree-container svg g {
    cursor: grab;
}

/* Visual feedback for different drag methods */
#tree-container svg g[data-drag-button="0"] {
    cursor: grab;
}

#tree-container svg g[data-drag-button="1"] {
    cursor: grab;
}

#tree-container svg g:active[data-drag-button="0"],
#tree-container svg g:active[data-drag-button="1"] {
    cursor: grabbing;
}

#info-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 260px;
    background: white;
    border: 1px solid #ccc;
    padding: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode #info-panel {
    background: #2a2a2a;
    border-color: #555;
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

.info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#info-toggle {
    display: none;
    padding: 3px 7px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 11px;
}

body.dark-mode #info-toggle {
    background: #7c7c84;
    color: #f5f5f5;
}

#reset-zoom {
    position: absolute;
    bottom: 10px;
    left: 120px;
    padding: 10px;
    min-width: 100px;
    background: #6c757d;
    color: white;
    border: none;
    cursor: pointer;
    font-family: 'Nunito Sans', sans-serif;
}

.theme-btn {
    position: absolute;
    bottom: 60px;
    left: 10px;
    padding: 10px;
    min-width: 40px;
    background: #2b2b2b;
    color: #f1f1f1;
    border: none;
    cursor: pointer;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 16px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body.dark-mode .theme-btn {
    background: #ffe58a;
    color: #7a5b00;
}

.connection-btn {
    position: absolute;
    bottom: 60px;
    left: 60px;
    padding: 10px;
    min-width: 40px;
    background: #2b2b2b;
    color: #f1f1f1;
    border: none;
    cursor: pointer;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 16px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.connection-btn.active {
    background: #4caf6d;
    color: #081c10;
}

body.dark-mode .connection-btn {
    background: #ffe58a;
    color: #7a5b00;
}

body.dark-mode .connection-btn.active {
    background: #4caf6d;
    color: #081c10;
}

.focus-btn {
    left: 110px;
}

.focus-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.selection-reset-btn {
    left: 160px;
}

.language-btn {
    position: absolute;
    bottom: 10px;
    left: 10px;
    padding: 10px;
    min-width: 100px;
    background: #6c757d;
    color: white;
    border: none;
    cursor: pointer;
    font-family: 'Nunito Sans', sans-serif;
}

#previous-btn, #next-btn {
    position: absolute;
    padding: 10px;
    min-width: 100px;
    background: #6c757d;
    color: white;
    border: none;
    cursor: pointer;
    font-family: 'Nunito Sans', sans-serif;
}

#previous-btn {
    top: 100px;
    left: 10px;
}

#next-btn {
    top: 100px;
    left: 125px;
}

@media (max-width: 768px) {
    #search-header {
        width: min(135px, calc(45vw - 12px));
        padding: 6px 8px;
    }

    #search-input {
        font-size: 12px;
        padding: 6px 8px;
    }

    #previous-btn {
        top: 85px;
        left: 10px;
    }

    #next-btn {
        top: 130px;
        left: 10px;
    }

    #info-panel {
        width: min(200px, calc(85vw - 20px));
    }

    #info-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 28px;
        min-height: 28px;
        padding: 3px 7px;
    }

    #info-panel.collapsed {
        max-height: 52px;
        overflow: hidden;
        padding-bottom: 8px;
    }

    #info-panel.collapsed #person-details {
        display: none;
    }

    #copyright {
        font-size: 9px;
        line-height: 1.2;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }

    #copyright .copyright-text {
        display: block;
    }

    #howto-container {
        pointer-events: none;
    }

    #howto-toggle {
        pointer-events: auto;
        position: relative;
        z-index: 25;
    }

    #howto-content {
        pointer-events: none;
    }

    #howto-container.open {
        pointer-events: auto;
    }

    #howto-container.open #howto-content {
        pointer-events: auto;
    }
}

.node {
    cursor: pointer;
}

.relationship-hitbox {
    pointer-events: stroke;
    stroke-linecap: round;
    fill: none;
}

.node circle {
    stroke: #a7a7a7;
    stroke-width: 2px;
}

body.dark-mode .node circle {
    stroke: #fff;
}

.node circle[data-gender="male"] {
    fill: rgb(25, 146, 186);
}

.node circle[data-gender="female"] {
    fill: pink;
}

.node circle[data-gender="marriage"] {
    fill: green;
}

.node circle[data-gender="unknown"] {
    fill: gray;
}

.node circle.node-disconnected {
    fill: #b0b0b0;
    stroke: #7a7a7a;
}

.node.highlighted circle {
    stroke: #ffeb3b;
    stroke-width: 4px;
}

body.dark-mode .node circle.node-disconnected {
    fill: #555;
    stroke: #bbb;
}

body.dark-mode .node.highlighted circle {
    stroke: #ffd54f;
    stroke-width: 4px;
}

.fuzzy-highlight {
    background-color: rgba(255, 235, 59, 0.35);
    padding: 0 2px;
    border-radius: 3px;
}

body.dark-mode .fuzzy-highlight {
    background-color: rgba(255, 213, 79, 0.45);
}

.search-feedback {
    margin-bottom: 8px;
    font-size: 12px;
    color: #8a6d0a;
    font-style: italic;
}

body.dark-mode .search-feedback {
    color: #ffe082;
}

.connection-tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Nunito Sans', sans-serif;
    z-index: 1000;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s ease;
}

body.dark-mode .connection-tooltip {
    background: rgba(255, 255, 255, 0.9);
    color: #222;
}

.relationship-link {
    stroke: #9aa0a6;
    stroke-width: 2px;
    stroke-opacity: 0.7;
    fill: none;
}

.relationship-link.parent-marriage-link {
    stroke: #4d7ea8;
}

.relationship-link.marriage-child-link {
    stroke: #5c9b5c;
}

.relationship-link.direct-parent-child-link {
    stroke: #8f8f8f;
    stroke-dasharray: 4 3;
}

body.dark-mode .relationship-link {
    stroke-opacity: 0.85;
}

.node text {
    font-size: 12px;
    fill: #333;
    text-anchor: start;
    transition: fill 0.3s ease;
}

body.dark-mode .node text {
    fill: #fff;
}

.spouse-link {
    fill: none;
    stroke: #ff6b6b;
    stroke-width: 3px;
    stroke-opacity: 0.8;
    stroke-dasharray: 5,5;
}

.link {
    fill: none;
    stroke: #999;
    stroke-width: 2px;
    stroke-opacity: 0.6;
}

mark {
    background-color: yellow;
    color: black;
    padding: 0 2px;
    border-radius: 2px;
}

.last-updated {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ccc;
    font-size: 12px;
    color: #666;
    text-align: center;
    transition: border-color 0.3s ease, color 0.3s ease;
}

body.dark-mode .last-updated {
    border-color: #555;
    color: #ccc;
}

.research-credit {
    margin-top: 4px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

body.dark-mode .research-credit {
    color: #ccc;
}

.visualization-credit {
    margin-top: 2px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

body.dark-mode .visualization-credit {
    color: #ccc;
}

#copyright {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 12px;
    color: #666;
    opacity: 0.7;
    text-align: right;
    z-index: 10;
    transition: color 0.3s ease;
}

#copyright .copyright-text {
    display: inline-block;
}

body.dark-mode #copyright {
    color: #ccc;
}

a:link {
    color: #007bff;
    text-decoration: none;
}

a:visited {
    color: #0056b3;
    text-decoration: none;
}

a:hover {
    color: #0056b3;
    text-decoration: underline;
}

a:active {
    color: #003d82;
    text-decoration: underline;
}

@media (max-width: 768px) {
    #copyright {
        font-size: 9px;
        line-height: 1.2;
    }

    #copyright .copyright-text {
        display: block;
    }
}

.relationship-hitbox {
    pointer-events: stroke;
    stroke-linecap: round;
    fill: none;
}
.family-packet-box .family-packet-frame {
    fill: rgba(245, 233, 212, 0.15);
    stroke: #c89d6d;
    stroke-width: 3;
    stroke-dasharray: 12 8;
    rx: 18;
    ry: 18;
    transition: stroke 0.2s ease;
}

.family-packet-label {
    font-size: 18px;
    fill: #5b4636;
    font-family: 'Syne', sans-serif;
}

.family-packet-label {
    cursor: pointer;
}

body.dark-mode .family-packet-label {
    fill: #f5f5f5;
}

.family-packet-box[data-pinned="true"] .family-packet-frame {
    stroke: #8c6b49;
    stroke-width: 4;
}

.family-packet-box[data-pinned="true"] .family-packet-label {
    font-weight: 700;
}

.family-packet-box[data-selected="true"] .family-packet-frame {
    fill: rgba(158, 236, 163, 0.15);
    stroke: #5c9b6b;
    stroke-width: 3.5;
}

.family-packet-box[data-selected="true"] .family-packet-label {
    fill: #2f6e40;
    font-weight: 700;
}

body.dark-mode .family-packet-box[data-selected="true"] .family-packet-frame {
    fill: rgba(158, 236, 163, 0.15);
    stroke: #76c399;
}

body.dark-mode .family-packet-box[data-selected="true"] .family-packet-label {
    fill: #c9f0d6;
}

#howto-container {
    position: fixed;
    right: 10px;
    bottom: 10px;
    width: 360px;
    max-width: 90vw;
    font-family: 'Nunito Sans', sans-serif;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

#howto-toggle {
    width: auto;
    padding: 10px 12px;
    border: none;
    background: #6c757d;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    border-radius: 20px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
}

body.dark-mode #howto-toggle {
    background: #4b5563;
}

#howto-toggle:hover {
    background: #5b646c;
}

#howto-content {
    background: rgba(255, 255, 255, 0.96);
    color: #222;
    border: 1px solid #ccc;
    border-top: none;
    padding: 12px 12px 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    text-align: left;
    width: 100%;
    pointer-events: none;
}

body.dark-mode #howto-content {
    background: rgba(34, 34, 34, 0.96);
    color: #f5f5f5;
    border-color: #444;
}

#howto-container.open #howto-content {
    max-height: 420px;
    opacity: 1;
    transform: translateY(0);
    overflow-y: auto;
    pointer-events: auto;
}

#howto-content {
    will-change: max-height, opacity, transform;
}

#howto-content ul {
    padding-left: 16px;
    margin: 6px 0 0;
}

#howto-content li {
    margin-bottom: 6px;
    line-height: 1.3;
}

.packet-connection-lines .packet-connection-line {
    stroke: #6a92b9;
    stroke-width: 2;
    stroke-dasharray: 6 6;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: stroke;
    fill: none;
}
.packet-connection-lines .packet-connection-line,
.packet-connection-hitbox {
    cursor: pointer;
}

.tooltip-role {
    font-size: 12px;
    color: #666;
    margin-left: 6px;
}
body:not(.show-packet-lines) .family-packet-frame[data-hover="true"] {
    stroke: #8c6b49;
}

.researcher-info {
    margin-top: 4px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

.info-tooltip-text {
    cursor: help;
    text-decoration: underline dotted;
    font-weight: 700;
}

.global-tooltip-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    padding: 40px 20px;
    overflow: auto;
}

.global-tooltip-overlay.active {
    display: flex;
}

.global-tooltip-content {
    background: rgba(255, 255, 255, 0.98);
    color: #111;
    width: 66vw;
    max-width: 900px;
    max-height: calc(100vh - 160px);
    overflow: auto;
    padding: 32px 28px;
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
    margin-top: 20px;
    word-break: break-word;
}

body.dark-mode .global-tooltip-content {
    background: rgba(30, 30, 30, 0.98);
    color: #f5f5f5;
}

.global-tooltip-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 22px;
    cursor: pointer;
}
