Robust Automatic Differentiation of Square-Root Kalman Filters via Gramian Differentials