Lesson learned... don't go to court w/o a lawyer (even a crappy one).
Lawyers typically bill either "per hour" or "per service", so technically if your attorney can account for her time and/or the documentation then you owe her the balance. You don't pay "by outcome".
I would strongly recommend you do some footwork, starting with a local support group for grandparents raising children- those folks may have great names/resources/support! You can also contact social services directly and schedule an appointment with a caseworker who may be able to help you understand the process.
Unfortunately, the court system typically errs on the side of parental custody which in this case doesn't seem in the best interest of the children. Find a good attorney and take out a personal loan if necessary.