/* PWA install sheet (single dialog) */
.pwa-backdrop[hidden],
.pwa-install-sheet[hidden],
.pwa-ios-banner[hidden],
.pwa-install-banner[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.pwa-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0, 0, 0, 0.45);
  -webkit-tap-highlight-color: transparent;
}

.pwa-install-sheet {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10051;
  width: calc(100% - 40px);
  max-width: 340px;
  box-sizing: border-box;
  padding: 20px 20px 18px;
  padding-top: 44px;
  border-radius: 16px;
  background: #1c1c1e;
  color: #fff;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.pwa-sheet-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 2;
}

.pwa-sheet-icon {
  border-radius: 12px;
  margin-bottom: 12px;
}

.pwa-sheet-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.pwa-sheet-desc {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.55;
  opacity: 0.8;
}

.pwa-sheet-action {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: #8ee832;
  color: #111;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.pwa-install-toast {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10052;
  max-width: 360px;
  width: calc(100% - 32px);
  padding: 12px 16px;
  background: #1c1c1e;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.pwa-install-toast[hidden] {
  display: none !important;
}

.pwa-update-banner {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 10070;
  width: min(520px, calc(100% - 24px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(16, 19, 23, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  color: #101318;
  box-shadow: 0 18px 48px rgba(16, 19, 23, 0.18);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.pwa-update-banner.is-force {
  border-color: rgba(252, 76, 2, 0.28);
  box-shadow: 0 18px 52px rgba(252, 76, 2, 0.2);
}

.pwa-update-copy {
  min-width: 0;
}

.pwa-update-copy strong,
.pwa-update-copy span {
  display: block;
}

.pwa-update-copy strong {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
}

.pwa-update-copy span {
  margin-top: 4px;
  color: #626d76;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
  word-break: keep-all;
}

.pwa-update-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.pwa-update-actions button {
  min-height: 40px;
  border-radius: 999px;
  border: 0;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.pwa-update-apply {
  background: #101318;
  color: #fff;
}

.pwa-update-banner.is-force .pwa-update-apply {
  background: #fc4c02;
}

.pwa-update-later {
  background: #eef1f3;
  color: #3f4a54;
}

.pwa-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: #3d3d3d;
  color: #fff;
  font-size: 13px;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ── PWA standalone: 상단 노치/상태바 회피 ── */
@media (display-mode: standalone), (display-mode: fullscreen) {
  .app-header {
    padding-top: env(safe-area-inset-top, 0px);
  }
  body.feed-reel-page .app-header {
    padding-top: env(safe-area-inset-top, 0px) !important;
  }
}

/* iOS Safari home screen 앱 (`apple-mobile-web-app-capable`) */
@supports (-webkit-touch-callout: none) {
  body.pwa-standalone .app-header {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

@media (max-width: 520px) {
  .pwa-update-banner {
    grid-template-columns: 1fr;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .pwa-update-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
  }
  .pwa-update-apply {
    width: 100%;
  }
}
