(function(){ // Wait for page to load var t=setInterval(function(){ var micBtn=document.getElementById("mic-btn"); if(!micBtn) return; clearInterval(t); // Check if already added if(document.getElementById("text-chat-box")) return; // Create text chat container var chatBox=document.createElement("div"); chatBox.id="text-chat-box"; chatBox.style.cssText="position:fixed;bottom:120px;left:50%;transform:translateX(-50%);width:90%;max-width:380px;z-index:9999;display:flex;gap:6px;padding:6px;"; var input=document.createElement("input"); input.id="text-chat-input"; input.type="text"; input.placeholder="Type a message..."; input.style.cssText="flex:1;background:rgba(0,20,40,0.9);border:1px solid hsl(195,100%,30%);border-radius:8px;padding:10px 14px;color:hsl(195,100%,80%);font-family:monospace;font-size:13px;outline:none;"; input.onfocus=function(){this.style.borderColor="hsl(195,100%,50%)";this.style.boxShadow="0 0 15px rgba(0,170,255,0.2)";}; input.onblur=function(){this.style.borderColor="hsl(195,100%,30%)";this.style.boxShadow="none";}; var sendBtn=document.createElement("button"); sendBtn.textContent="▶"; sendBtn.style.cssText="background:rgba(0,170,255,0.2);border:1px solid hsl(195,100%,40%);border-radius:8px;padding:10px 16px;color:hsl(195,100%,70%);font-size:14px;cursor:pointer;transition:all 0.2s;"; sendBtn.onmouseenter=function(){this.style.background="rgba(0,170,255,0.4)";}; sendBtn.onmouseleave=function(){this.style.background="rgba(0,170,255,0.2)";}; function sendMessage(){ var msg=input.value.trim(); if(!msg) return; input.value=""; input.disabled=true; sendBtn.disabled=true; sendBtn.textContent="◌"; fetch("/api/chat/george",{ method:"POST", headers:{"Content-Type":"application/json"}, body:JSON.stringify({message:msg}) }).then(function(r){return r.json()}).then(function(d){ input.disabled=false; sendBtn.disabled=false; sendBtn.textContent="▶"; input.focus(); }).catch(function(){ input.disabled=false; sendBtn.disabled=false; sendBtn.textContent="▶"; }); } sendBtn.onclick=sendMessage; input.onkeydown=function(e){if(e.key==="Enter")sendMessage();}; chatBox.appendChild(input); chatBox.appendChild(sendBtn); document.body.appendChild(chatBox); },500); })();