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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #091b29;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

/* Logo */
.logo-wrapper {
    text-align: center;
    padding: 24px 0 8px;
}

.logo {
    height: 100px;
    width: auto;
}

/* Main content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px;
    min-height: 0;
}

.title {
    font-size: 28px;
    font-weight: 600;
    text-align: center;
    padding: 24px 0 16px;
    flex-shrink: 0;
}

/* Chat container */
.chat-container {
    width: 100%;
    max-width: 560px;
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    min-height: 0;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 8px;
}

/* Message bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.2s ease-out;
}

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

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

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

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.assistant .message-bubble {
    background: #f3f4f6;
    color: #091b29;
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background: #4789f0;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Markdown content in assistant messages */
.message.assistant .message-bubble p {
    margin: 0;
}

.message.assistant .message-bubble p + p {
    margin-top: 8px;
}

.message.assistant .message-bubble strong {
    font-weight: 600;
}

.message.assistant .message-bubble code {
    background: #e5e7eb;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 13px;
}

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

.message.assistant .message-bubble a {
    color: #4789f0;
}

/* Status messages */
.status-message {
    align-self: flex-start;
    max-width: 85%;
    animation: fadeIn 0.2s ease-out;
}

.status-bubble {
    padding: 8px 14px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 13px;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #d1d5db;
    border-top-color: #6b7280;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Thinking dots */
.thinking {
    align-self: flex-start;
    max-width: 85%;
}

.thinking-bubble {
    padding: 12px 18px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    background: #f3f4f6;
    display: flex;
    gap: 4px;
    align-items: center;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: bounce 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Input area */
.input-area {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 16px 20px;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 6px 6px 6px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrapper:focus-within {
    border-color: #4789f0;
    box-shadow: 0 0 0 3px rgba(71, 137, 240, 0.15);
}

textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #091b29;
    padding: 6px 0;
    max-height: 120px;
    background: transparent;
}

textarea::placeholder {
    color: #9ca3af;
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #4789f0;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.send-btn:hover {
    background: #3a75d4;
}

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

/* Error banner */
.error-banner {
    width: 100%;
    max-width: 560px;
    margin: 8px auto;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 13px;
    text-align: center;
    animation: fadeIn 0.2s ease-out;
}

/* Footer */
.footer {
    padding: 16px;
    text-align: center;
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #6b7280;
}

.footer-links a {
    color: #6b7280;
    text-decoration: none;
}

.footer-links a:hover {
    color: #4789f0;
    text-decoration: underline;
}

.footer-links .divider {
    color: #d1d5db;
}

/* Responsive */
@media (max-width: 600px) {
    .title {
        font-size: 24px;
    }

    .message {
        max-width: 90%;
    }
}

/* Copy button for inline code */
.code-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f0f2f5;
    border-radius: 6px;
    padding: 2px 6px;
}

.code-copy code {
    background: none;
    padding: 0;
    font-size: 0.95em;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #5f6b7a;
    padding: 2px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.copy-btn:hover {
    color: #091b29;
    background: #dde1e7;
}
