.yps-chat {
  --yps-chat-ink: #211a13;
  --yps-chat-muted: #665443;
  --yps-chat-paper: #fffaf2;
  --yps-chat-line: #e6d9c6;
  --yps-chat-gold: #f2d19a;
  --yps-chat-action: #8e5e26;
}

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

.yps-chat-launcher {
  position: fixed;
  inset: auto max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) auto;
  z-index: 34;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 8px 18px;
  border: 1px solid #e3ba78;
  border-radius: 32px;
  background: var(--yps-chat-gold);
  box-shadow: 0 8px 28px #472d163d;
  color: var(--yps-chat-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.yps-chat-launcher:hover { background: #f9dfb6; }

.yps-chat-icon {
  position: relative;
  width: 22px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.yps-chat-icon::after {
  position: absolute;
  inset: auto auto -5px 3px;
  width: 5px;
  height: 5px;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  background: var(--yps-chat-gold);
  transform: skewY(-25deg);
  content: '';
}

.yps-chat-launcher:hover .yps-chat-icon::after { background: #f9dfb6; }

.yps-chat-icon i {
  position: absolute;
  inset: 6px auto auto 8px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 4px 0, -4px 0;
}

.yps-chat-dialog {
  --yps-chat-edge: 24px;
  position: fixed;
  inset: auto max(var(--yps-chat-edge), env(safe-area-inset-right))
    calc(max(var(--yps-chat-edge), env(safe-area-inset-bottom)) + var(--yps-chat-keyboard-offset, 0px)) auto;
  width: min(410px, calc(100% - 2 * var(--yps-chat-edge)));
  height: min(590px, calc(var(--yps-chat-visible-height, 100dvh) - 2 * var(--yps-chat-edge)));
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--yps-chat-line);
  border-radius: 24px;
  background: var(--yps-chat-paper);
  box-shadow: 0 26px 75px #26190f55;
  color: var(--yps-chat-ink);
}

.yps-chat-dialog[open] { display: flex; flex-direction: column; }
.yps-chat-dialog::backdrop { background: #24181055; }
html:has(.yps-chat-dialog[open]) { overflow: hidden; }

.yps-chat-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 44px;
  gap: 11px;
  align-items: center;
  flex-shrink: 0;
  padding: 15px 16px;
  border-bottom: 1px solid var(--yps-chat-line);
  background: #f7e9d1;
}

.yps-chat-head img { display: block; border-radius: 50%; }
.yps-chat-head h2 { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.2; }
.yps-chat-head p { margin: 4px 0 0; color: var(--yps-chat-muted); font-size: 12px; line-height: 1.2; }

.yps-chat-close {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid #e3cda9;
  border-radius: 50%;
  background: #fffbf3;
  color: var(--yps-chat-ink);
  font: inherit;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.yps-chat-close:hover { background: #f7e1b8; }

.yps-chat-history {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px;
}

.yps-chat-history:focus-visible { outline-offset: -4px; }

.yps-chat-intro {
  width: fit-content;
  max-width: 90%;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--yps-chat-line);
  border-radius: 13px 13px 13px 4px;
  background: #fff;
  color: var(--yps-chat-muted);
  font-size: 13px;
  line-height: 1.5;
}

.yps-chat-messages {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.yps-chat-message {
  max-width: 88%;
  width: fit-content;
  padding: 10px 13px;
  border: 1px solid var(--yps-chat-line);
  background: #fff;
}

.yps-chat-message.is-client {
  justify-self: end;
  border-color: #e4c58f;
  border-radius: 14px 14px 4px 14px;
  background: #f7e5c4;
}

.yps-chat-message.is-staff { border-radius: 14px 14px 14px 4px; }

.yps-chat-message p {
  margin: 0;
  font-size: 14px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.yps-chat-message-meta {
  display: block;
  margin-top: 5px;
  color: var(--yps-chat-muted);
  font-size: 11px;
  line-height: 1.35;
}

.yps-chat-connection,
.yps-chat-typing {
  flex-shrink: 0;
  margin: 0;
  padding: 0 16px 8px;
  color: var(--yps-chat-muted);
  font-size: 12px;
  line-height: 1.45;
}

.yps-chat-connection:empty,
.yps-chat-send-status:empty { display: none; }

.yps-chat-form {
  display: grid;
  gap: 7px;
  flex-shrink: 0;
  margin: 0;
  padding: 13px 16px 15px;
  border-top: 1px solid var(--yps-chat-line);
  background: #fffdf8;
}

.yps-chat-label { font-size: 12px; font-weight: 750; }

.yps-chat-form textarea {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid #d8c5a7;
  border-radius: 11px;
  background: #fff;
  color: var(--yps-chat-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  resize: none;
}

.yps-chat-form textarea::placeholder { color: var(--yps-chat-muted); opacity: 1; }

.yps-chat-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.yps-chat-send-status {
  flex: 1 1 auto;
  margin: 0;
  color: var(--yps-chat-muted);
  font-size: 12px;
  line-height: 1.4;
}

.yps-chat-send {
  flex: none;
  min-height: 44px;
  padding: 6px 17px;
  border: 1px solid var(--yps-chat-ink);
  border-radius: 10px;
  background: var(--yps-chat-ink);
  color: #fff6e9;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.yps-chat-send:hover:not(:disabled) { background: #563616; }
.yps-chat-send:disabled { opacity: .48; cursor: default; }
.yps-chat :focus-visible { outline: 2px solid var(--yps-chat-action); outline-offset: 3px; }
.yps-chat .yps-chat-history:focus-visible { outline-offset: -4px; }

@media (max-width: 540px) {
  .yps-chat-launcher {
    inset: auto max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) auto;
    min-height: 49px;
    padding-inline: 13px;
    font-size: 13px;
  }

  .yps-chat-dialog { --yps-chat-edge: 8px; border-radius: 20px; }
  .yps-chat-head { padding: 10px 12px; }
  .yps-chat-history { padding: 14px 12px; }
  .yps-chat-form { padding: 9px 12px 12px; }
}

@media (max-height: 420px) {
  .yps-chat-head { padding-block: 7px; }
  .yps-chat-form { padding-block: 7px; }
  .yps-chat-form textarea { max-height: 55px; }
}
.yps-chat-attachment {
  display: block;
  margin-block: 5px;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.market-product-copy [data-yps-chat] + #product-continue {
  display: flex;
  margin-top: 6px;
  background: transparent;
  color: var(--market-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
