.back-to-top {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #bfc7b9;
  border-radius: 50%;
  background: #f8f7f0;
  color: #455848;
  font: 22px/1 system-ui, sans-serif;
  cursor: pointer;
  visibility: hidden;
  opacity: 0;
  transition: opacity .18s ease, background-color .18s ease, color .18s ease;
}

.back-to-top[data-visible] {
  visibility: visible;
  opacity: 1;
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: #455848;
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}
