.zf-cs-toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100010;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}

.zf-cs-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff;
  color: #262626;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  border: 1px solid #f0f0f0;
  font-size: 14px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.zf-cs-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.zf-cs-toast--success {
  border-left: 4px solid #52c41a;
}

.zf-cs-toast--error {
  border-left: 4px solid #ff4d4f;
}

.zf-cs-toast--warning {
  border-left: 4px solid #faad14;
}

.zf-cs-toast--info {
  border-left: 4px solid #1677ff;
}

.zf-cs-toast-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.zf-cs-toast-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #8c8c8c;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.zf-cs-toast-close:hover {
  color: #262626;
}

.zf-cs-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  font-family: "Noto Sans TC", "Nunito Sans", sans-serif;
  font-size: 14px;
}

.zf-cs-root.zf-cs-root--open {
  inset: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.zf-cs-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.zf-cs-root--open .zf-cs-backdrop {
  display: block;
}

.zf-cs-launcher {
  width: 96px;
  aspect-ratio: 3 / 4;
  padding: 0;
  border: none;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 8px 28px rgba(26, 58, 92, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.zf-cs-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(26, 58, 92, 0.34);
}

.zf-cs-launcher:focus-visible {
  outline: 2px solid #1677ff;
  outline-offset: 3px;
}

.zf-cs-launcher-figure {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  background: linear-gradient(180deg, #e8f4ff 0%, #f7fbff 100%);
}

.zf-cs-launcher-figure--fallback::before {
  content: '';
  flex: 1;
  background: url('/img/cs-launcher-avatar.svg') center / cover no-repeat,
    linear-gradient(180deg, #e8f4ff 0%, #f7fbff 100%);
}

.zf-cs-launcher-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  pointer-events: none;
}

.zf-cs-launcher-label {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 6px;
  background: linear-gradient(180deg, #1a3a5c 0%, #234a70 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-align: center;
}

.zf-cs-panel {
  position: relative;
  z-index: 1;
  width: min(800px, 72vw);
  height: min(640px, 78vh);
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.zf-cs-panel--offline {
  width: min(640px, 68vw);
  height: min(480px, 70vh);
}

.zf-cs-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #1a3a5c;
  color: #fff;
  flex-shrink: 0;
}

.zf-cs-title {
  font-weight: 600;
  flex: 1;
  font-size: 16px;
}

.zf-cs-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
}

.zf-cs-status.is-online {
  background: #2ecc71;
}

.zf-cs-status.is-offline {
  background: #95a5a6;
}

.zf-cs-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.zf-cs-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px;
  min-height: 0;
}

.zf-cs-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8c8c8c;
  font-size: 14px;
}

.zf-cs-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.zf-cs-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 88%;
}

.zf-cs-msg-row--visitor {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.zf-cs-msg-row--agent {
  align-self: flex-start;
}

.zf-cs-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  position: relative;
}

.zf-cs-avatar--visitor {
  background: linear-gradient(135deg, #69b1ff, #1677ff);
  color: #fff;
}

.zf-cs-avatar--agent {
  background-color: #e8f4ff;
  background-image: url('/img/cs-agent-avatar.svg');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  color: transparent;
  font-size: 0;
  line-height: 0;
}

.zf-cs-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.zf-cs-msg-body {
  min-width: 0;
  max-width: calc(100% - 46px);
}

.zf-cs-msg-bubble {
  padding: 10px 14px;
  border-radius: 10px;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 14px;
}

.zf-cs-msg-row--visitor .zf-cs-msg-bubble {
  background: #e8f0fe;
  color: #262626;
  border-top-right-radius: 4px;
}

.zf-cs-msg-row--agent .zf-cs-msg-bubble {
  background: #fff;
  color: #262626;
  border: 1px solid #eee;
  border-top-left-radius: 4px;
}

.zf-cs-msg-bubble img {
  max-width: 240px;
  border-radius: 6px;
  display: block;
}

.zf-cs-contact-form label,
.zf-cs-offline-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.zf-cs-offline-form {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.zf-cs-panel--offline .zf-cs-body {
  padding: 12px 16px;
}

.zf-cs-panel--offline .zf-cs-offline-form textarea {
  min-height: 56px;
  max-height: 120px;
}

.zf-cs-panel--offline .zf-cs-hint {
  text-align: center;
  margin-bottom: 8px;
}

.zf-cs-contact-form input,
.zf-cs-offline-form textarea,
.zf-cs-input-row textarea {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}

.zf-cs-hint {
  color: #666;
  font-size: 13px;
  margin: 0 0 10px;
}

.zf-cs-hint--compact {
  margin: 0 0 6px;
  font-size: 12px;
}

.zf-cs-contact-inline {
  flex-shrink: 0;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.zf-cs-contact-inline label {
  margin-bottom: 6px;
  font-size: 12px;
}

.zf-cs-contact-inline input {
  padding: 6px 8px;
  font-size: 13px;
}

.zf-cs-welcome {
  align-self: flex-start;
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f2f2f2;
  color: #444;
  font-size: 13px;
  line-height: 1.45;
}

.zf-cs-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.zf-cs-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.zf-cs-input-row textarea {
  flex: 1;
  min-height: 72px;
}

.zf-cs-send-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: #8c8c8c;
}

.zf-cs-send-toggle {
  border: none;
  background: none;
  padding: 0;
  color: #1677ff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
}

.zf-cs-send-toggle:hover {
  text-decoration: underline;
}

.zf-cs-btn {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}

.zf-cs-btn--primary {
  background: #1a3a5c;
  color: #fff;
  border-color: #1a3a5c;
}

@media (max-width: 768px) {
  .zf-cs-panel {
    width: calc(100vw - 32px);
    height: min(580px, 86vh);
  }

  .zf-cs-panel--offline {
    width: calc(100vw - 32px);
    height: min(480px, 80vh);
  }
}

@media (max-width: 480px) {
  .zf-cs-root:not(.zf-cs-root--open):not(.zf-cs-root--page) {
    right: 12px;
    bottom: 12px;
  }

  .zf-cs-launcher {
    width: 84px;
  }

  .zf-cs-launcher-label {
    font-size: 12px;
    min-height: 32px;
  }
  .zf-cs-root--open {
    padding: 12px;
  }
  .zf-cs-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
  }
}

.zf-cs-launcher-link {
  text-decoration: none;
  color: inherit;
}

.zf-cs-close-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* 独立客服页：1920×1080 设计稿红框约 1200×800，居中显示 */
body.zf-cs-page-body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f6;
}

#zf-cs-page-root {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, calc((100vh - 74.074vh) / 2)) max(16px, calc((100vw - 62.5vw) / 2));
  box-sizing: border-box;
}

.zf-cs-root--page {
  position: static;
  inset: auto;
  right: auto;
  bottom: auto;
  z-index: 1;
  width: min(1200px, 62.5vw);
  max-width: min(1200px, 62.5vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  box-sizing: border-box;
}

.zf-cs-root--page.zf-cs-root--open {
  display: flex;
  padding: 0;
}

.zf-cs-root--page .zf-cs-panel {
  flex: none;
  width: 100%;
  height: min(800px, 74.074vh);
  min-height: 0;
  max-height: min(800px, 74.074vh);
  margin: 0;
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
}

@media (max-width: 1280px) {
  #zf-cs-page-root {
    padding: 16px;
  }

  .zf-cs-root--page {
    width: min(1200px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
  }

  .zf-cs-root--page .zf-cs-panel {
    height: min(800px, calc(100vh - 32px), 74.074vh);
    max-height: min(800px, calc(100vh - 32px), 74.074vh);
  }
}

@media (max-width: 768px) {
  #zf-cs-page-root {
    padding: 12px;
  }

  .zf-cs-root--page {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .zf-cs-root--page .zf-cs-panel {
    height: min(800px, calc(100vh - 24px), 74.074vh);
    max-height: min(800px, calc(100vh - 24px), 74.074vh);
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  #zf-cs-page-root {
    padding: 8px;
  }

  .zf-cs-root--page {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }

  .zf-cs-root--page .zf-cs-panel {
    height: min(800px, calc(100vh - 16px), 74.074vh);
    max-height: min(800px, calc(100vh - 16px), 74.074vh);
  }
}
