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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: #1a365d;
    color: #fff;
}

.header-icon {
    font-size: 28px;
}

.chat-header h1 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header .subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

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

.message {
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .message-content {
    background: #1a365d;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #f0f2f5;
    color: #1a202c;
    border-bottom-left-radius: 4px;
}

.message-sources {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.source-tag {
    font-size: 11px;
    padding: 2px 8px;
    background: #e2e8f0;
    color: #4a5568;
    border-radius: 12px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f0f2f5;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #a0aec0;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

#input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
}

#input:focus {
    border-color: #1a365d;
}

#send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #1a365d;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#send-btn:hover {
    background: #2a4a7f;
}

#send-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Markdown rendering inside messages */
.message-content h1, .message-content h2, .message-content h3 {
    margin: 8px 0 4px;
    font-size: 14px;
    font-weight: 600;
}

.message-content ul, .message-content ol {
    margin: 4px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 2px 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 13px;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 8px 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message-content th, .message-content td {
    border: 1px solid #d2d6dc;
    padding: 4px 8px;
    text-align: left;
}

.message-content th {
    background: #edf2f7;
    font-weight: 600;
}

.message-content strong {
    font-weight: 600;
}

.message-content p {
    margin: 4px 0;
}
