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

body {
    background: #0d0d0d;
    color: #fff;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --back-bar-h: 41px;
}

/* ── Back bar ─────────────────────────────────────────────── */

.cam-back {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.cam-back-link {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
}

.cam-back-link:hover {
    color: #fff;
}

/* ── Pre-camera info screen ───────────────────────────────── */

.camera-info {
    height: calc(100dvh - var(--back-bar-h));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 60px 24px;
    text-align: center;
}

.camera-info h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.camera-info p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
}

/* ── Video container ──────────────────────────────────────── */

.video-container {
    position: relative;
    width: 100%;
    height: calc(100dvh - var(--back-bar-h));
    background: #000;
}

#video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

#canvas {
    display: none;
}

/* ── Camera guide reticle ─────────────────────────────────── */

.camera-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-reticle {
    width: 80%;
    height: 75%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

/* ── Floating controls overlay ────────────────────────────── */

.controls-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 20px 24px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
}

/* ── Below-video area ─────────────────────────────────────── */

.below-video {
    padding: 16px;
    background: #141414;
}

.photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.photo-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220, 53, 69, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-remove:hover {
    background: rgba(220, 53, 69, 1);
}

.controls-upload {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    padding-top: 4px;
}

/* ── Message ──────────────────────────────────────────────── */

.message {
    margin: 12px 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    display: none;
}

.message.success {
    background: rgba(40, 167, 69, 0.15);
    color: #6fcf97;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.message.error {
    background: rgba(220, 53, 69, 0.15);
    color: #ff8090;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Overlay buttons — translucent, frosted */
.btn-capture {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    border: 1.5px solid rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 13px 28px;
}

.btn-capture:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-switch {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 13px 18px;
}

.btn-switch:hover {
    background: rgba(255, 255, 255, 0.22);
}

.btn-stop {
    background: rgba(220, 53, 69, 0.4);
    color: white;
    border: 1.5px solid rgba(220, 53, 69, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 13px 18px;
}

.btn-stop:hover {
    background: rgba(220, 53, 69, 0.65);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ── Loading spinner ──────────────────────────────────────── */

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none !important;
}
