:root {
  --ifw-green: #25d366;
  --ifw-green-dark: #128c7e;
  --ifw-green-soft: #dcf8c6;
  --ifw-ink: #10352f;
  --ifw-text: #1f2c34;
  --ifw-muted: #6f7c84;
  --ifw-surface: #ffffff;
  --ifw-shadow: 0 18px 50px rgba(16, 53, 47, 0.18);
  --ifw-shadow-soft: 0 10px 26px rgba(18, 140, 126, 0.18);
}

.ifw-widget {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  font-family: "Helvetica Neue", "Segoe UI", Arial, sans-serif;
}

.ifw-widget[data-position="right"] { right: 24px; }
.ifw-widget[data-position="left"] { left: 24px; }

.ifw-widget *,
.ifw-widget *::before,
.ifw-widget *::after { box-sizing: border-box; }

.ifw-widget__launcher {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(180deg, #2fe56f, #1ebf5c);
  box-shadow: 0 18px 44px rgba(37, 211, 102, 0.34);
  transition: transform 0.24s ease, box-shadow 0.24s ease, filter 0.24s ease;
  animation: ifw-launcher-pulse 3.2s ease-in-out infinite;
  overflow: hidden;
}

.ifw-widget__launcher::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: inherit;
  background: rgba(37, 211, 102, 0.2);
  z-index: -1;
  animation: ifw-launcher-halo 3.2s ease-in-out infinite;
}

.ifw-widget__launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 22px 50px rgba(37, 211, 102, 0.42);
  filter: saturate(1.05);
}

.ifw-widget__launcher svg {
  width: 34px;
  height: 34px;
  display: block;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.ifw-widget__launcher.is-gif > svg {
  opacity: 0;
  transform: scale(0.82);
}

.ifw-widget__launcher-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.ifw-widget__launcher.is-gif .ifw-widget__launcher-image {
  opacity: 1;
  transform: scale(1);
}

.ifw-widget__popup {
  position: absolute;
  bottom: 90px;
  width: min(330px, calc(100vw - 24px));
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.26s ease, transform 0.28s ease;
}

.ifw-widget[data-position="right"] .ifw-widget__popup { right: 0; }

.ifw-widget[data-position="left"] .ifw-widget__popup {
  left: 0;
  transform-origin: bottom left;
}

.ifw-widget.is-open .ifw-widget__popup {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ifw-widget__hover-tip {
  position: absolute;
  right: 88px;
  bottom: 16px;
  max-width: 220px;
  padding: 10px 14px;
  border-radius: 10px 10px 2px 10px;
  background: var(--ifw-green-soft);
  color: #223339;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 10px 22px rgba(16, 53, 47, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px) translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
  pointer-events: none;
  white-space: nowrap;
}

.ifw-widget__hover-tip::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 10px;
  width: 14px;
  height: 18px;
  background: var(--ifw-green-soft);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  filter: drop-shadow(2px 2px 2px rgba(16, 53, 47, 0.05));
}

.ifw-widget:hover .ifw-widget__hover-tip,
.ifw-widget:focus-within .ifw-widget__hover-tip {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) translateY(0);
}

.ifw-widget.is-open .ifw-widget__hover-tip {
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px) translateY(6px);
}

.ifw-widget[data-position="left"] .ifw-widget__hover-tip {
  left: 88px;
  right: auto;
  border-radius: 10px 10px 10px 2px;
  transform: translateX(-10px) translateY(6px);
}

.ifw-widget[data-position="left"] .ifw-widget__hover-tip::after {
  left: -6px;
  right: auto;
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
  filter: drop-shadow(-2px 2px 2px rgba(16, 53, 47, 0.05));
}

.ifw-widget[data-position="left"]:hover .ifw-widget__hover-tip,
.ifw-widget[data-position="left"]:focus-within .ifw-widget__hover-tip {
  transform: translateX(0) translateY(0);
}

.ifw-widget[data-position="left"].is-open .ifw-widget__hover-tip {
  transform: translateX(-10px) translateY(6px);
}

.ifw-card {
  overflow: hidden;
  border-radius: 20px;
  background: var(--ifw-surface);
  box-shadow: var(--ifw-shadow);
  color: var(--ifw-text);
}

.ifw-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 15px 13px;
  background: linear-gradient(180deg, #11786e, #106f65);
  color: #ffffff;
}

.ifw-card__identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ifw-card__avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

.ifw-card__avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #f6f2e8, #d8c8a6);
  color: #35504b;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.32);
}

.ifw-card__status {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ifw-green);
  border: 2px solid #11786e;
}

.ifw-card__meta { min-width: 0; }

.ifw-card__name {
  margin: 0;
  font-size: 1.38rem;
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ifw-card__reply {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ifw-card__close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ifw-card__close:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: rotate(90deg);
}

.ifw-card__body {
  padding: 15px;
  background:
    radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.42), transparent 14%),
    linear-gradient(180deg, rgba(239, 234, 226, 0.96), rgba(239, 234, 226, 0.96));
}

.ifw-card__bubble {
  width: fit-content;
  max-width: min(84%, 250px);
  background: #ffffff;
  border-radius: 16px 16px 16px 5px;
  padding: 10px 12px 8px;
  box-shadow: 0 10px 22px rgba(31, 44, 52, 0.08);
  animation: ifw-bubble-float 0.42s ease;
}

.ifw-card__bubble-label {
  display: block;
  margin-bottom: 6px;
  color: #7b6f67;
  font-size: 0.72rem;
}

.ifw-card__bubble-text {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.45;
  color: #202c33;
  font-weight: 700;
}

.ifw-card__bubble-time {
  display: block;
  margin-top: 5px;
  text-align: right;
  color: #97a0a5;
  font-size: 0.68rem;
}

.ifw-card__footer {
  padding: 14px 15px 15px;
  background: #ffffff;
}

.ifw-quick-replies {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 12px;
}

.ifw-quick-reply {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 0;
  padding: 8px 8px;
  border-radius: 999px;
  border: 1px solid rgba(18, 140, 126, 0.18);
  background: #f6fffb;
  color: var(--ifw-green-dark);
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
  box-shadow: 0 6px 16px rgba(16, 53, 47, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.ifw-quick-reply:hover {
  transform: translateY(-1px);
  background: #ecfff7;
  box-shadow: 0 10px 18px rgba(16, 53, 47, 0.1);
}

.ifw-cta { position: relative; }

.ifw-cta__button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #26d96b, #1db954);
  color: #ffffff;
  text-decoration: none;
  font-size: 1.22rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  box-shadow: var(--ifw-shadow-soft);
  transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

.ifw-cta__button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(37, 211, 102, 0.26);
  filter: saturate(1.05);
}

.ifw-cta__button svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.ifw-cta__qr {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 14px);
  width: 176px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(16, 53, 47, 0.18);
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
  text-align: center;
}

.ifw-cta:hover .ifw-cta__qr,
.ifw-cta:focus-within .ifw-cta__qr {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.ifw-cta__qr-image {
  width: 100%;
  display: block;
  border-radius: 13px;
  background: #ffffff;
  image-rendering: pixelated;
}

.ifw-cta__qr-visual {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(16, 53, 47, 0.06);
}

.ifw-cta__qr-logo-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 11px;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(16, 53, 47, 0.14);
  padding: 6px;
}

.ifw-cta__qr-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 6px;
}

.ifw-cta__qr-title {
  margin: 0 0 10px;
  font-size: 0.76rem;
  color: var(--ifw-muted);
  line-height: 1.4;
}

.ifw-cta__hint {
  display: none !important;
}

.ifw-card__powered {
  margin-top: 12px;
  text-align: center;
  font-size: 0.76rem;
  color: #7a868c;
  font-style: italic;
}

.ifw-card__powered a {
  color: var(--ifw-green-dark);
  text-decoration: none;
  font-weight: 600;
}

.ifw-card__powered a:hover { text-decoration: underline; }

@keyframes ifw-launcher-pulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.03); }
}

@keyframes ifw-launcher-halo {
  0%, 100% { transform: scale(0.95); opacity: 0.6; }
  50% { transform: scale(1.08); opacity: 0.2; }
}

@keyframes ifw-bubble-float {
  0% { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@media (max-width: 640px) {
  .ifw-widget[data-position="right"] { right: 12px; }
  .ifw-widget[data-position="left"] { left: 12px; }
  .ifw-widget__popup {
    width: min(330px, calc(100vw - 24px));
    bottom: 86px;
  }
  .ifw-widget__hover-tip {
    right: 78px;
    bottom: 14px;
    max-width: 170px;
    padding: 10px 14px;
    font-size: 0.84rem;
  }
  .ifw-widget[data-position="left"] .ifw-widget__hover-tip { left: 78px; }
  .ifw-card__name { font-size: 1.35rem; }
  .ifw-cta__button { font-size: 1.12rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ifw-widget *,
  .ifw-widget *::before,
  .ifw-widget *::after {
    animation: none !important;
    transition: none !important;
  }
}
