Bank's Interest Margin

Hello everyone,
Can someone explain to me why banks are to lose when the yield curve flattens?
Supposedly they “borrow short and lend long” so a flattening yield curve means a smaller margin.
However, my experience with banks is that they lend on a floating rate, so for example LIBOR + 3%. So no matter what happens with LIBOR, or whether the yield curve is flat or steep, the banks will still make 3% margin on that loan.
What am I missing?
Thanks for taking the time to explain.

The bank doesn’t borrow at LIBOR. LIBOR is the rate of its debt, but debt is a small part of funding.

Also, different loans are structured differently. Commercial loans are floating rate, but they also have ceilings and floors.

Other loans, like real estate, are fixed.

And as rates change, borrowers change. When rates start going up, borrowers lock in fixed rates while funding costs keep rising.

The impact on margin depends on the combination of all these factors on the asset and liability side. As a result, every bank has a different exposure. Some benefit from rising rates, others are hurt. Almost universally, flattening yield curve hurts.