:root { 
    --bg-color: #1e1e1e; 
    --sidebar-bg: #141414; 
    --text-color: #f5f5f7; 
    --user-msg-bg: #2c2c2e; 
    --accent-color: #0A84FF;
    --border-color: rgba(255, 255, 255, 0.08); 
}
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif; background-color: var(--bg-color); color: var(--text-color); display: flex; height: 100vh; overflow: hidden; }

/* 弹窗基础 */
.auth-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.auth-content { background: rgba(30, 30, 30, 0.9); border: 1px solid rgba(255,255,255,0.1); padding: 40px; border-radius: 24px; text-align: center; width: 320px; box-shadow: 0 30px 60px rgba(0,0,0,0.5); }
.auth-input { width: 100%; box-sizing: border-box; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.2); color: white; padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-size: 16px; outline: none; text-align: center; }
.auth-input:focus { border-color: var(--accent-color); }
.auth-btn { width: 100%; background: var(--accent-color); color: white; border: none; padding: 12px; border-radius: 12px; font-size: 16px; font-weight: bold; cursor: pointer; transition: 0.2s; }
.auth-btn:hover { transform: scale(1.02); }

/* 侧边栏与头部 Logo */
.sidebar { display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding-bottom: 20px; width: 260px; background-color: var(--sidebar-bg); padding: 20px; border-right: 1px solid var(--border-color); z-index: 10; box-sizing: border-box;}
.sidebar-top { display: flex; flex-direction: column; gap: 10px; flex: 1; overflow: hidden; }
.sidebar-bottom { padding-top: 15px; border-top: 1px solid var(--border-color); flex-shrink: 0; }

.app-header { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; padding-left: 5px; }
.app-logo-container { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.app-logo-container lottie-player { width: 100%; height: 100%; transform: scale(1.3); }
.app-title { font-family: 'Outfit', sans-serif; font-size: 22px; font-weight: 800; letter-spacing: 0.5px; background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 40%, #8e8e93 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0px 2px 8px rgba(255, 255, 255, 0.15)); }

.new-chat-btn { padding: 12px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: white; cursor: pointer; text-align: left; font-size: 15px; transition: 0.3s; }
.new-chat-btn:hover { background: rgba(255,255,255,0.1); }

/* 历史记录区 */
.history-section { display: flex; flex-direction: column; flex: 1; overflow: hidden; margin-top: 10px; }
.history-title { font-size: 13px; font-weight: 600; color: #8e8e93; padding: 0 5px; margin-bottom: 8px; }
.history-list { flex: 1; overflow-y: auto; padding-right: 4px; }
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.history-item { position: relative; padding: 10px 12px; border-radius: 10px; color: #d1d1d6; font-size: 14px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.history-item:hover { background: rgba(255,255,255,0.05); }
.history-item.active { background: rgba(255,255,255,0.1); color: white; font-weight: 500; }
.history-title-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.history-del-btn { opacity: 0; background: transparent; border: none; color: #8e8e93; cursor: pointer; transition: 0.2s; font-size: 16px; padding: 0 4px; }
.history-item:hover .history-del-btn { opacity: 1; }
.history-del-btn:hover { color: #ff453a; }

/* 仪表盘 */
.cdkey-info { display: flex; flex-direction: column; gap: 6px; }
.cdkey-title { font-size: 12px; color: #8e8e93; }
.cdkey-val { font-size: 14px; color: white; font-family: monospace; background: rgba(255,255,255,0.05); padding: 6px 8px; border-radius: 6px; word-break: break-all; }
.cdkey-exp { font-size: 12px; color: #34c759; }
.logout-btn { background: transparent; border: 1px solid rgba(255,69,58,0.5); color: #ff453a; padding: 8px; border-radius: 6px; cursor: pointer; font-size: 12px; margin-top: 4px; transition: 0.2s; }
.logout-btn:hover { background: #ff453a; color: white; }

/* 聊天区 */
.main { flex: 1; display: flex; flex-direction: column; position: relative; background: radial-gradient(circle at 50% 0%, #2a2a2a 0%, #1e1e1e 100%); }
.chat-container { flex: 1; overflow-y: auto; padding: 40px 0 180px 0; display: flex; flex-direction: column; align-items: center; scroll-behavior: smooth; }
.message { width: 100%; max-width: 800px; padding: 12px 24px; box-sizing: border-box; display: flex; flex-direction: column; animation: fadeIn 0.4s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.msg-user { align-items: flex-end; }
.msg-user .bubble { background-color: var(--user-msg-bg); padding: 14px 20px; border-radius: 24px; border-bottom-right-radius: 8px; max-width: 80%; line-height: 1.6; font-size: 15px; }
.msg-ai { align-items: flex-start; }
.msg-ai .bubble { max-width: 100%; line-height: 1.7; font-size: 15px; color: #d1d1d6; }

/* 悬浮图片组件 */
.image-wrapper { position: relative; display: inline-block; margin-top: 12px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border-color); }
.image-wrapper img { display: block; max-width: 450px; width: 100%; transition: transform 0.4s ease; }
.image-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s ease; }
.image-wrapper:hover .image-overlay { opacity: 1; }
.btn-edit-overlay { color: white; padding: 10px 20px; border-radius: 20px; font-size: 14px; backdrop-filter: blur(10px); display: flex; align-items: center; transition: 0.2s; background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); }
.btn-edit-overlay:hover { background: rgba(255,255,255,0.3); transform: scale(1.05); }

/* 输入区核心控制 (提升层级防止丢失) */
.input-area { position: fixed; bottom: 0; width: 100%; display: flex; flex-direction: column; align-items: center; background: linear-gradient(180deg, rgba(30,30,30,0) 0%, rgba(30,30,30,0.9) 30%, rgba(30,30,30,1) 100%); padding: 0 24px 24px 24px; box-sizing: border-box; pointer-events: none; z-index: 50; }
.mode-switcher { background: rgba(44, 44, 46, 0.8); backdrop-filter: blur(20px); border-radius: 20px; padding: 4px; display: flex; gap: 4px; margin-bottom: 12px; pointer-events: auto; border: 1px solid rgba(255,255,255,0.05); }
.mode-btn { padding: 6px 16px; border-radius: 16px; font-size: 13px; color: #8e8e93; cursor: pointer; transition: 0.3s; }
.mode-btn.active { background: #4a4a4c; color: white; }
.input-box { width: 100%; max-width: 768px; background: rgba(44, 44, 46, 0.7); backdrop-filter: blur(20px); border-radius: 28px; pointer-events: auto; display: flex; flex-direction: column; padding: 10px 16px; border: 1px solid rgba(255,255,255,0.1); }
.input-actions { display: flex; align-items: center; min-height: 44px; }
.input-box textarea { flex: 1; background: transparent; border: none; color: white; outline: none; font-size: 16px; padding: 12px; font-family: inherit; resize: none; max-height: 150px; overflow-y: auto; line-height: 1.5; }
.input-box textarea::placeholder { color: #8e8e93; }
.btn-action { background: rgba(255,255,255,0.1); border: none; color: white; border-radius: 50%; width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;}
.btn-send { background: white; color: black; margin-left: 10px; font-weight: bold; }
.btn-send:disabled { background: #555; color: #888; }

/* 附件区 */
.attachment-area { display: none; padding: 4px 12px 12px 12px; border-bottom: 1px solid rgba(255,255,255,0.05); margin-bottom: 8px; }
.preview-wrapper { position:relative; display:inline-block; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); }
.preview-wrapper img { height: 60px; width: 60px; object-fit: cover; display: block; }
.badge-mask { position:absolute; bottom:0; left:0; right:0; background:var(--accent-color); color:white; font-size:10px; text-align:center; padding:2px 0; }
.btn-remove { position:absolute; top:4px; right:4px; width:18px; height:18px; border-radius:50%; background:rgba(0,0,0,0.6); color:white; border:none; cursor:pointer; }

/* 画板弹窗 */
.canvas-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.8); backdrop-filter: blur(20px); z-index:9999; flex-direction:column; align-items:center; justify-content:center; }
.canvas-content { background: rgba(30, 30, 30, 0.9); border: 1px solid rgba(255,255,255,0.15); padding: 24px; border-radius: 24px; display: flex; flex-direction: column; align-items: center; max-width: 95vw; }
.checkerboard { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/OweDQTA21BKMmgA0k8g2wAA9AQBWKwIxQv/i7AAAAABJRU5ErkJggg=='); border-radius: 16px; overflow: hidden; max-width: 90vw; max-height: 65vh; display: flex; align-items: center; justify-content: center; }
#paintCanvas { display: block; cursor: crosshair; max-width: 100%; max-height: 100%; object-fit: contain; }
.loading { display: flex; align-items: center; gap: 10px; color: #8e8e93; font-size: 14px; margin-top: 10px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.2); border-top-color: var(--accent-color); border-radius: 50%; animation: spin 0.8s infinite linear; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ================= 移动端强力适配 ================= */
.mobile-header { display: none; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 90; backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); width: 280px; box-shadow: none; }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
    .sidebar-overlay { display: block; }
    
    .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: rgba(30, 30, 30, 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-color); z-index: 40; position: absolute; top: 0; left: 0; right: 0; }
    .menu-btn { background: transparent; border: none; color: white; display: flex; align-items: center; justify-content: center; padding: 4px; cursor: pointer; }
    .mobile-title { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 18px; background: linear-gradient(135deg, #fff 0%, #a1a1a6 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
    
    .chat-container { padding-top: 80px; padding-bottom: 180px; padding-left: 10px; padding-right: 10px; }
    
    .message { padding: 8px 10px; max-width: 100%; }
    .msg-user .bubble { max-width: 95%; font-size: 14px; }
    .msg-ai .bubble { font-size: 14px; }
    .image-wrapper img { max-width: 100%; border-radius: 12px; }
    
    .input-area { padding: 0 12px 16px 12px; }
    .input-box { border-radius: 20px; padding: 8px 12px; }
    .input-box textarea { font-size: 15px; padding: 8px; }
    
    .canvas-content { padding: 16px; width: 90vw; max-width: 90vw; }
    .checkerboard { max-height: 50vh; }
    .btn-edit-overlay { font-size: 13px; width: 100px !important; padding: 8px 16px; }
}