When the television series “Vegas” was still just a little more than an idea, Nora Ephron took her husband aside.

“All right, this is a CBS network show,” said the late screenwriter of such comedy classics as “When Harry Met Sally. “This is serious. You can’t phone this one in.”

Nick Pileggi promised her he wouldn’t. “I want to get back to Vegas,” he assured her. “I love Ralph Lamb.”

Sheriff Ralph Lamb, is the real-life inspiration for Dennis Quaid’s lead character in CBS’s new hit “Vegas.”

Lamb “has hands the size of a banker’s box, teeth marks in them,” Pileggi tells The Post. “I don’t know how many people he’s pulverized with those hands. But we’re not talking about the American Civil Liberties Union.

“He’s one tough motherf—er. And I’ve had wise guys tell me that.”

Pileggi, whose non-fiction books about mobsters and gamblers brought us movies like “GoodFellas” and “Casino” with characters worthy of actors the likes of Robert De Niro and Joe Pesci, is the co-creator, executive producer and writer for “Vegas.”

He first heard of the rancher-turned-sheriff of Clark County when he was researching and reporting his book “Casino: Love and Honor in Las Vegas.”

Often on horseback, Lamb helped corral the mob’s influence in Sin City during the 1960s and ’70s. The writer sought out Lamb for an interview, but the sheriff wasn’t interested.

Then, about four years ago, Pileggi had an idea for a movie about Vegas circa 1960s, and he remembered Lamb.

“Arthur Sarkissian knew Lamb though a mutual friend,” he said. Sarkissian, also an executive producer on Vegas, played go-between.

Enter Kirk Kerkorian, who built and owned the MGM Grand when it was the largest hotel/casino in the world.

“Back in the ’50s, Kerkorian flew junkets into Las Vegas before there was an official McCarran Airport,” Pileggi said. Lamb would light the runways with radio cars and trucks from the town so Kerkorian could land his planes with high rollers.

“These are two guys who had an insane relationship for about 50 years,” said Pileggi.

“One of them went off to be a trillionaire, the other just wanted to be a cowboy.”

It was Kerkorian who talked Lamb into the sitdown with Pileggi at the Bellagio.

In May of 2012, Ephron and Pileggi attended the “upfronts” where networks woo advertisers and showcase the coming season’s shows to the press.

Held at Carnegie Hall (“Can you believe it?” Pileggi asks), it was a first for both Pileggi and Ephron.

“ ‘Vegas’ was the premiere show that CBS was pushing,” Pileggi remembers.

“When they identified me as writer and creator, and I’m sitting in row two with Nora, she was so happy,” he said.

Last June, Ephron flew to Los Angeles to be with Pileggi while he worked on the pilot for “Vegas” with Greg Walker.

“She read everything I wrote,” Pileggi said.

Known only to close friends and family, however, was that Ephron was already gravely ill with blood cancer.

“When we were writing the pilot, that’s when she got really sick,” Pileggi says. “[But] she saw most of it,” he said.

Ephron was the love of Nick Pileggi’s life. “Yup,” he said with all the emotion that entails. “No one else.”