:root {
    --gold: #d4af37;
    --gold-bright: #f1c40f;
    --neon-cyan: #00f2ff;
    --neon-pink: #ff00ea;
    --bg-dark: #0a0a0b;
    --bg-card: rgba(15, 15, 17, 0.85);
    --text-main: #f0f0f0;
    --text-dim: #99a;
    --male-bg: rgba(52, 152, 219, 0.2);
    --male-border: #3498db;
    --female-bg: rgba(231, 76, 116, 0.2);
    --female-border: #e74c3c;
    --transition: cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at top right, #1a1a2e 0%, #0a0a0b 100%) fixed;
    color: var(--text-main);
    overflow: hidden;
    height: 100vh; width: 100vw;
}

/* ============ NAVBAR ============ */
.navbar {
    position: absolute; top: 0; left: 0; width: 100%;
    padding: 20px 5%; display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(20px); z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.nav-brand { font-size: 1.5rem; font-weight: 800; letter-spacing: 2px; color: var(--gold); }
.nav-brand span { font-size: 0.6rem; background: var(--gold); color: #000; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }
.nav-menu { display: flex; gap: 20px; align-items: center; }
.nav-menu a { 
    color: var(--text-dim); text-decoration: none; font-size: 0.9rem; font-weight: 600; 
    transition: var(--transition); position: relative;
    letter-spacing: 0.5px;
}
.nav-menu a::after {
    content: ''; position: absolute; bottom: -5px; left: 0;
    width: 0; height: 2px; background: var(--neon-cyan);
    transition: var(--transition); box-shadow: 0 0 10px var(--neon-cyan);
}
.nav-menu a:hover, .nav-menu a.active { 
    color: var(--neon-cyan); 
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px rgba(0,242,255,0.3);
}
.nav-menu a:hover::after, .nav-menu a.active::after { width: 100%; }

/* ============ TREE CANVAS ============ */
.app-container {
    height: 100vh; width: 100vw;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.tree-header { 
    text-align: center; padding: 120px 20px 20px;
    z-index: 100; pointer-events: none;
}
.tree-header * { pointer-events: auto; }
.tree-header h1 {
    font-size: 2.8rem; font-weight: 800; color: #fff; margin-bottom: 5px;
    letter-spacing: 2px; text-transform: uppercase;
    display: inline-block; padding: 15px 40px;
    border: 4px double var(--gold); border-radius: 4px;
    box-shadow: 0 0 30px rgba(212,175,55,0.3), inset 0 0 20px rgba(212,175,55,0.1);
    position: relative;
    text-shadow: 2px 2px 20px rgba(0,0,0,0.5);
}

@supports (-webkit-background-clip: text) or (background-clip: text) {
    .tree-header h1 {
        background: linear-gradient(110deg, #fff 0%, #fff 25%, #f5d97e 45%, #fff 65%, #fff 100%);
        background-size: 200% auto;
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        animation: glassShine 4s linear infinite;
    }
}

@keyframes glassShine {
    0% { background-position: 250% center; }
    100% { background-position: -150% center; }
}
.tree-header h1::before, .tree-header h1::after {
    content: "◈"; position: absolute; color: var(--gold); font-size: 1.2rem; top: 50%; transform: translateY(-50%);
}
.tree-header h1::before { left: 10px; }
.tree-header h1::after { right: 10px; }
.tree-header p { color: var(--text-dim); font-size: 0.95rem; }

.tree-view-wrapper {
    flex: 1; overflow: hidden; position: relative;
    cursor: grab; background: rgba(0,0,0,0.2);
}
.tree-view-wrapper:active { cursor: grabbing; }

.tree-canvas {
    position: absolute; width: 6000px; height: 6000px;
    background-image: 
        radial-gradient(rgba(212,175,55,0.1) 1px, transparent 1px),
        radial-gradient(rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 80px 80px, 20px 20px;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
}

/* ============ NODES ============ */
.family-node {
    position: absolute; width: 220px; padding: 15px;
    background: rgba(20, 20, 25, 0.7); border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 15px 35px rgba(0,0,0,0.6);
    backdrop-filter: blur(15px);
    display: flex; flex-direction: column; align-items: center; text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 50;
}
.family-node:hover { transform: translateY(-10px) scale(1.08); z-index: 500; border-color: var(--gold); }

.node-male { 
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.25) 0%, rgba(0,0,0,0.4) 100%); 
    border-color: rgba(52, 152, 219, 0.5); 
}
.node-male:hover { border-color: #3498db; box-shadow: 0 20px 50px rgba(52, 152, 219, 0.3); }

.node-female { 
    background: linear-gradient(135deg, rgba(231, 76, 116, 0.25) 0%, rgba(0,0,0,0.4) 100%); 
    border-color: rgba(231, 76, 116, 0.5); 
}
.node-female:hover { border-color: #e74c3c; box-shadow: 0 20px 50px rgba(231, 76, 116, 0.3); }

.node-photo {
    width: 80px; height: 80px; border-radius: 20px; /* Squircle style */
    margin-bottom: 15px; border: 3px solid rgba(255,255,255,0.1);
    object-fit: cover; box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    transition: 0.3s;
}
.family-node:hover .node-photo { border-color: #fff; transform: scale(1.1); }

.node-name { font-weight: 700; font-size: 1.1rem; margin-bottom: 5px; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.node-meta { font-size: 0.8rem; color: var(--text-dim); }

.btn-action {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    font-size: 0.9rem; transition: 0.3s;
}
.btn-action:hover { background: var(--gold); color: #000; border-color: var(--gold); transform: rotate(15deg); }

/* ============ CONNECTORS ============ */
.connector-line {
    position: absolute; background: rgba(255,255,255,0.15);
    height: 2px; transform-origin: top left;
    pointer-events: none; z-index: 10;
}

/* ============ BUTTONS ============ */
.btn-primary {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: white; padding: 8px 18px; border-radius: 50px; cursor: pointer;
    font-size: 0.85rem; font-weight: 700; transition: var(--transition);
}
.btn-primary:hover { background: var(--gold); color: #000; border-color: var(--gold); }
.btn-primary.gold { background: var(--gold); color: #000; border-color: var(--gold); }

.tree-controls {
    position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
    display: flex; gap: 15px; background: rgba(0,0,0,0.8);
    backdrop-filter: blur(15px); padding: 10px 25px; border-radius: 50px; 
    border: 1px solid rgba(212,175,55,0.3); z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.tree-controls button {
    background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer;
    width: 45px; height: 45px; border-radius: 50%; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.tree-controls button:hover { background: rgba(212,175,55,0.1); color: var(--gold); transform: scale(1.1); }

.family-item {
    padding: 20px; border: 1px solid rgba(255,255,255,0.05);
    background: rgba(255,255,255,0.02); border-radius: 12px;
    margin-bottom: 15px; transition: var(--transition);
    display: flex; justify-content: space-between; align-items: center;
}
.family-item:hover { background: rgba(212,175,55,0.1); border-color: var(--gold); }
.family-item strong { color: var(--gold); font-size: 1.1rem; }

/* ============ MODALS ============ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center; z-index: 2000;
    opacity: 0; pointer-events: none; transition: 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-box {
    background: var(--bg-dark); border: 1px solid var(--gold); padding: 40px;
    border-radius: 24px; width: 95%; max-width: 500px; position: relative;
    box-shadow: 0 0 50px rgba(212,175,55,0.2);
    max-height: 90vh; overflow-y: auto;
}
.modal-box h2 { font-size: 1.8rem; margin-bottom: 1.2rem; color: var(--gold); }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-dim); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.1);
    color: #fff; padding: 12px 15px; border-radius: 12px; font-family: inherit; font-size: 0.9rem;
    transition: var(--transition);
}
.form-group select option {
    background: #111; color: #fff; padding: 10px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--gold); background: rgba(255,255,255,0.1);
}

.lightbox-content {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; height: 100%; animation: fadeIn 0.4s ease;
}
.node-photo { cursor: zoom-in; transition: transform 0.3s ease; }
.node-photo:hover { transform: scale(1.05); }

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.btn-submit {
    width: 100%; background: var(--gold); color: #000; border: none;
    padding: 15px; border-radius: 12px; font-weight: 800; cursor: pointer;
    font-size: 1rem; margin-top: 10px; transition: var(--transition);
}
.btn-submit:hover { background: var(--gold-bright); box-shadow: 0 0 20px rgba(212,175,55,0.5); }
.btn-close {
    position: absolute; top: 20px; right: 20px; background: none; border: none;
    color: var(--text-dim); font-size: 1.5rem; cursor: pointer;
}

/* ============ MOBILE RESPONSIVE ============ */
@media (max-width: 768px) {
    .navbar { padding: 15px 4%; }
    .nav-brand { font-size: 1.2rem; }
    .nav-menu { gap: 10px; }
    .nav-menu a { font-size: 0.75rem; }
    .nav-menu .btn-primary { padding: 6px 12px; font-size: 0.7rem; }

    .tree-header { padding-top: 100px; padding-bottom: 10px; }
    .tree-header h1 { 
        font-size: 1.5rem; padding: 10px 25px; 
        border-width: 2px;
    }
    .tree-header h1::before, .tree-header h1::after { font-size: 0.8rem; }
    .tree-header p { font-size: 0.8rem; }

    .modal-box { 
        padding: 25px 20px; border-radius: 18px; 
        max-height: 85vh; overflow-y: auto;
    }
    .modal-box h2 { font-size: 1.4rem; margin-bottom: 0.8rem; }
    .modal-box p { font-size: 0.85rem; margin-bottom: 1rem; }
    
    .family-item { padding: 12px; margin-bottom: 10px; }
    .family-item strong { font-size: 0.9rem; }

    .tree-controls { bottom: 20px; padding: 8px 15px; gap: 8px; }
    .tree-controls button { width: 38px; height: 38px; font-size: 1rem; }
    
    #addMemberFloating { right: 20px; bottom: 20px; width: 50px; height: 50px; font-size: 1.2rem; }

    .family-node { width: 180px; padding: 12px; }
    .node-photo { width: 60px; height: 60px; margin-bottom: 10px; }
    .node-name { font-size: 0.95rem; }
    .node-meta { font-size: 0.7rem; }
}

@media (max-width: 480px) {
    .nav-menu a { display: none; } /* Hide text links on very small screens to save space */
    .nav-menu a.active { display: none; }
    .nav-brand { font-size: 1rem; }
}
