Need solution for safety gate at top of stairs

L

So I'm trying to figure out what to do to block the top of our stairs. We live in a townhouse and theres a long set of stairs from the front door to the main level living. As you can see there is no "wall" at the top to mount a gate to. And I dont think putting one on the top step is a possibility either because of the banister and there is also molding along the bottom of the wall that sticks out.

We also can't put a gate anywhere further back because of the bathroom door..

From there the space opens up entirely. Any ideas on what I can do?