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

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --sidebar: #1f2937;
  --sidebar2: #273346;
  --ink: #1a2233;
  --muted: #7a8494;
  --brand: #b8860b;
  --brand2: #8a6a1b;
  --accent: #2563eb;
  --line: #e5e8ee;
  --ai-bubble: #ffffff;
  --me-bubble: #dfe9ff;
  --radius: 12px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ Sidebar ============ */
.sidebar {
  width: 290px;
  min-width: 290px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar2));
  color: #e6e9f0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 12px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #d4a92c);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff; flex-shrink: 0;
}
.brand h1 { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand p { font-size: 11px; color: #9aa4b5; margin-top: 2px; }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mode-btn {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: #cfd5e0; padding: 9px 6px; border-radius: 9px; cursor: pointer;
  font-size: 13px; transition: .15s;
}
.mode-btn:hover { background: rgba(255,255,255,.12); }
.mode-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.new-chat-btn {
  background: rgba(255,255,255,.08); border: 1px dashed rgba(255,255,255,.22);
  color: #fff; padding: 9px; border-radius: 9px; cursor: pointer; font-size: 13px;
}
.new-chat-btn:hover { background: rgba(255,255,255,.15); }

.panel { display: flex; flex-direction: column; min-height: 0; }
.panel.grow { flex: 1; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 6px; font-size: 13px; font-weight: 600; color: #c6cdda; cursor: pointer;
}
.caret { transition: transform .15s; display: inline-block; }
.panel.open .caret { transform: rotate(90deg); }
.panel-body { display: none; padding: 0 2px; }
.panel.open .panel-body { display: block; }

.tmpl-item, .hist-item {
  width: 100%; text-align: left; background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07); color: #dbe1ec;
  border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer;
  font-size: 12.5px; line-height: 1.4; transition: .15s;
}
.tmpl-item:hover, .hist-item:hover { background: rgba(255,255,255,.12); }
.tmpl-item .tag { display: inline-block; font-size: 10px; background: rgba(184,134,11,.4); border-radius: 4px; padding: 1px 6px; margin-right: 6px; }
.hist-item .h-time { display: block; font-size: 10.5px; color: #8b96a7; margin-top: 2px; }
.hist-empty { font-size: 12px; color: #8b96a7; padding: 6px; }

.footer-note { border-top: 1px solid rgba(255,255,255,.08); padding-top: 10px; font-size: 11px; color: #93a0b0; line-height: 1.6; }
#status { margin-top: 4px; }
#status.ok { color: #7dd3a5; }
#status.bad { color: #f4a0a0; }

/* ============ Main chat ============ */
.main {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(184,134,11,.07), transparent 60%),
    radial-gradient(900px 420px at 95% 0%, rgba(37,99,235,.055), transparent 55%),
    linear-gradient(180deg, #fafbfc, #f4f6f9);
}
.chat-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 7%; 
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(20,30,60,.08);
}
.ct-back {
  display: none; width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 16px;
}
.ct-back:hover { border-color: var(--brand); color: var(--brand2); }
.ct-avatar {
  width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: linear-gradient(135deg, var(--fc, #2563eb), color-mix(in srgb, var(--fc, #2563eb) 50%, #fff));
  box-shadow: 0 5px 12px color-mix(in srgb, var(--fc, #2563eb) 32%, transparent);
}
.ct-name { font-weight: 700; font-size: 15px; color: #26303f; }
.ct-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #35a070; margin-top: 2px; }
.ct-status .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #34c77b;
  box-shadow: 0 0 0 0 rgba(52,199,123,.5); animation: pulseDot 2s infinite;
}
@keyframes pulseDot { 0% { box-shadow: 0 0 0 0 rgba(52,199,123,.45);} 70% { box-shadow: 0 0 0 6px rgba(52,199,123,0);} 100% { box-shadow: 0 0 0 0 rgba(52,199,123,0);} }

.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: 26px 7%; scroll-behavior: smooth; }
.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: #d3d9e3; border-radius: 8px; }
.chat::-webkit-scrollbar-thumb:hover { background: #adb6c4; }
.chat::-webkit-scrollbar-track { background: transparent; }

.empty { text-align: center; margin: auto; padding: 30px 0; max-width: 600px; }
.empty-icon {
  width: 96px; height: 96px; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center; font-size: 46px;
  border-radius: 30px; background: linear-gradient(135deg, #fff, #f7f1dd);
  border: 1px solid #ecdfae; box-shadow: 0 16px 34px rgba(184,134,11,.16);
  animation: floaty 4.5s ease-in-out infinite;
}
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.empty h2 { font-size: 24px; margin-bottom: 8px; color: #2b3344; }
.empty p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.action-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 18px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 2px 6px rgba(20,30,60,.05); transition: .16s;
}
.action-card:hover { border-color: var(--brand); box-shadow: 0 10px 22px rgba(184,134,11,.2); transform: translateY(-2px); }
.empty-samples { font-size: 13px; color: var(--muted); }
.sample-chip {
  background: #fff; border: 1px solid var(--line); border-radius: 999px; color: var(--accent);
  padding: 7px 14px; font-size: 12.5px; margin: 6px 4px 0; cursor: pointer;
  box-shadow: 0 1px 3px rgba(20,30,60,.04); transition: .15s;
}
.sample-chip:hover { border-color: var(--accent); background: #eff5ff; transform: translateY(-1px); }

.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 88%; align-self: flex-start; animation: msgIn .3s cubic-bezier(.2,.7,.3,1); }
.msg.me { max-width: 80%; align-self: flex-end; flex-direction: row-reverse; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.msg-avatar {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0; margin-top: 20px;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: linear-gradient(135deg, var(--fc, #2563eb), color-mix(in srgb, var(--fc, #2563eb) 48%, #fff));
  box-shadow: 0 4px 10px color-mix(in srgb, var(--fc, #2563eb) 30%, transparent);
}
.msg.me .msg-avatar {
  background: linear-gradient(135deg, #4770e6, #7a95f0);
  box-shadow: 0 4px 10px rgba(71,112,230,.32);
  color: #fff; font-weight: 700; font-size: 13.5px;
}

.msg-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg.me .msg-body { align-items: flex-end; }

.who { display: flex; align-items: baseline; gap: 8px; margin: 0 4px 5px; }
.who-name { font-size: 12.5px; font-weight: 600; color: #6b7688; }
.who-time { font-size: 10.5px; color: #abb2c0; }
.msg.me .who-name { color: #5b79d6; }
.msg.me .who { flex-direction: row-reverse; }

.bubble {
  padding: 12px 16px; border-radius: 4px 16px 16px 16px;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(20,30,60,.07);
  font-size: 14.5px; line-height: 1.78; color: #26303f;
}
.msg.me .bubble {
  border-radius: 16px 4px 16px 16px;
  background: linear-gradient(135deg, #4f7cf0, #3564e0);
  color: #fff; border: none; box-shadow: 0 4px 14px rgba(53,100,224,.25);
  white-space: pre-wrap; word-break: break-word;
}
.msg.me .bubble strong { color: #fff; }
.msg.me .bubble h1 { border-color: rgba(255,255,255,.3); color: #fff; }
.msg.me .bubble h2, .msg.me .bubble h3 { color: #fff; }
.msg.me .bubble blockquote { background: rgba(255,255,255,.14); border-color: #fff; color: #f2f5ff; }
.msg.me .bubble code { background: rgba(255,255,255,.18); color: #fff; }
.msg.me .bubble pre code { background: transparent; color: inherit; }
.msg.me .bubble th, .msg.me .bubble td { border-color: rgba(255,255,255,.28); }
.msg.me .bubble th { background: rgba(255,255,255,.12); }

.doc-meta { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; opacity: 0; transition: opacity .2s; }
.msg.ai .bubble:hover .doc-meta { opacity: 1; }
.doc-badge { background: #fdf3d8; color: var(--brand2); font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.doc-btn {
  background: #fff; border: 1px solid var(--line); color: var(--ink); border-radius: 7px;
  font-size: 11.5px; padding: 3px 10px; cursor: pointer; transition: .15s;
}
.doc-btn:hover { border-color: var(--brand); color: var(--brand2); background: #fdfbf3; }

.bubble h1, .bubble h2, .bubble h3 { margin: 10px 0 6px; }
.bubble h1 { font-size: 19px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.bubble h2 { font-size: 16px; }
.bubble h3 { font-size: 14.5px; }
.bubble p { margin: 6px 0; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble strong { color: #14397a; }
.bubble blockquote { border-left: 3px solid var(--brand); background: #faf7ec; padding: 6px 12px; margin: 8px 0; color: #5a4a1a; border-radius: 0 6px 6px 0; }
.bubble code { background: #f0f2f6; border-radius: 4px; padding: 1px 5px; font-size: 13px; font-family: ui-monospace, Menlo, monospace; }
.bubble pre { background: #232b38; color: #e6e9f0; border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.bubble pre code { background: transparent; color: inherit; }
.bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 13.5px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.bubble th { background: #f4f6fa; }

/* ============ Input area ============ */
.input-area {
  padding: 8px 7% 16px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.85) 34%);
}
.mode-hint { font-size: 12.5px; color: var(--brand2); background: #fdf3d8; border-radius: 12px 12px 0 0; padding: 8px 14px; display: none; border: 1px solid #ecd9a8; border-bottom: none; }
.input-row {
  display: flex; align-items: flex-end; background: #fff; border: 1px solid rgba(20,30,60,.1);
  border-radius: 16px; padding: 6px 6px 6px 14px;
  box-shadow: 0 4px 18px rgba(20,30,60,.08);
  transition: border-color .2s, box-shadow .2s;
}
.input-row:focus-within { border-color: #c9a84f; box-shadow: 0 8px 26px rgba(184,134,11,.2); }
#input { flex: 1; border: none; outline: none; resize: none; font-size: 14.5px; line-height: 1.6; font-family: inherit; max-height: 150px; padding: 8px 0; background: transparent; }
#sendBtn {
  width: 42px; height: 42px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, #c9a84f, #d4a92c); color: #fff; font-size: 17px; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(184,134,11,.4); transition: .15s;
}
#sendBtn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); }
#sendBtn:disabled { opacity: .45; cursor: not-allowed; }
.input-tip { font-size: 11px; color: var(--muted); text-align: center; margin-top: 7px; letter-spacing: .2px; }

/* 打字指示器 */
.typing-indicator { display: inline-flex; gap: 5px; align-items: center; }
.typing-indicator i { width: 7px; height: 7px; border-radius: 50%; background: #b9c2cf; animation: bump 1.1s ease-in-out infinite; }
.typing-indicator i:nth-child(2) { animation-delay: .15s; }
.typing-indicator i:nth-child(3) { animation-delay: .3s; }
@keyframes bump { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }
.typing-row { display: flex; align-items: center; gap: 10px; }
.typing-text { font-size: 13px; color: #98a1b0; }

/* ============ Modal ============ */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; }
.modal {
  position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(680px, 92vw); max-height: 84vh; background: #fff; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15,23,42,.35); display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-close { border: none; background: transparent; font-size: 16px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { background: #f0f2f6; }
.modal-body { padding: 16px 20px; overflow-y: auto; }

.tmpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tmpl-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; transition: .15s; background: #fff; text-align: left; }
.tmpl-card:hover { border-color: var(--brand); background: #fdfbf3; }
.tmpl-card .t-name { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.tmpl-card .t-cat { font-size: 10.5px; color: var(--brand2); background: #fdf3d8; display: inline-block; border-radius: 4px; padding: 1px 7px; margin-bottom: 5px; }
.tmpl-card .t-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #45506a; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 13.5px; font-family: inherit; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { min-height: 56px; resize: vertical; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), #d4a92c); color: #fff; border: none;
  padding: 10px 20px; border-radius: 9px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); padding: 10px 18px; border-radius: 9px; font-size: 14px; cursor: pointer; }
.btn-ghost:hover { border-color: var(--brand); }

.modal-preview { white-space: pre-wrap; background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12.5px; max-height: 300px; overflow-y: auto; line-height: 1.7; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

.hidden { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .chat-topbar { padding: 8px 4%; }
  .ct-back { display: flex; align-items: center; justify-content: center; }
  .chat, .input-area { padding-left: 4%; padding-right: 4%; }
  .msg { max-width: 94%; }
  .msg.me { max-width: 88%; }
  .tmpl-grid { grid-template-columns: 1fr; }
}
/* ============ 视图 & 登录 ============ */
.view { display: flex; flex-direction: column; height: 100vh; width: 100%; overflow: hidden; }
.view.hidden { display: none; }
#chatView { flex-direction: row; }

#loginView { align-items: center; justify-content: center; background: radial-gradient(1000px 500px at 20% -10%, #273246, #141a26); }
.login-card {
  background: #fff; border-radius: 22px; padding: 46px 40px 40px; width: min(400px, 92vw);
  text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.login-logo { font-size: 52px; margin-bottom: 14px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px;
  font-size: 14px; outline: none; width: 100%;
}
.login-form input:focus { border-color: var(--brand); }
.login-form button { width: 100%; }
.login-msg { margin-top: 12px; font-size: 13px; color: #c0392b; min-height: 18px; }

/* ============ 朋友选择视图 ============ */
.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; background: #fff; border-bottom: 1px solid var(--line);
}
.btn-ghost.dark { padding: 9px 16px; }

.picker-main { flex: 1; overflow-y: auto; padding: 34px 6%; background: var(--bg); }
.picker-main h2 { font-size: 20px; margin-bottom: 22px; color: #33405c; }

.friend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; max-width: 1100px; margin: 0 auto; }

.friend-card {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 20px 20px; text-align: center; cursor: pointer;
  transition: .18s; box-shadow: 0 1px 3px rgba(20,30,60,.05);
}
.friend-card:hover { border-color: var(--brand); transform: translateY(-3px); box-shadow: 0 12px 28px rgba(184,134,11,.16); }
.add-card { border-style: dashed; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 200px; }
.add-card .add-plus { font-size: 34px; color: #b6bfce; }
.add-card:hover { color: var(--brand2); border-color: var(--brand); }
.add-card:hover .add-plus { color: var(--brand); }

.fc-actions { position: absolute; top: 10px; right: 12px; display: none; gap: 6px; }
.friend-card:hover .fc-actions { display: flex; }
.fc-edit, .fc-del {
  background: #fff; border: 1px solid var(--line); border-radius: 7px; width: 26px; height: 26px;
  font-size: 12px; cursor: pointer; color: var(--muted); line-height: 1;
}
.fc-edit:hover { color: var(--accent); border-color: var(--accent); }
.fc-del:hover { color: #c0392b; border-color: #c0392b; }

.friend-avatar {
  width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--fc, #2563eb), color-mix(in srgb, var(--fc, #2563eb) 55%, #fff));
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--fc, #2563eb) 35%, transparent);
}
.fc-name { font-weight: 700; font-size: 16.5px; margin-bottom: 2px; }
.fc-title { font-size: 12px; color: var(--brand2); margin-bottom: 8px; }
.fc-desc { font-size: 12.5px; color: var(--muted); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ============ 聊天视图头部 ============ */
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 6px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.back-btn {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: #cfd5e0;
  border-radius: 9px; width: 34px; height: 34px; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,.14); }
.chat-head .friend-avatar { width: 42px; height: 42px; font-size: 20px; margin: 0; flex-shrink: 0; box-shadow: none; }
.head-name { font-weight: 700; font-size: 15px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-title { font-size: 11px; color: #9aa4b5; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ 弹窗表单 ============ */
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-tip { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.emoji-input { text-align: center; font-size: 20px; }
.modal-foot .btn-ghost, .modal-foot .btn-primary { margin: 0; }

@media (max-width: 820px) {
  .picker-main { padding: 24px 4%; }
  .friend-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .field-row { flex-direction: column; gap: 0; }
}

/* ============ 模型切换与角标 ============ */
.picker-actions { display: flex; gap: 8px; }
.model-row { display: flex; gap: 6px; align-items: center; padding: 4px 2px 9px; flex-wrap: wrap; }
.m-chip {
  border-radius: 999px; padding: 5px 12px; font-size: 11.5px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  box-shadow: 0 1px 3px rgba(20,30,60,.04); transition: .15s;
}
.m-chip b { font-weight: 700; margin-right: 5px; }
.m-chip:hover { border-color: var(--brand); }
.m-chip.active { background: #233249; border-color: #233249; color: #fff; }
.m-chip.active b { color: #fff; }
.m-chip.no-key { opacity: .5; }
.m-chip.no-key.active { opacity: 1; }

.model-badge {
  display: inline-block; margin-left: auto; padding: 1px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .5px;
  color: var(--mc, #2563eb);
  background: color-mix(in srgb, var(--mc, #2563eb) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--mc, #2563eb) 25%, #fff);
}
.msg.me .who .model-badge { display: none; }

.takeover-note {
  font-size: 11.5px; color: #8a6a1b; background: #fdf3d8; border: 1px solid #ecd9a8;
  border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; line-height: 1.5;
}
.msg.me .bubble .takeover-note { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.4); color: #f5eec9; }

/* 模型设置弹窗 */
.model-edit-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.me-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.me-name { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.me-name small { color: var(--muted); font-weight: 400; }
.me-dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.me-toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.me-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.me-grid .field input { font-size: 12.5px; }

/* ============ 登录/注册 ============ */
.login-tabs { display: flex; gap: 6px; background: #eef1f6; border-radius: 11px; padding: 4px; margin-bottom: 18px; }
.ltab {
  flex: 1; padding: 9px; border: none; background: transparent; border-radius: 8px;
  cursor: pointer; font-size: 13.5px; color: var(--muted); font-weight: 600; transition: .15s;
}
.ltab:hover { color: var(--ink); }
.ltab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 5px rgba(20,30,60,.14); }
.whoami { align-self: center; font-size: 12.5px; color: #aeb6c4; font-weight: 600; padding: 0 4px; }

/* ============ 附件 ============ */
.attach-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 2px 8px; }
.attach-chip {
  display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 8px; box-shadow: 0 1px 4px rgba(20,30,60,.05); max-width: 240px;
}
.attach-thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.attach-ico { font-size: 20px; width: 34px; height: 34px; display:flex; align-items:center; justify-content:center; flex-shrink:0; background:#f1f3f7; border-radius: 6px; }
.attach-meta { min-width: 0; }
.attach-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.attach-size { font-size: 10.5px; color: var(--muted); }
.attach-x {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 3px 5px; border-radius: 6px; flex-shrink: 0;
}
.attach-x:hover { background: #fbeaeb; color: #c0392b; }

#attachBtn {
  border: none; background: transparent; font-size: 19px; cursor: pointer;
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; color: #94a0b4;
  transition: .15s;
}
#attachBtn:hover { background: #f1f3f7; color: var(--brand2); }

.drop-overlay {
  position: fixed; inset: 0; z-index: 200; pointer-events: none;
  background: rgba(18,28,48,.35); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.drop-inner {
  background: rgba(255,255,255,.96); border: 2px dashed var(--brand); border-radius: 16px;
  padding: 26px 40px; font-size: 16px; font-weight: 700; color: var(--brand2);
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
}

.msg-files { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.msg-file-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px;
  background: #f1f5ff; color: #3b57a8; border: 1px solid #d9e3fb; border-radius: 999px; padding: 3px 10px;
}
.msg.me .bubble .msg-file-chip { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.4); color: #fff; }

/* ============ 读图摘要（Kimi 转录 → 模型分析） ============ */
.vision-note {
  border: 1px solid #e0d0ff; background: linear-gradient(180deg, #f7f2ff, #fbf7ff);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 12.5px; line-height: 1.6;
}
.vn-title { font-weight: 700; color: #6b3fb5; margin-bottom: 4px; }
.vn-body { color: #5c4a7a; white-space: pre-wrap; word-break: break-word; }
.msg.me .bubble .vision-note { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.35); }
.msg.me .bubble .vn-title { color: #efe6ff; }
.msg.me .bubble .vn-body { color: #f0ebfb; }
