On second thoughts, I think my idea can be simplified by setting the in-focus panel to never scroll out of view or be covered by other panels, so that its edges effectively become the edges on which other panels stack. (See screenshots)
To be clear, although I use the word locked in the screenshots, I don’t mean locking the position of the panel. You could scroll it to the left or right hand side, but it would never scroll out of focus. This means if you want to change the panels that you’re comparing, it would just be a case of scrolling until the other panel appears, or clicking the other panel into focus.
One thing that might not be ideal about this implementation is having a lot of unused space (titles) between the panels being compared, making it hard to switch your eyes between them. This could be resolved by adding a function to shift-click the title of a panel to rearrange it and make it the next panel over from the one that’s in-focus.