.back-to-top {
  position: fixed;
  z-index: 7;
  inset-inline-end: max(1rem, calc(0.75rem + env(safe-area-inset-right, 0px)));
  inset-block-end: calc(1rem + env(safe-area-inset-bottom, 0px));
  display: grid;
  place-items: center;
  width: var(--touch-target);
  height: var(--touch-target);
  padding: 0;
  color: var(--navy);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--paper-depth);
  cursor: pointer;
}

.back-to-top[hidden],
:root:has(dialog[open]) .back-to-top {
  display: none;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

@media (hover: hover) {
  .back-to-top:hover {
    color: var(--accent-text);
    background: var(--paper-linen);
  }
}
