:root {
    --bg-color: #FFFFFF; 
    --text-primary: #1A1A1A;
    --text-secondary: #8E8E93;
    --accent-color: #3B82F6; /* Blue for links/active */
    --user-bubble: #F2F3F5; 
    --ai-bubble: #FFFFFF;
    --header-bg: #FFFFFF;
    --border-color: #F0F0F0;
    
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #333; 
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text-primary);
}

#app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background-color: var(--bg-color);
    position: relative;
    display: flex;
    flex-direction: column;
}

@media (min-width: 481px) {
    #app-container {
        height: 90vh;
        border-radius: 16px;
        max-height: 850px;
        box-shadow: 0 20px 40px rgba(0,0,0,0.15);
        overflow: hidden;
    }
}

/* Utilities */
.icon-btn {
    background: none;
    border: none;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.icon-btn:active { background-color: rgba(0,0,0,0.05); }

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--header-bg);
    z-index: 10;
    height: 60px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-profile-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: #F0F4FF;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-text {
    display: flex;
    flex-direction: column;
}

.header-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.header-status {
    font-size: 11px;
    color: var(--accent-color);
    margin-top: 2px;
    display: flex;
    align-items: center;
}

/* Dropdown Menu */
.model-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 160px;
    padding: 6px;
    z-index: 100;
}
.dropdown-item {
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-primary);
}
.dropdown-item:hover { background-color: #F8F9FA; }
.dropdown-item.active {
    color: var(--accent-color);
    font-weight: 500;
    background-color: #F0F4FF;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Main Content Wrapper */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

/* Home View (Initial state) */
#home-view {
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

.main-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px 20px 20px;
}

.recommended-questions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0 24px;
    gap: 12px;
}

.rec-btn {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.rec-btn:active {
    background: #F7F7F7;
    transform: scale(0.98);
}

/* Chat View */
#chat-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Chat Messages */
.message-wrapper {
    display: flex;
    width: 100%;
}
.message-wrapper.user { justify-content: flex-end; }
.message-wrapper.ai { justify-content: flex-start; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px; 
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-ai {
    margin-right: 12px;
    background-color: #F0F4FF;
}

.avatar-user {
    background-color: #D3D3D3;
    margin-left: 12px;
    background-image: url('https://images.unsplash.com/photo-1544005313-94ddf0286df2?auto=format&fit=crop&q=80&w=80&h=80');
}

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

.bubble {
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.user .bubble {
    background-color: var(--user-bubble);
    color: var(--text-primary);
    border-radius: 16px 4px 16px 16px;
}

.ai .bubble {
    background-color: var(--ai-bubble);
    color: var(--text-primary);
    border-radius: 4px 16px 16px 16px;
}

/* Typing Effect */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 2px;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* Markdown parsing */
.bubble blockquote {
    border-left: 3px solid var(--border-color);
    color: var(--text-secondary);
    padding-left: 10px;
    margin: 8px 0;
    font-size: 14px;
}
.bubble code {
    background: rgba(0,0,0,0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}
.bubble pre {
    background: #F8F9FA;
    border: 1px solid #E9ECEF;
    color: #212529;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: monospace;
    font-size: 13px;
}
.bubble p { margin-bottom: 8px; }
.bubble p:last-child { margin-bottom: 0; }

/* Bottom Area (Quick Actions + Input) */
.bottom-area {
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
}

.quick-actions-scroll {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.quick-actions-scroll::-webkit-scrollbar { display: none; }

.action-btn {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.02);
}
.action-btn svg { stroke-width: 1.5; color: var(--accent-color); }
.action-btn.black-icon svg { color: var(--text-primary); }

.input-container {
    padding: 8px 16px 24px 16px; /* extra bottom for iOS */
}

.input-pill {
    background: #F4F5F7;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    min-height: 48px;
}

.input-icon {
    background: none;
    border: none;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1A1A1A;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 4px;
    font-size: 16px;
    outline: none;
    font-family: inherit;
    color: var(--text-primary);
}
.chat-input::placeholder { color: #A0A0A0; }

.send-btn-primary {
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0 16px;
    height: 36px;
    font-size: 14px;
    font-weight: 600;
    display: none; 
    margin-left: 4px;
}
