/* UI修改2.docx: original paper art; tiled/sliced instead of stretched. */
#chapterModal[data-paper="folio"],:is(#chapterModal,#modal)[data-paper="ink"]{
  width:min(980px,86vw);max-width:980px;height:min(780px,calc(100svh - 96px));max-height:calc(100svh - 96px);min-height:520px;overflow:hidden;
  padding:32px 100px 36px 104px;border:3px solid transparent;border-radius:2px;background:#eeede7;
  /* All four widths use the same .55 scale. Repeated edge/centre tiles preserve the ink and seals. */
  border-image:url('assets/ui/paper-notes/notes-frame.png') 420 115 360 155 fill / 231px 63.25px 198px 85.25px / 0 repeat;
  outline:2px solid #92836d;outline-offset:1px;box-shadow:0 22px 70px #16140fc0;color:#38342c;
}
:is(#chapterModal,#modal)[data-paper="ink"]{
  /* User-supplied 底图.png; keep the ink and seals at one uniform .437 scale. */
  border-image:url('assets/ui/paper-notes/dialog-frame.png') 529 145 453 195 fill / 231.173px 63.365px 197.961px 85.215px / 0 repeat;
}
#chapterModal[data-paper="ink"]:has(#chapterMusicVolume){width:min(850px,86vw);height:min(650px,calc(100svh - 96px))}
:is(#chapterModal,#modal)[data-paper][open]{display:flex;flex-direction:column}
:is(#chapterModal,#modal)[data-paper] .modal-content{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:10px 12px 4px 0;scrollbar-width:thin;scrollbar-color:#97886b #e8e2d4}
:is(#chapterModal,#modal)[data-paper] .modal-foot{flex-shrink:0;margin-top:14px;padding-top:12px}
:is(#chapterModal,#modal)[data-paper]{scrollbar-width:thin;scrollbar-color:#97886b #e8e2d4;scroll-behavior:auto}
:is(#chapterModal,#modal)[data-paper]::backdrop{background:#181a17a3;backdrop-filter:blur(5px)}
:is(#chapterModal,#modal)[data-paper] .modal-head{
  position:sticky;top:-30px;z-index:2;margin-bottom:20px;padding:14px 0 18px;
  border-bottom:1px solid #8d7c585e;background:#e9e2d1;
}
:is(#chapterModal,#modal)[data-paper] .modal-head{position:static;flex-shrink:0;background:none;border-color:#90877666}
:is(#chapterModal,#modal)[data-paper] .modal-head h2{color:#4d3c2c;font:30px/1.35 var(--serif);letter-spacing:4px;margin:9px 0 0}
:is(#chapterModal,#modal)[data-paper] .modal-head small{color:#6a5a45;letter-spacing:2px}
:is(#chapterModal,#modal)[data-paper] .close-button{
  flex-shrink:0;width:40px;height:40px;min-height:40px;border:1px solid #8c7959a6;
  color:#584831;background:#f9f5eb85;box-shadow:0 2px 5px #67543b15;
}
:is(#chapterModal,#modal)[data-paper] .close-button:hover{background:#e0d3b9;color:#30281f}
:is(#chapterModal,#modal)[data-paper] button:focus-visible{outline:2px solid #536b5e;outline-offset:3px}
:is(#chapterModal,#modal)[data-paper] .log-line{padding:18px 0;border-color:#75644945}
:is(#chapterModal,#modal)[data-paper] .log-line dt{font:22px/1.5 var(--serif);color:#634b30;margin-bottom:8px}
:is(#chapterModal,#modal)[data-paper] .log-line dt small{color:#6c6251}
:is(#chapterModal,#modal)[data-paper] .log-line dd{font-size:16px;line-height:1.95;color:#332e25;text-shadow:0 1px 0 #fff8}
:is(#chapterModal,#modal)[data-paper] :is(.setting-note,.empty-state,.modal-foot){color:#574f42;font-size:14px;line-height:1.85}
#chapterModal[data-paper="folio"] :is(.merchant-clue-note,.music-notes,.incense-notes,.temple-notes,.tm-notes){color:#433e33}
#chapterModal[data-paper="folio"] :is(p,dd){color:#494237;line-height:1.9}
#chapterModal[data-paper="folio"] :is(h3,h4,strong){color:#654d38}
#chapterModal[data-paper="folio"] .chapter-note-card{background:#faf8f1a6;border-color:#9e8c6c66;border-radius:2px;padding:16px}
#chapterModal[data-paper="folio"] .chapter-note-card p{font-size:14px;color:#474035}
#chapterModal[data-paper="folio"] .chapter-note-card small{color:#70604b}
#chapterModal[data-paper="folio"] .chapter-map{display:block;width:auto;max-width:100%;height:min(47svh,430px);margin:18px auto 2px;border:1px solid #a89b82;box-shadow:0 3px 10px #5e50371a}
#chapterModal[data-paper="folio"]:has(.temple-route-notes){height:min(540px,calc(100svh - 96px))}
#chapterModal[data-paper="folio"] .temple-route-notes .setting-note{font-size:17px;line-height:1.95;margin:18px 0 22px}
#chapterModal[data-paper="folio"] .stealth-notes-link{color:#67503b}
#chapterModal[data-paper="folio"] .music-notes-grid article{padding:12px;background:#faf8f2a3;border-color:#ab9c8166}
#chapterModal[data-paper="ink"] .setting-row{border-color:#95846b50;gap:24px}
#chapterModal[data-paper="ink"] .setting-row label{color:#4d4030;font-size:20px}
#chapterModal[data-paper="ink"] input[type="range"]{accent-color:#566e61}
#chapterModal[data-paper="ink"] select{color:#40382d;background:#f5f0e4;border:1px solid #9b896b;border-radius:2px;min-height:38px}
#chapterModal[data-paper="ink"] .flip-button{color:#f7f1e4;background:#566e61;border:1px solid #41594d;border-radius:2px;padding:12px 24px;margin-top:18px}
#chapterModal[data-paper="ink"] .flip-button:hover{background:#40594c}
/* The supplied character stays between the 3D city (0) and dialogue (6). */
.chapter-portrait{
  position:absolute;z-index:3;left:50%;bottom:var(--portrait-footline,34px);height:min(84svh,calc(100svh - 112px));width:auto;
  object-fit:contain;transform:translateX(-50%) scale(.975);transform-origin:50% 100%;pointer-events:none;user-select:none;
  filter:brightness(.84) saturate(.9) drop-shadow(0 5px 9px #20190d26);opacity:1;
  transition:filter .22s ease,opacity .22s ease,transform .28s cubic-bezier(.2,.65,.3,1);
}
.chapter-portrait.is-speaking{filter:brightness(1) saturate(1) drop-shadow(0 5px 9px #20190d26);opacity:1;transform:translateX(-50%) scale(1)}
/* Match Chen's left-side staging before brewing and when she returns to taste. */
#chenPortrait{left:27%}
@media(prefers-reduced-motion:reduce){.chapter-portrait{transition:none}}
