/* ==========================================================================
   خانه ایرانیان — ویجت پشتیبانی شناور
   chat-widget.css · v20261027 · RTL · هم‌راستا با توکن‌های style.css
   ========================================================================== */

.khw {
  --khw-navy: var(--navy, #1b2440);
  --khw-navy-2: var(--navy-2, #2a3660);
  --khw-brass: var(--brass, #a9824c);
  --khw-brass-light: var(--brass-light, #c7a76b);
  --khw-paper: var(--paper, #faf7f0);
  --khw-paper-alt: var(--paper-alt, #f1ead9);
  --khw-card: var(--card, #ffffff);
  --khw-line: var(--line, #e2d9c4);
  --khw-ink: var(--ink, #23262b);
  --khw-ink-soft: var(--ink-soft, #5b5a54);
  --khw-ok: var(--available, #3f7a5c);
  --khw-busy: var(--busy, #b0a99c);
  --khw-stamp: var(--stamp, #8c3b2e);
  --khw-ease: var(--ease, cubic-bezier(0.22, 0.8, 0.24, 1));
  --khw-radius: 22px;
  --khw-shadow: 0 34px 74px -32px rgba(27, 36, 64, 0.55),
    0 14px 30px -18px rgba(27, 36, 64, 0.28), 0 0 0 1px rgba(169, 130, 76, 0.14);

  position: fixed;
  inset: 0;
  z-index: 900;
  direction: rtl;
  pointer-events: none;
  font-family: "Yekan Bakh", Tahoma, sans-serif;
  font-size: 13px;
  line-height: 1.8;
  color: var(--khw-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.khw *,
.khw *::before,
.khw *::after {
  box-sizing: border-box;
}
.khw[hidden] {
  display: none !important;
}
.khw button,
.khw input,
.khw textarea,
.khw a {
  font-family: inherit;
}
.khw button {
  -webkit-tap-highlight-color: transparent;
}
.khw :focus-visible {
  outline: 2px solid var(--khw-brass);
  outline-offset: 2px;
}
.khw svg {
  display: block;
}
.khw img {
  max-width: 100%;
}

/* مقاوم‌سازی در برابر استایل‌های سراسری قالب سایت (header/footer/section) */
.khw button {
  margin: 0;
  text-transform: none;
}
.khw a {
  text-decoration: none;
}
.khw ul,
.khw li {
  margin: 0;
}

/* --------------------------------------------------------------------------
   لانچر شناور
   -------------------------------------------------------------------------- */
.khw-launcher-wrap {
  position: fixed;
  right: 22px;
  left: auto;
  bottom: 22px;
  z-index: 3;
  pointer-events: auto;
  transition: opacity 0.24s ease, transform 0.32s var(--khw-ease),
    visibility 0.24s linear;
}
.khw.is-open .khw-launcher-wrap {
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.7);
  pointer-events: none;
}

.khw-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 66px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--khw-paper);
  background: linear-gradient(
    148deg,
    #36436e 0%,
    var(--khw-navy-2) 32%,
    var(--khw-navy) 66%,
    #7c5f36 118%
  );
  box-shadow: 0 18px 34px -14px rgba(27, 36, 64, 0.62),
    0 8px 16px -10px rgba(27, 36, 64, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    inset 0 0 0 5px rgba(255, 255, 255, 0.07);
  transition: transform 0.3s var(--khw-ease), box-shadow 0.3s var(--khw-ease),
    filter 0.3s ease;
  isolation: isolate;
}
/* هالهٔ نفس‌کشنده */
.khw-launcher::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(169, 130, 76, 0.18),
    0 0 26px 3px rgba(199, 167, 107, 0.38);
  opacity: 0.7;
  animation: khw-breathe 4.4s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}
/* حلقهٔ داخلی ظریف */
.khw-launcher::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.26);
  box-shadow: inset 0 0 16px rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.khw-launcher:hover {
  transform: translateY(-3px) scale(1.035);
  box-shadow: 0 24px 42px -14px rgba(27, 36, 64, 0.68),
    0 10px 20px -12px rgba(27, 36, 64, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.32),
    inset 0 0 0 5px rgba(255, 255, 255, 0.09);
}
.khw-launcher:hover .khw-launcher-icon {
  transform: scale(1.06) rotate(-4deg);
}
.khw-launcher:active {
  transform: translateY(-1px) scale(0.985);
}
.khw-launcher-icon {
  width: 29px;
  height: 29px;
  transition: transform 0.35s var(--khw-ease);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
  pointer-events: none;
}
.khw-launcher-icon svg {
  width: 100%;
  height: 100%;
}
.khw-launcher-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* حلقه‌های پالس */
.khw-wave {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(199, 167, 107, 0.55);
  pointer-events: none;
  animation: khw-wave 3.6s var(--khw-ease) infinite;
  z-index: -1;
}
.khw-wave--2 {
  border-color: rgba(169, 130, 76, 0.4);
  animation-delay: 1.8s;
}

/* نشان آنلاین */
.khw-online {
  position: absolute;
  bottom: 5px;
  inset-inline-start: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--khw-ok);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(27, 36, 64, 0.35);
  animation: khw-ping 2.8s ease-out infinite;
  transition: background 0.3s ease;
}
.khw.is-offline .khw-online {
  background: var(--khw-busy);
  animation: none;
}

/* نشان پیام خوانده‌نشده */
.khw-badge {
  position: absolute;
  top: -4px;
  inset-inline-start: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(160deg, #b4482f, var(--khw-stamp));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 6px 14px -4px rgba(140, 59, 46, 0.7);
  animation: khw-badge-pop 0.42s var(--khw-ease) both;
  pointer-events: none;
}
.khw-badge[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   تول‌تیپ
   -------------------------------------------------------------------------- */
.khw-tip {
  position: absolute;
  bottom: calc(100% + 18px);
  right: 0;
  left: auto;
  width: 248px;
  padding: 12px 14px;
  cursor: pointer;
  border-radius: 15px;
  background: rgba(250, 247, 240, 0.92);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid rgba(169, 130, 76, 0.42);
  box-shadow: 0 20px 42px -20px rgba(27, 36, 64, 0.4),
    0 4px 12px -6px rgba(27, 36, 64, 0.16), inset 0 1px rgba(255, 255, 255, 0.75);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.94);
  transform-origin: bottom right;
  transition: opacity 0.34s var(--khw-ease), transform 0.4s var(--khw-ease),
    visibility 0.3s linear;
}
.khw-tip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 22px;
  left: auto;
  width: 12px;
  height: 12px;
  background: rgba(250, 247, 240, 0.94);
  border-inline-start: 1px solid rgba(169, 130, 76, 0.42);
  border-top: 1px solid rgba(169, 130, 76, 0.42);
  transform: rotate(45deg);
}
.khw-tip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.khw-tip-text {
  display: block;
  font-size: 11.5px;
  line-height: 1.85;
  color: var(--khw-navy);
  padding-inline-end: 12px;
  text-wrap: balance;
}
.khw-tip-text b {
  color: var(--khw-brass);
  font-weight: 700;
}
.khw-tip-close {
  position: absolute;
  top: 5px;
  inset-inline-start: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(169, 130, 76, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--khw-ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.khw-tip-close:hover {
  background: rgba(169, 130, 76, 0.2);
  color: var(--khw-navy);
}
.khw-tip-close svg {
  width: 9px;
  height: 9px;
}

/* --------------------------------------------------------------------------
   پنل گفتگو
   -------------------------------------------------------------------------- */
.khw-panel {
  position: fixed;
  right: 22px;
  left: auto;
  bottom: 22px;
  z-index: 2;
  /* گرید صریح: سربرگ / پیام‌ها / چیپ‌ها / نوشتن / فوتر — هرگز روی هم نمی‌افتند */
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  width: 380px;
  height: min(640px, 78vh);
  max-height: min(660px, 78vh);
  padding: 0;
  margin: 0;
  border-radius: var(--khw-radius);
  background: var(--khw-card);
  border: 1px solid rgba(169, 130, 76, 0.32);
  box-shadow: var(--khw-shadow);
  overflow: hidden;
  transform-origin: calc(100% - 33px) calc(100% - 33px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.84);
  transition: opacity 0.26s ease, transform 0.26s ease, visibility 0s linear 0.26s;
  overscroll-behavior: contain;
  pointer-events: none;
  will-change: transform, opacity;
}
.khw-panel > * {
  min-width: 0;
}
.khw.is-open .khw-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.34s ease, transform 0.42s var(--khw-ease);
}

/* سربرگ شیشه‌ای */
.khw-head {
  position: relative;
  inset: auto;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--khw-line);
  border-radius: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.78),
    rgba(250, 247, 240, 0.92)
  );
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: none;
  overflow: hidden;
}
.khw-head::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--khw-brass) 22%,
    var(--khw-brass-light) 50%,
    var(--khw-brass) 78%,
    transparent
  );
  opacity: 0.72;
}
.khw-head::after {
  content: "";
  position: absolute;
  top: -40%;
  bottom: -40%;
  left: auto;
  right: auto;
  width: 46%;
  background: linear-gradient(
    100deg,
    transparent,
    rgba(255, 255, 255, 0.55),
    transparent
  );
  transform: translateX(-160%) rotate(12deg);
  animation: khw-sheen 7.5s ease-in-out infinite;
  pointer-events: none;
}
.khw-head > * {
  position: relative;
  z-index: 1;
}

.khw-seal {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--khw-navy);
  background: radial-gradient(circle at 32% 26%, #fffdf7, var(--khw-paper-alt));
  border: 1.5px dashed var(--khw-brass);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6),
    0 4px 10px -6px rgba(27, 36, 64, 0.4);
}
.khw-seal::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px solid rgba(199, 167, 107, 0.55);
}
.khw-seal svg {
  width: 20px;
  height: 20px;
}

.khw-head-txt {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.khw-title {
  display: block;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
  color: var(--khw-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.khw-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--khw-ink-soft);
  line-height: 1.6;
}
.khw-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--khw-ok);
  flex: 0 0 auto;
  animation: khw-live 2.4s ease-out infinite;
}
.khw.is-offline .khw-live,
.khw.is-disabled .khw-live {
  background: var(--khw-busy);
  animation: none;
}
.khw-head-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.khw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--khw-ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.khw-icon-btn:hover {
  background: rgba(169, 130, 76, 0.16);
  color: var(--khw-navy);
}
.khw-icon-btn:active {
  transform: scale(0.92);
}
.khw-icon-btn svg {
  width: 15px;
  height: 15px;
}

/* نوار پیشرفت بارگذاری */
.khw-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 3;
}
.khw.is-loading .khw-progress {
  opacity: 1;
}
.khw-progress::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 42%;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--khw-brass-light),
    var(--khw-brass),
    transparent
  );
  animation: khw-progress 1.15s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   ناحیهٔ پیام‌ها
   -------------------------------------------------------------------------- */
.khw-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px 10px;
  background: radial-gradient(
      circle at 100% 0,
      rgba(199, 167, 107, 0.13),
      transparent 46%
    ),
    radial-gradient(circle at 0 100%, rgba(27, 36, 64, 0.055), transparent 42%),
    var(--khw-paper);
  scrollbar-width: thin;
  scrollbar-color: rgba(169, 130, 76, 0.4) transparent;
}
.khw-body::-webkit-scrollbar {
  width: 6px;
}
.khw-body::-webkit-scrollbar-track {
  background: transparent;
}
.khw-body::-webkit-scrollbar-thumb {
  background: rgba(169, 130, 76, 0.38);
  border-radius: 6px;
}
.khw-body::-webkit-scrollbar-thumb:hover {
  background: rgba(169, 130, 76, 0.6);
}
.khw-body > * {
  flex: 0 0 auto;
  min-width: 0;
}

/* پیام‌ها */
.khw-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: khw-msg-in 0.38s var(--khw-ease) both;
  animation-delay: var(--khw-delay, 0ms);
}
.khw-msg--visitor {
  justify-content: flex-start;
}
.khw-msg--assistant,
.khw-msg--admin {
  justify-content: flex-end;
}
.khw-msg--assistant .khw-avatar,
.khw-msg--admin .khw-avatar {
  order: 2;
}

.khw-avatar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-bottom: 18px;
  border-radius: 50%;
  color: var(--khw-brass);
  background: radial-gradient(circle at 30% 25%, #fffdf7, var(--khw-paper-alt));
  border: 1px dashed rgba(169, 130, 76, 0.75);
  box-shadow: 0 3px 8px -5px rgba(27, 36, 64, 0.45);
}
.khw-avatar svg {
  width: 14px;
  height: 14px;
}
.khw-msg--admin .khw-avatar {
  color: var(--khw-navy);
  border-style: solid;
  border-color: rgba(169, 130, 76, 0.55);
  background: var(--khw-paper-alt);
}

.khw-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 86%;
  min-width: 0;
}
.khw-msg--assistant .khw-bubble-wrap,
.khw-msg--admin .khw-bubble-wrap {
  align-items: flex-end;
}
.khw-msg--visitor .khw-bubble-wrap {
  align-items: flex-start;
}
.khw-role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-inline: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--khw-brass);
}
.khw-role::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--khw-brass);
}

.khw-bubble {
  position: relative;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.9;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.khw-msg--visitor .khw-bubble {
  color: #f8f3e8;
  background: linear-gradient(160deg, var(--khw-navy-2), var(--khw-navy));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 20px -14px rgba(27, 36, 64, 0.7),
    inset 0 1px rgba(255, 255, 255, 0.14);
}
.khw-msg--assistant .khw-bubble {
  color: var(--khw-ink);
  background: var(--khw-card);
  border: 1px solid var(--khw-line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 8px 18px -16px rgba(27, 36, 64, 0.45);
}
.khw-msg--admin .khw-bubble {
  color: var(--khw-ink);
  background: linear-gradient(165deg, #fffdf8, #fffaf1);
  border: 1px solid rgba(169, 130, 76, 0.55);
  border-bottom-left-radius: 6px;
  box-shadow: 0 8px 18px -16px rgba(27, 36, 64, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}
.khw-msg--assistant .khw-bubble .khw-line:first-child,
.khw-msg--admin .khw-bubble .khw-line:first-child {
  margin-top: 0;
}

/* متن پیام و مارک‌داون سبک */
.khw-bubble .khw-line + .khw-line {
  margin-top: 2px;
}
.khw-bubble .khw-br {
  display: block;
  height: 6px;
}
.khw-bubble strong {
  font-weight: 800;
}
.khw-msg--visitor .khw-bubble strong {
  color: #fff;
}
.khw-list {
  margin: 4px 0;
  padding: 0;
  list-style: none;
}
.khw-list li {
  position: relative;
  padding-inline-start: 14px;
  margin-top: 3px;
}
.khw-list li::before {
  content: "•";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  color: var(--khw-brass);
  font-weight: 700;
}
.khw-msg--visitor .khw-list li::before {
  color: var(--khw-brass-light);
}
.khw-link {
  color: #6d5025;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(169, 130, 76, 0.55);
  text-decoration-thickness: 1px;
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
  unicode-bidi: isolate;
  overflow-wrap: anywhere;
}
.khw-link--path {
  direction: ltr;
  unicode-bidi: isolate;
  word-break: normal;
}
.khw-link:hover {
  color: var(--khw-brass);
  text-decoration-color: var(--khw-brass);
}
.khw-msg--visitor .khw-link {
  color: var(--khw-brass-light);
  text-decoration-color: rgba(199, 167, 107, 0.55);
}
.khw-msg--visitor .khw-link:hover {
  color: #f1dcae;
}
.khw-tel {
  direction: ltr;
  unicode-bidi: isolate;
}

/* تصویر پیام */
.khw-img-btn {
  display: block;
  margin: 0 0 7px;
  padding: 0;
  width: 100%;
  max-width: 226px;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #101627;
  cursor: zoom-in;
  line-height: 0;
}
.khw-img-btn img {
  display: block;
  width: 100%;
  max-height: 230px;
  object-fit: cover;
  transition: transform 0.45s var(--khw-ease), opacity 0.3s ease;
  opacity: 0;
}
.khw-img-btn img.is-loaded {
  opacity: 1;
}
.khw-img-btn:hover img {
  transform: scale(1.035);
}
.khw-msg--visitor .khw-img-btn {
  background: rgba(255, 255, 255, 0.1);
}

/* متادیتای پیام */
.khw-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-inline: 5px;
  font-size: 9.5px;
  line-height: 1.6;
  color: var(--khw-ink-soft);
  opacity: 0.72;
}
.khw-time {
  direction: ltr;
  unicode-bidi: embed;
  letter-spacing: 0.02em;
}
.khw-sending {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid rgba(169, 130, 76, 0.35);
  border-top-color: var(--khw-brass);
  animation: khw-spin 0.8s linear infinite;
}
.khw-failed {
  color: var(--khw-stamp);
  opacity: 1;
  font-weight: 700;
}
.khw-retry {
  padding: 0;
  border: 0;
  background: none;
  color: var(--khw-brass);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.khw-retry:hover {
  color: var(--khw-navy);
}

/* تایپینگ */
.khw-typing .khw-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}
.khw-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--khw-brass);
  opacity: 0.45;
  animation: khw-dot 1.25s ease-in-out infinite;
}
.khw-typing-dot:nth-child(2) {
  animation-delay: 0.16s;
}
.khw-typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}

/* جداکنندهٔ روز */
.khw-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  font-size: 9.5px;
  color: var(--khw-ink-soft);
  opacity: 0.8;
  user-select: none;
}
.khw-divider::before,
.khw-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
}
.khw-divider::before {
  background: linear-gradient(90deg, transparent, var(--khw-line));
}
.khw-divider::after {
  background: linear-gradient(90deg, var(--khw-line), transparent);
}
.khw-divider span {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(226, 217, 196, 0.9);
  white-space: nowrap;
}

/* اعلان/هشدار سیستمی */
.khw-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 2px 0;
  padding: 9px 11px;
  border-radius: 12px;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--khw-ink-soft);
  background: rgba(241, 234, 217, 0.72);
  border: 1px dashed rgba(169, 130, 76, 0.42);
  animation: khw-msg-in 0.32s var(--khw-ease) both;
}
.khw-notice--warn {
  color: #7a3e1e;
  background: var(--warn-bg, #fbefe8);
  border-color: var(--warn-line, #d9a889);
  border-style: solid;
}
.khw-notice-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  color: var(--khw-brass);
}
.khw-notice--warn .khw-notice-icon {
  color: var(--warn-line, #d9a889);
}
.khw-notice-body {
  flex: 1 1 auto;
  min-width: 0;
}
.khw-notice-action {
  margin-top: 6px;
}
.khw-notice-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--khw-brass);
  background: transparent;
  color: var(--khw-navy);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.khw-notice-btn:hover {
  background: var(--khw-brass);
  color: #fff;
}
.khw-cooldown {
  font-weight: 700;
  color: var(--khw-stamp);
}

/* --------------------------------------------------------------------------
   کارت مشاوره (CTA)
   -------------------------------------------------------------------------- */
.khw-cta {
  position: relative;
  margin: 4px 0 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(169, 130, 76, 0.4);
  background: linear-gradient(160deg, #fffdf8 0%, var(--khw-paper-alt) 100%);
  box-shadow: 0 14px 28px -24px rgba(27, 36, 64, 0.55);
  overflow: hidden;
  animation: khw-msg-in 0.42s var(--khw-ease) both;
}
.khw-cta::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: 3px;
  background: linear-gradient(
    180deg,
    var(--khw-brass),
    var(--khw-brass-light),
    var(--khw-brass)
  );
}
.khw-cta-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}
.khw-cta-seal {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px dashed rgba(169, 130, 76, 0.7);
  color: var(--khw-brass);
  background: rgba(255, 255, 255, 0.6);
}
.khw-cta-seal svg {
  width: 16px;
  height: 16px;
}
.khw-cta-copy {
  min-width: 0;
}
.khw-cta-copy strong {
  display: block;
  font-size: 11.8px;
  font-weight: 800;
  color: var(--khw-navy);
  line-height: 1.6;
}
.khw-cta-copy span {
  display: block;
  font-size: 10px;
  color: var(--khw-ink-soft);
  line-height: 1.7;
}
.khw-cta-phone {
  display: block;
  margin: 0 0 9px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(27, 36, 64, 0.06);
  border: 1px dashed rgba(169, 130, 76, 0.4);
  color: var(--khw-navy);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.khw-cta-phone:hover {
  background: rgba(199, 167, 107, 0.18);
  border-color: var(--khw-brass);
}
.khw-cta-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 6px;
}
.khw-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 33px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(169, 130, 76, 0.55);
  background: rgba(255, 255, 255, 0.72);
  color: var(--khw-navy);
  font-size: 10.5px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease,
    transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.khw-cta-btn svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}
.khw-cta-btn:hover {
  background: #fff;
  border-color: var(--khw-brass);
  transform: translateY(-1px);
  box-shadow: 0 8px 16px -12px rgba(27, 36, 64, 0.6);
}
.khw-cta-btn--primary {
  background: linear-gradient(160deg, var(--khw-navy-2), var(--khw-navy));
  border-color: var(--khw-navy);
  color: var(--khw-paper);
  box-shadow: 0 10px 18px -12px rgba(27, 36, 64, 0.75);
}
.khw-cta-btn--primary:hover {
  background: linear-gradient(160deg, #33406b, var(--khw-navy-2));
  color: #fff;
}

/* --------------------------------------------------------------------------
   چیپ‌های پاسخ سریع
   -------------------------------------------------------------------------- */
.khw-quick {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  padding-inline-end: 22px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-padding-inline: 12px;
  overscroll-behavior-x: contain;
  background: linear-gradient(180deg, rgba(250, 247, 240, 0), var(--khw-paper));
  border-top: 1px dashed rgba(169, 130, 76, 0.22);
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    rgba(0, 0, 0, 0.55) 10px,
    #000 24px,
    #000 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    rgba(0, 0, 0, 0.55) 10px,
    #000 24px,
    #000 100%
  );
}
.khw-quick::-webkit-scrollbar {
  display: none;
}
.khw-quick[hidden] {
  display: none;
}
.khw-chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(169, 130, 76, 0.45);
  background: rgba(255, 255, 255, 0.82);
  color: var(--khw-navy);
  font: inherit;
  font-size: 10.8px;
  line-height: 1.7;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    transform 0.2s var(--khw-ease), box-shadow 0.2s ease;
}
.khw-chip:hover {
  background: var(--khw-paper-alt);
  border-color: var(--khw-brass);
  transform: translateY(-1px);
  box-shadow: 0 8px 14px -12px rgba(27, 36, 64, 0.5);
}
.khw-chip:active {
  transform: scale(0.97);
}

/* --------------------------------------------------------------------------
   ناحیهٔ نوشتن پیام
   -------------------------------------------------------------------------- */
.khw-compose {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  background: rgba(250, 247, 240, 0.97);
  border-top: 1px solid var(--khw-line);
}
.khw-preview {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 9px 12px 0;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--khw-line);
  animation: khw-msg-in 0.24s var(--khw-ease) both;
}
.khw-preview[hidden] {
  display: none;
}
.khw-preview-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--khw-paper-alt);
}
.khw-preview-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.khw-preview-meta strong {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--khw-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.khw-preview-meta span {
  display: block;
  font-size: 9.5px;
  color: var(--khw-ink-soft);
}
.khw-preview-remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(140, 59, 46, 0.1);
  color: var(--khw-stamp);
  cursor: pointer;
  transition: background 0.2s ease;
}
.khw-preview-remove:hover {
  background: rgba(140, 59, 46, 0.2);
}
.khw-preview-remove svg {
  width: 10px;
  height: 10px;
}

.khw-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
}
.khw-attach {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--khw-line);
  border-radius: 12px;
  background: #fff;
  color: var(--khw-ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
    transform 0.2s ease;
}
.khw-attach:hover {
  color: var(--khw-brass);
  border-color: rgba(169, 130, 76, 0.55);
  background: #fffdf8;
}
.khw-attach:active {
  transform: scale(0.94);
}
.khw-attach svg {
  width: 17px;
  height: 17px;
}

.khw-field {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  padding: 1px 10px;
  border-radius: 14px;
  border: 1px solid var(--khw-line);
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.khw-field:focus-within {
  border-color: rgba(169, 130, 76, 0.7);
  box-shadow: 0 0 0 3px rgba(199, 167, 107, 0.16);
}
.khw-input {
  flex: 1 1 auto;
  width: 100%;
  min-height: 36px;
  max-height: 108px;
  padding: 7px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--khw-ink);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.75;
  overflow-y: auto;
  scrollbar-width: thin;
}
.khw-input::placeholder {
  color: var(--khw-ink-soft);
  opacity: 0.62;
  font-size: 12px;
}
.khw-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.khw-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(150deg, #36436e, var(--khw-navy) 58%, #7c5f36 130%);
  box-shadow: 0 12px 22px -12px rgba(27, 36, 64, 0.75),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: transform 0.22s var(--khw-ease), box-shadow 0.22s ease,
    filter 0.22s ease;
}
.khw-send:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 16px 26px -12px rgba(27, 36, 64, 0.8),
    0 0 0 3px rgba(199, 167, 107, 0.18);
}
.khw-send:active:not(:disabled) {
  transform: scale(0.95);
}
.khw-send:disabled {
  opacity: 0.42;
  cursor: default;
  filter: saturate(0.6);
}
.khw-send svg {
  width: 18px;
  height: 18px;
}
.khw-count {
  display: none;
  padding: 0 12px 7px;
  font-size: 9.5px;
  color: var(--khw-ink-soft);
  text-align: end;
  direction: rtl;
}
.khw-count.is-visible {
  display: block;
}
.khw-count.is-over {
  color: var(--khw-stamp);
  font-weight: 700;
}

/* فوتر برند */
.khw-foot {
  position: relative;
  inset: auto;
  isolation: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 7px 13px;
  border: 0;
  border-top: 1px dashed rgba(169, 130, 76, 0.26);
  border-radius: 0;
  background: var(--khw-paper);
  box-shadow: none;
  overflow: visible;
  font-size: 9.5px;
  color: var(--khw-ink-soft);
}
.khw-foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  color: var(--khw-navy);
}
.khw-foot-brand::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--khw-brass);
}
.khw-foot a {
  color: var(--khw-brass);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.khw-foot a:hover {
  color: var(--khw-navy);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.khw-foot::before,
.khw-foot::after {
  content: none;
  animation: none;
}

/* --------------------------------------------------------------------------
   لایت‌باکس تصویر
   -------------------------------------------------------------------------- */
.khw-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 17, 30, 0.88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0s linear 0.24s;
  pointer-events: auto;
}
.khw-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.24s ease;
}
.khw-lightbox img {
  max-width: min(92vw, 860px);
  max-height: 84vh;
  border-radius: 10px;
  border: 1px solid rgba(199, 167, 107, 0.5);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.8);
  background: #0b0f1a;
  animation: khw-zoom-in 0.3s var(--khw-ease) both;
}
.khw-lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(250, 247, 240, 0.4);
  border-radius: 50%;
  background: rgba(250, 247, 240, 0.12);
  color: var(--khw-paper);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.khw-lightbox-close:hover {
  background: rgba(199, 167, 107, 0.32);
  transform: scale(1.06);
}
.khw-lightbox-close svg {
  width: 14px;
  height: 14px;
}
.khw-lightbox-close:focus-visible {
  outline-color: var(--khw-brass-light);
}

/* --------------------------------------------------------------------------
   انیمیشن‌ها
   -------------------------------------------------------------------------- */
@keyframes khw-wave {
  0% {
    opacity: 0.75;
    transform: scale(0.92);
  }
  72% {
    opacity: 0;
    transform: scale(1.95);
  }
  100% {
    opacity: 0;
    transform: scale(1.95);
  }
}
@keyframes khw-breathe {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.96);
  }
  50% {
    opacity: 0.95;
    transform: scale(1.04);
  }
}
@keyframes khw-ping {
  0%,
  62%,
  100% {
    box-shadow: 0 2px 6px rgba(27, 36, 64, 0.35),
      0 0 0 0 rgba(63, 122, 92, 0.5);
  }
  78% {
    box-shadow: 0 2px 6px rgba(27, 36, 64, 0.35),
      0 0 0 6px rgba(63, 122, 92, 0);
  }
}
@keyframes khw-msg-in {
  from {
    opacity: 0;
    transform: translateY(9px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes khw-dot {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
@keyframes khw-live {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(63, 122, 92, 0.45);
  }
  70% {
    box-shadow: 0 0 0 5px rgba(63, 122, 92, 0);
  }
}
@keyframes khw-sheen {
  0%,
  55% {
    transform: translateX(-160%) rotate(12deg);
  }
  85%,
  100% {
    transform: translateX(210%) rotate(12deg);
  }
}
@keyframes khw-badge-pop {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes khw-progress {
  0% {
    inset-inline-start: -45%;
  }
  100% {
    inset-inline-start: 105%;
  }
}
@keyframes khw-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes khw-zoom-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   موبایل — شیت تمام‌صفحه
   -------------------------------------------------------------------------- */
@media (max-width: 560px) {
  .khw-launcher-wrap {
    right: 16px;
    left: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  .khw-launcher {
    width: 60px;
    height: 60px;
  }
  .khw-launcher-icon {
    width: 26px;
    height: 26px;
  }
  .khw-tip {
    width: min(248px, calc(100vw - 44px));
  }
  .khw-panel {
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    transform-origin: calc(100% - 46px) calc(100% - 46px);
    transform: translateY(16px) scale(0.985);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .khw.is-open .khw-panel {
    transform: none;
  }
  .khw-head {
    padding-top: calc(11px + env(safe-area-inset-top));
    padding-inline: 16px;
  }
  .khw-seal {
    width: 40px;
    height: 40px;
  }
  .khw-title {
    font-size: 13.5px;
  }
  .khw-body {
    padding: 16px 14px 12px;
    gap: 11px;
  }
  .khw-bubble {
    font-size: 14px;
    line-height: 1.9;
  }
  .khw-bubble-wrap {
    max-width: 90%;
  }
  .khw-avatar {
    width: 32px;
    height: 32px;
    margin-bottom: 20px;
  }
  .khw-avatar svg {
    width: 16px;
    height: 16px;
  }
  .khw-composer {
    /* ناحیهٔ امن پایین فقط یک‌بار در فوتر اعمال می‌شود */
    padding: 10px 12px;
    gap: 7px;
  }
  .khw-input {
    font-size: 16px;
    min-height: 40px;
    max-height: 132px;
    padding: 8px 0;
  }
  .khw-input::placeholder {
    font-size: 14px;
  }
  .khw-send {
    width: 44px;
    height: 44px;
  }
  .khw-attach {
    width: 42px;
    height: 42px;
  }
  .khw-field {
    padding-inline: 12px;
  }
  .khw-quick {
    padding: 8px 14px;
    padding-inline-end: 22px;
  }
  .khw-chip {
    font-size: 11.5px;
    padding: 7px 13px;
  }
  .khw-cta-actions {
    grid-template-columns: 1.4fr 1fr 1fr;
  }
  .khw-foot {
    padding-bottom: calc(7px + env(safe-area-inset-bottom));
  }
  .khw-lightbox {
    padding: 12px;
  }
  .khw-lightbox img {
    max-width: 94vw;
    max-height: 78vh;
  }
}

@media (max-width: 360px) {
  .khw-cta-actions {
    grid-template-columns: 1fr 1fr;
  }
  .khw-cta-btn--primary {
    grid-column: 1 / -1;
  }
  .khw-bubble {
    font-size: 13.5px;
  }
  .khw-head-txt .khw-title {
    font-size: 12.5px;
  }
}

/* صفحه‌های خیلی کوتاه (منظره موبایل) */
@media (max-height: 520px) and (min-width: 561px) {
  .khw-panel {
    height: calc(100vh - 20px);
    max-height: none;
    bottom: 10px;
    right: 10px;
    left: auto;
  }
}

/* --------------------------------------------------------------------------
   دسترس‌پذیری
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .khw *,
  .khw *::before,
  .khw *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .khw-launcher::before,
  .khw-wave {
    display: none;
  }
  .khw-tip {
    transform: none;
  }
}

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

@media print {
  .khw {
    display: none !important;
  }
}
