Probably the easiest solution in this case is to go to Appearance -> Style Properties -> Messages. Under the message section (where you can add background, padding, etc) add margin-top: 3px !important; to the freeform CSS/LESS box.
You can also add, directly after that, &:before {margin-top: 0 !important;} to not add the top margin to the first post.
In your solution, you'll end up affecting all block elements, not messages.