:root {
  --bg: #f5f7f3;
  --surface: #fff;
  --ink: #172b25;
  --muted: #52635a;
  --accent: #245748;
  --line: #d7e0d8;
  --soft: #e8eee7;
  --frame: 65rem;
  --gutter: clamp(1rem, 4.6vw, 2.25rem);
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; background: var(--bg); color: var(--ink); line-height: 1.6; }
h1, h2, h3, p, figure { margin: 0; }
img, video { display: block; width: 100%; }
a { color: inherit; text-underline-offset: .23em; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: default; }
section[id], .timeline li[id], #main { scroll-margin-top: 1rem; }

.site-width { width: min(100%, var(--frame)); margin-inline: auto; padding-inline: var(--gutter); }
.skip-link { position: fixed; top: .6rem; left: .6rem; z-index: 5; padding: .6rem .8rem; background: var(--surface); transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }
.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; column-gap: .3rem; min-height: 3.75rem; }
.wordmark { font-size: .94rem; font-weight: 800; letter-spacing: .03em; text-decoration: none; white-space: nowrap; padding-block: .7rem; }
.pages { display: flex; align-self: stretch; gap: clamp(.2rem, 1.5vw, 1rem); font-size: .875rem; color: var(--muted); }
.pages a { display: grid; place-items: center; min-width: 2.75rem; border-bottom: 2px solid transparent; padding-inline: .24rem; white-space: nowrap; text-decoration: none; }
.pages a[aria-current="page"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.pages a:hover, .wordmark:hover { color: var(--accent); }

.location { font-size: .875rem; color: var(--muted); line-height: 1.5; }
.home-heading { padding-block: 1.55rem 1.15rem; }
.home-heading h1 { font-size: clamp(1.75rem, 7.9vw, 3.35rem); line-height: 1.15; font-weight: 800; letter-spacing: -.045em; margin-top: .45rem; }
.search { display: flex; align-items: center; gap: .7rem; min-height: 2.9rem; padding-inline: .83rem .35rem; border: 1px solid #c8d6cc; border-radius: .4rem; background: var(--surface); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px #24574826; }
.search input { width: 100%; min-width: 0; padding-block: .62rem; border: 0; background: transparent; outline: 0; color: var(--ink); }
.search input:focus-visible { outline: 0; }
.search input::placeholder { color: #586a61; opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { display: block; position: relative; flex: none; width: .84rem; height: .84rem; margin-right: .14rem; border: 1.5px solid var(--muted); border-radius: 50%; }
.search-icon::after { content: ""; position: absolute; width: .36rem; height: 1.5px; right: -.27rem; bottom: -.14rem; background: var(--muted); transform: rotate(46deg); }
.clear-search { flex: none; width: 2.75rem; min-height: 2.75rem; border: 0; background: transparent; font-size: 1.5rem; }
.featured-video { width: min(100%, 17.5rem); margin: 0 auto 1.35rem; }
.home-index { min-width: 0; }

.filters { display: flex; flex-wrap: wrap; gap: .08rem clamp(.15rem, 2.4vw, 1.2rem); align-items: end; border-bottom: 1px solid var(--line); }
.filters button { min-height: 2.9rem; padding: .36rem clamp(.45rem, 3.2vw, .9rem); border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: .94rem; }
.filters button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 800; }
.filters button:hover { background: var(--soft); }
.search-status { margin-top: .85rem; color: var(--muted); font-size: .875rem; }
.search-status:empty { margin: 0; }
.empty-result { padding-block: 1.4rem 4rem; color: var(--muted); }
#archive-results { display: grid; gap: 1.45rem; margin-block: 1.2rem 2.6rem; }
.archive-section { min-width: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; min-height: 2.75rem; }
.section-heading h2 { font-size: 1.24rem; line-height: 1.25; font-weight: 800; }
.section-action { display: inline-flex; align-items: center; min-height: 2.75rem; border: 0; background: transparent; text-decoration: none; color: var(--accent); padding: 0; font-size: .875rem; white-space: nowrap; }
.section-action:hover, .document-sources a:hover, .item-title:hover { text-decoration: underline; }
.archive-card { display: flex; align-items: stretch; gap: .8rem; background: var(--surface); padding: .58rem; min-height: 5.4rem; border: 1px solid var(--line); border-radius: .4rem; }
.archive-link { text-decoration: none; }
.archive-link:hover, .photo-tile:hover { border-color: var(--accent); }
.item-image { position: relative; flex: 0 0 clamp(3.7rem, 19vw, 6.25rem); width: clamp(3.7rem, 19vw, 6.25rem); aspect-ratio: 1.16; max-height: 6rem; border: 0; padding: 0; background: var(--soft); overflow: hidden; border-radius: .23rem; object-fit: cover; }
.document-card .item-image img { object-fit: contain; }
.item-image img { height: 100%; object-fit: cover; }
.item-copy { flex: 1; min-width: 0; align-self: center; }
.item-copy h3, .item-title { font-size: 1rem; line-height: 1.4; font-weight: 800; }
.item-copy p, .document-sources { color: var(--muted); font-size: .875rem; margin-top: .22rem; }
.item-title { padding: 0; border: 0; background: none; text-align: left; }
.document-sources { list-style: none; padding: 0; margin-bottom: 0; }
.document-sources li + li { margin-top: .08rem; }
.document-sources a { text-decoration: none; }
.home-photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .52rem; }
.photo-tile { align-self: stretch; min-width: 0; display: flex; flex-direction: column; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: .35rem; background: var(--surface); text-align: left; }
.photo-tile-image { aspect-ratio: 4 / 3; object-fit: cover; background: var(--soft); }
.photo-tile-caption { display: flex; flex-direction: column; gap: .11rem; padding: .4rem .5rem .5rem; line-height: 1.35; }
.photo-tile-caption strong { font-size: .875rem; }
.photo-time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.video-thumb img { object-position: center 30%; }
.play-icon { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border: 1px solid #ffffffad; border-radius: 50%; background: #152521e9; color: #fff; }
.play-icon::before { content: ""; display: block; border-block: .45rem solid transparent; border-left: .72rem solid currentColor; margin-left: .15rem; }
.video-thumb .play-icon { position: absolute; inset: 0; margin: auto; width: 1.85rem; height: 1.85rem; }
.video-thumb .play-icon::before { border-block-width: .31rem; border-left-width: .5rem; }
.video-list { display: grid; gap: .52rem; }
.record-list { margin: 0; padding: 0; list-style: none; }
.record-list li { border-top: 1px solid var(--line); }
.record-list a { display: grid; gap: .14rem; padding-block: .6rem; text-decoration: none; }
.record-list a:hover strong { text-decoration: underline; }
.record-list time { font-size: .875rem; color: var(--muted); }

.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .35rem 1.5rem; padding-block: 1rem 1.6rem; color: var(--muted); font-size: .83rem; border-top: 1px solid var(--line); }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

body[data-page="history"] {
  --bg: #f8f4eb;
  --surface: #fdf9f1;
  --ink: #2d2d24;
  --muted: #625b4e;
  --accent: #893a2c;
  --line: #dcd1be;
  --soft: #eee5d5;
}
.page-heading { padding-block: 1.6rem 1.2rem; }
.page-heading h1 { font-family: var(--serif); font-size: clamp(2.4rem, 10vw, 4.6rem); font-weight: 800; letter-spacing: .035em; line-height: 1.13; margin-top: .48rem; }
.history-wrap { padding-bottom: 2.35rem; }
.history-layout { display: grid; gap: 1.45rem; }
.evidence { background: var(--soft); border: 1px solid var(--line); padding: .62rem; }
.evidence-image { display: block; width: 100%; border: 0; padding: 0; background: var(--surface); }
.evidence-detail { padding: .6rem .25rem .28rem; }
.evidence-detail h2 { font-size: 1rem; }
.source-list { display: grid; gap: .22rem; list-style: none; margin: .35rem 0 0; padding: 0; font-size: .875rem; color: var(--accent); }
.source-list a { display: inline-block; padding-block: .18rem; }
.timeline { --axis: .33rem; position: relative; list-style: none; margin: 0; padding: 0; }
.timeline::before { content: ""; position: absolute; width: 1px; left: var(--axis); top: .7rem; bottom: 1rem; background: #cbb89f; }
.timeline li { position: relative; padding-left: 1.5rem; }
.timeline li::before { content: ""; position: absolute; left: var(--axis); top: .74rem; width: .48rem; height: .48rem; transform: translate(-50%, -50%); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 .21rem var(--bg); }
.timeline-entry { padding-bottom: 1rem; }
.timeline li + li .timeline-entry { border-top: 1px solid var(--line); padding-top: .95rem; }
.timeline li + li::before { top: 1.69rem; }
.record-date { display: block; margin-bottom: .17rem; color: var(--accent); font-size: .94rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timeline h2 { margin-bottom: .25rem; font-size: 1.15rem; line-height: 1.38; }
.timeline p { color: var(--ink); font-size: 1rem; line-height: 1.73; }
.record-source { display: flex; flex-wrap: wrap; gap: .15rem 1rem; margin-top: .42rem; color: var(--accent); font-size: .875rem; }
.record-source a { padding-block: .18rem; }
.timeline li:target .timeline-entry { background: var(--soft); box-shadow: .4rem 0 var(--soft), -.45rem 0 var(--soft); }

body[data-page="media"] {
  --bg: #1e261f;
  --surface: #263128;
  --ink: #f4f1e7;
  --muted: #c4cebe;
  --accent: #e8bf77;
  --line: #49594c;
  --soft: #354438;
}
.media-wrap { max-width: 49rem; margin-inline: auto; padding-bottom: 2.3rem; }
.video-section { width: min(100%, 19rem); margin-inline: auto; }
.video-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin-bottom: .7rem; }
.video-choices a { display: flex; flex-direction: column; justify-content: center; min-height: 2.75rem; padding: .36rem clamp(.36rem, 2vw, .65rem); border: 1px solid var(--line); border-radius: .3rem; color: var(--muted); font-size: .875rem; text-decoration: none; }
.video-choices a:hover, .video-choices a[aria-current="true"] { color: var(--accent); border-color: var(--accent); background: var(--surface); }
.video-choices span { word-break: keep-all; }
.video-choices a[aria-current="true"] span { font-weight: 700; }
.video-choices small { font-size: .8rem; font-variant-numeric: tabular-nums; }
.video-player { position: relative; align-self: start; background: #121913; aspect-ratio: 9 / 16; overflow: hidden; border-radius: .28rem; }
.video-player video { height: 100%; object-fit: contain; }
.main-play { width: 3.25rem; height: 3.25rem; position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); }
.video-error { padding-top: .6rem; font-size: .875rem; color: var(--muted); }
.video-error a { color: var(--accent); }
.field-section { margin-top: 1.4rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.field-section .section-heading { align-items: baseline; flex-wrap: wrap; margin-bottom: .5rem; }
.field-section .section-heading h2 { font-family: var(--serif); font-size: 1.6rem; }
.media-photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.media-photo-grid .lead-photo { grid-column: 1 / -1; }
.media-photo-grid img { aspect-ratio: 3 / 4; }
.media-photo-grid .lead-photo img { aspect-ratio: 4 / 3; }
.media-photo-grid .lead-photo .photo-tile-caption { flex-direction: row; justify-content: space-between; gap: .4rem; }
.media-history { display: flex; align-items: center; gap: .75rem; border-top: 1px solid var(--line); margin-top: 1.2rem; padding-top: .85rem; }
.media-history img { width: 4.7rem; height: 3.1rem; object-fit: cover; border-radius: .2rem; }
.media-history a { color: var(--accent); padding-block: .6rem; }

body[data-page="family"] {
  --bg: #f4f2e9;
  --surface: #fffdf6;
  --ink: #27342a;
  --muted: #596357;
  --accent: #365d48;
  --line: #d9ddce;
  --soft: #e9ecdf;
}
.family-wrap { max-width: 53rem; margin-inline: auto; padding-bottom: 2.25rem; }
.family-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .58rem; }
.family-grid .family-lead { grid-column: 1 / -1; }
.family-grid .photo-tile-image { object-fit: contain; }
.family-grid .family-lead img { aspect-ratio: 3 / 4; }

dialog {
  width: min(calc(100% - 1rem), 46rem);
  max-width: none;
  max-height: calc(100vh - 1rem);
  max-height: calc(100dvh - 1rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: .55rem;
  color: var(--ink);
  background: var(--surface);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #111e1bd4; }
body:has(dialog[open]) { overflow: hidden; }
.viewer-header, .viewer-pager { display: flex; justify-content: space-between; align-items: center; gap: .55rem; padding: .42rem .74rem; }
.viewer-header { border-bottom: 1px solid var(--line); }
body[data-page="family"] .viewer-header { justify-content: flex-end; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.viewer-header h2 { font-size: 1.12rem; line-height: 1.3; }
.viewer-header button, .viewer-pager button { min-height: 2.75rem; padding-inline: .6rem; border: 0; border-radius: .3rem; background: var(--soft); }
.viewer-scroll { overflow: auto; overscroll-behavior: contain; }
.viewer-scroll img { height: auto; max-height: min(65dvh, 48rem); object-fit: contain; background: var(--soft); }
.viewer-scroll figcaption { padding: .68rem .8rem .25rem; }
#viewer-sources { padding: .15rem .8rem .78rem; color: var(--accent); font-size: .875rem; }
.viewer-pager { border-top: 1px solid var(--line); }
.viewer-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; }

@media (min-width: 44rem) {
  .home-heading { padding-block: 2.15rem 1.45rem; }
  .home-heading h1 { font-size: clamp(2rem, 4.7vw, 3.3rem); }
  .home-layout { display: grid; grid-template-columns: clamp(13rem, 29vw, 19rem) minmax(0, 1fr); gap: clamp(1.35rem, 4vw, 3.2rem); align-items: start; }
  .featured-video { width: 100%; margin: 0; }
  .item-image { max-width: 5.6rem; }
  .page-heading { padding-block: 2.35rem 1.55rem; }
  .history-layout { grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); align-items: start; gap: 1.8rem; }
  .evidence { position: sticky; top: 1rem; }
  .media-photo-grid { gap: .67rem; }
  .family-grid { gap: .8rem; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .family-grid .family-lead { grid-column: 1; grid-row: 1 / span 2; }
}

@media (min-width: 58rem) {
  #archive-results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6rem; align-items: start; }
  #archive-results.single-group { grid-template-columns: minmax(0, 1fr); }
  .single-group .home-photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 22rem) {
  .location { font-size: .82rem; }
  .pages { gap: .12rem; }
  .pages a { padding-inline: .18rem; }
  .filters button { padding-inline: .48rem; }
  .media-photo-grid .photo-tile-caption strong { font-size: .79rem; }
}
