/* 八字命理分析 - 前端样式 */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: #f4f1ea;
  color: #2b2b2b;
  line-height: 1.6;
}

.topbar {
  background: #6b2c2c;
  color: #f7f0e3;
  padding: 16px 24px;
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 600; }

.container {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 16px;
}

.card {
  background: #fff;
  border: 1px solid #e3dccb;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  border-left: 4px solid #6b2c2c;
  padding-left: 10px;
}

.birth-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}
.birth-form label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: #555;
  gap: 4px;
}
.birth-form input, .birth-form select {
  padding: 8px 10px;
  border: 1px solid #c9c0ab;
  border-radius: 6px;
  font-size: 15px;
  background: #fff;
}
button {
  padding: 9px 26px;
  background: #6b2c2c;
  color: #f7f0e3;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}
button:hover { background: #7d3636; }
button:disabled { background: #aaa; cursor: not-allowed; }

.tip { color: #999; font-size: 12px; margin: 10px 0 0; }

.error-box {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fbeaea;
  border: 1px solid #e0b4b4;
  color: #a02c2c;
  border-radius: 6px;
  font-size: 14px;
}

/* 四柱 */
.pillars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.pillar {
  text-align: center;
  border: 1px solid #e3dccb;
  border-radius: 8px;
  padding: 12px 8px;
  background: #fbf8f1;
}
.pillar .p-label { font-size: 13px; color: #888; margin-bottom: 6px; }
.pillar .gan, .pillar .zhi { font-size: 26px; font-weight: 600; }
.pillar .gan { color: #6b2c2c; }
.pillar .zhi { color: #333; }
.pillar .wx { font-size: 12px; color: #999; }

.chart-meta { margin-top: 14px; font-size: 14px; color: #555; }
.chart-meta span { margin-right: 20px; }

/* 折叠明细 */
details {
  margin-top: 10px;
  border: 1px solid #ece5d4;
  border-radius: 6px;
  padding: 8px 12px;
  background: #fcfaf5;
}
details summary { cursor: pointer; font-size: 14px; color: #6b2c2c; }
pre {
  background: #f0ece2;
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
}

/* 信号/档位标签 */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  margin-right: 6px;
}
.tag-S, .tag-S\+ { background:#dff0d8; color:#2d6a2d; }
.tag-A { background:#d8e8f5; color:#2a5a86; }
.tag-B { background:#fcf3d0; color:#8a6d1a; }
.tag-E, .tag-N { background:#eee; color:#888; }
.tag-severe { background:#f8d7d7; color:#9a2222; }
.tag-normal { background:#fcf3d0; color:#8a6d1a; }

.signal-row {
  padding: 6px 0;
  border-bottom: 1px dashed #ece5d4;
  font-size: 14px;
}

/* 子标题 */
h3.sub {
  font-size: 15px; margin: 20px 0 8px; color: #6b2c2c;
  border-bottom: 1px solid #ece5d4; padding-bottom: 4px;
}

/* 五行力量条 */
.wx-bar-row {
  display: grid;
  grid-template-columns: 40px 1fr 50px;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 14px;
}
.wx-bar-track {
  background: #eee8d8; border-radius: 6px; height: 16px; overflow: hidden;
}
.wx-bar-fill { height: 100%; border-radius: 6px; }
.wx-bar-val { text-align: right; color: #555; }

.pattern-info, #shensha-info { font-size: 14px; margin-top: 10px; }
.pattern-info .big { font-size: 16px; font-weight: 600; color: #6b2c2c; }
.pattern-info div { margin-bottom: 4px; }

.shensha-chip {
  display: inline-block;
  background: #f0e9d6; border: 1px solid #ddd0b2; color: #6b5a2c;
  padding: 2px 10px; border-radius: 12px; font-size: 13px;
  margin: 0 8px 8px 0;
}

#career-events {
  display: flex; flex-wrap: wrap; gap: 8px 6px;
  font-size: 14px; line-height: 1.5;
}

.advice-list { margin: 8px 0 0; padding-left: 22px; font-size: 14px; }
.advice-list li { margin-bottom: 6px; }

.career-big { font-size: 15px; }
.career-big b { color: #6b2c2c; }

.grid-2 {
  display: grid; grid-template-columns: repeat(2,1fr); gap: 6px 20px; font-size: 14px;
}

/* ================= 文字版报告 ================= */
.report-card h2 {
  font-size: 20px;
  border-left: none;
  padding-left: 0;
  text-align: center;
  letter-spacing: 2px;
  color: #6b2c2c;
}
.report-section { margin-bottom: 22px; }
.report-section:last-child { margin-bottom: 4px; }
.report-section h3 {
  font-size: 16px;
  color: #6b2c2c;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #ece5d4;
}
.report-line {
  margin: 0 0 9px;
  font-size: 15px;
  line-height: 1.85;
  text-align: justify;
  color: #333;
}
.report-line:last-child { margin-bottom: 0; }

/* ================= 等待提示 ================= */
.loading-box {
  margin-top: 16px;
  padding: 28px 20px;
  text-align: center;
  background: #fbf8f1;
  border: 1px solid #e3dccb;
  border-radius: 10px;
}
.spinner {
  width: 42px; height: 42px;
  margin: 0 auto 16px;
  border: 4px solid #e3dccb;
  border-top-color: #6b2c2c;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: 16px; font-weight: 600; color: #6b2c2c; margin-bottom: 8px; }
.loading-sub { font-size: 13px; color: #888; line-height: 1.7; }

/* ================= 手机适配（<=600px） ================= */
@media (max-width: 600px) {
  html, body { overflow-x: hidden; }
  body { -webkit-text-size-adjust: 100%; }

  /* 顶栏：安全区 + 紧凑 */
  .topbar {
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  }
  .topbar h1 { font-size: 19px; }

  /* 容器：减小留白 */
  .container {
    margin: 14px auto 28px;
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .card {
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 14px;
  }
  .card h2 { font-size: 17px; margin-bottom: 14px; }
  h3.sub { font-size: 15px; margin: 18px 0 8px; }

  /* 表单：每项占整行，输入框加大触摸区 */
  .birth-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .birth-form label { font-size: 14px; }
  .birth-form input,
  .birth-form select {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    font-size: 16px;           /* >=16px 防止 iOS 自动放大 */
    border-radius: 8px;
  }
  .birth-form button,
  #submit-btn {
    width: 100%;
    min-height: 48px;
    padding: 12px;
    font-size: 16px;
    border-radius: 8px;
    margin-top: 2px;
  }

  /* 四柱：2×2，干支字号适中 */
  .pillars {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .pillar { padding: 14px 8px; border-radius: 10px; }
  .pillar .gan,
  .pillar .zhi { font-size: 28px; line-height: 1.3; }
  .pillar .p-label { font-size: 13px; margin-bottom: 8px; }

  /* 命盘元信息：换行成块，避免挤压 */
  .chart-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
  .chart-meta span { margin: 0; }

  /* 五行条：缩小标签列，保证进度条空间 */
  .wx-bar-row {
    grid-template-columns: 32px 1fr 46px;
    gap: 8px;
    font-size: 13.5px;
  }
  .wx-bar-track { height: 14px; }

  /* 神煞标签：允许换行，不横向溢出 */
  #shensha-info { display: flex; flex-wrap: wrap; gap: 8px; }
  .shensha-chip { margin: 0; font-size: 13px; padding: 5px 12px; }

  /* 十神强度：单列更易读 */
  .grid-2 { grid-template-columns: 1fr; gap: 8px; font-size: 14px; }

  .signal-row { padding: 9px 0; font-size: 14px; line-height: 1.5; }

  .pattern-info, .pattern-info .big { font-size: 15px; }
  .pattern-info .big { display: block; margin-bottom: 6px; }

  .advice-list { font-size: 14px; padding-left: 20px; }

  /* 原始 JSON：横向可滑动但不撑破页面 */
  pre { font-size: 11.5px; padding: 10px; -webkit-overflow-scrolling: touch; }

  details summary { min-height: 32px; padding: 6px 0; }

  /* 文字报告 */
  .report-card h2 { font-size: 19px; letter-spacing: 1px; }
  .report-section h3 { font-size: 15.5px; margin-bottom: 8px; }
  .report-line { font-size: 15px; line-height: 1.8; margin-bottom: 8px; }
}

/* 超窄屏（<=340px，如 iPhone SE 竖屏）进一步压缩 */
@media (max-width: 340px) {
  .pillar .gan, .pillar .zhi { font-size: 25px; }
  .card { padding: 14px; }
}
