It’s about a girl who got sucked or reincarnated into the book she wrote. The world is dying and she’s there to help it. She has a spirt guide to help her.
The male lead, who I think was the villain in her book, does not have a happy ending. In her book she gets to know him, falls for him, and wants to change the ending in the book she wrote. For that she needs to get back to her world which the male lead, who I think is a prince, helps her get to the castle were there was a cave that returned her to her own world.
The ending is that she gets back to her world and changes the ending of the book; she writes it so that the villain who is the male lead has a happy ending, the spirt guide that helped her through the reincarnated world visits her in the real world and helps her go back and she has a happy ending with the prince and gets married.