<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NOVA AI PRO</title>
<style>
:root{--bg:#0b1020;--panel:#111a2e;--card:#18243b;--text:#edf3ff;--muted:#91a2c0;--accent:#8067ff;--border:#293652}
.light{--bg:#f3f5fb;--panel:#fff;--card:#edf0f9;--text:#182039;--muted:#64718b;--accent:#634be8;--border:#dce1ef}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font:15px Inter,Arial,sans-serif}
button,textarea,select{font:inherit}
.app{display:flex;min-height:100vh}
.sidebar{width:255px;background:var(--panel);border-right:1px solid var(--border);padding:18px;display:flex;flex-direction:column;gap:15px}
.logo{font-size:24px;font-weight:800;letter-spacing:1px;background:linear-gradient(90deg,#9b8aff,#48d7ff);background-clip:text;color:transparent}
.sub{color:var(--muted);font-size:12px}
.new{background:var(--accent);color:white;border:0;padding:13px;border-radius:12px;cursor:pointer}
.side-title{font-size:12px;color:var(--muted);margin-top:8px}
#history{display:flex;flex-direction:column;gap:6px;overflow:auto}
.history-item{background:transparent;border:1px solid transparent;color:var(--text);padding:10px;text-align:left;border-radius:9px;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.history-item:hover{background:var(--card)}
.sidebar-bottom{margin-top:auto;display:grid;gap:9px}
.main{flex:1;min-width:0;display:flex;flex-direction:column;min-height:100vh}
.top{height:65px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:0 22px;gap:10px}
.top select,.top button{background:var(--card);color:var(--text);border:1px solid var(--border);border-radius:9px;padding:9px}
#chat{width:min(850px,100%);margin:auto;flex:1;padding:25px 20px 130px;display:flex;flex-direction:column;gap:20px}
.welcome{text-align:center;margin:auto 0}
.welcome h1{font-size:clamp(30px,6vw,49px);margin-bottom:8px;background:linear-gradient(90deg,#a28aff,#53d6ed);background-clip:text;color:transparent}
.welcome p{color:var(--muted)}
.suggestions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:28px auto;max-width:600px}
.suggestion{background:var(--card);border:1px solid var(--border);color:var(--text);padding:15px;border-radius:13px;text-align:left;cursor:pointer}
.message{display:flex;flex-direction:column;gap:7px;max-width:100%;line-height:1.7}
.message.user{align-self:flex-end;max-width:85%;background:var(--accent);color:white;padding:12px 16px;border-radius:17px 17px 4px 17px;white-space:pre-wrap;overflow-wrap:anywhere}
.message.bot{align-self:flex-start;width:100%;background:var(--panel);border:1px solid var(--border);padding:16px;border-radius:15px;white-space:pre-wrap;overflow-wrap:anywhere}
.actions{display:flex;gap:7px;flex-wrap:wrap}
.actions button{background:var(--card);color:var(--muted);border:1px solid var(--border);padding:6px 10px;border-radius:8px;cursor:pointer}
.composer-wrap{position:fixed;bottom:0;left:255px;right:0;background:linear-gradient(transparent,var(--bg) 20%);padding:18px 20px 20px}
.composer{max-width:850px;margin:auto;background:var(--panel);border:1px solid var(--border);border-radius:17px;padding:10px;box-shadow:0 10px 40px #0003}
#prompt{width:100%;resize:none;border:0;outline:0;background:transparent;color:var(--text);padding:10px;min-height:55px;max-height:180px}
.composer-bottom{display:flex;justify-content:space-between;align-items:center;gap:8px}
.composer-bottom button{border:0;border-radius:10px;padding:10px 14px;cursor:pointer}
<button class="send" id="sendBtn" type="button" onclick="sendMessage()">Send ↑</button>
.tool{background:var(--card);color:var(--text)}
#status{font-size:12px;color:var(--muted);text-align:center;margin-top:8px}
.mobile-menu{display:none}
@media(max-width:700px){
.sidebar{display:none;position:fixed;z-index:5;inset:0 auto 0 0;width:270px;box-shadow:0 0 0 100vmax #0008}
.sidebar.open{display:flex}
.mobile-menu{display:block}
.composer-wrap{left:0;padding:10px}
#chat{padding:18px 12px 125px}
.top{padding:0 12px}
.suggestions{grid-template-columns:1fr}
}
</style>
</head>
<body>
<div class="app">
<aside class="sidebar" id="sidebar">
<div>
<div class="logo">✦ NOVA AI</div>
<div class="sub">YOUR INTELLIGENT ASSISTANT</div>
</div>
<button class="new" onclick="newChat()">+ New conversation</button>
<div class="side-title">RECENT CONVERSATIONS</div>
<div id="history"></div>
<div class="sidebar-bottom">
<button class="tool" onclick="toggleTheme()">☀️ / ☾ Change theme</button>
<button class="tool" onclick="clearHistory()">Clear history</button>
<div class="sub">NOVA AI PRO • Built with OpenRouter</div>
</div>
</aside>
<main class="main">
<div class="top">
<div style="display:flex;align-items:center;gap:10px">
<button class="mobile-menu" onclick="toggleMenu()">☰</button>
<strong>NOVA AI PRO</strong>
</div>
<div style="display:flex;gap:7px">
<select id="mode">
<option value="You are a helpful, accurate AI assistant.">General</option>
<option value="You are an expert programmer. Give clear, working code.">Coding</option>
<option value="You are a professional writer.">Writing</option>
<option value="You are a careful research assistant. Explain uncertainty and do not invent facts.">Research</option>
<option value="You are a patient teacher. Explain concepts step by step.">Learning</option>
</select>
<select id="model">
<option value="openrouter/free">Free model router</option>
<option value="meta-llama/llama-3.3-70b-instruct:free">Llama 3.3 Free</option>
<option value="google/gemma-3-27b-it:free">Gemma 3 Free</option>
</select>
</div>
</div>
<section id="chat">
<div class="welcome" id="welcome">
<h1>Meet NOVA AI</h1>
<p>Your ideas. Your questions. A smarter conversation.</p>
<div class="suggestions">
<button class="suggestion" onclick="suggest('Teach me something interesting')">💡 Teach me something interesting</button>
<button class="suggestion" onclick="suggest('Help me write a professional email')">✍️ Write a professional email</button>
<button class="suggestion" onclick="suggest('Create a website using HTML and CSS')">💻 Build a website</button>
<button class="suggestion" onclick="suggest('Explain artificial intelligence simply')">🧠 Explain AI simply</button>
</div>
</div>
</section>
<div class="composer-wrap">
<div class="composer">
<textarea id="prompt" rows="2" placeholder="Message NOVA AI..."></textarea>
<div class="composer-bottom">
<div>
<button class="tool" onclick="voiceInput()">🎤</button>
<button class="tool" onclick="document.getElementById('file').click()">📎</button>
<input id="file" type="file" hidden accept=".txt,.md,.csv,.json" onchange="readFile(this)">
</div>
<div>
<button class="send" id="sendBtn" onclick="sendMessage()">Send ↑</button>
</div>
</div>
</div>
<div id="status">Ready when you are.</div>
</div>
</main>
</div>
<script>
/* Paste your OpenRouter key between the quotation marks below. */
const API_KEY = "vck_17mZ4p1Zj11aNx2WG2oc6YHjpGD7UYAMQeRIpEyW4HcZI7jb7p0UtFlS";
const API_URL = "https://openrouter.ai/api/v1/chat/completions";
const chat = document.getElementById("chat");
const promptBox = document.getElementById("prompt");
const statusBox = document.getElementById("status");
let conversations = [];
let current = {id:Date.now(),title:"New conversation",messages:[]};
let lastAnswer = "";
let attachedText = "";
function showWelcome(){
chat.innerHTML = <div class="welcome" id="welcome"><h1>Meet NOVA AI</h1><p>Your ideas. Your questions. A smarter conversation.</p><div class="suggestions"><button class="suggestion" onclick="suggest('Teach me something interesting')">💡 Teach me something interesting</button><button class="suggestion" onclick="suggest('Help me write a professional email')">✍️ Write a professional email</button><button class="suggestion" onclick="suggest('Create a website using HTML and CSS')">💻 Build a website</button><button class="suggestion" onclick="suggest('Explain artificial intelligence simply')">🧠 Explain AI simply</button></div></div>;
}
function addMessage(text,role){
const div=document.createElement("div");
div.className="message "+role;
div.textContent=text;
chat.appendChild(div);
if(role==="bot"){
const actions=document.createElement("div");
actions.className="actions";
const copy=document.createElement("button");
copy.textContent="Copy";
copy.onclick=()=>navigator.clipboard.writeText(text);
const read=document.createElement("button");
read.textContent="Read aloud";
read.onclick=()=>{speechSynthesis.cancel();speechSynthesis.speak(new SpeechSynthesisUtterance(text));};
actions.append(copy,read);
div.appendChild(actions);
}
chat.scrollTop=chat.scrollHeight;
return div;
}
function suggest(text){promptBox.value=text;sendMessage();}
async function sendMessage(){
const text=promptBox.value.trim();
if(!text)return;
if(!API_KEY || API_KEY==="vck_17mZ4p1Zj11aNx2WG2oc6YHjpGD7UYAMQeRIpEyW4HcZI7jb7p0UtFlS"){
statusBox.textContent="Add your OpenRouter API key in the code first.";
return;
}
const fullText=attachedText ? text+"\n\nAttached file:\n"+attachedText : text;
attachedText="";
promptBox.value="";
document.getElementById("welcome")?.remove();
current.messages.push({role:"user",content:fullText});
addMessage(text,"user");
const answerBox=addMessage("Thinking...","bot");
const sendBtn=document.getElementById("sendBtn");
sendBtn.disabled=true;
statusBox.textContent="NOVA AI is thinking...";
try{
const response=await fetch(API_URL,{
method:"POST",
headers:{
"Authorization":"Bearer "+API_KEY,
"Content-Type":"application/json"
},
body:JSON.stringify({
model:document.getElementById("model").value,
messages:[
{role:"system",content:document.getElementById("mode").value},
...current.messages
]
})
});
const data=await response.json();
if(!response.ok)throw new Error(data.error?.message || "HTTP error "+response.status);
const answer=data.choices?.[0]?.message?.content;
if(!answer)throw new Error("The model returned an empty answer. Try another model.");
answerBox.textContent=answer;
lastAnswer=answer;
current.messages.push({role:"assistant",content:answer});
current.title=text.slice(0,35);
saveHistory();
const actions=document.createElement("div");
actions.className="actions";
const copy=document.createElement("button");
copy.textContent="Copy";
copy.onclick=()=>navigator.clipboard.writeText(answer);
const read=document.createElement("button");
read.textContent="Read aloud";
read.onclick=()=>speechSynthesis.speak(new SpeechSynthesisUtterance(answer));
actions.append(copy,read);
answerBox.appendChild(actions);
statusBox.textContent="Ready.";
}catch(error){
answerBox.textContent="Sorry, I couldn't answer.\n\n"+error.message;
current.messages.pop();
statusBox.textContent="Connection error. Check your key or try another model.";
}finally{
sendBtn.disabled=false;
chat.scrollTop=chat.scrollHeight;
}
}
function saveHistory(){
const old=conversations.filter(c=>c.id!==current.id);
conversations=[...old,current].slice(-30);
try{localStorage.setItem("nova_history",JSON.stringify(conversations));}catch(e){}
renderHistory();
}
function loadHistory(){
try{conversations=JSON.parse(localStorage.getItem("nova_history")||"[]");}catch(e){conversations=[];}
renderHistory();
}
function renderHistory(){
const list=document.getElementById("history");
list.innerHTML="";
conversations.slice().reverse().forEach(c=>{
const b=document.createElement("button");
b.className="history-item";
b.textContent=c.title||"Conversation";
b.onclick=()=>openConversation(c.id);
list.appendChild(b);
});
}
function openConversation(id){
const found=conversations.find(c=>c.id===id);
if(!found)return;
current=JSON.parse(JSON.stringify(found));
chat.innerHTML="";
current.messages.forEach(m=>addMessage(m.content,m.role==="user"?"user":"bot"));
}
function newChat(){
current={id:Date.now(),title:"New conversation",messages:[]};
lastAnswer="";
showWelcome();
statusBox.textContent="New conversation.";
document.getElementById("sidebar").classList.remove("open");
}
function clearHistory(){
if(!confirm("Delete all saved conversations?"))return;
conversations=[];
localStorage.removeItem("nova_history");
renderHistory();
newChat();
}
function toggleTheme(){document.body.classList.toggle("light");}
function toggleMenu(){document.getElementById("sidebar").classList.toggle("open");}
function voiceInput(){
const R=window.SpeechRecognition||window.webkitSpeechRecognition;
if(!R){statusBox.textContent="Voice input isn't supported in this browser.";return;}
const r=new R();r.lang="en-IN";
r.onresult=e=>{promptBox.value=e.results[0][0].transcript;};
r.start();
}
function readFile(input){
const file=input.files[0];if(!file)return;
const reader=new FileReader();
reader.onload=()=>{attachedText=String(reader.result).slice(0,15000);statusBox.textContent="Attached: "+file.name;};
reader.readAsText(file);
}
promptBox.addEventListener("keydown",e=>{
if(e.key==="Enter"&&!e.shiftKey){e.preventDefault();sendMessage();}
});
loadHistory();
</script>
</body>
</html>