/* Installable app (PWA): install banner, how-to sheet, toast, pull-to-refresh, and the dashboard's phone tab bar. */
.pwa-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 22px; font: inherit; font-weight: 700; font-size: 15px; background: #0f9d76; color: #fff; cursor: pointer; }
.pwa-btn:hover { background: #0b8566; }
.pwa-btn-sm { padding: 9px 16px; font-size: 14px; border-radius: 10px; white-space: nowrap; }

.pwa-banner { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1060; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 12px;
    background: #0b1220; color: #e2e8f0; border-radius: 18px; box-shadow: 0 18px 50px -12px rgba(2, 6, 23, .6); border: 1px solid rgba(255, 255, 255, .08);
    transform: translateY(140%); transition: transform .35s cubic-bezier(.2, 1.2, .4, 1); font-family: inherit; }
.pwa-banner.on { transform: none; }
.pwa-banner-icon { width: 46px; height: 46px; border-radius: 12px; flex: none; background: #fff; }
.pwa-banner-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pwa-banner-txt b { font-size: 14.5px; color: #fff; }
.pwa-banner-txt span { font-size: 12.5px; color: #94a3b8; }
.pwa-banner-x { border: 0; background: none; color: #94a3b8; font-size: 15px; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; flex: none; }
@media (min-width: 640px) { .pwa-banner { left: auto; right: 20px; width: 420px; } }

.pwa-sheet { position: fixed; inset: 0; z-index: 2100; background: rgba(2, 6, 23, .6); display: flex; align-items: flex-end; justify-content: center; padding: 12px; animation: pwaFade .2s ease-out; }
.pwa-sheet-card { width: min(440px, 100%); background: #fff; color: #0f172a; border-radius: 22px; padding: 24px 22px calc(18px + env(safe-area-inset-bottom)); text-align: center; animation: pwaUp .3s cubic-bezier(.2, 1.2, .4, 1); font-family: inherit; }
.pwa-sheet-icon { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 10px; box-shadow: 0 6px 18px rgba(15, 23, 42, .15); }
.pwa-sheet-card h3 { font-size: 18px; font-weight: 800; margin: 0 0 14px; }
.pwa-sheet-note { color: #475569; font-size: 14.5px; margin: 0 0 16px; }
.pwa-steps { list-style: none; margin: 0 0 18px; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.pwa-steps li { display: flex; align-items: center; gap: 12px; font-size: 15px; background: #f1f5f9; border-radius: 12px; padding: 10px 12px; }
.pwa-step-ic { width: 34px; height: 34px; border-radius: 10px; background: #fff; color: #0a84ff; display: grid; place-items: center; font-weight: 800; flex: none; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.pwa-sheet-card .pwa-btn { width: 100%; }
@media (min-width: 640px) { .pwa-sheet { align-items: center; } }

.pwa-toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2100; background: #0b1220; color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 10px 30px rgba(2, 6, 23, .35); }

.pwa-ptr { position: fixed; top: 10px; left: 50%; z-index: 2000; width: 40px; height: 40px; border-radius: 50%; background: #fff; box-shadow: 0 6px 18px rgba(15, 23, 42, .2); display: grid; place-items: center; transform: translate(-50%, -50px); }
.pwa-ptr-spin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #cbd5e1; border-top-color: #0f9d76; display: block; }
.pwa-ptr.ready .pwa-ptr-spin { border-color: #0f9d76; border-top-color: transparent; }
.pwa-ptr.loading .pwa-ptr-spin { animation: pwaSpin .7s linear infinite; }

@keyframes pwaFade { from { opacity: 0; } }
@keyframes pwaUp { from { transform: translateY(40px); opacity: 0; } }
@keyframes pwaSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pwa-banner, .pwa-sheet, .pwa-sheet-card { transition: none; animation: none; } }

/* Inside the installed app: no install buttons, no tap flash. */
.pwa-standalone [data-pwa-install], .pwa-standalone .pwa-hide-in-app { display: none !important; }
.pwa-standalone body { -webkit-tap-highlight-color: transparent; }

/* Website: keep the chat / back-to-top buttons above the install banner. */
.pwa-banner-on .st-chatnow { bottom: calc(96px + env(safe-area-inset-bottom)); }
.pwa-banner-on .st-totop { bottom: calc(156px + env(safe-area-inset-bottom)); }

/* ---------------- Dashboard on a phone: app-style bottom tab bar ---------------- */
.hp-tabbar { display: none; }
@media (max-width: 991px) {
    .hp-tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; height: calc(62px + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
        background: color-mix(in srgb, var(--hp-surface, #fff) 94%, transparent); backdrop-filter: saturate(160%) blur(12px); border-top: 1px solid var(--hp-border, #e5e9f0); box-shadow: 0 -6px 24px -16px rgba(15, 23, 42, .35); user-select: none; -webkit-user-select: none; }
    .hp-tabbar a, .hp-tabbar button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 2px 0; border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600; color: var(--hp-muted, #64748b) !important; text-decoration: none; position: relative; -webkit-tap-highlight-color: transparent; }
    .hp-tabbar i { font-size: 19px; line-height: 1; }
    .hp-tabbar span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .hp-tabbar .active { color: var(--hp-primary, #0f9d76) !important; }
    .hp-tabbar .active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--hp-primary, #0f9d76); }
    .hp-tabbar .hp-tab-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; }
    .hp-tabbar a:active, .hp-tabbar button:active { transform: scale(.94); }

    .hp-body .hp-content { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
    .hp-body .as-fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
    .hp-body .pwa-banner { bottom: calc(72px + env(safe-area-inset-bottom)); }
    /* The inbox list sits above the tab bar; an open chat gets the whole screen (its own back button). */
    .hp-body .inbox[data-view="list"] { height: calc(100dvh - var(--hp-topbar-h, 64px) - 32px - 62px - env(safe-area-inset-bottom)); }
    .hp-body:has(.inbox[data-view="thread"]) .hp-tabbar { display: none; }
    .hp-body:has(.inbox[data-view="thread"]) .as-fab { bottom: 14px; }
}

/* Sidebar: "Install the app on your phone" */
.hp-install-app { display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 8px; padding: 10px 12px; border-radius: 12px; border: 1px dashed rgba(37, 211, 102, .45); background: rgba(37, 211, 102, .08); color: #d1fae5; font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer; }
.hp-install-app i { color: #25d366; font-size: 16px; }
.hp-install-app:hover { background: rgba(37, 211, 102, .14); }
