Planarized nanophotonic sensor for real-time fluid sensing