.jiuji-chat {
  position: fixed;
  right: 24px;
  bottom: 28px;
  z-index: 2147483000;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: #102036;
}

.jiuji-chat *,
.jiuji-chat *::before,
.jiuji-chat *::after {
  box-sizing: border-box;
}

.jiuji-chat__toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 178px;
  height: 78px;
  padding: 8px 16px 8px 10px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: #102a4c;
  box-shadow: 0 14px 34px rgba(16, 42, 76, 0.24);
  cursor: pointer;
  outline: none;
}

.jiuji-chat__toggle:hover,
.jiuji-chat__toggle:focus {
  background: #0b365f;
}

.jiuji-chat__toggle-avatar {
  display: grid;
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  color: #102a4c;
  background: #9ff2c8 url("/static/webf/images/sylogo.png") left -7px center / auto 52px no-repeat;
  font-size: 0;
  font-weight: 700;
  line-height: 1;
}

.jiuji-chat__toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.06;
  white-space: nowrap;
}

.jiuji-chat__toggle-icon {
  display: block;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  color: #9ff2c8;
}

.jiuji-chat__toggle-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.jiuji-chat__panel {
  position: absolute;
  right: 0;
  bottom: 96px;
  display: flex;
  flex-direction: column;
  width: 432px; /* 降级方案：不支持min的浏览器 */
  width: min(432px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  height: 600px; /* 降级方案：不支持min的浏览器 */
  height: min(600px, calc(100vh - 128px));
  max-height: calc(100vh - 128px);
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(16, 42, 76, 0.12);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(16, 42, 76, 0.22);
}

.jiuji-chat__panel[hidden] {
  display: none;
}

.jiuji-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  color: #fff;
  background: #102a4c;
}

.jiuji-chat__header strong {
  display: block;
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.2;
}

.jiuji-chat__header span {
  display: block;
  color: rgba(255, 255, 255, 0.76);
  font-size: 16px;
  line-height: 1.3;
}

.jiuji-chat__close {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}

.jiuji-chat__close:hover,
.jiuji-chat__close:focus {
  background: rgba(255, 255, 255, 0.2);
}

.jiuji-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  background: #f5f8fb;
}

.jiuji-chat__welcome {
  margin: 0 0 12px;
  padding: 18px 20px;
  border: 1px solid rgba(16, 42, 76, 0.08);
  border-radius: 8px;
  background: #fff;
  color: #43546b;
  font-size: 16px;
  line-height: 1.65;
}

.jiuji-chat__welcome p {
  margin: 0;
}

.jiuji-chat__welcome p + p {
  margin-top: 4px;
}

.jiuji-chat__message {
  max-width: 82%;
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.jiuji-chat__message--user {
  margin-left: auto;
  color: #fff;
  background: #1c7c63;
}

.jiuji-chat__message--assistant {
  margin-right: auto;
  color: #1f2d3d;
  background: #fff;
  border: 1px solid rgba(16, 42, 76, 0.08);
}

.jiuji-chat__form {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid rgba(16, 42, 76, 0.1);
  background: #fff;
}

.jiuji-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 54px;
  padding: 0 16px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  color: #102036;
  background: #fff;
  font-size: 17px;
  outline: none;
}

.jiuji-chat__input:focus {
  border-color: #1c7c63;
  box-shadow: 0 0 0 3px rgba(28, 124, 99, 0.12);
}

.jiuji-chat__send {
  flex: 0 0 84px;
  height: 54px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #1c7c63;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.jiuji-chat__send:hover,
.jiuji-chat__send:focus {
  background: #176d57;
}

.jiuji-chat__input:disabled,
.jiuji-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

@media (max-width: 640px) {
  .jiuji-chat {
    right: 14px;
    bottom: 18px;
  }

  .jiuji-chat__toggle {
    min-width: 150px;
    height: 68px;
    padding: 7px 12px 7px 8px;
  }

  .jiuji-chat__toggle-avatar {
    flex-basis: 54px;
    width: 54px;
    height: 54px;
    background-size: auto 46px;
  }

  .jiuji-chat__toggle-text {
    font-size: 19px;
  }

  .jiuji-chat__toggle-icon {
    flex-basis: 24px;
    width: 24px;
    height: 24px;
  }

  .jiuji-chat__panel {
    right: -2px;
    bottom: 82px;
    width: 95vw; /* 降级方案：不支持calc的浏览器 */
    width: calc(100vw - 28px);
    max-width: 100vw;
    height: 650px; /* 降级方案：不支持min的浏览器 */
    height: min(650px, calc(100vh - 96px));
    max-height: calc(100vh - 96px);
    padding: 0;
  }
}
