
:root{
  --btt-offset: 18px;
  --btt-threshold: 280px;
  --btt-lift: 0px;
}

.btt{
  position: fixed;
  right: max(var(--btt-offset), env(safe-area-inset-right));
  bottom: calc(var(--btt-offset) + env(safe-area-inset-bottom) + var(--btt-lift));

  inline-size: 52px;
  block-size: 52px;

  display: flex;
  align-items: center;
  justify-content: center;

  background-color: var(--violet, #7B48E8);
  color: #fff;

  border: none;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: .3s ease-in-out;

  box-shadow: 0 8px 18px rgba(0,0,0,.15);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);

  overflow: hidden;
  cursor: pointer;
}
.btt.visible{ opacity:1; transform: translateY(0); }
.btt.hidden{ pointer-events:none; }

.btt svg{ width:22px; height:22px; }
.btt svg path{ fill: currentColor; }

.btt:hover{
  background: #9464f9;
  box-shadow:
    0 0 17px #b492ff,
    inset 0 0 19px rgba(255,255,255,.31);
}
.btt:active{ transform: translateY(1px) scale(.985); }
.btt:focus-visible{
  outline: none;
  box-shadow:
    0 0 17px #b492ff,
    inset 0 0 19px rgba(255,255,255,.31),
    0 0 0 3px rgba(123,72,232,.35);
}

@media (max-width: 420px){
  .btt{ inline-size:48px; block-size:48px; right:14px; }
}

@media (max-width: 767px){
  .btt{
    bottom: calc(
      var(--btt-offset) +
      env(safe-area-inset-bottom) +
      max(var(--btt-lift), 70px)
    );
    right:14px;
  }
}
@media (min-width:768px) and (max-width:1024px){
  .btt{
    bottom: calc(
      var(--btt-offset) +
      env(safe-area-inset-bottom) +
      max(var(--btt-lift), 80px)
    );
  }
}

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