According to the conventional wisdom, the quixotic presidential run of Bernie Sanders should be over. In fact, by conventional standards, his campaign should barely have gotten off the ground.

As a self-described “democratic socialist” in a country where the “S” word has been anathema for most of the past century, Sanders should have been a ready mark for Hillary Clinton, easily Red-baited, branded as an out-of-touch, elderly extremist and consigned to the fringes of political relevance.

But while he still trails Clinton in the delegate count, he remains in the hunt for the Democratic nomination. According to the latest Public Policy Institute of California poll he has pulled to a dead heat with Clinton in the run-up to the Golden State’s critical primary election on June 7.

In the meantime, Sanders continues to draw enormous — or, as he might say in his thick Brooklynese, “yuuge” — crowds to his rallies. The one I attended last week, for example, attracted some 6,750 supporters, who packed a high school football field in Santa Monica, Calif.

So, how and why has he managed to defy the odds?

One big reason, undoubtedly, is that Clinton is a weak candidate, damaged by her insider status, history of scandal (the email controversy is only the latest in a long line) and the public’s grave doubts about her honesty.

Her unfavorability ratings — along with those of Donald Trump, her front-running GOP counterpart — sit at historic highs.

But Clinton’s deficits are only part of the overall picture.

Another reason Sanders remains in the fight is that the Red-baiting tactics directed against him largely have failed. Those tactics — which have been deployed in both overt, traditional forms and in coded, latter-day garb — have been continuous and unrelenting. They have come from Democrats and Republicans as well as from the mainstream media.

The vintage variety began in earnest with Missouri Democratic Sen. Claire McCaskill’s breathless tirade against him during a June 25 interview on MSNBC’s “Morning Joe” show. “I think the media is giving Bernie a pass right now,” the longtime Clinton backer told co-host Mika Brzezinski. “I very rarely read in any coverage of Bernie that he’s a socialist.”

Declaring that Clinton was destined to win the nomination — at the time, she was ahead of Sanders in national polls by as much as 60 points) — McCaskill struck a theme that would soon be echoed by others: that Sanders was “too liberal” to be elected. McCaskill urged the media to get on board, and they soon fell in line.

As if on cue, CNN’s Anderson Cooper grilled Sanders about his socialist beliefs during the Oct. 13 Democratic presidential debate in Las Vegas.

“How can any kind of socialist win a general election in the United States?” Cooper asked, adding: “The Republican attack ad in the general election — it writes itself. You supported the Sandinistas in Nicaragua. You honeymooned in the Soviet Union. And just this weekend, you said you were not a capitalist.”

Sanders responded with a class analysis rarely heard on primetime television but that has, nonetheless, become the now-familiar cornerstone of his campaign. “We’re going to win,” he said, “because we’re going to explain what democratic socialism is. And what democratic socialism is about is that it is immoral and wrong that the top one-tenth of 1 percent in this country own … almost as much as the bottom 90 percent. That it is wrong, today, in a rigged economy, that 57 percent of all new income is going to the top 1 percent.”

By January, as Sanders’ message gained even more traction, Clintons’ supporters and surrogates had become openly alarmed at the likelihood of a real challenge from the Vermont senator.

New York Times political correspondent Jonathan Martin brought many of their anxious voices together in an article published on Jan. 19. “Here in the heartland, we like our politicians in the mainstream, and he is not — he’s a socialist,” Missouri Democratic Gov. Jay Nixon said. “[A]s far as having him at the top of the ticket, it would be a meltdown all the way down the ballot.”

A Sanders candidacy “wouldn’t be helpful outside Vermont, Massachusetts, Berkeley, Palo Alto and Ann Arbor,” Rep. Steve Cohen, D-Tenn., said.

Martin also quoted McCaskill as saying: “The Republicans … can’t wait to run an ad with a hammer and sickle.”True to McCaskill’s warnings, Republican operatives, while staying primarily focused on Clinton, have begun Bernie-bashing, too, and they’ve been at it for quite a while. The “Sandinista” and “Soviet” slurs invoked by Anderson Cooper against Sanders actually originated with Breitbart News, which publicized them as a set of talking points in a twisted May 2015 review of his 1997 political memoir, “Outsider in the House.”

As Sanders’ White House bid accelerated, the “socialist” epithet and the jeers about his unelectability were picked up and repeated by prominent conservatives, including Lindsey Graham, John Kasich and GOP strategists like Ryan Williams, who worked as Mitt Romney’s 2012 campaign spokesman.

“There’s no mystery to what the attack on [Sanders as the nominee] would be,” Williams explained to Bloomberg reporter Sahil Kapur in April. “Bernie Sanders is literally a card-carrying socialist.”

Along with the old-style red smears, there has also been a new, post-modernist line of denigration, delivered mostly — and shamelessly — by Democratic officials and affiliated pundits, who have repackaged the classic affronts into more nuanced, contemporary forms.

Thus, we’ve been instructed by party mainstays such as Sen. Barbara Boxer of California and by Clinton herself that Sanders isn’t a “real Democrat.” Instead, we’ve been urged to believe by Washington Post columnist Dana Milbank that he is this election season’s Ralph Nader, whose Green Party candidacy allegedly tilted the 2000 presidential election in favor of George W. Bush, bringing us the disastrous invasion of Iraq.

Taking a slightly different tack, fellow Post columnist Eugene Robinson has accused Sanders of conducting a “scorched-earth campaign” within the Democratic Party by remaining in a race he can’t win. Sanders’ obstinacy, Robinson charges, “will succeed in only one thing: electing Donald Trump.”

Whether old-school or newfangled, the aim of the takedowns remains the same: to insulate the political status quo from any credible threat of fundamental change, even of the entirely peaceful, small “d” democratic and reform-minded genre offered by Sanders. And still, Sanders’ poll numbers, particularly as reflected in hypothetical match-ups against Trump, have continued to climb while Clinton’s have shrunk.

Seeking to comprehend why the Red-baiting, in all of its iterations, old and new, has fallen short, I reached out to Yeshiva University history professor Ellen Schrecker, considered by many the nation’s foremost authority on the subject.

Now 78 years old, Schrecker lives in New York City and is the author of numerous essays and books, including her highly praised interpretive monograph, “The Age of McCarthyism” (1994), and more recently, “The Lost Soul of Higher Education” (2010). A longstanding socialist, she voted for Sanders in her state’s primary.

The key to understanding why the current attacks have failed, she told me in a phone interview, lies with young people, Sanders’ primary base of support. “I think Red-baiting is losing its bite, particularly among the young, because they don’t know what communism was, and, as a result, baiting has lost its Cold War sting,” she said.

“The fragmentation of American politics [in the Internet Age] is also a factor,” she continued. “In the ’50s, we had three TV networks and a few major newspapers. It was easier to marginalize left-wing figures. Now, we have a proliferation of outlets. There are so many other things today people can be made to fear besides being a socialist: terrorism, transgenderism, guns or the lack of them.”

Recent public-opinion research bears out Schrecker’s views. A Pew poll from June 2015 found that 69 percent of voters under 30 were willing to vote for a socialist presidential candidate. A YouGov survey, conducted this January, found the same demographic had a higher opinion of socialism than capitalism, by a ratio of 43 to 32 percent.“Bernie Sanders has made it safe to be a socialist in American politics,” Schrecker added. “That could very well be his most important long-term achievement. He has offered a way of thinking about politics that we haven’t considered in 50 to 60 years. And he’s done so in sync with what people feel at a gut level. The Occupy Movement brought the issue of income inequality to the forefront, and it has stayed there. Sanders has given the issue a public face.”

The vital task now, Schrecker said, is to build an enduring movement for progressive change, especially considering the prospect of a Trump presidency, which she termed both “terrifying” and “crazy.”

The people I joined last week to hear Sanders speak seemed to know this only too well as they stood shoulder-to-shoulder on the football field at Santa Monica High School after waiting in lines stretching three city blocks.

They were, as they have been at other Sanders events, predominantly but not exclusively young. They were equally divided between women and men, and included large numbers of Latinos, Asians and African-Americans, whom Sanders has sometimes failed to reach. Judging from the conversations I had with a few of these supporters — and the chatter I discerned among others — they were smart, well-informed and hardly the stuff of naive stereotypes, much less the commie dupes of yesteryear.

As Sanders railed against sexism and economic, racial and environmental injustice and made his trademark pitch for “political revolution,” it occurred to me over the cheering of the crowd that something genuinely transformative was indeed happening, and that a new movement of the left was being born, if it had not already arrived.

In the final analysis, it is that movement that has sustained Sanders’ candidacy, more than the other way around. Even in the face of entrenched opposition, it will survive, with fits and starts, setbacks and successes, even if Sanders himself eventually fades from the political scene.