* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px; /* 基础字体大小统一控制 */
}

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

/* 侧边栏样式 - 关键修改：增加z-index确保覆盖在最上层 */
.sidebar {
    width: 260px;
    height: 100vh;
    background-color: #f9f9f9;
    border-right: 1px solid #f0f0f0;
    padding: 12px 8px;
    display: none; /* 默认隐藏 */
    flex-direction: column;
    gap: 16px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1001; /* 提高层级，确保覆盖主内容 */
}

.sidebar.show {
    display: flex;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.sidebar-logo {
    width: 24px;
    height: 24px;
}

.close-sidebar-btn {
    background: none;
    border: none;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background-color: #e8e8e8;
    border: none;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background-color: #e0e0e0;
}

.sidebar-search {
    padding: 8px 12px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sidebar-menu-item:hover {
    background-color: #e8e8e8;
}

.sidebar-menu-item svg {
    width: 18px;
    height: 18px;
    stroke: #666;
}

.sidebar-menu-item span {
    font-size: 14px;
    color: #333;
}

.more-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-divider {
    height: 1px;
    background-color: #e0e0e0;
    margin: 8px 0;
}

.recent-title {
    padding: 0 12px;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.recent-chats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
}

.recent-chat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.recent-chat-item:hover {
    background-color: #e8e8e8;
}

.recent-chat-name {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-more-btn {
    background: none;
    border: none;
    width: 24px;
    height: 24px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.recent-chat-item:hover .chat-more-btn {
    opacity: 1;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-top: 1px solid #e0e0e0;
    margin-top: auto;
}

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

.avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #0084ff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.user-detail {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    color: #333;
}

.user-plan {
    font-size: 12px;
    color: #666;
}

.upgrade-btn {
    padding: 4px 12px;
    background-color: #e8e8e8;
    border: none;
    border-radius: 12px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
}

/* 遮罩层 - 关键修改：调整z-index为1000，在侧边栏下方 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 1000; /* 低于侧边栏，高于主内容 */
    display: none;
}

.overlay.show {
    display: block;
}

/* 主容器：键盘适配核心 */
.chat-root {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 主内容区域 - 关键修改：移除shift类和margin-left相关样式 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* 移除了margin-left和transition相关样式 */
}

/* 顶部导航栏 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 12px;
    background-color: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

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

/* 给需要固定的 div 添加这个样式 */
.fixed-top {
    /* 核心：固定定位 */
    position: fixed;
    /* 固定在顶部 */
    top: 0;
    /* 铺满宽度（可选，根据需求调整） */
    left: 0;
    right: 0;
    /* 提高层级，防止被其他元素遮挡 */
    z-index: 999;
    /* 自定义样式（背景、高度等，按需修改） */
    background: white;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.menu-btn {
    width: 18px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    background: none;
    border: none;
    cursor: pointer;
}

.menu-btn span {
    width: 100%;
    height: 1.5px;
    background-color: #333;
    border-radius: 1px;
}

.title {
    font-size: 18px;
    font-weight: 600;
    color: #111;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dropdown-arrow {
    width: 10px;
    height: 10px;
    border: solid #666;
    border-width: 0 1.5px 1.5px 0;
    display: inline-block;
    padding: 1.5px;
    transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
}

.plus-btn {
    background-color: #f0f0ff;
    color: #5b5bd6;
    border: none;
    padding: 6px 12px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
}

.plus-btn::before {
    content: "✦";
    font-size: 14px;
}

.theme-btn {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: #333;
}

/* 聊天消息区域 - 核心调整：功能选项靠底部（输入框上方） */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: flex-end; /* 核心：内容靠底部（输入框上方） */
}

.message {
    padding-left: 5%;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.ai-message {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.4;
}

.user-message .message-bubble {
    background-color: #f3f3f4;
    color: #111;
}

.ai-message .message-bubble {
    background-color: transparent;
    color: #111;
}

.message-actions {
    display: flex;
    gap: 16px;
    padding: 0 6px;
}

.action-icon {
    width: 18px;
    height: 18px;
    stroke: #666;
    stroke-width: 1.5;
    fill: none;
    cursor: pointer;
    transition: stroke 0.2s;
}

.action-icon:hover {
    stroke: #333;
}

/* 给复制图标添加专属类名，精准识别 */
.copy-icon {
    stroke: #666;
}

/* 功能选项 - 调整到输入框上方 */
.features {
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: auto 0 0 0; /* 关键：自动占满上方空间，只靠底部 */
    width: 100%;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    color: #111;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.feature-item:hover {
    color: #5b5bd6;
}

.feature-icon {
    width: 22px;
    height: 22px;
    stroke: #111;
    stroke-width: 2;
    fill: none;
    transition: stroke 0.2s;
}

.feature-item:hover .feature-icon {
    stroke: #5b5bd6;
}

/* 生成图片专属界面 */
.image-create-container {
    display: none; /* 默认隐藏 */
    flex: 1;
    padding: 20px 18px;
    flex-direction: column;
    justify-content: flex-end;
}

.image-create-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.image-create-title {
    font-size: 18px;
    font-weight: 500;
    color: #111;
}

.image-create-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.update-text {
    font-size: 14px;
    color: #666;
}

.close-btn {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn svg {
    width: 16px;
    height: 16px;
    stroke: #666;
}

/* 图片模板区域 */
/* 图片预览容器：一行5张，更小缩略图 */
.image-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    margin-bottom: 10px;
    overflow: hidden;
}
.image-templates .template-item {
    position: relative;
    width: calc(20% - 7px);
    aspect-ratio: 1/1;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}
.image-templates .template-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 更小的删除按钮 */
.image-templates .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

.image-templates > div {
    flex: 0 0 calc(20% - 10px); /* 关键：一行最多 5 个，自动计算宽度 */
    max-width: calc(20% - 10px);
    box-sizing: border-box;
}

.template-item {
    flex-shrink: 0;
    width: 120px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f9f9f9;
}

.upload-template {
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #666;
    font-size: 13px;
}

.upload-icon {
    width: 24px;
    height: 24px;
    stroke: #666;
}

.template-img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}

.template-name {
    padding: 8px;
    font-size: 13px;
    color: #333;
    text-align: center;
    width: 100%;
    background-color: #fff;
}

/* 图片生成输入框区域 */
.image-input-area {
    padding: 8px 0;
}

.image-input-container {
    background-color: #f0f0f0;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
}

.image-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #111;
    font-size: 16px;
    line-height: 1.4;
}

.image-chat-input::placeholder {
    color: #999;
    font-size: 16px;
}

.image-input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.image-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: #e0e0e0;
    border: none;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-action-btn.svg {
    width: 16px;
    height: 16px;
}

.auto-select {
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: #e0e0e0;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 14px;
    color: #333;
}

.voice-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: #000;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.voice-btn svg {
    width: 16px;
    height: 16px;
}

/* 底部输入框（默认聊天模式） */
.chat-input-area {
    padding: 0px 12px 30px;
    background-color: #ffffff;
    flex-shrink: 0;
}

.chat-input-container {
    background-color: #2f2f2f;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
}

.add-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: #444;
    border: none;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 16px;
    line-height: 1.4;
}

.chat-input::placeholder {
    color: #aaa;
    font-size: 16px;
}

.chat-input-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: #444;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

/* 复制成功提示 */
.copy-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 999;
}

.copy-toast.show {
    opacity: 1;
}

/* 加载中点点动画 */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}
.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
    animation: dot-flash 1s infinite alternate;
}
.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes dot-flash {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}
/* 错误提示样式 */
.ai-message.error .message-bubble {
    color: #dc3545;
}

/* 模型选择下拉菜单样式 */
.model-dropdown-container {
    position: relative;
    display: inline-block;
}

.model-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    min-width: 300px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 8px 0;
    z-index: 999;
    display: none;
}

.model-dropdown-menu.show {
    display: block;
}

.model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.model-option:hover {
    background-color: #f5f5f5;
}

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

.model-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-name {
    font-size: 14px;
    font-weight: 500;
    color: #111;
}

.model-desc {
    font-size: 12px;
    color: #666;
}

.model-upgrade-btn {
    padding: 4px 12px;
    background-color: #e8e8e8;
    border: none;
    border-radius: 12px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
}

.model-checkmark {
    color: #111;
    font-size: 16px;
}

/* 点击空白处关闭下拉菜单 */
body.click-catcher {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 998;
    display: none;
}

body.click-catcher.show {
    display: block;
}

/* 上传图片预览区（输入框左上角） */
.upload-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    max-width: 100%;
    max-height: 140px;
    overflow-y: auto;
    padding-bottom: 4px;
}
.upload-preview-container::-webkit-scrollbar {
    display: none;
}

/* 思考中状态气泡 */
.thinking-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
}

/* 保持和你原来的 loading 点样式一致 */
.loading-dots {
    display: flex;
    gap: 4px;
}
.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #666;
    animation: dotBounce 1.4s infinite ease-in-out both;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 上传预览项样式 */
.upload-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    max-width: 100%;
    max-height: 140px;
    overflow-y: auto;
    padding-bottom: 4px;
}
.upload-preview-container::-webkit-scrollbar {
    display: none;
}

.preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #f0f0f0;
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.delete-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* 输入框上方图片预览区 */
.upload-preview-container {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    max-height: 120px;
    overflow-y: auto;
    padding: 0 4px;
}
.upload-preview-container::-webkit-scrollbar {
    display: none;
}

/* 预览小图样式 */
.preview-item {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background: #f1f1f1;
}
.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 删除按钮 */
.delete-icon {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.upload-tip {
    color: #dc3545;
    font-size: 12px;
    margin: 4px 0;
    padding: 0 4px;
}

/* 图片预览区域样式：一行5张 + 更小缩略图 */
.image-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    overflow: hidden;
}
.image-templates .template-item {
    position: relative;
    width: calc(20% - 7px);
    aspect-ratio: 1/1;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}
.image-templates .template-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-templates .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

/* 初始隐藏图片生成界面 */
#imageCreateContainer {
    display: none;
}

.upload-tip {
    color: #f44336;
    font-size: 12px;
    margin: 4px 10px;
    display: none;
}