/* PWA — compact install chip + push gate */
.pwa-install-float {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 140;
  width: min(100% - 24px, 380px);
  pointer-events: none;
  animation: pwa-install-enter .55s cubic-bezier(.22, 1, .36, 1);
}

.pwa-install-float--hide {
  animation: pwa-install-exit .42s ease-in forwards;
}

@keyframes pwa-install-enter {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(18px) scale(.94);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes pwa-install-exit {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(14px) scale(.96);
  }
}

body.is-logged-in .pwa-install-float {
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
}

body.messenger-body .pwa-install-float {
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  z-index: 160;
}

body.hub-body .pwa-install-float {
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 160;
}

.pwa-install-float-card {
  position: relative;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 40px 12px 16px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--primary, #2563eb) 28%, #e2e8f0);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(248, 250, 252, .94)),
    linear-gradient(120deg, color-mix(in srgb, var(--primary, #2563eb) 8%, transparent), transparent 55%);
  box-shadow:
    0 18px 44px rgba(15, 23, 42, .14),
    0 0 0 1px rgba(255, 255, 255, .85) inset;
  backdrop-filter: blur(14px);
  animation: pwa-install-pulse 2.6s ease-in-out infinite;
  overflow: visible;
}

.pwa-install-float-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 10px;
  background: rgba(148, 163, 184, .16);
  color: #64748b;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 12px;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.pwa-install-float-close:hover {
  background: rgba(220, 38, 38, .14);
  color: #dc2626;
  transform: scale(1.06);
}

.pwa-install-float-close:active {
  transform: scale(.94);
}

.pwa-install-float-ring {
  position: absolute;
  inset: -2px;
  border-radius: 22px;
  border: 2px solid color-mix(in srgb, var(--primary, #2563eb) 55%, #38bdf8);
  opacity: 0;
  pointer-events: none;
  animation: pwa-install-ring 2.6s ease-out infinite;
}

@keyframes pwa-install-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 18px 44px rgba(15, 23, 42, .14),
      0 0 0 0 color-mix(in srgb, var(--primary, #2563eb) 0%, transparent);
  }

  50% {
    transform: scale(1.015);
    box-shadow:
      0 22px 50px rgba(15, 23, 42, .16),
      0 0 0 6px color-mix(in srgb, var(--primary, #2563eb) 12%, transparent);
  }
}

@keyframes pwa-install-ring {
  0% {
    transform: scale(1);
    opacity: .55;
  }

  70%,
  100% {
    transform: scale(1.06);
    opacity: 0;
  }
}

.pwa-install-float-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(145deg, var(--primary, #2563eb), #0ea5e9);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--primary, #2563eb) 34%, transparent);
  animation: pwa-install-icon-glow 2.6s ease-in-out infinite;
}

@keyframes pwa-install-icon-glow {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.08);
  }
}

.pwa-install-float-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}

.pwa-install-float-title {
  font-size: 13.5px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.3;
}

.pwa-install-float-sub {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-install-float-btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 18px;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary, #2563eb), #0ea5e9);
  box-shadow: 0 8px 20px rgba(37, 99, 235, .28);
  transition: transform .15s ease, box-shadow .15s ease;
}

.pwa-install-float-btn:hover {
  box-shadow: 0 10px 24px rgba(37, 99, 235, .34);
}

.pwa-install-float-btn:active {
  transform: scale(.97);
}

/* Topbar install chip — removed; use native browser install in address bar */

@media (max-width: 680px) {
  .pwa-install-float {
    width: min(100% - 20px, 340px);
  }

  .pwa-install-float-title {
    font-size: 12.5px;
  }

  .pwa-install-float-sub {
    font-size: 10.5px;
  }

  .pwa-install-float-btn {
    padding: 0 14px;
    font-size: 11.5px;
  }
}

/* Push permission prompt — optional, non-blocking */
.pwa-push-gate {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 190;
  width: min(100% - 24px, 420px);
  pointer-events: none;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  display: block;
}

body.is-logged-in .pwa-push-gate {
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
}

body.is-logged-in .pwa-push-gate + .pwa-install-float,
body.is-logged-in:has(.pwa-push-gate) .pwa-install-float {
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

body.messenger-body .pwa-push-gate {
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

body.messenger-body:has(.pwa-push-gate) .pwa-install-float {
  bottom: calc(144px + env(safe-area-inset-bottom, 0px));
}

.pwa-push-gate-card {
  width: 100%;
  pointer-events: auto;
  padding: 20px 18px;
  border-radius: 20px;
  background: #fff;
  text-align: center;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .22);
  border: 1px solid #e2e8f0;
}

.pwa-push-gate-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(145deg, #f59e0b, #f97316);
}

.pwa-push-gate-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 900;
  color: #0f172a;
}

.pwa-push-gate-card p {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.75;
  color: #64748b;
}

.pwa-push-gate-card .primary-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
}

.pwa-push-gate-actions {
  display: grid;
  gap: 8px;
}

.pwa-push-gate-actions .primary-btn,
.pwa-push-gate-actions .secondary-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
}

.pwa-push-browser-tip {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  text-align: right;
  border: 1px solid #fde68a;
  background: linear-gradient(180deg, #fffbeb, #fff);
}

.pwa-push-browser-tip strong {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 900;
  color: #92400e;
}

.pwa-push-browser-tip ol {
  margin: 0;
  padding: 0 18px 0 0;
  font-size: 12px;
  line-height: 1.85;
  color: #78350f;
}

.pwa-push-browser-tip li + li {
  margin-top: 4px;
}

.pwa-push-kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid #fcd34d;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  color: #92400e;
  direction: ltr;
}

.pwa-push-gate-hint {
  margin-top: 12px !important;
  margin-bottom: 0 !important;
  font-size: 12px !important;
  color: #b45309 !important;
}

.pwa-push-gate--blocked .pwa-push-gate-card {
  max-height: min(70vh, 520px);
  overflow-y: auto;
  text-align: right;
}

.pwa-push-gate-card--scroll {
  scrollbar-width: thin;
}

.pwa-push-gate-icon--blocked {
  background: linear-gradient(145deg, #ef4444, #dc2626) !important;
}

.pwa-push-unblock-guide {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 16px;
  text-align: right;
  border: 1px solid #fecaca;
  background: linear-gradient(180deg, #fef2f2, #fff);
}

.pwa-push-unblock-guide strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 900;
  color: #991b1b;
}

.pwa-push-unblock-guide ol {
  margin: 0;
  padding: 0 20px 0 0;
  font-size: 12.5px;
  line-height: 1.9;
  color: #7f1d1d;
}

.pwa-push-unblock-guide li + li {
  margin-top: 6px;
}

.pwa-push-unblock-note {
  margin: 12px 0 0 !important;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 11.5px !important;
  font-weight: 800;
  line-height: 1.7 !important;
  color: #92400e !important;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.pwa-push-gate-hint i {
  margin-left: 4px;
}

@keyframes pwa-push-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.pwa-push-gate [data-pwa-push-recheck].is-shake {
  animation: pwa-push-shake .5s ease;
}

/* Install guide page */
.pwa-install-page {
  width: min(720px, 100%);
  margin: 0 auto;
}

.pwa-install-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.pwa-install-hero-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #fff;
  background: linear-gradient(145deg, var(--primary, #2563eb), #0ea5e9);
}

.pwa-install-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.pwa-install-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.pwa-install-tabs a.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary, #2563eb), #0ea5e9);
}

.pwa-install-steps {
  display: grid;
  gap: 12px;
}

.pwa-install-step {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #e8edf4;
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.pwa-install-step-num {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: var(--primary, #2563eb);
  background: var(--primary-soft, #eff6ff);
}

.pwa-install-step p {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: #334155;
}

.pwa-install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.pwa-install-actions .primary-btn,
.pwa-install-actions .secondary-btn {
  flex: 1 1 auto;
  justify-content: center;
  min-width: 160px;
}

@media (display-mode: standalone) {
  .pwa-install-float {
    display: none !important;
  }
}

/* Mandatory app update gate (PWA standalone) */
.pwa-update-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .72);
  backdrop-filter: blur(6px);
}

.pwa-update-gate-card {
  width: min(100%, 420px);
  padding: 24px 20px;
  border-radius: 20px;
  background: #fff;
  text-align: center;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .35);
  border: 1px solid #e2e8f0;
}

.pwa-update-gate-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
  font-size: 1.4rem;
}

.pwa-update-gate-card h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  color: #0f172a;
}

.pwa-update-gate-card p {
  margin: 0;
  color: #475569;
  line-height: 1.7;
  font-size: .95rem;
}

.pwa-update-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.pwa-update-gate-actions .primary-btn,
.pwa-update-gate-actions .secondary-btn {
  width: 100%;
  justify-content: center;
  text-decoration: none;
  gap: 8px;
  min-height: 44px;
}

.pwa-update-gate-actions .secondary-btn {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.pwa-update-open-browser {
  box-shadow: 0 10px 24px rgba(37, 99, 235, .28);
}

.pwa-update-gate-note {
  margin: 14px 0 0;
  font-size: .82rem;
  color: #64748b;
  line-height: 1.6;
}

.pwa-topbar-install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--primary, #2563eb) 28%, #cbd5e1);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(239, 246, 255, .98), rgba(255, 255, 255, .96));
  color: var(--primary, #2563eb);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .12);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.pwa-topbar-install:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary, #2563eb) 45%, #93c5fd);
  box-shadow: 0 12px 26px rgba(37, 99, 235, .16);
}

.pwa-topbar-install i {
  font-size: 13px;
}

@media (max-width: 640px) {
  .pwa-topbar-install span {
    display: none;
  }

  .pwa-topbar-install {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}
