.scroll-top {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: #1c2fd3;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
}

.scroll-top--visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.scroll-top:hover {
  background-color: #4053dc;
}

body.modal-open .scroll-top,
body.modal-open .b24-widget-button-wrapper {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 767px) {
  .scroll-top {
    right: auto;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    width: 44px;
    height: 44px;
  }

  /* Keep Bitrix24 clear of the browser's native bottom-right controls. */
  .b24-widget-button-wrapper.b24-widget-button-position-bottom-right {
    right: 16px !important;
    bottom: calc(132px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body:has(.material__widget) .scroll-top,
  body:has(.material__widget) .b24-widget-button-wrapper.b24-widget-button-position-bottom-right {
    bottom: calc(152px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
