:root {
  --bg: #d5dde8;
  --phone: #f7f7f8;
  --line: #d9d9de;
  --text: #16181d;
  --ios-blue: #0a84ff;
  --ios-gray: #e9e9eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, #e7edf6 0%, #c8d2df 100%);
  color: var(--text);
  min-height: 100vh;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.phone {
  width: min(880px, 100%);
  height: min(90vh, 860px);
  background: var(--phone);
  border: 1px solid #c7ccd6;
  border-radius: 24px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  box-shadow: 0 20px 60px rgba(0, 17, 34, 0.18);
}

.topbar {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: #ffffffd4;
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 1rem;
  text-align: center;
}

input,
textarea,
button {
  font: inherit;
}

.chat {
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

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

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

.bubble {
  position: relative;
  max-width: min(75%, 640px);
  border-radius: 18px;
  padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user .bubble {
  background: var(--ios-blue);
  color: #fff;
}

.message.assistant .bubble {
  background: var(--ios-gray);
  color: #111;
}

.content {
  min-height: 20px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 10px 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  background: #fff;
}

.composer textarea {
  resize: none;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 10px 14px;
  min-height: 42px;
  max-height: 120px;
}

button {
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ios-blue);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a6a6ad;
  animation: blink 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 0;
  }

  .phone {
    height: 100vh;
    border-radius: 0;
    border: none;
  }

  .bubble {
    max-width: 86%;
  }
}
