/* ============================================================
   大統曆 明代萬年曆 · 紙墨朱印
   ============================================================ */
:root {
  --paper: #f4efe3;
  --paper-2: #ece5d5;
  --paper-3: #e3d9c5;
  --ink: #17170f;
  --ink-2: #2a2a20;
  --muted: #7b7565;
  --faint: #9b9482;
  --red: #a3372a;
  --red-dark: #8a2a20;
  --red-soft: #bf4a34;
  --gold: #a9854e;
  --gold-soft: #c8a468;
  --jade: #2c4a3d;
  --line: rgba(23, 23, 15, 0.16);
  --line-strong: rgba(23, 23, 15, 0.3);
  --shadow: 0 30px 80px rgba(30, 24, 12, 0.12);
  --shadow-sm: 0 8px 24px rgba(30, 24, 12, 0.07);
  --serif: "Noto Serif TC", "Songti TC", "Songti SC", "Noto Serif CJK TC", "PMingLiU", "SimSun", serif;
  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-synthesis: none;
  background:
    radial-gradient(120% 80% at 80% -20%, rgba(201, 164, 104, 0.12), transparent 60%),
    radial-gradient(90% 60% at -10% 30%, rgba(44, 74, 61, 0.06), transparent 70%),
    var(--paper);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    repeating-linear-gradient(0deg, rgba(90, 68, 42, 0.028) 0, rgba(90, 68, 42, 0.028) 1px, transparent 1px, transparent 4px),
    repeating-linear-gradient(90deg, rgba(90, 68, 42, 0.018) 0, rgba(90, 68, 42, 0.018) 1px, transparent 1px, transparent 6px);
  mix-blend-mode: multiply;
}

::selection { background: rgba(163, 49, 40, 0.18); }

.site-bridge {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px max(20px, calc((100vw - 1280px) / 2));
  background: rgba(244, 239, 227, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.site-bridge a { text-decoration: none; }
.bridge-brand { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.bridge-seal {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid var(--red);
  color: var(--red);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1;
}
.bridge-name {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink);
}
.bridge-name small {
  font-family: var(--serif);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-left: 4px;
}
.bridge-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; flex-wrap: wrap; }
.bridge-nav a {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 5px 8px;
  border-radius: 1px;
  transition: 0.16s ease;
}
.bridge-nav a:hover { color: var(--ink); background: rgba(255, 255, 255, 0.45); }
.bridge-nav a.active { color: var(--red); border-bottom: 1px solid var(--red); }
.bridge-back {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--red);
  white-space: nowrap;
}
.bridge-back span { margin-left: 4px; }

.app {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 40px;
  position: relative;
  z-index: 1;
}

/* ---------- 頁首 ---------- */
.masthead {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line-strong);
}
.seal {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 2px solid var(--red);
  color: var(--red);
  display: grid;
  grid-template-rows: 1fr 1fr;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 3px rgba(163, 49, 40, 0.08);
  transform: rotate(-1.5deg);
}
.seal span { display: block; transform: translateY(-1px); }

.masthead-title { flex: 1; min-width: 240px; }
.masthead-title h1 {
  margin: 0;
  font-size: clamp(28px, 3.2vw, 40px);
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--ink);
}
.masthead-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.16em;
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.14em;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 2px;
  transition: 0.18s ease;
}
.tab:hover { background: rgba(255, 255, 255, 0.35); border-color: var(--line); }
.tab.active {
  background: var(--ink);
  color: #f8f0dd;
  border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(40, 35, 29, 0.18);
}

/* ---------- 行用範圍條 ---------- */
.regime-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.regime-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 3px rgba(68, 107, 90, 0.14);
}
.regime-sep { color: var(--faint); }
.regime-right { margin-left: auto; color: var(--gold); }

/* ---------- 通用 ---------- */
.view { display: none; padding-top: 24px; }
.view.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.26em;
  font-weight: 600;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.section-head h2 { margin: 0; font-size: clamp(24px, 2.6vw, 32px); letter-spacing: 0.08em; }
.section-head p { margin: 6px 0 0; }

.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #f8f0dd;
  padding: 8px 14px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 2px;
  transition: 0.16s ease;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.45); border-color: var(--ink); }
.btn.text { background: transparent; border-color: transparent; color: var(--red); padding-left: 4px; padding-right: 4px; }
.btn.text:hover { color: var(--red-dark); background: transparent; }
.icon-btn {
  appearance: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.28);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
  transition: 0.16s ease;
}
.icon-btn:hover { background: var(--ink); color: #f8f0dd; border-color: var(--ink); }

.num-input {
  width: 58px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 8px;
  border-radius: 2px;
  outline: none;
}
.num-input.year { width: 76px; }
.num-input:focus { border-color: var(--red); box-shadow: 0 0 0 2px rgba(163, 49, 40, 0.08); }
.field-label {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.14em;
  margin-right: 2px;
}
.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.mini-check input { accent-color: var(--red); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.32);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge.ok { color: var(--jade); border-color: rgba(44, 74, 61, 0.28); background: rgba(44, 74, 61, 0.08); }
.badge.bad { color: var(--red); border-color: rgba(163, 55, 42, 0.28); background: rgba(163, 55, 42, 0.07); }
.badge.warn { color: var(--red); border-color: rgba(163, 55, 42, 0.28); background: rgba(163, 55, 42, 0.055); }

/* ---------- 月曆工具列 ---------- */
.month-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.46);
  box-shadow: var(--shadow-sm);
}
.nav-group, .jump-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.month-title-wrap { min-width: 200px; padding: 0 8px; }
.month-title-wrap h2 { margin: 0; font-size: 24px; letter-spacing: 0.06em; }
.month-title-wrap p { margin: 3px 0 0; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.lunar-jump { padding-left: 14px; border-left: 1px solid var(--line); }

/* ---------- 月曆版面 ---------- */
.month-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.day-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.92), rgba(250, 243, 228, 0.8));
  box-shadow: var(--shadow);
  padding: 22px 20px;
  position: sticky;
  top: 16px;
}
.day-card::before {
  content: "";
  display: block;
  height: 4px;
  margin: -22px -20px 18px;
  background: linear-gradient(90deg, var(--red), var(--red-soft) 55%, var(--gold));
}
.day-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.day-weekday { color: var(--muted); font-size: 12px; letter-spacing: 0.16em; }
.today-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid rgba(163, 49, 40, 0.3);
  color: var(--red);
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.08em;
  vertical-align: 1px;
}
.day-big { font-family: var(--sans); font-size: 56px; line-height: 0.95; font-weight: 300; letter-spacing: -0.03em; }
.day-big.lunar-big { font-family: var(--serif); font-size: 40px; font-weight: 600; letter-spacing: 0.06em; line-height: 1.05; }
.day-ym { color: var(--muted); font-size: 12px; letter-spacing: 0.1em; text-align: right; line-height: 1.7; }
.lunar-main {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.lunar-main b { font-size: 24px; letter-spacing: 0.08em; }
.lunar-main span { color: var(--muted); font-size: 12px; }
.gz-line {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: 0.08em;
  line-height: 1.8;
}
.gz-y { color: var(--gold); }
.gz-m { color: var(--jade); }
.gz-d { color: var(--red-dark); }
.greg-block {
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.lunar-block { margin-top: 14px; }
.date-kicker {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.greg-date-main {
  margin-top: 4px;
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.greg-weekday {
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.lunar-date-main {
  margin-top: 3px;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.lunar-date-gz {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 7px;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.gz-sep { color: var(--faint); }
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}
.stat {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.28);
  padding: 8px 10px;
  min-width: 0;
}
.stat span { display: block; color: var(--muted); font-family: var(--sans); font-size: 10px; letter-spacing: 0.1em; }
.stat b { display: block; margin-top: 2px; font-size: 16px; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b.red { color: var(--red); }
.stat b.jade { color: var(--jade); }
.stat b.gold { color: var(--gold); }
.day-extra {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
}
.day-extra b { color: var(--ink-2); font-weight: 600; }
.day-note {
  margin-top: 12px;
  font-size: 11px;
  color: var(--red);
  line-height: 1.7;
  letter-spacing: 0.02em;
}

/* ---------- 日曆格 ---------- */
.calendar-panel {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.46);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.calendar-panel-below { margin-top: 18px; }
.month-layout .yiji-panel { margin-top: 0; }
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: rgba(40, 35, 29, 0.88);
  color: #f2e7d0;
}
.weekdays span {
  text-align: center;
  padding: 9px 4px;
  font-size: 12px;
  letter-spacing: 0.18em;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}
.weekdays span:last-child { border-right: 0; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.day-cell {
  min-height: 104px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 8px 7px;
  background: rgba(255, 253, 247, 0.34);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}
.day-cell:nth-child(7n) { border-right: 0; }
.day-cell:hover { background: rgba(255, 255, 255, 0.66); }
.day-cell.outside { background: rgba(224, 211, 186, 0.18); color: var(--faint); }
.day-cell.outside .cell-day { color: var(--faint); }
.day-cell.selected {
  background: rgba(163, 49, 40, 0.06);
  box-shadow: inset 0 0 0 2px var(--red);
  z-index: 2;
}
.day-cell.today::after {
  content: "";
  position: absolute;
  top: 7px; right: 7px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold);
}
.cell-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.cell-day { font-family: var(--sans); font-size: 19px; font-weight: 500; line-height: 1; }
.cell-lunar { font-size: 11px; color: var(--muted); white-space: nowrap; }
.day-cell.selected .cell-lunar { color: var(--red); }
.cell-mid {
  margin-top: 7px;
  font-size: 11px;
  color: var(--ink-2);
  min-height: 17px;
  line-height: 1.4;
}
.cell-mid .fest { color: var(--red); font-weight: 600; }
.cell-mid .term-name { color: var(--jade); font-weight: 600; }
.cell-bottom {
  position: absolute;
  left: 8px; bottom: 7px;
  display: flex;
  gap: 5px;
  align-items: center;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.04em;
}
.cell-bottom .xiu { color: var(--gold); }
.cell-bottom .jc { color: var(--ink-2); }
.cell-bottom .dot { width: 2px; height: 2px; background: var(--faint); border-radius: 50%; }
.calendar-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.calendar-legend i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-dot { background: var(--red); }
.dot-term { background: var(--jade); }
.dot-today { background: var(--gold); }
.legend-tip { margin-left: auto; color: var(--faint); }

/* ---------- 宜忌 ---------- */
.yiji-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.52);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.yiji-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.yiji-head h3 { margin: 0; font-size: 21px; letter-spacing: 0.1em; }
.yiji-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; }
.yiji-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding-top: 16px;
}
.yiji-col h4 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0.18em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.yiji-col h4::before { content: ""; width: 18px; height: 2px; background: currentColor; opacity: 0.6; }
.yiji-col.yi h4 { color: var(--red); }
.yiji-col.ji h4 { color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 13px;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.36);
  border-radius: 2px;
}
.chip-yi { color: var(--red-dark); border-color: rgba(163, 49, 40, 0.26); background: rgba(163, 49, 40, 0.055); }
.chip-ji { color: var(--ink-2); border-color: rgba(70, 59, 45, 0.22); background: rgba(70, 59, 45, 0.045); }
.yiji-notes {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}
.note-list { margin: 0; padding: 0; list-style: none; }
.note-list li {
  position: relative;
  padding-left: 14px;
  margin: 5px 0;
  font-size: 12px;
  line-height: 1.75;
  color: var(--muted);
}
.note-list li::before {
  content: "·";
  position: absolute;
  left: 2px;
  color: var(--gold);
}
.disclaimer {
  margin-top: 16px;
  padding: 10px 12px;
  border-left: 2px solid var(--gold-soft);
  background: rgba(173, 135, 71, 0.055);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

/* ---------- 首頁年神方位 ---------- */
.annual-gods-home {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.46);
  box-shadow: var(--shadow-sm);
}
.annual-gods-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.annual-gods-head h3 { margin: 4px 0 0; font-size: 21px; letter-spacing: 0.08em; }
.god-formula-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
  margin-bottom: 10px;
}
.god-formula { padding: 10px 12px; background: rgba(255, 252, 244, 0.9); }
.god-formula b { display: block; margin-bottom: 3px; font-size: 13px; font-weight: 400; color: var(--red-dark); letter-spacing: 0.06em; }
.god-formula p { margin: 0; font-size: 12px; line-height: 1.7; color: var(--muted); }
.god-tool {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 12px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 10px;
}
.god-tool label { font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }
.god-tool input {
  width: 96px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 2px;
}
.god-tool input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 2px rgba(163, 55, 42, 0.08); }
.god-result { font-size: 12px; color: var(--jade); letter-spacing: 0.04em; }
.annual-gods-table { min-width: 760px; }
.annual-gods-table td:first-child { color: var(--red-dark); font-weight: 500; }
.annual-gods-table td:nth-child(2) { color: var(--red); }
.annual-gods-table td:nth-child(3),
.annual-gods-table td:nth-child(4) { color: var(--gold); }
.annual-gods-table td:nth-child(5) { color: var(--red-dark); }
.annual-gods-table td:nth-child(6) { color: var(--gold); }
.annual-gods-table td:nth-child(7) { color: var(--jade); }
.annual-gods-table td:nth-child(8) { color: var(--red); }
.annual-gods-table .dir { font-family: var(--sans); font-size: 10px; color: var(--faint); margin-left: 3px; }
.annual-gods-table .gz { font-family: var(--serif); letter-spacing: 0.06em; }

/* ---------- 年曆 ---------- */
.year-controls { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.year-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}
.year-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.month-card {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.5);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: 0.16s ease;
  position: relative;
  overflow: hidden;
}
.month-card:hover { background: rgba(255, 255, 255, 0.72); border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.month-card::after {
  content: attr(data-month);
  position: absolute;
  right: 8px; bottom: -8px;
  font-family: var(--serif);
  font-size: 54px;
  color: rgba(64, 48, 32, 0.045);
  line-height: 1;
  pointer-events: none;
}
.mc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.mc-name { font-size: 19px; letter-spacing: 0.08em; }
.mc-size { font-family: var(--sans); font-size: 10px; color: var(--muted); border: 1px solid var(--line); padding: 2px 5px; }
.mc-leap { color: var(--red); border-color: rgba(163, 49, 40, 0.3); }
.mc-meta { margin-top: 8px; font-size: 11px; color: var(--muted); line-height: 1.7; }
.mc-meta b { color: var(--ink-2); font-weight: 600; }
.mc-terms { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.mc-term { font-size: 10px; color: var(--jade); border: 1px solid rgba(68, 107, 90, 0.22); padding: 1px 5px; background: rgba(68, 107, 90, 0.05); }

.year-side { display: grid; gap: 12px; position: sticky; top: 16px; }
.side-card {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.5);
  padding: 16px;
}
.side-card h4 { margin: 0 0 10px; font-size: 14px; letter-spacing: 0.14em; color: var(--gold); }
.year-god-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.year-god-row:last-child { border-bottom: 0; }
.year-god-row span { color: var(--muted); }
.year-god-row b { color: var(--ink); }
.year-stat-big { font-family: var(--sans); font-size: 32px; font-weight: 300; }
.note-card p { margin: 0; font-size: 11px; line-height: 1.85; color: var(--muted); }

/* ---------- 原曆 ---------- */
.stamp {
  border: 2px solid var(--red);
  color: var(--red);
  font-size: 13px;
  letter-spacing: 0.2em;
  padding: 9px 14px;
  transform: rotate(-2deg);
  opacity: 0.85;
}
.original-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -4px 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.42);
}
.orig-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 7px 12px;
  cursor: pointer;
  border-radius: 2px;
  transition: 0.16s ease;
}
.orig-tab:hover { background: rgba(255, 255, 255, 0.42); border-color: var(--line); }
.orig-tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #f8f0dd;
}
.orig-switch-note { margin-left: auto; color: var(--faint); font-family: var(--sans); font-size: 10px; letter-spacing: 0.08em; }
.original-select-label { font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }
.original-select {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 7px 30px 7px 11px;
  border-radius: 2px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.original-select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 2px rgba(163, 55, 42, 0.08); }
.original-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 18px;
  align-items: start;
}
.original-figure {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.5);
  padding: 12px;
}
.original-figure img { width: 100%; display: block; filter: saturate(0.92) contrast(1.02); }
.original-placeholder {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  background:
    radial-gradient(80% 80% at 50% 35%, rgba(169, 133, 78, 0.09), transparent 65%),
    repeating-linear-gradient(0deg, rgba(23, 23, 15, 0.025) 0, rgba(23, 23, 15, 0.025) 1px, transparent 1px, transparent 5px);
  text-align: center;
}
.original-placeholder[hidden] { display: none; }
.op-glyph {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border: 2px solid var(--red);
  color: var(--red);
  font-size: 34px;
  line-height: 1;
  transform: rotate(-1deg);
}
.original-placeholder p { margin: 0; font-size: 18px; letter-spacing: 0.14em; color: var(--ink-2); }
.original-placeholder small { font-family: var(--sans); font-size: 10px; line-height: 1.7; color: var(--muted); max-width: 360px; }
.caption { margin: 9px 2px 0; font-size: 11px; color: var(--muted); line-height: 1.7; }
.original-text {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.5);
  padding: 20px;
}
.original-text h3 { margin: 0 0 10px; font-size: 18px; letter-spacing: 0.1em; }
.original-text p { font-size: 13px; line-height: 1.95; color: var(--ink-2); }
.check-list { margin: 12px 0; padding: 0; list-style: none; }
.check-list li { position: relative; padding-left: 18px; margin: 6px 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--jade); font-family: var(--sans); }
.source-line { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--faint) !important; font-size: 11px !important; }

.compare-block {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.5);
  padding: 18px;
}
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.block-head h3 { margin: 0; font-size: 18px; letter-spacing: 0.1em; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: rgba(255, 255, 255, 0.32); }
.data-table .ok { color: var(--jade); font-weight: 600; }
.data-table .bad { color: var(--red); font-weight: 600; }
.data-table .num { font-family: var(--sans); }
.data-table.compact td, .data-table.compact th { padding: 7px 9px; }
.table-note { margin: 10px 2px 0; font-size: 11px; color: var(--faint); line-height: 1.7; }

/* ---------- 算法 ---------- */
.algo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.algo-card {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.5);
  padding: 20px;
  position: relative;
}
.algo-num {
  position: absolute;
  top: 14px; right: 16px;
  font-size: 30px;
  color: rgba(163, 49, 40, 0.16);
  line-height: 1;
}
.algo-card h3 { margin: 0 0 9px; font-size: 18px; letter-spacing: 0.08em; }
.algo-card p { margin: 0; font-size: 12.5px; line-height: 1.9; color: var(--muted); }
.formula {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(40, 35, 29, 0.035);
  border-left: 2px solid var(--gold-soft);
  font-size: 12px;
  line-height: 2;
  color: var(--ink-2);
}
.formula b { color: var(--red-dark); font-weight: 600; }
.formula-note { color: var(--faint); font-size: 11px; line-height: 1.7; }
.algo-validation {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: center;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(68, 107, 90, 0.06), rgba(255, 252, 244, 0.55));
  padding: 22px;
}
.algo-validation h3 { margin: 0 0 8px; font-size: 20px; }
.algo-validation p { margin: 0; font-size: 12.5px; line-height: 1.9; color: var(--muted); }
.validation-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.validation-stats div { text-align: center; border-left: 1px solid var(--line); }
.validation-stats b { display: block; font-family: var(--sans); font-size: 26px; font-weight: 300; color: var(--jade); }
.validation-stats span { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.algo-caveat {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.36);
  padding: 20px;
}
.algo-caveat h3 { margin: 0 0 8px; font-size: 16px; letter-spacing: 0.1em; }
.algo-caveat p { margin: 0 0 8px; font-size: 12px; line-height: 1.9; color: var(--muted); }
.sources { color: var(--faint) !important; font-size: 11px !important; }

/* ---------- 劉伯溫與大統曆 · 史料 ---------- */
.history-block {
  margin: 0 0 20px;
  padding: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(169, 133, 78, 0.055), rgba(255, 252, 244, 0.52) 42%, rgba(163, 55, 42, 0.035));
  position: relative;
  overflow: hidden;
}
.history-block::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold) 55%, var(--jade));
}
.history-head h3 {
  margin: 5px 0 8px;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0.08em;
  color: var(--ink);
}
.history-lede {
  margin: 0;
  max-width: 920px;
  font-size: 13px;
  line-height: 1.95;
  color: var(--ink-2);
}
.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: 24px;
  margin-top: 20px;
}
.history-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.history-timeline::before {
  content: "";
  position: absolute;
  left: 50px;
  top: 7px;
  bottom: 8px;
  width: 1px;
  background: var(--gold-soft);
}
.history-timeline li {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 14px;
  padding: 0 0 15px;
  position: relative;
}
.history-timeline li:last-child { padding-bottom: 0; }
.hy {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-align: right;
  padding-top: 3px;
  padding-right: 10px;
  position: relative;
}
.hy::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--red);
}
.history-timeline b {
  display: block;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--red-dark);
}
.history-timeline p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}
.history-quotes { display: grid; gap: 8px; align-content: start; }
.history-quotes blockquote {
  margin: 0;
  padding: 9px 13px;
  border-left: 2px solid var(--gold);
  background: rgba(255, 255, 255, 0.3);
}
.history-quotes p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-2);
}
.history-quotes cite {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.history-note {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  line-height: 1.85;
  color: var(--muted);
}

/* ---------- 字體與重點色 ---------- */
.masthead-title h1,
.section-head h2,
.tab,
.yiji-head h3,
.yiji-col h4,
.block-head h3,
.original-text h3,
.algo-card h3,
.algo-validation h3,
.algo-caveat h3,
.lunar-main b,
.stat b,
.day-extra b,
.year-god-row b,
.day-big.lunar-big,
.cell-day,
.cell-bottom { font-weight: 400; }
.cell-day,
.cell-bottom { font-family: var(--serif); }
b, strong { font-weight: 400; }

.lunar-main b { color: var(--red-dark); }
.yiji-head h3 { color: var(--ink); position: relative; padding-left: 12px; }
.yiji-head h3::before {
  content: "";
  position: absolute;
  left: 0; top: 0.12em; bottom: 0.12em;
  width: 3px;
  background: var(--red);
}
.yiji-col.ji h4 { color: var(--jade); }
.yiji-col.ji .chip-ji { color: var(--jade); border-color: rgba(44, 74, 61, 0.28); background: rgba(44, 74, 61, 0.045); }

.stat { border-top: 2px solid var(--line); }
.stat-jc { border-top-color: var(--red); }
.stat-jc span { color: var(--red); }
.stat-xiu { border-top-color: var(--gold); }
.stat-xiu span { color: var(--gold); }
.stat-hd { border-top-color: var(--jade); }
.stat-hd span { color: var(--jade); }
.stat-chong { border-top-color: var(--red-dark); }
.stat-chong span { color: var(--red-dark); }

.k-red { color: var(--red-dark) !important; }
.k-jade { color: var(--jade) !important; }
.k-gold { color: var(--gold) !important; }
.day-extra .k-red { font-weight: 500; }
.day-extra .k-jade { font-weight: 500; }
.day-extra .k-gold { font-weight: 500; }
.yiji-notes h4 { color: var(--gold) !important; }
.yiji-notes h4 + ul .note-list li::before { color: var(--red); }
.year-gods b { color: var(--ink); }
.year-god-row:nth-child(2) b { color: var(--red-dark); }
.year-god-row:nth-child(3) b { color: var(--jade); }
.year-god-row:nth-child(4) b { color: var(--gold); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(14px);
  background: rgba(40, 35, 29, 0.94);
  color: #f8f0dd;
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 頁尾 ---------- */
footer {
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.12em;
}
.footer-sep { color: var(--gold-soft); }

/* ---------- 可讀性：主要內容字級 ---------- */
.day-weekday,
.day-ym { font-size: 13px; }
.lunar-main b { font-size: 26px; }
.lunar-main span { font-size: 13px; }
.gz-line { font-size: 15px; }
.stat span { font-size: 11px; }
.stat b { font-size: 18px; }
.day-extra { font-size: 13px; }
.day-note { font-size: 12px; }
.cell-lunar { font-size: 12px; }
.cell-mid { font-size: 12px; }
.cell-bottom { font-size: 11px; }
.yiji-head h3 { font-size: 24px; }
.yiji-head p { font-size: 13px; }
.yiji-col h4 { font-size: 17px; }
.chip { font-size: 15px; }
.note-list li { font-size: 14px; }
.disclaimer { font-size: 12px; }
.calendar-legend { font-size: 12px; }

/* ---------- 響應式 ---------- */
@media (max-width: 1100px) {
  .month-layout { grid-template-columns: 290px minmax(0, 1fr); }
  .year-layout { grid-template-columns: 1fr; }
  .year-side { position: static; grid-template-columns: repeat(3, 1fr); }
  .original-layout { grid-template-columns: 1fr; }
  .algo-validation { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .site-bridge { padding: 9px 14px; gap: 10px; }
  .bridge-nav { display: none; }
  .bridge-back { font-size: 10px; }
  .app { width: min(100% - 24px, 1440px); padding-top: 14px; }
  .masthead { flex-wrap: wrap; gap: 12px; }
  .masthead-title { min-width: 0; }
  .tabs { width: 100%; order: 3; }
  .tab { flex: 1; padding: 9px 8px; }
  .history-grid { grid-template-columns: 1fr; gap: 18px; }
  .history-block { padding: 20px; }
  .month-layout { grid-template-columns: 1fr; }
  .day-card { position: static; }
  .month-toolbar { align-items: flex-start; }
  .lunar-jump { border-left: 0; padding-left: 0; }
  .year-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .algo-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .app { width: calc(100% - 14px); }
  .masthead-title h1 { font-size: 26px; }
  .masthead-title p { font-size: 10px; letter-spacing: 0.08em; }
  .regime-bar { font-size: 10px; }
  .regime-right { display: none; }
  .history-block { padding: 16px; }
  .god-formula-grid { grid-template-columns: 1fr; }
  .god-tool input { width: 84px; }
  .history-timeline::before { left: 42px; }
  .history-timeline li { grid-template-columns: 42px 1fr; gap: 10px; }
  .hy { font-size: 9px; padding-right: 8px; }
  .history-quotes p { font-size: 11.5px; }
  .day-cell { min-height: 82px; padding: 6px 5px; }
  .cell-day { font-size: 16px; }
  .cell-lunar { font-size: 10px; }
  .cell-mid { font-size: 10px; margin-top: 5px; }
  .cell-bottom { left: 5px; bottom: 5px; font-size: 9px; gap: 3px; }
  .weekdays span { font-size: 10px; padding: 7px 2px; }
  .yiji-cols { grid-template-columns: 1fr; }
  .yiji-notes { grid-template-columns: 1fr; }
  .year-grid { grid-template-columns: 1fr; }
  .year-side { grid-template-columns: 1fr; }
  .validation-stats div { border-left: 0; border-top: 1px solid var(--line); padding-top: 8px; }
  .section-head { align-items: flex-start; }
  .day-big { font-size: 46px; }
  .month-toolbar { padding: 12px; gap: 10px; }
  .nav-group { width: 100%; flex-wrap: nowrap; gap: 5px; }
  .nav-group .icon-btn { width: 30px; height: 30px; flex: 0 0 30px; font-size: 18px; }
  .month-title-wrap { flex: 1 1 auto; min-width: 0; padding: 0 2px; }
  .month-title-wrap h2 { font-size: 18px; white-space: nowrap; }
  .month-title-wrap p { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .jump-group { width: 100%; flex-wrap: nowrap; gap: 5px; }
  .jump-group .field-label { width: 30px; flex: 0 0 30px; font-size: 10px; }
  .num-input { width: 0; flex: 1 1 52px; min-width: 52px; padding: 7px 5px; font-size: 12px; }
  .num-input.year { flex: 1.35 1 66px; min-width: 66px; }
  .jump-group .btn { flex: 0 0 auto; padding: 8px 9px; font-size: 12px; }
  .lunar-jump { padding-left: 0; }
  .mini-check { flex: 0 0 auto; }
}
@media print {
  body { background: #fff; }
  .tabs, .month-toolbar, .calendar-panel, .day-card, footer, .regime-bar { display: none !important; }
  .view { display: block !important; }
}
