Add the floating margins to the size of the panel not to overflow content when floating
Before:
After:
This is because we're adding the floating margin inside the panel's window, which means that the actual length of the panel ends up being (content length - floating margins). I'm just adding them back when we calculate the size of the panel.