.scrollsmith-top-sentinel {
  position: absolute;
  z-index: -1;
  inset: 0 auto auto 0;
  width: 1px;
  height: min(55vh, 34rem);
  pointer-events: none;
}

.scrollsmith-back-to-top {
  position: fixed;
  z-index: 40;
  right: max(1.75rem, env(safe-area-inset-right));
  bottom: max(1.75rem, env(safe-area-inset-bottom));
  min-height: 46px;
  padding: 0.72rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--line, rgb(240 240 232 / 0.22));
  border-radius: 0;
  background: var(--surface, #202521);
  color: var(--ink, #f0f0e8);
  box-shadow: 0 12px 32px rgb(5 8 6 / 0.2);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms,
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.scrollsmith-back-to-top[data-visible] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.scrollsmith-back-to-top:hover {
  border-color: var(--accent, #e86243);
  background: var(--accent, #e86243);
  color: #101411;
}

.scrollsmith-back-to-top:active {
  transform: translateY(1px);
}

.scrollsmith-back-to-top:focus-visible {
  outline: 3px solid var(--accent, #e86243);
  outline-offset: 4px;
}

.scrollsmith-back-to-top > span {
  font-size: 1rem;
  line-height: 0.75;
}

html[data-mode="light"] .scrollsmith-back-to-top {
  background: var(--surface, #f7f6f1);
  color: var(--ink, #1a1f1b);
  box-shadow: 0 12px 32px rgb(36 42 37 / 0.14);
}

html[data-mode="light"] .scrollsmith-back-to-top:hover {
  background: var(--accent, #e86243);
  color: #101411;
}

@media (max-width: 600px) {
  .scrollsmith-back-to-top {
    right: max(1.25rem, env(safe-area-inset-right));
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    min-height: 44px;
    padding-inline: 0.85rem;
    font-size: 0.64rem;
  }
}

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