* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root {
    /* Light Mode Colors (Default) */
    --bg-main: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #8e8e93;
    --ai-bubble-bg: #f0f0f0;
    --ai-bubble-text: #1a1a1a;
    --user-bubble-bg: #6210CC; /* Purple from the image */
    --user-bubble-text: #ffffff;
    --border-color: #e5e5e5;
    --input-bg: #f9f9f9;
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-main: #121212;
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a5;
    --ai-bubble-bg: #2c2c2e;
    --ai-bubble-text: #f5f5f5;
    --user-bubble-bg: #7a28e5;
    --user-bubble-text: #ffffff;
    --border-color: #333333;
    --input-bg: #1c1c1e;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    transition: background-color 0.3s, color 0.3s;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 800px; /* Constrains width on large screens */
    position: relative;
}

/* Header & Divider */
.chat-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.date-divider {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

#theme-toggle {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
}

/* Chat Layout */
.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 16px 140px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.sender-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    margin-left: 4px;
}

.bubble-and-time {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.timestamp {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-bottom: 2px;
}

.bubble {
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
}

/* AI Message Styling */
.ai-message-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.ai-bubble {
    background-color: var(--ai-bubble-bg);
    color: var(--ai-bubble-text);
    border-bottom-left-radius: 4px;
}

.ai-avatar {
    width: 28px;
    height: 28px;
    color: var(--user-bubble-bg);
    margin-top: 20px;
    flex-shrink: 0;
}

/* User Message Styling */
.user-message-row {
    display: flex;
    justify-content: flex-end;
}

.user-message-row .bubble-and-time {
    flex-direction: row-reverse;
}

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

/* Typing Indicator (3 Dots) */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 6px 4px;
    align-items: center;
    height: 24px;
}

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

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

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

/* Footer & Input Area */
.footer-branding {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 0;
    position: fixed;
    bottom: 80px;
    width: 100%;
    max-width: 800px;
    background: transparent;
}

.input-container {
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: 800px;
    background-color: var(--bg-main);
    padding: 12px 16px 24px 16px;
    border-top: 1px solid var(--border-color);
}

.input-box {
    display: flex;
    align-items: center;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 4px 8px;
}

textarea {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 15px;
    resize: none;
    outline: none;
    max-height: 100px;
}

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

#send-btn {
    background: var(--user-bubble-bg);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

#send-btn:hover {
    opacity: 0.9;
}

#send-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

#send-btn svg {
    width: 18px;
    height: 18px;
    margin-left: 2px; /* Centers the paper airplane visually */
}