  We present the framework for obtaining precise predictions for the transverse
momentum of hadrons with respect to the thrust axis in $e^+e^-$ collisions.
This will enable a precise extraction of transverse momentum dependent (TMD)
fragmentation functions from a recent measurement by the Belle Collaboration.
Our analysis takes into account, for the first time, the nontrivial interplay
between the hadron transverse momentum and the cut on the thrust event shape.
To this end, we identify three different kinematic regions, derive the
corresponding factorization theorems within Soft Collinear Effective Theory,
and present all ingredients needed for the joint resummation of the transverse
momentum and thrust spectrum at NNLL accuracy. One kinematic region can give
rise to non-global logarithms (NGLs), and we describe how to include the
leading NGLs. We also discuss alternative measurements in $e^+e^-$ collisions
that can be used to access the TMD fragmentation function. Finally, by using
crossing symmetry, we obtain a new way to constrain TMD parton distributions,
by measuring the displacement of the thrust axis in $ep$ collisions.
