:root {
  color-scheme: light;
  --paper: #f6f5f0;
  --surface: #fffefa;
  --ink: #202820;
  --muted: #777d73;
  --line: #dedfd6;
  --green: #315d49;
  --green-pale: #e6eee8;
  --red: #bd5942;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "DM Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 14px; }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.topbar { height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(5.5vw, calc((100vw - 1280px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255, 254, 250, .72); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 500; letter-spacing: .16em; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--green); border-radius: 50%; }
.brand-mark span { width: 15px; height: 15px; border: 1.5px solid var(--green); border-radius: 50%; position: relative; }
.brand-mark span::after { content: ""; position: absolute; width: 8px; height: 15px; top: -2px; left: 5px; border-radius: 50%; background: var(--paper); }
.main-nav { height: 100%; display: flex; align-items: center; gap: 35px; }
.main-nav a { height: 100%; display: grid; align-items: center; color: var(--muted); border-bottom: 2px solid transparent; }
.main-nav a.active { color: var(--ink); border-color: var(--green); }
.today-chip { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.live-dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; }
main { width: min(1120px, calc(100% - 64px)); margin: 0 auto; }
.intro { display: flex; align-items: end; justify-content: space-between; padding: 56px 0 38px; }
.eyebrow { margin: 0 0 13px; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: .15em; }
.eyebrow-line { display: inline-block; width: 20px; height: 1px; margin: 0 8px 3px 0; background: var(--green); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: var(--serif); font-size: clamp(40px, 5vw, 59px); font-weight: 500; line-height: 1.04; }
h1 em { color: var(--green); font-weight: 500; }
.intro-copy { width: 290px; margin: 0 6% 6px 24px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.calendar-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; align-items: stretch; gap: 24px; }
.calendar-panel { min-width: 0; padding: 25px 28px 19px; border: 1px solid var(--line); background: var(--surface); }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 25px; }
.month-heading .eyebrow { margin-bottom: 5px; font-size: 9px; }
.month-heading h2 { margin: 0; font-family: var(--serif); font-size: 25px; font-weight: 500; }
.calendar-controls { display: flex; align-items: center; gap: 8px; }
.icon-button, .today-button { height: 34px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.icon-button { width: 34px; font-size: 18px; }
.icon-button:hover, .today-button:hover { border-color: var(--green); color: var(--green); }
.today-button { padding: 0 11px; font-size: 11px; }
.month-picker { width: 34px; height: 34px; padding: 5px; border: 1px solid var(--line); background: transparent; color: var(--green); cursor: pointer; }
.month-picker:hover, .month-picker[aria-expanded="true"] { border-color: var(--green); }
.month-picker-popover { position: absolute; z-index: 3; width: 255px; margin-top: 8px; padding: 12px; border: 1px solid #aeb4aa; background: var(--surface); box-shadow: 0 8px 20px #2028201c; }
.calendar-controls { position: relative; }
.month-picker-year { width: 100%; height: 28px; padding: 0 8px; border: 0; background: #ececea; color: var(--ink); outline-color: var(--green); }
.month-picker-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 10px 0 12px; }
.month-option, .month-picker-actions button { min-height: 32px; border: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: 11px; }
.month-option:hover, .month-option.is-selected { background: var(--green); color: white; }
.month-picker-actions { display: flex; justify-content: space-between; }
.month-picker-actions button { color: #1769d1; }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row { margin-bottom: 7px; color: var(--muted); font-size: 10px; text-align: center; }
.calendar-grid { grid-auto-rows: minmax(68px, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.calendar-cell { position: relative; min-width: 0; padding: 8px 7px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; transition: background .16s ease; }
.calendar-cell:hover { background: #f1f4ee; }
.calendar-cell.outside { background: #f6f5f0; }
.calendar-cell.outside .solar-number, .calendar-cell.outside .lunar-number { color: #aeb2aa; }
.solar-number { display: block; font-size: 15px; font-weight: 600; }
.lunar-number { display: block; margin-top: 7px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.lunar-number.new-moon { color: var(--green); font-weight: 700; }
.calendar-cell.is-today::before { content: ""; position: absolute; top: 5px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--red); }
.calendar-cell.is-selected { background: var(--green-pale); box-shadow: inset 0 0 0 1px var(--green); }
.calendar-cell.is-selected .solar-number { color: var(--green); }
.calendar-legend { display: flex; gap: 20px; padding-top: 15px; color: var(--muted); font-size: 10px; }
.calendar-legend span { display: flex; align-items: center; gap: 7px; }
.calendar-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.legend-today { background: var(--red); }
.legend-lunar { background: var(--green); }
.day-panel { position: relative; display: flex; min-height: 100%; flex-direction: column; padding: 23px 24px 19px; overflow: hidden; background: var(--green); color: #f8f7ef; }
.day-panel::after { content: ""; position: absolute; right: -61px; bottom: 68px; width: 175px; height: 175px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 0 0 17px rgba(255,255,255,.035), 0 0 0 35px rgba(255,255,255,.025); pointer-events: none; }
.day-panel-top { display: flex; align-items: center; justify-content: space-between; color: #c5d4c5; font-size: 9px; font-weight: 600; letter-spacing: .13em; }
.sun-symbol { color: #e5c887; font-size: 19px; }
.solar-date { display: flex; align-items: center; gap: 12px; margin: 29px 0 20px; }
.solar-date > span { font-family: var(--serif); font-size: 71px; line-height: .9; }
.solar-date > div { display: grid; gap: 6px; color: #d6e0d3; font-size: 10px; letter-spacing: .09em; }
.day-divider { height: 1px; background: rgba(255,255,255,.24); }
.detail-label { margin: 21px 0 8px; color: #c5d4c5; font-size: 9px; font-weight: 600; letter-spacing: .15em; }
.lunar-date { display: flex; align-items: baseline; gap: 7px; margin: 0; font-size: 12px; }
.lunar-date span:first-child { font-family: var(--serif); font-size: 41px; line-height: 1.1; }
.lunar-date span:last-child { margin-left: -4px; }
.lunar-year { margin: 7px 0 0; color: #d6e0d3; font-size: 10px; letter-spacing: .1em; }
.leap-note { width: max-content; margin: 11px 0 0; padding: 4px 8px; border: 1px solid rgba(255,255,255,.35); color: #f0dfb9; font-size: 10px; }
.day-panel-foot { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 26px; color: #c5d4c5; font-size: 9px; }
.moon-mark { color: #e5c887; font-size: 16px; }
.almanac-section { margin: 37px 0 0; border-top: 1px solid var(--line); }
.almanac-heading { display: flex; align-items: end; justify-content: space-between; padding: 23px 0 17px; }
.almanac-heading h2 { margin: 0; font-family: var(--serif); font-size: 25px; font-weight: 500; }
.source-link { color: var(--green); font-size: 11px; }
.almanac-content { padding: 18px 22px; border: 1px solid var(--line); background: var(--surface); }
.almanac-empty { margin: 0; color: var(--muted); font-size: 12px; }
.almanac-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 21px 25px; }
.almanac-facts > div { display: grid; align-content: start; gap: 7px; }
.almanac-facts span { color: var(--muted); font-size: 10px; }
.almanac-facts strong { font-size: 13px; font-weight: 600; }
.almanac-facts .auspicious-fact, .almanac-facts .hours-fact { grid-column: span 2; }
.almanac-facts .auspicious-fact span { color: var(--green); font-weight: 700; }
.almanac-facts p { margin: 0; font-size: 12px; line-height: 1.7; }
.converter-section { margin: 76px 0 65px; border-top: 1px solid var(--line); }
.converter-heading { display: flex; align-items: end; justify-content: space-between; padding: 27px 0 24px; }
.converter-heading h2 { margin: 0; font-family: var(--serif); font-size: 31px; font-weight: 500; }
.converter-heading > p { margin: 0 0 3px; color: var(--muted); font-size: 12px; }
.converter-body { display: grid; grid-template-columns: 1.35fr .8fr; gap: 52px; padding: 25px 28px; border: 1px solid var(--line); background: var(--surface); }
.segmented { display: inline-flex; gap: 4px; padding: 4px; background: #eeefe9; }
.segment { padding: 9px 12px; border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.segment.active { background: var(--surface); color: var(--green); box-shadow: 0 1px 4px #20282012; }
.date-fields { display: grid; grid-template-columns: .7fr .7fr 1fr; gap: 12px; margin: 19px 0 15px; }
.date-fields label { display: grid; gap: 7px; color: var(--muted); font-size: 10px; }
.date-fields input { width: 100%; height: 39px; padding: 0 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); outline-color: var(--green); }
.leap-toggle { display: flex; align-items: center; gap: 8px; margin: -3px 0 13px; color: var(--muted); font-size: 11px; }
.leap-toggle input { accent-color: var(--green); }
.convert-button { display: flex; width: 100%; height: 42px; align-items: center; justify-content: space-between; padding: 0 14px; border: 0; background: var(--green); color: white; font-size: 11px; cursor: pointer; }
.convert-button:hover { background: #244735; }
.conversion-result { display: flex; min-height: 130px; flex-direction: column; justify-content: center; padding-left: 29px; border-left: 1px solid var(--line); }
.result-kicker { color: var(--green); font-size: 9px; font-weight: 700; letter-spacing: .15em; }
.conversion-result p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.conversion-result .result-date { color: var(--ink); font-family: var(--serif); font-size: 25px; }
.conversion-result .result-error { color: var(--red); }
footer { display: flex; align-items: center; justify-content: space-between; padding: 20px max(5.5vw, calc((100vw - 1280px) / 2)); border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.footer-brand { color: var(--ink); font-size: 10px; }
.visually-hidden { 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: 800px) {
  main { width: min(100% - 36px, 620px); }
  .topbar { height: 64px; padding: 0 18px; }
  .main-nav { gap: 17px; font-size: 11px; }
  .today-chip { display: none; }
  .intro { padding: 43px 0 27px; }
  h1 { font-size: 45px; }
  .intro-copy { width: 210px; margin-right: 0; font-size: 11px; }
  .calendar-layout { grid-template-columns: 1fr; gap: 14px; }
  .day-panel { min-height: 210px; }
  .solar-date { margin: 20px 0 14px; }
  .day-panel-foot { padding-top: 19px; }
  .calendar-grid { grid-auto-rows: minmax(63px, 1fr); }
  .calendar-panel { padding: 20px 17px 15px; }
  .weekday-row { font-size: 9px; }
  .weekday-row span { overflow: hidden; text-overflow: ellipsis; }
  .calendar-cell { padding: 7px 5px; }
  .solar-number { font-size: 13px; }
  .lunar-number { font-size: 9px; }
  .converter-body { grid-template-columns: 1fr; gap: 21px; padding: 19px; }
  .conversion-result { min-height: 85px; padding: 16px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .almanac-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .almanac-facts .auspicious-fact, .almanac-facts .hours-fact { grid-column: span 2; }
}

@media (max-width: 480px) {
  main { width: calc(100% - 24px); }
  .topbar { padding: 0 12px; }
  .brand { gap: 7px; font-size: 11px; }
  .brand-mark { width: 26px; height: 26px; }
  .main-nav { gap: 12px; font-size: 10px; }
  .intro { display: block; padding-top: 36px; }
  h1 { font-size: 42px; }
  .intro-copy { width: auto; max-width: 320px; margin: 17px 0 0; }
  .calendar-panel { padding: 16px 10px 13px; }
  .calendar-toolbar { align-items: end; }
  .month-heading h2 { font-size: 21px; }
  .calendar-controls { gap: 5px; }
  .icon-button { width: 30px; height: 32px; }
  .today-button { height: 32px; padding: 0 7px; font-size: 10px; }
  .month-picker { width: 31px; height: 32px; }
  .weekday-row { font-size: 8px; }
  .calendar-grid { grid-auto-rows: minmax(54px, 1fr); }
  .calendar-cell { padding: 6px 3px; }
  .solar-number { font-size: 12px; }
  .lunar-number { margin-top: 6px; font-size: 8px; }
  .calendar-legend { gap: 12px; font-size: 9px; }
  .day-panel { padding: 18px 20px 16px; }
  .almanac-content { padding: 15px; }
  .almanac-facts { gap: 17px 12px; }
  .almanac-facts strong { font-size: 12px; }
  .converter-section { margin: 52px 0 42px; }
  .converter-heading { display: block; }
  .converter-heading h2 { font-size: 27px; }
  .converter-heading > p { margin-top: 11px; font-size: 11px; }
  .converter-body { padding: 13px; }
  .segment { padding: 9px 7px; font-size: 9px; }
  footer { padding: 17px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Dark folklore theme */
:root {
  color-scheme: dark;
  --paper: #090708;
  --surface: rgba(19, 10, 12, .91);
  --ink: #f1d8d3;
  --muted: #b58f8b;
  --line: rgba(173, 65, 60, .38);
  --green: #d94b45;
  --green-pale: rgba(118, 24, 27, .58);
  --red: #f05b50;
}

body {
  position: relative;
  isolation: isolate;
  background: #090708;
  color: var(--ink);
}

body::before {
  position: fixed;
  z-index: -2;
  inset: 0;
  content: "";
  background-image: linear-gradient(90deg, rgba(5, 3, 4, .92), rgba(25, 4, 7, .78)), url("https://images.unsplash.com/photo-1518709268805-4e9042af9f23?auto=format&fit=crop&w=2200&q=72");
  background-position: center;
  background-size: cover;
  filter: saturate(.75) contrast(1.12);
  opacity: .8;
}

body::after {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  background: radial-gradient(circle at 74% 25%, rgba(166, 25, 28, .2), transparent 30%), linear-gradient(180deg, transparent, rgba(5, 2, 3, .56));
  pointer-events: none;
}

.topbar, footer { border-color: var(--line); background: rgba(9, 7, 8, .86); }
.brand, .footer-brand, .main-nav a.active, h1, h2, .month-heading h2, .converter-heading h2 { color: var(--ink); }
.brand-mark, .brand-mark span { border-color: var(--red); }
.brand-mark span::after { background: var(--paper); }
.brand small, .today-chip, .intro-copy, .main-nav a, .converter-heading > p, footer { color: var(--muted); }
.eyebrow, .eyebrow-line, .source-link, .lunar-number.new-moon { color: var(--red); }
.eyebrow-line { background: var(--red); }
.live-dot, .calendar-cell.is-today::before, .legend-today { background: var(--red); }

.calendar-panel, .almanac-content, .converter-body, .month-picker-popover {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .3);
}
.icon-button, .today-button, .month-picker, .date-fields input { border-color: var(--line); color: var(--ink); }
.icon-button:hover, .today-button:hover, .month-picker:hover, .month-picker[aria-expanded="true"] { border-color: var(--red); color: var(--red); }
.month-picker-year, .segmented { background: rgba(74, 18, 21, .55); color: var(--ink); }
.month-option, .month-picker-actions button { color: var(--ink); }
.month-option:hover, .month-option.is-selected { background: var(--red); color: #180607; }
.calendar-grid, .calendar-cell, .calendar-cell.outside { border-color: var(--line); background: rgba(13, 8, 9, .82); }
.calendar-cell:hover { background: rgba(103, 21, 25, .62); }
.calendar-cell.is-selected { background: var(--green-pale); box-shadow: inset 0 0 0 1px var(--red); }
.calendar-cell.is-selected .solar-number { color: var(--red); }
.calendar-cell.outside .solar-number, .calendar-cell.outside .lunar-number { color: #6e4c4d; }
.calendar-legend, .weekday-row, .lunar-number { color: var(--muted); }
.legend-lunar { background: var(--red); }

.day-panel { background: linear-gradient(145deg, #691619, #26090d 72%); box-shadow: 0 18px 55px rgba(0, 0, 0, .35); }
.day-panel-top, .detail-label, .day-panel-foot { color: #e2aaa4; }
.solar-date > div, .lunar-year { color: #d6a19d; }
.day-divider { background: rgba(245, 130, 120, .32); }
.sun-symbol, .moon-mark { color: #ffb26c; }

.almanac-facts span { color: var(--muted); }
.almanac-facts .auspicious-fact span { color: var(--red); }
.segment.active { background: #401013; color: var(--red); }
.convert-button { background: #a52e32; color: #fff0ed; }
.convert-button:hover { background: #c43b3e; }
.result-kicker, .conversion-result .result-error { color: var(--red); }
.conversion-result .result-date { color: var(--ink); }

.card { border-color: var(--line) !important; background: rgba(20, 9, 11, .92) !important; color: var(--ink); }
.text-secondary { color: var(--muted) !important; }
.table { --bs-table-color: var(--ink); --bs-table-border-color: var(--line); }
.table-success { --bs-table-bg: rgba(113, 26, 29, .72); --bs-table-color: #ffd9d2; }
.table-secondary { --bs-table-bg: rgba(55, 38, 40, .8); --bs-table-color: #c7a9a6; }
.text-bg-success { background-color: #a52e32 !important; }