/* ========== 全局重置 & 苹果风格基础 ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* === iOS 色彩系统 === */
  --ios-blue: #007AFF;
  --ios-red: #FF3B30;
  --ios-orange: #FF9500;
  --ios-green: #34C759;
  --ios-teal: #5AC8FA;
  --ios-purple: #AF52DE;
  
  --color-primary: var(--ios-blue);
  --color-danger: var(--ios-red);
  --color-success: var(--ios-green);
  --color-warning: var(--ios-orange);
  
  /* iOS 背景层级 */
  --bg-root: #F2F2F7;        /* 最底层背景（iOS系统背景色） */
  --bg-secondary: #FFFFFF;    /* 卡片/列表背景 */
  --bg-tertiary: #F9F9F9;    /* 分组背景（比root稍亮） */
  
  /* iOS 文字颜色 */
  --text-primary: #000000;
  --text-secondary: #3C3C43;
  --text-tertiary: #8E8E93;
  --text-quaternary: #C7C7CC;
  
  /* iOS 分隔线 */
  --separator: rgba(60, 60, 67, 0.12);
  --separator-opaque: #E5E5EA;
  
  /* === iOS 字体系统 === */
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Menlo", monospace;
  
  /* iOS 字号规范 */
  --text-caption2: 11px;
  --text-caption1: 12px;
  --text-footnote: 13px;
  --text-subheadline: 15px;
  --text-callout: 16px;
  --text-body: 17px;
  --text-headline: 17px;
  --text-title3: 20px;
  --text-title2: 22px;
  --text-title1: 28px;
  --text-large-title: 34px;
  
  /* iOS 字重 */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  
  /* === iOS 间距系统（基于4px网格） === */
  --spacing-xxs: 4px;
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 20px;
  --spacing-xl: 24px;
  --spacing-xxl: 32px;
  
  /* === iOS 圆角（连续曲线） === */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 13px;       /* 卡片小圆角 */
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* === iOS 阴影（多层微阴影） === */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  
  /* === iOS 组件尺寸 === */
  --btn-height: 50px;           /* iOS按钮默认50px */
  --btn-height-sm: 36px;
  --input-height: 48px;
  --cell-height: 44px;          /* iOS标准cell高度 */
  --cell-height-lg: 52px;
  --avatar-sm: 36px;
  --avatar-md: 48px;
  --avatar-lg: 64px;
  --avatar-xl: 96px;
  --icon-sm: 20px;
  --icon-md: 24px;
  --icon-lg: 28px;
  --navbar-height: 44px;
  --tabbar-height: 50px;        /* iOS Tab Bar 高度（不含安全区） */
  
  /* === iOS 动效 === */
  --ease-out: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-in-out: cubic-bezier(0.42, 0, 0.58, 1);
  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ========== 基础 ========== */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-system);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  color: var(--text-primary);
  background: var(--bg-root);
  line-height: 1.47059;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ========== 容器 ========== */
.app-container {
  max-width: 430px;              /* iPhone 14 Pro Max 宽度 */
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;           /* 动态视口高度，解决移动端地址栏问题 */
  background: var(--bg-root);
  position: relative;
  overflow-x: hidden;
}

/* 页面内容区 - 底部留出Tab Bar空间 */
.page-content {
  padding: var(--spacing-md);
  padding-top: calc(var(--navbar-height) + var(--spacing-md));
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--spacing-xl));
}

/* 带大标题的页面头部 */
.page-header {
  padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
  padding-top: calc(var(--navbar-height) + var(--spacing-xs));
}

.page-header .large-title {
  font-size: var(--text-large-title);
  font-weight: var(--weight-bold);
  letter-spacing: 0.011em;
  line-height: 1.1;
  color: var(--text-primary);
}

/* ========== iOS 导航栏（透明/毛玻璃） ========== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--navbar-height);
  padding: 0 var(--spacing-md);
  background: rgba(242, 242, 247, 0.8);   /* 半透明 */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);     /* 毛玻璃效果 */
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 0.5px solid var(--separator);
}

.navbar .nav-title {
  font-size: var(--text-headline);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.022em;
  color: var(--text-primary);
}

.navbar .nav-left,
.navbar .nav-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-body);
  color: var(--ios-blue);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: var(--spacing-xs);
}

.navbar .nav-left { left: var(--spacing-sm); }
.navbar .nav-right { right: var(--spacing-sm); }

/* ========== iOS Tab Bar ========== */
.tabbar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(249, 249, 249, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--separator);
  z-index: 1000;
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--weight-medium);
  letter-spacing: -0.01em;
  color: var(--text-tertiary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s var(--ease-out);
}

.tabbar-item.active {
  color: var(--ios-blue);
}

.tabbar-item .tab-icon {
  width: 25px;
  height: 25px;
  margin-bottom: 2px;
  opacity: 0.8;
  transition: opacity 0.15s var(--ease-out);
}

.tabbar-item.active .tab-icon {
  opacity: 1;
}

/* 小红点 */
.tabbar-item .badge {
  position: absolute;
  top: 2px;
  right: -6px;
  width: 8px;
  height: 8px;
  background: var(--ios-red);
  border-radius: var(--radius-full);
}

/* ========== 表单元素（iOS风格） ========== */
input[type="text"],
input[type="password"],
input[type="tel"],
input[type="email"],
input[type="search"],
input[type="url"],
textarea,
select {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--spacing-md);
  font-family: var(--font-system);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  letter-spacing: -0.022em;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--separator-opaque);
  border-radius: var(--radius-sm);
  outline: none;
  -webkit-appearance: none;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

textarea {
  height: auto;
  min-height: 100px;
  padding: var(--spacing-sm) var(--spacing-md);
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--ios-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* placeholder 样式 */
input::placeholder,
textarea::placeholder {
  color: var(--text-quaternary);
  font-weight: var(--weight-regular);
}

/* 搜索框特殊样式 */
input[type="search"] {
  background: rgba(118, 118, 128, 0.12);
  border: none;
  border-radius: var(--radius-sm);
  padding-left: 32px;
}

input[type="search"]::placeholder {
  color: var(--text-tertiary);
}

/* ========== 按钮（iOS风格） ========== */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--btn-height);
  padding: 0 var(--spacing-xl);
  font-family: var(--font-system);
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.022em;
  color: #FFFFFF;
  background: var(--ios-blue);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-appearance: none;
  user-select: none;
  transition: opacity 0.15s var(--ease-out);
}

button:active,
.btn:active {
  opacity: 0.7;
}

button:disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 次要按钮 */
.btn-secondary {
  background: rgba(0, 122, 255, 0.12);
  color: var(--ios-blue);
}

/* 危险按钮 */
.btn-danger {
  background: var(--ios-red);
}

/* 纯文字按钮 */
.btn-text {
  background: transparent;
  color: var(--ios-blue);
  width: auto;
  height: auto;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-weight: var(--weight-regular);
}

/* 小按钮 */
.btn-sm {
  height: var(--btn-height-sm);
  padding: 0 var(--spacing-lg);
  font-size: var(--text-subheadline);
  border-radius: var(--radius-sm);
}

/* ========== 卡片（iOS风格 - 圆角+微阴影） ========== */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-sm);
}

/* 连续卡片（表单分组风格） */
.card-group {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-sm);
}

.card-group > * {
  border-bottom: 0.5px solid var(--separator);
}

.card-group > *:last-child {
  border-bottom: none;
}

/* ========== 列表项（iOS TableView Cell风格） ========== */
.list-item {
  display: flex;
  align-items: center;
  min-height: var(--cell-height);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s var(--ease-out);
  position: relative;
}

.list-item:active {
  background: #F0F0F5;
}

.list-item .item-left {
  margin-right: var(--spacing-sm);
  flex-shrink: 0;
}

.list-item .item-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.list-item .item-right {
  margin-left: var(--spacing-sm);
  color: var(--text-tertiary);
  flex-shrink: 0;
  font-size: var(--text-footnote);
  display: flex;
  align-items: center;
  gap: 4px;
}

.list-item .item-title {
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  letter-spacing: -0.022em;
  color: var(--text-primary);
  line-height: 1.3;
}

.list-item .item-desc {
  font-size: var(--text-footnote);
  color: var(--text-tertiary);
  margin-top: 2px;
  letter-spacing: -0.01em;
}

/* 带右箭头的列表项 */
.list-item .chevron {
  color: var(--text-quaternary);
  font-size: 14px;
}

/* ========== 头像（iOS风格） ========== */
.avatar {
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #E8E8ED, #D1D1D6);
}

.avatar-sm { width: var(--avatar-sm); height: var(--avatar-sm); }
.avatar-md { width: var(--avatar-md); height: var(--avatar-md); }
.avatar-lg { width: var(--avatar-lg); height: var(--avatar-lg); }
.avatar-xl { width: var(--avatar-xl); height: var(--avatar-xl); }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ========== 分组标题（iOS TableView Section Header风格） ========== */
.section-header {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: var(--text-footnote);
  font-weight: var(--weight-regular);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin-top: var(--spacing-md);
}

.section-header:first-child {
  margin-top: 0;
}

/* ========== 分割线 ========== */
.divider {
  height: 0.5px;
  background: var(--separator);
  margin: var(--spacing-xs) 0;
}

.divider-inset {
  margin-left: var(--spacing-md);
}

/* ========== 徽章/标签 ========== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: #FFFFFF;
  background: var(--ios-red);
  border-radius: var(--radius-full);
  letter-spacing: 0;
}

/* ========== 开关（纯CSS模拟iOS风格） ========== */
.toggle {
  width: 51px;
  height: 31px;
  background: var(--separator-opaque);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.2s var(--ease-out);
  position: relative;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s var(--spring);
}

.toggle.active {
  background: var(--ios-green);
}

.toggle.active::after {
  transform: translateX(20px);
}

/* ========== 弹窗（iOS Action Sheet风格） ========== */
.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: rgba(249, 249, 249, 0.95);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 2000;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.sheet-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  font-size: var(--text-callout);
  color: var(--ios-blue);
  border-bottom: 0.5px solid var(--separator);
  cursor: pointer;
}

.sheet-item:last-child {
  border-bottom: none;
}

.sheet-item.destructive {
  color: var(--ios-red);
}

.sheet-cancel {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-callout);
  font-weight: var(--weight-semibold);
  color: var(--ios-blue);
  border-top: 8px solid var(--bg-root);
  cursor: pointer;
}

/* ========== 动效 ========== */
.fade-in {
  animation: fadeIn 0.3s var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 工具类 ========== */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-blue { color: var(--ios-blue); }
.text-red { color: var(--ios-red); }

.text-sm { font-size: var(--text-footnote); }
.text-xs { font-size: var(--text-caption1); }
.text-lg { font-size: var(--text-title3); font-weight: var(--weight-semibold); }
.text-xl { font-size: var(--text-title2); font-weight: var(--weight-bold); }

.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.w-full { width: 100%; }

/* ========== 补充通用工具类 ========== */
.flex { display: flex; }
.flex-1 { flex: 1; min-width: 0; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.overflow-hidden { overflow: hidden; }
.rounded-full { border-radius: var(--radius-full); }
.rounded-lg { border-radius: var(--radius-lg); }
.no-shrink { flex-shrink: 0; }
.object-cover { object-fit: cover; }
.whitespace-nowrap { white-space: nowrap; }
.bg-white { background: var(--bg-secondary); }
.bg-root { background: var(--bg-root); }
.leading-relaxed { line-height: 1.6; }