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

:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --text: #e2e8f0;
  --muted: #94a3b8;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* ---- Auth pages (login / register) ------------------------------------- */
.auth-card {
  background: var(--panel);
  padding: 2.5rem;
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.auth-card h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-card input {
  padding: 0.8rem 1rem;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  color: var(--text);
  font-size: 1rem;
}
.auth-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
button {
  padding: 0.8rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--accent-2); }
.muted { margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }
.muted a { color: var(--accent); text-decoration: none; }
.error {
  background: #7f1d1d;
  color: #fecaca;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ---- Chat room --------------------------------------------------------- */
.chat {
  background: var(--panel);
  width: 100%;
  max-width: 640px;
  height: min(80vh, 720px);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}
.chat-header .room { font-weight: 700; }
.chat-header .me { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.9rem; }
.logout-form button {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  background: #334155;
}
.logout-form button:hover { background: #475569; }

.messages {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.msg { max-width: 75%; align-self: flex-start; }
.msg .meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.15rem; }
.msg .text {
  background: #334155;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  border-top-left-radius: 2px;
  word-wrap: break-word;
}
/* Your own messages sit on the right with the accent colour. */
.msg.mine { align-self: flex-end; text-align: right; }
.msg.mine .text {
  background: var(--accent);
  border-radius: 12px;
  border-top-right-radius: 2px;
}

.composer {
  display: flex;
  gap: 0.6rem;
  padding: 0.9rem 1.25rem;
  background: #0f172a;
  border-top: 1px solid #334155;
}
.composer input {
  flex: 1;
  padding: 0.8rem 1rem;
  border: 1px solid #334155;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
}
.composer input:focus { outline: 2px solid var(--accent); border-color: transparent; }
