.chat-camera-overlay {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
    background: rgba(12, 12, 13, 0.68);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chat-camera-overlay[hidden],
.chat-camera-dialog [hidden] {
    display: none !important;
}

.chat-camera-dialog {
    width: min(100%, 480px);
    max-height: min(760px, 100%);
    overflow: auto;
    padding: 18px;
    color: var(--text-primary, #f3f0e9);
    background: var(--bg-primary, #292826);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
    animation: chatCameraEnter 180ms ease-out;
}

@keyframes chatCameraEnter {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-camera-header,
.chat-camera-heading,
.chat-camera-actions {
    display: flex;
    align-items: center;
}

.chat-camera-header {
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.chat-camera-heading {
    min-width: 0;
    gap: 11px;
}

.chat-camera-heading-icon,
.chat-camera-close {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    color: var(--text-primary, #f3f0e9);
    background: var(--bg-secondary, rgba(255, 255, 255, 0.04));
}

.chat-camera-heading-icon svg,
.chat-camera-close svg {
    width: 20px;
    height: 20px;
}

.chat-camera-heading h2 {
    margin: 0;
    font-size: 15px;
    line-height: 1.35;
    font-weight: 650;
}

.chat-camera-heading p {
    margin: 3px 0 0;
    color: var(--text-secondary, #a6a39d);
    font-size: 12px;
    line-height: 1.4;
}

.chat-camera-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease;
}

.chat-camera-close:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.chat-camera-stage {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 14px;
    background: #111;
}

.chat-camera-stage video,
.chat-camera-stage img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #111;
}

.chat-camera-stage video[hidden],
.chat-camera-stage img[hidden] {
    display: none !important;
}

.chat-camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
}

.chat-camera-placeholder[hidden] {
    display: none !important;
}

.chat-camera-placeholder svg {
    width: 42px;
    height: 42px;
    opacity: 0.7;
}

.chat-camera-guide {
    position: absolute;
    inset: 10% 8%;
    border: 1px solid rgba(255, 255, 255, 0.52);
    border-radius: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease;
}

.chat-camera-stage.camera-ready .chat-camera-guide {
    opacity: 1;
}

.chat-camera-status {
    min-height: 18px;
    margin: 12px 2px 0;
    color: var(--text-secondary, #a6a39d);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

.chat-camera-fallback {
    display: grid;
    gap: 9px;
    margin: 10px 0 0;
    color: var(--text-secondary, #a6a39d);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.chat-camera-fallback[hidden] {
    display: none !important;
}

.chat-camera-fallback-btn,
.chat-camera-secondary,
.chat-camera-retake,
.chat-camera-confirm {
    min-height: 40px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
    border-radius: 11px;
    padding: 0 14px;
    color: var(--text-primary, #f3f0e9);
    background: var(--bg-secondary, rgba(255, 255, 255, 0.05));
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 140ms ease, transform 140ms ease;
}

.chat-camera-fallback-btn:hover,
.chat-camera-secondary:hover,
.chat-camera-retake:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.1));
}

.chat-camera-actions {
    justify-content: center;
    gap: 10px;
    min-height: 52px;
    margin-top: 14px;
}

.chat-camera-actions .chat-camera-secondary {
    margin-right: auto;
}

.chat-camera-shutter {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    padding: 0;
    border: 2px solid var(--text-primary, #f3f0e9);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: transform 120ms ease, opacity 120ms ease;
}

.chat-camera-shutter:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-camera-shutter:active:not(:disabled) {
    transform: scale(0.96);
}

.chat-camera-shutter:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.chat-camera-shutter-inner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--text-primary, #f3f0e9);
}

.chat-camera-confirm {
    margin-left: auto;
    border-color: var(--accent-color, #475569);
    background: var(--accent-color, #475569);
    color: var(--accent-text, #fff);
}

.chat-camera-confirm:hover {
    filter: brightness(1.08);
}

body.light-mode .chat-camera-overlay {
    background: rgba(30, 28, 25, 0.42);
}

body.light-mode .chat-camera-dialog {
    background: var(--bg-primary, #f3f0e9);
}

@media (max-width: 520px) {
    .chat-camera-overlay {
        align-items: flex-end;
        padding: 12px 12px max(12px, env(safe-area-inset-bottom));
    }

    .chat-camera-dialog {
        max-height: min(90dvh, 760px);
        padding: 15px;
        border-radius: 18px 18px 14px 14px;
    }

    .chat-camera-stage {
        aspect-ratio: 3 / 4;
        max-height: min(52dvh, 430px);
    }

    .chat-camera-actions {
        margin-top: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-camera-dialog,
    .chat-camera-close,
    .chat-camera-guide,
    .chat-camera-shutter,
    .chat-camera-fallback-btn,
    .chat-camera-secondary,
    .chat-camera-retake,
    .chat-camera-confirm {
        animation: none;
        transition: none;
    }
}
