:root {
    --primary-color: #FF7900;
    --primary-hover: #F16E00;
    --primary-light: #FFEFE0;
    --text-main: #000000;
    --text-secondary: #555555;
    --text-muted: #888888;
    --bg-main: #F6F6F8;
    --bg-white: #FFFFFF;
    --border-color: #E2E2E2;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --chat-max-width: 800px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: var(--chat-max-width);
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-white);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

/* Header */
.app-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-white);
    z-index: 10;
}

.header-content {
    display: flex;
}

.logo {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
}

.mm-logo {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: block;
    margin-top: 2px;
}

.title-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.45;
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    background-color: var(--bg-white);
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 24px; /* Space for scroll */
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message-bubble {
    padding: 16px 20px;
    font-size: 0.95rem;
    word-break: break-word;
    border-radius: var(--radius-lg);
    line-height: 1.6;
}

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

.message.assistant .message-bubble {
    background-color: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* Formatting for Assistant Message */
.message.assistant .message-bubble p {
    margin-bottom: 12px;
}
.message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}
.message.assistant .message-bubble ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message-source {
    display: block;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(0,0,0,0.1);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.message-source ul {
    margin: 8px 0 0 18px;
}

.message-source li {
    margin-bottom: 6px;
}

.message-source a {
    color: var(--primary-hover);
    text-decoration: none;
    font-weight: 500;
}

.message-source a:hover {
    text-decoration: underline;
}

/* Error Message */
.error-message {
    align-self: center;
    background-color: #FEECEB;
    color: #E02020;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin: 8px 0;
    max-width: 90%;
    text-align: center;
}

/* Loading */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background-color: var(--bg-main);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dots {
    display: flex;
    gap: 4px;
}

.dots span {
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dots span:nth-child(1) { animation-delay: -0.32s; }
.dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-main);
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 2px;
}

.quick-action-btn {
    background-color: var(--primary-light);
    color: var(--primary-hover);
    border: 1px solid rgba(255, 121, 0, 0.2);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: normal;
    text-align: left;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 8px 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 121, 0, 0.1);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    padding: 8px 0;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.4;
    color: var(--text-main);
    max-height: 150px;
    overflow-y: auto;
    outline: none;
}

textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.send-btn:hover {
    background-color: var(--primary-hover);
}

.send-btn:disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 12px;
}

/* Responsiveness */
@media (max-width: 600px) {
    .app-header {
        padding: 16px;
    }
    .chat-container {
        padding: 16px;
    }
    .chat-input-area {
        padding: 16px;
    }
    .message {
        max-width: 95%;
    }

    .quick-actions {
        gap: 8px;
    }

    .quick-action-btn {
        width: 100%;
        justify-content: flex-start;
    }

    .logo {
        align-items: center;
    }

    .mm-logo {
        width: 42px;
        height: 42px;
        margin-top: 0;
    }

    .logo h1 {
        font-size: 1.1rem;
    }
}
