Catherine Mintz playfully suggests that "it is a law of writing that wonderful things appear as soon as you are too tired to make notes."
Keeping a pen and paper at bedside is a logical remedy. I've done this for a dream journal, which has a slightly different objective, and I've done it for writing ideas at various times over the years. I don't any more, and here's why.
When I read over my notes in the cold, harsh light of day (not to mention an awake brain, with critical faculties online), those "brilliant" ideas fail the brilliancy test. It could be that they are indeed brilliant, but I'm not awake enough to write them down properly. It could also be that the very act of writing them down requires me to shift mental functioning (i.e., to wake up) enough to "lose" the creative connections. It could also be that they are indeed not all that brilliant, they only seem so at the time because I'm too sleepy to have any objective judgment.
I don't think any of these explanations is helpful. Moreover, it's entirely possible that the very act of writing down those sleeptime ideas and then struggling to put them into usable form is counterproductive. Consider daydreams. I believe they are most enjoyable when they have no other purpose than to let our imaginations wander as they will, indulging in whatever interests or pleases us at the moment. I also believe that this is a valuable part of the creative process, at least for writing. Don't know about sculpture or music.
Sleepytime inspirations are much the same -- illogical, bizarre, evanescent, apart from rational critical analysis. This does not mean they are without value. It's important to give our minds (and our creative muses) time to play. Play means we don't expect a utilitarian result. Play is for its own sake. But...
The very process of play, the freedom to do so, feeds into the "simmering soup pot" of ideas, images, connections, from which we draw our stories. Play enriches our inner landscapes, populating them with characters and events that connect with us. So what if we can't remember the next morning? Somewhere, something of value remains, waiting to emerge, perhaps in a totally different form.
I try not to fret about losing that one-and-only perfect solution. I remind myself that nothing creative is ever wasted... or lost. Instead of trying to hold on to a night's musings (muse-ings), I can gently direct my thoughts to a particular story or character or situation, night after night, trusting that if whatever arises in response is good and true, it will come back stronger every time. That makes it more likely to poke its head up when I am awake and focused -- oh yes, I remember you. Then I will have something to work with, using both my sleepytime mind and my rational alert mind in cooperative mode, neither trying to coerce or manage the other.
The image is by French painter Pierre Puvis de Chavannes (1824-1898)