:root {
    /* Color System */
    --bg-dark: #0f172a;
    --bg-light: #f8fafc;

    /* Default to Dark Theme variables */
    --bg-app: var(--bg-dark);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;

    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: 12px;
    --card-hover-bg: rgba(51, 65, 85, 0.8);

    /* Accents */
    --primary: #3b82f6;
    --accent-primary: #a78bfa;
    --accent-primary-rgb: 167, 139, 250;
    --accent-glow: rgba(59, 130, 246, 0.5);

    /* Layout */
    --header-height: 180px;
    --max-width: 1400px;
}

[data-theme="light"] {
    --bg-app: var(--bg-light);
    --text-primary: #1e293b;
    --text-secondary: #64748b;

    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.05);
    --card-hover-bg: rgba(255, 255, 255, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Yatra One', cursive;
    background-color: var(--bg-app);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color 0.5s ease;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Background Ambient Glow */
/* Background Ambient Glow (Mesh Gradient) */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.3) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.3) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.3) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(16, 185, 129, 0.3) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
    filter: blur(60px);
    animation: meshFlow 20s ease-in-out infinite alternate;
}

[data-theme="light"] .app-background {
    background-color: var(--bg-light);
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.2) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.2) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.2) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(16, 185, 129, 0.2) 0px, transparent 50%);
}

@keyframes meshFlow {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.1);
    }
}

.app-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.main-header {
    position: relative;
    z-index: 100;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--glass-surface);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    /* Solid Color - Gradient Removed */
    color: var(--text-primary);
}

/* Logo Icon Styling */
.logo-img {
    height: 48px;
    width: auto;
    object-fit: contain;
}

/* Intro Overlay */
.intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Keep it initially visible */
}

.intro-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.intro-brand__top,
.intro-brand__bottom {
    font-family: 'Yatra One', cursive;
    font-weight: 400;
    background: linear-gradient(135deg, #d4a853, #f0d78c, #d4a853);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInText 1.2s ease-out both;
}

.intro-brand__top {
    font-size: 2.5rem;
    animation-delay: 0.2s;
}

.intro-brand__bottom {
    font-size: 1.4rem;
    opacity: 0.85;
    animation-delay: 0.5s;
}

@keyframes fadeInText {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

[data-theme="light"] .intro-overlay {
    background-color: var(--bg-light);
}

.intro-overlay .logo-img {
    height: 240px;
    /* Big initial logo */
    width: auto;
}

.heart-beat {
    animation: pulseHeart 1.5s infinite ease-in-out;
}

@keyframes pulseHeart {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.15);
        opacity: 1;
        filter: drop-shadow(0 0 15px var(--accent-glow));
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

/* Navigation Tabs */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    padding: 0.5rem;
    border-radius: 99px;
    align-self: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-btn .material-symbols-rounded {
    font-size: 20px;
}

/* View Container */
.view-container {
    flex: 1;
    position: relative;
    min-height: 600px;
}



/* Header Tools */
.header-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Search Bar --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.header-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 12rem;
    max-width: clamp(14rem, 22vw, 20rem);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    padding: 0 1rem 0 0.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.header-search__icon {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-right: 0.4rem;
}

.header-search__input {
    flex: 1 1 auto;
    border: none;
    background: transparent;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0.55rem 0;
    min-width: 0;
    font-family: inherit;
}

.header-search__input::placeholder {
    color: var(--text-secondary);
}

.header-search__input:focus {
    outline: none;
}

.header-search__suggestions {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    border-radius: 1.2rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.5);
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 100;
}

[data-theme="light"] .header-search__suggestions {
    background: rgba(248, 250, 252, 0.98);
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.12);
}

.header-search__message {
    margin: 0;
    padding: 0.75rem 0.6rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.header-search__option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 0.9rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    transition: background 0.18s ease, transform 0.18s ease;
}

.header-search__option:hover,
.header-search__option:focus-visible,
.header-search__option.is-active {
    background: rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
    outline: none;
}

[data-theme="light"] .header-search__option:hover,
[data-theme="light"] .header-search__option:focus-visible,
[data-theme="light"] .header-search__option.is-active {
    background: rgba(59, 130, 246, 0.1);
}

.header-search__primary {
    font-size: 0.98rem;
    font-weight: 600;
}

.header-search__meta {
    margin-top: 0.35rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.header-search__meta span {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
}

[data-theme="light"] .header-search__meta span {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.header-search__note {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* --- Filter Toggle Button --- */
.filter-toggle,
.grid-sort-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.filter-toggle:hover,
.grid-sort-toggle:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

.filter-toggle.is-active {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

/* --- Filter Panel --- */
.filter-panel {
    position: absolute;
    top: 5rem;
    right: 1rem;
    width: clamp(280px, 28vw, 340px);
    border-radius: 1.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(22px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.5);
    z-index: 40;
}

[data-theme="light"] .filter-panel {
    background: rgba(248, 250, 252, 0.92);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.1);
}

.filter-panel.hidden {
    display: none;
}

.filter-panel__content {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: 1.2rem 1.4rem 1.3rem;
}

.filter-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.filter-panel__header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.filter-close {
    width: 2.4rem;
    height: 2.4rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.filter-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.filter-status {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.filter-section h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.filter-section__hint {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.filter-option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.filter-option {
    padding: 0.55rem 0.9rem;
    border-radius: 0.95rem;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.filter-option:hover {
    transform: translateY(-1px);
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.35);
}

.filter-option.is-active {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.35);
}

.filter-option.is-pending {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.4);
}

.filter-option .material-symbols-rounded,
.filter-footer .material-symbols-rounded {
    font-size: 1.35rem;
}

.filter-footer {
    display: flex;
    justify-content: flex-end;
}

/* Family Data Toggle */
.family-data-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.family-data-toggle:hover {
    border-color: var(--primary);
}

.family-data-toggle.is-active {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

[data-theme="light"] .family-data-toggle.is-active {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

/* Theme Toggle */
.theme-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    border-color: var(--primary);
    transform: rotate(15deg);
}

.theme-btn .icon {
    display: none;
}

body:not([data-theme="light"]) .theme-btn .sun {
    display: block;
}

body[data-theme="light"] .theme-btn .moon {
    display: block;
}

/* --- Shared Components --- */
.member-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    /* Ensure text is readable on colored backgrounds */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.member-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--group-color, var(--primary));
}

.member-card:hover {
    transform: translateY(-5px) scale(1.02);
    background: var(--card-hover-bg);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
    border-color: var(--group-color);
}

.member-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.member-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Modal (Retained styles but polished) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    padding: 2.5rem;
    overflow-y: auto;
    position: relative;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .modal-content {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
}

/* Modal Timeline Styles */
.lineage-section {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
}

.lineage-section::before {
    content: '';
    position: absolute;
    top: 30px;
    bottom: -30px;
    left: 50%;
    width: 2px;
    background: var(--glass-border);
    z-index: 0;
}

.lineage-section:last-child::before {
    display: none;
}

.lineage-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: var(--bg-app);
    padding: 0 1rem;
    z-index: 1;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    border-radius: 12px;
}

.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
    width: 100%;
}

.members-grid.single-card {
    grid-template-columns: 1fr;
}

.descendant-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    z-index: 1;
}

/* --- Rich Modal Styles --- */
.modal-person-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-person-header h2 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.modal-person-header .note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.modal-person-image-container {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem auto;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-person-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

[data-theme="light"] .modal-person-image-container {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.02);
}

.modal-person-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.date-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 0.8rem;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.date-item .material-symbols-rounded {
    font-size: 1.1rem;
    color: var(--primary);
}

[data-theme="light"] .date-item {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    display: inline-block;
}

[data-theme="light"] .modal-section h3 {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.ancestors-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.person-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.8rem;
    text-align: center;
    min-width: 100px;
    flex: 1;
}

.relation-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.person-name {
    font-weight: 600;
    color: var(--text-primary);
}

.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.person-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.person-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.person-chip.child {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.2));
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.person-chip.grandchild {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.1), rgba(167, 139, 250, 0.2));
    border-color: rgba(167, 139, 250, 0.3);
    color: #c4b5fd;
}

.person-chip.great-grandchild {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.1), rgba(236, 72, 153, 0.2));
    border-color: rgba(236, 72, 153, 0.3);
    color: #fca5a5;
}

/* Light Mode Chips Overrides */
[data-theme="light"] .person-chip {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

[data-theme="light"] .person-chip:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .person-chip.child {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.2));
    border-color: rgba(37, 99, 235, 0.3);
    color: #1e40af;
}

[data-theme="light"] .person-chip.grandchild {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(124, 58, 237, 0.2));
    border-color: rgba(124, 58, 237, 0.3);
    color: #6d28d9;
}

[data-theme="light"] .person-chip.great-grandchild {
    background: linear-gradient(135deg, rgba(219, 39, 119, 0.1), rgba(219, 39, 119, 0.2));
    border-color: rgba(219, 39, 119, 0.3);
    color: #9d174d;
}

.descendants-group {
    margin-bottom: 1rem;
}

.descendants-group h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-text {
    color: var(--text-disabled);
    font-style: italic;
    font-size: 0.9rem;
}

/* Generation Section & Headers */
.generation-section {
    margin-bottom: 3rem;
    animation: fadeIn 0.5s ease-out;
}

.generation-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--glass-bg);
    border-radius: 99px;
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    width: fit-content;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.gen-badge {
    font-weight: 800;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.count-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.generation-header:hover .count-badge {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

[data-theme="light"] .count-badge {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .generation-header:hover .count-badge {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.15);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {

    /* Layout Adjustments */
    .app-container {
        padding: 0.5rem;
        padding-bottom: 90px;
    }

    /* Header */
    .main-header {
        flex-wrap: wrap;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
        gap: 0.5rem;
    }

    .logo-area {
        flex: 1 1 auto;
        margin-bottom: 0;
    }

    .logo-area h1 {
        font-size: 1.1rem;
    }

    .logo-area .logo-img {
        height: 32px;
    }

    /* Tools — stay in the top row next to logo */
    .header-tools {
        flex: 0 0 auto;
        gap: 0.25rem;
    }

    .header-tools .icon-button,
    .header-tools .theme-btn {
        width: 34px;
        height: 34px;
    }

    .header-tools .icon-button .material-symbols-rounded,
    .header-tools .theme-btn .material-symbols-rounded {
        font-size: 20px;
    }

    /* Search — full-width second row */
    .header-search {
        order: 10;
        flex: 1 1 100%;
        max-width: 100%;
        min-width: 0;
    }

    .header-search__suggestions {
        width: calc(100vw - 1.5rem);
        left: 50%;
        transform: translateX(-50%);
    }

    /* Navigation - FIXED BOTTOM BAR */
    .main-nav {
        position: fixed;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 400px;
        background: rgba(15, 23, 42, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 24px;
        padding: 0.5rem 1rem;
        justify-content: space-between;
        align-items: center;
        gap: 0;
        z-index: 1000;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
        margin: 0;
        overflow: visible;
        display: flex;
    }

    /* Filter panel mobile */
    .filter-panel {
        position: fixed;
        top: auto;
        bottom: 80px;
        right: 0.75rem;
        left: 0.75rem;
        width: auto;
        max-height: 60vh;
        overflow-y: auto;
    }

    [data-theme="light"] .main-nav {
        background: rgba(255, 255, 255, 0.85);
        border: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    }

    .nav-btn {
        padding: 0.6rem;
        border-radius: 12px;
        flex-direction: column;
        gap: 0.2rem;
        font-size: 0.7rem;
        background: transparent;
        color: var(--text-secondary);
        width: auto;
        flex: 1;
    }

    .nav-btn:hover {
        background: transparent;
        color: var(--text-primary);
    }

    .nav-btn.active {
        background: rgba(255, 255, 255, 0.1);
        color: var(--primary);
        box-shadow: none;
    }

    [data-theme="light"] .nav-btn.active {
        background: rgba(0, 0, 0, 0.05);
    }

    .nav-btn .material-symbols-rounded {
        font-size: 24px;
        margin-bottom: 2px;
    }

    /* Grid View */
    .members-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0;
    }

    .member-card {
        padding: 0.75rem;
    }

    .member-name {
        font-size: 0.95rem;
    }

    .member-note {
        font-size: 0.75rem;
    }

    /* Modals */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        border-radius: 0;
        padding: 1rem;
        padding-bottom: 100px;
    }

    .close-btn {
        top: 1rem;
        right: 1rem;
    }

    .ancestors-grid {
        flex-wrap: wrap;
    }

    /* Generation Header */
    .generation-header {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 1rem;
        border-radius: 12px;
    }
}

/* Small Mobile Adjustments */
@media (max-width: 380px) {}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
}

.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge--alive {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-badge--alive .status-dot {
    background-color: #16a34a;
}

[data-theme="dark"] .status-badge--alive {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

.status-badge--dead {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge--dead .status-dot {
    background-color: #b91c1c;
}

[data-theme="dark"] .status-badge--dead {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}