/* ============ 八字命盘 H5 · 浅色主题 ============ */
:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #2b2620;
  --ink-2: #6b6257;
  --ink-3: #9b9184;
  --line: #ece6dc;
  --brand: #8c4a2f;
  --brand-soft: #f7ede6;
  --gold: #b08a3e;
  --good: #2e7d4f;
  --good-lite: #7aa66b;
  --mid: #b08a3e;
  --bad-lite: #c2703c;
  --bad: #b03a2e;
  --wx-mu: #4a7c46;
  --wx-huo: #c0392b;
  --wx-tu: #a08040;
  --wx-jin: #8a8f98;
  --wx-shui: #3465a4;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 45, 30, .06);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--ink); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif; font-size: 15px; line-height: 1.6; }
.page { max-width: 520px; margin: 0 auto; min-height: 100vh; padding: 0 14px 30px; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 34px 0 18px; }
.hero-logo { width: 58px; height: 58px; margin: 0 auto 10px; border-radius: 16px; background: linear-gradient(135deg, #8c4a2f, #b0713f); color: #fff; font-size: 24px; font-weight: 700; display: flex; align-items: center; justify-content: center; letter-spacing: 2px; box-shadow: var(--shadow); }
.hero h1 { font-size: 22px; letter-spacing: 3px; }
.hero-sub { color: var(--ink-3); font-size: 13px; margin-top: 4px; }

/* ---------- card / form ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow); }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 7px; font-weight: 600; }
.form-row .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
input[type="date"], input[type="time"], select {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; font-size: 16px; color: var(--ink); background: #faf8f4; outline: none;
}
input:focus, select:focus { border-color: var(--brand); background: #fff; }
.form-row-switch { display: flex; align-items: center; justify-content: space-between; }
.form-row-switch label { margin-bottom: 0; flex: 1; }

.seg { display: flex; background: #efe9df; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.seg-btn { flex: 1; height: 38px; border: 0; background: transparent; border-radius: 8px; font-size: 15px; color: var(--ink-2); }
.seg-btn.active { background: #fff; color: var(--brand); font-weight: 700; box-shadow: var(--shadow); }
.seg-sm { margin-bottom: 0; }
.seg-sm .seg-btn { height: 34px; font-size: 14px; }

.city-btn { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #faf8f4; font-size: 15px; color: var(--ink); text-align: left; padding: 0 12px; display: flex; justify-content: space-between; align-items: center; }
.city-btn::after { content: "›"; color: var(--ink-3); font-size: 18px; }

.switch { width: 48px; height: 28px; border-radius: 14px; background: #d8d0c4; position: relative; transition: .2s; flex-shrink: 0; }
.switch .knob { width: 22px; height: 22px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on { background: var(--brand); }
.switch.on .knob { left: 23px; }

.btn-primary { width: 100%; height: 48px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #8c4a2f, #b0713f); color: #fff; font-size: 17px; font-weight: 700; letter-spacing: 4px; margin-top: 6px; box-shadow: 0 4px 12px rgba(140, 74, 47, .25); }
.btn-primary:active { transform: scale(.98); }

.foot-note { text-align: center; color: var(--ink-3); font-size: 12px; padding: 18px 10px 0; }

/* ---------- 结果页 ---------- */
.res-header { display: flex; align-items: center; gap: 10px; padding: 14px 0; position: sticky; top: 0; background: var(--bg); z-index: 20; }
.back-btn { border: 0; background: var(--card); border-radius: 9px; height: 34px; padding: 0 12px; font-size: 15px; color: var(--ink-2); box-shadow: var(--shadow); }
.res-title { font-size: 17px; font-weight: 700; letter-spacing: 2px; }

.section { background: var(--card); border-radius: var(--radius); padding: 16px 15px; margin-bottom: 14px; box-shadow: var(--shadow); }
.section h3 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section h3::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--brand); }

.birth-summary { font-size: 14px; color: var(--ink-2); }
.birth-summary b { color: var(--ink); }
.birth-summary .tag { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 0 8px; font-size: 12px; margin: 2px 3px 2px 0; }

/* 四柱（天干在上、地支在下，上下结构） */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pillar { background: #faf8f4; border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; text-align: center; }
.pillar .p-name { font-size: 12px; color: var(--ink-3); }
.pillar .p-gz { display: flex; flex-direction: column; align-items: center; margin: 4px 0 2px; line-height: 1.2; }
.pillar .p-gz span { display: block; font-size: 27px; font-weight: 700; }
.pillar .p-gz .p-gan { margin-bottom: 2px; }
.pillar .p-ss { font-size: 12px; color: var(--brand); margin-bottom: 6px; min-height: 16px; }
.pillar .p-hide { border-top: 1px dashed var(--line); padding-top: 6px; }
.pillar .hide-line { font-size: 12px; color: var(--ink-2); line-height: 1.9; }
.pillar .hide-line .hide-gan { font-weight: 700; }
.pillar .hide-line .hide-ss { margin-left: 2px; }
.pillar .p-ny { font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.pillar .p-xk { font-size: 11px; color: var(--ink-3); }

/* 喜忌角色色（全篇统一）：用神金 / 喜神绿 / 仇神橙 / 忌神红 */
.cls-yong { color: #9a7425; font-weight: 700; }
.cls-xi { color: #2e7d4f; font-weight: 700; }
.cls-chou { color: #c2703c; font-weight: 700; }
.cls-ji { color: #b03a2e; font-weight: 700; }

/* 角色图例 */
.role-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; padding: 8px 10px; background: #faf8f4; border-radius: 8px; font-size: 12px; color: var(--ink-2); }
.role-legend span { display: inline-flex; align-items: center; gap: 4px; }
.role-legend .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cls-yong-bg { background: #9a7425; }
.cls-xi-bg { background: #2e7d4f; }
.cls-chou-bg { background: #c2703c; }
.cls-ji-bg { background: #b03a2e; }
.wx-neutral { background: #b8b0a3; }

.wx-mu { color: var(--wx-mu); } .wx-huo { color: var(--wx-huo); } .wx-tu { color: var(--wx-tu); } .wx-jin { color: var(--wx-jin); } .wx-shui { color: var(--wx-shui); }

/* 五行条 */
.wx-bars { display: grid; gap: 8px; }
.wx-bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.wx-bar-label { width: 64px; display: flex; align-items: center; gap: 4px; }
.wx-bar-track { flex: 1; height: 14px; background: #f0ebe2; border-radius: 7px; overflow: hidden; }
.wx-bar-fill { height: 100%; border-radius: 7px; transition: width .6s ease; }
.wx-bar-num { width: 40px; text-align: right; color: var(--ink-2); }

/* 十神 chips */
.ss-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ss-chip { background: #faf8f4; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 13px; }
.ss-chip b { color: var(--brand); }
.ss-chip small { color: var(--ink-3); margin-left: 4px; }

/* 喜用忌神 */
.xy-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; align-items: flex-start; }
.xy-row:last-child { border-bottom: 0; }
.xy-tag { flex-shrink: 0; width: 52px; text-align: center; border-radius: 7px; color: #fff; font-size: 13px; padding: 3px 0; margin-top: 2px; }
.xy-yong { background: #9a7425; } .xy-xi { background: #2e7d4f; }
.xy-chou { background: #c2703c; } .xy-ji { background: #b03a2e; }

/* 文本块 */
.text-lines p { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.text-lines p strong { color: var(--ink); }

/* 刑冲合害 */
.rel-item { background: #faf8f4; border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; padding: 8px 10px; margin-bottom: 8px; font-size: 14px; color: var(--ink-2); }
.rel-empty { color: var(--ink-3); font-size: 14px; }

/* 大运 */
.dy-item { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: #fdfcf9; }
.dy-head { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; }
.dy-head .dy-gz { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.dy-head .dy-meta { flex: 1; min-width: 0; }
.dy-head .dy-years { font-size: 12px; color: var(--ink-3); }
.dy-head .dy-age { font-size: 13px; color: var(--ink-2); }
.badge { flex-shrink: 0; border-radius: 7px; color: #fff; font-size: 12px; padding: 3px 9px; }
.badge.good { background: var(--good); } .badge.good-lite { background: var(--good-lite); }
.badge.mid { background: var(--mid); } .badge.bad-lite { background: var(--bad-lite); } .badge.bad { background: var(--bad); }
.dy-detail { display: none; border-top: 1px dashed var(--line); padding: 12px; background: #fff; }
.dy-item.open .dy-detail { display: block; }
.dy-detail .d-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 8px 0 5px; }
.dy-detail .d-title:first-child { margin-top: 0; }
.remind-list li { font-size: 13.5px; color: var(--ink-2); margin-bottom: 5px; list-style: none; padding-left: 14px; position: relative; }
.remind-list li::before { content: "·"; position: absolute; left: 2px; color: var(--gold); font-weight: 700; }

/* 流年 */
.ln-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.ln-item { border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; cursor: pointer; background: #fdfcf9; }
.ln-item.open { grid-column: 1 / -1; }
.ln-top { display: flex; justify-content: space-between; align-items: center; }
.ln-gz { font-weight: 700; font-size: 16px; }
.ln-year { font-size: 12px; color: var(--ink-3); }
.ln-detail { display: none; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.ln-item.open .ln-detail { display: block; }
.ln-detail .ln-line { font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }

/* ---------- 城市弹层 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; }
.modal-mask { position: absolute; inset: 0; background: rgba(30, 25, 18, .45); }
.modal-body { position: absolute; left: 0; right: 0; bottom: 0; top: 12vh; background: var(--card); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--line); }
.modal-close { border: 0; background: #f0ebe2; width: 30px; height: 30px; border-radius: 50%; color: var(--ink-2); }
.search-wrap { padding: 10px 14px; }
#city-search { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 15px; background: #faf8f4; outline: none; }
.city-panel { flex: 1; overflow: hidden; position: relative; }
.city-list { height: 100%; overflow-y: auto; padding: 0 14px 20px; }
.city-letter { font-size: 13px; font-weight: 700; color: var(--brand); padding: 10px 0 4px; }
.city-item { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 15px; cursor: pointer; }
.city-item small { color: var(--ink-3); }
.city-index { position: absolute; right: 4px; top: 6px; bottom: 6px; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.city-index a { font-size: 10px; color: var(--brand); text-decoration: none; padding: 0 5px; }

/* toast */
.toast { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); background: rgba(43, 38, 32, .9); color: #fff; border-radius: 9px; padding: 9px 16px; font-size: 14px; z-index: 200; max-width: 80vw; }

/* ---------- 大运付费解锁 ---------- */
.dy-lock { flex-shrink: 0; border: 1px solid var(--gold); color: var(--gold); border-radius: 7px; font-size: 11px; padding: 2px 8px; background: #f9f3e6; white-space: nowrap; }
.pay-body { top: 6vh; }
.pay-content { padding: 16px; overflow-y: auto; }
.pay-buy { display: block; text-align: center; text-decoration: none; margin-bottom: 6px; }
.pay-buy-note { font-size: 12px; color: var(--gold); text-align: center; margin: 0 0 10px; }
.pay-price { text-align: center; font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.pay-price b { font-size: 30px; color: #b03a2e; margin: 0 3px; }
.pay-price span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.pay-steps { margin: 0 0 10px; padding-left: 18px; }
.pay-steps li { font-size: 13px; color: var(--ink-2); margin-bottom: 5px; line-height: 1.7; }
.pay-query-note { font-size: 12px; color: var(--ink-3); text-align: center; margin: 0 0 14px; line-height: 1.7; }
.pay-query-note a { color: var(--gold); text-decoration: underline; }
.pay-unlock-row { display: flex; gap: 8px; }
.pay-code-input { flex: 1; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 15px; background: #faf8f4; outline: none; letter-spacing: 2px; font-family: inherit; }
.pay-code-input:focus { border-color: var(--gold); }
.pay-unlock-btn { width: auto; padding: 0 22px; margin-top: 0; letter-spacing: 2px; }
.pay-err { font-size: 12px; color: #b03a2e; margin-top: 8px; }

/* ==================== AI 分析板块 ==================== */
.ai-intro { font-size: 13px; color: var(--ink-2); margin: 0 0 12px; line-height: 1.7; }
.ai-prompt-area {
  width: 100%;
  font-size: 12px;
  font-family: "SF Mono", Consolas, "Microsoft YaHei", monospace;
  padding: 10px;
  border: 1px solid #e6e0d4;
  border-radius: 8px;
  background: #faf8f4;
  color: var(--ink-2);
  resize: vertical;
  line-height: 1.65;
  box-sizing: border-box;
  -webkit-user-select: text;
  user-select: text;
  white-space: pre;
}
.ai-actions { margin-top: 10px; display: flex; }
.ai-copy-btn { flex: 1; }
.ai-jump-tip { font-size: 12px; color: var(--ink-3); margin: 18px 0 10px; text-align: center; }
.ai-jump-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ai-jump-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 8px;
  border-radius: 10px;
  text-decoration: none;
  background: #faf8f4;
  border: 1px solid #e6e0d4;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.ai-jump-btn:active { transform: scale(0.97); }
.ai-jump-btn:hover { box-shadow: 0 2px 8px rgba(60,45,30,0.10); }
.ai-jump-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.ai-jump-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.ai-foot { font-size: 11px; color: var(--ink-3); margin: 12px 0 0; line-height: 1.6; }

/* AI 板块未解锁卡片：复用大运流年付费弹层样式（.pay-content）保持视觉一致 */
.ai-pay-card { padding: 16px; }
.ai-pay-card .pay-price span { color: var(--ink-2); }
.ai-pay-card .pay-buy { margin-bottom: 6px; }

@media (min-width: 560px) { .page { padding-top: 10px; } }
