* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    gap: 20px;
}

.branding {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 4px;
}
.branding-icon {
    font-size: 26px;
    color: #f5a623;
    filter: drop-shadow(0 0 4px rgba(245,166,35,0.4));
}
.branding-text {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 2px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #10a37f;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    font-size: 14px;
}
.new-chat-btn:hover { background: #0e8c6b; }

.sessions-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.session-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #2c2c2c;
    transition: 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-item.active {
    background: #e9ecef;
    font-weight: 500;
}
.session-item:hover:not(.active) {
    background: #f1f3f5;
}
.session-edit {
    float: right;
    color: #999;
    cursor: pointer;
    visibility: visible;
    margin-right: 4px;
}
.session-delete {
    float: right;
    color: #999;
    cursor: pointer;
    visibility: visible;
}
.session-item:hover .session-edit,
.session-item:hover .session-delete {
    visibility: visible;
}
.session-edit:hover { color: #10a37f; }
.session-delete:hover { color: #e74c3c; }

/* 主聊天区 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f9fafb;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid #e5e5e5;
}
.header-actions {
    display: flex;
    gap: 12px;
}
.greeting-btn, .settings-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}
.greeting-btn:hover, .settings-btn:hover {
    background: #f0f0f0;
}

/* 快捷工具栏 */
.toolbar {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 6px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.tb-btn {
    font-size: 13px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 12px;
    text-decoration: none;
    background: #f0f0f0;
    color: #555;
    transition: all .15s;
}
.tb-btn:hover { background: #e0e0e0; }
.tb-btn.tb-price { background: #e8f5e9; color: #2e7d32; }
.tb-btn.tb-price:hover { background: #c8e6c9; }
.tb-sep { color: #ddd; font-size: 12px; }
.tb-tz {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    cursor: help;
    padding: 2px 4px;
    border-radius: 4px;
    border-bottom: 1px dashed #ccc;
}
.tb-tz:hover { background: #f0f0f0; }

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    text-align: center;
    color: #6c757d;
    margin-top: 80px;
}

.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}
.message.user {
    align-self: flex-start;
}
.message.assistant {
    align-self: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.user .message-bubble {
    background: white;
    border: 1px solid #e5e5e5;
    color: #1f2a3a;
    border-bottom-left-radius: 4px;
}
.assistant .message-bubble {
    background: #10a37f;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-translation {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    margin-left: 12px;
    margin-right: 12px;
}
.user .message-translation {
    text-align: left;
}
.assistant .message-translation {
    text-align: right;
}

.copy-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 12px;
    margin-right: 12px;
    margin-top: 4px;
    text-align: right;
    display: inline-block;
}
.copy-btn:hover {
    color: #10a37f;
}

/* 输入区 */
.input-area {
    background: white;
    border-top: 1px solid #e5e5e5;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#messageInput {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}
.input-buttons {
    display: flex;
    justify-content: flex-end;
}
.send-btn {
    background: #10a37f;
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 30px;
    font-weight: 500;
    cursor: pointer;
}
.send-btn:hover {
    background: #0e8c6b;
}

/* 模态窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background: white;
    width: 700px;
    max-width: 90%;
    border-radius: 20px;
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e5e5;
}
.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.modal-body label {
    font-weight: 500;
    font-size: 14px;
}
.modal-body textarea {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 12px;
    padding: 12px;
    font-family: monospace;
    font-size: 13px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}
.save-btn {
    background: #10a37f;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
}
.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}
.upload-zone {
    border: 2px dashed #d0d5dd;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #fafbfc;
    margin: 8px 0 12px;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: #10a37f;
    background: #f0faf6;
}
.upload-zone .upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-zone p { margin: 4px 0; color: #666; font-size: 13px; }
.kb-files { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.kb-file-item {
    display: flex; align-items: center; gap: 6px;
    background: #f0faf6; border: 1px solid #b7e4d4;
    padding: 4px 10px; border-radius: 8px; font-size: 12px;
}
.kb-file-item .kb-del {
    cursor: pointer; color: #e74c3c; font-weight: bold; margin-left: 4px;
}
.kb-file-item .kb-del:hover { color: #c0392b; }
.session-item .title-text { flex: 1; cursor: pointer; }
.session-item .title-edit { display: none; flex: 1; }
.session-item.editing .title-text { display: none; }
.session-item.editing .title-edit { display: block; }
.session-item .title-edit input {
    width: 100%; border: 1px solid #10a37f; border-radius: 4px;
    padding: 2px 6px; font-size: 13px; outline: none;
}

/* 算力面板 */
.usage-panel {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    margin-top: 4px;
}
.usage-panel h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    color: #333;
}
.usage-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: #555;
}
.usage-stats .stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.usage-stats .stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}
.usage-stats .stat-label {
    font-size: 11px;
    color: #999;
}
.usage-bar-wrap {
    background: #e9ecef;
    border-radius: 10px;
    height: 10px;
    margin-top: 12px;
    overflow: hidden;
}
.usage-bar {
    height: 100%;
    background: linear-gradient(90deg, #10a37f, #f5a623);
    border-radius: 10px;
    transition: width 0.5s;
    width: 0%;
}

/* Message delete button */
.msg-delete-btn {
    position: absolute;
    top: 2px;
    right: 6px;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    z-index: 2;
}
.message:hover .msg-delete-btn {
    opacity: 1;
}
.msg-delete-btn:hover {
    color: #e53e3e;
    background: rgba(229,62,62,0.1);
}
.message { position: relative; }

/* 会话按钮始终可见 */
.session-item .session-edit,
.session-item .session-delete {
    visibility: visible !important;
    opacity: 1 !important;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    transition: background 0.15s;
}
.session-edit {
    color: #555 !important;
    background: #e8ecef;
}
.session-edit:hover {
    background: #10a37f !important;
    color: #fff !important;
}
.session-delete {
    color: #888 !important;
    background: #f0f0f0;
}
.session-delete:hover {
    background: #e74c3c !important;
    color: #fff !important;
}
/* Delete button - always visible at top-right of message */



/* Editable hint for AI messages */
.assistant .message-bubble[contenteditable="true"]:hover,
.assistant .message-translation[contenteditable="true"]:hover {
    box-shadow: inset 0 0 0 1px rgba(16,163,127,0.3);
}
.assistant .message-bubble:focus,
.assistant .message-translation:focus {
    outline: 2px solid #10a37f;
    outline-offset: -2px;
}

/* Subtle copy buttons */

.copy-en-btn:hover { color: #10a37f; }
.copy-zh-btn:hover { color: #f59e0b; }
.copy-zh-btn { margin-left: 2px; }
.assistant .copy-en-btn { text-align: right; }
.assistant .copy-zh-btn { text-align: right; }

/* Chinese bubble for AI - white/light style */
.assistant .message-translation {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #495057;
    margin-top: 6px;
    margin-left: 0;
    margin-right: 0;
    text-align: left;
    border-bottom-right-radius: 4px;
}
.user .message-translation {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    margin-left: 12px;
}
.assistant .message-translation[contenteditable=true]:hover {
    box-shadow: inset 0 0 0 1px rgba(16,163,127,0.2);
}
.assistant .message-translation:focus {
    outline: 2px solid #10a37f;
    outline-offset: -2px;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }

/* Delete button inside translation bubble */
.message-translation 
.message-translation 

/* 设置按钮 */
.settings-btn {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #888;
    border-top: 1px solid #eee;
    margin-top: auto;
}
.settings-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* 日志弹窗 */
.log-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.log-panel {
    background: #fff;
    border-radius: 12px;
    width: 680px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.log-header h3 { margin: 0; font-size: 16px; }
.log-close {
    font-size: 24px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}
.log-close:hover { color: #333; }
.log-body {
    padding: 12px 20px;
    overflow-y: auto;
    max-height: 60vh;
    font-size: 13px;
}
.log-item {
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.log-item:last-child { border: none; }
.log-item .action { color: #e53e3e; font-weight: 500; }
.log-item .detail { color: #555; flex: 1; margin: 0 12px; }
.log-item .time { color: #999; font-size: 12px; white-space: nowrap; }
.log-loading { text-align: center; padding: 30px; color: #999; }
.log-empty { text-align: center; padding: 30px; color: #999; }
/* 最终修复：文字完整显示，无截断 */
.sidebar { width: 320px !important; }
.sessions-list { display: block !important; flex: 1 !important; min-height: 0 !important; overflow-y: auto !important; overflow-x: hidden !important; }
.session-item { display: flex !important; align-items: center !important; padding: 5px 6px !important; min-height: 28px !important; flex-shrink: 0 !important; border-radius: 6px !important; overflow: visible !important; white-space: normal !important; text-overflow: clip !important; }
.session-item .title-text { flex: 1 !important; min-width: 0 !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; font-size: 13px !important; }
.session-item .session-edit { flex-shrink: 0 !important; margin-left: 4px !important; }
.session-item .session-delete { flex-shrink: 0 !important; margin-left: 2px !important; }

/* 备注按钮：绿色 */
.session-item .session-edit {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    cursor: pointer !important;
    border: 1px solid #a5d6a7 !important;
}
.session-item .session-edit:hover {
    background: #c8e6c9 !important;
}

/* 删除按钮：红色 */
.session-item .session-delete {
    background: #ffebee !important;
    color: #c62828 !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    cursor: pointer !important;
    border: 1px solid #ef9a9a !important;
}
.session-item .session-delete:hover {
    background: #ffcdd2 !important;
}

/* 聊天消息删除按钮新布局 */
.msg-del-en {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    cursor: pointer;
    z-index: 10;
}
.msg-del-en:hover {
    background: #ffcdd2;
}



.msg-del-zh {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
}
.msg-del-zh:hover {
    background: #ffcdd2;
}

.copy-zh-btn {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
}
.copy-zh-btn:hover {
    background: #c8e6c9;
}

/* 确保 message 容器有相对定位，让绝对定位的删按钮正确放置 */
.message {
    position: relative !important;
}

/* 复制按钮统一样式 */
.copy-en-btn,
.copy-zh-btn {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    border: 1px solid #a5d6a7 !important;
    border-radius: 4px !important;
    padding: 2px 8px !important;
    font-size: 11px !important;
    cursor: pointer !important;
}
.copy-en-btn:hover,
.copy-zh-btn:hover {
    background: #c8e6c9 !important;
}

/* 复制按钮定位在各自气泡右下角 */
.copy-en-btn,
.copy-zh-btn {
    display: inline-block;
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    border: 1px solid #a5d6a7 !important;
    border-radius: 4px !important;
    padding: 2px 8px !important;
    font-size: 11px !important;
    cursor: pointer !important;
    margin-top: 4px !important;
    margin-left: auto !important;
    float: right !important;
}
.copy-en-btn:hover,
.copy-zh-btn:hover {
    background: #c8e6c9 !important;
}

/* 空状态引导 */
.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}
.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}
.welcome-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}
.welcome-desc {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}
.welcome-hint {
    font-size: 12px;
    color: #10a37f;
    background: #e8f5e9;
    display: inline-block;
    padding: 6px 12px;
    border-radius: 16px;
}

/* 左侧选中态优化 */
.session-item.active {
    background: #e3f2fd !important;
    border-left: 4px solid #10a37f !important;
    box-shadow: 0 2px 8px rgba(16, 163, 127, 0.15) !important;
    font-weight: 600 !important;
    transform: translateX(2px) !important;
    transition: all 0.2s ease !important;
}
.session-item.active .title-text {
    color: #0d8a6a !important;
}
