E

ver since the battle royale for ratings that occurred between David Letterman and Jay Leno in the 1990s through 2015, late-night comedy talk shows have established a gossip-fueled niche in the minds of American TV viewers.

The new movie “Late Night”— starring Emma Thompson in a terrific, multilayered performance as a female talk show host in danger of losing her job to ageism and creative laziness, and Mindy Kaling of “The Office” fame as a young woman writer who inspires her to revive her creative spirit— offers a funny, insightful and surprisingly touching look at that world.

The movie follows a young Indian-American woman named Molly (Kaling), who works as a quality control inspector at a chemical plant in Pennsylvania but dreams of working in the comedy business. When longtime late-night host Katherine Newbury (Thompson) learns that her ratings are collapsing since she’s out of touch with the current zeitgeist and she has only one year left to be on her major TV network, she puts out word to hire a “diverse” writer.

Molly lands an interview through an incredibly clever tactic and wins the job because she’s the only female who applied. The rest of the writing staff are white men, who resent her presence immediately for having no comedy background and being an obvious case of de facto affirmative action.

At first, Molly fires back wisecracks in reply to their resentment, and is filled with politically correct self-pity, wishing the world would open before her just for being a “woman of color.” But eventually, she realizes that just as Katherine fought her way to success nearly 30 years ago, she too has to prove herself, work hard and truly be funny on the job.

She also saves Katherine at a press event that is going disastrously, by presenting herself as a bold move by Katherine. As she and her boss become friends, Katherine learns to take comedic chances again and find her spark while Molly learns that nothing comes free in life.

But crisis hits when a disgruntled rival reveals that Katherine engaged in a one-night fling with her male head writer three years before. The news humiliates her and devastates her Parkinson’s-stricken husband (John Lithgow), forcing her to make the biggest decisions of her life and career.

“Late Night” is an extremely well-written and engaging dramedy that is rated R for relatively mild foul language, but otherwise maintains a sweet innocence. The film’s smart script (by Kaling herself) offers some surprising takes on the lack of diversity in late-night talk show writers’ rooms, which are often dominated strictly by white men.

What’s refreshing about Kaling’s take on the issue is that she finds a way to show the men as more than just jerky stereotypes while also painting Molly as a person who needs to step up her creativity and show them a better way with her actions rather than just her words.

Kaling is also a fun comic foil for Thompson’s Katherine, bringing her youthful charm and naivete against the veteran host’s world-weariness and inner sadness. One of the film’s strongest suits lies in the way it weaves together the famous optics of other real-life stars — Katherine wears suits and a hairdo like Ellen DeGeneres, and her show’s title logo is copied from that of Stephen Colbert’s CBS show — to make viewers feel that Katherine very well could be a formidable real-life figure.

The movie has extremely funny moments with the writing-staff banter and the comedy stunts that Molly convinces the newly invigorated Katherine to perform for her show. But mostly this is a touching story of finding your place in the world on the one hand for Molly, and finding your drive and passion for life after losing it for Katherine.

In a summer filled with special effects-driven action spectacles and endless sequels and reboots, “Late Night” provides a fresh take on lovable characters and helps add a dose of humanity to the season.

“Late Night”: A