:root {
  --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pwa-brand: #e85578;
  --pwa-brand-dark: #b92f52;
  --pwa-surface: rgba(255, 255, 255, .94);
  --pwa-line: rgba(95, 67, 58, .15);
}

html { -webkit-tap-highlight-color: transparent; }
body.pwa-standalone { overscroll-behavior-y: none; }

.pwa-network-banner {
  position: fixed;
  z-index: 10002;
  top: 0;
  left: 50%;
  transform: translate(-50%, -120%);
  width: min(520px, calc(100% - 24px));
  padding: 10px 16px;
  border-radius: 0 0 16px 16px;
  background: #7f1d1d;
  color: #fff;
  text-align: center;
  font-weight: 900;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
  transition: transform .25s ease;
}
.pwa-network-banner.show { transform: translate(-50%, 0); }
.pwa-network-banner.online { background: #166534; }

.pwa-toast {
  position: fixed;
  z-index: 10003;
  left: 50%;
  bottom: calc(92px + var(--pwa-safe-bottom));
  transform: translate(-50%, 24px);
  width: max-content;
  max-width: min(440px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(43, 33, 29, .94);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .22);
}
.pwa-toast.show { opacity: 1; transform: translate(-50%, 0); }

.pwa-install-fab {
  position: fixed;
  z-index: 9998;
  right: 18px;
  bottom: calc(18px + var(--pwa-safe-bottom));
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pwa-brand), #f59e6b);
  color: #fff;
  font: inherit;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 14px 36px rgba(190, 45, 87, .34);
}
.pwa-install-fab.show { display: inline-flex; }
.pwa-install-fab svg { width: 20px; height: 20px; fill: currentColor; }

.pwa-mobile-nav {
  position: fixed;
  z-index: 9997;
  left: 10px;
  right: 10px;
  bottom: calc(8px + var(--pwa-safe-bottom));
  display: none;
  grid-template-columns: repeat(5, 1fr);
  min-height: 64px;
  padding: 7px 6px;
  border: 1px solid var(--pwa-line);
  border-radius: 22px;
  background: var(--pwa-surface);
  box-shadow: 0 16px 44px rgba(76, 48, 40, .18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.pwa-mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 50px;
  border-radius: 16px;
  color: #76665f;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}
.pwa-mobile-nav a.active {
  background: rgba(232, 85, 120, .11);
  color: var(--pwa-brand-dark);
}
.pwa-mobile-nav svg { width: 22px; height: 22px; fill: currentColor; }

.pwa-install-sheet {
  position: fixed;
  z-index: 10004;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(26, 20, 18, .46);
}
.pwa-install-sheet.show { display: flex; }
.pwa-install-card {
  width: min(520px, 100%);
  padding: 22px;
  border-radius: 26px;
  background: #fff;
  color: #322722;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}
.pwa-install-card h2 { margin: 0 0 8px; font-size: 23px; }
.pwa-install-card p { margin: 0; color: #76665f; line-height: 1.7; }
.pwa-install-card ol { margin: 14px 0 18px; padding-left: 22px; line-height: 1.8; }
.pwa-install-actions { display: flex; gap: 10px; }
.pwa-install-actions button {
  flex: 1;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--pwa-line);
  background: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.pwa-install-actions .primary { border: 0; background: var(--pwa-brand); color: #fff; }

body.dark .pwa-mobile-nav,
body.dark .pwa-install-card {
  --pwa-surface: rgba(34, 28, 26, .94);
  background: var(--pwa-surface);
  color: #fff;
}
body.dark .pwa-mobile-nav a { color: #c9bbb5; }
body.dark .pwa-mobile-nav a.active { color: #ff9db4; background: rgba(255, 157, 180, .12); }
body.dark .pwa-install-card p { color: #c9bbb5; }
body.dark .pwa-install-actions button { background: #2a2320; color: #fff; }
body.dark .pwa-install-actions .primary { background: var(--pwa-brand); }

@media (max-width: 760px) {
  body.pwa-public { padding-bottom: calc(88px + var(--pwa-safe-bottom)); }
  body.pwa-public .back-top { bottom: calc(88px + var(--pwa-safe-bottom)); }
  .pwa-mobile-nav { display: grid; }
  .pwa-install-fab { bottom: calc(86px + var(--pwa-safe-bottom)); right: 14px; }
}

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

@media (min-width: 761px) {
  .pwa-toast { bottom: 28px; }
}
