/* ================================================================
   🎨 全局变量 & 重置
   ================================================================ */
* { margin:0; padding:0; box-sizing:border-box; }
:root {
    --primary: #5b7cfa;
    --primary-light: #7b98ff;
    --primary-dark: #3a5cdb;
    --bg: #f2f4f8;
    --card: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --radius: 18px;
    --radius-sm: 10px;
    --transition: 0.25s ease;
    --safe-bottom: env(safe-area-inset-bottom,0px);
    --nav-height: 64px;
    --header-height: 56px;
    --theme-color: #5b7cfa;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
html, body { height:100%; font-family:var(--font); background:var(--bg); color:var(--text); font-size:15px; line-height:1.5; overflow:hidden; -webkit-font-smoothing:antialiased; }
input, textarea, button, select { font-family:var(--font); font-size:inherit; outline:none; border:none; }
button { cursor:pointer; background:none; touch-action:manipulation; }
a { color:var(--theme-color); text-decoration:none; }
::-webkit-scrollbar { width:4px; height:4px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:4px; }
.hidden { display:none !important; }
.flex-between { display:flex; align-items:center; justify-content:space-between; }
.flex-center { display:flex; align-items:center; justify-content:center; }

/* ================================================================
   📱 App Shell
   ================================================================ */
#app { display:flex; flex-direction:column; height:100%; max-width:480px; margin:0 auto; background:var(--bg); position:relative; overflow:hidden; box-shadow:0 0 40px rgba(0,0,0,0.08); }

/* ================================================================
   🧭 Header
   ================================================================ */
.app-header { height:var(--header-height); padding:0 16px; background:var(--card); border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; flex-shrink:0; z-index:10; position:relative; }
.app-header .title { font-weight:700; font-size:18px; letter-spacing:0.3px; background:linear-gradient(135deg,var(--theme-color),#a78bfa); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }
.app-header .header-actions { display:flex; gap:10px; align-items:center; }
.app-header .header-actions button { width:36px; height:36px; border-radius:50%; background:var(--bg); color:var(--text-secondary); font-size:18px; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.app-header .header-actions button:hover { background:var(--border); }
.app-header .back-btn { font-size:20px; color:var(--text); padding:4px 8px; }
.app-header .back-btn:hover { color:var(--theme-color); }

/* ================================================================
   📄 Pages
   ================================================================ */
.main-content { flex:1; overflow:hidden; position:relative; }
.page { display:none; height:100%; overflow-y:auto; padding:16px; padding-bottom:calc(16px + var(--safe-bottom)); background:var(--bg); animation:fadeIn 0.25s ease; }
.page.active { display:block; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ================================================================
   📌 Bottom Nav
   ================================================================ */
.bottom-nav { height:var(--nav-height); background:var(--card); border-top:1px solid var(--border); display:flex; align-items:stretch; flex-shrink:0; padding-bottom:var(--safe-bottom); position:relative; z-index:10; }
.bottom-nav .nav-item { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; font-size:11px; color:var(--text-secondary); transition:var(--transition); border:none; background:transparent; padding:4px 0; position:relative; -webkit-tap-highlight-color:transparent; }
.bottom-nav .nav-item .icon { font-size:22px; line-height:1; }
.bottom-nav .nav-item.active { color:var(--theme-color); }
.bottom-nav .nav-item .badge { position:absolute; top:4px; right:50%; transform:translateX(calc(50% + 18px)); background:#ef4444; color:#fff; font-size:10px; min-width:18px; height:18px; border-radius:9px; display:flex; align-items:center; justify-content:center; padding:0 5px; font-weight:600; }

/* ================================================================
   🤖 智能体卡片
   ================================================================ */
.agent-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:12px; margin-top:12px; }
.agent-card { background:var(--card); border-radius:var(--radius); padding:16px 12px 14px; box-shadow:var(--shadow); text-align:center; transition:var(--transition); border:1px solid transparent; cursor:pointer; position:relative; -webkit-tap-highlight-color:transparent; }
.agent-card:active { transform:scale(0.96); }
.agent-card:hover { transform:translateY(-2px); box-shadow:0 8px 30px rgba(0,0,0,0.08); }
.agent-card .avatar { width:60px; height:60px; border-radius:50%; object-fit:cover; margin:0 auto 8px; background:var(--bg); display:flex; align-items:center; justify-content:center; font-size:28px; font-weight:500; color:#fff; border:2px solid var(--border); position:relative; flex-shrink:0; overflow:hidden; }
.agent-card .avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.agent-card .avatar .mood { position:absolute; bottom:-4px; right:-4px; font-size:16px; background:var(--card); border-radius:50%; padding:2px; line-height:1; box-shadow:0 1px 4px rgba(0,0,0,0.1); }
.agent-card .name { font-weight:600; font-size:14px; margin-bottom:2px; word-break:break-word; }
.agent-card .category { font-size:11px; color:var(--text-secondary); background:var(--bg); padding:2px 10px; border-radius:10px; display:inline-block; margin-top:4px; }
.agent-card .gender-tag { position:absolute; bottom:8px; right:8px; font-size:14px; background:rgba(255,255,255,0.85); border-radius:50%; width:28px; height:28px; display:flex; align-items:center; justify-content:center; box-shadow:0 1px 4px rgba(0,0,0,0.08); }
.agent-card .edit-agent { position:absolute; top:8px; right:8px; font-size:14px; color:var(--text-secondary); opacity:0; transition:var(--transition); background:rgba(255,255,255,0.9); border-radius:50%; width:28px; height:28px; display:flex; align-items:center; justify-content:center; box-shadow:0 1px 4px rgba(0,0,0,0.08); z-index:2; }
.agent-card:hover .edit-agent { opacity:1; }
.agent-card .edit-agent:hover { background:#dbeafe; color:var(--theme-color); }
.agent-card .delete-agent { position:absolute; top:8px; left:8px; font-size:14px; color:#ef4444; opacity:0; transition:var(--transition); background:rgba(255,255,255,0.9); border-radius:50%; width:28px; height:28px; display:flex; align-items:center; justify-content:center; box-shadow:0 1px 4px rgba(0,0,0,0.08); z-index:2; }
.agent-card:hover .delete-agent { opacity:1; }
.agent-card .delete-agent:hover { background:#fee2e2; }
.agent-card .template-badge { position:absolute; top:8px; left:50%; transform:translateX(-50%); font-size:10px; background:rgba(91,124,250,0.15); color:var(--theme-color); padding:1px 8px; border-radius:8px; font-weight:500; letter-spacing:0.3px; }

/* ================================================================
   🏷️ 分类标签 & 顶部栏
   ================================================================ */
.top-bar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:4px; }
.top-bar .template-btn { font-size:13px; padding:6px 16px; border-radius:20px; background:linear-gradient(135deg,var(--theme-color),#a78bfa); color:#fff; border:none; font-weight:600; transition:var(--transition); flex-shrink:0; -webkit-tap-highlight-color:transparent; }
.top-bar .template-btn:active { transform:scale(0.94); }
.top-bar .template-btn:hover { opacity:0.85; }
.category-tabs { display:flex; gap:8px; overflow-x:auto; padding:4px 0 12px; flex-wrap:nowrap; -webkit-overflow-scrolling:touch; scrollbar-width:none; flex:1; }
.category-tabs::-webkit-scrollbar { display:none; }
.category-tabs .tab { flex-shrink:0; padding:6px 16px; border-radius:20px; background:var(--card); color:var(--text-secondary); font-size:13px; border:1px solid var(--border); transition:var(--transition); cursor:pointer; -webkit-tap-highlight-color:transparent; white-space:nowrap; }
.category-tabs .tab.active { background:var(--theme-color); color:#fff; border-color:var(--theme-color); }
.category-tabs .tab:hover:not(.active) { background:var(--border); }

/* ================================================================
   📚 模板库
   ================================================================ */
.template-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:8px 0; }
.template-card { background:var(--bg); border-radius:var(--radius-sm); padding:14px 12px; text-align:center; cursor:pointer; transition:var(--transition); border:2px solid transparent; -webkit-tap-highlight-color:transparent; }
.template-card:active { transform:scale(0.94); }
.template-card:hover { border-color:var(--theme-color); background:var(--card); }
.template-card .t-emoji { font-size:32px; display:block; margin-bottom:4px; }
.template-card .t-name { font-weight:600; font-size:14px; }
.template-card .t-desc { font-size:11px; color:var(--text-secondary); margin-top:2px; }
.template-card .t-tag { display:inline-block; font-size:10px; background:rgba(91,124,250,0.12); color:var(--theme-color); padding:1px 8px; border-radius:8px; margin-top:4px; }

/* ================================================================
   📭 空状态
   ================================================================ */
.empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:60px 20px; color:var(--text-secondary); text-align:center; }
.empty-state .icon { font-size:64px; margin-bottom:16px; opacity:0.5; }
.empty-state h3 { font-size:18px; margin-bottom:6px; color:var(--text); }
.empty-state p { font-size:14px; max-width:260px; }

/* ================================================================
   🔘 按钮
   ================================================================ */
.btn-primary { background:var(--theme-color); color:#fff; padding:10px 24px; border-radius:24px; font-weight:600; font-size:14px; transition:var(--transition); border:none; display:inline-flex; align-items:center; gap:6px; -webkit-tap-highlight-color:transparent; }
.btn-primary:active { transform:scale(0.96); }
.btn-primary:hover { background:var(--primary-dark); transform:scale(0.97); }
.btn-outline { background:transparent; color:var(--theme-color); padding:8px 20px; border-radius:24px; font-weight:600; font-size:13px; border:1.5px solid var(--theme-color); transition:var(--transition); }
.btn-outline:hover { background:var(--theme-color); color:#fff; }
.btn-danger { background:#ef4444; color:#fff; padding:8px 20px; border-radius:24px; font-weight:600; font-size:13px; transition:var(--transition); }
.btn-danger:hover { background:#dc2626; }
.btn-sm { padding:5px 14px; font-size:12px; border-radius:14px; }
.btn-block { width:100%; justify-content:center; }

/* ================================================================
   📝 表单
   ================================================================ */
.form-group { margin-bottom:16px; }
.form-group label { display:block; font-weight:600; font-size:13px; margin-bottom:4px; color:var(--text-secondary); }
.form-group .hint { font-size:12px; color:var(--text-secondary); margin-top:2px; }
.form-control { width:100%; padding:10px 14px; border-radius:var(--radius-sm); border:1.5px solid var(--border); background:var(--card); transition:var(--transition); color:var(--text); font-size:14px; -webkit-appearance:none; appearance:none; }
.form-control:focus { border-color:var(--theme-color); box-shadow:0 0 0 3px rgba(91,124,250,0.12); }
.form-control::placeholder { color:var(--text-secondary); opacity:0.6; }
textarea.form-control { resize:vertical; min-height:80px; line-height:1.6; font-size:14px; padding:10px 14px; border-radius:var(--radius-sm); border:1.5px solid var(--border); background:var(--card); width:100%; transition:var(--transition); color:var(--text); font-family:var(--font); }
textarea.form-control:focus { border-color:var(--theme-color); box-shadow:0 0 0 3px rgba(91,124,250,0.12); }
.modal-box textarea.form-control { min-height:80px; max-height:200px; overflow-y:auto; }
select.form-control { -webkit-appearance:auto; appearance:auto; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.avatar-upload { display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
.avatar-upload .preview { width:72px; height:72px; border-radius:50%; object-fit:cover; background:var(--bg); border:2px solid var(--border); display:flex; align-items:center; justify-content:center; font-size:32px; font-weight:500; color:#fff; flex-shrink:0; overflow:hidden; }
.avatar-upload .preview img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.avatar-upload .upload-btn { padding:6px 16px; border-radius:16px; background:var(--bg); color:var(--text-secondary); font-size:13px; border:1px solid var(--border); cursor:pointer; transition:var(--transition); }
.avatar-upload .upload-btn:hover { background:var(--border); }
.avatar-upload .color-picker { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.avatar-upload .color-picker input[type="color"] { width:36px; height:36px; border:2px solid var(--border); border-radius:50%; padding:0; cursor:pointer; background:none; }
.avatar-upload .color-picker input[type="color"]::-webkit-color-swatch-wrapper { padding:0; }
.avatar-upload .color-picker input[type="color"]::-webkit-color-swatch { border:none; border-radius:50%; }
.avatar-upload .flex-column { display:flex; flex-direction:column; gap:6px; flex:1; min-width:160px; }
.avatar-upload .flex-row { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }

/* ================================================================
   💬 对话页面
   ================================================================ */
.chat-container { display:flex; flex-direction:column; height:100%; background:var(--bg); }
.chat-header-info { padding:8px 16px; background:var(--card); border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; flex-shrink:0; gap:8px; flex-wrap:wrap; min-height:48px; }
.chat-header-info .chat-title { font-weight:600; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0; }
.chat-header-info .chat-title .group-tag { font-size:12px; color:var(--text-secondary); font-weight:400; }
.chat-header-info .header-btns { display:flex; gap:4px; flex-shrink:0; align-items:center; flex-wrap:wrap; }
.chat-header-info .header-btns .context-btn { background:#8b5cf6; color:#fff; border-color:#8b5cf6; font-size:11px; padding:3px 8px; }
.chat-header-info .header-btns .context-btn.active { background:#10b981; border-color:#10b981; }
.chat-header-info .header-btns .context-btn:hover { opacity:0.85; }
.chat-header-info .header-btns button { font-size:12px; padding:4px 10px; border-radius:12px; background:var(--bg); border:1px solid var(--border); transition:var(--transition); white-space:nowrap; -webkit-tap-highlight-color:transparent; }
.chat-header-info .header-btns button:active { transform:scale(0.94); }
.chat-header-info .header-btns button:hover { background:var(--theme-color); color:#fff; border-color:var(--theme-color); }
.chat-header-info .header-btns .clear-btn:hover { background:#ef4444; border-color:#ef4444; }
.chat-header-info .header-btns .auto-btn { background:#10b981; color:#fff; border-color:#10b981; }
.chat-header-info .header-btns .auto-btn:hover { background:#059669; border-color:#059669; }
.chat-header-info .header-btns .auto-btn.running { background:#f59e0b; border-color:#f59e0b; }
.chat-header-info .header-btns .auto-btn.running:hover { background:#d97706; border-color:#d97706; }

.search-bar { padding:8px 16px; background:var(--card); border-bottom:1px solid var(--border); display:flex; gap:8px; align-items:center; }
.search-bar input { flex:1; padding:6px 12px; border-radius:16px; border:1.5px solid var(--border); font-size:13px; background:var(--bg); transition:var(--transition); }
.search-bar input:focus { border-color:var(--theme-color); box-shadow:0 0 0 3px rgba(91,124,250,0.1); }
.search-bar .search-clear { font-size:16px; color:var(--text-secondary); padding:4px 8px; }

.chat-messages { flex:1; overflow-y:auto; padding:16px 12px; display:flex; flex-direction:column; gap:10px; position:relative; background-size:cover; background-position:center; background-repeat:no-repeat; background-color:var(--bg); }
.chat-messages .bg-overlay { position:absolute; inset:0; background:rgba(242,244,248,0.7); backdrop-filter:blur(2px); pointer-events:none; z-index:0; }
.watermark-emoji { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:120px; opacity:0.08; pointer-events:none; z-index:0; user-select:none; }
.chat-messages .msg { max-width:82%; padding:10px 14px; border-radius:var(--radius); background:var(--card); box-shadow:var(--shadow); animation:msgIn 0.2s ease; position:relative; word-break:break-word; transition:background 0.15s; z-index:1; }
.chat-messages .msg.user { align-self:flex-end; background:var(--theme-color); color:#fff; border-bottom-right-radius:4px; }
.chat-messages .msg.assistant { align-self:flex-start; background:var(--card); border-bottom-left-radius:4px; }
.chat-messages .msg .time { font-size:10px; color:var(--text-secondary); margin-top:4px; opacity:0.6; display:block; }
.chat-messages .msg.user .time { color:rgba(255,255,255,0.7); }
.chat-messages .msg .agent-name { font-size:11px; font-weight:600; color:var(--theme-color); margin-bottom:2px; }
.chat-messages .msg .msg-actions { display:none; position:absolute; right:4px; top:4px; gap:2px; background:rgba(255,255,255,0.92); border-radius:12px; padding:2px 4px; box-shadow:0 2px 8px rgba(0,0,0,0.1); flex-wrap:wrap; }
.chat-messages .msg:hover .msg-actions { display:flex; }
.chat-messages .msg .msg-actions button { font-size:13px; padding:2px 4px; color:var(--text-secondary); border-radius:6px; transition:var(--transition); min-width:24px; text-align:center; }
.chat-messages .msg .msg-actions button:hover { background:var(--border); color:var(--text); }
.chat-messages .msg .msg-actions .edit-msg:hover { color:var(--theme-color); }
.chat-messages .msg .msg-actions .del-msg:hover { color:#ef4444; }
.chat-messages .msg .msg-actions .regenerate-msg:hover { color:#f59e0b; }
.chat-messages .msg .msg-actions .recall-msg:hover { color:#8b5cf6; }
.chat-messages .msg .msg-actions .quote-msg:hover { color:#06b6d4; }
.chat-messages .msg .msg-actions .speak-msg:hover { color:#10b981; }
.chat-messages .msg .quote-context { font-size:12px; color:var(--text-secondary); background:var(--bg); padding:4px 8px; border-radius:6px; margin-bottom:4px; border-left:3px solid var(--theme-color); opacity:0.8; font-style:italic; }
.chat-messages .msg .quote-context .quote-author { font-weight:600; font-style:normal; }
.chat-messages .msg .typing-dots { display:flex; gap:4px; padding:4px 0; }
.chat-messages .msg .typing-dots span { width:8px; height:8px; border-radius:50%; background:var(--text-secondary); animation:dotPulse 1.2s infinite; }
.chat-messages .msg .typing-dots span:nth-child(2) { animation-delay:0.2s; }
.chat-messages .msg .typing-dots span:nth-child(3) { animation-delay:0.4s; }
@keyframes dotPulse { 0%,80%,100% { opacity:0.2; transform:scale(0.8); } 40% { opacity:1; transform:scale(1); } }
@keyframes msgIn { from { opacity:0; transform:translateY(8px) scale(0.96); } to { opacity:1; transform:translateY(0) scale(1); } }
.chat-messages .msg.read { opacity:0.85; }
.chat-messages .msg .mood-indicator { font-size:12px; margin-left:4px; }

.quote-indicator { background:var(--bg); padding:4px 12px; border-radius:12px; font-size:12px; color:var(--text-secondary); display:flex; align-items:center; gap:6px; margin-bottom:4px; border-left:3px solid var(--theme-color); flex-shrink:0; }
.quote-indicator .remove-quote { cursor:pointer; color:#ef4444; font-weight:bold; }

.chat-input-area { display:flex; flex-direction:column; gap:6px; padding:8px 12px; padding-bottom:calc(8px + var(--safe-bottom)); background:var(--card); border-top:1px solid var(--border); }
.chat-input-area .input-top-row { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.chat-input-area .input-top-row .quick-actions { display:flex; gap:4px; flex-wrap:wrap; flex:1; }
.chat-input-area .input-top-row .quick-actions .quick-btn { font-size:11px; padding:2px 10px; border-radius:12px; background:var(--bg); border:1px solid var(--border); color:var(--text-secondary); transition:var(--transition); cursor:pointer; -webkit-tap-highlight-color:transparent; white-space:nowrap; }
.chat-input-area .input-top-row .quick-actions .quick-btn:active { transform:scale(0.94); }
.chat-input-area .input-top-row .quick-actions .quick-btn:hover { background:var(--theme-color); color:#fff; border-color:var(--theme-color); }
.chat-input-area .input-top-row .identity-selector { display:flex; align-items:center; gap:4px; font-size:12px; color:var(--text-secondary); flex-shrink:0; }
.chat-input-area .input-top-row .identity-selector select { padding:2px 6px; border-radius:12px; border:1px solid var(--border); background:var(--bg); font-size:12px; outline:none; max-width:80px; font-family:var(--font); }
.chat-input-area .input-top-row .voice-btn { width:32px; height:32px; border-radius:50%; background:var(--bg); color:var(--text-secondary); font-size:16px; display:flex; align-items:center; justify-content:center; transition:var(--transition); flex-shrink:0; border:1.5px solid var(--border); -webkit-tap-highlight-color:transparent; }
.chat-input-area .input-top-row .voice-btn:active { transform:scale(0.92); }
.chat-input-area .input-top-row .voice-btn:hover { background:var(--border); }
.chat-input-area .input-top-row .voice-btn.listening { background:#ef4444; color:#fff; border-color:#ef4444; animation:pulse 1s infinite; }
.chat-input-area .input-bottom-row { display:flex; align-items:flex-end; gap:8px; width:100%; }
.chat-input-area .input-bottom-row textarea { flex:1; padding:10px 14px; border-radius:20px; border:1.5px solid var(--border); background:var(--bg); resize:none; min-height:44px; max-height:120px; font-size:14px; line-height:1.4; transition:var(--transition); font-family:var(--font); width:100%; }
.chat-input-area .input-bottom-row textarea:focus { border-color:var(--theme-color); box-shadow:0 0 0 3px rgba(91,124,250,0.1); }
.chat-input-area .input-bottom-row .send-btn { width:44px; height:44px; border-radius:50%; background:var(--theme-color); color:#fff; font-size:20px; display:flex; align-items:center; justify-content:center; transition:var(--transition); flex-shrink:0; border:none; -webkit-tap-highlight-color:transparent; }
.chat-input-area .input-bottom-row .send-btn:active { transform:scale(0.92); }
.chat-input-area .input-bottom-row .send-btn:hover { background:var(--primary-dark); }
.chat-input-area .markdown-hint { font-size:11px; color:var(--text-secondary); padding:2px 4px; opacity:0.5; text-align:right; }
@keyframes pulse { 0%,100% { box-shadow:0 0 0 0 rgba(239,68,68,0.4); } 50% { box-shadow:0 0 0 8px rgba(239,68,68,0); } }

/* ================================================================
   ⚙️ 设置页面
   ================================================================ */
.settings-group { background:var(--card); border-radius:var(--radius); padding:4px 0; margin-bottom:16px; box-shadow:var(--shadow); overflow:hidden; }
.settings-group .group-title { padding:12px 16px 4px; font-size:12px; color:var(--text-secondary); font-weight:600; letter-spacing:0.5px; }
.settings-item { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid var(--border); transition:var(--transition); cursor:pointer; -webkit-tap-highlight-color:transparent; }
.settings-item:last-child { border-bottom:none; }
.settings-item:active { background:var(--bg); }
.settings-item:hover { background:var(--bg); }
.settings-item .label { font-weight:500; font-size:14px; }
.settings-item .value { color:var(--text-secondary); font-size:13px; display:flex; align-items:center; gap:6px; }
.settings-item .color-picker-wrap { display:flex; gap:4px; }
.settings-item .color-picker-wrap .color-dot { width:24px; height:24px; border-radius:50%; border:2px solid var(--border); cursor:pointer; transition:var(--transition); }
.settings-item .color-picker-wrap .color-dot.active { border-color:var(--text); transform:scale(1.1); }
.settings-item .color-picker-wrap .color-dot:hover { transform:scale(1.15); }

/* ================================================================
   🖥️ Modal
   ================================================================ */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.4); backdrop-filter:blur(4px); z-index:100; display:flex; align-items:center; justify-content:center; padding:20px; animation:fadeIn 0.2s ease; }
.modal-overlay .modal-box { background:var(--card); border-radius:var(--radius); max-width:440px; width:100%; max-height:90vh; overflow-y:auto; padding:24px 20px 20px; box-shadow:0 20px 60px rgba(0,0,0,0.2); animation:slideUp 0.25s ease; }
@keyframes slideUp { from { opacity:0; transform:translateY(30px) scale(0.95); } to { opacity:1; transform:translateY(0) scale(1); } }
.modal-box .modal-title { font-size:18px; font-weight:700; margin-bottom:16px; display:flex; align-items:center; justify-content:space-between; }
.modal-box .modal-title .close { font-size:24px; color:var(--text-secondary); cursor:pointer; padding:0 4px; -webkit-tap-highlight-color:transparent; }
.modal-box .modal-actions { display:flex; gap:10px; margin-top:20px; justify-content:flex-end; flex-wrap:wrap; }

/* ================================================================
   📋 对话列表 & 多选
   ================================================================ */
.chat-list-toolbar { display:flex; align-items:center; gap:8px; margin-bottom:12px; flex-wrap:wrap; }
.chat-list-toolbar .left { display:flex; gap:6px; align-items:center; flex:1; }
.chat-list-toolbar .right { display:flex; gap:6px; align-items:center; }
.chat-list-toolbar .multi-select-btn { font-size:13px; padding:4px 12px; border-radius:14px; background:var(--bg); border:1px solid var(--border); transition:var(--transition); }
.chat-list-toolbar .multi-select-btn.active { background:var(--theme-color); color:#fff; border-color:var(--theme-color); }
.chat-list-toolbar .multi-select-btn:hover { background:var(--border); }
.chat-list-toolbar .delete-selected-btn { font-size:13px; padding:4px 12px; border-radius:14px; background:#ef4444; color:#fff; border:1px solid #ef4444; transition:var(--transition); }
.chat-list-toolbar .delete-selected-btn:disabled { opacity:0.4; pointer-events:none; }
.chat-list-toolbar .delete-selected-btn:hover { background:#dc2626; }

.chat-list-item { display:flex; align-items:center; gap:12px; padding:12px 14px; background:var(--card); border-radius:var(--radius-sm); margin-bottom:8px; box-shadow:var(--shadow); cursor:pointer; transition:var(--transition); border:1px solid transparent; position:relative; -webkit-tap-highlight-color:transparent; }
.chat-list-item:active { transform:scale(0.98); }
.chat-list-item:hover { border-color:var(--theme-color); }
.chat-list-item.pinned { border-left:4px solid var(--theme-color); }
.chat-list-item .chat-checkbox { width:20px; height:20px; border-radius:4px; border:2px solid var(--border); display:flex; align-items:center; justify-content:center; flex-shrink:0; background:var(--bg); transition:var(--transition); cursor:pointer; }
.chat-list-item .chat-checkbox.checked { background:var(--theme-color); border-color:var(--theme-color); color:#fff; }
.chat-list-item .chat-checkbox.checked::after { content:"✓"; font-size:14px; color:#fff; }
.chat-list-item .chat-checkbox + * { margin-left:0; }
.chat-list-item .chat-avatar { width:44px; height:44px; border-radius:50%; background:var(--bg); display:flex; align-items:center; justify-content:center; font-size:20px; flex-shrink:0; color:#fff; overflow:hidden; }
.chat-list-item .chat-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.chat-list-item .chat-info { flex:1; min-width:0; }
.chat-list-item .chat-info .chat-name { font-weight:600; font-size:14px; }
.chat-list-item .chat-info .chat-preview { font-size:13px; color:var(--text-secondary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-list-item .chat-time { font-size:11px; color:var(--text-secondary); flex-shrink:0; margin-right:4px; }
.chat-list-item .chat-actions { display:flex; gap:2px; flex-shrink:0; }
.chat-list-item .chat-actions button { font-size:16px; color:var(--text-secondary); padding:2px 4px; border-radius:50%; transition:var(--transition); -webkit-tap-highlight-color:transparent; }
.chat-list-item .chat-actions button:active { transform:scale(0.88); }
.chat-list-item .chat-actions button:hover { background:var(--bg); }
.chat-list-item .chat-actions .pin-btn:hover { color:var(--theme-color); }
.chat-list-item .chat-actions .delete-chat-btn:hover { background:#fee2e2; color:#ef4444; }

/* ================================================================
   👥 群成员管理
   ================================================================ */
.member-list { display:flex; flex-direction:column; gap:8px; margin:8px 0; }
.member-item { display:flex; align-items:center; justify-content:space-between; padding:8px 12px; background:var(--bg); border-radius:var(--radius-sm); }
.member-item .info { display:flex; align-items:center; gap:10px; min-width:0; }
.member-item .info .avatar-sm { width:32px; height:32px; border-radius:50%; object-fit:cover; background:var(--border); display:flex; align-items:center; justify-content:center; font-size:16px; color:#fff; font-weight:500; flex-shrink:0; overflow:hidden; }
.member-item .info .avatar-sm img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.member-item .info span { word-break:break-word; }
.member-item .remove-btn { color:#ef4444; font-size:16px; padding:4px 8px; border-radius:12px; transition:var(--transition); flex-shrink:0; }
.member-item .remove-btn:hover { background:#fee2e2; }
.add-member-section { margin-top:12px; border-top:1px solid var(--border); padding-top:12px; }
.add-member-section .available-list { display:flex; flex-wrap:wrap; gap:6px; margin:6px 0; }
.add-member-section .available-list .add-chip { padding:4px 12px; border-radius:14px; background:var(--bg); border:1px solid var(--border); font-size:13px; cursor:pointer; transition:var(--transition); display:flex; align-items:center; gap:4px; -webkit-tap-highlight-color:transparent; }
.add-member-section .available-list .add-chip:active { transform:scale(0.94); }
.add-member-section .available-list .add-chip:hover { background:var(--theme-color); color:#fff; border-color:var(--theme-color); }
.add-member-section .available-list .add-chip .add-icon { font-weight:bold; }

/* ================================================================
   ⏳ 加载提示
   ================================================================ */
.loading-overlay { position:fixed; inset:0; background:rgba(255,255,255,0.85); backdrop-filter:blur(2px); z-index:999; display:flex; align-items:center; justify-content:center; flex-direction:column; gap:12px; font-size:16px; color:var(--text-secondary); transition:opacity 0.3s; }
.loading-overlay.hidden { opacity:0; pointer-events:none; }
.loading-overlay .spinner { width:40px; height:40px; border:4px solid var(--border); border-top-color:var(--theme-color); border-radius:50%; animation:spin 0.8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ================================================================
   📸 快照 & 日志
   ================================================================ */
.snapshot-list { max-height:200px; overflow-y:auto; }
.snapshot-item { display:flex; align-items:center; justify-content:space-between; padding:8px 12px; border-bottom:1px solid var(--border); font-size:13px; gap:8px; flex-wrap:wrap; }
.snapshot-item .snapshot-time { color:var(--text-secondary); font-size:12px; }
.snapshot-item .snapshot-restore { color:var(--theme-color); cursor:pointer; font-weight:500; flex-shrink:0; }
.snapshot-item .snapshot-restore:hover { text-decoration:underline; }
.log-entry { font-size:12px; color:var(--text-secondary); padding:4px 0; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; gap:8px; }
.log-entry .log-time { opacity:0.6; flex-shrink:0; }

/* ================================================================
   📱 响应式
   ================================================================ */
@media (min-width:481px) { #app { border-radius:24px; margin-top:20px; margin-bottom:20px; max-height:calc(100vh - 40px); } }
@media (max-width:380px) {
    .agent-grid { grid-template-columns:1fr 1fr; }
    .form-row { grid-template-columns:1fr; }
    .chat-header-info .header-btns button { font-size:11px; padding:2px 8px; }
    .chat-input-area .input-top-row .identity-selector select { max-width:60px; font-size:11px; }
    .modal-box { padding:16px 14px; }
    .template-grid { grid-template-columns:1fr 1fr; }
}
@media (max-width:360px) {
    .agent-grid { grid-template-columns:1fr 1fr; gap:8px; }
    .agent-card { padding:12px 8px; }
    .agent-card .avatar { width:48px; height:48px; font-size:22px; }
    .chat-messages .msg { max-width:90%; padding:8px 12px; }
    .template-grid { grid-template-columns:1fr 1fr; }
}
@media (hover:hover) {
    .agent-card:hover .edit-agent,
    .agent-card:hover .delete-agent { opacity:1; }
    .chat-messages .msg:hover .msg-actions { display:flex; }
}
@media (hover:none) {
    .agent-card .edit-agent,
    .agent-card .delete-agent { opacity:1; }
    .chat-messages .msg .msg-actions { display:flex; }
}

/* ================================================================
   🧹 工具类
   ================================================================ */
.mt-8 { margin-top:8px; }
.mt-12 { margin-top:12px; }
.mt-16 { margin-top:16px; }
.mb-8 { margin-bottom:8px; }
.mb-12 { margin-bottom:12px; }
.gap-8 { gap:8px; }
.gap-12 { gap:12px; }
.text-center { text-align:center; }
.text-secondary { color:var(--text-secondary); }
.text-sm { font-size:13px; }
.w-full { width:100%; }
.flex { display:flex; }
.flex-col { flex-direction:column; }
.items-center { align-items:center; }
.flex-1 { flex:1; }
.relative { position:relative; }
.break-word { word-break:break-word; }
/* ================================================================
   🔐 登录遮罩
   ================================================================ */
#loginOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
    transition: opacity 0.4s;
}
#loginOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}
#loginOverlay .login-box {
    background: var(--card);
    border-radius: var(--radius);
    padding: 32px 28px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}
#loginOverlay .login-box .logo {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#loginOverlay .login-box .form-group {
    margin-bottom: 16px;
}
#loginOverlay .login-box .form-group label {
    display: block;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
#loginOverlay .login-box .form-group input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg);
}
#loginOverlay .login-box .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.12);
}
#loginOverlay .login-box .login-btn {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    transition: var(--transition);
    margin-top: 8px;
    cursor: pointer;
    border: none;
}
#loginOverlay .login-box .login-btn:hover {
    background: var(--primary-dark);
    transform: scale(0.97);
}
#loginOverlay .login-box .error-msg {
    color: #ef4444;
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
    min-height: 20px;
}