/* ==========================================================================
   宇勤在线客服（挂件）
   ========================================================================== */

.yq-chat {
  --yq-radius: 3px;
  position: relative;
  z-index: 118;
}

/* ---------- Launcher ---------- */
.yq-chat__launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 118;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 20px 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 16px 36px rgba(6, 23, 38, 0.28);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease),
    background 0.3s var(--ease);
}

.yq-chat.is-ready .yq-chat__launcher {
  opacity: 1;
  transform: none;
}

.yq-chat__launcher:hover {
  background: var(--blue);
}

.yq-chat__launcher svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.yq-chat__launcher span {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.yq-chat__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ad08a;
  box-shadow: 0 0 0 3px rgba(74, 208, 138, 0.18);
  flex: none;
}

.yq-chat.is-open .yq-chat__launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

/* ---------- Panel ---------- */
.yq-chat__panel {
  position: fixed;
  right: 22px;
  bottom: 86px;
  z-index: 130;
  display: flex;
  flex-direction: column;
  width: 384px;
  height: min(640px, calc(100vh - 120px));
  height: min(640px, calc(100dvh - 120px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--yq-radius);
  box-shadow: 0 28px 70px rgba(6, 23, 38, 0.24);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease),
    visibility 0.32s;
}

.yq-chat.is-open .yq-chat__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

/* ---------- Header ---------- */
.yq-chat__head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background:
    radial-gradient(220px 120px at 85% 0%, rgba(0, 112, 184, 0.55), transparent 70%),
    linear-gradient(135deg, #061726, #0a2b42);
  color: #fff;
}

.yq-chat__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.yq-chat__brand img {
  width: 34px;
  height: auto;
  flex: none;
}

.yq-chat__brand strong {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.yq-chat__brand small {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
}

.yq-chat__brand small::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4ad08a;
}

.yq-chat__close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.yq-chat__voice {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 5px 9px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
    border-color 0.25s var(--ease);
}

.yq-chat__voice:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.yq-chat__voice.is-on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.yq-chat__voice svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.yq-chat__voice .yq-voice-on {
  display: none;
}

.yq-chat__voice.is-on .yq-voice-on {
  display: block;
}

.yq-chat__voice.is-on .yq-voice-off {
  display: none;
}

.yq-chat__human {
  flex: none;
  padding: 5px 9px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.yq-chat__human:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.yq-chat__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.yq-chat__close svg {
  width: 16px;
  height: 16px;
}

/* ---------- Log ---------- */
.yq-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: var(--paper);
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.yq-chat__log::-webkit-scrollbar {
  width: 5px;
}

.yq-chat__log::-webkit-scrollbar-thumb {
  background: rgba(10, 28, 43, 0.18);
  border-radius: 4px;
}

.yq-msg {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 14px;
  animation: yq-in 0.3s var(--ease);
}

@keyframes yq-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.yq-msg--user {
  justify-content: flex-end;
}

.yq-msg__avatar {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.yq-msg__bubble {
  max-width: 82%;
  padding: 11px 13px;
  font-size: 13.5px;
  line-height: 1.78;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 3px 12px 12px 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.yq-msg--user .yq-msg__bubble {
  border: 0;
  border-radius: 12px 3px 12px 12px;
  background: var(--blue);
  color: #fff;
}

.yq-msg--typing .yq-msg__bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.yq-typing {
  display: inline-flex;
  gap: 4px;
}

.yq-typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted-light);
  animation: yq-blink 1.2s infinite both;
}

.yq-typing i:nth-child(2) { animation-delay: 0.15s; }
.yq-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes yq-blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Speak ---------- */
.yq-speak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: -6px 0 8px 34px;
  padding: 4px;
  min-height: 24px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 1;
  transition: color 0.25s var(--ease), opacity 0.25s var(--ease);
}

.yq-speak:hover {
  color: var(--blue);
  opacity: 1;
}

.yq-speak.is-speaking {
  color: var(--blue);
  opacity: 1;
}

.yq-speak svg {
  width: 12px;
  height: 12px;
}

/* ---------- Suggestions ---------- */
.yq-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 14px 37px;
}

.yq-chip {
  padding: 6px 11px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--blue);
  background: #fff;
  border: 1px solid rgba(0, 112, 184, 0.28);
  border-radius: 999px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
  text-align: left;
}

.yq-chip:hover {
  background: var(--blue);
  color: #fff;
}

/* ---------- Handoff ---------- */
.yq-handoff {
  margin: 2px 0 14px 37px;
  padding: 13px 14px;
  background: var(--blue-pale);
  border-left: 2px solid var(--blue);
}

.yq-handoff strong {
  display: block;
  font-size: 13px;
  color: #0a3550;
}

.yq-handoff p {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.7;
  color: #35617d;
}

.yq-handoff__phone {
  display: inline-block;
  margin-top: 8px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.yq-handoff__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.yq-handoff__actions button,
.yq-handoff__actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 2px;
}

.yq-handoff__actions a {
  background: var(--blue);
  color: #fff;
}

.yq-handoff__actions button {
  background: #fff;
  color: var(--blue);
  border: 1px solid rgba(0, 112, 184, 0.35);
}

/* ---------- Callback form ---------- */
.yq-callback {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.yq-callback input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  font-size: 12.5px;
  background: #fff;
  border: 1px solid rgba(10, 28, 43, 0.16);
  border-radius: 2px;
}

.yq-callback input:focus {
  outline: none;
  border-color: var(--blue);
}

.yq-callback button {
  height: 38px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  border-radius: 2px;
}

.yq-callback button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.yq-callback__note {
  font-size: 10px;
  line-height: 1.6;
  color: #5b7a8e;
}

.yq-callback__error {
  font-size: 10.5px;
  color: var(--danger);
}

.yq-callback__ok {
  font-size: 12px;
  line-height: 1.7;
  color: var(--ok);
}

/* ---------- Quick bar ---------- */
.yq-chat__quick {
  flex: none;
  display: flex;
  gap: 7px;
  padding: 9px 12px;
  overflow-x: auto;
  background: #fff;
  border-top: 1px solid var(--line);
  scrollbar-width: none;
}

.yq-chat__quick::-webkit-scrollbar {
  display: none;
}

.yq-chat__quick .yq-chip {
  flex: none;
  white-space: nowrap;
}

.yq-chat__quick.is-hidden {
  display: none;
}

/* ---------- Persistent callback ---------- */
.yq-chat__callback {
  flex: none;
  min-height: 32px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--blue);
  background: #fff;
  border-top: 1px solid var(--line);
  transition: background 0.25s var(--ease);
}

.yq-chat__callback:hover {
  background: var(--blue-pale);
}

.yq-chat__callback:disabled {
  color: var(--muted);
  cursor: default;
  background: #fff;
}

/* ---------- Form ---------- */
.yq-chat__form {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.yq-chat__mic {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(10, 28, 43, 0.16);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease),
    background 0.25s var(--ease);
}

.yq-chat__mic svg {
  width: 16px;
  height: 16px;
}

.yq-chat__mic:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.yq-chat__mic.is-listening {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  animation: yq-mic 1.4s ease-out infinite;
}

@keyframes yq-mic {
  0% { box-shadow: 0 0 0 0 rgba(178, 58, 46, 0.35); }
  70% { box-shadow: 0 0 0 7px rgba(178, 58, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(178, 58, 46, 0); }
}

.yq-chat__form input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  font-size: 13px;
  background: var(--paper);
  border: 1px solid rgba(10, 28, 43, 0.14);
  border-radius: 999px;
}

.yq-chat__form input:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}

.yq-chat__form button[type="submit"] {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}

.yq-chat__form button[type="submit"]:hover {
  background: #0084d6;
  transform: translateY(-1px);
}

.yq-chat__form button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

.yq-chat__form svg {
  width: 17px;
  height: 17px;
}

.yq-chat__note {
  flex: none;
  padding: 0 12px 10px;
  font-size: 9.5px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted-light);
  background: #fff;
}

/* ---------- Mobile ---------- */
@media (max-width: 1024px) {
  .yq-chat__launcher {
    bottom: 70px;
  }
}

@media (max-width: 640px) {
  .yq-chat__launcher {
    right: 14px;
    bottom: 70px;
    height: 46px;
    padding: 0 14px 0 12px;
    gap: 8px;
  }

  .yq-chat__launcher span {
    font-size: 12.5px;
  }

  .yq-chat__launcher svg {
    width: 18px;
    height: 18px;
  }

  .yq-chat__panel {
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    transform: translateY(18px);
  }

  .yq-chat__head {
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
    padding-bottom: 14px;
  }

  .yq-chat__voice span {
    display: none;
  }

  .yq-chat__voice {
    padding: 7px;
    width: 32px;
    height: 32px;
    justify-content: center;
  }

  .yq-chat__log {
    padding: 16px 14px 8px;
  }

  .yq-chat__quick {
    flex-wrap: wrap;
    overflow: visible;
    padding: 10px 12px;
  }

  .yq-chat__quick .yq-chip {
    flex: 0 1 auto;
    white-space: normal;
  }

  .yq-chat__form {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }

  .yq-chat__note {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }

  body.yq-chat-open {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .yq-chat__launcher,
  .yq-chat__panel,
  .yq-msg {
    animation: none;
    transition-duration: 0.001ms;
  }
}
