.wan-calendar-page {
  --wan-page-width: 1320px;
  --wan-page-gutter: 12px;
  --wan-bg: #f6f6f6;
  --wan-card: #e5e5e5;
  --wan-text: #222;
  --wan-muted: #666;
  --wan-border: #cccccc;
  --wan-holiday-bg: #ffebeb;
  --wan-holiday-text: #c62828;
  --wan-workday-bg: #e6f1ff;
  --wan-workday-text: #1565c0;
  box-sizing: border-box;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  background: linear-gradient(180deg, #f8f8f8 0%, #f1f1f1 100%);
  color: var(--wan-text);
  width: 100%;
}

.wan-calendar-page *,
.wan-calendar-page *::before,
.wan-calendar-page *::after {
  box-sizing: border-box;
}

.wan-calendar-page .calendar-container {
  width: min(var(--wan-page-width), calc(100% - (var(--wan-page-gutter) * 2)));
  margin: 0 auto;
  padding: 14px 0 18px;
}

.wan-calendar-page .head-panel {
  background: #ffffff;
  border: 1px solid #d9d9d9;
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 12px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
}

.wan-calendar-page .year-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  padding: 8px 4px;
}

.wan-calendar-page .year-title {
  margin: 0 0 2px 0;
  font-size: clamp(18px, 2.2vw, 28px);
}

.wan-calendar-page .year-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wan-calendar-page .year-subtitle {
  margin: 0;
  font-size: 13px;
  color: #7a7a7a;
}

.wan-calendar-page .year-desc {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: #6b6b6b;
}

.wan-calendar-page .year-nav-buttons {
  display: flex;
  gap: 8px;
}

.wan-calendar-page .nav-btn {
  display: inline-block;
  text-decoration: none;
  background: #ffffff;
  color: #333;
  border: 1px solid var(--wan-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.wan-calendar-page .nav-btn:hover {
  background: #f2f2f2;
}

.wan-calendar-page .nav-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.wan-calendar-page .year-jump {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wan-calendar-page .year-input {
  width: 88px;
  border: 1px solid var(--wan-border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.wan-calendar-page .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 0;
  border-top: 1px dashed #d8d8d8;
  padding: 10px 4px 2px;
  font-size: 13px;
  color: var(--wan-muted);
}

.wan-calendar-page .legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
  border: 1px solid var(--wan-border);
}

.wan-calendar-page .dot-holiday {
  background: var(--wan-holiday-bg);
}

.wan-calendar-page .dot-workday {
  background: var(--wan-workday-bg);
}

.wan-calendar-page .months-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.wan-calendar-page .month-card {
  background: linear-gradient(180deg, #ededed 0%, #e3e3e3 100%);
  border: 1px solid var(--wan-border);
  border-radius: 8px;
  padding: 8px;
  min-height: 280px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wan-calendar-page .month-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.wan-calendar-page .month-title {
  margin: 0 0 8px 0;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 700;
}

.wan-calendar-page .week-header,
.wan-calendar-page .days-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.wan-calendar-page .week-header {
  margin-bottom: 4px;
}

.wan-calendar-page .week-cell {
  text-align: center;
  font-size: 12px;
  color: var(--wan-muted);
  padding: 2px 0;
}

.wan-calendar-page .day-cell {
  min-height: 30px;
  border: 1px solid var(--wan-border);
  border-radius: 4px;
  background: #fbfbfb;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  padding: 5px 2px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}

.wan-calendar-page .day-cell.selected-day {
  border: 2px solid #7b4bff;
  box-shadow: inset 0 0 0 1px #f3edff, 0 0 0 2px rgba(123, 75, 255, 0.2);
  background: #f7f3ff;
}

.wan-calendar-page .day-cell.selected-day .day-number {
  color: #5a35c4;
}

.wan-calendar-page .today {
  border: 2px solid #f39c12;
  box-shadow: inset 0 0 0 1px #fff4dc, 0 0 0 2px rgba(243, 156, 18, 0.2);
  background: #fff8ea;
}

.wan-calendar-page .today .day-number {
  color: #b26d00;
}

.wan-calendar-page .day-cell.empty {
  background: #efefef;
  border-style: dashed;
  color: transparent;
}

.wan-calendar-page .day-number {
  font-weight: 600;
}

.wan-calendar-page .festival-text {
  font-size: 9px;
  line-height: 1.1;
  color: #567;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wan-calendar-page .lunar-text {
  font-size: 9px;
  line-height: 1.1;
  color: #7a7a7a;
}

.wan-calendar-page .tag {
  font-size: 10px;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
  border: 1px solid transparent;
}

.wan-calendar-page .holiday {
  background: var(--wan-holiday-bg);
  color: var(--wan-holiday-text);
  border-color: #ffc7c7;
}

.wan-calendar-page .holiday .tag {
  background: #ffd7d7;
  color: var(--wan-holiday-text);
  border-color: #ffb4b4;
}

.wan-calendar-page .workday {
  background: var(--wan-workday-bg);
  color: var(--wan-workday-text);
  border-color: #b9d8ff;
}

.wan-calendar-page .workday .tag {
  background: #d7e9ff;
  color: var(--wan-workday-text);
  border-color: #b0d0ff;
}

.wan-calendar-page .festival {
  border-color: #c7d9c7;
  background: #eef8ee;
}

#day-modal.modal {
  position: fixed;
  display: none;
  z-index: 10000;
  pointer-events: none;
  inset: 0;
}

#day-modal.modal.show {
  display: block;
}

#day-modal .modal-card {
  position: fixed;
  width: min(380px, calc(100vw - 16px));
  background: #fff;
  border-radius: 12px;
  border: 1px solid #d9d9d9;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.96) translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  --popup-border: #d9d9d9;
  --popup-bg: #ffffff;
  --popup-header-bg: #ffffff;
  --popup-arrow-border: #d9d9d9;
  --popup-arrow-fill: #ffffff;
  border-color: var(--popup-border);
  background: var(--popup-bg);
}

#day-modal.modal.show .modal-card {
  opacity: 1;
  transform: scale(1) translateY(0);
}

#day-modal .modal-card.popup-holiday {
  --popup-border: #ffbcbc;
  --popup-bg: #fff7f7;
  --popup-header-bg: #fff1f1;
  --popup-arrow-border: #ffbcbc;
  --popup-arrow-fill: #fff7f7;
}

#day-modal .modal-card.popup-workday {
  --popup-border: #b9d8ff;
  --popup-bg: #f5f9ff;
  --popup-header-bg: #edf5ff;
  --popup-arrow-border: #b9d8ff;
  --popup-arrow-fill: #f5f9ff;
}

#day-modal .modal-card.popup-festival {
  --popup-border: #bfe0bf;
  --popup-bg: #f3fbf3;
  --popup-header-bg: #eaf8ea;
  --popup-arrow-border: #bfe0bf;
  --popup-arrow-fill: #f3fbf3;
}

#day-modal .modal-card.popup-normal {
  --popup-border: #d9d9d9;
  --popup-bg: #ffffff;
  --popup-header-bg: #ffffff;
  --popup-arrow-border: #d9d9d9;
  --popup-arrow-fill: #ffffff;
}

#day-modal .modal-card::before,
#day-modal .modal-card::after {
  content: "";
  position: absolute;
  top: var(--arrow-top, 24px);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

#day-modal .modal-card.arrow-left::before {
  left: -9px;
  border-right: 9px solid var(--popup-arrow-border);
}

#day-modal .modal-card.arrow-left::after {
  left: -8px;
  border-right: 8px solid var(--popup-arrow-fill);
}

#day-modal .modal-card.arrow-right::before {
  right: -9px;
  border-left: 9px solid var(--popup-arrow-border);
}

#day-modal .modal-card.arrow-right::after {
  right: -8px;
  border-left: 8px solid var(--popup-arrow-fill);
}

#day-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #ececec;
  background: var(--popup-header-bg);
}

#day-modal .modal-title {
  margin: 0;
  font-size: 16px;
}

#day-modal .modal-close {
  border: 1px solid #d2d2d2;
  background: #fafafa;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

#day-modal .modal-content {
  padding: 12px;
  font-size: 14px;
  color: #444;
  line-height: 1.6;
}

#day-modal .modal-content p {
  margin: 0 0 6px 0;
}

.wan-calendar-page .wan-calendar-h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--wan-text);
}

.wan-calendar-page .wan-holiday-panel {
  margin-top: 28px;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--wan-border);
  background: var(--wan-panel-bg, #fafafa);
}

.wan-calendar-page .wan-holiday-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wan-calendar-page .wan-holiday-empty {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f5f5f5;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

.wan-calendar-page .wan-holiday-row {
  display: grid;
  grid-template-columns: 108px auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e8e8e8;
  font-size: 14px;
  line-height: 1.4;
}

.wan-calendar-page .wan-holiday-row-holiday {
  background: #fff5f5;
  border-color: #ffccc7;
}

.wan-calendar-page .wan-holiday-row-workday {
  background: #f0f7ff;
  border-color: #b0d0ff;
}

.wan-calendar-page .wan-holiday-date {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #333;
}

.wan-calendar-page .wan-holiday-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.wan-calendar-page .wan-holiday-row-holiday .wan-holiday-badge {
  background: #ffd6d6;
  color: #a8071a;
}

.wan-calendar-page .wan-holiday-row-workday .wan-holiday-badge {
  background: #d7e9ff;
  color: var(--wan-workday-text, #0958d9);
}

.wan-calendar-page .wan-holiday-note {
  color: var(--wan-muted);
}

/* ========== 万年历 · 深色主题（body.theme-dark 与 html data-theme 同步自 shell.js） ========== */
body.theme-dark .wan-calendar-page {
  color-scheme: dark;
  --wan-bg: #0f1219;
  --wan-card: #1e2436;
  --wan-text: #e8eaef;
  --wan-muted: #9aa0ac;
  --wan-border: #2a3142;
  --wan-holiday-bg: rgba(248, 113, 113, 0.18);
  --wan-holiday-text: #fca5a5;
  --wan-workday-bg: rgba(59, 130, 246, 0.2);
  --wan-workday-text: #93c5fd;
  --wan-panel-bg: #151a24;
  background: linear-gradient(180deg, #121820 0%, #0f1219 100%);
  color: var(--wan-text);
}

body.theme-dark .wan-calendar-page .head-panel {
  background: #181c27;
  border-color: #2a3142;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

body.theme-dark .wan-calendar-page .year-subtitle,
body.theme-dark .wan-calendar-page .year-desc {
  color: #9aa0ac;
}

body.theme-dark .wan-calendar-page .nav-btn {
  background: #181c27;
  color: #e8eaef;
  border-color: #2a3142;
}

body.theme-dark .wan-calendar-page .nav-btn:hover {
  background: #1e2436;
}

body.theme-dark .wan-calendar-page .year-input {
  background: #1a1f2e;
  color: #e8eaef;
  border-color: #2a3142;
}

body.theme-dark .wan-calendar-page .legend {
  border-top-color: #2a3142;
  color: var(--wan-muted);
}

body.theme-dark .wan-calendar-page .month-card {
  background: linear-gradient(180deg, #1a2230 0%, #151b28 100%);
  border-color: #2a3142;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

body.theme-dark .wan-calendar-page .month-card:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

body.theme-dark .wan-calendar-page .day-cell {
  background: #1a1f2e;
  border-color: #2a3142;
}

body.theme-dark .wan-calendar-page .day-cell.empty {
  background: #12161f;
  border-color: #2a3142;
}

body.theme-dark .wan-calendar-page .day-cell.selected-day {
  border-color: #8b5cf6;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.15), 0 0 0 2px rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.12);
}

body.theme-dark .wan-calendar-page .day-cell.selected-day .day-number {
  color: #c4b5fd;
}

body.theme-dark .wan-calendar-page .today {
  border-color: #f59e0b;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.2), 0 0 0 2px rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.12);
}

body.theme-dark .wan-calendar-page .today .day-number {
  color: #fbbf24;
}

body.theme-dark .wan-calendar-page .festival-text {
  color: #94a3b8;
}

body.theme-dark .wan-calendar-page .lunar-text {
  color: var(--wan-muted);
}

body.theme-dark .wan-calendar-page .holiday {
  border-color: rgba(248, 113, 113, 0.45);
}

body.theme-dark .wan-calendar-page .holiday .tag {
  background: rgba(248, 113, 113, 0.25);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--wan-holiday-text);
}

body.theme-dark .wan-calendar-page .workday {
  border-color: rgba(59, 130, 246, 0.45);
}

body.theme-dark .wan-calendar-page .workday .tag {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(147, 197, 253, 0.35);
  color: var(--wan-workday-text);
}

body.theme-dark .wan-calendar-page .festival {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

body.theme-dark #day-modal .modal-card.popup-normal {
  --popup-border: #2a3142;
  --popup-bg: #181c27;
  --popup-header-bg: #1c2230;
  --popup-arrow-border: #2a3142;
  --popup-arrow-fill: #181c27;
}

body.theme-dark #day-modal .modal-card.popup-holiday {
  --popup-border: rgba(248, 113, 113, 0.45);
  --popup-bg: #241a1e;
  --popup-header-bg: #2a1c22;
  --popup-arrow-border: rgba(248, 113, 113, 0.45);
  --popup-arrow-fill: #241a1e;
}

body.theme-dark #day-modal .modal-card.popup-workday {
  --popup-border: rgba(59, 130, 246, 0.45);
  --popup-bg: #151d2a;
  --popup-header-bg: #182235;
  --popup-arrow-border: rgba(59, 130, 246, 0.45);
  --popup-arrow-fill: #151d2a;
}

body.theme-dark #day-modal .modal-card.popup-festival {
  --popup-border: rgba(52, 211, 153, 0.4);
  --popup-bg: #151f1c;
  --popup-header-bg: #182520;
  --popup-arrow-border: rgba(52, 211, 153, 0.4);
  --popup-arrow-fill: #151f1c;
}

body.theme-dark #day-modal .modal-header {
  border-bottom-color: #2a3142;
}

body.theme-dark #day-modal .modal-title {
  color: #e8eaef;
}

body.theme-dark #day-modal .modal-close {
  border-color: #2a3142;
  background: #1a1f2e;
  color: #e8eaef;
}

body.theme-dark #day-modal .modal-content {
  color: #9aa0ac;
}

body.theme-dark .wan-calendar-page .wan-holiday-empty {
  background: #1a1f2e;
  color: var(--wan-muted);
  border: 1px solid #2a3142;
}

body.theme-dark .wan-calendar-page .wan-holiday-row {
  border-color: #2a3142;
}

body.theme-dark .wan-calendar-page .wan-holiday-row-holiday {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
}

body.theme-dark .wan-calendar-page .wan-holiday-row-workday {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(147, 197, 253, 0.3);
}

body.theme-dark .wan-calendar-page .wan-holiday-date {
  color: var(--wan-text);
}

body.theme-dark .wan-calendar-page .wan-holiday-row-holiday .wan-holiday-badge {
  background: rgba(248, 113, 113, 0.25);
  color: #fecaca;
}

body.theme-dark .wan-calendar-page .wan-holiday-row-workday .wan-holiday-badge {
  background: rgba(59, 130, 246, 0.28);
  color: #bfdbfe;
}

@media (max-width: 1100px) {
  .wan-calendar-page .months-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .wan-calendar-page {
    --wan-page-gutter: 8px;
  }

  .wan-calendar-page .calendar-container {
    padding: 8px 0 12px;
  }

  .wan-calendar-page .head-panel {
    padding: 8px;
  }

  .wan-calendar-page .months-grid {
    grid-template-columns: 1fr;
  }

  .wan-calendar-page .year-nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 6px 2px;
  }

  .wan-calendar-page .year-nav-buttons {
    width: 100%;
  }

  .wan-calendar-page .nav-btn {
    text-align: center;
    flex: 1;
  }

  .wan-calendar-page .wan-holiday-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
