/* PWA: плашка «Нет сети», плашка и окно установки. Подключается в base, login, register. */
:root {
  --pwa-surface: #ffffff;
  --pwa-surface-2: #faf9f7;
  --pwa-border: #e2ddd6;
  --pwa-text: #33363f;
  --pwa-muted: #6b6f78;
  --pwa-primary: #0e7490;
  --pwa-primary-text: #ffffff;
  --pwa-danger-bg: #fff4f1;
  --pwa-danger-border: #f5c8bc;
  --pwa-ok-bg: #effaf3;
  --pwa-ok-border: #b7e4c7;
  --pwa-ok-text: #1f7a45;
  --pwa-shadow: 0 12px 32px -8px rgba(30, 32, 38, 0.28), 0 2px 6px rgba(30, 32, 38, 0.08);
}
[data-theme="dark"] {
  --pwa-surface: #262930;
  --pwa-surface-2: #1f2228;
  --pwa-border: #3a3e48;
  --pwa-text: #f0efe9;
  --pwa-muted: #a9adb7;
  --pwa-primary: #22b8cf;
  --pwa-primary-text: #1c1e24;
  --pwa-danger-bg: #3a2a27;
  --pwa-danger-border: #6b3b31;
  --pwa-ok-bg: #1f3328;
  --pwa-ok-border: #2f5a40;
  --pwa-ok-text: #8fe0ae;
  --pwa-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.pwa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  font: 600 13px/1.2 "DM Sans", system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s, opacity 0.15s;
}
.pwa-btn:active { transform: scale(0.97); }
.pwa-btn[disabled] { opacity: 0.6; cursor: default; }
.pwa-btn-primary { background: var(--pwa-primary); color: var(--pwa-primary-text); }
.pwa-btn-ghost { background: transparent; color: var(--pwa-muted); border-color: var(--pwa-border); }
.pwa-btn-block { width: 100%; padding: 12px 14px; font-size: 14px; }
.pwa-x {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--pwa-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.pwa-x:hover { background: var(--pwa-surface-2); }

/* ── Нет сети ─────────────────────────────────────────── */
.pwa-net {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top, env(safe-area-inset-top, 0px)) + 10px);
  z-index: 10050;
  width: min(560px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--pwa-danger-border);
  background: var(--pwa-danger-bg);
  color: var(--pwa-text);
  box-shadow: var(--pwa-shadow);
  font: 13px/1.35 "DM Sans", system-ui, sans-serif;
  transform: translate(-50%, calc(-100% - 24px));
  opacity: 0;
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s, visibility 0s linear 0.28s;
}
.pwa-net.show {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s, visibility 0s;
}
.pwa-net.ok { border-color: var(--pwa-ok-border); background: var(--pwa-ok-bg); }
.pwa-net-ico {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--pwa-surface);
  color: var(--pwa-primary);
}
.pwa-net.ok .pwa-net-ico { color: var(--pwa-ok-text); }
.pwa-net-txt { flex: 1; min-width: 0; }
.pwa-net-title { font-weight: 700; }
.pwa-net-sub { color: var(--pwa-muted); font-size: 12.5px; margin-top: 1px; }
.pwa-net.ok .pwa-net-sub, .pwa-net.ok .pwa-net-retry { display: none; }
.pwa-net-retry .pwa-spin { display: none; }
.pwa-net-retry.busy .pwa-spin { display: inline-block; }
.pwa-spin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: pwaSpin 0.7s linear infinite;
}
@keyframes pwaSpin { to { transform: rotate(360deg); } }
@keyframes pwaShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.pwa-net-retry.shake { animation: pwaShake 0.3s; }

/* ── Плашка установки ─────────────────────────────────── */
.pwa-install {
  position: fixed;
  z-index: 9990;
  left: 50%;
  bottom: calc(var(--bottom-nav-h, 0px) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translate(-50%, calc(100% + 30px));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 6px;
  max-width: calc(100vw - 32px);
  border-radius: 999px;
  border: 1px solid var(--pwa-border);
  background: var(--pwa-surface);
  color: var(--pwa-text);
  box-shadow: var(--pwa-shadow);
  font: 14px/1.3 "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.05), opacity 0.25s, visibility 0s linear 0.45s;
}
.pwa-install.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.05), opacity 0.25s, visibility 0s; }
.pwa-install-main {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 2px 6px 2px 2px; border: none; background: transparent;
  color: inherit; font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px; min-width: 0;
  -webkit-tap-highlight-color: transparent; transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pwa-install-main:active { transform: scale(0.97); }
.pwa-install img { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.pwa-install-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pwa-install-chev { font-size: 20px; line-height: 1; color: var(--pwa-muted); margin-left: -4px; }
.pwa-install .pwa-x { position: static; width: 36px; height: 36px; min-width: 36px; border-radius: 50%; }
@media (min-width: 1025px) {
  .pwa-install { left: auto; right: 24px; transform: translateY(calc(100% + 30px)); }
  .pwa-install.show { transform: none; }
}

/* ── Окно с инструкцией ───────────────────────────────── */
.pwa-sheet-bg {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(20, 22, 28, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0s linear 0.2s;
}
.pwa-sheet-bg.show { opacity: 1; visibility: visible; transition: opacity 0.2s, visibility 0s; }
.pwa-sheet {
  position: relative;
  width: min(420px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 22px 20px 18px;
  border-radius: 18px;
  background: var(--pwa-surface);
  color: var(--pwa-text);
  box-shadow: var(--pwa-shadow);
  font: 13.5px/1.45 "DM Sans", system-ui, sans-serif;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.pwa-sheet-bg.show .pwa-sheet { transform: none; }
@media (max-width: 640px) {
  .pwa-sheet-bg { align-items: flex-end; padding: 0; }
  .pwa-sheet {
    width: 100%;
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
  }
}
.pwa-sheet .pwa-x { position: absolute; top: 12px; right: 12px; }
.pwa-sheet-head { text-align: center; margin-bottom: 16px; }
.pwa-sheet-head img { width: 60px; height: 60px; border-radius: 14px; border: 1px solid var(--pwa-border); }
.pwa-sheet-head h3 { margin: 10px 0 2px; font: 700 18px/1.25 "Outfit", "DM Sans", sans-serif; }
.pwa-sheet-head p { margin: 0; color: var(--pwa-muted); font-size: 13px; }
.pwa-perks { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.pwa-perks li {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--pwa-surface-2);
  border: 1px solid var(--pwa-border);
  font-size: 12px;
  color: var(--pwa-muted);
}
.pwa-steps { margin: 0 0 14px; padding: 0; list-style: none; counter-reset: pwa; }
.pwa-steps li {
  counter-increment: pwa;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--pwa-surface-2);
  border: 1px solid var(--pwa-border);
}
.pwa-steps li + li { margin-top: 8px; }
.pwa-steps li::before {
  content: counter(pwa);
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--pwa-primary);
  color: var(--pwa-primary-text);
  font-weight: 700;
  font-size: 12px;
}
.pwa-steps svg { vertical-align: -3px; color: var(--pwa-primary); }
.pwa-note { margin: 0 0 14px; font-size: 12.5px; color: var(--pwa-muted); }
.pwa-done { text-align: center; padding: 10px 0 14px; }
.pwa-done b { display: block; color: var(--pwa-ok-text); font-size: 15px; margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) {
  .pwa-net, .pwa-install, .pwa-sheet, .pwa-sheet-bg { transition: none !important; }
}

/* В установленном приложении пункт «Установить» в меню не нужен */
@media (display-mode: standalone) {
  #pwa-sidebar-btn, #pwa-install-login-btn { display: none !important; }
}

/* инструкция внутри общей шторки UI.sheet */
.pwa-sheet-ui .pwa-perks { justify-content: flex-start; margin: 0 0 14px; }
.pwa-sheet-ui .pwa-steps li { font-size: 15px; }
