:root {
    /* Clean Apple-style Minimalist Palette */
    --primary-color: #007AFF; /* iOS Blue */
    --primary-gradient: #007AFF;
    --primary-hover: #0056b3;
    
    --bg-color: #F5F5F7; /* Apple light gray background */
    --surface-color: rgba(255, 255, 255, 0.85);
    --surface-container-low: #F2F2F7;
    --surface-container-lowest: #FFFFFF;
    
    --text-main: #1D1D1F;
    --text-muted: #86868B;
    --outline-variant: #E5E5EA;
    
    --bubble-agent-bg: #E9E9EB;
    --bubble-agent-text: #1D1D1F;
    --bubble-user-bg: var(--primary-color);
    --bubble-user-text: #FFFFFF;
    --on-primary: #FFFFFF;
    
    /* Subtle Soft Shadow */
    --shadow-ambient: 0 10px 40px -10px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    /* Clean Border */
    --ghost-border: 1px solid rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    background: var(--bg-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    overflow: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.chat-container {
    width: 100%;
    max-width: 420px; 
    height: 85vh;
    max-height: 800px;
    background: var(--surface-color);
    border-radius: 32px;
    box-shadow: var(--shadow-ambient);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: var(--ghost-border);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    z-index: 10;
}

.chat-header {
    background: rgba(255, 255, 255, 0.6);
    padding: 24px 24px 16px;
    text-align: center;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: var(--ghost-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header-info h1 {
    font-size: 1.25rem; 
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header-info p {
    font-size: 0.8rem; 
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px; 
    background: transparent;
    
    scrollbar-width: none; /* Hide scrollbar for cleaner look */
}
.chat-messages::-webkit-scrollbar {
    display: none;
}

.message {
    display: flex;
    max-width: 80%;
    animation: messageSlideIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transform-origin: bottom center;
}

@keyframes messageSlideIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

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

.bubble {
    padding: 12px 16px;
    font-size: 0.9375rem; 
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

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

.message.agent .bubble {
    background: var(--bubble-agent-bg);
    color: var(--bubble-agent-text);
    border-radius: 20px 20px 20px 4px;
}

.bubble p {
    margin: 0 0 8px 0;
}
.bubble p:last-child {
    margin: 0;
}
.bubble a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
.bubble a:hover {
    text-decoration: underline;
}
.message.user .bubble a {
    color: #fff;
    text-decoration: underline;
}
.bubble pre {
    background: rgba(0,0,0,0.04);
    padding: 12px;
    border-radius: 12px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.85rem;
    margin: 8px 0;
    border: var(--ghost-border);
}
.bubble code {
    background: rgba(0,0,0,0.04);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85em;
}
.message.user .bubble pre, .message.user .bubble code {
    background: rgba(255,255,255,0.2);
    border: none;
}
.bubble ul, .bubble ol {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.message.error .bubble {
    background: #FFF0F0; 
    color: #FF3B30; 
    border: 1px solid rgba(255, 59, 48, 0.2);
    cursor: pointer;
    border-radius: 20px 20px 20px 4px;
}

.message.loading .bubble {
    background: var(--bubble-agent-bg);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

.chat-input-wrapper {
    padding: 12px 20px 20px;
    background: rgba(255,255,255,0.6);
    z-index: 10;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: var(--ghost-border);
}

.chat-form {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
    background: #FFFFFF;
    border: 1px solid var(--outline-variant);
    border-radius: 24px;
    padding: 4px 6px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.chat-form:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.chat-form input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: none;
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    background: transparent;
    color: var(--text-main);
}

.chat-form input[type="text"]::placeholder {
    color: var(--text-muted);
}

button {
    touch-action: manipulation;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

button#upload-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color 0.2s ease, background-color 0.2s ease;
}

button#upload-btn:hover {
    background: var(--surface-container-low);
    color: var(--text-main);
}

button#upload-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg-color), 0 0 0 4px var(--primary-color);
}

button#send-btn {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--primary-color);
    color: var(--on-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
    flex-shrink: 0;
}

button#send-btn:hover {
    transform: scale(1.05);
}

button#send-btn:active {
    transform: scale(0.95);
}

button#send-btn:disabled {
    background: var(--outline-variant);
    color: #A1A1A6;
    cursor: not-allowed;
    transform: none;
}

button#send-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg-color), 0 0 0 4px var(--primary-color);
}



@media (max-width: 480px) {
    .chat-container {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--surface-container-lowest);
    }
    body {
        background: var(--surface-container-lowest);
    }
}
