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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

header {
    padding: 16px 24px;
    background: #1a73e8;
    color: white;
    display: flex;
    align-items: center;
    gap: 16px;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

header .subtitle {
    opacity: 0.9;
    font-size: 14px;
}

#user-info {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-email {
    font-size: 14px;
    opacity: 0.9;
}

#sign-out-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#sign-out-btn:hover {
    background: rgba(255,255,255,0.3);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Login Screen */
#login-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    text-align: center;
}

.login-box h2 {
    margin-bottom: 8px;
    color: #333;
}

.login-box p {
    color: #666;
    margin-bottom: 24px;
}

/* Chat Screen */
#chat-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

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

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

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
}

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

.message.assistant .message-content {
    background: #f1f3f4;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content pre {
    background: #282c34;
    color: #abb2bf;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
}

.message-content code {
    background: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.message.assistant .message-content code {
    background: rgba(0,0,0,0.08);
}

.message.user .message-content code {
    background: rgba(255,255,255,0.2);
}

/* Tool use indicator */
.tool-use {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 13px;
    color: #856404;
}

.tool-use .tool-name {
    font-weight: 600;
}

/* Chat Input */
#chat-input-container {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    background: white;
}

#chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 15px;
    resize: none;
    max-height: 150px;
    font-family: inherit;
}

#chat-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

#send-btn {
    background: #1a73e8;
    border: none;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

#send-btn:hover {
    background: #1557b0;
}

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

#send-btn svg {
    width: 24px;
    height: 24px;
}

/* Loading indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

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

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

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

/* Error message */
.error-message {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 8px 0;
}

/* Sample questions */
.sample-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.sample-question {
    background: #e8f0fe;
    border: 1px solid #1a73e8;
    color: #1a73e8;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.sample-question:hover {
    background: #1a73e8;
    color: white;
}

/* Better markdown styling */
.message-content h2 {
    font-size: 18px;
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.message-content h3 {
    font-size: 16px;
    margin: 12px 0 6px 0;
    font-weight: 600;
}

.message-content h4 {
    font-size: 14px;
    margin: 10px 0 4px 0;
    font-weight: 600;
}

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

.message-content li {
    margin-bottom: 4px;
    line-height: 1.5;
}

.message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.4;
}

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

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

    header {
        padding: 12px 16px;
    }

    header h1 {
        font-size: 20px;
    }

    #chat-messages {
        padding: 16px;
    }

    .message {
        max-width: 95%;
    }

    #chat-input-container {
        padding: 12px 16px;
    }
}
