Since March, the nation's biggest airports have been in the grips of a line apocalypse. Security lines have metastasized. What were once unusually long waits have become routine. Big airports are threatening to kick out the Transportation Security Administration and turn the security process back over to private contractors.

Watch the security line at DIA grow. From 4:30, to 5:00, to 5:45. Now it's almost to baggage claim @DenverChannel pic.twitter.com/r9sWcNrK0m — Jason Gruenauer (@JGonTV) May 26, 2016

The lines aren't invariably nightmarish at every airport, all day long. Still, many people, including me, have missed flights because they arrived at the airport at what used to be a reasonable time and found themselves still trapped in line as their flight took off.

The immediate reason for the long lines is pretty simple: Americans are flying more than ever, and the TSA hasn't grown quickly enough to keep up. But the current mess is also a direct result of the TSA's last crisis. Last fall, the agency got in trouble for not doing enough to keep weapons and explosives off planes, and stepped up security as a result.

The TSA has serious problems with culture and management, including disciplining whistleblowers who called out problems. But it's also stuck between a rock and a hard place, the victim of a political consensus that insists airport security must be perfectly airtight without ever being even the slightest bit inconvenient.

Lines are getting longer partly because more people are flying

In one sense, the long lines are good news: They're a sign of economic recovery as more people are flying.

The number of Americans flying dropped precipitously as the recession began, and didn't recover to its 2007 level until 2014. But over the past year and a half, many more people have been flying: Nearly 900 million people passed through American airports in 2015, up 5 percent from 2014. The number of people the TSA had to screen, since some of those passengers came from foreign airports, increased by 6 percent.

At the same time, airplane tickets have gotten cheaper as oil prices have fallen. The average domestic plane ticket cost $363 last year, down 8 percent from 2014. It was less expensive to fly in 2015 than in any year since 2010.

So far this year, both trends have continued. Overall passenger traffic increased 4 percent in January and 6 percent in February compared with 2014, according to the Bureau of Transportation Statistics. Some of the biggest airports — Denver, Los Angeles, New York's JFK, and San Francisco — have seen even bigger increases.

Fares, too, are continuing to fall. Hopper, an app that tracks airline ticket prices, is predicting the lowest summer airfares since 2009.

But more people flying also means more people in security lines. And TSA staffing hasn't kept up. There are 15 percent more people flying than in 2013, and the TSA has 12 percent fewer staff.

Congress isn't wholly to blame for the budget cuts. The Department of Homeland Security's own budget request for the 2016 fiscal year proposed cutting 1,666 screeners' jobs, saying that "risk-based screening practices" — such as getting people signed up for TSA's PreCheck program, which allows you access to expedited security if you pass a background check and pay $85 — were making checkpoints more efficient. The goal, the department wrote, was to "continue transitioning to a smaller, more skilled, professional workforce."

The agency now admits that this was a mistake, and is hiring 768 more screeners.

Some airports want to solve the problem by hiring contractors to handle security rather than the TSA, though it's not clear if that would make much of a difference. Some airports with privatized security still have passengers reporting long lines, including San Francisco International and Rochester, New York:

SFO TSA 5:30 am #ihatethewait (@ San Francisco International Airport in San Francisco, CA) https://t.co/oIylCVd6km pic.twitter.com/ND5Bbt9ZuE — Matt Leung (@mattleung) May 25, 2016

Too long to get through security! Over 1 hr at ROC @asktsa 20 of us missed the flight #iHateTheWait https://t.co/iXzRm7jnUg — Erin Briggs, RN (@ErinBWellness) May 8, 2016

Lines weren't longer before because the TSA was sending people to expedited security

As airline passenger counts were reaching record-breaking levels in 2014, the TSA also started hurrying people through its expedited security lanes.

Since 2011, the TSA has offered PreCheck, which essentially offers pre-9/11 security for a price: Travelers at more than 150 airports keep their shoes and jackets on and their laptops and liquids in their bags, and they get to go through a regular metal detector rather than a body-scanning machine.

But initially the program didn't catch on as widely as the TSA hoped. Most Americans aren't frequent fliers, and the program cost $85. By late 2014, fewer than half a million people had signed up for PreCheck, the Wall Street Journal reported.

So in order to make sure the PreCheck lines were used, the TSA started routing regular passengers into them. In September 2013, just 10 percent of passengers got expedited screening — because they were over 70 or under 12, or because they were preapproved through PreCheck or Global Entry, a program focused on world travelers that allows them to get through customs more quickly.

Then in October 2013, the TSA expanded PreCheck to people who hadn't directly signed up for it, and the number of people getting expedited security immediately tripled.

There were a few ways to get PreCheck access without paying for it — you could be selected before arriving at the airport, based on the information you provide when you book your ticket, a program known as Secure Flight.

Or you could be routed into the PreCheck lanes at the airport once you were already there, a program known as "managed inclusion." The TSA would randomly assign people to either normal or expedited security lines. TSA officers observing travelers' behavior could pull you out of the expedited line, and explosives detection hand swab machines and dogs were supposed to add an additional layer of security.

The Government Accountability Office warned in March 2015 that these procedures hadn't been fully tested. Previous reports had suggested that the behavior detection officers aren't all that effective — a conclusion the TSA disagrees with. Still, at the time, the TSA was sending nearly half of all passengers to expedited screening, even though only about 7.2 million were actually qualified for PreCheck based on their background check, security clearance, or other factors:

Expediting the security lines sped up security and reduced the need for TSA screeners. But it also meant that security itself was less thorough. And if there's one thing the American people hate more than long security lines, it's the idea that a terrorist might be able to get a knife, gun, or bomb onto an airplane.

The TSA is trying to be less bad at its actual job: security

Then, starting last summer, a report from the Department of Homeland Security's inspector general concluded that the TSA was very, very bad at its actual job. Although the report was supposed to be classified, some damning details leaked: 95 percent of attempts to sneak prohibited items through security were successful.

The test results "were disappointing and troubling," John Roth, the inspector general, said in congressional testimony in November. "We found layers of security simply missing."

Randomly choosing passengers for PreCheck took a lot of heat. Congressional hearings featured one whistleblower who said the TSA was "handing out PreCheck status like Halloween candy."

So in response, the TSA clamped down on security. It was obvious that this would lead to longer security waits, as Jason Edward Harrington, a former TSA employee, wrote for the Guardian in June 2015:

The greatest challenge when it comes to such failures stems from the fundamental catch-22 of the TSA’s mission: if agents properly execute their duties, then internal testing results will improve and airplanes might be slightly safer. But meticulous adherence to the TSA’s standard of practice will mean lines that back up to the ticketing counters. Flights will be missed due to the enormous security delays, and the distended passenger lines themselves will become choice terrorist targets. It’s a classic quantity-versus-quality dilemma.

In October 2015, the TSA discontinued managed inclusion, the program that sends travelers into PreCheck lines at the airport and monitors them with behavior officers and explosive trace detectors.

Starting last fall, the TSA and some reporters warned that lines were going to get longer. Washington, DC's airports noticed the change almost immediately, the Washington Post reported.

"I knew that would dramatically increase the number of people in the standard lanes," Peter Neffenger, the administration's head, said at congressional hearings this week. But the TSA had planned its budget assuming the expedited screening was going to continue.

Since the uproar began about the long lines, Neffenger said the agency is holding daily calls with the busiest airports and has established a national command center to monitor security wait times. And some travelers still manage to breeze through the lines with no trouble:

One week ago: 1+ hour waits @ATLairport but now NO LINE for main security checkpoint pic.twitter.com/OOvPvW2Sux — Steve Gehlbach (@SteveGWSB) May 23, 2016

But as long as Americans insist that airport security be flawless, cheap, and fast, the seesawing between outrage that the TSA is too slow and that the TSA isn't doing enough is likely to continue.

The better way to board an airplane