/* The animated Saywit conversation used on the landing and login pages. */

.chat {
  position: relative;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 30px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-float);
  text-align: left;
}

/* Header */
.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fff, var(--surface));
}
.chat__avatars { display: flex; flex: none; }
.av {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin-left: -10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  background: var(--sand);
  color: #6f5a3a;
}
.av:first-child { margin-left: 0; }
.av--peach { background: var(--peach); color: #7a5034; }
.av--sky { background: var(--sky); color: #2e5359; }
.av--lilac { background: var(--lilac); color: #55467a; }
.av--lime { background: var(--lime); color: var(--ink); }
.av--sand { background: var(--sand); color: #6f5a3a; }

.chat__who { flex: 1; min-width: 0; }
.chat__who strong { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.chat__who span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat__side { display: flex; align-items: center; gap: 10px; flex: none; }

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid #d0dcc1;
  border-radius: 999px;
  background: var(--lime-wash);
  font-size: 11px;
  font-weight: 700;
}

.mode-badge--private { border-color: #cfe2d8; background: #e3efea; color: #2d6851; }

/* AI activity: the small orbit from the real app. */
.ai-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0;
  transform: translateX(8px);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.ai-status.is-on { opacity: 1; transform: none; }
.orbit {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(35, 53, 47, .22);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
}
.orbit::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 2px var(--lime);
}

/* Messages */
.chat__body {
  position: relative;
  height: 432px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 16px 10px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 64px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 64px);
  transition: opacity .3s var(--ease);
}
.chat__body.is-clearing { opacity: 0; }
/* Hide the static (no-JS) conversation until the player takes over; reveal it anyway if JS never does. */
.js .chat__body:not(.is-live) > * { opacity: 0; animation: chat-fallback 0s 2.5s forwards; }
@keyframes chat-fallback { to { opacity: 1; } }

.msg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: flex-start;
  max-width: 84%;
  flex: none;
}
.msg--out { align-self: flex-end; align-items: flex-end; }
.msg.has-reaction { margin-bottom: 18px; }
.msg__name { margin: 0 0 4px 12px; font-size: 11px; font-weight: 650; color: var(--faint); }
.msg__bubble {
  margin: 0;
  padding: 10px 14px;
  border-radius: 20px 20px 20px 6px;
  background: var(--paper-2);
  font-size: 14px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}
.msg--out .msg__bubble { border-radius: 20px 20px 6px 20px; background: #e7ebdc; color: var(--ink); }
.msg__photo + .msg__bubble { border-top-left-radius: 8px; }
.ask-tag {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.msg__photo {
  position: relative;
  width: 232px;
  margin: 0 0 3px;
  overflow: hidden;
  border-radius: 20px 20px 8px 6px;
  aspect-ratio: 4 / 3;
  background: var(--paper-3);
}
.msg__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 1s var(--ease), transform 1.2s var(--ease);
}
.msg__photo.is-loading img { filter: blur(16px) saturate(.5); transform: scale(1.12); }
.msg__photo::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  transition: opacity .3s;
}
.msg__photo.is-loading::after { opacity: 1; animation: spin .8s linear infinite; }

.msg__reaction {
  position: absolute;
  left: 12px;
  bottom: -19px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 12px -4px rgba(26, 40, 35, .25);
  font-size: 12px;
  font-weight: 650;
}
.msg--out .msg__reaction { left: auto; right: 12px; }

/* Centered system line, e.g. the Private-mode encryption notice. */
.chat-note {
  flex: none;
  align-self: center;
  margin: 2px 0 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e3efea;
  color: #2d6851;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  text-wrap: balance;
}

/* Typing indicator */
.msg__bubble--typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.msg__bubble--typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  animation: typing 1.2s var(--ease) infinite;
}
.msg__bubble--typing i:nth-child(2) { animation-delay: .15s; }
.msg__bubble--typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
  0%, 60%, 100% { opacity: .35; transform: none; }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* AI insight: private to the person who asked. */
.insight {
  flex: none;
  align-self: flex-start;
  width: 90%;
  padding: 13px 15px 11px;
  border: 1px solid #cbd8b9;
  border-radius: 20px 20px 20px 6px;
  background: linear-gradient(165deg, #f4f6eb 0%, #e8eedb 100%);
  box-shadow: 0 16px 32px -22px rgba(83, 135, 62, .7);
}
.insight__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; font-weight: 700; }
.insight__spark {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #e8eada;
  color: var(--ink-2);
  font-size: 11px;
}
.insight__only { margin-left: auto; font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: #5f7550; }
.insight__rows { display: grid; gap: 7px; margin: 0; }
.insight__rows > div { display: grid; grid-template-columns: 72px 1fr; align-items: baseline; gap: 10px; }
.insight__rows dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #557040; }
.insight__rows dd { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.insight__src {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px dashed #c5d3b6;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: #5f7550;
}

/* Composer */
.chat__composer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 12px 12px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.chat.is-composing .chat__composer { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(168, 190, 146, .6); }
.composer__plus { flex: none; font-size: 20px; line-height: 1; color: var(--faint); }
.composer__field {
  flex: 1;
  min-width: 0;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  font-size: 14px;
  white-space: nowrap;
}
.composer__field .ask-tag { display: none; flex: none; }
.chat.is-asking .composer__field .ask-tag { display: inline-flex; }
.composer__text:empty { display: none; }
.composer__text:not(:empty) + .composer__placeholder { display: none; }
.composer__placeholder { overflow: hidden; color: var(--faint); text-overflow: ellipsis; }
.chat.is-composing .composer__text::after {
  content: "";
  display: inline-block;
  width: 1.5px;
  height: 16px;
  margin-left: 1px;
  vertical-align: -3px;
  background: var(--ink);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.composer__send {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e8eada;
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 700;
  transition: transform .2s var(--ease-spring);
}
.composer__send.is-pressed { transform: scale(.82); }

@media (max-width: 600px) {
  .chat { border-radius: 26px; }
  .chat__body { height: 400px; padding-inline: 12px; }
  .msg { max-width: 88%; }
  .msg__photo { width: 200px; }
  .mode-badge { padding-inline: 8px; }
  .chat__side .ai-status span { display: none; }
}
