:root {
  --red: #d9272e;
  --red-dark: #a9141b;
  --red-soft: #fff0f0;
  --ink: #1f2024;
  --muted: #7c7c82;
  --line: #e7e5e3;
  --canvas: #f3f2f1;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family:
    "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.messenger-shell {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
}

.conversation-sidebar,
.chat-pane {
  min-width: 0;
  background: white;
}

.conversation-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 23px 12px;
}

.mini-brand {
  color: var(--red);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-decoration: none;
}

.sidebar-header h1 {
  margin: 4px 0 0;
  font-size: 27px;
}

.compose-button {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--red-dark);
  background: var(--red-soft);
  cursor: pointer;
}

.compose-button:hover {
  color: white;
  background: var(--red);
}

.conversation-search {
  height: 43px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 20px 13px;
  padding: 0 13px;
  border-radius: 999px;
  color: #77787d;
  background: #f0eff0;
}

.conversation-search svg {
  width: 19px;
  height: 19px;
}

.conversation-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
}

.conversation-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 58px;
  scrollbar-width: thin;
  scrollbar-color: #d0cdca transparent;
}

.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.conversation-item:hover,
.conversation-item.active {
  background: #f3f2f1;
}

.conversation-avatar,
.chat-avatar,
.user-result-avatar {
  position: relative;
  border-radius: 50%;
  overflow: hidden;
  color: white;
  background: linear-gradient(145deg, #dc3138, #8e1219);
}

.conversation-avatar {
  width: 52px;
  height: 52px;
}

.conversation-avatar img,
.chat-avatar img,
.user-result-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.avatar-initial {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 750;
}

.conversation-copy {
  min-width: 0;
}

.conversation-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conversation-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seller-pill {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 999px;
  color: var(--red-dark);
  background: var(--red-soft);
  font-size: 7px;
  font-weight: 650;
}

.conversation-preview {
  margin: 5px 0 0;
  overflow: hidden;
  color: #85858a;
  font-size: 10px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.conversation-time {
  color: #9b9b9f;
  font-size: 8px;
}

.unread-dot {
  min-width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  color: white;
  background: var(--red);
  font-size: 7px;
  font-weight: 700;
}

.sidebar-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.sidebar-footer a {
  color: #8c8986;
  font-size: 9px;
  text-decoration: none;
}

.chat-pane {
  position: relative;
}

.empty-chat {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.empty-chat-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--red);
  background: var(--red-soft);
}

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

.empty-chat h2 {
  margin: 16px 0 6px;
  font-size: 21px;
}

.empty-chat p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.empty-chat button {
  margin-top: 17px;
  padding: 9px 14px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--red);
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}

.active-chat {
  height: 100%;
  display: grid;
  grid-template-rows: 72px auto minmax(0, 1fr) auto;
}

.active-chat[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.mobile-back {
  display: none;
}

.chat-person {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.chat-avatar {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
}

.chat-person-copy {
  min-width: 0;
}

.chat-person-copy strong,
.chat-person-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-person-copy strong {
  font-size: 14px;
}

.chat-person-copy span {
  margin-top: 4px;
  color: #8d8a87;
  font-size: 9px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.chat-header-actions > button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--red);
  background: var(--red-soft);
  cursor: pointer;
}

.product-link {
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--red-dark);
  background: var(--red-soft);
  font-size: 9px;
  font-weight: 650;
  text-decoration: none;
}

.product-context {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px;
  border-bottom: 1px solid var(--line);
  background: #fffdfb;
}

.product-context[hidden] {
  display: none;
}

.product-context img {
  width: 42px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
}

.product-context span {
  min-width: 0;
}

.product-context strong,
.product-context small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-context strong {
  font-size: 10px;
}

.product-context small {
  margin-top: 3px;
  color: var(--red-dark);
  font-size: 9px;
  font-weight: 650;
}

.messages-scroll {
  min-height: 0;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 10%, rgba(217, 39, 46, 0.025), transparent 20%),
    #fff;
  scrollbar-width: thin;
  scrollbar-color: #d3cfcc transparent;
}

.messages-list {
  width: min(780px, calc(100% - 42px));
  min-height: 100%;
  margin: 0 auto;
  padding: 26px 0 20px;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0 20px;
}

.date-divider span {
  padding: 5px 10px;
  border-radius: 999px;
  color: #8b8885;
  background: #f3f1f0;
  font-size: 8px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 5px 0;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: white;
  background: #ad1c24;
  font-size: 9px;
  font-weight: 700;
}

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

.message-bubble-wrap {
  max-width: min(68%, 590px);
}

.message-sender {
  margin: 0 0 4px 7px;
  color: #85817e;
  font-size: 8px;
}

.message-bubble {
  padding: 9px 13px;
  border-radius: 17px 17px 17px 5px;
  color: #2e2d31;
  background: #eee;
  font-size: 12px;
  line-height: 1.48;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-row.mine .message-bubble {
  border-radius: 17px 17px 5px 17px;
  color: white;
  background: var(--red);
}

.message-time {
  margin-top: 3px;
  color: #a09c99;
  font-size: 7px;
}

.message-row.mine .message-time {
  text-align: right;
}

.no-messages {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  color: #97938f;
  text-align: center;
}

.no-messages span {
  font-size: 34px;
}

.no-messages h3 {
  margin: 10px 0 4px;
  color: #4e4b49;
  font-size: 13px;
}

.no-messages p {
  margin: 0;
  font-size: 9px;
}

.message-composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 13px 17px 15px;
  border-top: 1px solid var(--line);
  background: white;
}

.message-composer textarea {
  min-height: 42px;
  max-height: 125px;
  flex: 1;
  resize: none;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 20px;
  outline: 0;
  color: var(--ink);
  background: #f1f0f1;
  font-size: 11px;
  line-height: 1.5;
}

.message-composer textarea:focus {
  border-color: #edb8ba;
  background: white;
  box-shadow: 0 0 0 3px var(--red-soft);
}

.message-composer button {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 15px;
  border: 0;
  border-radius: 20px;
  color: white;
  background: var(--red);
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}

.message-composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.message-composer button svg {
  width: 15px;
  height: 15px;
}

.new-message-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(33, 28, 26, 0.48);
  backdrop-filter: blur(4px);
}

.new-message-backdrop[hidden] {
  display: none;
}

.new-message-modal {
  width: min(450px, 100%);
  min-height: 390px;
  padding: 21px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 22px 60px rgba(31, 20, 17, 0.24);
}

.new-message-modal > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.new-message-modal header span {
  color: var(--red);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
}

.new-message-modal h2 {
  margin: 4px 0 0;
  font-size: 19px;
}

.new-message-modal header button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f1efed;
  cursor: pointer;
}

.user-search > span {
  display: block;
  margin-bottom: 7px;
  color: #64605d;
  font-size: 9px;
  font-weight: 650;
}

.user-search > div {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid #ddd8d5;
  border-radius: 8px;
}

.user-search div > span {
  color: var(--red);
  font-weight: 700;
}

.user-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 11px;
}

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

.search-help {
  min-height: 180px;
  display: grid;
  place-content: center;
  justify-items: center;
  color: #999490;
  text-align: center;
}

.search-help svg {
  width: 28px;
  height: 28px;
}

.search-help p {
  font-size: 9px;
}

.user-result {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.user-result:hover {
  background: #f5f3f1;
}

.user-result-avatar {
  width: 41px;
  height: 41px;
}

.user-result strong,
.user-result small {
  display: block;
}

.user-result strong {
  font-size: 11px;
}

.user-result small {
  margin-top: 3px;
  color: #918d89;
  font-size: 8px;
}

.user-result > span:last-child {
  color: var(--red);
  font-size: 9px;
  font-weight: 650;
}

.message-toast {
  position: fixed;
  z-index: 120;
  bottom: 22px;
  left: 50%;
  padding: 10px 15px;
  border-radius: 8px;
  color: white;
  background: rgba(32, 31, 31, 0.94);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 0.2s ease;
}

.message-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.conversation-empty {
  padding: 50px 25px;
  color: #918d89;
  text-align: center;
}

.conversation-empty span {
  font-size: 28px;
}

.conversation-empty h3 {
  margin: 10px 0 4px;
  color: #45423f;
  font-size: 12px;
}

.conversation-empty p {
  margin: 0;
  font-size: 9px;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .messenger-shell {
    display: block;
    background: white;
  }

  .conversation-sidebar,
  .chat-pane {
    width: 100%;
    height: 100vh;
  }

  .chat-pane {
    display: none;
  }

  body.chat-open .conversation-sidebar {
    display: none;
  }

  body.chat-open .chat-pane {
    display: block;
  }

  .mobile-back {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    background: #f2f0ee;
  }

  .chat-header {
    padding: 0 12px;
  }

  .messages-list {
    width: calc(100% - 24px);
  }

  .message-bubble-wrap {
    max-width: 78%;
  }
}
