/* ==================================================================
   知宅风水 — CSS Design System
   品牌色: 深蓝 #1A3A5C + 金色 #C9A96E + 米白 #F8F6F3
   ================================================================== */
:root {
  --deep: #1A3A5C;
  --gold: #C9A96E;
  --gold-light: #E0C88A;
  --gold-dark: #A8883E;
  --cream: #F8F6F3;
  --white: #FFFFFF;
  --text: #2D2D2D;
  --text-secondary: #6B7B8D;
  --text-muted: #9BAAB8;
  --green: #2D8F47;
  --red: #C23535;
  --orange: #E8913A;
  --border: rgba(26,58,92,0.08);
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

body {
  font-family: "PingFang SC","Microsoft YaHei","Hiragino Sans GB",-apple-system,sans-serif;
  background: var(--cream);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ===== App Shell ===== */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--white); position: relative; }

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--deep) 0%, #0F2840 100%);
  padding: 20px 20px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.header::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}
.header h1 { font-size: 1.6rem; color: var(--gold); font-weight: 700; letter-spacing: 0.05em; }
.header p { font-size: 0.85rem; color: rgba(255,255,255,0.6); margin-top: 4px; }

/* ===== Tabs ===== */
.tabs { display: flex; background: var(--deep); padding: 0 16px; gap: 0; }
.tab {
  flex: 1; padding: 10px 2px; text-align: center; cursor: pointer;
  color: rgba(255,255,255,0.5); font-size: 0.7rem; font-weight: 500;
  border-bottom: 2px solid transparent; transition: var(--transition);
}
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab:hover { color: rgba(255,255,255,0.8); }

/* ===== Page Container ===== */
.page { padding: 20px 16px; min-height: calc(100vh - 200px); }

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 40px 20px; text-align: center;
  cursor: pointer; transition: var(--transition); background: #FAF9F7;
  position: relative; margin-bottom: 20px;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--gold); background: rgba(201,169,110,0.05); }
.upload-zone .icon { font-size: 3rem; margin-bottom: 10px; }
.upload-zone .title { font-size: 1rem; color: var(--deep); font-weight: 600; margin-bottom: 4px; }
.upload-zone .hint { font-size: 0.78rem; color: var(--text-muted); }
.upload-zone input[type=file] { display: none; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.95rem; color: var(--text); background: var(--white);
  transition: var(--transition); outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,169,110,0.15); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px; border: none; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 600; cursor: pointer; transition: var(--transition);
  width: 100%; text-align: center;
}
.btn-primary { background: var(--gold); color: var(--white); box-shadow: 0 2px 8px rgba(201,169,110,0.3); }
.btn-primary:hover { background: var(--gold-dark); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; box-shadow: none; transform: none; }
.btn-outline { background: transparent; border: 1.5px solid var(--deep); color: var(--deep); }
.btn-outline:hover { background: var(--deep); color: var(--white); }
.btn-sm { padding: 10px 20px; font-size: 0.85rem; width: auto; }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { filter: brightness(1.1); }

/* ===== Status ===== */
.status-banner {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: 0.88rem; display: flex; align-items: center; gap: 10px;
}
.status-banner.info { background: #EBF5FD; color: #1A6FB5; border: 1px solid #C5DFF0; }
.status-banner.success { background: #EDF7EE; color: var(--green); border: 1px solid #C5E8CA; }
.status-banner.error { background: #FDEDED; color: var(--red); border: 1px solid #F5C6C6; }
.status-banner.warning { background: #FFF8ED; color: var(--orange); border: 1px solid #FDE2B5; }

/* ===== Cards ===== */
.card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-title { font-size: 1.05rem; font-weight: 700; color: var(--deep); margin-bottom: 12px; }

/* ===== Score Circle ===== */
.score-section { text-align: center; padding: 24px 0; }
.score-circle {
  width: 120px; height: 120px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; flex-direction: column;
  border: 4px solid var(--gold); position: relative;
}
.score-circle .num { font-size: 2.5rem; font-weight: 800; color: var(--deep); }
.score-circle .label { font-size: 0.75rem; color: var(--text-muted); }
.score-grade { font-size: 1.1rem; font-weight: 600; color: var(--gold); margin-top: 8px; }

/* ===== Flaw / Strength Items ===== */
.item-list { list-style: none; }
.item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: none; }
.item-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.item-name { font-weight: 600; font-size: 0.95rem; flex: 1; }
.item-severity { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.item-severity.high { background: #FDEDED; color: var(--red); }
.item-severity.medium { background: #FFF8ED; color: var(--orange); }
.item-severity.low { background: #EDF7EE; color: var(--green); }
.item-location { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.item-detail { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 4px; }
.item-fix { font-size: 0.85rem; color: var(--green); font-weight: 500; }
.item-tip { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.item-tip::before { content: '💡 '; }

/* ===== Preview Image ===== */
.preview-img {
  width: 100%; max-height: 240px; object-fit: contain; border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 16px;
}

/* ===== Loading ===== */
.loading-wrap { text-align: center; padding: 60px 20px; }
.spinner {
  width: 48px; height: 48px; border: 4px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 0.95rem; color: var(--text-secondary); }
.progress-bar {
  width: 100%; height: 4px; background: var(--border); border-radius: 2px;
  margin-top: 16px; overflow: hidden;
}
.progress-bar .fill {
  height: 100%; background: var(--gold); border-radius: 2px;
  transition: width 0.5s ease;
}

/* ===== Bazi Form ===== */
.resident-card {
  background: #FAF9F7; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 12px;
}
.resident-card .remove-btn {
  float: right; background: none; border: none; color: var(--red); cursor: pointer;
  font-size: 0.85rem; padding: 4px 8px;
}

/* ===== Liunian ===== */
.liunian-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 16px 0;
}
.liunian-cell {
  background: #FAF9F7; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 8px; text-align: center; cursor: pointer; transition: var(--transition);
}
.liunian-cell:hover { border-color: var(--gold); }
.liunian-cell .dir { font-size: 0.85rem; font-weight: 600; color: var(--deep); }
.liunian-cell .star-name { font-size: 0.65rem; color: var(--text-muted); }
.liunian-cell.auspicious .dir { color: var(--green); }
.liunian-cell.inauspicious .dir { color: var(--red); }

/* ===== Full Report ===== */
.report-text {
  white-space: pre-wrap; font-size: 0.9rem; line-height: 1.8; color: var(--text);
  background: #FAF9F7; padding: 20px; border-radius: var(--radius-sm);
  max-height: 60vh; overflow-y: auto;
}

/* ===== Footer ===== */
.footer {
  text-align: center; padding: 20px; font-size: 0.72rem; color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.footer a { color: var(--gold-dark); text-decoration: none; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app { max-width: 100%; }
  .page { padding: 16px 12px; }
  .header h1 { font-size: 1.3rem; }
}
