/* ============ 黃曆 · 全站樣式 ============ */
:root {
  --bg: #f4f2ec;
  --card: #ffffff;
  --ink: #33302a;
  --ink-2: #6f6a5f;
  --ink-3: #a29b8c;
  --red: #c2402f;
  --red-deep: #9e3225;
  --red-soft: #fbeeec;
  --gold: #9a7b3f;
  --gold-soft: #f5efe2;
  --green: #3d7a50;
  --line: #e7e2d6;
  --radius: 14px;
  --kai: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- 頂欄 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1000px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none !important; color: var(--ink); }
.logo { width: 34px; height: 34px; align-self: center; fill: var(--red); }
.brand-name {
  font-family: var(--kai); font-size: 24px; font-weight: 700; letter-spacing: 4px;
  color: var(--ink);
}
.brand-sub { font-size: 12px; color: var(--ink-3); letter-spacing: 1px; }

.topnav { display: flex; align-items: center; gap: 8px; }
.btn {
  font: inherit; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 9px; padding: 6px 14px; cursor: pointer;
  transition: all .16s ease;
}
.btn:hover { border-color: var(--red); color: var(--red); }
.btn:active { transform: scale(.96); }
.btn.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.solid:hover { background: var(--red-deep); color: #fff; }
.btn.ghost { padding: 6px 10px; }
.btn.sm { padding: 2px 10px; font-size: 14px; }
#date-pick {
  font: inherit; border: 1px solid var(--line); border-radius: 9px;
  padding: 5px 10px; color: var(--ink); background: var(--card);
}
#date-pick:focus { outline: 2px solid rgba(194,64,47,.3); border-color: var(--red); }

/* ---------- 版面 ---------- */
.page { max-width: 1000px; margin: 0 auto; padding: 22px 20px 40px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
  box-shadow: 0 1px 4px rgba(60,50,30,.05);
}
.block { margin-top: 18px; }
.block-title {
  font-family: var(--kai); font-size: 17px; letter-spacing: 4px;
  display: flex; align-items: center; gap: 9px; margin-bottom: 14px;
}
.block-title::before {
  content: ""; width: 4px; height: 17px; border-radius: 2px; background: var(--red);
}

/* ---------- 當日詳情（紙質黃曆版式） ---------- */
.detail {
  position: relative;
  padding: 26px 30px 30px;
  background: linear-gradient(180deg, #fffdf7, #fffdf7);
  border-color: #e5dbc6;
}
.detail::before {                       /* 朱砂雙線框 */
  content: ""; position: absolute; inset: 7px;
  border: 1px solid rgba(194, 64, 47, .45); border-radius: 9px;
  pointer-events: none;
}
.detail::after {                        /* 內細線 */
  content: ""; position: absolute; inset: 11px;
  border: 1px solid rgba(194, 64, 47, .22); border-radius: 6px;
  pointer-events: none;
}

.paper-date { display: flex; align-items: center; justify-content: center; gap: 16px; }
.paper-date::before, .paper-date::after {
  content: ""; flex: 1; max-width: 150px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(194,64,47,.4));
}
.paper-date::after { background: linear-gradient(270deg, transparent, rgba(194,64,47,.4)); }
.paper-date span {
  font-size: 13.5px; color: var(--ink-2); letter-spacing: 2px; white-space: nowrap;
}

.paper-grid {
  display: grid; grid-template-columns: 1fr 1.2fr 1fr;
  gap: 24px; align-items: center; margin-top: 20px;
}

/* 宜 / 忌 豎排面板（傳統右宜左忌） */
.yj-paper { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.seal {
  font-family: var(--kai); font-size: 21px; letter-spacing: 0;
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 7px; background: #3b362d; color: #f6f2e9;
  box-shadow: 0 2px 5px rgba(50,40,20,.18);
}
.seal.red { background: var(--red); color: #fdf6e8; }
.vitems {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 7px; max-width: 236px;
}
.vitems span {
  font-family: var(--kai); font-size: 13px; letter-spacing: 1.5px;
  padding: 3px 11px; border-radius: 999px; line-height: 1.5;
}
.yi .vitems span { background: var(--red-soft); color: var(--red-deep); }
.ji .vitems span { background: #f0ede3; color: #45403a; }

.paper-center { text-align: center; padding: 10px 20px 0; }
.paper-center .lunar-big {
  font-family: var(--kai); font-size: 74px; font-weight: 700;
  line-height: 1.3; letter-spacing: 6px; margin: 0 -6px 2px 0;
}
.paper-center .lunar-full { font-size: 15px; color: var(--ink-2); letter-spacing: 3px; }
.paper-center .pillars {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 14px; color: var(--ink-2); letter-spacing: 1px;
}
.paper-center .pillars b { color: var(--ink); font-family: var(--kai); font-size: 17px; margin: 0 6px 0 2px; }
.paper-center .clash { margin-top: 5px; font-size: 13px; color: var(--ink-2); }
.paper-center .clash b { color: var(--red); }

@media (max-width: 760px) {
  .detail { padding: 20px 16px 24px; }
  .paper-grid { grid-template-columns: 1fr; gap: 20px; }
  .paper-center { order: -1; padding: 0; }
  .yj-paper { flex-direction: row; justify-content: center; align-items: center; gap: 14px; }
  .vitems { justify-content: flex-start; max-width: 320px; }
}

/* ---------- 速覽 ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-top: 18px; padding: 16px 22px; }
.fact { border-left: 3px solid var(--gold-soft); padding-left: 10px; }
.fact .k { font-size: 11.5px; color: var(--gold); letter-spacing: 2px; }
.fact .v { font-size: 14.5px; font-weight: 600; }
.fact.dir { border-left-color: var(--red); }
.fact.dir .k { color: var(--red-deep); }
.fact.dir .v { font-family: var(--kai); font-size: 16px; }

/* ---------- 時辰 ---------- */
.hours-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 2px 2px 10px; border-bottom: 1px dashed var(--line); margin-bottom: 10px;
}
.hours-head .hh-k {
  font-family: var(--kai); font-size: 13px; color: var(--red);
  letter-spacing: 2px; white-space: nowrap;
}
.hours-head .hh-v { font-size: 14px; font-weight: 700; color: var(--red-deep); letter-spacing: 2px; }
.hours-head .hh-v.none { color: var(--ink-3); font-weight: 500; }

.hours { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.hour {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  background: #fcfbf8; transition: all .15s ease;
}
.hour:hover { transform: translateY(-2px); box-shadow: 0 3px 10px rgba(60,50,30,.09); }
.hour .row1 { display: flex; justify-content: space-between; align-items: baseline; }
.hour .name { font-weight: 700; font-size: 15px; }
.hour .time { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hour .row2 { display: flex; justify-content: space-between; font-size: 11px; margin-top: 2px; }
.hour .sc { color: var(--ink-3); }
.hour .star { font-weight: 600; }
.hour .row3 {
  font-size: 11px; color: var(--ink-2); margin-top: 3px; line-height: 1.6;
}
.hour .row3 .lab {
  display: inline-block; font-size: 10px; border-radius: 4px;
  padding: 0 4px; margin-right: 5px; letter-spacing: 1px;
}
.hour .row3 .yi2 { background: var(--red-soft); color: var(--red-deep); }
.hour .row3 .ji2 { background: #efece3; color: #4a453c; }
.hour.good { border-left: 3px solid var(--red); background: #fdf7f5; }
.hour.good .star { color: var(--red); }
.hour.bad { border-left: 3px solid #cfc9bb; }
.hour.bad .star { color: var(--ink-3); }

/* ---------- 節氣 ---------- */
.term-now { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 560px) { .term-now { grid-template-columns: 1fr; } }
.tn {
  background: linear-gradient(150deg, var(--red-soft), #fdf7f2);
  border: 1px solid #f0dcd5; border-radius: 12px; padding: 14px 18px;
}
.tn:last-child { background: linear-gradient(150deg, var(--gold-soft), #fbf8f0); border-color: #e8dfc8; }
.tn-k { font-size: 11.5px; color: var(--ink-3); letter-spacing: 2px; }
.tn-name { font-family: var(--kai); font-size: 30px; font-weight: 700; color: var(--red); line-height: 1.4; }
.tn-name.gold { color: var(--gold); }
.tn-d { font-size: 13px; color: var(--ink-2); }
.tn-p { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.tn-p em { font-style: normal; color: var(--red); font-weight: 600; }
.tn:last-child .tn-p em { color: var(--gold); }

.term-strip { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  background: #fcfbf8;
}
.chip b { font-weight: 600; font-size: 12.5px; color: var(--ink); letter-spacing: 1px; }
.chip.past { opacity: .38; }
.chip.cur { background: var(--red); border-color: var(--red); }
.chip.cur b, .chip.cur { color: #fff; }

/* ---------- 月曆 ---------- */
.cal-head { display: flex; justify-content: space-between; align-items: center; }
.cal-nav { display: flex; gap: 6px; }
.calendar table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th { font-size: 12px; color: var(--ink-3); font-weight: 500; padding: 6px 0; }
.calendar th:first-child { color: var(--red); }
.calendar th:last-child { color: var(--gold); }
.calendar td { text-align: center; padding: 2px 0; }
.cell {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; max-width: 46px; height: 52px; border-radius: 12px;
  cursor: pointer; transition: background .14s ease;
}
.cell:focus-visible { outline-offset: -2px; }
.cell:hover { background: var(--gold-soft); }
.cell .num { font-size: 16.5px; font-weight: 600; line-height: 1.3; }
.cell .lunar { font-size: 10px; color: var(--ink-3); line-height: 1.4; max-width: 46px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cell .lunar.term, .cell .lunar.fest { color: var(--red); }
.cell .lunar.month { color: var(--gold); }
.cell.sel { background: var(--red); box-shadow: 0 3px 10px rgba(158,50,37,.35); }
.cell.sel .num, .cell.sel .lunar { color: #fff; }
.cell.sel .lunar.fest, .cell.sel .lunar.term { color: #ffd9c9; }
.cell.today:not(.sel) { border: 1px solid var(--red); }
.cell.dim { opacity: .3; }
.cal-legend { margin-top: 12px; font-size: 12px; color: var(--ink-3); text-align: center; }
.dot-today, .dot-sel { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin: 0 2px; }
.dot-today { border: 1px solid var(--red); }
.dot-sel { background: var(--red); }

/* ---------- 二維碼（弱化為附屬位，不與內容卡爭層級） ---------- */
.qrcodes { display: flex; justify-content: center; gap: 22px; margin-top: 18px; flex-wrap: wrap; }
.qr { text-align: center; padding: 12px; width: 150px; box-shadow: none; background: rgba(255,255,255,.6); }
.qr img { width: 100%; height: auto; border-radius: 8px; display: block; }
.qr figcaption { margin-top: 8px; font-size: 13px; color: var(--ink-2); letter-spacing: 2px; }

/* ---------- 頁腳 ---------- */
.foot { text-align: center; padding: 18px 20px 34px; font-size: 12.5px; color: var(--ink-3); }
