/* Dialogue has a readable, measured page; neither its text nor card scrolls. */
.bookworm-theme dialog.wb-chapter-story {
  width:min(840px,calc(100vw - var(--wb-safe-left) - var(--wb-safe-right) - 32px));
  height:min(var(--reader-height,420px),calc(100dvh - var(--wb-safe-top) - var(--wb-safe-bottom) - 32px));
  max-height:none; padding:24px; overflow:hidden;
}
.bookworm-theme dialog.wb-chapter-story[open] {display:grid;grid-template-rows:auto auto minmax(0,1fr) 48px;gap:12px;}
.bookworm-theme .wb-chapter-story .wb-chapter-story-label {margin:0;font-size:16px;}
.bookworm-theme .wb-chapter-story h2 {margin:0;font-size:clamp(24px,3vw,34px);line-height:1.1;}
.wb-reader-body {display:grid;grid-template-columns:minmax(0,1fr);gap:20px;min-height:0;}
.has-portrait .wb-reader-body {grid-template-columns:clamp(96px,15vw,128px) minmax(0,1fr);}
#wb-chapter-story-portrait {width:100%;height:min(100%,180px);min-height:0;object-fit:contain;object-position:top;}
#wb-chapter-story-portrait[hidden] {display:none;}
.wb-reader-copy {display:grid;grid-template-rows:auto minmax(0,1fr);gap:10px;min-height:0;}
.bookworm-theme .wb-chapter-story .wb-conversation-speaker {margin:0;font-size:21px;line-height:1.2;}
.bookworm-theme #wb-chapter-story-text {min-height:0;margin:0;overflow:hidden;overflow-wrap:anywhere;font-size:clamp(20px,2.6vw,25px);line-height:1.4;}
.wb-reader-nav {display:flex;align-items:center;gap:12px;min-width:0;}
.bookworm-theme .wb-reader-nav button {float:none;margin:0;min-height:44px;padding:7px 18px;font-size:22px;}
.bookworm-theme .wb-reader-nav #wb-chapter-story-continue {margin-left:auto;}
.wb-reader-nav .wb-conversation-page {order:1;white-space:nowrap;margin:0;font-size:15px;}
.wb-reader-nav #wb-chapter-story-continue {order:2;}
/* Battle banter is text only, with natural content height. */
.bookworm-theme .wb .wb-speech {display:block;width:max-content;max-width:min(280px,42%);height:auto;min-height:0;padding:8px 12px;overflow:visible;font-size:17px;line-height:1.25;}
.bookworm-theme .wb .wb-speech[hidden] {display:none;}
.bookworm-theme .wb .wb-speech :is(strong,button) {display:none;}
.bookworm-theme .wb .wb-speech p {margin:0;min-height:0;max-height:none;overflow:visible;overflow-wrap:anywhere;}
@media(min-width:720px) and (max-width:1100px) and (min-height:540px) and (max-height:760px) and (orientation:landscape) {
  .bookworm-theme .wb.desk :is(.wb-speech,.wb-speech.you) {
    top:54px;bottom:auto;left:auto;right:12px;transform:none;
    width:max-content;height:auto;max-width:min(280px,38%);max-height:none;overflow:visible;
    padding:8px 12px;font-size:17px;line-height:1.25;
  }
  .bookworm-theme .wb.desk .wb-speech.you {left:12px;right:auto;}
  .bookworm-theme .wb.desk .wb-speech::after {display:none;}
  .bookworm-theme .wb.desk .wb-speech strong {font-size:21px;}
  .bookworm-theme .wb.desk .wb-speech p {max-height:none;overflow:visible;}
  .bookworm-theme .wb.desk .wb-relic-panel {overflow:hidden;display:grid;grid-template-rows:auto minmax(0,1fr);gap:8px;}
  .bookworm-theme .wb.desk .wb-relic-panel h2 {margin:0;padding-bottom:6px;}
  .bookworm-theme .wb.desk .wb-relics {grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;align-items:start;align-content:start;padding:0;min-height:0;margin:0;}
  .bookworm-theme .wb.desk .wb-socket {min-width:0;gap:8px;}
  .bookworm-theme .wb.desk .wb-socket-n {width:min(80px,100%);height:auto;aspect-ratio:84/117;min-width:0;min-height:44px;max-width:100%;padding:10px 8px;}
  .bookworm-theme .wb.desk .wb-socket-name {font-size:15px;line-height:1.15;}
  .bookworm-theme .wb.desk .wb-socket :is(p,.wb-relic-eye) {display:none;}
}
@media(max-height:500px) {
  .bookworm-theme dialog.wb-chapter-story {padding:14px;}
  .bookworm-theme dialog.wb-chapter-story[open] {gap:8px;grid-template-rows:auto minmax(0,1fr) 44px;}
  .bookworm-theme .wb-chapter-story-label {display:none;}
  .bookworm-theme #wb-chapter-story-text {font-size:19px;line-height:1.3;}
}
@media(max-width:480px) {
  .bookworm-theme dialog.wb-chapter-story {padding:16px;}
  .bookworm-theme dialog.wb-chapter-story[open] {grid-template-rows:auto auto minmax(0,1fr) 72px;gap:8px;}
  .wb-reader-body {gap:12px;}
  .wb-reader-nav {display:grid;grid-template-columns:1fr 1fr;grid-template-rows:20px 44px;gap:4px 8px;}
  .wb-reader-nav .wb-conversation-page {grid-column:1/-1;grid-row:1;}
  .bookworm-theme .wb-reader-nav #wb-chapter-story-back {grid-column:1;grid-row:2;}
  .bookworm-theme .wb-reader-nav #wb-chapter-story-continue {grid-column:2;grid-row:2;margin:0;}
  .bookworm-theme .wb-reader-nav button {font-size:18px;padding:6px 10px;}
}
