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

body.pwa-install-visible {
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

body.inline-editing .pwa-install-prompt {
  display: none !important;
}

body.inline-editing.pwa-install-visible {
  padding-bottom: 0;
}

.pwa-install-prompt {
  position: fixed;
  z-index: 10000;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin-left: auto;
  padding: 14px 42px 14px 14px;
  border: 1px solid rgb(19 93 102 / 30%);
  border-color: color-mix(in srgb, var(--brand, #135d66), transparent 70%);
  border-radius: 18px;
  background: var(--surface, #ffffff);
  background: color-mix(in srgb, var(--surface, #ffffff), transparent 3%);
  box-shadow: 0 18px 50px rgb(0 0 0 / 24%);
  color: var(--ink, #172124);
  font-family: inherit;
  line-height: 1.35;
  animation: pwa-install-enter 220ms ease-out both;
  backdrop-filter: blur(12px);
}

.pwa-install-prompt__icon {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 13px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 16%);
}

.pwa-install-prompt__content {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.pwa-install-prompt__content strong {
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pwa-install-prompt__content span {
  color: var(--muted, #647174);
  font-size: 0.78rem;
}

.pwa-install-prompt__action {
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--brand, #135d66);
  color: #fff;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.pwa-install-prompt__action:focus-visible,
.pwa-install-prompt__close:focus-visible {
  outline: 3px solid var(--accent, #e6a23c);
  outline-color: color-mix(in srgb, var(--accent, #e6a23c), white 20%);
  outline-offset: 2px;
}

.pwa-install-prompt__close {
  position: absolute;
  top: 5px;
  right: 7px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted, #647174);
  font: 500 24px/1 system-ui, sans-serif;
  cursor: pointer;
  place-items: center;
}

@keyframes pwa-install-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 821px) {
  body.pwa-install-visible {
    padding-bottom: 0;
  }

  .pwa-install-prompt {
    display: none !important;
  }
}

@media (max-width: 520px) {
  body.pwa-install-visible {
    padding-bottom: calc(164px + env(safe-area-inset-bottom));
  }

  .pwa-install-prompt {
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 12px 40px 12px 12px;
  }

  .pwa-install-prompt__icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .pwa-install-prompt__action {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (display-mode: standalone) and (max-width: 820px) {
  html {
    overscroll-behavior-y: none;
  }

  body > header.site-header:not([data-header]) {
    padding-top: max(16px, env(safe-area-inset-top)) !important;
  }

  header.site-header[data-header] > .site-header-inner {
    padding-top: env(safe-area-inset-top);
  }

  body > .topbar {
    padding-top: max(12px, env(safe-area-inset-top)) !important;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-install-prompt {
    animation: none;
  }
}

/* Folha de instruções de instalação (iOS e navegadores sem prompt nativo). */
.pwa-install-sheet {
  position: fixed;
  /* Acima do convite: vale para o fallback não-modal (iOS < 15.4). No top layer é ignorado. */
  z-index: 10001;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 24px);
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface, #ffffff);
  color: var(--ink, #172124);
  box-shadow: 0 -18px 50px rgb(0 0 0 / 24%);
  font-family: inherit;
  line-height: 1.4;
  overflow: auto;
}

.pwa-install-sheet::backdrop {
  background: rgb(0 0 0 / 45%);
}

.pwa-install-sheet[open] {
  animation: pwa-install-sheet-enter 240ms ease-out both;
}

.pwa-install-sheet__inner {
  display: grid;
  gap: 18px;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}

.pwa-install-sheet__header {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-right: 40px;
}

.pwa-install-sheet__header img {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 16%);
}

.pwa-install-sheet__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.pwa-install-sheet__hint {
  margin: 2px 0 0;
  color: var(--muted, #647174);
  font-size: 0.82rem;
}

.pwa-install-sheet__hint:empty {
  display: none;
}

.pwa-install-sheet__close {
  position: absolute;
  top: -4px;
  right: -6px;
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted, #647174);
  font: 500 26px/1 system-ui, sans-serif;
  cursor: pointer;
  place-items: center;
}

.pwa-install-sheet__steps {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: pwa-step;
}

.pwa-install-sheet__steps[hidden] {
  display: none;
}

.pwa-install-sheet__steps li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.pwa-install-sheet__steps strong {
  display: block;
  font-size: 0.98rem;
}

.pwa-install-sheet__steps span:not(.pwa-install-sheet__step-icon) {
  display: block;
  margin-top: 2px;
  color: var(--muted, #647174);
  font-size: 0.84rem;
}

.pwa-install-sheet__step-icon {
  display: grid;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--brand, #135d66);
  background: color-mix(in srgb, var(--brand, #135d66), transparent 88%);
  color: var(--brand, #135d66);
  place-items: center;
}

.pwa-install-sheet__done {
  min-height: 48px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--brand, #135d66);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}

.pwa-install-sheet__done:focus-visible,
.pwa-install-sheet__close:focus-visible {
  outline: 3px solid var(--accent, #e6a23c);
  outline-color: color-mix(in srgb, var(--accent, #e6a23c), white 20%);
  outline-offset: 2px;
}

@keyframes pwa-install-sheet-enter {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-install-sheet[open] {
    animation: none;
  }
}
