Use scrollbar-gutter: stable to reserve scrollbar space and stop horizontal layout shift between pages or states that overflow vs. don't.
CSS Overflow Module Level 3 — scrollbar-gutter
web.dev — scrollbar-gutter and scrollbar-width are Baseline Newly available