.back-to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 45;
  display: grid;
  inline-size: 44px;
  block-size: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(18, 86, 105, 0.24);
  border-radius: 14px;
  background: rgba(247, 251, 252, 0.86);
  color: #155b70;
  box-shadow: 0 8px 24px rgba(11, 46, 59, 0.14), 0 1px 3px rgba(11, 46, 59, 0.11);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(9px) scale(0.96);
  transition: opacity 180ms ease, transform 220ms ease, color 180ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.back-to-top[hidden] { display: none; }
.back-to-top.is-visible { opacity: 0.84; pointer-events: auto; transform: translateY(0) scale(1); }
.back-to-top svg { inline-size: 20px; block-size: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.back-to-top:hover { border-color: rgba(18, 111, 127, 0.38); background: rgba(250, 254, 255, 0.96); color: #087f87; box-shadow: 0 10px 27px rgba(11, 46, 59, 0.18), 0 1px 4px rgba(11, 46, 59, 0.12); opacity: 1; transform: translateY(-2px); }
.back-to-top:active { transform: translateY(0) scale(0.97); }
.back-to-top:focus-visible { outline: 3px solid rgba(30, 147, 155, 0.34); outline-offset: 3px; opacity: 1; }
body.menu-page-dimmed .back-to-top,
body.site-search-open .back-to-top,
.site-header.mobile-menu-open ~ .back-to-top,
html.image-viewer-open .back-to-top { opacity: 0; pointer-events: none; transform: translateY(9px) scale(0.96); }

@media (max-width: 700px) {
  .back-to-top { right: max(12px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); inline-size: 40px; block-size: 40px; border-radius: 13px; }
  .back-to-top svg { inline-size: 18px; block-size: 18px; }
}

@media (prefers-reduced-motion: reduce) { .back-to-top { transition: none; } }
@media print { .back-to-top { display: none !important; } }
