.studio-chat {
  --chat-blue: var(--blue, #0054a6);
  --chat-edge: clamp(12px, 2vw, 26px);
  position: fixed;
  right: max(var(--chat-edge), env(safe-area-inset-right));
  bottom: max(var(--chat-edge), env(safe-area-inset-bottom));
  z-index: 1000;
  color: #182b40;
  font: 400 1rem/1.5 Inter, Arial, sans-serif;
  text-align: left;
}
.studio-chat *, .studio-chat *::after { box-sizing: border-box; }
.studio-chat [hidden] { display: none; }
.studio-chat button { font-family: inherit; cursor: pointer; }
.studio-chat :focus-visible { outline: 3px solid #147bd0; outline-offset: 2px; }
.studio-chat .studio-chat__launcher {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid #ffffffb3;
  border-radius: 50%;
  background: var(--chat-blue);
  color: #fff;
  box-shadow: 0 4px 16px #122e4d36;
}
.studio-chat__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 27px;
  height: 21px;
  border: 2px solid currentColor;
  border-radius: 7px;
}
.studio-chat__icon::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 5px;
  width: 8px;
  height: 7px;
  background: var(--chat-blue);
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  transform: skewY(-32deg);
}
.studio-chat__icon i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: -5px 0 currentColor, 5px 0 currentColor;
}
.studio-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  width: min(365px, calc(100vw - 2 * var(--chat-edge) - env(safe-area-inset-left) - env(safe-area-inset-right)));
  height: min(440px, calc(100vh - 96px));
  height: min(440px, calc(100dvh - 96px - env(safe-area-inset-bottom)));
  overflow: auto;
  background: white;
  border: 1px solid #d5e2ee;
  border-radius: 16px;
  box-shadow: 0 10px 40px #17395829;
}
.studio-chat__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--chat-blue);
  color: white;
}
.studio-chat__header strong { display: block; font-size: 17px; }
.studio-chat__header span { display: block; font-size: 13px; color: #e3efff; }
.studio-chat__close {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: white;
  font-size: 28px;
  line-height: 1;
}
.studio-chat__close:hover { background: #ffffff24; }
.studio-chat__close:focus-visible { outline-color: white; }
.studio-chat__log {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 60px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
}
.studio-chat__message {
  align-self: flex-start;
  max-width: 90%;
  margin: 0;
  padding: 9px 12px;
  background: #eff4f9;
  border-radius: 12px 12px 12px 3px;
  font-size: 15px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.studio-chat__message[data-role="user"] {
  align-self: flex-end;
  border-radius: 12px 12px 3px;
  background: var(--chat-blue);
  color: #fff;
}
.studio-chat__speaker { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.studio-chat__status { margin: 0 16px; color: #425b73; font-size: 14px; }
.studio-chat__status:not(:empty) { padding-bottom: 8px; }
.studio-chat__form { display: flex; gap: 8px; margin: 0; padding: 12px 14px 6px; border-top: 1px solid #e0e8ef; }
.studio-chat__input, .studio-chat__send { border-radius: 8px; padding: 9px 12px; line-height: 1.4; }
.studio-chat__input { flex: 1; min-width: 0; border: 1px solid #abbccc; color: #182b40; background: #fff; font: inherit; }
.studio-chat__send { border: 0; background: var(--chat-blue); color: white; font-size: 14px; font-weight: 600; }
.studio-chat__send:disabled { opacity: .65; cursor: wait; }
.studio-chat__footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 16px 8px; }
.studio-chat__contact, .studio-chat__end { color: var(--chat-blue); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.studio-chat__end { padding: 6px 0; border: 0; background: transparent; }
.studio-chat__end:disabled { opacity: .65; cursor: wait; }

@media (max-width: 760px), (max-height: 480px) and (pointer: coarse) {
  .studio-chat {
    bottom: calc(max(var(--chat-edge), env(safe-area-inset-bottom)) + var(--chat-covered-bottom, 0px));
  }
  .studio-chat .studio-chat__launcher[aria-expanded="true"] { display: none; }
  .studio-chat__panel {
    bottom: 0;
    height: min(440px, calc(100vh - 32px));
    height: min(440px, calc(var(--chat-visible-height, 100dvh) - 2 * var(--chat-edge) - env(safe-area-inset-bottom) - env(safe-area-inset-top)));
  }
  .studio-chat__header, .studio-chat__form, .studio-chat__footer { flex-shrink: 0; }
  .studio-chat__close, .studio-chat__send { min-width: 44px; min-height: 44px; }
  .studio-chat__footer :is(a, button) { display: inline-flex; align-items: center; min-height: 44px; }
  .studio-chat__footer [hidden] { display: none; }
}
