:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #deded6;
  color: #29271f;
  --paper: #eeebdf;
  --detail-paper: #f6f3e9;
  --ink: #29271f;
  --muted: #5c5547;
  --cobalt: #274195;
  --ochre: #8e4e16;
  --line: #cfc7b4;
  --timeline-ink: #1c1a17;
  --row-height: 83px;
  --end-padding: 24px;
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p, ol { margin: 0; }
a { color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 4px; }
.preview { max-width: 438px; margin: auto; padding: 16px 12px; }
.panel { min-width: 0; }
.screen {
  width: 100%;
  min-height: 750px;
  background: var(--paper);
  border: 1px solid #c7c0b0;
  border-radius: 12px;
}
.year-archive-header {
  padding: max(21px, env(safe-area-inset-top)) 19px 10px;
  text-align: center;
}
#year-archive-title:focus, #overview-title:focus { outline: none; }
#year-list {
  --year-axis-x: clamp(21px, 7vw, 29px);
  position: relative;
  list-style: none;
  padding: 6px 17px max(36px, env(safe-area-inset-bottom)) var(--year-axis-x);
}
#year-list:not(:empty)::before {
  content: "";
  position: absolute;
  inset-block: 0 20px;
  left: var(--year-axis-x);
  width: 8px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: var(--timeline-ink);
  pointer-events: none;
}
#year-list > li + li { margin-top: 25px; }
.year-link {
  position: relative;
  display: block;
  padding: 7px 0 0 clamp(21px, 6.5vw, 27px);
  border-radius: 6px;
  text-decoration: none;
}
.year-link::before {
  content: "";
  position: absolute;
  top: 24px;
  left: 0;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--timeline-ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--paper);
}
.year-number {
  display: block;
  color: var(--ink);
  font-size: clamp(2.125rem, 10vw, 2.5rem);
  line-height: 1;
}
.year-summary {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
.year-thumbnails {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0;
  margin-top: 10px;
}
.year-thumbnails img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--line);
}
.year-link:focus-visible { outline-offset: 3px; }
@media (hover: hover) {
  .year-link:hover .year-number { color: var(--cobalt); }
}
.overview-header {
  display: grid;
  grid-template-columns: minmax(44px, 1fr) minmax(0, max-content) minmax(44px, 1fr);
  align-items: center;
  gap: 12px;
  padding: max(30px, env(safe-area-inset-top)) 27px 25px;
}
#back-to-years { justify-self: start; }
.overview h2, .detail h2 {
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  color: var(--ink);
  font-size: 1.78rem;
  font-weight: 800;
  line-height: 1.17;
}
#overview-title,
#year-archive-title,
#overview-year,
.year-number,
.date-block time,
.entry-time,
.author {
  font-family: "MengQi-PRenTi", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-synthesis: none;
}
#overview-title, #year-archive-title { font-size: 2.25rem; line-height: 1.17; }
#overview-year {
  justify-self: end;
  color: var(--muted);
  font-size: 1.05rem;
}

#dates {
  position: relative;
  padding: 0 0 var(--end-padding);
  list-style: none;
}
#dates::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 7px;
  bottom: calc(var(--end-padding) + 18px);
  left: 50%;
  width: 5px;
  transform: translateX(-50%);
  background: var(--timeline-ink);
  border-radius: 2.5px;
  pointer-events: none;
}
#dates li {
  --tone: var(--ochre);
  padding-top: var(--gap, 0px);
}
#dates li.with-photos { --tone: var(--cobalt); }
.date-row {
  --heading-center: 15px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  width: 100%;
  min-height: var(--row-height);
  color: var(--ink);
  text-decoration: none;
}
.branch {
  --inner: 14px;
  position: relative;
  z-index: 2;
  display: block;
  min-width: 0;
  padding-top: 1px;
  margin-top: calc(var(--day-anchor-y, var(--heading-center)) - var(--heading-center));
}
.has-collage .branch { --inner: 31px; }
.to-right .branch { grid-column: 2; padding-inline: var(--inner) 13px; }
.to-left .branch { grid-column: 1; padding-inline: 13px var(--inner); text-align: right; }
.date-node {
  position: absolute;
  z-index: 2;
  top: var(--day-anchor-y, var(--heading-center));
  left: 50%;
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--timeline-ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--paper);
  pointer-events: none;
}
.today .date-node {
  width: 14px;
  height: 14px;
  border-color: var(--cobalt);
  background: var(--cobalt);
}
.date-star { display: none; }
.important .date-node {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-color: var(--ochre);
  background: var(--ochre);
  color: #fffdf2;
}
.important .date-star { display: block; font: 11px/1 -apple-system, BlinkMacSystemFont, sans-serif; }

.date-block {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-height: 32px;
}
.to-left .date-block { flex-direction: row-reverse; }
.date-block time {
  background: var(--paper);
  font-size: 1.82rem;
  line-height: 1;
}
.weekday { color: var(--muted); background: var(--paper); font-size: .875rem; white-space: nowrap; }
.today .weekday { color: var(--cobalt); font-weight: 700; }
.important-note {
  display: block;
  width: max-content;
  max-width: 100%;
  margin-top: 2px;
  overflow: hidden;
  color: #743b13;
  background: var(--paper);
  font-size: .83rem;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.to-left .important-note { margin-left: auto; }
.counts {
  display: grid;
  justify-items: start;
  gap: 2px;
  margin-top: 7px;
  font-size: .875rem;
  line-height: 1.34;
}
.to-left .counts { justify-items: end; }
.counts > span {
  padding: 1px 5px;
  background: #faf7ec;
  color: var(--muted);
  white-space: nowrap;
}
.counts .photo-label { margin-inline-start: 6px; }
.to-left .counts .photo-label { margin: 0 6px 0 0; }
.counts b { color: var(--ink); font-weight: 740; font-variant-numeric: tabular-nums; }
.with-photos .photo-label, .with-photos .photo-label b { color: var(--cobalt); }
.date-row:focus-visible { z-index: 1; outline-offset: -5px; }
.date-row:active { background: #4d38100b; }
@media (hover: hover) {
  .date-row:hover .date-block time { color: var(--tone); }
  .date-row:hover .counts > span { background: #fffdf5; }
}

.detail { background: var(--detail-paper); }
.detail-header { padding: max(21px, env(safe-area-inset-top)) 25px 18px; }
.detail-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#back, #back-to-years, #important-toggle {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 4px;
  font: 1.65rem/1 -apple-system, BlinkMacSystemFont, sans-serif;
}
#back, #back-to-years {
  color: var(--cobalt);
  text-decoration: none;
}
#important-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
#important-toggle[aria-pressed="true"] { color: #743b13; }
#important-toggle:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; }
#important-note {
  display: block;
  width: min(100%, 260px);
  min-height: 44px;
  margin: 4px auto 0;
  padding: 4px 2px;
  border: 0;
  border-bottom: 1px solid #bfb49c;
  border-radius: 0;
  background: transparent;
  color: #743b13;
  font: inherit;
  font-size: 1rem;
  text-align: center;
}
#important-note::placeholder { color: var(--muted); }
#important-note:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; }
#important-status { margin-top: 8px; color: var(--muted); font-size: .875rem; }
.detail-date { display: flex; justify-content: center; align-items: baseline; gap: 8px; margin-top: 10px; }
#detail-title:focus { outline: 0; }
#detail-day { color: var(--muted); font-size: .875rem; }
:is(#entries, .book-entries) {
  position: relative;
  display: grid;
  gap: 9px;
  list-style: none;
  padding: 11px 15px 35px;
}
:is(#entries, .book-entries):not(:empty)::before {
  content: "";
  position: absolute;
  inset-block: 0 26px;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: #b5ab97;
}
.entry-row {
  --entry-accent: #26417c;
  --entry-paper: #e4eaf0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(22px, 7vw, 30px);
  align-items: start;
}
.entry-row:is([data-author="fufu"], [data-member="2"]) {
  --entry-accent: #754a24;
  --entry-paper: #efe4ce;
}
.entry-row::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--entry-accent);
  box-shadow: 0 0 0 2px var(--detail-paper);
}
.entry-time, .entry { grid-row: 1; }
.entry-time {
  grid-column: 2;
  justify-self: start;
  margin-top: 8px;
  color: var(--entry-accent);
  font-size: .98rem;
  line-height: 18px;
  white-space: nowrap;
}
.entry {
  position: relative;
  grid-column: 1;
  justify-self: end;
  min-width: 0;
  max-width: 100%;
  padding: 8px 9px 9px;
  border-radius: 13px 6px 13px 13px;
  background: var(--entry-paper);
}
.entry:has(.photos:not([hidden])) { width: 100%; }
.entry::before {
  content: "";
  position: absolute;
  top: 12px;
  right: -7px;
  width: 8px;
  height: 10px;
  background: var(--entry-paper);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.entry-row:is([data-author="fufu"], [data-member="2"]) .entry-time { grid-column: 1; justify-self: end; }
.entry-row:is([data-author="fufu"], [data-member="2"]) .entry {
  grid-column: 2;
  justify-self: start;
  border-radius: 6px 13px 13px 13px;
}
.entry-row:is([data-author="fufu"], [data-member="2"]) .entry::before { right: auto; left: -7px; transform: scaleX(-1); }
.author { color: var(--entry-accent); font-size: .86rem; }
.content { margin-top: 3px; font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere; }
.place { margin-top: 4px; color: var(--muted); font-size: .79rem; overflow-wrap: anywhere; }
.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 4px; margin-top: 7px; }
.photo-open {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
  touch-action: manipulation;
}
.photo-open:last-child:nth-child(odd) { grid-column: 1 / -1; }
.photo-open:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.photo-open img { display: block; width: 100%; height: auto; border-radius: inherit; }

html:has(#photo-viewer[open], #moment-editor[open]) { overflow: hidden; }
#photo-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: calc(60px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border: 0;
  background: transparent;
}
#photo-viewer[open] {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
}
#photo-viewer::backdrop { background: #151310f0; }
#photo-viewer form {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
}
#photo-viewer button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ffffff20;
  color: #fff;
  font: 1.6rem/1 -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
#photo-viewer button:focus-visible { outline: 2px solid white; outline-offset: 2px; }
#photo-viewer-image { display: block; max-width: min(100%, 1080px); max-height: 100%; }

.compare .preview { width: min(100%, 886px); max-width: none; padding: 24px 24px 32px; }
.preview-heading { margin-bottom: 20px; }
.preview-heading p { font-size: .85rem; font-weight: 700; }
.preview-heading h1 { margin-top: 4px; font-size: 1.875rem; letter-spacing: -.045em; }
.compare .screens { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.compare .panel { display: flex; flex-direction: column; }
.compare #year-archive { grid-column: 1 / -1; width: min(100%, 414px); justify-self: center; }
.compare .screen { flex: 1; }
.frame-caption { margin-bottom: 8px; color: #49463c; font-size: .9rem; font-weight: 650; }

@media (max-width: 500px) {
  body:not(.compare) { background: var(--paper); }
  body:not(.compare) .preview { padding: 0; }
  body:not(.compare) .screen { min-height: 100svh; border: 0; border-radius: 0; }
}
@media (max-width: 690px) {
  .compare .preview { max-width: 442px; padding: 18px 12px; }
  .compare .screens { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 349px) {
  .detail-header, .overview-header { padding-inline: 18px; }
  .date-block time { font-size: 1.66rem; }
  .date-row { --heading-center: 14px; }
  .has-collage .branch { --inner: 24px; }
}

.branches, .stickers { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stickers { z-index: 1; }
.sticker {
  position: absolute;
  width: 0;
  height: 0;
  object-fit: contain;
  filter: drop-shadow(0 1px 0 #39281c22);
}

.detail-write-actions { display: flex; justify-content: center; gap: 4px; margin-top: 5px; }
#new-moment, #backfill-moment, #moment-editor button, .moment-add-photo { font: inherit; cursor: pointer; touch-action: manipulation; }
#new-moment, #backfill-moment {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--cobalt);
  font-size: .9rem;
  font-weight: 650;
}
#new-moment:not([hidden]) + #backfill-moment { color: var(--muted); }
#moment-editor {
  position: fixed;
  inset: 0;
  width: min(100%, 430px);
  max-width: none;
  max-height: calc(100dvh - 18px);
  margin: auto auto 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 15px 15px 0 0;
  background: var(--detail-paper);
  color: var(--ink);
}
@media (min-width: 501px) {
  #moment-editor { margin: auto; border-radius: 15px; }
}
#moment-editor::backdrop { background: #2b241a71; }
#moment-form { display: flex; flex-direction: column; max-height: calc(100dvh - 18px); }
.moment-header, .moment-photo-actions, .moment-sticker-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.moment-header { padding: 15px 15px 12px 19px; }
#moment-date { color: var(--muted); font-size: .85rem; }
#moment-title { margin-top: 3px; font-size: 1.46rem; line-height: 1.2; }
#moment-editor #close-moment {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
}
.moment-body { min-height: 0; padding: 0 19px 17px; overflow-y: auto; overscroll-behavior: contain; }
#moment-backfill-fields { margin-bottom: 11px; }
.moment-backfill-inputs { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px; }
.moment-backfill-inputs label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: .85rem; }
.moment-backfill-inputs input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #faf7ef;
  color: var(--ink);
  font: 1rem/1.2 -apple-system, BlinkMacSystemFont, sans-serif;
}
#moment-time-status { margin-top: 5px; color: var(--ochre); font-size: .83rem; }
#moment-text {
  display: block;
  width: 100%;
  min-height: 104px;
  padding: 11px 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #faf7ef;
  color: inherit;
  font: inherit;
  line-height: 1.5;
}
#moment-text::placeholder { color: var(--muted); }
.moment-photo-actions { margin-top: 10px; }
.moment-photo-pickers { display: flex; gap: 4px; }
.moment-add-photo, #moment-editor #make-stickers {
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--cobalt);
  font-size: .9rem;
  font-weight: 650;
}
.moment-add-photo.moment-camera { border-color: transparent; background: transparent; }
.moment-add-photo:has(input:disabled) { opacity: .55; cursor: default; }
.moment-add-photo input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: inherit; }
#moment-photo-count { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
#moment-photos {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}
#moment-photos li { position: relative; min-width: 0; }
#moment-photos .moment-photo-choose {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 2px;
  border: 2px solid transparent;
  border-radius: 7px;
  background: transparent;
}
#moment-photos .moment-photo-choose[aria-pressed="true"] { border-color: var(--cobalt); }
#moment-photos img { display: block; width: 100%; height: 100%; aspect-ratio: 1; border-radius: 3px; object-fit: cover; }
#moment-photos .moment-photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #282116d9;
  color: white;
  line-height: 1;
}
.moment-sticker-section { margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--line); }
#moment-sticker-title { margin: 0; font-size: 1rem; }
#moment-photo-status, #moment-sticker-status { margin-top: 5px; color: var(--muted); font-size: .83rem; line-height: 1.4; }
#moment-photo-status { color: var(--ochre); }
#moment-stickers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 9px; }
#moment-stickers button {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
}
#moment-stickers button[aria-pressed="true"] { border-color: var(--cobalt); background: #e5eaf3; box-shadow: inset 0 0 0 1px var(--cobalt); }
#moment-stickers img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.moment-footer { padding: 10px 19px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
#moment-editor #save-moment {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--cobalt);
  border-radius: 5px;
  background: var(--cobalt);
  color: white;
  font-weight: 650;
}
#moment-editor button:disabled { opacity: .55; cursor: default; }
#new-moment:focus-visible, #backfill-moment:focus-visible,
#moment-editor :is(button, textarea, #moment-day, #moment-time):focus-visible, .moment-add-photo:focus-within {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}
