Give each day its own return plan. A sample trip from San Francisco could include an Oakland evening, a Peninsula afternoon and a Sausalito waterfront visit. Start by looking up the last useful trip for each, including any connection and the final walk.
Plan each evening from the final door home
For the ferry day, check the operator’s actual weekday or weekend table and save an earlier departure as your target. If that option fails, price a replacement before you leave. One route can have a later service that is useless because it ends at a different terminal. Golden Gate Ferry Sausalito schedule
For a late rail day, check local last stops and look at 511’s All Nighter network for a verified bus alternative. In the sample plan, move the activity to another night if the only workable ride leaves before it ends. Give all three days a common review time for new alerts. 511 All Nighter routes
The Wayfinder Newsletter: one free weekly email with the week's new guides from the Wayfinder publications, some of them before they're published on the sites. You choose which publications you get.