What are the grammatical rules for writing dialogue?

On single vs. double quotes: Keep in mind that you can have your compile settings replace all instances of " with ’ and vice-versa, so if you prefer one, even if you’re writing for a market that requires the other, you can write however you prefer. Oh… except for contractions. Wouldn"t want my contractions to use double-quotes. That"d drive me nuts! I wonder if there’s an easy way around that.

For examples of inner dialogue, look at Frank Herbert’s Dune. People are constantly thinking to themselves through that book.

I think the reason that you’re finding the rules so hard to find in a succinct format is that there are a lot of rules around grammar & style in general. There are entire style manuals on such things. I highly recommend you pick up a couple and look through the topics you are struggling with. The Chicago Manual of Style*, and Struck & White’s Elements of Style are two very good examples, and seeing the differences between the two can illustrate what is hard-and-fast, and what is more like opinion or preference. Be sure to get recent editions of the print versions, since some things have changed since we’ve all gained access to italics and bold.