| <!DOCTYPE html>
|
| <html lang="en">
|
| <head>
|
| <meta charset="UTF-8" />
|
| <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
| <title>Student Assistant – Vikou Nelson</title>
|
| <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><rect width='100' height='100' rx='22' fill='%236366f1'/><text x='50' y='68' text-anchor='middle' font-size='42' font-weight='bold' font-family='sans-serif' fill='white'>S</text></svg>">
|
| <style>
|
| * { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
| body {
|
| font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
| background:
|
| radial-gradient(
|
| ellipse 60% 40% at 80% 0%,
|
| rgba(167, 139, 250, 0.12),
|
| transparent 60%
|
| ),
|
| radial-gradient(
|
| ellipse 60% 40% at 0% 100%,
|
| rgba(99, 102, 241, 0.10),
|
| transparent 60%
|
| ),
|
| #f3f0ff;
|
| color: #1e1b4b;
|
| display: flex;
|
| flex-direction: column;
|
| align-items: center;
|
| min-height: 100vh;
|
| min-height: 100dvh;
|
| padding: 12px 24px 16px;
|
| }
|
|
|
| .header {
|
| position: relative;
|
| overflow: hidden;
|
| width: 100%;
|
| max-width: 1400px;
|
| margin-bottom: 12px;
|
| padding: 18px 28px 18px;
|
| border-radius: 18px;
|
| background: linear-gradient(
|
| 145deg,
|
| #1e1b4b 0%,
|
| #312e81 45%,
|
| #4f46e5 100%
|
| );
|
| box-shadow:
|
| 0 4px 6px rgba(30, 27, 75, 0.08),
|
| 0 20px 48px rgba(30, 27, 75, 0.22);
|
| text-align: center;
|
| }
|
|
|
| .header::before {
|
| content: "";
|
| position: absolute;
|
| inset: 0;
|
| background:
|
| radial-gradient(
|
| ellipse 80% 60% at 50% -20%,
|
| rgba(196, 181, 253, 0.28),
|
| transparent 55%
|
| ),
|
| radial-gradient(
|
| ellipse 50% 40% at 100% 100%,
|
| rgba(129, 140, 248, 0.18),
|
| transparent 50%
|
| );
|
| pointer-events: none;
|
| }
|
|
|
| .header-link {
|
| position: absolute;
|
| top: 18px;
|
| left: 18px;
|
| z-index: 2;
|
| display: inline-flex;
|
| align-items: center;
|
| gap: 6px;
|
| padding: 7px 14px 7px 13px;
|
| font-size: 0.78rem;
|
| font-weight: 500;
|
| letter-spacing: 0.02em;
|
| color: #ede9fe;
|
| background: rgba(255, 255, 255, 0.06);
|
| border: 1px solid rgba(196, 181, 253, 0.32);
|
| border-radius: 999px;
|
| text-decoration: none;
|
| backdrop-filter: blur(4px);
|
| transition:
|
| background 0.2s ease,
|
| border-color 0.2s ease,
|
| transform 0.15s ease;
|
| }
|
|
|
| .header-link:hover {
|
| background: rgba(167, 139, 250, 0.20);
|
| border-color: rgba(167, 139, 250, 0.55);
|
| transform: translateY(-1px);
|
| }
|
|
|
| .header-link svg {
|
| width: 14px;
|
| height: 14px;
|
| stroke: currentColor;
|
| }
|
|
|
| .header-inner {
|
| position: relative;
|
| z-index: 1;
|
| display: grid;
|
| grid-template-columns: auto 1fr;
|
| align-items: center;
|
| gap: 16px 18px;
|
| }
|
|
|
| .header-brand {
|
| display: flex;
|
| flex-direction: column;
|
| align-items: flex-start;
|
| gap: 4px;
|
| min-width: 0;
|
| }
|
|
|
| .header-icon {
|
| display: flex;
|
| align-items: center;
|
| justify-content: center;
|
| width: 44px;
|
| height: 44px;
|
| border-radius: 12px;
|
| background: rgba(255, 255, 255, 0.08);
|
| border: 1px solid rgba(255, 255, 255, 0.14);
|
| box-shadow: 0 6px 18px rgba(0, 0, 0, 0.20);
|
| backdrop-filter: blur(8px);
|
| }
|
|
|
| .header-icon svg {
|
| width: 24px;
|
| height: 24px;
|
| stroke: #c4b5fd;
|
| }
|
|
|
| .header-title {
|
| color: #f5f3ff;
|
| font-size: 1.25rem;
|
| font-weight: 700;
|
| letter-spacing: -0.02em;
|
| line-height: 1.15;
|
| }
|
|
|
| .header-subtitle {
|
| color: #c7d2fe;
|
| font-size: 0.82rem;
|
| font-weight: 400;
|
| letter-spacing: 0.01em;
|
| max-width: 560px;
|
| line-height: 1.45;
|
| }
|
|
|
| .header-subtitle strong {
|
| color: #ede9fe;
|
| font-weight: 600;
|
| }
|
|
|
| .header-divider { display: none; }
|
|
|
| .skills-block {
|
| grid-column: 1 / -1;
|
| display: flex;
|
| align-items: center;
|
| justify-content: center;
|
| gap: 10px;
|
| width: 100%;
|
| flex-wrap: wrap;
|
| padding-top: 4px;
|
| border-top: 1px solid rgba(196, 181, 253, 0.15);
|
| margin-top: 6px;
|
| }
|
|
|
| .skills-label {
|
| color: #a5b4fc;
|
| font-size: 0.65rem;
|
| font-weight: 600;
|
| letter-spacing: 0.18em;
|
| text-transform: uppercase;
|
| opacity: 0.85;
|
| margin-top: 4px;
|
| }
|
|
|
| .tags {
|
| display: flex;
|
| flex-wrap: wrap;
|
| justify-content: center;
|
| gap: 6px;
|
| max-width: 100%;
|
| margin-top: 4px;
|
| }
|
|
|
| .tag {
|
| padding: 4px 11px;
|
| font-size: 0.74rem;
|
| font-weight: 500;
|
| color: #ede9fe;
|
| background: rgba(255, 255, 255, 0.06);
|
| border: 1px solid rgba(196, 181, 253, 0.28);
|
| border-radius: 999px;
|
| backdrop-filter: blur(4px);
|
| transition:
|
| background 0.2s ease,
|
| border-color 0.2s ease,
|
| transform 0.15s ease;
|
| }
|
|
|
| .tag:hover {
|
| background: rgba(167, 139, 250, 0.18);
|
| border-color: rgba(167, 139, 250, 0.50);
|
| transform: translateY(-1px);
|
| }
|
|
|
| .chat-container {
|
| position: relative;
|
| overflow: hidden;
|
| width: 100%;
|
| max-width: 1400px;
|
| display: flex;
|
| flex-direction: column;
|
| height: min(820px, calc(100dvh - 210px));
|
| min-height: 480px;
|
| border-radius: 18px;
|
| background: linear-gradient(
|
| 160deg,
|
| #1e1b4b 0%,
|
| #312e81 55%,
|
| #4338ca 100%
|
| );
|
| box-shadow:
|
| 0 4px 6px rgba(30, 27, 75, 0.08),
|
| 0 20px 48px rgba(30, 27, 75, 0.26);
|
| }
|
|
|
| .chat-container::before {
|
| content: "";
|
| position: absolute;
|
| inset: 0;
|
| pointer-events: none;
|
| background:
|
| radial-gradient(
|
| ellipse 70% 50% at 100% 0%,
|
| rgba(196, 181, 253, 0.16),
|
| transparent 60%
|
| );
|
| }
|
|
|
| .messages {
|
| position: relative;
|
| flex: 1;
|
| overflow-y: auto;
|
| padding: 22px 22px 14px;
|
| display: flex;
|
| flex-direction: column;
|
| gap: 14px;
|
| scrollbar-width: thin;
|
| scrollbar-color: rgba(196, 181, 253, 0.35) transparent;
|
| }
|
|
|
| .messages::-webkit-scrollbar { width: 8px; }
|
| .messages::-webkit-scrollbar-track { background: transparent; }
|
| .messages::-webkit-scrollbar-thumb {
|
| background: rgba(196, 181, 253, 0.30);
|
| border-radius: 4px;
|
| }
|
| .messages::-webkit-scrollbar-thumb:hover {
|
| background: rgba(196, 181, 253, 0.50);
|
| }
|
|
|
| .message {
|
| max-width: 78%;
|
| padding: 11px 15px;
|
| border-radius: 16px;
|
| line-height: 1.55;
|
| font-size: 0.95rem;
|
| word-wrap: break-word;
|
| animation: msgIn 0.18s ease-out;
|
| }
|
|
|
| @keyframes msgIn {
|
| from { opacity: 0; transform: translateY(4px); }
|
| to { opacity: 1; transform: translateY(0); }
|
| }
|
|
|
| .message.user {
|
| align-self: flex-end;
|
| color: #f5f3ff;
|
| background: linear-gradient(135deg, #6366f1, #a78bfa);
|
| border-bottom-right-radius: 4px;
|
| box-shadow: 0 6px 18px rgba(99, 102, 241, 0.32);
|
| }
|
|
|
| .message.assistant {
|
| align-self: flex-start;
|
| color: #ede9fe;
|
| background: rgba(255, 255, 255, 0.06);
|
| border: 1px solid rgba(196, 181, 253, 0.22);
|
| border-bottom-left-radius: 4px;
|
| backdrop-filter: blur(8px);
|
| }
|
|
|
| .message.typing {
|
| align-self: flex-start;
|
| color: #c7d2fe;
|
| background: rgba(255, 255, 255, 0.04);
|
| border: 1px solid rgba(196, 181, 253, 0.16);
|
| border-bottom-left-radius: 4px;
|
| font-style: italic;
|
| }
|
|
|
| .message.assistant p { margin: 0 0 8px; }
|
| .message.assistant p:last-child { margin-bottom: 0; }
|
| .message.assistant a {
|
| color: #c4b5fd;
|
| text-decoration: underline;
|
| text-underline-offset: 2px;
|
| }
|
| .message.assistant code {
|
| background: rgba(15, 23, 42, 0.55);
|
| color: #f0abfc;
|
| padding: 1px 6px;
|
| border-radius: 4px;
|
| font-size: 0.88em;
|
| font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
| }
|
| .message.assistant pre {
|
| background: rgba(15, 23, 42, 0.72);
|
| border: 1px solid rgba(196, 181, 253, 0.18);
|
| border-radius: 10px;
|
| padding: 10px 12px;
|
| margin: 8px 0;
|
| overflow-x: auto;
|
| font-size: 0.86em;
|
| font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
| }
|
| .message.assistant pre code {
|
| background: transparent;
|
| color: #ede9fe;
|
| padding: 0;
|
| }
|
| .message.assistant ul,
|
| .message.assistant ol {
|
| padding-left: 22px;
|
| margin: 6px 0;
|
| }
|
| .message.assistant strong { color: #f5f3ff; }
|
|
|
| .input-area {
|
| position: relative;
|
| display: flex;
|
| gap: 10px;
|
| padding: 14px 16px;
|
| background: rgba(30, 27, 75, 0.55);
|
| border-top: 1px solid rgba(196, 181, 253, 0.18);
|
| backdrop-filter: blur(6px);
|
| }
|
|
|
| .input-area input {
|
| flex: 1;
|
| padding: 12px 18px;
|
| color: #f5f3ff;
|
| background: rgba(255, 255, 255, 0.06);
|
| border: 1px solid rgba(196, 181, 253, 0.28);
|
| border-radius: 24px;
|
| font-size: 0.95rem;
|
| outline: none;
|
| transition: border-color 0.2s, background 0.2s;
|
| }
|
|
|
| .input-area input::placeholder { color: #c7d2fe; }
|
|
|
| .input-area input:focus {
|
| border-color: #a78bfa;
|
| background: rgba(255, 255, 255, 0.10);
|
| }
|
|
|
| .input-area button {
|
| padding: 11px 22px;
|
| color: #f5f3ff;
|
| background: linear-gradient(135deg, #6366f1, #a78bfa);
|
| border: none;
|
| border-radius: 24px;
|
| font-size: 0.95rem;
|
| font-weight: 600;
|
| cursor: pointer;
|
| transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s;
|
| box-shadow: 0 6px 18px rgba(99, 102, 241, 0.32);
|
| }
|
|
|
| .input-area button:hover {
|
| transform: translateY(-1px);
|
| filter: brightness(1.05);
|
| }
|
| .input-area button:disabled {
|
| background: #4b5563;
|
| box-shadow: none;
|
| cursor: not-allowed;
|
| transform: none;
|
| filter: none;
|
| }
|
|
|
| @media (max-width: 720px) {
|
| body { padding: 8px 12px 12px; }
|
| .header {
|
| padding: 44px 14px 14px;
|
| border-radius: 14px;
|
| }
|
| .header-link {
|
| top: 10px;
|
| left: 10px;
|
| padding: 5px 10px;
|
| font-size: 0.70rem;
|
| }
|
| .header-inner { gap: 10px 12px; }
|
| .header-icon { width: 38px; height: 38px; border-radius: 10px; }
|
| .header-icon svg { width: 20px; height: 20px; }
|
| .header-title { font-size: 1.05rem; }
|
| .header-subtitle {
|
| font-size: 0.76rem;
|
| line-height: 1.4;
|
| }
|
| .skills-label { display: none; }
|
| .tag { font-size: 0.70rem; padding: 3px 9px; }
|
| .chat-container {
|
| height: calc(100dvh - 230px);
|
| min-height: 380px;
|
| border-radius: 14px;
|
| }
|
| .message { max-width: 88%; }
|
| }
|
| </style>
|
| </head>
|
| <body>
|
|
|
| <header class="header">
|
| <a class="header-link" href="/" aria-label="Back to main">
|
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| <path d="M19 12H5"/>
|
| <path d="m11 18-6-6 6-6"/>
|
| </svg>
|
| Back
|
| </a>
|
| <div class="header-inner">
|
| <div class="header-icon" aria-hidden="true">
|
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
| <path d="M22 10v6"/>
|
| <path d="M2 10l10-5 10 5-10 5z"/>
|
| <path d="M6 12v5a6 3 0 0 0 12 0v-5"/>
|
| </svg>
|
| </div>
|
| <div class="header-brand">
|
| <h1 class="header-title">Student Assistant</h1>
|
| <p class="header-subtitle">
|
| Your AI study companion — get help with concepts, exercises and
|
| quick explanations across math, stats, AI and more.
|
| </p>
|
| </div>
|
| <div class="skills-block">
|
| <span class="skills-label">Study areas</span>
|
| <div class="tags">
|
| <span class="tag">Mathematics</span>
|
| <span class="tag">Statistics</span>
|
| <span class="tag">Econometrics</span>
|
| <span class="tag">Programming</span>
|
| <span class="tag">Machine Learning</span>
|
| <span class="tag">Data Science</span>
|
| <span class="tag">AI Concepts</span>
|
| </div>
|
| </div>
|
| </div>
|
| </header>
|
|
|
| <div class="chat-container">
|
| <div class="messages" id="messages"></div>
|
| <div class="input-area">
|
| <input type="text" id="input" placeholder="Ask your study question..." maxlength="2000" />
|
| <button id="sendBtn" onclick="sendMessage()">Send</button>
|
| </div>
|
| </div>
|
|
|
| <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| <script>
|
| const history = [];
|
|
|
| if (window.marked && marked.setOptions) {
|
| marked.setOptions({ breaks: true, gfm: true });
|
| }
|
|
|
| function escapeHtml(text) {
|
| return text
|
| .replace(/&/g, "&")
|
| .replace(/</g, "<")
|
| .replace(/>/g, ">")
|
| .replace(/"/g, """)
|
| .replace(/'/g, "'");
|
| }
|
|
|
| function renderAssistant(text) {
|
| if (window.marked && marked.parse) {
|
| return marked.parse(text);
|
| }
|
| return escapeHtml(text).replace(/\n/g, "<br>");
|
| }
|
|
|
| function addMessage(text, role) {
|
| const msgs = document.getElementById("messages");
|
| const div = document.createElement("div");
|
| div.className = `message ${role}`;
|
| if (role === "assistant") {
|
| div.innerHTML = renderAssistant(text);
|
| } else {
|
| div.textContent = text;
|
| }
|
| msgs.appendChild(div);
|
| msgs.scrollTop = msgs.scrollHeight;
|
| return div;
|
| }
|
|
|
| addMessage(
|
| "The student assistant is currently unavailable. Please check "
|
| + "back later.",
|
| "assistant"
|
| );
|
|
|
| async function sendMessage() {
|
| const input = document.getElementById("input");
|
| const btn = document.getElementById("sendBtn");
|
| const text = input.value.trim();
|
| if (!text) return;
|
|
|
| addMessage(text, "user");
|
| input.value = "";
|
| btn.disabled = true;
|
|
|
| const typing = addMessage("Typing...", "typing");
|
|
|
| try {
|
| const res = await fetch("/chat/students", {
|
| method: "POST",
|
| headers: { "Content-Type": "application/json" },
|
| body: JSON.stringify({ message: text, history: history })
|
| });
|
|
|
| typing.remove();
|
|
|
| if (res.status === 429) {
|
| addMessage(
|
| "You're sending messages too quickly. Please wait a moment "
|
| + "before trying again.",
|
| "assistant"
|
| );
|
| } else if (!res.ok) {
|
| addMessage(
|
| "The student assistant is currently unavailable. Please "
|
| + "check back later.",
|
| "assistant"
|
| );
|
| } else {
|
| const data = await res.json();
|
| addMessage(data.response, "assistant");
|
| history.push({ role: "user", content: text });
|
| history.push({ role: "assistant", content: data.response });
|
| }
|
| } catch (e) {
|
| typing.remove();
|
| addMessage(
|
| "The student assistant is currently unavailable. Please "
|
| + "check back later.",
|
| "assistant"
|
| );
|
| }
|
|
|
| btn.disabled = false;
|
| input.focus();
|
| }
|
|
|
| document.getElementById("input").addEventListener("keydown", e => {
|
| if (e.key === "Enter") sendMessage();
|
| });
|
| </script>
|
|
|
| </body>
|
| </html>
|
|
|