/* Keep the novel in its own column; ads never enter the prose. */
.reader-ad-layout { --rail-width:160px; --rail-top:100px; }
.admin-bar .reader-ad-layout { --rail-top:132px; }
.reader-rail { display:none; min-width:0; }
.reader-ad { color:var(--muted); background:var(--surface); border:1px solid var(--line); text-align:center; overflow:hidden; }
.reader-ad-label { display:block; font:9px/20px var(--sans); letter-spacing:.12em; text-transform:uppercase; }
.reader-ad-content { min-height:600px; }
.reader-ad-end { margin:32px auto; width:100%; }
.reader-ad-end .reader-ad-content { min-height:90px; }
.reader-ad-mobile { display:none; }
.reader-utilities { display:grid; gap:3px; margin-bottom:22px; padding:14px 0; border-block:1px solid var(--line); }
.reader-utilities a,.reader-utilities button { display:flex; align-items:center; gap:10px; min-height:44px; padding:9px 8px; color:var(--muted); font:12px/1.5 var(--sans); text-align:left; background:transparent; border:0; cursor:pointer; }
.reader-utilities a:hover,.reader-utilities button:hover { color:var(--gold); }

@media(min-width:1000px) {
  .reader-ad-layout { display:grid; grid-template-columns:minmax(0,var(--reader-width)) var(--rail-width); justify-content:center; column-gap:32px; width:calc(100% - 64px); margin:auto; }
  .reader-ad-layout .reader-main { grid-column:1; grid-row:1; width:100%; max-width:none; padding:0; margin:0; min-width:0; }
  .reader-rail-right { display:block; grid-column:2; grid-row:1; padding-top:56px; }
  .reader-rail-inner { position:sticky; top:var(--rail-top); }
  .reader-ad-left,.reader-ad-right { width:var(--rail-width); border:0; box-shadow:inset 0 0 0 1px var(--line); }
}
@media(min-width:1280px) {
  .reader-ad-layout { grid-template-columns:var(--rail-width) minmax(0,var(--reader-width)) var(--rail-width); }
  .reader-ad-layout .reader-main { grid-column:2; }
  .reader-rail-left { display:block; grid-column:1; grid-row:1; padding-top:56px; }
  .reader-rail-right { grid-column:3; }
}
@media(min-width:1536px) { .reader-ad-layout { --rail-width:300px; } }
/* Tall creative + tools should remain reachable on short windows. */
@media(min-width:1000px) and (max-height:900px) { .reader-rail-right .reader-rail-inner { position:static; } }
@media(min-width:1280px) and (max-height:760px) { .reader-rail-left .reader-rail-inner { position:static; } }

@media(max-width:760px) {
  /* A sticky sibling follows the chapter, above the existing 61px navigation.
     Negative margin keeps its initial flow space out of the chapter heading. */
  .reader-ad-mobile { display:block; position:sticky; top:calc(100dvh - 133px - env(safe-area-inset-bottom)); z-index:34; height:72px; width:100%; margin-bottom:-72px; border-inline:0; }
  .reader-ad-mobile .reader-ad-content { min-height:50px; width:min(320px,100%); margin:auto; }
  .reader-ad-mobile .reader-ad-label { line-height:20px; }
  .reader-ad-end { display:none; }
  .reader-ad-layout .reader-main { padding-bottom:140px; }
  .reader-ad-layout .reader-footnote { padding-bottom:25px; }
  .reader-ad-layout .chapter-discussion { padding-bottom:20px; }
}
@media print {
  .reader-rail,.reader-ad { display:none !important; }
  .reader-ad-layout { display:block; width:100%; }
}
