/* 空盒子 · Load 聊天 — 浅色主题，PC + 手机自适应 */
:root{
  --bg:#f4f5f8; --panel:#ffffff; --ink:#20242c; --sub:#6b7280;
  --line:#e6e8ee; --accent:#5b7fa8; --accent-soft:#eaf0f7;
  --bubble-in:#ffffff; --bubble-out:#d9e7f5; --shadow:0 6px 24px rgba(30,45,70,.08);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;color:var(--ink);background:var(--bg)}
button,input,textarea,select{font-family:inherit}
.app{display:flex;height:100dvh;max-width:1280px;margin:0 auto;background:var(--panel);box-shadow:var(--shadow)}

/* 侧栏 */
.sidebar{width:300px;flex:none;border-right:1px solid var(--line);display:flex;flex-direction:column;background:#fafbfd}
.brand{display:flex;align-items:center;gap:12px;padding:18px 20px;border-bottom:1px solid var(--line)}
.brand-mark{width:40px;height:40px;border-radius:12px;background:linear-gradient(135deg,#6d8fb8,#41628a);color:#fff;display:flex;align-items:center;justify-content:center;font-size:20px;font-weight:700}
.brand-name{font-weight:700;font-size:16px}.brand-sub{font-size:11px;color:var(--sub);margin-top:2px}
.side-scroll{flex:1;overflow-y:auto;padding:8px 0 20px}
.side-section{padding:14px 18px;border-bottom:1px solid var(--line)}
.side-title{font-size:12px;font-weight:700;color:var(--sub);margin-bottom:10px;display:flex;justify-content:space-between;align-items:center}
.side-hint{font-weight:400;color:#9aa1ac;font-size:10px}
.role-card{display:flex;align-items:center;gap:10px;padding:10px;border-radius:12px;margin-bottom:8px;border:1px solid transparent}
.role-card.active{background:var(--accent-soft);border-color:#cddcec}
.role-card.disabled{opacity:.5}
.role-avatar{width:36px;height:36px;border-radius:50%;background:#41628a;color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;flex:none}
.role-info{flex:1;min-width:0}.role-name{font-weight:600;font-size:14px}.role-desc{font-size:11px;color:var(--sub)}
.role-tag{font-size:10px;color:#41628a;background:#fff;border:1px solid #cddcec;border-radius:10px;padding:2px 7px}
.scene-select{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
.scene-chip{font-size:11px;padding:5px 10px;border-radius:14px;border:1px solid var(--line);background:#fff;cursor:pointer;color:var(--sub)}
.scene-chip.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.scene-options{max-height:260px;overflow-y:auto}
.opt-item{display:block;width:100%;text-align:left;font-size:12px;padding:8px 10px;margin-bottom:6px;border:1px solid var(--line);border-radius:9px;background:#fff;cursor:pointer;color:var(--ink)}
.opt-item:hover{border-color:var(--accent);background:var(--accent-soft)}
.opt-label{font-size:10px;color:#9aa1ac;margin-bottom:6px}
.empty-hint{font-size:11px;color:#9aa1ac;padding:6px 0}
.status-box{background:#fff;border:1px solid var(--line);border-radius:10px;padding:6px 12px}
.status-row{display:flex;justify-content:space-between;font-size:11px;padding:7px 0;border-bottom:1px dashed var(--line)}
.status-row:last-child{border:0}.status-row span{color:var(--sub)}.status-row b{font-weight:600;text-align:right;max-width:170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.link-btn{display:block;width:100%;text-align:left;background:none;border:0;padding:8px 0;color:var(--accent);font-size:12px;cursor:pointer}
.link-btn:hover{text-decoration:underline}

/* 聊天区 */
.chat{flex:1;display:flex;flex-direction:column;min-width:0}
.chat-head{display:flex;align-items:center;gap:12px;padding:12px 20px;border-bottom:1px solid var(--line)}
.chat-avatar{width:38px;height:38px;border-radius:50%;background:linear-gradient(135deg,#6d8fb8,#41628a);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700}
.chat-title{flex:1}.chat-name{font-weight:700;font-size:15px}.chat-status{font-size:11px;color:var(--sub);margin-top:2px}
.dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:#4caf7d;margin-right:4px}
.icon-btn{width:36px;height:36px;border:1px solid var(--line);border-radius:10px;background:#fff;color:var(--sub);cursor:pointer;font-size:16px;flex:none}
.icon-btn:hover{border-color:var(--accent);color:var(--accent)}
.mobile-only{display:none}
.notice{font-size:11px;color:#8a6d3b;background:#fdf6e7;border-bottom:1px solid #f0e2be;padding:8px 20px;line-height:1.5}
.notice.ok{color:#3d6b52;background:#edf7f1;border-color:#cfe8d9}
.messages{flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:14px}
.welcome{display:flex;gap:12px;align-items:flex-start;max-width:620px;margin:10px auto 20px}
.welcome-mark{width:44px;height:44px;border-radius:50%;background:linear-gradient(135deg,#6d8fb8,#41628a);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;flex:none}
.welcome-text h2{margin:2px 0 6px;font-size:17px}.welcome-text p{margin:0;color:var(--sub);font-size:13px;line-height:1.6}
.msg{display:flex;gap:10px;max-width:78%;animation:fade .25s ease}
@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.msg.load{align-self:flex-start}.msg.me{align-self:flex-end;flex-direction:row-reverse}
.msg-avatar{width:32px;height:32px;border-radius:50%;background:#41628a;color:#fff;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex:none}
.msg.me .msg-avatar{background:#c9d4e0;color:#405064}
.bubble{padding:10px 14px;border-radius:14px;line-height:1.7;font-size:14px;white-space:pre-wrap;word-break:break-word}
.msg.load .bubble{background:var(--bubble-in);border:1px solid var(--line);border-top-left-radius:4px}
.msg.me .bubble{background:var(--bubble-out);border-top-right-radius:4px}
.msg-time{font-size:10px;color:#9aa1ac;margin-top:4px}
.msg.me .msg-time{text-align:right}
.msg-image{max-width:220px;border-radius:10px;display:block;margin-top:6px}
.thinking{color:var(--sub);font-size:13px;font-style:italic}

/* 输入区 */
.composer{border-top:1px solid var(--line);padding:12px 20px calc(12px + env(safe-area-inset-bottom))}
.attach-preview img{height:54px;border-radius:8px;margin-bottom:8px;border:1px solid var(--line)}
.input-row{display:flex;align-items:flex-end;gap:8px}
.input-row textarea{flex:1;resize:none;border:1px solid var(--line);border-radius:12px;padding:10px 12px;font-size:14px;line-height:1.5;max-height:120px;background:#fff;outline:none}
.input-row textarea:focus{border-color:var(--accent)}
.send-btn{border:0;border-radius:12px;background:var(--accent);color:#fff;padding:0 18px;height:40px;font-weight:600;cursor:pointer}
.send-btn:disabled{opacity:.5;cursor:not-allowed}
.composer-hint{font-size:10px;color:#9aa1ac;margin-top:6px;text-align:right}

/* 抽屉 */
.drawer-mask{position:fixed;inset:0;background:rgba(20,28,40,.35);opacity:0;pointer-events:none;transition:.25s;z-index:40}
.drawer-mask.show{opacity:1;pointer-events:auto}
.drawer{position:fixed;top:0;right:0;height:100dvh;width:400px;max-width:92vw;background:#fff;box-shadow:-8px 0 32px rgba(0,0,0,.12);transform:translateX(100%);transition:.28s;z-index:50;display:flex;flex-direction:column}
.drawer.wide{width:620px}
.drawer.show{transform:none}
.drawer-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--line)}
.drawer-head h3{margin:0;font-size:16px}
.drawer-body{flex:1;overflow-y:auto;padding:18px 20px}
.field{margin-bottom:16px}
.field.inline{display:flex;align-items:center;justify-content:space-between}
.field label{display:block;font-size:12px;font-weight:600;margin-bottom:6px}
.field label .hint{font-weight:400;color:#9aa1ac;font-size:10px}
.field input[type=text],.field input[type=password],.field input[type=number],.field select{width:100%;border:1px solid var(--line);border-radius:9px;padding:9px 10px;font-size:13px;outline:none;background:#fff}
.field input:focus,.field select:focus{border-color:var(--accent)}
.field input[type=checkbox]{width:18px;height:18px}
.field-note{font-size:11px;color:var(--sub);line-height:1.6;background:#f7f8fa;border-radius:9px;padding:10px}
.primary-btn{width:100%;border:0;border-radius:10px;background:var(--accent);color:#fff;padding:12px;font-weight:600;cursor:pointer}
.ghost-btn{width:100%;border:1px solid var(--line);border-radius:10px;background:transparent;color:var(--sub);padding:10px;font-weight:500;cursor:pointer;margin-top:8px}
.ghost-btn:hover{border-color:var(--accent);color:var(--accent)}
.mem-card{border:1px solid var(--line);border-radius:10px;padding:12px;margin-bottom:10px}
.mem-title{font-weight:600;font-size:13px;margin-bottom:4px}
.mem-meta{font-size:10px;color:#9aa1ac;margin-bottom:6px}
.mem-content{font-size:12px;color:var(--sub);line-height:1.6}
.mem-evidence{font-size:11px;color:#8a8f98;margin-top:6px;padding-left:8px;border-left:2px solid var(--line)}
.persona-pre{font-size:12px;line-height:1.7;white-space:pre-wrap;color:var(--sub)}

/* 手机 */
@media(max-width:820px){
  .sidebar{position:fixed;left:0;top:0;height:100dvh;width:82vw;max-width:320px;z-index:60;transform:translateX(-100%);transition:.28s;box-shadow:8px 0 28px rgba(0,0,0,.12)}
  .sidebar.show{transform:none}
  .mobile-only{display:block}
  .msg{max-width:88%}
  .chat-head{padding:10px 14px}
  .composer{padding:10px 12px calc(10px + env(safe-area-inset-bottom))}
  .messages{padding:14px}
  .notice{padding:8px 14px}
}
