Kathryn Hahn has been dependably funny all over the comedy landscape, a supporting player on television (Parks & Recreation and Girls) and in films (Step Brothers and Wanderlust). Now comes Afternoon Delight, her first starring role. The movie has her playing an unglamorous, non-romantic lead, in a plot that deals frankly with sex and develops several complicated relationships among adult characters. It’s as if writer-director Jill Soloway knew any one of these interests could get her movie pigeonholed or underfunded, and decided to go for broke by including them all.

Hahn plays Rachel, 30something, married to Jeff (Josh Radnor), and living in a lush California house. Jeff develops phone apps that are lucrative enough for Rachel to stay home with their young son, and even hire help when she needs it. But the couple’s sex life is suffering. In search of new experiences, Rachel brings her husband to a strip club, where they meet McKenna (Juno Temple). The encounter doesn’t exactly rekindle their marital fires, but Rachel can’t stop thinking about McKenna, and decides she can help her. Soon, McKenna is half-working as Rachel’s nanny, and staying in the guest bedroom, while continuing her work as a hooker, off-site.

Indie sex comedies can get just as dopey as their big studio counterparts when it comes to sex, sometimes dopier, with a smug sense that they’re getting away with something bigger movies can’t. But Soloway’s film is thoughtful and honest on the subject; her dialogue can be laugh-out-loud explicit when Rachel and Jeff voice their frustrations. They aren’t exactly repressed, and they aren’t exactly falling out of love, but something is missing, and Rachel spends much of the movie on the brink of sexual exploration. At the same time, even as Jeff looks askance at Rachel’s bizarre new project, he doesn’t say much to dissuade her. Radnor underplays his part, suggesting that Jeff uses his low-key intelligence as an excuse for bad behavior: he says mean or dismissive things, but not emphatically enough to be turned into the bad guy. He and Rachel both seem put off by the rituals of upper-middle-class parenting, but parlay their feelings into sarcasm and avoidance.

With its funny people approaching middle age, the film feels like a female-centric Judd Apatow movie, particularly his more recent forays into comedy-drama. Like This is 40, Afternoon Delight takes place in a bubble of California privilege that serves as a source for satire, in particular the banality of endless fundraisers and activities organized by supermoms like Jennie (Michaela Watkins). Still, the film sometimes takes this environment for granted: Soloway is far from oblivious of the characters’ status, but sometimes it’s hard to understand their complaints (however implicit or understandable) about the anxiety of their well-appointed, comfortable lifestyle.

Hahn makes any of these potential problems less important: Rachel’s limitations, and even the movie’s, seem endearing when she’s on screen. Hahn tends to play extreme parts in her mainstream career, but her performance in Delight tangles up the charm of a romantic-comedic heroine with the ennui and confusion of a dramatic subject until they’re wonderfully difficult to distinguish. Temple, a similarly longtime supporting player, and too often as a “lost girl,” brings to McKenna a certain amount of savvy to leaven her kewpie-doll naiveté.

The women’s friendly but vaguely uneasy relationship doesn’t seem sustainable, and the movie climaxes with intercut sequences of vast discomfort: Rachel gets too drunk on a girls’ night and makes wild confessions and nasty jokes, while a poker game with Jeff and his friends spins out of control, aided by a spurned McKenna. These two sequences, shot with handheld cameras, coax the movie into psychodrama territory. They also amplify the movie’s unpredictability, as they convey the unsteadiness of real life, but in their aftermath, the story turns become easier to anticipate.

In spite of this exhausted collapse, though, Afternoon Delight is a surprisingly graceful exploration of inept midlife crises. As Rachel enters her late-30s wilderness, Hahn only gets better.