* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #120914;
  color: #f7eef7;
}

body {
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 760px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top left, rgba(255, 113, 206, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(155, 89, 255, 0.22), transparent 38%),
    #160d19;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ff71ce, #9b59ff);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  box-shadow: 0 8px 24px rgba(255, 113, 206, 0.25);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.topbar p {
  margin: 4px 0 0;
  color: rgba(247, 238, 247, 0.62);
  font-size: 14px;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  scroll-behavior: smooth;
}

.emptyState {
  margin: 20vh auto 0;
  text-align: center;
  color: rgba(247, 238, 247, 0.72);
}

.emptyState h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.emptyState p {
  margin: 0;
}

.message {
  margin: 0 0 16px;
  max-width: 82%;
}

.message strong {
  display: block;
  margin: 0 0 5px;
  font-size: 13px;
  color: rgba(247, 238, 247, 0.66);
}

.message.user {
  margin-left: auto;
}

.message.user strong {
  text-align: right;
}

.bubble {
  white-space: pre-wrap;
  line-height: 1.45;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 15px;
}

.message.assistant .bubble {
  background: rgba(255, 255, 255, 0.09);
  border-top-left-radius: 6px;
}

.message.user .bubble {
  background: linear-gradient(135deg, #ff71ce, #9b59ff);
  color: white;
  border-top-right-radius: 6px;
}

.typing .bubble {
  color: rgba(247, 238, 247, 0.68);
  font-style: italic;
}

.inputBar {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 7, 14, 0.9);
}

textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  min-height: 46px;
  max-height: 140px;
  border-radius: 18px;
  padding: 13px 14px;
  font: inherit;
  background: rgba(255, 255, 255, 0.1);
  color: #f7eef7;
}

textarea::placeholder {
  color: rgba(247, 238, 247, 0.45);
}

button {
  border: 0;
  border-radius: 18px;
  padding: 0 18px;
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #ff71ce, #9b59ff);
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

@media (max-width: 640px) {
  .app {
    max-width: none;
  }

  .message {
    max-width: 92%;
  }

  .topbar {
    padding-top: 14px;
  }

  button {
    padding: 0 14px;
  }
}

.profileText {
  flex: 1;
}

.newChatButton {
  min-height: 38px;
  border-radius: 14px;
  padding: 0 14px;
  font-size: 13px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.newChatButton:hover {
  background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 430px) {
  .newChatButton {
    padding: 0 10px;
    font-size: 12px;
  }

  .topbar {
    gap: 10px;
  }
}

.retryButton {
  margin-top: 10px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #f0b6d5;
  color: #24111d;
  font-weight: 700;
  cursor: pointer;
}

.retryButton:hover {
  filter: brightness(1.08);
}

.errorMessage .bubble p {
  margin: 0;
}