.csm-chat {
  --chat-ink: #122546;
  --chat-muted: #43566d;
  --chat-border: #d2dce9;
  --chat-surface: #f5f8fc;
  position: fixed;
  z-index: 48;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--chat-keyboard, 0px));
  width: min(370px, calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  color: var(--chat-ink);
  color-scheme: light;
  font: 14px/1.45 system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.csm-chat [hidden], .csm-chat[hidden] { display: none !important; }
.csm-chat > * { pointer-events: auto; }
.csm-chat :is(button, a, input):focus-visible {
  outline: 2px solid #2368b9;
  outline-offset: 2px;
}

.csm-chat button { font: inherit; }
.csm-chat .csm-chat-launch {
  order: 1;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid #293f61;
  border-radius: 24px;
  color: #fff;
  background: var(--chat-ink);
  box-shadow: 0 4px 15px #12254633;
  font-weight: 700;
}

.csm-chat-icon {
  position: relative;
  width: 17px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}

.csm-chat-icon::after {
  position: absolute;
  bottom: -4px;
  left: 3px;
  width: 5px;
  height: 5px;
  content: "";
  background: var(--chat-ink);
  border-bottom: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: skewY(-35deg);
}

.csm-chat-invite, .csm-chat-panel {
  background: #fff;
  border: 1px solid var(--chat-border);
  box-shadow: 0 10px 32px #12254626;
}

.csm-chat-invite {
  position: relative;
  max-width: 100%;
  border-radius: 16px;
  padding: 13px 48px 8px 15px;
}

.csm-chat-invite p { font-weight: 700; }
.csm-chat .csm-chat-start {
  min-height: 38px;
  padding: 0 2px;
  background: none;
  color: #174e96;
  font-weight: 650;
}

.csm-chat .csm-chat-close {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 24px;
  line-height: 1;
}

.csm-chat-invite .csm-chat-close { position: absolute; top: 4px; right: 4px; }
.csm-chat-invite .csm-chat-close:hover { background: #e9eff7; }

.csm-chat-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(500px, calc(var(--chat-viewport, 100dvh) - 90px));
  border-radius: 18px;
  overflow: hidden;
}

.csm-chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 10px 16px;
  background: var(--chat-ink);
  color: #fff;
}

.csm-chat-top p { margin: 0; color: #d6e3f5; font-size: 12px; }
.csm-chat-top h2 { margin: 0; font: 700 18px/1.3 system-ui, sans-serif; color: inherit; }
.csm-chat-top .csm-chat-close:hover { background: #ffffff26; }
.csm-chat-top .csm-chat-close:focus-visible { outline-color: #bddbff; }

.csm-chat-body {
  min-height: 0;
  padding: 14px;
  background: var(--chat-surface);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.csm-chat-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.csm-chat-actions button {
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  background: #fff;
  color: #174e96;
  font-size: 12px;
  font-weight: 650;
}

.csm-chat-reply, .csm-chat-question {
  width: fit-content;
  max-width: 95%;
  margin: 0;
  padding: 9px 11px;
  border-radius: 12px;
  overflow-wrap: anywhere;
}

.csm-chat-reply { background: #e7eef8; }
.csm-chat-question { margin: 12px 0 8px auto; background: var(--chat-ink); color: #fff; }
.csm-chat-status { margin: 8px 0 0; color: var(--chat-muted); }
.csm-chat-status:empty { margin: 0; }

.csm-chat-results { display: grid; gap: 6px; list-style: none; padding: 0; margin: 8px 0 0; }
.csm-chat-results a, .csm-chat-links a {
  display: block;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  color: #174e96;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.csm-chat-links { display: grid; gap: 6px; margin-top: 8px; }
.csm-chat :is(.csm-chat-results, .csm-chat-links) a:hover,
.csm-chat-actions button:hover { background: #edf4fd; }
.csm-chat-results small { display: block; color: var(--chat-muted); font-weight: 500; }
.csm-chat-results .csm-chat-available { color: #176449; }

.csm-chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--chat-border); }
.csm-chat-form input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #9eacc0;
  border-radius: 9px;
  background: #fff;
  color: var(--chat-ink);
  font: 16px/1.3 system-ui, sans-serif;
}
.csm-chat-form input::placeholder { color: var(--chat-muted); }
.csm-chat-form button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--chat-ink);
  color: #fff;
  font-weight: 700;
}

.csm-chat[data-keyboard] .csm-chat-launch { display: none; }
.csm-chat[data-keyboard] .csm-chat-panel { max-height: calc(var(--chat-viewport) - 36px); }

.csm-chat-privacy {margin:0;padding:8px 12px;color:#43566d;font-size:11px;line-height:1.4;background:#fff}
.csm-chat-photo {float:left;width:48px;height:60px;object-fit:contain;margin:0 10px 4px 0;border-radius:4px}
.csm-chat-results a {display:flow-root}
.csm-chat-reply {white-space:pre-line}
.csm-chat-error button,.csm-chat-error a {display:inline-block;margin:8px 8px 0 0;padding:8px;background:#fff;color:#174e96;border:1px solid #d2dce9;border-radius:8px}
.csm-chat-shake {animation:csm-chat-attention .65s ease-in-out}
@keyframes csm-chat-attention {0%,100%{transform:translateX(0)}25%{transform:translateX(-3px) rotate(-3deg)}50%{transform:translateX(3px) rotate(3deg)}75%{transform:translateX(-2px) rotate(-2deg)}}
@media(prefers-reduced-motion:reduce){.csm-chat-shake{animation:none}}
