.pg-back-to-top {
  position: fixed;
  z-index: 55;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
  width: 52px;
  height: 52px;
  border: 1px solid #5b8cff;
  background: #101216;
  color: #9dbbff;
  font: 500 10px/1.2 "JetBrains Mono", monospace;
  letter-spacing: .12em;
  text-decoration: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity .2s, background-color .2s, color .2s;
}

.pg-back-to-top.is-visible,
.pg-back-to-top:focus-visible {
  visibility: visible;
  opacity: 1;
}

.pg-back-to-top:hover,
.pg-back-to-top:focus-visible {
  background: #9dbbff;
  color: #101216;
}

@media (prefers-reduced-motion: reduce) {
  .pg-back-to-top { transition: none; }
}
