* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #2d3748;
  background: #f0edf5;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.chat-container {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(139, 127, 199, 0.15);
  display: flex;
  flex-direction: column;
  height: 85vh;
  max-height: 700px;
  overflow: hidden;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #8b7fc7, #a78bfa);
  color: white;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon { font-size: 24px; }

.chat-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.online-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
}

.pulse {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafafa;
}

.message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.other {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e8e4f0;
  border-bottom-left-radius: 4px;
}

.message.self {
  align-self: flex-end;
  background: #8b7fc7;
  color: white;
  border-bottom-right-radius: 4px;
}

.message-username {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
  opacity: 0.7;
}

.message.self .message-username { color: rgba(255,255,255,0.8); }

.message-text {
  font-size: 14px;
  word-break: break-word;
}

.message-time {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 4px;
  text-align: right;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: #a0aec0;
  gap: 8px;
}

.empty-state span { font-size: 40px; }

/* Input area */
.input-area {
  padding: 12px 16px;
  border-top: 1px solid #e8e4f0;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.username-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.username-row label {
  font-size: 12px;
  font-weight: 600;
  color: #718096;
  white-space: nowrap;
}

.username-row input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #e8e4f0;
  border-radius: 8px;
  width: 100%;
}

.message-row {
  display: flex;
  gap: 8px;
}

.message-row input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid #e8e4f0;
  border-radius: 12px;
}

.message-row input:focus,
.username-row input:focus {
  outline: none;
  border-color: #8b7fc7;
  box-shadow: 0 0 0 3px rgba(139, 127, 199, 0.1);
}

.btn-send {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: #8b7fc7;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-send:hover:not(:disabled) {
  background: #7c6fb8;
  transform: translateY(-1px);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Scrollbar */
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: #d4d0e0; border-radius: 3px; }

/* Responsive */
@media (max-width: 500px) {
  .chat-container {
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
  body { padding: 0; }
}