/* ============================================================
 * metaphysics-h5 样式 —— 复用 miniprogram Design Token（玫瑰金体系）
 * 主色 #B05B68 / 深 #9A4A57 / 浅粉底 #F5E3E6 / 米金 #F7E8D8
 * 移动优先（375px 基准），微信内 H5
 * ============================================================ */

:root {
  --brand: #B05B68;
  --brand-deep: #9A4A57;
  --brand-pink: #F5E3E6;
  --gold: #F7E8D8;
  --gold-deep: #8A6A4F;
  --bg: #F8F4F2;
  --card: #FFFFFF;
  --border: #EFE4E1;
  --text: #3A2E2B;
  --text-sub: #5F4F4A;
  --text-weak: #9A8C87;
  --text-faint: #C8B8B4;
  --r-14: 14px;
  --r-12: 12px;
  --r-99: 99px;
  --pad-page: 16px;
  --shadow: 0 2px 12px rgba(176, 91, 104, 0.08);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 0 var(--pad-page) 40px; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-14);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title::before {
  content: "";
  width: 4px; height: 16px;
  border-radius: 2px;
  background: var(--brand);
}

/* ---------- 顶部品牌 ---------- */
.brand-header {
  text-align: center;
  padding: 32px 0 24px;
}
.brand-logo {
  width: 52px; height: 52px;
  margin: 0 auto 10px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(176, 91, 104, 0.3);
}
.brand-name { font-size: 20px; font-weight: 700; color: var(--text); }
.brand-slogan { font-size: 13px; color: var(--text-weak); margin-top: 4px; }

/* ---------- 首页双入口卡片 ---------- */
.entry-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

.entry-card {
  display: block;
  background: var(--card);
  border-radius: var(--r-14);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  text-decoration: none;
  color: var(--text);
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease;
}
.entry-card:active { transform: scale(0.98); }

.entry-card.liuyao::after {
  content: "☯";
  position: absolute; right: -8px; top: -16px;
  font-size: 88px; opacity: 0.06; transform: rotate(15deg);
}
.entry-card.bazi::after {
  content: "✦";
  position: absolute; right: 6px; top: -18px;
  font-size: 96px; opacity: 0.06;
}

.entry-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}
.entry-card.liuyao .entry-icon { background: var(--brand-pink); }
.entry-card.bazi .entry-icon { background: var(--gold); }

.entry-title { font-size: 17px; font-weight: 700; }
.entry-desc { font-size: 13px; color: var(--text-sub); margin-top: 4px; }
.entry-tag {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--brand-deep);
  background: var(--brand-pink);
  border-radius: var(--r-99);
  padding: 2px 10px;
}

/* ---------- 顶部返回条 ---------- */
.topbar {
  display: flex; align-items: center;
  padding: 18px 0 6px;
  gap: 8px;
}
.back-btn {
  border: none; background: none;
  font-size: 15px; color: var(--text-sub);
  padding: 4px 8px 4px 0;
  cursor: pointer;
}
.back-btn::before { content: "‹"; font-size: 22px; margin-right: 2px; color: var(--brand); }
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-note { font-size: 12px; color: var(--text-faint); }

/* ---------- 表单 ---------- */
.field-label {
  font-size: 14px; font-weight: 600; color: var(--text);
  margin: 16px 0 10px;
  display: flex; align-items: center; gap: 6px;
}
.field-label:first-child { margin-top: 0; }
.field-label::before {
  content: "";
  width: 3px; height: 13px;
  border-radius: 2px;
  background: var(--brand);
}
.field-label .req { color: var(--brand); font-weight: 700; }

/* 类别宫格（四色低饱和，复用 Design Token 宫格色） */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.cat-item {
  border: 1.5px solid var(--border);
  border-radius: var(--r-12);
  background: var(--card);
  padding: 12px 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.cat-item:active { transform: scale(0.96); }
.cat-item .cat-icon { font-size: 18px; display: block; margin-bottom: 4px; }
.cat-item.selected {
  border-color: var(--brand);
  color: var(--brand-deep);
  background: var(--brand-pink);
  font-weight: 600;
}
.cat-item[data-cat="学习"] .cat-icon { color: #8A7FB8; }
.cat-item[data-cat="考试"] .cat-icon { color: #6E8FA8; }
.cat-item[data-cat="亲子关系"] .cat-icon { color: #7E9A85; }
.cat-item[data-cat="人际关系"] .cat-icon { color: #B05B68; }
.cat-item[data-cat="情绪状态"] .cat-icon { color: #8A6A4F; }
.cat-item[data-cat="习惯与方法"] .cat-icon { color: #9A4A57; }

/* 输入框 */
.input, .textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-12);
  background: var(--card);
  font-size: 15px;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.input:focus, .textarea:focus { border-color: var(--brand); }
.textarea { min-height: 96px; resize: none; line-height: 1.7; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

.input-row { display: flex; gap: 10px; }
.input-row .input { flex: 1; }

/* 下拉选择（年月日） */
.select-row { display: flex; gap: 10px; }
#bazi-hour { flex: 0 0 110px; }
.select-row .input { flex: 1; }
.select {
  flex: 1;
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-12);
  background: var(--card);
  font-size: 15px;
  color: var(--text);
  padding: 12px 10px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239A8C87' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.select:focus { border-color: var(--brand); }
.select:invalid, .select option[value=""] { color: var(--text-faint); }
.select option { color: var(--text); }

.field-hint { font-size: 12px; color: var(--text-weak); margin-top: 6px; line-height: 1.6; }

/* 性别单选 */
.gender-row { display: flex; gap: 10px; }
.gender-opt {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--r-12);
  background: var(--card);
  padding: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.15s;
}
.gender-opt.selected { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-pink); font-weight: 600; }

/* ---------- 主按钮 ---------- */
.btn-primary {
  display: block;
  width: 100%;
  border: none;
  border-radius: var(--r-99);
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px;
  margin-top: 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(176, 91, 104, 0.35);
  transition: transform 0.12s, opacity 0.2s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.55; box-shadow: none; }

.btn-ghost {
  display: block;
  width: 100%;
  border: 1.5px solid var(--brand);
  border-radius: var(--r-99);
  background: var(--card);
  color: var(--brand-deep);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  margin-top: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:active { background: var(--brand-pink); }

/* ---------- 起卦中（动画） ---------- */
.casting-wrap {
  text-align: center;
  padding: 60px 0 40px;
}
.coins {
  display: flex; justify-content: center; align-items: center;
  gap: 18px;
  margin-bottom: 26px;
  min-height: 84px;
  perspective: 800px;
}
.coin {
  width: 72px; height: 72px;
  perspective: 500px;
  filter: drop-shadow(0 6px 10px rgba(90, 70, 40, 0.35));
}
.coin-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.coin.tossing .coin-inner {
  animation: coinToss 0.55s ease-in-out infinite;
}
.coin.settled.head .coin-inner { transform: rotateY(0deg); }
.coin.settled.tail .coin-inner { transform: rotateY(180deg); }
.coin-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 50%;
}
.coin-face.back { transform: rotateY(180deg); }
@keyframes coinToss {
  0% { transform: translateY(0) rotateY(0deg); }
  25% { transform: translateY(-26px) rotateY(140deg); }
  55% { transform: translateY(-8px) rotateY(280deg); }
  75% { transform: translateY(-16px) rotateY(340deg); }
  100% { transform: translateY(0) rotateY(720deg); }
}
.countdown {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  font-size: 30px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(176, 91, 104, 0.35);
}
.casting-text { font-size: 16px; font-weight: 600; color: var(--text); }
.casting-sub { font-size: 13px; color: var(--text-weak); margin-top: 6px; }

/* 卦象展示（起卦结果骨架） */
.hexagram-line {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 18px; margin: 5px 0;
}
.hexagram-line .seg { height: 8px; border-radius: 3px; background: var(--brand-deep); }
.hexagram-line .seg.yang { width: 70px; }
.hexagram-line .seg.yin-a { width: 32px; margin-right: 6px; }
.hexagram-line .seg.yin-b { width: 32px; }
.hexagram-line.dong .seg { background: var(--gold-deep); box-shadow: 0 0 0 2px rgba(138,106,79,0.25); }

/* ---------- 结果页 ---------- */
.result-hero {
  text-align: center;
  background: linear-gradient(160deg, #FBF3F4, #F7E8D8);
  border-radius: var(--r-14);
  padding: 26px 18px 22px;
  margin-bottom: 14px;
  position: relative;
}
.result-kind { font-size: 12px; color: var(--gold-deep); letter-spacing: 2px; margin-bottom: 8px; }
.result-name { font-size: 30px; font-weight: 800; color: var(--brand-deep); letter-spacing: 6px; }
.result-sub { font-size: 13px; color: var(--text-weak); margin-top: 10px; }
.result-hero .hexagram { margin: 16px auto 0; max-width: 140px; }

/* 行动指南 */
.guide-block { margin-top: 4px; }
.guide-head {
  font-size: 14px; font-weight: 700; color: var(--brand-deep);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px;
}
.guide-head::before { content: "✦"; font-size: 15px; }
.guide-text {
  font-size: 15px; color: var(--text);
  white-space: pre-wrap;
  line-height: 1.9;
}

/* 四柱展示 */
.pillars-wrap { margin: 16px auto 0; max-width: 240px; }
.pillars { display: flex; gap: 8px; justify-content: center; }
.pillar {
  flex: 1;
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(176,91,104,0.18);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
}
.pillar-label { font-size: 11px; color: var(--text-weak); margin-bottom: 4px; }
.pillar-gz { font-size: 15px; font-weight: 700; color: var(--brand-deep); letter-spacing: 1px; }

/* 分享按钮区 */
.share-actions { margin-top: 8px; }

/* 免责声明 */
.disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  padding: 18px 10px 8px;
  line-height: 1.7;
}

/* ---------- 分享卡弹层 ---------- */
.share-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
/* hidden 属性必须优先生效：display:flex 会覆盖 hidden 默认样式，导致弹层一进页面就显示且关不掉 */
.share-modal[hidden] { display: none !important; }
.share-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.share-modal-body {
  position: relative;
  background: var(--card);
  border-radius: var(--r-14);
  padding: 22px 20px 18px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.share-modal-title { font-size: 17px; font-weight: 700; color: var(--text); }
.share-modal-tip { font-size: 12px; color: var(--text-weak); margin: 6px 0 14px; }
.share-modal-img {
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  background: var(--bg);
  border: 1px solid var(--border);
}
.share-modal-img img {
  width: 100%;
  height: auto;
  display: block;
}
.share-modal-body .btn-ghost { margin-top: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 80px;
  transform: translateX(-50%);
  background: rgba(58, 46, 43, 0.9);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--r-99);
  z-index: 99;
  max-width: 80vw;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* 错误提示 */
.error-box {
  background: #FBEEEC;
  border: 1px solid #E8C4BE;
  color: #A94438;
  border-radius: var(--r-12);
  padding: 12px 14px;
  font-size: 13px;
  margin: 12px 0;
  line-height: 1.6;
}

/* 加载（API 等待） */
.loading-row {
  text-align: center;
  padding: 24px 0;
  color: var(--text-weak);
  font-size: 13px;
}
.spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 进入动画 */
.view { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
