:root {
  color-scheme: light;
  --page: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfe;
  --ink: #18243a;
  --secondary: #56647b;
  --muted: #8793a6;
  --line: #e7ebf2;
  --line-strong: #d9e0eb;
  --blue: #315bd4;
  --blue-dark: #2447b0;
  --blue-soft: #edf2ff;
  --red: #c74655;
  --red-soft: #fff0f1;
  --teal: #188a7a;
  --teal-soft: #eaf8f5;
  --shadow: 0 12px 36px rgba(37, 58, 96, .055);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; }
button, select, .day-button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, .day-button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(49, 91, 212, .36);
  outline-offset: 2px;
}
.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;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: .06em;
}
.brand-mark {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--blue);
  color: white;
}
.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.topbar-date { margin: 0; color: var(--secondary); font-size: .88rem; }
.today-button {
  justify-self: end;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--blue);
  background: white;
  font-size: .88rem;
  font-weight: 650;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.today-button:hover { background: var(--blue-soft); border-color: #b7c6f2; }

.page-shell {
  width: min(1280px, calc(100% - 48px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  gap: 20px;
  align-items: start;
  margin: 28px auto 34px;
}
.calendar-card, .day-card, .events-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.calendar-card { overflow: hidden; }
.calendar-toolbar {
  min-height: 122px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px 26px;
}
.month-kicker {
  margin: 0 0 1px;
  color: var(--blue);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .12em;
}
.month-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: 2rem;
  font-weight: 760;
  letter-spacing: -.045em;
  line-height: 1.3;
}
.month-heading p:last-child {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .16em;
}
.toolbar-actions, .date-pickers, .month-stepper { display: flex; align-items: center; }
.toolbar-actions { gap: 11px; }
.date-pickers { gap: 7px; }
.date-pickers select {
  appearance: none;
  min-width: 104px;
  height: 38px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--secondary);
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364758a' stroke-width='2'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 9px center;
  font-size: .85rem;
  cursor: pointer;
}
.date-pickers label:last-child select { min-width: 76px; }
.month-stepper { gap: 6px; }
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--secondary);
  background: white;
  cursor: pointer;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.icon-button:hover { color: var(--blue); background: var(--blue-soft); border-color: #b7c6f2; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row {
  min-height: 43px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}
.weekday-row span { color: var(--secondary); font-size: .8rem; font-weight: 650; text-align: center; }
.weekday-row .weekend { color: var(--muted); }
.calendar-grid {
  gap: 1px;
  padding-top: 1px;
  background: var(--line);
}
.day-button {
  position: relative;
  min-width: 0;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 3px;
  padding: 10px 8px 7px;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: white;
  text-align: left;
  cursor: pointer;
  transition: background .14s ease;
}
.day-button:hover { background: #f5f8ff; }
.day-button.is-selected { background: #f3f6ff; }
.day-button.is-outside { background: #fbfcfe; }
.day-button.is-outside:hover { background: #f5f8ff; }
.solar-day {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  font-size: .98rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.is-outside .solar-day { color: #abb6c5; }
.is-today .solar-day { color: var(--blue); box-shadow: inset 0 0 0 1.5px var(--blue); }
.is-selected .solar-day { color: white; background: var(--blue); box-shadow: none; }
.is-workday:not(.is-selected) .solar-day { color: var(--teal); }
.day-note {
  width: 100%;
  overflow: hidden;
  padding-left: 7px;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.is-festival .day-note { color: var(--red); font-weight: 650; }
.is-term .day-note { color: var(--teal); font-weight: 650; }
.is-outside .day-note { color: #b8c1cc; }
.holiday-marker {
  position: absolute;
  top: 12px;
  right: 10px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  font-size: .69rem;
  font-weight: 750;
  line-height: 1;
}
.holiday-marker.holiday { color: var(--red); background: var(--red-soft); }
.holiday-marker.workday { color: var(--teal); background: var(--teal-soft); }
.is-outside .holiday-marker { opacity: .55; }

.legend {
  min-height: 50px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 11px 22px;
  background: white;
  color: var(--secondary);
  font-size: .75rem;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-badge { width: 17px; height: 17px; display: inline-grid; place-items: center; border-radius: 4px; font-size: .65rem; font-style: normal; font-weight: 750; }
.holiday-badge { color: var(--red); background: var(--red-soft); }
.workday-badge { color: var(--teal); background: var(--teal-soft); }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.festival-dot { background: var(--red); }
.term-dot { background: var(--teal); }
.today-dot { width: 10px; height: 10px; border: 1.5px solid var(--blue); }
.legend .keyboard-tip { margin-left: auto; color: var(--muted); }

.details-column { display: grid; gap: 16px; }
.day-card { overflow: hidden; }
.day-card-head {
  min-height: 153px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 24px 24px 20px;
  background: #f3f6ff;
  border-bottom: 1px solid #e2e9fc;
}
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: .75rem; font-weight: 650; letter-spacing: .04em; }
.day-card-head .eyebrow { color: var(--blue-dark); }
.date-number-line { display: flex; align-items: flex-end; gap: 12px; }
.date-number-line > strong {
  color: var(--blue);
  font-size: 4rem;
  font-weight: 760;
  letter-spacing: -.085em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.date-number-line h2 { margin: 0 0 2px; font-size: 1.03rem; font-weight: 700; }
.date-number-line p { margin: 0 0 3px; color: var(--secondary); font-size: .8rem; }
.zodiac-seal {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #cbd7f7;
  border-radius: 10px;
  color: var(--blue-dark);
  background: white;
  font-size: 1.1rem;
  font-weight: 700;
}
.lunar-panel { padding: 21px 24px 23px; }
.lunar-main { margin: 0; font-size: 1.22rem; font-weight: 730; }
.lunar-year { margin: 4px 0 0; color: var(--secondary); font-size: .82rem; }
.event-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.event-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 650;
}
.event-tag.festival, .event-tag.holiday { color: var(--red); background: var(--red-soft); }
.event-tag.term, .event-tag.workday { color: var(--teal); background: var(--teal-soft); }
.event-tag.plain { color: var(--secondary); background: var(--page); }
.date-facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.date-facts div { min-width: 0; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.date-facts div:nth-child(odd) { border-right: 1px solid var(--line); }
.date-facts div:nth-last-child(-n+2) { border-bottom: 0; }
.date-facts dt { color: var(--muted); font-size: .72rem; }
.date-facts dd { margin: 3px 0 0; color: var(--ink); font-size: .85rem; font-weight: 650; }

.events-card { padding: 22px 22px 18px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 13px; }
.section-heading .eyebrow { margin-bottom: 3px; }
.section-heading h2 { margin: 0; font-size: 1.08rem; font-weight: 730; }
.section-heading > span { color: var(--muted); font-size: .76rem; }
.month-events { list-style: none; margin: 0; padding: 0; display: grid; }
.month-events li + li { border-top: 1px solid #f0f2f6; }
.month-event {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 47px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 3px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.month-event:hover { background: var(--surface-soft); }
.event-date { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.event-name { overflow: hidden; font-size: .84rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.event-kind { padding: 3px 7px; border-radius: 5px; font-size: .68rem; font-weight: 650; }
.event-kind.festival { color: var(--red); background: var(--red-soft); }
.event-kind.term { color: var(--teal); background: var(--teal-soft); }
.month-events-empty { padding: 18px 2px; color: var(--muted); font-size: .84rem; }
.schedule-source { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .73rem; line-height: 1.6; }
.schedule-source a { color: var(--blue); text-underline-offset: 3px; }

footer {
  width: min(1280px, calc(100% - 48px));
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto;
  padding: 0 0 25px;
  color: var(--muted);
  font-size: .75rem;
}
footer p { margin: 0; }
noscript { display: block; max-width: 600px; margin: 50px auto; padding: 20px; color: var(--red); text-align: center; }

@media (max-width: 1000px) {
  .page-shell { grid-template-columns: minmax(0, 1fr) 310px; }
  .calendar-toolbar { padding-inline: 19px; }
  .date-pickers { display: none; }
  .day-button { min-height: 82px; }
  .legend .keyboard-tip { display: none; }
}
@media (max-width: 790px) {
  .topbar { padding-inline: 20px; }
  .page-shell { grid-template-columns: 1fr; width: min(700px, calc(100% - 32px)); margin-top: 20px; }
  .details-column { grid-template-columns: 1fr 1fr; }
  .date-pickers { display: flex; }
  footer { width: min(700px, calc(100% - 32px)); }
}
@media (max-width: 620px) {
  .topbar { min-height: 62px; grid-template-columns: 1fr auto; padding-inline: 16px; }
  .topbar-date { display: none; }
  .brand { font-size: 1.07rem; }
  .today-button { padding: 7px 12px; }
  .page-shell { width: calc(100% - 20px); gap: 12px; margin-top: 12px; }
  .calendar-card, .day-card, .events-card { border-radius: 13px; }
  .calendar-toolbar { min-height: 128px; display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 14px 15px 13px; }
  .month-heading h1 { font-size: 1.66rem; }
  .month-kicker { font-size: .7rem; }
  .toolbar-actions { display: contents; }
  .month-stepper { grid-column: 2; grid-row: 1; }
  .date-pickers { grid-column: 1 / -1; grid-row: 2; }
  .date-pickers select { height: 32px; min-width: 95px; font-size: .8rem; }
  .date-pickers label:last-child select { min-width: 70px; }
  .icon-button { width: 34px; height: 34px; }
  .weekday-row { min-height: 35px; }
  .weekday-row span { font-size: .75rem; }
  .day-button { min-height: 65px; align-items: flex-start; gap: 0; padding: 5px 2px 4px; text-align: left; }
  .solar-day { width: 29px; height: 29px; margin-left: 1px; font-size: .9rem; }
  .day-note { padding: 0 1px; font-size: .69rem; text-align: left; }
  .holiday-marker { top: 2px; right: 2px; width: 15px; height: 15px; border-radius: 3px; font-size: .58rem; }
  .legend { min-height: 47px; gap: 6px 11px; padding: 9px 12px; font-size: .68rem; }
  .legend-badge { width: 15px; height: 15px; }
  .details-column { grid-template-columns: 1fr; gap: 12px; }
  .day-card-head { min-height: 138px; padding: 20px; }
  .date-number-line > strong { font-size: 3.6rem; }
  .lunar-panel { padding: 18px 20px; }
  .date-facts div { padding: 13px 20px; }
  .events-card { padding: 18px 18px 16px; }
  footer { width: calc(100% - 28px); flex-wrap: wrap; gap: 3px 12px; font-size: .7rem; }
}
@media (max-width: 360px) {
  .calendar-toolbar { padding-inline: 11px; }
  .month-heading h1 { font-size: 1.48rem; }
  .month-stepper { gap: 4px; }
  .icon-button { width: 31px; height: 31px; }
  .day-note { font-size: .65rem; }
}
@media (min-width: 1001px) and (min-height: 720px) {
  body { display: flex; flex-direction: column; }
  .topbar { flex: 0 0 64px; min-height: 64px; }
  .page-shell {
    flex: 0 0 auto;
    height: min(760px, calc(100dvh - 128px));
    align-items: stretch;
    margin: 12px auto 14px;
  }
  .calendar-card {
    height: 100%;
    display: grid;
    grid-template-rows: 84px 36px minmax(0, 1fr) 38px;
  }
  .calendar-toolbar { min-height: 0; padding: 10px 22px; }
  .month-heading h1 { font-size: 1.75rem; }
  .weekday-row { min-height: 0; }
  .calendar-grid { min-height: 0; grid-template-rows: repeat(6, minmax(0, 1fr)); }
  .day-button { min-height: 0; gap: 1px; padding: 6px 8px 4px; }
  .solar-day { width: 30px; height: 30px; font-size: .94rem; }
  .holiday-marker { top: 8px; right: 8px; }
  .legend { min-height: 0; padding: 7px 18px; gap: 6px 15px; }
  .details-column { height: 100%; min-height: 0; grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
  .day-card-head { min-height: 0; padding: 14px 20px 12px; }
  .day-card-head .eyebrow { margin-bottom: 3px; }
  .date-number-line > strong { font-size: 3.3rem; }
  .lunar-panel { padding: 9px 20px; }
  .event-tags { margin-top: 8px; }
  .event-tag { min-height: 22px; padding: 2px 8px; }
  .date-facts div { padding: 6px 20px; }
  .events-card { min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: 12px 18px 10px; }
  .section-heading { flex: 0 0 auto; margin-bottom: 4px; }
  .month-events { min-height: 0; flex: 1 1 auto; overflow-y: auto; }
  .month-event { min-height: 29px; padding: 2px 3px; }
  .schedule-source { flex: 0 0 auto; margin-top: 7px; padding-top: 7px; }
  footer { flex: 0 0 auto; margin: auto auto 0; padding-bottom: 12px; }
}
@media (min-width: 1001px) and (min-height: 720px) and (max-height: 749px) {
  .day-card-head { padding: 10px 20px 8px; }
  .date-number-line > strong { font-size: 3.1rem; }
  .lunar-panel { padding: 6px 20px; }
  .date-facts div { padding: 5px 20px; }
  .events-card { padding-top: 10px; padding-bottom: 8px; }
  .month-event { min-height: 26px; padding: 1px 3px; }
  .schedule-source { margin-top: 5px; padding-top: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
