/* Autoscroll control */
.autoscroll-btn.active {
  background: var(--accent, #ff2d78);
  color: #fff;
  border-color: transparent;
}
.autoscroll-btn .as-icon {
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}
.autoscroll-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px calc(12px + var(--safe-r)) 6px calc(12px + var(--safe-l));
  background: var(--glass-bar);
  backdrop-filter: blur(var(--glass-blur, 16px)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur, 16px)) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: calc(60px + var(--safe-t, 0px));
  z-index: 35;
}
.autoscroll-chip[hidden] { display: none !important; }
.autoscroll-chip .as-chip-label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
  flex-shrink: 0;
}
.autoscroll-chip .as-chip-val {
  font-size: 12px;
  font-weight: 700;
  min-width: 1.6em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.autoscroll-chip .as-speed {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent, #ff2d78);
  height: 28px;
  cursor: pointer;
}
.autoscroll-chip .as-stop {
  flex-shrink: 0;
  appearance: none;
  border: 1px solid var(--glass-border);
  background: var(--accent, #ff2d78);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
}
.autoscroll-chip .as-stop:active {
  transform: scale(0.96);
}

/*
 * ROOT CAUSE FIX: swipe-lock.css sets overflow-x:hidden on html/body, which
 * breaks position:sticky. Once autoscroll moves the page, the sticky topbar
 * (toggle) and sticky chip scroll off-screen — user can't stop. While ON,
 * pin both with position:fixed so Stop + Speed stay tappable.
 */
body.has-autoscroll-chip {
  /* topbar ~60px + chip ~40px + safe-area */
  padding-top: calc(100px + var(--safe-t, 0px));
}
body.has-autoscroll-chip .topbar {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  transform: none !important;
  z-index: 50;
}
body.has-autoscroll-chip .autoscroll-chip {
  position: fixed !important;
  top: calc(60px + var(--safe-t, 0px));
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  transform: none !important;
  z-index: 49;
  box-shadow: 0 2px 12px var(--shadow, rgba(0, 0, 0, 0.12));
}

@media (min-width: 600px) and (orientation: portrait) {
  body.has-autoscroll-chip .topbar,
  body.has-autoscroll-chip .autoscroll-chip {
    left: 50%;
    right: auto;
    width: 100%;
    max-width: 580px;
    transform: translateX(-50%) !important;
  }
}
@media (min-width: 720px) {
  .autoscroll-chip {
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 580px;
  }
  body.has-autoscroll-chip .topbar,
  body.has-autoscroll-chip .autoscroll-chip {
    left: 50%;
    right: auto;
    width: 100%;
    max-width: 580px;
    transform: translateX(-50%) !important;
  }
}
