.scroll-top-button {
  position: fixed;
  z-index: 18;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--scroll-top-keyboard-offset, 0px));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  opacity: .96;
  transition: background-color .16s ease, color .16s ease, opacity .16s ease, transform .16s ease;
}

.scroll-top-button[hidden] { display: none !important; }
.scroll-top-button:hover { background: var(--primary-soft); color: var(--primary); }
.scroll-top-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.scroll-top-button:active { transform: translateY(1px); }
.scroll-top-button svg { width: 19px; height: 19px; }

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  html.learning-mode .scroll-top-button {
    bottom: calc(var(--learn-keyboard-offset, 0px) + var(--learn-footer-height, 80px) + 12px);
  }
}

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