/* ---------------------------------------------------------- 全站返回顶部
   右下角悬浮按钮，后台与前台共用；显隐由 js/backtop.js 控制（.is-on）
   层级 40：低于 toast(90) 与 lightbox(100)，高于普通内容
   ---------------------------------------------------------- */

.backtop {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 50%;
  background: var(--card);
  color: var(--ink-soft);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease,
              color .16s ease, border-color .16s ease;
  -webkit-tap-highlight-color: transparent;
}

.backtop.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.backtop:hover {
  color: var(--accent-deep);
  border-color: var(--accent);
}

.backtop:active {
  transform: translateY(1px);
}

.backtop:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.backtop svg {
  width: 18px;
  height: 18px;
  display: block;
}

@media (max-width: 640px) {
  .backtop {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: 40px;
    height: 40px;
  }
  .backtop svg { width: 17px; height: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .backtop { transition: none; }
}