:root {
  --za-bg: #eef2f7;
  --za-bg-card: #ffffff;
  --za-primary: #1b4332;
  --za-primary-light: #2d6a4f;
  --za-gold: #c9a227;
  --za-gold-light: #e8c547;
  --za-accent: #d4af37;
  --za-red: #c41e3a;
  --za-blue: #1d4ed8;
  --za-green: #15803d;
  --za-text: #1e293b;
  --za-text-muted: #64748b;
  --za-border: #e2e8f0;
  --za-shadow: 0 4px 20px rgba(15, 39, 68, 0.08);
  --za-shadow-sm: 0 2px 8px rgba(15, 39, 68, 0.06);
  --za-radius: 12px;
  --za-radius-sm: 8px;
  --za-font: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body.za-theme,
body.za-theme .cgi-wrap {
  font-family: var(--za-font);
  color: var(--za-text);
  -webkit-font-smoothing: antialiased;
}

body.za-theme {
  background: var(--za-bg);
  background-image: linear-gradient(180deg, #f8fafc 0%, var(--za-bg) 120px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.za-page-head {
  background: linear-gradient(135deg, #0f2744 0%, var(--za-primary) 50%, var(--za-primary-light) 100%);
  color: #fff;
  text-align: center;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(15, 39, 68, 0.2);
  border-bottom: 3px solid var(--za-gold);
}

.za-page-foot {
  text-align: center;
  padding: 20px 16px;
  color: var(--za-text-muted);
  font-size: 12px;
  line-height: 1.8;
  background: var(--za-bg-card);
  margin: 12px 8px;
  border-radius: var(--za-radius);
  box-shadow: var(--za-shadow-sm);
}

.za-nav-top {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--za-primary) 0%, var(--za-primary-light) 100%);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--za-shadow);
  border-bottom: 2px solid var(--za-gold);
}

.za-nav-top ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

.za-nav-top li { flex: 1; }

.za-nav-top a {
  display: block;
  padding: 14px 8px;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
  border-bottom: 3px solid transparent;
}

.za-nav-top a:hover,
.za-nav-top a:active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--za-gold-light);
  border-bottom-color: var(--za-gold);
}

.za-kj-wrap {
  max-width: 800px;
  margin: 0 auto;
  background: var(--za-bg-card);
  border-radius: 0 0 var(--za-radius) var(--za-radius);
  box-shadow: var(--za-shadow);
  overflow: hidden;
}

.za-kj-tabs ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  gap: 8px;
  background: linear-gradient(180deg, #f8fafc, #fff);
  border-bottom: 1px solid var(--za-border);
}

.za-kj-tabs li {
  flex: 1;
  min-height: 44px;
  line-height: 44px;
  text-align: center;
  border-radius: var(--za-radius-sm);
  background: #f1f5f9;
  color: var(--za-text-muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  position: relative;
  z-index: 31;
}

.za-kj-tabs li.cur {
  color: #fff;
  box-shadow: var(--za-shadow-sm);
  transform: translateY(-1px);
}

.za-kj-tabs li:nth-child(1).cur { background: linear-gradient(135deg, #1b4332, #2d6a4f); }
.za-kj-tabs li:nth-child(2).cur { background: linear-gradient(135deg, #9b1c1c, #dc2626); }
.za-kj-tabs li:nth-child(3).cur { background: linear-gradient(135deg, #1e40af, #3b82f6); }

.za-kj-frame {
  height: auto;
  min-height: 210px;
  overflow: visible;
  background: #fff;
}

.za-kj-frame iframe {
  display: block;
  width: 100%;
  height: 220px;
  min-height: 210px;
  border: 0;
}

.za-content-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 8px 16px;
}

.za-content-wrap .box {
  border-radius: var(--za-radius);
  box-shadow: var(--za-shadow);
  overflow: hidden;
  margin-bottom: 12px;
  border: none;
}

#content-lam,
#content-xg,
#sicai-section,
#sicai-inline-root {
  overflow: visible;
  box-shadow: none;
  background: transparent;
}

#sicai-inline-root {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

#sicai-inline-root .nav2 {
  position: sticky;
  top: 0;
  z-index: 850;
}

#content-lam iframe,
#content-xg iframe,
#sicaiindexFrame {
  touch-action: pan-y;
}

.za-banner img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--za-radius);
}

.za-shengxiao {
  margin: 12px 0;
  border-radius: var(--za-radius);
  overflow: hidden;
  box-shadow: var(--za-shadow-sm);
}

.za-shengxiao img {
  width: 100%;
  height: auto;
  display: block;
}

.za-disclaimer {
  background: var(--za-bg-card);
  border-radius: var(--za-radius);
  padding: 20px 16px;
  margin: 16px 8px;
  box-shadow: var(--za-shadow-sm);
  line-height: 1.8;
  font-size: 13px;
  color: var(--za-text-muted);
}

.za-disclaimer .za-disclaimer-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--za-primary);
  text-align: center;
  margin-bottom: 12px;
}

.za-back-top {
  position: fixed;
  right: 12px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--za-primary), var(--za-primary-light));
  box-shadow: 0 4px 16px rgba(27, 67, 50, 0.35);
  cursor: pointer;
  z-index: 98;
  border: 2px solid var(--za-gold);
  display: none;
}

.za-back-top::after {
  content: "↑";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
}

/* 聊天室悬窗 - 右侧竖条，减少遮挡资料 */
.za-chat-widget {
  position: fixed;
  right: 0;
  top: calc(75vh - 70px);
  z-index: 10050;
  font-family: var(--za-font);
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.za-chat-fab {
  width: 46px;
  min-width: 46px;
  min-height: 140px;
  height: auto;
  padding: 14px 6px 12px;
  border: none;
  border-radius: 14px 0 0 14px;
  cursor: pointer;
  background: linear-gradient(180deg, #0f2744 0%, var(--za-primary) 50%, var(--za-primary-light) 100%);
  box-shadow: -6px 4px 24px rgba(15, 39, 68, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 2px solid var(--za-gold);
  border-right: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
}

.za-chat-fab::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 197, 71, 0.5), transparent);
  pointer-events: none;
}

.za-chat-fab:hover {
  transform: translateX(-3px);
  box-shadow: -10px 6px 28px rgba(15, 39, 68, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.za-chat-fab-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.za-chat-fab-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(232, 197, 71, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.za-chat-fab-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  text-align: center;
}

.za-chat-fab-label {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.za-chat-fab-sub {
  display: none;
}

.za-chat-fab-pulse {
  position: absolute;
  inset: -4px;
  inset-right: 0;
  border-radius: 16px 0 0 16px;
  border: 2px solid var(--za-gold);
  border-right: none;
  animation: za-chat-pulse 2.2s ease-out infinite;
  pointer-events: none;
}

@keyframes za-chat-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}

.za-chat-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--za-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(196, 30, 58, 0.4);
}

.za-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10049;
  background: rgba(15, 39, 68, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.za-chat-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.za-chat-panel {
  position: fixed;
  right: 52px;
  top: 3vh;
  bottom: 3vh;
  width: 390px;
  z-index: 10051;
  max-height: none;
  height: auto;
  background: var(--za-bg-card);
  border-radius: var(--za-radius);
  box-shadow: 0 12px 48px rgba(15, 39, 68, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(16px) scale(0.98);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  border: 1px solid var(--za-border);
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.za-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.za-chat-head {
  background: linear-gradient(135deg, #0f2744 0%, var(--za-primary) 55%, var(--za-primary-light) 100%);
  color: #fff;
  padding: 18px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--za-gold);
  flex-shrink: 0;
}

.za-chat-head-info {
  flex: 1;
  min-width: 0;
}

.za-chat-head-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0 0 6px;
}

.za-chat-head-sub {
  font-size: 13px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
}

.za-chat-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
  animation: za-chat-blink 2s ease-in-out infinite;
}

@keyframes za-chat-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.za-chat-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 24px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 10px;
  transition: background 0.2s;
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.za-chat-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.za-chat-messages {
  flex: 1 1 auto;
  min-height: 180px;
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 14px;
  background: linear-gradient(180deg, #f8fafc, #fff);
  -webkit-overflow-scrolling: touch;
  writing-mode: horizontal-tb;
  box-sizing: border-box;
}

.za-chat-welcome {
  text-align: center;
  padding: 24px 16px;
  color: var(--za-text-muted);
}

.za-chat-welcome-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.za-chat-welcome p {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--za-primary);
}

.za-chat-welcome span {
  font-size: 12px;
}

.za-chat-msg {
  margin-bottom: 12px;
  max-width: 88%;
  width: auto;
  clear: both;
  writing-mode: horizontal-tb;
  word-break: break-word;
}

.za-chat-msg.is-self {
  margin-left: auto;
  text-align: right;
}

.za-chat-msg-meta {
  font-size: 11px;
  color: var(--za-text-muted);
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  writing-mode: horizontal-tb;
  white-space: normal;
}

.za-chat-msg.is-self .za-chat-msg-meta {
  justify-content: flex-end;
}

.za-chat-msg-name {
  font-weight: 600;
  color: var(--za-primary);
}

.za-chat-msg.is-self .za-chat-msg-name {
  color: var(--za-gold);
}

.za-chat-msg-bubble {
  display: inline-block;
  padding: 12px 16px;
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  box-shadow: var(--za-shadow-sm);
  font-size: 15px;
  line-height: 1.5;
  color: var(--za-text);
  text-align: left;
  word-break: break-word;
  border: 1px solid var(--za-border);
}

.za-chat-msg.is-self .za-chat-msg-bubble {
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(135deg, var(--za-primary), var(--za-primary-light));
  color: #fff;
  border-color: transparent;
}

.za-chat-form {
  padding: 14px 14px 16px;
  background: #fff;
  border-top: 1px solid var(--za-border);
  flex-shrink: 0;
}

.za-chat-name-row {
  margin-bottom: 8px;
}

.za-chat-name {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--za-border);
  border-radius: var(--za-radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.za-chat-name:focus {
  border-color: var(--za-primary-light);
}

.za-chat-input-row {
  display: flex;
  gap: 8px;
}

.za-chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--za-border);
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.za-chat-input:focus {
  border-color: var(--za-primary-light);
}

.za-chat-send {
  padding: 0 22px;
  height: 44px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--za-primary), var(--za-primary-light));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.15s;
  border: 1px solid var(--za-gold);
}

.za-chat-send:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.za-chat-widget.is-active .za-chat-fab-pulse {
  animation: none;
  opacity: 0;
}

.za-chat-tabs {
  display: flex;
  gap: 0;
  background: #f1f5f9;
  border-bottom: 1px solid var(--za-border);
  flex-shrink: 0;
  width: 100%;
}

.za-chat-tab {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--za-text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.za-chat-tab.is-active {
  color: var(--za-primary);
  background: #fff;
  box-shadow: inset 0 -2px 0 var(--za-gold);
}

.za-chat-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.za-chat-view-room,
.za-chat-view-kefu {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  writing-mode: horizontal-tb;
}

.za-chat-muted-tip {
  padding: 8px 14px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 13px;
  text-align: center;
  border-top: 1px solid #fca5a5;
}

.za-chat-contact-kefu {
  display: block;
  width: calc(100% - 28px);
  margin: 8px 14px 0;
  padding: 8px 12px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #166534;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}

.za-chat-contact-kefu:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.za-chat-msg.is-kefu .za-chat-msg-bubble {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #166534;
  border-color: #86efac;
}

.za-chat-kefu-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #16a34a;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.za-chat-kefu-name {
  color: #15803d !important;
}

.za-chat-kefu-welcome {
  padding: 12px 14px;
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  color: #166534;
  font-size: 13px;
  line-height: 1.6;
  flex-shrink: 0;
}

.za-chat-private-messages {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  padding: 14px;
  background: linear-gradient(180deg, #f8fafc, #fff);
}

.za-chat-pm-msg {
  margin-bottom: 10px;
  max-width: 90%;
}

.za-chat-pm-msg.is-self {
  margin-left: auto;
  text-align: right;
}

.za-chat-pm-msg.is-kefu .za-chat-msg-bubble {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}

.za-chat-private-form {
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid var(--za-border);
  flex-shrink: 0;
}

.za-chat-private-send {
  padding: 0 18px;
  height: 44px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.za-chat-private-send:disabled,
.za-chat-send:disabled,
.za-chat-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media screen and (max-width: 480px) {
  .za-chat-widget {
    right: 0;
    top: calc(69vh - 64px);
    bottom: auto;
  }

  .za-chat-fab {
    width: 44px;
    min-width: 44px;
    min-height: 128px;
    padding: 12px 5px 10px;
    border-radius: 12px 0 0 12px;
  }

  .za-chat-fab-label {
    font-size: 13px;
    letter-spacing: 2px;
  }

  .za-chat-fab-icon {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .za-chat-panel {
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: none;
    height: 100%;
    border-radius: 0;
    transform: translateY(12px) scale(0.98);
  }

  .za-chat-panel.is-open {
    transform: translateY(0) scale(1);
  }

  .za-chat-messages {
    min-height: 220px;
    max-height: none;
  }

  .za-chat-tab {
    font-size: 13px;
    padding: 10px 6px;
  }
}
