#kefuRoot,
#kefuRoot * {
  box-sizing: border-box;
}

#kefuRoot {
  position: relative;
  z-index: 9997;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

#kefuBubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#kefuBubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(108, 92, 231, 0.5);
}

#kefuBubble svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#kefuPanel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 400px;
  height: 620px;
  min-width: 320px;
  min-height: 420px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(20, 20, 43, 0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  resize: both;
}

#kefuPanel.kefu-open {
  display: flex;
}

.kefu-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
}

.kefu-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.kefu-status {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.82;
}

.kefu-actions {
  display: flex;
  gap: 4px;
}

.kefu-actions button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.kefu-actions button:hover {
  background: rgba(255, 255, 255, 0.28);
}

.kefu-msgs {
  flex: 1 1 auto;
  padding: 14px;
  overflow-y: auto;
  background: #f7f8fc;
}

.kefu-row {
  display: flex;
  margin-bottom: 10px;
}

.kefu-row.kefu-user {
  justify-content: flex-end;
}

.kefu-bubble {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #23263a;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 20, 43, 0.08);
}

.kefu-user .kefu-bubble {
  color: #fff;
  background: #6c5ce7;
}

.kefu-row.kefu-bot .kefu-bubble {
  max-width: 92%;
}

.kefu-table-wrap {
  max-width: 100%;
  margin: 6px 0;
  overflow-x: auto;
}

.kefu-table-wrap table {
  width: 100%;
  min-width: 260px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.kefu-table-wrap th,
.kefu-table-wrap td {
  padding: 6px 8px;
  border: 1px solid #e3e5ee;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
}

.kefu-table-wrap th {
  background: #f2f3f8;
  font-weight: 700;
  white-space: nowrap;
}

.kefu-bubble p {
  margin: 0 0 6px;
}

.kefu-bubble p:last-child {
  margin-bottom: 0;
}

.kefu-bubble strong {
  font-weight: 700;
}

.kefu-bubble em {
  font-style: italic;
}

.kefu-bubble ul,
.kefu-bubble ol {
  margin: 4px 0 6px;
  padding-left: 18px;
}

.kefu-bubble li {
  margin: 2px 0;
}

.kefu-bubble code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(108, 92, 231, 0.08);
  font-family: Consolas, Monaco, monospace;
  font-size: 12.5px;
}

.kefu-bubble pre {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f2f3f8;
  overflow-x: auto;
}

.kefu-bubble pre code {
  padding: 0;
  background: none;
}

.kefu-bubble .kefu-h {
  margin: 2px 0 6px;
  font-weight: 700;
}

.kefu-user .kefu-bubble code {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

.kefu-sys .kefu-bubble {
  margin: 0 auto;
  max-width: 100%;
  font-size: 12.5px;
  color: #8a8fa3;
  background: transparent;
  box-shadow: none;
  text-align: center;
}

.kefu-welcome {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.08), rgba(162, 155, 254, 0.16));
}

.kefu-welcome-title {
  font-size: 14px;
  font-weight: 700;
  color: #23263a;
}

.kefu-welcome-desc {
  margin: 4px 0 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #6b7085;
}

.kefu-suggest {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kefu-suggest-btn {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(108, 92, 231, 0.25);
  border-radius: 8px;
  background: #fff;
  color: #5a4fd6;
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.kefu-suggest-btn:hover {
  background: #f4f2ff;
  border-color: rgba(108, 92, 231, 0.45);
}

.kefu-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 0 10px;
  max-width: 92%;
}

.kefu-followup-btn {
  padding: 6px 10px;
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: 14px;
  background: #fff;
  color: #5a4fd6;
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.kefu-followup-btn:hover {
  background: #f4f2ff;
  border-color: rgba(108, 92, 231, 0.5);
}

.kefu-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 18px;
}

.kefu-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b8bccc;
  animation: kefuBlink 1.2s infinite ease-in-out;
}

.kefu-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.kefu-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes kefuBlink {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.kefu-gate {
  flex: 0 0 auto;
  display: none;
  padding: 12px 16px;
  border-top: 1px solid #eceef5;
  background: #fff;
  text-align: center;
  font-size: 13px;
  color: #5b5f73;
}

.kefu-gate a {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 18px;
  border-radius: 8px;
  background: #6c5ce7;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
}

.kefu-inputbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eceef5;
  background: #fff;
}

#kefuInput {
  flex: 1 1 auto;
  min-height: 38px;
  max-height: 92px;
  padding: 9px 10px;
  border: 1px solid #e1e4ee;
  border-radius: 10px;
  resize: none;
  outline: none;
  font-size: 13.5px;
  line-height: 1.5;
  font-family: inherit;
  color: #23263a;
}

#kefuInput:focus {
  border-color: #6c5ce7;
}

#kefuInput:disabled {
  background: #f4f5f9;
}

#kefuSend {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: #6c5ce7;
  color: #fff;
  font-size: 13.5px;
  cursor: pointer;
}

#kefuSend:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.kefu-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 0 14px 8px;
  background: #fff;
  font-size: 11px;
  color: #a0a4b5;
}

#kefuRemain {
  color: #6c5ce7;
}

@media (max-width: 767px) {
  #kefuBubble {
    right: 16px;
    bottom: 88px;
    width: 52px;
    height: 52px;
  }

  #kefuBubble svg {
    width: 24px;
    height: 24px;
  }

  #kefuPanel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 82vh;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 82vh;
    border-radius: 16px 16px 0 0;
    resize: none;
  }
}
