.mm-back-to-top {
  --scroll-progress: 0%;
  box-sizing: border-box;
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 56px;
  height: 56px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: linear-gradient(135deg, #7220a9, #501179);
  box-shadow: 0 12px 28px rgba(45, 14, 69, .28);
  color: #fff;
  cursor: pointer;
  font: 800 12px/1.2 Montserrat, system-ui, sans-serif;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(.86);
  transition: width .25s ease, opacity .22s ease, visibility .22s ease, transform .25s ease, box-shadow .25s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.mm-back-to-top__ring {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  padding: 3px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#ffda70 var(--scroll-progress), rgba(255, 255, 255, .22) 0);
}

.mm-back-to-top__core {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: #641991;
}

.mm-back-to-top__core svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: transform .25s ease;
}

.mm-back-to-top__label {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-6px);
  transition: max-width .25s ease, opacity .2s ease, transform .25s ease;
}

.mm-back-to-top:hover,
.mm-back-to-top:focus-visible {
  width: 140px;
  padding-right: 12px;
  box-shadow: 0 16px 34px rgba(45, 14, 69, .35);
}

.mm-back-to-top:hover .mm-back-to-top__label,
.mm-back-to-top:focus-visible .mm-back-to-top__label {
  max-width: 70px;
  opacity: 1;
  transform: translateX(0);
}

.mm-back-to-top:hover .mm-back-to-top__core svg,
.mm-back-to-top:focus-visible .mm-back-to-top__core svg {
  transform: translateY(-3px);
}

.mm-back-to-top:active { transform: translateY(1px) scale(.95); }
.mm-back-to-top:focus-visible { outline: 3px solid #ffda70; outline-offset: 3px; }

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

@media (hover: none) {
  .mm-back-to-top:hover { width: 56px; padding-right: 3px; }
  .mm-back-to-top:hover .mm-back-to-top__label { max-width: 0; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mm-back-to-top,
  .mm-back-to-top__label,
  .mm-back-to-top__core svg { transition: none; }
}
