/* Chat Relay visitor widget — Default + Dark Lab themes.
   System fonts only. No external fonts or CDNs. */
#cr-chat {
  --cr-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  position: fixed;
  z-index: 99999;
  bottom: 20px;
  right: 20px;
  font: 14px/1.45 var(--cr-font);
  color: #111;
}
#cr-chat.cr-pos-left { right: auto; left: 20px; }

#cr-chat * { box-sizing: border-box; }

.cr-chat-bubble {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--cr-color, #0f766e);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cr-chat-bubble:hover { filter: brightness(1.08); }
.cr-chat-bubble:focus-visible {
  outline: 3px solid var(--cr-accent, #0f766e);
  outline-offset: 3px;
}
.cr-chat-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  line-height: 14px;
  border: 2px solid #fff;
}

.cr-chat-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: min(360px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  min-width: 0;
  height: 520px;
  max-height: min(520px, calc(100vh - 100px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden;
}
#cr-chat.cr-pos-left .cr-chat-panel { right: auto; left: 0; }
.cr-chat-panel[hidden] { display: none; }

.cr-chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--cr-color, #0f766e);
  color: #fff;
}
.cr-chat-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}
.cr-chat-logo {
  flex: 0 0 auto;
  width: 36px;
  height: 40px;
  display: none;
  color: var(--cr-accent, #2ee8d6);
}
.cr-chat-logo img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 8px;
}
.cr-chat-brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.cr-chat-brand-text strong {
  font-size: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-chat-tagline {
  display: none;
  font-size: 11px;
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-chat-x {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.cr-chat-x:hover { background: rgba(255, 255, 255, 0.12); }
.cr-chat-x:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.cr-chat-status { display: none; }
.cr-chat-welcome { display: none; }
.cr-theme-default .cr-chat-send-icon { display: none; }

.cr-chat-chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px 0;
  min-width: 0;
}
.cr-chat-chip {
  appearance: none;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  color: #134e4a;
  border-radius: 999px;
  padding: 6px 12px;
  font: 12px/1.2 var(--cr-font);
  cursor: pointer;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-chat-chip:hover { background: #ecfeff; border-color: var(--cr-accent, #0f766e); }
.cr-chat-chip:focus-visible {
  outline: 2px solid var(--cr-accent, #0f766e);
  outline-offset: 2px;
}

.cr-chat-note {
  flex: 0 0 auto;
  padding: 10px 14px;
  color: #444;
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.cr-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cr-m {
  max-width: 85%;
  min-width: 0;
  padding: 8px 11px;
  border-radius: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cr-m-body { white-space: pre-wrap; }
.cr-m-meta {
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cr-m.v { align-self: flex-start; background: #f1f5f9; color: #111; }
.cr-m.a { align-self: flex-end; background: var(--cr-accent, #0f766e); color: #fff; }
.cr-m.a .cr-m-meta { color: #fff; opacity: 0.85; }
.cr-sys { font-size: 12px; color: #666; text-align: center; }

.cr-chat-typing {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 8px;
  font-size: 12px;
  color: #555;
}
.cr-chat-typing[hidden] { display: none; }
.cr-chat-typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.cr-chat-typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  display: block;
  animation: cr-dot 1.1s infinite ease-in-out;
}
.cr-chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.cr-chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cr-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .cr-chat-typing-dots i { animation: none; opacity: 0.8; }
  .cr-chat-bubble:hover { filter: none; }
}

.cr-chat-form {
  flex: 0 0 auto;
  padding: 8px 12px 12px;
  border-top: 1px solid #e5e7eb;
  min-width: 0;
}
.cr-chat-who {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}
.cr-chat-who input,
.cr-chat-row textarea {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
  color: #111;
}
.cr-chat-who input:focus,
.cr-chat-row textarea:focus {
  outline: 2px solid var(--cr-accent, #0f766e);
  outline-offset: 1px;
  border-color: var(--cr-accent, #0f766e);
}
.cr-chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  min-width: 0;
}
.cr-chat-row textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 40px;
  max-height: 96px;
}
.cr-chat-send {
  flex: 0 0 auto;
  background: var(--cr-accent, #0f766e);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font: 600 13px var(--cr-font);
}
.cr-chat-send:hover { filter: brightness(1.06); }
.cr-chat-send:disabled { opacity: 0.6; cursor: not-allowed; }
.cr-chat-send:focus-visible {
  outline: 2px solid var(--cr-accent, #0f766e);
  outline-offset: 2px;
}
.cr-chat-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.cr-chat-err { color: #b91c1c; font-size: 12px; margin-top: 6px; min-width: 0; overflow-wrap: anywhere; }
#cr-chat.cr-started .cr-chat-who { display: none; }

@media (max-width: 480px) {
  #cr-chat { bottom: 12px; right: 12px; }
  #cr-chat.cr-pos-left { left: 12px; }
  .cr-chat-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 80px;
    width: auto;
    max-width: none;
    height: min(560px, calc(100vh - 96px));
    max-height: calc(100vh - 96px);
    align-items: stretch;
  }
  #cr-chat.cr-pos-left .cr-chat-panel { left: 8px; right: 8px; }
  .cr-chat-who { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Dark Lab ---------- */
.cr-theme-dark-lab {
  color: #e8f6f4;
}
.cr-theme-dark-lab .cr-chat-bubble {
  background: #10161c;
  color: var(--cr-accent, #2ee8d6);
  box-shadow:
    0 0 0 1px rgba(46, 232, 214, 0.35),
    0 0 22px rgba(46, 232, 214, 0.28),
    0 10px 24px rgba(0, 0, 0, 0.45);
}
.cr-theme-dark-lab .cr-chat-bubble:focus-visible {
  outline-color: var(--cr-accent, #2ee8d6);
}
.cr-theme-dark-lab .cr-chat-dot {
  background: var(--cr-accent, #2ee8d6);
  color: #041016;
  border-color: #10161c;
  font-weight: 700;
}

.cr-theme-dark-lab .cr-chat-panel {
  background-color: #0a1014;
  background-image: linear-gradient(180deg, #10181e 0%, #0a1014 48%, #080c10 100%);
  border: 1px solid rgba(46, 232, 214, 0.28);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(46, 232, 214, 0.08),
    0 0 40px rgba(46, 232, 214, 0.16),
    0 24px 48px rgba(0, 0, 0, 0.55);
  color: #e8f6f4;
  height: 580px;
  max-height: min(580px, calc(100vh - 100px));
}
.cr-theme-dark-lab .cr-chat-head {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='84' viewBox='0 0 48 84'><path d='M24 2 L45 14 V38 L24 50 L3 38 V14 Z' fill='none' stroke='%232ee8d6' stroke-opacity='0.16' stroke-width='1'/></svg>") repeat,
    linear-gradient(180deg, rgba(10, 16, 22, 0.2) 0%, rgba(8, 12, 16, 0.85) 100%);
  background-color: #0b1116;
  color: #f4fffd;
  padding: 16px 14px 14px;
  border-bottom: 1px solid rgba(46, 232, 214, 0.12);
}
.cr-theme-dark-lab .cr-chat-logo { display: block; }
.cr-theme-dark-lab .cr-chat-logo img {
  width: 36px;
  height: 40px;
  object-fit: cover;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  border-radius: 0;
}
.cr-theme-dark-lab .cr-chat-brand-text strong {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}
.cr-theme-dark-lab .cr-chat-tagline {
  display: block;
  color: rgba(46, 232, 214, 0.85);
  opacity: 1;
  margin-top: 2px;
  letter-spacing: 0.01em;
}
.cr-theme-dark-lab .cr-chat-x {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(46, 232, 214, 0.45);
  border-radius: 10px;
  color: var(--cr-accent, #2ee8d6);
  background: rgba(8, 16, 20, 0.6);
}
.cr-theme-dark-lab .cr-chat-x:hover { background: rgba(46, 232, 214, 0.12); }
.cr-theme-dark-lab .cr-chat-x:focus-visible {
  outline: 2px solid var(--cr-accent, #2ee8d6);
  outline-offset: 2px;
}

.cr-theme-dark-lab .cr-chat-status {
  display: flex;
  padding: 12px 14px 0;
}
.cr-theme-dark-lab .cr-chat-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(46, 232, 214, 0.35);
  background: rgba(16, 28, 32, 0.9);
  color: var(--cr-accent, #2ee8d6);
  font-size: 12px;
  font-weight: 600;
}
.cr-theme-dark-lab .cr-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cr-accent, #2ee8d6);
  box-shadow: 0 0 8px var(--cr-accent, #2ee8d6);
}
.cr-theme-dark-lab .cr-chat-status-shield { opacity: 0.9; }

.cr-theme-dark-lab .cr-chat-welcome {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 14px 0;
  padding: 12px;
  min-width: 0;
  border-radius: 14px;
  border: 1px solid rgba(46, 232, 214, 0.18);
  background: rgba(12, 20, 24, 0.85);
}
.cr-theme-dark-lab .cr-chat-welcome-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cr-accent, #2ee8d6);
  background: rgba(46, 232, 214, 0.1);
  border: 1px solid rgba(46, 232, 214, 0.28);
}
.cr-theme-dark-lab .cr-chat-welcome-text { min-width: 0; }
.cr-theme-dark-lab .cr-chat-welcome-text strong {
  display: block;
  font-size: 15px;
  color: #f4fffd;
}
.cr-theme-dark-lab .cr-chat-welcome-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #b7c9c6;
  overflow-wrap: anywhere;
}

.cr-theme-dark-lab .cr-chat-chips { padding: 12px 14px 4px; }
.cr-theme-dark-lab .cr-chat-chip {
  background: rgba(10, 18, 22, 0.9);
  border: 1px solid rgba(46, 232, 214, 0.35);
  color: var(--cr-accent, #2ee8d6);
  padding: 7px 12px;
}
.cr-theme-dark-lab .cr-chat-chip:hover {
  background: rgba(46, 232, 214, 0.12);
  border-color: var(--cr-accent, #2ee8d6);
}
.cr-theme-dark-lab .cr-chat-chip:focus-visible {
  outline: 2px solid var(--cr-accent, #2ee8d6);
}

.cr-theme-dark-lab .cr-chat-note { display: none; }

.cr-theme-dark-lab .cr-chat-log { padding: 10px 14px 8px; gap: 10px; }
.cr-theme-dark-lab .cr-m {
  padding: 9px 12px 7px;
  border-radius: 14px;
}
/* Visitor on the right (teal), agent on the left (dark charcoal). */
.cr-theme-dark-lab .cr-m.v {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(18, 70, 66, 0.95), rgba(10, 46, 44, 0.95));
  border: 1px solid rgba(46, 232, 214, 0.45);
  color: #e9fffb;
}
.cr-theme-dark-lab .cr-m.a {
  align-self: flex-start;
  background: #1a222a;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #e8edf2;
}
.cr-theme-dark-lab .cr-m.v .cr-m-meta { color: #9feee6; opacity: 1; justify-content: flex-end; }
.cr-theme-dark-lab .cr-m.a .cr-m-meta { color: #9aa3ad; opacity: 1; }
.cr-theme-dark-lab .cr-m-ticks { color: var(--cr-accent, #2ee8d6); }
.cr-theme-dark-lab .cr-sys { color: #8b9694; }

.cr-theme-dark-lab .cr-chat-typing {
  color: #9feee6;
  padding: 0 16px 10px;
}
.cr-theme-dark-lab .cr-chat-typing-dots i { background: var(--cr-accent, #2ee8d6); }

.cr-theme-dark-lab .cr-chat-form {
  border-top: 0;
  padding: 4px 12px 14px;
  background: transparent;
}
.cr-theme-dark-lab .cr-chat-who {
  grid-template-columns: minmax(0, 1fr);
}
.cr-theme-dark-lab .cr-chat-log {
  scrollbar-width: thin;
  scrollbar-color: rgba(46, 232, 214, 0.35) transparent;
}
.cr-theme-dark-lab .cr-chat-log::-webkit-scrollbar { width: 6px; }
.cr-theme-dark-lab .cr-chat-log::-webkit-scrollbar-track { background: transparent; }
.cr-theme-dark-lab .cr-chat-log::-webkit-scrollbar-thumb {
  background: rgba(46, 232, 214, 0.35);
  border-radius: 999px;
}
.cr-theme-dark-lab .cr-chat-who input,
.cr-theme-dark-lab .cr-chat-row textarea {
  background: #10171d;
  border: 1px solid rgba(46, 232, 214, 0.22);
  color: #f4fffd;
  border-radius: 999px;
  padding: 10px 14px;
}
.cr-theme-dark-lab .cr-chat-who input::placeholder,
.cr-theme-dark-lab .cr-chat-row textarea::placeholder { color: #7f8e8c; }
.cr-theme-dark-lab .cr-chat-who input:focus,
.cr-theme-dark-lab .cr-chat-row textarea:focus {
  outline: 2px solid var(--cr-accent, #2ee8d6);
  outline-offset: 1px;
  border-color: var(--cr-accent, #2ee8d6);
  background: #121b22;
}
.cr-theme-dark-lab .cr-chat-row textarea {
  border-radius: 999px;
  min-height: 44px;
  padding: 11px 16px;
}
.cr-theme-dark-lab .cr-chat-send {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cr-accent, #2ee8d6);
  color: #041016;
  box-shadow: 0 0 16px rgba(46, 232, 214, 0.4);
}
.cr-theme-dark-lab .cr-chat-send-label { display: none; }
.cr-theme-dark-lab .cr-chat-send-icon { display: block; }
.cr-theme-dark-lab .cr-chat-send:focus-visible {
  outline: 2px solid #f4fffd;
  outline-offset: 2px;
}
.cr-theme-dark-lab .cr-chat-err { color: #ffa8a8; }

@media (max-width: 480px) {
  .cr-theme-dark-lab .cr-chat-panel {
    height: min(620px, calc(100vh - 96px));
    border-radius: 18px;
  }
}
