/* ================================================================== */
/* 基础                                                                */
/* ================================================================== */
:root {
  --wx-green: #07c160;
  --wx-green-dark: #06ad56;
  --wx-green-soft: #e8f8ee;
  --self-bubble: #95ec69;
  --sidebar: #2e2e2e;
  --sidebar-hover: #3a3a3a;
  --sidebar-active: #424242;
  --bg: #f5f5f5;
  --panel: #ffffff;
  --border: #e7e7e7;
  --text: #191919;
  --text-2: #666666;
  --muted: #9a9a9a;
  --danger: #e64340;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

input, textarea {
  font: inherit;
  color: inherit;
}

.hidden { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .18); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .28); }
::-webkit-scrollbar-track { background: transparent; }

/* ================================================================== */
/* 登录 / 注册                                                         */
/* ================================================================== */
.auth-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% 8%, rgba(7, 193, 96, .12), transparent 60%),
    radial-gradient(800px 500px at 88% 92%, rgba(64, 158, 255, .10), transparent 60%),
    #f2f4f5;
}

.auth-card {
  width: 388px;
  max-width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 38px 34px 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .04);
}

.auth-brand { text-align: center; margin-bottom: 26px; }

.auth-logo {
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--wx-green);
}

.auth-slogan {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .5px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: #f4f5f6;
  border-radius: 9px;
  padding: 4px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  padding: 8px 0;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-2);
  transition: .18s;
}

.auth-tab.on {
  background: #fff;
  color: var(--wx-green);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

.field { display: block; margin-bottom: 16px; }

.field span {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid #e2e3e5;
  border-radius: 8px;
  background: #fafbfb;
  outline: none;
  transition: .18s;
}

.field input:focus {
  border-color: var(--wx-green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, .10);
}

.auth-error {
  min-height: 18px;
  margin: -4px 0 10px;
  color: var(--danger);
  font-size: 12px;
}

.btn-primary {
  background: var(--wx-green);
  color: #fff;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  transition: .18s;
}

.btn-primary:hover { background: var(--wx-green-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; transform: none; }

.auth-submit { width: 100%; height: 44px; font-size: 15px; }

.auth-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  color: #b3b3b3;
  line-height: 1.7;
}

/* ================================================================== */
/* 应用骨架                                                            */
/* ================================================================== */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: 302px;
  flex: 0 0 302px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--sidebar);
  color: #ececec;
  user-select: none;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 10px;
}

.me-avatar {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  font-size: 16px;
}

.me-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-actions { display: flex; gap: 2px; }

.side-btn {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9b9b9;
  transition: .15s;
}

.side-btn:hover { background: rgba(255, 255, 255, .10); color: #fff; }

.search {
  margin: 2px 12px 10px;
  height: 30px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  background: #262626;
  border-radius: 5px;
  color: #7d7d7d;
}

.search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #ddd;
  font-size: 12px;
}

.search input::placeholder { color: #777; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background .12s;
}

.chat-item:hover { background: var(--sidebar-hover); }
.chat-item.active { background: var(--sidebar-active); }

.chat-item .avatar {
  width: 43px;
  height: 43px;
  font-size: 17px;
  border-radius: 6px;
}

.chat-info { flex: 1; min-width: 0; }

.chat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chat-name {
  font-size: 13.5px;
  color: #ededed;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  flex: none;
  font-size: 10.5px;
  color: #808080;
}

.chat-preview {
  margin-top: 4px;
  font-size: 11.5px;
  color: #929292;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 26px;
}

.unread {
  position: absolute;
  right: 13px;
  bottom: 11px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: #fa5151;
  color: #fff;
  font-size: 10px;
  line-height: 17px;
  text-align: center;
}

.list-empty {
  padding: 40px 20px;
  text-align: center;
  color: #767676;
  font-size: 12px;
  line-height: 1.8;
}

.sidebar-foot {
  flex: none;
  padding: 9px 14px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: 10.5px;
  color: #6f6f6f;
  text-align: center;
  letter-spacing: .2px;
}

/* ================================================================== */
/* 聊天区域                                                            */
/* ================================================================== */
.chat-pane {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #b9b9b9;
  gap: 8px;
}

.empty-badge {
  width: 86px;
  height: 86px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #c9c9c9;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .05);
  margin-bottom: 8px;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: #a9a9a9;
  letter-spacing: 2px;
}

.empty-sub { font-size: 12px; color: #bdbdbd; }

.chat-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-header {
  flex: none;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.chat-title { min-width: 0; }

.chat-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-title span {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  color: var(--muted);
}

.chat-actions { margin-left: auto; position: relative; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 5px;
  font-size: 20px;
  line-height: 1;
  color: #6b6b6b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: #e8e8e8; }

.menu {
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 132px;
  padding: 5px;
  background: #fff;
  border-radius: 7px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  z-index: 30;
}

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text);
}

.menu button:hover { background: #f4f4f4; }
.menu button.danger { color: var(--danger); }

.back-btn {
  display: none;
  width: 30px;
  height: 34px;
  margin-left: -8px;
  font-size: 28px;
  line-height: 1;
  color: #555;
  border-radius: 5px;
}

.back-btn:hover { background: #e8e8e8; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 22px 18px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

.messages::before {
  content: "";
  display: block;
  flex: 0 0 auto;
  margin-top: auto;
}

.messages > * { flex: 0 0 auto; }

.messages.is-empty { justify-content: center; }
.messages.is-empty::before { display: none; }

.loading-tip,
.empty-chat {
  padding: 60px 0;
  text-align: center;
  color: #b5b5b5;
  font-size: 12px;
}

.load-more {
  display: block;
  margin: 4px auto 12px;
  padding: 5px 15px;
  border-radius: 14px;
  background: #fff;
  color: #8a8a8a;
  font-size: 11.5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.load-more:hover { color: var(--wx-green); }

.time-sep {
  margin: 16px 0 10px;
  text-align: center;
  font-size: 11px;
  color: #b0b0b0;
}

.system-msg {
  margin: 10px auto;
  max-width: 70%;
  text-align: center;
  font-size: 11.5px;
  color: #a8a8a8;
  line-height: 1.6;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 14px 0;
}

.msg.self { flex-direction: row-reverse; }

.msg .avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
  border-radius: 5px;
}

.msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(62%, 560px);
  min-width: 0;
}

.msg.self .msg-body { align-items: flex-end; }

.msg-sender {
  margin: 0 4px 4px;
  font-size: 11px;
  color: #9c9c9c;
}

.bubble {
  position: relative;
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .035);
}

.msg.self .bubble { background: var(--self-bubble); }

.bubble::after {
  content: "";
  position: absolute;
  top: 12px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
}

.msg.other .bubble::after {
  left: -11px;
  border-right-color: #fff;
}

.msg.self .bubble::after {
  right: -11px;
  border-left-color: var(--self-bubble);
}

.msg-img {
  display: block;
  max-width: 240px;
  max-height: 320px;
  border-radius: 4px;
  margin: 4px 0;
  cursor: zoom-in;
  background: #f2f2f2;
}

.bubble .msg-img:first-child { margin-top: 0; }
.bubble .msg-img:last-child { margin-bottom: 0; }

.msg-actions {
  height: 16px;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity .15s;
}

.msg:hover .msg-actions { opacity: 1; }

.star-btn {
  font-size: 14px;
  line-height: 1;
  color: #c2c2c2;
  padding: 1px 2px;
}

.star-btn:hover { color: #f0a020; }
.star-btn.on { color: #f0a020; }

/* 输入区 */
.composer {
  flex: none;
  padding: 8px 18px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.attach-strip {
  display: flex;
  gap: 8px;
  padding: 4px 0 8px;
  flex-wrap: wrap;
}

.attach-item {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 6px;
  overflow: hidden;
  background: #e8e8e8;
  border: 1px solid #ddd;
}

.attach-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-item .attach-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .35);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.attach-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  line-height: 17px;
  text-align: center;
}

.attach-remove:hover { background: rgba(0, 0, 0, .75); }

.composer textarea {
  display: block;
  width: 100%;
  min-height: 26px;
  max-height: 140px;
  padding: 3px 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.55;
}

.composer textarea::placeholder { color: #b6b6b6; }

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 2px;
}

.hint {
  margin-right: auto;
  font-size: 10.5px;
  color: #b6b6b6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.send-btn {
  flex: none;
  padding: 6px 24px;
  border-radius: 4px;
  background: var(--wx-green);
  color: #fff;
  font-size: 13px;
  transition: .15s;
}

.send-btn:hover { background: var(--wx-green-dark); }
.send-btn:disabled { opacity: .5; cursor: default; }

/* ================================================================== */
/* 弹窗                                                                */
/* ================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .38);
  animation: fade-in .15s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 430px;
  max-width: 100%;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
  animation: pop-in .18s ease;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.modal-wide { width: 560px; }
.modal-sm { width: 380px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.counter {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  font-size: 20px;
  line-height: 1;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: #f2f2f2; color: #555; }

.text-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  margin-bottom: 14px;
  border: 1px solid #e2e3e5;
  border-radius: 7px;
  background: #fafbfb;
  outline: none;
}

.text-input:focus {
  border-color: var(--wx-green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, .10);
}

.picker-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.picker-label span { color: #b0b0b0; }

.user-picker {
  flex: 1;
  min-height: 120px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 6px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 6px;
  cursor: pointer;
}

.user-row:hover { background: #f6f7f8; }

.user-row .avatar {
  width: 32px;
  height: 32px;
  font-size: 13px;
  border-radius: 5px;
}

.user-row .u-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--wx-green);
  cursor: pointer;
}

.user-row .u-arrow { color: #c5c5c5; font-size: 16px; }

.picker-empty {
  padding: 32px 10px;
  text-align: center;
  color: #b5b5b5;
  font-size: 12px;
}

.picker-search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px;
  margin-bottom: 10px;
  border: 1px solid #e7e7e7;
  border-radius: 7px;
  background: #fafbfb;
  color: #aaa;
}

.picker-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.btn-ghost {
  padding: 9px 18px;
  border-radius: 7px;
  background: #f2f3f4;
  color: #555;
  font-size: 13px;
}

.btn-ghost:hover { background: #e9eaeb; }

.btn-danger {
  padding: 9px 18px;
  border-radius: 7px;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
}

.btn-danger:hover { background: #cf3b38; }

.confirm-text {
  margin: 2px 0 6px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
}

/* 收藏列表 */
.fav-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.fav-empty {
  padding: 56px 20px;
  text-align: center;
  color: #b5b5b5;
  font-size: 12px;
  line-height: 2;
}

.fav-item {
  padding: 12px 13px;
  margin-bottom: 8px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fcfcfc;
}

.fav-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  color: #a3a3a3;
  margin-bottom: 6px;
}

.fav-meta .fav-chat {
  color: var(--wx-green);
  font-weight: 500;
}

.fav-meta .fav-del {
  margin-left: auto;
  color: #bbb;
  font-size: 11px;
}

.fav-meta .fav-del:hover { color: var(--danger); }

.fav-content {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.fav-content .msg-img {
  max-width: 180px;
  max-height: 220px;
  margin: 4px 0;
}

/* ================================================================== */
/* Toast                                                               */
/* ================================================================== */
.toast-wrap {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 9px 18px;
  border-radius: 7px;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  animation: toast-in .18s ease;
  max-width: 80vw;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.toast.out { opacity: 0; transition: opacity .25s; }

/* ================================================================== */
/* 移动端                                                              */
/* ================================================================== */
@media (max-width: 760px) {
  .sidebar {
    width: 100%;
    flex-basis: 100%;
    padding-top: env(safe-area-inset-top);
  }

  .chat-pane {
    position: fixed;
    inset: 0;
    z-index: 40;
    transform: translateX(100%);
    transition: transform .22s ease;
    padding-top: env(safe-area-inset-top);
  }

  .app.chat-open .chat-pane { transform: none; }

  .back-btn { display: flex; align-items: center; justify-content: center; }

  .chat-header { padding: 0 14px; }
  .messages { padding: 10px 14px 16px; }

  .msg-body { max-width: 74%; }

  .msg-img {
    max-width: min(220px, 46vw);
    max-height: 260px;
  }

  .composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }

  .hint { display: none; }

  .msg:hover .msg-actions { opacity: 0; }
  .msg.show-actions .msg-actions { opacity: 1; }

  .modal { max-height: 88vh; }
  .modal-wide { width: 100%; }
}
