/* ===== Theme & Variables ===== */
:root {
  --primary: #3B82F6;
  --primary-light: #DBEAFE;
  --primary-dark: #1D4ED8;
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --purple: #8B5CF6;
  --purple-light: #EDE9FE;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;
  --white: #FFFFFF;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --header-h: 52px;
  --tab-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--white);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

/* Header */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-back {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--gray-700);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin-right: 4px;
  flex-shrink: 0;
}
.header-back:active { background: var(--gray-100); }

.header-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-900);
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Main Content */
.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* Pages */
.page {
  display: none;
  padding: 16px;
  min-height: 100%;
}
.page.active { display: block; }

/* Tab Bar */
.tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--tab-h);
  padding-bottom: var(--safe-bottom);
  background: var(--white);
  border-top: 1px solid var(--gray-100);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 11px;
  padding: 4px 12px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.tab-item.active { color: var(--primary); }
.tab-item span { margin-top: 1px; }

/* Scrollbar */
.app-main::-webkit-scrollbar { width: 0; }

/* Hidden */
.hidden { display: none !important; }