* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Helvetica, Arial, sans-serif;
}

button {
    border: none;
    outline: none;
    background: none;
    color: white;
}

#camera {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: black;
}

/* ---------------- TOP ---------------- */

#top-bar {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px;
    z-index: 100;
}

.ev-container {
    display: flex;
    align-items: flex-start;
    gap: 1px;
    position: relative;
    left: 20px;
}

.ev-text {
    position: relative;
    top: 2px;
    font-size: 8px;
    font-weight: 500;
    color: #808080;
}

.ev-number {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.top-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.privacy-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #25d84d;
}

.top-right-pill {
    position: relative;
    right: -2px;
    width: 110px;
    height: 35px;
    border-radius: 24px;
    background: rgba(55, 55, 55, 0.72);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 120;
    top: 50px;
}

.pill-icon {
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 19px;
}

    .pill-icon img {
        width: 20px;
        height: 20px;
        display: block;
    }

.more-icon {
    gap: 4px;
}

.dot {
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
}

/* ---------------- PREVIEW ---------------- */

#preview {
    position: absolute;
    left: 0;
    top: 58px;
    width: 100%;
    height: calc(100% - 150px);
    background: #000;
    overflow: hidden;
}

#camera-feed,
#captured-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#camera-feed {
    z-index: 1;
    transition: opacity 0.18s ease;
}

#captured-frame {
    z-index: 2;
    display: none;
    transform-origin: center center;
    will-change: transform, opacity;
}

#camera.vanish-ready #camera-feed,
#camera.vanishing #camera-feed,
#camera.vanished #camera-feed {
    opacity: 0;
}

/*
    Общая длительность анимации побега кадра.
    Меняешь 2.6s на 2s / 3s / 3.5s — и вся анимация растягивается.
    ВАЖНО: в camera.js переменная VANISH_DURATION должна совпадать:
    2.6s = 2600
*/
#camera.vanishing #captured-frame {
    animation: capturedFrameScuttleAway 2.6s linear forwards;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
}

.v-line {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(255,255,255,.35);
}

.left {
    left: 33.333%;
}

.right {
    left: 66.666%;
}

.h-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,.35);
}

.top {
    top: 33.333%;
}

.bottom {
    top: 66.666%;
}

.level-line {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 180px;
    height: 2px;
    transform: translate(-50%,-50%);
    background: #ffd500;
    z-index: 5;
}

/* ---------------- BOTTOM ---------------- */

#bottom-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 30px;
    background: black;
    z-index: 50;
}

/* ---------------- ZOOM ---------------- */

.zoom-selector {
    position: fixed;
    left: 50%;
    bottom: 210px;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 28px;
    z-index: 120;
}

.zoom-btn {
    color: white;
    font-size: 14px;
}

    .zoom-btn.active {
        width: 30px;
        height: 30px;
        border-radius: 23px;
        background: #4a4a4a;
        color: #ffd500;
    }

/* ---------------- CAPTURE ---------------- */

.capture-row {
    position: fixed;
    left: 0;
    bottom: 54px;
    width: 100%;
    height: 90px;
    z-index: 120;
}

.shutter-btn {
    position: absolute;
    left: 50%;
    top: -40px;
    transform: translateX(-50%);
    width: 75px;
    height: 75px;
    border-radius: 50%;
    background: white;
    border: 5px solid #9a9a9a;
}

.gallery-placeholder {
    position: fixed;
    left: 26px;
    bottom: 25px;
    width: 46px;
    height: 46px;
    border-radius: 22px;
    background: #444;
    z-index: 120;
}

.switch-camera-btn {
    position: fixed;
    right: 26px;
    bottom: 25px;
    width: 46px;
    height: 46px;
    border-radius: 23px;
    background: #444;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 120;
}

    .switch-camera-btn img {
        width: 30px;
        height: 30px;
        display: block;
        pointer-events: none;
    }

/* ---------------- MODES ---------------- */

.mode-selector {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    width: 150px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 300;
}

.mode-bg {
    position: absolute;
    left: -15px;
    top: -8px;
    width: 180px;
    height: 45px;
    border-radius: 999px;
    background: rgba(28, 28, 28, 0.95);
    z-index: 1;
}

.mode-active {
    position: absolute;
    right: -15px;
    top: -8px;
    width: 90px;
    height: 45px;
    border-radius: 999px;
    background: rgba(78, 78, 78, 0.65);
    z-index: 2;
}

.mode-btn {
    position: relative;
    z-index: 3;
    width: 68px;
    height: 32px;
    color: white;
    font-size: 14px;
    font-weight: 500;
}

    .mode-btn.active {
        color: #ffd500;
    }

/* ---------------- CAPTURE ANIMATION ---------------- */

#camera.capturing .ev-container,
#camera.capturing .top-right-pill,
#camera.capturing .privacy-dot,
#camera.capturing .grid-overlay,
#camera.capturing .level-line,
#camera.capturing .zoom-selector,
#camera.capturing .capture-row,
#camera.capturing .mode-selector,
#camera.photo-taken .ev-container,
#camera.photo-taken .top-right-pill,
#camera.photo-taken .privacy-dot,
#camera.photo-taken .grid-overlay,
#camera.photo-taken .level-line,
#camera.photo-taken .zoom-selector,
#camera.photo-taken .gallery-placeholder,
#camera.photo-taken .shutter-btn,
#camera.photo-taken .switch-camera-btn,
#camera.photo-taken .mode-selector {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.capture-flash {
    position: fixed;
    inset: 0;
    background: black;
    opacity: 0;
    pointer-events: none;
    z-index: 999;
}

    .capture-flash.active {
        animation: cameraBlackFlash 0.55s ease forwards;
    }

@keyframes cameraBlackFlash {
    0% {
        opacity: 0;
    }

    35% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ---------------- VANISH / SCUTTLE ANIMATION ---------------- */

/*
    Здесь настраивается сама "живая" анимация.

    transform: translateX(...)
    0px      = кадр на месте
    -18px    = маленький дерг влево
    18px     = маленький дерг вправо
    60px     = первый рывок вправо
    150px    = второй рывок вправо
    220px    = третий рывок вправо
    120vw    = финальный уход полностью за экран вправо

    Проценты слева — тайминг внутри общей длительности.
    Если общая длительность 2.6s:
    10% = 0.26s
    50% = 1.3s
    100% = 2.6s
*/
@keyframes capturedFrameScuttleAway {
    /* Старт: кадр спокойно стоит */
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    /* Первый живой twitch: дернулся влево */
    3% {
        transform: translateX(-10px);
        opacity: 1;
    }
    /* Twitch вправо */
    6% {
        transform: translateX(10px);
        opacity: 1;
    }
    /* Вернулся почти на место */
    9% {
        transform: translateX(0);
        opacity: 1;
    }
    /* Первый маленький рывок вправо */
    30% {
        transform: translateX(0px);
        opacity: 1;
    }
    /* Маленькая пауза после первого рывка */
    40% {
        transform: translateX(60px);
        opacity: 1;
    }
    /* Второй рывок вправо */
    55% {
        transform: translateX(150px);
        opacity: 1;
    }
    /* Пауза после второго рывка */
    67% {
        transform: translateX(150px);
        opacity: 1;
    }
    /* Третий рывок вправо */
    78% {
        transform: translateX(220px);
        opacity: 1;
    }
    /* Очень короткая пауза перед финальным побегом */
    93% {
        transform: translateX(220px);
        opacity: 1;
    }
    /* Финальный рывок полностью за экран */
    100% {
        transform: translateX(120vw);
        opacity: 1;
    }
}

/* ---------------- AFTER CAPTURE BUTTONS ---------------- */

.after-capture-btn {
    display: none;
    position: fixed;
    bottom: 25px;
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: #1A1A1A;
    z-index: 400;
}

.retake-btn {
    left: 26px;
}

.send-btn {
    right: 26px;
}

#camera.photo-taken .after-capture-btn {
    display: block;
}

#camera.sending .after-capture-btn {
    display: none;
}
