/* ===== 基础 ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #faf6ec;
  color: #2a2a2a;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶部 ===== */
.topbar {
  background: #fff;
  padding: 16px 28px 14px;
  border-bottom: 1px solid #ece6d6;
  position: sticky; top: 0; z-index: 5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.02);
}
.brand-line {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; flex-wrap: wrap;
}
.brand-line .date-range {
  font-size: 13px;
  font-weight: 500;
  color: #888;
  margin-left: auto;
  letter-spacing: 0.5px;
}
.brand-line .big {
  font-size: 24px;
  color: #c93b2c;
  letter-spacing: 1px;
}
.brand-line .chip {
  font-size: 12px;
  padding: 2px 10px;
  background: #f3eada;
  color: #7a5a25;
  border-radius: 999px;
  font-weight: 500;
}
.chip-city {
  background: #e6f2e2;
  color: #3a7a36;
}
.sub-line {
  display: flex; justify-content: flex-end; align-items: center;
  margin-top: 8px;
  color: #888;
  font-size: 13px;
}
.sub-line .tip {
  color: #a04a30;
  background: #fbeee0;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
}

.controls {
  display: flex; gap: 12px; align-items: center;
  margin-top: 12px; flex-wrap: wrap;
}
.controls label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #555;
}
.controls input[type="date"],
.controls input[type="number"],
.controls select {
  padding: 5px 8px;
  border: 1px solid #d8d0bb;
  border-radius: 4px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: #333;
}
.controls input[type="number"] { width: 75px; }

.master-picker {
  display: flex; gap: 4px; align-items: center;
  background: #faf6ec;
  padding: 2px 4px;
  border-radius: 6px;
}
.master-picker .label {
  font-size: 13px; color: #555;
  margin: 0 4px;
}
.master-btn {
  padding: 4px 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: #555;
  transition: all 0.1s;
}
.master-btn:hover {
  background: #fff;
  border-color: #d4a64a;
  color: #8a6a1a;
}
.master-btn.active {
  background: #c93b2c;
  color: #fff;
  border-color: #c93b2c;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(201,59,44,0.25);
}

.switch-pills {
  display: flex; gap: 12px;
}
.switch {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: #555;
  cursor: pointer;
  user-select: none;
}
.switch input { margin: 0; cursor: pointer; }

.action-btn {
  padding: 5px 14px;
  background: #c93b2c;
  color: #fff;
  border: none;
  border-radius: 4px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.action-btn:hover { background: #a82e22; }

/* ===== 日历网格 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  padding: 18px 20px 50px;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 10px 12px;
  border: 1px solid #ece6d6;
  display: flex; flex-direction: column; gap: 5px;
  min-height: 200px;
  position: relative;
  transition: transform 0.1s, box-shadow 0.1s;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  border-color: #d8d0bb;
}
.card.has-flag { border-color: #f1c4a8; }
.card.flag-ren { background: #fff5f0; }

/* 今日卡片 */
.card.today {
  border: 2px solid #c93b2c;
  background: linear-gradient(135deg, #fff7f0 0%, #fff 60%);
  box-shadow: 0 4px 14px rgba(201, 59, 44, 0.15);
  transform: translateY(-2px);
}
/* 今日角标已去掉 — 红框 + "今"字已足够 */
.card.today .date {
  color: #c93b2c;
  font-weight: 800;
}
.today-tag {
  display: inline-block;
  background: #c93b2c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

/* 日期行 */
.date-row { display: flex; flex-direction: column; line-height: 1.2; }
.date { font-weight: 700; font-size: 16px; color: #222; }
.weekday { font-size: 12px; color: #888; margin-top: 1px; }
.lunar { font-size: 11px; color: #999; margin-top: 1px; }

/* 干支 */
.gan-row { display: flex; gap: 4px; margin-top: 6px; }
.gan {
  display: inline-flex; justify-content: center; align-items: center;
  width: 30px; height: 30px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.el-row { display: flex; gap: 4px; }
.el {
  font-size: 11px;
  color: #888;
  width: 30px; text-align: center;
}

/* 十神 */
.ten-row { display: flex; gap: 4px; margin-top: 2px; }
.ten {
  display: inline-flex; justify-content: center; align-items: center;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  background: #f0eada;
  color: #5a4a25;
  font-weight: 500;
}

/* 建除 + 值日神 */
.jz-row {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}
.jianchu {
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 500;
}
.jianchu.jc-黑 { background: #e8e3d3; color: #6a5a30; }
.jianchu.jc-黄 { background: #fbf2dc; color: #8a6a1a; }
.zhishi.zs-吉 { color: #2a7a3a; font-weight: 500; }
.zhishi.zs-凶 { color: #a04030; font-weight: 500; }
.dot { color: #ccc; }

/* 节日 */
.festival {
  font-size: 11px;
  color: #c93b2c;
  background: #fbeee0;
  padding: 2px 7px;
  border-radius: 3px;
  align-self: flex-start;
  font-weight: 500;
}

/* 特殊日 */
.flag-row { display: flex; flex-wrap: wrap; gap: 4px; }
.flag {
  font-size: 10px;
  padding: 2px 6px;
  background: #fbe0db;
  color: #a8331f;
  border-radius: 3px;
  font-weight: 500;
}

/* 提示语 */
.prompts {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: 11.5px;
  color: #555;
  line-height: 1.55;
}
.prompts li { margin-bottom: 2px; }

.copy-hint {
  position: absolute;
  bottom: 6px; right: 8px;
  font-size: 10px;
  color: #ccc;
  opacity: 0;
  transition: opacity 0.1s;
}
.card:hover .copy-hint { opacity: 1; }

/* 纯净版 */
.grid.pure .card { min-height: 130px; }
.grid.pure .card:hover { transform: none; cursor: default; }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 20, 20, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-box {
  background: #fffaf0;
  border-radius: 12px;
  padding: 28px 32px 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  color: #888;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #c93b2c; }
.modal-box h2 {
  margin: 0 0 4px;
  font-size: 20px;
  color: #222;
}
.gz-line {
  font-size: 14px;
  color: #666;
  margin-bottom: 16px;
}
.modal-section {
  margin-bottom: 18px;
}
.modal-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.pillars {
  display: flex; gap: 16px;
}
.pillar {
  flex: 1;
  text-align: center;
  background: #fff;
  padding: 12px 8px;
  border-radius: 8px;
  border: 1px solid #ece6d6;
}
.pill-label { font-size: 11px; color: #999; margin-bottom: 4px; }
.pill-big {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border-radius: 6px;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin: 4px 0;
}
.pill-sub { font-size: 11px; color: #888; }
.pill-ten {
  font-size: 12px;
  color: #5a4a25;
  background: #f0eada;
  padding: 2px 8px;
  border-radius: 3px;
  display: inline-block;
  margin-top: 4px;
}
.hidden-stems {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.hidden-stem {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.hidden-stem em {
  font-style: normal;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.9;
  background: rgba(255,255,255,0.25);
  padding: 1px 5px;
  border-radius: 3px;
}
.jz-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.jc-chip, .zs-chip {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
}
.zs-chip em.zs-type {
  font-style: normal;
  font-size: 11px;
  opacity: 0.75;
  margin-left: 4px;
  font-weight: 400;
}
/* 建除"大凶"(破/闭)用更深的红 */
.jc-chip.jc-凶, .jianchu.jc-凶 {
  background: #d94030;
  color: #fff;
  font-weight: 600;
}
.jc-chip.jc-黑 { background: #e8e3d3; color: #6a5a30; }
.jc-chip.jc-黄 { background: #fbf2dc; color: #8a6a1a; }
.zs-chip.zs-吉 { background: #e6f2e2; color: #2a7a3a; }
.zs-chip.zs-凶 { background: #fbe0db; color: #a04030; }
.yiji { display: flex; flex-direction: column; gap: 8px; }
.yiji-row { display: flex; align-items: center; gap: 8px; }
.yiji-label {
  font-size: 12px;
  color: #888;
  width: 40px;
}
.yiji-note {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  padding-left: 48px;
  line-height: 1.5;
}
.el-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.el-chip.like { border: 1px solid; }
.el-chip.dislike { border: 1px solid; }
.empty { color: #aaa; font-size: 12px; }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag-big {
  padding: 4px 10px;
  background: #fbe0db;
  color: #a8331f;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.prompts-list ul {
  list-style: none; padding: 0; margin: 0;
}
.prompts-list li {
  font-size: 13px;
  color: #555;
  line-height: 1.6;
  padding-left: 14px;
  position: relative;
}
.prompts-list li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: #c93b2c;
  font-weight: 700;
}
.modal-actions {
  margin-top: 16px;
  text-align: center;
}

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(40,40,40,0.92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================ */
/* ============ 响应式: 平板 (< 900px) ============ */
/* ============================================ */
@media (max-width: 900px) {
  .topbar { padding: 12px 16px 10px; }
  .brand-line .big { font-size: 20px; }
  .sub-line { font-size: 12px; }
  .controls { gap: 8px; }
  .controls input[type="date"] { padding: 4px 6px; font-size: 12px; }
  .controls input[type="number"] { width: 60px; padding: 4px 6px; font-size: 12px; }
  .master-btn { padding: 3px 8px; font-size: 12px; }
  .grid { gap: 6px; padding: 12px; }
  .card { padding: 8px; min-height: 170px; }
  .date { font-size: 15px; }
  .gan { width: 26px; height: 26px; font-size: 14px; }
  .el { width: 26px; font-size: 10px; }
  .ten { font-size: 11px; padding: 1px 6px; }
  .prompts { font-size: 10.5px; }
  .prompts li { line-height: 1.45; }
}

/* ============================================ */
/* ============ 响应式: 手机 (< 640px) ============ */
/* ============================================ */
@media (max-width: 640px) {
  html, body { font-size: 13px; }

  .topbar {
    padding: 10px 12px 10px;
  }
  .brand-line { gap: 6px; }
  .brand-line .big { font-size: 16px; letter-spacing: 0.5px; }
  .brand-line .chip { font-size: 10px; padding: 1px 7px; }
  .sub-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    font-size: 11px;
  }
  .sub-line .tip { font-size: 10px; padding: 1px 8px; }

  /* 控件: 分多行, 紧凑 */
  .controls {
    gap: 6px;
    margin-top: 8px;
  }
  .controls > label {
    font-size: 11px;
  }
  .controls input[type="date"] { padding: 4px; font-size: 11px; }
  .controls input[type="number"] { width: 50px; padding: 4px; font-size: 11px; }
  .controls .action-btn { padding: 5px 10px; font-size: 12px; }
  .switch { font-size: 11px; }

  /* 日主: 5 个一行换行 */
  .master-picker {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
  }
  .master-picker .label { font-size: 11px; flex-shrink: 0; }
  .master-btn {
    padding: 3px 7px;
    font-size: 11px;
    flex-shrink: 0;
  }

  /* 7 列压缩, 内容裁切到核心 */
  .grid {
    gap: 3px;
    padding: 8px 6px 30px;
  }
  .card {
    padding: 4px 3px 6px;
    min-height: 0;
    border-radius: 5px;
    gap: 2px;
  }
  .card:hover { transform: none; }
  .card.has-flag { border-color: #f1c4a8; }
  .card.flag-ren { background: #fff5f0; }

  /* 今日卡片 mobile: 不上移, 红色粗边框保留 */
  .card.today {
    transform: none;
    box-shadow: 0 0 0 2px #c93b2c inset, 0 2px 6px rgba(201,59,44,0.2);
  }
  .card.today::before {
    font-size: 7px;
    padding: 1px 4px 2px;
    letter-spacing: 0.5px;
  }

  .date { font-size: 12px; line-height: 1.1; }
  .weekday { font-size: 9px; margin-top: 0; }
  .lunar { font-size: 9px; margin-top: 0; }
  .today-tag { font-size: 8px; padding: 0 4px; margin-left: 3px; }

  .gan-row { gap: 2px; margin-top: 2px; }
  .gan {
    width: 20px; height: 20px;
    font-size: 11px;
    border-radius: 3px;
  }
  .el-row { gap: 2px; }
  .el { width: 20px; font-size: 8px; }

  /* 移动端隐藏次要信息, 靠 modal 看完整 */
  .ten-row, .jz-row, .prompts, .flag-row, .festival {
    display: none;
  }
  /* 但保留"点开详情"提示, 告诉用户卡片可点 */
  .copy-hint {
    display: block;
    text-align: center;
    font-size: 9px;
    color: #c93b2c;
    opacity: 0.7;
    margin-top: 2px;
  }

  /* 移动端 .card.today 角标已去掉 (同桌面版) */

  /* Modal: 全屏从底部弹出 */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 22px 18px 18px;
  }
  .modal-box h2 { font-size: 18px; }
  .gz-line { font-size: 12px; margin-bottom: 12px; }
  .modal-section { margin-bottom: 14px; }
  .modal-section h3 { font-size: 10px; }
  .pillars { gap: 10px; }
  .pillar { padding: 8px 4px; }
  .pill-big { width: 40px; height: 40px; font-size: 20px; }
  .modal-close {
    top: 8px; right: 10px;
    width: 36px; height: 36px;
    font-size: 22px;
  }
  .prompts-list li { font-size: 12.5px; line-height: 1.55; }

  /* Toast 在手机上往上挪避开底部手势 */
  #toast { bottom: 30px; padding: 8px 18px; font-size: 13px; }
}

/* ============================================ */
/* ============ 响应式: 小屏 (< 380px) ============ */
/* ============================================ */
@media (max-width: 380px) {
  .brand-line .big { font-size: 14px; }
  .controls > label { font-size: 10px; }
  .date { font-size: 11px; }
  .gan { width: 18px; height: 18px; font-size: 10px; }
  .el { width: 18px; font-size: 7px; }
}
