/**
 * Face Shape Detector v3.1 — Premium Optical UI
 * Multi-step guided flow with face validation
 * Fixes: Bug 1,2,7,8 + UI improvements A–G
 */

/* Google Fonts loaded via wp_enqueue_style in PHP (no render-blocking @import) */

:root {
    --fsd-primary: #1a6b4a;
    --fsd-primary-hover: #145a3d;
    --fsd-primary-soft: #edf7f2;
    --fsd-primary-glow: rgba(26,107,74,0.12);
    --fsd-gold: #b8965a;
    --fsd-gold-soft: #faf5ec;
    --fsd-red: #c0392b;
    --fsd-red-soft: #fdf0ef;
    --fsd-text: #1c2024;
    --fsd-text-mid: #4a5568;
    --fsd-text-light: #8896a6;
    --fsd-bg: #ffffff;
    --fsd-bg-subtle: #f8fafb;
    --fsd-border: #e8ecf0;
    --fsd-radius: 16px;
    --fsd-radius-sm: 10px;
    --fsd-shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --fsd-shadow-md: 0 8px 30px rgba(0,0,0,0.08);
    --fsd-shadow-lg: 0 24px 60px rgba(0,0,0,0.12);
    --fsd-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fsd-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================================
   VISIBILITY + STEP TRANSITIONS (UI-D: smooth transitions)
   ========================================================================= */

/* Step visibility control */
.fsd-hidden { display: none !important; }

/* Step transition animations */
.fsd-step {
    animation: fsd-stepFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fsd-stepFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* =========================================================================
   BUTTON STYLES (default, minimal, banner, inline)
   ========================================================================= */

.fsd-scan-wrapper { font-family: var(--fsd-font); }

.fsd-style-default { margin: 20px 0; padding: 20px 0; border-top: 1px solid var(--fsd-border); }

.fsd-scan-button {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 14px 28px; background: var(--fsd-primary); color: #fff;
    border: none; border-radius: var(--fsd-radius-sm);
    font-family: var(--fsd-font); font-size: 15px; font-weight: 600;
    cursor: pointer; transition: all var(--fsd-transition);
    letter-spacing: 0.01em; position: relative; overflow: hidden;
}
.fsd-scan-button::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%); pointer-events: none; }
.fsd-scan-button:hover { background: var(--fsd-primary-hover); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(26,107,74,0.25); }
.fsd-scan-button:active { transform: translateY(0); }
.fsd-btn-icon { display: flex; align-items: center; opacity: 0.9; }
.fsd-btn-icon svg { width: 20px; height: 20px; }
.fsd-btn-arrow { opacity: 0.6; font-size: 18px; margin-left: 4px; transition: transform var(--fsd-transition); }
.fsd-scan-button:hover .fsd-btn-arrow { transform: translateX(3px); opacity: 1; }
.fsd-scan-hint { margin: 10px 0 0; font-size: 12px; font-family: var(--fsd-font); color: var(--fsd-text-light); letter-spacing: 0.02em; }

.fsd-style-minimal { display: inline-block; }
.fsd-scan-button-minimal {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 12px 24px; background: transparent; color: var(--fsd-primary);
    border: 2px solid var(--fsd-primary); border-radius: var(--fsd-radius-sm);
    font-family: var(--fsd-font); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all var(--fsd-transition);
}
.fsd-scan-button-minimal:hover { background: var(--fsd-primary-soft); transform: translateY(-1px); }

.fsd-style-banner {
    background: linear-gradient(135deg, var(--fsd-primary-soft) 0%, #f2faf6 100%);
    border: 1px solid rgba(26,107,74,0.1); border-radius: var(--fsd-radius);
    padding: 28px 32px;
}
.fsd-banner-content { display: flex; align-items: center; gap: 20px; }
.fsd-banner-icon { color: var(--fsd-primary); flex-shrink: 0; }
.fsd-banner-icon svg { width: 40px; height: 40px; }
.fsd-banner-text { flex: 1; }
.fsd-banner-title { font-family: var(--fsd-font); font-size: 18px; font-weight: 700; color: var(--fsd-text); margin: 0 0 4px; }
.fsd-banner-desc { font-family: var(--fsd-font); font-size: 13px; color: var(--fsd-text-mid); margin: 0 0 12px; line-height: 1.5; }
.fsd-banner-badges { display: flex; gap: 12px; }
.fsd-banner-badge-item { display: flex; align-items: center; gap: 4px; font-family: var(--fsd-font); font-size: 11px; font-weight: 600; color: var(--fsd-primary); }
.fsd-banner-badge-item svg { width: 14px; height: 14px; }

/* Bug 8: Banner button style */
.fsd-scan-button-banner {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 12px 24px; background: var(--fsd-primary); color: #fff;
    border: none; border-radius: var(--fsd-radius-sm);
    font-family: var(--fsd-font); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all var(--fsd-transition);
    white-space: nowrap; position: relative; overflow: hidden;
}
.fsd-scan-button-banner::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%); pointer-events: none; }
.fsd-scan-button-banner:hover { background: var(--fsd-primary-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,107,74,0.25); }

.fsd-style-inline { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--fsd-bg-subtle); border: 1px solid var(--fsd-border); border-radius: var(--fsd-radius-sm); }
.fsd-inline-icon { color: var(--fsd-primary); display: flex; flex-shrink: 0; }
.fsd-inline-icon svg { width: 20px; height: 20px; }
.fsd-inline-title { flex: 1; font-family: var(--fsd-font); font-size: 14px; font-weight: 600; color: var(--fsd-text); }
.fsd-scan-button-inline { padding: 8px 18px; background: var(--fsd-primary); color: #fff; border: none; border-radius: 8px; font-family: var(--fsd-font); font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--fsd-transition); white-space: nowrap; }
.fsd-scan-button-inline:hover { background: var(--fsd-primary-hover); transform: translateY(-1px); }

/* =========================================================================
   MODAL — v3.1 Dark full-screen on mobile
   ========================================================================= */

.fsd-modal {
    position: fixed; inset: 0; z-index: 999999;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; font-family: var(--fsd-font);
}

.fsd-modal-overlay {
    position: absolute; inset: 0;
    background: rgba(10,12,15,0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.fsd-modal-content {
    position: relative; background: var(--fsd-bg);
    border-radius: 20px; box-shadow: var(--fsd-shadow-lg);
    width: 100%; max-width: 640px; max-height: 92vh;
    overflow-y: auto; padding: 36px;
    animation: fsd-modalIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fsd-modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

.fsd-modal-close {
    position: absolute; top: 16px; right: 20px;
    background: var(--fsd-bg-subtle); border: 1px solid var(--fsd-border);
    border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--fsd-text-mid); transition: all var(--fsd-transition);
    z-index: 10; padding: 0; line-height: 1;
}
.fsd-modal-close svg { display: block; width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; }
.fsd-modal-close:hover { background: #fff; color: var(--fsd-text); box-shadow: var(--fsd-shadow-sm); }

/* Dark mode close button for camera steps */
.fsd-modal-dark .fsd-modal-close {
    background: rgba(0,0,0,0.4); border-color: rgba(255,255,255,0.15); color: rgba(255,255,255,0.8);
}
.fsd-modal-dark .fsd-modal-close:hover {
    background: rgba(0,0,0,0.6); color: #fff; box-shadow: none;
}

.fsd-modal-header { text-align: center; margin-bottom: 20px; }

.fsd-modal-badge {
    display: inline-block; padding: 4px 14px;
    background: var(--fsd-primary-soft); color: var(--fsd-primary);
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; border-radius: 20px; margin-bottom: 12px;
}
.fsd-badge-success { background: #e6f9ed; color: #1a8a4a; }

.fsd-modal-title { font-size: 22px; font-weight: 700; color: var(--fsd-text); margin: 0 0 6px; line-height: 1.3; }
.fsd-modal-subtitle { font-size: 14px; color: var(--fsd-text-mid); margin: 0; line-height: 1.5; }

/* =========================================================================
   STEP 1: CONSENT SCREEN
   ========================================================================= */

.fsd-consent-screen { text-align: center; padding: 10px 0; }

.fsd-consent-icon {
    width: 72px; height: 72px; margin: 0 auto 20px;
    color: var(--fsd-primary); opacity: 0.85;
}
.fsd-consent-icon svg { width: 100%; height: 100%; }

.fsd-consent-title {
    font-size: 22px; font-weight: 700; color: var(--fsd-text);
    margin: 0 0 8px; font-family: var(--fsd-font); line-height: 1.3;
}

.fsd-consent-subtitle {
    font-size: 14px; color: var(--fsd-text-mid); margin: 0 0 28px;
    line-height: 1.6; max-width: 380px; margin-left: auto; margin-right: auto;
}

.fsd-consent-features {
    display: flex; flex-direction: column; gap: 12px;
    max-width: 340px; margin: 0 auto 32px; text-align: left;
}

.fsd-consent-feature {
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; color: var(--fsd-text); font-family: var(--fsd-font);
}

.fsd-consent-check {
    width: 28px; height: 28px; flex-shrink: 0;
    background: #e6f9ed; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #15803d;
}
.fsd-consent-check svg { width: 16px; height: 16px; }

.fsd-consent-actions { display: flex; flex-direction: column; gap: 10px; max-width: 300px; margin: 0 auto; }

/* =========================================================================
   STEP 2: PREPARATION SCREEN
   ========================================================================= */

.fsd-prepare-screen { position: relative; border-radius: 14px; overflow: hidden; min-height: 480px; background: #0a0c0f; }

.fsd-camera-bg-container {
    position: absolute; inset: 0; z-index: 0;
}
.fsd-camera-bg-container video {
    width: 100%; height: 100%; object-fit: cover;
    transform: scaleX(-1); filter: brightness(0.3) blur(3px);
}

.fsd-prepare-overlay {
    position: relative; z-index: 1;
    padding: 40px 24px; text-align: center;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 480px;
}

.fsd-prepare-title {
    font-size: 20px; font-weight: 700; color: #fff;
    letter-spacing: 0.1em; text-transform: uppercase;
    margin: 0 0 28px; font-family: var(--fsd-font);
}

.fsd-prepare-checklist {
    display: flex; flex-direction: column; gap: 14px;
    max-width: 340px; margin: 0 auto 28px; text-align: left;
}

.fsd-prepare-item {
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; color: rgba(255,255,255,0.9); font-family: var(--fsd-font);
}

.fsd-prepare-icon {
    width: 24px; height: 24px; flex-shrink: 0;
    background: rgba(46,204,113,0.2); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #2ecc71;
}
.fsd-prepare-icon svg { width: 14px; height: 14px; }

.fsd-prepare-guides {
    display: flex; gap: 32px; justify-content: center;
    margin: 0 0 28px;
}

.fsd-prepare-guide {
    position: relative; width: 56px; color: rgba(255,255,255,0.5);
}
.fsd-prepare-guide svg { width: 100%; }

.fsd-guide-badge {
    position: absolute; top: -6px; left: -6px;
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 800; line-height: 1;
}
.fsd-guide-bad { background: #e74c3c; color: #fff; }
.fsd-guide-good { background: #2ecc71; color: #fff; }

/* =========================================================================
   STEP 3: ACTIVE SCANNING
   ========================================================================= */

.fsd-scan-screen { position: relative; }

.fsd-camera-container {
    position: relative; width: 100%; aspect-ratio: 4/3;
    border-radius: 14px; overflow: hidden; background: #0a0c0f;
}

.fsd-camera-corner {
    position: absolute; width: 24px; height: 24px;
    border-color: rgba(255,255,255,0.5); border-style: solid;
    border-width: 0; z-index: 4; pointer-events: none;
}
.fsd-corner-tl { top: 12px; left: 12px; border-top-width: 2.5px; border-left-width: 2.5px; border-radius: 4px 0 0 0; }
.fsd-corner-tr { top: 12px; right: 12px; border-top-width: 2.5px; border-right-width: 2.5px; border-radius: 0 4px 0 0; }
.fsd-corner-bl { bottom: 12px; left: 12px; border-bottom-width: 2.5px; border-left-width: 2.5px; border-radius: 0 0 0 4px; }
.fsd-corner-br { bottom: 12px; right: 12px; border-bottom-width: 2.5px; border-right-width: 2.5px; border-radius: 0 0 4px 0; }

#fsd-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#fsd-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; }
#fsd-snapshot-canvas { position: absolute; pointer-events: none; opacity: 0; width: 0; height: 0; }

/* ── Face Guide Oval with dynamic states ── */
.fsd-face-guide {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 3; pointer-events: none;
    transition: opacity 0.3s;
}
.fsd-face-guide > svg:first-child { width: 48%; max-width: 180px; transition: all 0.4s ease; }

/* State: no-face (default white dashed) */
.fsd-face-guide[data-state="no-face"] > svg:first-child ellipse {
    stroke: rgba(255,255,255,0.4); stroke-dasharray: 8,6;
}

/* State: detected but not centered (yellow) */
.fsd-face-guide[data-state="detected"] > svg:first-child ellipse {
    stroke: #f1c40f; stroke-dasharray: 8,6; stroke-width: 2.5;
}

/* State: centered and stable (green solid) */
.fsd-face-guide[data-state="centered"] > svg:first-child ellipse {
    stroke: #2ecc71; stroke-dasharray: none; stroke-width: 3;
    animation: fsd-guide-pulse 1.5s ease-in-out infinite;
}

/* State: moving (orange) */
.fsd-face-guide[data-state="moving"] > svg:first-child ellipse {
    stroke: #e67e22; stroke-dasharray: 6,4; stroke-width: 2.5;
}

/* State: scanning (green pulsing) */
.fsd-face-guide[data-state="scanning"] > svg:first-child ellipse {
    stroke: #2ecc71; stroke-dasharray: none; stroke-width: 3;
    animation: fsd-guide-scan-pulse 0.8s ease-in-out infinite;
}

@keyframes fsd-guide-pulse {
    0%, 100% { stroke-opacity: 0.8; }
    50% { stroke-opacity: 0.4; }
}

@keyframes fsd-guide-scan-pulse {
    0%, 100% { stroke-opacity: 1; stroke: #2ecc71; }
    50% { stroke-opacity: 0.6; stroke: #27ae60; }
}

/* ── Progress ring (UI-A: replaces bottom progress bar) ── */
.fsd-progress-ring {
    position: absolute; inset: 0;
    width: 48%; max-width: 180px;
    margin: auto;
    pointer-events: none;
    transform: rotate(-90deg);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.fsd-progress-ring.fsd-ring-active {
    opacity: 1;
}
.fsd-progress-ring ellipse {
    transition: stroke-dashoffset 0.15s linear;
    filter: drop-shadow(0 0 6px rgba(46,204,113,0.5));
}

/* ── Scanning line animation (UI-A) ── */
.fsd-scan-line {
    position: absolute;
    left: 15%; right: 15%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(46,204,113,0.8) 40%, rgba(46,204,113,1) 50%, rgba(46,204,113,0.8) 60%, transparent 100%);
    z-index: 4;
    pointer-events: none;
    box-shadow: 0 0 12px rgba(46,204,113,0.6), 0 0 4px rgba(46,204,113,0.3);
    top: 20%;
}
.fsd-scan-line.fsd-scan-line-active {
    animation: fsd-scanLine 2.2s ease-in-out infinite;
}
@keyframes fsd-scanLine {
    0% { top: 18%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 78%; opacity: 0; }
}

/* ── Scan banner (NE BOUGEZ PAS) ── */
.fsd-scan-banner {
    position: absolute; top: 0; left: 0; right: 0;
    z-index: 6; padding: 14px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
    text-align: center;
    animation: fsd-stepFadeIn 0.2s ease;
}

.fsd-scan-banner span {
    font-family: var(--fsd-font); font-size: 16px; font-weight: 700;
    color: #fff; letter-spacing: 0.12em; text-transform: uppercase;
}

/* ── Toast notification (Bug 6) ── */
.fsd-toast {
    position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
    z-index: 8; padding: 10px 22px;
    background: rgba(0,0,0,0.75); border-radius: 24px;
    text-align: center;
    animation: fsd-toastIn 0.3s ease;
}
.fsd-toast span {
    font-family: var(--fsd-font); font-size: 13px; font-weight: 500;
    color: rgba(255,255,255,0.95); white-space: nowrap;
}
@keyframes fsd-toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Guide status text ── */
.fsd-guide-status {
    position: absolute; bottom: 50px; left: 0; right: 0;
    text-align: center; z-index: 5; pointer-events: none;
}

.fsd-guide-status span {
    display: inline-block; padding: 6px 16px;
    background: rgba(0,0,0,0.55); border-radius: 20px;
    font-family: var(--fsd-font); font-size: 13px; font-weight: 500;
    color: rgba(255,255,255,0.9);
}

/* ── Loading (UI-E: enhanced) ── */
.fsd-loading-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(10,12,15,0.88); z-index: 10;
    animation: fsd-stepFadeIn 0.3s ease;
}
.fsd-loading-overlay p {
    color: rgba(255,255,255,0.8); font-size: 14px; margin-top: 18px;
    font-family: var(--fsd-font); font-weight: 500; letter-spacing: 0.02em;
}

.fsd-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: #2ecc71; border-radius: 50%;
    animation: fsd-spin 0.7s linear infinite;
}
@keyframes fsd-spin { to { transform: rotate(360deg); } }

/* ── Progress bar (legacy, hidden by default — replaced by ring) ── */
.fsd-scan-progress {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 0; z-index: 5;
}

.fsd-progress-bar {
    width: 100%; height: 4px; background: rgba(255,255,255,0.12);
    overflow: hidden;
}

.fsd-progress-fill {
    height: 100%; background: #2ecc71; width: 0%;
    box-shadow: 0 0 10px rgba(46,204,113,0.5);
}

/* =========================================================================
   SHARED BUTTON STYLES
   ========================================================================= */

.fsd-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px; border-radius: var(--fsd-radius-sm);
    font-family: var(--fsd-font); font-size: 14px; font-weight: 600;
    cursor: pointer; border: none; transition: all var(--fsd-transition);
}
.fsd-btn svg { flex-shrink: 0; }

.fsd-btn-primary { background: var(--fsd-primary); color: #fff; }
.fsd-btn-primary:hover { background: var(--fsd-primary-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,107,74,0.2); }

.fsd-btn-secondary { background: var(--fsd-bg-subtle); color: var(--fsd-text-mid); border: 1px solid var(--fsd-border); }
.fsd-btn-secondary:hover { background: #fff; color: var(--fsd-text); box-shadow: var(--fsd-shadow-sm); }

.fsd-btn-ghost { background: transparent; color: var(--fsd-text-light); font-weight: 500; }
.fsd-btn-ghost:hover { color: var(--fsd-text); }

.fsd-btn-lg { padding: 14px 32px; font-size: 15px; border-radius: 12px; width: 100%; }

/* Bug 1: White button for dark backgrounds */
.fsd-btn-white {
    background: #fff; color: var(--fsd-primary); font-weight: 700;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.fsd-btn-white:hover { background: #f0f0f0; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.25); }

/* Bug 2: Back button base styling for desktop */
.fsd-back-btn {
    position: absolute; top: 16px; left: 20px;
    background: var(--fsd-bg-subtle); border: 1px solid var(--fsd-border);
    border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--fsd-text-mid); transition: all var(--fsd-transition);
    z-index: 10; padding: 0; line-height: 1;
}
.fsd-back-btn svg { display: block; width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; }
.fsd-back-btn:hover { background: #fff; color: var(--fsd-text); box-shadow: var(--fsd-shadow-sm); }

/* =========================================================================
   CAMERA ERROR
   ========================================================================= */

.fsd-camera-error { text-align: center; padding: 24px 16px; }
.fsd-error-icon { font-size: 36px; margin-bottom: 12px; }
.fsd-camera-error h4 { font-size: 17px; font-weight: 700; color: var(--fsd-text); margin: 0 0 8px; font-family: var(--fsd-font); }
.fsd-camera-error p { font-size: 14px; color: var(--fsd-text-mid); margin: 0 0 16px; font-family: var(--fsd-font); }
.fsd-error-tips { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; max-width: 360px; margin-left: auto; margin-right: auto; }
.fsd-error-tips li { padding: 6px 0 6px 24px; font-size: 13px; color: var(--fsd-text); font-family: var(--fsd-font); position: relative; line-height: 1.5; }
.fsd-error-tips li::before { content: '→'; position: absolute; left: 4px; color: var(--fsd-primary); font-weight: 700; }

/* =========================================================================
   RESULTS v3.1
   ========================================================================= */

.fsd-result-content { text-align: center; padding: 44px 0 16px; }

.fsd-compat-content { padding: 44px 0 0; }

.fsd-r { text-align: center; padding: 4px 0 0; position: relative; overflow: hidden; }

/* Badge */
.fsd-r-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 24px; border-radius: 100px;
    font-family: var(--fsd-font); font-size: 16px; font-weight: 700;
    margin-bottom: 18px; letter-spacing: -0.01em;
}
.fsd-r-badge-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    font-size: 13px; font-weight: 800; line-height: 1;
}
.fsd-badge-good { background: linear-gradient(135deg, #e8f9ef 0%, #d0f0de 100%); color: #15803d; box-shadow: 0 2px 12px rgba(21,128,61,0.12); }
.fsd-badge-good .fsd-r-badge-icon { background: #15803d; color: #fff; }
.fsd-badge-ok { background: linear-gradient(135deg, #fef9ec 0%, #fdf0d5 100%); color: #92400e; box-shadow: 0 2px 12px rgba(146,64,14,0.08); }
.fsd-badge-ok .fsd-r-badge-icon { background: #d97706; color: #fff; }
.fsd-badge-bad { background: linear-gradient(135deg, #fef2f2 0%, #fde8e8 100%); color: #991b1b; box-shadow: 0 2px 12px rgba(153,27,27,0.08); }
.fsd-badge-bad .fsd-r-badge-icon { background: #dc2626; color: #fff; }

/* Product Card */
.fsd-r-product {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px; background: #fff; border: 1px solid var(--fsd-border);
    border-radius: 14px; margin: 0 auto 16px; max-width: 380px; text-align: left;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.fsd-r-product-img-wrap { width: 56px; height: 56px; flex-shrink: 0; background: var(--fsd-bg-subtle); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.fsd-r-product-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fsd-r-product-details { min-width: 0; flex: 1; }
.fsd-r-product-name { display: block; font-size: 13px; font-weight: 600; color: var(--fsd-text); font-family: var(--fsd-font); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fsd-r-product-price { display: block; font-size: 15px; font-weight: 700; color: var(--fsd-primary); font-family: var(--fsd-font); margin-top: 2px; }
.fsd-r-product-price del { color: var(--fsd-text-light); font-weight: 400; font-size: 12px; }
.fsd-r-product-price ins { text-decoration: none; }

/* Message */
.fsd-r-message { margin-bottom: 18px; }
.fsd-r-message-main { font-size: 15px; font-weight: 600; color: var(--fsd-text); margin: 0 0 2px; line-height: 1.5; font-family: var(--fsd-font); }
.fsd-r-message-sub { font-size: 13px; color: var(--fsd-text-light); margin: 0; line-height: 1.5; font-family: var(--fsd-font); }

/* Shape Card */
.fsd-r-shape-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; background: linear-gradient(135deg, var(--fsd-primary-soft) 0%, #f2faf6 100%);
    border: 1px solid rgba(26,107,74,0.1); border-radius: 14px;
    margin: 0 auto 22px; max-width: 380px; text-align: left;
}
.fsd-r-shape-visual { width: 44px; height: 44px; flex-shrink: 0; background: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); padding: 6px; overflow: hidden; }
.fsd-r-shape-icon { width: 28px; height: 36px; color: var(--fsd-primary); }
.fsd-r-shape-icon svg { width: 100%; height: 100%; }
.fsd-r-shape-text { flex-shrink: 0; }
.fsd-r-shape-eyebrow { display: block; font-size: 10px; font-weight: 700; color: var(--fsd-text-light); font-family: var(--fsd-font); text-transform: uppercase; letter-spacing: 0.08em; }
.fsd-r-shape-name { display: block; font-size: 17px; font-weight: 700; color: var(--fsd-primary); font-family: var(--fsd-font); line-height: 1.3; }
.fsd-r-shape-tip { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 6px; padding-left: 12px; border-left: 1px solid rgba(26,107,74,0.12); margin-left: auto; }
.fsd-r-shape-tip-icon { font-size: 14px; flex-shrink: 0; line-height: 1.4; }
.fsd-r-shape-tip-text { font-size: 11px; color: var(--fsd-text-mid); font-family: var(--fsd-font); line-height: 1.45; }

/* UI-B: Face snapshot in results */
.fsd-r-shape-visual.fsd-has-snapshot {
    width: 52px; height: 52px; padding: 0; border-radius: 50%;
    border: 2px solid var(--fsd-primary);
}
.fsd-r-shape-visual.fsd-has-snapshot img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.fsd-r-standalone-snapshot {
    width: 100px; height: 100px; margin: 0 auto 14px;
    border-radius: 50%; overflow: hidden;
    border: 3px solid var(--fsd-primary);
    box-shadow: 0 4px 20px rgba(26,107,74,0.15);
}
.fsd-r-standalone-snapshot img {
    width: 100%; height: 100%; object-fit: cover;
}

/* v3: Confidence indicator */
.fsd-r-confidence {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; background: #fef9ec; border: 1px solid #fde68a;
    border-radius: 10px; margin: 0 auto 18px; max-width: 380px;
    font-size: 13px; color: #92400e; font-family: var(--fsd-font); line-height: 1.4;
}
.fsd-r-confidence-icon { font-size: 15px; flex-shrink: 0; }

/* CTA Buttons */
.fsd-r-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-width: 380px; margin-left: auto; margin-right: auto; }
.fsd-r-cta {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 14px 24px; border-radius: 12px; font-family: var(--fsd-font);
    font-size: 15px; font-weight: 700; cursor: pointer; border: none;
    transition: all 0.2s ease; text-decoration: none; line-height: 1;
}
.fsd-r-cta svg { flex-shrink: 0; }
.fsd-r-cta-primary { background: var(--fsd-primary); color: #fff; box-shadow: 0 2px 8px rgba(26,107,74,0.2); }
.fsd-r-cta-primary:hover { background: var(--fsd-primary-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,107,74,0.28); color: #fff; }
.fsd-r-cta-glow { box-shadow: 0 2px 8px rgba(26,107,74,0.2), 0 0 0 3px rgba(26,107,74,0.08); animation: fsd-glow-pulse 2s ease-in-out infinite; }
@keyframes fsd-glow-pulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(26,107,74,0.2), 0 0 0 3px rgba(26,107,74,0.08); }
    50% { box-shadow: 0 4px 20px rgba(26,107,74,0.3), 0 0 0 6px rgba(26,107,74,0.06); }
}
.fsd-r-cta-outline { background: #fff; color: var(--fsd-text); border: 1.5px solid var(--fsd-border); }
.fsd-r-cta-outline:hover { border-color: var(--fsd-primary); color: var(--fsd-primary); background: var(--fsd-primary-soft); }
.fsd-r-cta-ghost { background: transparent; color: var(--fsd-text-light); padding: 10px 24px; font-weight: 600; font-size: 13px; }
.fsd-r-cta-ghost:hover { color: var(--fsd-text); }

/* Footer links */
.fsd-r-footer { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; }
.fsd-r-link { background: none; border: none; color: var(--fsd-text-light); font-size: 12px; font-family: var(--fsd-font); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; transition: color 0.2s; }
.fsd-r-link:hover { color: var(--fsd-primary); }
.fsd-r-sep { color: var(--fsd-border); font-size: 12px; }

/* Disclaimer */
.fsd-r-disclaimer { font-size: 11px; color: var(--fsd-text-light); margin: 0; padding-top: 12px; border-top: 1px solid var(--fsd-border); font-family: var(--fsd-font); line-height: 1.5; text-align: center; opacity: 0.7; }

/* Standalone Result */
.fsd-r-standalone-header { margin-bottom: 12px; }
.fsd-r-standalone-shape { margin-bottom: 20px; }
.fsd-r-standalone-icon { width: 64px; height: 80px; margin: 0 auto 10px; color: var(--fsd-primary); }
.fsd-r-standalone-icon svg { width: 100%; height: 100%; }
.fsd-r-standalone-name { font-size: 26px; font-weight: 700; color: var(--fsd-primary); margin: 0 0 4px; font-family: var(--fsd-font); }
.fsd-r-standalone-desc { font-size: 14px; color: var(--fsd-text-mid); margin: 0; font-family: var(--fsd-font); }

.fsd-r-tips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; margin-bottom: 20px; max-width: 400px; margin-left: auto; margin-right: auto; }
.fsd-r-tip-card { padding: 14px; border-radius: 12px; }
.fsd-r-tip-rec { background: var(--fsd-primary-soft); }
.fsd-r-tip-advice { background: var(--fsd-gold-soft); }
.fsd-r-tip-title { display: block; font-size: 12px; font-weight: 700; font-family: var(--fsd-font); margin-bottom: 6px; }
.fsd-r-tip-rec .fsd-r-tip-title { color: var(--fsd-primary); }
.fsd-r-tip-advice .fsd-r-tip-title { color: #7a6a3a; }
.fsd-r-tip-body { display: block; font-size: 13px; color: var(--fsd-text); font-family: var(--fsd-font); line-height: 1.5; }

/* UI-C: Frame shape recommendation icons for standalone results */
.fsd-frame-shapes-grid {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
    margin: 0 auto 20px; max-width: 420px;
}
.fsd-frame-shape-card {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 14px; background: var(--fsd-primary-soft);
    border: 1px solid rgba(26,107,74,0.1); border-radius: 12px;
    min-width: 90px; flex: 1; max-width: 120px;
    cursor: pointer; transition: all var(--fsd-transition);
    text-decoration: none; color: inherit;
}
.fsd-frame-shape-card:hover {
    border-color: var(--fsd-primary); background: #fff;
    transform: translateY(-2px); box-shadow: 0 4px 16px rgba(26,107,74,0.12);
}
.fsd-frame-shape-card svg {
    width: 40px; height: 24px; color: var(--fsd-primary); opacity: 0.8;
}
.fsd-frame-shape-card span {
    font-size: 11px; font-weight: 600; color: var(--fsd-text); font-family: var(--fsd-font);
    text-align: center; line-height: 1.3;
}

/* Confetti */
.fsd-confetti { position: absolute; top: -10px; width: 8px; height: 8px; border-radius: 2px; animation: fsd-confetti-fall linear forwards; pointer-events: none; z-index: 5; opacity: 0.85; }
@keyframes fsd-confetti-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(350px) rotate(720deg); opacity: 0; }
}

/* =========================================================================
   COMPATIBILITY GRID
   ========================================================================= */

.fsd-compat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.fsd-compat-card { position: relative; background: var(--fsd-bg); border: 1px solid var(--fsd-border); border-radius: var(--fsd-radius-sm); padding: 18px 14px; text-align: center; transition: all var(--fsd-transition); overflow: hidden; }
.fsd-compat-card-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.fsd-compat-good .fsd-compat-card-bar { background: var(--fsd-primary); }
.fsd-compat-ok .fsd-compat-card-bar { background: var(--fsd-gold); }
.fsd-compat-bad .fsd-compat-card-bar { background: var(--fsd-red); }
.fsd-compat-highlight { border-color: var(--fsd-primary); background: var(--fsd-primary-soft); box-shadow: 0 0 0 3px var(--fsd-primary-glow); }
.fsd-compat-card-icon { width: 36px; height: 44px; margin: 0 auto 8px; color: var(--fsd-text-light); }
.fsd-compat-highlight .fsd-compat-card-icon { color: var(--fsd-primary); }
.fsd-compat-card-icon svg { width: 100%; height: 100%; }
.fsd-compat-card-title { font-size: 13px; font-weight: 700; margin: 0 0 4px; color: var(--fsd-text); }
.fsd-compat-card-desc { font-size: 11px; color: var(--fsd-text-light); margin: 0 0 10px; line-height: 1.4; }
.fsd-compat-card-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.fsd-compat-good .fsd-compat-card-badge { background: var(--fsd-primary-soft); color: var(--fsd-primary); }
.fsd-compat-ok .fsd-compat-card-badge { background: var(--fsd-gold-soft); color: #7a6a3a; }
.fsd-compat-bad .fsd-compat-card-badge { background: var(--fsd-red-soft); color: var(--fsd-red); }
.fsd-compat-you { display: block; margin-top: 6px; font-size: 11px; font-weight: 700; color: var(--fsd-primary); }

/* Generic advice */
.fsd-generic-advice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
.fsd-advice-card { background: var(--fsd-primary-soft); border-radius: var(--fsd-radius-sm); padding: 20px; }
.fsd-advice-card h4 { font-size: 14px; font-weight: 700; color: var(--fsd-primary); margin: 0 0 10px; }
.fsd-advice-card ul { list-style: none; padding: 0; margin: 0; }
.fsd-advice-card li { padding: 3px 0; font-size: 13px; color: var(--fsd-text); }
.fsd-advice-card li::before { content: '✓ '; color: var(--fsd-primary); font-weight: 700; }
.fsd-advice-tip { background: var(--fsd-gold-soft); }
.fsd-advice-tip h4 { color: #7a6a3a; }
.fsd-advice-tip p { font-size: 13px; color: var(--fsd-text); margin: 0; line-height: 1.6; }

/* Result actions */
.fsd-result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--fsd-border); }

/* Page highlight */
.fsd-page-highlight { outline: 3px solid var(--fsd-primary) !important; outline-offset: 4px; border-radius: 8px; animation: fsd-pulse-highlight 1.5s ease 3; }
@keyframes fsd-pulse-highlight { 0%,100% { outline-color: var(--fsd-primary); } 50% { outline-color: transparent; } }

/* =========================================================================
   DEBUG PANEL
   ========================================================================= */

.fsd-debug-panel { margin-top: 16px; border: 2px solid #f39c12; border-radius: 8px; background: #fffdf0; overflow: hidden; font-size: 13px; }
.fsd-debug-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; background: #f39c12; color: #fff; font-weight: 700; font-size: 12px; letter-spacing: 0.5px; }
.fsd-debug-toggle { background: rgba(255,255,255,0.3); border: none; color: #fff; width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-weight: 700; font-size: 14px; line-height: 1; }
.fsd-debug-body { padding: 12px 14px; max-height: 400px; overflow-y: auto; }
.fsd-debug-section { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px dashed #e0d9c0; }
.fsd-debug-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.fsd-debug-section h5 { font-size: 12px; font-weight: 700; color: #8a7033; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.fsd-debug-data { color: #333; line-height: 1.5; }
.fsd-debug-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: 'Courier New', monospace; }
.fsd-debug-table td { padding: 3px 6px; border-bottom: 1px solid #f0ead8; }
.fsd-debug-table td:first-child { color: #666; white-space: nowrap; }
.fsd-debug-table td:nth-child(2) { text-align: right; color: #222; font-weight: 700; }
.fsd-debug-hint { color: #999; font-size: 11px; font-style: italic; font-family: var(--fsd-font); }
.fsd-debug-score-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; padding: 3px 6px; border-radius: 4px; }
.fsd-debug-score-row.fsd-debug-winner { background: rgba(26,107,74,0.08); border-left: 3px solid var(--fsd-primary); }
.fsd-debug-score-label { width: 100px; font-size: 12px; color: #555; flex-shrink: 0; }
.fsd-debug-winner .fsd-debug-score-label { color: var(--fsd-primary); font-weight: 700; }
.fsd-debug-score-bar-bg { flex: 1; height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.fsd-debug-score-bar { height: 100%; background: var(--fsd-primary); border-radius: 4px; transition: width 0.3s; opacity: 0.5; }
.fsd-debug-winner .fsd-debug-score-bar { opacity: 1; }
.fsd-debug-score-val { width: 24px; text-align: right; font-weight: 700; font-size: 12px; font-family: 'Courier New', monospace; }
.fsd-debug-crown { font-size: 14px; }

/* =========================================================================
   RESPONSIVE — v3.1 Full-screen mobile
   ========================================================================= */

@media (max-width: 768px) {
    .fsd-modal { padding: 0; }

    .fsd-modal-content {
        width: 100%; height: 100%; max-height: 100vh;
        border-radius: 0; padding: 0;
        animation: fsd-modalIn-mobile 0.3s ease;
        display: flex; flex-direction: column;
    }

    @keyframes fsd-modalIn-mobile {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: none; }
    }

    .fsd-modal-close {
        background: rgba(0,0,0,0.3); border: none; color: #fff;
        top: 12px; right: 12px;
    }
    .fsd-modal-close:hover { background: rgba(0,0,0,0.5); color: #fff; }

    .fsd-back-btn {
        background: rgba(0,0,0,0.3); border: none; color: #fff;
        top: 12px; left: 12px;
    }
    .fsd-back-btn:hover { background: rgba(0,0,0,0.5); color: #fff; }

    /* Steps fill entire modal */
    .fsd-step { flex: 1; display: flex; flex-direction: column; }
    .fsd-step.fsd-hidden { display: none !important; }

    /* Consent fills screen */
    .fsd-consent-screen { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px; }

    /* Preparation fills screen */
    .fsd-prepare-screen { flex: 1; min-height: 0; border-radius: 0; }
    .fsd-prepare-overlay { flex: 1; min-height: 0; padding: 60px 20px 32px; }

    /* UI-G: Scan fills screen with ZERO padding */
    .fsd-scan-screen { flex: 1; display: flex; flex-direction: column; }
    .fsd-camera-container { flex: 1; aspect-ratio: unset; border-radius: 0; }

    /* Kill modal content padding during scan step */
    .fsd-modal-content:has(#fsd-step-scan:not(.fsd-hidden)) { padding: 0; }

    /* Results scrollable */
    #fsd-step-result, #fsd-step-compatibility { overflow-y: auto; padding: 20px; }

    .fsd-modal-title { font-size: 18px; }
    .fsd-compat-grid { grid-template-columns: repeat(2, 1fr); }
    .fsd-generic-advice { grid-template-columns: 1fr; }
    .fsd-result-actions { flex-direction: column; }
    .fsd-btn { width: 100%; justify-content: center; }
    .fsd-r-tips { grid-template-columns: 1fr; }
    .fsd-r-shape-card { flex-wrap: wrap; }
    .fsd-r-shape-tip { padding-left: 0; border-left: none; margin-left: 0; padding-top: 10px; border-top: 1px solid rgba(26,107,74,0.1); width: 100%; }
    .fsd-banner-content { flex-direction: column; text-align: center; gap: 16px; }
    .fsd-banner-badges { justify-content: center; flex-wrap: wrap; gap: 10px; }
    .fsd-style-inline { flex-wrap: wrap; }
    .fsd-inline-title { width: 100%; }
    .fsd-consent-title { font-size: 20px; }

    /* Debug panel on mobile */
    .fsd-debug-panel { margin: 10px; }

    /* Frame shape cards tighter on mobile */
    .fsd-frame-shape-card { min-width: 75px; padding: 10px 8px; }
}

@media (max-width: 480px) {
    .fsd-compat-card { padding: 12px 8px; }
    .fsd-compat-card-desc { display: none; }
    .fsd-r-badge { font-size: 14px; padding: 8px 18px; }
    .fsd-r-product { max-width: 100%; }
    .fsd-r-shape-card { max-width: 100%; }
    .fsd-r-actions { max-width: 100%; }
    .fsd-r-confidence { max-width: 100%; }
    .fsd-frame-shapes-grid { max-width: 100%; }
}
