.riva-support {
  position: fixed;
  z-index: 125;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  color: var(--ink, #171311);
  --riva-support-accent: var(--terracotta-dark, #71351f);
}

.riva-support [hidden] { display: none !important; }
.riva-support button, .riva-support input { font: inherit; }
.riva-support button { cursor: pointer; }
.riva-support button:disabled { cursor: wait; opacity: .65; }
.riva-support :is(button, input):focus-visible { outline: 2px solid #a44436; outline-offset: 3px; }

/* A plain round chat button in the site's dark terracotta, like its other buttons and line icons.
   It turns into a close icon while the chat is open. */
.riva-support-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--riva-support-accent);
  box-shadow: 0 10px 26px rgba(34, 23, 17, .24);
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
/* Only a real pointer gets the hover look, so it never sticks on a phone after a tap. */
@media (hover: hover) {
  .riva-support-toggle:hover { background: var(--ink, #171311); transform: translateY(-1px); }
}
.riva-support-toggle:active { transform: scale(.96); }
.riva-support-icon {
  grid-area: 1 / 1;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity .18s ease, transform .18s ease;
}
.riva-support-dots { stroke-width: 2.6; }
.riva-support-icon-close { opacity: 0; transform: rotate(-45deg) scale(.7); }
.riva-support-toggle[aria-expanded="true"] .riva-support-icon-chat { opacity: 0; transform: scale(.7); }
.riva-support-toggle[aria-expanded="true"] .riva-support-icon-close { opacity: 1; transform: none; }
/* A small note above the button tells visitors they can ask here. Tapping it opens the chat, and it
   hides while the chat, the cart or a product is open. */
.riva-support-hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 11px);
  padding: 7px 13px;
  border: 1px solid var(--line, #e3d9ce);
  border-radius: 12px;
  color: var(--ink, #171311);
  background: var(--paper, #fffdf9);
  box-shadow: 0 8px 22px rgba(34, 23, 17, .12);
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  animation: riva-support-hint-in .35s ease .8s both;
}
.riva-support-hint::after {
  content: "";
  position: absolute;
  right: 23px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border: solid var(--line, #e3d9ce);
  border-width: 0 1px 1px 0;
  background: inherit;
  transform: rotate(45deg);
}
@keyframes riva-support-hint-in { from { opacity: 0; transform: translateY(4px); } }
.riva-support-toggle[aria-expanded="true"] .riva-support-hint,
body:has(.cart-drawer.open, .product-modal.open) .riva-support-hint { display: none; }
@media (prefers-reduced-motion: reduce) {
  .riva-support-toggle, .riva-support-icon { transition: none; }
  .riva-support-toggle:hover, .riva-support-toggle:active { transform: none; }
  .riva-support-hint { animation: none; }
}

.riva-support-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 30px));
  height: min(540px, calc(100dvh - 97px));
  overflow: hidden;
  border: 1px solid #e5d7c8;
  border-radius: 16px;
  background: #fffdf9;
  box-shadow: 0 12px 40px #26120f38;
  font-size: .875rem;
}

.riva-support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #f3e8dd;
  border-bottom: 1px solid #e5d7c8;
}

.riva-support-header h2 { margin: 0; font-size: 1rem; }
.riva-support-subtitle { margin: 0; color: #60463d; font-size: .75rem; }
.riva-support-close {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 1.5rem !important;
}

.riva-support-body { flex: 1; min-height: 0; overflow: auto; padding: 12px; overscroll-behavior: contain; }
.riva-support-log { display: flex; flex-direction: column; gap: 8px; }
.riva-support-log p {
  max-width: 85%;
  margin: 0;
  padding: 8px 11px;
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
/* Like WhatsApp and Messenger, the visitor's own messages sit on the right and Riva's replies on the left.
   The chat is right-to-left, so flex-start is the right edge and flex-end the left one. The tighter
   bottom corner on each side points to who sent the message. */
.riva-support-log .riva-support-agent { align-self: flex-end; border-bottom-left-radius: 3px; background: #f4ece3; }
.riva-support-log .riva-support-visitor {
  align-self: flex-start;
  border-bottom-right-radius: 3px;
  background: var(--riva-support-accent);
  color: #fff;
}

.riva-support-message {
  display: flex;
  gap: 8px;
  padding: 9px 12px 3px;
  border-top: 1px solid #e5d7c8;
}

.riva-support input:not([type="checkbox"]) {
  min-width: 0;
  width: 100%;
  min-height: 40px;
  padding: 6px 9px;
  border: 1px solid #a99486;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font-size: 1rem;
}
/* The empty box stays right-to-left, so the Arabic hint sits on the right, but what the visitor types
   takes its direction from its first letters: an English message keeps its punctuation at the end. */
.riva-support-message input { unicode-bidi: plaintext; }

.riva-support form button {
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--riva-support-accent);
  white-space: nowrap;
}

.riva-shop-cards {
  display: grid;
  gap: 7px;
  padding: 0 24px 0 0;
  padding-inline: 24px 0;
  margin: 7px 0;
  list-style: decimal;
}
.riva-shop-cards li::marker { color: #755443; font-size: .75rem; font-weight: 700; }
.riva-shop-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e6d8c9;
  border-radius: 10px;
  text-decoration: none;
  color: #352319;
}
.riva-shop-card:hover { border-color: #a86346; background: #fffaf2; }
.riva-shop-card:focus-visible { outline: 2px solid #a44436; outline-offset: 2px; }
.riva-shop-card img { width: 66px; height: 66px; border-radius: 6px; object-fit: cover; flex: 0 0 66px; }
.riva-shop-card > span { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.riva-shop-card strong { font-size: .81rem; line-height: 1.35; }
.riva-shop-card small { color: #654e42; line-height: 1.35; }
.riva-shop-price { font-size: .8rem; font-weight: 700; }
.riva-shop-action { width: fit-content; color: var(--riva-support-accent); text-decoration: underline; text-underline-offset: 3px; font-size: .75rem; }
.riva-shop-unavailable { color: #654e42; padding: 5px; }
@media (max-width: 700px) {
  .cart-drawer.open { --riva-cart-support-space: max(76px, calc(env(safe-area-inset-bottom) + 68px)); }
  .cart-drawer.open .cart-panel { bottom: var(--riva-cart-support-space); }
  .cart-drawer.open::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: var(--riva-cart-support-space);
    border-top: 1px solid #e5d7c8;
    background: #fffdf9;
    pointer-events: none;
  }
  body:has(.cart-drawer.open .checkout-form :is(input, textarea, select):focus)
    .riva-support-toggle[aria-expanded="false"] { visibility: hidden; }
}
.riva-support-typing { color: #60463d; font-style: italic; }
.riva-support-older {
  display: block;
  margin: 0 auto 8px;
  padding: 5px 12px;
  border: 1px solid #e5d7c8;
  border-radius: 8px;
  background: #fffdf9;
  color: var(--riva-support-accent);
}
.riva-support-status, .riva-support-note { margin: 0; padding: 3px 12px 7px; color: #60463d; font-size: .75rem; }
