/* =============================================
   CHAT PANEL
   ============================================= */
.chat-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  height: 62dvh;
  min-height: 340px;
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}

/* ---- HEADER ---- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 16px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  background: var(--bg-elevated);
  flex-shrink: 0;
  user-select: none;
}
.chat-header svg { opacity: 0.6; flex-shrink: 0; }

/* ---- SCROLLABLE DISPLAY ---- */
#chat-display {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  position: relative;
}

/* Custom scrollbar */
#chat-display::-webkit-scrollbar { width: 3px; }
#chat-display::-webkit-scrollbar-track { background: transparent; }
#chat-display::-webkit-scrollbar-thumb {
  background: var(--border-md);
  border-radius: 10px;
}

/* ---- OVERLAY (empty state) ---- */
.overlay-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
  pointer-events: none;
  padding: 20px;
  min-height: 100%;
  width: 100%;
}
.overlay-text svg { opacity: 0.35; }
.overlay-text span {
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.55;
  letter-spacing: 0.03em;
}

/* ---- MESSAGES ---- */
.message-wrapper {
  display: flex;
  width: 100%;
  animation: msgIn 0.18s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.my-msg   { justify-content: flex-end; }
.peer-msg { justify-content: flex-start; }

.message-bubble {
  max-width: 78%;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.45;
  word-break: break-word;
}
.my-msg .message-bubble {
  background: linear-gradient(135deg, #2750d8, var(--accent));
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.peer-msg .message-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: 18px 18px 18px 4px;
}

.system-msg {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-3);
  font-weight: 500;
  margin: 4px 0;
  width: 100%;
  letter-spacing: 0.04em;
}

/* ---- INPUT AREA ---- */
.message-input {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.message-input input {
  flex: 1;
  min-width: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-1);
  outline: none;
  padding: 9px 15px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.message-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.message-input input::placeholder { color: var(--text-3); }
.message-input input:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.send-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 14px var(--accent-glow);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}