/* ==========================================================================
   Base Reset & Normalize
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 62.5%; /* 1rem = 10px */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  font-size: 1.4rem;
  line-height: 1.6;
  color: #323233;
  background-color: #f7f8fa;
  overflow-x: hidden;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

img {
  max-width: 100%;
  display: block;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

button {
  border: none;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
}

/* ==========================================================================
   CSS Variables - Color System
   ========================================================================== */

:root {
  /* Brand Colors */
  --color-primary: #1989fa;
  --color-primary-light: #4ba3fc;
  --color-primary-dark: #0d6ecd;
  
  /* Status Colors */
  --color-success: #07c160;
  --color-warning: #ff976a;
  --color-danger: #ee0a24;
  --color-info: #909399;
  
  /* Neutral Colors */
  --color-text-primary: #323233;
  --color-text-secondary: #646566;
  --color-text-placeholder: #969799;
  --color-border: #ebedf0;
  --color-background: #f7f8fa;
  --color-white: #ffffff;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  
  /* Safe Area */
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
  --safe-area-left: env(safe-area-inset-left);
  --safe-area-right: env(safe-area-inset-right);
}

/* ==========================================================================
   Layout Utilities
   ========================================================================== */

.container {
  width: 100%;
  max-width: 750px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.page {
  min-height: 100vh;
  padding-bottom: calc(56px + var(--safe-area-bottom));
  background-color: var(--color-background);
}

.page-content {
  padding: var(--space-lg);
}

/* Flexbox Utilities */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

.align-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

/* Grid Utilities */
.grid {
  display: grid;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

/* Spacing Utilities */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.pt-sm { padding-top: var(--space-sm); }
.pt-md { padding-top: var(--space-md); }
.pt-lg { padding-top: var(--space-lg); }

.pb-sm { padding-bottom: var(--space-sm); }
.pb-md { padding-bottom: var(--space-md); }
.pb-lg { padding-bottom: var(--space-lg); }

/* Text Utilities */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-bold {
  font-weight: 600;
}

.text-sm {
  font-size: 1.2rem;
}

.text-md {
  font-size: 1.4rem;
}

.text-lg {
  font-size: 1.6rem;
}

.text-xl {
  font-size: 1.8rem;
}

.text-2xl {
  font-size: 2.0rem;
}

.text-primary {
  color: var(--color-primary);
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-placeholder {
  color: var(--color-text-placeholder);
}

.text-success {
  color: var(--color-success);
}

.text-warning {
  color: var(--color-warning);
}

.text-danger {
  color: var(--color-danger);
}

/* Display Utilities */
.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.hidden {
  display: none;
}

/* Overflow Utilities */
.overflow-hidden {
  overflow: hidden;
}

.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Position Utilities */
.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.fixed {
  position: fixed;
}

/* ==========================================================================
   Safe Area Support
   ========================================================================== */

.safe-area-top {
  padding-top: var(--safe-area-top);
}

.safe-area-bottom {
  padding-bottom: var(--safe-area-bottom);
}

/* ==========================================================================
   Mobile Viewport Optimization
   ========================================================================== */

@media screen and (max-width: 320px) {
  html {
    font-size: 58.59%;
  }
}

@media screen and (min-width: 480px) {
  html {
    font-size: 75%;
  }
}
