/* 微聊 —— WeChat 风格 */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* hidden 属性必须永远生效（覆盖元素自身的 display 规则），否则多个页面会同时显示挤在一起 */
[hidden] { display: none !important; }
:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --bg: #ededed;
  --panel: #fff;
  --line: #e5e5e5;
  --text: #191919;
  --text2: #888;
  --bubble-me: #95ec69;
  --nav-bg: #2e2e2e;
  --danger: #e64340;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; outline: none; }

/* ---------- 通用按钮 ---------- */
.btn-primary {
  background: var(--green); color: #fff; border-radius: 6px;
  padding: 10px 18px; font-size: 14px; font-weight: 500;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { background: #b7e5c9; cursor: not-allowed; }
.btn-ghost {
  border: 1px solid var(--line); border-radius: 6px; padding: 9px 14px;
  background: #fff; color: var(--green); font-size: 13px; white-space: nowrap;
}
.btn-block {
  display: block; width: 100%; text-align: left; background: #fff;
  padding: 15px 18px; border-radius: 10px; margin-bottom: 10px; font-size: 15px;
  border-bottom: 1px solid var(--line); border-radius: 0;
}
.btn-block:hover { background: #f7f7f7; }
.me-actions .btn-block:first-child { border-radius: 10px 10px 0 0; }
.btn-danger { color: var(--danger); }
.mini-btn {
  width: 28px; height: 28px; border-radius: 6px; background: rgba(0,0,0,.05);
  font-size: 17px; line-height: 1; color: #444;
}
.mini-btn:hover { background: rgba(0,0,0,.1); }
.icon-btn { font-size: 22px; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { background: rgba(0,0,0,.06); }

/* ---------- 登录页 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #d7f2e2 0%, #ededed 55%, #dcecf7 100%);
  padding: 20px;
}
.auth-card {
  width: 400px; max-width: 100%; background: #fff; border-radius: 16px;
  padding: 36px 34px 26px; box-shadow: 0 12px 40px rgba(0,0,0,.10);
}
.auth-logo { text-align: center; margin-bottom: 20px; }
.logo-badge {
  width: 62px; height: 62px; margin: 0 auto 10px; border-radius: 16px;
  background: var(--green); color: #fff; font-size: 30px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.auth-logo h1 { font-size: 22px; }
.auth-sub { color: var(--text2); font-size: 13px; margin-top: 4px; }
.auth-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 10px 2px; font-size: 13px; color: var(--text2);
  border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }
.auth-pane { display: flex; flex-direction: column; gap: 12px; }
.auth-pane input {
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; font-size: 14px;
}
.auth-pane input:focus { border-color: var(--green); }
.otp-row { display: flex; gap: 8px; }
.otp-row input { flex: 1; }
.auth-pane .btn-primary { width: 100%; }
.auth-error { color: var(--danger); font-size: 13px; text-align: center; }
.auth-tip { color: var(--text2); font-size: 12px; text-align: center; margin-top: 14px; }
.auth-link { color: var(--text2); font-size: 13px; padding: 2px; }
.auth-link:hover { color: var(--green); }

/* ---------- 主框架 ---------- */
#app-view { display: flex; height: 100vh; overflow: hidden; }
#nav {
  width: 64px; background: var(--nav-bg); display: flex; flex-direction: column;
  align-items: center; padding-top: 18px; gap: 8px; flex-shrink: 0;
}
.nav-btn {
  position: relative; width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #9a9a9a;
}
.nav-btn:hover { color: #cfcfcf; }
.nav-btn.active { color: var(--green); }
.nav-badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px;
  background: var(--danger); color: #fff; border-radius: 8px; font-size: 11px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
#main { flex: 1; min-width: 0; display: flex; }
.view { flex: 1; display: flex; min-width: 0; }

/* ---------- 会话列表 + 聊天 ---------- */
.conv-pane {
  width: 300px; background: #f7f7f7; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.pane-header {
  padding: 14px 16px; font-size: 16px; font-weight: 600; background: #f7f7f7;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
  display: flex; gap: 12px; padding: 12px 14px; cursor: pointer; align-items: center;
  border-bottom: 1px solid #efefef;
}
.conv-item:hover { background: #ececec; }
.conv-item.active { background: #dcdcdc; }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; }
.conv-name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--text2); flex-shrink: 0; margin-left: 6px; }
.conv-preview {
  font-size: 13px; color: var(--text2); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-unread {
  min-width: 18px; height: 18px; background: var(--danger); color: #fff;
  font-size: 11px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; padding: 0 5px; flex-shrink: 0;
}
.conv-empty { padding: 40px 20px; text-align: center; color: var(--text2); font-size: 13px; }

.chat-pane { flex: 1; display: flex; min-width: 0; background: var(--bg); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #b5b5b5; }
.chat-empty-icon { font-size: 52px; margin-bottom: 10px; }
.chat-room { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: 14px 18px; background: #f7f7f7; border-bottom: 1px solid var(--line);
  font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.chat-header .sub { font-size: 12px; color: var(--text2); font-weight: 400; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px 24px; }
.msg-row { display: flex; margin-bottom: 16px; gap: 10px; align-items: flex-start; }
.msg-row.me { flex-direction: row-reverse; }
.msg-body { max-width: 62%; }
.msg-bubble {
  padding: 9px 13px; border-radius: 8px; background: #fff; line-height: 1.5;
  word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.04);
  position: relative; margin-top: 6px;
}
.msg-row.me .msg-bubble { background: var(--bubble-me); }
.msg-bubble img { max-width: 220px; max-height: 220px; border-radius: 6px; display: block; cursor: pointer; }
.msg-name { font-size: 12px; color: var(--text2); }
.msg-time { font-size: 11px; color: #a5a5a5; text-align: center; margin: 4px 0 14px; }
.chat-input-bar {
  padding: 10px 14px; background: #f7f7f7; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
#chat-input {
  flex: 1; border: none; background: #fff; border-radius: 6px; padding: 10px 12px; font-size: 14px;
}
.btn-send { padding: 9px 20px; }
.emoji-panel {
  position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; display: grid; grid-template-columns: repeat(8, 34px); gap: 2px;
  box-shadow: 0 6px 24px rgba(0,0,0,.15); z-index: 30;
}
.emoji-panel button { font-size: 20px; height: 34px; border-radius: 6px; }
.emoji-panel button:hover { background: #f0f0f0; }
.chat-room { position: relative; }

/* ---------- 通讯录 ---------- */
.page-col {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  max-width: 720px; margin: 0 auto; width: 100%;
}
.search-bar { display: flex; gap: 8px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.search-bar input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; }
#contact-result { padding: 0 16px; }
.contact-result-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
}
.contact-scroll { flex: 1; overflow-y: auto; background: #fff; }
.group-label {
  padding: 8px 16px; background: #f4f4f4; color: var(--text2); font-size: 12px;
  position: sticky; top: 0;
}
.contact-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid #f2f2f2; }
.contact-item:hover { background: #fafafa; }
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-size: 15px; }
.contact-sub { font-size: 12px; color: var(--text2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-actions { display: flex; gap: 8px; flex-shrink: 0; }
.contact-actions button { font-size: 13px; padding: 6px 14px; border-radius: 6px; }
.btn-accept { background: var(--green); color: #fff; }
.btn-reject { background: #eee; color: #666; }

/* ---------- 朋友圈 ---------- */
.moments-col {
  flex: 1; overflow-y: auto; background: #fff; min-width: 0;
  max-width: 640px; margin: 0 auto; width: 100%;
}
.composer { padding: 14px 16px; border-bottom: 8px solid #f4f4f4; }
.composer textarea {
  width: 100%; min-height: 70px; border: none; resize: vertical; font-size: 15px;
  background: transparent;
}
.composer-foot { display: flex; align-items: flex-end; gap: 10px; margin-top: 6px; }
.img-previews { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.img-previews .thumb { position: relative; }
.img-previews img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.img-previews .rm {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
  background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
#btn-publish { margin-left: auto; }
.moment-card { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid #f0f0f0; }
.moment-main { flex: 1; min-width: 0; }
.moment-name { color: #576b95; font-weight: 600; font-size: 15px; }
.moment-content { margin-top: 5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.moment-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 8px; max-width: 400px; }
.moment-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; cursor: pointer; }
.moment-time { margin-top: 8px; font-size: 12px; color: #b0b0b0; display: flex; align-items: center; gap: 12px; }
.moment-like-btn { color: #576b95; font-size: 12px; }
.moment-likes {
  margin-top: 8px; background: #f7f7f7; border-radius: 6px; padding: 7px 10px;
  font-size: 13px; color: #576b95;
}
.moment-comment { border-top: 1px solid #eee; padding: 6px 0; font-size: 13px; line-height: 1.5; }
.moment-comment .who { color: #576b95; font-weight: 500; }
.comment-bar { display: flex; gap: 8px; margin-top: 8px; }
.comment-bar input {
  flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-size: 13px;
}
.comment-bar button { font-size: 13px; padding: 7px 14px; }
.moment-del { color: var(--danger); font-size: 12px; }

/* ---------- 我 ---------- */
.me-col { padding: 0 16px 20px; }
.me-card {
  background: #fff; border-radius: 12px; margin: 20px 0; padding: 22px 20px;
  display: flex; align-items: center; gap: 16px;
}
.me-name { font-size: 20px; font-weight: 600; }
.me-wxid { color: var(--text2); font-size: 13px; margin-top: 4px; }
.me-sign { color: var(--text2); font-size: 13px; margin-top: 8px; }
.avatar {
  border-radius: 8px; color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 600; flex-shrink: 0; overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; padding: 24px; width: 420px; max-width: 100%;
  max-height: 84vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal .form-col { display: flex; flex-direction: column; gap: 12px; }
.modal .form-col input, .modal .form-col textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.modal .row-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal .row-btns .btn-cancel { padding: 10px 18px; border-radius: 6px; color: #666; }
.modal .row-btns .btn-cancel:hover { background: #f2f2f2; }
#toast-root {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; animation: toast-in .2s ease;
}
.toast.err { background: rgba(214, 69, 65, .92); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .conv-pane { width: 220px; }
  .msg-body { max-width: 78%; }
  #nav { width: 54px; }
  #local-video { width: 100px; height: 140px; }
}

/* ---------- 移动端：单页切换（微信样式） ---------- */
.btn-back { display: none; }
@media (max-width: 760px) {
  #app-view { flex-direction: column; }
  #nav {
    order: 2; width: 100%; height: 54px; flex-direction: row;
    justify-content: space-around; align-items: center;
    padding: 0 0 env(safe-area-inset-bottom); border-top: 1px solid #3a3a3a;
  }
  #main { order: 1; flex: 1; min-height: 0; }
  .btn-back { display: flex; font-size: 26px; color: #333; }
  .conv-pane { width: 100%; border-right: none; }
  /* 进入聊天：隐藏会话列表，聊天页全屏 */
  #app-view.chat-open .conv-pane { display: none; }
  #app-view:not(.chat-open) .chat-pane { display: none; }
  .page-col, .moments-col { padding: 0; }
  .me-col { padding: 0 12px 16px; }
}

/* ---------- 语音消息 ---------- */
.voice-bubble {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px;
  background: transparent; padding: 2px 0;
}
.voice-bubble .voice-ico {
  width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.08);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0;
}
.msg-row.me .voice-bubble .voice-ico { background: rgba(0,0,0,.12); }
.voice-bubble.playing .voice-ico { background: var(--green); color: #fff; }

/* ---------- 录音提示 ---------- */
.recording-badge {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(230,67,64,.92); color: #fff; padding: 8px 16px; border-radius: 20px;
  font-size: 13px; z-index: 40; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { opacity: .75; } }
.icon-btn.recording { background: rgba(230,67,64,.14); color: var(--danger); animation: pulse 1.2s infinite; }

/* ---------- 视频通话浮层 ---------- */
#call-overlay {
  position: fixed; inset: 0; background: #111; z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
#call-overlay[hidden] { display: none; }
#remote-video {
  width: 100%; height: 100%; object-fit: cover; background: #000;
}
#local-video {
  position: absolute; top: 18px; right: 18px; width: 150px; height: 200px;
  object-fit: cover; border-radius: 12px; background: #222;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.call-info {
  position: absolute; top: 26px; left: 0; right: 0; text-align: center; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.6); pointer-events: none;
}
.call-name { font-size: 20px; font-weight: 600; }
.call-status { font-size: 13px; opacity: .85; margin-top: 6px; }
.call-btns {
  position: absolute; bottom: 40px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 26px;
}
.call-btn {
  width: 62px; height: 62px; border-radius: 50%; background: rgba(255,255,255,.18);
  color: #fff; font-size: 24px; backdrop-filter: blur(4px);
}
.call-btn:hover { background: rgba(255,255,255,.28); }
.call-btn-end { background: var(--danger); transform: rotate(135deg); }
.call-btn-end:hover { background: #ff504d; }

/* ---------- 群聊选择 ---------- */
.pick-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid #f2f2f2; cursor: pointer;
}
.pick-item:hover { background: #fafafa; }
.pick-item input { width: 17px; height: 17px; accent-color: var(--green); }
.pick-list { border: 1px solid var(--line); border-radius: 8px; }

