:root {
  --primary: #325bf3;
  --primary-weak: #eef2ff;
  --bg: #f6f7f9;
  --panel: #fff;
  --border: #e9eaee;
  --text: #1d2129;
  --sub: #8a919f;
  --danger: #f53f3f;
  --ok: #00b42a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 13px; color: var(--text); background: var(--bg);
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 52px; flex: 0 0 auto; display: flex; align-items: center; gap: 16px;
  padding: 0 18px; background: #fff; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.brand-logo {
  position: relative;
  width: 26px; height: 26px; border-radius: 7px; overflow: visible;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* 平台标识：抖音用图标，小红书用文字胶囊（横版字标缩到 16px 会糊） */
.platform-tag { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: 0 0 16px; }
.platform-tag img { width: 16px; height: 16px; object-fit: contain; display: block; }
.platform-tag.is-xhs {
  width: auto; flex: 0 0 auto; height: 15px; padding: 0 4px; border-radius: 3px;
  background: #ffe9e9; color: #ff2442; font-size: 10px; line-height: 15px; white-space: nowrap;
}
.brand-badge {
  position: absolute; top: -7px; right: -9px; display: none;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); border: 1.5px solid #fff; color: #fff;
  font-size: 10px; font-weight: 600; line-height: 13px; text-align: center;
}
.brand-badge.on { display: inline-block; }
.plugin-status { flex: 1; color: var(--sub); font-size: 12px; }
.plugin-status .on { color: var(--ok); }
.plugin-status .off { color: #ff7d7d; }
.top-right { display: flex; align-items: center; gap: 10px; }
.user { color: var(--sub); }
.link-btn { background: none; border: none; color: var(--sub); cursor: pointer; font-size: 13px; }
.link-btn:hover { color: var(--primary); }

/* ---------- 三栏 ---------- */
.layout { flex: 1; display: flex; min-height: 0; padding: 12px; gap: 12px; }
.col-left, .col-center, .col-right {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.col-left { width: 268px; flex: 0 0 268px; }
.col-center { flex: 1; min-width: 0; }
.col-right { width: 340px; flex: 0 0 340px; overflow-y: auto; }

/* ---------- 左栏 ---------- */
.left-head { padding: 12px 12px 8px; }
.filter-select {
  width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 8px; font-size: 12px; color: var(--text); background: #fff; outline: none;
}
.left-search { padding: 0 12px 8px; }
.left-search input {
  width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px; font-size: 12px; outline: none; background: #fafbfc;
}
.left-search input:focus { border-color: var(--primary); background: #fff; }
.left-count { padding: 0 14px 8px; color: var(--sub); font-size: 11px; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.conv-item {
  display: flex; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
}
.conv-item:hover { background: #f7f8fa; }
.conv-item.on { background: var(--primary-weak); }
.conv-avatar, .avatar-lg { position: relative; flex: 0 0 auto; }
.conv-avatar { width: 38px; height: 38px; }
.conv-avatar img, .avatar-lg img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: #eef0f4;
}
.avatar-fallback {
  width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 15px; background: #93a5f0;
}
.online-dot {
  position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok); border: 2px solid #fff;
}
.conv-main { flex: 1; min-width: 0; }
.conv-row1 { display: flex; align-items: center; gap: 6px; }
.conv-name {
  font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; min-width: 0;
}
.conv-time { color: var(--sub); font-size: 11px; flex: 0 0 auto; }
.conv-row2 { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.conv-last {
  color: var(--sub); font-size: 12px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; min-width: 0;
}
.unread-badge {
  background: var(--danger); color: #fff; border-radius: 9px; min-width: 18px; height: 18px;
  line-height: 18px; text-align: center; font-size: 11px; padding: 0 5px; flex: 0 0 auto;
}
.pending-dot { color: var(--primary); font-size: 11px; flex: 0 0 auto; }
.conv-item.fresh { animation: conv-flash 1.8s ease-out; }
@keyframes conv-flash {
  0%, 40% { background: #ffeff0; box-shadow: inset 3px 0 0 var(--danger); }
  100% { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}
.empty { padding: 30px 12px; text-align: center; color: var(--sub); font-size: 12px; }

/* ---------- 中栏 ---------- */
.chat-head {
  height: 64px; flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid var(--border);
}
.chat-head-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chat-title { font-size: 15px; font-weight: 600; }
.chat-sub { color: var(--sub); font-size: 12px; }
.chat-body { flex: 1; overflow-y: auto; padding: 20px 18px; background: #fbfcfd; }
.msg { display: flex; margin-bottom: 16px; }
.msg.peer { justify-content: flex-start; }
.msg.me { justify-content: flex-end; }
.msg-inner { max-width: 66%; }
.bubble {
  padding: 9px 12px; border-radius: 10px; line-height: 1.6; white-space: pre-wrap;
  word-break: break-word; display: inline-block; font-size: 13px;
}
.msg.peer .bubble { background: #fff; border: 1px solid var(--border); }
.msg.me .bubble { background: var(--primary); color: #fff; }
.msg.pending .bubble { background: var(--primary); color: #fff; opacity: .5; }
.msg-meta { font-size: 11px; color: var(--sub); margin-top: 4px; }
.msg.me .msg-meta { text-align: right; }
.phone-hit { background: #d9f7be; color: #237804; padding: 0 2px; border-radius: 2px; }
.msg.me .phone-hit { background: rgba(255, 255, 255, .28); color: #fff; }
.day-divider { text-align: center; color: var(--sub); font-size: 11px; margin: 6px 0 14px; }
.sys-tip {
  margin: 0 auto 14px; max-width: 78%; text-align: center; font-size: 12px; color: #a8700a;
  background: #fff7e6; border: 1px solid #ffe7ba; border-radius: 6px; padding: 6px 10px;
}

/* ---------- 输入区 ---------- */
.composer { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 10px 14px 12px; background: #fff; }
.quick-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.quick-chip {
  border: 1px solid var(--border); background: #fafbfc; border-radius: 14px; padding: 3px 10px;
  font-size: 12px; color: #4e5969; cursor: pointer;
}
.quick-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-weak); }
.composer textarea {
  width: 100%; height: 72px; resize: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-family: inherit; font-size: 13px; outline: none; line-height: 1.6;
}
.composer textarea:focus { border-color: var(--primary); }
.composer-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.send-tip { flex: 1; font-size: 12px; color: var(--sub); min-height: 18px; }
.send-tip.warn { color: #d46b08; }
.send-btn {
  width: 92px; height: 34px; border: none; border-radius: 8px; background: var(--primary);
  color: #fff; font-size: 13px; cursor: pointer;
}
.send-btn:disabled { background: #c9cdd4; cursor: not-allowed; }

/* ---------- 右栏 ---------- */
.panel-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; font-size: 11px; letter-spacing: .06em; color: var(--sub);
}
.save-flag { color: var(--ok); }
.save-flag.err { color: var(--danger); }
.profile-card { display: flex; gap: 12px; padding: 4px 16px 12px; align-items: center; }
.avatar-lg { width: 48px; height: 48px; }
.avatar-lg .avatar-fallback { font-size: 18px; }
.profile-id { min-width: 0; }
.profile-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-sub {
  color: var(--sub); font-size: 11px; margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 16px 14px;
  padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.stat { text-align: center; }
.stat b { display: block; font-size: 16px; font-weight: 600; }
.stat span { color: var(--sub); font-size: 11px; }
.prof-section { padding: 4px 16px 10px; }
.prof-section-title {
  font-size: 12px; font-weight: 600; margin: 8px 0; padding-left: 8px; position: relative; color: #4e5969;
}
.prof-section-title::before {
  content: ''; position: absolute; left: 0; top: 3px; width: 3px; height: 11px;
  background: var(--primary); border-radius: 2px;
}
.field { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.field > span { width: 62px; flex: 0 0 62px; color: var(--sub); font-size: 12px; }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; height: 32px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 8px; font-size: 12px; outline: none; font-family: inherit; background: #fff;
}
.field textarea { height: auto; padding: 6px 8px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field-inline { flex: 1; min-width: 0; display: flex; gap: 6px; }
.mini-btn {
  flex: 0 0 auto; height: 32px; padding: 0 10px; border-radius: 6px; border: none;
  background: var(--primary); color: #fff; font-size: 12px; cursor: pointer;
}
.mini-btn:hover { opacity: .9; }
.prof-foot {
  display: flex; gap: 10px; padding: 12px 16px 16px; border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: #fff;
}
.ghost-btn, .primary-btn { flex: 1; height: 34px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.ghost-btn { border: 1px solid var(--border); background: #fff; color: #4e5969; }
.primary-btn { border: none; background: var(--primary); color: #fff; }
.ghost-btn:disabled, .primary-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1280px) {
  .col-left { width: 232px; flex-basis: 232px; }
  .col-right { width: 300px; flex-basis: 300px; }
}
@media (max-width: 1000px) {
  .col-right { display: none; }
}

/* ---------- 登录/错误页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  gap: 56px; padding: 24px;
}
.login-art { width: 360px; flex: 0 0 auto; }
.login-art img { width: 100%; height: auto; display: block; }
@media (max-width: 860px) {
  .login-art { display: none; }
}
.login-box {
  width: 340px; max-width: 100%; background: #fff; padding: 28px; border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .06); border: 1px solid var(--border);
}
.login-box h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 18px; font-size: 18px; }
.login-box h2 img { width: 26px; height: 26px; object-fit: contain; }
.login-box label { display: block; margin-bottom: 4px; color: var(--sub); font-size: 12px; }
.login-box input[type="text"], .login-box input[type="password"] {
  width: 100%; height: 34px; margin-bottom: 12px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none;
}
.login-box input:focus { border-color: var(--primary); }
.login-box button {
  width: 100%; height: 36px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 14px; cursor: pointer;
}
.login-box .help-block { color: var(--danger); font-size: 12px; margin: -8px 0 8px; }
.error-box {
  max-width: 460px; margin: 12vh auto; background: #fff; padding: 28px; border-radius: 12px;
  text-align: center; border: 1px solid var(--border);
}
.error-box h2 { font-size: 30px; color: var(--primary); margin: 0 0 8px; }

/* 顶栏导航链接 */
.nav-link { color: var(--primary); text-decoration: none; font-size: 13px; margin-right: 6px; }
.nav-link:hover { text-decoration: underline; }
