* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #808080;
    min-height: 100vh;
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styles - Fixed/Locked Panel */
.sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    background: #3a3a3a;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.sidebar h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    text-align: center;
    font-size: 20px;
}

.user-info {
    background: #3a3a3a;
    padding: 10px 15px;
    border-bottom: 1px solid #555;
}

.user-info p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #ccc;
}

.user-info span {
    font-weight: 600;
    color: #ffffff;
}

.sidebar-buttons {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-buttons .btn {
    width: 100%;
    padding: 8px;
    font-size: 12px;
}

.search-box {
    padding: 10px;
}

.search-box input {
    width: 100%;
    padding: 8px;
    border: 2px solid #555;
    border-radius: 5px;
    font-size: 12px;
    background: #ffffff;
    color: #333;
}

.members-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
}

.member-item {
    padding: 8px;
    margin: 4px 0;
    background: #4a4a4a;
    color: #e0e0e0;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid transparent;
    font-size: 12px;
}

.member-item:hover {
    background: #5a5a5a;
    transform: translateX(5px);
}

.member-item.selected {
    background: #5a5a5a;
    border-left-color: #7b68ae;
}

.member-item.gen-1 { border-left-color: #e1bee7; }
.member-item.gen-2 { border-left-color: #b2dfdb; }
.member-item.gen-3 { border-left-color: #ffccbc; }
.member-item.gen-4 { border-left-color: #bbdefb; }

.stats {
    padding: 10px;
    background: #333;
    border-top: 1px solid #555;
}

.stats p {
    margin: 4px 0;
    font-size: 12px;
    color: #ccc;
}

/* Main Content - Offset by sidebar width */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 20px 20px;
    margin-left: 240px;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}



.sticky-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
}

.toolbar {
    background: #c0bbb7;
    padding: 10px 15px;
    border-radius: 10px;
    margin-bottom: 8px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    color: #333;
}

#topScrollbar {
    position: fixed;
    z-index: 999;
    overflow-x: auto;
    overflow-y: hidden;
    display: block;
    background: #f1f1f1;
    height: 21px;
    border: 2px solid white;
}

#topScrollbarInner {
    height: 1px;
}

.tree-canvas {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 0;
    overflow: visible;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-height: 0;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-primary { background: #2196f3; }
.btn-secondary { background: #9c27b0; }
.btn-success { background: #4caf50; }
.btn-danger { background: #f44336; }
.btn-warning { background: #ff9800; }
.btn-info { background: #00bcd4; }
.btn-add { background: #4caf50; }
.btn-edit { background: #2196f3; }
.btn-restore { background: #9c27b0; }
.btn-show-all { background: #ff9800; }
.btn-admin { background: #9c27b0; }
.btn-info { background: #17a2b8; }
.btn-logout { background: #f44336; width: 100%; padding: 8px; font-size: 12px; }

/* Button color groups for sidebar */
.btn-purple { background: #ffffff; color: #333; }
.btn-purple:hover { background: #f0f0f0; color: #333; }
.btn-blue { background: #7b68ae; color: #fff; }
.btn-blue:hover { background: #6a5a9e; color: #fff; }
.btn-green { background: #4caf50; }
.btn-green:hover { background: #388e3c; }

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideDown 0.3s;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2196f3;
}

.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Tree Visualization */
.tree-node {
    display: inline-block;
    margin: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.tree-node:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.tree-node.selected {
    border: 3px solid #2196f3;
}

.tree-node.male {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tree-node.female {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

/* Generation Colors */
.generation-1 {
    background: #e1bee7 !important;
    color: #4a148c !important;
}

.generation-2 {
    background: #b2dfdb !important;
    color: #004d40 !important;
}

.generation-3 {
    background: #ffccbc !important;
    color: #bf360c !important;
}

.generation-4 {
    background: #bbdefb !important;
    color: #01579b !important;
}

.generation-5 {
    background: #f8bbd0 !important;
    color: #880e4f !important;
}

.tree-node-name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
}

.tree-node-info {
    font-size: 12px;
    opacity: 0.9;
}

.tree-level {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin: 30px 0;
    position: relative;
}

.tree-children {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-left: 40px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Profile photo popup animation */
@keyframes photoPopupGrow {
    from {
        transform: scale(var(--popup-start-scale, 0.18));
        opacity: 0.7;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#profilePhotoPopup.photo-popup-animate {
    animation: photoPopupGrow 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes photoPopupShrink {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(var(--popup-start-scale, 0.18));
        opacity: 0;
    }
}

#profilePhotoPopup.photo-popup-shrink {
    animation: photoPopupShrink 1s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

/* User Maintenance Styles */
.user-maintenance-section {
    margin-top: 20px;
}

.users-list {
    margin-top: 20px;
}

.user-item {
    padding: 15px;
    margin: 10px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.user-item.inactive {
    opacity: 0.6;
    border-left-color: #ccc;
}

.user-item h4 {
    margin: 0 0 8px 0;
    color: #333;
}

.user-item p {
    margin: 4px 0;
    font-size: 14px;
    color: #666;
}

.user-item .user-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.user-item .user-actions button {
    padding: 6px 12px;
    font-size: 12px;
}

/* Email Notification Styles */
.email-notification-section {
    padding: 10px 0;
}

.email-template-section h3,
.email-recipients-section h3 {
    color: #2c5f2d;
    margin-bottom: 15px;
}

.email-recipients-list {
    background: white;
}

.email-recipients-list label {
    transition: background 0.2s;
}

.email-recipients-list label:hover {
    background: #f3f4f6;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-primary {
    background: #3B82F6;
    color: white;
}

.btn-primary:hover {
    background: #2563EB;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        max-height: 300px;
        height: auto;
    }

    .main-content {
        margin-left: 0;
        height: auto;
        min-height: calc(100vh - 300px);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Hide mobile-only elements on desktop by default */
.mobile-header,
.sidebar-overlay,
.mobile-photo-popup,
.mobile-fab-container,
.mobile-logout-btn,
.mobile-sidebar-close {
    display: none;
}

.mobile-sidebar-settings {
    display: none;
}

/* Zoom controls - hidden on desktop */
.zoom-controls {
    display: none;
}

/* Lineage View Banner */
.lineage-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: #dbeafe;
    color: #1e40af;
    padding: 8px 15px;
    font-size: 13px;
    border-bottom: 2px solid #3b82f6;
    gap: 10px;
}

.lineage-banner button {
    background: none;
    border: none;
    color: #1e40af;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    font-weight: bold;
}

.lineage-banner button:hover {
    color: #dc2626;
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .sidebar {
    background: #1e1e2e;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
}

body.dark-mode .sidebar h1 {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

body.dark-mode .user-info {
    background: #2d2d3d;
    border-bottom-color: #404050;
}

body.dark-mode .user-info p {
    color: #e0e0e0;
}

body.dark-mode .user-info span {
    color: #a78bfa;
}

body.dark-mode .search-box input {
    background: #2d2d3d;
    border-color: #404050;
    color: #e0e0e0;
}

body.dark-mode .member-item {
    background: #2d2d3d;
    color: #e0e0e0;
}

body.dark-mode .member-item:hover {
    background: #3d3d4d;
}

body.dark-mode .member-item.selected {
    background: #3d4d5d;
}

body.dark-mode .stats {
    background: #2d2d3d;
    border-top-color: #404050;
}

body.dark-mode .stats p {
    color: #e0e0e0;
}

body.dark-mode .toolbar {
    background: #1e1e2e;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .tree-canvas {
    background: #1e1e2e;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .modal-content {
    background: #1e1e2e;
    color: #e0e0e0;
}

body.dark-mode .modal-content h2 {
    color: #e0e0e0;
}

body.dark-mode .form-group label {
    color: #e0e0e0;
}

body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
    background: #2d2d3d;
    border-color: #404050;
    color: #e0e0e0;
}

body.dark-mode .close {
    color: #888;
}

body.dark-mode .close:hover {
    color: #e0e0e0;
}

body.dark-mode .user-item {
    background: #2d2d3d;
    border-left-color: #a78bfa;
}

body.dark-mode .user-item h4 {
    color: #e0e0e0;
}

body.dark-mode .user-item p {
    color: #b0b0b0;
}

body.dark-mode #darkModeBtn {
    background: #fbbf24;
    color: #1a1a2e;
}

body.dark-mode .email-recipients-list {
    background: #2d2d3d;
}

body.dark-mode .email-recipients-list label {
    color: #e0e0e0;
}

body.dark-mode .email-recipients-list label:hover {
    background: #3d3d4d;
}

body.dark-mode #publicViewLabel {
    color: white;
}

body.dark-mode #panelLockLabel {
    color: #e0e0e0;
}

body.dark-mode #viewModeLabel {
    color: #e0e0e0;
}

body.dark-mode #viewModeSelect {
    background: #2d2d3d;
    border-color: #404050;
    color: #e0e0e0;
}

body.dark-mode .lineage-banner {
    background: #1e3a5f;
    color: #93c5fd;
    border-bottom-color: #3b82f6;
}

body.dark-mode .lineage-banner button {
    color: #93c5fd;
}

body.dark-mode .lineage-banner button:hover {
    color: #f87171;
}

body.dark-mode .sidebar-separator {
    border-top-color: #404050;
}
body.dark-mode .mobile-setting-label {
    background: #2d2d3d;
    color: #e0e0e0;
}
body.dark-mode .mobile-setting-label select {
    background: #2d2d3d;
    border-color: #404050;
    color: #e0e0e0;
}

/* Mobile Responsive - portrait phones (≤480px) and landscape phones */
@media (max-width: 480px), (max-height: 480px) and (orientation: landscape) and (max-width: 960px) {
    /* Hide sidebar completely by default */
    .sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        width: 240px;
        min-width: 240px;
        max-width: 240px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Make sidebar buttons section scrollable */
    .sidebar .sidebar-buttons {
        flex-shrink: 0;
        max-height: none;
        overflow-y: visible;
    }

    /* Ensure members list has enough space for search results */
    .sidebar .members-list {
        min-height: 40vh;
    }

    /* Reduce padding and font size for mobile sidebar */
    .sidebar h1 {
        font-size: 1.4em !important;
        padding: 10px;
        margin-bottom: 0 !important;
    }

    .sidebar h2 {
        font-size: 1em !important;
        padding: 0 10px 10px;
    }

    .sidebar .user-info {
        padding: 8px 10px;
    }

    .sidebar .sidebar-buttons .btn {
        padding: 10px 8px;
        font-size: 13px;
    }

    /* Sidebar overlay when open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Main content takes full width */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Mobile header with hamburger and search */
    .mobile-header {
        display: flex;
        align-items: center;
        padding: 10px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        gap: 10px;
    }

    .hamburger-btn {
        background: white;
        border: none;
        border-radius: 5px;
        padding: 8px 12px;
        font-size: 20px;
        cursor: pointer;
        flex-shrink: 0;
    }

    .mobile-header .mobile-search {
        flex: 1;
        padding: 8px 12px;
        border: none;
        border-radius: 5px;
        font-size: 14px;
    }

    .mobile-header .mobile-search-results {
        position: absolute;
        top: 50px;
        left: 50px;
        right: 10px;
        background: white;
        border: 1px solid #ddd;
        border-radius: 5px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        max-height: 200px;
        overflow-y: auto;
        z-index: 1001;
        display: none;
    }

    .mobile-header .mobile-search-results.active {
        display: block;
    }

    .mobile-search-results .search-result-item {
        padding: 10px 15px;
        border-bottom: 1px solid #eee;
        cursor: pointer;
    }

    .mobile-search-results .search-result-item:hover {
        background: #f5f5f5;
    }

    /* Hide toolbar buttons on mobile */
    .toolbar {
        display: none !important;
    }

    /* Show mobile tools bar */
    .mobile-tools-bar {
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
        background: #f9fafb;
        border-bottom: 1px solid #e5e7eb;
    }

    #topScrollbar {
        display: none !important;
    }

    /* Show mobile logout button in sidebar */
    .mobile-logout-btn {
        display: block !important;
        margin-top: 15px;
    }

    /* Red X close button for mobile sidebar */
    .mobile-sidebar-close {
        display: block !important;
        position: absolute;
        top: 8px;
        right: 10px;
        background: none;
        border: none;
        color: #dc3545;
        font-size: 28px;
        font-weight: bold;
        cursor: pointer;
        z-index: 1001;
        line-height: 1;
        padding: 0 5px;
    }

    /* Broadcast banner: 1-line truncated on mobile, expandable */
    #broadcastBanner {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        cursor: pointer;
    }
    #broadcastBanner.expanded {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    /* F10 help panel responsive */
    #f10HelpPanel {
        width: 90vw !important;
        height: 60vh !important;
        top: 80px !important;
        right: 5vw !important;
    }

    /* Hide view-only banner text, make it smaller */
    #viewOnlyBanner {
        font-size: 12px;
        padding: 5px 10px;
    }

    /* Tree canvas full width */
    .tree-canvas {
        width: 100%;
    }

    /* Photo popup modal for mobile */
    .mobile-photo-popup {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
        z-index: 2000;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }

    .mobile-photo-popup.active {
        display: flex;
    }

    .mobile-photo-popup img {
        max-width: 80%;
        max-height: 60%;
        border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    }

    .mobile-photo-popup .person-name {
        color: white;
        font-size: 20px;
        margin-top: 15px;
        text-align: center;
        padding: 0 20px;
    }

    .mobile-photo-popup .no-photo-placeholder {
        width: 150px;
        height: 150px;
        background: white;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 60px;
        color: #667eea;
    }

    .mobile-photo-popup .close-popup {
        position: absolute;
        top: 20px;
        right: 20px;
        background: white;
        border: none;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        font-size: 24px;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* Mobile FAB Container */
    .mobile-fab-container {
        display: block;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 500;
    }

    /* FAB Menu (expandable) */
    .mobile-fab-menu {
        display: none;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 15px;
    }

    .mobile-fab-menu.active {
        display: flex;
    }

    /* FAB Menu Items */
    .fab-menu-item {
        background: white;
        color: #333;
        border: none;
        border-radius: 25px;
        padding: 12px 20px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        text-align: left;
        white-space: nowrap;
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .fab-menu-item:hover, .fab-menu-item:active {
        transform: scale(1.02);
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    }

    /* Main FAB Button */
    .mobile-fab-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        font-size: 24px;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        transition: transform 0.3s;
        display: block;
        margin-left: auto;
    }

    .mobile-fab-btn.active {
        transform: rotate(45deg);
    }

    /* My Silver Family Tree button - hidden by default, shown only in view-only mode */
    .mobile-home-btn {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 25px;
        padding: 12px 20px;
        font-size: 14px;
        font-weight: bold;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        margin-top: 15px;
        display: none;
        width: 100%;
    }

    /* Hide desktop-only elements */
    #publicFamilySearch,
    #publicSearchResults,
    #familySelectorContainer,
    #publicViewLabel,
    #panelLockLabel,
    #viewModeLabel {
        display: none !important;
    }

    /* Mobile sidebar settings controls */
    .mobile-sidebar-settings {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .sidebar-separator {
        border: none;
        border-top: 1px solid #ddd;
        margin: 10px 0 5px 0;
    }

    .mobile-setting-label {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        color: #333;
        cursor: pointer;
        padding: 8px;
        background: #f8f9fa;
        border-radius: 6px;
    }

    .mobile-setting-label input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .mobile-setting-label select {
        padding: 4px 8px;
        font-size: 13px;
        border-radius: 4px;
        border: 1px solid #ddd;
        flex: 1;
    }

    /* Zoom controls - bottom left (FAB is bottom right) */
    .zoom-controls {
        display: flex;
        position: fixed;
        bottom: 90px;
        left: 15px;
        flex-direction: column;
        gap: 4px;
        z-index: 500;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        padding: 4px;
    }

    .zoom-btn {
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 6px;
        background: white;
        color: #333;
        font-size: 20px;
        font-weight: bold;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }

    .zoom-btn:active {
        background: #e0e0e0;
    }

    .zoom-label-btn {
        font-size: 11px;
        font-weight: 600;
        color: #666;
    }

    /* Dark mode zoom controls */
    body.dark-mode .zoom-controls {
        background: rgba(40, 40, 40, 0.95);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    }

    body.dark-mode .zoom-btn {
        background: #333;
        color: #e0e0e0;
    }

    body.dark-mode .zoom-btn:active {
        background: #555;
    }

    body.dark-mode .zoom-label-btn {
        color: #aaa;
    }
}

/* =============================================================================
   FAMILY CHAT BOX
   ============================================================================= */

.chat-box {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 436px;
    height: 420px;
    min-width: 300px;
    min-height: 250px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transition: border-color 0.2s;
}

.chat-resize-handle {
    position: absolute;
    z-index: 1001;
    pointer-events: auto;
}

.chat-box.chat-dragover .chat-resize-handle {
    pointer-events: none;
}

.chat-resize-handle.left {
    left: 0;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
}

.chat-resize-handle.bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    cursor: ns-resize;
}

.chat-resize-handle.bottom-left {
    bottom: 0;
    left: 0;
    width: 12px;
    height: 12px;
    cursor: nesw-resize;
}

.chat-resize-handle.bottom-right {
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
}

.chat-box.chat-dragover {
    border: 2px dashed #4a90d9;
    background: rgba(74, 144, 217, 0.05);
}

.chat-header {
    background: #7b68ae;
    color: #fff;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;
    border-radius: 4px;
}

.chat-header-actions button:hover {
    background: rgba(255,255,255,0.2);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f0f2f5;
}

.chat-bubble {
    max-width: 100%;
    padding: 4px 10px;
    font-size: 13px;
    word-wrap: break-word;
    border-radius: 0;
    background: transparent;
}

.chat-mine, .chat-theirs {
    align-self: stretch;
    background: transparent;
    box-shadow: none;
}

.chat-sender {
    font-weight: bold;
    font-size: 13px;
    color: #7b68ae;
}

.chat-text {
    line-height: 1.5;
}

.chat-time {
    font-size: 12px;
    color: #888;
}

.chat-text a {
    color: #1a73e8;
    text-decoration: underline;
    word-break: break-all;
}

.chat-text img {
    max-width: 200px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 4px;
}

.chat-file-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#chatMicBtn.recording {
    background: #dc3545 !important;
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.chat-text audio {
    max-width: 220px;
    height: 36px;
    margin-top: 4px;
    display: block;
}

.chat-input-row {
    display: flex;
    padding: 8px;
    border-top: 1px solid #e0e0e0;
    gap: 6px;
    background: #fff;
}

.chat-input-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
}

.chat-input-row input:focus {
    border-color: #7b68ae;
}

.chat-input-row button {
    background: #7b68ae;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-row button:hover {
    background: #3d6a4a;
}

.chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    font-size: 10px;
    font-weight: bold;
    border-radius: 10px;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
}

/* =============================================================================
   ONLINE MEMBERS PANEL
   ============================================================================= */

.online-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #333;
    color: white;
    font-size: 10px;
    font-weight: bold;
    border-radius: 10px;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
}

.online-members-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 200px;
    max-height: 300px;
    z-index: 9999;
    overflow: hidden;
}

.online-members-header {
    padding: 10px 14px;
    font-weight: bold;
    font-size: 13px;
    border-bottom: 1px solid #eee;
    color: #333;
    display: flex;
    align-items: center;
}

.online-members-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 4px 0;
}

.online-member-item {
    padding: 8px 14px;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
}

.online-member-item:hover {
    background: #f5f5f5;
}

/* Dark mode overrides */
body.dark-mode .online-count-badge {
    background: #aaa;
    color: #222;
}

body.dark-mode .online-members-panel {
    background: #2a2a2a;
    border-color: #444;
}

body.dark-mode .online-members-header {
    color: #ddd;
    border-bottom-color: #444;
}

body.dark-mode .online-member-item {
    color: #ddd;
}

body.dark-mode .online-member-item:hover {
    background: #333;
}

/* =============================================================================
   ANCESTOR MEMORIES
   ============================================================================= */

.memories-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #e8e8e8;
}

.memories-title {
    font-size: 16px;
    color: #7b68ae;
    margin: 0 0 12px 0;
}

.memories-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.memory-item {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 3px solid #7b68ae;
}

.memory-author {
    font-weight: bold;
    font-size: 12px;
    color: #333;
    margin-bottom: 3px;
}

.memory-date {
    font-weight: normal;
    color: #999;
    font-size: 11px;
}

.memory-text {
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

.memories-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    font-size: 13px;
    padding: 15px;
}

.memories-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.memories-input-row textarea {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
}

.memories-input-row textarea:focus {
    border-color: #7b68ae;
    outline: none;
}

.memories-input-row button {
    white-space: nowrap;
}

/* Voice Call Bar */
.voice-call-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #2d6a3f;
    color: white;
    font-size: 13px;
}

.voice-call-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-pulse {
    animation: voicePulse 1.5s ease-in-out infinite;
    color: #7cf5a0;
}

@keyframes voicePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.voice-participant-count {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.voice-call-controls {
    display: flex;
    gap: 6px;
}

.voice-call-controls button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.voice-call-controls button:hover {
    background: rgba(255,255,255,0.3);
}

.voice-leave-btn {
    background: #e74c3c !important;
}

.voice-leave-btn:hover {
    background: #c0392b !important;
}

#voiceCallBtn {
    position: relative;
}

#voiceCallBtn.voice-active {
    background: #2ecc71 !important;
    animation: voicePulse 1.5s ease-in-out infinite;
}

/* Video Call Styles */
.video-container {
    background: #1a1a2e;
    border-bottom: 1px solid #333;
    padding: 8px;
    min-height: 120px;
    max-height: 70vh;
    overflow-y: auto;
    resize: vertical;
}

.video-container.screen-sharing {
    max-height: 80vh;
}

.video-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    height: 100%;
}

.video-container.screen-sharing .video-grid {
    flex-wrap: nowrap;
    flex-direction: column;
    align-items: stretch;
    height: 100%;
}

/* When YOU are sharing, your local video is the screen share — make it fill */
.video-container.screen-sharing .video-wrapper.video-local {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

/* When receiving a screen share, the remote video fills the space */
.video-container.screen-sharing .video-wrapper:not(.video-local) {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

/* Hide local "You" preview when viewing someone else's screen share */
.video-container.screen-sharing.viewing-remote .video-wrapper.video-local {
    display: none;
}

.video-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    flex: 1 1 140px;
    min-width: 140px;
    min-height: 105px;
    max-width: 100%;
    height: 100%;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hmong Heritage Styles */
.heritage-category-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #444;
    transition: background 0.15s;
}
.heritage-category-item:hover { background: #f3f0ff; color: #6a0dad; }
.heritage-category-item.active { background: #6a0dad; color: #fff; font-weight: 600; }
.heritage-entry-card {
    padding: 12px 15px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.heritage-entry-card:hover { border-color: #6a0dad; box-shadow: 0 2px 8px rgba(106,13,173,0.1); }
.heritage-media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}
.heritage-media-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}
.heritage-media-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}
.heritage-media-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239,68,68,0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    #hmongHeritageModal .modal-content > div {
        flex-direction: column !important;
    }
    #heritageCategoryList {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 10px !important;
        padding-right: 0 !important;
        max-height: 200px;
        overflow-y: auto;
    }
    .heritage-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .heritage-tile { padding: 15px 10px !important; }
    .heritage-tile-icon { font-size: 24px !important; }
    .heritage-detail-header { flex-wrap: wrap; gap: 8px; }
}

/* Heritage Modal Layout */
.heritage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #3a3a3a 0%, #1a1a1a 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px 10px 0 0;
}
.heritage-header h2 { margin: 0; font-size: 22px; }
.heritage-body { padding: 20px; max-height: 75vh; overflow-y: auto; }
.heritage-intro { text-align: center; color: #666; margin-bottom: 20px; font-size: 14px; }
.heritage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}
.heritage-tile {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.heritage-tile:hover {
    background: #f0f0f0;
    border-color: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.heritage-tile-icon { font-size: 32px; margin-bottom: 10px; color: #333; }
.heritage-tile-name { font-weight: bold; font-size: 14px; color: #333; margin-bottom: 4px; }
.heritage-tile-hmong { font-size: 12px; color: #555; font-style: italic; }
.heritage-tile-count { font-size: 11px; color: #999; margin-top: 6px; }
.heritage-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}
.heritage-detail-header h3 { margin: 0; font-size: 20px; color: #333; }
.heritage-back-btn {
    background: #6c757d; color: white; border: none;
    padding: 6px 14px; border-radius: 5px; cursor: pointer; font-size: 13px;
}
.heritage-back-btn:hover { background: #555; }
.heritage-add-btn { font-size: 13px; }
.heritage-category-desc {
    color: #666; font-size: 13px; margin-bottom: 15px;
    padding: 10px; background: #f8f9fa; border-radius: 6px;
}
.heritage-entries { display: flex; flex-direction: column; gap: 12px; }
.heritage-entry-title { font-weight: bold; font-size: 16px; color: #333; margin-bottom: 6px; }
.heritage-entry-meta { font-size: 11px; color: #999; margin-bottom: 8px; }
.heritage-entry-text { font-size: 14px; color: #555; line-height: 1.6; white-space: pre-wrap; margin-bottom: 10px; }
.heritage-entry-media { margin-top: 10px; }
.heritage-entry-media audio { width: 100%; }
.heritage-entry-media video { width: 100%; max-height: 400px; border-radius: 6px; }
.heritage-entry-media img { max-width: 100%; max-height: 400px; border-radius: 6px; cursor: pointer; }
.heritage-entry-actions { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; }
.heritage-entry-actions button { padding: 4px 10px; font-size: 12px; border: none; border-radius: 4px; cursor: pointer; }
.heritage-btn-edit { background: #ffc107; color: #333; }
.heritage-btn-delete { background: #dc3545; color: white; }
.heritage-empty { text-align: center; color: #999; padding: 40px; font-size: 14px; }

.video-label {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.video-local video {
    transform: scaleX(-1);
}

#videoCamBtn.video-active {
    background: #2ecc71 !important;
    color: #fff !important;
}

#screenShareBtn.video-active {
    background: #2ecc71 !important;
    color: #fff !important;
}

/* Family Calendar */
.calendar-nav { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 15px 0; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-header-cell { text-align: center; font-weight: 600; padding: 8px 4px; background: #6a0dad; color: white; font-size: 13px; border-radius: 4px; }
.calendar-cell { min-height: 65px; padding: 4px; border: 1px solid #e5e7eb; cursor: pointer; position: relative; font-size: 13px; border-radius: 4px; }
.calendar-cell:hover { background: #f3f0ff; }
.calendar-cell.today { background: #ede9fe; border-color: #6a0dad; font-weight: 700; }
.calendar-cell.other-month { color: #ccc; background: #fafafa; cursor: default; }
.calendar-day-number { font-weight: 600; }
.calendar-event-dots { margin-top: 2px; }
.calendar-event-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 1px; }
.event-item { padding: 10px; margin: 6px 0; border-left: 4px solid #6a0dad; background: #f9fafb; border-radius: 4px; }
.event-item-header { display: flex; justify-content: space-between; align-items: center; }
.event-type-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; color: white; }

/* Dark mode overrides for chat and memories */
body.dark-mode .chat-box {
    background: #2d2d2d;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

body.dark-mode .chat-messages {
    background: #1a1a1a;
}

body.dark-mode .chat-theirs {
    background: #3a3a3a;
    color: #e0e0e0;
}

body.dark-mode .chat-mine {
    background: #2e5a3a;
    color: #e0e0e0;
}

body.dark-mode .voice-call-bar {
    background: #1a4d2e;
}

body.dark-mode .chat-input-row {
    background: #2d2d2d;
    border-top-color: #444;
}

body.dark-mode .chat-input-row input {
    background: #1a1a1a;
    border-color: #444;
    color: #e0e0e0;
}

body.dark-mode .chat-time {
    color: #777;
}

body.dark-mode .memory-item {
    background: #333;
    border-left-color: #5a9a6a;
}

body.dark-mode .memory-author {
    color: #ddd;
}

body.dark-mode .memory-text {
    color: #bbb;
}

body.dark-mode .memories-section {
    border-top-color: #444;
}

body.dark-mode .memories-input-row textarea {
    background: #1a1a1a;
    border-color: #444;
    color: #e0e0e0;
}

/* Dark mode calendar */
body.dark-mode .calendar-cell { border-color: #374151; background: #1f2937; color: #e5e7eb; }
body.dark-mode .calendar-cell:hover { background: #374151; }
body.dark-mode .calendar-cell.today { background: #3b2d6e; border-color: #7c3aed; }
body.dark-mode .calendar-cell.other-month { color: #4b5563; background: #111827; }
body.dark-mode .event-item { background: #1f2937; border-left-color: #7c3aed; }

/* Mobile responsive chat */
@media (max-width: 600px) {
    .chat-box {
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}
