.trs-desk,
.trs-desk * { box-sizing: border-box; }

.trs-desk {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9000;
  font-family: var(--body, Inter, system-ui, sans-serif);
}

.trs-desk__fab {
  position: relative;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #7a4ab5, #67399f 55%, #552f87);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 14px 36px rgba(103, 57, 159, 0.4);
  display: grid;
  place-items: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.trs-desk__fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(103, 57, 159, 0.48);
}

.trs-desk__fab svg { width: 24px; height: 24px; display: block; }

.trs-desk__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #cf4e4e;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  display: none;
}

.trs-desk__badge.is-on { display: block; }

.trs-desk__panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(392px, calc(100vw - 1.5rem));
  height: min(600px, calc(100vh - 7.5rem));
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(20, 18, 26, 0.08);
  box-shadow: 0 28px 90px rgba(20, 18, 26, 0.24);
}

.trs-desk.is-open .trs-desk__panel { display: flex; }
.trs-desk.is-open .trs-desk__fab-open { display: none; }
.trs-desk:not(.is-open) .trs-desk__fab-close { display: none; }

.trs-desk__head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.05rem 0.85rem;
  background: linear-gradient(180deg, #1c1826, #16131d);
  color: #fff;
}

.trs-desk__head-copy {
  flex: 1;
  min-width: 0;
}

.trs-desk__x {
  flex: none;
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.trs-desk__x svg {
  width: 18px;
  height: 18px;
  display: block;
}

.trs-desk__x:hover {
  background: rgba(255, 255, 255, 0.14);
}

.trs-desk__face {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.18);
}

.trs-desk__head-copy h2 {
  font-family: var(--sans, "Inter Tight", sans-serif);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0;
  color: #fff;
}

.trs-desk__head-copy p {
  margin: 0.28rem 0 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.62);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.trs-desk__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ecf8e;
  box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.2);
  display: inline-block;
}

.trs-desk__dot--idle {
  background: #837c90;
  box-shadow: none;
}

.trs-desk__dot--busy {
  background: #d4a017;
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.22);
  animation: trs-desk-pulse 1s ease-in-out infinite;
}

.trs-desk__face-wrap {
  width: 42px;
  height: 42px;
  flex: none;
}

.trs-desk__system {
  align-self: center;
  max-width: 90%;
  font-size: 0.72rem;
  color: #837c90;
  text-align: center;
  padding: 0.15rem 0.4rem;
}

.trs-desk__wait {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1rem;
  border-top: 1px solid rgba(20, 18, 26, 0.06);
  background: #faf8fc;
  font-size: 0.75rem;
  color: #837c90;
}

.trs-desk__wait[hidden] { display: none !important; }

.trs-desk__wait-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4a017;
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.18);
  animation: trs-desk-pulse 1.1s ease-in-out infinite;
}

@keyframes trs-desk-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.trs-desk__form input:disabled,
.trs-desk__form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.trs-desk__team {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  background: #f7f5fa;
  border-bottom: 1px solid rgba(20, 18, 26, 0.06);
}

.trs-desk__team img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #fff;
  margin-left: -6px;
}

.trs-desk__team img:first-child { margin-left: 0; }

.trs-desk__team span {
  margin-left: 0.4rem;
  font-size: 0.72rem;
  color: #837c90;
}

.trs-desk__log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.9rem 0.65rem;
  background: linear-gradient(180deg, #faf8fc, #f4f1f8);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trs-desk__row {
  display: flex;
  max-width: 92%;
  gap: 0.45rem;
  align-items: flex-end;
}

.trs-desk__row--you { margin-left: auto; justify-content: flex-end; }

.trs-desk__avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.trs-desk__stack {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.trs-desk__name {
  font-size: 0.68rem;
  color: #837c90;
  padding-left: 0.15rem;
}

.trs-desk__bubble {
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #14121a;
  background: #fff;
  border: 1px solid rgba(20, 18, 26, 0.07);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(20, 18, 26, 0.04);
}

.trs-desk__row--agent .trs-desk__bubble {
  border-bottom-left-radius: 5px;
}

.trs-desk__row--you .trs-desk__bubble {
  background: linear-gradient(145deg, #7a4ab5, #67399f);
  color: #fff;
  border-color: transparent;
  border-bottom-right-radius: 5px;
}

.trs-desk__form {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem;
  border-top: 1px solid rgba(20, 18, 26, 0.07);
  background: #fff;
}

.trs-desk__form input {
  flex: 1;
  height: 44px;
  border: 1px solid rgba(20, 18, 26, 0.14);
  border-radius: 999px;
  padding: 0 1rem;
  font: inherit;
  font-size: 0.875rem;
  color: #14121a;
  outline: none;
  background: #faf8fc;
}

.trs-desk__form input:focus {
  border-color: #67399f;
  background: #fff;
}

.trs-desk__form button {
  height: 44px;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 999px;
  background: #14121a;
  color: #fff;
  font-family: var(--sans, "Inter Tight", sans-serif);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
}

.trs-desk__form button:hover { background: #2a2534; }

@media (max-width: 560px) {
  .trs-desk {
    right: 0.85rem;
    bottom: calc(0.85rem + env(safe-area-inset-bottom));
  }
  .trs-desk__panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    z-index: 9500;
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* FAB overlaps Send on mobile fullscreen — hide it while open */
  .trs-desk.is-open .trs-desk__fab {
    display: none;
  }
  .trs-desk__head {
    padding-top: calc(0.85rem + env(safe-area-inset-top));
  }
  .trs-desk__form {
    padding-bottom: calc(0.8rem + env(safe-area-inset-bottom));
  }
}
