
.lc-wrap {
  position: fixed;
  inset-inline-end: 18px;
  bottom: 18px;
  z-index: 900;
  font-family: var(--font);
  direction: rtl;
}
.lc-wrap.lc-left { inset-inline-end: auto; inset-inline-start: 18px }

.lc-fab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px 11px 14px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: var(--green, #17a673);
  color: #fff;
  font: 800 calc(12.5px * var(--fz-base, 1)) / 1 var(--font);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .17);
  position: relative;
  transition: transform .16s, box-shadow .16s, background .16s;
}
.lc-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0, 0, 0, .22) }
.lc-fab:active { transform: translateY(0) }
.lc-fab-ico { display: grid; place-items: center }
.lc-wrap.lc-offline .lc-fab { background: var(--lc-off, #2b3242); color: #fff }
.lc-wrap.is-open .lc-fab { opacity: 0; pointer-events: none }

.lc-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
  flex: 0 0 auto;
}
.lc-dot.is-on {
  background: #37e39b;
  animation: lc-pulse 2.2s ease-in-out infinite;
}
@keyframes lc-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(55, 227, 155, .35) }
  50%      { box-shadow: 0 0 0 6px rgba(55, 227, 155, 0) }
}
@media (prefers-reduced-motion: reduce) { .lc-dot.is-on { animation: none } }

.lc-badge {
  position: absolute;
  top: -6px;
  inset-inline-start: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red, #e3342f);
  color: #fff;
  font: 900 10px/20px var(--font);
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface, #fff);
}
.lc-badge[hidden] { display: none }

.lc-panel {
  position: absolute;
  inset-inline-end: 0;
  bottom: 0;
  width: 348px;
  max-width: calc(100vw - 28px);
  max-height: min(72vh, 560px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .22);
  animation: lc-in .18s ease-out;
}
.lc-wrap.lc-left .lc-panel { inset-inline-end: auto; inset-inline-start: 0 }
.lc-panel[hidden] { display: none }
@keyframes lc-in { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

.lc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  background: var(--green, #17a673);
  color: #fff;
}
.lc-head b { display: block; font-size: calc(13px * var(--fz-base, 1)) }
.lc-state { font-size: calc(10.5px * var(--fz-small, 1)); opacity: .9 }
.lc-head-act button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font: 900 15px/1 var(--font);
  cursor: pointer;
}
.lc-head-act button:hover { background: rgba(255, 255, 255, .3) }

.lc-body { padding: 15px; overflow-y: auto; flex: 1 }
.lc-body[hidden] { display: none }

.lc-hello { margin: 0 0 10px; font-size: calc(12px * var(--fz-base, 1)); line-height: 1.95 }
.lc-hello a { color: var(--green, #17a673); font-weight: 800 }
.lc-hours {
  margin: 0 0 12px;
  font-size: calc(11px * var(--fz-small, 1));
  color: var(--muted);
}
.lc-start label {
  display: block;
  margin: 9px 0 4px;
  font-size: calc(11px * var(--fz-small, 1));
  font-weight: 800;
}
.lc-start input,
.lc-start select,
.lc-start textarea,
.lc-rate textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--ink);
  font: 500 calc(12px * var(--fz-base, 1)) / 1.7 var(--font);
  resize: vertical;
}
.lc-btn {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  border: 0;
  border-radius: 11px;
  background: var(--green, #17a673);
  color: #fff;
  font: 800 calc(12.5px * var(--fz-btn, 1)) / 1 var(--font);
  cursor: pointer;
}
.lc-btn:hover { filter: brightness(1.06) }
.lc-err {
  margin: 9px 0 0;
  font-size: calc(11px * var(--fz-small, 1));
  font-weight: 700;
  color: var(--red, #e3342f);
}
.lc-err[hidden] { display: none }

.lc-thread { display: flex; flex-direction: column; padding: 0 }
.lc-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}
.lc-m {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: calc(12px * var(--fz-base, 1));
  line-height: 1.85;
}
.lc-m p { margin: 0; white-space: pre-wrap; word-break: break-word }
.lc-m-who {
  display: block;
  font-size: calc(9.5px * var(--fz-small, 1));
  font-weight: 800;
  opacity: .7;
  margin-bottom: 2px;
}
.lc-m-time {
  display: block;
  margin-top: 3px;
  font-size: calc(9px * var(--fz-small, 1));
  opacity: .6;
  text-align: end;
}
.lc-m-visitor {
  align-self: flex-start;
  background: var(--green, #17a673);
  color: #fff;
  border-end-start-radius: 5px;
}
.lc-m-agent {
  align-self: flex-end;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-end-end-radius: 5px;
}
.lc-m-system {
  align-self: center;
  max-width: 96%;
  text-align: center;
  background: transparent;
  color: var(--muted);
  font-size: calc(10.5px * var(--fz-small, 1));
  padding: 4px 8px;
}
.lc-m-system .lc-m-time { display: none }
.lc-m.is-sending { opacity: .55 }
.lc-m.is-failed { background: var(--red, #e3342f); color: #fff }
.lc-m.is-failed::after { content: ' ✕ نرسید'; font-size: 9px; font-weight: 800 }

.lc-typing {
  padding: 0 15px 8px;
  font-size: calc(10.5px * var(--fz-small, 1));
  color: var(--muted);
}
.lc-typing[hidden] { display: none }

.lc-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 11px 13px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.lc-compose[hidden] { display: none }
.lc-compose textarea {
  width: 100%;
  max-height: 96px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface2);
  color: var(--ink);
  font: 500 calc(12px * var(--fz-base, 1)) / 1.7 var(--font);
  resize: none;
  overflow-y: auto;
}
.lc-send {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: var(--green, #17a673);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.lc-send:hover { filter: brightness(1.08) }
.lc-send svg { transform: scaleX(-1) }

.lc-rate { padding: 15px; border-top: 1px solid var(--line) }
.lc-rate[hidden] { display: none }
.lc-rate b { display: block; margin-bottom: 9px; font-size: calc(12.5px * var(--fz-base, 1)) }
.lc-stars { display: flex; gap: 4px; margin-bottom: 10px; flex-direction: row-reverse; justify-content: flex-end }
.lc-stars button {
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  color: var(--line);
  padding: 0;
}
.lc-stars button.is-on { color: #f5b301 }
.lc-skip {
  width: 100%;
  margin-top: 7px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 calc(11px * var(--fz-small, 1)) / 1 var(--font);
  cursor: pointer;
  padding: 7px;
}

.lc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface2);
  font-size: calc(10px * var(--fz-small, 1));
  color: var(--muted);
}
.lc-endbtn {
  border: 0;
  background: none;
  color: var(--red, #e3342f);
  font: 800 calc(10.5px * var(--fz-small, 1)) / 1 var(--font);
  cursor: pointer;
  padding: 0;
}
.lc-endbtn[hidden] { display: none }

@media (max-width: 900px) {
  .lc-wrap {
    inset-inline-end: 12px;
    bottom: calc(var(--sf-dock-b, calc(var(--sf-bnav-h, 64px) + 10px + env(safe-area-inset-bottom, 0px))) + var(--sf-dock-y, 0px));
    z-index: 106;
  }
  .lc-wrap.lc-left { inset-inline-start: 12px }
  .lc-fab-txt { display: none }
  .lc-fab { padding: 13px }
  .lc-panel {
    position: fixed;
    inset-inline: 10px;
    bottom: calc(calc(var(--sf-dock-b, calc(var(--sf-bnav-h, 64px) + 10px + env(safe-area-inset-bottom, 0px))) + var(--sf-dock-y, 0px)) + var(--nv-fab-h, 56px) + 8px);
    width: auto;
    max-height: min(74vh, calc(100vh - 150px));
  }
}

.lc-thread { overflow: hidden; min-height: 0 }
.lc-msgs { min-height: 0; overscroll-behavior: contain }
.lc-panel > .lc-head,
.lc-panel > .lc-compose,
.lc-panel > .lc-foot,
.lc-panel > .lc-rate { flex: 0 0 auto }

html[data-theme="dark"] .lc-wrap { --lc-off: #39425a }
html[data-theme="dark"] .lc-fab {
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .12);
}
html[data-theme="dark"] .lc-wrap.lc-offline .lc-fab:hover { background: #454f6b }
html[data-theme="dark"] .lc-badge { box-shadow: 0 0 0 2px var(--surface2, #1b1f2a) }
html[data-theme="dark"] .lc-dot { background: rgba(255, 255, 255, .55) }
.lc-fab-ico svg { stroke: currentColor }

@media (min-width: 641px) and (max-width: 900px) {
  .lc-panel { max-height: min(74dvh, calc(100dvh - 150px)) }
}

@media (max-width: 900px) {
  .lc-start input,
  .lc-start select,
  .lc-start textarea,
  .lc-rate textarea,
  .lc-compose textarea { font-size: max(16px, calc(12px * var(--fz-base, 1))) }
  .lc-send { width: 44px; height: 44px }
  .lc-fab { min-height: 48px; min-width: 48px; justify-content: center }
  .lc-head-act button { width: 36px; height: 36px; font-size: 18px }
  .lc-m { max-width: 88% }
}

@media (max-width: 640px), (max-width: 900px) and (max-height: 480px) {
  .lc-wrap.is-open { z-index: 1200 }

  .lc-panel {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overscroll-behavior: contain;
    animation: lc-sheet-in .2s ease-out;
  }
  .lc-wrap.lc-left .lc-panel { inset: 0 }

  @keyframes lc-sheet-in {
    from { opacity: .4; transform: translateY(14px) }
    to   { opacity: 1;  transform: none }
  }

  .lc-head {
    flex: 0 0 auto;
    padding: calc(13px + env(safe-area-inset-top, 0px)) 15px 13px;
  }

  .lc-body { min-height: 0 }
  .lc-thread { flex: 1 1 auto; min-height: 0 }
  .lc-msgs { padding: 14px 13px }

  .lc-compose,
  .lc-rate,
  .lc-foot { flex: 0 0 auto }
  .lc-compose textarea { max-height: 30dvh }
  .lc-foot { padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px)) }

  .lc-wrap.is-open .lc-fab { display: none }
}

@media (max-width: 640px), (max-width: 900px) and (max-height: 480px) {
  html:has(.lc-wrap.is-open),
  body:has(.lc-wrap.is-open) { overflow: hidden }
  body:has(.lc-wrap.is-open) .sf-bottomnav,
  body:has(.lc-wrap.is-open) .sf-stickybuy { display: none !important }
}
