.oc-chat {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 400px;
  height: 550px;
  background: #fff;
  color: #111;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  z-index: 9999;
  font-family: system-ui;
}
.oc-header {
  background: #ededed;
  background-image: url('./img/grey.png');
  background-repeat: no-repeat;
  background-size: cover;
  color: #54595f;
  padding: 10px 12px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.oc-header-title {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 600;
}
.oc-header-title-sub {
  font-size: 12px;
  font-weight: 400;
}
.oc-header-minus img {
  width: 31px;
  cursor: pointer;
}
.oc-messages {
  flex: 1;
  padding: 12px 6px;
  overflow-y: auto;
  background: #f6f7fb;
}
.oc-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e9ecf3;
  background: #fff;
  align-items: end;
}
.oc-input textarea {
  flex: 1;
  border: 1px solid #e1e4ec;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  resize: none;
  max-height: 140px;
  min-height: 40px;
  line-height: 1.35;
  font-family: system-ui;
}
.oc-send {
  flex: 0 0 44px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: #ee7619;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.oc-send:active {
  background: #df6203;
}

.oc-send:disabled,
.oc-send.is-disabled {
  background: #e8e8e8;
  color: #aaa;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.9;
}

.oc-input textarea:disabled,
.oc-input textarea.is-disabled {
  background: #f2f2f2;
  color: #999;
  cursor: not-allowed;
  pointer-events: none;
}

.oc-msg {
  display: flex;
  margin: 8px 0;
  align-items: flex-end;
}
.oc-msg.agent {
  justify-content: flex-start;
}
.oc-msg.user {
  justify-content: flex-end;
}
.oc-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 28px;
  margin: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
}
.oc-avatar.agent {
  background: #ffd369;
  color: #fff;
}
.oc-avatar.user {
  background: #ee7619;
  color: #fff;
}
.oc-bubble {
  max-width: 72%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.35;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.oc-msg.agent .oc-bubble {
  background: #ffead9;
  color: #54595f;
  border-top-left-radius: 6px;
}
.oc-msg.user .oc-bubble {
  background: #ffaa68;
  color: #54595f;
  border-top-right-radius: 6px;
}

/* typing loader */
.oc-typing {
  display: flex;
  align-items: flex-end;
  margin: 8px 0;
}
.oc-typing .oc-bubble {
  background: #ffead9;
  color: #54595f;
  border-top-left-radius: 6px;
}
.oc-dots {
  display: inline-flex;
  gap: 6px;
  padding: 2px 0;
}
.oc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ee7619;
  opacity: 0.4;
  animation: ocPulse 1.2s infinite ease-in-out;
}
.oc-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.oc-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes ocPulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* launcher button */
.oc-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #ee7619;
  color: #393e46;
  font-size: 24px;
  width: 55px;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 9999;
}

.oc-launcher img {
  width: 32px;
}

/* ===== Базовые предохраны на любой экран ===== */
.oc-chat {
  max-height: 90vh;
}

@media (max-width: 1024px) {
  .oc-chat {
    width: 360px;
    height: 520px;
  }
  .oc-bubble {
    max-width: 80%;
  }
}

@media (max-width: 768px) {
  .oc-chat {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(80px, calc(env(safe-area-inset-bottom) + 64px));
    width: calc(
      100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))
    );
    max-width: 480px;
    height: min(78vh, 600px);
    border-radius: 12px;
  }
  .oc-launcher {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
    border-radius: 14px;
  }
  .oc-launcher img {
    width: 30px;
  }
  .oc-bubble {
    max-width: 84%;
  }
}

@media (max-width: 420px) {
  .oc-chat {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100dvw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .oc-header {
    padding: 8px 10px;
  }
  .oc-header-title-sub {
    font-size: 11px;
  }
  .oc-header-minus img {
    width: 22px;
  }
  .oc-messages {
    padding: 10px 6px;
  }
  .oc-input {
    padding: 8px;
    gap: 6px;
  }
  .oc-input textarea {
    min-height: 36px;
    max-height: 120px;
    font-size: 14px;
    padding: 8px 10px;
  }
  .oc-send {
    flex-basis: 40px;
    height: 40px;
    font-size: 15px;
  }
  .oc-avatar {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    font-size: 13px;
    margin: 0 6px;
  }
  .oc-bubble {
    padding: 8px 10px;
    border-radius: 12px;
    max-width: 86%;
  }
}

@media (max-height: 600px) {
  .oc-chat {
    height: calc(100vh - 110px);
    bottom: max(60px, env(safe-area-inset-bottom));
  }
}

.oc-messages {
  scrollbar-width: thin;
}
.oc-messages::-webkit-scrollbar {
  width: 8px;
}
.oc-messages::-webkit-scrollbar-thumb {
  background: #d6d9e3;
  border-radius: 6px;
}
