:root {
  color-scheme: light;
  --app-height: 100dvh;
  --viewport-top: 0px;
  --bg: #e5ddd5;
  --panel: #efeae2;
  --ink: #111b21;
  --muted: #667781;
  --brand: #008069;
  --brand-dark: #006b59;
  --user: #d9fdd3;
  --assistant: #ffffff;
  --line: #d1d7db;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #d9dbd5;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

.app {
  position: fixed;
  top: var(--viewport-top);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(920px, 100vw);
  height: var(--app-height);
  max-height: var(--app-height);
  margin: 0;
  background:
    radial-gradient(circle at 18px 18px, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    var(--panel);
  background-size: 32px 32px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #d8dee3;
}

.topbar > div {
  flex: 1;
  min-width: 0;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.topbar p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #1fa855;
  display: inline-block;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #54656f;
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover:not(:disabled) {
  background: #e4e8eb;
  color: #111b21;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  width: 100%;
  margin: 4px 0;
}

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

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

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  margin-bottom: 2px;
}

.bubble {
  width: fit-content;
  max-width: min(660px, 78%);
  padding: 8px 10px 9px;
  border-radius: 8px;
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.bubble span {
  display: block;
}

.bubble time {
  display: block;
  float: right;
  margin: 4px 0 -4px 10px;
  color: #667781;
  font-size: 11px;
  line-height: 1.2;
  user-select: none;
}

.user time {
  color: #5f7f5a;
}

.assistant {
  background: var(--assistant);
  border-top-left-radius: 2px;
}

.user {
  background: var(--user);
  border-top-right-radius: 2px;
}

.typing-bubble {
  min-width: 54px;
  padding: 11px 13px;
}

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

.bubble .typing-dots i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #9aa3a8;
  animation: typingPulse 1.2s infinite ease-in-out;
}

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

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

@keyframes typingPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.location-card {
  display: block;
  position: relative;
  width: min(360px, 78%);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.location-card:hover .location-action {
  color: var(--brand-dark);
  text-decoration: underline;
}

.location-map {
  position: relative;
  display: block;
  height: 128px;
  overflow: hidden;
  background: #dcebdc;
}

.location-map iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.location-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.location-details {
  display: grid;
  gap: 3px;
  padding: 10px 11px 8px;
}

.location-details strong {
  font-size: 15px;
  line-height: 1.2;
}

.location-details span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.location-details .location-action {
  margin-top: 3px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
}

.location-card time {
  display: block;
  margin: -2px 9px 7px 0;
  color: #667781;
  font-size: 11px;
  line-height: 1.2;
  text-align: right;
}

.contact-card {
  display: grid;
  gap: 8px;
  width: min(420px, 78%);
  padding: 11px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.contact-card strong {
  font-size: 15px;
  line-height: 1.2;
}

.contact-card > span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.contact-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #d6dee3;
  border-radius: 18px;
  background: #fff;
  color: var(--brand);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.contact-action:hover {
  border-color: rgba(0, 128, 105, 0.32);
  background: #f2fbf8;
  color: var(--brand-dark);
}

.contact-action.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.contact-action.primary:hover {
  background: var(--brand-dark);
  color: #fff;
}

.contact-action.loading {
  opacity: 0.75;
  pointer-events: none;
}

.contact-card time {
  display: block;
  margin: -2px 0 0;
  color: #667781;
  font-size: 11px;
  line-height: 1.2;
  text-align: right;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: #f0f2f5;
  border-top: 1px solid #d8dee3;
}

textarea {
  min-width: 0;
  border: 0;
  border-radius: 22px;
  padding: 12px 16px;
  font: inherit;
  line-height: 1.35;
  outline: none;
  background: #fff;
  resize: none;
  overflow-y: hidden;
  scrollbar-width: thin;
}

textarea:focus {
  box-shadow: 0 0 0 2px rgba(0, 128, 105, 0.16);
}

button {
  border: 0;
  border-radius: 22px;
  padding: 0 20px;
  min-width: 84px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

button:hover:not(:disabled) {
  background: var(--brand-dark);
}

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

  .messages {
    padding: 14px;
  }

  .bubble {
    max-width: 94%;
  }

  .location-card {
    width: min(340px, 94%);
  }

  .contact-card {
    width: min(360px, 94%);
  }

  .contact-action {
    flex: 1 1 120px;
  }

  .message-avatar {
    width: 24px;
    height: 24px;
  }

  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .composer {
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 8px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }

  button {
    min-width: 76px;
    height: 44px;
    padding: 0 14px;
  }
}
