:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --accent: #0ea5e9;
    --bg-dark: #fbfcfd;
    --bg-surface: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.08);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --success: #10b981;
}

/* Modal Loading Overlay */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 1.25rem;
    color: white;
    text-align: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.modal-loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(139, 92, 246, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    margin-bottom: 1.5rem;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.modal-loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

.modal-loading-subtext {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    max-width: 250px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.98); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: clip;  /* clip (not hidden) — avoids creating a containing block for position:fixed */
    min-height: 100vh;
}

/* Background gradient blobs */
.bg-blob {
    position: fixed;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    filter: blur(80px);
    pointer-events: none;
}

.blob-1 {
    top: -200px;
    right: -100px;
}

.blob-2 {
    bottom: -200px;
    left: -100px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.1) 0%, transparent 70%);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 7000;  /* sticky navigation, below full-screen overlays like modals and viewers */
    border-bottom: 1px solid var(--border-glass);
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-img {
    height: 64px;
    width: auto;
    object-fit: contain;
    display: block;
    transition: opacity 0.2s ease;
}

.logo-img:hover {
    opacity: 0.85;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-main);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.3);
}

.btn-glass {
    background: var(--bg-glass);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(4px);
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 5%;
}

.section-hero {
    text-align: center;
    padding: 4rem 0;
}

h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    letter-spacing: -0.05em;
}

.gradient-text {
    background: linear-gradient(135deg, #1e293b 0%, #64748b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.25rem;
    max-width: 600px;
    margin: 0 auto 3rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
}

.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 1.5rem;
    padding: 2rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.feature-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.feature-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.feature-image-placeholder {
    width: 100%;
    aspect-ratio: 16/10;
    background: #000;
    border-radius: 1rem;
    margin-top: 1rem;
    object-fit: cover;
}

/* Tool Page Specifics */
.tool-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    margin-top: 2rem;
    min-height: calc(100vh - 200px);
}

.tool-sidebar {
    background: white;
    border: 1px solid var(--border-glass);
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    height: fit-content;
}



.tool-canvas {
    background: #f1f5f9;
    border: 1px solid var(--border-glass);
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 500px;
}

.upload-area {
    border: 2px dashed var(--border-glass);
    border-radius: 1rem;
    padding: 3rem;
    text-align: center;
    width: 80%;
    max-width: 500px;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}



.option-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.radio-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.radio-tile {
    padding: 1rem;
    border: 1px solid var(--border-glass);
    border-radius: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.radio-tile:hover {
    background: var(--bg-glass);
}

.radio-tile.selected {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

.input-field {
    width: 100%;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
}

.selected-card {
    border-color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.08) !important;
    box-shadow: 0 0 0 2px var(--primary), var(--shadow-md);
    transform: scale(1.02);
}

/* Loader Spinner */
.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-glass);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

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

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

.animate-fade-in {
    animation: fadeIn 0.8s ease forwards;
}

/* Responsive */
@media (max-width: 1024px) {
    .tool-container {
        grid-template-columns: 1fr;
    }

    .tool-sidebar {
        order: 2;
    }

    .tool-canvas {
        order: 1;
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
        border-bottom: 1px solid var(--border-glass);
        box-shadow: var(--shadow-md);
    }

    .nav-links.active {
        display: flex;
    }

    .mobile-menu-btn {
        display: block !important;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    main {
        padding: 1rem 5%;
    }
}

/* --- Image Viewer Enhancements --- */
.viewer-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9000;  /* above modals (8500) and nav (7000) so close button is always reachable */
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#viewer-content-container {
    cursor: grab;
}

#viewer-content-container:active {
    cursor: grabbing;
}

#viewer-transform-wrapper {
    transition: transform 0.05s linear;
    /* Smooth but responsive */
    will-change: transform;
}

#viewer-face-overlay {
    z-index: 1;
}

.viewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    cursor: pointer;
    z-index: 9999;
    transition: all 0.2s ease;
}

.viewer-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.viewer-actions {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.75rem;
    border-radius: 1.25rem;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.viewer-actions .btn {
    padding: 0.8rem 1.5rem;
}

.viewer-actions #viewer-fix-faces-btn {
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.4);
}

.viewer-actions svg {
    margin-right: 8px;
}

@media (max-width: 768px) {
    .viewer-actions {
        bottom: 1.5rem;
        padding: 0.5rem;
        gap: 0.5rem;
        width: calc(100% - 2rem);
        max-width: 380px;
        border-radius: 1rem;
    }

    .viewer-actions .btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        flex: 1;
        justify-content: center;
    }

    .viewer-actions svg {
        width: 16px;
        height: 16px;
        margin-right: 4px;
    }

    .viewer-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
}

.face-detection-box {
    position: absolute;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background-color: transparent;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5), inset 0 0 5px rgba(99, 102, 241, 0.3);
    pointer-events: auto; /* Ensure it can be clicked */
    cursor: pointer;
    opacity: 0; /* Hidden by default */
}

/* Show boxes when hovering over the viewer */
#image-viewer:hover .face-detection-box {
    opacity: 1;
}

/* Keep processing boxes always visible */
.face-detection-box.processing {
    opacity: 1 !important;
}


.face-detection-box:hover {
    border-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6), inset 0 0 10px rgba(99, 102, 241, 0.4);
    transition: var(--transition);
}

#user-profile-summary:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-soft);
}

#user-dropdown {
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-glass);
    animation: slideDown 0.2s ease-out;
}

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

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

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-glass);
    transition: var(--transition);
}

.history-item:hover {
    background: rgba(139, 92, 246, 0.05);
}

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

/* History Tabs */
.history-tabs {
    border-bottom: 1px solid var(--border-glass);
}

.history-tab-btn {
    transition: all 0.2s ease;
    outline: none;
}

.history-tab-btn:after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary);
    transition: width 0.3s ease;
    border-radius: 3px 3px 0 0;
}

.history-tab-btn.active {
    color: var(--text-main) !important;
    font-weight: 700 !important;
}

.history-tab-btn.active:after {
    width: 100%;
}

/* Modal Enhancements */
.modal {
    display: none;
    position: fixed;
    z-index: 8500;   /* above nav (7000) and mobile overlay (8000) */
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    /* Flex column so the inner wrapper can be centred vertically */
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;           /* backdrop scrolls when card is taller than viewport */
    padding: 2rem 1rem;
}

/* Centre the card vertically when there is room; let backdrop scroll otherwise */
.modal > .modal-content {
    margin: auto;
}

.modal-content {
    background: white;
    border-radius: 1.5rem;
    position: relative;
    /* No max-height / overflow here — let the backdrop handle scrolling */
    overflow: visible;
    animation: modalAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card {
    background: var(--bg-surface);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-glass);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

/* Thin custom scrollbar for the modal backdrop */
.modal::-webkit-scrollbar {
    width: 6px;
}
.modal::-webkit-scrollbar-track {
    background: transparent;
}
.modal::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 3px;
}
.modal::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
}

/* Right column gallery: scrolls inside the card instead of stretching it */
.modal-grid > div:last-child {
    display: flex;
    flex-direction: column;
    min-height: 0;          /* allow flex child to shrink */
}

#edit-person-gallery {
    flex: 1;
    overflow-y: auto;
    max-height: 340px;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(99,102,241,0.25) transparent;
}

#edit-person-gallery::-webkit-scrollbar {
    width: 5px;
}
#edit-person-gallery::-webkit-scrollbar-track {
    background: transparent;
}
#edit-person-gallery::-webkit-scrollbar-thumb {
    background: rgba(99,102,241,0.25);
    border-radius: 3px;
}
#edit-person-gallery::-webkit-scrollbar-thumb:hover {
    background: rgba(99,102,241,0.5);
}

@media (max-width: 768px) {
    .modal-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    #edit-person-gallery {
        max-height: 220px;
    }
}


.close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    z-index: 10;
}

.close:hover {
    color: var(--text-main);
    transform: scale(1.1);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

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

#header-user-avatar {
    transition: var(--transition);
}

#header-user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--primary);
}

/* Input Fields */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-glass);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

@media (max-width: 768px) {

    .header-actions .btn-glass#login-btn,
    .header-actions #user-profile-summary {
        padding: 0.4rem 0.6rem;
    }

    #header-user-name {
        display: none;
    }
}

/* --- Image Comparison Slider --- */
.comparison-slider-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background: #000;
}

.comparison-slider {
    position: relative;
    width: 100%;
    display: flex;
    overflow: hidden;
}

.comparison-slider img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.comparison-slider .before {
    position: relative;
    z-index: 1;
}

.comparison-slider .after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    clip-path: inset(0 0 0 50%);
}

.comparison-slider-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    z-index: 10;
    cursor: ew-resize;
    margin: 0;
}

.comparison-slider-input::-webkit-slider-runnable-track {
    background: transparent;
}

.comparison-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 4px;
    height: 1000px;
    background: var(--primary);
    cursor: ew-resize;
    position: relative;
    box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.2);
}

.comparison-slider .slider-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.3);
    z-index: 9;
    pointer-events: none;
    transition: transform 0.1s ease-out;
}

.comparison-slider .slider-label {
    position: absolute;
    bottom: 20px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 6px;
    z-index: 5;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.comparison-slider .label-before {
    left: 20px;
}

.comparison-slider .label-after {
    right: 20px;
}

/* ========================================
   Persons Nav Badge
   ======================================== */
.nav-persons-link {
    display: inline-flex !important;
    align-items: center;
    gap: 0.4rem;
}

.nav-badge {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    line-height: 1.6;
    letter-spacing: 0.02em;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
    animation: badgePop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes badgePop {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ========================================
   Persons Page Layout
   ======================================== */
.persons-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.5rem 0 3rem;
}

.persons-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.persons-page-title {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0;
}

.persons-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.persons-search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

.persons-search-input {
    padding: 0.55rem 1rem 0.55rem 2.4rem;
    border-radius: 99px;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-main);
    font-size: 0.875rem;
    font-family: inherit;
    width: 220px;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.persons-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    width: 260px;
}

.persons-sort-select {
    padding: 0.55rem 1rem;
    border-radius: 99px;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-main);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.persons-sort-select:focus {
    outline: none;
    border-color: var(--primary);
}

.persons-login-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 5rem 2rem;
    border: 2px dashed var(--border-glass);
    border-radius: 1.5rem;
    background: var(--bg-surface);
}

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

/* Card */
.person-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
}

.person-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.2);
}

.person-card-avatar {
    position: relative;
    height: 260px;
    overflow: hidden;
    background: linear-gradient(160deg, #e8e6ff 0%, #f5f3ff 100%);
    cursor: zoom-in;
}

.person-card-avatar img.person-main-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.person-card:hover .person-main-avatar {
    transform: scale(1.06);
}

.person-avatar-strip {
    position: absolute;
    bottom: 0.6rem;
    left: 0.75rem;
    display: flex;
}

.person-avatar-strip img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
    margin-right: -8px;
    background: #e5e7eb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.person-avatar-strip img:hover {
    transform: translateY(-3px);
    z-index: 10;
}

.person-photo-count {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 99px;
    letter-spacing: 0.03em;
}

.person-card-body {
    padding: 1rem 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
}

.person-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-card-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    min-height: 22px;
}

.person-meta-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 8px;
    border-radius: 99px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    white-space: nowrap;
}

.person-meta-pill.sex-female {
    color: var(--secondary);
    background: rgba(236, 72, 153, 0.08);
    border-color: rgba(236, 72, 153, 0.15);
}

.person-meta-pill.neutral {
    color: var(--text-muted);
    background: rgba(100, 116, 139, 0.07);
    border-color: rgba(100, 116, 139, 0.12);
}

.person-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.person-action-btn {
    flex: 1;
    padding: 0.48rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 0.75rem;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: var(--transition);
    font-family: inherit;
}

.person-action-btn:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.person-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
    color: #ef4444;
}

.person-action-btn.accent:hover {
    background: rgba(14, 165, 233, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}

@media (max-width: 600px) {
    .persons-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 1rem; }
    .persons-page-header { flex-direction: column; align-items: flex-start; }
    .persons-search-input { width: 100%; }
}/* --- Composite Refactor: Wizard & Canvas Sections --- */

.wizard-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.wizard-steps .step {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 2px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.wizard-steps .step.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.wizard-steps .step.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.wizard-steps .step-line {
    flex: 1;
    height: 2px;
    background: var(--border-glass);
    max-width: 60px;
}

.wizard-content {
    background: var(--bg-glass);
    border-radius: 1.5rem;
    padding: 2.5rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s ease-out;
}

.wizard-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

/* Canvas Sections */
.canvas-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.persons-horizontal-list {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 1rem;
    min-height: 120px;
    align-items: center;
    border: 1px solid var(--border-glass);
}

.empty-state-msg {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
}

.upload-trigger-card {
    min-width: 100px;
    height: 100px;
    border: 2px dashed var(--border-glass);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.upload-trigger-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}

.person-card-mini {
    min-width: 90px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 0.75rem;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    user-select: none;
    flex-shrink: 0;
}

.person-card-mini:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.person-card-mini.selected {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

.person-card-mini img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.person-card-mini .name {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}


/* Restoration Wizard Styles */
.upload-zone {
    border: 2px dashed var(--border-glass);
    border-radius: 1.5rem;
    padding: 4.5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.04);
    transform: scale(1.01);
}

.option-card {
    transition: all 0.2s ease;
}

.option-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06) !important;
}

#restore-wizard-steps-indicator {
    max-width: 500px;
    margin: 0 auto 2.5rem;
}

.restore-wizard-actions .btn {
    min-width: 120px;
}


/* Active Glass Button Fix */
.btn-glass.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    font-weight: 700;
}

/* Pagination Controls */
.pagination-container {
    margin-top: 2rem;
    padding: 1rem 0;
}

.pagination-btn {
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.pagination-btn:hover:not(.disabled) {
    background: var(--bg-glass);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.pagination-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.pagination-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(0,0,0,0.05);
}


.face-detect-zone {
    border: 2px dashed var(--border-glass);
    border-radius: 1rem;
    padding: 3rem;
    text-align: center;
    width: 80%;
    max-width: 500px;
    cursor: pointer;
    transition: var(--transition);
}

.face-detect-zone:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}

/* Face Extraction UI Enhancements */
.face-extraction-card {
    position: relative;
    transition: transform 0.2s;
}
.face-extraction-card:hover {
    transform: translateY(-2px);
}

.face-action-btn-container {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.face-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    white-space: nowrap;
    padding: 0 8px;
}

.face-action-btn svg {
    flex-shrink: 0;
}

.face-action-btn span {
    width: 0;
    opacity: 0;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
    margin-left: 0;
}

/* Expand width and show text on hover of the CARD */
.face-extraction-card:hover .face-action-btn {
    width: auto;
    border-radius: 20px;
}

.face-extraction-card:hover .face-action-btn span {
    width: auto;
    opacity: 1;
    margin-left: 6px;
    margin-right: 4px;
}

.btn-face-create { background: #10b981; }
.btn-face-add { background: #6366f1; }
.btn-face-ignore { background: #ef4444; }

.face-form-inline {
    margin-top: 10px;
    animation: slideDown 0.3s ease-out;
}

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

/* Face Swap Popover Steps */
.popover-step-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border-radius: 99px;
    background: rgba(0,0,0,0.1);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.popover-step-pill.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.popover-step-pill.completed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.popover-step-num {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    font-size: 0.65rem;
}

.popover-step-pill.active .popover-step-num {
    background: white;
    color: var(--primary);
}

.popover-step-check {
    font-size: 0.8rem;
    font-weight: 800;
}

.popover-step-line {
    flex: 1;
    height: 2px;
    background: var(--border-glass);
    border-radius: 2px;
}

/* Face Swap Method Selector */
.method-selector {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.25rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-glass);
}

.method-btn {
    flex: 1;
    padding: 0.4rem 0.2rem;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.method-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.method-btn.active {
    background: var(--primary);
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

.method-status {
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 2px;
    text-transform: uppercase;
    font-weight: 800;
}
.method-status.free {
    background: #10b981;
    color: white;
}
.method-status.paid {
    background: rgba(255,255,255,0.1);
    color: var(--text-muted);
}
.method-btn.active .method-status.paid {
    background: rgba(0,0,0,0.2);
    color: white;
}

.box-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 6px;
    backdrop-filter: blur(2px);
    z-index: 100;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.face-detection-box.processing {
    pointer-events: none !important;
    border-color: var(--primary) !important;
    border-style: solid !important;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.animate-slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Face Fix Popover Wizard & History */
#popover-wizard-indicators {
    background: rgba(0,0,0,0.03);
    border-bottom: 1px dashed var(--border-glass);
}

.popover-step-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 55px;
}

.popover-step-pill.active {
    opacity: 1;
}

.popover-step-pill.completed {
    opacity: 0.8;
}

.popover-step-num {
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.popover-step-pill.active .popover-step-num {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.popover-step-pill.completed .popover-step-num {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.popover-step-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.popover-step-pill.active .popover-step-label {
    color: var(--primary);
}

.popover-step-line {
    flex: 1;
    height: 1px;
    background: var(--border-glass);
    margin-top: -12px;
    max-width: 25px;
}

.popover-history-item {
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.popover-history-item:hover {
    transform: scale(1.15) translateY(-2px);
    z-index: 5;
}

.popover-history-item img {
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Radio Tiles for Swap Mode */
.radio-grid {
    display: grid;
    gap: 0.75rem;
}

.radio-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.85rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    border-radius: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.4rem;
}

.radio-tile:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(99, 102, 241, 0.3);
}

.radio-tile.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.radio-tile span {
    display: block;
    line-height: 1.2;
}

/* ═══════════════════════════════════════════════════════════════════
   Desktop Face-Fix Popover  (ffp-*)
   White card, clean product-style design
   ═══════════════════════════════════════════════════════════════════ */

.ffp-panel {
    width: 400px;
    /* Fixed height so the body scrolls rather than the whole panel growing */
    height: min(85vh, 780px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;      /* clip horizontal; ffp-body handles vertical scroll */
    overflow-x: hidden;
    font-family: var(--font-sans);
    color: #111;
}

/* Header */
.ffp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid #f0f0f5;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
    background: #fff;
}
.ffp-header-left { display: flex; align-items: center; gap: 0.5rem; }
.ffp-title { font-weight: 700; font-size: 0.95rem; color: #111; }
.ffp-header-right { display: flex; align-items: center; gap: 0.5rem; }
.ffp-help-btn {
    display: flex; align-items: center; gap: 4px;
    background: none; border: 1px solid #e5e7eb;
    border-radius: 8px; padding: 0.3rem 0.65rem;
    font-size: 0.75rem; font-weight: 600; color: #6b7280;
    cursor: pointer; transition: background 0.15s;
}
.ffp-help-btn:hover { background: #f3f4f6; }
.ffp-close-btn {
    background: none; border: none; cursor: pointer;
    color: #9ca3af; font-size: 1rem; padding: 0.2rem 0.4rem;
    border-radius: 6px; transition: color 0.15s;
    line-height: 1;
}
.ffp-close-btn:hover { color: #374151; }

/* 4-step progress bar */
.ffp-steps {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid #f0f0f5;
    background: #fafafa;
    flex-shrink: 0;
}
.ffp-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
    cursor: pointer;
    transition: opacity 0.15s;
}
.ffp-step:hover .ffp-step-circle { box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.ffp-step-circle {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.22s;
    position: relative;
    flex-shrink: 0;
}
/* Active step */
.ffp-step.active .ffp-step-circle {
    background: #6366f1;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.18);
}
/* Completed step — show green checkmark */
.ffp-step.done .ffp-step-circle {
    background: #22c55e;  /* green = completed */
    color: #fff;
    font-size: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px;
}
.ffp-step-label {
    font-size: 0.6rem; font-weight: 600; color: #9ca3af;
    white-space: nowrap; transition: color 0.2s;
}
.ffp-step.active .ffp-step-label { color: #6366f1; font-weight: 700; }
.ffp-step.done   .ffp-step-label { color: #22c55e; }  /* green label for done */
/* Connector line */
.ffp-step-connector {
    flex: 1; height: 2px;
    background: #e5e7eb;
    margin: 0 4px 14px;
    transition: background 0.22s;
    border-radius: 2px;
}
/* Line turns indigo when the PRECEDING step is done */
.ffp-step.done + .ffp-step-connector { background: #22c55e; }  /* green connector after done step */

/* Scrollable body */
.ffp-body {
    flex: 1;
    min-height: 0;          /* critical: lets flex child shrink so overflow-y:auto works */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}
.ffp-body::-webkit-scrollbar { width: 4px; }
.ffp-body::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }

/* Sections */
.ffp-section {
    padding: 1rem 1.1rem 0.75rem;
    border-bottom: 1px solid #f0f0f5;
}
.ffp-section:last-child { border-bottom: none; }
.ffp-section-title { font-size: 0.88rem; font-weight: 700; color: #111; margin-bottom: 2px; }
.ffp-section-sub   { font-size: 0.72rem; color: #6b7280; margin-bottom: 0.6rem; }

/* Selected face card */
.ffp-selected-face-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.6rem;
}
.ffp-selected-face-label { font-size: 0.68rem; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 0.45rem; }
.ffp-selected-face-row   { display: flex; align-items: center; gap: 0.75rem; }
.ffp-face-preview { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; border: 2px solid #6366f1; flex-shrink: 0; }
.ffp-face-info    { display: flex; flex-direction: column; gap: 4px; }
.ffp-face-name    { font-size: 0.85rem; font-weight: 700; color: #111; }
.ffp-face-badge   { display: inline-block; background: rgba(99,102,241,0.1); color: #6366f1; font-size: 0.65rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }

/* Undo/Redo/Reset row */
.ffp-action-row { display: flex; gap: 0.4rem; }
.ffp-action-btn {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 8px;
    padding: 0.4rem 0.5rem; font-size: 0.75rem; font-weight: 600; color: #374151;
    cursor: pointer; transition: background 0.15s;
}
.ffp-action-btn:disabled { opacity: 0.4; cursor: default; }
.ffp-action-btn:not(:disabled):hover { background: #e5e7eb; }

/* Catalog / Upload tabs */
.ffp-tabs { display: flex; border-bottom: 1.5px solid #e5e7eb; margin-bottom: 0.7rem; gap: 0; }
.ffp-tab {
    padding: 0.4rem 1rem; font-size: 0.82rem; font-weight: 600; color: #9ca3af;
    background: none; border: none; border-bottom: 2px solid transparent;
    cursor: pointer; transition: all 0.18s; margin-bottom: -1.5px;
}
.ffp-tab.active { color: #6366f1; border-bottom-color: #6366f1; }

/* Search row */
.ffp-search-row { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; }
.ffp-search-wrap { flex: 1; position: relative; }
.ffp-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #9ca3af; pointer-events: none; }
.ffp-search-input {
    width: 100%; padding: 0.45rem 0.75rem 0.45rem 2rem;
    border: 1.5px solid #e5e7eb; border-radius: 8px;
    font-size: 0.82rem; color: #111; background: #fff;
    outline: none; font-family: inherit;
    transition: border-color 0.15s;
}
.ffp-search-input:focus { border-color: #6366f1; }
.ffp-filter-select {
    padding: 0.45rem 0.6rem; border: 1.5px solid #e5e7eb; border-radius: 8px;
    font-size: 0.78rem; color: #374151; background: #fff;
    outline: none; cursor: pointer; font-family: inherit;
}

/* Person grid */
.ffp-person-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ffp-person-grid .popover-person-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    cursor: pointer; width: 68px; flex-shrink: 0;
    border-radius: 8px; padding: 4px;
    border: 2px solid transparent; transition: border-color 0.15s;
}
.ffp-person-grid .popover-person-item img {
    width: 56px; height: 56px; border-radius: 8px;
    object-fit: cover; border: 2px solid #e5e7eb;
    transition: border-color 0.15s;
}
.ffp-person-grid .popover-person-item span {
    font-size: 0.65rem; font-weight: 600; color: #374151;
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; width: 100%; text-align: center;
}
.ffp-person-grid .popover-person-item img[style*="var(--primary)"] { border-color: #6366f1; }

/* Face view header */
.ffp-face-view-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.ffp-back-link { background: none; border: none; color: #6366f1; font-weight: 600; font-size: 0.8rem; cursor: pointer; padding: 0; }
.ffp-face-view-title { font-size: 0.82rem; font-weight: 700; color: #111; }

/* Upload drop area */
.ffp-upload-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 1.5rem; border: 2px dashed #d1d5db; border-radius: 10px;
    cursor: pointer; background: #fafafa; font-size: 0.82rem; color: #6b7280;
    transition: border-color 0.2s; text-align: center;
}
.ffp-upload-drop:hover { border-color: #6366f1; background: rgba(99,102,241,0.03); }

/* Swap type grid */
.ffp-swap-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.5rem; }
.ffp-swap-type-card {
    display: flex; align-items: center; gap: 0.6rem;
    border: 2px solid #e5e7eb; border-radius: 10px;
    padding: 0.7rem 0.75rem; cursor: pointer; background: #fff;
    position: relative; transition: all 0.18s;
}
.ffp-swap-type-card.selected { border-color: #6366f1; background: rgba(99,102,241,0.04); }
.ffp-swap-type-icon { color: #6366f1; flex-shrink: 0; }
.ffp-swap-type-name { font-size: 0.82rem; font-weight: 700; color: #111; }
.ffp-swap-type-desc { font-size: 0.68rem; color: #6b7280; margin-top: 1px; }
.ffp-swap-type-radio {
    position: absolute; top: 0.6rem; right: 0.6rem;
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid #d1d5db; background: #fff; transition: all 0.18s;
}
.ffp-swap-type-card.selected .ffp-swap-type-radio { border-color: #6366f1; background: #6366f1; box-shadow: inset 0 0 0 3px #fff; }

/* Method grid */
.ffp-method-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.5rem; margin-top: 0.5rem; }
.ffp-method-card {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; padding: 0.65rem 0.4rem;
    border: 2px solid #e5e7eb; border-radius: 10px;
    cursor: pointer; background: #fff; text-align: center;
    transition: all 0.18s;
}
.ffp-method-card.active,
.ffp-method-card.selected { border-color: #6366f1; background: rgba(99,102,241,0.05); }
.ffp-method-icon { color: #6366f1; }
.ffp-method-name { font-size: 0.72rem; font-weight: 700; color: #111; line-height: 1.2; }
.ffp-method-sub  { font-size: 0.62rem; color: #6b7280; line-height: 1.2; }

/* Advanced settings */
.ffp-advanced { margin-top: 0.75rem; }
.ffp-advanced-summary {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.78rem; font-weight: 600; color: #6b7280;
    cursor: pointer; list-style: none; padding: 0.35rem 0;
    transition: color 0.15s;
}
.ffp-advanced-summary::-webkit-details-marker { display: none; }
.ffp-advanced-summary::after { content: '▾'; margin-left: auto; font-size: 0.75rem; }
details.ffp-advanced[open] .ffp-advanced-summary::after { content: '▴'; }
.ffp-advanced-summary:hover { color: #374151; }
.ffp-advanced-body { padding-top: 0.5rem; }
.ffp-adv-label  { display: block; font-size: 0.72rem; font-weight: 600; color: #6b7280; margin-bottom: 0.3rem; }
.ffp-adv-select {
    width: 100%; padding: 0.4rem 0.6rem;
    border: 1.5px solid #e5e7eb; border-radius: 8px;
    font-size: 0.82rem; color: #111; background: #fff;
    outline: none; font-family: inherit; cursor: pointer;
}
.ffp-adv-select:focus { border-color: #6366f1; }

/* History */
.ffp-history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.ffp-history-label  { font-size: 0.68rem; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.04em; }
.ffp-hist-nav {
    background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 5px;
    padding: 2px 7px; font-size: 0.8rem; color: #374151; cursor: pointer;
}

/* Footer + Generate button */
.ffp-footer {
    padding: 0.85rem 1.1rem;
    border-top: 1px solid #f0f0f5;
    background: #fff;
    flex-shrink: 0;
}
.ffp-generate-btn {
    width: 100%;
    padding: 0.85rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    box-shadow: 0 6px 18px rgba(99,102,241,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}
.ffp-generate-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(99,102,241,0.42); }
.ffp-generate-btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

/* Tab helper: hide panel on catalog/upload switch */
.ffp-tab-panel-hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════
   Mobile Face-Swap Wizard  (mfs-*)
   Full-screen iOS-style overlay — white clean design
   ═══════════════════════════════════════════════════════════════════ */

.mfs-overlay {
    position: fixed;
    inset: 0;
    z-index: 8000;          /* above nav (7000) */
    background: #f5f5f7;
    display: none;          /* hidden by default — JS adds .mfs-active to show */
    flex-direction: column;
    overflow: hidden;
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}
.mfs-overlay.mfs-active {
    display: flex;
    animation: mfsSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mfsSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Header ── */
.mfs-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    min-height: 52px;
}

.mfs-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6366f1;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    border-radius: 8px;
    transition: background 0.15s;
    flex-shrink: 0;
}
.mfs-back-btn:hover { background: #f0f0f5; }

.mfs-header-title {
    flex: 1;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}
.mfs-emoji { font-size: 1.1rem; }

.mfs-save-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6366f1;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: background 0.15s;
}
.mfs-save-btn:hover { background: #ededfd; }

.mfs-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    flex-shrink: 0;
}

/* ── Step indicator ── */
.mfs-steps {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    gap: 0;
}

.mfs-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
    position: relative;
}

.mfs-step-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #9ca3af;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
}

.mfs-step.active .mfs-step-dot {
    background: #6366f1;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.mfs-step.completed .mfs-step-dot {
    background: #6366f1;
    color: #fff;
}

.mfs-step-lbl {
    font-size: 0.62rem;
    color: #9ca3af;
    white-space: nowrap;
    transition: color 0.25s;
}
.mfs-step.active .mfs-step-lbl   { color: #6366f1; font-weight: 600; }
.mfs-step.completed .mfs-step-lbl { color: #6366f1; }

.mfs-step-line {
    flex: 1;
    height: 2px;
    background: #e5e7eb;
    margin: 0 4px;
    margin-bottom: 14px; /* align with dot centres */
    transition: background 0.25s;
}
.mfs-step.completed + .mfs-step-line,
.mfs-step.active + .mfs-step-line {
    /* line between completed and next stays grey – colour only on done */
}
/* colour the line when previous step is completed */
.mfs-step.completed ~ .mfs-step-line { background: #6366f1; }

/* ── Body ── */
.mfs-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mfs-step-panel {
    padding: 1rem;
}

/* ── Target image + overlay ── */
.mfs-img-wrap {
    position: relative;
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 3/4;
    max-height: 42vh;
}
.mfs-target-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mfs-face-overlay {
    position: absolute;
    inset: 0;
    pointer-events: auto;
}
.mfs-expand-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 8px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.mfs-detect-spinner {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #fff;
    font-size: 0.85rem;
    backdrop-filter: blur(4px);
}
.mfs-spinner-ring {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* Mobile face-detection boxes */
.mfs-face-box {
    position: absolute;
    border: 2.5px solid #6366f1;
    border-radius: 8px;
    background: rgba(99,102,241,0.08);
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 0 10px rgba(99,102,241,0.4);
}
.mfs-face-box.selected {
    border-color: #6366f1;
    background: rgba(99,102,241,0.2);
    box-shadow: 0 0 18px rgba(99,102,241,0.6);
}

/* ── Section titles ── */
.mfs-section-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #111;
    margin-top: 1rem;
    margin-bottom: 0.2rem;
}
.mfs-section-sub {
    font-size: 0.78rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
}

/* ── Face thumbnail strip ── */
.mfs-face-strip {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.mfs-face-thumb {
    width: 76px;
    height: 76px;
    border-radius: 10px;
    object-fit: cover;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    background: #e5e7eb;
}
.mfs-face-thumb.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}
.mfs-face-thumb-wrap {
    position: relative;
    width: 76px;
}
.mfs-face-check {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: #6366f1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}
.mfs-face-thumb.selected + .mfs-face-check { display: flex; }

/* ── Chosen face row ── */
.mfs-chosen-row {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 0.75rem 1rem;
}
.mfs-chosen-lbl {
    font-size: 0.72rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.5rem;
}
.mfs-chosen-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.mfs-chosen-thumb {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    border: 2px solid #6366f1;
    flex-shrink: 0;
}
.mfs-chosen-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    flex: 1;
}
.mfs-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s;
}
.mfs-action-btn:disabled { opacity: 0.4; cursor: default; }
.mfs-action-btn:not(:disabled):hover { background: #e5e7eb; }
.mfs-reset-btn { flex-direction: column; align-items: flex-start; line-height: 1.2; }

/* ── Step 2: Source tabs ── */
.mfs-source-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.mfs-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.18s;
}
.mfs-tab.active {
    border-color: #6366f1;
    color: #6366f1;
    background: rgba(99,102,241,0.06);
}

/* ── Search ── */
.mfs-search {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    border: 1.5px solid #e5e7eb;
    background: #f9fafb;
    font-size: 0.875rem;
    color: #111;
    margin-bottom: 0.75rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}
.mfs-search:focus { border-color: #6366f1; background: #fff; }

/* ── Person grid ── */
.mfs-person-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
}
.mfs-person-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border-radius: 10px;
    padding: 4px;
    border: 2px solid transparent;
    transition: all 0.18s;
}
.mfs-person-card.selected {
    border-color: #6366f1;
    background: rgba(99,102,241,0.06);
}
.mfs-person-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    background: #e5e7eb;
}
.mfs-person-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: #374151;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.mfs-empty {
    grid-column: 1/-1;
    text-align: center;
    font-size: 0.85rem;
    color: #9ca3af;
    padding: 2rem 0;
}

.mfs-face-photos-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.mfs-back-link {
    background: none;
    border: none;
    color: #6366f1;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
}
.mfs-selected-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #111;
}

/* Upload area */
.mfs-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 2rem;
    border: 2px dashed #d1d5db;
    border-radius: 14px;
    cursor: pointer;
    background: #fafafa;
    font-size: 0.875rem;
    color: #6b7280;
    transition: border-color 0.2s;
    text-align: center;
}
.mfs-upload-area:hover { border-color: #6366f1; background: rgba(99,102,241,0.03); }

/* ── Step 3: Swap type ── */
.mfs-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.mfs-type-card {
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    padding: 1rem 0.75rem;
    cursor: pointer;
    background: #fff;
    position: relative;
    transition: all 0.18s;
    display: block;
    text-align: left;
}
.mfs-type-card.selected {
    border-color: #6366f1;
    background: rgba(99,102,241,0.04);
}
.mfs-type-icon { font-size: 1.5rem; margin-bottom: 0.35rem; }
.mfs-type-name { font-weight: 700; font-size: 0.9rem; color: #111; margin-bottom: 0.2rem; }
.mfs-type-desc { font-size: 0.72rem; color: #6b7280; }
.mfs-radio-dot {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: #fff;
    transition: all 0.18s;
}
.mfs-type-card.selected .mfs-radio-dot {
    border-color: #6366f1;
    background: #6366f1;
    box-shadow: inset 0 0 0 3px #fff;
}

/* Mood select */
.mfs-select {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    font-size: 0.875rem;
    color: #111;
    font-family: inherit;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    cursor: pointer;
}
.mfs-select:focus { border-color: #6366f1; }

/* ── Step 4: Method grid ── */
.mfs-method-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.mfs-method-card {
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    padding: 0.85rem;
    cursor: pointer;
    background: #fff;
    display: block;
    transition: all 0.18s;
}
.mfs-method-card.selected {
    border-color: #6366f1;
    background: rgba(99,102,241,0.04);
}
.mfs-method-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.mfs-method-icon { font-size: 1.2rem; flex-shrink: 0; }
.mfs-method-name { font-weight: 700; font-size: 0.82rem; color: #111; line-height: 1.2; }
.mfs-method-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}
.mfs-method-badge.recommended { background: rgba(99,102,241,0.12); color: #6366f1; }
.mfs-method-radio {
    margin-left: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: #fff;
    flex-shrink: 0;
    transition: all 0.18s;
}
.mfs-method-card.selected .mfs-method-radio {
    border-color: #6366f1;
    background: #6366f1;
    box-shadow: inset 0 0 0 2.5px #fff;
}
.mfs-method-desc { font-size: 0.7rem; color: #6b7280; line-height: 1.3; }

/* ── Preview & Swap ── */
.mfs-preview-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #111;
    margin-bottom: 0.2rem;
}
.mfs-preview-sub {
    font-size: 0.78rem;
    color: #6b7280;
    margin-bottom: 0.85rem;
}

/* Before/After */
.mfs-ba-wrap {
    display: flex;
    align-items: stretch;
    gap: 0;
    border-radius: 14px;
    overflow: hidden;
    background: #000;
    margin-bottom: 1rem;
    position: relative;
    aspect-ratio: 16/9;
}
.mfs-ba-side {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.mfs-ba-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mfs-ba-label {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    z-index: 1;
}
.mfs-ba-before { background: rgba(0,0,0,0.5); color: #fff; }
.mfs-ba-after  { background: rgba(99,102,241,0.85); color: #fff; }
.mfs-ba-swap-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    background: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    color: #6366f1;
}

/* Summary cards */
.mfs-summary-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.mfs-summary-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
}
.mfs-sum-icon { font-size: 1.4rem; flex-shrink: 0; }
.mfs-sum-icon-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #6366f1;
    flex-shrink: 0;
}
.mfs-sum-info { flex: 1; }
.mfs-sum-label { font-size: 0.68rem; color: #9ca3af; font-weight: 500; }
.mfs-sum-value { font-size: 0.88rem; font-weight: 700; color: #111; }
.mfs-sum-edit {
    background: none;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6366f1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.mfs-sum-edit:hover { background: rgba(99,102,241,0.06); }

/* Swap button */
.mfs-swap-btn {
    width: 100%;
    padding: 0.95rem;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 8px 20px rgba(99,102,241,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    margin-bottom: 0.75rem;
}
.mfs-swap-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(99,102,241,0.4); }
.mfs-swap-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.mfs-swap-status {
    text-align: center;
    font-size: 0.82rem;
    color: #6b7280;
    padding: 0.5rem;
}

/* ── Result screen ── */
.mfs-result-img {
    width: 100%;
    border-radius: 14px;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    margin-bottom: 1rem;
    max-height: 55vh;
    object-fit: contain;
    background: #000;
}

.mfs-download-btn {
    width: 100%;
    padding: 0.85rem;
    border-radius: 14px;
    border: 2px solid #6366f1;
    background: #fff;
    color: #6366f1;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    transition: all 0.18s;
}
.mfs-download-btn:hover { background: rgba(99,102,241,0.05); }

.mfs-result-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.mfs-result-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem;
    border-radius: 12px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.mfs-result-action-btn:hover { background: #f3f4f6; }

/* Privacy note */
.mfs-privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: #9ca3af;
}

/* ── Footer CTA ── */
.mfs-footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}
.mfs-cta-btn {
    width: 100%;
    padding: 0.95rem;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(99,102,241,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}
.mfs-cta-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(99,102,241,0.4); }
.mfs-cta-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ── Trigger button: show on mobile, hide on desktop ── */
.mfs-open-trigger {
    display: none;
}
@media (max-width: 640px) {
    .mfs-open-trigger { display: inline-flex; }
}

/* ======================================================
   Photo Thumbnail – 3-dot context menu (Person Gallery)
   ====================================================== */

.photo-thumb-wrap {
    position: relative;
    overflow: visible !important; /* allow menu to escape card bounds */
}

.photo-thumb-wrap > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.6rem;
}

/* "Main" badge at bottom of thumbnail */
.photo-main-badge {
    position: absolute;
    bottom: 0.35rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.18rem 0.55rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

/* 3-dot button */
.photo-menu-btn {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #374151;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    z-index: 2;
}

.photo-menu-btn:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.22);
    transform: scale(1.1);
}

/* Context menu popup */
.photo-context-menu {
    background: white;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 0.85rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.14), 0 2px 6px rgba(0,0,0,0.08);
    padding: 0.35rem;
    min-width: 210px;
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    transform-origin: top right;
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.photo-context-menu.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.photo-ctx-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
    color: #1e293b;
}

.photo-ctx-item:hover {
    background: rgba(99,102,241,0.07);
}

.photo-ctx-item--danger:hover {
    background: rgba(239,68,68,0.07);
}

.photo-ctx-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.photo-ctx-icon--main {
    background: rgba(99,102,241,0.12);
    color: var(--primary);
}

.photo-ctx-icon--ref {
    background: rgba(16,185,129,0.12);
    color: #10b981;
}

.photo-ctx-icon--del {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
}

.photo-ctx-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.photo-ctx-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

.photo-ctx-item--danger .photo-ctx-label {
    color: #ef4444;
}

.photo-ctx-sub {
    font-size: 0.68rem;
    color: #94a3b8;
    line-height: 1.3;
}

.photo-ctx-divider {
    height: 1px;
    background: rgba(0,0,0,0.06);
    margin: 0.25rem 0.4rem;
}

/* Premium Toast Notifications */
#toast-notification-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    width: calc(100% - 48px);
    pointer-events: none;
}

.toast-notification {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-left: 5px solid var(--primary);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    gap: 0.9rem;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    overflow: hidden;
}

.toast-notification:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 25px 30px -5px rgba(99, 102, 241, 0.12), 0 15px 15px -5px rgba(0, 0, 0, 0.06);
    border-color: rgba(99, 102, 241, 0.3);
}

.toast-notification.toast-success {
    border-left-color: #10b981;
}
.toast-notification.toast-error {
    border-left-color: #ef4444;
}
.toast-notification.toast-info {
    border-left-color: #0ea5e9;
}
.toast-notification.toast-warning {
    border-left-color: #f59e0b;
}

.toast-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}
.toast-error .toast-icon {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}
.toast-info .toast-icon {
    background: rgba(14, 165, 233, 0.12);
    color: #0ea5e9;
}
.toast-warning .toast-icon {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.toast-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.toast-message {
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast-close {
    font-size: 1.1rem;
    color: #94a3b8;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    color: #475569;
    background: rgba(0, 0, 0, 0.05);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%) translateY(0);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* --- Notification Dropdown Animations & Item Layouts --- */
.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-glass);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    align-items: flex-start;
    position: relative;
    text-decoration: none;
    text-align: left;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.notification-item.unread {
    background: rgba(99, 102, 241, 0.08);
}

.notification-item.unread:hover {
    background: rgba(99, 102, 241, 0.12);
}

.notification-icon-wrapper {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.notification-item.unread .notification-icon-wrapper {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

.notification-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.notification-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
}

.notification-message {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.notification-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 0.15rem;
}

.notification-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

#notification-list::-webkit-scrollbar {
    width: 6px;
}

#notification-list::-webkit-scrollbar-track {
    background: transparent;
}

#notification-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
}
