The other day, I came across a recent study by the American Academy of Sleep Medicine. It found that insomnia affects about 23 percent of U.S. workers, and it put the annual national cost for the sleeping disorder at $63.2 billion.

That night, I lay awake for hours worrying about all that wasted money.

OK, I didn’t really. But I have spent countless hours when I wanted to be asleep fretting about things far less important. And I have spent considerable time reflecting on sleeplessness. Here, for the lucky 77 percent of Americans unaffected by the plague, is a primer on what the rest of us suffer.

There are, in my experience, two main types of insomnia.

Type 1: You brush teeth, crawl into bed and get comfy with whatever combination of blanket, pillow, white-noise-producing fan, dog and spouse suits you. Then, just like the other diurnal creatures from the prairie to the forest, you fall gently into a sweet, deep sleep that can last for several hours.

Until … you turn over to settle the hip, or cover the foot or switch the pillow to the cool side. You order yourself: Do not think! Do not think! Think nothing!

But then a tiny, seemingly harmless thought fragment slips through, and that single speck of brain activity mutates instantly into a cacophony of ceaseless inner chatter. Thoughts of things left undone or unsaid begin their taunt. Mundane, niggling details repeat and repeat like acid reflux. The night is lost.

Type 2: After dragging through your day, hallucinating from sleep deprivation, you yawn through dinner, take the hot soothing bath, drink the warm milk, lay the weary head upon the pillow, close the bloodshot eyes.

Then, instantly: Pop! The eyes are open.

You play possum, hold unnaturally still. But the foot must twitch. You are too hot, too cold. There is no comfortable position for any part of body or soul. The dog licks itself. The spouse snores. You hate them both. You seethe. You whimper. If religious, you wail at the heavens, beseech the sleep gods. Tears of exhaustion and frustration seep.

You try the couch but cannot escape the repeating lyrics of a bank commercial from your youth.

You try all the tricks. Massage the face. Tense and relax various body parts. Snap on the light and read till the words blur, have the shot of whiskey or the addictive, hangover-producing magic white pill.

Those of us with the affliction have tried everything: melatonin, Benadryl, Sleepytime tea, breathing exercises, ear plugs, quitting coffee, getting more exercise, getting less exercise, eating earlier, meditation, flannel sheets, relaxation tapes, more sex, less sex.

Sleepers have been known to suggest that a guilty conscience must be the culprit. But thoughts as morality-neutral and ethics-free as whether or not to use fabric softener can, in the dark of night, be urgent enough to keep the eyes on the ceiling. There is no concern too mundane to consider, no minutiae too minute to obsess over. All is equal in the dark.

If you are an insomniac, you spend hours in the dark relentlessly rehearsing your future confrontations with the cashier who snubbed you at the market or ponder why it is considered necessary to put mayo on a tuna sandwich, even though the tuna salad already contains mayo.

You turn over new leaves and resolve to shake up your life. You consider firing your agent and cutting your hair, beginning a diet or moving to Brazil. Meanwhile, the numbers just keep sliding past on the digital alarm clock.

More time passes and you enter the panic stage, knowing that if you don’t sleep soon, tomorrow will be shot. You’ll be a zombie. You’ll look like hell. You’ll say or do something wildly inappropriate, humiliate yourself, the kids, the spouse. You’ll get yourself fired or shot. You’ll cross that tauntingly close line into utter, irreversible madness.

Finally comes resignation. You give up, throw aside the limp sheet, turn on the computer or paint the kitchen or sit at the dining room table spooning in carbs and waiting for the sky to lighten. Perhaps you then slump in your chair, sliding into a brief moment of drooling unconscious.

And then, good morning! The day begins.

Many things can aggravate insomnia’s symptoms: working, not working, needing to get up in the morning, having said or done something cringe-worthy earlier in the day, or week or lifetime. The future can trigger symptoms, as can the past, as can having children, a spouse, parents, siblings, co-workers, neighbors, friends, acquaintances, relatives or none of the above. Concerns about encroaching global stupidity, catastrophic weather anomalies, dust bunnies under the armoire or the inevitability of death can all set off the disorder.

And even a single night of tossing and turning can produce such dire consequences as sleeping on the inside while driving on the outside, inappropriate weeping while wielding a machete, divorce and incarceration.

The proven treatments are two: lobotomy and death.

I hope this disturbing treatise won’t keep you awake tonight: The country can’t afford more insomnia.

Amy Goldman Koss’ latest novel for teens is “The Not So Great Depression.” She wrote this for the Los Angeles Times.