* {
  box-sizing: border-box;
}

:root {
  --kadima-green: #0b3d2e;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --text: #14201b;
  --shadow: 0 24px 80px rgba(0,0,0,.18);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, rgba(15,46,85,.18), transparent 28%),
    radial-gradient(circle at 88% 20%, rgba(21,92,70,.20), transparent 26%),
    linear-gradient(135deg, #f5f0e7 0%, #f8f7f2 50%, #edf5f1 100%);
}

.page {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.phone {
  width: min(430px, 100%);
  height: min(760px, calc(100dvh - 44px));
  min-height: 620px;
  border-radius: 36px;
  overflow: hidden;
  background: #f0ebe0;
  box-shadow: var(--shadow);
  border: 10px solid #111;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  position: relative;
}

.phone:before {
  content: "";
  width: 136px;
  height: 26px;
  background: #111;
  border-radius: 0 0 18px 18px;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
}

.phone-top {
  background: var(--kadima-green);
  color: white;
  padding: 24px 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  position: relative;
  z-index: 2;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--kadima-green);
  font-weight: 800;
  letter-spacing: -.04em;
  flex: 0 0 auto;
  overflow: hidden;
  position: relative;
  border: 2px solid rgba(255,255,255,.72);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar span {
  display: none;
}

.avatar.fallback span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.contact {
  display: grid;
  line-height: 1.15;
}

.contact span {
  margin-top: 4px;
  font-size: 12px;
  opacity: .78;
}

.dots {
  margin-left: auto;
  letter-spacing: 2px;
  opacity: .75;
}

.chat-bg {
  min-height: 0;
  background-color: #efe7da;
  background-image:
    radial-gradient(circle at 20px 20px, rgba(11,61,46,.045) 0 2px, transparent 3px),
    radial-gradient(circle at 62px 72px, rgba(15,46,85,.035) 0 2px, transparent 3px);
  background-size: 86px 86px;
  padding: 18px 14px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}

.bubble {
  width: fit-content;
  max-width: 86%;
  padding: 10px 12px 8px;
  border-radius: 14px;
  line-height: 1.35;
  font-size: 15px;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
  animation: pop .18s ease-out;
}

.bubble.bot {
  align-self: flex-start;
  background: var(--bubble-in);
  border-top-left-radius: 4px;
}

.bubble.user {
  align-self: flex-end;
  background: var(--bubble-out);
  border-top-right-radius: 4px;
}

.bubble small {
  display: block;
  text-align: right;
  font-size: 10px;
  color: rgba(0,0,0,.45);
  margin-top: 3px;
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 13px 14px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa39e;
  animation: bounce 1s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: .15s;
}

.typing i:nth-child(3) {
  animation-delay: .3s;
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 34dvh;
  padding: 10px 12px;
  background: rgba(239,231,218,.98);
  border-top: 1px solid rgba(0,0,0,.06);
  overscroll-behavior: contain;
}

.quick-actions:empty {
  display: none;
}

.quick-actions button {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--kadima-green);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  cursor: pointer;
  line-height: 1.25;
  flex: 0 0 auto;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 8px;
  padding: 10px;
  background: #ece5da;
}

.composer.hidden {
  display: none;
}

.composer input {
  height: 46px;
  border-radius: 999px;
  border: 0;
  padding: 0 16px;
  font-size: 16px;
  outline: none;
  background: #fff;
}

.composer button {
  height: 46px;
  width: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--kadima-green);
  color: white;
  font-size: 19px;
  cursor: pointer;
}

@keyframes pop {
  from { 
    transform: translateY(4px); 
    opacity: 0; 
  }

  to { 
    transform: translateY(0); 
    opacity: 1; 
  }
}

@keyframes bounce {
  0%, 
  80%, 
  100% { 
    transform: translateY(0); 
    opacity: .5; 
  }

  40% { 
    transform: translateY(-4px); 
    opacity: 1; 
  }
}

@media (max-width: 460px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .page {
    padding: 0;
    display: block;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .phone {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .phone:before {
    display: none;
  }

  .phone-top {
    min-height: 78px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .chat-bg {
    padding: 14px 12px 18px;
  }

  .quick-actions {
    max-height: 38dvh;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .quick-actions button {
    padding: 13px 14px;
    font-size: 14px;
  }

  .composer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}