Yun Yaoyao, a modern woman who finishes reading a novel, transmigrates into the body of the eponymous character, Yun Yaoyao, at a critical moment. She finds herself at a palace banquet where she is falsely accused of an affair with a guard by her scheming stepmother and stepsister. The reigning emperor, Tu Shanjin, is known as a tyrant who executes people on a whim. Facing immediate execution, the transmigrated Yun Yaoyao seizes a hairpin and attempts to assassinate Tu Shanjin, intending to take him down with her. In a twist of fate, she succeeds in stabbing him, but instead of dying, she passes out and awakens three days later to find she has swapped souls with the emperor. She now inhabits Tu Shanjin's male body, while the original Tu Shanjin occupies Yun Yaoyao's female body.Tu Shanjin, trapped in Yun Yaoyao's weak and delicate form, is thrown into the water prison with her family, who continue to curse him. He struggles with the physical limitations and indignities of being a woman, including the mandatory virginity test, which he refuses until forcibly subdued. Meanwhile, the new Emperor Tu Shanjin, controlled by Yun Yaoyao, manages to survive politically. When Prince Ze arrives to negotiate Yun Yaoyao's fate, Yun Yaoyao uses the opportunity to clear the Yun family's name while simultaneously neutralizing Prince Ze's political ambitions. She announces that the assassination was a ruse to expose the truth, pardons Yun Yaoyao, and decrees that the engagement between Yun Yaoyao and Prince Ze be annulled. Instead, she marries Yun Yanyan to Prince Ze and takes Yun Yaoyao into the imperial harem as Consort Miao, effectively trapping her potential rival and the Minister of Rites under the emperor's watchful eye.The original Tu Shanjin, now Consort Miao, is brought to the Palace of Cultivated Mind to meet Yun Yaoyao. The two confront each other, revealing their soul swap. Yun Yaoyao fabricates a story that she is the Book of Life and Death from the Underworld, sent to save the dynasty from ruin due to Tu Shanjin's cruel reign. She warns him of a grim fate—being overthrown, tortured, and reborn as a series of lowly creatures—if he does not cooperate. Tu Shanjin, though skeptical of her supernatural claims, recognizes her intelligence and agrees to a temporary truce. They must work together to maintain the charade and find a way to restore their original bodies.As the new emperor, Yun Yaoyao begins to reform the court. She faces opposition from remonstrating officials who object to a regicide entering the harem. To deflect their criticism and avoid sending her own allies' daughters into the dangerous palace, she spreads rumors that the emperor has unusual predilections for male companions, terrifying the ministers into silence. She also shows unexpected kindness to Minister Di Shunzhi, a sharp-tongued writer whose fictional stories have been damaging the emperor's reputation, by offering medical care for his sick sister. This gesture wins Di Shunzhi's loyalty and prompts him to rewrite his narratives to praise the emperor. Simultaneously, Yun Yaoyao learns to wield Tu Shanjin's physical prowess, discovering that while his body is weak from neglect, it responds well to training. The two continue to navigate court politics, planning a palace banquet to solicit donations for a major water conservancy project, setting the stage for further political maneuvering and personal growth.