* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #ffffff;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 240px;
    background: #f7f7f7;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #e5e5e5;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    color: #333;
    transition: all 0.2s;
    text-align: left;
}

.new-chat-btn:hover {
    background: #f0f0f0;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 2px;
    font-size: 14px;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background 0.2s;
}

.chat-item:hover {
    background: #eee;
}

.chat-item.active {
    background: #e8f4fd;
    color: #333;
}

.chat-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-actions {
    display: none;
    gap: 4px;
    flex-shrink: 0;
}

.chat-item:hover .chat-actions {
    display: flex;
}

.chat-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0.6;
    transition: all 0.2s;
}

.chat-action-btn:hover {
    background: #ddd;
    opacity: 1;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #e5e5e5;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: #666;
}

.setting-value {
    font-size: 12px;
    color: #999;
}

.setting-slider {
    width: 100%;
    cursor: pointer;
}

.setting-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.setting-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    color: #333;
    box-sizing: border-box;
}

.setting-input:focus {
    outline: none;
    border-color: #4a90e2;
}

/* 开关按钮 */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4a90e2;
}

input:checked + .slider:before {
    transform: translateX(16px);
}

/* 主区域 */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* 顶部栏 */
.header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
    gap: 12px;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    color: #666;
}

.menu-btn:hover {
    background: #f5f5f5;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.header-right {
    flex-shrink: 0;
}

.model-tabs {
    display: flex;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 3px;
}

.model-tab {
    padding: 6px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.model-tab:hover {
    color: #333;
}

.model-tab.active {
    background: #fff;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 500;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-title {
    font-size: 24px;
    color: #999;
    font-weight: 400;
}

/* 消息 */
.message {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: #f5f5f5;
}

.message.user .message-avatar {
    background: #e8f4fd;
}

.message-content {
    max-width: 75%;
}

.message.user .message-content {
    text-align: right;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: #e8f4fd;
    color: #333;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: #f7f7f7;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* 思考过程 */
.reasoning-box {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #888;
    text-align: left;
}

.reasoning-title {
    font-weight: 500;
    margin-bottom: 8px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.reasoning-content {
    white-space: pre-wrap;
    line-height: 1.5;
}

.reasoning-box.collapsed .reasoning-content {
    display: none;
}

/* Markdown 样式 */
.message-bubble p {
    margin-bottom: 10px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble pre {
    background: #f5f5f5;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 10px 0;
    text-align: left;
}

.message-bubble code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

/* 复制按钮 */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    background: #e0e0e0;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
    z-index: 10;
}

.copy-btn:hover {
    background: #d0d0d0;
    color: #333;
}

.message-bubble ul,
.message-bubble ol {
    margin: 10px 0;
    padding-left: 24px;
    text-align: left;
}

.message-bubble li {
    margin-bottom: 4px;
}

/* 打字光标 */
.typing-cursor {
    display: inline-block;
    width: 6px;
    height: 16px;
    background: #999;
    animation: blink 1s infinite;
    vertical-align: middle;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 思考中动画 */
.thinking {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: thinking 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes thinking {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 输入区域 */
.input-area {
    padding: 16px 24px 24px;
    flex-shrink: 0;
    border-top: 1px solid #e5e5e5;
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #f7f7f7;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 12px 16px;
}

.input-wrapper:focus-within {
    border-color: #ccc;
    background: #fff;
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    color: #333;
}

.message-input::placeholder {
    color: #bbb;
}

.send-btn {
    padding: 8px 20px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: #555;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* 移动端遮罩 */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
}

.sidebar-overlay.show {
    display: block;
}

/* ========== 手机端适配 ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .menu-btn {
        display: block;
    }
    
    .header {
        padding: 8px 10px;
        gap: 6px;
        min-height: 44px;
    }
    
    .menu-btn {
        font-size: 18px;
        padding: 4px 6px;
        flex-shrink: 0;
    }
    
    .header-title {
        font-size: 14px;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: 500;
        display: none; /* 手机端隐藏标题，给按钮腾空间 */
    }
    
    .header-right {
        flex-shrink: 0;
    }
    
    .header-right {
        display: none; /* 手机端顶部模型按钮隐藏，都放侧边栏 */
    }
    
    .model-tabs-sidebar {
        width: 100%;
    }
    
    .model-tabs-sidebar .model-tab {
        flex: 1;
        text-align: center;
    }
    
    .chat-area {
        padding: 12px;
    }
    
    .input-area {
        padding: 10px 10px 14px;
    }
    
    .message {
        gap: 10px;
        margin-bottom: 16px;
    }
    
    .message-content {
        max-width: 82%;
    }
    
    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }
    
    .message-bubble {
        padding: 9px 12px;
        font-size: 14px;
        border-radius: 10px;
    }
    
    .empty-title {
        font-size: 18px;
    }
    
    .input-wrapper {
        padding: 10px 12px;
        border-radius: 10px;
        gap: 8px;
    }
    
    .message-input {
        font-size: 15px;
    }
    
    .send-btn {
        padding: 7px 14px;
        font-size: 13px;
    }
    
    .reasoning-box {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    /* 手机端对话列表按钮一直显示 */
    .chat-actions {
        display: flex;
    }
}

/* 悬浮菜单按钮 - 手机端用 */
.fab-menu {
    display: none;
    position: fixed;
    left: 16px;
    top: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #333;
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .fab-menu {
        display: flex;
    }
    
    .menu-btn {
        display: none !important;
    }
    
    .header {
        padding: 16px !important;
        justify-content: center !important;
    }
    
    .header-title {
        display: block !important;
        text-align: center;
        font-size: 16px !important;
    }
}
