/* Independent, premium book-reading environment. Does not change the portal theme. */
body:has(.book-reader-shell) { background: #f7f7f8; }
body:has(.book-reader-shell) .app-sidebar, body:has(.book-reader-shell) .app-topbar, body:has(.book-reader-shell) .book-context-bar { display: none !important; }
body:has(.book-reader-shell) .app-content-shell { margin-left: 0 !important; width: 100% !important; min-width: 0; }
body:has(.book-reader-shell) .app-main { width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
.book-reader-shell { --reader-bg: #f7f7f8; --reader-paper: #fff; --reader-ink: #20242b; --reader-muted: #767d88; --reader-line: #e5e7eb; --reader-font-size: 19px; width: 100%; max-width: none; margin: 0; min-height: 100vh; color: var(--reader-ink); background: var(--reader-bg); font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.book-reader-shell *, .book-reader-shell *::before, .book-reader-shell *::after { box-sizing: border-box; }
.book-reader-shell a { text-decoration: none; color: inherit; }
.book-reader-shell button, .book-reader-shell select { font: inherit; }
.reader-toolbar { height: 64px; min-height: 64px; width: 100%; position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: 1fr minmax(0,2fr) 1fr; align-items: center; padding: 0 clamp(16px,3vw,44px); background: var(--reader-paper); border-bottom: 1px solid var(--reader-line); backdrop-filter: blur(12px); }
.reader-toolbar-start, .reader-toolbar-end { display: flex; align-items: center; gap: 10px; }
.reader-toolbar-end { justify-content: flex-end; }
.reader-toolbar-title { justify-self: center; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.reader-back { font-size: 12px; font-weight: 650; color: var(--reader-muted) !important; margin-right: 12px; white-space: nowrap; }
.reader-icon-button, .reader-drawer-head button { height: 32px; min-height: 32px; min-width: 32px; padding: 0 5px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--reader-ink); cursor: pointer; font-size: 13px; box-shadow: none; }
.reader-icon-button:hover, .reader-drawer-head button:hover { border-color: var(--reader-line); background: var(--reader-bg); }
.reader-drawer-backdrop { position: fixed; z-index: 80; inset: 0; background: rgba(17,24,39,.42); }
.reader-drawer-backdrop[hidden] { display: none !important; }
.reader-drawer { position: fixed; z-index: 81; top: 0; bottom: 0; left: 0; width: min(355px,92vw); overflow-y: auto; padding: 23px; background: var(--reader-paper); border-right: 1px solid var(--reader-line); box-shadow: 16px 0 45px #00000012; transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility .2s ease; }
.reader-drawer.is-open { transform: translateX(0); visibility: visible; }
.reader-drawer-head { display: flex; justify-content: space-between; align-items: center; text-transform: uppercase; font-size: 11px; font-weight: 750; letter-spacing: .14em; color: var(--reader-muted); }
.reader-drawer-book { padding: 27px 0 22px; font: 600 23px/1.18 Georgia, 'Times New Roman', serif; border-bottom: 1px solid var(--reader-line); }
.reader-drawer-book small { display: block; margin-top: 8px; font: 12px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--reader-muted); }
.reader-drawer nav { padding: 12px 0; display: grid; }
.reader-drawer nav a { display: grid; gap: 4px; padding: 12px 10px; border-radius: 7px; }
.reader-drawer nav a:hover, .reader-drawer nav a[aria-current="page"] { background: var(--reader-bg); }
.reader-drawer nav a span { text-transform: uppercase; letter-spacing: .08em; color: var(--reader-muted); font-size: 10px; }
.reader-drawer nav a strong { font: 500 14px/1.4 Georgia, 'Times New Roman', serif; }
.reader-kicker, .reader-rail-label { margin: 0; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .18em; color: var(--reader-muted); }
.reader-entry { max-width: 1110px; margin: 0 auto; padding: clamp(54px,8vw,116px) 32px 88px; display: grid; grid-template-columns: minmax(215px,340px) minmax(0,610px); gap: clamp(42px,7vw,105px); align-items: center; }
.reader-entry-cover { min-width: 0; }
.reader-entry-cover img, .reader-empty-cover { display: block; width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 3px; box-shadow: 0 24px 65px #1b253027, 0 3px 12px #1b253016; }
.reader-empty-cover { display: flex; flex-direction: column; justify-content: space-between; padding: 25px; background: #222936; color: #fff; font: 500 30px/1.1 Georgia, 'Times New Roman', serif; }
.reader-empty-cover small { font: 12px sans-serif; }
.reader-entry-copy h1 { margin: 18px 0 12px; font: 500 clamp(38px,5vw,67px)/1.05 Georgia, 'Times New Roman', serif; letter-spacing: -.045em; }
.reader-subtitle { margin: 0 0 18px; max-width: 525px; font: 19px/1.55 Georgia, 'Times New Roman', serif; color: #545d6b; }
.reader-author { font-size: 12px; font-weight: 650; letter-spacing: .025em; color: var(--reader-muted); }
.reader-entry-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 30px 0 35px; }
.reader-entry-actions a { display: inline-flex; align-items: center; justify-content: center; gap: 22px; min-height: 39px; padding: 10px 15px; border-radius: 6px; border: 1px solid #d7dce3; font-size: 12px; font-weight: 650; }
.reader-entry-actions .reader-main-button { background: #232a35; color: #fff; border-color: #232a35; }
.reader-entry-actions a:hover { opacity: .86; }
.reader-description { max-width: 550px; font: 15px/1.8 Georgia, 'Times New Roman', serif; color: #525b68; }
.reader-description p { margin: 0 0 12px; }
.reader-landing-contents { max-width: 1100px; margin: 0 auto; padding: 35px 32px 110px; border-top: 1px solid var(--reader-line); }
.reader-landing-contents h2 { margin: 12px 0 28px; font: 500 32px Georgia, 'Times New Roman', serif; }
.reader-landing-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 38px; }
.reader-landing-list a { display: grid; grid-template-columns: 110px minmax(0,1fr) 14px; gap: 14px; align-items: baseline; padding: 15px 0; border-bottom: 1px solid var(--reader-line); }
.reader-landing-list a span { font-size: 11px; color: var(--reader-muted); }
.reader-landing-list a strong { font: 500 15px/1.4 Georgia, 'Times New Roman', serif; }
.reader-landing-list a:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.reader-workspace { display: grid; grid-template-columns: 258px minmax(0,1fr); min-height: calc(100vh - 64px); }
.reader-rail { border-right: 1px solid var(--reader-line); background: var(--reader-paper); padding: 35px 14px 32px 22px; position: sticky; top: 64px; max-height: calc(100vh - 64px); overflow-y: auto; align-self: start; }
.reader-rail-label { padding: 0 8px 17px; }
.reader-rail nav { display: grid; gap: 2px; }
.reader-rail nav a { display: grid; gap: 3px; border-radius: 7px; padding: 10px 9px; font-size: 12px; line-height: 1.4; }
.reader-rail nav a small { color: var(--reader-muted); font-size: 10px; }
.reader-rail nav a[aria-current="page"] { background: #edf0f4; color: #182231; }
.reader-rail nav a:hover:not([aria-current="page"]) { background: var(--reader-bg); }
.reader-main { min-width: 0; padding: 25px clamp(20px,4vw,65px) 95px; }
.reader-mode-switch { display: flex; width: max-content; max-width: 100%; gap: 3px; margin: 0 auto 44px; padding: 4px; border: 1px solid var(--reader-line); border-radius: 8px; background: var(--reader-paper); }
.reader-mode-switch a { padding: 8px 15px; border-radius: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--reader-muted); }
.reader-mode-switch a[aria-current="true"] { background: #232a35; color: #fff; }
.reader-manuscript { max-width: 760px; margin: 0 auto; }
.reader-section-heading { text-align: center; margin: 0 0 43px; }
.reader-section-heading > span { display: block; font-size: 10px; text-transform: uppercase; font-weight: 700; letter-spacing: .16em; color: var(--reader-muted); }
.reader-section-heading h1 { margin: 18px auto 21px; font: 500 clamp(32px,4vw,48px)/1.15 Georgia, 'Times New Roman', serif; letter-spacing: -.025em; }
.reader-heading-rule { width: 38px; height: 1px; background: #bdc3cd; margin: auto; }
.reader-book-text { font: 400 var(--reader-font-size)/1.82 Georgia, 'Times New Roman', serif; color: var(--reader-ink); overflow-wrap: break-word; }
.reader-book-text p { margin: 0 0 1.2em; }
.reader-book-text h2, .reader-book-text h3, .reader-book-text h4 { font-family: Georgia, 'Times New Roman', serif; font-weight: 600; line-height: 1.3; margin: 1.65em 0 .75em; }
.reader-book-text blockquote { margin: 1.3em 0; border-left: 2px solid #a3adbc; padding: .2em 0 .2em 1.1em; color: var(--reader-muted); }
.reader-book-text img { max-width: 100%; height: auto; }
.reader-player { padding: clamp(17px,3vw,26px); margin: 0 0 38px; border: 1px solid var(--reader-line); border-radius: 10px; background: var(--reader-paper); box-shadow: 0 8px 35px #15203309; }
.reader-player-top { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.reader-player-top > div:first-child { display: grid; gap: 5px; min-width: 0; }
.reader-player-kicker { color: var(--reader-muted); font-size: 10px; font-weight: 750; letter-spacing: .15em; }
.reader-player-top strong { font: 500 22px/1.25 Georgia, 'Times New Roman', serif; }
.reader-player-top small { font-size: 12px; color: var(--reader-muted); }
.reader-audio-mark { display: grid; place-items: center; flex: 0 0 39px; height: 39px; border-radius: 8px; background: #f0f2f5; font-size: 19px; }
.reader-player audio { display: block; width: 100%; height: 44px; }
.reader-audio-extras { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--reader-muted); }
.reader-audio-extras select { width: auto; min-height: 31px; height: 31px; padding: 4px 7px; font-size: 12px; border: 1px solid var(--reader-line); border-radius: 5px; background: var(--reader-paper); color: var(--reader-ink); }
#reader-save-state { margin-left: auto; font-size: 11px; }
.reader-player-note { margin: 12px 0 0; font-size: 11px; line-height: 1.5; color: var(--reader-muted); }
.reader-unavailable { font-size: 13px; }
.reader-unavailable p { margin: 6px 0; color: var(--reader-muted); }
.reader-unavailable a { text-decoration: underline; }
.reader-section-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; margin-top: 75px; padding-top: 23px; border-top: 1px solid var(--reader-line); }
.reader-section-nav > div:last-child { text-align: right; }
.reader-section-nav a { display: inline-grid; gap: 7px; max-width: 100%; }
.reader-section-nav a strong { font: 500 14px/1.4 Georgia, 'Times New Roman', serif; }
.reader-section-nav a small { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: var(--reader-muted); }
.reader-section-nav .reader-contents-link { font-size: 12px; color: var(--reader-muted); }
.reader-night { --reader-bg: #171b21; --reader-paper: #20252d; --reader-ink: #e8e5df; --reader-muted: #a7afb9; --reader-line: #383f48; }
body:has(.reader-night) { background: #171b21; }
.reader-night .reader-rail nav a[aria-current="page"] { background: #303945; color: #e8e5df; }
.reader-night .reader-mode-switch a[aria-current="true"], .reader-night .reader-entry-actions .reader-main-button { background: #e8e5df; color: #20252d; border-color: #e8e5df; }
.reader-night .reader-entry-copy .reader-subtitle, .reader-night .reader-description { color: #bfc6cf; }
.reader-night .reader-audio-mark { background: #303945; }
.reader-night .reader-book-text { color: var(--reader-ink); }
.reader-night .reader-back { color: var(--reader-muted) !important; }
@media (max-width: 980px) { .reader-workspace { grid-template-columns: minmax(0,1fr); } .reader-rail { display: none; } .reader-main { padding: 22px 24px 90px; } }
@media (max-width: 700px) { .reader-toolbar { height: 56px; min-height: 56px; padding: 0 10px; gap: 4px; } .reader-toolbar-title { font-size: 13px; } .reader-toolbar-start, .reader-toolbar-end { gap: 2px; } .reader-back { margin-right: 2px; } .reader-back span { display: none; } .reader-icon-button { min-width: 28px; padding: 0 2px; font-size: 12px; } .reader-entry { grid-template-columns: 1fr; padding: 40px 24px 40px; gap: 35px; } .reader-entry-cover { width: min(230px,75%); margin: 0 auto; } .reader-entry-copy h1 { font-size: 41px; } .reader-entry-copy { text-align: center; } .reader-entry-actions { justify-content: center; } .reader-description { text-align: left; } .reader-landing-contents { padding: 35px 24px 70px; } .reader-landing-list { grid-template-columns: 1fr; } .reader-landing-list a { grid-template-columns: 83px minmax(0,1fr) 14px; gap: 8px; } .reader-main { padding: 18px 20px 70px; } .reader-mode-switch { margin-bottom: 33px; } .reader-mode-switch a { padding: 7px 10px; font-size: 11px; } .reader-section-heading { margin-bottom: 30px; } .reader-section-heading h1 { font-size: 34px; } .reader-book-text { line-height: 1.72; } .reader-section-nav { grid-template-columns: 1fr 1fr; } .reader-section-nav .reader-contents-link { grid-column: 1/-1; grid-row: 2; justify-self: center; } }
@media (prefers-reduced-motion: reduce) { .reader-drawer { transition: none; } }

/* Chapter controls stay visible while reading or listening. */
.book-reader-shell:has(.reader-section-nav) { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
.reader-section-nav {
  position: fixed;
  z-index: 55;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  margin: 0;
  padding: 8px max(20px, env(safe-area-inset-left, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 68px;
  color: var(--reader-ink);
  background: var(--reader-paper);
  border-top: 1px solid var(--reader-line);
  box-shadow: 0 -8px 25px rgba(17, 24, 39, .045);
}
.reader-section-nav .reader-section-prev,
.reader-section-nav .reader-section-next {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  min-width: 0;
  max-width: 100%;
  min-height: 42px;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 17px;
}
.reader-section-nav .reader-section-prev:hover,
.reader-section-nav .reader-section-next:hover,
.reader-section-nav .reader-contents-link:hover { background: var(--reader-bg); }
.reader-section-nav .reader-section-next { justify-self: end; }
.reader-section-nav .reader-nav-caption { display: grid; min-width: 0; gap: 2px; }
.reader-section-nav .reader-nav-caption strong {
  display: block;
  overflow: hidden;
  max-width: min(30vw, 340px);
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 500 13px/1.3 Georgia, 'Times New Roman', serif;
}
.reader-section-nav .reader-nav-caption small { font-size: 9px; letter-spacing: .1em; color: var(--reader-muted); font-weight: 700; }
.reader-section-nav .reader-contents-link {
  justify-self: center;
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.reader-section-nav .reader-nav-placeholder { min-width: 0; }
@media (max-width: 700px) {
  .book-reader-shell:has(.reader-section-nav) { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  .reader-section-nav { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 5px; min-height: 62px; padding: 7px 9px calc(7px + env(safe-area-inset-bottom, 0px)); }
  .reader-section-nav .reader-section-prev, .reader-section-nav .reader-section-next { gap: 5px; min-width: 0; padding: 5px 2px; }
  .reader-section-nav .reader-nav-caption strong { max-width: 24vw; font-size: 11px; }
  .reader-section-nav .reader-contents-link { grid-column: auto; grid-row: auto; font-size: 11px; padding: 9px 7px; }
}
@media (max-width: 380px) { .reader-section-nav .reader-nav-caption strong { display: none; } }


/* v3: navigation is moved to a direct child of BODY so mobile scrolling
   containers cannot establish a different fixed-position containing block. */
body > .reader-section-nav {
  position: fixed !important;
  inset: auto 0 0 0;
  z-index: 1000;
  box-sizing: border-box;
  --reader-bg: #f7f7f8;
  --reader-paper: #fff;
  --reader-ink: #20242b;
  --reader-muted: #767d88;
  --reader-line: #e5e7eb;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-text-size-adjust: 100%;
  margin-top: 0;
}
body > .reader-section-nav.reader-night {
  --reader-bg: #171b21;
  --reader-paper: #20252d;
  --reader-ink: #e8e5df;
  --reader-muted: #a7afb9;
  --reader-line: #383f48;
}
body > .reader-section-nav a {
  color: inherit;
  text-decoration: none;
  box-sizing: border-box;
}
body > .reader-section-nav .reader-nav-caption small { color: var(--reader-muted); }
@media (max-width: 700px) {
  body > .reader-section-nav { padding-bottom: calc(7px + env(safe-area-inset-bottom, 0px)); }
}
