Brown the butter: melt the butter in a medium skillet over medium heat. Stir frequently as the foam subsides and the milk solids turn golden-brown and give off a nutty aroma, about 6–8 minutes. Remove from heat and pour into a heatproof bowl, scraping the browned bits. Let the butter cool until warm but still liquid, about 10–15 minutes.
Whisk the dry ingredients in a bowl: combine the flour, baking soda, and sea salt; set aside.
Combine sugars and brown butter: while the browned butter is still warm (not hot), whisk in the brown sugar and granulated sugar until mostly smooth and glossy. The mixture will be slightly loose — that's fine.
Add eggs and flavorings: beat in the eggs one at a time until incorporated, then stir in the vanilla and the espresso powder (if using). Mix just until homogeneous; avoid overbeating.
Fold in dry ingredients: pour the flour mixture into the wet mixture in two additions, folding with a spatula until you no longer see streaks of flour. The dough should be thick and slightly sticky.
Stir in chocolate chunks: fold the chopped chocolate into the dough so chunks are distributed evenly. If you like prominent pockets of chocolate, reserve a few large pieces to press onto the tops of the cookies before baking.
Chill the dough: cover the bowl and refrigerate for at least 45 minutes and up to 24 hours. Chilling firms the dough, concentrates flavor, and prevents excessive spreading.
Shape the cookies: preheat the oven to 350°F (177°C). Line baking sheets with parchment. Using a 3-tablespoon scoop (or a large cookie scoop), portion the dough into balls and place 8 per sheet, leaving room to spread. If you reserved chunks, press a few pieces onto each ball now. Chill the scooped balls on the sheet for 10–15 minutes while the oven comes to temperature.
Bake: bake one sheet at a time in the center of the oven for 10–12 minutes, rotating halfway, until the edges are golden and the centers still look slightly soft. For chewier centers, aim for the shorter time; for crisper edges, bake a minute or two longer.
Finish and cool: remove the cookies from the oven and immediately sprinkle with flaky sea salt. Let them rest on the baking sheet for 5 minutes to set, then transfer to a wire rack to cool completely (or enjoy warm). Store cooled cookies in an airtight container for up to 4 days, or freeze the dough balls for later baking.