Coming in to Edinburgh on the airport shuttle bus, you pass the city’s zoo, festooned with ­posters for its star attractions, Tian Tian and Yang Guang. The old joke used to be that there were more pandas in Scotland than Tory MPs. Since the early hours of 8 May, however, that axiom applies to ­Labour and the Liberal Democrats, too.

How can Labour recover from the loss of 40 of its Scottish seats? The task falls to Kezia Dugdale, the 33-year-old elected on 15 August as the sixth leader of Scottish Labour in eight years. In May, she was at a TV studio when the general election exit poll was announced and neither she, the Scottish Tory leader Ruth Davidson, nor the Lib Dems’ Willie Rennie could believe it. But by the time she reached Labour’s headquarters on Bath Street in Glasgow, and watched a five-figure majority in Rutherglen and Hamilton West get swept away, she knew the party had suffered a wipeout. “I watched Jim Murphy lose his seat and he joined us not too long after that, and then Brian Roy [Scottish Labour’s general secretary], watched his dad lose his seat,” she tells me. “The atmosphere was just deathly quiet.”

Small wonder the scene was funereal. Labour once dominated Scottish politics effortlessly – in fact, the effortlessness may have been the problem, because the party became complacent and its electoral machine was rusty with underuse. Now, Labour gets kicking after kicking. On 14 August there were swings to the SNP of over 20 per cent in council by-elections in Falkirk and in Wishaw, Lanarkshire. Similar swings were recorded earlier in the month in Glasgow and last month in Aberdeen.

At this point, the drubbing Labour is receiving reminds me of that clip from The Simpsons where a child shouts: “Stop! Stop! He’s already dead!” The party has been routed at Westminster and it seems likely to lose all its constituency MSPs at next year’s Holyrood elections, too. Its survival there would then depend on the vagaries of the D’Hondt system, which will award Labour a few dozen list MSPs, based on its total vote share. (The SNP could do so well in some constituencies that it won’t get topped up with any list MSPs.)

What can Kezia Dugdale do to arrest the party’s decline? It feels as though everyone I speak to is more dejected than the last. “The crucial thing is to regain permission to be heard,” says David Torrance, the biographer of Alex Salmond and Nicola Sturgeon. “That was lost during the referendum debate and wasn’t regained during the election.” Stephen Daisley, STV’s digital political correspondent, adds: “Labour lacks a coherent narrative. A stray cat could tell you what the SNP stands for: protecting Scotland from wicked Westminster. Put two Labour supporters in a room – more and more of an ask in Scotland – and you’ll get three opinions on what the party’s message is.”

According to Dugdale, Willie Rennie often runs up Arthur’s Seat and back at lunchtime, such is the proximity of the old peak to the Scottish Parliament. Her own uphill struggle is no less daunting. When I ask her how far back Labour’s problems go, she laughs: “We’re only here for an hour!” She says that “2007 was the warning sign, because we shouldn’t have lost that . . . Some people might even say 2003 because we started to look like caretakers.”

She says the blame for the party’s present predicament should not fall on any individual or policy, but does criticise the 2015 manifesto. “There were 160 different policies in our manifesto in Scotland . . . 160 policies and nobody knew what we were for.” The road back to credibility lies in outlining the ethos behind Scottish Labour. As she puts it: “What we did was say, ‘This is what we’re going to do with policies . . .’ Barely if ever did we tell people why.”

Here, Dugdale faces a huge disadvantage against the SNP leadership, which has a simple answer to most questions: more powers for Scotland. “What is galling for Scottish Labour is that attempts to hold ministers to account are branded unpatriotic,” Daisley says. “‘Stop talking down Scotland’ is the nationalists’ favourite response. The challenge for Labour is that Scottish voters might now be voting on their national ambitions rather than policy. Scottish Labour is talking about service delivery. The SNP is waving a flag. Flags always win.”

The election of Jeremy Corbyn as Labour’s leader in Westminster may pose an intriguing problem for the SNP, which ran in May on an anti-austerity platform (although the IFS found its manifesto was more fiscally conservative than Labour’s). Many former Scottish Labour supporters say they now back the SNP because of that stance. But if Labour is also anti-austerity, will any of those voters come back? “The idea a Corbyn-led Labour Party can help it recover in Scotland is, I am afraid, for the birds,” the Spectator’s Alex Massie wrote on Twitter recently. Another centre-right commentator told me: “It’ll be like Canada, post-referendum. The SNP are like the Bloc Québécois; people will vote for them to represent Scotland’s interests at Westminster.”

The SNP now also has the advantage of the staff and infrastructure that come with 56 Westminster MPs. “We’ve gone from 41 to one, against a juggernaut of 56 whose raison d’être is to get an independent Scotland,” says Labour’s only remaining MP in Scotland, Ian Murray. He feels the press is hostile, too, and argues that “some of the media in Scotland would rather continue to attack Labour than hold the SNP or Tory government to account”. He must surely be thinking of the National, a bruisingly partisan publication that specialises in grotesque photoshopped cover pictures. Recent highlights include Boris Johnson as the Joker and Tim Farron as Frankenstein.

I ask Dugdale how she plans to cope with abuse on social media. “I’ve never really let it affect me, because I just feel sorry for the people who live on the internet in the middle of the night,” she says. “The most powerful button in the world is the mute button.” It helps that her close friends work in politics. “I can’t just go home at 6pm and drink a bottle of wine. Sometimes I have to do things at the last minute. Sometimes, despite making plans, you have to cancel. Normal people don’t think that’s cool.”

She also gets occasional support from the other two main party leaders, Sturgeon of the SNP and the Tories’ Davidson. Having three women at the top of Scottish politics does not make things “less aggressive, just different. It’s undoubtedly different. There’s a degree of camaraderie between the three of us.” That said, she is unimpressed by the others’ criticisms of my New Statesman piece on childlessness in politics. “They saw the outrage and went with it. In my gut, I don’t think either of them had read the full article before they commented on the front cover . . . Ruth Davidson is not a feminist and Nicola Sturgeon is a late convert, in my view.”

Dugdale has been involved in politics for only a decade. She is not from a political family, though her father Jeff, once a Tory supporter, is now an SNP member who likes to wind his daughter up on Twitter. She joined Labour when, after graduating in law, she found herself unemployed and wondering what to do with her life. “I had no great drive to do law other than watching a lot of Ally McBeal,” she says now. “I thought that everyone who did law just had unisex loos, went to the piano bar at night and spent their entire life in the courtroom.”

Instead, she ended up, aged 23, “on the sofa in our pyjamas watching Trisha” with a flatmate who was a member of the Labour Party and encouraged her to get involved in politics. She found that she was a good election agent, and in 2011 she acted as a key seat organiser with a place on the regional list. “I was expecting to wake up the day after the 2011 election unemployed, with a pretty decent redundancy package and a summer to work out what I was going to do with the rest of my life. I woke up as an MSP.”

She knows that many observers believe there is no way back for Scottish Labour. Her hopes rest on a few calculations: the first is that the SNP leadership (with the exception of Salmond) doesn’t want to push for a second referendum too soon, yet its activists might try to get it into the 2016 manifesto. “It’s an incredibly difficult call for Nicola Sturgeon, because it’s what her 100,000 party members want but it’s not what the country wants,” Dugdale says. “We were told this was a once-in-a-lifetime, once-in-a-generation opportunity. I was 33 when they told me that, and I’m still 33 and they’re changing the rules.”

The second is that the SNP has now governed Scotland for eight years, four of those with a majority, and at some point Scottish voters might treat them as incumbents rather than insurgents. As Murray puts it: “What gives me a little bit of hope for the 2016 election is that they’re going to have to start answering for their own pretty abysmal record.” He thinks that grumbles about public services (the police, the NHS, the justice system) might finally boil over; Dugdale’s own focus will be on education. She says this policy area is “integral to battling poverty and inequality in all its forms”, and it can’t hurt that Scotland’s primary schools are full of children who have never known anything other than SNP rule.

Intelligent, funny, hard-working, well-liked and – well, normal (her trashy telly ­anecdotes were clearly real, rather than focus-grouped to make her sound “authentic”), Kezia Dugdale is an impressive politician. But she is under no illusions about how hard her job will be. As she puts it: “There were lots of people saying, ‘Don’t stand, because you’ll have a crap election in 2016, it’s inevitable, and then they’ll have your head and that’ll be you done.’”