:root {
    --bg-color: #0d0c22;
    --glass-bg: rgba(42, 42, 46, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-color: #e0e0e0;
    --highlight-color: #00aaff;
    --ai-bubble-bg: rgba(61, 61, 66, 0.7);
    --user-bubble-bg: rgba(0, 123, 255, 0.7);
    --font-primary: 'Space Grotesk', sans-serif;
    --font-secondary: 'Roboto Mono', monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-primary);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #1d1d4e, #0d0c22, #4e1d4e);
    background-size: 400% 400%;
    animation: gradient-flow 15s ease infinite;
    z-index: -1;
}
@keyframes gradient-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#chat-container {
    width: 90%;
    max-width: 800px;
    height: 90vh;
    background: var(--glass-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}
header .title-animation h1 {
    font-size: 1.8em;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px var(--highlight-color), 0 0 20px var(--highlight-color);
}
header p { font-size: 0.9em; opacity: 0.8; font-family: var(--font-secondary); }

#chat-log {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#chat-log::-webkit-scrollbar { width: 8px; }
#chat-log::-webkit-scrollbar-track { background: transparent; }
#chat-log::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.2); border-radius: 20px; }

.message { display: flex; max-width: 85%; align-items: flex-start; gap: 10px; line-height: 1.6; animation: fadeIn 0.5s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message .bubble { padding: 12px 18px; border-radius: 20px; word-wrap: break-word; }
.message .avatar { width: 40px; height: 40px; border-radius: 50%; background: #333; flex-shrink: 0; display: flex; justify-content: center; align-items: center; font-family: var(--font-secondary); font-weight: 500; }
.user-message { justify-content: flex-end; align-self: flex-end; }
.user-message .avatar { background: var(--user-bubble-bg); content: 'U'; }
.user-message .bubble { background-color: var(--user-bubble-bg); border-bottom-right-radius: 5px; }
.ai-message { align-self: flex-start; }
.ai-message .avatar { background: var(--ai-bubble-bg); content: 'AI'; }
.ai-message .bubble { background-color: var(--ai-bubble-bg); border-bottom-left-radius: 5px; }

.tool-info { display: flex; align-items: center; gap: 8px; font-size: 0.8em; opacity: 0.7; margin-top: 8px; font-family: var(--font-secondary); }
.tool-info i { font-size: 1.2em; color: var(--highlight-color); }
.copy-button { background: none; border: none; color: #aaa; cursor: pointer; opacity: 0; transition: opacity 0.2s; }
.ai-message:hover .copy-button { opacity: 1; }
.copy-button:hover { color: #fff; }

#chat-form { display: flex; padding: 15px; border-top: 1px solid var(--border-color); gap: 10px; }
#user-input {
    flex-grow: 1;
    background-color: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 12px 20px;
    color: var(--text-color);
    font-family: var(--font-primary);
    font-size: 1em;
    transition: all 0.3s ease;
}
#user-input:focus { outline: none; border-color: var(--highlight-color); box-shadow: 0 0 10px var(--highlight-color); }
#send-button {
    background: var(--highlight-color);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}
#send-button:hover { transform: scale(1.1); box-shadow: 0 0 15px var(--highlight-color); }
#send-button svg { width: 24px; height: 24px; color: white; }

.hidden { display: none !important; }
#typing-indicator { padding: 10px 20px; }
.dot-flashing { position: relative; width: 10px; height: 10px; border-radius: 5px; background-color: var(--highlight-color); color: var(--highlight-color); animation: dot-flashing 1s infinite linear alternate; animation-delay: .5s; }
.dot-flashing::before, .dot-flashing::after { content: ''; display: inline-block; position: absolute; top: 0; }
.dot-flashing::before { left: -15px; width: 10px; height: 10px; border-radius: 5px; background-color: var(--highlight-color); color: var(--highlight-color); animation: dot-flashing 1s infinite alternate; animation-delay: 0s; }
.dot-flashing::after { left: 15px; width: 10px; height: 10px; border-radius: 5px; background-color: var(--highlight-color); color: var(--highlight-color); animation: dot-flashing 1s infinite alternate; animation-delay: 1s; }
@keyframes dot-flashing { 0% { background-color: var(--highlight-color); } 50%, 100% { background-color: rgba(0, 170, 255, 0.2); } }