:root {
  --paper: #f5efe3;
  --card: #fffcf6;
  --ink: #2b251e;
  --ink-2: #6c6255;
  --ink-3: #9c9082;
  --line: #e7ddcb;
  --red: #b0392d;
  --red-deep: #8e2a20;
  --gold: #a87b3e;
  --green: #55724a;
  --shadow: 0 20px 46px -28px rgba(62, 45, 28, .45);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 560px at 8% -12%, #fdf8ec 0%, rgba(253, 248, 236, 0) 62%),
    radial-gradient(900px 520px at 102% -4%, #f1e5d2 0%, rgba(241, 229, 210, 0) 58%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .5;
  background-image: repeating-linear-gradient(0deg, rgba(120, 90, 60, .028) 0 1px, transparent 1px 3px);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1140px;
  margin: 0 auto;
  padding: 30px 24px 42px;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff8ec;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  background: linear-gradient(150deg, var(--red) 0%, var(--red-deep) 100%);
  box-shadow: 0 10px 20px -10px rgba(142, 42, 32, .85), inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.brand-copy h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .16em;
}

.brand-copy p {
  margin: 4px 0 0;
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--ink-3);
}

.today-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 246, .78);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: .06em;
  cursor: pointer;
  transition: border-color .18s, color .18s, background .18s;
}

.today-btn:hover {
  border-color: rgba(176, 57, 45, .45);
  color: var(--red);
  background: #fffaf0;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: 20px;
  align-items: start;
}

/* ---------- calendar ---------- */

.cal-card {
  padding: 22px 22px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.nav-group { display: flex; gap: 4px; }

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.icon-btn:hover:not(:disabled) {
  background: #f4ebdc;
  color: var(--ink);
}

.icon-btn:disabled {
  opacity: .25;
  cursor: default;
}

.cal-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.pickers {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.pickers select {
  max-width: 132px;
  padding: 2px 15px 2px 4px;
  border: 0;
  border-radius: 8px;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239c9082' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 3px center;
  background-size: 9px 6px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 23px;
  letter-spacing: .02em;
  text-align: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.pickers select:hover { background: #f4ebdc; }
.pickers select:focus-visible { outline: 2px solid rgba(176, 57, 45, .45); outline-offset: 2px; }

.lunar-year {
  font-size: 11.5px;
  letter-spacing: .2em;
  color: var(--ink-3);
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--ink-3);
  text-align: center;
}

.weekdays .wk { color: #b06a5d; }

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

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 76px;
  padding: 6px 2px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}

.day:hover { background: #f6efe2; }

.day.selected {
  border-color: rgba(176, 57, 45, .5);
  background: #fdf6e9;
  box-shadow: 0 0 0 3px rgba(176, 57, 45, .07);
}

.d-num {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  font-family: var(--serif);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  border-radius: 50%;
}

.d-lunar {
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.1;
  color: var(--ink-3);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.d-lunar.is-term { color: var(--green); }
.d-lunar.is-festival { color: var(--red); font-weight: 600; }

.day.weekend .d-num { color: #a4594a; }

.day.today .d-num {
  color: #fff8ec;
  background: linear-gradient(150deg, var(--red), var(--red-deep));
  box-shadow: 0 8px 16px -9px rgba(142, 42, 32, .9);
}

.day.today .d-lunar { color: var(--red); }
.day.out { opacity: .38; }

.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
  padding: 12px 6px 0;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--ink-3);
  vertical-align: 1px;
}

.today-dot { background: var(--red); }
.term-dot { background: var(--green); }
.fest-dot { background: var(--red); }

.legend-hint {
  margin-left: auto;
  letter-spacing: .04em;
}

/* ---------- side panel ---------- */

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 20px 22px 20px;
  border-radius: 22px;
  color: #f7efe1;
  background:
    radial-gradient(130% 120% at 12% 0%, #42392f 0%, #2b251f 46%, #211c17 100%);
  box-shadow: 0 24px 46px -28px rgba(40, 30, 20, .9);
}

.hero::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -66px;
  width: 190px;
  height: 190px;
  border: 1px solid rgba(214, 181, 130, .28);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(214, 181, 130, .05), 0 0 0 40px rgba(214, 181, 130, .035);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  letter-spacing: .18em;
  color: #c8b593;
}

.hero-main {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-top: 8px;
}

.hero-day {
  font-family: var(--serif);
  font-size: 64px;
  line-height: .92;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.hero-info { padding-bottom: 5px; min-width: 0; }

.hero-lunar {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: .04em;
  color: #f2e6d0;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.hero-chips:empty { display: none; }

.chip {
  padding: 2px 9px;
  border: 1px solid rgba(214, 181, 130, .38);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .08em;
  color: #ecd3a9;
  white-space: nowrap;
}

.hero-gz {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(214, 181, 130, .16);
  font-size: 12.5px;
  letter-spacing: .08em;
  color: #b7a68c;
}

.facts-card {
  padding: 4px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 16px 36px -30px rgba(62, 45, 28, .6);
}

.facts {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  margin: 0;
}

.facts dt,
.facts dd {
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}

.facts dt {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--ink-3);
}

.facts dd {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink);
  text-align: right;
}

.facts dt:last-of-type,
.facts dd:last-of-type { border-bottom: 0; }

/* ---------- footer ---------- */

.foot {
  margin-top: 28px;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--ink-3);
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }

  .side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

@media (max-width: 640px) {
  .page { padding: 18px 13px 30px; }

  .topbar { margin-bottom: 16px; }

  .brand { gap: 11px; }
  .seal { width: 40px; height: 40px; font-size: 22px; border-radius: 9px; }
  .brand-copy h1 { font-size: 21px; letter-spacing: .12em; }
  .brand-copy p { font-size: 9.5px; letter-spacing: .14em; }
  .today-btn { padding: 8px 12px; font-size: 11.5px; }

  .cal-card { padding: 14px 12px 10px; border-radius: 18px; }

  .icon-btn { width: 31px; height: 31px; font-size: 17px; }
  .pickers select { font-size: 19px; max-width: 104px; }
  .lunar-year { font-size: 10.5px; letter-spacing: .14em; }

  .weekdays { font-size: 11px; padding: 6px 0 8px; }
  .days { gap: 2px; padding-top: 6px; }

  .day { min-height: 58px; gap: 3px; border-radius: 11px; padding: 4px 1px; }
  .d-num { min-width: 28px; height: 28px; font-size: 16.5px; }
  .d-lunar { font-size: 9.5px; }

  .legend { gap: 11px; font-size: 10.5px; padding-top: 10px; margin-top: 8px; }
  .legend-hint { display: none; }

  .side { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 18px 18px; border-radius: 18px; }
  .hero-day { font-size: 54px; }
  .hero-lunar { font-size: 15.5px; }
  .facts-card { padding: 2px 16px; }
  .facts dt, .facts dd { padding: 8px 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.noscript {
  margin: 40px auto;
  padding: 16px 20px;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  text-align: center;
}
