/* ============================================
   私信功能样式 - 卡哇伊风格
   ============================================ */

/* 页面整体 */
.messages-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  padding-top: 76px;
  min-height: calc(100vh - 76px);
  padding-bottom: 80px;
}

.messages-container {
  display: flex;
  gap: 0;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(255, 107, 157, 0.08);
  border: 1px solid rgba(255, 107, 157, 0.08);
  min-height: calc(100vh - 160px);
}

/* 左侧会话列表 */
.messages-sidebar {
  width: 320px;
  min-width: 320px;
  background: #FFF8FA;
  border-right: 1px solid rgba(255, 107, 157, 0.08);
  display: flex;
  flex-direction: column;
}

.sidebar-top-actions {
  padding: 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 107, 157, 0.06);
}

.btn-new-conversation {
  background: linear-gradient(135deg, #FF6B9D, #C084FC);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-new-conversation:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
}

/* 会话列表 */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 6px;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.conversation-item:hover {
  border-color: rgba(255, 107, 157, 0.2);
  background: rgba(255, 107, 157, 0.03);
}

.conversation-item.active {
  border-color: #FF6B9D;
  background: rgba(255, 107, 157, 0.06);
}

.conversation-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 107, 157, 0.2);
}

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

.conversation-partner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.conversation-partner span {
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
}

.conversation-time {
  font-size: 0.7rem;
  color: #999;
  flex-shrink: 0;
  margin-left: 8px;
}

.conversation-last-message {
  font-size: 0.8rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-unread {
  background: #FF6B9D;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  flex-shrink: 0;
  padding: 0 5px;
}

.conversation-empty {
  text-align: center;
  padding: 60px 20px;
  color: #bbb;
}

.conversation-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.conversation-empty p {
  font-size: 0.85rem;
}

/* 右侧消息区域 */
.messages-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fafafa;
}

.messages-header-bar {
  padding: 14px 20px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 107, 157, 0.06);
  position: relative;
}

.current-partner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.partner-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 107, 157, 0.2);
}

.partner-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
}

.partner-status {
  font-size: 0.75rem;
  color: #999;
}

.header-actions {
  display: flex;
  gap: 6px;
  position: relative;
}

.btn-action {
  background: none;
  border: 1px solid rgba(255, 107, 157, 0.15);
  color: #FF6B9D;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-action:hover {
  background: rgba(255, 107, 157, 0.08);
  transform: scale(1.05);
}

/* 消息列表 */
.messages-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-item {
  display: flex;
  max-width: 75%;
}

.message-item.sent {
  align-self: flex-end;
}

.message-item.received {
  align-self: flex-start;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.message-item.sent .message-bubble {
  background: linear-gradient(135deg, #FF6B9D, #C084FC);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-item.received .message-bubble {
  background: #fff;
  color: #333;
  border: 1px solid rgba(255, 107, 157, 0.12);
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
  text-align: right;
}

.message-item.received .message-time {
  color: #bbb;
  text-align: left;
}

.message-status {
  font-size: 0.6rem;
  margin-left: 4px;
  opacity: 0.7;
}

.message-empty {
  text-align: center;
  padding: 80px 20px;
  color: #bbb;
}

.message-empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.message-empty p {
  font-size: 0.9rem;
}

/* 消息输入 */
.message-input-area {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid rgba(255, 107, 157, 0.06);
}

.message-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.message-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255, 107, 157, 0.2);
  border-radius: 18px;
  font-size: 0.9rem;
  resize: none;
  max-height: 100px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.2s;
  background: #f9f9f9;
}

.message-textarea:focus {
  border-color: #FF6B9D;
  background: #fff;
}

.btn-send {
  background: linear-gradient(135deg, #FF6B9D, #C084FC);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 加载状态 */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #bbb;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
  border: 3px solid rgba(255, 107, 157, 0.12);
  border-top: 3px solid #FF6B9D;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  width: 90%;
  max-width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-overlay.show .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 20px 24px 12px;
  background: linear-gradient(135deg, #FF6B9D, #C084FC);
  text-align: center;
  border-radius: 20px 20px 0 0;
  position: relative;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255,255,255,0.35);
  transform: rotate(90deg);
}

.modal-body {
  padding: 20px 24px;
}

.modal-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(255,107,157,0.2);
  border-radius: 12px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.modal-search-input:focus {
  border-color: #FF6B9D;
}

.user-list {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 12px;
}

.user-list-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: #f9f9f9;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.user-list-item:hover {
  border-color: rgba(255,107,157,0.2);
  background: rgba(255,107,157,0.03);
}

.user-list-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 10px;
  border: 2px solid rgba(255,107,157,0.2);
}

.user-list-info {
  flex: 1;
}

.user-list-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
}

.user-list-username {
  font-size: 0.75rem;
  color: #999;
}

.btn-start-chat {
  background: linear-gradient(135deg, #FF6B9D, #C084FC);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-start-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(255,107,157,0.3);
}

/* 消息详情 */
.message-detail-content {
  padding: 12px 0;
}

.message-detail-content p {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #666;
}

.message-detail-content p strong {
  color: #333;
}

.message-detail-content .msg-body {
  background: #f5f5f5;
  padding: 16px;
  border-radius: 12px;
  margin-top: 12px;
  line-height: 1.6;
  font-size: 0.9rem;
  color: #333;
}

.message-detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
}

.btn-delete {
  background: #EF4444;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-delete:hover {
  background: #DC2626;
}

.btn-close-detail {
  background: #6B7280;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-close-detail:hover {
  background: #4B5563;
}

/* 会话菜单 */
.btn-conversation-menu {
  position: relative;
}

.conversation-menu {
  position: absolute;
  top: 50px;
  right: 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  z-index: 1000;
  min-width: 160px;
  padding: 6px;
  display: none;
}

.conversation-menu.show {
  display: block;
  animation: slideIn 0.2s ease;
}

.menu-item {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #333;
  transition: background 0.15s;
}

.menu-item:hover {
  background: rgba(255,107,157,0.06);
}

.menu-divider {
  height: 1px;
  padding: 0;
  margin: 4px 0;
  background: rgba(255,107,157,0.08);
  border-radius: 0;
}

.menu-item-danger {
  color: #EF4444 !important;
}
.menu-item-danger:hover {
  background: rgba(239,68,68,0.08) !important;
}

/* 免打扰标志 */
.dnd-badge {
  font-size: 14px;
  opacity: 0.7;
  pointer-events: none;
  display: flex;
  align-items: center;
  margin-right: 4px;
}

/* 菜单滑块 */
.menu-slider {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px !important;
  cursor: default !important;
}
.menu-slider:hover {
  background: transparent !important;
}
.menu-slider-label {
  font-size: 0.85rem;
  color: #333;
}
/* 开关滑块 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.switch input:checked + .switch-slider {
  background: linear-gradient(135deg, #FF6B9D, #C084FC);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* 会话列表免打扰图标 */
.conversation-dnd-icon {
  font-size: 11px;
  opacity: 0.5;
  margin-left: 4px;
}

/* 侧栏设置 */
.sidebar-settings {
  margin-top: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255,107,157,0.06);
}

.sidebar-setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  cursor: pointer;
  font-size: 0.8rem;
  color: #666;
}

.sidebar-setting-item input[type="checkbox"] {
  accent-color: #FF6B9D;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.sidebar-setting-btn {
  display: block;
  width: 100%;
  padding: 8px 0;
  margin-top: 4px;
  background: none;
  border: 1px solid rgba(255,107,157,0.12);
  border-radius: 10px;
  color: #666;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.sidebar-setting-btn:hover {
  border-color: #FF6B9D;
  color: #FF6B9D;
}

/* 移动端返回按钮 */
.btn-back-mobile {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #FF6B9D;
  cursor: pointer;
  padding: 4px 8px;
  margin-right: 4px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .btn-back-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* 动画 */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}



/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .messages-page {
    padding: 0;
    padding-top: calc(var(--navbar-height, 56px) + 16px);
    padding-bottom: 56px;
  }

  .messages-container {
    border-radius: 0;
    border: none;
    min-height: 0;
  }

  .messages-sidebar {
    width: 100%;
    min-width: 100%;
    border-right: none;
  }

  .messages-main {
    display: none;
  }

  .messages-main.show {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 56px;
    z-index: 100;
    background: #fafafa;
  }

  .messages-sidebar.hide {
    display: none;
  }

  .messages-header-bar {
    flex-shrink: 0;
    padding: 12px 14px;
  }

  .messages-list-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
  }

  .message-input-area {
    flex-shrink: 0;
    padding: 10px 12px;
  }

  .sidebar-top-actions {
    padding: 12px;
  }

  .message-item {
    max-width: 85%;
  }

  .modal-card {
    width: 92%;
    max-width: none;
    max-height: 70vh;
  }

  .conversation-menu {
    top: 44px;
    right: 12px;
  }

  .user-list {
    max-height: 40vh;
  }
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 157, 0.2);
  border-radius: 2px;
}

/* ============================================
   私信页独立排版优化
   保留聊天页的粉紫气质，强化会话扫描、消息阅读和移动端返回路径。
   ============================================ */
body.messages-page {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body.messages-page main.messages-page {
  max-width: 1160px;
  padding-top: calc(var(--navbar-height, 64px) + 20px);
  padding-left: 20px;
  padding-right: 20px;
}

body.messages-page .messages-container {
  min-height: min(760px, calc(100vh - 150px));
  border-radius: 22px;
  box-shadow: 0 12px 36px rgba(255, 107, 157, 0.1);
}

body.messages-page .messages-sidebar {
  width: 340px;
  min-width: 340px;
  background: linear-gradient(180deg, #fff8fb 0%, #fffafd 55%, #f9f5ff 100%);
}

body.messages-page .sidebar-top-actions {
  padding: 18px;
}

body.messages-page .btn-new-conversation {
  min-height: 44px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(255, 107, 157, 0.16);
}

body.messages-page .conversation-list {
  padding: 10px;
}

body.messages-page .conversation-item {
  min-height: 68px;
  margin-bottom: 8px;
  padding: 11px 12px;
  border-radius: 15px;
}

body.messages-page .conversation-item.active {
  background: linear-gradient(90deg, rgba(255, 107, 157, 0.11), rgba(167, 139, 250, 0.08));
  box-shadow: inset 3px 0 0 #ff6b9d;
}

body.messages-page .messages-main {
  background: linear-gradient(180deg, #fffefe 0%, #faf8ff 100%);
}

body.messages-page .messages-header-bar {
  min-height: 68px;
  padding: 12px 20px;
  box-sizing: border-box;
}

body.messages-page .messages-list-container {
  padding: 22px 24px;
}

body.messages-page .messages-list {
  gap: 12px;
  max-width: 820px;
  margin: 0 auto;
}

body.messages-page .message-item {
  max-width: min(78%, 620px);
}

body.messages-page .message-bubble {
  padding: 11px 15px;
  border-radius: 17px;
  line-height: 1.6;
}

body.messages-page .message-input-area {
  padding: 14px 20px 18px;
}

body.messages-page .message-input-wrapper {
  max-width: 820px;
  margin: 0 auto;
}

body.messages-page .message-textarea {
  min-height: 48px;
  padding: 12px 15px;
  background: rgba(255,255,255,0.9);
}

body.messages-page .btn-send {
  width: 48px;
  height: 48px;
  box-shadow: 0 6px 16px rgba(255, 107, 157, 0.18);
}

body.messages-page .message-empty {
  padding: 120px 20px;
}

@media (max-width: 768px) {
  body.messages-page main.messages-page {
    padding: calc(var(--navbar-height, 56px) + 8px) 0 64px;
  }

  body.messages-page .messages-container {
    min-height: calc(100vh - 128px);
    border-radius: 0;
  }

  body.messages-page .messages-sidebar {
    background: linear-gradient(180deg, #fff9fb, #fbf7ff);
  }

  body.messages-page .conversation-item {
    min-height: 70px;
  }

  body.messages-page .messages-main.show {
    top: var(--navbar-height, 56px);
    bottom: 56px;
  }

  body.messages-page .messages-list-container {
    padding: 14px 12px;
  }

  body.messages-page .message-item {
    max-width: 88%;
  }

  body.messages-page .message-input-area {
    padding: 10px 12px 12px;
  }

  body.messages-page .message-empty {
    padding: 86px 18px;
  }
}

/* ===== 私信页交互收口 ===== */
body.messages-page .messages-container,
body.messages-page .messages-sidebar,
body.messages-page .messages-main,
body.messages-page .messages-list-container,
body.messages-page .message-input-wrapper {
  min-width: 0;
}

body.messages-page .conversation-item,
body.messages-page .btn-new-conversation,
body.messages-page .btn-action,
body.messages-page .btn-send,
body.messages-page .state-retry {
  touch-action: manipulation;
}

body.messages-page .conversation-item {
  overflow-wrap: anywhere;
}

body.messages-page .btn-action,
body.messages-page .btn-send {
  min-width: 44px;
  min-height: 44px;
}

body.messages-page .state-error {
  min-height: 180px;
}

@media (max-width: 768px) {
  body.messages-page main.messages-page {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  body.messages-page .messages-main.show {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  body.messages-page .messages-list-container {
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
  }

  body.messages-page .message-input-area {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  body.messages-page .message-item {
    max-width: min(88%, 620px);
  }

  body.messages-page .modal-card {
    width: min(92vw, 440px);
    max-height: calc(100dvh - 112px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.messages-page .message-item,
  body.messages-page .conversation-item,
  body.messages-page .modal-card {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== 私信页第二轮收口：移动端稳定的双层阅读布局 ===== */
body.messages-page .messages-container,
body.messages-page .messages-sidebar,
body.messages-page .messages-main,
body.messages-page .messages-list-container,
body.messages-page .message-input-wrapper,
body.messages-page .current-partner,
body.messages-page .partner-info {
  min-width: 0;
}

body.messages-page .messages-list-container,
body.messages-page .conversation-list {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body.messages-page .conversation-partner,
body.messages-page .partner-name,
body.messages-page .conversation-last-message,
body.messages-page .message-bubble {
  overflow-wrap: anywhere;
  word-break: break-word;
}

body.messages-page .conversation-partner > span:first-child,
body.messages-page .partner-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.messages-page .message-input-wrapper {
  align-items: flex-end;
}

body.messages-page .message-textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

body.messages-page .message-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.messages-page .message-detail-actions > button {
  min-height: 44px;
  min-width: 96px;
  flex: 1 1 120px;
}

body.messages-page .user-list-item {
  min-width: 0;
}

body.messages-page .user-list-info {
  min-width: 0;
}

@media (min-width: 769px) {
  body.messages-page .messages-container {
    height: min(760px, calc(100vh - 150px));
  }

  body.messages-page .messages-list-container {
    min-height: 0;
  }
}

@media (max-width: 768px) {
  body.messages-page main.messages-page {
    width: 100%;
    max-width: none;
    padding-top: calc(var(--navbar-height, 56px) + 8px);
    padding-right: 0;
    padding-left: 0;
  }

  body.messages-page .messages-container {
    width: 100%;
    min-height: calc(100dvh - var(--navbar-height, 56px) - 68px);
  }

  body.messages-page .messages-main.show {
    top: var(--navbar-height, 56px);
    right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    left: 0;
    width: 100%;
    min-width: 0;
    height: auto;
  }

  body.messages-page .messages-header-bar {
    gap: 8px;
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
  }

  body.messages-page .current-partner {
    flex: 1 1 auto;
  }

  body.messages-page .header-actions {
    flex: 0 0 auto;
  }

  body.messages-page .messages-list-container {
    min-height: 0;
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
  }

  body.messages-page .message-item {
    max-width: min(88%, 32rem);
  }

  body.messages-page .message-input-area {
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
  }

  body.messages-page .message-detail-actions > button {
    flex-basis: calc(50% - 4px);
  }

  body.messages-page .modal-card {
    width: min(92vw, 440px);
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 112px);
  }
}

@media (max-width: 380px) {
  body.messages-page .conversation-item {
    padding-right: 9px;
    padding-left: 9px;
  }

  body.messages-page .conversation-avatar {
    width: 40px;
    height: 40px;
    margin-right: 9px;
  }

  body.messages-page .message-bubble {
    padding: 10px 12px;
    font-size: 0.86rem;
  }

  body.messages-page .message-detail-actions > button {
    flex-basis: 100%;
  }
}

/* ===== 私信移动端最终收口：全宽对话层与独立纵向滚动 ===== */
@media (max-width: 768px) {
  body.messages-page {
    width: 100%;
    overflow-x: hidden;
  }

  body.messages-page main.messages-page {
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
    margin: 0;
  }

  body.messages-page .messages-container,
  body.messages-page .messages-sidebar {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  body.messages-page .messages-main.show {
    display: flex;
    position: fixed;
    top: var(--navbar-height, 56px);
    right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    left: 0;
    width: 100vw;
    max-width: none;
    height: auto;
    min-height: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  body.messages-page .messages-list-container {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    box-sizing: border-box;
  }

  body.messages-page .messages-list {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
  }

  body.messages-page .message-item {
    max-width: min(88%, 620px);
  }
}
