html,
body {
  min-height: 100%;
  min-height: 100dvh;
}

body {
  min-width: 0;
}

[data-pwa-install-page] {
  min-width: 320px;
}

[data-pwa-refresh-indicator] {
  position: fixed;
  z-index: 160;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  box-sizing: border-box;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  max-width: calc(100vw - 2rem);
  padding: 0.55rem 0.8rem;
  color: var(--text-primary, #172033);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  border-radius: 0.75rem;
  background: var(--surface-card, #ffffff);
  box-shadow: 0 0.55rem 1.5rem rgb(23 32 51 / 18%);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 1.5rem));
  transition:
    opacity 160ms ease-out,
    transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-pwa-refresh-indicator][data-pwa-refresh-origin="pull"] {
  z-index: 0;
  top: calc(env(safe-area-inset-top) + 0.625rem);
  justify-content: center;
  gap: 0;
  width: 2.5rem;
  min-height: 2.5rem;
  max-width: calc(100vw - 2rem);
  height: 2.5rem;
  padding: 0.625rem;
  overflow: hidden;
  border-radius: 999px;
  box-shadow: 0 0.35rem 1rem rgb(23 32 51 / 16%);
  transition:
    opacity 180ms ease-out,
    transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
    width 320ms cubic-bezier(0.16, 1, 0.3, 1),
    gap 260ms ease-out,
    padding 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-pwa-refresh-indicator][data-pwa-refresh-origin="pull"] [data-pwa-refresh-label] {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-0.25rem);
  transition:
    max-width 320ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 200ms ease-out,
    transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-pwa-refresh-indicator][data-pwa-refresh-origin="pull"][data-pwa-refresh-state="refreshing"] {
  gap: 0.55rem;
  width: min(12.25rem, calc(100vw - 2rem));
  min-height: 2.75rem;
  height: 2.75rem;
  padding: 0.625rem 0.85rem;
}

[data-pwa-refresh-indicator][data-pwa-refresh-origin="pull"][data-pwa-refresh-state="refreshing"] [data-pwa-refresh-label] {
  max-width: 9rem;
  opacity: 1;
  transform: translateX(0);
}

[data-pwa-refresh-indicator][data-pwa-refresh-state="pulling"],
[data-pwa-refresh-indicator][data-pwa-refresh-state="ready"],
[data-pwa-refresh-indicator][data-pwa-refresh-state="refreshing"],
[data-pwa-refresh-indicator][data-pwa-refresh-state="complete"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

[data-pwa-refresh-visual] {
  display: grid;
  flex: 0 0 1.25rem;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--sellpal-brand, #03c07f);
}

[data-pwa-refresh-visual] svg {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  transition: transform 180ms ease-out;
}

[data-pwa-refresh-indicator][data-pwa-refresh-state="ready"] [data-pwa-refresh-visual] svg {
  transform: rotate(180deg);
}

[data-pwa-refresh-indicator][data-pwa-refresh-state="refreshing"] [data-pwa-refresh-visual] svg {
  animation: sellpal-pwa-refresh-spin 1100ms linear infinite;
}

@keyframes sellpal-pwa-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive, DOM-backed iPhone UI scenes for the installation guide. */
[data-pwa-install-page] .ios-scene {
  --ios-accent: var(--sellpal-brand);
  --ios-ink: var(--text-primary);
  --ios-muted: var(--text-secondary);
  --ios-line: var(--border-default);
  --ios-surface: var(--surface-card);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  min-height: 13rem;
  padding: clamp(1rem, 5vw, 1.5rem);
  overflow: hidden;
  color: var(--ios-ink);
  font-size: 0.72rem;
  line-height: 1.25;
  background: linear-gradient(135deg, var(--state-selected-bg), var(--state-hover-bg));
}

[data-pwa-install-page] .ios-scene__device {
  flex: 1 1 13rem;
  min-width: 0;
  max-width: 27rem;
  overflow: hidden;
  border: 1px solid var(--ios-line);
  border-radius: 1.1rem;
  background: var(--ios-surface);
  box-shadow: 0 0.6rem 1.5rem rgb(15 23 42 / 10%);
}

[data-pwa-install-page] .ios-scene__device--phone {
  flex: 0 1 15rem;
  border-radius: 1.35rem;
}

[data-pwa-install-page] .ios-scene__device--dialog {
  flex-basis: 18rem;
}

[data-pwa-install-page] .ios-scene__device--confirm {
  flex-basis: 19rem;
}

[data-pwa-install-page] .ios-scene__browser-bar,
[data-pwa-install-page] .ios-scene__statusbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.15rem;
  padding: 0.45rem 0.65rem;
  color: var(--ios-muted);
  background: var(--state-hover-bg);
}

[data-pwa-install-page] .ios-scene__browser-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
}

[data-pwa-install-page] .ios-scene__browser-control {
  font-size: 0.64rem;
  font-weight: 700;
}

[data-pwa-install-page] .ios-scene__browser-control svg,
[data-pwa-install-page] .ios-scene__toolbar-icon svg,
[data-pwa-install-page] .ios-scene__status-icons svg,
[data-pwa-install-page] .ios-scene__action-chevron svg {
  display: block;
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

[data-pwa-install-page] .ios-scene__status-icons svg {
  width: 2rem;
  height: 0.8rem;
}

[data-pwa-install-page] .ios-scene__address {
  min-width: 0;
  padding: 0.25rem 0.55rem;
  overflow: hidden;
  color: var(--ios-ink);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 0.5rem;
  background: var(--ios-surface);
}

[data-pwa-install-page] .ios-scene__browser-content,
[data-pwa-install-page] .ios-scene__phone-content {
  display: grid;
  align-content: center;
  gap: 0.35rem;
  min-height: 6.25rem;
  padding: 1rem;
  color: var(--ios-ink);
  background: var(--ios-surface);
}

[data-pwa-install-page] .ios-scene__browser-content strong,
[data-pwa-install-page] .ios-scene__phone-content strong {
  font-size: 1rem;
}

[data-pwa-install-page] .ios-scene__browser-content span,
[data-pwa-install-page] .ios-scene__phone-content span {
  color: var(--ios-muted);
}

[data-pwa-install-page] .ios-scene__browser-toolbar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
  color: var(--ios-muted);
  border-top: 1px solid var(--ios-line);
}

[data-pwa-install-page] .ios-scene__toolbar-spacer {
  flex: 1;
}

[data-pwa-install-page] .ios-scene__share-button,
[data-pwa-install-page] .ios-scene__action-icon {
  display: grid;
  place-items: center;
  color: var(--ios-accent);
  border-radius: 0.55rem;
  background: var(--state-selected-bg);
}

[data-pwa-install-page] .ios-scene__share-button {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--ios-accent);
}

[data-pwa-install-page] .ios-scene__share-button svg,
[data-pwa-install-page] .ios-scene__action-icon svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

[data-pwa-install-page] .ios-scene__statusbar {
  justify-content: space-between;
  min-height: 1.6rem;
  padding-block: 0.3rem;
  font-size: 0.64rem;
  font-weight: 700;
}

[data-pwa-install-page] .ios-scene__phone-content {
  min-height: 5rem;
  background: var(--state-hover-bg);
}

[data-pwa-install-page] .ios-scene__share-sheet {
  display: grid;
  gap: 0.55rem;
  padding: 0.65rem 0.8rem 0.8rem;
  border-top: 1px solid var(--ios-line);
  border-radius: 1rem 1rem 0 0;
  background: var(--ios-surface);
}

[data-pwa-install-page] .ios-scene__sheet-grabber {
  width: 2.2rem;
  height: 0.22rem;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--ios-line);
}

[data-pwa-install-page] .ios-scene__share-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  color: var(--ios-muted);
  text-align: center;
}

[data-pwa-install-page] .ios-scene__action {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.45rem;
  border-radius: 0.65rem;
}

[data-pwa-install-page] .ios-scene__action--selected {
  color: var(--ios-ink);
  background: var(--state-selected-bg);
  box-shadow: inset 0 0 0 1px var(--ios-accent);
}

[data-pwa-install-page] .ios-scene__action-icon {
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
}

[data-pwa-install-page] .ios-scene__action-chevron {
  margin-left: auto;
  color: var(--ios-muted);
}

[data-pwa-install-page] .ios-scene__dialog-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem;
  border-bottom: 1px solid var(--ios-line);
}

[data-pwa-install-page] .ios-scene__dialog-title span:last-child {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

[data-pwa-install-page] .ios-scene__dialog-title small {
  color: var(--ios-muted);
  font-size: 0.68rem;
}

[data-pwa-install-page] .ios-scene__app-icon {
  display: grid;
  flex: 0 0 2.4rem;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  color: var(--text-inverse);
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: 0.7rem;
  background: var(--ios-accent);
}

[data-pwa-install-page] .ios-scene__field,
[data-pwa-install-page] .ios-scene__toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.72rem 0.8rem;
  border-bottom: 1px solid var(--ios-line);
}

[data-pwa-install-page] .ios-scene__field span {
  color: var(--ios-muted);
}

[data-pwa-install-page] .ios-scene__field strong {
  padding: 0.28rem 0.5rem;
  border-radius: 0.4rem;
  background: var(--state-hover-bg);
}

[data-pwa-install-page] .ios-scene__toggle-row > span:first-child {
  max-width: 14rem;
}

[data-pwa-install-page] .ios-scene__toggle {
  display: flex;
  align-items: center;
  flex: 0 0 2.4rem;
  width: 2.4rem;
  height: 1.45rem;
  padding: 0.15rem;
  border-radius: 999px;
  background: var(--ios-accent);
}

[data-pwa-install-page] .ios-scene__toggle span {
  width: 1.15rem;
  height: 1.15rem;
  margin-left: auto;
  border-radius: 50%;
  background: var(--text-inverse);
}

[data-pwa-install-page] .ios-scene__dialog-actions,
[data-pwa-install-page] .ios-scene__confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.7rem 0.8rem 0.8rem;
  color: var(--ios-muted);
  text-align: center;
}

[data-pwa-install-page] .ios-scene__dialog-actions strong,
[data-pwa-install-page] .ios-scene__confirm-actions strong {
  color: var(--ios-accent);
}

[data-pwa-install-page] .ios-scene__confirm-copy {
  margin: 0;
  padding: 0.8rem;
  color: var(--ios-muted);
}

[data-pwa-install-page] .ios-scene__confirm-actions {
  border-top: 1px solid var(--ios-line);
}

[data-pwa-install-page] .ios-scene__hint {
  flex: 0 1 9rem;
  min-width: 8rem;
  color: var(--ios-muted);
}

[data-pwa-install-page] .ios-scene__hint span,
[data-pwa-install-page] .ios-scene__hint strong {
  display: block;
}

[data-pwa-install-page] .ios-scene__hint span {
  margin-bottom: 0.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

[data-pwa-install-page] .ios-scene__hint strong {
  color: var(--ios-ink);
  font-size: 0.8rem;
}

@media (max-width: 30rem) {
  [data-pwa-install-page] .ios-scene {
    align-items: stretch;
  }

  [data-pwa-install-page] .ios-scene__device,
  [data-pwa-install-page] .ios-scene__device--phone,
  [data-pwa-install-page] .ios-scene__device--dialog,
  [data-pwa-install-page] .ios-scene__device--confirm {
    flex-basis: 100%;
    max-width: none;
  }

  [data-pwa-install-page] .ios-scene__hint {
    flex-basis: 100%;
    min-width: 0;
  }
}

.sellpal-pwa-install-sheet {
  width: min(100%, 34rem);
  max-width: none;
  max-height: min(86dvh, 46rem);
  margin: auto auto 0;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 1.25rem 1.25rem 0 0;
  background: transparent;
  box-shadow: 0 -0.75rem 2.5rem rgba(23, 32, 51, 0.18);
  overscroll-behavior: contain;
}

.sellpal-pwa-install-sheet::backdrop {
  background: rgba(23, 32, 51, 0.48);
}

@media (min-width: 40rem) {
  .sellpal-pwa-install-sheet {
    margin-bottom: 1.5rem;
    border-radius: 1.25rem;
  }
}

@supports (padding: env(safe-area-inset-top)) {
  @media (display-mode: standalone) {
    body {
      padding-top: env(safe-area-inset-top);
      padding-right: env(safe-area-inset-right);
      padding-bottom: env(safe-area-inset-bottom);
      padding-left: env(safe-area-inset-left);
    }
  }

  [data-pwa-status] {
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
  }

  [data-pwa-install-page] {
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
}

@media (display-mode: standalone) {
  html,
  body {
    overscroll-behavior-y: none;
  }

  html {
    background: #f3f4f6;
  }

  body {
    overflow-x: hidden;
  }

  [data-pwa-pull-surface] {
    position: relative;
    z-index: 1;
    background-color: inherit;
    transform: translate3d(0, var(--pwa-pull-offset, 0), 0);
  }

  [data-pwa-pull-surface][data-pwa-pull-surface-state="pulling"] {
    will-change: transform;
  }

  [data-pwa-pull-surface][data-pwa-pull-surface-state="settling"],
  [data-pwa-pull-surface][data-pwa-pull-surface-state="refreshing"] {
    will-change: transform;
    transition: transform 360ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  [data-pwa-browser-only] {
    display: none;
  }
}

[data-pwa-offline] {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1rem;
  box-sizing: border-box;
  background: #f3f4f6;
  color: #172033;
  font-family: system-ui, sans-serif;
}

[data-pwa-offline] main {
  width: min(100%, 32rem);
  text-align: center;
}

[data-pwa-offline] img {
  border-radius: 1.5rem;
}

[data-pwa-offline] a {
  display: inline-block;
  min-height: 44px;
  padding: 0.75rem 1rem;
  box-sizing: border-box;
  border: 0;
  border-radius: 0.75rem;
  background: #03c07f;
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  [data-pwa-refresh-indicator],
  [data-pwa-refresh-visual] svg,
  [data-pwa-pull-surface] {
    transition: none;
  }

  [data-pwa-refresh-indicator][data-pwa-refresh-state="refreshing"] [data-pwa-refresh-visual] svg {
    animation-duration: 1.5s;
  }
}
