:root {
    --portal-pwa-blue: #2f67ff;
    --portal-pwa-navy: #122968;
    --portal-pwa-text: #111b3f;
    --portal-pwa-muted: #6a7698;
    --portal-pwa-border: #e3eafa;
    --portal-pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
    --portal-pwa-safe-top: env(safe-area-inset-top, 0px);
}

html.portal-pwa-standalone,
html.portal-pwa-standalone body {
    overscroll-behavior-y: none;
}

html.portal-pwa-standalone body {
    -webkit-user-select: none;
    user-select: none;
}

html.portal-pwa-standalone input,
html.portal-pwa-standalone textarea,
html.portal-pwa-standalone select,
html.portal-pwa-standalone [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
}

.portal-pwa-install-wrap {
    display: none !important;
}

html.portal-pwa-installable .portal-pwa-install-wrap,
html.portal-pwa-ios-installable .portal-pwa-install-wrap,
html.portal-pwa-android-installable .portal-pwa-install-wrap {
    display: flex !important;
}

.portal-pwa-install-btn {
    min-width: 42px;
    height: 42px;
    border: 1px solid rgba(47, 103, 255, .14) !important;
    background: #f2f6ff !important;
    color: var(--portal-pwa-blue) !important;
    border-radius: 13px !important;
}

.portal-pwa-install-btn:hover,
.portal-pwa-install-btn:focus {
    background: #e7efff !important;
    color: var(--portal-pwa-navy) !important;
}

.portal-pwa-network-status {
    position: fixed;
    top: calc(12px + var(--portal-pwa-safe-top));
    left: 50%;
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100vw - 32px);
    padding: 10px 15px;
    border-radius: 999px;
    background: #172554;
    color: #fff;
    box-shadow: 0 14px 38px rgba(15, 23, 42, .24);
    font-size: 13px;
    font-weight: 700;
    transform: translate(-50%, -145%);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
    pointer-events: none;
}

.portal-pwa-network-status.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.portal-pwa-network-status.is-online {
    background: #0f766e;
}

.portal-pwa-auth-install {
    position: fixed;
    right: max(18px, env(safe-area-inset-right, 0px));
    bottom: calc(18px + var(--portal-pwa-safe-bottom));
    z-index: 4000;
    display: none;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: 15px;
    background: rgba(18, 41, 104, .94);
    color: #fff;
    box-shadow: 0 16px 38px rgba(18, 41, 104, .24);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    backdrop-filter: blur(14px);
}

html.portal-pwa-installable .portal-pwa-auth-install,
html.portal-pwa-ios-installable .portal-pwa-auth-install,
html.portal-pwa-android-installable .portal-pwa-auth-install {
    display: inline-flex;
}

.portal-pwa-install-sheet {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(4px);
}

.portal-pwa-install-sheet-card {
    width: min(100%, 440px);
    padding: 24px;
    border-radius: 24px;
    background: #fff;
    color: var(--portal-pwa-text);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.portal-pwa-install-sheet-card h3 {
    margin: 0 0 10px;
    font-size: 20px;
}

.portal-pwa-install-sheet-card p {
    margin: 0 0 18px;
    color: var(--portal-pwa-muted);
    line-height: 1.55;
}

.portal-pwa-install-sheet-card ol {
    margin: 0 0 22px;
    padding-left: 22px;
    color: #33415f;
}

.portal-pwa-install-sheet-card li + li {
    margin-top: 8px;
}


.portal-pwa-install-sheet-handle {
    width: 42px;
    height: 5px;
    margin: -10px auto 18px;
    border-radius: 999px;
    background: #d9e1f1;
}

.portal-pwa-install-sheet-note {
    margin: -4px 0 18px;
    padding: 12px 14px;
    border: 1px solid #dfe7f5;
    border-radius: 13px;
    background: #f5f8ff;
    color: #52617f;
    font-size: 13px;
    line-height: 1.5;
}
.portal-pwa-install-sheet-card button {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 13px;
    background: var(--portal-pwa-blue);
    color: #fff;
    font: inherit;
    font-weight: 700;
}

.portal-mobile-bottom-nav {
    display: none;
}

@media (max-width: 767.98px) {
    body.portal-user-pwa .page-content {
        padding-bottom: calc(104px + var(--portal-pwa-safe-bottom)) !important;
    }

    body.portal-user-pwa .main-container > .footer {
        padding-bottom: calc(82px + var(--portal-pwa-safe-bottom));
    }

    .portal-mobile-bottom-nav {
        position: fixed;
        right: 10px;
        bottom: calc(10px + var(--portal-pwa-safe-bottom));
        left: 10px;
        z-index: 1080;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: end;
        min-height: 68px;
        padding: 7px 6px 6px;
        border: 1px solid rgba(223, 231, 248, .92);
        border-radius: 22px;
        background: rgba(255, 255, 255, .94);
        box-shadow: 0 18px 46px rgba(18, 41, 104, .17);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .portal-mobile-bottom-nav__item {
        position: relative;
        display: flex;
        min-width: 0;
        min-height: 52px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        border-radius: 15px;
        color: #7a86a6;
        text-decoration: none;
        font-size: 10.5px;
        font-weight: 700;
        line-height: 1;
        transition: background .18s ease, color .18s ease, transform .18s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .portal-mobile-bottom-nav__item i {
        font-size: 22px;
        line-height: 1;
    }

    .portal-mobile-bottom-nav__item span {
        display: block;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .portal-mobile-bottom-nav__item.active {
        background: #eef4ff;
        color: var(--portal-pwa-blue);
    }

    .portal-mobile-bottom-nav__item:active {
        transform: scale(.96);
    }

    .portal-mobile-bottom-nav__item--create {
        min-height: 64px;
        margin-top: -18px;
        background: transparent !important;
        color: var(--portal-pwa-navy);
    }

    .portal-mobile-bottom-nav__create-icon {
        display: grid !important;
        width: 50px;
        height: 50px;
        place-items: center;
        overflow: visible !important;
        border: 5px solid #fff;
        border-radius: 18px;
        background: linear-gradient(145deg, #3b73ff, #1b48c7);
        color: #fff;
        box-shadow: 0 12px 26px rgba(47, 103, 255, .34);
    }

    .portal-mobile-bottom-nav__item--create i {
        font-size: 25px;
    }

    html.portal-pwa-standalone body.portal-user-pwa #header {
        padding-top: var(--portal-pwa-safe-top);
        height: calc(70px + var(--portal-pwa-safe-top));
    }

    html.portal-pwa-standalone body.portal-user-pwa .main-container {
        padding-top: calc(70px + var(--portal-pwa-safe-top));
    }

    html.portal-pwa-standalone body.portal-user-pwa .main-container > .footer {
        display: none !important;
    }

    html.portal-pwa-standalone .portal-mobile-bottom-nav {
        bottom: max(8px, var(--portal-pwa-safe-bottom));
    }

    .portal-pwa-auth-install {
        right: 14px;
        bottom: calc(14px + var(--portal-pwa-safe-bottom));
    }
}

@media (display-mode: standalone) {
    .portal-pwa-install-wrap,
    .portal-pwa-auth-install {
        display: none !important;
    }
}

/* v7: Android native install prompt is opening. */
[data-pwa-install].is-installing,
[data-pwa-install]:disabled {
    opacity: .72;
    cursor: wait;
    pointer-events: none;
}
