/* Base reset */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f5f7fb;
  color: #1b1d23;
}

/* App wrapper */
.app {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(600px 400px at 0% 0%, rgba(59,130,246,.15), transparent 70%),
    radial-gradient(500px 300px at 100% 0%, rgba(16,185,129,.15), transparent 70%),
    #f5f7fb;
}

/* Panels */
section {
  width: min(900px, 100%);
  background: #fff;
  border: 1px solid #e2e5ec;
  border-radius: 18px;
  overflow: hidden;
}

/* Join screen */
#join-screen { padding: 40px 28px; }
#join-screen h1 {
  margin: 0 0 20px;
  font-size: 26px;
}
#user-form { display: grid; gap: 14px; max-width: 480px; }
#user-form label {
  font-size: 14px;
  color: #6b7280;
}
#user-form input[type="text"] {
  padding: 12px 14px;
  border: 1px solid #e2e5ec;
  border-radius: 12px;
}
#user-form input[type="text"]::placeholder { color: #9aa3ad; }
#join-btn {
  width: fit-content;
  padding: 10px 16px;
  border-radius: 12px;
  background: hsl(273, 63%, 81%);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* Chat screen */
#chat-screen {
  grid-template-rows: auto 1fr auto;
  min-height: min(78vh, 820px);
}

/* Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e5ec;
}
.chat-title { margin: 0; font-size: 18px; }
.current-user {
  font-size: 13px;
  color: #6b7280;
  border: 1px solid #e2e5ec;
  padding: 4px 10px;
  border-radius: 999px;
}

/* Messages area */
.messages {
  padding: 20px 18px;
  padding-bottom: 80px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  align-content: start;
}

/* Message bubbles */
.message {
  display: grid;
  grid-template:
    "name" auto
    "bubble" auto
    "meta" auto / 1fr;
  gap: 6px;
  max-width: min(70ch, 85%);
}
.message .name {
  font-size: 12px;
  color: #6b7280;
  padding: 0 6px;
}
.message .bubble {
  background: #eef2ff;
  border: 1px solid #e2e5ec;
  padding: 10px 14px;
  border-radius: 16px;
}
.message .msg-text { margin: 0; line-height: 1.4; }
.message .meta {
  font-size: 11px;
  color: #6b7280;
  display: flex;
  gap: 8px;
  padding: 0 6px;
}

/* My messages */
.message.me { justify-self: end; text-align: right; }
.message.me .bubble { background: #fadcfc; }
.message.me .meta { justify-content: flex-end; }

/* Reactions */
.like-btn, .dislike-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: #85364b;
  background: transparent;
  cursor: pointer;
}
.like-btn:hover, .dislike-btn:hover {
  border-color: #e2e5ec;
}

/* Composer */
.composer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e2e5ec;
  background: #fff;
}
#msg-input {
  padding: 12px 14px;
  border: 1px solid #e2e5ec;
  border-radius: 999px;
}
#msg-input::placeholder { color: #9aa3ad; }
#color-picker {
  width: 42px; height: 42px;
  border-radius: 999px;
  border: 1px solid #e2e5ec;
}
#send-msg {
  width: 42px; height: 42px;
  border-radius: 999px;
  background: hsl(273, 63%, 81%);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* Small screens */
@media (max-width: 560px) {
  .app { padding: 12px; }
  #join-screen { padding: 26px 16px; }
  .current-user { display: none; }
  .message { max-width: 92%; }
}
