  If a knot $K$ in $S^3$ admits a pair of truly cosmetic surgeries, we show
that the surgery slopes are either $\pm 2$ or $\pm 1/q$ for some value of $q$
that is explicitly determined by the knot Floer homology of $K$. Moreover, in
the former case the genus of $K$ must be two, and in the latter case there is
bound relating $q$ to the genus and the Heegaard Floer thickness of $K$. As a
consequence, we show that the cosmetic crossing conjecture holds for
alternating knots (or more generally, Heegaard Floer thin knots) with genus not
equal to two. We also show that the conjecture holds for any knot $K$ for which
each prime summand of $K$ has at most 16 crossings; our techniques rule out
cosmetic surgeries in this setting except for slopes $\pm 1$ and $\pm 2$ on a
small number of knots, and these remaining examples can be checked by comparing
hyperbolic invariants. These results make use of the surgery formula for
Heegaard Floer homology, which has already proved to be a powerful tool for
obstructing cosmetic surgeries; we get stronger obstructions than previously
known by considering the full graded theory. We make use of a new graphical
interpretation of knot Floer homology and the surgery formula in terms of
immersed curves, which makes the grading information we need easier to access.
