One of the most popular design posts ever on TreeHugger was about Emmanuel Combarel Dominique Marrec's design for a bed in a box in a French apartment. That was permanent and hung from the ceiling; now French hardware chain Leroy Merlin shows how you can build your own bed in a box. Their clever design is on heavy duty casters and can roll around your loft.PDF here) in French, but with good comprehensible drawings. It has a lot of plywood or MDF panels running at 1 metre by 2 metres (39 inches by 78 inches) so there is going to be a fair bit of waste cut out of North American 4x8 sheets of plywood.
North Americans are often not comfortable with niche beds like this, where you cannot walk around the bed to make it. It works best with a duvet that you can just throw from one end. The 20" gap is probably wide enough to squeeze though in a pinch if you don't want to wake your partner.
More at du cote de chez vous