Theodore Twombly, the hero of the touching futuristic love story “Her,” is a hopeless romantic. That’s a benefit on his job. His empathy allows him to compose custom-tailored personal messages for In a blissful dream state he pours out other people’s innermost feelings, while his desktop computer transcribes it in longhand.

In real life, however, emotional sensitivity is a mixed bag. Wounded by his impending divorce, too forlorn for the dating scene, he’s uncertain how to move on in life. In an unnamed near-future metropolis — imagine L.A. larger, cleaner, full of consumer comforts but still communally lonely — he’s adrift and anonymous.

Like most of the film’s background extras, he spends his time talking to his gadgets. “Play melancholy song,” he tells his smartphone. When it offers up a dirge, he adds, “Not that melancholy.” Searching for that special someone, Theodore finds instead a perfect post-human. Billed as “not just an operating system, but a consciousness,” OS1 is a cognitive companion that responds to his dreams and desires.

When Theo powers up this simulacrum, she calls herself Samantha, having read a book on baby names in a millisecond. Good choice. It means “listener.” Her voice exudes comfort, acceptance, intimacy. At first she mothers Theodore, a ukulele-playing emo man-child who half-jokes, “I can’t even prioritize between video games and Internet porn.” She prods him along, nudging him out of his funk.

Their conversations shade into mutual affection and, ultimately, romance. Just as Theo says what his clients want to say, Samantha says what he wants to hear. She’s got everything — except a body. Then programming art begins to imitate life as Theo’s hyperintelligent virtual mate, who can give her attention to thousands at once, grows restless.

Making a film of this odd situation involves a stratospheric degree of difficulty. Joaquin Phoenix, delivering a finely calibrated performance as Theo, is essentially playing tennis without a partner, reacting to a character who is never present in the flesh. Scarlett Johansson, voicing Samantha, makes her fully alive, charming, emotionally rounded and alluring through intonation alone. The actors tell their fantastic tale with a tragicomic authenticity that should bite through the hardest of hearts.

Spike Jonze, directing his first self-authored screenplay, balances poignant emotion with metaphysics. Is love, like virtual life in cyberspace, an excursion into fantasy or something real? Do we cherish each other or bond with doppelgängers we have created in our imaginations? Jonze’s direction is calm and contemplative, lingering long enough to truly ponder the issues it raises.

“Her” is meticulously imagined, down to the costume designs and color schemes. Theo lives in a world divided, half plain-vanilla tones of beige and ecru, and half sensual tangerines and Valentine’s-heart reds. Shooting in Los Angeles and Shanghai, Jonze creates a futuristic reality that looks very much like the world around us. Jonze is deeply invested in the story’s themes of heartbreak and divorce, as well. The tense lunch scene between Theo and his ex is painfully raw. Is it coincidence that Rooney Mara strikingly resembles Jonze’s former wife, Sofia Coppola?

I wish that Jonze had created a less repetitious visual design. Too much of the running time features doe-eyed close-ups of Phoenix, whose visage is not endlessly fascinating. But there’s plenty of creativity where it counts. Jonze encourages our awe at the mysteries of life even if they arrive in the form of technology.