:root {
  --paper: #f5f5f3;
  --ink: #30322f;
  --quiet: #787b74;
  --rule: #d8dad3;
  --serif: "Iowan Old Style", "Palatino Linotype", "Noto Serif CJK SC", "Songti SC", "SimSun", serif;
  --sans: "Avenir Next", "Microsoft YaHei", sans-serif;
}
html, body { background: var(--paper); color: var(--ink); font-family: var(--sans); }
#cabinCanvas { position: fixed; inset: 0; width: 100%; height: 100%; filter: grayscale(1); }
.cabin-return { position: fixed; top: 35px; left: 40px; z-index: 6; color: var(--ink); font: 12px/1.4 var(--sans); text-decoration: none; padding: 8px 0; }
.cabin-return:hover { text-decoration: underline; text-underline-offset: 4px; }
.shelf-catalog { display: none; position: fixed; z-index: 7; top: 88px; left: 40px; width: 264px; padding: 18px; box-sizing: border-box; background: #f5f5f3ed; border: 1px solid var(--rule); font: 12px/1.5 var(--sans); backdrop-filter: blur(10px); }
body[data-cabin-focus=shelf] .shelf-catalog { display: block; }
.shelf-catalog [hidden], .book-dialog [hidden] { display: none !important; }
.library-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 15px; }
.library-heading > span { font: 17px var(--serif); }
.library-heading output { color: var(--quiet); font-size: 10px; font-variant-numeric: tabular-nums; }
#librarySearch { box-sizing: border-box; width: 100%; min-width: 0; border: 0; border-bottom: 1px solid #b7bab1; border-radius: 0; padding: 7px 0 9px; background: transparent; color: var(--ink); font: 16px var(--sans); }
.library-filters { display: flex; gap: 8px; margin: 11px 0; }
.library-filters select { min-width: 0; flex: 1; border: 0; color: var(--quiet); background: transparent; padding: 5px 0; font: 11px var(--sans); }
.library-notice { color: var(--quiet); font-size: 11px; margin: 12px 0; }
#libraryDirectory summary { cursor: pointer; padding: 7px 0; color: var(--quiet); }
#libraryList { list-style: none; margin: 4px -5px 10px; padding: 0 5px; max-height: min(310px,35dvh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
#libraryList button { width: 100%; display: flex; flex-direction: column; text-align: left; padding: 11px 0; border: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--ink); font: 13px/1.55 var(--serif); cursor: pointer; overflow-wrap: anywhere; }
#libraryList button:hover { padding-left: 5px; }
#libraryList small { margin-top: 4px; color: var(--quiet); font: 10px var(--sans); }
.library-batches { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--rule); }
.library-batches button { border: 0; background: transparent; color: var(--ink); font: 11px var(--sans); padding: 6px 0; cursor: pointer; }
.library-batches button:disabled { color: #b7bab1; cursor: default; }
.library-batches output { color: var(--quiet); font-size: 10px; }
#menuDot { top: 36px; right: 40px; width: 62px; height: 33px; border: 1px solid var(--rule); border-radius: 0; background: rgba(245,245,243,.92); box-shadow: none; font: 11px var(--sans); color: var(--ink); letter-spacing: 2px; }
#menuDot:hover { color: var(--ink); transform: none; border-color: var(--ink); box-shadow: none; }
#menuDot:active { transform: scale(.97); }
#menuPanel { top: 82px; right: 40px; width: 250px; padding: 22px; max-height: calc(100dvh - 172px); border: 1px solid var(--rule); border-radius: 2px; background: rgba(248,248,245,.98); font-family: var(--sans); box-shadow: 0 18px 50px #30322f13; transform: translateY(-8px); }
#menuPanel .title { font: 18px var(--serif); margin-bottom: 19px; }
#menuPanel .sub { color: var(--quiet); font-size: 10px; font-weight: 400; letter-spacing: 3px; }
#menuPanel .sep { background: var(--rule); margin: 15px 0; }
#menuPanel .toggle { border-color: #b3b7ae; background: #e1e3db; }
#menuPanel .toggle.on { border-color: var(--ink); background: var(--ink); }
#menuPanel .knob { background: #fafaf8; box-shadow: none; }
#menuPanel .wxChip { border: 1px solid var(--rule); border-radius: 0; color: var(--quiet); background: transparent; font-size: 11px; }
#menuPanel .wxChip.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }
#menuPanel .viewBtn { font: 11px/2 var(--sans); border-radius: 0; border-color: var(--rule); background: transparent; color: var(--ink); }
#menuPanel .viewBtn:hover { border-color: var(--ink); }
#menuPanel input[type=range] { accent-color: var(--ink); }
#menuPanel .slot { border-radius: 2px; }
#menuPanel .slot.on { border-color: var(--ink); background: #e8e9e3; box-shadow: none; }
#menuPanel .aboutBox { background: transparent; border-color: var(--rule); border-radius: 0; }
#menuPanel .aboutLink { color: var(--quiet); }
.controls-note { font-size: 10px; line-height: 1.9; color: var(--quiet); }
#clock { top: 44px; right: 126px; left: auto; border: 0; background: transparent; box-shadow: none; padding: 0; color: var(--quiet); font: 11px/1.4 var(--sans); letter-spacing: 1px; }
.cabin-dock { position: fixed; z-index: 6; bottom: max(30px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 3px; padding: 5px; border: 1px solid var(--rule); background: rgba(245,245,243,.94); box-shadow: 0 4px 20px #30322f05; }
.cabin-dock button { border: 0; border-radius: 0; padding: 10px 16px; margin: 0; width: auto; background: transparent; color: var(--quiet); cursor: pointer; white-space: nowrap; font: 11px/1.3 var(--sans); letter-spacing: 1px; }
.cabin-dock button.on { color: var(--paper); background: var(--ink); }
.cabin-dock button:hover { color: var(--ink); background: #e3e5de; transform: none; }
.cabin-dock button.on:hover { background: #454841; color: var(--paper); }
.cabin-dock .dock-divider { width: 1px; background: var(--rule); margin: 8px 5px; }
.cabin-caption { position: fixed; z-index: 5; bottom: 47px; left: 40px; color: var(--quiet); font-size: 10px; letter-spacing: 1px; pointer-events: none; }
#shelfHint { position: fixed; z-index: 6; bottom: 98px; left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none; text-align: center; color: var(--quiet); font-size: 11px; letter-spacing: 1px; transition: opacity .3s; white-space: nowrap; background: #f5f5f3c9; padding: 5px 10px; }
#shelfHint.show { opacity: 1; }
#hint { bottom: 100px; color: var(--ink); background: #f5f5f3eb; border: 1px solid var(--rule); border-radius: 0; box-shadow: none; font: 11px var(--sans); padding: 9px 14px; }
#hint b { color: var(--ink); }
body[data-cabin-focus=shelf] #hint { visibility: hidden; }
#signEditor, #noteEditor, #picEditor { background: var(--paper); color: var(--ink); border-color: var(--rule); border-radius: 2px; box-shadow: 0 16px 50px #30322f20; font-family: var(--sans); }
#signOk, #noteOk, #picOk { background: var(--ink); color: var(--paper); border-color: var(--ink); border-radius: 0; }
.touchBtn { border-color: #9ca197; background: #f5f5f3d9; color: var(--ink); box-shadow: none; font-family: var(--sans); }
.touchBtn.pressed { background: var(--ink); color: var(--paper); }
#joyBase { border-color: #9ca197; background: #f5f5f344; }
#joyKnob { background: #53584bb3; border-color: #53584b; }
body.touch .touchBtn { width: 44px; height: 44px; font-size: 11px; border-width: 1px; }
body.touch #btnAct { right: 22px; bottom: 112px; }
body.touch #btnSprint { right: 78px; bottom: 112px; }
body.touch #btnJump { right: 22px; bottom: 166px; }
body.touch #btnCast { right: 78px; bottom: 166px; background: #f5f5f3d9; }
body.touch #btnCast.pressed { background: var(--ink); }
body.touch #joyZone { bottom: 110px; height: 130px; }
body[data-cabin-focus=shelf] #joyZone, body[data-cabin-focus=shelf] .touchBtn { display: none; }
button:focus-visible, [role=button]:focus-visible, input:focus-visible { outline: 2px solid #60675b; outline-offset: 4px; }

/* 实体书：两块静态纸页和一张有正反面的翻页纸，共享一个书脊。 */
.book-dialog { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; padding: 0; margin: 0; border: 0; background: transparent; color: #e5e6e0; overflow: hidden; }
.book-dialog::backdrop { background: #1e211deb; backdrop-filter: blur(7px) grayscale(1); }
.reader-actions { display: flex; align-items: center; gap: 16px; }
.reader-actions > a, .reader-actions > button { color: #e5e6e0; background: none; border: 0; font: 11px/1.5 var(--sans); text-decoration: none; cursor: pointer; padding: 10px 0; white-space: nowrap; }
.reader-actions > button:disabled { opacity: .3; cursor: default; }
.reader-actions > a:hover { text-decoration: underline; text-underline-offset: 4px; }
.reader-actions .reader-close { border: 1px solid #74796f; padding: 10px 15px; }
.reader-directory { position: absolute; z-index: 25; right: 40px; top: 76px; width: min(340px,calc(100vw - 44px)); max-height: 55dvh; overflow-y: auto; padding: 14px; box-sizing: border-box; background: #f3f2ec; color: var(--ink); box-shadow: 0 10px 35px #0004; }
.reader-directory button { display: block; text-align: left; width: 100%; border: 0; border-bottom: 1px solid #deded6; background: none; color: inherit; padding: 11px 6px; font: 14px/1.5 var(--serif); cursor: pointer; }
.reader-directory button:hover { background: #e9e8df; }
.reader-directory .directory-subheading { padding-left: 20px; font-size: 12px; }
.book-prose { height: 100%; overflow-y: auto; overflow-wrap: anywhere; font: clamp(13px,1.15vw,17px)/1.85 var(--serif); scrollbar-width: thin; user-select: text; overscroll-behavior: contain; touch-action: pan-y; }
.book-prose > :first-child { margin-top: 0; }
.book-prose > :last-child { margin-bottom: 0; }
.book-prose p { margin: 0 0 .9em; }
.book-prose h1, .book-prose h2 { font-size: 1.35em; line-height: 1.5; font-weight: 500; margin: 1em 0 .8em; }
.book-prose h3, .book-prose h4 { font-size: 1.1em; line-height: 1.5; margin: 1em 0 .6em; }
.book-prose ul, .book-prose ol { margin: .5em 0 1em; padding-left: 1.5em; }
.book-prose li { margin: .25em 0; }
.book-prose blockquote { margin: .7em 0; padding-left: 1em; border-left: 2px solid #a9ac9e; color: #6a6d61; }
.book-prose a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.book-prose img { display: block; max-width: 100%; max-height: min(240px,35dvh); height: auto; object-fit: contain; margin: .5em auto; }
.book-wide-content { max-width: 100%; overflow-x: auto; overscroll-behavior: contain; margin: .5em 0; }
.book-prose pre { margin: 0; padding: .7em; background: #eeede5; white-space: pre; font: 12px/1.7 Consolas, monospace; }
.book-prose code { font: .85em Consolas, monospace; }
.book-prose table { border-collapse: collapse; min-width: 100%; font-size: .85em; white-space: nowrap; }
.book-prose th, .book-prose td { border: 1px solid #c9cbbf; padding: .4em .6em; text-align: left; }
.book-prose .callout { border-left: 2px solid #a9ac9e; padding: .5em 1em; margin: .8em 0; }
.book-prose .katex-display { max-width: 100%; overflow-x: auto; }
.book-page:has(.book-prose) { padding-bottom: 50px; }
.pagination-measure { position: fixed !important; visibility: hidden; pointer-events: none; z-index: -1; padding-bottom: 50px !important; }
.page-scroll-note { position: absolute; bottom: 36px; left: 0; width: 100%; text-align: center; color: var(--quiet); font: 9px var(--sans); }
.page-retry { align-self: center; cursor: pointer; border: 1px solid #a9ac9e; padding: 10px 20px; background: transparent; color: var(--ink); }
.reader-shell { height: 100%; box-sizing: border-box; display: grid; grid-template-rows: 90px 1fr 90px; padding: 0 40px; }
.reader-top, .reader-bottom { width: min(1100px, 100%); margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.reader-top { align-self: center; width: 100%; }
.reader-heading { display: flex; gap: 20px; align-items: baseline; }
#readerEdition { color: #a5aaa0; font: 10px var(--sans); letter-spacing: 2px; }
#readerTitle { margin: 0; font: 400 17px var(--serif); letter-spacing: 3px; }
.reader-close { border: 1px solid #6a7065; background: none; color: #e4e7df; padding: 10px 16px; cursor: pointer; font: 11px var(--sans); letter-spacing: 1px; }
.reader-close:hover { background: #e4e7df; color: #30322f; }
.reader-center { display: flex; align-items: center; justify-content: center; min-height: 0; }
.book-object { width: min(1100px, calc(100vw - 128px), calc((100dvh - 204px) * 1.5)); aspect-ratio: 1.5; position: relative; perspective: 2300px; isolation: isolate; filter: drop-shadow(0 25px 35px #0004); animation: book-arrive .65s cubic-bezier(.2,.7,.2,1) both; }
.book-block { position: absolute; inset: 0 -3px; background: repeating-linear-gradient(#d8d7d0 0 1px,#f1f0e9 1px 3px); transform: translateY(8px); border: 3px solid #575b50; border-top-width: 0; z-index: -1; box-shadow: 0 2px 3px #0006; }
.book-spread { position: absolute; inset: 0; transform-style: preserve-3d; cursor: grab; }
.book-spread:active { cursor: grabbing; }
.book-spine { position: absolute; left: calc(50% - 14px); top: 0; bottom: 0; width: 28px; z-index: 6; pointer-events: none; background: linear-gradient(90deg,transparent,#514e4120 30%,#625f4e38 48%,#fff3 62%,transparent); }
.book-page { position: absolute; top: 0; bottom: 0; width: 50%; padding: clamp(20px,3.5vw,52px); box-sizing: border-box; color: #30322b; background: #f8f7f1; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; font-family: var(--serif); user-select: none; touch-action: pan-y; }
.page-left { left: 0; background: linear-gradient(90deg,#f3f2ec 92%,#e0ded2); }
.page-right { right: 0; background: linear-gradient(90deg,#e8e6dc,#f8f7f1 5%,#f8f7f1 97%,#eeede5); }
.book-page::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .24; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23aaa' filter='url(%23n)' opacity='.16' d='M0 0h180v180H0z'/%3E%3C/svg%3E"); }
.page-chapter { margin: 0 0 28px; color: #858779; font: 9px/1.5 var(--sans); letter-spacing: 2px; }
.page-title { margin: 0 0 25px; font-weight: 400; font-size: clamp(20px,2.05vw,30px); line-height: 1.5; letter-spacing: 2px; }
.page-copy { margin: 0 0 18px; font-size: clamp(12px,1.23vw,18px); line-height: 1.95; text-align: justify; }
.page-number { position: absolute; bottom: 21px; left: 0; right: 0; text-align: center; font: 10px var(--serif); color: #858779; letter-spacing: 2px; }
.title-page { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.title-page .title-rule { height: 42px; width: 1px; background: #707765; margin: 24px 0; }
.title-page h3 { margin: 0; font: 400 clamp(26px,3.1vw,45px)/1.5 var(--serif); letter-spacing: 5px; }
.title-page p { margin: 18px 0 0; color: #7a7c6f; font: 12px/1.8 var(--serif); letter-spacing: 2px; white-space: pre-line; }
.plate-page { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.plate-page svg { width: 84%; max-height: 60%; overflow: visible; color: #4c5544; }
.plate-page .plate-number { font: italic 46px var(--serif); margin: 26px 0 9px; color: #4c5544; }
.plate-page .plate-caption { font: 8px/1.8 var(--sans); letter-spacing: 2px; text-align: center; color: #858779; }
.colophon { height: 100%; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.colophon h3 { font: 400 22px var(--serif); letter-spacing: 3px; margin-bottom: 25px; }
.colophon p { font: 11px/2 var(--sans); white-space: pre-line; color: #7a7c6f; }
.page-image { width: 100%; height: 100%; object-fit: contain; }
.flip-sheet { position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; transform-origin: left center; transform-style: preserve-3d; z-index: 10; pointer-events: none; }
.flip-sheet[hidden] { display: none; }
.flip-sheet.backwards { left: 0; transform-origin: right center; }
.flip-sheet .book-page { width: 100%; right: auto; left: 0; }
.flip-sheet .sheet-back { transform: rotateY(180deg); }
.flip-sheet .sheet-front { box-shadow: -12px 0 30px #181d1710; }
.flip-sheet .sheet-back { box-shadow: 12px 0 30px #181d1720; }
.reader-bottom { width: 100%; font: 10px var(--sans); letter-spacing: 1px; color: #a5aaa0; }
.reader-turn-controls { display: flex; align-items: center; gap: 18px; }
.reader-turn-controls button { background: transparent; color: #e4e7df; border: 1px solid #646a5f; width: 42px; height: 34px; font: 18px var(--serif); cursor: pointer; }
.reader-turn-controls button:hover:not(:disabled) { color: #30322f; background: #e4e7df; }
.reader-turn-controls button:disabled { opacity: .25; cursor: default; }
#readerProgress { min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; }
.reader-gesture { margin: 0; }
@keyframes book-arrive { from { opacity: 0; transform: translateY(32px) rotateX(13deg) scale(.9); } to { opacity: 1; transform: translateY(0) rotateX(0) scale(1); } }
@media (max-width: 1000px) { .cabin-caption { bottom: 97px; left: 50%; transform: translateX(-50%); white-space: nowrap; } body[data-cabin-focus=shelf] .cabin-caption { display: none; } }
@media (max-width: 640px) {
  .cabin-return { left: 22px; top: 25px; }
  .shelf-catalog { top: 88px; left: 22px; width: min(280px,calc(100vw - 44px)); padding: 12px 15px; }
  .library-heading { margin-bottom: 7px; }
  .library-heading > span { font-size: 15px; }
  .library-filters { margin: 5px 0; }
  .library-batches { padding-top: 5px; margin-top: 4px; }
  #libraryList { max-height: 24dvh; }
  #menuDot { right: 22px; top: 27px; }
  #clock { top: 77px; right: 22px; font-size: 9px; }
  #menuPanel { top: 70px; right: 22px; max-height: calc(100dvh - 155px); }
  .cabin-dock { bottom: max(22px,env(safe-area-inset-bottom)); gap: 1px; }
  .cabin-dock button { padding: 10px 11px; font-size: 10px; }
  .cabin-dock .dock-divider { margin-left: 1px; margin-right: 1px; }
  body.touch .cabin-caption { bottom: 79px; font-size: 9px; }
  body.touch #hint { bottom: 230px; font-size: 10px; }
  #shelfHint { bottom: 82px; font-size: 10px; }
  .reader-shell { padding: 0 20px; grid-template-rows: 115px 1fr 84px; }
  .reader-top { flex-wrap: wrap; align-content: center; gap: 9px; }
  .reader-heading { width: 100%; min-width: 0; }
  #readerTitle { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .reader-actions { width: 100%; justify-content: space-between; gap: 10px; }
  .reader-actions > a, .reader-actions > button { font-size: 10px; padding: 7px 0; }
  .reader-actions .reader-close { padding: 7px 10px; }
  .reader-directory { top: 113px; right: 22px; }
  .book-prose { font-size: clamp(13px,3.8vw,16px); line-height: 1.85; }
  .reader-heading { display: block; }
  #readerEdition { font-size: 8px; }
  #readerTitle { font-size: 15px; margin-top: 8px; }
  .reader-close { padding: 9px 11px; font-size: 10px; }
  .book-object { width: min(calc(100vw - 44px),calc((100dvh - 215px) * .7)); aspect-ratio: .7; perspective: 1500px; }
  .book-spread > .page-left { display: none; }
  .book-spread > .page-right { width: 100%; }
  .book-spine { left: -3px; width: 13px; }
  .book-page { padding: 28px 25px; }
  .page-chapter { margin-bottom: 20px; }
  .page-title { font-size: 24px; }
  .page-copy { font-size: clamp(12px,3.8vw,16px); line-height: 1.85; }
  .title-page h3 { font-size: 34px; }
  .title-page p { font-size: 11px; }
  .flip-sheet, .flip-sheet.backwards { width: 100%; left: 0; transform-origin: left center; }
  .flip-sheet.backwards { transform-origin: right center; }
  .reader-bottom { flex-direction: column; gap: 12px; }
  .reader-gesture { font-size: 9px; }
  .reader-turn-controls { gap: 15px; }
}
@media (max-height: 540px) and (min-width: 641px) {
  .reader-shell { grid-template-rows: 60px 1fr 60px; }
  .book-object { width: min(calc(100vw - 140px),calc((100dvh - 140px) * 1.5)); }
  .book-page { padding: 18px 25px; }
  .page-copy { font-size: 10px; line-height: 1.6; margin-bottom: 10px; }
  .page-title { font-size: 18px; margin-bottom: 14px; }
  .page-chapter { margin-bottom: 12px; }
  .page-number { bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .book-object { animation: none; }
}
