:root {
    --ink: #223046;
    --accent: #5f84bd;
    --accent-soft: #dce6f7;
    --leaf: #f0b341;
    --cream: #f7f2e4;
    --card: #fffdf8;
    --line: #b8c9e8;
    --ok: #1f7a47;
    --warn: #b04a2c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Manrope", sans-serif;
    background: radial-gradient(circle at top right, #f5f8ff 0%, #eef2fb 40%, #f6f3ea 100%);
    position: relative;
    overflow-x: hidden;
}

.page-bg {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(120deg, rgba(95, 132, 189, 0.12), transparent 55%),
        radial-gradient(circle at 20% 20%, rgba(240, 179, 65, 0.16), transparent 40%);
    pointer-events: none;
    z-index: -1;
}

.hero {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1rem 1rem;
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    gap: 1.5rem;
    align-items: center;
    animation: fadeIn 700ms ease;
}

.hero-logo {
    width: 100%;
    max-width: 250px;
    justify-self: center;
    filter: drop-shadow(0 14px 24px rgba(48, 82, 140, 0.22));
}

.hero-copy h1 {
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(2.1rem, 5vw, 3.4rem);
    line-height: 1;
    margin: 0.1rem 0 0.75rem;
}

.kicker {
    margin: 0;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: #35588f;
    font-weight: 700;
}

.subtext {
    margin: 0;
    max-width: 52ch;
    color: #3f4f67;
}

.tree-controls {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.8rem 1rem 1.4rem;
}

.tree-controls label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.45rem;
}

.control-row {
    display: flex;
    gap: 0.75rem;
}

#nameSearch,
#resetTree {
    border-radius: 999px;
    border: 1px solid #c8d6ef;
    font: inherit;
}

#nameSearch {
    flex: 1;
    min-width: 0;
    padding: 0.65rem 1rem;
    background: #ffffff;
}

#nameSearch:focus {
    outline: 3px solid #d8e3f7;
    border-color: #9eb6de;
}

#resetTree {
    padding: 0.65rem 1.1rem;
    background: linear-gradient(180deg, #ffffff, #edf2fc);
    color: #28406a;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

#resetTree:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(52, 78, 118, 0.14);
}

.tree-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 0.4rem 2.4rem;
    overflow-x: auto;
    overflow-y: hidden;
}

.tree {
    list-style: none;
    margin: 0;
    padding: 1.2rem 1.2rem 2rem;
    display: inline-flex;
    justify-content: center;
    min-width: 100%;
}

.tree ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 0.7rem;
    margin: 0;
    padding: 2.2rem 0 0;
    position: relative;
}

.tree ul::before {
    content: "";
    position: absolute;
    left: 10%;
    right: 10%;
    top: 0.8rem;
    border-top: 2px solid var(--line);
}

.tree li {
    text-align: center;
    position: relative;
    padding: 0 0.35rem;
}

.tree li::before {
    content: "";
    position: absolute;
    top: -1.4rem;
    left: 50%;
    transform: translateX(-50%);
    height: 1.4rem;
    border-left: 2px solid var(--line);
}

.tree > li::before {
    display: none;
}

.member {
    border: 2px solid #e4ecfb;
    background: var(--card);
    color: var(--ink);
    border-radius: 16px;
    min-width: 150px;
    max-width: 210px;
    padding: 0.65rem 0.75rem;
    box-shadow: 0 10px 18px rgba(38, 64, 107, 0.08);
    transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease;
}

.member.has-children {
    cursor: pointer;
}

.member:hover {
    transform: translateY(-3px);
    border-color: #d0def6;
    box-shadow: 0 14px 24px rgba(38, 64, 107, 0.14);
}

.member-name {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
}

.member-meta {
    display: block;
    margin-top: 0.18rem;
    font-size: 0.78rem;
    color: #546883;
}

.member-toggle {
    display: inline-block;
    margin-top: 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #2d4f82;
    background: #eaf0fd;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}

.member.highlight {
    border-color: var(--leaf);
    box-shadow: 0 0 0 4px rgba(240, 179, 65, 0.23), 0 14px 24px rgba(38, 64, 107, 0.14);
}

.member.match-miss {
    opacity: 0.4;
}

.children.collapsed {
    display: none;
}

footer {
    padding: 0.4rem 1rem 2rem;
    text-align: center;
    font-size: 0.88rem;
    color: #50607a;
}

.contact-cta {
    position: fixed;
    top: 1rem;
    right: 1rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #2f5e9d, #244a7b);
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    padding: 0.72rem 1.35rem;
    box-shadow: 0 12px 26px rgba(31, 58, 99, 0.32);
    cursor: pointer;
    z-index: 40;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.contact-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(31, 58, 99, 0.38);
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 50;
}

.modal.is-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(21, 33, 52, 0.58);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    width: min(560px, 100%);
    border-radius: 18px;
    background: #fffdf8;
    border: 1px solid #d9e4f7;
    box-shadow: 0 24px 54px rgba(23, 40, 72, 0.28);
    padding: 1.2rem 1rem 1rem;
}

.modal-content h2 {
    margin: 0;
    font-family: "Cormorant Garamond", serif;
    font-size: 2rem;
}

.modal-subtext {
    margin: 0.2rem 0 1rem;
    color: #52637d;
    font-size: 0.95rem;
}

.modal-close {
    position: absolute;
    right: 0.5rem;
    top: 0.4rem;
    border: 0;
    background: transparent;
    color: #4f6485;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.contact-form {
    display: grid;
    gap: 0.7rem;
}

.contact-form input,
.contact-form textarea,
.contact-form button {
    font: inherit;
}

.contact-form input,
.contact-form textarea {
    width: 100%;
    border: 1px solid #c8d7f0;
    background: #ffffff;
    border-radius: 12px;
    padding: 0.7rem 0.8rem;
}

.contact-form textarea {
    min-height: 120px;
    resize: vertical;
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: 3px solid #dce7f8;
    border-color: #9ab2da;
}

.contact-form button {
    justify-self: end;
    border: 0;
    border-radius: 12px;
    padding: 0.68rem 1.15rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, #3e72b5, #2f5b94);
    cursor: pointer;
}

.modal-open {
    overflow: hidden;
}

.contact-success {
    text-align: center;
    padding: 1.2rem 0.5rem 0.5rem;
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    background: #dcf5e8;
    color: #1f7a47;
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 0.8rem;
}

.contact-success h2 {
    margin: 0 0 0.4rem;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.9rem;
    color: #1f4e30;
}

.contact-success p {
    margin: 0 0 1.2rem;
    color: #3b5c48;
    font-size: 0.98rem;
}

.success-close-btn {
    border: 0;
    border-radius: 12px;
    padding: 0.65rem 1.4rem;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, #3e72b5, #2f5b94);
    cursor: pointer;
}

.contact-error {
    margin: 0;
    font-size: 0.88rem;
    color: #b04a2c;
    background: #fdf0ec;
    border: 1px solid #f0c9bb;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
}

#contactSubmitBtn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.contact-success {
    text-align: center;
    padding: 1.2rem 0.5rem 0.5rem;
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    background: #dcf5e8;
    color: #1f7a47;
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 0.8rem;
}

.contact-success h2 {
    margin: 0 0 0.4rem;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.9rem;
    color: #1f4e30;
}

.contact-success p {
    margin: 0 0 1.2rem;
    color: #3b5c48;
    font-size: 0.98rem;
}

.success-close-btn {
    border: 0;
    border-radius: 12px;
    padding: 0.65rem 1.4rem;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, #3e72b5, #2f5b94);
    cursor: pointer;
}

.contact-error {
    margin: 0;
    font-size: 0.88rem;
    color: #b04a2c;
    background: #fdf0ec;
    border: 1px solid #f0c9bb;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
}

#contactSubmitBtn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-copy {
        margin: 0 auto;
    }

    .tree {
        justify-content: flex-start;
        min-width: 850px;
    }
}

@media (max-width: 640px) {
    .control-row {
        flex-direction: column;
    }

    #resetTree {
        width: 100%;
    }

    .contact-cta {
        top: 0.7rem;
        right: 0.7rem;
        width: auto;
    }

    .modal-content {
        padding: 1rem 0.85rem 0.85rem;
    }

    .contact-form button {
        width: 100%;
    }
}
