:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --chat-bg: #ffffff;
    --user-bubble: #2563eb;
    --user-text: #ffffff;
    --bot-bubble: #f1f5f9;
    --bot-text: #1e293b;
    --border-color: #e2e8f0;
    --text-muted: #64748b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: #0f172a;
    height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    background-color: var(--chat-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    position: relative;
}

/* Header */
header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    z-index: 10;
}

.header-content h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.attribution {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    margin-top: 0.2rem;
    display: block;
}

.attribution:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.select-wrapper {
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
}

.select-wrapper label {
    color: var(--text-muted);
    margin-bottom: 2px;
}

select {
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    background: #fff;
}

#reset-btn {
    background: none;
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    color: var(--text-muted);
    transition: all 0.2s;
}

#reset-btn:hover {
    background: #f1f5f9;
    color: #ef4444;
}

/* Chat Area */
main {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-muted);
}

.welcome-message h2 {
    color: #334155;
    margin-bottom: 0.5rem;
}

.note {
    font-size: 0.85rem;
    background: #fff7ed;
    color: #c2410c;
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

/* Messages */
.message {
    display: flex;
    width: 100%;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
}

.message.user .bubble {
    background-color: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .bubble {
    background-color: var(--bot-bubble);
    color: var(--bot-text);
    border-bottom-left-radius: 0.25rem;
}

.bubble.streaming::after {
    content: '▋';
    display: inline-block;
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Status Bar */
#status-bar {
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.hidden {
    display: none;
}

.status-text {
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.progress-container {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.2s ease;
}

/* Footer / Input */
footer {
    padding: 1rem;
    background: #fff;
    border-top: 1px solid var(--border-color);
}

#chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: #f8fafc;
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    max-height: 150px;
    color: #334155;
}

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

button#send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

button#send-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        height: 100%;
        max-width: 100%;
    }
    
    .bubble {
        max-width: 90%;
    }

    .controls span {
        display: none;
    }
}