.back-to-top {
  position: fixed;
  z-index: 90;
  right: clamp(18px, 2.4vw, 36px);
  bottom: max(clamp(18px, 2.4vw, 34px), env(safe-area-inset-bottom));
  width: 50px;
  height: 50px;
  padding: 0;
  border: 1px solid rgba(244, 216, 146, .82);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fffdf8;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 242, 196, .34), transparent 31%),
    linear-gradient(145deg, #ddb65b, #9c6b20 58%, #c99637);
  box-shadow: 0 13px 30px rgba(77, 51, 12, .2), inset 0 1px 0 rgba(255, 255, 255, .36);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(.92);
  transition:
    opacity .34s ease,
    visibility .34s ease,
    transform .42s cubic-bezier(.22, 1, .36, 1),
    box-shadow .3s ease,
    filter .3s ease;
}

.back-to-top::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 249, 227, .2);
  border-radius: 3px;
  pointer-events: none;
}

.back-to-top > span {
  position: relative;
  width: 17px;
  height: 20px;
  display: block;
}

.back-to-top > span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 10px;
  height: 10px;
  border-top: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  transform: translateX(-50%) rotate(45deg);
}

.back-to-top > span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 1.5px;
  height: 16px;
  border-radius: 999px;
  background: currentColor;
  transform: translateX(-50%);
}

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

.back-to-top:is(:hover, :focus-visible) {
  filter: brightness(1.07);
  box-shadow: 0 17px 34px rgba(77, 51, 12, .27), inset 0 1px 0 rgba(255, 255, 255, .45);
  transform: translateY(-3px) scale(1.02);
  outline: none;
}

.back-to-top:active {
  transform: translateY(-1px) scale(.98);
}

@media (max-width: 620px) {
  .back-to-top {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: opacity .2s ease, visibility .2s ease; }
}
