:root {
  --accent: #70aaff;
  --surface: #071a35;
  --track: rgba(255, 255, 255, .15);
}

.back-to-top {
  --scroll-button-size: 48px;
  position: fixed;
  z-index: 70;
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: grid;
  width: var(--scroll-button-size);
  height: var(--scroll-button-size);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  overflow: visible;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #0a2142, var(--surface));
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .24s ease, visibility .24s ease, transform .24s ease, box-shadow .24s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.back-to-top.is-visible:hover {
  transform: translateY(-2px);
  background: linear-gradient(145deg, #0a2142, var(--surface));
  box-shadow: 0 6px 16px rgba(0, 0, 0, .36), 0 0 18px color-mix(in srgb, var(--accent) 28%, transparent);
}

.back-to-top:active {
  transform: scale(.95);
}

.back-to-top.is-visible:active {
  transform: scale(.95);
}

.back-to-top:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.back-to-top .scroll-progress-ring {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  pointer-events: none;
}

.back-to-top .scroll-progress-track,
.back-to-top .scroll-progress-value {
  fill: none;
  stroke-width: 3;
}

.back-to-top .scroll-progress-track {
  stroke: var(--track);
}

.back-to-top .scroll-progress-value {
  stroke: var(--accent);
  stroke-dasharray: 141.37;
  stroke-dashoffset: 141.37;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 24px 24px;
  transition: stroke .24s ease;
}

.back-to-top:hover .scroll-progress-value {
  stroke: color-mix(in srgb, var(--accent) 78%, white);
}

.back-to-top .scroll-progress-icon {
  position: relative;
  z-index: 1;
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s ease;
}

.back-to-top:hover .scroll-progress-icon {
  transform: translateY(-2px);
}

body.has-connect-dial #back-to-top {
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

body.has-package-bar #back-to-top {
  bottom: calc(164px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 640px) {
  .back-to-top {
    --scroll-button-size: 44px;
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  body.has-connect-dial #back-to-top {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  body.has-package-bar #back-to-top {
    bottom: calc(164px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top,
  .scroll-progress-value,
  .scroll-progress-icon {
    transition: none;
  }
}
