* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Theme Variables */
:root {
    --bg-primary: #3a3a3a;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8f0;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --card-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --header-gradient: linear-gradient(135deg, #d4dbfa 0%, #e5d9f2 100%);
    --accent-primary: #FF6B35;
    --accent-secondary: #F7931E;
    --accent-blue: #2196F3;
    --accent-green: #4caf50;
    --accent-red: #f44336;
}

[data-theme="dark"] {
    --bg-primary: #1a1a22;
    --bg-secondary: #1a1a22;
    --bg-tertiary: #252530;
    --text-primary: #f5f5f5;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-color: #333333;
    --card-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    --header-gradient: linear-gradient(135deg, #252530 0%, #2a2a35 100%);
    --accent-primary: #FF6B35;
    --accent-secondary: #F7931E;
    --accent-blue: #3eaaff;
    --accent-green: #66bb6a;
    --accent-red: #ef5350;
}

html {
    overflow-y: scroll;
    overflow-x: hidden;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    display: none;
}

html, body, * {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--header-gradient);
    min-height: 100vh;
    padding: 0;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Dark background on desktop */
@media (min-width: 768px) {
    body {
        background: #1a1a1a;
    }
}

body::-webkit-scrollbar {
    display: none;
}

body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.app-container {
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 0;
    background: var(--bg-primary);
    width: 100%;
}

/* On desktop, constrain to mobile aspect ratio */
@media (min-width: 768px) {
    .app-container {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        height: 95vh;
        width: auto;
        max-width: none;
        aspect-ratio: 390 / 844; /* Force mobile aspect ratio - width calculated from height */
        min-height: auto;
    }
}

/* Auth Section */
.auth-section {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
    display: none;
    justify-content: center;
    align-items: center;
    gap: 12px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 100;
}

.auth-section.show {
    display: flex;
}

.auth-btn {
    background: #4285f4;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-btn:hover {
    background: #357ae8;
}

.auth-btn.secondary {
    background: #dc3545;
    margin-left: 12px;
}

.auth-btn.secondary:hover {
    background: #c82333;
}

.auth-btn.test-user {
    background: #28a745;
    margin-left: 12px;
}

.auth-btn.test-user:hover {
    background: #218838;
}

.auth-btn.control-panel {
    background: #6c757d;
    margin-left: 12px;
}

.auth-btn.control-panel:hover {
    background: #5a6268;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    top: 10px;
    right: max(70px, calc(50% - 240px + 70px));
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 998;
    box-shadow: var(--card-shadow);
}

.theme-toggle-btn:hover {
    transform: scale(1.05);
    background: var(--bg-tertiary);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-toggle-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    transition: transform 0.3s ease;
}

/* Profile Menu */
.user-profile {
    position: fixed;
    top: 10px;
    right: max(10px, calc(50% - 240px + 10px));
    z-index: 999;
}

.profile-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.profile-button:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.user-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    background: var(--bg-tertiary);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    min-width: 240px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    transition: background 0.3s ease;
}

.profile-dropdown.open {
    display: flex;
}

.profile-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.3s ease;
}

.dropdown-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.dropdown-name {
    font-weight: 500;
    font-size: 16px;
    color: var(--text-primary);
    word-break: break-word;
    transition: color 0.3s ease;
}

.dropdown-item {
    padding: 12px 16px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-primary);
    transition: background 0.2s, color 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
}

.dropdown-item.upload-photo {
    color: var(--accent-blue);
    font-weight: 500;
    display: flex;
    align-items: center;
}

.dropdown-item.upload-photo svg {
    display: inline;
}

.dropdown-item.upload-profile-selfie {
    color: var(--accent-blue);
    font-weight: 500;
    display: flex;
    align-items: center;
}

.dropdown-item.upload-profile-selfie svg {
    display: inline;
}

.dropdown-item.control-panel {
    color: var(--text-secondary);
}

.dropdown-item.sign-out {
    color: var(--accent-red);
    font-weight: 500;
}

.dropdown-theme-toggle {
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: border-color 0.3s ease;
}

.dropdown-theme-toggle .theme-toggle-btn {
    position: static;
    width: 40px;
    height: 40px;
    box-shadow: none;
    background: var(--bg-tertiary);
    z-index: auto;
    right: auto;
    top: auto;
}

.dropdown-theme-toggle .theme-toggle-btn:hover {
    background: var(--bg-secondary);
}

/* Camera Section */
.camera-section {
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
    box-shadow: none;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 0;
}

.camera-btn {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    border: none;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 30px rgba(255, 107, 53, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    overflow: hidden;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 999;
}

.camera-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.camera-btn:hover {
    transform: translateX(-50%) scale(1.12);
    box-shadow: 0 15px 40px rgba(255, 107, 53, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.camera-btn:active::before {
    width: 150px;
    height: 150px;
}

.camera-btn:active {
    transform: translateX(-50%) scale(0.92);
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.4),
        inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.camera-btn svg {
    width: 39px;
    height: 39px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    transition: transform 0.2s ease;
}

.camera-btn:active svg {
    transform: scale(0.95);
}

.upload-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.upload-btn {
    background: #9C27B0;
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}

.upload-btn:hover {
    background: #7B1FA2;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(156, 39, 176, 0.5);
}

.upload-btn:active {
    transform: translateY(0);
}

.delete-all-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
}

.delete-all-btn:hover {
    background: #d32f2f;
}

/* Desktop styles for camera section */
@media (min-width: 768px) {
    .camera-section {
        padding: 20px;
        gap: 16px;
    }

    .camera-btn,
    .upload-btn {
        padding: 16px 32px;
        font-size: 18px;
        gap: 10px;
        flex: 0 1 auto;
    }

    .camera-btn svg,
    .upload-btn svg {
        width: 24px;
        height: 24px;
    }

    .delete-all-btn {
        padding: 12px 24px;
        font-size: 14px;
        width: auto;
    }
}

/* Photo Grid */
.photo-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 0;
}

/* Photos tab wrapper */
.photos-tab {
    flex: 1;
    overflow-y: auto;
    display: none;
    background: var(--header-gradient);
    scroll-snap-type: y proximity;
    scroll-padding-top: 0px;
    padding-top: 120px;
}

.photos-tab.active {
    display: block;
}

/* Messages tab wrapper */
.messages-tab {
    flex: 1;
    overflow-y: auto;
    display: none;
    background: var(--bg-primary);
    transition: background 0.3s ease;
}

.messages-tab.active {
    display: flex;
    flex-direction: column;
}

.group-header {
    width: 100%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 6px 16px;
    border-radius: 16px 16px 0 0;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    backdrop-filter: blur(10px);
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    order: -1;
}

.group-stats {
    display: flex;
    gap: 16px;
    font-size: 14px;
    font-weight: 500;
    margin-right: 25px;
    margin-left: -5px;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Group Container and Thumbnail Scroll */
.group-container {
    width: 100%;
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    scroll-snap-align: center;
    scroll-snap-stop: normal;
    background: transparent;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    scroll-margin: 40px;
}

.group-container:last-child {
    margin-bottom: 0;
}

/* Sample card snaps at very top with camera button */
.group-container.sample-card {
    scroll-snap-align: end;
}

/* Photo Areas Wrapper */
.group-photos-wrapper {
    display: flex;
    gap: 0;
    width: 100%;
    height: min(50vw, 240px);
}

/* Left side - Person Photo Area */
.group-person-photo-area {
    flex: 1;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    transition: background 0.3s ease;
    border-radius: 0;
    cursor: pointer;
    position: relative;
}

.photo-counter {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
}

.group-person-photo-area img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s;
}

.group-person-photo-area img:hover {
    transform: scale(1.05);
}

.group-person-photo-area img.processing {
    position: relative;
    border: 3px solid transparent;
    background-image:
        linear-gradient(white, white),
        conic-gradient(
            from 0deg,
            transparent 0%,
            transparent 25%,
            rgba(76, 175, 80, 0.3) 35%,
            rgba(76, 175, 80, 0.8) 45%,
            rgb(76, 175, 80) 50%,
            rgba(76, 175, 80, 0.8) 55%,
            rgba(76, 175, 80, 0.3) 65%,
            transparent 75%,
            transparent 100%
        );
    background-origin: border-box;
    background-clip: padding-box, border-box;
    animation: rotateBorder 30s linear infinite;
}

/* Right side - Profile Display Area */
.selected-user-profile-display {
    flex: 1;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    transition: background 0.3s ease;
    border-radius: 0;
}

.profile-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-large-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.profile-actions {
    position: absolute;
    bottom: 8px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.profile-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    font-size: 0;
    z-index: 10;
    opacity: 0.75;
}

.profile-action-btn:hover {
    opacity: 1;
}

.profile-close-btn {
    background: rgba(255, 59, 48, 0.9);
    color: white;
}

.profile-close-btn:hover {
    background: rgba(255, 59, 48, 1);
    transform: scale(1.1);
}

.profile-chat-btn {
    background: rgba(102, 126, 234, 0.9);
    color: white;
}

.profile-chat-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.1);
}

.profile-action-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
}

.photo-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
}

/* Desktop grid layout disabled - mobile-first design */
/*
@media (min-width: 768px) {
    .photo-grid {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 11px;
        padding: 0 10px;
    }

    .photo-row {
        display: contents;
    }
}
*/

.photo-item {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s;
    background: var(--bg-secondary);
    width: 30%;
    max-width: 225px;
}

/* Disabled for mobile-first design
@media (min-width: 768px) {
    .photo-item {
        width: auto;
        max-width: none;
    }
}
*/

.photo-item:hover {
    transform: scale(1.05);
}

/* Snaking border effect for processed photos */
.photo-item.processed {
    position: relative;
    border: 3px solid transparent;
    background-image:
        linear-gradient(white, white),
        conic-gradient(
            from 0deg,
            transparent 0%,
            transparent 25%,
            rgba(76, 175, 80, 0.3) 35%,
            rgba(76, 175, 80, 0.8) 45%,
            rgb(76, 175, 80) 50%,
            rgba(76, 175, 80, 0.8) 55%,
            rgba(76, 175, 80, 0.3) 65%,
            transparent 75%,
            transparent 100%
        );
    background-origin: border-box;
    background-clip: padding-box, border-box;
    animation: rotateBorder 30s linear infinite;
}

@keyframes rotateBorder {
    0% {
        background-image:
            linear-gradient(white, white),
            conic-gradient(
                from 0deg,
                transparent 0%,
                transparent 25%,
                rgba(76, 175, 80, 0.3) 35%,
                rgba(76, 175, 80, 0.8) 45%,
                rgb(76, 175, 80) 50%,
                rgba(76, 175, 80, 0.8) 55%,
                rgba(76, 175, 80, 0.3) 65%,
                transparent 75%,
                transparent 100%
            );
    }
    100% {
        background-image:
            linear-gradient(white, white),
            conic-gradient(
                from 360deg,
                transparent 0%,
                transparent 25%,
                rgba(76, 175, 80, 0.3) 35%,
                rgba(76, 175, 80, 0.8) 45%,
                rgb(76, 175, 80) 50%,
                rgba(76, 175, 80, 0.8) 55%,
                rgba(76, 175, 80, 0.3) 65%,
                transparent 75%,
                transparent 100%
            );
    }
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-timestamp {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px;
    font-size: 14px;
    text-align: center;
}

.photo-description {
    display: none;
}

.photo-description.analyzing {
    font-style: italic;
    opacity: 0.7;
}

/* Find Similar Button */
.find-similar-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(156, 39, 176, 0.9);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}

.find-similar-btn:hover {
    background: rgba(123, 31, 162, 1);
    transform: scale(1.05);
}

/* Similar Photos Container */
.similar-photos-container {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.similar-title {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    width: 100%;
}

.similar-photo-wrapper {
    position: relative;
    width: 80px;
    height: 120px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
}

.similar-photo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.confidence-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    font-size: 12px;
    font-weight: 700;
    color: white;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.confidence-high {
    background: rgba(76, 175, 80, 0.9);
}

.confidence-medium {
    background: rgba(255, 152, 0, 0.9);
}

.confidence-low {
    background: rgba(244, 67, 54, 0.9);
}

/* Loading */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    text-align: center;
    z-index: 1000;
    transition: background 0.3s ease;
}

.spinner {
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--accent-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading p {
    color: var(--text-primary);
    font-weight: 500;
    transition: color 0.3s ease;
}

/* Version Indicator */
.version-indicator {
    position: fixed;
    bottom: 10px;
    left: max(10px, calc(50% - 240px + 10px));
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-family: monospace;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.version-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.version-label {
    opacity: 0.7;
}

.version-status {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    font-weight: bold;
    font-size: 12px;
}

.status-synced {
    color: #4caf50;
}

.status-mismatch {
    color: #ff9800;
}

.status-error {
    color: #f44336;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.empty-state h2 {
    font-size: 24px;
    margin-bottom: 12px;
    opacity: 0.9;
}

.empty-state p {
    font-size: 16px;
    opacity: 0.7;
}

/* Description Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    margin: 5% auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
    transition: background 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    z-index: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.copy-btn {
    position: absolute;
    right: 56px;
    top: 16px;
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    transition: all 0.2s;
    z-index: 1;
    width: 34px;
    height: 34px;
}

.copy-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-btn svg {
    flex-shrink: 0;
}

.copy-btn.copied {
    background: var(--accent-green);
}


.modal-title {
    padding: 20px 24px;
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    transition: color 0.3s ease;
}

/* Modal Sections */
.modal-section {
    margin-bottom: 16px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 107, 53, 0.2);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.modal-section p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
    transition: color 0.3s ease;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
        max-height: 75vh;
    }

    .modal-title {
        font-size: 18px;
        padding: 16px 20px;
    }

    .modal-body {
        padding: 20px;
        font-size: 14px;
    }

    .modal-section h4 {
        font-size: 15px;
    }

    .group-thumbnails-scroll {
        padding: 8px;
    }

    .selected-user-profile-display {
        padding: 8px;
    }
}

/* Crop Modal */
.crop-modal {
    z-index: 3000;
}

.crop-modal-content {
    width: 95%;
    max-width: 900px;
    height: 90vh;
    max-height: 90vh;
    margin: 2.5vh auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
}

.crop-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
}

#cropCanvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
    cursor: grab;
}

#cropCanvas.dragging {
    cursor: grabbing;
}

.crop-controls {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: #2a2a2a;
    border-top: 1px solid #444;
}

.crop-btn {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.crop-use {
    background: #4caf50;
    color: white;
}

.crop-use:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.crop-cancel {
    background: #f44336;
    color: white;
}

.crop-cancel:hover {
    background: #da190b;
    transform: translateY(-1px);
}

.crop-btn:active {
    transform: translateY(0);
}

/* Camera Preview Modal */
.camera-modal {
    z-index: 3000;
}

.camera-modal-content {
    width: 95%;
    max-width: 100%;
    height: 90vh;
    max-height: 90vh;
    margin: 2.5vh auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
}

.camera-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-close-btn:hover {
    background: white;
    transform: scale(1.1);
}

.camera-close-btn:active {
    transform: scale(0.95);
}

.preview-video {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    touch-action: none;
}

.zoom-info {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    z-index: 10;
}

.zoom-level {
    display: inline-block;
}

.capture-btn {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: #2196F3;
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
    z-index: 10;
    min-width: 200px;
}

.capture-btn:hover {
    background: #1976D2;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.5);
}

.capture-btn:active {
    transform: translateX(-50%);
}

/* Delete Button */
.group-delete-btn {
    position: absolute;
    right: 8px;
    top: 2px;
    background: transparent;
    color: #ff6666;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s;
    line-height: 1;
    z-index: 10;
    font-weight: normal;
}

.group-delete-btn:hover {
    color: #ff4444;
}

.group-delete-btn.active {
    color: #ff4444;
    font-weight: bold;
}

/* Chat Features */
.chat-button {
    position: relative;
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: none;
    align-items: center;
    gap: 8px;
}

.chat-button:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.chat-button:active {
    transform: translateY(0);
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    min-width: 24px;
}

.notification-badge.hidden {
    display: none;
}

/* In-Group Chat Section */
.group-chat {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0;
    margin: 0;
    margin-top: -1px;
    display: flex;
    flex-direction: column;
    max-height: 400px;
    overflow: hidden;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 8px 12px 32px 12px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 200px;
    background: var(--bg-primary);
    transition: background 0.3s ease;
    pointer-events: none;
    scroll-snap-type: y proximity;
    scroll-padding-bottom: 0px;
}

/* Spacer before first message to make it reachable when scrolling */
.chat-messages.has-overflow::before {
    content: '';
    display: block;
    min-height: 150px;
    flex-shrink: 0;
}

.chat-messages::-webkit-scrollbar {
    display: none;
}

.chat-messages {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.chat-message {
    display: flex;
    flex-direction: row-reverse;
    gap: 8px;
    animation: slideIn 0.3s ease;
    transition: all 0.3s ease;
    justify-content: flex-start;
    pointer-events: auto;
    scroll-snap-align: end;
}

/* All messages get speech bubble styling */
.chat-message-text {
    border-radius: 18px;
    position: relative;
    overflow: visible;
}


@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: #f0f0f0;
}

.chat-message-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 70%;
    min-width: 0;
    align-items: flex-end;
}

.chat-message-author {
    display: none;
}

.chat-message-text {
    font-size: 18px;
    color: var(--text-primary);
    line-height: 1.2;
    word-wrap: break-word;
    background: rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    border-radius: 18px;
    transition: background 0.3s ease, color 0.3s ease;
    text-align: left;
    display: inline-block;
    max-width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-message.own .chat-message-text {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.chat-message.selected .chat-message-text {
    background: rgba(102, 126, 234, 0.6);
    border-color: rgba(102, 126, 234, 0.8);
}

.chat-loading {
    text-align: center;
    color: #999;
    padding: 12px;
    font-size: 15px;
}

.group-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 6px 16px 16px 16px;
    background: var(--bg-primary);
    transition: background 0.3s ease;
}

.group-chat-input {
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s, background 0.3s ease, color 0.3s ease, box-shadow 0.2s;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.group-chat-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: rgba(255, 255, 255, 0.12);
}

.group-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.group-chat-send-btn {
    background: transparent;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.group-chat-send-btn:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

.group-chat-send-btn:active {
    transform: scale(0.95);
}

.group-chat-send-btn svg {
    width: 20px;
    height: 20px;
}

.group-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Chat FAB (Floating Action Button) */
.chat-fab {
    position: fixed;
    bottom: 64px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 900;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.chat-fab:active {
    transform: scale(0.95);
}

.chat-fab svg {
    width: 24px;
    height: 24px;
}

.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #f44336;
    color: white;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
}

@media (max-width: 768px) {
    .chat-fab {
        bottom: 60px;
        right: 20px;
        width: 52px;
        height: 52px;
    }
}
/* ============================================
   Profile Settings Page
   ============================================ */

.settings-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 1000;
    overflow-y: auto;
}

.settings-header {
    background: var(--header-gradient);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.back-button {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.back-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.settings-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.settings-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.settings-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}

.settings-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.settings-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.profile-photo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.settings-profile-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.settings-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.settings-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: var(--accent-blue);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.settings-btn:active {
    transform: translateY(0);
}

.google-account-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.google-photo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.google-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.google-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.google-email {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Update dropdown styles */
.dropdown-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-email {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Google Account section in dropdown */
.google-account-section {
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    margin: 8px 0 0 0;
}

.google-account-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.google-account-info-dropdown {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.dropdown-google-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.dropdown-google-name {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Update Google Account section styles */
.google-account-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-google-email {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Force portrait orientation */
@media screen and (orientation: landscape) and (max-height: 600px) {
    body::before {
        content: 'Please rotate your device to portrait mode';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #667eea;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 999999;
        font-size: 20px;
        text-align: center;
        padding: 20px;
    }

    body > *:not(::before) {
        display: none !important;
    }
}


/* ============================================
   DEMO MODE STYLES
   ============================================ */

.demo-user-switch {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
}

.demo-switch-track {
    position: relative;
    display: flex;
    /* Background set dynamically via inline style to show both user colors */
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
}

.demo-switch-option {
    position: relative;
    padding: 8px 20px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 2;
    /* Color set dynamically via inline style based on active/inactive state */
    min-width: 70px;
}

.demo-switch-option.active {
    /* Color set dynamically via inline style */
}

.demo-switch-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    /* Background color set dynamically via inline style based on active user theme */
    border-radius: 17px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
    z-index: 1;
}

.demo-switch-track.user2 .demo-switch-slider {
    transform: translateX(100%);
}

.demo-switch-option:hover:not(.active) {
    color: #333;
}

.demo-switch-option:active {
    transform: scale(0.97);
}

