.camera-page {
    padding-bottom: 0 !important;
}

.camera-shell {
    position: relative;
    width: 100%;
    min-height: calc(100vh - var(--header-h) - var(--mobile-nav-h));
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 960px) {
    .camera-shell {
        min-height: 80vh;
        flex-direction: row;
        gap: 0;
    }
}

/* ---------- Stage (video/canvas) ---------- */
.camera-stage {
    position: relative;
    flex: 1;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-video,
.camera-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-video.is-front { transform: scaleX(-1); }

.camera-tint {
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: normal;
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}

.camera-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.85) 100%);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
}

.camera-grain {
    position: absolute;
    inset: -20%;
    pointer-events: none;
    opacity: 0;
    background-repeat: repeat;
    mix-blend-mode: overlay;
    transition: opacity var(--dur-base) var(--ease-out);
}

/* ---------- Top bar ---------- */
.camera-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--space-4) + env(safe-area-inset-top)) var(--space-4) var(--space-4);
    background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
}

.camera-icon-btn {
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.14);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 1.1rem;
}
.camera-icon-btn:active { transform: scale(0.92); }
.camera-icon-btn.is-active { background: var(--accent-grad); border-color: transparent; }

.camera-filter-name {
    position: absolute;
    top: calc(var(--space-6) + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    pointer-events: none;
}

/* ---------- Countdown ---------- */
.camera-countdown {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.25);
}
.camera-countdown.is-active { display: flex; }
.camera-countdown__num {
    font-size: 7rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 4px 24px rgba(0,0,0,0.6);
    animation: countdownPulse 1s var(--ease-out);
}
@keyframes countdownPulse {
    from { transform: scale(1.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ---------- Flash ---------- */
.camera-flash {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}
.camera-flash.is-flashing { animation: flashPop 320ms ease-out; }
@keyframes flashPop {
    0% { opacity: 0.9; }
    100% { opacity: 0; }
}

/* ---------- Bottom bar (mobile) ---------- */
.camera-bottombar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 10;
    padding: var(--space-4) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
    /* Sin degradado grande: cada tarjeta de filtro ya lleva su propio
       fondo sólido (ver .filter-chip), así que aquí no hace falta
       oscurecer media pantalla de cámara para que se lea el texto. */
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.filter-carousel {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    padding-bottom: var(--space-1);
    scrollbar-width: none;
}
.filter-carousel::-webkit-scrollbar { display: none; }

.filter-chip {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 64px;
    padding: 6px 4px 8px;
    border-radius: 16px;
    /* Fondo propio y sólido, para que el texto se lea igual sin importar
       lo clara que sea la escena que esté viendo la cámara en ese momento. */
    background: rgba(10, 10, 14, 0.75);
}

.filter-chip__swatch {
    width: 56px; height: 56px;
    border-radius: 16px;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.25);
    transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.filter-chip.is-active .filter-chip__swatch {
    border-color: #fff;
    transform: scale(1.06);
    box-shadow: 0 0 0 2px var(--accent-solid);
}
.filter-chip.is-active {
    background: rgba(10, 10, 14, 0.9);
}
.filter-chip__label {
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
}
.filter-chip.is-active .filter-chip__label { color: #fff; }

.camera-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.shutter-btn {
    justify-self: center;
    width: 76px; height: 76px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid #fff;
    display: grid;
    place-items: center;
    transition: transform var(--dur-fast) var(--ease-out);
}
.shutter-btn::after {
    content: '';
    width: 60px; height: 60px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--dur-fast) var(--ease-out), border-radius var(--dur-fast);
}
.shutter-btn:active::after { transform: scale(0.82); }
.shutter-btn:active { transform: scale(0.96); }

.camera-side-action { justify-self: center; }

/* ---------- Desktop side panel ---------- */
.camera-panel {
    display: none;
}
@media (min-width: 960px) {
    .camera-panel {
        display: flex;
        flex-direction: column;
        width: 300px;
        flex: none;
        background: var(--bg-2);
        border-left: 1px solid var(--border-subtle);
        padding: var(--space-5);
        gap: var(--space-5);
        overflow-y: auto;
    }
    .camera-bottombar .filter-carousel { display: none; }
}
@media (min-width: 960px) {
    .camera-page-show-panel .camera-bottombar .filter-carousel { display: none; }
}

.camera-panel__title { font-size: var(--fs-h3); }
.camera-panel__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.filter-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: all var(--dur-fast) var(--ease-out);
}
.filter-tile:hover { background: var(--surface-glass); }
.filter-tile.is-active {
    background: var(--surface-glass-strong);
    border-color: var(--accent-solid);
}
.filter-tile__swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    object-fit: cover;
}
.filter-tile__label { font-size: var(--fs-xs); font-weight: 700; }

/* ---------- Permission / error states ---------- */
.camera-state {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-6);
    background: var(--bg-1);
}
.camera-state.is-active { display: flex; }
.camera-state__icon { font-size: 3rem; margin-bottom: var(--space-4); }
.camera-state__title { font-size: var(--fs-h3); margin-bottom: var(--space-2); }
.camera-state__text { color: var(--text-secondary); max-width: 40ch; margin-bottom: var(--space-5); }

/* ---------- Review / after capture ---------- */
.camera-review-actions {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 10;
    padding: var(--space-5) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
    display: none;
    gap: var(--space-3);
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
}
.camera-review-actions.is-active { display: flex; }
.camera-review-actions .btn { flex: 1; }

/* ---------- Pixelar zona ---------- */
.pixelate-overlay {
    position: absolute;
    inset: 0;
    z-index: 11;
    display: none;
    touch-action: none;
}
.pixelate-overlay.is-active {
    display: block;
    cursor: crosshair;
}
.pixelate-overlay__rect {
    position: absolute;
    border: 2px dashed #fff;
    background: rgba(255,255,255,0.15);
    pointer-events: none;
}

.pixelate-toolbar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 10;
    padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
    display: none;
    gap: var(--space-3);
    justify-content: center;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
}
.pixelate-toolbar.is-active { display: flex; }
.pixelate-toolbar #btn-pixelate-toggle.is-active {
    background: var(--accent-grad);
    color: #fff;
    border-color: transparent;
}

/* ---------- Post-capture filter chooser ---------- */
.result-panel {
    display: none;
    padding: var(--space-5) var(--space-5) var(--space-7);
}
.result-panel.is-active { display: block; }
.result-panel__heading { font-size: var(--fs-h2); margin-bottom: var(--space-1); }
.result-panel__sub { color: var(--text-secondary); margin-bottom: var(--space-5); }

.result-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-3);
}
.result-panel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-6);
}
