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

:root {
    /* Claude-inspired cream/paper palette */
    --bg-primary: #FAF9F6;
    --bg-secondary: #F5F4F0;
    --bg-tertiary: #EEEEE8;
    --bg-input: #FFFFFF;
    --text-primary: #1D1D1B;
    --text-secondary: #666660;
    --text-muted: #9C9C94;
    --accent: #0D9488;
    --accent-hover: #0B7C72;
    --border: #E5E5DF;
    --user-bubble: #EEEEE8;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 980px;
    margin: 0 auto;
    background: var(--bg-primary);
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-primary);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 17px;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.logo svg {
    color: var(--accent);
}

.clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.clear-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
    background: transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-icon {
    margin-bottom: 24px;
    color: var(--accent);
}

.welcome-screen h1 {
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-screen p {
    font-size: 15px;
    color: var(--text-muted);
}

/* Message Bubbles */
.message {
    margin-bottom: 32px;
    animation: fadeIn 0.2s ease;
}

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

.message-role {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.message.user .message-role {
    color: var(--text-secondary);
}

.message.assistant .message-role {
    color: var(--accent);
}

.message-text {
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-text {
    background: var(--user-bubble);
    padding: 14px 18px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    display: inline-block;
    max-width: 85%;
}

.message.assistant .message-text {
    padding: 0;
}

.message-text code {
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.message-text pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
}

.message-text pre code {
    background: transparent;
    padding: 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.9);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Streaming Cursor */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 18px;
    background: var(--accent);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

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

/* Input Area */
.chat-input-area {
    padding: 16px 24px 24px;
    background: var(--bg-primary);
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.input-form {
    max-width: 720px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    padding: 0;
    resize: none;
    outline: none;
    max-height: 200px;
    min-height: 24px;
}

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

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.send-btn:not(:disabled) {
    background: var(--accent);
    color: white;
    cursor: pointer;
}

.send-btn:not(:disabled):hover {
    background: var(--accent-hover);
}

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

.made-by {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    letter-spacing: 0.02em;
}

.made-by a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s ease;
}

.made-by a:hover {
    color: var(--text-secondary);
}

/* Error Message */
.error-message {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #DC2626;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 24px;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .chat-header {
        padding: 12px 16px;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-area {
        padding: 12px 16px 20px;
    }

    .message {
        margin-bottom: 24px;
    }

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

    .welcome-screen h1 {
        font-size: 20px;
    }

    .input-wrapper {
        padding: 10px 14px;
        border-radius: 16px;
    }

    .input-wrapper textarea {
        font-size: 16px;
    }
}


/* Touch-friendly tap targets */
@media (pointer: coarse) {
    .clear-btn,
    .send-btn {
        min-width: 44px;
        min-height: 44px;
    }
}
