* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242736;
    --border: #2e3247;
    --text: #e4e4e7;
    --text-muted: #8b8fa3;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --user-bg: #1e3a5f;
    --agent-bg: #1a1d27;
    --tool-bg: #1c2333;
    --error: #ef4444;
    --success: #22c55e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.screen { display: flex; height: 100vh; }
.hidden { display: none !important; }

/* Login */
#login-screen {
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 360px;
    text-align: center;
}

.login-card h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.login-card input:focus {
    border-color: var(--accent);
}

.login-card button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}

.login-card button:hover { background: var(--accent-hover); }

.error {
    color: var(--error);
    font-size: 13px;
    margin-top: 12px;
}

/* Chat Screen */
#chat-screen {
    flex-direction: column;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

header h2 { font-size: 16px; }

.badge {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
}

.btn-text:hover { color: var(--text); }

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.msg.user {
    align-self: flex-end;
    background: var(--user-bg);
    border-bottom-right-radius: 4px;
}

.msg.agent {
    align-self: flex-start;
    background: var(--agent-bg);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg.agent p { margin-bottom: 8px; }
.msg.agent p:last-child { margin-bottom: 0; }
.msg.agent ul, .msg.agent ol { margin-left: 20px; margin-bottom: 8px; }
.msg.agent code {
    background: var(--surface2);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 13px;
}
.msg.agent pre {
    background: var(--surface2);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.msg.agent pre code {
    background: none;
    padding: 0;
}
.msg.agent strong { color: var(--accent-hover); }
.msg.agent a { color: var(--accent-hover); }

.msg.tool-info {
    align-self: flex-start;
    background: var(--tool-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 12px;
    max-width: 70%;
}

.msg.tool-info .tool-name {
    color: var(--accent-hover);
    font-weight: 600;
}

/* Tool Status Bar */
.tool-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Chat Input */
.chat-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

#message-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
}

#message-input:focus { border-color: var(--accent); }

#send-btn {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

#send-btn:hover { background: var(--accent-hover); }
#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar */
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Mobile */
@media (max-width: 600px) {
    .msg { max-width: 95%; }
    .login-card { width: 90%; padding: 28px; }
}
