The Church explicitly teaches that evil inner thoughts are themselves already morally relevant—not just external actions.
“For out of the heart come evil thoughts…”
This means: moral evaluation begins with the inner consent of the will.
Source: CCC 1853; Mt 15:19