/* Keep the folio, instrument and reading grid on the same measure. */
:root {
  --ui: "Inter", "SF Pro Display", "PingFang SC", "Helvetica Neue", -apple-system, sans-serif;
  --body-ink: #bdb9b1;
  --heading-ink: #f4f1ea;
}
.wrap { width: min(1180px, 90%); }
.bar .brand, .foot .brand { font: 400 19px/1 var(--ui) !important; letter-spacing: -.03em; }
.bar nav a, .lang button, .foot a { font-family: var(--ui); }
#progress {
  position: absolute; inset: 0 0 auto; height: 1px;
  background: var(--gold); transform: scaleX(0); transform-origin: left;
}
.cover-edition { margin: 36px 0 10px; color: #a8a09c; font: 11.5px/1.6 var(--ui); letter-spacing: .06em; text-transform: uppercase; }
.cover-doi {
  color: var(--gold); text-transform: none; letter-spacing: .015em; white-space: nowrap;
  text-decoration: underline; text-decoration-color: #766249; text-underline-offset: 4px;
}
.cover-doi:is(:hover, :focus-visible) { text-decoration-color: currentColor; }
.cover-info { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-top: 16px; }
.monograph h1 { margin: 0; }
.subtitle { margin: 10px 0 0; font: 400 1rem/1.5 var(--ui); }
.byline { margin: 0; color: #c0b8b5; font: 12px/1.6 var(--ui); }
.cover-links { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.cover-links a { padding: 4px 0; border-bottom: 1px solid #655640; font: 12px/1.5 var(--ui); color: var(--gold); }
.cover-links a + a { border-color: var(--rule); color: var(--sub); }

.bundle {
  display: grid; grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  align-items: center; gap: 18px; min-height: 82px; padding: 12px 0;
  border-block: 1px solid #554c42; margin: 26px 0 0; scroll-margin-top: 82px;
}
.bundle-heading { display: flex; gap: 12px; align-items: center; color: var(--gold); }
.bundle-heading h2 { margin: 0; font: 400 12px/1.5 var(--mono); letter-spacing: .055em; }
.bundle-heading p { margin: 2px 0 0; font: 11.5px/1.4 var(--ui); color: #a39b97; }
.files { display: grid; grid-template-columns: repeat(4, minmax(8.1em, 1fr)); gap: 7px; font: 12px var(--mono); }
.file-card {
  display: grid; place-items: center; min-height: 34px; padding: 3px 10px; white-space: nowrap;
  border: 1px solid #4c4643; border-radius: 30px; color: #d8d4cc;
}
.file-card:hover, .file-card:focus-visible, .file-card.downloading { color: #f3d8ad; border-color: #ad916d; background: #221f1d; }
.done-label, .downloading .default-label { display: none; }
.downloading .done-label { display: inline; }
#bib-copy { justify-self: end; border-left: 1px solid #514b48; padding: 7px 0 7px 18px; font: 12px var(--mono); color: var(--gold); }

.reading { display: grid; grid-template-columns: 230px minmax(0, 1fr); align-items: start; gap: 56px; margin-top: 54px; }
.reading aside { position: sticky; top: 90px; max-height: calc(100svh - 108px); overflow: auto; scrollbar-width: thin; }
.contents summary { cursor: pointer; list-style: none; }
.contents nav { display: grid; }
.contents a { padding: 6px 12px; border-left: 1px solid var(--rule); font: 12px/1.5 var(--ui); color: var(--sub); }
.contents a[aria-current] { border-color: var(--gold); color: var(--gold); background: linear-gradient(90deg, #d6b88d10, transparent); }
#reader { min-width: 0; font: 400 16px/1.72 var(--ui); color: var(--body-ink); overflow-wrap: anywhere; }
html[lang=zh] #reader { line-height: 1.82; }
#reader :is(section, [id]) { scroll-margin-top: var(--reading-line, 88px); }
#reader :is(h2, h3, h4) { line-height: 1.35; text-wrap: pretty; }
#reader h2 { display: flex; align-items: baseline; gap: 16px; margin: 64px 0 20px; padding-top: 18px; border-top: 1px solid var(--rule); color: var(--heading-ink); font-size: 25px; font-weight: 400; }
.section-number { flex: none; padding: 4px 7px; border: 1px solid #64533e; color: var(--gold); font: 12px/1 var(--mono); }
#reader h3 { margin: 32px 0 12px; font-size: 18px; color: #ebe6dc; font-weight: 500; }
#reader h4 { margin: 24px 0 8px; font-size: 16px; font-weight: 600; color: var(--heading-ink); }
#reader p { max-width: 770px; margin: .8em 0; }
#reader :is(strong,b) { font-weight: 600; color: var(--heading-ink); }
#abstract { position: relative; padding: clamp(18px, 2.3vw, 34px); border: 1px solid #38363f; background: linear-gradient(115deg,#201f26,#16161d 65%,#15151b); }
#abstract::before { content: ""; position: absolute; inset: -1px auto -1px -1px; width: 2px; background: linear-gradient(#d9be91,#afa2d5); }
#reader #abstract h2 { margin: 0 0 20px; padding: 0; border: none; color: var(--gold); font: 12px/1.4 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
#abstract p:last-child { margin-bottom: 0; }
#reader :is(code,pre) { font: .85em/1.65 var(--mono); color: #d0c9dc; }
#reader pre { white-space: pre-wrap; background: var(--panel); border-left: 1px solid var(--gold); padding: 18px; }
#reader pre code { font: inherit; }
#reader a { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
#reader :is(ol,ul) { max-width: 770px; padding-inline-start: 2em; }
#reader li { padding-inline-start: .35em; }
#reader li + li { margin-top: 12px; }
#reader li::marker { color: var(--gold); font: 12px var(--mono); }
math { font: 1.02em "STIX Two Math", "Cambria Math", math; }
math[display=inline], .katex { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: -.18em; scrollbar-width: thin; }
html[lang=zh] #reader .katex:not(.math-scroll > .katex) { font-size: .96em; vertical-align: -.04em; }
#reader .equation { display: grid; grid-template-columns: 2em minmax(0,1fr) 2em; align-items: center; max-width: none; margin: 24px 0; padding: 22px 24px; background: rgba(255,255,255,.025); border-block: 1px solid #484249; }
.equation > :first-child { grid-column: 2; }
.equation .math-scroll { min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.math-scroll > :is(.katex,math) { display: block; width: max-content; max-width: none; margin-inline: auto; overflow: visible; }
.eqno { justify-self: end; font: 12px var(--mono); color: var(--gold); }
.statement { border-left: 2.5px solid var(--gold); background: linear-gradient(110deg,#242128,#19191f 68%,#15151b); padding: clamp(16px,2vw,28px); margin: 22px 0; }
#reader .statement h4 { margin: 0 0 12px; font: 500 18px/1.45 var(--ui); color: var(--heading-ink); }
.statement-kind { display: block; margin-bottom: 8px; color: var(--gold); text-transform: uppercase; font: 12px/1.4 var(--mono); letter-spacing: .1em; }
.statement > :last-child { margin-bottom: 0 !important; }
#reader figure { margin: 28px 0; padding: clamp(8px,1.4vw,18px); border: 1px solid #31313d; background: #12131c; }
.enlarge { display: block; width: 100%; padding: 0; cursor: zoom-in; }
#reader img { display: block; width: 100%; height: auto; background: #12131c; }
figcaption, caption { font: 13px/1.55 var(--ui); color: var(--sub); text-align: left; }
#reader figcaption { margin-top: 12px; }
#reader .tablewrap { overflow: auto; scrollbar-width: thin; margin: 22px 0; }
table { width: 100%; border-collapse: collapse; border-block: 1px solid #777066; font: 14px/1.55 var(--ui); font-variant-numeric: tabular-nums lining-nums; }
th, td { padding: 8px; vertical-align: top; text-align: left; border-bottom: 1px solid var(--rule); }
thead { background: #1c1c23; color: var(--heading-ink); }
thead th { border-bottom: 1px solid #a48a66; font-weight: 500; }
caption { padding-bottom: 12px; }
.table-plate { color: var(--gold); display: block; padding: 4px 0; font: 12px/1.5 var(--ui); cursor: zoom-in; }
#reader table p { margin: 0; }
#reader details { padding: 18px; border: 1px solid var(--rule); }
#reader details summary { cursor: pointer; color: var(--gold); }
#reader summary h2 { display: inline; border: 0; }
#lightbox { border: 0; background: #0c0d12f7; color: var(--ink); width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; padding: 60px 5vw 20px; }
#lightbox::backdrop { background: var(--bg); }
#lightbox[open] { display: grid; place-items: center; }
#lightbox > div { width: 100%; text-align: center; }
#lightbox img { max-width: 100%; max-height: 68dvh; background: #12131c; object-fit: contain; border: 1px solid #31313d; padding: 6px; }
#lightbox p { font: 15px/1.5 var(--ui); margin: 12px auto; max-width: 85ch; }
.exit { position: absolute; top: 12px; right: 4%; border: 1px solid var(--rule); padding: 7px 14px; font: 13px var(--mono); }
@media(prefers-reduced-motion: no-preference) {
  #reader .entered { animation: reader-enter .45s ease-out; }
  @keyframes reader-enter { from { opacity: .72; transform: translateY(3px); } to { opacity: 1; transform: none; } }
}
@media(max-width: 850px) {
  .bundle { grid-template-columns: 1fr auto; gap: 10px; padding: 12px 0; }
  .files { grid-column: 1/-1; grid-row: 2; }
  #bib-copy { grid-column: 2; grid-row: 1; }
}
@media(max-width: 800px) {
  #reader .equation { grid-template-columns: 1.45em minmax(0,1fr) 1.45em; padding: 18px 10px; }
  #reader h2 { margin-top: 48px; }
  .reading { grid-template-columns: minmax(0, 1fr); gap: 24px; margin-top: 28px; }
  .reading aside { position: static; max-height: none; }
  .contents { border-block: 1px solid var(--rule); padding: 10px 0; }
  .contents summary { margin: 0; list-style: revert; }
  .contents nav { padding-top: 10px; }
  #reader table { min-width: 510px; }
}
@media(max-width: 590px) {
  .files { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; }
}

/* Research title leaf. */
.monograph { padding-bottom: 28px; }
.monograph h1 { font: 400 clamp(2.4rem,4.6vw,4.3rem)/1.02 Baskerville,"Times New Roman",serif; letter-spacing: -.046em; text-wrap: balance; background: linear-gradient(107deg,#eff2f5 12%,#efe8dc 55%,#cab89e); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.subtitle { font-size: clamp(15px,1.15vw,18px); color: #d3ccc4; letter-spacing: .016em; max-width: 56ch; text-wrap: balance; }
.subtitle i { display: inline-block; font-style: normal; }
.opening { margin: 15px 0 0; padding-left: 13px; border-left: 1px solid #947950; color: #d8c6a9; font: 400 clamp(15px,1.2vw,18px)/1.5 var(--serif); max-width: 1180px; text-wrap: pretty; }
.opening > span > span { display: block; }
.opening.folded { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.quote-toggle { margin-left: 14px; padding: 4px 0; font: 12px/1.5 var(--ui); color: var(--gold); }
@media(min-width:600px) and (max-width:1150px) {
  .opening > span > span { display: inline; }
}
@media(max-width:800px) {
  .opening { line-height: 1.6; }
  .opening > span > span { text-wrap: balance; }
}
.bundle { grid-template-columns: auto minmax(0,1fr) auto; }
.files { grid-template-columns: repeat(4,minmax(0,1fr)); }
.file-card { display: flex; align-items: center; justify-content: start; gap: 9px; padding: 6px; border-radius: 4px; white-space: normal; font: 13px/1.3 var(--ui); background:#15151b; }
.file-card img { width:36px; height:48px; object-fit:contain; background:#24232a; border:1px solid #5e5550; border-radius:1px; }
.file-card small { display:block; margin-top:4px; color:#bcb2a7; font:10px/1.2 var(--mono); }
@media(max-width:950px) {
  .bundle { grid-template-columns: 1fr auto; }
  .files { grid-column:1/-1; grid-row:2; }
  #bib-copy { grid-column:2; grid-row:1; }
}
@media(max-width:590px) {
  .files { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .monograph h1 { font-size:clamp(30px,9vw,48px); }
  .subtitle { max-width:34ch; }
  html[lang=zh] .subtitle { max-width:16em; }
}

/* Mobile Safari / touch compatibility */
#reader .tablewrap, .equation .math-scroll { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
#lightbox { padding: max(56px, env(safe-area-inset-top)) 4vw max(20px, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.file-card, #bib-copy, .cover-links a, .contents a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
@media(max-width: 590px) {
  .wrap { width: min(1180px, 92%); }
  .bar nav { gap: 10px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .bar nav::-webkit-scrollbar { display: none; }
  .file-card { min-height: 58px; padding: 7px 8px; gap: 7px; font-size: 12px; }
  .file-card img { width: 32px; height: 42px; flex: none; }
  .monograph { padding-bottom: 22px; }
  .cover-edition { margin-top: 24px; }
  .cover-info { flex-direction: column; align-items: flex-start; gap: 8px; }
  .opening { font-size: 15px; line-height: 1.62; padding-left: 11px; }
}
