@font-face {
  font-family: "WI Estedad";
  src: url("../../public/font/estedad/woff2/Estedad-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "WI Estedad";
  src: url("../../public/font/estedad/woff2/Estedad-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "WI Estedad";
  src: url("../../public/font/estedad/woff2/Estedad-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

.cw {
  --side: #12203a;
  --side2: #1b2d4f;
  --side-mute: #9fb0d0;
  --panel: #fff;
  --ink: #16202e;
  --mute: #6b7788;
  --line: #e3e8ef;
  --me: #0e8f7e;
  --them: #fff;
  --them-ink: #16202e;
  --bg: #f4f6fa;
  --badge: #f6b73c;
  --online: #34d399;
  --r: 18px;
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 20px;
  z-index: 10000;
  font-family: "WI Estedad", Tahoma, sans-serif;
  color: var(--ink);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  .cw {
    --panel: #131b2a;
    --ink: #e8edf6;
    --mute: #8e9bb0;
    --line: #223049;
    --them: #1d283b;
    --them-ink: #e8edf6;
    --bg: #0f1624;
    --me: #0f9b88;
    color-scheme: dark;
  }
}
.cw * { box-sizing: border-box; margin: 0; }
.cw button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.cw [hidden] { display: none !important; }
.cw :focus-visible { outline: 2px solid var(--badge); outline-offset: 2px; }

.cw .launcher {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 22px 22px 22px 6px;
  background: var(--me);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 30px -10px rgba(14, 143, 126, 0.7);
  transition: transform 0.2s, border-radius 0.3s;
}
.cw .launcher:hover { transform: translateY(-2px); }
.cw .launcher svg { grid-area: 1 / 1; transition: opacity 0.2s, transform 0.3s; }
.cw .launcher .x { opacity: 0; transform: rotate(-90deg); }
.cw.open .launcher { border-radius: 22px; }
.cw.open .launcher .c { opacity: 0; transform: rotate(90deg); }
.cw.open .launcher .x { opacity: 1; transform: none; }
.cw .ubadge {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--badge);
  color: #2b1d00;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--panel);
}
.cw .tip {
  position: absolute;
  bottom: 76px;
  left: 0;
  width: max-content;
  max-width: 250px;
  padding: 12px 38px 12px 16px;
  background: var(--panel);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  line-height: 1.8;
  animation: wi-pop 0.35s ease-out;
}
.cw .tip button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--mute);
  font-size: 16px;
  line-height: 1;
}
.cw .tip button:hover { background: var(--bg); }

.cw .panel {
  position: absolute;
  bottom: 76px;
  left: 0;
  width: 380px;
  height: min(620px, calc(100vh - 110px));
  height: min(620px, calc(100dvh - 110px));
  display: none;
  flex-direction: column;
  background: var(--panel);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 70px -20px rgba(8, 16, 34, 0.55);
}
.cw.open .panel { display: flex; animation: wi-pop 0.25s ease-out; }
@keyframes wi-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.cw .head {
  background: var(--side);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cw .avatar {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--me);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
}
.cw .avatar::after {
  content: "";
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--online);
  border: 2.5px solid var(--side);
}
.cw .head-t { flex: 1; min-width: 0; }
.cw .head-t b {
  display: block;
  font-size: 15.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw .head-t small { font-size: 12.5px; color: var(--side-mute); }
.cw .ibtn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--side-mute);
  flex: none;
  transition: background 0.2s, color 0.2s;
}
.cw .ibtn:hover { background: var(--side2); color: #fff; }

.cw .body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.cw .start { padding: 26px 22px; overflow-y: auto; }
.cw .start h2 { font-size: 18px; margin-bottom: 6px; }
.cw .start p { font-size: 14px; color: var(--mute); line-height: 1.9; margin-bottom: 18px; }
.cw .start label { display: block; font-size: 13px; color: var(--mute); margin: 12px 0 5px; }
.cw .start input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
}
.cw .start input:focus { outline: 0; border-color: var(--me); }
.cw .start .go {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  border-radius: 14px;
  background: var(--me);
  color: #fff;
  font-weight: 500;
  font-size: 15px;
}
.cw .start .go:disabled { opacity: 0.55; cursor: default; }
.cw .err { display: block; margin-top: 12px; color: #e0475b; font-size: 13px; }
.cw .start input.bad { border-color: #e0475b; }

.cw .msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.cw .day {
  align-self: center;
  margin: 2px 0 10px;
  padding: 3px 12px;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--mute);
  font-size: 12px;
}
.cw .msg {
  max-width: 82%;
  padding: 8px 13px 6px;
  font-size: 14.5px;
  line-height: 1.85;
  border-radius: var(--r);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: wi-pop 0.2s ease-out;
}
.cw .msg.me {
  align-self: flex-start;
  background: var(--me);
  color: #fff;
  border-end-start-radius: 5px;
}
.cw .msg.them {
  align-self: flex-end;
  background: var(--them);
  color: var(--them-ink);
  border-end-end-radius: 5px;
  box-shadow: 0 1px 0 var(--line);
}
.cw .msg.system {
  align-self: center;
  max-width: 92%;
  background: transparent;
  color: var(--mute);
  box-shadow: none;
  font-size: 12.5px;
  text-align: center;
  padding: 4px 8px;
}
.cw .msg.first { margin-top: 8px; }
.cw .nm {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--me);
  line-height: 1.6;
  margin-bottom: 1px;
}
.cw .meta {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px;
  opacity: 0.75;
}
.cw .msg.system .meta { justify-content: center; }
.cw .tick {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cw .msg.read .tick { color: #bdf5ea; }

.cw .composer {
  position: relative;
  padding: 10px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.cw .composer .err { flex: 1 0 100%; margin-top: 0; }
.cw .field {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 3px 5px;
  transition: border-color 0.2s;
}
.cw .field:focus-within { border-color: var(--me); }
.cw .field textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  resize: none;
  outline: 0;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  padding: 8px 6px;
  line-height: 1.7;
  max-height: 110px;
}
.cw .field .ibtn { width: 34px; height: 34px; color: var(--mute); }
.cw .field .ibtn:hover { background: var(--line); color: var(--ink); }
.cw .send {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--me);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform 0.15s, opacity 0.2s;
}
.cw .send:hover { transform: scale(1.06); }
.cw .send:disabled { opacity: 0.4; transform: none; cursor: default; }
.cw .send svg { transform: scaleX(-1); }
.cw .emoji {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 12px;
  display: none;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.3);
  z-index: 2;
}
.cw .emoji.show { display: grid; animation: wi-pop 0.15s; }
.cw .emoji button { font-size: 21px; width: 36px; height: 36px; border-radius: 10px; }
.cw .emoji button:hover { background: var(--bg); }

.cw.page {
  position: relative;
  left: auto;
  bottom: auto;
  z-index: 0;
  min-height: 100%;
  min-height: 100dvh;
}
.cw.page .panel {
  display: flex;
  position: relative;
  bottom: auto;
  left: auto;
  width: min(480px, 100%);
  height: 100dvh;
  margin-inline: auto;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}

@media (max-width: 520px) {
  .cw:not(.page) { left: auto; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .cw:not(.page) .panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
  }
  .cw:not(.page).open .launcher { display: none; }
  .cw:not(.page) .head { padding-top: max(16px, env(safe-area-inset-top)); }
  .cw:not(.page) .composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .cw:not(.page) .tip { max-width: 210px; }
}
@media (prefers-reduced-motion: reduce) {
  .cw * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* dimaco2 — راست صفحه، رنگ و شعاع از تم فعال */
.cw.d2 {
  left: auto;
  right: max(20px, env(safe-area-inset-right));
  z-index: 60;
  font-family: Estedad, Tahoma, sans-serif;
  font-weight: 500;
  color: var(--color-base-content);
  color-scheme: light;
  --side: var(--color-neutral);
  --side2: color-mix(in srgb, var(--color-neutral) 82%, var(--color-primary));
  --side-mute: color-mix(in srgb, var(--color-neutral-content) 68%, transparent);
  --panel: var(--color-base-100);
  --ink: var(--color-base-content);
  --mute: color-mix(in srgb, var(--color-base-content) 58%, transparent);
  --line: var(--color-base-300);
  --me: var(--color-primary);
  --them: var(--color-base-100);
  --them-ink: var(--color-base-content);
  --bg: var(--color-base-200);
  --badge: var(--color-accent);
  --online: var(--color-success);
  --r: 20px;
}
[data-theme="dimaco2-dark"] .cw.d2 { color-scheme: dark; }
.cw.d2 :focus-visible { outline-color: var(--color-primary); }
.cw.d2 .launcher {
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-primary-content);
  box-shadow: 0 14px 28px -10px color-mix(in srgb, var(--color-primary) 72%, transparent);
}
.cw.d2.open .launcher { border-radius: 999px; }
.cw.d2 .launcher .mark {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  font-family: Inter, "Helvetica Neue", "Arial Black", Arial, sans-serif;
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
  direction: ltr;
  user-select: none;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.cw.d2 .launcher .mark-face,
.cw.d2 .launcher .mark-ghost {
  grid-area: 1 / 1;
}
.cw.d2 .launcher .mark-face {
  animation: wi-d-live 4.2s ease-in-out infinite;
}
.cw.d2 .launcher .mark-ghost {
  color: transparent;
  -webkit-text-stroke: 1.5px currentColor;
  opacity: 0;
  animation: wi-d-ghost 4.2s ease-out infinite;
}
.cw.d2.open .launcher .mark {
  opacity: 0;
  transform: rotate(90deg) scale(0.72);
}
.cw.d2.open .launcher .mark-face,
.cw.d2.open .launcher .mark-ghost {
  animation: none;
}
@keyframes wi-d-live {
  0%, 58%, 100% { transform: translateY(0) scale(1); }
  28% { transform: translateY(-1.5px) scale(1.06); }
}
@keyframes wi-d-ghost {
  0%, 16% { transform: scale(1); opacity: 0; }
  26% { transform: scale(1); opacity: 0.5; }
  58%, 100% { transform: scale(1.28); opacity: 0; }
}
.cw.d2 .tip {
  left: auto;
  right: 0;
  max-width: min(250px, calc(100vw - max(20px, env(safe-area-inset-right, 0px)) - max(16px, env(safe-area-inset-left, 0px))));
  max-width: min(250px, calc(100dvw - max(20px, env(safe-area-inset-right, 0px)) - max(16px, env(safe-area-inset-left, 0px))));
  border-radius: 22px 22px 6px 22px;
  overflow-wrap: anywhere;
}
.cw.d2 .ubadge {
  background: var(--color-accent);
  color: var(--color-accent-content);
  border-color: var(--color-base-100);
}
.cw.d2 .head { color: var(--color-neutral-content); }
.cw.d2 .avatar {
  background: var(--color-primary);
  color: var(--color-primary-content);
}
.cw.d2 .msg.me { color: var(--color-primary-content); }
.cw.d2 .msg.read .tick { color: var(--color-primary-content); }
.cw.d2 .nm { color: var(--color-primary); }
.cw.d2 .start .go,
.cw.d2 .send {
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-primary-content);
  font-weight: 800;
}
.cw.d2 .start input {
  border-radius: 14px;
  font-weight: 500;
  background: var(--color-base-100);
}
.cw.d2 .start h2 { font-weight: 800; }
.cw.d2 .field { border-radius: 999px; }
.cw.d2 .field textarea { font-weight: 500; }
@media (min-width: 521px) {
  .cw.d2 .panel { left: auto; right: 0; }
  .cw.d2 .panel {
    border-radius: 22px;
    border: 1px solid var(--line);
    box-shadow: 0 24px 60px color-mix(in srgb, #001018 22%, transparent);
  }
}
@media (prefers-reduced-motion: reduce) {
  .cw.d2 .launcher .mark-ghost { opacity: 0; }
}
