/* 絮语 · AI 陪聊 —— 浅色暖调，无外部依赖 */
:root{
  --bg:#f5f3f0;
  --surface:#ffffff;
  --surface-2:#faf8f6;
  --line:#e9e4de;
  --line-soft:#f0ece7;
  --text:#2d2a33;
  --sub:#6f6976;
  --muted:#9b949f;
  --primary:#6d5ce7;
  --primary-dark:#5b49d6;
  --primary-soft:#efebff;
  --danger:#d4595b;
  --shadow:0 8px 30px rgba(52,42,72,.08);
  --shadow-sm:0 2px 10px rgba(52,42,72,.06);
  --radius:16px;
}
*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{height:100%;margin:0}
body{
  background:var(--bg);color:var(--text);
  font-family:"PingFang SC","Microsoft YaHei","Hiragino Sans GB","Segoe UI",system-ui,-apple-system,sans-serif;
  font-size:14px;line-height:1.6;-webkit-font-smoothing:antialiased;
}
.sprite{position:absolute;width:0;height:0;overflow:hidden}
svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:none}
button,input,textarea,select{font-family:inherit;font-size:inherit;color:inherit}
button{cursor:pointer;border:0;background:none;padding:0}
input,textarea,select{outline:none}
::selection{background:#ded6ff}
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-thumb{background:#dcd6d0;border-radius:8px;border:2px solid transparent;background-clip:padding-box}
::-webkit-scrollbar-thumb:hover{background:#c8c0ba;background-clip:padding-box}
::-webkit-scrollbar-track{background:transparent}

/* ---------- 布局 ---------- */
.app{display:flex;height:100vh;height:100dvh;overflow:hidden;position:relative}
.sidebar{width:286px;flex:none;background:var(--surface);border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0}
.chat{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--bg);position:relative}
.settings{width:304px;flex:none;background:var(--surface);border-left:1px solid var(--line);display:flex;flex-direction:column;min-height:0}
.app.settings-closed .settings{display:none}
.mobile-only{display:none !important}

/* ---------- 左栏 ---------- */
.brand{display:flex;align-items:center;gap:11px;padding:20px 18px 14px}
.brand-mark{width:38px;height:38px;border-radius:12px;background:linear-gradient(135deg,#8a7af0,#6d5ce7);color:#fff;display:grid;place-items:center;font-size:19px;font-weight:600;box-shadow:0 5px 14px rgba(109,92,231,.28)}
.brand-text{display:flex;flex-direction:column;line-height:1.25;min-width:0}
.brand-text strong{font-size:17px;letter-spacing:.5px}
.brand-text span{font-size:11px;color:var(--muted);margin-top:3px}
.search-wrap{margin:4px 14px 12px;position:relative}
.search-wrap input{width:100%;height:38px;padding:0 12px 0 36px;border:1px solid var(--line);background:var(--surface-2);border-radius:11px;font-size:13px;transition:.18s}
.search-wrap input:focus{border-color:#b9adf5;background:#fff;box-shadow:0 0 0 3px rgba(109,92,231,.09)}
.search-icon{position:absolute;left:12px;top:11px;color:var(--muted);width:15px;height:15px}
.filters{display:flex;gap:4px;padding:0 14px 12px;flex-wrap:wrap}
.chip{padding:5px 9px;border-radius:20px;background:var(--surface-2);border:1px solid var(--line-soft);color:var(--sub);font-size:12px;transition:.15s;white-space:nowrap}
.chip:hover{background:#f0ecff;color:var(--primary)}
.chip.active{background:var(--primary);border-color:var(--primary);color:#fff;box-shadow:0 3px 9px rgba(109,92,231,.24)}
.list-head{display:flex;justify-content:space-between;padding:0 18px 7px;font-size:11px;color:var(--muted);letter-spacing:.3px}
.char-list{flex:1;overflow-y:auto;padding:0 10px 12px;min-height:0}
.char-item{display:flex;align-items:center;gap:11px;padding:9px 9px;border-radius:13px;cursor:pointer;position:relative;transition:.15s;margin-bottom:2px}
.char-item:hover{background:var(--surface-2)}
.char-item.active{background:var(--primary-soft)}
.char-item.active::before{content:"";position:absolute;left:-10px;top:12px;bottom:12px;width:3px;border-radius:0 3px 3px 0;background:var(--primary)}
.ci-avatar{width:40px;height:40px;border-radius:13px;flex:none;display:grid;place-items:center;color:#fff;font-size:17px;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,.14)}
.ci-body{min-width:0;flex:1}
.ci-name{display:flex;align-items:center;gap:5px;font-size:13.5px;font-weight:600;white-space:nowrap}
.ci-name .badge{font-size:9px;font-weight:500;padding:1px 5px;border-radius:5px;background:#eee9ff;color:var(--primary);line-height:1.5}
.ci-name .badge.male{background:#e6f0f7;color:#4b83a8}
.ci-name .badge.custom{background:#fff0e2;color:#c07a35}
.ci-tag{font-size:11.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:1px}
.ci-star{opacity:0;color:#c8c1d6;transition:.15s;padding:4px}
.char-item:hover .ci-star,.char-item.fav .ci-star{opacity:1}
.char-item.fav .ci-star{color:#e9a93c}
.char-item.fav .ci-star svg{fill:currentColor}
.empty-list{text-align:center;color:var(--muted);padding:36px 12px;font-size:12.5px;line-height:2}
.sidebar-footer{padding:12px 14px 16px;border-top:1px solid var(--line);background:var(--surface)}
.primary-btn{height:38px;width:100%;border-radius:11px;background:var(--primary);color:#fff;display:flex;align-items:center;justify-content:center;gap:7px;font-size:13px;font-weight:600;transition:.18s;box-shadow:0 4px 12px rgba(109,92,231,.22)}
.primary-btn:hover{background:var(--primary-dark);transform:translateY(-1px)}
.primary-btn svg{width:15px;height:15px}
.primary-btn.full{width:100%}
.mini-actions{display:flex;gap:8px;margin-top:9px}
.mini-actions button{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;height:31px;border-radius:9px;border:1px solid var(--line);background:var(--surface-2);color:var(--sub);font-size:11.5px;transition:.15s}
.mini-actions button:hover{border-color:#c9bff5;color:var(--primary);background:#fff}
.mini-actions svg{width:13px;height:13px}

/* ---------- 对话头部 ---------- */
.chat-head{height:70px;flex:none;display:flex;align-items:center;gap:12px;padding:0 22px;background:rgba(255,255,255,.9);backdrop-filter:blur(12px);border-bottom:1px solid var(--line);z-index:3}
.head-avatar{width:40px;height:40px;border-radius:13px;display:grid;place-items:center;color:#fff;font-size:18px;font-weight:600;flex:none;text-shadow:0 1px 2px rgba(0,0,0,.14)}
.head-meta{min-width:0;flex:1}
.head-meta h2{margin:0;font-size:15.5px;font-weight:600;display:flex;align-items:center;gap:8px}
.head-meta p{margin:1px 0 0;font-size:11.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.head-actions{display:flex;align-items:center;gap:6px;flex:none}
.icon-btn{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;color:var(--sub);transition:.15s}
.icon-btn:hover{background:var(--primary-soft);color:var(--primary)}
.icon-btn.ghost{color:var(--danger)}
.icon-btn.ghost:hover{background:#fdeeee;color:var(--danger)}
.status{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--sub);background:var(--surface-2);border:1px solid var(--line);padding:5px 10px;border-radius:20px;white-space:nowrap}
.dot{width:7px;height:7px;border-radius:50%;background:#c9c3cf;display:inline-block;flex:none}
.status.ok .dot,.dot.ok{background:#4caf86;box-shadow:0 0 0 3px rgba(76,175,134,.14)}
.status.bad .dot,.dot.bad{background:var(--danger);box-shadow:0 0 0 3px rgba(212,89,91,.13)}
.dot.wait{background:#e9a93c;box-shadow:0 0 0 3px rgba(233,169,60,.15)}

/* ---------- 消息区 ---------- */
.messages{flex:1;overflow-y:auto;padding:26px 0 12px;min-height:0;scroll-behavior:smooth}
.msg-wrap{max-width:820px;margin:0 auto;padding:0 26px}
.msg{display:flex;gap:10px;margin-bottom:20px;animation:pop .22s ease both}
.msg.user{flex-direction:row-reverse}
@keyframes pop{from{opacity:0;transform:translateY(7px)}to{opacity:1;transform:none}}
.msg-av{width:32px;height:32px;border-radius:11px;flex:none;display:grid;place-items:center;color:#fff;font-size:14px;font-weight:600;margin-top:2px;text-shadow:0 1px 2px rgba(0,0,0,.12)}
.msg.user .msg-av{background:linear-gradient(135deg,#a99cf2,#7d6ce8)}
.msg-main{max-width:min(76%,620px);min-width:0}
.bubble{padding:11px 15px;border-radius:16px;background:#fff;border:1px solid var(--line);box-shadow:var(--shadow-sm);font-size:14.2px;line-height:1.78;word-break:break-word;white-space:normal}
.msg.user .bubble{background:linear-gradient(135deg,#7a68ea,#6754dd);border-color:transparent;color:#fff;box-shadow:0 5px 16px rgba(109,92,231,.2)}
.bubble p{margin:0 0 8px}
.bubble p:last-child{margin-bottom:0}
.bubble strong{font-weight:650}
.bubble code{background:rgba(120,110,150,.11);padding:1px 5px;border-radius:5px;font-size:.9em;font-family:ui-monospace,Consolas,monospace}
.bubble pre{background:#f5f3f8;border:1px solid var(--line);border-radius:9px;padding:10px 12px;overflow-x:auto;margin:8px 0;font-size:12.5px}
.bubble pre code{background:none;padding:0}
.msg.assistant .bubble{border-top-left-radius:5px}
.msg.user .bubble{border-top-right-radius:5px}
.msg-meta{display:flex;align-items:center;gap:9px;margin-top:5px;font-size:10.5px;color:var(--muted);opacity:.62;transition:.15s;height:16px}
.msg.user .msg-meta{justify-content:flex-end}
.msg:hover .msg-meta{opacity:1}
.msg-meta button{color:var(--muted);display:inline-flex;align-items:center;gap:3px;font-size:10.5px}
.msg-meta button:hover{color:var(--primary)}
.msg-meta svg{width:12px;height:12px}
.bubble.typing::after{content:"";display:inline-block;width:2px;height:15px;background:var(--primary);vertical-align:-3px;margin-left:3px;animation:blink .85s steps(1) infinite}
@keyframes blink{50%{opacity:0}}
.bubble.error{background:#fdf2f2;border-color:#f3d5d5;color:#a94143;white-space:pre-wrap;font-size:12.8px}
.thinking{margin-bottom:8px;border:1px dashed #ddd6ec;border-radius:10px;background:#faf8ff;color:#7c7390;font-size:11.8px}
.thinking summary{cursor:pointer;padding:6px 10px;list-style:none;user-select:none}
.thinking summary::-webkit-details-marker{display:none}
.thinking summary::before{content:"▸ ";color:var(--primary)}
.thinking[open] summary::before{content:"▾ "}
.thinking div{padding:2px 11px 9px;white-space:pre-wrap;line-height:1.6;max-height:190px;overflow:auto}

/* 存量会话异常提示 */
.notice{display:flex;align-items:center;gap:14px;justify-content:space-between;background:#fff8e8;border:1px solid #f0dfb4;color:#8a6a2f;border-radius:12px;padding:10px 14px;margin-bottom:18px;font-size:12px;line-height:1.6}
.notice button{flex:none;background:#fff;border:1px solid #e6cf9c;color:#8a6a2f;padding:5px 12px;border-radius:8px;font-size:11.5px;font-weight:600}
.notice button:hover{background:#fdf1d6}

/* 空状态 */
.welcome{max-width:560px;margin:0 auto;text-align:center;padding:44px 24px 12px;animation:pop .3s ease both}
.welcome-av{width:78px;height:78px;border-radius:24px;margin:0 auto 16px;display:grid;place-items:center;color:#fff;font-size:34px;font-weight:600;box-shadow:0 12px 28px rgba(70,55,120,.18);text-shadow:0 2px 4px rgba(0,0,0,.14)}
.welcome h3{margin:0 0 5px;font-size:20px;font-weight:650}
.welcome .w-sub{color:var(--muted);font-size:12.5px;margin:0 0 20px}
.welcome .tags{display:flex;justify-content:center;gap:6px;flex-wrap:wrap;margin-bottom:20px}
.welcome .tags span{font-size:11px;padding:3px 10px;border-radius:20px;background:#fff;border:1px solid var(--line);color:var(--sub)}
.welcome .greeting{background:#fff;border:1px solid var(--line);border-radius:16px;padding:16px 19px;font-size:14.5px;line-height:1.85;text-align:left;box-shadow:var(--shadow-sm);position:relative}
.welcome .greeting::before{content:"“";position:absolute;left:8px;top:-2px;font-size:26px;color:#d9d1f5}
.welcome .q-title{font-size:11.5px;color:var(--muted);margin:24px 0 10px;letter-spacing:1px}

/* ---------- 输入区 ---------- */
.composer{flex:none;padding:8px 22px 14px;background:linear-gradient(to top,var(--bg) 76%,rgba(245,243,240,0))}
.quick-row{display:flex;gap:7px;max-width:820px;margin:0 auto 9px;flex-wrap:wrap;padding:0 26px}
.quick-row button{font-size:11.5px;padding:5px 11px;border-radius:18px;background:#fff;border:1px solid var(--line);color:var(--sub);transition:.15s}
.quick-row button:hover{border-color:#c6baf5;color:var(--primary);background:#faf8ff}
.input-box{max-width:820px;margin:0 auto;display:flex;align-items:flex-end;gap:8px;background:#fff;border:1px solid var(--line);border-radius:16px;padding:8px 9px 8px 16px;box-shadow:var(--shadow);transition:.18s}
.input-box:focus-within{border-color:#bfb2f6;box-shadow:0 0 0 4px rgba(109,92,231,.09),var(--shadow)}
.input-box textarea{flex:1;resize:none;border:0;background:transparent;line-height:1.7;max-height:140px;min-height:26px;padding:3px 0;font-size:14px;overflow-y:auto}
.input-box textarea::placeholder{color:#b4aeb9}
.send-btn{width:36px;height:36px;border-radius:11px;background:var(--primary);color:#fff;display:grid;place-items:center;transition:.18s;flex:none}
.send-btn:hover{background:var(--primary-dark);transform:translateY(-1px)}
.send-btn:disabled{background:#d6d0e6;cursor:not-allowed;transform:none}
.send-btn svg{width:16px;height:16px}
.composer-hint{max-width:820px;margin:7px auto 0;padding:0 26px;display:flex;justify-content:space-between;font-size:10.5px;color:var(--muted)}

/* ---------- 设置 ---------- */
.settings-head{height:70px;flex:none;display:flex;align-items:center;justify-content:space-between;padding:0 18px;border-bottom:1px solid var(--line)}
.settings-head h3{margin:0;font-size:15px}
.settings-body{flex:1;overflow-y:auto;padding:16px 18px 24px;min-height:0}
.panel-card{border:1px solid var(--line);border-radius:13px;padding:13px 14px;background:var(--surface-2);margin-bottom:18px}
.status-card{background:#faf8ff;border-color:#e9e3fb}
.status-line{display:flex;align-items:center;gap:8px;font-size:13px}
.status-card p{margin:5px 0 8px;font-size:11.5px;color:var(--sub);line-height:1.6;word-break:break-word;white-space:pre-line}
.text-btn{display:inline-flex;align-items:center;gap:5px;color:var(--primary);font-size:11.5px;font-weight:600}
.text-btn:hover{text-decoration:underline}
.text-btn svg{width:13px;height:13px}
.info-card{margin-top:22px;margin-bottom:0}
.info-card strong{font-size:12.5px}
.info-card p{margin:6px 0 0;font-size:11.5px;color:var(--sub);line-height:1.7}
.field{margin-bottom:16px;min-width:0}
.field label{display:flex;justify-content:space-between;align-items:center;font-size:12px;font-weight:600;color:var(--sub);margin-bottom:7px}
.field label em{color:var(--danger);font-style:normal}
.field label output{font-weight:500;color:var(--primary);font-variant-numeric:tabular-nums}
.field input[type=text],.field input[type=number],.field select,.field textarea{
  width:100%;border:1px solid var(--line);background:var(--surface-2);border-radius:10px;padding:9px 11px;font-size:12.8px;transition:.16s
}
.field textarea{resize:vertical;line-height:1.65}
.field input:focus,.field select:focus,.field textarea:focus{border-color:#b9adf5;background:#fff;box-shadow:0 0 0 3px rgba(109,92,231,.09)}
.field input[type=range]{width:100%;accent-color:var(--primary);margin:4px 0}
.tip{font-size:10.8px;color:var(--muted);line-height:1.6;margin:6px 0 0}
.preset-row{display:flex;gap:6px;margin-top:7px}
.tiny-btn{flex:1;font-size:11px;padding:5px 6px;border:1px solid var(--line);border-radius:8px;color:var(--sub);background:#fff;transition:.15s}
.tiny-btn:hover{border-color:#c6baf5;color:var(--primary);background:#faf8ff}
.field-row{display:flex;gap:10px}
.field-row>.field{flex:1}

/* ---------- 弹窗 ---------- */
.modal-mask{position:fixed;inset:0;background:rgba(35,29,50,.42);backdrop-filter:blur(3px);z-index:40;display:grid;place-items:center;padding:20px}
.modal-mask[hidden]{display:none}
.modal{width:min(620px,100%);max-height:min(88vh,860px);background:var(--surface);border-radius:18px;box-shadow:0 24px 70px rgba(30,20,55,.25);display:flex;flex-direction:column;animation:pop .2s ease both}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:17px 22px;border-bottom:1px solid var(--line)}
.modal-head h3{margin:0;font-size:16px}
.modal-body{overflow-y:auto;padding:20px 22px;flex:1}
.modal-foot{display:flex;align-items:center;gap:9px;padding:14px 22px;border-top:1px solid var(--line)}
.modal-foot .spacer{flex:1}
.plain-btn{padding:9px 18px;border-radius:10px;border:1px solid var(--line);color:var(--sub);font-size:13px;background:#fff}
.plain-btn:hover{background:var(--surface-2)}
.danger-btn{padding:9px 14px;border-radius:10px;color:var(--danger);font-size:12.5px;background:#fdf2f2}
.danger-btn:hover{background:#fbe4e4}
.modal-foot .primary-btn{width:auto;padding:0 20px}
.color-row{display:flex;gap:7px;flex-wrap:wrap;padding:4px 0}
.color-dot{width:24px;height:24px;border-radius:8px;border:2px solid transparent;transition:.15s}
.color-dot.active{border-color:var(--text);transform:scale(1.08)}
.color-dot:hover{transform:scale(1.08)}

/* 应用内确认弹窗 */
.confirm-mask{z-index:55}
.confirm-box{width:min(380px,100%);background:var(--surface);border-radius:16px;padding:22px 24px 18px;box-shadow:0 24px 70px rgba(30,20,55,.25);animation:pop .2s ease both}
.confirm-box h3{margin:0 0 8px;font-size:16px}
.confirm-box p{margin:0 0 20px;font-size:12.8px;color:var(--sub);line-height:1.75}
.confirm-foot{display:flex;justify-content:flex-end;gap:9px}
.confirm-foot .plain-btn{padding:9px 18px}
.danger-solid{padding:9px 18px;border-radius:10px;background:var(--danger);color:#fff;font-size:13px;font-weight:600;transition:.15s}
.danger-solid:hover{background:#bf4648}

.toast{position:fixed;bottom:28px;left:50%;transform:translateX(-50%);background:#2d2a33;color:#fff;padding:10px 18px;border-radius:11px;font-size:12.5px;z-index:60;box-shadow:0 10px 30px rgba(0,0,0,.2);animation:pop .2s ease both;max-width:80vw;text-align:center}
.toast[hidden]{display:none}
.scrim{display:none}

/* ---------- 响应式 ---------- */
@media(max-width:1180px){
  .settings{position:fixed;right:0;top:0;bottom:0;z-index:20;transform:translateX(101%);transition:transform .24s ease;box-shadow:-12px 0 36px rgba(40,30,60,.13);width:310px}
  .app.settings-open .settings{transform:none}
  .app.settings-closed .settings{display:flex}
  .app.settings-open .scrim{display:block;position:fixed;inset:0;background:rgba(35,29,50,.24);z-index:19}
}
@media(max-width:760px){
  .mobile-only{display:grid !important}
  .sidebar{position:fixed;left:0;top:0;bottom:0;z-index:22;transform:translateX(-101%);transition:transform .24s ease;box-shadow:12px 0 36px rgba(40,30,60,.13);width:min(300px,86vw)}
  .app.sidebar-open .sidebar{transform:none}
  .app.sidebar-open .scrim{display:block;position:fixed;inset:0;background:rgba(35,29,50,.24);z-index:21}
  .chat-head{padding:0 12px;height:62px;gap:9px}
  .head-avatar{width:36px;height:36px;border-radius:11px;font-size:16px}
  .head-meta h2{font-size:14px}
  .status{display:none}
  .messages{padding-top:18px}
  .msg-wrap{padding:0 14px}
  .msg-main{max-width:84%}
  .composer{padding:6px 12px 12px}
  .quick-row,.composer-hint{padding:0 2px}
  .quick-row button:nth-child(n+4){display:none}
  .settings{width:min(310px,90vw)}
  .brand{padding:16px 14px 12px}
}

/* 账号信息 / 退出登录 */
.settings-head .user-badge{margin-left:auto;max-width:112px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11.5px;color:var(--muted);background:var(--surface-2);border:1px solid var(--line);padding:4px 9px;border-radius:20px}
.settings-head .logout-btn{border:0;background:transparent;cursor:pointer;padding:4px 2px;color:var(--muted)}
.settings-head .logout-btn:hover{color:var(--primary);text-decoration:none}

/* 后台配置入口卡片 */
.admin-card{background:#faf8ff;border-color:#e9e3fb}
.admin-card strong{font-size:12.5px;color:var(--primary)}
.admin-card p{margin:6px 0 10px;font-size:11.5px;color:var(--sub);line-height:1.6}
.admin-link{display:flex;text-decoration:none;font-size:12.5px}

