.rl-chat,
.rl-chat * { box-sizing: border-box; }
.rl-chat [hidden] { display: none !important; }

.rl-chat {
  --chat-navy: #07111f;
  --chat-panel: rgba(10, 24, 42, 0.98);
  --chat-line: rgba(154, 198, 239, 0.22);
  --chat-muted: #9eb0c8;
  --chat-cyan: #7ee7ff;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 1200;
  color: #f6fbff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.rl-chat button,
.rl-chat input,
.rl-chat textarea { font: inherit; }

.rl-chat-launcher {
  position: relative;
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 0 19px;
  border: 1px solid rgba(126, 231, 255, 0.44);
  border-radius: 17px;
  color: #06111f;
  background: linear-gradient(120deg, #7ee7ff, #a5b8ff 60%, #c4a8ff);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38), 0 0 35px rgba(95, 141, 255, 0.2);
  font-weight: 780;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.rl-chat-launcher:hover,
.rl-chat-launcher:focus-visible { transform: translateY(-2px); box-shadow: 0 22px 58px rgba(0, 0, 0, 0.43), 0 0 42px rgba(95, 141, 255, 0.28); }
.rl-chat-launcher-icon { font-size: 1.05rem; }
.rl-chat-unread { position: absolute; top: -4px; right: -4px; width: 13px; height: 13px; border: 2px solid #07111f; border-radius: 50%; background: #67e6b3; box-shadow: 0 0 15px rgba(103, 230, 179, 0.8); }

.rl-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(390px, calc(100vw - 32px));
  height: min(650px, calc(100vh - 108px));
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 25px;
  background:
    radial-gradient(circle at 95% 0%, rgba(95, 141, 255, 0.2), transparent 31%),
    linear-gradient(155deg, rgba(14, 31, 52, 0.99), var(--chat-panel));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58), 0 0 65px rgba(95, 141, 255, 0.12);
  backdrop-filter: blur(20px);
  transform-origin: bottom right;
  animation: rl-chat-enter 180ms ease-out;
}

@keyframes rl-chat-enter { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

.rl-chat-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--chat-line);
  background: rgba(255, 255, 255, 0.025);
}

.rl-chat-brand { display: flex; align-items: center; gap: 12px; }
.rl-chat-brand img { width: 38px; height: 38px; filter: drop-shadow(0 0 16px rgba(126, 231, 255, 0.24)); }
.rl-chat-brand div { display: grid; gap: 2px; }
.rl-chat-brand strong { color: #fff; font-size: 0.95rem; }
.rl-chat-brand span { color: var(--chat-muted); font-size: 0.75rem; }
.rl-chat-brand span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #7d8da3; }
.rl-chat-brand span.is-online::before { background: #67e6b3; box-shadow: 0 0 12px rgba(103, 230, 179, 0.8); }

.rl-chat-close { width: 38px; height: 38px; border: 1px solid var(--chat-line); border-radius: 12px; color: #d7e5f4; background: rgba(255, 255, 255, 0.04); font-size: 1.45rem; line-height: 1; cursor: pointer; }
.rl-chat-close:hover,
.rl-chat-close:focus-visible { border-color: rgba(126, 231, 255, 0.48); color: #fff; background: rgba(255, 255, 255, 0.08); }

.rl-chat-welcome { min-height: 0; padding: 24px 22px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: rgba(126, 231, 255, 0.3) transparent; }
.rl-chat-eyebrow { margin: 0 0 7px; color: var(--chat-cyan); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.rl-chat-welcome h2 { margin: 0 0 9px; color: #fff; font-size: 1.55rem; line-height: 1.2; }
.rl-chat-welcome > p:not(.rl-chat-eyebrow) { margin: 0 0 20px; color: var(--chat-muted); font-size: 0.88rem; line-height: 1.58; }
.rl-chat-welcome label { display: grid; gap: 7px; margin-top: 12px; color: #dce8f4; font-size: 0.78rem; font-weight: 700; }
.rl-chat-welcome label span { color: #71859d; font-weight: 500; }
.rl-chat input,
.rl-chat textarea { width: 100%; border: 1px solid var(--chat-line); border-radius: 12px; outline: none; color: #f6fbff; background: rgba(3, 11, 20, 0.64); resize: none; }
.rl-chat input { min-height: 43px; padding: 0 12px; }
.rl-chat textarea { padding: 11px 12px; line-height: 1.45; }
.rl-chat input:focus,
.rl-chat textarea:focus { border-color: rgba(126, 231, 255, 0.62); box-shadow: 0 0 0 3px rgba(126, 231, 255, 0.08); }
.rl-chat-primary { width: 100%; min-height: 47px; margin-top: 16px; border: 0; border-radius: 13px; color: #06111f; background: linear-gradient(120deg, #7ee7ff, #a5b8ff 60%, #c4a8ff); font-weight: 800; cursor: pointer; }
.rl-chat-primary:disabled { opacity: 0.58; cursor: wait; }
.rl-chat-welcome small { display: block; margin-top: 12px; color: #71859d; font-size: 0.68rem; text-align: center; }

.rl-chat-conversation { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; min-height: 0; }
.rl-chat-messages { min-height: 0; padding: 18px 16px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-color: rgba(126, 231, 255, 0.26) transparent; }
.rl-chat-welcome::-webkit-scrollbar,
.rl-chat-messages::-webkit-scrollbar { width: 6px; }
.rl-chat-welcome::-webkit-scrollbar-track,
.rl-chat-messages::-webkit-scrollbar-track { background: transparent; }
.rl-chat-welcome::-webkit-scrollbar-thumb,
.rl-chat-messages::-webkit-scrollbar-thumb { border: 1px solid transparent; border-radius: 999px; background: linear-gradient(180deg, rgba(126,231,255,.58), rgba(165,184,255,.42)); background-clip: padding-box; }
.rl-chat-message { display: grid; justify-items: start; margin: 0 0 15px; }
.rl-chat-message.is-visitor { justify-items: end; }
.rl-chat-message p { max-width: 82%; margin: 0; padding: 11px 13px; border: 1px solid var(--chat-line); border-radius: 15px 15px 15px 5px; color: #eaf3fb; background: rgba(255, 255, 255, 0.055); font-size: 0.86rem; line-height: 1.48; overflow-wrap: anywhere; }
.rl-chat-message.is-visitor p { border-color: rgba(126, 231, 255, 0.22); border-radius: 15px 15px 5px 15px; color: #07111f; background: linear-gradient(135deg, #85e9ff, #aebdff); }
.rl-chat-message span { margin-top: 5px; color: #71859d; font-size: 0.64rem; }
.rl-chat-composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 11px 12px 4px; border-top: 1px solid var(--chat-line); }
.rl-chat-composer textarea { min-height: 43px; max-height: 90px; }
.rl-chat-composer button { align-self: end; min-height: 43px; padding: 0 13px; border: 0; border-radius: 11px; color: #06111f; background: linear-gradient(120deg, #7ee7ff, #a5b8ff); font-size: 0.78rem; font-weight: 800; cursor: pointer; }
.rl-chat-notice { margin: 4px 12px 0; color: #71859d; font-size: 0.62rem; text-align: center; }

@media (max-width: 560px), (hover: none) and (pointer: coarse) and (max-height: 560px) {
  body.rl-chat-open { overflow: hidden; overscroll-behavior: none; }
  .rl-chat { inset: 0; width: 100%; height: 100dvh; pointer-events: none; }
  .rl-chat:not(.is-open) { top: auto; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); left: auto; width: auto; height: auto; }
  .rl-chat-launcher { position: relative; top: auto; right: auto; bottom: auto; min-height: 49px; padding: 0 15px; border-right: 0; border-radius: 15px 0 0 15px; pointer-events: auto; }
  .rl-chat-launcher > span:not(.rl-chat-launcher-icon) { display: inline; }
  .rl-chat-launcher-icon { font-size: 1.12rem; }
  .rl-chat.is-open .rl-chat-launcher { display: none; }
  .rl-chat-panel { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; box-shadow: none; pointer-events: auto; animation-duration: 140ms; }
  .rl-chat-header { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-right: calc(14px + env(safe-area-inset-right, 0px)); padding-left: calc(14px + env(safe-area-inset-left, 0px)); }
  .rl-chat-welcome { padding-right: calc(18px + env(safe-area-inset-right, 0px)); padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); padding-left: calc(18px + env(safe-area-inset-left, 0px)); }
  .rl-chat input,
  .rl-chat textarea { font-size: 17px; line-height: 1.45; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  .rl-chat textarea { resize: none; }
  .rl-chat button { touch-action: manipulation; }
  .rl-chat-messages { padding-right: calc(14px + env(safe-area-inset-right, 0px)); padding-left: calc(14px + env(safe-area-inset-left, 0px)); }
  .rl-chat-welcome,
  .rl-chat-messages { scrollbar-width: none; }
  .rl-chat-welcome::-webkit-scrollbar,
  .rl-chat-messages::-webkit-scrollbar { width: 0; height: 0; }
  .rl-chat-composer { padding-right: calc(12px + env(safe-area-inset-right, 0px)); padding-left: calc(12px + env(safe-area-inset-left, 0px)); }
  .rl-chat-notice { margin-bottom: calc(7px + env(safe-area-inset-bottom, 0px)); }
}

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