/* ============================================================
   八字排盘 · 中国风设计系统 v1.0
   参考: docs/design-system.md
   原则: 去黑取墨 / 宣纸为底 / 朱砂点睛 / 赭石为骨
   ============================================================ */

:root {
  /* ---- 背景 ---- */
  --bg-page: #F7F4EE;       /* 宣纸白 */
  --bg-card: #FBF9F4;       /* 素笺 */
  --bg-alt: #F0EBE0;        /* 浅宣 - 交替行/大字底色 */

  /* ---- 文字 ---- */
  --text-primary: #3B3530;   /* 墨色 */
  --text-secondary: #9B9080; /* 烟灰 */
  --text-label: #B0A595;     /* 淡褐 */

  /* ---- 强调 ---- */
  --accent: #8B7355;         /* 赭石 */
  --accent-dark: #6B5D4A;    /* 深褐 */
  --accent-red: #C84030;     /* 朱砂红 */

  /* ---- 边框 ---- */
  --border: #E8E0D5;         /* 米线 */
  --divider: #C8B89A;        /* 秋香 */

  /* ---- 五行色 ---- */
  --el-wood: #4A9B3F;
  --el-fire: #C84030;
  --el-earth: #9B7B4A;
  --el-metal: #C9A84C;
  --el-water: #3B6FB5;

  /* ---- 字体 ---- */
  --font-serif: "STSong","SimSun","Songti SC","Noto Serif CJK SC",serif;
  --font-sans: "PingFang SC","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
  --font-mono: "DIN Alternate","Helvetica Neue",monospace;

  /* ---- 圆角 ---- */
  --radius: 2px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==================== 字体工具类 ==================== */
.font-serif { font-family: var(--font-serif); }
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }

/* ==================== 输入页 ==================== */

#inputPage { padding: 16px 12px; }

.app-header { text-align: center; padding: 24px 0 20px; }
.app-header .app-title {
  font-family: var(--font-serif);
  font-size: 24px; font-weight: 700; color: var(--text-primary); letter-spacing: 4px;
}
.app-header .app-subtitle {
  font-family: var(--font-serif);
  font-size: 12px; color: var(--text-secondary); margin-top: 6px; letter-spacing: 2px;
}

/* 模式切换 - 宣纸底 + 朱砂下划线 */
.mode-tabs {
  display: flex;
  background: #FAF7F2;
  border-bottom: 2px solid var(--divider);
  margin: 0 -12px 16px;
}
.mode-tab {
  flex: 1; padding: 14px 0; text-align: center; cursor: pointer;
  background: none; border: none; font-size: 15px;
  color: var(--text-secondary); transition: all 0.2s; position: relative;
  font-family: var(--font-sans);
}
.mode-tab.active {
  color: var(--accent); font-weight: 600;
}
.mode-tab.active::after {
  content: ''; position: absolute; bottom: -2px; left: 50%;
  transform: translateX(-50%); width: 28px; height: 2px;
  background: var(--accent-red); border-radius: 1px;
}

/* 表单卡片 */
.form-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px;
  font-family: var(--font-serif);
}
.form-group select, .form-group input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  font-size: 15px; color: var(--text-primary); background: var(--bg-card);
  -webkit-appearance: none; border-radius: var(--radius);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239B9080' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
  font-family: var(--font-sans);
}
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* 性别 */
.gender-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.gender-btn {
  flex: 1; padding: 10px 0; text-align: center; cursor: pointer;
  background: var(--bg-card); border: none; font-size: 15px;
  color: var(--text-secondary); transition: all 0.15s; font-family: var(--font-sans);
}
.gender-btn.active { background: var(--accent); color: var(--bg-page); font-weight: 600; }

/* 干支选择器 */
.ganzi-select { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.ganzi-option {
  padding: 8px 0; text-align: center; border: 1px solid var(--border);
  cursor: pointer; font-size: 15px; background: var(--bg-card);
  color: var(--text-primary); transition: all 0.15s;
  font-family: var(--font-serif); border-radius: var(--radius);
}
.ganzi-option.selected {
  background: var(--accent); color: var(--bg-page); border-color: var(--accent-dark); font-weight: 600;
}

/* 按钮 */
.btn-primary {
  width: 100%; padding: 14px; background: var(--accent); color: var(--bg-page);
  border: 1px solid var(--accent-dark); border-radius: var(--radius);
  font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 16px;
  transition: opacity 0.2s; letter-spacing: 3px; font-family: var(--font-sans);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  padding: 8px 20px; background: var(--bg-alt); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; cursor: pointer; font-family: var(--font-sans);
}

.section-desc {
  font-family: var(--font-serif);
  font-size: 13px; color: var(--text-secondary); line-height: 1.7; margin: 10px 0;
}

/* ==================== 报告页 ==================== */

#reportPage { display: none; }
#inputPage.hidden { display: none; }
#reportPage.show { display: block; }

.back-btn {
  background: none; border: none; color: var(--text-secondary);
  font-size: 14px; cursor: pointer; padding: 12px;
  display: flex; align-items: center; gap: 4px; font-family: var(--font-sans);
}

/* 报告Tab栏 - 宣纸底 + 朱砂下划线 */
.report-tabs {
  display: flex; background: #FAF7F2; border-bottom: 2px solid var(--divider);
  margin: 0 -12px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.report-tabs::-webkit-scrollbar { display: none; }
.report-tab {
  padding: 14px 16px; cursor: pointer; font-size: 14px;
  color: var(--text-secondary); border: none; background: none;
  white-space: nowrap; transition: all 0.2s; position: relative; font-family: var(--font-sans);
}
.report-tab.active { color: var(--accent); font-weight: 600; }
.report-tab.active::after {
  content: ''; position: absolute; bottom: -2px; left: 50%;
  transform: translateX(-50%); width: 24px; height: 2px;
  background: var(--accent-red); border-radius: 1px;
}

#reportContent { padding: 12px; }

/* ==================== 排盘信息条 ==================== */
.paipan-info {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  font-family: var(--font-serif); font-size: 13px; color: var(--text-secondary); line-height: 1.8;
}
.paipan-info .info-name {
  font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px;
  font-family: var(--font-serif);
}
.paipan-info .info-sex { color: var(--accent-red); font-weight: 600; font-size: 14px; }

/* ==================== 四柱排盘网格 ==================== */
.paipan-grid {
  display: grid; grid-template-columns: 52px 1fr 1fr 1fr 1fr;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
}
.grid-cell {
  padding: 8px 4px; text-align: center; font-size: 14px; color: var(--text-primary);
  border-bottom: 1px solid var(--border); font-family: var(--font-sans);
}
.grid-cell:nth-child(5n+1) {
  background: var(--bg-alt); font-size: 12px; color: var(--text-label); font-family: var(--font-serif);
}
.grid-header {
  font-size: 14px; color: var(--accent); font-weight: 600;
  background: var(--bg-card) !important; padding: 10px 4px; font-family: var(--font-sans);
}

/* 天干/地支大字 */
.grid-stem, .grid-branch {
  font-size: 30px; font-weight: 700; padding: 12px 4px; line-height: 1.2;
  font-family: var(--font-serif); background: var(--bg-alt);
}

/* 藏干 */
.grid-zanggan {
  font-size: 12px; color: var(--text-secondary); line-height: 1.6; padding: 6px 2px;
  font-family: var(--font-serif);
}
.grid-zanggan .zg-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: 2px;
}
.grid-zanggan .zg-item {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 3px;
  font-weight: 600;
  font-size: 13px;
}

/* 十神标签 */
.shishen-tag {
  display: inline-block; font-size: 12px; padding: 2px 6px; color: var(--accent-dark);
  font-family: var(--font-sans);
}

/* ==================== 大运表 ==================== */
.dayun-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dayun-section .section-header {
  padding: 12px 14px; font-size: 14px; font-weight: 600; color: var(--accent);
  border-bottom: 1px solid var(--border); font-family: var(--font-sans);
}
.dayun-table {
  width: 100%; border-collapse: collapse; font-size: 13px; min-width: 400px;
}
.dayun-table th {
  background: var(--bg-alt); color: var(--text-secondary); padding: 8px 6px;
  text-align: center; font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--border); font-family: var(--font-sans);
}
.dayun-table td {
  padding: 10px 6px; text-align: center; border-bottom: 1px solid var(--border);
  color: var(--text-primary); font-family: var(--font-sans);
}
.dayun-table td.dy-ganzhi { font-size: 17px; font-weight: 700; font-family: var(--font-serif); }

/* ==================== 评分条 ==================== */
.score-bar {
  display: flex; align-items: center; gap: 10px; margin: 8px 0; padding: 0 14px;
}
.score-bar .score-label {
  width: 56px; font-size: 13px; color: var(--text-secondary); flex-shrink: 0;
  font-family: var(--font-serif);
}
.score-bar .bar-bg {
  flex: 1; height: 16px; background: var(--bg-alt); overflow: hidden; border-radius: var(--radius);
}
.score-bar .bar-fill { height: 100%; background: var(--accent); transition: width 0.5s; }
.score-bar .score-val {
  width: 36px; text-align: right; font-size: 14px; font-weight: 600;
  color: var(--text-primary); flex-shrink: 0; font-family: var(--font-mono);
}

/* ==================== 结论卡片 ==================== */
.conclusion-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.conclusion-card .card-title {
  font-size: 13px; color: var(--accent); margin-bottom: 6px; font-weight: 600;
  font-family: var(--font-sans);
}
.conclusion-card .card-value {
  font-size: 17px; font-weight: 700; color: var(--text-primary); font-family: var(--font-sans);
}
.conclusion-card .card-detail {
  font-size: 13px; color: var(--text-secondary); margin-top: 8px; line-height: 1.8;
  font-family: var(--font-serif);
}

/* ==================== 流年列表 ==================== */
.liunian-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 4px; font-size: 14px; font-family: var(--font-sans);
}
.liunian-item .ly-year { font-weight: 600; color: var(--text-primary); font-family: var(--font-serif); }
.liunian-item .ly-score { color: var(--accent); font-weight: 600; font-family: var(--font-mono); }

/* ==================== 神煞区 ==================== */
.shensha-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.shensha-section .ss-title {
  font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 8px; font-family: var(--font-sans);
}
.shensha-section .ss-item {
  font-size: 13px; color: var(--text-secondary); line-height: 1.8; font-family: var(--font-serif);
}
.shensha-section .ss-item .ss-pillar {
  color: var(--text-primary); font-weight: 600; margin-right: 4px; font-family: var(--font-sans);
}

/* ==================== 骨架屏 ==================== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, #FAF5EC 50%, var(--bg-alt) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
  border-radius: var(--radius); height: 60px; margin-bottom: 12px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ==================== 错误 ==================== */
.error-box {
  background: #FBF0EE; border: 1px solid #E8C8C0; border-radius: var(--radius);
  padding: 20px; text-align: center; margin: 12px 0;
}
.error-box .error-msg { color: var(--accent-red); font-size: 14px; margin-bottom: 12px; font-family: var(--font-sans); }

/* ==================== 报告标题 ==================== */
h2 {
  font-size: 15px; margin: 16px 0 8px; color: var(--accent);
  font-weight: 600; padding-left: 4px; font-family: var(--font-sans);
}

/* ==================== 五行色工具类 ==================== */
.el-wood { color: var(--el-wood); }
.el-fire { color: var(--el-fire); }
.el-earth { color: var(--el-earth); }
.el-metal { color: var(--el-metal); }
.el-water { color: var(--el-water); }

/* ==================== Sticky Tab 栏 ==================== */
.sticky-tabs {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  background: #FAF7F2;
  border-bottom: 2px solid var(--divider);
  margin: 0 -12px;
}
.sticky-tab {
  flex: 1;
  padding: 14px 0;
  text-align: center;
  font-size: 15px;
  color: var(--text-secondary);
  background: none;
  border: none;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
}
.sticky-tab.active {
  color: var(--accent);
  font-weight: 600;
}
.sticky-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2px;
  background: var(--accent-red);
  border-radius: 1px;
}

/* ==================== 报告区段 ==================== */
.report-section {
  padding: 8px 0 16px;
  scroll-margin-top: 50px;
}
#section-basic {
  min-height: auto;
  padding-bottom: 4px;
}
#section-paipan, #section-analysis {
  min-height: 30vh;
}

/* ==================== 紧凑基本信息条 ==================== */
.basic-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  font-size: 12px;
  font-family: var(--font-sans);
  line-height: 1.6;
}
.basic-bar-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  font-family: var(--font-serif);
  margin-right: 6px;
}
.basic-bar-sex {
  color: var(--accent-red);
  font-weight: 600;
  font-size: 11px;
  margin-right: 6px;
}
.basic-bar-item {
  color: var(--text-secondary);
  font-size: 11px;
  padding-right: 6px;
  margin-right: 6px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.basic-bar-item:last-child {
  border-right: none;
  margin-right: 0;
  padding-right: 0;
}

/* ==================== 干支关系卡片 ==================== */
.gz-rel-card {
  background: var(--bg-card);
  border: 1px solid var(--divider);
  border-left: 3px solid var(--accent-red);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.gz-rel-title {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
  font-family: var(--font-sans);
}
.gz-rel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rel-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius);
  font-family: var(--font-serif);
  white-space: nowrap;
}
.rel-he { background: #E8F5E9; color: #2E7D32; }
.rel-chong { background: #FFEBEE; color: #C62828; }
.rel-xing { background: #FFF3E0; color: #E65100; }
.rel-hai { background: #FCE4EC; color: #AD1457; }
.rel-ke { background: #FFF8E1; color: #F57F17; }
.rel-sheng { background: #E3F2FD; color: #1565C0; }

/* ==================== 头像区 ==================== */
.avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.avatar-section.compact {
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px 12px;
}
.avatar-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-alt);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-img.small {
  width: 36px;
  height: 36px;
}
.avatar-img svg { width: 100%; height: 100%; }
.avatar-info { flex: 1; }
.avatar-section.compact .avatar-info {
  display: flex;
  align-items: center;
  gap: 2px;
}
.avatar-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-serif);
  letter-spacing: 2px;
}
.avatar-section.compact .avatar-name {
  font-size: 16px;
  letter-spacing: 1px;
  margin-right: 8px;
}
.avatar-sex {
  font-size: 13px;
  color: var(--accent-red);
  margin-top: 4px;
  font-family: var(--font-serif);
}
.avatar-section.compact .avatar-sex {
  font-size: 12px;
  margin-top: 0;
}

/* ==================== 信息卡片行 ==================== */
.info-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.info-label {
  width: 70px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  font-family: var(--font-serif);
}
.info-value {
  flex: 1;
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 500;
}

/* ==================== 基本信息紧凑网格 ==================== */
.basic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.basic-grid.compact {
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 8px;
}
.basic-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-card);
  gap: 6px;
}
.basic-grid.compact .basic-item {
  padding: 5px 8px;
  gap: 4px;
  flex-direction: column;
  align-items: flex-start;
}
.basic-label {
  font-size: 12px;
  color: var(--text-label);
  flex-shrink: 0;
  font-family: var(--font-serif);
}
.basic-grid.compact .basic-label {
  font-size: 10px;
  line-height: 1.2;
}
.basic-value {
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 500;
}
.basic-grid.compact .basic-value {
  font-size: 12px;
  line-height: 1.3;
}

/* ==================== 区段标题 ==================== */
.section-h2 {
  font-size: 16px;
  margin: 20px 0 10px;
  color: var(--accent);
  font-weight: 600;
  padding-left: 10px;
  border-left: 3px solid var(--accent-red);
  font-family: var(--font-sans);
  padding-top: 8px;
  padding-bottom: 8px;
}

/* ==================== 评分原因 ==================== */
.score-reason {
  font-size: 12px;
  color: var(--text-label);
  padding: 0 14px 4px;
  margin: 0;
  font-family: var(--font-serif);
  line-height: 1.6;
}

/* ==================== 神煞行 ==================== */
.ss-row {
  display: flex;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.ss-row:last-child { border-bottom: none; }
.ss-pillar {
  width: 40px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
  font-family: var(--font-sans);
}
.ss-tags {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ss-tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  background: var(--bg-alt);
  color: var(--text-primary);
  border-radius: var(--radius);
  font-family: var(--font-serif);
}

/* ==================== 干支关系项 ==================== */
.rel-item {
  font-size: 13px;
  color: var(--text-primary);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-serif);
}
.rel-item:last-child { border-bottom: none; }

/* ==================== 十二长生格子 ==================== */
.grid-cs {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-serif);
  padding: 6px 2px;
  background: rgba(139, 115, 85, 0.04);
}

/* ==================== 四柱网格增强 ==================== */

/* 藏干十神标注 */
.zg-shishen {
  display: block;
  font-size: 13px;
  color: var(--text-label);
  line-height: 1.4;
  font-family: var(--font-sans);
  margin-left: 2px;
}

/* 副星格子 */
.grid-fuxing {
  padding: 4px 2px;
  line-height: 1.6;
}
.grid-fuxing .shishen-tag {
  display: block;
  margin-bottom: 1px;
  font-size: 11px;
}

/* 神煞格子 - #4 一行一个，字体参考grid-cs */
.grid-shensha {
  padding: 4px 2px;
  line-height: 1.8;
  background: rgba(200, 64, 48, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ss-mini {
  display: block;
  font-size: 12px;
  padding: 1px 6px;
  background: var(--bg-alt);
  color: var(--accent-dark);
  border-radius: var(--radius);
  margin: 1px 0;
  font-family: var(--font-serif);
  white-space: nowrap;
  border: 1px solid var(--border);
  text-align: center;
}

/* ==================== 卡片组 ==================== */
.card-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.card-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--bg-alt);
}
.card-group-content {
  padding: 12px 14px;
}
.grouped-card {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.grouped-card:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.grouped-card .card-title {
  font-size: 12px;
  color: var(--text-label);
  margin-bottom: 4px;
  font-family: var(--font-sans);
}
.grouped-card .card-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-sans);
}
.grouped-card .card-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.7;
  font-family: var(--font-serif);
}

/* ==================== 大运折叠手风琴 ==================== */
.dayun-accordion {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.dayun-accordion.expanded {
  border-color: var(--divider);
  overflow: visible;
}
.dayun-header {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
/* #2 展开大运的标题吸附在顶部 */
.dayun-accordion.expanded .dayun-header {
  position: sticky;
  top: 51px;
  z-index: 40;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin: -1px -1px 0 -1px;
  width: calc(100% + 2px);
}
.dayun-header:active {
  background: var(--bg-alt);
}
.dy-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dy-gz {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-serif);
  letter-spacing: 1px;
}
.dy-meta {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
}
.dy-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dy-current-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--accent-red);
  color: var(--bg-page);
  border-radius: var(--radius);
  font-family: var(--font-sans);
}
.dy-score {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  min-width: 28px;
  text-align: right;
}
.dy-arrow {
  font-size: 18px;
  color: var(--accent);
  transition: transform 0.3s;
  font-weight: bold;
}
.dayun-accordion.expanded .dy-arrow {
  transform: rotate(180deg);
}

/* 折叠内容 */
.dayun-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  padding: 0 14px;
}
.dayun-content.expanded {
  padding: 0 14px 14px;
}

/* 大运总评 */
.dy-summary {
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-bottom: 8px;
}
.dy-shishen {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-family: var(--font-sans);
}
.dy-comment {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.7;
  font-family: var(--font-serif);
}

/* 五维运势 */
.dy-advice {
  margin-bottom: 10px;
}
.dy-advice-title {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
  font-family: var(--font-sans);
}

/* 流年列表 */
.dy-liunian-list {
  margin-top: 8px;
}
.liunian-row {
  margin-left: 12px;
  border-left: 2px solid var(--border);
  padding: 8px 0 8px 12px;
  margin-bottom: 6px;
  position: relative;
}
.liunian-row.ly-current {
  border-left-color: var(--accent-red);
  background: rgba(200, 64, 48, 0.03);
}
.liunian-row.ly-current::before {
  content: '今';
  position: absolute;
  left: -8px;
  top: 8px;
  width: 16px;
  height: 16px;
  background: var(--accent-red);
  color: var(--bg-page);
  font-size: 9px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
}
.ly-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.ly-year-tag {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-serif);
}
.ly-age {
  font-size: 12px;
  color: var(--text-label);
  font-family: var(--font-sans);
}
.ly-comment {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 2px 0 4px;
  font-family: var(--font-serif);
}

/* 流年五维迷你条 */
.ly-detail-bars {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.ly-mini-bar {
  flex: 1;
  min-width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ly-mini-label {
  font-size: 10px;
  color: var(--text-label);
  font-family: var(--font-sans);
}
.bar-bg.mini {
  height: 8px;
  width: 100%;
}

/* ==================== 大运五维雷达图行 ==================== */
.dy-radar-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.dy-radar-left {
  flex: 1;
  min-width: 0;
}
.dy-radar-right {
  flex-shrink: 0;
  padding-top: 4px;
}
/* 大运五维文字点评 */
.dy-dim-row {
  padding: 5px 0;
  border-top: 1px dashed var(--border);
}
.dy-dim-row:first-of-type {
  border-top: none;
}
.dy-dim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.dy-dim-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-sans);
}
.dy-dim-rating {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.dy-dim-text {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  font-family: var(--font-serif);
}

/* ==================== 流年时间轴 ==================== */
.ly-timeline {
  margin-top: 10px;
  position: relative;
}
.ly-node {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
  position: relative;
}
.ly-node::before {
  content: '';
  position: absolute;
  left: 27px;
  top: 20px;
  bottom: -6px;
  width: 1px;
  background: var(--border);
}
.ly-node:last-child::before {
  display: none;
}
.ly-node-year {
  width: 48px;
  flex-shrink: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
  padding-top: 6px;
  position: relative;
  z-index: 1;
}
.ly-node-year::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
}
.ly-node.ly-current .ly-node-year {
  color: var(--accent-red);
}
.ly-node.ly-current .ly-node-year::after {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

/* ==================== 流年卡片 ==================== */
.ly-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}
.ly-card.expanded {
  border-color: var(--divider);
}
.ly-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}
.ly-gz {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-serif);
  letter-spacing: 1px;
}
.ly-card-header .ly-age {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
}
.ly-card-header .ly-score {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
  min-width: 24px;
  text-align: right;
}
.ly-arrow {
  font-size: 16px;
  color: var(--accent);
  transition: transform 0.3s;
  font-weight: bold;
}
.ly-card.expanded .ly-arrow {
  transform: rotate(180deg);
}

/* 流年概览：结合大运背景的文字建议 */
.ly-card-overview {
  padding: 0 10px 8px;
}
.ly-context-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-family: var(--font-serif);
  margin: 0;
  text-align: justify;
}

/* 流年详细（折叠） */
.ly-card-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.ly-card-detail.expanded {
  /* max-height set by JS */
}

/* 五维详细解析 */
.ly-dim-row {
  padding: 6px 10px;
  border-top: 1px dashed var(--border);
}
.ly-dim-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-sans);
  margin-right: 6px;
}
.ly-dim-rating {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.ly-dim-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 2px;
  font-family: var(--font-serif);
}

/* AI 解读降级提示（调试可见，默认展开） */
.llm-fail-hint {
  margin: 0 12px 12px;
  padding: 10px 12px;
  border: 1px dashed #C8A84C;
  background: rgba(233, 213, 167, 0.18);
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent-dark);
  line-height: 1.7;
  font-family: var(--font-sans);
}
.llm-fail-hint-head {
  font-weight: 600;
  color: #8B6F2A;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.llm-fail-hint .hint-toggle {
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(139, 111, 42, 0.12);
  border-radius: 10px;
  color: #8B6F2A;
  font-weight: 500;
  user-select: none;
}
.llm-fail-hint .hint-toggle:active { opacity: 0.6; }
.llm-fail-hint-reason {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #6B5D4A;
  word-break: break-all;
}
.llm-fail-hint-detail {
  margin-top: 6px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

/* ==================== 格局用神解释样式 ==================== */
.geshi-explain {
  color: var(--accent-dark) !important;
  font-style: normal;
  padding: 6px 8px;
  background: rgba(139, 115, 85, 0.05);
  border-radius: var(--radius);
  margin-top: 6px;
}
.yongshen-explain {
  color: var(--accent-dark) !important;
  font-style: normal;
  padding: 6px 8px;
  background: rgba(139, 115, 85, 0.05);
  border-radius: var(--radius);
  margin-top: 6px;
}

/* ==================== 空亡格子 ==================== */
.grid-kw {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-label);
  font-family: var(--font-sans);
}
.grid-kw.kw-active {
  color: var(--accent-red);
}

/* ==================== 成格标签 ==================== */
.header-tags {
  display: flex;
  gap: 6px;
  align-items: center;
}
.chengge-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius);
  font-size: 10px;
  font-weight: normal;
  font-family: var(--font-sans);
  vertical-align: middle;
}
.chengge-yes {
  background: rgba(74, 155, 63, 0.15);
  color: var(--el-wood);
}
.chengge-no {
  background: rgba(200, 64, 48, 0.15);
  color: var(--accent-red);
}
.level-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: normal;
  font-family: var(--font-sans);
  vertical-align: middle;
}

/* ==================== 维度分析 ==================== */
.dim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.dim-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-sans);
}
.dim-rating {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ==================== 神煞信息卡 ==================== */
.info-value .ss-pillar {
  color: var(--accent);
  font-weight: 600;
  margin-right: 4px;
  font-family: var(--font-sans);
  font-size: 12px;
}
.info-value .ss-mini {
  display: inline-block;
  font-size: 11px;
  padding: 1px 5px;
  background: var(--bg-alt);
  color: var(--accent-dark);
  border-radius: var(--radius);
  margin: 1px 2px;
  font-family: var(--font-serif);
  white-space: nowrap;
}

/* ============================================================
   LLM 大模型解读区块（与模板文案强对比）
   - 浅金色背景 + 左侧金色边框 = 一眼能识别
   - "✨ AI 解读" 角标 = 明显标签
   - 排队中状态显示 .llm-pending（3 条 shimmer 骨架）
   - 完成态：淡入动画
   ============================================================ */

/* ============================================================
   记录功能（H5 MVP 飞书多维表）
   - 顶部"我的命盘"胶囊 + 抽屉列表
   ============================================================ */

.record-toolbar {
  max-width: 720px;
  margin: 8px auto -4px;
  padding: 0 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.record-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e6dcc7);
  color: var(--text-primary, #2a2826);
  font-size: 13px;
  font-family: var(--font-sans, sans-serif);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.record-pill:hover { background: #f7f1e1; }
.record-pill-icon { font-size: 14px; line-height: 1; }
.record-pill-text { font-weight: 600; }

/* 微信授权入口与用户卡片（v2.6.0）*/
.wxauth-pill { background: #07c160; color: #fff; border-color: #07c160; }
.wxauth-pill:hover { background: #06ad56; color: #fff; }
.wx-user-card { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; background: var(--bg-card, #fff); border: 1px solid var(--border, #e6dcc7); border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.wx-user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #eee; flex-shrink: 0; }
.wx-user-nick { font-size: 13px; font-weight: 600; color: var(--text-primary, #2a2826); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 抽屉遮罩 */
.records-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  z-index: 999;
  align-items: center;
  justify-content: center;
}
.records-drawer-overlay.show { display: flex; }
.records-drawer {
  background: var(--bg-card, #fdfaf2);
  border-radius: 12px;
  width: min(720px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  overflow: hidden;
}
.records-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, #e6dcc7);
}
.records-drawer-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent, #8B7355);
  font-family: var(--font-serif, serif);
}
.records-drawer-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary, #6e6a64);
}
.records-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fafafa;
}

/* 卡片 */
.record-card {
  background: #fff;
  border: 1px solid var(--border, #e6dcc7);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.record-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.record-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.record-card-pillars {
  font-family: var(--font-serif, serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #2a2826);
}
.record-card-score {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-red, #b33a3a);
}
.record-card-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary, #6e6a64);
}
.record-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.record-card-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(139,115,85,0.10);
  color: var(--text-primary, #2a2826);
}
.record-card-dims {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary, #6e6a64);
}
.record-card-time {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-label, #9a948c);
  text-align: right;
}

.records-drawer-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border, #e6dcc7);
  font-size: 11px;
  color: var(--text-label, #9a948c);
  text-align: center;
  background: #f7f3ea;
}

.records-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary, #6e6a64);
  font-size: 13px;
}
.records-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.records-skeleton > div {
  height: 70px;
  border-radius: 10px;
  background: linear-gradient(90deg, #f0eae0 25%, #e6dcc7 50%, #f0eae0 75%);
  background-size: 200% 100%;
  animation: records-shimmer 1.2s linear infinite;
}
@keyframes records-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   LLM 大模型解读区块（与模板文案强对比）
   - 浅金色背景 + 左侧金色边框 = 一眼能识别
   - "✨ AI 解读" 角标 = 明显标签
   - 排队中状态显示 .llm-pending（3 条 shimmer 骨架）
   - 完成态：淡入动画
   ============================================================ */
.llm-narrative-box {
  position: relative;
  margin: 10px 0 14px;
  padding: 12px 12px 12px 16px;
  background: linear-gradient(135deg, #FBF6E8 0%, #F8F0DC 100%);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-serif);
  line-height: 1.85;
  font-size: 13.5px;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(139, 115, 85, 0.08);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.llm-narrative-box p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.llm-narrative-box .llm-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-dark);
  background: rgba(139, 115, 85, 0.14);
  padding: 2px 8px;
  border-radius: 8px;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

/* ---- 排队中：单行动态角标 + 宽 shimmer（满宽到父卡片右内侧） ---- */
.llm-narrative-box.llm-pending {
  background: linear-gradient(135deg, rgba(251, 246, 232, 0.6) 0%, rgba(248, 240, 220, 0.6) 100%);
  border-left-color: var(--accent);
  border-left-width: 3px;
  padding: 10px 12px 10px 14px;
  margin: 8px 0 12px;
  box-shadow: 0 1px 2px rgba(139, 115, 85, 0.06);
  min-height: 48px;
  display: flex;
  align-items: center;
  /* 让整行到父卡片右内侧 */
  width: 100%;
  box-sizing: border-box;
}
.llm-narrative-box.llm-pending .llm-badge {
  background: rgba(139, 115, 85, 0.14);
  color: var(--accent-dark);
  margin-bottom: 0;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  animation: llm-pulse 1.2s ease-in-out infinite;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;        /* 角标不缩，宽度固定 */
  border-radius: 12px;
}
.llm-shimmer-inline {
  display: inline-block;
  flex: 1;                /* 占满剩余空间到父卡片右内侧 */
  height: 10px;
  border-radius: 5px;
  background: rgba(139, 115, 85, 0.18);
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  margin-left: 4px;
  min-width: 0;           /* 允许多行缩 */
}
.llm-shimmer-inline::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(139, 115, 85, 0.7) 50%,
    transparent 100%);
  animation: llm-shimmer 1.4s linear infinite;
}
.llm-skeleton {
  position: relative;
  height: 14px;
  margin: 10px 0;
  background: rgba(139, 115, 85, 0.12);
  border-radius: 4px;
  overflow: hidden;
}
.llm-skeleton-short { width: 65%; }
.llm-skeleton-mid   { width: 88%; }
.llm-skeleton-single {
  height: 20px;
  width: 100%;
  margin: 6px 0 0;
}
.llm-skeleton .llm-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.85) 50%,
    transparent 100%);
  animation: llm-shimmer 1.6s linear infinite;
}
@keyframes llm-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes llm-shimmer-overlay {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes llm-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ---- 加载完成：淡入 + 高度自然展开 ---- */
.llm-narrative-box.llm-loaded {
  opacity: 0;
  transform: translateY(6px);
}
.llm-narrative-box.llm-loaded.show {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
/* nn-loaded 的内容区背景不抖动：从骨架（白色块）淡入到真实内容（白底） */
.llm-narrative-box.llm-loaded .llm-badge {
  transition: background 0.4s ease, color 0.4s ease;
}

/* summary 卡片稍大 */
#llm-summary-box {
  font-size: 14.5px;
  line-height: 1.95;
  padding: 14px 14px 14px 18px;
}
