/* 其一 · 设计令牌精调与升级样式
 *
 * 这份样式在 styles.css 基础上做增量升级，三大原则：
 * 1) 不破坏任何已有 class 与 id
 * 2) 只新增 token、修复关键样式、增强动效
 * 3) 暗色模式（墨夜）通过 :root[data-theme="dark"] 与 prefers-color-scheme 自动启用
 *
 * 内容分区：
 *   A. 设计令牌补全（间距/字号阶梯/阴影/边框/动效）
 *   B. 关键修复：水墨背景对比度 + 移动端溢出
 *   C. 全站微交互增强
 *   D. 首页 hero 沉浸层
 *   E. 公共组件精修：卡片/按钮/对话框/导航
 *   F. 排盘九宫盘增强
 *   G. 暗色模式（墨夜）
 *   H. 加载/空/错误状态统一规范
 *   I. 无障碍增强
 */

/* ============ A. 设计令牌补全 ============ */
:root {
  /* 间距阶梯 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 56px;
  --sp-10: 72px;

  /* 字号阶梯（基于 clamp 流式） */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: clamp(22px, 2.6vw, 28px);
  --fs-3xl: clamp(26px, 3.2vw, 36px);
  --fs-display: clamp(38px, 6vw, 72px);

  /* 字间距 */
  --tracking-tight: -0.01em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-xwide: 0.08em;
  --tracking-cn: 0.12em;

  /* 行高 */
  --lh-tight: 1.2;
  --lh-snug: 1.4;
  --lh-normal: 1.6;
  --lh-loose: 1.8;

  /* 阴影层级 */
  --shadow-xs: 0 1px 2px var(--shadow);
  --shadow-sm: 0 2px 6px var(--shadow);
  --shadow-md: 0 6px 16px var(--shadow);
  --shadow-lg: 0 12px 28px var(--shadow-md);
  --shadow-xl: 0 22px 50px var(--shadow-md);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  --shadow-inset-dark: inset 0 1px 0 rgba(255, 255, 255, 0.08);

  /* 描边透明度 */
  --border-soft: 1px solid rgba(214, 210, 196, 0.6);
  --border-medium: 1px solid var(--line);
  --border-strong: 1px solid var(--line-strong);

  /* 动效曲线 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 180ms;
  --dur-base: 280ms;
  --dur-slow: 480ms;

  /* 容器 */
  --container-max: 1240px;
  --container-pad: clamp(20px, 3vw, 32px);
  --header-height: var(--header-h);

  /* 强调色升级：单色系锁定，避免 AI 紫/多色 */
  --accent-soft: rgba(14, 111, 102, 0.08);
  --accent-medium: rgba(14, 111, 102, 0.18);
  --gold-soft: rgba(184, 134, 47, 0.1);
  --cinnabar-soft: rgba(169, 58, 46, 0.08);

  /* 文字层级 */
  --text-primary: var(--ink);
  --text-secondary: var(--muted);
  --text-tertiary: rgba(92, 106, 104, 0.78);
  --text-disabled: rgba(92, 106, 104, 0.5);
  --text-on-accent: #fff;
  --text-on-dark: rgba(255, 255, 255, 0.92);
  --text-on-dark-soft: rgba(255, 255, 255, 0.72);
}

/* ============ B. 关键修复 ============ */

/* 修复：移动端首页 hero 文字溢出（body 内容超出视口宽度） */
html, body { overflow-x: hidden; }
body.bg-themed { overflow-x: clip; } /* clip 不创建滚动容器 */

/* 修复：水墨背景在文档下半部分压字 —— 强化底部 scrim */
body.bg-themed::after {
  background:
    linear-gradient(180deg,
      rgba(248, 246, 239, 0.55) 0%,
      rgba(248, 246, 239, 0.62) 30%,
      rgba(248, 246, 239, 0.78) 70%,
      rgba(248, 246, 239, 0.92) 100%) !important;
}

/* 修复：body::before 水墨背景过强 */
body::before {
  opacity: 0.6;
}

/* ============ C. 全站微交互增强 ============ */

/* 全局点击涟漪（自动添加 .ripple 类即可） */
.btn,
.module,
.tab,
.ask-scene,
.palace {
  position: relative;
  isolation: isolate;
}

.btn::after,
.module::after,
.tab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), rgba(255, 255, 255, 0.3), transparent 50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease-out);
  z-index: 0;
}
.btn.secondary::after { background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), rgba(14, 111, 102, 0.15), transparent 50%); }
.btn:active::after,
.module:active::after,
.tab:active::after { opacity: 1; transition: opacity 0.05s linear; }

/* 全局平滑滚动 */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* 文本选中样式 */
::selection {
  background: rgba(14, 111, 102, 0.22);
  color: var(--ink);
}

/* ============ D. 首页 hero 沉浸层 ============ */

/* 竖排篆刻点缀（绝对定位在 hero 左上/左下角） */
.home-hero .hero-copy { position: relative; }
.home-hero .hero-copy::before {
  content: "其一";
  position: absolute;
  top: -42px;
  left: -8px;
  font-family: var(--serif);
  font-size: clamp(80px, 14vw, 180px);
  line-height: 1;
  color: rgba(232, 200, 120, 0.08);
  letter-spacing: 0.1em;
  font-weight: 800;
  pointer-events: none;
  user-select: none;
}

/* hero 视觉区：金色光晕 + 多层差速旋转光环（logo 本身已是完整罗盘，故只做「光环」不画罗盘） */
.home-hero .hero-visual {
  position: relative;
}
.home-hero .hero-aura {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 0;
}
/* 金色径向光晕（从中心 logo 向外散出） */
.home-hero .hero-aura::before {
  content: "";
  position: absolute;
  width: 88%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center,
      rgba(232, 200, 120, 0.32) 0%,
      rgba(232, 200, 120, 0.16) 28%,
      rgba(232, 200, 120, 0.06) 55%,
      transparent 75%);
  filter: blur(8px);
  animation: aura-breathe 4.5s var(--ease-out) infinite;
}
@keyframes aura-breathe {
  0%, 100% { opacity: 0.78; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .home-hero .hero-aura::before { animation: none; opacity: 0.85; }
}

/* 三个 SVG 光环层：装饰点 + 外环 + 内环，差速旋转 */
.hero-aura-dots,
.hero-aura-outer,
.hero-aura-inner {
  width: min(380px, 96%);
  height: auto;
  position: absolute;
  transform-origin: center center;
}
.hero-aura-dots   { animation: aura-spin-cw  30s linear infinite; }
.hero-aura-outer  { animation: aura-spin-cw  80s linear infinite; }
.hero-aura-inner  { animation: aura-spin-ccw 60s linear infinite; }
/* 外环虚线透明度降低，避免与 logo 内部线条打架 */
.hero-aura-outer circle:first-child { stroke: rgba(232, 200, 120, 0.22); }

@keyframes aura-spin-cw  { to { transform: rotate(360deg); } }
@keyframes aura-spin-ccw { to { transform: rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) {
  .hero-aura-dots,
  .hero-aura-outer,
  .hero-aura-inner { animation: none; }
}

/* logo 居中并轻微浮起（在光环之上） */
.home-hero .hero-visual > img {
  position: relative;
  z-index: 1;
  width: min(240px, 60vw) !important;
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.42));
  animation: logo-float 6s var(--ease-out) infinite;
}
@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .home-hero .hero-visual > img { animation: none; }
}

/* hero 印章（朱砂方印——增强质感：双层 inset + 外阴影 + 轻微光泽） */
.home-hero .hero-seal {
  position: absolute;
  top: 8px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 240, 230, 0.16) 0%, transparent 45%),
    var(--cinnabar);
  color: #fff;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 6px 14px rgba(169, 58, 46, 0.42),
    0 2px 4px rgba(0, 0, 0, 0.32);
  z-index: 2;
  transform: rotate(-3deg);
  transition: transform 0.4s var(--ease-spring);
}
.home-hero:hover .hero-seal { transform: rotate(-6deg) scale(1.05); }

/* hero 印章装饰（朱砂方印） */
.home-hero::after {
  content: "";
  position: absolute;
  right: 36px;
  bottom: 28px;
  width: 56px;
  height: 56px;
  background: var(--cinnabar);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.32),
    0 6px 16px rgba(0, 0, 0, 0.32);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.1em;
  z-index: 2;
  opacity: 0.92;
}

/* 视觉层次：hero 内文字底部细线 */
.hero-copy > p:not(.eyebrow)::after {
  content: "";
  display: block;
  width: 32px;
  height: 1px;
  margin-top: 18px;
  background: rgba(232, 200, 120, 0.5);
}

/* hero 内新文案装饰：竖排文字点缀 */
.home-hero .hero-copy .vertical-deco {
  position: absolute;
  top: 50%;
  left: -32px;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  color: rgba(232, 200, 120, 0.45);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.4em;
  pointer-events: none;
  user-select: none;
}

/* ============ E. 公共组件精修 ============ */

/* 卡片通用强化（覆盖到所有 .module 和 .card 系） */
.module,
.brand-card,
.today-card,
.home-trust,
.chart-result,
.evidence-chain,
.decision-guide,
.palace {
  transition:
    transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

/* 模块卡 hover 增加内部 SVG 装饰层浮现 */
.module:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 48px rgba(24, 35, 42, 0.14);
}

/* 模块图标 SVG 适配 */
.module-icon {
  display: grid !important;
  place-items: center;
  width: 46px !important;
  height: 46px !important;
}
.module-icon svg { width: 24px; height: 24px; }

/* 印章类元素的统一动效 */
.seal,
.today-seal,
.scenario-seal,
.seal-sm,
.principle-seal {
  transition: transform var(--dur-base) var(--ease-spring);
}
.module:hover .seal,
.module:hover .today-seal,
.module:hover .scenario-seal {
  transform: rotate(-6deg) scale(1.05);
}

/* 按钮：拉满触控区域，最小高度 */
.btn { min-height: 46px; }
.btn.small { min-height: 32px; }

/* 焦点环统一 */
.btn:focus-visible,
.tab:focus-visible,
.module:focus-visible,
.ask-scene:focus-visible,
.palace:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(14, 111, 102, 0.16);
}

/* 深色 hero 内按钮的焦点环（金色，更亮） */
.home-hero .btn:focus-visible {
  outline-color: #e8c878;
  box-shadow: 0 0 0 4px rgba(232, 200, 120, 0.4);
}

/* 对话框增强 */
.auth-dialog,
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(10, 16, 20, 0.32);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  max-width: min(440px, calc(100vw - 32px));
}
.auth-dialog::backdrop {
  background: rgba(10, 16, 20, 0.55);
  backdrop-filter: blur(2px);
}
.auth-head,
.redeem-head {
  border-bottom: 1px solid var(--line);
}

/* 顶部导航暗色层叠增强 */
.site-header {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(16, 28, 33, 0.94) !important;
}

/* 导航 tab 焦点环 */
.tab:focus-visible {
  outline: 2px solid #e8c878;
  outline-offset: 2px;
}

/* ============ F. 排盘九宫盘增强 ============ */

.board {
  gap: 10px !important;
}

.palace {
  min-height: 168px;
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, var(--surface) 0%, rgba(255, 254, 251, 0.6) 100%);
}

.palace:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 16px 32px rgba(10, 85, 79, 0.18);
  z-index: 2;
}

.palace.is-yongshen {
  background:
    linear-gradient(180deg, var(--yongshen-bg) 0%, rgba(255, 250, 240, 0.7) 100%) !important;
  border-color: var(--gold) !important;
  box-shadow:
    inset 0 0 0 1.5px var(--gold),
    0 12px 28px rgba(184, 134, 47, 0.16) !important;
}

/* 用神宫高亮微微脉动（reduced-motion 已自动关闭） */
@media (prefers-reduced-motion: no-preference) {
  .palace.is-yongshen {
    animation: yongshen-pulse 3s var(--ease-out) infinite;
  }
  @keyframes yongshen-pulse {
    0%, 100% { box-shadow: inset 0 0 0 1.5px var(--gold), 0 12px 28px rgba(184, 134, 47, 0.16); }
    50% { box-shadow: inset 0 0 0 1.5px var(--gold), 0 12px 32px rgba(184, 134, 47, 0.26); }
  }
}

/* 九宫盘中宫的装饰 */
.palace.p5 {
  background:
    radial-gradient(circle at center, rgba(232, 200, 120, 0.08) 0%, transparent 60%),
    var(--palace-center-bg) !important;
}

/* 九星图标 强化可读性 */
.palace-gan .tian,
.palace-gan .di {
  font-family: var(--serif);
  letter-spacing: 0.02em;
}

/* ============ G. 暗色模式（墨夜） ============ */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181c;
    --surface: #1c2228;
    --surface-soft: #232a31;
    --ink: #e8e4d8;
    --muted: #a8a89c;
    --line: #2e353c;
    --line-strong: #4a525b;
    --line-strong-hover: #5e6770;
    --accent: #4ea89f;
    --accent-strong: #6fc4bb;
    --cinnabar: #d9665a;
    --gold: #d4a84b;
    --gold-ink: #e8c878;
    --badge-gold-bg: rgba(184, 134, 47, 0.18);
    --badge-ji-bg: rgba(78, 168, 159, 0.16);
    --badge-xiong-bg: rgba(217, 102, 90, 0.18);
    --badge-user-bg: rgba(120, 140, 160, 0.18);
    --badge-user-ink: #b0c4d8;
    --yongshen-bg: rgba(184, 134, 47, 0.08);
    --palace-center-bg: #1f262c;
    --marker-bg: #2a323a;
    --legend-angan: #b8a896;
    --legend-shen: #8aabbb;
    --legend-star: #b09fc8;
    --shadow: rgba(0, 0, 0, 0.32);
    --shadow-md: rgba(0, 0, 0, 0.42);
    --shadow-lg: rgba(0, 0, 0, 0.52);
    --shadow-accent: rgba(78, 168, 159, 0.34);
    --shadow-accent-hover: rgba(78, 168, 159, 0.5);
    --text-primary: var(--ink);
    --text-secondary: var(--muted);
    --text-tertiary: rgba(168, 168, 156, 0.72);
    --accent-soft: rgba(78, 168, 159, 0.12);
    --gold-soft: rgba(184, 134, 47, 0.16);
    --cinnabar-soft: rgba(217, 102, 90, 0.14);
  }

  :root:not([data-theme="light"]) html { background-color: #0e1216; }
  :root:not([data-theme="light"]) body { color: var(--ink); }

  /* 暗色头部导航 */
  :root:not([data-theme="light"]) .site-header {
    background: rgba(10, 14, 18, 0.94) !important;
    border-bottom-color: rgba(232, 200, 120, 0.18);
  }

  /* 暗色背景图遮罩（更暗更透明） */
  :root:not([data-theme="light"]) body.bg-themed::after {
    background:
      linear-gradient(180deg,
        rgba(20, 24, 28, 0.72) 0%,
        rgba(20, 24, 28, 0.78) 30%,
        rgba(20, 24, 28, 0.88) 70%,
        rgba(20, 24, 28, 0.95) 100%) !important;
  }

  :root:not([data-theme="light"]) body::before { opacity: 0.18; }

  /* 暗色卡片增强 */
  :root:not([data-theme="light"]) .module,
  :root:not([data-theme="light"]) .brand-card,
  :root:not([data-theme="light"]) .today-card,
  :root:not([data-theme="light"]) .chart-result,
  :root:not([data-theme="light"]) .evidence-chain,
  :root:not([data-theme="light"]) .palace {
    background:
      linear-gradient(180deg, rgba(28, 34, 40, 0.92), rgba(28, 34, 40, 0.78));
    border-color: rgba(232, 200, 120, 0.1);
  }

  :root:not([data-theme="light"]) .module-mesh {
    background-image:
      linear-gradient(rgba(232, 200, 120, 0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(232, 200, 120, 0.04) 1px, transparent 1px);
  }

  /* 暗色九宫盘 */
  :root:not([data-theme="light"]) .palace {
    background:
      linear-gradient(180deg, rgba(28, 34, 40, 0.95), rgba(28, 34, 40, 0.75)) !important;
    border-color: rgba(232, 200, 120, 0.18);
  }
  :root:not([data-theme="light"]) .palace.p5 {
    background:
      radial-gradient(circle at center, rgba(232, 200, 120, 0.1) 0%, transparent 60%),
      rgba(31, 38, 44, 0.92) !important;
  }
  :root:not([data-theme="light"]) .palace.is-yongshen {
    background:
      linear-gradient(180deg, rgba(184, 134, 47, 0.16), rgba(184, 134, 47, 0.08)) !important;
    border-color: var(--gold) !important;
  }
  :root:not([data-theme="light"]) .palace-gan .tian { color: var(--accent-strong); }
  :root:not([data-theme="light"]) .palace-gan .di { color: var(--ink); }

  /* 暗色底部导航品牌字 */
  :root:not([data-theme="light"]) .brand h1 { color: #fff; }

  /* 暗色表单 */
  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) textarea {
    background: rgba(20, 24, 28, 0.6);
    color: var(--ink);
    border-color: var(--line);
  }

  /* 暗色 dialog */
  :root:not([data-theme="light"]) dialog,
  :root:not([data-theme="light"]) .auth-dialog {
    background: var(--surface);
    color: var(--ink);
    border-color: rgba(232, 200, 120, 0.18);
  }
  :root:not([data-theme="light"]) dialog::backdrop { background: rgba(0, 0, 0, 0.7); }

  /* 暗色证据链 */
  :root:not([data-theme="light"]) .evidence-type.fact {
    background: rgba(78, 168, 159, 0.18);
    color: var(--accent-strong);
  }
  :root:not([data-theme="light"]) .evidence-type.infer {
    background: rgba(184, 134, 47, 0.18);
    color: var(--gold-ink);
  }
  :root:not([data-theme="light"]) .evidence-type.advice {
    background: rgba(217, 102, 90, 0.18);
    color: var(--cinnabar);
  }

  /* 暗色 footer */
  :root:not([data-theme="light"]) footer {
    color: var(--text-secondary);
    border-top: 1px solid rgba(232, 200, 120, 0.12);
  }
}

/* 手动主题切换：当 data-theme="dark" 显式设置 */
:root[data-theme="dark"] {
  --bg: #14181c;
  --surface: #1c2228;
  --surface-soft: #232a31;
  --ink: #e8e4d8;
  --muted: #a8a89c;
  --line: #2e353c;
  --line-strong: #4a525b;
  --accent: #4ea89f;
  --accent-strong: #6fc4bb;
  --cinnabar: #d9665a;
  --gold: #d4a84b;
  --gold-ink: #e8c878;
  --shadow: rgba(0, 0, 0, 0.32);
  --shadow-md: rgba(0, 0, 0, 0.42);
}
:root[data-theme="light"] {
  /* 显式 light 时强制锁定原色（不被 prefers-color-scheme 干扰） */
  --bg: #efeee7;
  --surface: #fffefb;
  --ink: #18232a;
  --accent: #0e6f66;
}

/* ============ H. 加载/空/错误状态 ============ */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(232, 200, 120, 0.16) 50%, transparent 100%);
  animation: skeleton-shine 1.6s linear infinite;
  pointer-events: none;
}
@keyframes skeleton-shine {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; opacity: 0.5; }
}

/* 空状态 */
.empty-state {
  display: grid;
  place-items: center;
  gap: 14px;
  padding: clamp(40px, 8vw, 80px) 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
  color: var(--muted);
}
.empty-state h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.empty-state p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  max-width: 32em;
}

/* 错误状态 */
.error-state {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid rgba(217, 102, 90, 0.35);
  border-radius: var(--radius);
  background: var(--cinnabar-soft);
  color: var(--cinnabar);
  font-size: 13px;
  line-height: 1.65;
}
.error-state strong {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.06em;
}

/* 成功提示 */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: rgba(20, 32, 39, 0.95);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
  z-index: 200;
}
.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============ I. 无障碍增强 ============ */

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 减弱动效偏好：覆盖样式强制减速 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 主题切换按钮（顶部 user-area 旁边） */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: background 0.25s var(--ease-out), color 0.25s var(--ease-out);
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.theme-toggle svg { width: 16px; height: 16px; }

/* ============ J. 模块卡片：左装饰金条渐变加底部细节 ============ */

.module {
  border-top: 2px solid transparent;
  background:
    linear-gradient(180deg, var(--surface) 0%, rgba(255, 254, 251, 0.85) 100%);
}
.module:hover {
  border-top-color: var(--accent);
}

/* 模块卡的"卦象预览"更精致 */
.module .module-preview i,
.module .module-preview b {
  border-radius: 4px !important;
  background: rgba(255, 254, 251, 0.7);
  transition: all 0.25s var(--ease-out);
}
.module:hover .module-preview i,
.module:hover .module-preview b {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ============ K. 场景卡 / 原则带 / 品牌卡 ============ */

.home-scenarios a {
  position: relative;
  border-top: 1px solid transparent;
  transition: all 0.3s var(--ease-out);
}
.home-scenarios a::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}
.home-scenarios a:hover::before { opacity: 0.7; }
.home-scenarios a:hover {
  border-top-color: transparent;
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(24, 35, 42, 0.12);
}

/* 原则带分隔更精致 */
.home-principles article {
  transition: background 0.3s var(--ease-out);
}
.home-principles article:hover {
  background: var(--surface-soft);
}

/* ============ L. 排盘页九宫盘外的"legend"图例条 ============ */

.legend {
  position: relative;
}
.legend::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 24px;
  height: 1px;
  background: var(--accent);
}

/* ============ M. 表单精修 ============ */

.chart-form input,
.chart-form select,
.chart-form textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"], select, textarea {
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background 0.2s var(--ease-out);
}
input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--line-strong);
}

/* ============ N. 移动端精细化 ============ */

@media (max-width: 720px) {
  /* 导航 tab 字号收紧 */
  .tab { font-size: 13px; min-width: 60px; padding: 0 10px; }

  /* 模块卡 padding 减少 */
  .module { padding: 18px; }

  /* 九宫盘单格变小 */
  .palace { min-height: 130px; padding: 8px; }
  .palace-gan .tian { font-size: 26px; }
  .palace-gan .di { font-size: 20px; }

  /* Hero padding 收紧 */
  .home-hero { padding: 24px 18px; gap: 18px; }
  .hero-copy h1 { font-size: clamp(34px, 11vw, 48px); }
  .hero-copy .eyebrow { font-size: 11px; letter-spacing: 0.22em; }

  /* Hero 文字溢出修复 */
  .home-hero { overflow: hidden; }
  .home-hero .hero-copy { width: 100%; max-width: 100%; }
  .home-hero .hero-copy > p:not(.eyebrow) {
    width: 100%;
    max-width: 100%;
    font-size: 14px;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.8;
  }

  /* 移动端压缩 hero 品牌展示：顶部导航已有「其一」，Hero 内大标题缩小，避免首屏重复占位 */
  .home-hero .hero-copy h1 {
    font-size: clamp(30px, 9vw, 42px) !important;
    margin-bottom: 2px;
  }
  /* 移动端隐藏 hero 内装饰巨字与印章（防溢出色块 + 减少干扰） */
  .home-hero .hero-copy::before { display: none; }
  .home-hero::after { display: none; }
  .home-hero .hero-seal { display: none; }
  .hero-aura-dots,
  .hero-aura-outer,
  .hero-aura-inner { width: min(280px, 86%); }
  .home-hero .hero-visual > img { width: min(190px, 56vw) !important; }
  .home-hero .hero-aura::before { width: 78%; }

  /* 卡片阴影在移动端减弱（性能） */
  .module, .today-card, .chart-result { box-shadow: 0 4px 12px var(--shadow); }

  /* 移动端折叠 nav.tabs */
  .site-header.is-mobile {
    flex-wrap: wrap;
    padding: 8px 14px;
    min-height: 56px;
  }
  .site-header.is-mobile .tabs.is-collapsed {
    display: none;
  }
  .site-header.is-mobile .brand h1 { font-size: 18px; }
  .site-header.is-mobile .brand p { display: none; }
  .site-header.is-mobile .brand-mark { width: 36px; height: 36px; }
  .menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    transition: background 0.25s var(--ease-out);
  }
  .menu-trigger:hover { background: rgba(255, 255, 255, 0.24); }

  /* 移动端底部 Tab Bar（核心功能直达） */
  .site-bottom-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    display: flex;
    justify-content: space-around;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    background: rgba(16, 28, 33, 0.97);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(232, 200, 120, 0.24);
  }
  .site-bottom-tabs a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 11px;
    text-decoration: none;
    transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out);
  }
  .site-bottom-tabs a svg { width: 20px; height: 20px; }
  .site-bottom-tabs a:hover { color: #fff; }
  .site-bottom-tabs a.is-active {
    color: #fff;
    background: var(--accent);
  }
  /* 底部留白，避免 Tab Bar 遮挡内容 */
  body.has-bottom-tabs {
    padding-bottom: 78px;
  }
  /* 底部导航与内容间距更舒展 */
  .site-bottom-tabs {
    padding-top: 8px;
  }
}

@media (min-width: 721px) {
  .menu-trigger { display: none; }
  .mobile-menu-overlay { display: none !important; }
  .site-bottom-tabs { display: none !important; }
  body.has-bottom-tabs { padding-bottom: 0; }
}

/* 顶部导航 CTA「开始排盘」 */
.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(10, 85, 79, 0.4);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
.header-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(10, 85, 79, 0.5);
}
.header-cta:focus-visible {
  outline: 2px solid #e8c878;
  outline-offset: 2px;
}

/* 「今日一局」说明文字对比度提升 */
.today-head p {
  color: var(--text-secondary);
  font-size: 12.5px;
  opacity: 1;
}
@media (prefers-color-scheme: dark) {
  .today-head p { color: var(--muted); }
}

/* 移动菜单面板（所有尺寸都定义，在 ≥721 时被 display:none 覆盖） */
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 20, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out);
}
.mobile-menu-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.mobile-menu-panel {
  width: min(320px, 80vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 24px;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease-out);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mobile-menu-overlay.is-open .mobile-menu-panel {
  transform: none;
}
.mobile-menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 20px;
}
.mobile-menu-item {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-family: var(--serif);
  letter-spacing: 0.06em;
  transition: background 0.2s var(--ease-out);
}
.mobile-menu-item:hover {
  background: var(--surface-soft);
}
.mobile-menu-item.is-active {
  background: var(--accent);
  color: #fff;
}

/* ============ O. 滚动条美化 ============ */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
  background-clip: content-box;
}

/* ============ P. 排印增强 ============ */

p { line-height: var(--lh-loose); }
h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  letter-spacing: var(--tracking-cn);
  line-height: var(--lh-snug);
}

/* ============ R. 案例页分类色（按领域） ============ */

.case-card {
  position: relative;
  border-left: 4px solid transparent;
  padding-left: 16px;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}
.case-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(24, 35, 42, 0.1);
  border-left-color: var(--accent);
}

/* 不同 purpose 对应不同左侧色 */
.case-card.case-purpose-事业 { border-left-color: var(--accent); }
.case-card.case-purpose-财运 { border-left-color: var(--gold); }
.case-card.case-purpose-婚姻 { border-left-color: #c45479; }
.case-card.case-purpose-疾病 { border-left-color: var(--cinnabar); }
.case-card.case-purpose-考试 { border-left-color: #5e8a6a; }
.case-card.case-purpose-诉讼 { border-left-color: #7a5a8a; }
.case-card.case-purpose-出行 { border-left-color: #4d7796; }
.case-card.case-purpose-寻人失物 { border-left-color: #b38240; }

.case-card:hover.case-purpose-事业 { border-left-color: var(--accent-strong); }
.case-card:hover.case-purpose-财运 { border-left-color: var(--gold-ink); }
.case-card:hover.case-purpose-婚姻 { border-left-color: #a8486b; }
.case-card:hover.case-purpose-疾病 { border-left-color: var(--cinnabar); }
.case-card:hover.case-purpose-考试 { border-left-color: #4a7058; }
.case-card:hover.case-purpose-诉讼 { border-left-color: #5e4576; }
.case-card:hover.case-purpose-出行 { border-left-color: #3c5e7a; }
.case-card:hover.case-purpose-寻人失物 { border-left-color: #92632e; }

/* 案例 purpose 标签按领域色 */
.case-purpose {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.case-card.case-purpose-财运 .case-purpose { background: var(--gold-soft); color: var(--gold-ink); }
.case-card.case-purpose-婚姻 .case-purpose { background: rgba(196, 84, 121, 0.12); color: #a8486b; }
.case-card.case-purpose-疾病 .case-purpose { background: var(--cinnabar-soft); color: var(--cinnabar); }
.case-card.case-purpose-考试 .case-purpose { background: rgba(94, 138, 106, 0.14); color: #4a7058; }
.case-card.case-purpose-诉讼 .case-purpose { background: rgba(122, 90, 138, 0.14); color: #5e4576; }
.case-card.case-purpose-出行 .case-purpose { background: rgba(77, 119, 150, 0.14); color: #3c5e7a; }
.case-card.case-purpose-寻人失物 .case-purpose { background: rgba(179, 130, 64, 0.14); color: #92632e; }

/* ============ S. 个人中心引导卡增强 ============ */

.member-empty {
  background: linear-gradient(180deg, var(--surface) 0%, rgba(255, 254, 251, 0.82) 100%);
}
.guest-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}
.guest-points span:not(.guest-dot) {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  transition: all 0.25s var(--ease-out);
  cursor: default;
}
.guest-points span:not(.guest-dot):hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.guest-points .guest-dot {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0;
}

/* ============ T. 排盘页 toolbar 精修 ============ */

.toolbar {
  position: relative;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  margin-bottom: 18px;
}
.toolbar::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  width: 36px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

/* ============ U. 首页案例信任背书区 ============ */

.home-proof {
  padding: clamp(20px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px var(--shadow);
}
.proof-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.proof-seal {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: var(--serif);
  font-size: 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.proof-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.08em;
}
.proof-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.proof-head a {
  margin-left: auto;
  color: var(--accent-strong);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.proof-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.proof-card {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.3s var(--ease-out), border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
.proof-card:hover {
  transform: translateY(-3px);
  border-color: rgba(14, 111, 102, 0.4);
  box-shadow: 0 16px 32px rgba(24, 35, 42, 0.12);
}
.proof-tag {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.proof-card:nth-child(2) .proof-tag { background: var(--gold-soft); color: var(--gold-ink); }
.proof-card:nth-child(3) .proof-tag { background: var(--cinnabar-soft); color: var(--cinnabar); }
.proof-card strong {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.04em;
}
.proof-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}
.proof-result {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: rgba(14, 111, 102, 0.1);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-top: 2px;
}
.proof-card:nth-child(2) .proof-result {
  background: var(--gold-soft);
  color: var(--gold-ink);
}
.proof-card:nth-child(3) .proof-result {
  background: var(--cinnabar-soft);
  color: var(--cinnabar);
}

@media (max-width: 860px) {
  .proof-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .proof-head { flex-wrap: wrap; }
  .proof-head a { margin-left: 0; }
}

/* ============ Q. 进入动画增强 ============ */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.fade-up {
  animation: fade-up 0.5s var(--ease-out) both;
}
.fade-up-d1 { animation-delay: 0.08s; }
.fade-up-d2 { animation-delay: 0.16s; }
.fade-up-d3 { animation-delay: 0.24s; }
.fade-up-d4 { animation-delay: 0.32s; }

@media (prefers-reduced-motion: reduce) {
  .fade-up,
  .fade-up-d1,
  .fade-up-d2,
  .fade-up-d3,
  .fade-up-d4 { animation: none !important; }
}