* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;

    width: 100%;
    height: 100%;

    overflow: hidden;

    background: #000;
    color: #fff;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    overscroll-behavior: none;
}

button,
select {
    font: inherit;
}

button {
    touch-action: manipulation;
}

.hidden {
    display: none !important;
}


/* ==========================================================
   APP
   ========================================================== */

#camera-app {
    position: fixed;
    inset: 0;

    overflow: hidden;

    background: #000;
}

#preview {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: cover;

    background: #000;
}


/* ==========================================================
   ROTATE
   ========================================================== */

#rotate-warning {
    display: none;

    position: absolute;
    inset: 0;

    z-index: 1000;

    align-items: center;
    justify-content: center;
    flex-direction: column;

    gap: 8px;

    background: #000;

    text-align: center;
}

.rotate-icon {
    font-size: 52px;
}

#rotate-warning strong {
    font-size: 22px;
}

#rotate-warning span {
    color: #888;

    font-size: 13px;
}

@media (orientation: portrait) {

    #rotate-warning {
        display: flex;
    }

}


/* ==========================================================
   INITIAL CAMERA GATE
   ========================================================== */

#camera-gate {
    position: absolute;
    inset: 0;

    z-index: 100;

    display: grid;
    place-items: center;

    padding: 25px;

    background:
        radial-gradient(
            circle at 50% 38%,
            #181818,
            #060606 60%,
            #000
        );
}

.gate-box {
    width: min(
        420px,
        100%
    );

    text-align: center;
}

.gate-brand {
    margin-bottom: 10px;

    color: #777;

    font-size: 10px;
    font-weight: 900;

    letter-spacing: .18em;
}

.gate-box h1 {
    margin: 0 0 8px;

    font-size: 27px;
}

.gate-box p {
    margin:
        0
        auto
        20px;

    max-width: 360px;

    color: #999;

    line-height: 1.45;

    font-size: 14px;
}

.primary-large {
    min-width: 210px;
    min-height: 51px;

    border: 0;
    border-radius: 10px;

    background: #fff;
    color: #000;

    font-weight: 900;
}


/* ==========================================================
   TOP HUD
   ========================================================== */

#top-bar {
    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    z-index: 30;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding:
        max(
            12px,
            env(safe-area-inset-top)
        )
        max(
            15px,
            env(safe-area-inset-right)
        )
        12px
        max(
            15px,
            env(safe-area-inset-left)
        );

    pointer-events: none;
}

.top-left,
.top-right {
    display: flex;
    align-items: center;

    gap: 7px;
}

.top-right {
    pointer-events: auto;
}

.hud {
    min-height: 34px;

    display: flex;
    align-items: center;

    padding: 0 11px;

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            .16
        );

    border-radius: 999px;

    background:
        rgba(
            0,
            0,
            0,
            .66
        );

    backdrop-filter:
        blur(10px);

    font-size: 10px;
    font-weight: 900;
}

.hud.subtle {
    color: #aaa;
}

.status-dot {
    width: 7px;
    height: 7px;

    margin-right: 7px;

    border-radius: 50%;

    background: #777;
}

.status.live .status-dot {
    background: #ff3d3d;

    box-shadow:
        0 0 0 4px
        rgba(
            255,
            61,
            61,
            .12
        );
}

.status.connecting .status-dot {
    background: #fff;
}

.status.error .status-dot {
    background: #ff913d;
}

.round-button {
    width: 39px;
    height: 39px;

    display: grid;
    place-items: center;

    padding: 0;

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            .18
        );

    border-radius: 50%;

    background:
        rgba(
            0,
            0,
            0,
            .68
        );

    color: #fff;

    backdrop-filter:
        blur(10px);

    font-size: 18px;
}


/* ==========================================================
   ZOOM
   ========================================================== */

#zoom-controls {
    position: absolute;

    left: 50%;
    bottom: 70px;

    z-index: 35;

    display: flex;

    gap: 7px;

    transform:
        translateX(-50%);
}

.zoom-button {
    width: 43px;
    height: 43px;

    padding: 0;

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            .18
        );

    border-radius: 50%;

    background:
        rgba(
            0,
            0,
            0,
            .73
        );

    color: #fff;

    backdrop-filter:
        blur(10px);

    font-size: 10px;
    font-weight: 900;
}

.zoom-button.active {
    background: #fff;
    color: #000;
}

.zoom-button:disabled {
    opacity: .28;
}


/* ==========================================================
   BOTTOM HUD
   ========================================================== */

#bottom-bar {
    position: absolute;

    left: 0;
    right: 0;
    bottom: 0;

    z-index: 30;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 12px;

    padding:
        12px
        max(
            15px,
            env(safe-area-inset-right)
        )
        max(
            13px,
            env(safe-area-inset-bottom)
        )
        max(
            15px,
            env(safe-area-inset-left)
        );

    pointer-events: none;
}

.stream-info {
    min-height: 35px;

    display: flex;
    align-items: center;

    gap: 7px;

    padding: 0 11px;

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            .15
        );

    border-radius: 999px;

    background:
        rgba(
            0,
            0,
            0,
            .67
        );

    backdrop-filter:
        blur(10px);

    font-size: 10px;
    font-weight: 800;
}

.separator {
    color: #555;
}

.bottom-actions {
    display: flex;

    gap: 8px;

    pointer-events: auto;
}

.secondary-action,
.start-action,
.stop-action {
    min-height: 44px;

    padding: 0 17px;

    border-radius: 10px;

    font-size: 11px;
    font-weight: 900;
}

.secondary-action {
    border:
        1px solid
        rgba(
            255,
            255,
            255,
            .18
        );

    background:
        rgba(
            0,
            0,
            0,
            .7
        );

    color: #fff;
}

.secondary-action:disabled {
    opacity: .35;
}

.start-action {
    min-width: 105px;

    border: 1px solid #fff;

    background: #fff;
    color: #000;
}

.start-action:disabled {
    opacity: .4;
}

.stop-action {
    min-width: 105px;

    border:
        1px solid
        rgba(
            255,
            70,
            70,
            .55
        );

    background:
        rgba(
            80,
            0,
            0,
            .78
        );

    color: #fff;
}


/* ==========================================================
   TOAST
   ========================================================== */

.toast {
    position: absolute;

    z-index: 80;

    left: 50%;
    bottom: 124px;

    max-width:
        min(
            520px,
            calc(
                100%
                - 40px
            )
        );

    transform:
        translateX(-50%);

    padding: 10px 14px;

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            .16
        );

    border-radius: 9px;

    background:
        rgba(
            0,
            0,
            0,
            .9
        );

    color: #eee;

    backdrop-filter:
        blur(12px);

    font-size: 12px;

    text-align: center;

    white-space: pre-line;
}


/* ==========================================================
   SETTINGS
   ========================================================== */

.settings-backdrop {
    position: absolute;
    inset: 0;

    z-index: 59;

    border: 0;

    background:
        rgba(
            0,
            0,
            0,
            .44
        );
}

.settings-drawer {
    position: absolute;

    z-index: 60;

    top: 0;
    right: 0;
    bottom: 0;

    width:
        min(
            420px,
            90vw
        );

    display: flex;
    flex-direction: column;

    border-left:
        1px solid #292929;

    background:
        rgba(
            5,
            5,
            5,
            .97
        );

    backdrop-filter:
        blur(18px);

    transform:
        translateX(102%);

    transition:
        transform
        180ms
        ease;
}

.settings-drawer.open {
    transform:
        translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding:
        max(
            16px,
            env(safe-area-inset-top)
        )
        16px
        14px;

    border-bottom:
        1px solid #222;
}

.drawer-brand {
    color: #666;

    font-size: 9px;
    font-weight: 900;

    letter-spacing: .16em;
}

.drawer-header h2 {
    margin: 3px 0 0;

    font-size: 19px;
}

.drawer-close {
    width: 37px;
    height: 37px;

    padding: 0;

    border:
        1px solid #292929;

    border-radius: 50%;

    background: #0d0d0d;
    color: #fff;

    font-size: 24px;
}

.drawer-scroll {
    flex: 1;

    overflow-y: auto;

    padding:
        0
        16px
        max(
            22px,
            env(safe-area-inset-bottom)
        );

    overscroll-behavior:
        contain;
}

.settings-section {
    padding: 16px 0;

    border-bottom:
        1px solid #202020;
}

.settings-section:last-child {
    border-bottom: 0;
}

.settings-section h3 {
    margin: 0 0 13px;

    font-size: 13px;
}

.settings-section label {
    display: block;

    margin: 11px 0 6px;

    color: #888;

    font-size: 11px;
}

.settings-section select {
    width: 100%;
    min-height: 43px;

    padding: 0 10px;

    border:
        1px solid #2d2d2d;

    border-radius: 8px;

    outline: none;

    background: #0d0d0d;
    color: #fff;

    font-size: 14px;
}

.settings-section select:disabled {
    opacity: .42;
}

.setting-grid {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 9px;
}

.settings-help {
    margin:
        12px
        0
        0;

    color: #666;

    line-height: 1.45;

    font-size: 10px;
}

.status-list {
    display: grid;

    gap: 9px;
}

.status-list > div {
    display: flex;
    justify-content: space-between;

    gap: 12px;

    font-size: 12px;
}

.status-list span {
    color: #777;
}

.status-list strong {
    color: #ddd;

    text-align: right;
}

.account-email {
    overflow: hidden;

    color: #bbb;

    font-size: 12px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-button {
    width: 100%;
    min-height: 42px;

    margin-top: 13px;

    border:
        1px solid #303030;

    border-radius: 8px;

    background: #0d0d0d;
    color: #aaa;

    font-size: 11px;
    font-weight: 800;
}


/* ==========================================================
   SMALL LANDSCAPE
   ========================================================== */

@media
    (orientation: landscape)
    and (max-height: 450px) {

    #top-bar {
        padding-top: 8px;
    }

    #bottom-bar {
        padding-bottom: 8px;
    }

    #zoom-controls {
        bottom: 58px;
    }

    .hud {
        min-height: 30px;
    }

    .round-button {
        width: 35px;
        height: 35px;
    }

    .zoom-button {
        width: 37px;
        height: 37px;
    }

    .secondary-action,
    .start-action,
    .stop-action {
        min-height: 39px;
    }

}
