FROM “Morning in America” to “Yes, we can”, presidential elections have long seemed like contests in optimism: the candidate with the most upbeat message usually wins. In 2016 that seems to have been turned on its head: America is shrouded in a most unAmerican pessimism. The gloom touches race relations, which—after the shooting of white police officers by a black sniper in Dallas, and Black Lives Matter protests against police violence, followed by arrests, in several cities—seem to get ever worse. It also hangs over the economy. Politicians of the left and right argue that American capitalism fails ordinary people because it has been rigged by a cabal of self-serving elitists. The mood is one of anger and frustration.

America has problems, but this picture is a caricature of a country that, on most measures, is more prosperous, more peaceful and less racist than ever before. The real threat is from the man who has done most to stoke national rage, and who will, in Cleveland, accept the Republican Party’s nomination to run for president. Win or lose in November, Donald Trump has the power to reshape America so that it becomes more like the dysfunctional and declining place he claims it to be.

This nation is going to hell

The dissonance between gloomy rhetoric and recent performance is greatest on the economy. America’s recovery is now the fourth-longest on record, the stockmarket is at an all-time high, unemployment is below 5% and real median wages are at last starting to rise. There are genuine problems, particularly high inequality and the plight of low-skilled workers left behind by globalisation. But these have festered for years. They cannot explain the sudden fury in American politics.

On race relations there has, in fact, been huge progress. As recently as 1995, only half of Americans told pollsters that they approved of mixed-race marriages. Now the figure is nearly 90%. More than one in ten of all marriages are between people who belong to different ethnic groups. The movement of non-whites to the suburbs has thrown white, black, Hispanic and Asian-Americans together, and they get along just fine. Yet despite all this, many Americans are increasingly pessimistic about race. Since 2008, when Barack Obama was elected president, the share of Americans who say relations between blacks and whites are good has fallen from 68% to 47%. The election of a black president, which seemed the ultimate proof of racial progress, was followed by a rising belief that race relations are actually getting worse.

What explains the divergence between America’s healthy vital signs and the perception, put with characteristic pithiness by Mr Trump, that the country is “going down fast”? Future historians will note that from about 2011 white and non-white babies were born in roughly equal numbers, with the ageing white population on course to become a minority around 2045. This was always going to be a jarring change for a country in which whites of European descent made up 80-90% of the population for about 200 years: from the presidency of George Washington to that of Ronald Reagan.

Demographic insecurity is reinforced by divisive partisan forces. The two parties have concluded that there is little overlap between the groups likely to vote for them, and that success therefore lies in making those on their own side as furious as possible, so that they turn out in higher numbers than the opposition. Add a candidate, Mr Trump, whose narcissistic bullying has prodded every sore point and amplified every angry sentiment, and you have a country that, despite its strengths, is at risk of a severe self-inflicted wound.

Reshaping politics

The damage would be greatest were he to win the presidency. His threats to tear up trade agreements and force American firms to bring jobs back home might prove empty. He might not be able to build his wall on the border with Mexico or deport the 11m foreigners currently in the United States who have no legal right to be there. But even if he failed to keep these campaign promises, he has, by making them, already damaged America’s reputation in the world. And breaking them would make his supporters angrier still.

The most worrying aspect of a Trump presidency, though, is that a person with his poor self-control and flawed temperament would have to make snap decisions on national security—with the world’s most powerful army, navy and air force at his command and nuclear-launch codes at his disposal.

Betting markets put the chance of a Trump victory at around three in ten—similar to the odds they gave for Britain voting to leave the European Union. Less obvious, but more likely, is the damage Mr Trump will do even if he loses. He has already broken the bounds of permissible political discourse with his remarks about Mexicans, Muslims, women, dictators and his political rivals. It may be impossible to put them back in place once he is gone. And history suggests that candidates who seize control of a party on a prospectus at odds with that party’s traditional values tend eventually to reshape it (see article). Barry Goldwater achieved this feat for the Republicans: though he lost 44 states in 1964, just a few elections later the party was running on his platform. George McGovern, who fared even worse than Goldwater, losing 49 states in 1972, remoulded the Democratic Party in a similar fashion.

One lesson of Mr Trump’s success to date is that the Republicans’ old combination of shrink-the-state flintiness and social conservatism is less popular with primary voters than Trumpism, a blend of populism and nativism delivered with a sure, 21st-century touch for reality television and social media. His nomination could prove a dead end for the Republican Party. Or it could point towards the party’s future.

When contemplating a protest vote in favour of tearing up the system, which is what Mr Trump’s candidacy has come to represent, some voters may ask themselves what they have to lose. (That, after all, is the logic that drove many Britons to vote for Brexit on June 23rd.) But America in 2016 is peaceful, prosperous and, despite recent news, more racially harmonious than at any point in its history. So the answer is: an awful lot.