This is the loft bed/desk I've been building for the past few days.
The room I use as an office is 8' by 10', with a 3x3' corner of that used by the attic stairs--plus it has 2 large windows and a total of 3 doors. Most of the time we've lived here, we have blocked off one or the other of the doors--otherwise there isn't much useful space in the room. That is why the picture is different colors-I couldn't get far enough away to get the whole thing in the picture at one time, so I took 3 and spliced them together.
I re-used a lot of stuff, including some lumber from a previous loft bed. The back of the rear shelf rests on a 2x4 strung across the bed legs, the front hangs from 1/4 threaded rod inserted into T nuts in the mattress support. The rail is 1/2" electrical conduit inserted into holes drilled into the wood. The first and last bar are screwed in place to hold the entire assembly together.
I'm very happy with the result so far. More desk space in the same basic area, as much storage, the lights work better with less glare--and there's now a guest bed, at least for a reasonably agile single guest.