* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f0f2f5;
    --chat-bg: #ffffff;
    --bot-msg: #e9ecf1;
    --user-msg: #4a90d9;
    --user-text: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #65676b;
    --border: #dcdfe3;
    --accent: #4a90d9;
    --radius: 16px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: var(--chat-bg);
    box-shadow: 0 0 20px rgba(0,0,0,0.08);
}

/* Header */
.chat-header {
    padding: 14px 20px;
    background: var(--accent);
    color: white;
    flex-shrink: 0;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message a {
    color: inherit;
    text-decoration: underline;
}

.message.bot {
    align-self: flex-start;
    background: var(--bot-msg);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--user-msg);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
}

/* Buttons inside messages */
.msg-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.msg-buttons .btn-row {
    display: flex;
    gap: 6px;
}

.msg-buttons button,
.msg-buttons a.btn-link {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--accent);
    border-radius: 10px;
    background: white;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.msg-buttons button:hover,
.msg-buttons a.btn-link:hover {
    background: var(--accent);
    color: white;
}

/* File messages */
.file-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bot-msg);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 85%;
}

.file-msg .file-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.file-msg .file-info {
    display: flex;
    flex-direction: column;
}

.file-msg .file-name {
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
}

.file-msg .file-name:hover {
    text-decoration: underline;
}

.file-msg .file-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Typing indicator */
.typing-indicator {
    padding: 8px 20px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Input area */
.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--chat-bg);
    flex-shrink: 0;
}

.chat-input input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input input:focus {
    border-color: var(--accent);
}

.chat-input button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.chat-input button:hover {
    background: #3a7bc8;
}

/* Markdown-like formatting */
.message strong { font-weight: 600; }
.message em { font-style: italic; }

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #c4c4c4; border-radius: 3px; }

/* Mobile */
@media (max-width: 600px) {
    .chat-container {
        max-width: 100%;
    }
    .message {
        max-width: 90%;
    }
}
