:root {
    /* 莫兰迪色系 */
    --m-blue: #708BB3;
    --m-blue-dim: #5A7091;
    --m-pink: #D4A8A4;
    --m-green: #9FB3A2;
    --m-gray: #8E8E93;
    
    /* 材质与颜色 */
    --bg-base: #F2F2F7;
    --text-primary: #1D1D1F;
    --text-secondary: #6e6e73;
    --accent: #007AFF;
    
    /* Glass Materials */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    --glass-blur: blur(20px) saturate(180%);
    
    /* Chat Bubbles */
    --bubble-user: #007AFF;
    --text-user: #FFFFFF;
    --bubble-ai: rgba(255, 255, 255, 0.6);
    
    /* Blobs */
    --blob-1: #D4E3FC;
    --blob-2: #E8D6D5;
    --blob-3: #D8E6DA;

    --radius: 18px;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="dark"] {
    --bg-base: #000000;
    --text-primary: #F5F5F7;
    --text-secondary: #98989D;
    --accent: #0A84FF;
    
    --glass-bg: rgba(30, 30, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    
    --bubble-user: #0A84FF;
    --bubble-ai: rgba(44, 44, 46, 0.7);
    
    --blob-1: #1C2533;
    --blob-2: #332222;
    --blob-3: #1A2620;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-base: #000000;
        --text-primary: #F5F5F7;
        --text-secondary: #98989D;
        --accent: #0A84FF;
        --glass-bg: rgba(30, 30, 30, 0.65);
        --glass-border: rgba(255, 255, 255, 0.12);
        --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
        --bubble-user: #0A84FF;
        --bubble-ai: rgba(44, 44, 46, 0.7);
        --blob-1: #1C2533;
        --blob-2: #332222;
        --blob-3: #1A2620;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    height: 100vh;
    height: 100svh;
    overflow: hidden; 
    transition: color var(--transition), background-color var(--transition);
}

.ambient-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.8; animation: float 20s infinite alternate; }
.blob-1 { top: -10%; left: -10%; width: 60vw; height: 60vw; background: var(--blob-1); }
.blob-2 { bottom: -10%; right: -10%; width: 70vw; height: 70vw; background: var(--blob-2); animation-delay: -5s; }
.blob-3 { top: 40%; left: 40%; width: 50vw; height: 50vw; background: var(--blob-3); animation-delay: -10s; opacity: 0.5; }
@keyframes float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(30px, 50px) scale(1.1); } }

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

/* Header */
.app-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px 16px;
    margin: 16px;
    border-radius: 99px;
    z-index: 10;
}
.header-left, .header-right { display: flex; gap: 8px; align-items: center; }
.header-right { justify-content: flex-end; }
.header-center h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }

.current-model-badge {
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(120, 120, 128, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
}
.current-model-badge.visible { display: block; }

/* Icon Buttons */
.icon-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: rgba(120, 120, 128, 0.1); color: var(--text-primary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition);
}
.icon-btn:hover { background: rgba(120, 120, 128, 0.2); transform: scale(1.05); }
.icon-btn svg { width: 20px; height: 20px; stroke-width: 2px; }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small svg { width: 16px; height: 16px; }

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; opacity: 0.8; }
.welcome-card { padding: 32px; text-align: center; border-radius: 24px; }
.welcome-card h2 { margin-bottom: 8px; font-size: 20px; }
.welcome-card p { color: var(--text-secondary); font-size: 14px; }

/* Messages */
.message { display: flex; gap: 12px; max-width: 100%; animation: fadeUp 0.3s ease; }
.message.user { justify-content: flex-end; }
.message.ai { justify-content: flex-start; }

.message-bubble {
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.6;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.message.user .message-bubble {
    background: var(--bubble-user);
    color: var(--text-user);
    border-bottom-right-radius: 4px;
}
.message.ai .message-bubble {
    background: var(--bubble-ai);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

/* Markdown */
.message-bubble p { margin-bottom: 10px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: rgba(0,0,0,0.1); padding: 2px 4px; border-radius: 4px; }
.message.user .message-bubble code { background: rgba(255,255,255,0.2); }
.message-bubble pre { margin: 10px 0; border-radius: 8px; overflow: hidden; background: #1e1e1e !important; }
.message-bubble pre code { display: block; padding: 12px; background: transparent; overflow-x: auto; color: #e6edf3; border-radius: 0; }

/* Input Area */
.input-area { padding: 16px; margin: 0 16px 16px; border-radius: 24px; z-index: 20; }
.input-wrapper { display: flex; align-items: flex-end; gap: 10px; }
.glass-input {
    flex: 1; background: transparent; border: none; padding: 12px 0;
    font-size: 16px; color: var(--text-primary); outline: none; resize: none; max-height: 120px; font-family: inherit;
}
.glass-input::placeholder { color: var(--text-secondary); opacity: 0.6; }
.send-btn {
    width: 36px; height: 36px; padding: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-bottom: 4px; opacity: 1; transition: all 0.2s;
}
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; background: var(--text-secondary); }

.glass-btn { border: none; font-weight: 600; cursor: pointer; transition: var(--transition); }
.glass-btn.primary { background: var(--text-primary); color: var(--bg-base); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.glass-btn.secondary { background: rgba(120, 120, 128, 0.1); color: var(--text-primary); padding: 10px 20px; border-radius: 12px; }

/* Modal & Settings */
.modal {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0,0,0,0.2); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center;
    opacity: 1; visibility: visible; transition: all 0.3s;
}
.modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.modal-content {
    width: 90%; max-width: 500px; padding: 24px; border-radius: 24px;
    max-height: 85vh; overflow-y: auto;
    transform: scale(1); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal.hidden .modal-content { transform: scale(0.95); }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 20px; margin: 0; }

.settings-tabs { display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 4px; }
.tab-btn {
    background: transparent; border: none; padding: 8px 12px; border-radius: 8px;
    color: var(--text-secondary); font-size: 14px; font-weight: 600;
    cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.tab-btn.active { background: rgba(120, 120, 128, 0.1); color: var(--text-primary); }

.tab-content { display: none; animation: fadeIn 0.3s; }
.tab-content.active { display: block; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-hint { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 4px; opacity: 0.8; }

/* Input Row (For inline button) */
.input-row { display: flex; gap: 8px; }
.input-row .glass-input { flex: 1; }
.input-row .icon-btn { border-radius: 12px; width: 44px; height: 44px; }

.form-group .glass-input { 
    background: rgba(120, 120, 128, 0.05); border: 1px solid rgba(120, 120, 128, 0.1); 
    border-radius: 12px; padding: 12px; width: 100%;
}
.form-group .glass-input:focus { border-color: var(--accent); background: rgba(120, 120, 128, 0.08); }

.settings-divider { height: 1px; background: rgba(120, 120, 128, 0.1); margin: 24px 0; }
.form-row { display: flex; gap: 16px; }
.form-group.half { flex: 1; }

.btn-save { width: 100%; margin-top: 8px; }

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

/* Adding specific styles for Reasoning Block */

.reasoning-details {
    background: rgba(120, 120, 128, 0.05);
    border: 1px solid rgba(120, 120, 128, 0.1);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.reasoning-details summary {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reasoning-details summary:hover {
    background: rgba(120, 120, 128, 0.05);
}

.reasoning-content {
    padding: 12px;
    padding-top: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    border-top: 1px solid rgba(120, 120, 128, 0.05);
    white-space: pre-wrap;
}

/* ... Keep existing styles ... */
/* Ensure .settings-tabs overflow works well */
.settings-tabs {
    display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 4px;
    scrollbar-width: none; /* Firefox */
}
.settings-tabs::-webkit-scrollbar { display: none; } /* Chrome */