/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #111;
  color: #333;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.page { display: none; width: 100%; height: 100%; }
.page.active { display: flex; justify-content: center; align-items: center; }

/* ===== Login Page ===== */
.login-container {
  background: #fff;
  border-radius: 8px;
  padding: 60px 50px;
  text-align: center;
  box-shadow: 0 4px 30px rgba(0,0,0,0.3);
  min-width: 340px;
}
.login-logo { margin-bottom: 30px; }
.login-logo h1 {
  font-size: 22px;
  font-weight: 400;
  color: #333;
  margin-top: 12px;
}
.login-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.login-form input:focus { border-color: #07C160; }
.login-form button {
  width: 100%;
  padding: 12px;
  background: #07C160;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.2s;
}
.login-form button:hover { background: #06AD56; }
.login-form button:disabled { background: #ccc; cursor: not-allowed; }
.login-tip { color: #999; font-size: 12px; margin-top: 16px; }

/* Partner Selection Cards */
.partner-select {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  margin-bottom: 20px;
}
.partner-option {
  flex: 1;
  padding: 16px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  background: #fafafa;
}
.partner-option:hover {
  border-color: #b0b0b0;
  background: #f0f0f0;
}
.partner-option.selected {
  border-color: #07C160;
  background: #f0faf4;
}
.partner-icon {
  font-size: 32px;
  margin-bottom: 6px;
}
.partner-label {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

/* Remember Username Checkbox */
.remember-username {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  font-size: 13px;
  color: #666;
  margin-top: 12px;
  margin-bottom: 8px;
}
.remember-username input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}
.remember-username label {
  cursor: pointer;
  user-select: none;
}

/* Invite Code */
.invite-code-box {
  margin-top: 12px;
}
.invite-code-box input {
  text-align: left;
  letter-spacing: 2px;
  font-size: 15px;
  font-weight: 500;
  transition: border-color 0.2s;
}
.invite-code-box input::placeholder {
  letter-spacing: 0;
  font-weight: 400;
}
.invite-code-box input.input-error {
  border-color: #e74c3c;
}
.invite-code-box input.input-error:focus {
  border-color: #e74c3c;
}
.invite-code-error {
  color: #e74c3c;
  font-size: 12px;
  margin-top: 6px;
  min-height: 0;
  text-align: center;
  transition: all 0.2s;
}
.invite-code-error:empty {
  display: none;
}

/* Agreement Checkbox */
.agreement-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
  margin-bottom: 10px;
}
.agreement-box input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}
.agreement-box label {
  cursor: pointer;
  user-select: none;
}
.agreement-box a {
  color: #576b95;
  text-decoration: none;
}
.agreement-box a:hover {
  text-decoration: underline;
}

/* ===== Connection Status Bar ===== */
.connection-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ff9800;
  color: white;
  text-align: center;
  padding: 8px 16px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===== Main Layout (WeChat Desktop) ===== */
.wechat-container {
  width: 95vw;
  height: 92vh;
  max-width: 1600px;
  background: #f5f5f5;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

/* Desktop - Extra Large screens (1600px+) */
@media (min-width: 1600px) {
  .wechat-container {
    width: 1600px;
    height: 92vh;
  }
}

/* Desktop - Large screens (1200px - 1599px) */
@media (min-width: 1200px) and (max-width: 1599px) {
  .wechat-container {
    width: 90vw;
    height: 90vh;
  }
}

/* Tablet / Small laptop (769px - 1199px) */
@media (min-width: 769px) and (max-width: 1199px) {
  .wechat-container {
    width: 95vw;
    height: 90vh;
  }
}

/* ===== Sidebar ===== */
.sidebar {
  display: flex;
  width: 300px;
  min-width: 300px;
  background: #ebebeb;
  border-right: 1px solid #d6d6d6;
}
.sidebar-icons {
  width: 54px;
  background: #e3e3e3;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 20px;
  gap: 6px;
}
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: #07C160;
  margin-bottom: 20px;
  overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: #666;
  transition: background 0.15s;
}
.sidebar-icon:hover { background: #d4d4d4; }
.sidebar-icon.active { color: #07C160; }
.sidebar-icon svg { width: 22px; height: 22px; }

.contact-list-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.search-bar {
  padding: 14px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ebebeb;
}
.search-bar input {
  flex: 1;
  border: none;
  background: #e0e0e0;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
  color: #999;
}
.contact-list {
  flex: 1;
  overflow-y: auto;
}
.contact-list::-webkit-scrollbar { width: 4px; }
.contact-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Contact Item */
.contact-item {
  display: flex;
  align-items: center;
  padding: 12px 10px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.contact-item:hover { background: #d9d9d9; }
.contact-item.active { background: #c9c9c9; }
.contact-item .avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  margin-right: 10px;
  background: #ddd;
  flex-shrink: 0;
  overflow: hidden;
}
.contact-item .avatar img { width: 100%; height: 100%; object-fit: cover; }
.contact-item .info { flex: 1; min-width: 0; }
.contact-item .info .name {
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-item .info .last-msg {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}
.contact-item .meta {
  text-align: right;
  flex-shrink: 0;
  margin-left: 8px;
}
.contact-item .meta .time { font-size: 11px; color: #bbb; }
.contact-item .unread-badge {
  background: #F44336;
  color: white;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  float: right;
  margin-top: 4px;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  position: relative;
}
.content-view { display: none; flex-direction: column; height: 100%; }
.content-view.active { display: flex; }

/* ===== Chat View ===== */
.chat-header {
  height: 50px;
  background: #ededed;
  border-bottom: 1px solid #d6d6d6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 400;
  color: #000;
}
.chat-header-actions { display: flex; gap: 8px; }
.header-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #666;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: background 0.15s;
}
.header-icon-btn:hover { background: #d9d9d9; }
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 8px 20px;
  background: #f5f5f5;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* Message Bubbles */
.message-row {
  display: flex;
  margin-bottom: 12px;
  align-items: flex-start;
}
.message-row.from-user { justify-content: flex-end; }
.message-row .msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
  overflow: hidden;
  background: #ddd;
}
.message-row .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-row.from-gf .msg-avatar { margin-right: 10px; }
.message-row.from-user .msg-avatar { margin-left: 10px; order: 2; }
.message-bubble {
  max-width: 60%;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
}
.message-image {
  max-width: 300px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #f0f0f0;
}
.message-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.2s;
}
.message-image img:hover {
  transform: scale(1.02);
  word-break: break-word;
  position: relative;
}
.message-row.from-gf .message-bubble {
  background: #fff;
  color: #333;
}
.message-row.from-user .message-bubble {
  background: #95EC69;
  color: #000;
}

/* Typing Indicator Bar (at top) */
/* Typing animation for chat title */
.typing-pulse {
  /* Animation removed to prevent flickering */
  color: #576b95;
}

/* Old typing indicator (keep for backward compatibility) */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 4px;
  max-width: 80px;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* System Notification in Chat */
.message-row.system-notification {
  justify-content: center;
  margin: 12px 0;
}
.notification-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0f0f0;
  padding: 8px 16px;
  border-radius: 16px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: background 0.15s;
}
.notification-bubble:hover {
  background: #e0e0e0;
}
.notification-bubble.no-click {
  cursor: default;
}
.notification-bubble.no-click:hover {
  background: #f0f0f0;
}
.notification-icon { font-size: 14px; }
.notification-text { color: #576b95; }

/* Chat Input */
.chat-input-area {
  background: #f5f5f5;
  border-top: 1px solid #d6d6d6;
  display: flex;
  flex-direction: column;
}
.chat-toolbar {
  padding: 2px 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid #e5e5e5;
  background: #fff;
}
.toolbar-icon { 
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: all 0.2s;
}
.toolbar-icon:hover { 
  color: #333;
  transform: scale(1.1);
}
.toolbar-icon svg {
  display: block;
}
.chat-input-wrapper { 
  flex: 1;
  padding: 6px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input-wrapper textarea {
  flex: 1;
  border: none;
  background: #fff;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 36px;
}
.chat-send-bar {
  display: flex;
  align-items: center;
}
.chat-send-bar button {
  padding: 7px 16px;
  background: #07C160;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.chat-send-bar button:hover { background: #06AD56; }
.chat-send-bar button:disabled { 
  background: #ccc; 
  cursor: not-allowed; 
}

/* ===== Contact Detail View ===== */
.detail-header {
  height: 50px;
  background: #ededed;
  border-bottom: 1px solid #d6d6d6;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 400;
  gap: 12px;
}
.detail-back {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #333;
  display: flex;
  align-items: center;
}
.detail-content {
  flex: 1;
  overflow-y: auto;
  background: #f5f5f5;
}
.detail-content::-webkit-scrollbar { width: 5px; }
.detail-content::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.detail-profile {
  background: #fff;
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  background: #eee;
}
.detail-info { flex: 1; }
.detail-name {
  font-size: 18px;
  font-weight: 500;
  color: #000;
  margin-bottom: 6px;
}
.detail-meta {
  font-size: 13px;
  color: #888;
}

.detail-section {
  background: #fff;
  padding: 14px 20px;
  border-bottom: 1px solid #f0f0f0;
}
.detail-label {
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
}
.detail-value {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
}

/* Affection display */
.affection-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.affection-stage {
  font-size: 14px;
  color: #576b95;
  font-weight: 500;
}
.affection-score {
  font-size: 13px;
  color: #999;
}
.affection-bar {
  width: 100%;
  height: 6px;
  background: #e5e5e5;
  border-radius: 3px;
  overflow: hidden;
}
.affection-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b9d 0%, #ffa8c5 100%);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.detail-moments-entry {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  transition: background 0.15s;
}
.detail-moments-entry:hover { background: #f8f8f8; }
.moments-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 8px;
  background: #f44336;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
}
.detail-moments-preview {
  flex: 1;
  display: flex;
  gap: 4px;
  min-height: 60px;
}
.moments-preview-loading {
  color: #999;
  font-size: 13px;
  display: flex;
  align-items: center;
}
.moments-preview-img {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  object-fit: cover;
  background: #f0f0f0;
}
.detail-arrow {
  flex-shrink: 0;
}

.detail-actions {
  display: flex;
  gap: 12px;
  padding: 20px;
  background: #fff;
  margin-top: 12px;
}
.detail-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: #f5f5f5;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  color: #333;
}
.detail-action-btn:hover { background: #e8e8e8; }
.detail-action-btn span { font-size: 12px; }
.detail-action-btn svg { color: #07C160; }

/* ===== Moments View ===== */
.moments-header {
  height: 50px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 500;
}
.moments-back {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  color: #333;
  margin-right: 8px;
}
.moments-header-spacer { flex: 1; }
.moments-content {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}
.moments-content::-webkit-scrollbar { width: 5px; }
.moments-content::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* Moments Cover */
.moments-cover {
  height: 260px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-size: cover;
  background-position: center;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}
.moments-cover-info {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 12px;
}
.moments-cover-name {
  color: white;
  font-size: 17px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.moments-cover-avatar {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  border: 2px solid #fff;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transform: translateY(20px);
}

/* Moments Posts */
.moments-posts {
  padding: 30px 0 20px;
}

.moment-date-group {
  padding: 0 16px;
}
.moment-date-label {
  font-size: 12px;
  color: #999;
  padding: 16px 0 4px 0;
  font-weight: 500;
}
.moment-date-label:first-child { padding-top: 8px; }

.moment-item {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.moment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  margin-right: 10px;
  flex-shrink: 0;
  overflow: hidden;
  background: #eee;
}
.moment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.moment-body { flex: 1; min-width: 0; }
.moment-author {
  font-size: 14px;
  color: #576b95;
  font-weight: 500;
  margin-bottom: 4px;
}
.moment-text {
  font-size: 14px;
  color: #333;
  line-height: 1.6;
  margin-bottom: 8px;
  word-break: break-word;
}
.moment-images {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}
.moment-images.count-1 { grid-template-columns: 1fr; max-width: 240px; }
.moment-images.count-2 { grid-template-columns: 1fr 1fr; max-width: 320px; }
.moment-images.count-3 { grid-template-columns: 1fr 1fr 1fr; max-width: 360px; }
.moment-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  background: #f0f0f0;
  cursor: pointer;
}
.moment-images img:hover { opacity: 0.9; }
.moment-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}
.moment-location { color: #576b95; }
.moment-comments {
  background: #f7f7f7;
  border-radius: 2px;
  padding: 6px 8px;
  margin-top: 8px;
  font-size: 13px;
}
.moment-likes {
  color: #576b95;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}
.moment-comment-item { padding: 2px 0; line-height: 1.4; }
.moment-comment-item .commenter { color: #576b95; font-weight: 500; }

/* Moments Unlock Divider */
.moments-unlock-divider {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  gap: 12px;
}
.moments-unlock-line {
  flex: 1;
  height: 1px;
  background: #e0e0e0;
}
.moments-unlock-text {
  font-size: 13px;
  color: #888;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.moments-unlock-redpacket {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #f56c6c;
  cursor: pointer;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 16px;
  background: #fff5f5;
  border: 1px solid #fdd;
  transition: all 0.2s;
}
.moments-unlock-redpacket:hover {
  background: #fee;
  border-color: #f56c6c;
}
.moments-unlock-redpacket:active {
  transform: scale(0.96);
}
.moments-unlock-redpacket svg {
  flex-shrink: 0;
}

/* Locked moment with fog overlay */
.moment-locked-wrapper {
  position: relative;
  overflow: hidden;
}
.moment-locked-fog {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.88) 40%, rgba(255,255,255,0.96) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

/* Load More */
.moments-load-more {
  text-align: center;
  padding: 30px 20px;
  color: #999;
  font-size: 14px;
}

.load-more-trigger {
  padding: 10px;
  cursor: default;
  user-select: none;
}

/* Loading */
.moments-loading {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}
.loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #eee;
  border-top-color: #07C160;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login loading overlay */
.login-loading {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: white;
}
.login-loading .loading-spinner {
  width: 40px;
  height: 40px;
  border-width: 4px;
  margin-bottom: 20px;
}
.login-loading p { font-size: 14px; }

/* Moments context menu button (like WeChat) */
.moment-action-btn {
  display: none; /* Hidden for now */
}

/* Image preview overlay */
.image-preview {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
}
.image-preview img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

/* Image preview modal */
.image-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.image-preview-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.image-preview-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.image-preview-container img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-preview-close {
  position: absolute;
  top: -45px;
  right: 0;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.image-preview-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Mobile menu button */
.mobile-back-btn {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: #333;
  margin-right: 10px;
}

.mobile-back-btn:active {
  opacity: 0.7;
}


/* ===== Mobile Bottom Navigation Bar ===== */
.mobile-bottom-nav {
  display: none;
}

/* ===== Mobile Responsive Design ===== */
@media (max-width: 768px) {
  /* Full screen on mobile */
  .wechat-container {
    width: 100vw;
    height: calc(100vh - 50px);
    max-width: 100vw;
    max-height: calc(100vh - 50px);
    border-radius: 0;
  }
  
  /* Hide left sidebar icons on mobile */
  .sidebar-icons {
    display: none !important;
  }
  
  /* Mobile navigation: show sidebar by default, hide main-content */
  .sidebar {
    width: 100%;
    flex: 1;
    display: flex;
  }
  
  .main-content {
    position: fixed;
    left: 100%;
    top: 0;
    width: 100%;
    height: calc(100% - 50px);
    z-index: 1000;
    transition: left 0.3s ease;
  }
  
  /* When chat is active, show main-content */
  .main-content.mobile-active {
    left: 0;
  }
  
  /* Show back button in chat header on mobile */
  .mobile-back-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: #000;
    margin-right: 8px;
  }
  
  /* Show bottom nav on mobile */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #f7f7f7;
    border-top: 1px solid #d6d6d6;
    z-index: 1001;
    align-items: center;
    justify-content: space-around;
  }
  
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: #999;
    font-size: 10px;
    gap: 2px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  
  .mobile-nav-item.active {
    color: #07C160;
  }
  
  .mobile-nav-item.disabled {
    color: #ccc;
  }
  
  .mobile-nav-item svg {
    width: 24px;
    height: 24px;
  }
  
  .mobile-nav-label {
    font-size: 10px;
    line-height: 1;
  }
  
  /* Login page adjustments */
  .login-container {
    width: 90%;
    padding: 30px 20px;
  }
  
  .login-form input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Chat header with menu button */
  .chat-header {
    padding: 12px 10px;
  }
  
  #chatTitle {
    font-size: 16px;
  }
  
  /* Contact list */
  .contact-item {
    padding: 12px 10px;
  }
  
  .contact-avatar {
    width: 44px;
    height: 44px;
  }
  
  .contact-name {
    font-size: 15px;
  }
  
  .contact-msg {
    font-size: 13px;
  }
  
  /* Chat messages */
  .message-row {
    padding: 8px 10px;
  }
  
  .msg-avatar {
    width: 36px;
    height: 36px;
  }
  
  .msg-avatar img {
    width: 36px;
    height: 36px;
  }
  
  .message-bubble {
    max-width: 70%;
    font-size: 15px;
    padding: 8px 12px;
  }
  
  /* Input area */
  .chat-toolbar {
    padding: 8px 10px;
    gap: 15px;
  }
  
  .toolbar-icon svg {
    width: 22px;
    height: 22px;
  }
  
  .chat-input-wrapper {
    padding: 8px 10px;
  }
  
  .chat-input-wrapper textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 36px;
  }
  
  #sendBtn {
    font-size: 14px;
    padding: 6px 12px;
  }
  
  /* Moments page */
  .moments-cover {
    height: 200px;
  }
  
  .moments-header-info {
    bottom: 15px;
    right: 15px;
  }
  
  .moments-avatar {
    width: 60px;
    height: 60px;
  }
  
  .moments-post {
    padding: 15px 10px;
  }
  
  .moment-images {
    gap: 4px;
  }
  
  .moment-images img {
    border-radius: 4px;
  }
  
  /* Detail page */
  .detail-header {
    padding: 12px 10px;
  }
  
  .detail-content {
    padding: 15px 10px;
  }
  
  .detail-avatar {
    width: 60px;
    height: 60px;
  }
  
  .detail-name {
    font-size: 18px;
  }
  
  .detail-section {
    padding: 12px 0;
  }
  
  .detail-actions {
    padding: 15px 0;
    gap: 8px;
  }
  
  .detail-action-btn {
    padding: 10px 8px;
    font-size: 13px;
  }
  
  .detail-action-btn svg {
    width: 20px;
    height: 20px;
  }
  
  /* Image preview */
  .image-preview-close {
    top: 10px;
    right: 10px;
  }
}

/* Extra small devices (phones in portrait, less than 576px) */
@media (max-width: 576px) {
  .login-logo {
    font-size: 48px;
    margin-bottom: 20px;
  }
  
  .login-title {
    font-size: 20px;
  }
  
  .message-bubble {
    max-width: 75%;
    font-size: 14px;
  }
  
  .chat-toolbar {
    gap: 12px;
  }
  
  .moments-cover {
    height: 180px;
  }
  
  .moments-avatar {
    width: 50px;
    height: 50px;
  }
  
  .detail-action-btn {
    flex-direction: column;
    gap: 4px;
    padding: 8px 6px;
    font-size: 12px;
  }
  
  .detail-action-btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 0;
  }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .moments-cover {
    height: 150px;
  }
  
  .chat-messages {
    max-height: calc(100vh - 200px);
  }
}

/* Tablet devices */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }
  
  .main-content {
    margin-left: 280px;
  }
  
  .contact-list {
    max-height: calc(100vh - 110px);
  }
}

/* ============================================================
   Payment Modal
   ============================================================ */
.payment-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.payment-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.payment-dialog {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  z-index: 1;
}

.payment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #07C160;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
}

.payment-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.8;
}
.payment-close:hover {
  opacity: 1;
}

.payment-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.payment-qrcode {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 8px;
}

.payment-qrcode canvas {
  width: 100% !important;
  height: 100% !important;
}

.payment-amount {
  font-size: 16px;
  color: #333;
}

.payment-price {
  font-size: 24px;
  font-weight: 600;
  color: #e64340;
}

.payment-status {
  font-size: 14px;
  color: #888;
  text-align: center;
}

.payment-save-btn {
  display: inline-block;
  padding: 8px 24px;
  font-size: 14px;
  color: #fff;
  background: #07c160;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.payment-save-btn:active {
  background: #06ad56;
}

.payment-save-tip {
  font-size: 12px;
  color: #aaa;
  text-align: center;
}

.payment-status.success {
  color: #07C160;
  font-weight: 500;
}

.payment-status.error {
  color: #e64340;
}

/* Sandbox / Mock Mode Styles */
.payment-sandbox-badge {
  background: #ff9800;
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
  margin-left: 8px;
}

.payment-mock-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
  width: 100%;
}

.mock-countdown-icon {
  font-size: 32px;
}

.mock-countdown-text {
  font-size: 14px;
  color: #f57c00;
  font-weight: 500;
}

.mock-countdown-bar {
  width: 100%;
  height: 6px;
  background: #ffe0b2;
  border-radius: 3px;
  overflow: hidden;
}

.mock-countdown-progress {
  height: 100%;
  background: linear-gradient(90deg, #ff9800, #f57c00);
  border-radius: 3px;
  transition: width 1s linear;
  width: 100%;
}

/* In sandbox mode, the header has an orange accent */
.payment-dialog.sandbox-mode .payment-header {
  background: linear-gradient(135deg, #ff9800, #f57c00);
}

.payment-dialog.sandbox-mode .payment-qrcode {
  border-color: #ffe082;
  position: relative;
}

.payment-dialog.sandbox-mode .payment-qrcode::after {
  content: '沙盒测试';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 24px;
  font-weight: bold;
  color: rgba(255, 152, 0, 0.2);
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 4px;
}

/* ============================================================
   Agreement Modal
   ============================================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden {
  display: none;
}
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 1;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 500;
  color: #333;
}
.close-modal {
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}
.close-modal:hover {
  color: #333;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
}
.agreement-text h4 {
  font-size: 16px;
  margin: 16px 0 10px;
  color: #333;
}
.agreement-text h4:first-child {
  margin-top: 0;
}
.agreement-text p {
  margin-bottom: 12px;
}
.agreement-text ul {
  padding-left: 20px;
  margin-bottom: 16px;
}
.agreement-text li {
  margin-bottom: 6px;
}
.agreement-text hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 20px 0;
}
.disclaimer-list li {
  color: #666;
  font-size: 13px;
}
.disclaimer-list strong {
  color: #333;
}
.footer-note {
  margin-top: 20px;
  text-align: right;
  font-style: italic;
  color: #999;
}
.agree-btn {
  width: 100%;
  padding: 12px;
  background: #07C160;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 20px;
}
.agree-btn:hover {
  background: #06AD56;
}

/* ============================================================
   Red Packet Amount Dialog
   ============================================================ */
.redpacket-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.redpacket-dialog {
  background: #fff;
  border-radius: 12px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.redpacket-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.redpacket-dialog-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.redpacket-dialog-close:hover {
  color: #fff;
}
.redpacket-dialog-body {
  padding: 18px;
}
.redpacket-presets {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.redpacket-preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fef5f5;
  border: 1px solid #f5d5d5;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.redpacket-preset-item:hover {
  background: #fce8e8;
  border-color: #e74c3c;
}
.redpacket-preset-item:active {
  transform: scale(0.98);
}
.redpacket-preset-item.selected {
  background: #fce8e8;
  border-color: #e74c3c;
  box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.15);
}
.preset-label {
  font-size: 14px;
  color: #333;
  font-weight: 500;
}
.preset-amount {
  font-size: 16px;
  color: #e74c3c;
  font-weight: 600;
}
.redpacket-dialog-footer {
  display: flex;
  gap: 10px;
  padding: 0 18px 18px;
  justify-content: flex-end;
}
.redpacket-btn-cancel,
.redpacket-btn-confirm {
  padding: 8px 24px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-weight: 500;
  transition: all 0.15s;
}
.redpacket-btn-cancel {
  background: #f0f0f0;
  color: #666;
}
.redpacket-btn-cancel:hover {
  background: #e0e0e0;
}
.redpacket-btn-confirm {
  background: #e74c3c;
  color: #fff;
}
.redpacket-btn-confirm:hover {
  background: #c0392b;
}

/* ============================================================
   Moments Unlock Tier Dialog
   ============================================================ */
.moments-unlock-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.moments-unlock-dialog {
  background: #fff;
  border-radius: 12px;
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.moments-unlock-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #576b95, #3a5998);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.moments-unlock-dialog-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.moments-unlock-dialog-close:hover {
  color: #fff;
}
.moments-unlock-dialog-body {
  padding: 18px;
}
.moments-unlock-dialog-desc {
  font-size: 14px;
  color: #666;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
}
.moments-unlock-tiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.moments-unlock-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: #f8f9ff;
  border: 2px solid #e8ecf5;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  gap: 4px;
}
.moments-unlock-tier:hover {
  background: #eef1ff;
  border-color: #576b95;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(87, 107, 149, 0.15);
}
.moments-unlock-tier:active {
  transform: scale(0.97);
}
.moments-unlock-tier.featured {
  border-color: #576b95;
  background: #eef1ff;
}
.tier-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  background: #f56c6c;
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 0 8px 0 8px;
  font-weight: 500;
}
.tier-amount {
  font-size: 22px;
  font-weight: 700;
  color: #576b95;
}
.tier-label {
  font-size: 12px;
  color: #999;
}
.moments-unlock-dialog-footer {
  display: flex;
  padding: 0 18px 18px;
  justify-content: center;
}
.moments-unlock-btn-cancel {
  padding: 8px 32px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-weight: 500;
  transition: all 0.15s;
  background: #f0f0f0;
  color: #666;
}
.moments-unlock-btn-cancel:hover {
  background: #e0e0e0;
}
