converting ira to roth

I have been converting money from my IRA into a Roth for the past 5 years. I move just enough to stay in the lower tax bracket. Last year I was caught by surprise from my advisor that had sold shares in a non-qualified account which caused a capital gains of over $25,000. I was not expecting that and had to pay an additional $5000 in personal income tax. I want to avoid that this next year. Can I convert a certain mount before Dec 31, figure what my taxes would be after Jan 1, and repay to my IRA within the 60-day period if the amount I am converting puts me in a higher tax bracket for 2025? If I can do that, does it jeopardized in conversion I would want to do in 2026?