/* ==========================================================
   知命 · 设计系统与全部页面样式
   现代高级 UI × 东方水墨意境
   色彩：墨黑 / 深灰 / 米白 / 宣纸色 / 极少量暖金
   动画：水墨晕染式淡入、轻微位移，克制不夸张
   ========================================================== */

:root {
  /* Color Tokens */
  --paper:     #f4f0e6;   /* 宣纸底 */
  --card:      #fbf8f1;   /* 卡片 */
  --ink:       #2a2721;   /* 主文字 · 墨黑 */
  --ink-soft:  #6f6a5c;   /* 次级文字 · 深灰 */
  --ink-faint: #a39d8c;   /* 弱文字 · 淡灰 */
  --line:      #e2dccb;   /* 分隔线 */
  --gold:      #a08a5f;   /* 暖金（极少量强调） */
  --gold-soft: #ede6d3;   /* 暖金浅底 */

  /* 五行（低饱和） */
  --wx-mu:   #5a7d5f;
  --wx-huo:  #a85643;
  --wx-tu:   #9c7c3c;
  --wx-jin:  #8a8375;
  --wx-shui: #4a6b85;

  /* Spacing / Radius */
  --sp-1: 6px; --sp-2: 12px; --sp-3: 18px; --sp-4: 26px;
  --radius: 14px;
  --shadow: 0 1px 8px rgba(58, 52, 38, 0.06);

  /* Font */
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ==========================================================
   水墨背景层
   ========================================================== */
.ink-bg {
  position: fixed; inset: 0;
  z-index: -1; overflow: hidden;
  pointer-events: none;
}
.ink-blob {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: 0.5;
}
.ink-blob.b1 {
  width: 55vmax; height: 55vmax; top: -18vmax; left: -12vmax;
  background: radial-gradient(closest-side, rgba(74, 70, 60, 0.16), transparent 70%);
  animation: drift1 70s ease-in-out infinite alternate;
}
.ink-blob.b2 {
  width: 48vmax; height: 48vmax; bottom: -16vmax; right: -14vmax;
  background: radial-gradient(closest-side, rgba(110, 100, 80, 0.12), transparent 70%);
  animation: drift2 90s ease-in-out infinite alternate;
}
.ink-blob.b3 {
  width: 34vmax; height: 34vmax; top: 38%; left: 55%;
  background: radial-gradient(closest-side, rgba(90, 84, 68, 0.08), transparent 70%);
  animation: drift1 110s ease-in-out infinite alternate-reverse;
}
@keyframes drift1 { to { transform: translate(6vmax, 4vmax) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-5vmax, -3vmax) scale(1.08); } }
.mist {
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(244, 240, 230, 0.65) 50%, transparent 70%);
  background-size: 260% 100%;
  animation: mist 36s linear infinite;
  opacity: 0.5;
}
@keyframes mist { from { background-position: 130% 0; } to { background-position: -130% 0; } }

/* ==========================================================
   应用骨架 / 视图切换
   ========================================================== */
.app {
  max-width: 680px; margin: 0 auto;
  padding: 22px 18px 96px;
}

.view { display: none; }
.view.active { display: block; animation: viewIn 0.65s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* 内容渐进浮现（水墨晕染式） */
.view.active.stagger > * { opacity: 0; animation: rise 0.6s ease forwards; }
.view.active.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.view.active.stagger > *:nth-child(2) { animation-delay: 0.12s; }
.view.active.stagger > *:nth-child(3) { animation-delay: 0.19s; }
.view.active.stagger > *:nth-child(4) { animation-delay: 0.26s; }
.view.active.stagger > *:nth-child(5) { animation-delay: 0.33s; }
.view.active.stagger > *:nth-child(6) { animation-delay: 0.40s; }
.view.active.stagger > *:nth-child(7) { animation-delay: 0.47s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================
   页头
   ========================================================== */
.page-head { margin: 6px 2px 20px; }
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.brand-seal {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink); color: var(--card);
  font-family: var(--font-serif); font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.page-title {
  font-family: var(--font-serif); font-weight: 600;
  font-size: 24px; letter-spacing: 6px;
}
.page-title.small { font-size: 21px; letter-spacing: 4px; }
.page-sub {
  color: var(--ink-soft); font-size: 12.5px;
  letter-spacing: 2.5px; margin-top: 4px;
}

/* ==========================================================
   知命 · 首页
   ========================================================== */
.hero {
  background: linear-gradient(180deg, var(--card), rgba(251, 248, 241, 0.55));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 10px; margin-bottom: var(--sp-3);
  box-shadow: var(--shadow);
}
.hero-label {
  font-family: var(--font-serif); font-size: 13.5px;
  letter-spacing: 3px; color: var(--ink);
  display: flex; justify-content: space-between; align-items: baseline;
}
.hero-note { font-size: 10.5px; color: var(--ink-faint); letter-spacing: 1px; }
.trend-svg { width: 100%; height: 108px; display: block; margin-top: 4px; }
.mt-far  { fill: rgba(74, 70, 58, 0.07); }
.mt-near { fill: rgba(74, 70, 58, 0.12); }
#trend-line {
  fill: none; stroke: var(--gold); stroke-width: 1.7;
  stroke-linecap: round;
  stroke-dasharray: 420; stroke-dashoffset: 420;
  animation: draw 2.8s ease-out 0.5s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
.trend-dot { fill: var(--gold); opacity: 0; animation: dotIn 0.8s ease 3.1s forwards; }
@keyframes dotIn { to { opacity: 1; } }
.hero-years {
  display: flex; justify-content: space-between;
  padding: 2px 6px 6px;
  color: var(--ink-faint); font-size: 10.5px; letter-spacing: 2px;
  font-family: var(--font-serif);
}

.cta {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: var(--ink); color: var(--card);
  border: none; border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: var(--sp-3);
  cursor: pointer; transition: opacity 0.25s;
  font-family: var(--font-sans); text-align: left;
}
.cta:hover { opacity: 0.92; }
.cta-text { display: flex; flex-direction: column; gap: 2px; }
.cta-title { font-family: var(--font-serif); font-size: 16.5px; letter-spacing: 4px; }
.cta-sub { font-size: 11.5px; color: rgba(251, 248, 241, 0.65); letter-spacing: 1px; }
.cta-arrow { font-size: 18px; color: var(--gold); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.mini:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(58, 52, 38, 0.09); }
.mini-k { font-size: 11px; color: var(--gold); letter-spacing: 2.5px; margin-bottom: 5px; }
.mini-v { font-family: var(--font-serif); font-size: 15.5px; letter-spacing: 1px; }
.mini-s { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }

.foot-note {
  text-align: center; color: var(--ink-faint);
  font-size: 10.5px; letter-spacing: 2px; margin-top: 26px;
}

/* ==========================================================
   卡片（通用，排盘与各页共用）
   ========================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-top: var(--sp-2);
  box-shadow: var(--shadow);
}
.card-title {
  font-family: var(--font-serif);
  font-size: 15px; letter-spacing: 3px;
  padding-left: 10px; margin-bottom: 12px;
  border-left: 2px solid var(--gold);
}
.card-sub { font-size: 12px; color: var(--ink-soft); margin-bottom: 16px; }

/* ==========================================================
   排盘表单
   ========================================================== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: 1px; }
.field input, .field select {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 15px; color: var(--ink);
  outline: none; transition: border-color 0.15s;
}
.field input:focus, .field select:focus { border-color: var(--gold); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.hint { font-size: 11px; color: var(--ink-faint); margin-top: 5px; }

.gender-toggle { display: flex; gap: 10px; }
.gender-toggle input { display: none; }
.radio-pill span {
  display: inline-block; padding: 8px 26px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 14px; color: var(--ink-soft); cursor: pointer;
  transition: all 0.15s;
}
.radio-pill input:checked + span {
  background: var(--ink); border-color: var(--ink); color: var(--card);
}

.btn-primary {
  width: 100%; padding: 13px; margin-top: 6px;
  background: var(--ink); color: var(--card);
  border: none; border-radius: 10px;
  font-size: 15px; letter-spacing: 6px; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }

/* ==========================================================
   排盘结果
   ========================================================== */
.basic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.basic-grid .item { font-size: 14px; }
.basic-grid .k { color: var(--ink-soft); margin-right: 6px; }
.calc-note {
  margin-top: 12px; padding: 10px 12px;
  background: var(--gold-soft); border-radius: 8px;
  font-size: 12px; color: #7a6844; line-height: 1.7;
}

.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pillar {
  background: linear-gradient(180deg, #fff, #f8f4ea);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 4px; text-align: center;
}
.pillar .pillar-name {
  font-size: 11.5px; color: var(--ink-soft); margin-bottom: 8px; letter-spacing: 2px;
}
.pillar .pillar-name.day { color: var(--gold); font-weight: 600; }
.pillar .gan, .pillar .zhi {
  font-size: 30px; font-weight: 700;
  font-family: var(--font-serif);
  display: block; line-height: 1.35;
}
.pillar .tag {
  display: inline-block; margin-top: 4px;
  font-size: 10.5px; padding: 1px 8px; border-radius: 999px; color: #fff;
}
.pillar .shensha { font-size: 11px; color: var(--ink-soft); margin-top: 6px; }

.wx-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wx-label { width: 52px; font-size: 14px; text-align: right; flex-shrink: 0; }
.wx-bar-track { flex: 1; height: 20px; background: #efe9da; border-radius: 999px; overflow: hidden; }
.wx-bar { height: 100%; border-radius: 999px; min-width: 4px; transition: width 0.5s; }
.wx-count { width: 46px; font-size: 13px; color: var(--ink-soft); }

.strength-head { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px;
  background: #efe9da; color: var(--ink);
}
.chip.accent { background: var(--ink); color: var(--card); }
.chip.good { background: #e6ece3; color: var(--wx-mu); }
.chip.bad  { background: #f0e4dc; color: var(--wx-huo); }
.strength-logic { font-size: 13px; color: var(--ink-soft); }
.favor-line { margin-top: 8px; font-size: 14px; }

.rel-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.rel-tag {
  padding: 5px 12px; border-radius: 8px; font-size: 12.5px;
  background: var(--gold-soft); color: #7a6844;
}
.rel-tag b { font-weight: 600; }
.rel-empty { font-size: 13px; color: var(--ink-faint); }

.dayun-note { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.dayun-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dayun-table { border-collapse: collapse; min-width: 100%; }
.dayun-table th, .dayun-table td {
  padding: 8px 12px; font-size: 13px; text-align: center;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.dayun-table th { color: var(--ink-faint); font-weight: 400; }
.dayun-table td.gz { font-size: 17px; font-weight: 700; font-family: var(--font-serif); }
.dayun-table tr.current td { background: var(--gold-soft); }
.dayun-table tr.current td.gz { color: var(--gold); }

.liunian-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 4px; border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.liunian-item:last-child { border-bottom: none; }
.ln-year { font-weight: 600; font-size: 14px; width: 92px; }
.ln-gz { font-size: 18px; font-weight: 700; font-family: var(--font-serif); width: 56px; }
.ln-god { font-size: 12px; color: var(--ink-soft); width: 48px; }
.ln-rels { flex: 1; min-width: 160px; }
.ln-rel { font-size: 12px; color: var(--gold); margin-right: 8px; }
.ln-none { font-size: 12px; color: var(--ink-faint); }

.ai-card { border: 1px dashed #cfc5ab; background: transparent; box-shadow: none; }
.ai-waiting { text-align: center; font-size: 13px; color: var(--ink-faint); padding: 10px 0; }
.ai-stream { font-size: 14px; line-height: 1.9; }
.ai-stream .ai-sec-title {
  font-family: var(--font-serif); font-size: 15px; color: var(--gold);
  margin: 14px 0 4px; letter-spacing: 1px;
}
.ai-stream .ai-sec-title:first-child { margin-top: 0; }
.ai-stream .ai-error {
  background: #f0e4dc; color: #8c4a38;
  border-radius: 8px; padding: 10px 14px; font-size: 13px;
}
.ai-stream .cursor {
  display: inline-block; width: 7px; height: 15px;
  background: var(--gold); vertical-align: -2px;
  animation: blink 0.8s infinite; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

.disclaimer {
  margin-top: 20px; font-size: 11px; color: var(--ink-faint);
  text-align: center; line-height: 1.8;
}
.btn-ghost {
  display: block; margin: 16px auto 0; padding: 10px 28px;
  background: transparent; border: 1px solid var(--line);
  border-radius: 999px; color: var(--ink-soft);
  font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

.error-box {
  margin-top: 16px; padding: 12px 16px;
  background: #f0e4dc; border: 1px solid #dcb9a8;
  border-radius: 10px; color: #8c4a38; font-size: 14px;
}

/* ==========================================================
   问道
   ========================================================== */
.wendao-intro { text-align: center; margin: 26px 0 8px; }
.intro-line {
  font-family: var(--font-serif); font-size: 19px;
  letter-spacing: 5px; color: var(--ink);
}
.intro-sub { font-size: 12px; color: var(--ink-faint); margin-top: 10px; line-height: 2; }

.q-list { margin-top: 26px; }
.q-hint {
  font-size: 11px; color: var(--ink-faint);
  letter-spacing: 3px; margin-bottom: 12px; text-align: center;
}
.q-chip {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  color: var(--ink); font-size: 14px; line-height: 1.6;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
  font-family: var(--font-sans);
}
.q-chip:hover { transform: translateY(-2px); border-color: #cfc5ab; }

.chat-log { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 16px; }
.bubble {
  max-width: 84%; padding: 12px 15px;
  border-radius: 14px; font-size: 14px; line-height: 1.85;
  animation: rise 0.45s ease both;
}
.bubble.user {
  align-self: flex-end;
  background: var(--ink); color: var(--card);
  border-bottom-right-radius: 4px;
}
.bubble.ai {
  align-self: flex-start;
  background: var(--card); border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.chat-input-row { display: flex; gap: 10px; }
.chat-input-row input {
  flex: 1; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; font-size: 14px; outline: none;
}
.chat-input-row input:focus { border-color: var(--gold); }
.chat-input-row button {
  width: 52px; border: none; border-radius: 12px;
  background: var(--ink); color: var(--card);
  font-family: var(--font-serif); font-size: 15px;
  cursor: pointer; letter-spacing: 0;
}
.chat-note {
  text-align: center; font-size: 10.5px;
  color: var(--ink-faint); margin-top: 12px; letter-spacing: 1px;
}

/* ==========================================================
   养运
   ========================================================== */
.yangyun-intro {
  text-align: center; font-family: var(--font-serif);
  font-size: 14.5px; color: var(--ink-soft);
  letter-spacing: 2px; line-height: 2.2; margin: 8px 0 22px;
}
.wx-circle-row { display: flex; justify-content: space-between; margin-bottom: 26px; }
.wx-circle {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.35s ease;
}
.wx-circle:hover { transform: translateY(-3px); }
.wx-circle span { font-family: var(--font-serif); font-size: 17px; }
.wx-circle i { font-style: normal; font-size: 9px; color: var(--ink-faint); letter-spacing: 1px; }
.wx-circle.c-mu span   { color: var(--wx-mu); }
.wx-circle.c-huo span  { color: var(--wx-huo); }
.wx-circle.c-tu span   { color: var(--wx-tu); }
.wx-circle.c-jin span  { color: var(--wx-jin); }
.wx-circle.c-shui span { color: var(--wx-shui); }

.sec-label {
  font-family: var(--font-serif); font-size: 12.5px;
  letter-spacing: 4px; color: var(--ink-soft);
  margin: 6px 0 12px; display: flex; align-items: center; gap: 10px;
}
.sec-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.item-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(58, 52, 38, 0.09); }
.item-visual {
  height: 92px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 30px; letter-spacing: 6px;
  padding-left: 6px;
}
.iv-1 { background: linear-gradient(160deg, #e9ece3, #dde4d8); color: #5a7d5f; }
.iv-2 { background: linear-gradient(160deg, #e8e4d6, #dcd4c0); color: #6f6248; }
.iv-3 { background: linear-gradient(160deg, #efe8da, #e4dac6); color: #9c7c3c; }
.iv-4 { background: linear-gradient(160deg, #e3e8ec, #d5dde3); color: #4a6b85; }
.item-name {
  font-family: var(--font-serif); font-size: 15px;
  letter-spacing: 3px; padding: 10px 14px 0;
}
.item-desc { font-size: 11px; color: var(--ink-faint); padding: 3px 14px 14px; }

/* ==========================================================
   同道
   ========================================================== */
.topic {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 15px 17px; margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
}
.topic:hover { transform: translateY(-2px); }
.topic-t { font-size: 14.5px; line-height: 1.7; }
.topic-m { font-size: 11px; color: var(--ink-faint); margin-top: 5px; letter-spacing: 1px; }

.share-card {
  background: var(--card); border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: 12px; padding: 16px 18px;
  box-shadow: var(--shadow);
}
.share-text { font-size: 13.5px; line-height: 1.9; color: var(--ink-soft); }
.share-m { font-size: 11px; color: var(--ink-faint); margin-top: 8px; }

/* ==========================================================
   自观
   ========================================================== */
.self-quote {
  text-align: center; margin: 22px 0 26px;
  font-family: var(--font-serif); font-size: 20px;
  letter-spacing: 6px; line-height: 2.1; color: var(--ink);
}
.self-list { display: flex; flex-direction: column; gap: 10px; }
.self-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 15px 17px;
  display: flex; align-items: baseline; gap: 14px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.3s ease;
}
.self-card:hover { transform: translateX(3px); }
.self-k {
  font-family: var(--font-serif); font-size: 14px;
  letter-spacing: 3px; color: var(--gold); flex-shrink: 0;
}
.self-v { font-size: 12.5px; color: var(--ink-soft); }

/* ==========================================================
   底部五导航
   ========================================================== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 680px; margin: 0 auto;
  display: flex;
  background: rgba(247, 243, 234, 0.97);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.nav-item {
  flex: 1; background: none; border: none;
  padding: 9px 0 8px; cursor: pointer;
  color: var(--ink-faint);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--font-serif); font-size: 11px; letter-spacing: 2px;
  transition: color 0.25s ease;
}
.nav-item svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-item svg .fill { fill: currentColor; stroke: none; }
.nav-item.active { color: var(--ink); }
.nav-item.active span { position: relative; }
.nav-item.active span::after {
  content: ""; position: absolute; left: 50%; bottom: -5px;
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--gold); transform: translateX(-50%);
}

/* ==========================================================
   响应式微调
   ========================================================== */
@media (min-width: 640px) {
  .app { padding: 34px 24px 110px; }
  .page-title { font-size: 27px; }
  .pillar .gan, .pillar .zhi { font-size: 34px; }
  .trend-svg { height: 124px; }
}
