nutes = now.getMinutes().toString().padStart(2, "0");

          // Determine AM or PM
          const ampm = hours >= 12 ? "pm" : "am";

          return `${timePeriod} at ${displayHours}:${minutes}${ampm}`;
        }

        function logMessage(msg) {
          const time = new Date().toLocaleTimeString();
          log.textContent = `[${time}] ${msg}\n` + log.textContent;
        }

        toggleBtn.addEventListener("click", async () => await toggleCapture());
        startCamera();

        function c