:root {
  --primary: #FF6B8A;
  --primary-light: #FF8FA8;
  --primary-dark: #E5526F;
  --gradient: linear-gradient(135deg, #FF6B8A, #FF8E53);
  --gradient-h: linear-gradient(90deg, #FF6B8A, #FF8E53);
  --bg: #FFF5F7;
  --card-bg: rgba(255,255,255,0.92);
  --text: #333;
  --text-secondary: #888;
  --text-light: #bbb;
  --border: #f0e0e5;
  --shadow: 0 2px 12px rgba(255,107,138,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --tab-height: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, 'SF Pro Display', 'Roboto', 'Helvetica Neue', sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }

/* 访客提示条 */
.guest-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  padding: 8px 16px; text-align: center; font-size: 12px;
  background: linear-gradient(90deg, #FFF3E0, #FCE4EC); color: #E65100;
  padding-top: calc(8px + var(--safe-top));
}

/* 主容器 */
.page-container {
  height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-top); padding-bottom: calc(var(--tab-height) + var(--safe-bottom));
}
.page-container.no-tab { padding-bottom: 0; }

/* 底部Tab栏 */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--tab-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(255,255,255,0.95);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,107,138,0.1);
  width: 100%;
  box-sizing: border-box;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; min-width: 0; height: var(--tab-height); position: relative; cursor: pointer;
  color: var(--text-light); transition: color 0.2s;
  -webkit-user-select: none; user-select: none;
}
.tab-item.active { color: var(--primary); }
.tab-icon { width: 24px; height: 24px; fill: currentColor; margin-bottom: 2px; }
.tab-item span { font-size: 11px; font-weight: 500; }
.badge {
  position: absolute; top: 4px; right: 50%; transform: translateX(14px);
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  background: #FF3B30; color: #fff; font-size: 10px; line-height: 16px;
  text-align: center; font-weight: 600;
}

/* 卡片 */
.card {
  background: var(--card-bg); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin: 0 12px 12px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 8px 20px;
  border: none; border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--gradient); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:active { transform: scale(0.97); opacity: 0.8; }

/* 输入框 */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.input-field {
  width: 100%; height: 44px; padding: 0 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; background: #fff;
  transition: border-color 0.2s; outline: none;
}
.input-field:focus { border-color: var(--primary); }
textarea.input-field { height: 80px; padding: 8px 12px; resize: vertical; }

/* 抽屉 */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5);
  transition: opacity 0.3s;
}
.drawer-container {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 201;
  max-height: 85vh; background: #fff; border-radius: 20px 20px 0 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: var(--safe-bottom);
  /* 不在CSS中设置transform/transition，完全由JS控制动画 */
}
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.drawer-header h3 { font-size: 16px; font-weight: 600; }
.drawer-close { font-size: 24px; color: var(--text-light); cursor: pointer; line-height: 1; }
.drawer-body { padding: 16px 20px; }

/* 标签切换 */
.tabs {
  display: flex; border-bottom: 1px solid var(--border); margin-bottom: 12px;
  background: #fff; position: sticky; top: 0; z-index: 10;
}
.tab-btn {
  flex: 1; padding: 12px 0; text-align: center; font-size: 14px;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  cursor: pointer; transition: all 0.2s; font-weight: 500;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* 进度条 */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gradient); border-radius: 4px; transition: width 0.5s; }

/* 头像 */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  background: var(--border); flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 80px; height: 80px; }

/* 宝箱浮动 */
.chest-float {
  position: fixed; bottom: 80px; right: 16px; z-index: 50;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--gradient); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(255,107,138,0.4); cursor: pointer;
  animation: chestBounce 1s ease infinite;
}
.chest-icon { font-size: 24px; }
.chest-badge {
  position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px;
  border-radius: 8px; background: #FF3B30; color: #fff; font-size: 10px;
  line-height: 16px; text-align: center; padding: 0 4px;
}
@keyframes chestBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 特效层 */
.effect-layer {
  position: fixed; inset: 0; z-index: 999; pointer-events: none; overflow: hidden;
}

/* 飘字动画（积分飘字等） */
.float-text {
  position: fixed; z-index: 300; font-size: 18px; font-weight: 700;
  color: var(--primary); pointer-events: none;
  animation: floatUp 1.5s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* Toast提示（居中弹出） */
.toast-popup {
  position: fixed; z-index: 400; left: 50%; top: 45%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75); color: #fff;
  padding: 10px 24px; border-radius: 8px;
  font-size: 14px; pointer-events: none;
  animation: toastFade 2s ease-out forwards;
}
@keyframes toastFade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

/* 空状态 */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* 加载 */
.loading { text-align: center; padding: 20px; color: var(--text-light); }
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 列表项 */
.list-item {
  display: flex; align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--border); gap: 12px;
}
.list-item:last-child { border-bottom: none; }

/* 选择器 */
.select-field {
  width: 100%; height: 44px; padding: 0 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; background: #fff; outline: none;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* 页面头部 */
.page-header {
  display: flex; align-items: center; padding: 12px 16px;
  background: #fff;
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--border);
}
.page-header h2 { font-size: 18px; font-weight: 600; flex: 1; }
.page-header .back-btn { font-size: 24px; color: var(--text); cursor: pointer; margin-right: 8px; }

/* 网格 */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* 工具类 */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }

/* 响应式 */
@media (min-width: 768px) {
  .page-container { max-width: 480px; margin: 0 auto; }
  .tab-bar { max-width: 480px; left: 0; right: 0; margin: 0 auto; }
  .drawer-container { max-width: 480px; left: 0; right: 0; margin: 0 auto; }
  #chat-screen { max-width: 480px; left: 0; right: 0; margin-left: auto; margin-right: auto; }
  .chat-input-bar { max-width: 480px; }
  .guest-banner { max-width: 100%; }
}
