*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  -webkit-text-size-adjust: 100%;
}

.page {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

.header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 16px;
  background: var(--primary-color, #6B5F9A);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  position: relative;
  z-index: 10;
}

.header__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chat-frame-wrap {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  background: #fff;
}

#chat-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.loading,
.error-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: #fff;
  z-index: 5;
}

.loading.hidden,
.error-panel.hidden {
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e8e8e8;
  border-top-color: var(--primary-color, #6B5F9A);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading p,
.error-panel p {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
}

.error-panel h2 {
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.error-panel .retry-btn {
  margin-top: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--primary-color, #6B5F9A);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.error-panel .retry-btn:active {
  opacity: 0.85;
}

/* 底部备案栏（参考公司官网页脚底部一行） */
.site-footer {
  flex: 0 0 auto;
  background: #6B5F9A;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
}

.site-footer__copy {
  white-space: nowrap;
}

.site-footer__sep {
  color: rgba(255, 255, 255, 0.35);
  user-select: none;
}

.site-footer__link {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  white-space: nowrap;
}

.site-footer__link:hover,
.site-footer__link:focus {
  color: #fff;
  text-decoration: underline;
}

.site-footer__link--gongan {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.site-footer__gongan-icon {
  display: block;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .site-footer {
    font-size: 11px;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .site-footer__inner {
    gap: 4px 8px;
  }

  .site-footer__sep {
    display: none;
  }

  .site-footer__copy,
  .site-footer__link {
    white-space: normal;
  }
}

/* 微信 WebView 安全区 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .header {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
}
