* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1b120c;
  color: #f5e9df;
  height: 100vh;
  height: 100dvh; /* accounts for mobile browser address bar so it doesn't get pushed out of view */
  overflow: hidden;
}
#chat-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #4a3325;
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #c1522b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.header-text { flex: 1; }
.header-text h1 { font-size: 18px; margin: 0; }
.header-text span { font-size: 12px; color: #c8a98b; }
#logout-btn {
  background: transparent;
  border: 1px solid #4a3325;
  color: #c8a98b;
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
}
#logout-btn:hover { background: #3a2818; color: #f5e9df; }
#messages {
  flex: 1;
  min-height: 0; /* without this, flex items refuse to shrink below their content's natural height, which was pushing the input box off-screen on shorter (mobile) viewports */
  overflow-y: auto;
  padding: 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.msg.pet {
  background: #3a2818;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.sticker-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  align-self: center;
  display: block;
}
.msg-text {
  white-space: pre-wrap;
}
.msg.own {
  background: #c1522b;
  color: #1b120c;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg.system {
  align-self: center;
  background: transparent;
  color: #c8a98b;
  font-style: italic;
  font-size: 12px;
}
#typing-indicator {
  font-size: 12px;
  color: #c8a98b;
  padding: 0 4px 8px;
}
#typing-indicator.hidden { display: none; }
.dots span {
  animation: blink 1.4s infinite both;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}
#message-form {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #4a3325;
  flex-shrink: 0;
}
header { flex-shrink: 0; }
#message-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid #4a3325;
  background: #241609;
  color: #f5e9df;
  font-size: 14px;
}
#message-input:focus { outline: 2px solid #c1522b; }
#message-form button {
  padding: 10px 20px;
  border: none;
  border-radius: 20px;
  background: #c1522b;
  color: #1b120c;
  font-weight: 600;
  cursor: pointer;
}
#message-form button:hover { background: #d96a41; }

.login-body {
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #241609;
  border: 1px solid #4a3325;
  border-radius: 16px;
  padding: 32px;
  width: 320px;
  text-align: center;
}
.avatar.large {
  width: 64px;
  height: 64px;
  font-size: 32px;
  margin: 0 auto 12px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .subtitle { color: #c8a98b; margin: 0 0 20px; font-size: 14px; }
#login-form input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid #4a3325;
  background: #1b120c;
  color: #f5e9df;
  font-size: 14px;
}
#login-form input:focus { outline: 2px solid #c1522b; }
#login-form button {
  width: 100%;
  padding: 10px 14px;
  margin-top: 4px;
  border: none;
  border-radius: 10px;
  background: #c1522b;
  color: #1b120c;
  font-weight: 600;
  cursor: pointer;
}
#login-form button:hover { background: #d96a41; }
.login-card .error { color: #f87171; font-size: 13px; min-height: 18px; margin: 10px 0 0; }
