:root {
  color-scheme: light;
  --wine: #230d18;
  --wine-soft: #3a111a;
  --red: #aa0d2d;
  --red-dark: #85091f;
  --gold: #c9a93e;
  --paper: #fbf7e9;
  --paper-deep: #f3e9c9;
  --ink: #261b1b;
  --muted: #817573;
  --line: #e9dfc5;
  --shadow: 0 12px 30px rgba(27, 5, 10, .16);
  font-family: "Noto Serif TC", "Noto Serif CJK TC", "Microsoft JhengHei", "Songti SC", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font: 14px / 1.6 "Noto Serif TC", "Noto Serif CJK TC", "Microsoft JhengHei", "Songti SC", serif;
  background: #f8f6ee url("./assets/qianyige-background.webp") no-repeat top center;
}
button, select { font: inherit; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #d0ac37; outline-offset: 2px; }
.app-shell { min-height: 100vh; }
.topbar {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0;
  line-height: 0;
  background: transparent;
}
.site-banner { display: block; width: 100%; }
.site-banner img { display: block; width: 100%; height: auto; }
.site-nav {
  width: min(980px, 100%);
  min-height: 39px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  background: #160d17;
  border-top: 2px solid var(--gold);
  border-bottom: 1px solid #70562b;
  scrollbar-width: thin;
}
.site-nav a {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-right: 1px solid rgba(235, 215, 164, .12);
  color: #e9dfd2;
  text-decoration: none;
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: .08em;
  transition: background .18s, color .18s;
}
.site-nav a:hover, .site-nav a.current { background: #391321; color: #f0d164; }
.page-content {
  width: min(980px, 100%);
  max-width: 980px;
  margin: 0 auto;
  padding: 24px clamp(12px, 2.5vw, 24px) 16px;
  background: var(--red);
  border-top: 3px solid var(--gold);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 16px 44px rgba(25, 8, 14, .18);
}
.layout { display: grid; grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); align-items: stretch; gap: 16px; }
.panel { border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
.calendar-panel { padding: 20px 18px 17px; }
.month-heading { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; margin-bottom: 13px; }
.month-heading h1 { margin: 0; text-align: center; font-size: 23px; font-weight: 650; letter-spacing: .08em; color: var(--red); }
.arrow-button { border: 0; width: 36px; height: 36px; border-radius: 50%; background: transparent; color: var(--red); cursor: pointer; font-size: 28px; line-height: 1; transition: background .18s, transform .18s; }
.arrow-button:hover { background: #f2e6d5; transform: scale(1.05); }
.picker-row { display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; }
.picker-row select { min-width: 100px; border: 1px solid transparent; border-radius: 6px; padding: 7px 10px; background: #f3ead7; color: #5c4240; cursor: pointer; }
.picker-row select:hover { border-color: #ddcfae; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.weekday-row { padding-bottom: 8px; border-bottom: 1px solid var(--line); color: #867975; text-align: center; font-size: 12px; }
.weekday-row span:first-child, .weekday-row span:last-child { color: var(--red); }
.days-grid { padding-top: 8px; }
.day-cell { position: relative; aspect-ratio: 1 / 1; min-width: 0; padding: 3px; border: 0; border-radius: 8px; background: transparent; color: #3f3331; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: background .16s, color .16s, transform .16s; }
.day-cell:hover { background: #f1e8d6; transform: translateY(-1px); }
.day-cell.weekend .day-number { color: var(--red); }
.day-number { font-size: 15px; line-height: 1.15; }
.lunar-mini { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #9b8b7e; font-size: 9px; line-height: 1.2; }
.day-cell.solar-term .lunar-mini { color: #9e7b17; font-weight: 700; }
.day-cell.selected { background: var(--red); color: white; box-shadow: 0 5px 12px rgba(163, 14, 40, .22); }
.day-cell.selected .day-number, .day-cell.selected.weekend .day-number { color: white; }
.day-cell.selected .lunar-mini { color: #f3dfb0; }
.day-cell.today:not(.selected) { box-shadow: inset 0 0 0 1px #c9a93e; }
.day-cell.empty { cursor: default; }
.day-cell.empty:hover { background: transparent; transform: none; }
.calendar-legend { display: flex; justify-content: center; gap: 18px; margin-top: 15px; color: var(--muted); font-size: 11px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.calendar-legend i { width: 9px; height: 9px; display: inline-block; border-radius: 50%; }
.legend-selected { background: var(--red); }
.legend-term { background: var(--gold); }
.calendar-hint { margin: 13px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: #998d81; font-size: 11px; line-height: 1.8; }
.detail-panel { background: var(--paper-deep); }
.detail-content { min-height: 100%; }
.detail-top { padding: 22px 26px 19px; background: #fffaf0; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 14px; display: flex; align-items: center; gap: 9px; color: var(--red); font-family: serif; font-size: 19px; letter-spacing: .2em; }
.eyebrow::after { content: "◆"; color: var(--gold); font-size: 11px; }
.date-row { display: flex; align-items: center; gap: 18px; }
.big-day { min-width: 91px; color: var(--red); font-family: Georgia, "Times New Roman", serif; font-size: 78px; line-height: .95; text-align: center; }
.date-info strong { display: block; color: #34252a; font-size: 19px; font-weight: 650; }
.lunar-summary { margin-top: 6px; color: #746965; font-size: 13px; }
.ganzhi-line { margin-top: 4px; color: #8d7a6a; font-size: 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.badge { padding: 4px 10px; border-radius: 999px; background: #d6b33d; color: #fff; font-size: 11px; }
.badge.subtle { background: #37252a; }
.badge.term { background: #eee4c5; color: #7d641c; }
.info-section { padding: 14px 24px; border-bottom: 1px solid rgba(207, 188, 145, .46); display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: start; scroll-margin-top: 12px; }
.info-label { padding-top: 3px; color: var(--red); font-family: serif; font-size: 15px; letter-spacing: .12em; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { padding: 6px 11px; border-radius: 5px; background: var(--red); color: white; font-size: 12px; line-height: 1.3; }
.tag.bad { background: #34262a; }
.two-column { padding: 17px 18px 19px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(220px, .95fr); gap: 13px; }
.subcard { min-width: 0; padding: 17px 18px; border: 1px solid #e1d4b5; border-radius: 10px; background: rgba(255, 252, 240, .9); scroll-margin-top: 12px; }
.subcard h2 { margin: 0 0 14px; color: var(--red); font-family: serif; font-size: 19px; font-weight: 600; letter-spacing: .1em; }
.hour-groups { display: grid; gap: 10px; }
.hour-group { display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: start; }
.hour-period { padding-top: 2px; color: var(--red); font-size: 12px; }
.hour-list { display: grid; gap: 5px; }
.hour-item { display: flex; flex-wrap: wrap; gap: 4px 8px; color: #584e4b; font-size: 12px; line-height: 1.6; }
.hour-branch { color: #36292b; font-weight: 650; }
.hour-star { color: #8d7b4b; font-size: 10px; }
.empty-inline { color: #958a7e; font-size: 12px; line-height: 1.8; }
.direction-list { display: grid; grid-template-columns: 1fr auto; gap: 11px 12px; margin: 0; font-size: 12px; }
.direction-list dt { color: #625451; }
.direction-list dd { margin: 0; color: #31272a; font-weight: 650; }
.day-meta { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.day-meta h3 { margin: 0 0 8px; color: var(--red); font-family: serif; font-size: 17px; letter-spacing: .08em; }
.day-meta p { margin: 0; color: #6e625d; font-size: 12px; line-height: 1.8; }
.loading-state, .error-state { min-height: 400px; padding: 28px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; color: #7f6a68; text-align: center; }
.error-state strong { color: var(--red); }
.spinner { width: 22px; height: 22px; border: 2px solid #eadfbe; border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { margin-bottom: 14px; padding: 10px 14px; border: 1px solid #e7d49c; border-radius: 8px; background: #fff5d8; color: #6e551b; font-size: 12px; }
.page-footer { padding: 16px 4px 3px; color: #fae9df; text-align: center; font-size: 11px; letter-spacing: .06em; }
.footer-divider { padding: 0 8px; color: #e3c956; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 860px) {
  .page-content { padding-top: 17px; }
  .layout { grid-template-columns: minmax(260px, .83fr) minmax(0, 1.17fr); gap: 13px; }
  .calendar-panel { padding: 18px 14px; }
  .detail-top { padding: 20px 20px 17px; }
  .two-column { grid-template-columns: 1fr; padding: 14px; }
}
@media (max-width: 680px) {
  .site-nav { min-height: 37px; padding: 0 3px; }
  .site-nav a { padding: 0 12px; font-size: 12px; }
  .page-content { width: 100%; padding: 12px 10px 12px; }
  .layout { grid-template-columns: 1fr; gap: 12px; }
  .calendar-panel { padding: 16px 18px 14px; }
  .month-heading { margin-bottom: 10px; }
  .month-heading h1 { font-size: 21px; }
  .picker-row { margin-bottom: 12px; }
  .day-cell { border-radius: 7px; }
  .day-number { font-size: 14px; }
  .lunar-mini { font-size: 8px; }
  .calendar-legend { margin-top: 11px; }
  .detail-top { padding: 18px 16px 15px; }
  .eyebrow { margin-bottom: 12px; font-size: 17px; }
  .date-row { gap: 10px; }
  .big-day { min-width: 70px; font-size: 66px; }
  .date-info strong { font-size: 16px; }
  .info-section { padding: 12px 15px; grid-template-columns: 34px 1fr; gap: 8px; }
  .tag-list { gap: 6px; }
  .tag { padding: 6px 9px; font-size: 11px; }
  .two-column { padding: 11px; gap: 10px; }
  .subcard { padding: 15px; }
  .page-footer { font-size: 10px; line-height: 1.8; }
}
