.messages-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  background: #fff;
  border: 1px solid var(--line-200);
  border-radius: var(--radius-m);
  overflow: hidden;
  height: calc(100vh - 120px);
  min-height: 420px;
}

.thread-list {
  border-right: 1px solid var(--line-200);
  padding: 10px;
  overflow-y: auto;
  min-height: 0;
}
.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
}
.thread-item:hover {
  background: var(--mint-50);
}
.thread-item.is-active {
  background: var(--green-100);
}
.thread-item img {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}
.thread-info {
  flex: 1;
  min-width: 0;
}
.thread-info strong {
  display: block;
  font-size: 14px;
}
.thread-info span {
  display: block;
  font-size: 12.5px;
  color: var(--muted-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-time {
  font-size: 11.5px;
  color: var(--muted-500);
  flex-shrink: 0;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  padding: 2px 20px;
  min-height: 0;
}
.chat-head {
     display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line-200);
    margin-bottom: 9px;
    flex-shrink: 0;
}
.chat-head img {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
}
.chat-head strong {
  display: block;
  font-size: 15px;
}
.chat-head span {
  font-size: 12.5px;
  color: var(--muted-500);
}

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  overflow-y: auto;
  min-height: 0;
}
.bubble {
  max-width: 70%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.bubble-in {
  background: var(--mint-50);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.bubble-out {
  background: var(--green-700);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-input {
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--line-200);
  padding-top: 16px;
  flex-shrink: 0;
}
.chat-input input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line-200);
  border-radius: 999px;
  font-size: 13.5px;
}

@media (max-width: 860px) {
  .messages-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .thread-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: space-between;
    border-right: none;
    border-bottom: 1px solid var(--line-200);
    height: 5rem;
  }
  .thread-item {
    flex-direction: column;
    text-align: center;
    min-width: 120px;
  }
  .thread-info span {
    display: none;
  }
}
