def add_time(start, duration, day=None):
    """Adds a time duration to a start time.
    
    Parameters
    ----------
    start : str
        Start time in the format "11:05 AM".
    duration : str
        Duration to add in hours:minutes, e.g. "15:27".
    day : str, default=None
        Full name of day of the week for the start time
        (case insensitive), e.g. "tuesday"

    Returns
    -------
    str
        Time when duration ends including the number of
        days passed, if any. If option `day` is provided,
        also returns the day the duration ends.
    
    """
    
    start_time, start_ampm = start.split()
    start_hour, start_min = start_time.split(":")
    dur_hour, dur_min = duration.split(":")

    new_hour = int(start_hour) + int(dur_hour)
    new_min = int(start_min) + int(dur_min)
    if start_ampm == "PM":
        new_hour += 12
    if new_min >= 60:
        new_min = new_min % 60
        new_hour += 1
    add_days = new_hour // 24
    new_hour = new_hour % 24
    new_ampm = "AM"
    if new_hour == 12:
        new_ampm = "PM"
    elif new_hour > 12:
        new_hour -= 12
        new_ampm = "PM"
    elif new_hour == 0:
        new_hour = 12
    extra = ""
    if add_days == 1:
        extra = " (next day)"
    elif add_days > 1:
        extra = f" ({add_days} days later)"
    days_of_week = ["monday", "tuesday", "wednesday",
                    "thursday", "friday", "saturday", "sunday"]
    if day:
        if day.lower() in days_of_week:
            day_index = days_of_week.index(day.lower())
            day_index += add_days
            new_day = days_of_week[day_index % 7]
            extra = f", {new_day.capitalize()}" + extra
        else:
            return f"Error: '{day}' is not a day of the week."


    return f"{new_hour}:{new_min:02} {new_ampm}{extra}"