There’s no such thing as downtime for your brain. You think you’re able to shut off your thoughts sometimes — when you’re lost in a movie, meditating, practicing yoga. And you certainly think that the brain gets at least a little break when you’re sleeping. That, however, turns out to be when your brain does some of its best work — and we should all be grateful. In this week’s issue of TIME (available to subscribers here), I explore how sleeptime can be the brain’s most creative hours — a state of consciousness in which some of humanity’s great works of art and engineering have been conceived, not to mention the solutions to some of your own daytime concerns.

We’re all familiar with the idea of sleeping on a problem and having it sort itself out, or of going to bed after an evening of cramming for finals and waking up to find that, far from having forgotten what we learned, we actually seem to understand it better. Paul McCartney has said that the melody for “Yesterday” came to him in a dream. Billy Joel says the same is true for every song he’s ever written. Stephen King has literally dreamed up some of the most surreal scenes in his books and Mary Shelley came up with the idea of Frankenstein the same way. And if you’ve ever used a sewing machine, you can thank a dream inventor Elias Howe had in which he saw himself being attacked by people bearing spears with holes in the pointed end. That was the inspiration for the design of the needle.

Nocturnal creativity had long been familiar to scientists, but only now, with the help of sophisticated imaging technology — PET scans, fMRIs, high-density EEGs and more — have they been able to see the brain in action. They’re learning about how the powering-down of the prefrontal cortex effectively shuts off the cognitive censor and the powering up of the visual and other cortices gives rise to new and untried combinations of ideas. They’re learning too how the left and right hemispheres communicate with each other in ways they don’t during the day, and how nighttime increases in the level of cortisol — usually thought of as a stress hormone — foster creativity in a counterintuitive way. When we’re awake, cortisol can fragment memories — one reason eyewitness crime scene accounts are so unreliable. But at night that very fragmentation allows creative recombinations of ideas.

Most important, investigators are learning more about how we can all foster our own nighttime creativity. We may never be a McCartney or an Elias Howe, but we can work to tap the wellspring of ideas that flow when we’re sleeping and wake up with fresh inspirations we didn’t have before.