
/* The desktop paged reader fills the window. Continuous/mobile use their own layout. */
@media (min-width:701px) {
 html:has(body.reader-mode #readerApp:not([data-mode="continuous"])),
 body.reader-mode:has(#readerApp:not([data-mode="continuous"])) {height:100dvh;overflow:hidden!important;overscroll-behavior:none}
 body.reader-mode:has(#readerApp:not([data-mode="continuous"])) > :is(.topbar,.site-footer) {display:none!important}
 .reader-mode .reader-shell:not([data-mode="continuous"]) {
   display:grid;grid-template-rows:54px 33px minmax(0,1fr) 51px 42px;
   width:100%;max-width:none;height:100dvh;min-height:0!important;max-height:100dvh;
   margin:0;padding:0!important;overflow:hidden;overscroll-behavior:none
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-top {
   grid-row:1;display:grid;grid-template-columns:1fr auto 1fr;
   width:100%;height:54px;min-height:0;margin:0;align-items:center;gap:12px;
   padding:5px clamp(16px,3vw,48px)
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-top-actions {min-width:0;gap:8px;white-space:nowrap}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-top-actions :is(a,button) {
   height:36px;min-height:36px;padding:7px 11px!important;font-size:12px
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .sojang-reading-actions {
   grid-row:2;display:flex;flex-wrap:nowrap;align-items:center;justify-content:center;
   min-height:0;margin:0 auto;padding:2px 8px;gap:8px
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .sojang-reading-actions .reader-toc-button {
   height:26px;min-height:26px;padding:3px 12px;font-size:11px
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-overline {display:none!important}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reading-desk {
   grid-row:3;display:flex;position:relative;box-sizing:border-box;align-items:center;justify-content:center;
   width:100%;max-width:none;height:100%;min-height:0;margin:0;overflow:hidden;
   padding:8px clamp(14px,3vw,46px) 9px;gap:clamp(12px,1.7vw,26px)
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .book-turn-stage {
   box-sizing:border-box;position:relative;flex:0 0 auto;
   height:min(100%,calc((100vw - 182px) * var(--sj-reader-inverse-ratio,0.70946)))!important;
   width:auto!important;min-width:0;min-height:0!important;max-width:none!important;
   max-height:100%!important;aspect-ratio:var(--sj-reader-spread-ratio,1.40952);margin:0
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-side-arrow {
   flex:0 0 52px;width:52px;height:64px;margin:0
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-left-page,
 .reader-mode .reader-shell:not([data-mode="continuous"]) .book-turn-stage > .reader-paper {
   padding:clamp(28px,3vw,44px) clamp(28px,3.1vw,48px) 30px
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-bottom {
   grid-row:4;display:grid;box-sizing:border-box;
   grid-template-columns:minmax(0,1fr) minmax(130px,205px) minmax(0,1fr);
   align-items:center;width:min(1060px,calc(100% - 104px));max-width:none;
   height:51px;min-height:0;margin:0 auto!important;padding:3px 0;gap:14px
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-bottom .reader-pager {
   width:100%;height:38px;min-height:38px;padding:6px 14px;margin:0
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reading-progress {
   width:100%;min-width:0;max-width:none;align-self:center
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .progress-track {margin:0 0 3px}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reading-progress small {display:block;margin:0;text-align:center}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-subnav {
   grid-row:5;display:flex;flex-direction:row;align-items:flex-start;justify-content:center;
   width:100%;height:42px;min-height:0;margin:0;padding:0 12px 6px;gap:10px
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-subnav p {display:none!important}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-subnav :is(.sj-reader-settings-open,.comments-toggle) {
   display:inline-flex;align-items:center;justify-content:center;height:34px;min-height:34px;
   margin:0;padding:5px 14px;line-height:1.2;font-size:12px
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .bgm-control {position:fixed;right:18px;bottom:9px;z-index:92}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .bgm-circle {width:38px;height:38px}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .sojang-reader-notice {bottom:105px}
 /* Only the comments panel scrolls, never the book or the document. */
 .reader-mode .reader-shell:not([data-mode="continuous"]) .episode-discussion:not([hidden]) {
   position:fixed!important;z-index:96;top:69px;right:max(18px,calc((100vw - 1200px)/2));
   bottom:108px;left:auto;width:min(485px,calc(100vw - 36px));max-width:none;max-height:none;
   margin:0;padding:22px 26px 28px;overflow-x:hidden;overflow-y:auto;
   overscroll-behavior:contain;box-shadow:0 15px 55px rgba(62,38,54,.22)
 }
}
@media (min-width:701px) and (max-height:560px) {
 .reader-mode .reader-shell:not([data-mode="continuous"]) {grid-template-rows:46px 29px minmax(0,1fr) 44px 38px}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-top {height:46px}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-bottom {height:44px}
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-subnav {height:38px}
}

/* Larger screen typography for folio labels; manuscript text size is controlled
   by reader.js so its actual measured pagination matches the rendered pages. */
@media(min-width:701px){
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-paper-top,
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-left-page .reader-paper-top {
   font-size:14px;line-height:1.5
 }
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-paper-bottom,
 .reader-mode .reader-shell:not([data-mode="continuous"]) .reader-left-page .reader-paper-bottom {
   font-size:13px
 }
}

/* R16 Figma: episode comments is a full-screen cream overlay with its own
   scroll container. The book/document underneath stays exactly where it was. */
.reader-mode .reader-shell .episode-discussion.sj-figma-comments:not([hidden]){
  display:block!important;position:fixed!important;
  inset:0!important;top:0!important;right:0!important;bottom:0!important;left:0!important;
  z-index:180!important;box-sizing:border-box;
  width:100vw!important;height:100vh!important;height:100dvh!important;
  max-width:none!important;max-height:none!important;
  padding:0!important;margin:0!important;
  border:0!important;border-radius:0!important;
  background:#fbf8f3!important;box-shadow:none!important;
  overflow-x:hidden!important;overflow-y:auto!important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;scrollbar-gutter:stable;
  color:#342c36;
}
.reader-mode .sj-figma-comments .sj-comment-panel-content{
  box-sizing:border-box;width:min(560px,100%);min-height:100%;max-width:none;
  margin:0 auto;padding:clamp(30px,5vh,54px) 24px 56px;
}
.reader-mode .sj-figma-comments .sj-comment-panel-header{
  display:flex;flex-direction:column;align-items:flex-start;gap:0;
  border:0;padding:0;margin:0 0 20px;
}
.reader-mode .sj-figma-comments .sj-comment-panel-header h2{
  color:#342c36;font-family:"Noto Serif KR","AppleMyungjo",serif;
  font-weight:500;font-size:clamp(24px,2.3vw,28px);line-height:1.5;
  letter-spacing:-.035em;margin:0 0 16px;padding:0;
}
.reader-mode .sj-figma-comments .sojang-comments-close{
  position:static!important;float:none!important;display:inline-flex;
  justify-content:center;align-items:center;
  width:160px;min-width:0;min-height:48px;height:48px;
  padding:10px 20px;margin:0!important;
  border:1px solid #a78b9e!important;border-radius:7px!important;
  background:#fff!important;color:#794a64!important;
  font:500 13px/1.4 var(--sojang-sans, sans-serif);
  box-shadow:0 3px 8px #51394712;cursor:pointer;
}
.reader-mode .sj-figma-comments .sojang-comments-close:hover{background:#f8eff5!important}
.reader-mode .sj-figma-comments .sj-comment-panel-meta{
  margin:20px 0 6px;font-size:12px;line-height:1.8;color:#7c6f79;
}
.reader-mode .sj-figma-comments .sj-comment-composer{
  margin:0 0 24px;padding:0;border:0;background:transparent;
}
.reader-mode .sj-figma-comments .sj-comment-composer label{
  display:block;margin-bottom:9px;color:#342c36;font-size:13px;font-weight:600;
}
.reader-mode .sj-figma-comments .sj-comment-composer textarea{
  display:block;box-sizing:border-box;width:100%;
  min-height:130px;height:130px;resize:vertical;
  margin:0!important;padding:16px;border:1px solid #a78b9e!important;
  border-radius:9px!important;background:#fff!important;color:#342c36!important;
  font-family:var(--sojang-sans,sans-serif);font-size:15px;line-height:1.8;
}
.reader-mode .sj-figma-comments .sj-comment-composer textarea::placeholder{color:#766875;opacity:1}
.reader-mode .sj-figma-comments .sj-comment-limit{
  display:block;margin:10px 0 19px;color:#776c77;font-size:12px;
}
.reader-mode .sj-figma-comments .comment-form-footer{
  display:flex;justify-content:flex-start;margin:0;padding:0;
}
.reader-mode .sj-figma-comments .comment-form-footer .button{
  min-width:160px;min-height:48px;padding:10px 22px;margin-left:0!important;
  border-radius:6px!important;border:0!important;
  background:#784b65!important;color:#fff!important;font-size:14px;font-weight:600;
  box-shadow:0 3px 7px #51394718;
}
.reader-mode .sj-figma-comments .sj-comment-cards{
  display:flex;flex-direction:column;gap:18px;width:100%;margin:0;padding:0;
}
.reader-mode .sj-figma-comments .sj-comment-cards .comment-entry{
  box-sizing:border-box;display:block;width:100%;margin:0;padding:20px 18px 18px;
  border:0!important;border-radius:0!important;background:#fff!important;
  box-shadow:none!important;
}
.reader-mode .sj-figma-comments .comment-entry-top{
  display:flex;align-items:center;flex-wrap:wrap;gap:7px;
  margin:0 0 13px;padding:0;
}
.reader-mode .sj-figma-comments .comment-entry-top strong{
  color:#3a303a;font-size:13px;font-weight:650;
}
.reader-mode .sj-figma-comments .comment-entry-top time{
  margin:0;color:#796d78;font-size:12px;
}
.reader-mode .sj-figma-comments .comment-avatar{width:28px;height:28px;flex:none}
.reader-mode .sj-figma-comments .comment-body{
  color:#372f38;font-size:15px;line-height:1.85;margin:0 0 18px;white-space:pre-wrap;
}
.reader-mode .sj-figma-comments .comment-actions{
  display:flex;align-items:center;gap:9px;flex-wrap:wrap;margin:0;padding:0;
}
.reader-mode .sj-figma-comments .comment-actions :is(.comment-heart,.report-text),
.reader-mode .sj-figma-comments .comment-entry-top .comment-delete{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:130px;min-height:40px;margin:0;padding:8px 12px;
  border:1px solid #aa8b9d!important;border-radius:5px!important;
  background:#fff!important;color:#764b65!important;
  font-size:12px;font-weight:500;cursor:pointer;
}
.reader-mode .sj-figma-comments .sj-comment-reading-note{
  color:#8c818b;margin:26px 0 0;font-size:12px;line-height:1.7;
}
.reader-mode .sj-figma-comments .sj-comment-login{
  margin-bottom:24px;display:flex;flex-direction:column;align-items:flex-start;
  gap:10px;font-size:14px;
}
.reader-mode .sj-figma-comments .sj-comment-login p{margin:0}
.reader-mode .sj-figma-comments .sj-comment-login button{
  min-height:42px;border:1px solid #aa8b9d;border-radius:6px;background:#fff;color:#764b65;
}
.reader-mode .sj-figma-comments .comments-more{margin:16px auto 0;display:block;max-width:100%}
.reader-mode .sj-figma-comments .comments-more[hidden]{display:none!important}
@media(max-width:700px){
 .reader-mode .reader-shell .episode-discussion.sj-figma-comments:not([hidden]){
   inset:0!important;width:100vw!important;height:100dvh!important;
   padding:0!important;margin:0!important;overflow-y:auto!important;
 }
 .reader-mode .sj-figma-comments .sj-comment-panel-content{
   padding:24px 24px calc(52px + env(safe-area-inset-bottom));
 }
 .reader-mode .sj-figma-comments .sj-comment-panel-header h2{font-size:25px}
 .reader-mode .sj-figma-comments .sj-comment-composer textarea{min-height:126px;height:126px}
}

/* Keep owner deletion alongside reaction actions, as on R16's comment cards. */
.reader-mode .sj-figma-comments .comment-actions .comment-delete{
 display:inline-flex;align-items:center;justify-content:center;
 min-width:130px;min-height:40px;margin:0;padding:8px 12px;
 border:1px solid #aa8b9d!important;border-radius:5px!important;
 background:#fff!important;color:#764b65!important;font-size:12px;
}
