/* PWA installation guide: the single style owner for every supported caller. */
.pwa-guide-overlay {
    --pwa-guide-safe-top: max(var(--app-overlay-safe-top, 0px), env(safe-area-inset-top, 0px));
    --pwa-guide-safe-bottom: max(var(--app-dialog-safe-bottom, 0px), env(safe-area-inset-bottom, 0px));
    position: fixed;
    top: var(--pwa-guide-safe-top);
    right: 0;
    bottom: var(--pwa-guide-safe-bottom);
    left: 0;
    z-index: var(--z-popup, 20000);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
    overscroll-behavior: contain;
    padding: 12px;
    background: rgba(0, 0, 0, 0.62);
}

.pwa-guide-dialog,
.pwa-guide-dialog * {
    box-sizing: border-box;
}

.pwa-guide-dialog {
    width: 100%;
    max-width: 500px;
    max-height: min(
        86dvh,
        calc(100dvh - var(--pwa-guide-safe-top) - var(--pwa-guide-safe-bottom) - 24px)
    );
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    background: #1a1a2e;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.pwa-guide-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px 10px;
    border-bottom: 1px solid #2a2a4a;
    background: #1a1a2e;
}

.pwa-guide-header h3 {
    min-width: 0;
    margin: 0;
    color: #e0e0ff;
    font-size: 1.02rem;
}

.pwa-guide-close {
    flex: 0 0 auto;
    width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: #a8a8c0;
    font-size: 1.55rem;
    line-height: 1;
    cursor: pointer;
}

.pwa-guide-close:hover,
.pwa-guide-close:focus-visible {
    color: #fff;
}

.pwa-guide-close:focus-visible,
.pwa-guide-tab:focus-visible,
.pwa-guide-install-btn:focus-visible,
.pwa-guide-ok:focus-visible {
    outline: 3px solid rgba(79, 195, 247, 0.65);
    outline-offset: 2px;
}

.pwa-guide-intro {
    min-width: 0;
    padding: 12px 18px 2px;
    color: #a8a8c0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.pwa-guide-intro p {
    margin: 0;
}

.pwa-guide-android-summary {
    padding: 4px 0 6px;
}

.pwa-guide-android-summary strong {
    display: block;
    color: #f8fafc;
    font-size: 1rem;
}

.pwa-guide-android-summary p {
    margin: 5px 0 0;
    color: #cbd5e1;
    font-size: 0.86rem;
    line-height: 1.55;
}

.pwa-guide-tabs {
    display: flex;
    gap: 6px;
    min-width: 0;
    overflow: visible;
    padding: 10px 18px 0;
    border-bottom: 1px solid #2a2a4a;
}

.pwa-guide-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 6px;
    border: 1px solid #2a2a4a;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: #22233a;
    color: #9090a8;
    overflow-wrap: anywhere;
    font-size: 0.82rem;
    line-height: 1.3;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.pwa-guide-tab:hover {
    background: #2a2a44;
    color: #c0c0d8;
}

.pwa-guide-tab-active {
    position: relative;
    top: 1px;
    border-color: #4fc3f7;
    border-bottom-color: #1a1a2e;
    background: #1a1a2e;
    color: #4fc3f7;
    font-weight: 600;
}

.pwa-guide-body {
    min-width: 0;
    padding: 18px;
    overflow: visible;
}

.pwa-guide-steps {
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.pwa-guide-steps li {
    display: flex;
    gap: 10px;
    min-width: 0;
    padding: 8px 0;
    color: #d8d8e8;
    font-size: 0.9rem;
    line-height: 1.55;
}

.pwa-guide-step-n {
    display: inline-flex;
    flex: 0 0 24px;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4fc3f7;
    color: #0a0a18;
    font-size: 0.78rem;
    font-weight: 700;
}

.pwa-guide-step-t {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.pwa-guide-step-t b {
    color: #fff;
}

.pwa-guide-note {
    margin: 6px 0 10px;
    padding: 8px 10px;
    border-left: 3px solid #4a4a66;
    border-radius: 4px;
    background: #22223a;
    color: #8888a0;
    overflow-wrap: anywhere;
    font-size: 0.78rem;
    line-height: 1.5;
}

.pwa-guide-install-btn {
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    padding: 11px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    color: #0a0a18;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
}

.pwa-guide-body > .pwa-guide-install-btn:first-child {
    min-height: 52px;
    margin: 0 0 14px;
    font-size: 1rem;
}

.pwa-guide-next-label {
    margin: 0 0 4px;
    color: #94a3b8;
    font-size: 0.76rem;
    font-weight: 800;
}

.pwa-guide-install-btn:disabled {
    background: #2a2a44;
    color: #666;
    cursor: not-allowed;
}

.pwa-guide-install-hint {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    font-weight: 400;
    opacity: 0.8;
}

.pwa-guide-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 11px 18px 14px;
    border-top: 1px solid #2a2a4a;
    flex-wrap: wrap;
}

.pwa-guide-hide-label {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    color: #a8a8c0;
    font-size: 0.78rem;
    cursor: pointer;
}

.pwa-guide-hide-label input {
    accent-color: #4fc3f7;
}

.pwa-guide-ok {
    min-width: 72px;
    min-height: 44px;
    margin-left: auto;
    padding: 7px 18px;
    border: 0;
    border-radius: 6px;
    background: #4fc3f7;
    color: #0a0a18;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.pwa-guide-ok:hover {
    background: #29b6f6;
}

body.mobile-shell-open #pwaGuideOverlay,
body.mobile-shell-open .pwa-guide-overlay {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

@media (max-width: 767px) {
    .pwa-guide-overlay {
        padding: 8px;
    }

    .pwa-guide-dialog {
        max-width: calc(100vw - 16px);
        max-height: calc(
            100dvh - var(--pwa-guide-safe-top) - var(--pwa-guide-safe-bottom) - 16px
        );
        border-radius: min(12px, 2.5vw);
    }

    .pwa-guide-header {
        padding: 8px 10px 6px 14px;
    }

    .pwa-guide-intro {
        padding: 8px 14px 0;
    }

    .pwa-guide-tabs {
        gap: 3px;
        padding: 6px 12px 0;
    }

    .pwa-guide-tab {
        min-height: 44px;
        padding: 7px 3px;
        font-size: 0.76rem;
    }

    .pwa-guide-body {
        padding: 12px 14px;
    }

    .pwa-guide-footer {
        align-items: stretch;
        padding: 10px 14px 14px;
    }

    .pwa-guide-hide-label {
        flex: 1 1 calc(50% - 5px);
    }

    .pwa-guide-ok {
        flex: 1 0 100%;
        margin-left: 0;
    }
}
