.support-chat{
  position:fixed;
  right:18px;
  bottom:104px;
  z-index:80;
  font-family:'Cairo',system-ui,sans-serif;
}

.support-chat__button{
  width:50px;
  height:50px;
  border:0;
  border-radius:50%;
  display:grid;
  place-items:center;
  cursor:pointer;
  background:var(--grad);
  color:#041120;
  box-shadow:0 14px 34px rgba(17,140,255,.26);
  transition:transform .18s ease,box-shadow .18s ease,filter .18s ease;
}

.support-chat__button:hover{
  transform:translateY(-2px);
  box-shadow:0 18px 42px rgba(17,140,255,.32);
  filter:saturate(1.05);
}

.support-chat__button svg{
  width:23px;
  height:23px;
  fill:currentColor;
}

.support-chat__panel{
  position:absolute;
  right:0;
  bottom:62px;
  width:min(360px,calc(100vw - 32px));
  height:min(520px,calc(100vh - 136px));
  display:none;
  grid-template-rows:auto minmax(0,1fr) auto;
  background:color-mix(in srgb,var(--surface) 97%,transparent);
  border:1px solid color-mix(in srgb,var(--line) 86%,transparent);
  border-radius:20px;
  box-shadow:0 22px 58px rgba(3,16,33,.22);
  overflow:hidden;
  backdrop-filter:blur(16px);
}

.support-chat.is-open .support-chat__panel{
  display:grid;
}

.support-chat__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  min-height:58px;
  padding:12px 13px;
  border-bottom:1px solid color-mix(in srgb,var(--line) 78%,transparent);
  background:linear-gradient(135deg,rgba(66,239,230,.11),rgba(156,101,255,.075));
}

.support-chat__header strong{
  display:block;
  font-size:14px;
  line-height:1.25;
  letter-spacing:0;
}

.support-chat__header span{
  display:block;
  max-width:260px;
  color:var(--muted);
  font-size:10.5px;
  line-height:1.35;
  font-weight:800;
  margin-top:2px;
}

.support-chat__close{
  flex:0 0 auto;
  width:28px;
  height:28px;
  border-radius:50%;
  border:1px solid var(--line);
  background:var(--control-bg);
  color:var(--text);
  cursor:pointer;
  font-size:18px;
  line-height:1;
}

.support-chat__messages{
  min-height:0;
  padding:11px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:7px;
  scrollbar-width:thin;
}

.support-chat__message{
  max-width:86%;
  padding:7px 9px;
  border-radius:13px;
  background:var(--control-bg);
  color:var(--soft);
  font-size:12.5px;
  line-height:1.55;
  white-space:pre-wrap;
  box-shadow:0 7px 18px rgba(3,16,33,.07);
}

.support-chat__message.is-user{
  align-self:flex-end;
  background:var(--grad);
  color:#041120;
  border-bottom-left-radius:13px;
  border-bottom-right-radius:5px;
}

[dir="ltr"] .support-chat__message.is-user{
  align-self:flex-end;
  border-bottom-right-radius:5px;
  border-bottom-left-radius:13px;
}

.support-chat__message.is-assistant{
  align-self:flex-start;
  border-bottom-right-radius:13px;
  border-bottom-left-radius:5px;
}

[dir="ltr"] .support-chat__message.is-assistant{
  border-bottom-left-radius:5px;
  border-bottom-right-radius:13px;
}

.support-chat__message.is-error{
  border:1px solid rgba(244,67,54,.35);
  color:#ffb4ac;
}

.support-chat__message.is-loading{
  opacity:.72;
  font-style:italic;
}

.support-chat__form,
.support-chat__escalation{
  padding:10px;
  border-top:1px solid color-mix(in srgb,var(--line) 78%,transparent);
  background:color-mix(in srgb,var(--surface2) 76%,transparent);
}

.support-chat__human{
  width:100%;
  border:1px solid rgba(66,239,230,.32);
  background:rgba(66,239,230,.085);
  color:var(--soft);
  border-radius:11px;
  padding:7px 9px;
  font:inherit;
  font-size:12.5px;
  line-height:1.35;
  font-weight:900;
  cursor:pointer;
  margin-bottom:7px;
}

.support-chat__input-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:7px;
  align-items:end;
}

.support-chat textarea,
.support-chat input{
  width:100%;
  border-radius:11px;
  font-size:12.5px;
  line-height:1.45;
}

.support-chat__input-row textarea{
  min-height:38px;
  max-height:88px;
  resize:vertical;
}

.support-chat__input-row button,
.support-chat__escalation button[type="submit"]{
  min-height:38px;
  border:0;
  border-radius:11px;
  background:var(--grad);
  color:#041120;
  font:inherit;
  font-size:12.5px;
  line-height:1.2;
  font-weight:900;
  padding:9px 11px;
  cursor:pointer;
  white-space:nowrap;
}

.support-chat__escalation{
  display:grid;
  gap:7px;
}

.support-chat__escalation[hidden]{
  display:none;
}

.support-chat__escalation strong{
  font-size:13px;
  line-height:1.3;
}

.support-chat__escalation input{
  min-height:38px;
}

.support-chat__escalation textarea{
  min-height:82px;
  max-height:120px;
  resize:vertical;
}

.support-chat__escalation div{
  display:flex;
  gap:7px;
  justify-content:flex-end;
}

.support-chat__escalation button[data-cancel]{
  min-height:38px;
  border:1px solid var(--line);
  border-radius:11px;
  background:var(--control-bg);
  color:var(--text);
  font:inherit;
  font-size:12.5px;
  font-weight:900;
  padding:9px 11px;
  cursor:pointer;
}

.support-chat.is-busy button{
  opacity:.75;
}

@media(max-width:560px){
  .support-chat{
    right:12px;
    bottom:92px;
  }

  .support-chat__button{
    width:48px;
    height:48px;
  }

  .support-chat__button svg{
    width:22px;
    height:22px;
  }

  .support-chat__panel{
    right:0;
    bottom:58px;
    width:calc(100vw - 24px);
    height:min(70vh,500px);
    border-radius:18px;
  }

  .support-chat__header{
    min-height:54px;
    padding:10px 12px;
  }

  .support-chat__header span{
    max-width:220px;
  }

  .support-chat__messages{
    padding:10px;
  }

  .support-chat__input-row{
    grid-template-columns:minmax(0,1fr) auto;
  }

  .support-chat__input-row button{
    min-width:64px;
  }
}

@media(max-width:380px){
  .support-chat__panel{
    height:min(68vh,470px);
  }

  .support-chat__input-row{
    grid-template-columns:1fr;
  }

  .support-chat__input-row button{
    width:100%;
  }
}
