Even if the thought of seeing another high-school comedy fills you with dread, you should still check out Kelly Fremon Craig’s “The Edge of Seventeen,” which proves that even the most unpromising of genres can occasionally produce a gem. Surprisingly sharp and insightful and often very funny, but with a strong strain of serious drama in the mix, the film also gives Hailee Steinfeld the first role to show her full potential since her Oscar-nominated debut in “True Grit” back in 2010.

Steinfeld plays Nadine, who has an extremely sharp tongue and an attitude toward others that can only be described as contemptuous. Her cynical outlook and abrasive behavior are traced back to her childhood, when the only person who treated her lovingly—her father (Eric Keenleyside), a genial fellow—died of a heart attack while driving her home. Since then she’s had a terrible relationship with her mother Mona (Kyra Sedgwick), who is herself desperately trying to find happiness, and an even worse one with her older brother Darian (Blake Jenner), to whom—in her estimation—life has brought an endless stream of undeserved successes while she suffers.

Of course, the person whom Nadine has most wounded is herself. She has only a single friend—Krista (Haley Lu Richardson), whom she met when they were just tykes and who has been her BFF ever since. The film’s major crisis will come when Krista and Darian become a couple, the ultimate betrayal in her eyes.

For support Nadine intrudes upon the peaceful lunchtimes of her history teacher Mr. Bruner (Woody Harrelson), claiming that she’s about to kill herself and being nonplussed by his retort that he’s just been writing a suicide note himself. The relationship the script builds between them will culminate when he becomes the person she can lean on at a point when the crush she’s long harbored for a hunky classmate (Alexander Calvert) turns out badly on their first date.

Happily she has an alternative to the cad in Erwin (Hayden Szeto), a shy guy who occupies the desk adjacent to hers in class. Erwin, who turns out to be an aspiring filmmaker, is obviously besotted with Nadine, but she puts him off until she realizes how much he actually has to offer—friendship at the very least, and perhaps a good deal more. Nadine will also come to terms with her family and with Krista.

In a way “The Edge of Seventeen” takes off from the template established so memorably by John Hughes back in the eighties with “Sixteen Candles,” but it’s far from a carbon copy, being, if you’ll pardon the expression, a far edgier piece of work. Nadine can be considered a descendant of Samantha, who was played by Molly Ringwald in that film, but she’s a distinctly modern version, far more free in expressing herself—unkindly, for the most part—and angrier with the world. And the journey she takes, though marked by some amiable moments, is a much more challenging one, with disappointing twists outweighing the uplifting ones.

Steinfeld is a revelation as the perpetually unhappy girl. She’s had some success in the interval since “Grit”—in “Pitch Perfect 2,” for example—but most of her films since then have been mediocre at best; this one gives her the chance to shine at both comedy and drama, and she seizes every opportunity that Craig’s incisive, intelligent screenplay has to offer. She’s well matched, too, by the excellent supporting cast. Harrelson brings his expert timing to Nadine’s supportive teacher, while Sedgwick shows nuance in the part of her mother. Richardson is excellent as Krista, who tries to maintain their friendship through a rough patch, and Jenner expertly balances the apparently easygoing qualities of Darian with an undercurrent of vulnerability and unrecognized pain. Best of all is Szeto, a natural scene-stealer who makes Erwin a charmingly quirky guy.

“The Edge of Seventeen” is a polished product—the presence of veteran James L. Brooks among the producers obviously helped the technical side. Doug Emmett’s cinematography, William Arnold’s production design, and especially Carla Hetland’s costumes—so important in defining character—are all top-notch. The carefully-chosen music selections add to the texture.

Here’s a film that will probably be relegated to the category of teen comedy, but to pigeonhole it that way would be a mistake. It’s actually much more.