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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --border: #0f3460;
  --accent: #e94560;
  --text: #eaeaea;
  --text-muted: #888;
  --system: #666;
  --input-bg: #0f3460;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.status {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.status.connected {
  background: #1a4a2e;
  color: #4ade80;
}

.status.disconnected {
  background: #4a1a1a;
  color: #f87171;
}

.status.reconnecting {
  background: #4a3a1a;
  color: #fbbf24;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 100%;
  animation: fadein 0.15s ease;
}

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

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.msg-username {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}

.msg-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.msg-text {
  line-height: 1.5;
  word-break: break-word;
  color: var(--text);
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  border-left: 2px solid var(--accent);
}

.msg.mine .msg-username {
  color: #60a5fa;
}

.msg.mine .msg-text {
  border-left-color: #60a5fa;
}

.msg-system {
  text-align: center;
  font-size: 0.78rem;
  color: var(--system);
  font-style: italic;
  padding: 2px 0;
}

#input-form {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}

#message-input:focus {
  border-color: var(--accent);
}

#message-input::placeholder {
  color: var(--text-muted);
}

button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

button[type="submit"]:hover {
  opacity: 0.85;
}

button[type="submit"]:active {
  opacity: 0.7;
}

#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-track {
  background: transparent;
}

#messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
