:root {
  --client-chat-viewport-height: 100dvh;
  --client-chat-viewport-top: 0px;
  --client-chat-blue: #3e83f2;
  --client-chat-ink: #172235;
  --client-chat-muted: #718096;
  --client-chat-surface: #ffffff;
  --client-chat-canvas: #f3f6f9;
}

.chat-panel,
.service-support.chat-panel {
  box-sizing: border-box;
  color: var(--client-chat-ink);
  background: var(--client-chat-surface);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 18px 54px rgba(25, 43, 68, .16);
  backdrop-filter: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.chat-widget.open .chat-panel,
.service-chat-widget.open .chat-panel {
  animation: client-chat-open 180ms ease-out both;
}

@keyframes client-chat-open {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-head,
.service-support-head.chat-head {
  min-width: 0;
}

.chat-participant {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.chat-participant img,
.chat-participant-fallback {
  grid-column: 1;
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  object-fit: cover;
  color: #2866a8;
  background: #edf4fb;
  border: 0;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.chat-participant.is-ai img { padding: 5px; object-fit: contain; }
.chat-participant strong,
.service-support-head .chat-participant strong { grid-column: 2; align-self: end; min-width: 0; overflow: hidden; color: var(--client-chat-ink); font-size: 14px; font-weight: 650; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.chat-participant small { grid-column: 2; align-self: start; overflow: hidden; color: var(--client-chat-muted); font-size: 10px; font-weight: 450; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }

.chat-messages,
.service-support-messages.chat-messages {
  min-width: 0;
  background: var(--client-chat-canvas);
  border: 0;
  border-radius: 8px;
  scrollbar-gutter: stable;
}

.chat-message,
.service-support-message.chat-message {
  max-width: min(86%, 340px);
  color: var(--client-chat-ink);
  background: #fff;
  border: 0;
  border-radius: 12px 12px 12px 4px;
  box-shadow: 0 1px 4px rgba(24, 46, 73, .06);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chat-message.client,
.service-support-message-row.outgoing .service-support-message {
  align-self: flex-end;
  color: #17304b;
  background: #dfeeff;
  border: 0;
  border-radius: 12px 12px 4px 12px;
}

.chat-message-author,
.service-support-message .chat-message-author { display: none; }
.chat-message.is-new,
.service-support-message-row.pending { animation: client-chat-message 180ms ease-out both; }

@keyframes client-chat-message {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: 3px;
  color: inherit;
  font-size: 9px;
  font-weight: 400;
  opacity: .55;
}

.chat-composer,
.service-support-composer-controls.chat-composer {
  min-width: 0;
  background: #fff;
  border: 1px solid #d9e2eb;
  border-radius: 12px;
  box-shadow: none;
}

.chat-composer textarea,
.service-support-composer textarea {
  min-width: 0;
  color: var(--client-chat-ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
}

.chat-toggle,
.service-chat-widget .chat-toggle,
.chat-send,
.service-support-icon-button.primary {
  background: var(--client-chat-blue);
  background-image: none;
}

.chat-close,
.service-support .chat-close,
.chat-notifications,
.service-support .chat-notifications { background: transparent; }

.chat-scroll-down,
.service-support-down {
  position: absolute;
  right: 21px;
  bottom: 79px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #49657f;
  background: rgba(255, 255, 255, .96);
  border: 1px solid #d8e2eb;
  border-radius: 50%;
  box-shadow: 0 5px 15px rgba(30, 49, 73, .12);
}

.chat-scroll-down[hidden] { display: none; }
.chat-scroll-down svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 620px) {
  body.client-chat-open { position: fixed; inset: 0; width: 100%; overflow: hidden; }
  .chat-widget.open { top: var(--client-chat-viewport-top); right: 0; bottom: auto; left: 0; width: 100%; height: var(--client-chat-viewport-height); }
  .service-chat-widget.open { top: var(--client-chat-viewport-top); right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); left: 0; width: 100%; height: calc(var(--client-chat-viewport-height) - 58px - env(safe-area-inset-bottom)); }
  .chat-widget.open .chat-panel,
  .service-chat-widget.open .service-support.chat-panel,
  .chat-widget.has-thread .chat-panel,
  .service-chat-widget.has-thread .service-support.chat-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border-radius: 0;
  }
  .chat-messages,
  .service-support-messages.chat-messages { flex: 1 1 auto; min-height: 0; max-height: none; padding: 8px 5px; }
  .chat-message,
  .service-support-message.chat-message { max-width: 90%; }
  .chat-participant { grid-template-columns: 38px minmax(0, 1fr); }
  .chat-participant img,
  .chat-participant-fallback { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel,
  .service-support.chat-panel,
  .chat-message,
  .service-support-message-row,
  .chat-participant { animation: none !important; transition: none !important; }
}
