.back-to-top {
  position: fixed;
  z-index: 40;
  right: max(32px, calc(env(safe-area-inset-right) + 28px));
  bottom: max(32px, calc(env(safe-area-inset-bottom) + 18px));
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid #466047;
  border-radius: 50%;
  background: #365037;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 14px #25392535;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease, visibility .22s, background-color .18s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover { background: #29412c; }
.back-to-top:active { background: #213624; }

.back-to-top:focus-visible {
  outline: 2px solid #e4a833;
  outline-offset: 3px;
}

.back-to-top svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 600px) {
  .back-to-top {
    right: max(22px, calc(env(safe-area-inset-right) + 18px));
    bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px));
    width: 44px;
    height: 44px;
  }
}

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