:root{
  --lc-bg: #ffffff;
  --lc-ink: #111111;
  --lc-muted: rgba(17,17,17,.65);
  --lc-line: #e9e9e9;
  --lc-soft: #f6f6f6;
  --lc-shadow: 0 18px 50px rgba(0,0,0,.18);
  --lc-radius: 18px;
  --lc-radius-sm: 12px;
}

.lc-widget{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  font-family: inherit;
}

@supports (padding: max(0px)){
  .lc-widget{
    bottom: max(16px, env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
  }
}

.lc-btn{
  display:flex;
  gap:10px;
  align-items:center;
  border:0;
  border-radius:999px;
  padding:12px 14px;
  cursor:pointer;
  background: var(--lc-ink);
  color:#fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
}

.lc-dot{ width:10px; height:10px; border-radius:50%; background:#777; }
.lc-widget.is-online .lc-dot{ background:#00c27a; }
.lc-title{ font-weight:800; text-transform:lowercase; }
.lc-status{ opacity:.85; font-size:13px; }

.lc-panel{
  width: 340px;
  max-width: calc(100vw - 24px);
  background: var(--lc-bg);
  border-radius: var(--lc-radius);
  box-shadow: var(--lc-shadow);
  overflow:hidden;
  margin-top:10px;
  border: 1px solid var(--lc-line);
}

.lc-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px 12px;
  background: var(--lc-ink);
  color:#fff;
}

.lc-head-title{ font-weight:800; letter-spacing:.2px; text-transform:lowercase; }

.lc-close{
  border:0;
  background:transparent;
  color:#fff;
  font-size:22px;
  line-height:1;
  cursor:pointer;
  padding:6px 10px;
  border-radius:10px;
}
.lc-close:active{ transform: translateY(1px); }

.lc-body{
  height: 320px;
  overflow:auto;
  padding:10px;
  background: var(--lc-soft);
}

.lc-sys{
  font-size:13px;
  color: var(--lc-muted);
  margin: 0 0 8px 0;
}

.lc-msg{ display:flex; margin:8px 0; }
.lc-left{ justify-content:flex-start; }
.lc-right{ justify-content:flex-end; }
.lc-system{ justify-content:center; opacity:.75; }

.lc-bubble{
  max-width: 82%;
  padding:10px 12px;
  border-radius:14px;
  background:#fff;
  border: 1px solid #e5e5e5;
  color: var(--lc-ink);
  word-break: break-word;
  white-space: pre-wrap;
}

.lc-right .lc-bubble{
  background: var(--lc-ink);
  color:#fff;
  border-color: var(--lc-ink);
}

.lc-system .lc-bubble{
  background:#f1f1f1;
  border-color:#eee;
}

.lc-typing{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  margin:8px 0 0;
  border-radius:12px;
  background:#f2f2f2;
  color:#222;
  font-size:13px;
}
.lc-typing[hidden]{ display:none; }

.lc-typing .dots{ display:inline-flex; gap:4px; }
.lc-typing .dots i{
  width:6px; height:6px;
  border-radius:50%;
  background:#777;
  display:inline-block;
  animation: lcDot 1s infinite ease-in-out;
}
.lc-typing .dots i:nth-child(2){ animation-delay: .15s; }
.lc-typing .dots i:nth-child(3){ animation-delay: .30s; }

@keyframes lcDot{
  0%, 80%, 100%{ transform: translateY(0); opacity:.4; }
  40%{ transform: translateY(-4px); opacity:1; }
}

.lc-start{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px;
  border-top: 1px solid var(--lc-line);
  background: #fff;
}
.lc-start input{
  width:100%;
  padding:12px 12px;
  border:1px solid #ddd;
  border-radius:12px;
  outline: none;
}
.lc-start input:focus{ border-color:#bdbdbd; }

.lc-start-btn{
  background: var(--lc-ink);
  color:#fff;
  border:0;
  padding:12px 12px;
  cursor:pointer;
  border-radius:12px;
  font-size:14px;
  font-weight:800;
}
.lc-start-btn:disabled{ opacity:.5; cursor:default; }

.lc-send{
  display:flex;
  gap:8px;
  padding:10px;
  border-top: 1px solid var(--lc-line);
  background:#fff;
  align-items:flex-end;
  position: relative;
}

.lc-send input{
  flex:1;
  padding:12px 12px;
  border:1px solid #ddd;
  border-radius:12px;
  outline:none;
}
.lc-send input:focus{ border-color:#bdbdbd; }

.lc-send .lc-emo-btn{
  width:44px;
  height:44px;
  border:1px solid #ddd;
  border-radius:12px;
  background:#fff;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  line-height:1;
}
.lc-send .lc-emo-btn:active{ transform: translateY(1px); }

.lc-send button[type="submit"]{
  width:44px;
  height:44px;
  border:0;
  border-radius:12px;
  background: var(--lc-ink);
  color:#fff;
  cursor:pointer;
  font-size:18px;
}

/* pending */
.lc-msg.is-pending .lc-bubble{ opacity:.65; }

/* emoji popover */
.lc-emo-pop{
  position:absolute;
  right:10px;
  bottom:58px;
  width: 280px;
  max-width: calc(100% - 20px);
  background:#fff;
  border:1px solid var(--lc-line);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.18);
  padding:10px;
}
.lc-emo-pop[hidden]{ display:none; }

.lc-emo-grid{
  display:grid;
  grid-template-columns: repeat(8, 1fr);
  gap:6px;
}
.lc-emo-item{
  width:100%;
  height:34px;
  border:0;
  background:#fff;
  border-radius:10px;
  cursor:pointer;
  font-size:18px;
}
.lc-emo-item:active{ transform: translateY(1px); background:#f3f3f3; }

/* mobile: bottom sheet full width */
@media (max-width: 520px){
  .lc-widget{
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  @supports (padding: max(0px)){
    .lc-widget{
      bottom: max(12px, env(safe-area-inset-bottom));
      left: max(12px, env(safe-area-inset-left));
      right: max(12px, env(safe-area-inset-right));
    }
  }

  .lc-btn{
    width: 100%;
    justify-content: center;
    padding: 14px 16px;
    border-radius: 16px;
  }

  .lc-panel{
    width: 100%;
    max-width: 100%;
    border-radius: 18px;
  }

  .lc-body{
    height: min(56vh, 420px);
  }

  .lc-emo-pop{
    right: 10px;
    left: 10px;
    width: auto;
  }
}

/* ensure */
[hidden]{ display:none !important; }

/* mobile */
@media (max-width: 520px){

  .lc-widget{
    right: 14px;
    left: auto;
    bottom: 14px;
    width: auto;
  }

  @supports (padding: max(0px)){
    .lc-widget{
      right: max(14px, env(safe-area-inset-right));
      bottom: max(14px, env(safe-area-inset-bottom));
      left: auto;
    }
  }

  /* кнопка */
  .lc-btn{
    width: auto;
    min-width: 58px;
    height: 58px;
    padding: 0 18px;
    border-radius: 18px;
    justify-content: center;
    gap: 8px;

    box-shadow:
      0 10px 25px rgba(0,0,0,.18),
      0 4px 10px rgba(0,0,0,.12);
  }

  /* текст */
  .lc-title{
    font-size: 14px;
  }

  .lc-status{
    display:none;
  }

  /* панель */
  .lc-panel{
    width: calc(100vw - 20px);
    max-width: 380px;
    border-radius: 22px;
    margin-left: auto;
  }

  .lc-body{
    height: 58vh;
  }

  .lc-send input{
    font-size: 16px; /* щоб iOS не зумило */
  }

  .lc-emo-pop{
    left: 10px;
    right: 10px;
    width: auto;
  }
}