/* Pull-to-refresh lives above routed pages but below sheets/toasts/navigation. */
.pull-refresh {
  position: absolute;
  z-index: 36;
  top: calc(var(--safe-t) + 10px);
  left: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  max-width: min(calc(100% - 32px), 280px);
  padding: 7px 12px;
  color: var(--text-2);
  background: color-mix(in srgb, var(--surface-2) 94%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  box-shadow: var(--sh-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 20px)) scale(0.9);
  transition:
    opacity var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) ease;
  will-change: transform, opacity;
}

.pull-refresh-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--gold-2);
  background: var(--gold-soft);
  border-radius: 50%;
  transition: transform var(--dur) var(--ease-out), background var(--dur-fast) ease;
}

.pull-refresh-label {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.45;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.app-shell.is-pulling .pull-refresh,
.app-shell.is-refreshing .pull-refresh {
  opacity: 1;
  transform: translate(-50%, min(calc(var(--pull-distance, 0px) - 52px), 22px)) scale(1);
}

.app-shell.is-pull-armed .pull-refresh {
  color: var(--text);
  border-color: var(--gold-ring);
}

.app-shell.is-pull-armed .pull-refresh-icon {
  color: var(--on-gold);
  background: var(--grad-gold);
  transform: rotate(180deg);
}

.app-shell.is-refreshing .pull-refresh {
  transform: translate(-50%, 8px) scale(1);
}

.app-shell.is-refreshing .pull-refresh-icon {
  color: var(--on-gold);
  background: var(--grad-gold);
  animation: pull-refresh-spin 760ms linear infinite;
}

.pull-refresh.is-complete .pull-refresh-icon {
  animation: none;
  color: #062b1d;
  background: var(--success);
}

.pull-refresh.is-error {
  border-color: color-mix(in srgb, var(--danger) 65%, transparent);
}

.pull-refresh.is-error .pull-refresh-icon {
  animation: none;
  color: #fff;
  background: var(--danger);
}

.app-shell.is-pull-resetting .pull-refresh {
  transition-duration: 260ms;
}

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

@media (min-width: 768px) {
  .pull-refresh {
    /* Keep the feedback centred in the content pane, not across the side rail. */
    left: calc(50% - (var(--tablet-rail, 86px) / 2));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pull-refresh,
  .pull-refresh-icon { transition: none; }
  .app-shell.is-refreshing .pull-refresh-icon { animation-duration: 1.5s; }
}

