#brx-content {
  scroll-margin-top: var(--header-height, 4.5rem);
}

.reading-tools {
  position: relative;
  z-index: var(--z-floating);
  pointer-events: none;
}

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: var(--motion-progress-height, 3px);
  background: color-mix(in srgb, currentColor 12%, transparent);
  pointer-events: none;
}

.reading-progress-fill {
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--brand-primary, #b42318);
  animation: weipei-reading-progress linear both;
  animation-timeline: scroll(root block);
}

@keyframes weipei-reading-progress {
  to { transform: scaleX(1); }
}

.back-to-top {
  position: fixed;
  right: max(var(--space-m), env(safe-area-inset-right));
  bottom: max(calc(var(--mobile-action-bar-height) + var(--space-m)), env(safe-area-inset-bottom));
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  padding: 0.65rem 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: var(--radius-pill);
  background: var(--surface, #fff);
  color: var(--brand-dark, #3e0703);
  box-shadow: var(--shadow-small);
  font: inherit;
  font-size: max(0.875rem, var(--text-s));
  line-height: 1;
  cursor: pointer;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  animation: weipei-back-to-top linear both;
  animation-timeline: scroll(root block);
  animation-range: 32rem 42rem;
}

@keyframes weipei-back-to-top {
  to {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
}

.back-to-top:hover {
  box-shadow: var(--shadow-hover);
}

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

@media (min-width: 768px) {
  .back-to-top {
    bottom: max(var(--space-l), env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .reading-progress-fill,
  .back-to-top { animation-duration: 0.01ms; }
}
