/* Floating page navigation; gallery dialogs remain in the top layer. */
.sw-back-to-top {
  --top-tone: 24, 26, 30;
  --top-end: #42464e;
  --top-hover: #34383f;
  position: fixed;
  z-index: 45;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(104px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(247, 243, 235, .3);
  border-radius: 50%;
  background: rgba(var(--top-tone), .2);
  color: #f7f3eb;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 3px 16px #0002;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 220ms ease, visibility 220ms, transform 180ms ease, background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sw-back-to-top[data-theme="green"] {
  --top-tone: 19, 35, 26;
  --top-end: #315442;
  --top-hover: #254839;
}
.sw-back-to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.sw-back-to-top.is-at-end { background: var(--top-end); border-color: #c5a581; box-shadow: 0 4px 20px #0004; }
.sw-back-to-top svg { display: block; width: 21px; height: 21px; flex: none; filter: drop-shadow(0 1px 2px #0006); transition: transform 180ms ease; }
@media (hover: hover) {
  .sw-back-to-top:hover { background: var(--top-hover); border-color: #c5a581; box-shadow: 0 6px 22px #0004; transform: translateY(0); }
  .sw-back-to-top:hover > svg { animation: sw-top-bounce 850ms ease-in-out infinite; }
}
@keyframes sw-top-bounce {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-5px); }
}
.sw-back-to-top:active { transform: scale(.92); background: var(--top-end); }
.sw-back-to-top:focus-visible { outline: 2px solid #c5a581; outline-offset: 4px; background: var(--top-hover); }
@media (max-width: 760px) {
  .sw-back-to-top { right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); width: 44px; height: 44px; }
  .sw-back-to-top[data-theme="green"] { bottom: calc(88px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sw-back-to-top, .sw-back-to-top svg { transition: none; }
  .sw-back-to-top:hover > svg { animation: none; transform: none; }
}
