/* =====================================================================
   WeChat-styled chat — 微聊
   Primary #07C160, Self-bubble #95EC69, Background #EDEDED, Sidebar #F7F7F7
===================================================================== */

:root {
  --wechat-green:   #07C160;
  --wechat-green-hover: #06AD56;
  --wechat-green-light: #95EC69;
  --wechat-bg:      #EDEDED;
  --wechat-sidebar: #F7F7F7;
  --wechat-panel:   #FFFFFF;
  --wechat-text:    #191919;
  --wechat-subtext: #888888;
  --wechat-border:  #E5E5E5;
  --wechat-bubble-self: #95EC69;
  --wechat-bubble-peer: #FFFFFF;
  --wechat-danger:  #FA5151;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--wechat-text);
  background: var(--wechat-bg);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, textarea {
  font-family: inherit; font-size: 14px; outline: none;
  border: none; background: transparent; color: inherit;
}
textarea { resize: none; }
.hidden { display: none !important; }

/* ============================ AUTH SCREEN ============================ */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--wechat-bg);
  z-index: 10;
}
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(7,193,96,0.18), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(7,193,96,0.18), transparent 50%);
}
.auth-card {
  position: relative;
  width: min(420px, calc(100vw - 40px));
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 30px 28px 24px;
  animation: float-in .35s ease-out;
}
@keyframes float-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.brand {
  text-align: center;
  margin-bottom: 18px;
}
.brand-logo {
  display: inline-block;
  font-size: 36px;
  font-weight: 800;
  color: white;
  background: var(--wechat-green);
  width: 72px; height: 72px;
  line-height: 72px;
  border-radius: 22px;
  box-shadow: 0 6px 16px rgba(7,193,96,0.4);
  letter-spacing: 2px;
}
.brand-sub { margin-top: 12px; color: var(--wechat-subtext); font-size: 13px; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--wechat-border);
  margin-bottom: 18px;
}
.tab {
  flex: 1; text-align: center;
  padding: 10px 0;
  color: var(--wechat-subtext);
  font-size: 15px;
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .15s;
}
.tab.active { color: var(--wechat-green); font-weight: 600; }
.tab.active::after {
  content: '';
  position: absolute; left: 30%; right: 30%; bottom: -1px;
  height: 2px; background: var(--wechat-green);
  border-radius: 2px;
}
.tab:hover { color: var(--wechat-green); }

.form { display: none; flex-direction: column; gap: 12px; }
.form.active { display: flex; }
.field {
  display: flex; align-items: center;
  background: #F5F5F5;
  border-radius: var(--radius);
  padding: 0 12px;
  height: 44px;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.field:focus-within { border-color: var(--wechat-green); background: #fff; }
.field .ico { margin-right: 8px; font-size: 16px; }
.field input { flex: 1; height: 100%; }

.primary-btn {
  background: var(--wechat-green);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  height: 44px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
  transition: background .15s, transform .1s;
}
.primary-btn:hover { background: var(--wechat-green-hover); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { background: #B6E5C7; cursor: not-allowed; }
.primary-btn.small { height: 32px; font-size: 13px; padding: 0 14px; margin: 0; }

.form-err { color: var(--wechat-danger); font-size: 13px; min-height: 18px; }
.form-hint { color: var(--wechat-subtext); font-size: 12px; text-align: center; margin-top: 4px; }

/* ============================ TOPBAR / MAIN LAYOUT ============================ */
.app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
}
.topbar {
  height: 56px;
  flex-shrink: 0;
  background: var(--wechat-bg);
  border-bottom: 1px solid var(--wechat-border);
  display: flex; align-items: center;
  padding: 0 14px;
  position: relative;
  z-index: 5;
}
.topbar-left, .topbar-right { width: 56px; display: flex; align-items: center; }
.topbar-right { justify-content: flex-end; }
.topbar-icon {
  width: 36px; height: 36px;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  color: var(--wechat-text);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.topbar-icon:hover { background: rgba(0,0,0,0.05); }
.topbar-title {
  flex: 1; text-align: center;
  font-weight: 600;
  display: flex; align-items: baseline; justify-content: center; gap: 8px;
}
.brand-mini {
  font-weight: 800; color: var(--wechat-green);
  background: rgba(7,193,96,0.1);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 13px;
}
#page-title { font-size: 16px; }

.main-area {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ============================ SIDEBAR ============================ */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--wechat-sidebar);
  border-right: 1px solid var(--wechat-border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--wechat-border);
}
.stab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 0;
  font-size: 13px;
  color: var(--wechat-subtext);
  position: relative;
  transition: color .15s, background .15s;
}
.stab:hover { color: var(--wechat-text); background: rgba(0,0,0,0.02); }
.stab.active { color: var(--wechat-text); font-weight: 600; }
.stab.active::after {
  content: '';
  position: absolute; left: 35%; right: 35%; bottom: 0;
  height: 2px; background: var(--wechat-green);
  border-radius: 2px;
}

.stab-panel { display: none; flex-direction: column; flex: 1; min-height: 0; }
.stab-panel.active { display: flex; }

.search-bar {
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--wechat-border);
  flex-shrink: 0;
}
.search-bar input {
  width: 100%;
  background: #EDEDED;
  height: 32px;
  border-radius: 16px;
  padding: 0 14px;
  font-size: 13px;
}
.search-bar input:focus { background: #fff; border: 1px solid var(--wechat-green); height: 30px; }

.list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
.list::-webkit-scrollbar-track { background: transparent; }

.conv-item {
  display: flex; align-items: center;
  padding: 12px;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background .15s;
  position: relative;
}
.conv-item:hover { background: #f0f0f0; }
.conv-item.active { background: #E8E8E8; }
.conv-item .meta { flex: 1; min-width: 0; }
.conv-item .name {
  font-weight: 600; font-size: 15px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.conv-item .name .time {
  font-weight: 400; font-size: 11px; color: var(--wechat-subtext);
}
.conv-item .preview {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--wechat-subtext);
}
.conv-item .preview-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 180px;
}
.unread-badge {
  background: var(--wechat-danger);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  padding: 0 6px;
  border-radius: 8px;
  min-width: 16px; text-align: center;
  font-weight: 600;
  margin-left: 6px;
}
.unread-badge.zero { display: none; }
.conv-item.hidden { display: none; }

.avatar {
  width: 42px; height: 42px;
  border-radius: 6px;
  background: var(--wechat-green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
.avatar.lg { width: 56px; height: 56px; border-radius: 8px; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; border-radius: 5px; }
.avatar.peek {
  background: linear-gradient(135deg, #07C160, #00B8A9);
}

.sub-section-title {
  background: #F0F0F0;
  color: var(--wechat-subtext);
  font-size: 11px;
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky; top: 0;
  z-index: 1;
}
.req-count {
  display: inline-block;
  background: var(--wechat-danger);
  color: #fff;
  border-radius: 8px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 14px;
  margin-left: 6px;
  vertical-align: middle;
}

.user-search-results {
  background: #fff;
  border-top: 1px solid var(--wechat-border);
  max-height: 240px;
  overflow-y: auto;
}
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.user-row .meta { flex: 1; min-width: 0; }
.user-row .name { font-weight: 600; }
.user-row .sub  { font-size: 12px; color: var(--wechat-subtext); }
.friend-add-btn {
  background: var(--wechat-green);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
}
.friend-add-btn:disabled { background: #B6E5C7; }
.friend-add-btn.added { background: #ccc; }

.req-actions { display: flex; gap: 6px; }
.req-accept, .req-reject {
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  color: #fff;
}
.req-accept { background: var(--wechat-green); }
.req-reject { background: #ccc; }

.empty-state {
  padding: 28px 16px;
  color: var(--wechat-subtext);
  font-size: 13px;
  text-align: center;
}

/* ============================ CHAT PANEL ============================ */
.chat-panel {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--wechat-bg);
}
.chat-header {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--wechat-border);
  display: flex; align-items: center;
  padding: 0 18px;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header-empty {
  color: var(--wechat-subtext);
  width: 100%;
  text-align: center;
}
.chat-header .name { font-weight: 600; font-size: 16px; }
.chat-header .meta-sub { font-size: 12px; color: var(--wechat-subtext); }
.chat-header-info-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--wechat-subtext);
  width: 32px; height: 32px;
  border-radius: 50%;
}
.chat-header-info-btn:hover { background: rgba(0,0,0,0.05); color: var(--wechat-text); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex; flex-direction: column;
  min-height: 0;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
.chat-body-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--wechat-subtext); gap: 12px;
}
.empty-logo { font-size: 60px; opacity: 0.4; }

.msg-group { width: 100%; }
.msg-time {
  text-align: center;
  color: var(--wechat-subtext);
  font-size: 11px;
  padding: 12px 0 6px;
}
.msg-row {
  display: flex; align-items: flex-start;
  gap: 10px;
  margin: 4px 0;
  animation: msg-in .2s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-row.self { flex-direction: row-reverse; }
.bubble {
  max-width: min(60%, 520px);
  padding: 9px 12px;
  border-radius: 4px;
  position: relative;
  word-wrap: break-word; word-break: break-word;
  box-shadow: var(--shadow-1);
  line-height: 1.4;
  white-space: pre-wrap;
}
.msg-row.self .bubble {
  background: var(--wechat-bubble-self);
  border-top-right-radius: 0;
}
.msg-row.peer .bubble {
  background: var(--wechat-bubble-peer);
  border-top-left-radius: 0;
}
.bubble-image {
  max-width: 240px; max-height: 240px;
  border-radius: 4px;
  cursor: zoom-in;
  display: block;
}
.bubble.recalled {
  background: transparent !important;
  box-shadow: none;
  color: var(--wechat-subtext);
  font-size: 12px;
  font-style: italic;
  padding: 4px 0;
}
.msg-status {
  font-size: 10px;
  color: var(--wechat-subtext);
  margin-right: 4px;
  align-self: flex-end;
  padding-bottom: 4px;
}
.msg-actions {
  position: absolute; top: -32px; right: 0;
  background: #fff;
  border: 1px solid var(--wechat-border);
  border-radius: 4px;
  box-shadow: var(--shadow-1);
  display: none;
  z-index: 2;
}
.bubble-wrap { position: relative; display: flex; gap: 6px; max-width: 70%; }
.bubble-wrap:hover .msg-actions { display: flex; }
.msg-action-btn {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--wechat-text);
}
.msg-action-btn:hover { background: #f5f5f5; }
.msg-action-btn.danger { color: var(--wechat-danger); }

.typing-indicator {
  display: flex; gap: 4px; align-items: center;
  padding: 8px 12px;
  background: var(--wechat-bubble-peer);
  border-radius: 4px;
  border-top-left-radius: 0;
  width: fit-content;
  margin: 4px 0;
  box-shadow: var(--shadow-1);
}
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #888;
  animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

.chat-footer {
  height: auto;
  background: #F7F7F7;
  border-top: 1px solid var(--wechat-border);
  padding: 8px 12px;
  display: flex; align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.chat-action {
  background: transparent;
  border: none;
  font-size: 22px;
  width: 38px; height: 38px;
  border-radius: 6px;
  flex-shrink: 0;
}
.chat-action:hover { background: rgba(0,0,0,0.05); }
#msg-input {
  flex: 1;
  background: #fff;
  border: 1px solid var(--wechat-border);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 38px;
  max-height: 120px;
  line-height: 18px;
  font-size: 14px;
}
#msg-input:focus { border-color: var(--wechat-green); }
.send-btn {
  background: var(--wechat-green);
  color: #fff;
  border: none;
  border-radius: 6px;
  height: 38px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--wechat-green-hover); }
.send-btn:disabled { background: #B6E5C7; cursor: not-allowed; }

/* ============================ INFO PANEL ============================ */
.info-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--wechat-sidebar);
  border-left: 1px solid var(--wechat-border);
  position: relative;
  overflow-y: auto;
}
.info-close {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.05);
  border: none;
  font-size: 22px;
  color: var(--wechat-subtext);
  z-index: 2;
}
.info-close:hover { background: rgba(0,0,0,0.1); color: var(--wechat-text); }
.info-body { padding: 28px 20px 20px; }
.info-empty { color: var(--wechat-subtext); text-align: center; padding: 60px 20px; }
.info-header { text-align: center; padding: 24px 0 18px; }
.info-header .avatar { width: 72px; height: 72px; border-radius: 12px; font-size: 32px; margin: 0 auto 12px; }
.info-header .name { font-weight: 600; font-size: 18px; margin-bottom: 4px; }
.info-header .uname { font-size: 12px; color: var(--wechat-subtext); }
.info-section {
  background: #fff;
  margin: 8px 0;
  border-radius: var(--radius);
  padding: 14px 16px;
}
.info-label {
  color: var(--wechat-subtext);
  font-size: 12px;
  margin-bottom: 4px;
}
.info-value {
  font-size: 14px;
  word-wrap: break-word;
}
.info-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--wechat-border);
}
.info-row:last-child { border-bottom: none; }
.info-btn {
  width: 100%;
  background: var(--wechat-danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px;
  margin-top: 20px;
  font-size: 14px;
  font-weight: 600;
}
.info-btn:hover { background: #E04545; }

/* ============================ MOMENTS ============================ */
.moments-header {
  position: relative;
  height: 180px;
  flex-shrink: 0;
}
.m-cover {
  height: 130px;
  background:
    linear-gradient(135deg, #07C160 0%, #00B8A9 100%);
}
.m-my {
  position: absolute;
  bottom: 0; right: 14px;
  display: flex; align-items: center; gap: 10px;
  color: #fff;
}
.m-my .avatar { width: 56px; height: 56px; border-radius: 10px; font-size: 22px; box-shadow: var(--shadow-1); }
.m-my-name { text-shadow: 0 1px 2px rgba(0,0,0,0.4); font-weight: 600; }
.moments-compose {
  background: #fff;
  padding: 10px 12px;
  display: flex; gap: 8px; align-items: flex-end;
  border-bottom: 1px solid var(--wechat-border);
  flex-shrink: 0;
}
.moments-compose textarea {
  flex: 1;
  background: #F5F5F5;
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 38px; max-height: 100px;
  line-height: 20px;
}
.moments-list { padding-bottom: 20px; }
.moment {
  background: #fff;
  padding: 14px;
  border-bottom: 1px solid var(--wechat-border);
  display: flex; gap: 12px;
}
.moment .meta-text { flex: 1; min-width: 0; }
.moment .user-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.moment .uname { font-weight: 600; color: var(--wechat-green); margin-right: 6px; }
.moment .body { margin-top: 6px; line-height: 1.5; word-wrap: break-word; white-space: pre-wrap; }
.moment .moment-time { font-size: 11px; color: var(--wechat-subtext); margin-top: 4px; }
.moment .imgs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
  max-width: 220px;
}
.moment .imgs img {
  width: 100%; aspect-ratio: 1/1; object-fit: cover;
  border-radius: 4px; background: #f0f0f0;
  cursor: zoom-in;
}
.moment .actions {
  display: flex; align-items: center; gap: 12px;
  margin-top: 8px; font-size: 12px;
}
.moment .actions button {
  background: transparent; border: none; color: var(--wechat-subtext); padding: 4px 0;
}
.moment .actions button:hover { color: var(--wechat-text); }
.moment .actions button.active { color: var(--wechat-danger); }
.moment .likes {
  background: #EDEDED;
  border-radius: 4px;
  padding: 6px 10px;
  margin-top: 8px;
  font-size: 12px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.moment .likes b { color: var(--wechat-green); margin-right: 4px; }
.moment .comments {
  background: #EDEDED;
  border-radius: 4px;
  padding: 6px 10px;
  margin-top: 4px;
  font-size: 12px;
}
.moment .comments .c-line { padding: 2px 0; }
.moment .comments .c-user { color: var(--wechat-green); font-weight: 600; margin-right: 4px; }

/* ============================ MODAL ============================ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: min(360px, calc(100vw - 40px));
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
.modal-title { font-weight: 600; padding: 16px; border-bottom: 1px solid var(--wechat-border); }
.modal-body { padding: 16px; color: var(--wechat-subtext); line-height: 1.5; }
.modal-actions { display: flex; border-top: 1px solid var(--wechat-border); }
.modal-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px;
  font-size: 14px;
  border-right: 1px solid var(--wechat-border);
}
.modal-btn:last-child { border-right: none; }
.modal-btn.primary { color: var(--wechat-green); font-weight: 600; }

/* ============================ IMAGE VIEWER ============================ */
.img-viewer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.img-viewer img { max-width: 95vw; max-height: 95vh; border-radius: 4px; }
.img-viewer-close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
}

/* ============================ TOAST ============================ */
.toast {
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.82);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 300;
  pointer-events: none;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================ MOBILE ============================ */
.floating-back {
  position: fixed;
  left: 16px; bottom: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--wechat-green);
  color: #fff;
  font-size: 24px;
  border: none;
  box-shadow: var(--shadow-2);
  z-index: 50;
}

@media (max-width: 768px) {
  .sidebar { width: 100%; }
  .chat-panel, .info-panel { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .chat-panel { display: flex; flex: 1; }
  .app.info-open .chat-panel { display: none; }
  .app.info-open .info-panel { display: flex; flex: 1; width: 100%; border-left: none; }
  .floating-back { display: block; }
  .app:not(.chat-open):not(.info-open) .floating-back { display: none; }
}

/* loading spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(7,193,96,0.2);
  border-top-color: var(--wechat-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.msg-input-with-emoji {
  position: relative;
}
.emoji-popup {
  position: absolute;
  bottom: 50px; left: 0;
  width: 280px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 10px;
  display: none;
  z-index: 4;
  max-height: 200px;
  overflow-y: auto;
}
.emoji-popup.open { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-popup .e {
  font-size: 22px;
  text-align: center;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
}
.emoji-popup .e:hover { background: rgba(0,0,0,0.05); }

/* ============================ WEBRTC CALL ============================ */
.wc-call-hidden { display: none !important; }
.wc-call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  animation: wc-call-fade-in .25s ease-out;
}
@keyframes wc-call-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.wc-call-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: #fff;
}

/* 远程视频全屏铺满 */
.wc-call-remote-video,
.wc-call-remote-audio {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.wc-call-remote-audio {
  /* 音频通话时 audio 元素不可见 */
  display: none !important;
}

/* 语音通话面板（居中） */
.wc-call-audio-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}
.wc-call-audio-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(135deg, #07C160, #00B8A9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  background-size: cover;
  background-position: center;
  animation: wc-call-pulse 2.4s ease-in-out infinite;
}
@keyframes wc-call-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 24px rgba(0,0,0,0.4); }
  50%      { transform: scale(1.05); box-shadow: 0 4px 32px rgba(7,193,96,0.4); }
}
.wc-call-audio-name {
  font-size: 22px;
  font-weight: 600;
  margin-top: 4px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.wc-call-audio-status {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.5px;
}
.wc-call-audio-timer {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  font-variant-numeric: tabular-nums;
  min-height: 18px;
}

/* 来电大按钮（被叫方） */
.wc-call-incoming-actions {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 24px;
  background: rgba(0,0,0,0.55);
}
.wc-call-incoming-tip {
  text-align: center;
  color: #fff;
}
.wc-call-incoming-name {
  font-size: 26px;
  font-weight: 600;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.wc-call-incoming-type {
  margin-top: 6px;
  font-size: 14px;
  color: rgba(255,255,255,0.85);
}
.wc-call-incoming-btns {
  display: flex;
  gap: 80px;
  align-items: center;
}
.wc-call-accept {
  background: #07C160 !important;
  color: #fff !important;
}
.wc-call-accept:hover { background: #06ad55 !important; }
.wc-call-reject {
  background: #FA5151 !important;
  color: #fff !important;
}
.wc-call-reject:hover { background: #e84949 !important; }

/* 本地视频小窗（拖拽） */
.wc-call-local-pip {
  position: absolute;
  top: 90px;
  right: 18px;
  width: 110px;
  height: 150px;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1a1a;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.12);
  cursor: grab;
  z-index: 5;
  transition: transform .15s ease;
  touch-action: none;
}
.wc-call-local-pip:active { cursor: grabbing; }
.wc-call-local-pip.dragging { transition: none; opacity: 0.92; }
.wc-call-local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  transform: scaleX(-1); /* 镜像，符合习惯 */
}

/* 顶部条 */
.wc-call-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 100%);
  z-index: 4;
  transition: opacity .35s ease;
}
.wc-call-peer-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.wc-call-status {
  font-size: 12px;
  color: rgba(255,255,255,0.78);
}

/* 底部控制条 */
.wc-call-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 26px;
  z-index: 4;
  transition: opacity .35s ease, transform .35s ease;
}
.wc-call-controls.wc-call-controls-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}
.wc-call-controls.wc-call-controls-visible {
  opacity: 1;
  transform: translateY(0);
}

/* 圆形控制按钮 */
.wc-call-ctrl-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .15s ease, transform .12s ease;
  padding: 0;
}
.wc-call-ctrl-btn:hover { background: rgba(255,255,255,0.28); }
.wc-call-ctrl-btn:active { transform: scale(0.94); background: rgba(255,255,255,0.4); }
.wc-call-ctrl-btn.active { background: rgba(255,255,255,0.85); color: #111; }
.wc-call-ctrl-btn.active:hover { background: rgba(255,255,255,0.95); }

.wc-call-hangup {
  width: 64px;
  height: 64px;
  background: #FA5151 !important;
  color: #fff !important;
}
.wc-call-hangup:hover { background: #e84949 !important; }
.wc-call-hangup:active { background: #d83f3f !important; }

/* 通话按钮（聊天头部） */
.wc-call-header-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--wechat-subtext);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.wc-call-header-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--wechat-text);
}
.wc-call-header-btn + .wc-call-header-btn { margin-left: 4px; }
.wc-call-header-btn + .chat-header-info-btn { margin-left: 4px; }

/* 移动端适配 */
@media (max-width: 600px) {
  .wc-call-local-pip {
    width: 90px;
    height: 120px;
    top: 70px;
    right: 12px;
  }
  .wc-call-controls { gap: 18px; bottom: 28px; }
  .wc-call-ctrl-btn { width: 48px; height: 48px; }
  .wc-call-hangup { width: 58px; height: 58px; }
  .wc-call-incoming-btns { gap: 60px; }
}
