/* Card-page-to-conversation transition */
.card-page {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f4f3ef;
  transform: translate3d(0, 0, 0);
  transition: transform .65s cubic-bezier(.76, 0, .21, 1);
  will-change: transform;
}
body.message-open { overflow: hidden; }
body.message-open .card-page { transform: translate3d(-100%, 0, 0); }

.message-invite {
  margin: 8px 0 36px;
  padding: 18px;
  border: 1px solid #d2dfec;
  border-radius: 18px;
  background: linear-gradient(145deg, #edf5fb 0%, #fff 100%);
}
#fallback .message-invite {
  margin-top: 36px;
}
.message-invite p {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #3d5970;
}
.message-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 13px 16px;
  border-radius: 14px;
  background: #1769cf;
  border: 1px solid #1769cf;
  color: white;
  box-shadow: 0 4px 0 #bed7f2, 0 9px 18px rgba(19, 87, 167, .14);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.015em;
  text-align: left;
  transition: background .2s, transform .2s, box-shadow .2s;
}
.message-trigger:hover {
  background: #0e57b6;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #bed7f2, 0 12px 22px rgba(19, 87, 167, .18);
}
.message-trigger:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #bed7f2;
}
.message-trigger .message-trigger-icon {
  display: grid;
  place-items: center;
  flex: 0 0 35px;
  height: 35px;
  border-radius: 11px;
  background: rgba(255,255,255,.17);
}
.message-trigger svg { width: 21px; height: 21px; }
.message-trigger .message-trigger-arrow { margin-left: auto; font-size: 20px; opacity: .82; }

/* A full-page Messages-inspired environment, revealed underneath the card. */
.message-screen {
  position: fixed;
  z-index: 1;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 15% 10%, #edf5ff 0%, transparent 36%),
              radial-gradient(circle at 90% 85%, #d1e1f3 0%, transparent 40%),
              #dfe6f0;
  transition: opacity .3s ease, visibility 0s linear .65s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #20242c;
}
.message-screen.is-visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}
.message-phone {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #e9edf3;
  transform: translate3d(34px, 0, 0) scale(.986);
  transition: transform .7s cubic-bezier(.17, .67, .24, 1);
}
.message-screen.is-visible .message-phone { transform: translate3d(0, 0, 0) scale(1); }
.msg-top {
  flex: 0 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 12px 13px;
  background: rgba(251, 252, 255, .96);
  border-bottom: 1px solid #d5dae2;
  box-shadow: 0 1px 9px rgba(37, 53, 80, .04);
}
.msg-top-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.msg-back {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  width: 75px;
  min-height: 48px;
  padding: 6px 0;
  border: 0;
  color: #1376e8;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
}
.msg-back:hover { color: #0056bf; }
.msg-back svg { width: 20px; height: 20px; flex: 0 0 20px; }
.msg-contact { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; }
.msg-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 5px;
  background: linear-gradient(145deg, #346e51, #12372b);
  border-radius: 50%;
  color: white;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}
.msg-contact strong { display: block; font-size: 14px; line-height: 1.2; font-weight: 650; }
.msg-contact span { display: block; margin-top: 2px; font-size: 11px; color: #7d8593; }
.msg-header-spacer { width: 75px; flex: 0 0 75px; }
.msg-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 18px clamp(15px, 4vw, 26px) 26px;
  scrollbar-color: #c5cedc transparent;
  scrollbar-width: thin;
}
.msg-date {
  margin: 2px 0 12px;
  text-align: center;
  font-size: 12px;
  color: #7d8695;
  font-weight: 600;
}
.msg-bubble-row { display: flex; width: 100%; animation: message-pop .28s cubic-bezier(.2,.8,.25,1) both; }
.msg-bubble-row.is-incoming { justify-content: flex-start; }
.msg-bubble-row.is-outgoing { justify-content: flex-end; }
.msg-bubble {
  max-width: min(85%, 395px);
  padding: 11px 15px;
  border-radius: 19px;
  background: #fff;
  color: #252932;
  box-shadow: 0 1px 2px rgba(36, 54, 80, .07);
  font-size: 16px;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.is-incoming .msg-bubble { border-bottom-left-radius: 6px; }
.is-outgoing .msg-bubble {
  border-bottom-right-radius: 6px;
  background: #1479f3;
  color: white;
  box-shadow: 0 2px 6px rgba(20, 121, 243, .12);
}
.msg-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 65px;
  min-height: 43px;
  justify-content: center;
}
.msg-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a0a7b2;
  animation: msg-typing-pulse 1s ease-in-out infinite;
}
.msg-typing-dot:nth-child(2) { animation-delay: .15s; }
.msg-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes msg-typing-pulse {
  0%, 60%, 100% { opacity: .48; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
.msg-note {
  margin: -6px 8px 6px;
  font-size: 11px;
  color: #7b8494;
}
.msg-note.is-right { text-align: right; }

.msg-composer, .msg-done {
  flex: 0 0 auto;
  padding: 12px 13px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid #d4dbe5;
  background: rgba(249, 250, 252, .98);
}
.msg-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 5px 6px 5px 16px;
  border: 1px solid #d6dbe3;
  border-radius: 25px;
  background: #fff;
}
.msg-composer-row:focus-within {
  border-color: #7db4f4;
  box-shadow: 0 0 0 2px rgba(20, 121, 243, .13);
}
.msg-composer-row input, .msg-composer-row textarea {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: auto;
  min-height: 39px;
  max-height: 135px;
  padding: 9px 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: #242a33;
  border-radius: 0;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  box-shadow: none;
}
.msg-composer-row textarea { min-height: 42px; resize: vertical; }
.msg-composer-row input:focus-visible, .msg-composer-row textarea:focus-visible { outline: none; }
.msg-composer-row input::placeholder, .msg-composer-row textarea::placeholder { color: #9198a5; }
.msg-send {
  display: grid;
  flex: 0 0 39px;
  place-items: center;
  width: 39px;
  height: 39px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #1479f3;
  color: white;
  transition: transform .18s, background .18s;
}
.msg-send:hover { transform: scale(1.06); background: #0769dc; }
.msg-send:disabled { opacity: .6; cursor: wait; }
.msg-send svg { width: 21px; height: 21px; }
.msg-send.is-sending svg { display: none; }
.msg-send.is-sending::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: white;
  border-radius: 50%;
  animation: message-spin .75s linear infinite;
}
.msg-composer-help {
  padding: 0 9px;
  margin: 9px 0 0;
  font-size: 11px;
  color: #667284;
  line-height: 1.35;
  text-align: center;
}
.msg-error {
  padding: 8px 12px;
  margin: 0 0 10px;
  border: 1px solid #e9a6a6;
  border-radius: 10px;
  background: #fff0f0;
  color: #a12424;
  font-size: 13px;
}
.msg-done { text-align: center; }
.msg-done strong { display: block; margin: 1px 0 5px; font-size: 16px; }
.msg-done p { margin: 0 0 12px; font-size: 13px; color: #6a7484; }
.msg-done button {
  padding: 10px 17px;
  border: 1px solid #1479f3;
  border-radius: 12px;
  background: #fff;
  color: #0a66cb;
  font-size: 14px;
  font-weight: 600;
}
.msg-done button:hover { background: #e9f3ff; }
.msg-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@keyframes message-pop {
  from { opacity: 0; transform: translate3d(0, 8px, 0) scale(.98); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes message-spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .message-screen { padding: 24px; }
  .message-phone {
    height: min(850px, 100%);
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 28px;
    box-shadow: 0 27px 90px rgba(33, 53, 81, .23), 0 5px 25px rgba(33, 53, 81, .08);
  }
  .msg-top { padding-top: 18px; }
  .msg-composer, .msg-done { padding-bottom: 18px; }
}
@media (max-width: 480px) {
  .message-invite { margin-top: 6px; padding: 14px; }
  .message-trigger { min-height: 58px; }
}
@media (prefers-reduced-motion: reduce) {
  .card-page, .message-screen, .message-phone,
  .message-trigger, .msg-send, .msg-bubble-row, .msg-typing-dot { transition: none; animation: none; }
}