/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 56px);
}

.threads {
  border-right: 1px solid #e5e5e5;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.threadList {
  overflow: auto;
  flex: 1;
}

.threadItem {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}

.threadItem:hover { background: #fafafa; }
.threadItem.active { background: #eef5ff; }

.threadTop {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.threadName {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}
.threadPhone {
  font-size: 0.82rem;
  color: #666;
}
.threadPreview {
  font-size: 0.85rem;
  color: #555;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.threadTime {
  font-size: 0.75rem;
  color: #777;
  white-space: nowrap;
}

.chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chatHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.messageList {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: #fbfbfb;
}

.msgRow {
  display: flex;
  margin-bottom: 10px;
}

.msgRow.inbound { justify-content: flex-start; }
.msgRow.outbound { justify-content: flex-end; }

.bubble {
  max-width: min(720px, 85%);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #eee;
  background: white;
}

.msgRow.outbound .bubble {
  background: #e8f1ff;
  border-color: #d6e6ff;
}

.bubble .meta {
  margin-top: 6px;
  font-size: 0.72rem;
  color: #666;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.attachmentThumb {
  margin-top: 8px;
  cursor: pointer;
  border-radius: 10px;
  max-width: 260px;
  max-height: 200px;
  object-fit: cover;
  border: 1px solid #e6e6e6;
}

.mediaContainer {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.mediaContainer img,
.mediaContainer video {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .threads { height: 45vh; }
  .chat { height: calc(55vh - 56px); }
}
