* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  color: #111;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.app {
  width: 100%;
  max-width: 900px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-left: 1px solid #e5e5e5;
  border-right: 1px solid #e5e5e5;
}

.topbar {
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e8e8e8;
  background: #ffffff;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.topbar p {
  margin: 0;
  color: #555;
  font-size: 14px;
}

.chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message-row.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(75%, 700px);
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.assistant-bubble {
  background: #f3f4f6;
  color: #111;
  border-bottom-left-radius: 6px;
}

.user-bubble {
  background: #dbeafe;
  color: #111;
  border-bottom-right-radius: 6px;
}

.chat-input-area {
  display: flex;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid #e8e8e8;
  background: #ffffff;
}

#messageInput {
  flex: 1;
  resize: none;
  min-height: 52px;
  max-height: 180px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.4;
  border: 1px solid #cccccc;
  border-radius: 16px;
  outline: none;
  font-family: inherit;
}

#messageInput:focus {
  border-color: #999999;
}

#sendBtn {
  align-self: flex-end;
  height: 52px;
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  background: #111111;
  color: #ffffff;
  font-size: 15px;
  cursor: pointer;
}

#sendBtn:hover {
  opacity: 0.92;
}

#sendBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.typing {
  opacity: 0.8;
  font-style: italic;
}

@media (max-width: 700px) {
  .app {
    max-width: 100%;
    border: none;
  }

  .message-bubble {
    max-width: 88%;
  }

  .topbar h1 {
    font-size: 20px;
  }
}