Immigration officers have been known to hassle people whose plane departs after midnight of their last stamped in date. (technically the next day, even though they're going through immigration on their last day)
Typically the fine is waived, but the passenger still receives the violation stamp in their passport.
Can't create your own document showing your entire itinerary ?
As I said, I don't know how the Royal Thai Embassy will react to your rather singular routing.
Why not just transit through KL by air to BKK or enter LOS visa exempt? Or consider getting a multiple entry TR visa from which you'll be able to stay longer??
Then you'll likely need to include the flights from Spain to Malaysia in your online application, mate. Though I'm really not sure how they'll react to a ferry as part of your journey... if they're unhappy with your application, they'll advise you.