Closing costs are the fees you pay at settlement on top of your down payment. They include lender fees (origination, points, processing, underwriting), third-party fees (appraisal, title insurance, survey, attorney), prepaids (homeowners insurance, property tax escrow), and recording charges.
Total closing costs typically run 2% to 5% of the purchase price. On a $400,000 home that's $8,000–$20,000. The exact number depends on state, loan program, lender, and how much in prepaids you owe.
You can offset closing costs with seller credits (negotiated as part of the purchase), lender credits (in exchange for a slightly higher rate), and down-payment assistance programs. Your Loan Estimate shows the exact breakdown.