/* Kinline - Family Tree Database Styles */

:root {
    /* Kinline Colors - MeshLabs palette */
    --primary: #239eff;
    --primary-dark: #1b89ff;
    --primary-light: #3873ff;
    --accent: #f63f9f;
    --secondary: #7f8087;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --bg-primary: #0a0b0f;
    --bg-secondary: #12131a;
    --bg-tertiary: #1a1c26;
    
    --text-primary: #f3f5ff;
    --text-secondary: #a0a3b1;
    --text-muted: #6b6e7a;
    
    --border-color: rgba(243, 245, 255, 0.08);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.5);
    
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    
    /* Spacing Scale (8px base) */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.5rem;    /* 24px */
    --space-6: 2rem;      /* 32px */
    --space-8: 3rem;      /* 48px */
    
    /* Input sizing */
    --input-height: 2.5rem;      /* 40px - proper touch target */
    --input-height-sm: 2rem;     /* 32px */
    --input-height-lg: 3rem;     /* 48px */
    --input-padding-x: 0.875rem; /* 14px */
    --input-padding-y: 0.5rem;   /* 8px */
    --input-font-size: 0.9375rem; /* 15px */
}

/* Dark Mode - same as base (MeshLabs is dark-first) */
[data-theme="dark"] {
    --primary: #239eff;
    --primary-dark: #1b89ff;
    --accent: #f63f9f;
    
    --bg-primary: #0a0b0f;
    --bg-secondary: #12131a;
    --bg-tertiary: #1a1c26;
    
    --text-primary: #f3f5ff;
    --text-secondary: #a0a3b1;
    --text-muted: #6b6e7a;
    
    --border-color: rgba(243, 245, 255, 0.08);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.5);
}

[data-theme="dark"] .book-cover {
    background: linear-gradient(135deg, rgba(243, 245, 255, 0.12) 0%, var(--bg-tertiary) 100%);
}

[data-theme="dark"] .data-table tbody tr:hover {
    background: var(--bg-tertiary);
}

/* Tree dark mode - forest theme colors */
[data-theme="dark"] .tree-node.male rect {
    fill: #0d1a2e;
    stroke: #239eff;
}

[data-theme="dark"] .tree-node.female rect {
    fill: #2a0d1f;
    stroke: #f63f9f;
}

[data-theme="dark"] .tree-node.unknown rect {
    fill: #1a1c26;
    stroke: #6b6e7a;
}

[data-theme="dark"] .tree-node text {
    fill: #f3f5ff;
}

[data-theme="dark"] .tree-link {
    stroke: #3873ff44;
}

/* Dark mode link colors */
[data-theme="dark"] a {
    color: #239eff;
}

[data-theme="dark"] a:hover {
    color: #f63f9f;
}

[data-theme="dark"] .family-member,
[data-theme="dark"] .data-table a,
[data-theme="dark"] .person-card,
[data-theme="dark"] .linked-people a,
[data-theme="dark"] .external-links a {
    color: var(--primary);
}

[data-theme="dark"] .linked-people a:hover {
    background: var(--primary);
    color: var(--bg-primary);
}

[data-theme="dark"] .btn {
    background: var(--bg-tertiary);
    border-color: rgba(243, 245, 255, 0.12);
    color: var(--text-primary);
}

[data-theme="dark"] .btn:hover {
    background: rgba(243, 245, 255, 0.12);
}

[data-theme="dark"] .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

[data-theme="dark"] .btn-primary:hover {
    background: var(--primary-dark);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg-tertiary);
    border-color: rgba(243, 245, 255, 0.12);
    color: var(--text-primary);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 158, 255, 0.2);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Content above mesh background canvas */
.navbar, .container, main, footer, .flash-container {
    position: relative;
    z-index: 1;
}
/* main must outrank footer in stacking order so that fixed modals
   inside main (z-index 1000+) aren't painted behind the footer.
   Must use main.container (specificity 0-1-1) to beat the .container
   class rule (0-1-0) that would otherwise override a bare `main` selector. */
main.container {
    z-index: 2;
}

/* Glass morphism base class */
.glass-card {
    background: rgba(243, 245, 255, 0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(243, 245, 255, 0.06);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
}

.glass-card:hover {
    background: rgba(243, 245, 255, 0.06);
    border-color: rgba(243, 245, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Text utilities */
.text-accent { color: var(--accent); }
.text-primary-color { color: var(--primary); }

/* Card - glassmorphic variant of generic .card */
.card {
    background: rgba(243, 245, 255, 0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(243, 245, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.card:hover {
    background: rgba(243, 245, 255, 0.05);
    border-color: rgba(243, 245, 255, 0.1);
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card .text-muted,
.card p.text-muted {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ============ Base Form Elements ============ */
/* Consistent input styling across all forms */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="url"],
textarea,
select {
    height: var(--input-height);
    padding: var(--input-padding-y) var(--input-padding-x);
    font-size: var(--input-font-size);
    font-family: inherit;
    color: var(--text-primary);
    background: rgba(243, 245, 255, 0.03);
    border: 1px solid rgba(243, 245, 255, 0.08);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

textarea {
    height: auto;
    min-height: 5rem;
    resize: vertical;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 158, 255, 0.2);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* Small inputs */
input.input-sm,
select.input-sm {
    height: var(--input-height-sm);
    font-size: 0.8125rem;
    padding: 0.25rem 0.625rem;
}

/* Large inputs */
input.input-lg,
select.input-lg {
    height: var(--input-height-lg);
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

/* Checkbox and radio - keep natural size */
input[type="checkbox"],
input[type="radio"] {
    height: auto;
    width: auto;
}

/* Navbar */
.navbar {
    background: rgba(10, 11, 15, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(243, 245, 255, 0.06);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Tree switcher (Path A) — dropdown in the nav to pick the active tree */
.tree-switcher {
    position: relative;
}
.tree-menu-toggle {
    display: flex; align-items: center; gap: 0.4rem;
    background: rgba(243, 245, 255, 0.04);
    border: 1px solid rgba(243, 245, 255, 0.1);
    color: var(--text-primary);
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s;
}
.tree-menu-toggle:hover { background: rgba(243, 245, 255, 0.08); }
.tree-menu-toggle .tree-icon { font-size: 0.95rem; }
.tree-menu-toggle .tree-name {
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-menu-toggle .dropdown-arrow { font-size: 0.7rem; color: var(--text-muted); }
.tree-menu-dropdown {
    position: absolute; right: 0; top: calc(100% + 0.4rem);
    background: var(--bg-secondary);
    border: 1px solid rgba(243, 245, 255, 0.1);
    border-radius: 8px;
    min-width: 240px; max-height: 360px; overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
    padding: 0.35rem 0;
}
.tree-menu-dropdown.open { display: block; }
.tree-menu-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.55rem 0.85rem; color: var(--text-primary);
    text-decoration: none; font-size: 0.88rem;
    transition: background 0.1s;
}
.tree-menu-item:hover { background: rgba(35, 158, 255, 0.08); }
.tree-menu-item.active {
    background: rgba(35, 158, 255, 0.12);
    color: #5fb1ff;
    font-weight: 500;
}
.tree-menu-item .tree-item-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-right: 0.5rem;
}
.tree-menu-item .tree-item-role {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.3px;
    color: var(--text-muted);
}
.tree-menu-item.active .tree-item-role { color: #5fb1ff; }
.tree-menu-divider {
    height: 1px; background: rgba(243, 245, 255, 0.08);
    margin: 0.35rem 0;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.nav-logo {
    height: 32px;
    width: auto;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(243, 245, 255, 0.06);
}

.nav-links a.active,
.nav-links li.active > a {
    color: var(--primary);
    background: rgba(35, 158, 255, 0.1);
}

/* Nav dropdown */
.nav-dropdown {
    position: relative;
}
.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: rgba(18, 19, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(243, 245, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    list-style: none;
    min-width: 200px;
    padding: 0.5rem 0;
    z-index: 200;
}

/* Bridge hover gap for nav dropdown */
.nav-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 4px;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}
.nav-dropdown-menu li a {
    display: block;
    padding: 0.5rem 1rem;
    border-radius: 0;
    white-space: nowrap;
}
.nav-dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin: 0.25rem 0;
}
.nav-dropdown-divider a { display: none; }

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--input-height);
    padding: 0 var(--space-4);
    border: 1px solid rgba(243, 245, 255, 0.1);
    border-radius: var(--radius);
    background: rgba(243, 245, 255, 0.04);
    color: var(--text-primary);
    font-size: var(--input-font-size);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    background: rgba(243, 245, 255, 0.08);
    border-color: rgba(243, 245, 255, 0.15);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 0 20px rgba(35, 158, 255, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-small {
    height: var(--input-height-sm);
    padding: 0 var(--space-3);
    font-size: 0.8125rem;
}

.btn-large {
    height: var(--input-height-lg);
    padding: 0 var(--space-5);
    font-size: 1rem;
}

/* Dashboard */
.dashboard {
    text-align: center;
    max-width: 1100px;
    margin: 0 auto;
}

.dash-hero {
    padding: 3rem 0 2.5rem;
}

.dash-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.dash-subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
}

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

.stats-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.25rem 1.5rem;
    min-width: 140px;
    flex: 1;
    position: relative;
    overflow: hidden;
    text-align: left;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    margin-top: 0.125rem;
}

.stat-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: var(--bar-width, 0%);
    background: var(--primary);
    border-radius: 0 1px 0 0;
}

.stat-bar-pink { background: var(--accent); }
.stat-bar-mid { background: #3873ff; }
.stat-bar-deep { background: #4b5bff; }

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 3rem;
}

/* Legacy class support */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.action-card {
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
}

.action-card:hover {
    color: var(--text-primary);
    border-color: rgba(35, 158, 255, 0.2);
}

.action-card:hover .action-icon {
    color: var(--primary);
}

.action-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    transition: color 0.3s;
}

.action-text {
    font-weight: 500;
    font-size: 0.8125rem;
}

/* Recent Section */
.recent-section {
    text-align: left;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.recent-section h2 {
    margin-bottom: 1rem;
}

.people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.person-card {
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: var(--text-primary);
}

.person-card:hover {
    border-color: rgba(35, 158, 255, 0.2);
}

.person-card:hover .person-name {
    color: var(--primary);
}

.person-name {
    display: block;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: color 0.2s;
}

.person-dates {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* Search/Filter */
.search-filters {
    margin-bottom: 1rem;
}

.filter-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--bg-primary);
}

.result-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Data Table */
.data-table {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    border-collapse: collapse;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.data-table tbody tr {
    cursor: pointer;
    transition: all 0.15s;
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
    box-shadow: inset 3px 0 0 var(--primary);
}

.data-table a {
    color: var(--text-primary);
    text-decoration: none;
}

.data-table a:hover {
    color: var(--primary);
}

.nickname {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Person Detail */
.person-detail {
    
}

/* Person Hero */
.person-hero {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 0;
}

.person-hero-photo {
    flex-shrink: 0;
}

.hero-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(243, 245, 255, 0.1);
}

.hero-photo-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(243, 245, 255, 0.04);
    border: 1px solid rgba(243, 245, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.person-hero-info {
    flex: 1;
    min-width: 0;
}

.person-hero-name {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
}

.person-nickname {
    color: var(--text-muted);
    font-weight: 400;
}

.person-suffix {
    color: var(--text-secondary);
    font-weight: 400;
}

.person-hero-dates {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

.person-hero-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Tabs */
.tabs-container {
    background: transparent;
    border: none;
    margin-top: 0;
}

.tabs {
    display: flex;
    border-bottom: 1px solid rgba(243, 245, 255, 0.06);
    background: transparent;
    overflow-x: auto;
    gap: 0;
}

.tab-btn {
    flex: 0 0 auto;
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn .badge {
    background: rgba(243, 245, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.6875rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-weight: 600;
}

.tab-btn.active .badge {
    background: rgba(35, 158, 255, 0.15);
    color: var(--primary);
}

.tab-content {
    display: none;
    padding: 1.5rem 0;
    animation: fadeIn 0.3s ease-in;
    overflow: visible;
}

.tab-content.active {
    display: block;
}

/* Remove extra borders from detail-section inside tabs */
.tab-content .detail-section {
    border: none;
}

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

/* Overview Grid */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Table Scroll Container */
.table-scroll {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.table-scroll::-webkit-scrollbar {
    height: 8px;
}

.table-scroll::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Map Preview */
.map-preview {
    text-align: center;
    padding: 3rem 2rem;
}

/* Profile Photos */
.profile-photo-container {
    flex-shrink: 0;
    margin-right: 1.5rem;
}

.profile-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-color);
    box-shadow: var(--shadow);
}

.profile-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

[data-theme="dark"] .profile-photo {
    border-color: rgba(243, 245, 255, 0.12);
}

[data-theme="dark"] .profile-photo-placeholder {
    background: var(--bg-tertiary);
    border-color: rgba(243, 245, 255, 0.12);
}

.header-content {
    flex: 1;
}

.header-content h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.life-dates {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.detail-section {
    padding: 1.5rem;
}

.detail-section h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(243, 245, 255, 0.06);
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.625rem 1.25rem;
}

.info-list dt {
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}

.info-list dd {
    font-weight: 500;
    font-size: 0.9375rem;
}

.no-data {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
}

.help-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Family Groups */
.family-group {
    margin-bottom: 1.5rem;
}

.family-group h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.family-unit {
    margin-bottom: 0.5rem;
}

.family-member {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.family-member:hover {
    text-decoration: underline;
}

.marriage-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.children-list {
    list-style: none;
}

.children-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.children-list li:last-child {
    border-bottom: none;
}

.children-list li a {
    font-weight: 500;
}

/* Notes Section */
.notes-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.notes-section h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.notes-section p {
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.child-dates {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

/* Forms */
.add-relation-form,
.add-external-form,
.add-fact-form,
.add-link-form,
.add-evidence-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

/* Fix dropdown/select overflow */
.add-relation-form select,
.add-link-form select,
.add-evidence-form select,
.person-select {
    max-width: 100%;
    min-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure form containers don't overflow */
.detail-section {
    overflow: hidden;
}

.detail-section form {
    max-width: 100%;
}

.add-fact-form,
.add-link-form,
.add-evidence-form {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.add-fact-form h4,
.add-link-form h4,
.add-evidence-form h4 {
    width: 100%;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.form-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
}

/* Form inputs in detail sections - inherit base styles, just constrain width */
.add-relation-form input,
.add-external-form input,
.add-fact-form input,
.add-link-form input,
.add-evidence-form input {
    max-width: 100%;
    flex: 1;
    min-width: 0;
}

.add-relation-form select,
.add-external-form select,
.add-fact-form select,
.add-link-form select,
.add-evidence-form select {
    max-width: 100%;
    flex: 1;
    min-width: 0;
    box-shadow: 0 0 0 3px rgba(35, 158, 255, 0.15);
}

/* Fix label wrapping */
.add-link-form label,
.upload-form label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    font-size: 0.875rem;
}

/* Responsive form layout */
@media (max-width: 500px) {
    .add-link-form,
    .add-relation-form,
    .add-evidence-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .add-link-form select,
    .add-relation-form select,
    .add-evidence-form select {
        width: 100%;
    }
}

/* Facts Table */
.facts-table {
    width: 100%;
    min-width: 600px;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.facts-table th,
.facts-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.facts-table th {
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.facts-table th:nth-child(1) { width: 15%; }
.facts-table th:nth-child(2) { width: 15%; }
.facts-table th:nth-child(3) { width: 30%; }
.facts-table th:nth-child(4) { width: 30%; }
.facts-table th:nth-child(5) { width: 10%; text-align: center; }

.facts-table td:nth-child(5) {
    text-align: center;
}

/* External Links */
.external-links {
    list-style: none;
    margin-bottom: 1rem;
}

.external-links li {
    padding: 0.25rem 0;
}

.external-links a {
    color: var(--primary);
}

/* Files */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.file-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

.file-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.file-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.file-icon {
    font-size: 2rem;
    padding: 1.5rem;
}

.file-name {
    display: block;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 0.25rem;
}

.primary-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

/* Upload Form */
.upload-form {
    margin-top: 2rem;
    padding: 1.5rem;
    border-top: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.upload-form h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.upload-form input[type="file"] {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    width: 100%;
    cursor: pointer;
}

.upload-form input[type="text"] {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.upload-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.upload-form button {
    width: 100%;
}

.upload-form-inline {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}

.upload-form-inline input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

/* Files Page */
.files-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.file-card-large {
    background: rgba(243, 245, 255, 0.03);
    border: 1px solid rgba(243, 245, 255, 0.06);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.file-card-large:hover {
    background: rgba(243, 245, 255, 0.06);
    border-color: rgba(35, 158, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.file-thumbnail {
    height: 150px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon-large {
    font-size: 4rem;
}

.file-info {
    padding: 1rem;
}

.file-title {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.file-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* File Detail */
.file-detail-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

.file-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.file-preview img {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-sm);
}

.file-icon-xlarge {
    font-size: 8rem;
    padding: 3rem;
    color: var(--text-muted);
}

.evidence-table {
    width: 100%;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.evidence-table th,
.evidence-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

/* Form Page */
.form-page {
    max-width: 800px;
    margin: 0 auto;
}

.main-form {
    background: rgba(243, 245, 255, 0.03);
    border: 1px solid rgba(243, 245, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(243, 245, 255, 0.1);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    background: rgba(243, 245, 255, 0.04);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 158, 255, 0.15), 0 0 12px rgba(35, 158, 255, 0.08);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Import Page */
.import-page {
    max-width: 600px;
    margin: 0 auto;
}

.import-info {
    padding: 2rem;
    margin-bottom: 2rem;
}

.import-info h2 {
    margin-bottom: 1rem;
}

.import-info h3 {
    font-size: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.import-info ul {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.import-form {
    padding: 2rem;
    text-align: center;
}

.import-form .form-group {
    margin-bottom: 1.5rem;
}

.import-form input[type="file"] {
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    cursor: pointer;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.alert h3 {
    margin-bottom: 0.5rem;
}

/* Library */
.library-page .page-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.book-category {
    margin-bottom: 2rem;
}

.book-category h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: rgba(243, 245, 255, 0.03);
    border: 1px solid rgba(243, 245, 255, 0.06);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    transition: all 0.3s ease;
}

.book-card:hover {
    background: rgba(243, 245, 255, 0.06);
    border-color: rgba(35, 158, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.book-cover {
    width: 80px;
    min-height: 120px;
    background: linear-gradient(135deg, rgba(35, 158, 255, 0.08) 0%, rgba(246, 63, 159, 0.04) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.book-icon {
    font-size: 2rem;
}

.book-info {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
}

.book-source {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.book-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    flex: 1;
}

.book-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

.unmarked-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.unmarked-section h2 {
    margin-bottom: 0.5rem;
}

.unmarked-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.unmarked-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.unmarked-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.unmarked-info .file-size {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.mark-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.mark-form select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Timeline */
.timeline {
    max-width: 800px;
}

.timeline-century {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
}

.timeline-event {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.timeline-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.timeline-content {
    flex: 1;
}

.timeline-date {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
}

.timeline-title {
    margin: 0.25rem 0;
}

.timeline-title .event-type {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.timeline-title a {
    color: var(--text-primary);
    font-weight: 500;
}

.timeline-place,
.timeline-value {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Tasks */
.add-task-form {
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.add-task-form h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
}

.add-task-form .form-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.add-task-form input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.add-task-form textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.task-section {
    margin-bottom: 2rem;
}

.task-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.task-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.task-card.priority-1 {
    border-left: 3px solid var(--warning);
}

.task-card.priority-2 {
    border-left: 3px solid var(--danger);
}

.task-card.in-progress {
    border-left: 3px solid var(--primary);
    background: rgba(35, 158, 255, 0.05);
}

.task-card.done {
    opacity: 0.6;
}

.task-card.done .task-title {
    text-decoration: line-through;
}

.task-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.task-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.task-person {
    font-size: 0.875rem;
}

.task-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.danger-zone {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.danger-zone h2 {
    color: var(--danger);
}

/* Relationship Calculator */
.calculator-card {
    padding: 2rem;
    margin-bottom: 2rem;
}

.relationship-form {
    text-align: center;
}

.person-selectors {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.person-select-group {
    flex: 1;
    max-width: 300px;
}

.person-select-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.person-select-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.relationship-arrow {
    font-size: 2rem;
}

.result-card {
    padding: 2rem;
}

.result-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.relationship-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.person-badge {
    background: rgba(243, 245, 255, 0.04);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    text-align: center;
}

.person-badge strong {
    display: block;
    margin-bottom: 0.25rem;
}

.person-badge span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.relationship-badge {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 1.125rem;
}

.relationship-path {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.relationship-path h3 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.path-chain {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.path-node {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.path-node:hover {
    background: var(--primary);
    color: white;
}

.path-connector {
    color: var(--text-muted);
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem 2rem;
    border-top: 1px solid rgba(243, 245, 255, 0.04);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.footer-brand {
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.footer-sep { color: var(--text-muted); }
.footer-mesh { color: var(--text-muted); }

.footer-logo { display: none; }

/* Responsive */
@media (max-width: 768px) {
    /* ── Prevent horizontal overflow site-wide ── */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    main {
        padding: 1rem;
        overflow-x: hidden;
    }

    /* ── Nav: single compact row ── */
    .navbar {
        flex-direction: row;
        flex-wrap: nowrap;
        height: 48px;
        padding: 0 0.75rem;
        gap: 0;
    }

    .nav-left {
        flex-direction: row;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        gap: 0.25rem;
        align-items: center;
    }

    .nav-brand .nav-logo {
        height: 22px;
        width: auto;
    }

    .nav-links {
        flex: 1;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0;
        flex-wrap: nowrap;
    }

    .nav-links::-webkit-scrollbar { display: none; }

    .nav-links li a {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
        white-space: nowrap;
    }

    /* Keep avatar + theme toggle at right; hide search input (use Ctrl+K) */
    .nav-right {
        flex-shrink: 0;
        gap: 0.5rem;
        align-items: center;
    }

    .nav-search { display: none; }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.6875rem;
    }

    .container {
        padding: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .header-actions .btn {
        flex: 1 1 auto;
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .overview-grid {
        grid-template-columns: 1fr;
    }
    
    .file-detail-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-form {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }
    
    .tab-content {
        padding: 1rem;
    }
    
    .profile-photo-container {
        margin-right: 1rem;
    }
    
    .profile-photo,
    .profile-photo-placeholder {
        width: 80px;
        height: 80px;
    }
    
    .header-content h1 {
        font-size: 1.25rem;
    }
    
    .life-dates {
        font-size: 0.9rem;
    }
}

/* Global Quick Search */
.nav-search {
    position: relative;
}

.nav-search input {
    padding: 0.4rem 0.75rem 0.4rem 2.25rem;
    border: 1px solid rgba(243, 245, 255, 0.08);
    border-radius: var(--radius);
    background: rgba(243, 245, 255, 0.04);
    color: var(--text-primary);
    font-size: 0.8125rem;
    width: 200px;
    transition: width 0.3s, border-color 0.2s, background 0.2s;
    height: 36px;
}

.nav-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(35, 158, 255, 0.06);
    width: 280px;
}

.nav-search input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-dropdown.active {
    display: block;
}

.search-result {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover, .search-result.selected {
    background: var(--bg-secondary);
}

.search-result .name {
    font-weight: 500;
}

.search-result .dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
}

/* Keyboard shortcut hint */
.kbd {
    background: var(--bg-secondary);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-family: monospace;
    border: 1px solid var(--border-color);
}

/* Welcome Header Branding */
.welcome-header {
    display: none; /* Replaced by dash-hero */
}

.welcome-icon {
    display: none;
}

.tagline {
    color: var(--text-muted);
}

/* Footer Branding - legacy overrides */

/* User Menu in Navbar */
.nav-user {
    position: relative;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: white;
    cursor: pointer;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    position: relative;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-dropdown-header {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-dropdown-divider {
    border-top: 1px solid rgba(243, 245, 255, 0.06);
    margin: 0;
}

.user-role {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    font-weight: 600;
}

.user-role.role-admin { background: rgba(35, 158, 255, 0.15); color: var(--primary); }
.user-role.role-editor { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.user-role.role-viewer { background: rgba(243, 245, 255, 0.08); color: var(--text-secondary); }

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: rgba(18, 19, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(243, 245, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    min-width: 180px;
    z-index: 200;
}

/* Bridge the gap so mouse hover isn't lost moving to dropdown */
.user-menu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.5rem;
}

.user-menu:hover .user-dropdown {
    display: block;
}

.user-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
}

.user-dropdown a:hover {
    background: var(--bg-secondary);
}

.user-dropdown a:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.user-dropdown a:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ============ Person Autocomplete ============ */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 2px;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg-secondary);
}

.autocomplete-name {
    font-weight: 500;
}

.autocomplete-dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.autocomplete-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Recent people pills */
.recent-people {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.recent-person {
    padding: 0.25rem 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.recent-person:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: 480px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

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

/* External Chips */
.external-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: rgba(243, 245, 255, 0.04);
    border: 1px solid rgba(243, 245, 255, 0.08);
    border-radius: 999px;
    font-size: 0.8125rem;
}

.external-chip strong {
    color: var(--text-muted);
    font-weight: 500;
}

.external-chip a {
    color: var(--primary);
    text-decoration: none;
}

.external-chip a:hover {
    color: var(--accent);
}

/* Data Table (global) */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(243, 245, 255, 0.06);
}

.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(243, 245, 255, 0.03);
}

.data-table tbody tr:hover {
    background: rgba(243, 245, 255, 0.03);
}
