To understand why it's so hard to pry yourself free from your phone, Facebook account and Twitter, you need to know about B.F. Skinner's pigeons.
In the 1950s, Skinner began putting the birds in a box and training them to peck on a piece of plastic whenever they wanted food. Then the Harvard psychology researcher rigged the system so that not every peck would yield a tasty treat. It became random - a reward every 3 pecks, then 5 pecks, then 2 pecks.
The pigeons went crazy and began pecking compulsively for hours on end.
Fast forward six decades. We have become the pigeons pecking at our iPhones, scrolling through news feeds, swiping left/right on Tinder for hours, the uncertainty of what we might find keeping us obsessed by design.
In the modern economy of tablets and apps, our attention has become the most valuable commodity. Tech companies have armies of behavioural researchers whose sole job is to apply principles like Skinner's variable rewards to grab and hold our focus as often and long as possible.
But some people are starting to fight back. A small but growing number of behavioural scientists and former Silicon Valley developers have begun trying to counterprogram those news alerts, friend requests and updates crowding our waking hours.
Increasingly, the rebel developers are using fire to fight fire - creating apps that try to put users back in control. They call their movement "digital wellness," and in recent weeks, they scored two huge victories when Google and Apple announced plans to incorporate some aspects of digital-wellness apps - like allowing users to track their screen time - into upcoming Android and iPhone operating systems.
"The system is built against us, because the more you use these products like Facebook and Google, the more money they make," said Nick Fitz, a behavioural researcher at Duke University. "It's like playing chess against a billion-dollar company. For every one of us trying to fix the attention economy, they have 20 researchers trying to suck you further into it."
Fitz has wrestled for the past two years with one small corner of this emerging battlefield: annoying notifications.
In an experiment, he tracked the smartphone use of more than 200 people. Most received between 65 to 80 notifications a day. When he eliminated their alerts, their stress levels dropped. A haze of inattention lifted. Their concentration improved.
But cutting off the updates also caused a spike of anxiety in most of his subjects, who reported feeling fears of missing out (FOMO in millennial speak).
So Fitz and a team of developers created an app to bundle those notifications and deliver them in three batches - morning, afternoon and evening. The people with the app on their phone reported lower stress, higher productivity and no spike in anxiety.
The 29-year-old researcher said his work was sparked by an epiphany in his life a few years ago. His father was visiting him at graduate school, and "I realized I was sitting there in the bathroom scrolling through Instagram, while my 78-year-old dad - who I only have so many years left with - was waiting for me outside," he recalled.
Since then, Fitz has slowly unplugged from Facebook and Instagram and rarely uses them these days. On his web browser, he has installed an extension app called "Mortality" so that whenever he goes online, he is greeted by a black-and-white countdown of the days he has left to live (based on average life expectancy).
"I'm not saying that technology is inherently bad," Fitz said. "But people should be conscious of how they're using it and how it's using them."
The average American, for instance, checks their phone every 12 minutes. Market research shows the average user touches their cellphone 2,617 times a day.
In a 2014 survey, 46 per cent of users said their smartphone is something "they couldn't live without."
Such habits fuel today's web economy. Among the legions of developers who specialize in behavioural design, one of the most famous is Nir Eyal, whose 2014 best-selling book "Hooked" is required reading in Silicon Valley.
Eyal details the four key elements of craveable tech: the trigger (the ping from an unread message), the action (clicking open an app), user investment (liking or commenting on other posts) and the variable reward (the crucial hook, which Eyal traces back to Skinner's experiments).
What's important is that web users, like the pigeons in Skinner's boxes, do not know when they will come across their reward. As they hunt through their news feeds, their brains experience surges of dopamine. The neurochemical is associated with the feeling of anticipation and plays a large role in linking specific cues with reward.
The mental health effect of today's constant digital grab for our attention is unclear. Some studies have linked social media and smartphones to stress, depression in teens and poor sleep. Other researchers have cast doubt on such findings.
But lately, amid the tech backlash over data-mining scandals and election interference, warnings have come from the very people who helped develop the web's earliest and biggest platforms.
Facebook's founding president, for one, admitted at an event last year that the company had been "exploiting a vulnerability in human psychology." Its creators, Sean Parker said, "understood this consciously, and we did it anyway."
In response to the criticism, Facebook and other tech companies say they are trying to improve products to address such concerns. Facebook pledged $1 million last year to research the effect of social media on youth.
Kevin Holesh has read the work of Eyal and other behavioural designers closely. As a web developer, he employed many of the same principles at previous start-ups.
Then five years ago, he found himself increasingly frustrated with the way he and his fiancée were spending their evenings. "We would spend all day working. At night, we'd spend dinner half-talking, half-catching up on things on our phone. Then, we'd turn on the TV and basically zone out in our separate worlds for the rest of the night," he said.
He decided to create an app to fix what he felt was broken in his relationship with his iPhone and fiancée. He essentially took the core concepts of Eyal's "Hooked" model and subverted them to create reverse hooks to lure users away from their technological cravings.
His Moment app works like a Fitbit, tracking the number of hours users spend on their phone and specific programs. It sends notifications after they've been on for an especially long stretch, suggesting a break. It also allows them to turn their usage into a game of sorts, challenging them to pick up their device less and less - until they feel like they're back in control.
Moment is now one of the most successful digital wellness programmes, downloaded 5.9 million times.
Shortly after it launched, Holesh and his fiancée-turned-wife uprooted their lives and moved into an RV. The twentysomethings have worked together from the road ever since.
"Our routine these days is basically a lot of conversation," Holesh said from a state park in Utah. "We cook together. We talk about life goals over dinner. We're thinking of having kids soon, so that's been a huge topic of conversation lately. We read and we get a lot more sleep than most people."
Several other apps have also emerged in the past couple of years. A particularly popular one - called Forest - plants a virtual tree on your phone whenever you put it down to focus on work. But the second you pick it back up, the tree withers and dies.
"I don't know why I care if these trees die, but I do," reads one user's review on iTunes.
Other apps - Freedom, SelfControl, AppDetox, cold turkey and StayFocusd - help users block websites or apps they've had trouble quitting.
Andrew Dunn, a San Francisco product manager, launched recently launched a program that essentially gives Android phone users a new home screen - batching their notifications, removing the colourfully attractive logos on apps and making it harder to access apps they feel are wasting their time.
One fundamental problem he and other developers struggle with is how to create successful apps without employing the usual hooks and business models.
"You don't want to monetize based on ads. That kind of defeats the whole purpose of decluttering people's lives," Dunn said. He also doesn't want to generate revenue by collecting user data or demanding a high purchase fee. Getting buy-in from investors has understandably been difficult.
Ultimately, his team decided to create a way to let Siempo users pay what they can. "These are the kinds of questions we're still wrestling with in the humane, ethical tech movement," he noted.
In the three years since publishing "Hooked," Eyal has increasingly focused on the importance of ethics instead of just the techniques of design.
The behavioural design guru does not regret writing the book. "There will always be downsides to new technology," he said in an interview from New York. "The solution isn't to throw it out. The solution is to make it better."
At the same time, he thinks users have to take personal responsibility as well. "It's so much easier to blame the technology," he said.
Eyal has spent much of the past year quietly visiting the country's biggest tech companies and trying to persuade top executives to install safeguards to help chronically addicted users. "We should be demanding that these companies use the data they're collecting to help those who are overusing them," he said.