/* ===================== 全局重置与变量 ===================== */
:root {
  --primary: #2B6CB0;
  --primary-light: #4299E1;
  --primary-dark: #1A4971;
  --accent: #38A169;
  --danger: #E53E3E;
  --warn: #DD6B20;
  --gold: #D69E2E;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --text: #1A202C;
  --text-secondary: #718096;
  --text-tertiary: #A0AEC0;
  --border: #E2E8F0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Helvetica, "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #000;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; outline: none; border: none; background: none; color: inherit; }
a { text-decoration: none; color: inherit; }
ul, li { list-style: none; }
img { display: block; max-width: 100%; }

/* ===================== 手机外壳 ===================== */
#app {
  width: 390px;
  height: 100vh;
  max-height: 844px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0,0,0,0.3);
}

@media (max-height: 844px) {
  #app { height: 100vh; max-height: 100vh; }
}

/* ===================== 页面容器 ===================== */
.page {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: none;
  flex-direction: column;
  animation: fadeIn 0.25s ease;
}
.page.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

.page-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===================== 状态栏 ===================== */
.status-bar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  position: relative;
  flex-shrink: 0;
}
.status-bar.light { background: transparent; color: #fff; }

/* ===================== 导航栏 ===================== */
.nav-bar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  position: relative;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.nav-bar .nav-title { font-size: 17px; font-weight: 600; }
.nav-bar .nav-back {
  position: absolute;
  left: 12px;
  font-size: 24px;
  color: var(--text);
  padding: 4px 8px;
  line-height: 1;
}
.nav-bar .nav-action {
  position: absolute;
  right: 16px;
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
}

/* ===================== 底部 TabBar ===================== */
.tab-bar {
  height: 60px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: var(--safe-bottom);
}
.tab-bar .tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-tertiary);
  font-size: 10px;
}
.tab-bar .tab-item.active { color: var(--primary); }
.tab-bar .tab-item .tab-icon { font-size: 22px; line-height: 1; }

/* ===================== 按钮 ===================== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  transition: opacity 0.2s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-sm { height: 36px; font-size: 14px; border-radius: 6px; width: auto; padding: 0 16px; }
.btn:disabled { opacity: 0.4; }

/* ===================== 输入框 ===================== */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 13px; color: var(--text-secondary); font-weight: 500; padding-left: 4px; }
.input-field {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  height: 48px;
  padding: 0 14px;
  gap: 10px;
}
.input-field input { flex: 1; font-size: 15px; }
.input-field .input-prefix { color: var(--text-secondary); font-size: 15px; }
.input-field .input-suffix { font-size: 13px; color: var(--primary); font-weight: 600; white-space: nowrap; }
.input-field.focused { border: 1.5px solid var(--primary); }

/* ===================== 卡片 ===================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ===================== 标签 ===================== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.tag-primary { background: #EBF4FF; color: var(--primary); }
.tag-accent { background: #F0FFF4; color: var(--accent); }
.tag-warn { background: #FFFAF0; color: var(--warn); }
.tag-danger { background: #FFF5F5; color: var(--danger); }
.tag-gold { background: #FFFAF0; color: var(--gold); }
.tag-gray { background: #F7FAFC; color: var(--text-secondary); }

/* ===================== 空状态 ===================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text-tertiary);
}
.empty-state .empty-icon { font-size: 48px; }
.empty-state .empty-text { font-size: 14px; }

/* ===================== 弹窗 ===================== */
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-mask.active { display: flex; }
.modal {
  background: var(--card);
  border-radius: 16px;
  width: 80%;
  max-width: 320px;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 20px 20px 8px; font-size: 17px; font-weight: 600; text-align: center; }
.modal-body { padding: 8px 20px 20px; font-size: 14px; color: var(--text-secondary); text-align: center; line-height: 1.6; }
.modal-footer { display: flex; border-top: 1px solid var(--border); }
.modal-footer .modal-btn { flex: 1; height: 48px; font-size: 16px; font-weight: 500; }
.modal-footer .modal-btn:first-child { border-right: 1px solid var(--border); color: var(--text-secondary); }
.modal-footer .modal-btn:last-child { color: var(--primary); }

/* ===================== Toast ===================== */
.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 2000;
  display: none;
  white-space: nowrap;
  max-width: 260px;
  text-align: center;
}
.toast.active { display: block; animation: toastIn 0.2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -40%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* ===================== 通用工具 ===================== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
.py-12 { padding-top: 12px; padding-bottom: 12px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.text-gold { color: var(--gold); }
.text-bold { font-weight: 600; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; }
.text-2xl { font-size: 32px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.full-w { width: 100%; }
