/* Standalone PWA navigation. Hidden in normal Safari/Chrome browser tabs. */
.pwa-standalone-nav {
    display: none;
}

html.pwa-standalone {
    --pwa-nav-height: 70px;
    --pwa-nav-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html.pwa-standalone body {
    padding-bottom: calc(var(--pwa-nav-height) + var(--pwa-nav-safe-bottom) + 12px);
}

/*
 * IMPORTANT: this is intentionally a <div role="navigation">, not a <nav>.
 * The legacy SKINBALANCE frontend has a global `nav { position:fixed; top:0; ... }`
 * rule. Using a generic <nav> here made the PWA bar inherit top:0 while our own
 * CSS also set bottom, stretching the element over almost the whole viewport.
 * Explicit geometry below is kept defensive as an additional isolation layer.
 */
html.pwa-standalone .pwa-standalone-nav {
    position: fixed !important;
    z-index: 2147483000;
    top: auto !important;
    left: 12px !important;
    right: 12px !important;
    bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
    width: auto !important;
    height: auto !important;
    min-height: var(--pwa-nav-height);
    max-height: 84px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    justify-content: initial;
    gap: 4px;
    margin: 0 !important;
    padding: 7px !important;
    border: 1px solid rgba(61, 43, 61, .13);
    border-radius: 23px;
    background: rgba(249, 243, 240, .94);
    box-shadow: 0 14px 38px rgba(61, 43, 61, .20);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
    overflow: hidden;
    isolation: isolate;
    box-sizing: border-box;
}

html.pwa-standalone .pwa-standalone-nav__item {
    appearance: none;
    -webkit-appearance: none;
    min-width: 0;
    min-height: 54px;
    margin: 0;
    padding: 6px 3px 5px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: #3d2b3d;
    font-family: "DM Sans", Arial, sans-serif;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: .015em;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-sizing: border-box;
}

html.pwa-standalone .pwa-standalone-nav__item svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

html.pwa-standalone .pwa-standalone-nav__item:active {
    background: rgba(61, 43, 61, .09);
    transform: translateY(1px);
}

html.pwa-standalone .pwa-standalone-nav__item.is-disabled,
html.pwa-standalone .pwa-standalone-nav__item:disabled {
    opacity: .34;
    cursor: default;
    transform: none;
}

@media (min-width: 700px) {
    html.pwa-standalone .pwa-standalone-nav {
        left: 50% !important;
        right: auto !important;
        width: min(480px, calc(100vw - 32px)) !important;
        transform: translateX(-50%);
    }
}

@media (max-width: 370px) {
    html.pwa-standalone .pwa-standalone-nav {
        left: 7px !important;
        right: 7px !important;
        padding: 6px 4px !important;
    }

    html.pwa-standalone .pwa-standalone-nav__item {
        font-size: 9px;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    html.pwa-standalone {
        --pwa-nav-height: 58px;
    }

    html.pwa-standalone .pwa-standalone-nav {
        min-height: 58px;
        max-height: 68px;
        padding: 4px 7px !important;
        border-radius: 19px;
    }

    html.pwa-standalone .pwa-standalone-nav__item {
        min-height: 48px;
        flex-direction: row;
        gap: 5px;
        font-size: 9px;
    }

    html.pwa-standalone .pwa-standalone-nav__item svg {
        width: 19px;
        height: 19px;
    }
}
