New walls, redesigned bridges and restored floodplains: towns in a small German valley are testing how they can survive the next extreme flood.