/* ZhiMing Web UI —— 紧凑命理审美 */

* { box-sizing: border-box; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Serif SC", serif;
  font-size: 14px;
  line-height: 1.5;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  background: #fafaf7;
  color: #222;
}

header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  color: #4a3a2a;
}
.subtitle {
  margin: 0 0 24px;
  color: #888;
  font-size: 13px;
}

h2 {
  border-bottom: 2px solid #c9b88a;
  padding-bottom: 4px;
  margin-top: 32px;
  color: #4a3a2a;
  font-size: 18px;
}
h3 {
  margin-top: 18px;
  color: #6a5a3a;
  font-size: 15px;
}

section {
  background: #fff;
  padding: 16px 20px;
  border: 1px solid #e8e0d0;
  border-radius: 4px;
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #555;
}
input, select {
  font-family: inherit;
  font-size: 14px;
  padding: 4px 8px;
  border: 1px solid #c9b88a;
  border-radius: 3px;
  background: #fff;
  min-width: 140px;
}

button {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 16px;
  border: 1px solid #8a7a5a;
  background: #c9b88a;
  color: #fff;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 8px;
}
button:hover { background: #b9a87a; }
button:disabled { background: #ccc; border-color: #999; cursor: wait; }

#add-event { background: #6a8a6a; border-color: #5a7a5a; }
#add-event:hover { background: #5a7a5a; }

.event-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: center;
}
.event-row select, .event-row input { min-width: 100px; }
.event-row .remove { background: #aa6a5a; border-color: #8a4a3a; padding: 4px 10px; }
.event-row .remove:hover { background: #8a4a3a; }

.submit-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#loading { color: #b85a3a; font-style: italic; }

.card {
  background: #fff;
  padding: 16px 20px;
  border: 1px solid #e8e0d0;
  border-radius: 4px;
  margin-bottom: 16px;
}

pre {
  background: #f5f0e5;
  padding: 12px;
  border-radius: 3px;
  border: 1px solid #e8e0d0;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
th, td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #e8e0d0;
  font-size: 13px;
}
th {
  background: #f5f0e5;
  color: #6a5a3a;
  font-weight: 600;
}
tr.top1 td { background: #f9f5e6; font-weight: 600; }

.event-card {
  background: #fafaf3;
  padding: 10px 14px;
  border-left: 3px solid #c9b88a;
  margin-bottom: 10px;
  border-radius: 2px;
}
.event-card .head { font-weight: 600; color: #4a3a2a; }
.event-card .signals { font-size: 12.5px; color: #555; margin-top: 4px; }

.expert-card {
  background: #fafaf3;
  padding: 10px 14px;
  border-left: 3px solid #6a8a6a;
  margin-bottom: 10px;
  border-radius: 2px;
}
.expert-card .school { font-weight: 600; color: #4a3a2a; margin-bottom: 4px; }
.expert-card .judgment { font-size: 13px; white-space: pre-wrap; }

/* ----- 八字合一表（bz.jpg 风格：四柱纵向排盘） ----- */
table.bazi { table-layout: fixed; }
table.bazi thead th { height: 0; border: none; padding: 0; }
table.bazi tbody tr { display: block; }
table.bazi tbody td.bz-col {
  display: inline-block;
  vertical-align: top;
  width: 22%;
  padding: 6px 4px;
  border-right: 1px dashed #e8e0d0;
  text-align: center;
  border-bottom: none;
}
table.bazi tbody td.bz-col.is-day {
  background: #fff5dc;
  border-left: 2px solid #c9b88a;
  border-right: 2px solid #c9b88a;
}
table.bazi tbody td.bz-col:last-child { border-right: none; }
.bz-nayin { font-size: 12px; color: #6a5a3a; margin-bottom: 4px; }
.bz-shishen { font-size: 13px; color: #4a3a2a; font-weight: 600; margin-bottom: 6px; }
.bz-hidegan-list { min-height: 60px; margin-bottom: 6px; }
.bz-hidegan { font-size: 12px; color: #6a5a3a; line-height: 1.4; }
.bz-zhi {
  font-size: 32px;
  font-weight: 700;
  color: #4a3a2a;
  line-height: 1.2;
  margin-bottom: 2px;
}
.bz-gan {
  font-size: 36px;
  font-weight: 700;
  color: #4a3a2a;
  line-height: 1.1;
}
/* 天干五行色（bz.jpg 风格：甲乙木青、丙丁火红、戊己土黄、庚辛金白、壬癸水黑） */
.bz-gan[data-wx="木"], .bz-zhi[data-wx="木"] { color: #2d7a3a; }
.bz-gan[data-wx="火"], .bz-zhi[data-wx="火"] { color: #c43a2a; }
.bz-gan[data-wx="土"], .bz-zhi[data-wx="土"] { color: #b8901a; }
.bz-gan[data-wx="金"], .bz-zhi[data-wx="金"] { color: #6a5a3a; }
.bz-gan[data-wx="水"], .bz-zhi[data-wx="水"] { color: #2a4a8a; }
table.bazi td.is-day .bz-gan, table.bazi td.is-day .bz-zhi {
  color: #6a4a2a;
}

/* ----- 大运表（横向 8+ 列 × 流年 10 行，列间距紧凑） ----- */
table#dayun-table { table-layout: fixed; }
table#dayun-table th {
  font-size: 10px;
  color: #888;
  font-weight: normal;
  padding: 2px 1px;
}
table#dayun-table td {
  font-size: 11px;
  text-align: center;
  padding: 2px 1px;
  border-bottom: 1px solid #e8e0d0;
}
table#dayun-table td.da-yun-ganzhi {
  font-size: 16px;
  font-weight: 700;
  color: #4a3a2a;
  padding: 6px 1px;
  border-bottom: 2px solid #c9b88a;
}

/* ----- 紫微 12 宫方格（文墨天机风格：4 列 × 3 行 + 中央元信息条 + 盘外 4 角方位） ----- */
.ziwei-grid-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: #6a5a3a;
  margin-bottom: 8px;
}
.ziwei-grid-meta .legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.ziwei-grid-meta .legend i.star-major { background: #4a3a2a; }
.ziwei-grid-meta .legend i.star-soft { background: #6a8a6a; }
.ziwei-grid-meta .legend i.star-tough { background: #aa3a3a; }
.ziwei-grid-meta .legend i.star-adj { background: #c9b88a; }

.ziwei-frame {
  position: relative;
  padding: 22px 28px;          /* 给 4 角方位留位置 */
  background: #fafaf3;
  border: 2px solid #c9b88a;
  border-radius: 4px;
  box-sizing: border-box;
}
.ziwei-frame .compass {
  position: absolute;
  font-size: 10.5px;
  color: #888;
  font-weight: 500;
  letter-spacing: 1px;
}
.ziwei-frame .compass.top    { top: 4px;     left: 50%; transform: translateX(-50%); }
.ziwei-frame .compass.bottom { bottom: 4px;  left: 50%; transform: translateX(-50%); }
.ziwei-frame .compass.left   { left: 4px;    top: 50%;  transform: translateY(-50%); writing: vertical-rl; }
.ziwei-frame .compass.right  { right: 4px;   top: 50%;  transform: translateY(-50%); writing: vertical-rl; }

.ziwei-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 100px);
  gap: 4px;
  background: #c9b88a;
  border: 1px solid #c9b88a;
  border-radius: 3px;
  padding: 2px;
}
.ziwei-grid .palace-cell {
  position: relative;
  background: #fafaf3;
  border: 1px solid #e8e0d0;
  padding: 6px 8px 22px;
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ziwei-grid .palace-cell.is-ming {
  background: #fff5dc;
  border-color: #6a4a2a;
  box-shadow: inset 0 0 0 1px #c9b88a;
}
/* 第 1 行（主星 + 6吉6煞 + 天马禄存）+ 杂曜行 */
.ziwei-grid .stars-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1px 3px;
  align-content: flex-start;
}
.ziwei-grid .stars-row.row4 {
  justify-content: flex-start;
  color: #888;
  font-size: 10px;
  margin-top: auto;
}
.ziwei-grid .stars-row.row5 {
  justify-content: flex-end;
  color: #aaa;
  font-size: 10px;
}
.ziwei-grid .muted { color: #bbb; font-size: 11px; }
/* 单颗星：四化竖排（display:block）+ 红框 */
.ziwei-grid .star {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin-right: 3px;
  line-height: 1.05;
}
.ziwei-grid .star-major { color: #4a3a2a; font-weight: 700; font-size: 12px; }
.ziwei-grid .star-soft { color: #6a8a6a; font-size: 11px; }
.ziwei-grid .star-tough { color: #aa3a3a; font-size: 11px; }
.ziwei-grid .star-adj { color: #888; font-size: 10.5px; }
.ziwei-grid .star-flower { color: #b85a8a; font-size: 10.5px; }
/* 四化：红框小方块（禄/权/科/忌） */
.ziwei-grid .mutagen {
  display: inline-block;
  color: #c43a2a;
  background: #fff5f5;
  border: 1px solid #c43a2a;
  border-radius: 2px;
  padding: 0 3px;
  margin-top: 1px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.4;
  min-width: 12px;
  text-align: center;
}
/* 左下角：宫名（横排） */
.ziwei-grid .cell-corner-bl {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-weight: 600;
  color: #4a3a2a;
  font-size: 12px;
}
/* 右下角：宫干支（竖排：干上、支下） */
.ziwei-grid .cell-corner-br {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #6a5a3a;
  font-size: 11px;
  line-height: 1.1;
  font-weight: 600;
}
/* 底部中央：大限岁数 */
.ziwei-grid .cell-decadal {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  color: #888;
  font-size: 10px;
  font-weight: 500;
}

/* 中央元信息条：占中央 2×2（row 2-3 × col 2-3） */
.ziwei-grid .ziwei-meta {
  grid-row: 2 / 4;
  grid-column: 2 / 4;
  background: #fff5dc;
  border: 1px solid #c9b88a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #4a3a2a;
  text-align: center;
  line-height: 1.6;
  padding: 4px 8px;
  border-radius: 2px;
}
.ziwei-grid .ziwei-meta .meta-row { display: block; }
.ziwei-grid .ziwei-meta b { color: #6a4a2a; font-size: 13px; margin-right: 4px; }

/* 反馈留言 modal */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff8e7;
  border: 1px solid #c9b88a;
  border-radius: 4px;
  padding: 20px;
  width: 90%; max-width: 480px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.modal-box h3 {
  margin: 0 0 12px;
  color: #4a3a2a;
  border-bottom: 1px solid #c9b88a;
  padding-bottom: 6px;
}
.modal-box button {
  padding: 6px 16px;
  background: #c9b88a;
  color: #4a3a2a;
  border: 1px solid #a89870;
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
}
.modal-box button:hover { background: #d9c89a; }
.modal-box button:disabled { opacity: 0.5; cursor: not-allowed; }
#feedback-cancel { background: #eee; color: #666; }
#feedback-cancel:hover { background: #ddd; }