/* Chat polish: header hierarchy, compact tools, background selector. */
.chat-presence.contact-meta {
  display: flex !important;
  flex-wrap: wrap !important;
  align-content: center !important;
  align-items: center !important;
  justify-content: center !important;
  column-gap: 6px !important;
  row-gap: 1px !important;
  min-height: 48px !important;
  padding: 4px 72px 5px !important;
  box-sizing: border-box !important;
}

.chat-presence .contact-name-red {
  max-width: min(54vw, 240px) !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 20px !important;
  color: #e5484d !important;
}

.chat-presence .contact-vip-badge {
  flex: 0 0 auto !important;
  min-width: 29px !important;
  height: 16px !important;
  padding: 0 6px !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #4a3f68, #76659b) !important;
  color: #fff !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  line-height: 16px !important;
  text-align: center !important;
  box-sizing: border-box !important;
}

.chat-presence .presence-dot {
  display: none !important;
}

.chat-presence .presence-copy {
  flex: 0 0 100% !important;
  width: 100% !important;
  color: #718096 !important;
  font-size: 11px !important;
  line-height: 16px !important;
  text-align: center !important;
}

.popup-layer .more-layer .list {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 16px 8px !important;
  padding: 6px 10px 12px !important;
  box-sizing: border-box !important;
}

.popup-layer .more-layer .list .box {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 7px !important;
}

.popup-layer .more-layer .list .tool-icon {
  width: 46px !important;
  height: 46px !important;
  flex: 0 0 46px !important;
  border: 1px solid #e6eaf0 !important;
  border-radius: 14px !important;
  background-color: #fff !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 24px 24px !important;
  box-shadow: 0 5px 16px rgba(34, 48, 73, .07) !important;
  color: transparent !important;
  font-size: 0 !important;
  box-sizing: border-box !important;
}

.popup-layer .more-layer .list .tool_text {
  width: 100% !important;
  color: #303846 !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 16px !important;
  text-align: center !important;
  white-space: nowrap !important;
}

.tool-album { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234f5f73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='3'/%3E%3Ccircle cx='9' cy='9' r='1.5'/%3E%3Cpath d='m5.5 17 4.5-4 3 2.5 2.5-2 3 3.5'/%3E%3C/svg%3E") !important; }
.tool-camera { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234f5f73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7h3l1.4-2h5.2L16 7h3a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z'/%3E%3Ccircle cx='12' cy='13' r='3.5'/%3E%3C/svg%3E") !important; }
.tool-redpacket { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23e45454' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='3' width='14' height='18' rx='3'/%3E%3Cpath d='M5 8c4 3 10 3 14 0'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3C/svg%3E") !important; }
.tool-transfer { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234f5f73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h14l-3-3M20 16H6l3 3'/%3E%3C/svg%3E") !important; }
.tool-phone { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234f5f73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 4 5 5.5c-1 1-.4 4.5 2.5 7.5s6.5 4.5 8 3.5L18 14l-4-2-1.5 1.5c-1.7-.7-3.3-2.3-4-4L10 8 7 4Z'/%3E%3C/svg%3E") !important; }
.tool-video { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234f5f73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='6' width='13' height='12' rx='3'/%3E%3Cpath d='m16 10 5-3v10l-5-3'/%3E%3C/svg%3E") !important; }
.tool-file { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234f5f73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h8l4 4v14H6z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h5'/%3E%3C/svg%3E") !important; }
.tool-gift { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234f5f73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='9' width='18' height='12' rx='2'/%3E%3Cpath d='M12 9v12M3 13h18M12 9H8.5A2.5 2.5 0 1 1 11 6.5ZM12 9h3.5A2.5 2.5 0 1 0 13 6.5Z'/%3E%3C/svg%3E") !important; }

.content.has-chat-background {
  background-color: #eef2f6 !important;
  background-image: linear-gradient(rgba(247, 249, 252, .18), rgba(247, 249, 252, .18)), var(--chat-bg-image) !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

.content.has-chat-background .msg-list {
  background: transparent !important;
}

.chat-bg-panel {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 12px 10px !important;
  padding: 14px !important;
  border-top: 1px solid #edf0f4 !important;
  background: #fbfcfe !important;
  box-sizing: border-box !important;
}

.chat-bg-option {
  position: relative !important;
  min-width: 0 !important;
}

.chat-bg-thumb {
  width: 100% !important;
  aspect-ratio: 4 / 5 !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 2px solid transparent !important;
  border-radius: 12px !important;
  background-color: #eef2f6 !important;
  background-position: center !important;
  background-size: cover !important;
  color: #8491a3 !important;
  font-size: 12px !important;
  box-shadow: inset 0 0 0 1px rgba(44, 62, 80, .05) !important;
  box-sizing: border-box !important;
}

.chat-bg-option.active .chat-bg-thumb {
  border-color: #347ff0 !important;
  box-shadow: 0 0 0 3px rgba(52, 127, 240, .12) !important;
}

.chat-bg-option.active::after {
  content: "✓" !important;
  position: absolute !important;
  top: 6px !important;
  right: 6px !important;
  width: 20px !important;
  height: 20px !important;
  border-radius: 50% !important;
  background: #347ff0 !important;
  color: #fff !important;
  font-size: 12px !important;
  line-height: 20px !important;
  text-align: center !important;
  box-shadow: 0 2px 7px rgba(31, 87, 179, .25) !important;
}

.chat-bg-name {
  margin-top: 6px !important;
  overflow: hidden !important;
  color: #435064 !important;
  font-size: 11px !important;
  line-height: 16px !important;
  text-align: center !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

@media (max-width: 380px) {
  .popup-layer .more-layer .list { gap: 13px 5px !important; padding-inline: 4px !important; }
  .popup-layer .more-layer .list .tool-icon { width: 42px !important; height: 42px !important; flex-basis: 42px !important; }
  .chat-bg-panel { gap: 10px 8px !important; padding: 12px !important; }
}

/* Background status text is secondary information, not a second title. */
.chat-bg-current-value {
  flex: 0 1 auto !important;
  max-width: 128px !important;
  margin-left: auto !important;
  overflow: hidden !important;
  color: #7a8797 !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 18px !important;
  letter-spacing: 0 !important;
  text-align: right !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.chat-bg-current-value + .row-arrow {
  margin-left: 8px !important;
}

/* The compiled page injects a later scoped `background` shorthand.
   Use a more specific rule and paint the image on the actual scroll viewport. */
uni-page-body .page .content.has-chat-background,
body .page .content.has-chat-background {
  background-color: #eef2f6 !important;
  background-image: none !important;
}

uni-page-body .page .content.has-chat-background .msg-list,
body .page .content.has-chat-background .msg-list {
  background-color: transparent !important;
  background-image: linear-gradient(rgba(247, 249, 252, .14), rgba(247, 249, 252, .14)), var(--chat-bg-image) !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

uni-page-body .page .content.has-chat-background .msg-list .uni-scroll-view,
uni-page-body .page .content.has-chat-background .msg-list .uni-scroll-view-content,
body .page .content.has-chat-background .msg-list .uni-scroll-view,
body .page .content.has-chat-background .msg-list .uni-scroll-view-content {
  background-color: transparent !important;
  background-image: none !important;
}
