.uzb-chat-root,
.uzb-chat-root * {
  box-sizing: border-box;
}

.uzb-chat-root {
  --uzb-blue: #0876e8;
  --uzb-dark: #102131;
  --uzb-muted: #637083;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--uzb-dark);
}

.uzb-chat-root [hidden] {
  display: none !important;
}

.uzb-chat-launcher {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #15a8ff, #075fd0);
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 86, 180, .34);
  cursor: pointer;
  font-size: 27px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.uzb-chat-root.is-inviting .uzb-chat-launcher {
  animation: uzb-chat-invite 1.8s ease-in-out 2;
}

.uzb-chat-launcher::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ff4d4f;
}

.uzb-chat-invite {
  position: absolute;
  right: 74px;
  bottom: 8px;
  width: max-content;
  max-width: 230px;
  padding: 11px 14px;
  border: 1px solid rgba(17, 55, 88, .12);
  border-radius: 14px 14px 4px 14px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(10, 33, 58, .2);
  color: var(--uzb-dark);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition: opacity .25s ease, transform .25s ease;
}

.uzb-chat-root.is-inviting .uzb-chat-invite {
  opacity: 1;
  transform: none;
}

@keyframes uzb-chat-invite {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.04); }
}

.uzb-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(0, 86, 180, .4);
}

.uzb-chat-launcher:focus-visible,
.uzb-chat-root button:focus-visible,
.uzb-chat-root input:focus-visible {
  outline: 3px solid rgba(0, 184, 200, .4);
  outline-offset: 2px;
}

.uzb-chat-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: min(370px, calc(100vw - 28px));
  height: min(590px, calc(100vh - 120px));
  display: none;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(17, 55, 88, .12);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(10, 33, 58, .25);
}

.uzb-chat-root.is-open .uzb-chat-panel {
  display: grid;
  animation: uzb-chat-in .22s ease-out;
}

@keyframes uzb-chat-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.uzb-chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 76px;
  padding: 14px 15px;
  color: #fff;
  background: linear-gradient(125deg, #09253e, #096bd1 72%, #00a9ba);
}

.uzb-chat-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  height: 44px;
  border: 2px solid rgba(255,255,255,.65);
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  font-size: 21px;
}

.uzb-chat-title {
  min-width: 0;
  flex: 1;
}

.uzb-chat-title strong,
.uzb-chat-title span {
  display: block;
}

.uzb-chat-title strong { font-size: 16px; }
.uzb-chat-title span {
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255,255,255,.82);
}

.uzb-chat-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.13);
  cursor: pointer;
  font-size: 20px;
}

.uzb-chat-main {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(#f8fbff, #f2f7fb);
}

.uzb-chat-welcome {
  display: grid;
  align-content: center;
  min-height: 100%;
  text-align: center;
}

.uzb-chat-welcome h3 {
  margin: 0 0 8px;
  font-size: 21px;
}

.uzb-chat-welcome p {
  margin: 0 auto 20px;
  max-width: 280px;
  color: var(--uzb-muted);
  font-size: 14px;
  line-height: 1.5;
}

.uzb-chat-name {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #cad6e2;
  border-radius: 13px;
  background: #fff;
  color: var(--uzb-dark);
  font-size: 16px;
}

.uzb-chat-start {
  width: 100%;
  height: 48px;
  margin-top: 10px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--uzb-blue);
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
}

.uzb-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.uzb-chat-message {
  align-self: flex-start;
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 15px 15px 15px 4px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(25, 54, 82, .08);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.uzb-chat-message.visitor {
  align-self: flex-end;
  border-radius: 15px 15px 4px 15px;
  color: #fff;
  background: var(--uzb-blue);
}

.uzb-chat-message.has-avatar {
  position: relative;
  margin-left: 38px;
}

.uzb-chat-message-avatar {
  position: absolute;
  left: -40px;
  bottom: 0;
  width: 32px;
  height: 32px;
  border: 2px solid #fff;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 3px 10px rgba(10, 33, 58, .18);
}

.uzb-chat-sender {
  display: block;
  margin-bottom: 3px;
  color: #0876e8;
  font-size: 11px;
  font-weight: 700;
}

.uzb-chat-message.visitor .uzb-chat-sender {
  color: rgba(255,255,255,.8);
}

.uzb-chat-status {
  padding: 7px 16px;
  color: var(--uzb-muted);
  background: #f2f7fb;
  font-size: 12px;
  text-align: center;
}

.uzb-chat-form {
  display: none;
  align-items: end;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid #e1e9f0;
  background: #fff;
}

.uzb-chat-tool {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: #edf5fc;
  color: #155b97;
  cursor: pointer;
  font-size: 18px;
}

.uzb-chat-mic.is-recording {
  color: #fff;
  background: #df2d3b;
  animation: uzb-recording 1s ease-in-out infinite;
}

@keyframes uzb-recording {
  50% { opacity: .62; }
}

.uzb-chat-root.has-session .uzb-chat-form { display: flex; }

.uzb-chat-text {
  min-width: 0;
  flex: 1;
  height: 44px;
  padding: 0 13px;
  border: 1px solid #cbd8e4;
  border-radius: 13px;
  color: var(--uzb-dark);
  font-size: 15px;
}

.uzb-chat-send {
  flex: 0 0 44px;
  height: 44px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--uzb-blue);
  cursor: pointer;
  font-size: 19px;
}

.uzb-chat-attachment {
  display: block;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid currentColor;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.uzb-chat-image {
  display: block;
  width: 100%;
  max-width: 250px;
  max-height: 220px;
  margin-top: 8px;
  border-radius: 10px;
  object-fit: cover;
  cursor: zoom-in;
}

.uzb-chat-root.is-busy button { cursor: wait; }
.uzb-chat-error { color: #b42318; }

@media (max-width: 520px) {
  .uzb-chat-root { right: 12px; bottom: 12px; }
  .uzb-chat-panel {
    position: fixed;
    inset: 8px;
    width: auto;
    height: auto;
    border-radius: 18px;
  }
  .uzb-chat-root.is-open .uzb-chat-launcher { visibility: hidden; }
  .uzb-chat-invite { right: 70px; max-width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  .uzb-chat-panel,
  .uzb-chat-launcher { animation: none; transition: none; }
}
