/* 移动端重绘 - 适配小米/华为/Edge 等国产浏览器 */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 禁止 overscroll 拉拽导致页面整体移动（小米/华为部分机型） */
  overscroll-behavior: none;
}

body {
  margin: 0;
  padding: 0;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "HarmonyOS Sans", sans-serif;
  font-size: 15px;
  color: #191919;
  background: #EDEDED;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

body * {
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  -webkit-user-select: auto;
  user-select: auto;
}

#app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 手机端整体背景启用时：让背景图能透出来 */
body.mobile-bg-enabled {
  background: transparent !important;
}
body.mobile-bg-enabled #app {
  background: transparent;
}
/* 背景图透出 100% */
body.mobile-bg-enabled .page,
body.mobile-bg-enabled .page-friends,
body.mobile-bg-enabled .page-chat,
body.mobile-bg-enabled .page-moments,
body.mobile-bg-enabled .page-profile {
  background: transparent;
}
body.mobile-bg-enabled .friends-search-bar,
body.mobile-bg-enabled .chat-main-body,
body.mobile-bg-enabled .chat-info-body {
  background: transparent;
}
body.mobile-bg-enabled .chat-info-panel,
body.mobile-bg-enabled .chat-info-user,
body.mobile-bg-enabled .chat-info-list,
body.mobile-bg-enabled .group-friend-modal-content {
  background: rgba(255, 255, 255, 0.06);
}
body.mobile-bg-enabled .app-header {
  background: rgba(255, 255, 255, 0.95);
}
body.mobile-bg-enabled .chat-header {
  background: rgba(255, 255, 255, 0.95);
}
body.mobile-bg-enabled .moments-feed {
  background: transparent;
}
body.mobile-bg-enabled .moments-scroll {
  background: transparent;
}

/* 底部导航 - 适配刘海/手势条，保证可点击 */
.app-header {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  background: #F7F7F7;
  border-top: 1px solid #E5E5E5;
  z-index: 9999;
  pointer-events: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.app-header nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
}

.app-header .nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  min-height: 44px;
  background: none;
  border: none;
  color: #999;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.app-header .nav-tab.active {
  color: #07C160;
}

.app-header .nav-tab.active .nav-icon {
  color: #07C160;
}

.nav-icon {
  color: inherit;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
}

.nav-label {
  line-height: 1;
}

/* 主内容区 - 动态视口高度（地址栏显隐） */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 56px;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
}

/* 好友搜索页 - 按图中布局：顶部搜索栏、中间列表、中下部居中 logo、底栏 */
.page-friends {
  flex-direction: column;
  height: 100%;
  background: #EDEDED;
}

.friends-search-bar {
  display: flex;
  align-items: center;
  padding: 10px 16px 12px;
  padding-left: max(16px, calc(16px + env(safe-area-inset-left)));
  padding-right: max(16px, calc(16px + env(safe-area-inset-right)));
  padding-top: max(10px, calc(10px + env(safe-area-inset-top)));
  background: #FFF;
  gap: 10px;
}

.friends-search-bar input {
  flex: 1;
  padding: 10px 14px 10px 16px;
  font-size: 15px;
  border: none;
  border-radius: 8px;
  background: #EBEBEB;
  outline: none;
  color: #191919;
}

.friends-search-bar .search-icon {
  width: 22px;
  height: 22px;
  opacity: 0.6;
  flex-shrink: 0;
}

/* 搜索栏下方：列表 + 中下部 logo 区域 */
.friends-content-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #FFF;
}

.friend-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #FFF;
}

/* 占位把 logo 再往上一点 */
.friends-logo-spacer {
  flex: 1;
  min-height: 0;
  background: #FFF;
}

/* 中下部居中的 XhaMil Chat logo，往上、放大 2 倍 */
.friends-logo-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px 20px;
  background: #FFF;
}

.friends-logo-img {
  display: block;
  max-width: 480px;
  width: auto;
  height: auto;
  max-height: 176px;
  object-fit: contain;
}

.friend-item {
  display: flex;
  align-items: center;
  padding: 12px 12px 12px 16px;
  padding-left: max(16px, calc(16px + env(safe-area-inset-left)));
  padding-right: max(16px, calc(16px + env(safe-area-inset-right)));
  border-bottom: 1px solid #ECECEC;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  background: #FFF;
  position: relative;
}

.friend-item:active {
  background: #ECECEC;
}

.friend-item::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-right: 1.5px solid #C0C0C0;
  border-top: 1.5px solid #C0C0C0;
  transform: translateY(-50%) rotate(45deg);
}

.friend-avatar {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: #E5E5E5;
  overflow: hidden;
  flex-shrink: 0;
  margin-right: 12px;
}

.friend-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.friend-avatar .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #666;
}

.friend-avatar {
  position: relative;
}

.friend-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e54d42;
  border: 2px solid #fff;
}

.friend-name {
  flex: 1;
  font-size: 16px;
  color: #191919;
  font-weight: 400;
  min-width: 0;
}

.friend-meta {
  font-size: 12px;
  color: #999;
}

.friend-add-btn {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid #07c160;
  background: #fff;
  color: #07c160;
}

.friend-add-btn:disabled {
  opacity: 0.6;
  border-color: #ccc;
  color: #999;
}

/* 群聊头像：随人数 1–9 宫格（一人一格，最多九宫格） */
.friend-avatar-group {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  margin-right: 12px;
  display: grid;
  gap: 1px;
  background: #e0e0e0;
}

.friend-avatar-group-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.friend-avatar-group-2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.friend-avatar-group-3,
.friend-avatar-group-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.friend-avatar-group-5,
.friend-avatar-group-6 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.friend-avatar-group-7,
.friend-avatar-group-8,
.friend-avatar-group-9 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }

.friend-avatar-group .avatar-cell {
  background: #e8e8e8;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.friend-avatar-group .avatar-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.friend-avatar-group .avatar-cell .initial {
  font-size: 10px;
  font-weight: 600;
  color: #666;
}

/* 组建群聊 - 好友列表弹窗（居中） */
.group-friend-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.group-friend-modal.group-friend-modal-open {
  display: flex;
}

.group-friend-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.group-friend-modal-content {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: 70vh;
  background: #fff;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.group-friend-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.group-friend-modal-title {
  font-size: 17px;
  font-weight: 500;
  color: #333;
}

.group-friend-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.group-friend-modal-body {
  flex: 1;
  overflow-y: auto;
  max-height: 50vh;
  padding: 8px 0;
}

.group-friend-modal-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.group-friend-modal-item:active {
  background: #f5f5f5;
}

.group-friend-modal-item .friend-avatar {
  width: 44px;
  height: 44px;
  margin-right: 12px;
}

.group-friend-modal-item .friend-name {
  flex: 1;
  font-size: 16px;
  color: #333;
}

.group-friend-modal-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #07c160;
}

.group-friend-modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid #eee;
}

.group-friend-btn {
  flex: 1;
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.group-friend-cancel {
  background: #f0f0f0;
  color: #333;
}

.group-friend-confirm {
  background: #07c160;
  color: #fff;
}

.group-friend-confirm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 聊天页 - 顶部标题栏 */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: 44px;
  padding-left: max(8px, calc(8px + env(safe-area-inset-left)));
  padding-right: max(8px, calc(8px + env(safe-area-inset-right)));
  padding-top: max(0px, env(safe-area-inset-top));
  min-height: calc(44px + env(safe-area-inset-top));
  background: #EDEDED;
  border-bottom: 1px solid #D9D9D9;
}

.chat-header .back-btn {
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  margin-right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #191919;
  position: relative;
  z-index: 2;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chat-header .chat-title {
  flex: 1;
  font-size: 17px;
  font-weight: 500;
  color: #191919;
  text-align: center;
  margin: 0 -44px;
}

.chat-header-more {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #191919;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.chat-header-more:active {
  opacity: 0.7;
}

/* 聊天信息面板 */
.chat-info-panel {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 200;
  background: #EDEDED;
  flex-direction: column;
}

.chat-info-panel.chat-info-open {
  display: flex;
}

.chat-info-header {
  display: flex;
  align-items: center;
  height: 48px;
  padding-left: max(16px, calc(16px + env(safe-area-inset-left)));
  padding-right: max(16px, calc(16px + env(safe-area-inset-right)));
  padding-top: max(0px, env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
}

.chat-info-header .back-btn {
  width: 36px;
  height: 36px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #333;
}

.chat-info-title {
  font-size: 17px;
  font-weight: 500;
  color: #333;
}

.chat-info-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.chat-info-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
}

.chat-info-user-top {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.chat-info-avatar {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: #e0e0e0;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-info-avatar-group {
  display: grid;
  gap: 1px;
  padding: 0;
}

.chat-info-avatar-group-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.chat-info-avatar-group-2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.chat-info-avatar-group-3,
.chat-info-avatar-group-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.chat-info-avatar-group-5,
.chat-info-avatar-group-6 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.chat-info-avatar-group-7,
.chat-info-avatar-group-8,
.chat-info-avatar-group-9 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }

.chat-info-avatar-group .avatar-cell {
  background: #e8e8e8;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-info-avatar-group .avatar-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-info-avatar-group .avatar-cell .initial {
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

.chat-info-add-actions {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.chat-info-add-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 56px;
  min-height: 64px;
  padding: 8px 0;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  background: #fff;
  color: #333;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chat-info-add-btn:active {
  background: #f5f5f5;
}

.chat-info-add-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #576b95;
}

.chat-info-add-icon svg {
  width: 22px;
  height: 22px;
}

.chat-info-add-label {
  font-size: 11px;
  color: #666;
}

.chat-info-members-invite {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-info-members-avatars {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-info-member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-info-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-info-member-avatar .initial {
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.chat-info-invite-btn {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid #07c160;
  background: #fff;
  color: #07c160;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-info-invite-btn:active {
  background: #f0f9f4;
}

/* 群聊信息：成员列表 + 邀请/解散 */
.chat-info-group-members-wrap {
  padding: 16px 0;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
}

.chat-info-group-members {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  padding: 0 16px;
}

.chat-info-group-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.chat-info-group-member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-info-group-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-info-group-member-avatar .initial {
  font-size: 18px;
  font-weight: 600;
  color: #666;
}

.chat-info-group-member-name {
  font-size: 13px;
  color: #333;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-info-group-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
}

.chat-info-group-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  background: #f0f0f0;
  color: #e54d42;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-info-group-btn:active {
  background: #e8e8e8;
}

.chat-info-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-info-avatar .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: #666;
}

.chat-info-name {
  font-size: 16px;
  font-weight: 500;
  color: #333;
}

.chat-info-list {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.chat-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 15px;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}

.chat-info-row:last-child {
  border-bottom: none;
}

.chat-info-friend-actions {
  background: #fff;
  border-radius: 12px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid #e5e5e5;
}

.chat-info-action-row {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  color: #333;
  background: #fff;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-info-action-row:last-child {
  border-bottom: none;
}

.chat-info-action-row:active {
  background: #f8f8f8;
}

.chat-info-action-danger {
  color: #e54d42;
}

.chat-info-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 30px;
}

.chat-info-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.chat-info-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #e0e0e0;
  border-radius: 15px;
  transition: 0.25s;
}

.chat-info-slider::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: 0.25s;
}

.chat-info-switch input:checked + .chat-info-slider {
  background: #07c160;
}

.chat-info-switch input:checked + .chat-info-slider::before {
  transform: translateX(20px);
}

/* 消息区域 - 微信风格 */
.chat-main-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  -webkit-overflow-scrolling: touch;
  background: #EDEDED;
}

.chat-row {
  display: flex;
  margin-bottom: 14px;
  align-items: flex-start;
}

.chat-row.from-me {
  flex-direction: row-reverse;
}

.chat-row .avatar-wrap {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #E5E5E5;
}

.chat-row.from-me .avatar-wrap {
  margin-left: 8px;
}

.chat-row:not(.from-me) .avatar-wrap {
  margin-right: 8px;
}

.chat-row .avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-row .avatar-wrap .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.45;
  word-wrap: break-word;
}

.chat-row.from-me .chat-bubble {
  background: #95EC69;
  color: #191919;
  border-radius: 4px 4px 0 4px;
}

.chat-row:not(.from-me) .chat-bubble {
  background: #FFF;
  color: #191919;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  border-radius: 4px 4px 4px 0;
}

.chat-bubble-img {
  max-width: 180px;
  border-radius: 12px;
  overflow: hidden;
  background: #f0f0f0;
}

.chat-bubble-img img {
  display: block;
  max-width: 100%;
  height: auto;
}

.chat-bubble-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #95ec69;
  color: #333;
}

.chat-row:not(.from-me) .chat-bubble-voice {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.chat-bubble-voice audio {
  max-width: 160px;
  height: 36px;
  outline: none;
}

.chat-voice-dur {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.chat-bubble-friend-request {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.friend-request-text {
  font-size: 15px;
}

.friend-request-actions {
  display: flex;
  gap: 10px;
}

.friend-request-btn {
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.friend-request-btn.accept {
  background: #07c160;
  color: #fff;
}

.friend-request-btn.reject {
  background: #f5f5f5;
  color: #666;
}

.friend-request-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.friend-request-done {
  font-size: 13px;
  color: #999;
}

.chat-voice-recording {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 8px;
  background: #fff5f5;
  border-radius: 12px;
  font-size: 14px;
  color: #e54d42;
}

.chat-voice-recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e54d42;
  animation: chat-voice-blink 1s ease-in-out infinite;
}

@keyframes chat-voice-blink {
  50% { opacity: 0.3; }
}

.chat-voice-stop-btn {
  margin-left: auto;
  padding: 6px 14px;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  background: #e54d42;
  color: #fff;
  cursor: pointer;
}

/* 输入区 */
.chat-input-area.chat-readonly {
  display: none;
}

.chat-input-area {
  position: relative;
  padding: 10px 12px 14px;
  padding-left: max(12px, calc(12px + env(safe-area-inset-left)));
  padding-right: max(12px, calc(12px + env(safe-area-inset-right)));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: #F5F5F5;
  border-top: 1px solid #E5E5E5;
}

.chat-more-panel {
  display: none;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 8px;
}

.chat-more-panel.chat-more-panel-open {
  display: flex;
}

/* iOS 风格弹窗：浮在输入框上方 */
.chat-more-popup {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 100%;
  margin-bottom: 8px;
  padding: 16px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: none;
  margin-bottom: 8px;
  z-index: 100;
}

.chat-more-popup.chat-more-panel-open {
  display: flex;
}

.chat-more-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 64px;
  padding: 12px 0;
  border: none;
  border-radius: 12px;
  background: #f5f5f5;
  color: #333;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-more-option:active {
  background: #e8e8e8;
}

.chat-more-option-icon {
  font-size: 24px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #e8e8e8;
  color: #576b95;
}

.chat-more-option-icon svg {
  width: 28px;
  height: 28px;
}

.chat-more-icon-photo {
  color: #07c160;
}

.chat-more-icon-voice {
  color: #576b95;
}

.chat-more-option-text {
  font-size: 12px;
  color: #666;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 16px;
  border: 1px solid #E5E5E5;
  border-radius: 6px;
  outline: none;
  background: #FFF;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  min-height: 36px;
}

/* 麦克风按钮：未录音灰色，录音中高亮变红 */
.chat-mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #576b95;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  transition: color 0.2s, background 0.2s;
}

.chat-mic-btn .chat-mic-btn-icon {
  width: 24px;
  height: 24px;
}

.chat-mic-btn:active {
  background: rgba(0, 0, 0, 0.06);
}

/* 麦克风外包装：显示秒数 + 按钮 */
.chat-mic-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.chat-mic-dur {
  font-size: 13px;
  color: #e54d42;
  min-width: 32px;
  text-align: right;
  display: none;
}

.chat-mic-dur.recording {
  display: block;
}

/* 录音中：红色柔和呼吸（不抽动） */
.chat-mic-btn.recording {
  color: #fff;
  background: #e54d42;
  animation: chat-mic-recording-pulse 2s ease-in-out infinite;
}

.chat-mic-btn.recording:active {
  background: #c93c32;
  animation: none;
}

@keyframes chat-mic-recording-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(229, 77, 66, 0.4); }
  50% { opacity: 0.92; box-shadow: 0 0 0 6px rgba(229, 77, 66, 0); }
}

.chat-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #576b95;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.chat-more-btn:active {
  background: #f0f0f0;
}

.chat-more-btn svg {
  width: 24px;
  height: 24px;
}

.chat-send-btn {
  padding: 8px 16px;
  font-size: 15px;
  border: none;
  border-radius: 6px;
  background: #07C160;
  color: #FFF;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  font-weight: 400;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.chat-send-btn:active {
  opacity: 0.9;
}

/* 空状态 */
.empty-hint {
  text-align: center;
  color: #888;
  font-size: 14px;
  padding: 40px 20px;
}

.empty-hint a {
  color: #07C160;
  text-decoration: none;
}

/* 每个页面占满除底部导航外的整屏区域 */
#app {
  overflow-x: hidden;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 56px; /* 预留底部导航高度 */
  display: none;
  flex-direction: column;
  z-index: 0;
}

.page.active {
  display: flex;
  z-index: 5;
}

/* 聊天页（世界大厅/私聊）：从右侧滑入，不挡点击 */
.page-chat {
  display: flex !important;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
  visibility: hidden;
  z-index: 0;
}

.page-chat.active {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
  z-index: 10;
}

/* 朋友圈加载中（整页，已不用） */
.moments-loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 150;
  align-items: center;
  justify-content: center;
  background: rgba(245, 245, 245, 0.9);
  font-size: 15px;
  color: #666;
}

.moments-loading-text {
  animation: moments-loading-pulse 0.8s ease-in-out infinite;
}

@keyframes moments-loading-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* 帖子单独加载 - dominos 动画 */
.posts-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
  gap: 16px;
}

.posts-loading-spinner {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-left: -30px;
}

.posts-loading-spinner span {
  position: absolute;
  top: 50%;
  left: var(--left, 50%);
  width: 28px;
  height: 6px;
  background: #07c160;
  animation: posts-dominos 1s ease infinite;
  transform-origin: center;
}

.posts-loading-spinner span:nth-child(1) { --left: 60px; animation-delay: 0.125s; }
.posts-loading-spinner span:nth-child(2) { --left: 52px; animation-delay: 0.25s; }
.posts-loading-spinner span:nth-child(3) { --left: 44px; animation-delay: 0.375s; }
.posts-loading-spinner span:nth-child(4) { --left: 36px; animation-delay: 0.5s; }
.posts-loading-spinner span:nth-child(5) { --left: 28px; animation-delay: 0.625s; }
.posts-loading-spinner span:nth-child(6) { --left: 20px; animation-delay: 0.75s; }
.posts-loading-spinner span:nth-child(7) { --left: 12px; animation-delay: 0.875s; }
.posts-loading-spinner span:nth-child(8) { --left: 4px; animation-delay: 1s; }

@keyframes posts-dominos {
  50% { opacity: 0.7; }
  75% {
    transform: rotate(90deg);
    opacity: 1;
  }
  80% { opacity: 1; }
}

.posts-loading-text {
  font-size: 14px;
  color: #999;
}

/* 朋友圈页 - 背景图和帖子一起往下滑，在上面 */
.page-moments {
  flex: 1;
  flex-direction: column;
  background: #EDEDED;
  overflow: hidden;
}

.moments-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.moments-cover {
  position: relative;
  width: 100%;
  height: 220px;
  min-height: 220px;
  overflow: hidden;
  flex-shrink: 0;
}

.moments-cover-bg {
  position: absolute;
  inset: 0;
  background-color: #7CB342;
  background-image: url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.moments-cover-publish-btn {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.moments-cover-publish-btn:active {
  background: rgba(0, 0, 0, 0.5);
}

.moments-cover-publish-btn svg {
  width: 20px;
  height: 20px;
}

.moments-publish-label {
  font-weight: 500;
}

.moments-cover-overlay {
  position: absolute;
  bottom: 12px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 发布朋友圈弹窗 */
.moments-publish-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.moments-publish-overlay.moments-publish-open {
  display: flex;
}

.moments-publish-modal {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.moments-publish-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  color: #333;
}

.moments-publish-textarea {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  outline: none;
  resize: none;
  box-sizing: border-box;
  margin-bottom: 12px;
}

.moments-publish-textarea:focus {
  border-color: #07c160;
}

.moments-publish-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.moments-publish-add-img {
  width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px dashed #ddd;
  border-radius: 10px;
  background: #f9f9f9;
  color: #999;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.moments-publish-add-img:active {
  background: #f0f0f0;
}

.moments-publish-add-icon {
  font-size: 24px;
  color: #07c160;
}

.moments-publish-preview-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}

.moments-publish-preview {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}

.moments-publish-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.moments-publish-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.moments-publish-cancel,
.moments-publish-submit {
  padding: 10px 24px;
  font-size: 15px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.moments-publish-cancel {
  background: #f5f5f5;
  color: #666;
}

.moments-publish-submit {
  background: #07c160;
  color: #fff;
}

.moments-publish-submit:active {
  opacity: 0.9;
}

.moments-cover-name {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.moments-cover-avatar {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #d3d3d3;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.9);
}

.moments-cover-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.moments-cover-avatar .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #666;
}

.moments-feed {
  background: #fff;
  margin-top: -1px;
}

.moments-post {
  display: flex;
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  align-items: flex-start;
}

.moments-post-avatar {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #e0e0e0;
  overflow: hidden;
  flex-shrink: 0;
  margin-right: 12px;
}

.moments-post-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.moments-post-avatar .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #666;
}

.moments-post-body {
  flex: 1;
  min-width: 0;
}

.moments-post-author {
  font-size: 15px;
  font-weight: 500;
  color: #333;
  margin-bottom: 6px;
}

.moments-post-text {
  font-size: 15px;
  color: #333;
  line-height: 1.5;
  margin-bottom: 10px;
}

.moments-post-img {
  max-width: 100%;
  border-radius: 8px;
  display: block;
}

.moments-post-imgs {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
}

.moments-post-imgs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
}

/* 我的 页面 - 微信风格 */
.page-profile {
  flex: 1;
  background: #EDEDED;
}

.profile-header {
  display: flex;
  align-items: center;
  padding: 24px 20px 20px;
  background: #EDEDED;
}

.profile-avatar-large {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #d3d3d3;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-large .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 600;
  color: #777;
}

.profile-name-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: 18px;
  gap: 10px;
}

.profile-name-row .profile-name {
  font-size: 18px;
  font-weight: 500;
  color: #191919;
}

.profile-name-row .profile-name-line {
  height: 1px;
  width: 100%;
  background: #cfcfcf;
}

.profile-menu {
  margin: 0 12px 16px;
  background: #FFF;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.04);
  overflow: hidden;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  padding-left: max(18px, calc(18px + env(safe-area-inset-left)));
  padding-right: max(18px, calc(18px + env(safe-area-inset-right)));
  font-size: 15px;
  background: #fff;
  border: none;
  border-bottom: 1px solid #eee;
  color: #333;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.profile-menu-item:last-child {
  border-bottom: none;
}

.profile-menu-item:active {
  background: #f7f7f7;
}

.profile-menu-item-danger {
  color: #e54d42;
}

.profile-item-icon svg {
  width: 18px;
  height: 18px;
}

.profile-item-text {
  flex: 1;
  text-align: left;
}

/* 设置页 */
.page-settings {
  flex-direction: column;
  background: #fff;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: 48px;
  padding-left: max(16px, calc(16px + env(safe-area-inset-left)));
  padding-right: max(16px, calc(16px + env(safe-area-inset-right)));
  padding-top: max(0px, env(safe-area-inset-top));
  min-height: calc(48px + env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
}

.settings-back-btn {
  width: 32px;
  height: 32px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #333;
  -webkit-tap-highlight-color: transparent;
}

.settings-back-btn:active {
  opacity: 0.6;
}

.settings-title-text {
  flex: 1;
  font-size: 17px;
  font-weight: 500;
  color: #333;
}

.settings-content {
  flex: 1;
  padding: 24px 16px;
}

.settings-section {
  margin-bottom: 32px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-avatar-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.settings-avatar-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #e0e0e0;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-avatar-large .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 600;
  color: #666;
}

.settings-label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: #333;
  margin-bottom: 12px;
}

.settings-text-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
  outline: none;
  background: #f9f9f9;
  color: #333;
}

.settings-text-input:focus {
  border-color: #07c160;
  background: #fff;
}

.settings-text-input::placeholder {
  color: #999;
}

/* 朋友圈背景图预览 */
.moments-bg-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.moments-bg-preview {
  position: relative;
  width: 100%;
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  background-color: #7CB342;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.moments-bg-preview .preview-label {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
}

.moments-bg-overlay {
  position: absolute;
  bottom: 12px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.moments-bg-name {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.moments-bg-avatar {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #d3d3d3;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.9);
}

.moments-bg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.moments-bg-avatar .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #666;
}

.upload-bg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
  background: #fff;
  color: #333;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.upload-bg-btn:active {
  background: #f5f5f5;
}

.upload-bg-btn svg {
  width: 18px;
  height: 18px;
}

/* 安全区域 - 小米/华为/Edge 刘海与手势条 */
@supports (padding: max(0px)) {
  .app-header {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    height: calc(56px + env(safe-area-inset-bottom));
  }
  .page {
    bottom: calc(56px + env(safe-area-inset-bottom));
  }
  .app-main {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }
}

/* 兼容不支持 env() 的旧版内核 */
@supports not (padding: env(safe-area-inset-bottom)) {
  body {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
  }
  .app-header {
    padding-left: 0;
    padding-right: 0;
  }
}
