/* 手機 App 模式：安裝按鈕與說明視窗（只在手機／平板顯示） */
.pwa-install {
  position: fixed;
  z-index: 1070;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: none;
  align-items: center;
  gap: 2px;
  background: #0b1f3a;
  color: #fff;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(11, 31, 58, .35);
  font-size: 15px;
  line-height: 1;
}
.pwa-install.show { display: inline-flex; animation: pwaIn .35s ease-out; }
.pwa-install button {
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer;
}
.pwa-install .pwa-install-main { padding: 12px 6px 12px 16px; font-weight: 600; }
.pwa-install .pwa-install-main i { margin-right: 6px; }
.pwa-install .pwa-install-close { padding: 12px 14px 12px 8px; opacity: .7; font-size: 13px; }
@keyframes pwaIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.pwa-sheet-backdrop {
  position: fixed; inset: 0; z-index: 1090;
  background: rgba(0, 0, 0, .45);
  display: none; align-items: flex-end; justify-content: center;
}
.pwa-sheet-backdrop.show { display: flex; }
.pwa-sheet {
  background: #fff; color: #222; width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  font-size: 15px; line-height: 1.7;
  animation: pwaIn .25s ease-out;
}
.pwa-sheet h5 { font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.pwa-sheet h5 img { width: 36px; height: 36px; border-radius: 9px; }
.pwa-sheet ol { padding-left: 1.3em; margin-bottom: 12px; }
.pwa-sheet .pwa-key {
  display: inline-block; padding: 0 6px; border: 1px solid #ccc; border-radius: 6px;
  background: #f6f6f6; font-weight: 600; white-space: nowrap;
}
.pwa-sheet .pwa-note { font-size: 13px; color: #666; }
.pwa-sheet .pwa-actions { display: flex; gap: 10px; margin-top: 14px; }
.pwa-sheet .pwa-actions a, .pwa-sheet .pwa-actions button {
  flex: 1; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid #0b1f3a;
  background: #fff; color: #0b1f3a; font-weight: 600; text-decoration: none; font-size: 15px;
}
.pwa-sheet .pwa-actions .primary { background: #0b1f3a; color: #fff; }

/* App 模式（從主畫面開啟）時：iPhone 沒有上一頁按鈕，補一個 */
.pwa-back {
  position: fixed; z-index: 1070;
  left: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(11, 31, 58, .85); color: #fff; font-size: 20px;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.pwa-back.show { display: flex; }
@media print { .pwa-install, .pwa-back, .pwa-sheet-backdrop { display: none !important; } }

/* 按鈕顯示時，頁面底部留空間，避免擋住最下面的按鈕或頁尾 */
body.pwa-has-install { padding-bottom: 76px; }
