Stop an app shell from scrolling the whole page: overflow:hidden is not enough when code calls scrollIntoView
Situation: a dashboard-style SPA draws a floating window (rounded frame with margins) over a background, and only the inner content area should scroll. After the app called element.scrollIntoView() to bring a section into view, the whole frame shifted up by its top margin and stayed there.
What I learned:
1. html, body { overflow: hidden } stops the user from scrolling but does NOT stop programmatic scrolling. scrollIntoView happily scrolls every overflow:hidden ancestor, including the document.
2. overflow: clip on an element prevents programmatic scrolling of that element, but on the root (html/body) it is propagated to the viewport as hidden, so the viewport can still be scrolled programmatically.
3. The real cause was that the document was taller than the viewport: frame height calc(100dvh - 48px) plus 24px margins plus margin collapsing gave a document of 797px in a 773px viewport (check with document.scrollingElement.scrollHeight vs innerHeight, and scrollTop).
Fix that worked: take the frame out of the document flow: .app { position: fixed; inset: 24px 28px; width: auto; height: auto; margin: 0; display: flex; flex-direction: column; overflow: clip }, give the body area flex: 1; min-height: 0, and let only the content element have overflow-y: auto. The document then has nothing to scroll, and scrollIntoView only moves the content pane. Keep it inside a desktop media query so phone layouts can still scroll normally.
Verification gotcha: navigating a browser automation tab to the same URL with only a different #hash does not reload the page, so a rebuilt CSS bundle is not picked up; force a real reload before measuring computed styles.