:root {
  --wechat-green: #07C160;
  --wechat-green-dark: #06AD56;
  --ink: #1a1a1a;
  --ink-2: #576b95;
  --text: #333;
  --text-soft: #8a8a8a;
  --line: #ebebeb;
  --bg: #f0f4f2;
  --card: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 50% 0%, rgba(7, 193, 96, .10), transparent 55%),
    linear-gradient(180deg, #f6faf8 0%, #eef2f0 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(20, 40, 32, .08);
  padding: 28px 22px 22px;
  text-align: center;
}

/* ---------- states ---------- */
.state { animation: fadeUp .32s ease both; }
.state[hidden] { display: none !important; }

.state-loading, .state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  gap: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(7, 193, 96, .18);
  border-top-color: var(--wechat-green);
  animation: spin .8s linear infinite;
}

.state-text { margin: 0; color: var(--text-soft); font-size: 15px; }

.error-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff1f0; color: #f5222d;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
}
.error-title { margin: 0; font-size: 17px; color: var(--ink); }
.error-text { margin: 0; font-size: 14px; color: var(--text-soft); }

/* ---------- ready ---------- */
.head { margin-bottom: 18px; }

.title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .5px;
}

.subtitle {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.5;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: #f7f9f8;
  border-radius: 14px;
  text-align: left;
}
.profile[hidden] { display: none !important; }

.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  flex: 0 0 46px;
  background: linear-gradient(135deg, var(--wechat-green), #4ecb8c);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600;
  letter-spacing: .5px;
}

.profile-text { min-width: 0; }

.name-row { display: flex; align-items: center; gap: 8px; }

.name {
  font-size: 16px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.badge {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--wechat-green-dark);
  background: rgba(7, 193, 96, .1);
  border: 1px solid rgba(7, 193, 96, .25);
  padding: 1px 7px;
  border-radius: 20px;
}

.dept { font-size: 12.5px; color: var(--text-soft); margin-top: 3px; }

.qr-box {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-img {
  width: 100%;
  max-width: 240px;
  height: auto;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  /* 允许长按弹出「识别二维码」—— 微信里没有二维码相机时的备用路径 */
  -webkit-touch-callout: default;
}
.qr-img[hidden] { display: none !important; }

.qr-fallback {
  padding: 60px 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
}
.qr-fallback[hidden] { display: none !important; }

/* ---------- v17：长按识别指引（v17 起是页面的主操作提示） ---------- */
.qr-hint {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: #eefaf3;
  border: 1px solid #b7e6cd;
  color: #0a6b3d;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.7;
}
.qr-hint:empty { display: none; }

/* ---------- v17：操作提示条（顾客点「换一个主播」后出现） ---------- */
.auto-bar {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f5f7f6;
  border: 1px solid #e2e6e4;
  color: #5a6b64;
  font-size: 12.5px;
  line-height: 1.6;
}
.auto-bar[hidden] { display: none !important; }

/* ---------- v16：ICP 备案号页脚 ---------- */
.icp {
  margin: 14px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: #9aa4ad;
  text-align: center;
}
.icp a { color: #9aa4ad; text-decoration: none; }
.icp a:hover { text-decoration: underline; }
.icp[hidden] { display: none !important; }

/* ---------- 占位码警告 ---------- */
.warn {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #ad6800;
  font-size: 12.5px;
  line-height: 1.6;
  text-align: left;
}
.warn[hidden] { display: none !important; }

.qr-box.is-placeholder {
  border: 2px dashed #f0a020;
  background: #fffdf7;
}

.tip {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.6;
}
.tip:empty { display: none; }

.btn {
  appearance: none;
  border: none;
  background: var(--wechat-green);
  color: #fff;
  font-size: 15px;
  padding: 11px 24px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.97); background: var(--wechat-green-dark); }

.btn-ghost {
  margin-top: 18px;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid #d9d9d9;
  padding: 9px 20px;
  font-size: 14px;
}
.btn-ghost:active { background: #f5f5f5; color: var(--wechat-green-dark); }
.btn-ghost[hidden] { display: none !important; }

.footer {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: #b3b3b3;
  line-height: 1.6;
}
.footer:empty { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
