/* ============ 全局 ============ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  background-attachment: fixed;
  color: #ffffff;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  width: 100%;
  max-width: 750px;
  margin: 0 auto;
  position: relative;
}

.hidden {
  display: none !important;
}

/* ============ 页面切换 ============ */
.page {
  display: none;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 首页 ============ */
.home-header {
  text-align: center;
  padding: 60px 0 40px;
}

.brand-title {
  font-size: 30px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 2px;
  color: #f5f5f5;
}

.brand-subtitle {
  font-size: 14px;
  color: #a0a0c0;
  margin: 0;
  letter-spacing: 1px;
}

.card-list {
  padding: 20px 0;
}

.card {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
  cursor: pointer;
  transition: all 0.25s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.card:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.13);
}

.card-icon {
  font-size: 36px;
  margin-right: 16px;
  flex-shrink: 0;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 12px;
  color: #a0a0c0;
  line-height: 1.5;
}

.card-arrow {
  font-size: 28px;
  color: #a0a0c0;
  margin-left: 12px;
}

.card-palm { border-color: rgba(233, 100, 67, 0.3); }
.card-fortune { border-color: rgba(147, 130, 233, 0.3); }

.home-footer {
  text-align: center;
  font-size: 11px;
  color: #666680;
  margin-top: 60px;
  padding-bottom: 30px;
}

/* ============ 子页面头部 ============ */
.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 8px;
  background: rgba(26, 26, 46, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  margin: 0 -20px 20px;
  padding-left: 8px;
  padding-right: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.back-btn {
  width: 40px;
  height: 40px;
  font-size: 28px;
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.back-btn:active { opacity: 0.6; }

.page-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  text-align: center;
  padding-right: 40px;
}

.page-body {
  padding-bottom: 40px;
}

/* ============ 提示框 ============ */
.tip-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.tip-title {
  font-size: 15px;
  font-weight: 600;
  color: #f5f5f5;
  margin-bottom: 6px;
}

.tip-box p {
  margin: 0;
  font-size: 13px;
  color: #a0a0c0;
  line-height: 1.6;
}

/* ============ 上传区 ============ */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.2s;
}

.upload-area:active { background: rgba(255, 255, 255, 0.1); }

.upload-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 14px;
  color: #a0a0c0;
}

.preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.preview-area img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  object-fit: contain;
}

.link-btn {
  margin-top: 12px;
  background: transparent;
  border: none;
  color: #7b9cff;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
}

.link-btn:active { opacity: 0.6; }

/* ============ 表单 ============ */
.form-area {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 22px;
}

.form-group { margin-bottom: 22px; }

.form-label {
  display: block;
  font-size: 14px;
  color: #d0d0e0;
  margin-bottom: 10px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 15px;
  color: #f5f5f5;
  outline: none;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus { border-color: rgba(147, 130, 233, 0.6); }

.form-input::-webkit-date-and-time-value { text-align: left; }

.gender-selector {
  display: flex;
  gap: 12px;
}

.gender-option {
  flex: 1;
  text-align: center;
  padding: 14px 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  font-size: 15px;
  color: #a0a0c0;
  cursor: pointer;
  transition: all 0.2s;
}

.gender-option.active {
  background: rgba(147, 130, 233, 0.3);
  border-color: rgba(147, 130, 233, 0.6);
  color: #ffffff;
}

/* ============ 按钮 ============ */
.primary-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 16px 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #ffffff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: inherit;
}

.palm-btn {
  background: linear-gradient(135deg, #e96443, #904e95);
}

.fortune-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
}

.primary-btn:active { opacity: 0.85; }

.primary-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: #666680;
  cursor: not-allowed;
}

.secondary-btn {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 14px 0;
  font-size: 15px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  cursor: pointer;
  font-family: inherit;
}

.secondary-btn:active { opacity: 0.85; }

/* ============ 加载 ============ */
.loading-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #e96443;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.page-fortune .spinner { border-top-color: #764ba2; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  font-size: 15px;
  color: #f5f5f5;
}

.loading-sub {
  margin-top: 6px;
  font-size: 12px;
  color: #a0a0c0;
}

/* ============ 结果 ============ */
.result-area {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 22px;
  margin-top: 20px;
}

.result-header {
  text-align: center;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.result-title {
  font-size: 17px;
  font-weight: 700;
  color: #f5f5f5;
  margin-bottom: 6px;
}

.result-info {
  font-size: 12px;
  color: #a0a0c0;
}

.result-content {
  font-size: 14px;
  color: #d0d0e0;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-image-wrap {
  margin-bottom: 20px;
  text-align: center;
}

.result-image {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ============ 错误 ============ */
.error-area {
  text-align: center;
  padding: 40px 20px;
}

.error-text {
  font-size: 14px;
  color: #ff6b6b;
  margin-bottom: 20px;
  line-height: 1.6;
  word-break: break-word;
}

/* ============ 大屏适配 ============ */
@media (min-width: 768px) {
  #app {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
  }
  .brand-title { font-size: 36px; }
}
