/* ============ 字体（思源黑体） ============ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700;800;900&display=swap');

/* ============ 设计变量 ============ */
:root {
  /* 主题色 */
  --primary: #C8161D;        /* 中国红 */
  --primary-dark: #A51117;
  --primary-deeper: #7A0C11;
  --primary-light: #FDECEE;
  --primary-soft: #FFF1F2;

  /* 现代辅助色 */
  --accent: #FF3B45;           /* 亮红强调 */
  --gold: #C9A14A;             /* 备用金 */
  --ink: #0F0F0F;              /* 深黑 */

  /* 中性色（偏冷现代） */
  --text-1: #0F0F0F;
  --text-2: #3A3A3A;
  --text-3: #8A8A8E;
  --text-4: #B9B9BE;
  --bg-page: #F5F5F7;
  --bg-card: #FFFFFF;
  --bg-gray: #F4F4F6;
  --border: #ECECEF;

  /* 状态色 */
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #F44336;

  /* 尺寸（设计稿宽 390，--page-scale 由 JS 按屏宽写入） */
  --design-w: 390px;
  --page-scale: 1;
  --status-h: 44px;
  --tabbar-h: 56px;
  --home-indicator-h: 22px;
  --safe-top: calc(env(safe-area-inset-top, 0px) / var(--page-scale));
  --safe-bottom: calc(env(safe-area-inset-bottom, 0px) / var(--page-scale));

  /* 阴影 */
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-tabbar: 0 -2px 12px rgba(0, 0, 0, 0.05);
}

/* ============ Reset ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}
body {
  font-family: "Noto Sans SC", -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}
.font-display { font-family: "Noto Sans SC", sans-serif; font-weight: 800; letter-spacing: -0.02em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }
input, textarea { font-family: inherit; outline: none; border: none; }

/* 滚动条美化（仅桌面端可见） */
.app-view::-webkit-scrollbar { width: 0; }

/* ============ 应用容器（390 设计稿 + 屏宽等比缩放） ============ */
.app-shell {
  position: relative;
  width: var(--design-w);
  height: 100%; /* 兜底：不支持 calc/var 的旧浏览器 */
  height: calc(var(--app-h, 100dvh) / var(--page-scale)); /* JS 动态视口高度，适配 iOS 工具栏收展 */
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  overflow: hidden;
  zoom: var(--page-scale);
}

/* 不支持 zoom 时用 transform 兜底 */
@supports not (zoom: 1) {
  .app-shell {
    zoom: normal;
    transform: scale(var(--page-scale));
    transform-origin: top center;
  }
}

@media (min-width: 481px) {
  body {
    background: #E8E8EC;
  }
  .app-shell {
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 12px 40px rgba(0, 0, 0, 0.08);
  }
}

/* ============ 状态栏 ============ */
.status-bar {
  height: calc(var(--status-h) + var(--safe-top));
  padding: var(--safe-top) 24px 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  transition: background 0.2s, color 0.2s;
}
.status-bar.is-primary {
  background: #E63946;
  color: #fff;
}
.status-time {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.status-icons {
  display: flex;
  align-items: center;
  gap: 5px;
  color: inherit;
}

/* ============ 微信胶囊 ============ */
.capsule {
  position: absolute;
  top: calc(var(--safe-top) + var(--status-h) - 32px);
  right: 14px;
  width: 87px;
  height: 32px;
  background: rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  color: var(--text-1);
  font-size: 16px;
  z-index: 60;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.capsule.is-primary {
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
.capsule-dots, .capsule-close {
  flex: 1;
  text-align: center;
  line-height: 1;
}
.capsule-divider {
  width: 0.5px;
  height: 16px;
  background: rgba(0, 0, 0, 0.15);
}
.capsule.is-primary .capsule-divider {
  background: rgba(255, 255, 255, 0.35);
}
.capsule-close { font-size: 14px; transform: translateY(-1px); }

/* ============ 应用主视图 ============ */
.app-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: var(--bg-page);
  /* 滚动平滑 */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.app-view.has-tabbar { padding-bottom: calc(var(--tabbar-h) + var(--home-indicator-h) + var(--safe-bottom) - 6px); }

/* 页面切换动画 */
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.page {
  min-height: 100%;
  animation: fadeIn 0.25s ease;
}
.page.page-detail {
  animation: slideInRight 0.28s ease;
}

/* ============ TabBar ============ */
.tabbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-h) + var(--home-indicator-h) + var(--safe-bottom));
  padding-bottom: calc(var(--home-indicator-h) + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--border);
  box-shadow: var(--shadow-tabbar);
  display: flex;
  align-items: stretch;
  z-index: 90;
}
.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding-top: 6px;
  color: var(--text-3);
  font-size: 10px;
  position: relative;
  cursor: pointer;
  transition: color 0.15s;
}
.tabbar-item svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s;
}
.tabbar-item.active { color: var(--primary); }
.tabbar-item.active svg { transform: translateY(-1px); }
.tabbar-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(14px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 600;
  border: 1.5px solid #fff;
}

/* Home Indicator */
.home-indicator {
  position: absolute;
  bottom: calc(6px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background: #1A1A1A;
  border-radius: 3px;
  z-index: 100;
  opacity: 0.85;
}

/* 移动端真机自带系统 Home Indicator：隐藏原型手画的假指示条，并释放其在 TabBar / 页面底部的占位 */
@media (max-width: 480px), (pointer: coarse) {
  :root { --home-indicator-h: 0px; }
  .home-indicator { display: none; }
}

/* ============ 移除模拟小程序顶部条（假状态栏 + 微信胶囊） ============ */
.status-bar, .capsule { display: none; }

/* 顶部安全区：内容避开手机刘海 */
.app-view { padding-top: var(--safe-top); }

/* ============ Toast ============ */
.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  max-width: 200px;
  text-align: center;
  line-height: 1.5;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ============ 通用工具类 ============ */
.page-pad { padding: 12px; }
.flex { display: flex; }
.flex-c { display: flex; align-items: center; }
.flex-c-bw { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.txt-12 { font-size: 12px; }
.txt-13 { font-size: 13px; }
.txt-16 { font-size: 16px; }
.txt-bold { font-weight: 600; }
.txt-gray { color: var(--text-3); }
.txt-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.txt-ellipsis-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 状态栏深色背景下文字白色 */
.status-bar-dark .status-bar,
.status-bar-dark .capsule { color: #fff; }
.status-bar-dark .capsule {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.2);
}
.status-bar-dark .capsule-divider { background: rgba(255, 255, 255, 0.3); }
