:root {
  --wall: #ece6db;
  --wall-2: #e2dbcd;
  --paper: #fbf9f4;
  --ink: #1f1c18;
  --ink-2: #5d564c;
  --ink-3: #8a8274;
  --stamp: #a3281e;
  --line: #cfc6b5;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --top: 48px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--wall); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body.home { height: 100%; overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

/* ── header ─────────────────────────────────────────────── */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5; height: calc(var(--top) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--wall) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.top .seal { width: 22px; height: 22px; border-radius: 3px; background: var(--stamp); color: #fff; font: 600 13px/22px var(--serif); text-align: center; flex: none; }
.top .name { font: 700 17px/1 var(--serif); letter-spacing: .08em; white-space: nowrap; }
.top .sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top .count { margin-left: auto; font: 500 12px/1 var(--mono); color: var(--ink-2); flex: none; display: flex; align-items: center; gap: 8px; text-decoration: none; }
.top .count .hn { font-family: var(--sans); color: var(--ink-3); }
.top .count .menu { font-family: var(--sans); font-size: 12px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink-2); }

/* ── exhibit screen (home stream and item pages) ────────── */
#hall { position: fixed; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; }

.ex {
  height: 100svh; scroll-snap-align: start; scroll-snap-stop: always;
  padding: calc(var(--top) + env(safe-area-inset-top) + 10px) 16px 14px;
  display: grid; gap: 10px;
  grid-template-rows: minmax(0, 30fr) minmax(0, 40fr) auto;
  grid-template-areas: "sheet" "stage" "label";
  position: relative;
}

.sheet {
  grid-area: sheet; position: relative; min-height: 0;
  background: var(--paper); border: 1px solid #ddd5c5;
  box-shadow: 0 1px 0 #fff inset, 0 6px 18px -10px rgba(60, 45, 20, .35);
  display: flex; align-items: center; justify-content: center;
  padding: 10px 10px 24px; cursor: zoom-in;
}
.sheet img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; mix-blend-mode: multiply; }
.sheet figcaption {
  position: absolute; left: 10px; right: 10px; bottom: 6px;
  display: flex; justify-content: space-between;
  font: 10.5px/1.2 var(--mono); color: var(--ink-3); letter-spacing: .02em;
}
.sheet figcaption b { color: var(--stamp); font-weight: 600; }

.stage {
  grid-area: stage; position: relative; min-height: 0;
  background: radial-gradient(120% 90% at 50% 30%, #f4efe6 0%, var(--wall-2) 70%, #d8cfbe 100%);
  touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none;
}
.stage:active { cursor: grabbing; }
.stage .tag { position: absolute; left: 10px; top: 8px; z-index: 3; font: 10.5px/1.2 var(--mono); color: var(--ink-3); }
.stage .tag b { color: var(--ink-2); font-weight: 600; }
.stage .hint { position: absolute; right: 10px; top: 8px; z-index: 3; font-size: 11px; color: var(--ink-3); transition: opacity .6s; }
.stage .hint::before { content: "⟲ "; }
.stage.touched .hint { opacity: 0; }
.stage .ph {
  position: absolute; left: 50%; top: 54%; width: 62%; height: 72%; transform: translate(-50%, -50%);
  object-fit: contain; transition: opacity .5s; pointer-events: none;
}
.stage.ready .ph { opacity: 0; }

.label { grid-area: label; }
.label .no { display: flex; align-items: baseline; gap: 10px; font: 600 13px/1.3 var(--mono); color: var(--stamp); letter-spacing: .02em; }
.label .no span { color: var(--ink-3); font-weight: 400; }
.label .ttl { font: 700 23px/1.25 var(--serif); margin-top: 3px; letter-spacing: .02em; }
.label .ttl a { text-decoration: none; }
.label .orig { font: italic 12px/1.35 Georgia, "Times New Roman", serif; color: var(--ink-3); margin-top: 2px; }
.label .plain { font-size: 14.5px; line-height: 1.6; margin-top: 8px; color: var(--ink); }
.label .meta { font-size: 11.5px; line-height: 1.5; color: var(--ink-3); margin-top: 7px; }
.label .meta a { color: var(--ink-2); text-underline-offset: 2px; white-space: nowrap; }

/* ── catalog (home) ─────────────────────────────────────── */
.catalog {
  scroll-snap-align: start; min-height: 100svh;
  padding: calc(var(--top) + env(safe-area-inset-top) + 28px) 16px 40px;
  max-width: 1180px; margin: 0 auto;
}
.catalog h2, .about h2, .dossier h2 { font: 700 20px/1.3 var(--serif); letter-spacing: .06em; }
.catalog .lead { margin-top: 8px; font-size: 13.5px; line-height: 1.75; color: var(--ink-2); max-width: 46em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 6px; }
.chips button { padding: 5px 12px; border: 1px solid var(--line); border-radius: 14px; font-size: 13px; color: var(--ink-2); background: var(--paper); }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.hallsec { margin-top: 18px; }
.hallsec h3 { font: 600 15px/1.4 var(--serif); letter-spacing: .06em; color: var(--ink); }
.hallsec h3 small { font: 400 12px var(--sans); color: var(--ink-3); margin-left: 8px; letter-spacing: 0; }
.grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.card a { display: block; text-decoration: none; background: var(--paper); border: 1px solid #ddd5c5; padding: 8px 8px 10px; height: 100%; }
.card a:hover { border-color: var(--ink-3); }
.card img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; background: radial-gradient(circle at 50% 40%, #f4efe6, var(--wall-2)); }
.card .cn { display: block; margin-top: 7px; font: 600 14px/1.35 var(--serif); }
.card .cno { display: block; margin-top: 2px; font: 11px/1.3 var(--mono); color: var(--ink-3); }

.about { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(40px + env(safe-area-inset-bottom)); color: var(--ink-2); font-size: 13.5px; line-height: 1.8; scroll-snap-align: end; }
.about p { margin-top: 8px; }
.foot { margin-top: 18px; font-size: 12px; color: var(--ink-3); }

/* ── item page dossier ──────────────────────────────────── */
.dossier { max-width: 820px; margin: 0 auto; padding: 28px 16px calc(48px + env(safe-area-inset-bottom)); }
.dossier section { margin-top: 30px; }
.dossier section:first-child { margin-top: 0; }
.dossier p { margin-top: 10px; font-size: 15.5px; line-height: 1.85; }
.dossier .note { font-size: 13.5px; color: var(--ink-2); }
.dossier dl { display: grid; grid-template-columns: 6.5em 1fr; gap: 8px 14px; margin-top: 12px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.55; }
.dossier dt { color: var(--ink-3); }
.dossier dd { word-break: break-word; }
.dossier dd i { font-family: Georgia, "Times New Roman", serif; }
.dossier .src { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }
.ask { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.ask span { font-size: 12px; letter-spacing: .1em; color: var(--ink-3); margin-right: 2px; }
.ask a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; text-decoration: none; background: var(--paper); }
.ask a:hover { border-color: var(--ink-2); }
.steps { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; font-size: 14px; }
.steps a { text-decoration: none; color: var(--ink-2); }
.steps a:hover { text-decoration: underline; }
.back { display: inline-block; margin-top: 14px; padding: 9px 16px; background: var(--ink); color: var(--paper); text-decoration: none; font-size: 14px; letter-spacing: .04em; }
.dossier .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.dossier .card[aria-current] a { border-color: var(--stamp); }

/* ── lightbox ───────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 10; background: rgba(251, 249, 244, .97); display: none; align-items: center; justify-content: center; padding: 56px 12px 24px; cursor: zoom-out; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.lightbox .x { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px; font-size: 13px; color: var(--ink-2); }

@media (min-width: 900px) {
  :root { --top: 56px; }
  .top { padding-left: 32px; padding-right: 32px; }
  .top .name { font-size: 20px; }
  .top .sub { font-size: 12.5px; }
  .ex {
    padding: calc(var(--top) + 24px) 32px 28px;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "sheet stage" "label stage";
    gap: 22px 28px; max-width: 1500px; margin: 0 auto;
  }
  .sheet { padding: 18px 18px 32px; }
  .sheet figcaption { font-size: 11.5px; left: 16px; right: 16px; bottom: 10px; }
  .label .ttl { font-size: 30px; }
  .label .orig { font-size: 13.5px; }
  .label .plain { font-size: 16px; max-width: 34em; }
  .label .meta { font-size: 12.5px; }
  .stage .tag, .stage .hint { font-size: 12px; }
  .catalog { padding-left: 32px; padding-right: 32px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
}
@media (max-width: 899px) {
  .top .count .hn { display: none; }
}
@media (max-height: 700px) and (max-width: 899px) {
  .label .plain { font-size: 13.5px; line-height: 1.5; }
  .label .ttl { font-size: 20px; }
}
