:root {
    --header-height: 56px;
    --input-area-height: 80px;
    --message-max-width: 88%;
    --primary-color: #1a73e8;
    --primary-light: #e8f0fe;
    --secondary-color: #f8f9fa;
    --text-color: #202124;
    --text-light: #5f6368;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --radius-sm: 12px;
    --radius-md: 14px;
    --radius-lg: 16px;
    --transition-normal: all 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--secondary-color);
    overflow: hidden;
    color: var(--text-color);
    line-height: 1.5;
    touch-action: manipulation;
}

.header {
    height: var(--header-height);
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0 16px;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    margin-top: var(--header-height);
    margin-bottom: var(--input-area-height);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    background-color: var(--secondary-color);
    overscroll-behavior: contain;
}

.message {
    max-width: var(--message-max-width);
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: bold;
}

.message-content {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
}

.ai-message .message-content {
    background-color: white;
    border-bottom-left-radius: var(--radius-sm);
    border-top-left-radius: var(--radius-sm);
}

.thinking-container {
    margin-bottom: 8px;
    border-bottom: none; /* 移除底部边框 */
    padding-bottom: 8px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.thinking-container.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    border-top: none;
}

.thinking-content {
    color: var(--text-light);
    font-size: 0.9em;
    padding: 8px 0;
}

.toggle-thinking {
    display: inline-block;
    margin-top: 6px;
    color: var(--primary-color);
    font-size: 0.8em;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    background: none;
    border: none;
    padding: 2px 4px;
    border-radius: 4px;
}

.toggle-thinking:hover {
    background-color: rgba(0,0,0,0.05);
}

.toggle-thinking:before {
    content: "▼";
    display: inline-block;
    margin-right: 4px;
    font-size: 0.8em;
    transition: transform 0.2s ease;
}

/* 使用类来控制图标方向 */
.toggle-thinking.collapsed:before {
    transform: rotate(-90deg);
}

.final-answer {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-weight: 500;
    margin-bottom: 8px; /* 添加底部间距 */
}

.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 14px;
    background-color: white;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    gap: 8px;
    height: var(--input-area-height);
    z-index: 100;
    box-shadow: var(--shadow-lg);
    align-items: center;
}

#user-input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-lg);
    outline: none;
    font-size: 15px;
    background: white;
    appearance: none;
    transition: var(--transition-normal);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    min-height: 48px;
    resize: none;
    max-height: 120px;
}

#user-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

#send-button, #reset-button {
    padding: 10px 14px;
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    white-space: nowrap;
    min-width: 60px;
    flex-shrink: 0;
    height: 48px;
    position: relative;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#reset-button {
    background: linear-gradient(135deg, #5f6368, #80868b);
    display: none;
}

.typing-indicator {
    padding: 10px 14px;
    background-color: white;
    border-radius: var(--radius-md);
    display: none;
    align-items: center;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
    margin-left: 46px;
}

.typing-indicator span {
    height: 7px;
    width: 7px;
    float: left;
    margin: 0 2px;
    background-color: #5f6368;
    display: block;
    border-radius: 50%;
    opacity: 0.4;
}

.typing-indicator span:nth-of-type(1) {
    animation: 1s blink infinite 0.3333s;
}

.typing-indicator span:nth-of-type(2) {
    animation: 1s blink infinite 0.6666s;
}

.typing-indicator span:nth-of-type(3) {
    animation: 1s blink infinite 0.9999s;
}

@keyframes blink {
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.ai-avatar {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.user-avatar {
    background-color: var(--primary-color);
    color: white;
}

.ai-message code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background-color: #f1f3f4;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.85em;
    color: #d32f2f;
    border: 1px solid #dadce0;
}

.ai-message pre {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    border: 1px solid #e0e0e0;
    font-size: 0.85em;
}

.ai-message .list-item {
    display: block;
    margin: 8px 0;
    position: relative;
    padding-left: 18px;
}

.message-timestamp {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
    text-align: right;
    opacity: 0.8;
}

.message-divider {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    margin: 12px 0;
    position: relative;
}

.message-divider:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1px solid rgba(0,0,0,0.1);
    z-index: -1;
}

.message-divider span {
    background-color: var(--secondary-color);
    padding: 0 10px;
}

@media (min-width: 768px) {
    #reset-button {
        display: inline-block;
    }
}

@media (max-width: 360px) {
    :root {
        --header-height: 50px;
        --input-area-height: 70px;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .message-content {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    #user-input {
        padding: 10px 12px;
        font-size: 14px;
        min-height: 44px;
    }

    #send-button, #reset-button {
        padding: 8px 12px;
        font-size: 0.9rem;
        height: 44px;
        min-width: 54px;
    }
}

/* 发送按钮加载动画样式 */
#send-button .button-text {
    transition: opacity 0.2s ease;
}

#send-button .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -9px;
    margin-left: -9px;
}

#send-button.loading .button-text {
    opacity: 0;
}

#send-button.loading .spinner {
    display: block;
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}