Historical judgment deals in fundamentals rather than detailed balance sheets, thus the achievements of Prime Ministers tend to get boiled down to one or two perceived failures or successes. Clement Attlee emerges well because of the Welfare State and NHS; Margaret Thatcher for ostensibly saving the UK from economic collapse.

Others fare less well. Neville Chamberlain, a progressive and reforming Tory PM, is remembered solely for appeasing Hitler; Sir Anthony Eden, a principled and talented Foreign Secretary, is forever associated with the humiliation of Suez, and poor old Tony Blair, whose domestic achievements were many, will hereafter be judged solely on the basis of his misadventure in Iraq.

To that tragic roll call will now be added the name of David Cameron. Had the European referendum gone his way he’d have been remembered for keeping two Unions together (just) and winning an unexpected overall majority; now he’ll be immortalised as the Prime Minister who presided over his country’s departure from the European Union. He’ll end up as derided and unloved as Edward Heath, the Conservative leader who took us into Europe in the first place.

Yet for what it’s worth Mr Cameron’s resignation statement yesterday morning showed him at his best: dignified, humbled and pitch perfect. Its aim was reassurance, for the country, the markets and EU citizens at home and abroad, and it did the job as well as it could in the circumstances. He knows he screwed up and it showed in every carefully-uttered word outside the Downing Street home he’ll vacate within a few months.

So where did the Remain campaign go wrong? Oh, where to start: everything it did in the short space of time available – fewer than five months compared with the two years plus in Scotland – suggested a belief it had learnt the lessons of the No campaign during the Scottish referendum, but talk about heavy-handed: the blizzard of warnings and statistics ended up looking like Better Together on steroids, and it wasn’t a pretty sight.

The idea, however, that “Britain Stronger in Europe” could have prosecuted the case against Brexit without being “negative” is the worst sort of political naivety. There were, as in 2014, clear economic risks attached, and any responsible campaign was compelled to flag those up. What strategists didn’t bank on, however, was the anti-politics (and yes, anti-expert) climate that greeted their messaging; one could almost sense eyeballs rolling in certain parts of the country (and yes, even in Scotland).

Ukip leader Nigel Farage might be many things but he ain’t stupid, and I remember him saying earlier this year that if the EU referendum became perceived as a battle between the Establishment and we’ll-make-Britain-great-again (English) nationalists like him then Remain would lose. He was correct, and that narrative developed with astonishing speed. It matters not that so-called “Project Fear” has already turned out, in certain respects, to be Project Fact.

At the same time Remain could have done some more work on a “positive” meta-narrative. This is something Yes Scotland understood well a few years ago, that as long as its overarching argument was (by and large) upbeat and forward looking, then it could get away with a certain amount of negativity underneath and no one would notice the inconsistency. Leave also had the best lines: “Take Back Control” might have been vague and dishonest, but it was a hell of a lot easier to understand than anything produced by the other side.

Instead it fell back on tired old lines from the independence referendum, “stronger together” (simply a variation on “better together”) and, of course, “the best of both worlds”. But the trouble is that for many voters – indeed the majority – in England and Wales it wasn’t clear to them what was supposed to be good about either world or union, the UK or the EU.

Anyone who’s bothered reading proper analysis about where Ukip’s support came from knows that the stereotype of corduroy-wearing, cigar-smoking hang-em-and-flog-em Tories comprising its core support is exactly that, an escapist fantasy. In fact, there are just as many former Labour voters attracted by populist Faragist patter, working-class men and women who feel left behind and ignored. And they didn’t desert Labour because, as the SNP and Corbynistas would have us believe, the party drifted to the Right, but because it became too metropolitan and liberal in its concerns: wind farms, equal marriage and a laissez faire approach to migration all contributed to the malaise.

And that’s where Remain struggled to connect with voters, particularly in Middle, or rather Northern England. Often its attack lines also smacked of the chattering-class concerns that had driven voters away from the three main UK parties in the first place. I lost count of the number of times I heard Inners bang on about Erasmus, the (perfectly admirable) education exchange programme for students in EU member states. This is all well and good, but not only is the UK under-represented when it comes to that particular project, but those who have taken advantage of it were highly likely to already be Remainers.

Spending a lot of time preaching to the converted isn’t a good look for any campaign, particularly when the polls are tight. On this point I’m not being wise after the event: at a private dinner a couple of weeks ago I made the same observation to the (highly-capable) John Edward of the Scottish bit of Remain, and while he had the good grace to concede the point, even had the broader campaign changed tack at that point it would have been too little too late.

In its quixotic quest for a “positive” argument the SNP fell back on similar territory (it issued the same press release about Erasmus several times), and I doubt it won over a single moderate Eurosceptic (let’s not forget that nearly two fifths of Scots voted to Leave the EU on Thursday). Nicola Sturgeon and co only pulled out all the stops relatively late in the day (although to be fair the proximity to May’s Holyrood election went against their reasonable objections), the First Minister virtually pleading with her supporters to back the status quo. It seems likely a lot ignored that advice, although that doesn’t make it the SNP’s fault, as Labour was quick to suggest once the result became clear.

Another trope now doing the rounds is that Mr Cameron should never have called a referendum on the UK’s membership of the EU in the first place (some have said the same, even more preposterously, about that in Scotland), but this doesn’t stand up to much scrutiny. Europe had split his party, and to an extent the country, for more than 40 years, while he and several predecessors had reneged on the promise of referendums predicated on certain EU Treaties. The boil had to be lanced, and that it has now created an almighty mess isn’t a very compelling argument against having attempted it in the first place.

I was in the audience at Bloomberg more than three years ago when the outgoing Prime Minister first announced his intention to hold an in/out European referendum once he had a mandate to do so, indeed he linked it rhetorically with that already announced on the separate issue of Scottish independence. Both were long-running issues, he said, that needed resolved, and what better way to resolve them than via referendums?

The late Edward Heath hated the “r” word, believing it to be a abrogation of (Westminster) Parliamentary sovereignty and, therefore, responsibility. That was a mainstream enough view in the mid-1970s, when the last European referendum took place, but harder to sustain in the wake of several devolution ballots and the often forgotten UK-wide referendum on the Alternative Vote back in 2011.

But while the “essay-crisis Prime Minister” bluffed his way through one referendum, he came royally unstuck with the other. He was complacent, heavy-handed and, perhaps emboldened by his surprise election win last May, a little too convinced of his own infallibility, an over-confidence doubtless underpinned by his “elitist” education and background. As a result, Mr Cameron knows his political history – and he’ll be acutely aware it isn’t going to be kind.