/* ==========================================================================
   WePoker support widget
   Floating assistant: 3s teaser, 6s auto-open, preset answers, official
   support handoff. Kept self-contained so page layouts are unaffected.
   ========================================================================== */

.wpk-support {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--wpk-support-bottom, 20px) + env(safe-area-inset-bottom, 0px));
  z-index: 99;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", Arial, sans-serif;
  pointer-events: none;
}

.wpk-support > * {
  pointer-events: auto;
}

.wpk-support [hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Launcher
   -------------------------------------------------------------------------- */
.wpk-support-launcher {
  position: relative;
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--wpk-mint, #84f9cc);
  color: #08231b;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .2), 0 2px 8px rgba(0, 0, 0, .12);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.wpk-support-launcher:hover {
  background: var(--wpk-mint-hover, #6de8b8);
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, .24), 0 3px 10px rgba(0, 0, 0, .12);
}

.wpk-support-launcher:active {
  background: var(--wpk-mint-active, #5dd8a8);
  transform: translateY(0);
}

.wpk-support-launcher svg {
  display: block;
  width: 30px;
  height: 30px;
  pointer-events: none;
}

.wpk-support-launcher::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(132, 249, 204, .5);
  border-radius: inherit;
  pointer-events: none;
  animation: wpk-support-ring 2.4s ease-out 2;
}

.wpk-support-launcher.is-open::after {
  display: none;
}

.wpk-support-launcher-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #ff6b67;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

/* --------------------------------------------------------------------------
   Teaser bubble
   -------------------------------------------------------------------------- */
.wpk-support-teaser {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--wpk-support-bottom, 20px) + 76px + env(safe-area-inset-bottom, 0px));
  width: min(300px, calc(100vw - 32px));
  border: 1px solid rgba(13, 58, 43, .08);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .06);
  animation: wpk-support-teaser-in .28s cubic-bezier(.2, .8, .2, 1) both;
}

.wpk-support-teaser-main {
  display: block;
  width: 100%;
  padding: 15px 38px 15px 16px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--wpk-ink, #1e1e1e);
  text-align: left;
  cursor: pointer;
}

.wpk-support-teaser-main strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.wpk-support-teaser-main span {
  display: block;
  color: #6d7773;
  font-size: 12px;
  line-height: 1.5;
}

.wpk-support-teaser-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #8c9691;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.wpk-support-teaser-close:hover {
  background: #f1f5f3;
  color: #1e1e1e;
}

/* --------------------------------------------------------------------------
   Panel
   -------------------------------------------------------------------------- */
.wpk-support-panel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--wpk-support-bottom, 20px) + 76px + env(safe-area-inset-bottom, 0px));
  width: 374px;
  height: min(480px, calc(100dvh - var(--wpk-support-bottom, 20px) - 96px - env(safe-area-inset-bottom, 0px)));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(13, 58, 43, .08);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22), 0 4px 16px rgba(0, 0, 0, .08);
  overflow: hidden;
  transform-origin: bottom right;
  animation: wpk-support-panel-in .24s cubic-bezier(.2, .8, .2, 1) both;
}

.wpk-support-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 16px 18px;
  background:
    radial-gradient(circle at 88% -20%, rgba(132, 249, 204, .24), transparent 48%),
    linear-gradient(135deg, #061b13 0%, #0b2b20 58%, #103b2c 100%);
  color: #fff;
  flex: 0 0 auto;
}

.wpk-support-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 0;
}

.wpk-support-head-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  border-radius: 50%;
  background: rgba(132, 249, 204, .14);
  color: var(--wpk-mint, #84f9cc);
}

.wpk-support-head-icon svg {
  display: block;
  width: 22px;
  height: 22px;
}

.wpk-support-head h2 {
  margin: 1px 0 4px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: .01em;
}

.wpk-support-head p {
  margin: 0;
  color: rgba(255, 255, 255, .65);
  font-size: 11px;
  line-height: 1.4;
}

.wpk-support-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .9);
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease;
}

.wpk-support-close:hover {
  background: rgba(255, 255, 255, .18);
}

.wpk-support-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 17px 15px 14px;
  background: linear-gradient(180deg, #f7faf8 0%, #fbfcfb 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 60, 48, .2) transparent;
}

.wpk-support-body::-webkit-scrollbar {
  width: 5px;
}

.wpk-support-body::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(30, 60, 48, .18);
}

.wpk-support-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wpk-support-msg {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  max-width: 100%;
  animation: wpk-support-msg-in .22s ease-out both;
}

.wpk-support-msg.is-user {
  justify-content: flex-end;
}

.wpk-support-avatar {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
  border-radius: 50%;
  background: #0b2b20;
  color: var(--wpk-mint, #84f9cc);
}

.wpk-support-avatar svg {
  width: 14px;
  height: 14px;
  display: block;
}

.wpk-support-bubble {
  max-width: calc(100% - 34px);
  padding: 10px 12px;
  border: 1px solid #e5ece8;
  border-radius: 5px 15px 15px 15px;
  background: #fff;
  color: var(--wpk-ink, #1e1e1e);
  font-size: 13px;
  line-height: 1.58;
  overflow-wrap: anywhere;
  white-space: pre-line;
  box-shadow: 0 2px 10px rgba(13, 58, 43, .035);
}

.wpk-support-msg.is-user .wpk-support-bubble {
  border-color: #9aebcb;
  border-radius: 15px 5px 15px 15px;
  background: var(--wpk-mint, #84f9cc);
  color: #09271d;
  box-shadow: none;
}

.wpk-support-bubble a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 8px;
  color: #087a59;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.wpk-support-bubble a::after {
  content: "↗";
  font-size: 11px;
  line-height: 1;
}

.wpk-support-msg.is-system {
  display: block;
  max-width: 100%;
  margin: 2px 0;
  color: #8a9691;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Quick questions
   -------------------------------------------------------------------------- */
.wpk-support-quick {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 11px 0 2px 31px;
}

.wpk-support-quick-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 9px 11px 9px 13px;
  border: 1px solid rgba(13, 58, 43, .1);
  border-radius: 11px;
  background: #fff;
  color: #23302b;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  opacity: 0;
  transform: translateY(5px);
  transition: border-color .18s ease, background .18s ease, opacity .22s ease, transform .22s ease;
}

.wpk-support-quick-btn.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.wpk-support-quick-btn:hover {
  border-color: rgba(9, 122, 89, .3);
  background: #f2fbf7;
}

.wpk-support-quick-btn:disabled {
  border-color: #eef2f0;
  background: #fafcfb;
  color: #a9b2ae;
  cursor: default;
}

.wpk-support-quick-btn svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: #0b8f69;
}

.wpk-support-quick-btn:disabled svg {
  color: #c2cbc7;
}

/* --------------------------------------------------------------------------
   Human handoff
   -------------------------------------------------------------------------- */
.wpk-support-handoff {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 15px 0 2px 31px;
  padding: 11px 12px;
  border: 1px solid #dfeae5;
  border-radius: 13px;
  background: #fff;
}

.wpk-support-handoff-copy {
  min-width: 0;
}

.wpk-support-handoff-copy strong {
  display: block;
  margin-bottom: 2px;
  color: #1e2b25;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.wpk-support-handoff-copy span {
  display: block;
  color: #8b9691;
  font-size: 10px;
  line-height: 1.45;
}

.wpk-support-handoff-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 99px;
  background: #0b2b20;
  color: var(--wpk-mint, #84f9cc);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background .18s ease;
}

.wpk-support-handoff-btn:hover {
  background: #123c2b;
}

/* --------------------------------------------------------------------------
   Live message input
   -------------------------------------------------------------------------- */
.wpk-support-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 12px;
  border-top: 1px solid #edf3f0;
  background: #fff;
}

.wpk-support-form[hidden] {
  display: none !important;
}

.wpk-support-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  padding: 0 13px;
  border: 1px solid #dce7e2;
  border-radius: 13px;
  background: #f6faf8;
  color: var(--wpk-ink, #1e1e1e);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  outline: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.wpk-support-input::placeholder {
  color: #9aa5a0;
}

.wpk-support-input:focus {
  border-color: #82d8bb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(132, 249, 204, .18);
}

.wpk-support-input:disabled {
  opacity: .68;
}

.wpk-support-send {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #0b2b20;
  color: var(--wpk-mint, #84f9cc);
  cursor: pointer;
  transition: background .18s ease, opacity .18s ease, transform .18s ease;
}

.wpk-support-send svg {
  display: block;
  width: 19px;
  height: 19px;
}

.wpk-support-send:hover {
  background: #143d2d;
  transform: translateY(-1px);
}

.wpk-support-send:active {
  transform: translateY(0);
}

.wpk-support-send:disabled {
  opacity: .5;
  cursor: default;
  transform: none;
}

.wpk-support-form.is-sending .wpk-support-send svg {
  animation: wpk-support-send-pulse 1s ease-in-out infinite;
}

@keyframes wpk-support-send-pulse {
  0%, 100% { opacity: .5; transform: scale(.94); }
  50%      { opacity: 1; transform: scale(1); }
}

/* --------------------------------------------------------------------------
   Footer / fallback
   -------------------------------------------------------------------------- */
.wpk-support-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  padding: 8px 16px 10px;
  border-top: 1px solid #eef3f0;
  background: #fff;
  color: #96a09b;
  font-size: 10px;
  line-height: 1.4;
}

.wpk-support-fallback {
  color: #0b8161;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */
@keyframes wpk-support-panel-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes wpk-support-teaser-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes wpk-support-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes wpk-support-ring {
  0%   { transform: scale(.92); opacity: .8; }
  60%  { transform: scale(1.08); opacity: .15; }
  100% { transform: scale(1.12); opacity: 0; }
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */
@media screen and (max-width: 767px) {
  .wpk-support {
    right: max(12px, env(safe-area-inset-right));
    gap: 10px;
  }

  .wpk-support-launcher {
    width: 56px;
    height: 56px;
  }

  .wpk-support-launcher svg {
    width: 27px;
    height: 27px;
  }

  .wpk-support-launcher-badge {
    top: 0;
    right: 0;
  }

  .wpk-support-teaser {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--wpk-support-bottom, 12px) + 66px + env(safe-area-inset-bottom, 0px));
    width: min(290px, calc(100vw - 88px));
    border-radius: 16px;
  }

  .wpk-support-teaser-main {
    padding: 13px 36px 13px 14px;
  }

  .wpk-support-teaser-main strong {
    font-size: 13px;
  }

  .wpk-support-teaser-main span {
    font-size: 11px;
  }

  .wpk-support-panel {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--wpk-support-bottom, 12px) + 66px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
    max-width: 374px;
    height: min(470px, calc(100dvh - var(--wpk-support-bottom, 16px) - 84px - env(safe-area-inset-bottom, 0px)));
    border-radius: 21px;
  }

  .wpk-support-header {
    padding: 15px 13px 13px 15px;
  }

  .wpk-support-head-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .wpk-support-head h2 {
    font-size: 15px;
  }

  .wpk-support-head p {
    font-size: 10px;
  }

  .wpk-support-body {
    padding: 14px 12px 12px;
  }

  .wpk-support-input {
    height: 44px;
    font-size: 16px;
  }

  .wpk-support-send {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .wpk-support-form {
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom, 0px));
  }

  .wpk-support-bubble {
    font-size: 12.5px;
  }

  .wpk-support-quick,
  .wpk-support-handoff {
    margin-left: 31px;
  }

  .wpk-support-quick-btn {
    font-size: 11.5px;
  }

  .wpk-support-handoff {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .wpk-support-handoff-btn {
    width: 100%;
  }
}

.wpk-support-panel[hidden],
.wpk-support-teaser[hidden] {
  display: flex !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.wpk-support-teaser[hidden] {
  display: block !important;
}

.wpk-support-quick-btn[hidden] {
  display: flex !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .wpk-support-launcher,
  .wpk-support-panel,
  .wpk-support-teaser,
  .wpk-support-quick-btn,
  .wpk-support-msg {
    animation: none !important;
    transition: none !important;
  }

  .wpk-support-launcher::after {
    display: none;
  }
}
