Nancy Pelosi was feeling confident when she appeared on The Late Show with Stephen Colbert last week: “What now I'm saying is, we will win. We will win.” A few days later, while on the trail in her San Francisco congressional district, Pelosi told campaign volunteers that they shouldn't be distracted by President Trump's reframing of the midterm election around illegal immigration. “Don't take the bait,” she warned. “Just stick with health care, good paying jobs, and clean government.” The rest will take care of itself.

For historical reasons alone, Democrats have reason to be optimistic. Democrats need to net 23 seats to win the majority. According to the Gallup organization, the average loss of House seats for the party of a president with less than 50 percent support is 37. President Trump is at 44 percent in the Real Clear Politics average.

That's the good news for liberals. The bad news is the Democratic Party is unprepared for a return to power after eight years in the House minority. An eagerness to deal a blow to Trump and his Republican allies has created the illusion of party unity while generating massive enthusiasm, cash, and political momentum. Resistance to Trump provides a sense of solidarity and mission. What it cannot do is overcome internal party divisions, determine a consensus governing agenda, and prevent overreach.

In fact, the opposite is likely true. Just as happened to the Republicans when the Tea Party Congress took office in 2011, an Election Day victory ultimately may inflame rather than mitigate intra-party tensions.

Pelosi herself is a source of the internal pressure. The first female Speaker of the House is a controversial figure both outside and inside her party. Her longevity is a problem. If Republicans are in the midst of an ideological transition from a Chamber-of-Commerce party to a nationalist-populist one, Democrats are experiencing generational change. The outsized expectations of a rising cohort of Democrats are butting up against the warhorses that have led the party for close to a generation. The resulting clashes are in the public eye.

Pelosi is 78 years old. Her deputies Steny Hoyer and James Clyburn are, respectively, 79 and 78. If Democrats win, Barbara Lee has said she will campaign to join the leadership team. She is a sprightly 72. Likely committee chairmen include Nita Lowey (81), Maxine Waters (80), Jerry Nadler (71), and Elijah Cummings (67). Last year, CNN's Ryan Struyk crunched the numbers and found that, at the beginning of this 115th Congress, the average age of Democratic members (61) was four years older than the average age of Republicans (57).

Tim Ryan of Ohio already has challenged Pelosi. He is 45 years old. Last July, Linda Sanchez of California said she would run for the leadership post sought by Barbara Lee. Sanchez is 49 years old. And the incoming freshmen class of Democrats probably will see the bloom of youth: Amy McGrath is 43, Conor Lamb is 34, and Alexandria Ocasio-Cortez is 29. The generation gap has made it easier for Democrats to rebuke the formidable Pelosi. According to CNN, about 30 Democrats in competitive House races have said they don't support her as speaker.

“ The irony of the party of progress being led by men and women eligible for the senior discount at the movie theater is not lost on congressional Democrats. ”

Pelosi has tried to play down the criticism and secure her position by suggesting she might not remain speaker for long. "I see myself as a transitional figure," she told The Los Angeles Times last month. This statement is truer than she may realize. The Democratic vanguard is made up of politicians who are less cautious, more socially and culturally liberal, and more critical of business and of democratic capitalism in general than are Pelosi, Hoyer, and Clyburn.

Today's party is more confident in and assertive of its left orientation than the one Pelosi joined decades ago. Only 13 percent of Democrats say they are conservative, according to Gallup. According to Elaine Kamarck of the Brookings Institution, 44 percent of Democratic House candidates this year self-identified as progressive, a high, even though more "establishment" Democrats won primaries than progressives. Barring divine intervention, the next Democratic caucus will include two members of the Democratic Socialists of America: Ocasio-Cortez and Rashida Tlaib of Michigan. A record number of Democratic candidates in 2018 are women repelled by President Trump, his rhetoric and attitudes, and the social conservatism he represents. "Well-educated whites, especially white women, are pushing the party decisively leftward," writes Thomas B. Edsall of The New York Times.

There is a striking mismatch between the left-wing energy of the Democratic base and the agenda to which Pelosi has committed her party. Infrastructure, prescription drugs, universal background checks for firearms, tax increases on corporations and high earners, a civil-rights bill that expands anti-discrimination law to include gays and lesbians and transgender people, legalization of unauthorized immigrants brought to the country as children, and lobbying reform comprise a serious agenda likely to be passed out of the House.

Notice, though, that it does not include the preeminent issue for many Democrats: Medicare for All. How will a newly empowered left respond if Pelosi slow-walks its preferred avenue toward universal health care? More importantly, how will the conference, and the activists and special interest groups it represents, react when the Democratic wish list dies in the Senate or is vetoed by the president?

It is Trump who should give boisterous liberals pause. Even his opponents ought to recognize him as the most important political figure our age. According to Pew, 60 percent of voters say he is a factor in their midterm vote. But a repudiation of Trump in the House of Representatives will not be the end of his presidency. Far from it: He has the ability to shape media narratives that is far greater than any Democrat save perhaps Oprah Winfrey.

Trump's unpredictability and ingenuity could back Pelosi into a corner. Seeking a legacy, she may be tempted into working with the president on areas where they have something in common: infrastructure, prescription drugs. How her caucus would react to compromise is unknown. More likely, the next Democratic House will repeat the mistakes of earlier congresses: It will interpret its electoral mandate as an ideological one and overreach.

Whether it is by cutting Medicare, impeaching Bill Clinton, attempting to cut off funding for the war in Iraq, using the debt ceiling as leverage to cut spending, or shutting down the government over the Affordable Health Care Act, Congresses have a way of overplaying their hands. That usually benefits incumbent presidents. Another impeachment or a series of bills that allow Trump to portray the Democrats as prisoners of the identity-politics left may backfire on Pelosi's House. If that happens, liberals will be reminded of a lesson well understood by conservatives: In politics, all victories are Pyrrhic victories.

Matthew Continetti is editor in chief of The Washington Free Beacon. You can follow him on Twitter @continetti.