.messages-root {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px;
}

.messages-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  height: calc(100vh - 110px);
  min-height: 420px;
}

/* ---------- Conversation list ---------- */
.convo-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}

.new-chat {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.new-chat input {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.convo-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}

.convo-empty {
  padding: 20px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
}

.convo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

.convo-item:hover {
  background: var(--panel-2);
}

.convo-item.active {
  background: rgba(93, 143, 255, 0.15);
}

.convo-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.convo-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.convo-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

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

.convo-time {
  flex-shrink: 0;
  font-size: 10.5px;
  color: var(--text-dim);
}

.convo-preview {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-item.unread .convo-preview {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Thread ---------- */
.thread-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}

.thread-empty {
  margin: auto;
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

.thread-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble-row {
  display: flex;
}

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

.bubble {
  max-width: 70%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 7px 11px;
}

.bubble-row.mine .bubble {
  background: rgba(93, 143, 255, 0.2);
  border-color: rgba(93, 143, 255, 0.4);
  border-radius: 14px 14px 4px 14px;
}

.bubble-text {
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-time {
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
}

.read-mark {
  margin-left: 4px;
  font-weight: 700;
  letter-spacing: -2px;
}

.read-mark.seen {
  color: var(--accent-2);
}

.send-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.send-form textarea {
  flex: 1;
  margin: 0;
  resize: none;
}

@media (max-width: 700px) {
  .messages-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 200px 1fr;
    height: auto;
  }

  .thread-panel {
    min-height: 420px;
  }

  .bubble {
    max-width: 85%;
  }
}
