/* ==========================================================================
   紫微斗数 · 排盘与解读  —  样式（东方玄墨主题）
   ========================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  /* 色板：深墨底 + 鎏金点缀 + 朱砂强调 */
  --bg:        #15110c;
  --bg-2:      #1b1610;
  --surface:   #221c13;
  --surface-2: #2a2317;
  --surface-3: #332a1b;
  --border:    #3b3222;
  --border-soft: #2c2519;

  --gold:      #c9a05a;
  --gold-2:    #e6cf97;
  --gold-dim:  #8a6f42;
  --cinnabar:  #c04a34;
  --cinnabar-2:#e07a5f;

  --text:      #ece2cd;
  --text-2:    #c3b697;
  --text-3:    #8f8267;
  --text-inv:  #1c150c;

  --ok:        #7fae6b;
  --warn:      #d9a441;
  --danger:    #c04a34;

  /* 圆角 / 阴影 / 间距 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,.38);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.5);
  --space: 4px;

  /* 字体 */
  --font-display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-body:    "Noto Sans CJK SC", "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono:    "JetBrains Mono", "SFMono-Regular", "Consolas", "Courier New", monospace;

  --sidebar-w: 340px;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  background:
    radial-gradient(1100px 620px at 82% -8%, rgba(201,160,90,.10), transparent 60%),
    radial-gradient(900px 560px at -6% 14%, rgba(192,74,52,.07), transparent 55%),
    radial-gradient(760px 500px at 50% 118%, rgba(201,160,90,.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 细腻噪点纹理 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; }
a { color: var(--gold); text-decoration: none; }
code { font-family: var(--font-mono); font-size: .9em; color: var(--gold-2); }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(21,17,12,.82);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  color: var(--gold);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, var(--surface-3), var(--surface));
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(201,160,90,.08);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-family: var(--font-display); font-size: 17px; letter-spacing: .04em; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .18em; }

.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav a {
  padding: 7px 14px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px;
  transition: color .2s, background .2s;
}
.topnav a:hover { color: var(--gold-2); background: var(--surface-2); }

.topbar-note {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-3);
  padding: 6px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}

/* ---------- 页面布局 ---------- */
.page { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 24px; }
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 24px; align-items: start; }

/* ---------- 首屏导语 ---------- */
.hero { padding: 40px 4px 32px; }
.hero-kicker {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--gold);
  margin-bottom: 16px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(201,160,90,.06);
}
.hero-title {
  font-size: 44px;
  line-height: 1.15;
  letter-spacing: .02em;
  margin-bottom: 18px;
}
.hero-title-accent {
  margin-left: 14px;
  background: linear-gradient(100deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead { max-width: 640px; color: var(--text-2); font-size: 16px; margin: 0 0 20px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-size: 12px; color: var(--text-2);
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

/* ---------- 面板 ---------- */
.panel {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-icon {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--gold);
  background: rgba(201,160,90,.08);
  border: 1px solid var(--border);
}
.panel-title { font-size: 17px; letter-spacing: .04em; }
.panel-meta { margin-left: auto; font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }

/* ---------- 表单 ---------- */
.form-panel { position: sticky; top: 84px; }
.form-panel .panel-head { margin-bottom: 0; }
#paipan-form { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field[hidden] { display: none; }
.field-label { font-size: 13px; color: var(--text-2); letter-spacing: .02em; }

.input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(201,160,90,.14); }

/* 日历/时间控件图标跟随主题 */
input[type="date"], input[type="time"] { color-scheme: dark; }

.select-wrap { position: relative; }
.select-wrap .input { appearance: none; padding-right: 34px; }
.select-caret {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-3);
}

/* 分段控件 */
.seg { display: grid; grid-auto-flow: column; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.seg-btn {
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-2);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { color: var(--text-inv); background: var(--gold); font-weight: 600; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-family: var(--font-body);
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform .15s, background .2s, box-shadow .2s, opacity .2s;
}
.btn-primary {
  color: var(--text-inv);
  background: linear-gradient(160deg, var(--gold-2), var(--gold));
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255,255,255,.14);
}
.btn-primary:hover { background: linear-gradient(160deg, #f0dcae, #d8b26a); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.form-footnote {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12px; color: var(--text-3);
  line-height: 1.6;
  padding-top: 4px;
  border-top: 1px dashed var(--border-soft);
}
.form-footnote svg { flex: none; margin-top: 2px; color: var(--warn); }

/* ---------- 命盘网格 ---------- */
.chart-panel { margin-bottom: 24px; }

#chart-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(128px, auto);
  gap: 6px;
  padding: 20px;
}

.palace {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  min-width: 0;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.palace:hover {
  border-color: var(--gold-dim);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.palace.is-ming { border-color: var(--gold-dim); background: linear-gradient(160deg, rgba(201,160,90,.10), var(--surface-2)); }
.palace.is-shen { box-shadow: inset 0 0 0 1px var(--cinnabar); }

.palace-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.palace-name { font-family: var(--font-display); font-size: 14px; color: var(--gold-2); letter-spacing: .06em; }
.palace-zhi { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }

.palace-ganzhi { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); margin: 2px 0 6px; }

.palace-stars { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.star {
  font-size: 12px;
  line-height: 1.4;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.star.is-main { color: var(--gold-2); border-color: var(--gold-dim); background: rgba(201,160,90,.08); }
.star.is-aux { font-size: 11px; color: var(--text-2); }
.star-bright { font-size: 10px; color: var(--text-3); margin-left: 2px; }
.star.is-si { color: var(--cinnabar-2); border-color: var(--cinnabar); background: rgba(192,74,52,.12); }

.palace-daxian { margin-top: 6px; font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); }

/* 中心信息 */
.chart-center {
  grid-row: 2 / 4;
  grid-column: 2 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background:
    radial-gradient(180px 180px at 50% 42%, rgba(201,160,90,.14), transparent 70%),
    var(--surface);
}
.chart-center .taiji {
  width: 34px; height: 34px;
  color: var(--gold);
  margin-bottom: 2px;
}
.chart-center .c-label { font-size: 11px; color: var(--text-3); letter-spacing: .1em; }
.chart-center .c-value { font-family: var(--font-display); font-size: 15px; color: var(--text); }
.chart-center .c-strong { font-size: 20px; color: var(--gold-2); }
.chart-center .c-row { display: flex; flex-direction: column; align-items: center; }
.chart-center .c-divider { width: 40px; height: 1px; background: var(--border); margin: 2px 0; }

/* 口径说明 */
.warnings { padding: 0 20px 18px; display: flex; flex-direction: column; gap: 8px; }
.warning-item {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12.5px; color: var(--text-2);
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--warn);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.warning-item svg { flex: none; margin-top: 2px; color: var(--warn); }

/* ---------- 加载骨架 ---------- */
.skeleton { padding: 20px; }
.skeleton-grid {
  height: 360px;
  border-radius: var(--r-md);
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface-3) 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 解读 ---------- */
.analysis-panel { margin-bottom: 24px; }
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; border-bottom: 1px solid var(--border-soft); overflow-x: auto; }
.tab {
  padding: 9px 15px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-2);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s, border-color .2s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--gold-2); border-bottom-color: var(--gold); }

.analysis-body { padding: 20px; }

/* 总论 */
.summary-block h3 { font-size: 16px; color: var(--gold-2); margin-bottom: 12px; }
.summary-block p { color: var(--text-2); margin: 0 0 12px; }
.dim-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; padding: 0; list-style: none; }
.dim-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.dim-card .dim-title { font-size: 13px; color: var(--text-3); letter-spacing: .08em; margin-bottom: 6px; }
.dim-card ul { margin: 0; padding-left: 16px; color: var(--text-2); font-size: 13.5px; }
.dim-card li { margin: 3px 0; }
.dim-card.is-strength .dim-title { color: var(--ok); }
.dim-card.is-challenge .dim-title { color: var(--cinnabar-2); }

/* 六宫卡片 */
.palace-list { display: flex; flex-direction: column; gap: 12px; }
.palace-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.palace-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.palace-card-name { font-family: var(--font-display); font-size: 15px; color: var(--gold-2); }
.palace-card-stars { font-size: 12px; color: var(--text-3); }
.palace-card p { margin: 0; color: var(--text-2); font-size: 14px; }

/* 四化 */
.sihua-list { display: flex; flex-direction: column; gap: 12px; }
.sihua-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.sihua-name { font-family: var(--font-display); font-size: 15px; color: var(--gold-2); }
.sihua-pos { grid-column: 2; font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.sihua-text { grid-column: 1 / 3; color: var(--text-2); font-size: 13.5px; margin-top: 6px; }
.sihua-badge {
  justify-self: start;
  align-self: start;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text-inv);
}
.sihua-badge.lu  { background: var(--ok); }
.sihua-badge.quan{ background: var(--gold); }
.sihua-badge.ke  { background: #4a86c8; }
.sihua-badge.ji  { background: var(--cinnabar); }

/* 大限流年 */
.horo-list { display: flex; flex-direction: column; gap: 12px; }
.horo-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.horo-card-head { font-family: var(--font-display); font-size: 15px; color: var(--gold-2); margin-bottom: 8px; }
.horo-card p { margin: 0; color: var(--text-2); font-size: 14px; }
.horo-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.horo-meta .m { font-size: 12px; color: var(--text-3); }
.horo-meta .m b { color: var(--text); font-weight: 600; }

/* ---------- 页脚 ---------- */
.footer { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 24px; }
.footer p {
  margin: 0;
  padding: 16px 20px;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
  border-top: 1px solid var(--border-soft);
}

.anchor { height: 1px; }

/* ---------- 进入动画 ---------- */
.reveal { opacity: 0; animation: fadeUp .6s cubic-bezier(.2,.7,.3,1) forwards; }
.reveal:nth-of-type(1) { animation-delay: .02s; }
.reveal:nth-of-type(2) { animation-delay: .08s; }
.reveal:nth-of-type(3) { animation-delay: .14s; }
.reveal:nth-of-type(4) { animation-delay: .2s; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .dim-list { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .topbar-inner { flex-wrap: wrap; gap: 12px; }
  .topnav { order: 3; width: 100%; justify-content: stretch; }
  .topnav a { flex: 1; text-align: center; }
  .topbar-note { display: none; }
  .hero-title { font-size: 32px; }
  .hero-title-accent { margin-left: 8px; display: inline-block; }
  #chart-grid { padding: 10px; gap: 4px; grid-auto-rows: minmax(110px, auto); }
  .palace { padding: 7px 8px; }
  .palace-name { font-size: 12px; }
  .star { font-size: 10.5px; padding: 1px 5px; }
  .sihua-item { grid-template-columns: 1fr; }
  .sihua-pos { grid-column: 1; }
  .sihua-text { grid-column: 1; }
}

@media (max-width: 480px) {
  .page { padding: 16px; }
  .hero { padding: 24px 4px; }
  #chart-grid { grid-template-columns: repeat(4, minmax(74px, 1fr)); overflow-x: auto; }
  .chart-center .c-strong { font-size: 17px; }
}

/* ---------- 术数体系切换 ---------- */
.module-switch {
  display: flex;
  gap: 6px;
  justify-content: center;
  width: fit-content;
  margin: 4px auto 12px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  box-shadow: var(--shadow-sm);
}
.module-btn {
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .04em;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.module-btn:hover { color: var(--text); }
.module-btn.is-active {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: var(--text-inv);
}
.module[hidden] { display: none; }

/* ---------- 奇门遁甲：九宫盘 ---------- */
.qimen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 540px;
  margin: 0 auto;
}
.qimen-cell {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  padding: 12px 10px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.qimen-cell.is-empty { background: transparent; border-style: dashed; opacity: .35; }
.qimen-cell.is-center { border-color: var(--gold-dim); }
.qg-head { display: flex; justify-content: space-between; align-items: baseline; }
.qg-gong { font-family: var(--font-display); color: var(--gold-2); font-size: 19px; line-height: 1; }
.qg-fang { font-size: 11px; color: var(--text-3); }
.qg-gan { display: flex; gap: 6px; align-items: center; }
.qg-tian, .qg-dipan {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
}
.qg-tian { background: var(--cinnabar); color: #fff; }
.qg-dipan { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.qg-line1 { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.qg-line2 { font-size: 11px; color: var(--gold-dim); }

/* ---------- 奇门 / 八字 解读块 ---------- */
.qimen-block, .bazi-block {
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--gold-dim);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg-2);
}
.qimen-block:last-child, .bazi-block:last-child { margin-bottom: 0; }
.qimen-block-title, .bazi-block-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  color: var(--gold-2);
  font-size: 15px;
}
.qimen-block-text, .bazi-block-text { margin: 0; color: var(--text-2); }

/* ---------- 四柱八字 ---------- */
.bazi-table {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.bazi-pillar {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  padding: 12px 8px;
  text-align: center;
}
.bazi-pillar.is-day { border-color: var(--gold); }
.bp-name { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.bp-gan { font-family: var(--font-display); font-size: 30px; color: var(--gold-2); line-height: 1.2; }
.bp-zhi { font-family: var(--font-display); font-size: 20px; color: var(--text); margin: 2px 0 8px; }
.bp-canggan { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); margin-bottom: 6px; }
.bp-shishen { font-size: 12px; color: var(--cinnabar-2); }

.bazi-wuxing { border-top: 1px solid var(--border-soft); padding-top: 14px; }
.wx-title { font-family: var(--font-display); color: var(--gold-2); font-size: 14px; margin-bottom: 10px; }
.wx-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wx-name { width: 20px; font-family: var(--font-display); color: var(--text); }
.wx-bar { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.wx-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 999px; }
.wx-val { width: 64px; text-align: right; font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }

.bazi-dayun { }
.dayun-head { font-family: var(--font-display); color: var(--gold-2); font-size: 14px; margin-bottom: 12px; }
.dayun-list { display: flex; flex-wrap: wrap; gap: 8px; }
.dayun-item {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  text-align: center;
  background: var(--bg-2);
  min-width: 86px;
}
.dy-ganzhi { display: block; font-family: var(--font-display); color: var(--gold-2); font-size: 16px; }
.dy-range { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.dayun-item.is-child { border-style: dashed; opacity: .7; }

/* 未触发解读时的占位提示 */
.hint-text { margin: 0; padding: 18px 0; color: var(--text-3); font-size: 14px; line-height: 1.7; }

/* 白话文解释 */
.baihua-block {
  border: 1px solid var(--gold-dim);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  padding: 16px 18px;
  margin-bottom: 18px;
}
.baihua-title {
  font-family: var(--font-display);
  color: var(--gold-2);
  font-size: 14px;
  margin-bottom: 8px;
}
.baihua-text { margin: 0; color: var(--text); font-size: 15px; line-height: 1.9; }

/* 历史记录 */
.history-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-md);
  border: 1px solid var(--gold-dim);
  background: transparent; color: var(--gold-2);
  font-size: 13px; cursor: pointer; transition: .2s;
  white-space: nowrap;
}
.history-btn:hover { background: rgba(212,175,110,.1); border-color: var(--gold); }

.history-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
.history-modal[hidden] { display: none; }
.history-backdrop { position: absolute; inset: 0; background: rgba(8,8,12,.72); backdrop-filter: blur(2px); }
.history-panel {
  position: relative; width: min(640px, 100%); max-height: 76vh;
  background: var(--surface); border: 1px solid var(--gold-dim);
  border-radius: var(--r-md); padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.history-head { display: flex; align-items: center; justify-content: space-between; }
.history-title { font-family: var(--font-display); color: var(--gold-2); font-size: 18px; margin: 0; }
.history-close { border: none; background: transparent; color: var(--text-3); cursor: pointer; padding: 4px; border-radius: 6px; line-height: 1; }
.history-close:hover { color: var(--text); }
.history-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--gold-dim); border-radius: var(--r-md);
  background: var(--bg-2); cursor: pointer; transition: .15s;
}
.history-item:hover { border-color: var(--gold); }
.hi-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.hi-name { font-family: var(--font-display); color: var(--text); font-size: 15px; }
.hi-module { font-size: 12px; color: var(--gold-2); padding: 1px 8px; border: 1px solid var(--gold-dim); border-radius: 999px; }
.hi-summary { font-size: 12px; color: var(--text-3); }
.hi-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hi-date { font-size: 12px; color: var(--text-3); }
.hi-del { border: none; background: transparent; color: var(--text-3); font-size: 12px; cursor: pointer; padding: 2px 4px; }
.hi-del:hover { color: #e0a080; }

@media (max-width: 640px) {
  .bazi-table { grid-template-columns: repeat(2, 1fr); }
  .qimen-grid { gap: 6px; }
  .qimen-cell { min-height: 96px; padding: 8px 6px; gap: 5px; }
  .qg-gong { font-size: 16px; }
  .qg-tian, .qg-dipan { width: 22px; height: 22px; font-size: 11px; }
}

/* ---------- AI 生成中 / 原始文本 ---------- */
.analyzing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  text-align: center;
}
.analyzing-spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.analyzing-text { font-family: var(--font-display); color: var(--gold-2); font-size: 16px; letter-spacing: .04em; }
.analyzing-count { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }
.raw-text { color: var(--text-2); line-height: 1.9; white-space: normal; }

/* ---------- 婚姻合婚 ---------- */
#hunyin-form { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.party-group {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border: 1px solid var(--border-soft); border-radius: var(--r-md);
  background: var(--bg-2);
}
.party-title {
  font-family: var(--font-display); font-size: 14px; color: var(--gold-2);
  letter-spacing: .06em; padding-bottom: 8px; border-bottom: 1px dashed var(--border-soft);
}

.hunyin-score { padding: 20px 20px 8px; text-align: center; }
.hy-score-main { display: flex; align-items: baseline; justify-content: center; gap: 14px; }
.hy-score-num {
  font-family: var(--font-display); font-size: 64px; line-height: 1;
  background: linear-gradient(100deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hy-score-level { font-family: var(--font-display); font-size: 22px; color: var(--gold-2); }
.hy-score-summary { margin: 12px auto 4px; max-width: 520px; color: var(--text-2); font-size: 14px; }
.hy-score-desc { color: var(--text-3); font-size: 13px; margin-bottom: 8px; }

.hunyin-zodiac { padding: 4px 20px 16px; }
.hy-zodiac {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  border: 1px solid var(--gold-dim); border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  padding: 14px 16px;
}
.hz-label { font-size: 12px; color: var(--text-3); letter-spacing: .08em; }
.hz-pair { font-family: var(--font-display); font-size: 20px; color: var(--gold-2); }
.hz-rel {
  font-size: 12px; color: var(--text-inv); background: var(--gold);
  padding: 2px 10px; border-radius: 999px; font-weight: 600;
}
.hz-text { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--text-2); }

.hunyin-dims { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.hy-dim {
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  background: var(--bg-2); padding: 12px 14px;
}
.hy-dim-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.hy-dim-name { font-family: var(--font-display); color: var(--gold-2); font-size: 14px; }
.hy-dim-weight { font-size: 11px; color: var(--text-3); }
.hy-dim-score { margin-left: auto; font-family: var(--font-mono); font-size: 15px; color: var(--text); }
.hy-dim-bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.hy-dim-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 999px; }
.hy-dim-text { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.7; }

.hunyin-bazis { padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.hy-party { }
.hy-party-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.hy-party-name { font-family: var(--font-display); font-size: 16px; color: var(--gold-2); }
.hy-party-meta { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }

.hunyin-points { padding: 16px 20px 0; display: flex; flex-direction: column; gap: 12px; }
.hy-points { display: flex; flex-direction: column; gap: 8px; }
.hy-points-title { font-family: var(--font-display); font-size: 14px; color: var(--ok); }
.hy-points-title.is-warn { color: var(--cinnabar-2); }
.hy-point {
  font-size: 13px; color: var(--text-2); line-height: 1.7;
  padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-soft); background: var(--bg-2);
}
.hy-point.is-good { border-left: 3px solid var(--ok); }
.hy-point.is-warn { border-left: 3px solid var(--cinnabar); }

.hunyin-block {
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--gold-dim);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg-2);
}
.hunyin-block:last-child { margin-bottom: 0; }
.hunyin-block-title {
  margin: 0 0 6px; font-family: var(--font-display);
  color: var(--gold-2); font-size: 15px;
}
.hunyin-block-text { margin: 0; color: var(--text-2); }

/* ---------- 生肖配对 / 桃花运势 ---------- */
#shengxiao-form, #taohua-form, #qimen-form, #bazi-form, #tarot-form { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.shengxiao-result { padding: 24px; text-align: center; }
.sx-score-main { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; }
.sx-pair { font-family: var(--font-display); font-size: 24px; color: var(--gold-2); }
.sx-score-num {
  font-family: var(--font-display); font-size: 56px; line-height: 1;
  background: linear-gradient(100deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sx-level { font-family: var(--font-display); font-size: 18px; color: var(--gold-2); }
.sx-relation {
  display: inline-block; font-size: 13px; color: var(--text-inv); background: var(--gold);
  padding: 3px 12px; border-radius: 999px; font-weight: 600; margin-bottom: 12px;
}
.sx-text { margin: 0 auto 8px; max-width: 460px; color: var(--text-2); font-size: 14px; line-height: 1.8; }
.sx-desc { margin: 0; color: var(--text-3); font-size: 13px; }

.taohua-result { padding: 24px; }
.th-summary { margin: 0 0 18px; color: var(--text-2); font-size: 14px; line-height: 1.8; text-align: center; }
.th-cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.th-card {
  flex: 1 1 140px; min-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1px solid var(--gold-dim); border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--surface), var(--bg-2)); padding: 18px 14px;
}
.th-card-name { font-size: 12px; color: var(--text-3); letter-spacing: .08em; }
.th-card-zhi { font-family: var(--font-display); font-size: 28px; color: var(--gold-2); }
.th-card-zhi2 { font-family: var(--font-mono); font-size: 14px; color: var(--text-2); }

/* 塔罗牌卡 */
.tarot-card.is-major { border-color: var(--gold-2); box-shadow: 0 0 0 1px var(--gold-dim) inset; }
.tarot-card.is-reversed { border-color: var(--gold-dim); }
.tarot-card-title { font-family: var(--font-display); font-size: 22px; color: var(--text-1); }
.tarot-card-line { padding: 10px 0; border-bottom: 1px dashed var(--gold-dim); }
.tarot-card-line:last-child { border-bottom: none; }
.tarot-card-line strong { color: var(--text-1); font-size: 14px; }
.tarot-card-line .hunyin-block-text { margin-top: 4px; }

/* ==========================================================================
   H5 移动端适配（优先编辑现有样式，不新增页面）
   - 安全区（刘海/灵动岛/底部手势条）
   - 大触控目标（>= 44px）
   - 模块切换横向滚动
   - 字号/间距收紧
   ========================================================================== */

/* 安全区：给 body 留底部手势条空间 */
body { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* 顶部条安全区（在原有 12px 基础上叠加 safe-area） */
.topbar-inner {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
}
@media (max-width: 768px) {
  .topbar-inner { gap: 12px; padding-left: calc(16px + env(safe-area-inset-left, 0px)); padding-right: calc(16px + env(safe-area-inset-right, 0px)); }
}

/* 模块切换条：7 个按钮，手机上横向滚动，不换行 */
@media (max-width: 768px) {
  .module-switch {
    width: auto;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 6px 12px;
    margin: 0 -12px 12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .module-switch::-webkit-scrollbar { display: none; }
  .module-btn {
    flex: 0 0 auto;
    padding: 8px 16px;
    font-size: 14px;
    white-space: nowrap;
  }
}

/* 触控目标：表单输入/按钮最小 44px，方便手指点 */
@media (max-width: 768px) {
  .input, .select-wrap select, .seg-btn, .btn {
    min-height: 44px;
    font-size: 16px; /* 避免 iOS 聚焦时自动放大 */
  }
  .btn { min-width: 44px; }
  .field-label { font-size: 13px; }
  textarea.input { min-height: 88px; }
}

/* 字号 / 间距收紧 */
@media (max-width: 768px) {
  body { font-size: 14px; }
  .page { padding: 14px 12px 24px; }
  .panel-title { font-size: 16px; }
  .panel-head { padding: 12px 14px; gap: 8px; }
  .panel-icon { width: 28px; height: 28px; }
  .layout { gap: 12px; }
  /* 表单内边距（panel 本身无 padding，内边距来自表单与 panel-head） */
  #paipan-form, #hunyin-form, #shengxiao-form, #taohua-form,
  #qimen-form, #bazi-form, #tarot-form { padding: 14px; gap: 12px; }
  .analysis-body { padding: 14px; }
  .tabs { padding: 10px 14px 0; }
  .tab { min-height: 44px; padding: 10px 12px; }
  .hero { padding: 18px 4px 14px; }
  .hero-title { font-size: 28px; }
  .brand-title { font-size: 17px; }
  .brand-sub { font-size: 11px; }
  .history-btn { padding: 6px 12px; min-height: 36px; font-size: 13px; }
}

/* 紫微命盘：手机上保持可读，允许横滑 */
@media (max-width: 768px) {
  #chart-grid {
    grid-template-columns: repeat(4, minmax(68px, 1fr));
    gap: 3px;
    padding: 6px;
  }
  .palace { padding: 5px 4px; }
  .palace-name { font-size: 11px; }
  .palace-zhi { font-size: 10px; }
  .palace-ganzhi { font-size: 10px; }
  .star { font-size: 10px; padding: 1px 3px; }
  .palace-daxian { font-size: 9px; }
  .chart-center .c-strong { font-size: 15px; }
}

/* 八字 / 奇门 / 合婚 表格与卡片 */
@media (max-width: 640px) {
  .bazi-table { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .qimen-grid { gap: 6px; max-width: 100%; }
  .qimen-cell { min-height: 90px; padding: 8px 6px; }
  .qg-gong { font-size: 15px; }
  .qg-tian, .qg-dipan { width: 22px; height: 22px; font-size: 11px; }
  .th-cards { gap: 8px; }
  .th-card { flex: 1 1 100px; min-width: 90px; padding: 12px 8px; }
  .th-card-zhi { font-size: 22px; }
  .tarot-card-title { font-size: 18px; }
}

/* 历史记录弹层：手机上全屏 */
@media (max-width: 640px) {
  .history-modal { padding: 0; align-items: stretch; }
  .history-panel {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
    padding: calc(16px + env(safe-area-inset-top, 0px))
             calc(16px + env(safe-area-inset-right, 0px))
             calc(16px + env(safe-area-inset-bottom, 0px))
             calc(16px + env(safe-area-inset-left, 0px));
  }
  .history-close { padding: 10px; } /* 放大关闭按钮热区 */
  .history-list { -webkit-overflow-scrolling: touch; }
}

/* 底部安全区补偿：主要按钮/解读区 */
@media (max-width: 480px) {
  .btn-primary { min-height: 48px; font-size: 16px; }
  .hunyin-block, .qimen-block, .bazi-block { padding: 12px; }
  .hunyin-block-title, .qimen-block-title, .bazi-block-title { font-size: 14px; }
  .shengxiao-result, .taohua-result { padding: 16px; }
  .analyzing { padding: 32px 16px; }
  .footer { padding: 16px 12px; font-size: 12px; }
}
