:root {
  --deep-brown: #1b1713;
  --paper: #cfc5b5;
  --paper-light: #d8cfc1;
  --ink: #29231d;
  --soft-ink: #6f655a;
  --line: rgba(48, 39, 31, 0.18);
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-writing: "ChillHuoKai", "Songti SC", "Noto Serif CJK SC", serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--deep-brown); }
body { margin: 0; color: var(--ink); font-family: var(--font-ui); -webkit-font-smoothing: antialiased; }
/* Only the writing waits briefly. Navigation and photographs remain available. */
html[data-writing-font="pending"] .day-copy { visibility: hidden; }
html[data-writing-font="fallback"] .day-copy { font-family: "Songti SC", "Noto Serif CJK SC", serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
.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; }

.home-body { overflow: hidden; background: var(--deep-brown); }
.home-page { height: 100svh; min-height: 100svh; display: grid; grid-template-rows: minmax(0, 1fr) 48px; overflow: hidden; background: var(--deep-brown); }
.home-figure { position: relative; min-height: 0; margin: 0; overflow: hidden; background: #17130f; }
.home-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: var(--desktop-focus, 56% 20%); opacity: 0; animation: home-reveal 1.35s ease-out 0.08s forwards; }
.home-entry { display: flex; align-items: center; justify-content: center; color: #d7cbb8; font-size: 12px; letter-spacing: 0.16em; }
.home-entry a { padding: 12px 20px; transition: color 180ms ease; }
.home-entry a:hover, .home-entry a:focus-visible { color: #fff8ea; }
@keyframes home-reveal { to { opacity: 1; } }

.day-page { min-height: 100svh; color: var(--ink); background-color: var(--paper); background-image: radial-gradient(circle at 17% 23%, rgba(255,255,255,.18) 0 0.7px, transparent 0.9px), radial-gradient(circle at 72% 68%, rgba(66,48,33,.08) 0 0.65px, transparent 0.9px), linear-gradient(115deg, rgba(255,255,255,.06), rgba(91,70,48,.04)); background-size: 9px 11px, 13px 15px, 100% 100%; }
.day-header { width: min(1220px, calc(100% - 48px)); height: 72px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); color: var(--soft-ink); font-size: 12px; letter-spacing: 0.11em; }
.day-header a:first-child { justify-self: start; }
.day-header span:last-child { justify-self: end; }
.date-jump { width: min(1120px, calc(100% - 48px)); min-height: 54px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); color: var(--soft-ink); font-family: var(--font-ui); font-size: 11px; letter-spacing: .1em; }
.date-jump-label { white-space: nowrap; }
.date-jump-fields { display: flex; align-items: center; gap: 8px; }
.date-jump select, .date-jump button { appearance: none; padding: 8px 2px; border: 0; border-radius: 0; background: transparent; color: var(--ink); font: inherit; letter-spacing: .06em; cursor: pointer; }
.date-jump select { padding-right: 15px; background-image: linear-gradient(45deg, transparent 50%, var(--soft-ink) 50%), linear-gradient(135deg, var(--soft-ink) 50%, transparent 50%); background-position: calc(100% - 5px) 50%, 100% 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.date-jump button { margin-left: 12px; color: var(--soft-ink); }
.date-jump select:focus-visible, .date-jump button:focus-visible { outline: 1px solid var(--soft-ink); outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.day-article { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: clamp(64px, 9vw, 120px) 0 44px; }
.day-date { display: block; margin: 0 0 30px; padding: 0; border: 0; background: none; color: var(--soft-ink); font-size: 12px; letter-spacing: 0.12em; cursor: pointer; }
.day-copy { margin: 0 0 clamp(58px, 7vw, 92px); font-family: var(--font-writing); font-size: clamp(25px, 2.25vw, 35px); font-weight: 400; line-height: 1.78; letter-spacing: 0.035em; white-space: pre-line; }
.day-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(14px, 2.2vw, 28px); }
.day-gallery button { display: block; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.day-gallery img { display: block; width: 100%; height: auto; }
.day-footer { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 24px 0 36px; display: grid; grid-template-columns: 1fr auto 1fr; border-top: 1px solid var(--line); color: var(--soft-ink); font-size: 12px; letter-spacing: 0.08em; }
.day-footer span:last-child { text-align: right; }
.day-missing { margin: 0 0 22px; font-family: var(--font-writing); font-size: clamp(24px, 3vw, 34px); }
.day-article > .day-missing + a { color: var(--soft-ink); font-size: 12px; letter-spacing: .1em; }
.on-this-day { display: block; width: min(1120px, calc(100% - 48px)); margin: -18px auto 30px; color: var(--soft-ink); text-align: center; font-size: 11px; letter-spacing: .08em; }

.calendar-dialog { width: min(360px, calc(100% - 32px)); padding: 22px; border: 1px solid rgba(48,39,31,.22); background: var(--paper-light); color: var(--ink); box-shadow: 0 24px 80px rgba(32,24,17,.35); }
.calendar-dialog::backdrop { background: rgba(17,14,11,.54); }
.calendar-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.calendar-heading h2 { margin: 0 0 5px; font-size: 16px; font-weight: 550; }
.calendar-heading p { margin: 0; color: var(--soft-ink); font-size: 12px; }
.calendar-heading button { padding: 0 4px; border: 0; background: transparent; color: var(--soft-ink); font-size: 24px; cursor: pointer; }
.calendar-month { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 26px 0 18px; font-size: 13px; }
.calendar-month button { padding: 6px 10px; border: 0; background: transparent; color: var(--soft-ink); font-size: 18px; cursor: pointer; }
.calendar-month button:first-child { justify-self: start; }
.calendar-month button:last-child { justify-self: end; }
.calendar-month strong { font-weight: 500; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.calendar-weekdays { color: var(--soft-ink); font-size: 10px; }
.calendar-weekdays span, .calendar-grid span, .calendar-grid a { display: grid; place-items: center; aspect-ratio: 1; }
.calendar-grid { margin-top: 6px; font-size: 12px; }
.calendar-grid span { color: rgba(41,35,29,.38); }
.calendar-grid a { border-radius: 50%; background: var(--ink); color: #f4ecdf; }

.lightbox[hidden] { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 40px 72px; border: 0; background: rgba(17, 14, 11, 0.96); color: #eee4d5; touch-action: pan-y; }
.lightbox-image { display: block; max-width: min(1100px, 100%); max-height: calc(100svh - 80px); object-fit: contain; }
.lightbox-close, .lightbox-prev, .lightbox-next { position: fixed; border: 0; background: transparent; color: inherit; cursor: pointer; }
.lightbox-close { top: 20px; right: 22px; font-size: 25px; }
.lightbox-prev, .lightbox-next { top: 50%; padding: 18px; font-size: 26px; transform: translateY(-50%); }
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }

@media (max-width: 700px) {
  .home-page { grid-template-rows: minmax(0, 1fr) 46px; }
  .home-image { object-position: var(--mobile-focus, 59% 45%); }
  .day-header, .date-jump, .day-article, .day-footer { width: calc(100% - 32px); }
  .day-header { height: 60px; }
  .date-jump { min-height: 58px; gap: 10px; }
  .date-jump-label { display: none; }
  .date-jump-fields { width: 100%; justify-content: space-between; gap: 4px; }
  .date-jump button { margin-left: auto; }
  .day-article { padding-top: 56px; }
  .day-date { margin-bottom: 24px; }
  .day-copy { margin-bottom: 52px; font-size: 24px; }
  .day-gallery { grid-template-columns: 1fr; gap: 16px; }
  .lightbox { padding: 52px 20px; }
}

@media (prefers-reduced-motion: reduce) { .home-image { opacity: 1; animation: none; } }
