.wym-chat {
  --wym-chat-ink: #171916;
  --wym-chat-paper: #f1efe7;
  --wym-chat-paper-soft: #faf8f1;
  --wym-chat-muted: #666962;
  --wym-chat-line: rgba(23, 25, 22, .16);
  --wym-chat-signal: #d94e2b;
  --wym-chat-positive: #64c288;
  --wym-chat-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --wym-chat-display: "Archivo", "Avenir Next Condensed", "Helvetica Neue", sans-serif;
  --wym-chat-body: "Avenir Next", "Helvetica Neue", sans-serif;
  --wym-chat-ease: cubic-bezier(.22, 1, .36, 1);
  position: fixed;
  z-index: 240;
  left: var(--wym-chat-left, 24px);
  bottom: var(--wym-chat-bottom, 24px);
  color: var(--wym-chat-ink);
  font-family: var(--wym-chat-body);
  -webkit-font-smoothing: antialiased;
}

.wym-chat *,
.wym-chat *::before,
.wym-chat *::after { box-sizing: border-box; }
.wym-chat [hidden] { display: none !important; }
.wym-chat[data-attachments="false"] .wym-chat__composer { grid-template-columns: minmax(0, 1fr) 44px; }

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

.wym-chat button,
.wym-chat a { -webkit-tap-highlight-color: transparent; }

.wym-chat :focus-visible {
  outline: 3px solid var(--wym-chat-signal);
  outline-offset: 3px;
}

.wym-chat__launcher {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  width: 208px;
  min-height: 58px;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 8px;
  overflow: hidden;
  color: #f8f5ec;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 2px;
  background: var(--wym-chat-ink);
  box-shadow: 0 18px 46px rgba(14, 16, 13, .2);
  cursor: pointer;
  text-align: left;
  transform-origin: left bottom;
  transition: transform 220ms var(--wym-chat-ease), opacity 160ms ease, box-shadow 220ms ease;
}

.wym-chat__launcher::before {
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--wym-chat-signal);
  content: "";
}

.wym-chat__launcher:hover {
  box-shadow: 0 22px 56px rgba(14, 16, 13, .28);
  transform: translateY(-3px);
}

.wym-chat__launcher-mark {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
}

.wym-chat__launcher-mark svg { width: 19px; height: 19px; }

.wym-chat__presence-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--wym-chat-ink);
  border-radius: 50%;
  background: #7f837b;
  transition: background 180ms ease;
}

.wym-chat[data-human-available="true"] .wym-chat__presence-dot { background: var(--wym-chat-positive); }
.wym-chat[data-transport-mode="local-review"][data-human-available="true"] .wym-chat__presence-dot { background: #e0a04d; }

.wym-chat__launcher-copy { display: grid; gap: 2px; min-width: 0; }
.wym-chat__launcher-copy strong {
  font: 700 .72rem/1.1 var(--wym-chat-display);
  letter-spacing: .01em;
}
.wym-chat__launcher-copy small {
  overflow: hidden;
  color: #bfc2ba;
  font: 650 .46rem/1.25 var(--wym-chat-mono);
  letter-spacing: .075em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.wym-chat__launcher-arrow {
  color: var(--wym-chat-signal);
  font: 700 1rem/1 var(--wym-chat-mono);
  transition: transform 220ms var(--wym-chat-ease);
}
.wym-chat__launcher:hover .wym-chat__launcher-arrow { transform: translateX(3px); }

.wym-chat__badge {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  padding-inline: 6px;
  color: #fff;
  border: 2px solid var(--wym-chat-paper);
  border-radius: 12px;
  background: var(--wym-chat-signal);
  font: 750 .62rem/1 var(--wym-chat-mono);
  opacity: 0;
  transform: scale(.65);
  transition: opacity 160ms ease, transform 200ms var(--wym-chat-ease);
}
.wym-chat[data-unread]:not([data-unread="0"]) .wym-chat__badge { opacity: 1; transform: scale(1); }

.wym-chat__panel {
  position: absolute;
  left: 0;
  bottom: 0;
  display: grid;
  width: min(390px, calc(100vw - 32px));
  height: min(650px, calc(100dvh - 48px));
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  border: 1px solid var(--wym-chat-ink);
  border-radius: 2px;
  background: var(--wym-chat-paper-soft);
  box-shadow: 0 28px 90px rgba(14, 16, 13, .3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(.97);
  transform-origin: left bottom;
  visibility: hidden;
  transition: opacity 180ms ease, transform 280ms var(--wym-chat-ease), visibility 0s linear 280ms;
}

.wym-chat.is-open .wym-chat__launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.94);
}

.wym-chat.is-open .wym-chat__panel {
  opacity: 1;
  pointer-events: auto;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}

/* WebKit can retain inherited visibility paint across panel open/close.
   Set both states on the affected content only; [hidden] still uses display:none. */
.wym-chat__panel :is(.wym-chat__head-copy, .wym-chat__message, .wym-chat__attach svg),
.wym-chat__panel :is(.wym-chat__head-copy, .wym-chat__message, .wym-chat__attach svg) * { visibility: hidden; }
.wym-chat.is-open .wym-chat__panel :is(.wym-chat__head-copy, .wym-chat__message, .wym-chat__attach svg),
.wym-chat.is-open .wym-chat__panel :is(.wym-chat__head-copy, .wym-chat__message, .wym-chat__attach svg) * { visibility: visible; }

.wym-chat__head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  padding: 20px 18px 18px;
  color: #f8f5ec;
  background:
    linear-gradient(rgba(255,255,255,.034) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.034) 1px, transparent 1px),
    var(--wym-chat-ink);
  background-size: 30px 30px;
}

.wym-chat__head::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--wym-chat-signal);
  content: "";
}

.wym-chat__head-copy { display: grid; gap: 5px; }
.wym-chat__kicker {
  margin: 0;
  color: #aeb1aa;
  font: 650 .5rem/1.3 var(--wym-chat-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.wym-chat__head h2 {
  margin: 0;
  font: 700 1.42rem/1 var(--wym-chat-display);
  letter-spacing: -.025em;
}
.wym-chat__status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 1px 0 0;
  color: #c3c6be;
  font-size: .7rem;
  line-height: 1.35;
}
.wym-chat__status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7f837b;
  content: "";
}
.wym-chat[data-human-available="true"] .wym-chat__status::before { background: var(--wym-chat-positive); }
.wym-chat[data-transport-mode="local-review"][data-human-available="true"] .wym-chat__status::before { background: #e0a04d; }

.wym-chat__close {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  color: #f8f5ec;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 0;
  background: rgba(255,255,255,.04);
  cursor: pointer;
  font: 500 1.2rem/1 var(--wym-chat-mono);
  transition: background 160ms ease, transform 160ms ease;
}
.wym-chat__close:hover { background: rgba(255,255,255,.11); transform: rotate(4deg); }

.wym-chat__context {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--wym-chat-line);
  background: var(--wym-chat-paper);
}
.wym-chat__context span {
  color: #a9361e;
  font: 750 .48rem/1.2 var(--wym-chat-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.wym-chat__context strong {
  overflow: hidden;
  font-size: .72rem;
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wym-chat__messages {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(rgba(23,25,22,.027) 1px, transparent 1px),
    var(--wym-chat-paper-soft);
  background-size: 100% 44px;
  scrollbar-width: thin;
  scrollbar-color: rgba(23,25,22,.28) transparent;
}

.wym-chat__day {
  margin: 2px 0 16px;
  color: var(--wym-chat-muted);
  font: 650 .48rem/1.2 var(--wym-chat-mono);
  letter-spacing: .1em;
  text-align: center;
  text-transform: uppercase;
}

.wym-chat__message {
  display: grid;
  justify-items: start;
  gap: 5px;
  margin-bottom: 14px;
}
.wym-chat__message[data-author="customer"] { justify-items: end; }
.wym-chat__message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--wym-chat-muted);
  font: 600 .46rem/1.2 var(--wym-chat-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.wym-chat__bubble {
  max-width: 86%;
  padding: 11px 13px;
  border: 1px solid var(--wym-chat-line);
  background: #fffdf7;
  font-size: .79rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wym-chat__message[data-author="customer"] .wym-chat__bubble {
  color: #f8f5ec;
  border-color: var(--wym-chat-ink);
  background: var(--wym-chat-ink);
}
.wym-chat__message[data-author="assistant"] .wym-chat__message-meta { color: #9f321d; }
.wym-chat__message[data-author="assistant"] .wym-chat__bubble {
  border-color: rgba(217,78,43,.34);
  background: #fff8ee;
}
.wym-chat__attachments { display: grid; gap: 5px; margin-top: 8px; }
.wym-chat__attachment {
  display: flex;
  max-width: 100%;
  align-items: center;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px solid currentColor;
  font: 600 .56rem/1.35 var(--wym-chat-mono);
  opacity: .72;
}
.wym-chat__attachment-copy { display: grid; min-width: 0; flex: 1; gap: 3px; }
.wym-chat__attachment-copy small { font: inherit; opacity: .8; }
.wym-chat__download { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; padding: 0; border: 1px solid currentColor; border-radius: 9px; color: inherit; background: transparent; cursor: pointer; font: 600 1rem/1 var(--wym-chat-mono); }
.wym-chat__download:hover { background: rgba(255,255,255,.12); }
.wym-chat__download:disabled { opacity: .45; cursor: wait; }
.wym-chat__download:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.wym-chat__attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wym-chat__quick {
  display: flex;
  gap: 7px;
  margin-top: 8px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.wym-chat__quick::-webkit-scrollbar { display: none; }
.wym-chat__quick button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--wym-chat-ink);
  border: 1px solid var(--wym-chat-line);
  border-radius: 0;
  background: var(--wym-chat-paper);
  cursor: pointer;
  font: 700 .5rem/1.2 var(--wym-chat-mono);
  letter-spacing: .035em;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.wym-chat__quick button:hover { color: #fff; border-color: #a9361e; background: #a9361e; }
.wym-chat__quick button:disabled { cursor: not-allowed; opacity: .48; }

.wym-chat__after-hours-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  max-height: 190px;
  margin: 8px 0 14px;
  overflow: hidden;
  border: 1px solid var(--wym-chat-line);
  background: var(--wym-chat-line);
  opacity: 1;
  transform: none;
  transform-origin: center top;
  transition: max-height 180ms var(--wym-chat-ease), margin 180ms ease, border-width 180ms ease, opacity 130ms ease, transform 180ms var(--wym-chat-ease);
}
.wym-chat__after-hours-actions.is-collapsing {
  max-height: 0;
  margin-block: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px);
}
.wym-chat__after-hours-label {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 10px;
  color: #656861;
  background: var(--wym-chat-paper);
  font: 650 .47rem/1.25 var(--wym-chat-mono);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.wym-chat__after-hours-actions button {
  min-height: 46px;
  padding: 9px 10px;
  color: var(--wym-chat-ink);
  border: 0;
  border-radius: 0;
  background: #fffdf7;
  cursor: pointer;
  font: 700 .51rem/1.25 var(--wym-chat-mono);
  letter-spacing: .035em;
  text-align: left;
  transition: color 150ms ease, background 150ms ease;
}
.wym-chat__after-hours-actions button[data-after-hours-action="chat"] { box-shadow: inset 3px 0 #d94e2b; }
.wym-chat__after-hours-actions button:hover,
.wym-chat__after-hours-actions button[data-selected="true"] {
  color: #fff;
  background: #9f321d;
}
.wym-chat__after-hours-actions button:disabled { cursor: not-allowed; opacity: .48; }

.wym-chat__selected-files {
  display: flex;
  gap: 6px;
  padding: 9px 12px 0;
  overflow-x: auto;
  border-top: 1px solid var(--wym-chat-line);
  background: #fffdf7;
  scrollbar-width: none;
}
.wym-chat__selected-files:empty { display: none; }
.wym-chat__file-chip {
  display: inline-flex;
  min-height: 44px;
  min-width: 0;
  max-width: 220px;
  align-items: center;
  gap: 7px;
  padding: 0 0 0 8px;
  border: 1px solid var(--wym-chat-line);
  background: var(--wym-chat-paper);
  font: 600 .5rem/1.2 var(--wym-chat-mono);
}
.wym-chat__file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wym-chat__file-chip button { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; padding: 0; border: 0; background: transparent; cursor: pointer; }

.wym-chat__composer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid var(--wym-chat-line);
  background: #fffdf7;
}
.wym-chat__attach,
.wym-chat__send {
  display: grid;
  height: 44px;
  place-items: center;
  padding: 0;
  border-radius: 0;
  cursor: pointer;
}
.wym-chat__attach {
  color: var(--wym-chat-ink);
  border: 1px solid var(--wym-chat-line);
  background: transparent;
}
.wym-chat__attach svg { width: 16px; height: 16px; }
.wym-chat__send {
  color: #fff;
  border: 1px solid var(--wym-chat-signal);
  background: var(--wym-chat-signal);
  font: 750 1rem/1 var(--wym-chat-mono);
}
.wym-chat__send:disabled { cursor: not-allowed; opacity: .42; }
.wym-chat__composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 108px;
  resize: none;
  padding: 10px 0 8px;
  color: var(--wym-chat-ink);
  border: 0;
  border-bottom: 1px solid var(--wym-chat-line);
  border-radius: 0;
  outline: 0;
  background: transparent;
  font-size: .78rem;
  line-height: 1.4;
}
.wym-chat__composer textarea:focus { border-color: var(--wym-chat-signal); }
.wym-chat__composer textarea::placeholder { color: #6f726c; }

.wym-chat__channels {
  position: relative;
  border-top: 1px solid var(--wym-chat-line);
  background: var(--wym-chat-paper);
  transition: background 180ms ease, border-color 180ms ease;
}
.wym-chat__channels[hidden] { display: none; }
.wym-chat[data-human-hours="after-hours"] .wym-chat__channels {
  border-top-color: rgba(217,78,43,.48);
  background: #fff8ee;
}
.wym-chat__channels summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  cursor: pointer;
  font: 700 .5rem/1.2 var(--wym-chat-mono);
  letter-spacing: .065em;
  list-style: none;
  text-transform: uppercase;
}
.wym-chat[data-human-hours="after-hours"] .wym-chat__channels summary { color: #9f321d; }
.wym-chat__channels summary::-webkit-details-marker { display: none; }
.wym-chat__channels summary span:last-child { color: var(--wym-chat-signal); font-size: .8rem; }
.wym-chat__channel-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--wym-chat-line);
}
.wym-chat__channel-list a {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  color: inherit;
  border-right: 1px solid var(--wym-chat-line);
  border-bottom: 1px solid var(--wym-chat-line);
  text-decoration: none;
}
.wym-chat__channel-list a:nth-child(2n) { border-right: 0; }
.wym-chat__channel-list a:nth-last-child(-n+2) { border-bottom: 0; }
.wym-chat__channel-list a:hover { background: #fffdf7; }
.wym-chat__channels[data-channel-filter="whatsapp"] .wym-chat__channel-list a:not([data-contact-type="whatsapp"]),
.wym-chat__channels[data-channel-filter="email"] .wym-chat__channel-list a:not([data-contact-type="email"]) {
  display: none;
}
.wym-chat[data-human-hours="after-hours"] .wym-chat__channel-list a { background: rgba(255,253,247,.72); }
.wym-chat[data-human-hours="after-hours"] .wym-chat__channel-list a:hover { color: #8d2a17; background: #fffdf7; }
.wym-chat__channel-list strong { font-size: .62rem; }
.wym-chat__channel-list small {
  overflow: hidden;
  color: var(--wym-chat-muted);
  font: 600 .45rem/1.25 var(--wym-chat-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wym-chat__sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 640px) {
  .wym-chat {
    left: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  .wym-chat__launcher {
    width: 56px;
    min-height: 56px;
    grid-template-columns: 1fr;
    padding: 7px;
  }
  .wym-chat__launcher-copy,.wym-chat__launcher-arrow { display: none; }
  .wym-chat__launcher-mark { width: 40px; height: 40px; }
  .wym-chat__panel {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: min(720px, calc(100dvh - 10px));
    border-width: 1px 0 0;
    transform: translateY(24px);
    transform-origin: center bottom;
  }
  .wym-chat__messages { padding: 16px; }
  .wym-chat__bubble { max-width: 90%; }
  .wym-chat__after-hours-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wym-chat__channels { padding-bottom: env(safe-area-inset-bottom); }
  .wym-chat[data-human-hours="after-hours"] .wym-chat__channel-list { grid-template-columns: 1fr; }
  .wym-chat[data-human-hours="after-hours"] .wym-chat__channel-list a {
    border-right: 0;
    border-bottom: 1px solid var(--wym-chat-line);
  }
}

@media (max-width: 390px) {
  .wym-chat { bottom: max(82px, calc(14px + env(safe-area-inset-bottom))); }
}

@media (prefers-reduced-motion: reduce) {
  .wym-chat *,
  .wym-chat *::before,
  .wym-chat *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
