document.addEventListener('DOMContentLoaded', function () { const calcContainer = document.getElementById('dynamic-calc'); const staticCalc = document.getElementById('static-calc'); if (calcContainer) { calcContainer.style.display = 'block'; if (staticCalc) staticCalc.style.display = 'none'; const input = document.getElementById('calc-input'); const history = document.getElementById('calc-history'); const buttons = document.querySelectorAll('.calc-buttons button'); const staticCalcContent = staticCalc?.textContent.trim(); // load HTML calc const initialQuery = input.value.trim(); let currentInput = initialQuery; let historyLog = []; if (initialQuery && staticCalcContent) { historyLog.push(`${initialQuery} = ${staticCalcContent}`); } const updateUI = () => { input.value = currentInput; history.innerHTML = historyLog.map(entry => `