:root {
  --page-width: 1320px;
  --page-gutter: 12px;
  --bg: #f6f6f6;
  --card: #e5e5e5;
  --text: #222;
  --muted: #666;
  --border: #cccccc;
  --holiday-bg: #ffebeb;
  --holiday-text: #c62828;
  --workday-bg: #e6f1ff;
  --workday-text: #1565c0;
}

* {
  box-sizing: border-box;
}

body {
  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(--text);
}

.hero {
  width: 100%;
  height: 200px;
  overflow: hidden;
  margin: 0 0 10px 0;
  background: #ddd;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

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

.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);
}

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

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

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

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

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

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

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

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

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

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

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

.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(--muted);
}

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

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

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

.months-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.site-footer {
  width: min(var(--page-width), calc(100% - (var(--page-gutter) * 2)));
  margin: 8px auto 20px;
  padding: 14px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
  color: #666;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: #2f6db5;
  text-decoration: none;
  margin: 0 6px;
}

.site-footer a:hover {
  text-decoration: underline;
}

.month-card {
  background: linear-gradient(180deg, #ededed 0%, #e3e3e3 100%);
  border: 1px solid var(--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;
}

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

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

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

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

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

.day-cell {
  min-height: 30px;
  border: 1px solid var(--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;
}

.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;
}

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

.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;
}

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

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

.day-number {
  font-weight: 600;
}

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

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

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

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

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

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

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

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

.modal {
  position: fixed;
  display: none;
  z-index: 999;
  pointer-events: none;
}

.modal.show {
  display: block;
}

.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);
}

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

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

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

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

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

.modal-card::before,
.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;
}

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

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

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

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

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

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

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

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

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

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

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

  .container {
    padding: 8px 0 12px;
  }

  .head-panel {
    padding: 8px;
  }

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

  .site-footer {
    margin: 8px auto 12px;
    padding: 10px 8px;
    font-size: 12px;
  }

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

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

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