.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 998;
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 50%;
  background: var(--nav-color, #ffffff);
  color: var(--text-color, #1a1a1a);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top i {
  font-size: 28px;
  line-height: 1;
}

.back-to-top:hover {
  border-color: #ef1111;
  background: #ef1111;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 17, 17, 0.4);
}

.back-to-top:focus-visible {
  outline: 3px solid rgba(239, 17, 17, 0.55);
  outline-offset: 3px;
}

@media (max-width: 768px) {
  .back-to-top {
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(32px + env(safe-area-inset-bottom));
    width: 44px;
  }
}
