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

:root {
    --bg: #0a0a0f;
    --surface: #14141f;
    --surface2: #1e1e2e;
    --accent: #6c5ce7;
    --accent-hover: #7c6df7;
    --text: #e0e0e0;
    --text-dim: #888;
    --border: #2a2a3a;
    --bot-bg: #1a1a2e;
    --user-bg: #6c5ce7;
    --error: #e74c3c;
}

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

.screen[hidden] {
    display: none !important;
}

.screen {
    width: 100%;
    max-width: 520px;
    height: 85vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* Auth Screen */
#auth-screen {
    justify-content: center;
    align-items: center;
    background: var(--surface);
}

.auth-card {
    text-align: center;
    padding: 2.5rem 2rem;
    width: 100%;
}

.logo {
    width: 64px;
    height: 64px;
    background: var(--accent);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1.2rem;
}

.auth-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.subtitle {
    color: var(--text-dim);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

#auth-form input {
    padding: 0.8rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

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

#auth-form button {
    padding: 0.8rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#auth-form button:hover {
    background: var(--accent-hover);
}

.error {
    color: var(--error);
    margin-top: 0.8rem;
    font-size: 0.85rem;
}

.site-link {
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.site-link:hover {
    color: var(--accent);
}

/* Chat Screen */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-sm {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.chat-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.status {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.header-badge {
    padding: 0.35rem 0.8rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
}

.header-badge:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.message {
    display: flex;
    max-width: 80%;
}

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.bubble {
    padding: 0.7rem 1rem;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.message.bot .bubble {
    background: var(--bot-bg);
    border-bottom-left-radius: 4px;
}

.message.user .bubble {
    background: var(--user-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.bot .bubble.typing::after {
    content: "▊";
    animation: blink 0.7s infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Chat Input */
.chat-input {
    display: flex;
    gap: 0.6rem;
    padding: 0.8rem 1.2rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.chat-input input {
    flex: 1;
    padding: 0.7rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

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

#send-btn {
    padding: 0.7rem 1.2rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#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) {
    .screen {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    .message {
        max-width: 90%;
    }
}
