Ok, so the inside of the bed w/ tail closed is ~61in. Diagonally its ~76in, minus the distance you loose from the geometry of the tire. And with the tailgate down, its ~81in from the edge of the tail to inside of the bed.
its like ~17 and 7/8in from the lowest spot on the bed. The ribs are about a 1/2in. So excluding the wheel wells, anything 17in or less should fit under the top of the railing, siting on top of the ribs.