/* 全站返回顶部 */
.back-to-top {
  --btt-size: 56px;
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  z-index: 1150;
  width: var(--btt-size);
  height: var(--btt-size);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary, #2b7cd3);
  color: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 0.22s ease,
    visibility 0.22s ease,
    transform 0.22s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

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

.back-to-top:hover {
  background: var(--color-primary-dark, #1f6ab8);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.22);
}

.back-to-top:focus-visible {
  outline: 2px solid var(--color-primary, #2b7cd3);
  outline-offset: 3px;
}

.back-to-top__icon {
  width: 24px;
  height: 24px;
  display: block;
}

@media (max-width: 767px) {
  .back-to-top {
    --btt-size: 52px;
    right: 12px;
    bottom: 18px;
  }

  .back-to-top__icon {
    width: 22px;
    height: 22px;
  }
}

/* 有 Cookie 条时略抬高，避免重叠 */
body:has(.cookie-consent:not([hidden])) .back-to-top {
  bottom: max(88px, calc(18px + env(safe-area-inset-bottom, 0px)));
}

body.pageset-mode .back-to-top,
html.pageset-on .back-to-top {
  display: none !important;
}
