/* Scroll-to-top FAB — san-control.ru */
.sc-totop {
  --tt-size: 48px;
  --tt-primary: #277A58;
  --tt-accent: #20A063;
  --tt-shadow: 0 8px 24px rgba(31, 97, 70, 0.28);
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  /* Above Jivo chat (~72px) + gap */
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 980;
  width: var(--tt-size);
  height: var(--tt-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--tt-primary);
  box-shadow: var(--tt-shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 12px, 0) scale(0.92);
  transition:
    opacity 0.22s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.22s,
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.sc-totop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
}
.sc-totop.is-hidden-ui {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.sc-totop:hover {
  background: var(--tt-accent);
  color: #fff;
  box-shadow: 0 10px 28px rgba(32, 160, 99, 0.36);
}
.sc-totop:focus-visible {
  outline: 2px solid var(--tt-accent);
  outline-offset: 3px;
}
.sc-totop:active {
  transform: scale(0.96);
}

.sc-totop__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.sc-totop__track {
  fill: none;
  stroke: #E2E8F0;
  stroke-width: 2.5;
}
.sc-totop__progress {
  fill: none;
  stroke: var(--tt-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 113.1;
  transition: stroke-dashoffset 0.08s linear;
}
.sc-totop:hover .sc-totop__track {
  stroke: rgba(255, 255, 255, 0.35);
}
.sc-totop:hover .sc-totop__progress {
  stroke: #fff;
}

.sc-totop__icon {
  width: 20px;
  height: 20px;
  display: block;
  position: relative;
  z-index: 1;
}

/* Mobile: above bottom bar + Jivo */
@media (max-width: 982px) {
  .sc-totop {
    --tt-size: 44px;
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(100px + env(safe-area-inset-bottom));
  }
  body.sc-header-on .sc-totop {
    bottom: calc(var(--sc-mobile-bottom-h, 60px) + env(safe-area-inset-bottom) + 100px);
  }
}

/* Desktop: above Jivo with smaller gap */
@media (min-width: 983px) {
  .sc-totop {
    right: max(28px, env(safe-area-inset-right));
    bottom: calc(40px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-totop,
  .sc-totop__progress {
    transition: none !important;
  }
}
