* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #efeae2;
  color: #111;
}

#login-screen,
#chat-screen {
  max-width: 640px;
  margin: 0 auto;
}

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: white;
  width: 100%;
  max-width: 360px;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.login-box h1 {
  margin-top: 0;
  font-size: 24px;
  text-align: center;
}

.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
}

.login-box button,
#form button,
#logout {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: #128c7e;
  color: white;
  font-size: 16px;
  cursor: pointer;
}

.login-box button {
  width: 100%;
}

#error {
  color: #b00020;
  font-size: 14px;
  min-height: 20px;
  text-align: center;
}

#chat-screen {
  height: 100vh;
  display: none;
  flex-direction: column;
  background: #efeae2;
}

header {
  background: #075e54;
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header strong {
  font-size: 18px;
}

#logout {
  background: rgba(255,255,255,0.18);
  padding: 8px 12px;
  font-size: 14px;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.msg {
  max-width: 78%;
  padding: 10px 12px;
  margin: 8px 0;
  border-radius: 10px;
  line-height: 1.35;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

.sent {
  margin-left: auto;
  background: #d9fdd3;
  border-top-right-radius: 2px;
}

.received {
  margin-right: auto;
  background: white;
  border-top-left-radius: 2px;
}

.time {
  display: block;
  text-align: right;
  font-size: 11px;
  color: #666;
  margin-top: 4px;
}

#form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #f0f0f0;
}

#text {
  flex: 1;
  padding: 12px;
  border: 0;
  border-radius: 20px;
  font-size: 16px;
  outline: none;
}

#form button {
  border-radius: 20px;
}

#image-button {
  min-width: 74px;
  height: 44px;
  border-radius: 22px;
  background: white;
  color: #075e54;
  font-weight: bold;
  border: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.msg img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  margin-bottom: 6px;
  display: block;
  object-fit: contain;
}

@media (max-width: 520px) {
  #chat-screen,
  #login-screen {
    max-width: 100%;
  }

  #messages {
    padding: 10px;
  }

  .msg {
    max-width: 86%;
  }

  #form {
    padding: 8px;
  }

  #form button {
    padding: 12px;
  }
}
