/* Book shelf, local contents and a continuous reading surface share the site chrome. */
.writing-v3{--writing-blue:#386ca8;--writing-gray:#777;display:flex;flex-direction:column;height:100svh;height:100dvh;min-height:0;overflow:hidden}
.writing-v3>.page-head{flex:none}
.writing-v3 .wb{display:grid;grid-template-columns:minmax(190px,20%) minmax(0,1fr) 100px;gap:2.7vw;flex:1;min-height:0;height:auto;margin:0;padding:0 4vw 100px;overflow:hidden;align-items:stretch}
.writing-v3 .wb-index{display:flex;flex-direction:column;position:relative;top:auto;height:100%;min-height:0;max-height:none;overflow:hidden;padding:8px 1.8vw 0 0;border-right:1px solid #e7e7e7}
.writing-v3 .book-index{flex:none}
.writing-v3 .wb-index h1{font-size:14px;font-weight:400;letter-spacing:.16em;margin:0 0 .9em}
.writing-v3 .wb-row button{padding:.55em 0 .55em .65em;font-size:12px;gap:.65em}
.writing-v3 .wb-row .wb-date{font-size:9px;color:#8a8a8a}
.writing-v3 .wb-row .wb-title{white-space:normal;line-height:1.6}
.article-index{display:flex;flex-direction:column;min-height:0;flex:1;margin-top:2.2em}
#writing-filters{font-size:11px;flex:none;margin-bottom:1em}
#writing-filters summary{cursor:pointer;width:max-content;max-width:100%;color:#777;list-style:none;padding:3px 0}
#writing-filters summary::after{content:'+';display:inline-block;margin-left:1em;color:#999}
#writing-filters[open] summary::after{content:'−'}
#writing-filters summary::-webkit-details-marker{display:none}
#article-filter-controls{padding:.8em 0 0}
.writing-filter{display:grid;grid-template-columns:2.5em minmax(0,1fr);gap:.5em;align-items:baseline;margin-bottom:.55em;color:#888}
.writing-filter select{min-width:0;width:100%;font-size:11px;padding:.15em 0;background:transparent;border:0;border-bottom:1px solid #e4e4e4;color:#444}
.clear-filters{font-size:10px;color:#777;text-decoration:underline;text-underline-offset:.3em;padding:.4em 0}
.text-directory{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding-right:8px;padding-bottom:24px}
.text-group{margin:0 0 1.8em}
.text-group h3{font-size:10px;font-weight:400;line-height:1.7;color:#999;margin:0 0 .5em}
.text-list{list-style:none;margin:0;padding:0}
.text-row+.text-row{border-top:1px solid #f0f0f0}
.text-entry{display:grid;grid-template-columns:9px minmax(0,1fr);gap:.7em;align-items:start;text-align:left;width:100%;padding:.75em 0}
.text-entry:hover{text-decoration:none}
.text-entry:hover .text-title,.text-row.on .text-title{text-decoration:underline;text-underline-offset:.3em}
.text-entry:focus-visible{outline:1px solid var(--writing-blue);outline-offset:-1px}
.text-mark{display:block;justify-self:center;width:5px;height:10px;margin-top:5px;color:#555}
.text-mark-book{background:currentColor}.text-mark-blue{color:var(--writing-blue)}
.text-mark-essay{height:6px;border:1px solid currentColor;margin-top:7px}
.text-mark-field{width:6px;border-left:1px solid currentColor;border-top:1px solid currentColor;border-bottom:1px solid currentColor}
.text-words{display:flex;flex-direction:column;gap:.2em;min-width:0}
.text-title{font-size:11px;line-height:1.8;letter-spacing:.025em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.text-context{font-size:10px;line-height:1.8;color:#777}
.writing-v3 .wb-stage{position:relative;overflow-y:auto;overflow-x:hidden;min-height:0;min-width:0;height:100%;padding:0 8px 0 0;overscroll-behavior:contain;scrollbar-width:thin;scroll-padding-top:20px}
.writing-v3 .wb-stage:focus-visible{outline:none}
.writing-v3 .wb-book-linked{--book-unit:clamp(.8px,min(.09vw,.17svh),1.65px);min-height:100%;grid-template-columns:calc(330*var(--book-unit)) minmax(0,1fr);gap:clamp(20px,2.3vw,50px);align-items:center;padding:0 0 4vh}
.writing-v3 .wb-shelf{position:relative;top:auto;margin:0;width:calc(330*var(--book-unit));height:calc(324*var(--book-unit));justify-self:start}
.writing-v3 .wb-info-host{padding:0;max-width:32em;align-self:center}
.writing-v3 .wb-info-host .wb-outgoing{top:0}
.writing-v3 .wb-info h2{font-size:clamp(18px,1.18vw,24px);line-height:1.65;letter-spacing:.065em;margin-bottom:.65em}
.writing-v3 .wb-meta{font-size:10px;line-height:1.9;color:#777}
.writing-v3 .wb-introduction{margin-top:2em;font-size:14px;line-height:2.1;letter-spacing:.025em;max-width:30em}
.writing-v3 .wb-introduction p{margin:0}
.book-more{font-size:11px;line-height:2;color:#777;margin-top:1em;max-width:35em}
.book-more summary{width:max-content;cursor:pointer;list-style:none;text-decoration:underline;text-underline-offset:.35em}
.book-more summary::-webkit-details-marker{display:none}.book-more p{margin:1.3em 0;font-size:13px;color:#4b4b4b}
.book-actions{display:flex;align-items:baseline;flex-wrap:wrap;gap:1.1em 1.5em;margin-top:1.8em}
.writing-v3 .wb-info .wb-open{margin:0;padding:0;font-size:12px;letter-spacing:.08em}
.book-text-link{padding:0;font-size:11px;text-decoration:underline;text-underline-offset:.3em}
.book-motion-toggle{padding:0;font-size:10px;color:#888}
.writing-idle{transform-origin:50% 88%}
.reading-pane{min-height:100%;padding:2vh 0 4vh;border-top:1px solid #e7e7e7;scroll-margin-top:0}
.writing-v3 .article-read{max-width:42em;margin:5vh auto 0;padding:0 clamp(12px,3vw,48px);font-size:16px;line-height:2.1;letter-spacing:.025em}
.writing-v3 .article-read header{margin-bottom:2.8em}
.writing-v3 .article-read h2{font-size:clamp(21px,1.8vw,29px);font-weight:400;line-height:1.65;letter-spacing:.045em}
.writing-v3 .article-kind{font-size:11px;line-height:2;color:#777}
.writing-v3 .article-note{font-size:11px;line-height:1.9;color:#888}
.writing-v3 .article-read>p{white-space:pre-line;margin:0 0 1.5em}
.article-figure{margin:2.7em 0}.article-figure img{display:block;width:100%;height:auto}
.article-figure figcaption{font-size:11px;color:#777;line-height:1.9;margin-top:.9em}
.text-reader-nav{display:flex;justify-content:center;gap:3em;margin:4em auto 2em;padding:1.8em 3vw;border-top:1px solid #eee;font-size:12px}
.article-source-project{margin-top:2.5em;padding-top:1.4em;border-top:1px solid #eee;font-size:13px}
.article-source-project a{text-decoration:underline;text-underline-offset:.3em}
.writing-empty{padding:2em 0;font-size:12px;line-height:1.9;color:#888}
.writing-v3::after{content:'';position:fixed;left:0;right:0;bottom:0;height:72px;background:white;pointer-events:none;z-index:3}
.writing-v3 #status:empty{display:none}
.night-cover-back{transform:translateZ(calc(var(--book-d)/-2)) rotateY(180deg)}
.book-back-art{position:absolute;inset:0;display:block;width:100%;height:100%;object-fit:fill}
.night-reader .reader-stack{background-image:var(--reader-cover-art);background-size:100% 100%;background-position:center}
.leaf.front-cover-surface img{width:100%;left:0;object-fit:fill}
@media(min-width:761px) and (max-width:1250px){
 .writing-v3 .wb{grid-template-columns:200px minmax(0,1fr) 80px;gap:2vw}
 .writing-v3 .wb-book-linked{--book-unit:clamp(.8px,.105vw,1.2px);grid-template-columns:minmax(0,1fr);gap:1.5em;align-content:center}
 .writing-v3 .wb-shelf{justify-self:center}
 .writing-v3 .wb-info-host{max-width:35em;padding:0 2vw}
 .writing-v3 .wb-introduction{font-size:13px;margin-top:1em}
}
@media(max-width:760px){
 .writing-v3 .wb{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto 32px minmax(0,1fr);gap:10px;padding:0 5vw 120px;min-height:0}
 .writing-v3 .wb-index{height:auto;max-height:42dvh;overflow-y:auto;border:0;border-bottom:1px solid #eee;padding:0 0 .5em;grid-row:1}
 .writing-v3 .wb-index h1{margin:0 0 .5em;font-size:12px}
 .writing-v3 #index-books{display:flex;flex-wrap:wrap;gap:.3em 1.8em}
 .writing-v3 .wb-row button{font-size:11px;gap:.5em;padding:.2em 0;border-left:0}
 .writing-v3 .wb-row .wb-date{display:none}.writing-v3 .wb-row.on .wb-title{text-decoration:underline;text-underline-offset:.3em}
 .writing-v3 .article-index{min-height:0}
 #writing-filters{margin:0}#writing-filters summary{font-size:10px}
 #article-filter-controls{display:grid;grid-template-columns:1fr 1fr;gap:.4em 1em}
 .writing-filter{grid-template-columns:2.5em minmax(0,1fr);font-size:10px;margin:0}.writing-filter select{font-size:16px}
 .clear-filters{grid-column:1/-1;justify-self:start}
 .text-title{font-size:12px}.text-context{font-size:10px}
 .writing-v3 .wb-stage{grid-row:3;height:100%;padding:0}
 .writing-v3 .wb-book-linked{--book-unit:min(.9px,calc(85vw / 330));display:grid;grid-template-columns:minmax(0,1fr);gap:1.7em;padding:1em 0 2em;align-content:start}
 .writing-v3 .wb-shelf{justify-self:center;margin:0}
 .writing-v3 .wb-info-host{padding:0;max-width:100%}.writing-v3 .wb-info h2{font-size:19px}
 .writing-v3 .wb-introduction{font-size:14px;margin-top:1.3em}
 .reading-pane{padding:0 0 2em}.writing-v3 .article-read{padding:0 2vw;font-size:15px;line-height:2.1;margin-top:2em}
 .text-reader-nav{gap:2em;margin-bottom:2em;font-size:11px}.writing-v3::after{height:100px}
}
@media(prefers-reduced-motion:reduce){.writing-idle{transform:none!important}}

/* Move the visible label under pressure; keep the hit area in place. */
.writing-v3 :is(.wb-title, .text-words, .timeline-date, .book-actions button, .text-reader-nav button) {
  transition: opacity 120ms ease-out, translate 150ms ease-out;
}
.writing-v3 :is(.wb-row button:active .wb-title, .text-entry:active .text-words, .timeline-point:active .timeline-date, .book-actions button:enabled:active, .text-reader-nav button:enabled:active) {
  opacity: .7;
  transition-duration: 60ms;
}
@media (prefers-reduced-motion: no-preference) {
  .writing-v3 .wb-stack-book .book3d { transition: translate 150ms ease-out; }
  .writing-v3 .wb-stack-book:active .book3d { translate: 0 2px; transition-duration: 60ms; }
  .writing-v3 :is(.wb-row button:active .wb-title, .text-entry:active .text-words, .timeline-point:active .timeline-date, .book-actions button:enabled:active, .text-reader-nav button:enabled:active) {
    translate: 0 1px;
  }
}

#article-sources {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1.1em;
  margin-bottom: .25em;
  font-size: 12px;
}
#article-sources button {
  min-height: 30px;
  padding: 0;
  color: #555;
  text-decoration: underline;
  text-decoration-color: #bbb;
  text-underline-offset: .35em;
}
#article-sources button[aria-pressed="true"], #article-sources button:hover {
  color: #202020;
  text-decoration-color: currentColor;
}

/* Continue reading: each step names the text it leads to. */
.text-reader-nav .text-step{display:flex;flex-direction:column;align-items:center;gap:.35em;max-width:16em;padding:.3em 0;text-align:center}
.text-reader-nav .text-step:disabled{opacity:.35}
.text-step-title{font-size:10px;line-height:1.7;color:#888;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.text-reader-nav .text-step:hover:not(:disabled) .text-step-label{text-decoration:underline;text-underline-offset:.3em}
@media(max-width:760px){
 .text-reader-nav .text-step{max-width:42vw}
}
/* Focus moves to the article heading for assistive technology; it is not a control. */
.writing-v3 .article-read h2[tabindex="-1"]:focus{outline:none}

.writing-v3 :is(.work-return,.work-readings a) { display:inline-block; padding:.3em 0; font-size:12px; color:#555; text-decoration:underline; text-underline-offset:.28em; }
.writing-v3 .article-read > .work-return { margin-bottom:1.1em; }
.writing-v3 .work-readings { display:flex; flex-wrap:wrap; gap:.5em 1.8em; margin:1.5em 0; }
#book-frame > .work-return { align-self:center; }

/* The reading surface fits each book independently of its size on the shelf. */
#book-frame { flex:1; min-height:0; display:flex; flex-direction:column; color:inherit; }
#book-frame .reader-head { padding-block:max(6px,env(safe-area-inset-top)) 6px; }
#book-frame #book-stage { padding:5px clamp(8px,2.3vw,32px) 10px; }
#book-reader #book-frame .reader-tools { margin-bottom:max(48px,5.5vmin); padding-block:2px; column-gap:clamp(8px,2vw,24px); }
#book-reader #book-fullscreen { min-height:44px; padding:0 .35em; text-decoration:underline; text-underline-offset:.25em; white-space:nowrap; }
#book-frame .reader-tools :is(#previous,#next) { min-width:32px; min-height:44px; }
#book-reader.book-fullscreen { height:100dvh; }
#book-reader.book-fullscreen #book-frame { background-color:var(--paper-base,#fff); background-image:var(--paper-surface-image); background-size:var(--paper-surface-size); }
#book-reader.book-fullscreen #book-stage { padding:2px max(3px,env(safe-area-inset-right)) 8px max(3px,env(safe-area-inset-left)); }
#book-reader.book-fullscreen .reader-head { padding-block:max(4px,env(safe-area-inset-top)) 4px; }
#book-reader.book-fullscreen #close-book, #book-reader.book-fullscreen > #sound-control, #book-reader.book-fullscreen .work-return { display:none; }
#book-reader.book-fullscreen #book-frame .reader-tools { margin:0; padding:0 4px max(2px,env(safe-area-inset-bottom)); }
@media(max-width:760px) {
  /* Keep the expanded mobile audio controls clear of the book toolbar. */
  #book-reader:not(.book-fullscreen) #book-frame .reader-tools { margin-bottom:calc(84px + max(16px,env(safe-area-inset-bottom))); }
  #book-reader #book-frame .reader-tools { padding-inline:6px; gap:6px; }
  #book-reader #book-stage { padding-inline:8px; }
}


/* The shelf and the reading room keep the same navigation and their own space. */
.writing-v3 .wb {
  grid-template-columns: clamp(165px,17vw,230px) minmax(0,1fr);
}
.writing-v3 .wb-index { border:0; }
.writing-views, .directory-mode {
  display:flex;
  align-items:baseline;
  flex-wrap:wrap;
  gap:.35em 1.1em;
}
.writing-views { flex:none; margin-bottom:1.4rem; }
.writing-views button, .directory-mode button {
  font:inherit;
  font-size:12px;
  line-height:1.5;
  color:#666;
  padding:.4em 0;
  text-align:left;
}
.writing-views button[aria-current], .directory-mode button[aria-pressed=true] {
  color:var(--ink,#202020);
  text-decoration:underline;
  text-underline-offset:.32em;
}
.directory-mode { margin-bottom:.6em; }
.directory-mode button, .directory-mode span { font-size:11px; }
.directory-mode span, .directory-year { color:#666; }
.directory-year { font-size:13px; margin:0 0 1.3em; }
.writing-v3 .article-index { margin:0; }
.writing-v3 .reading-pane { border:0; }
.writing-v3 .text-group h3 { color:#666; }
.writing-v3 .text-context .writing-date { font:inherit; }
.writing-v3 .wb-row .writing-date { font-size:10px; color:#666; }
.writing-date > [lang=en], html:lang(en) .writing-date > [lang=zh-CN] { display:none; }
html:lang(en) .writing-date > [lang=en] { display:inline; }
.wb[data-writing-view=books] :is(.article-index,.reading-pane),
.wb[data-writing-view=articles] :is(.book-index,.wb-book-linked) { display:none; }
@media(max-width:760px) {
  .writing-v3 .wb {
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:auto minmax(0,1fr);
    gap:.6em;
    padding-bottom:80px;
  }
  .writing-v3 .wb-stage { grid-row:2; }
  .writing-v3 .wb-index { padding:0; max-height:none; }
  .writing-views { margin:0 0 .45em; gap:.35em 1.6em; }
  .writing-v3 .wb-row .writing-date { display:none; }
  .writing-v3 .wb[data-writing-view=articles][data-directory-open=false] .article-index,
  .writing-v3 .wb[data-writing-view=articles][data-directory-open=true] .wb-stage { display:none; }
  .writing-v3 .wb[data-writing-view=articles][data-directory-open=true] .wb-index {
    grid-row:1/-1;
    height:100%;
    overflow:auto;
  }
  .writing-v3 .article-index { flex:1; min-height:0; }
  .writing-v3 .text-directory { display:block; max-height:none; padding-top:1.1em; }
  .writing-v3 .wb-book-linked {
    --book-unit:max(.66px,min(1.27px,calc(85vw / 270),calc((var(--stage-room,100svh) - 105px) / 324)));
    padding-top:.5em;
    gap:1em;
  }
  .writing-v3 .wb-shelf { width:calc(270 * var(--book-unit)); left:calc(-12 * var(--book-unit)); }
  .writing-v3 .article-read { margin-top:1.2em; }
}
