/* Layout and reading tools. Shared chrome lives in academy/theme.css. */
:root { --reading-size: 20px; }
body.books {
  --ink: #1a2430; --ground: #f5f6f7; --accent: var(--red); --wash: #f7f8f9;
  --reading-font: Abel, 'Arial Narrow', sans-serif;
  background: var(--ground); color: var(--ink);
}
.books a { color: var(--accent); }
.books .skip-link { color: #fff; }
.books .mast a { color: var(--ink); }
.books strong, .books b { color: inherit; font-weight: 700; text-decoration: none; }
.books .button { color: white; }
.books button.secondary, .books .button.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.books button.secondary:hover, .books .button.secondary:hover { background: var(--wash); border-color: var(--muted); }
.books button.small { padding: 4px 9px; min-width: 36px; min-height: 36px; }
.books .text-button { padding: 0; background: none; border: 0; color: var(--ink); min-height: 44px; text-align: left; overflow-wrap: anywhere; }
.books .danger { color: #aa182b; }
.books .eyebrow { color: var(--accent); }
.lead { color: var(--muted); font-size: 22px; max-width: 720px; margin-bottom: 32px; }
.books .panel { background: var(--paper); margin: 0 0 20px; }
.books .panel > :first-child { margin-top: 0; }
.books .panel > :last-child { margin-bottom: 0; }
.narrow { max-width: 700px; margin: 40px auto; }
.books .panel.narrow { margin: 40px auto; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-heading > div { min-width: 0; }
.page-heading h1 { overflow-wrap: anywhere; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,330px),1fr)); gap: 20px; margin-top: 28px; }
.book-grid > .panel { margin: 0; }
.book-card { min-width: 0; max-width: 500px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.card-copy { padding: 28px; }
.manual-library-section + .manual-library-section { border-top: 1px solid var(--line); padding-top: 32px; margin-top: 40px; }
.manual-library-section > h2 { margin-bottom: 12px; }
.card-copy .manual-card-title { overflow-wrap: anywhere; font-size: 28px; line-height: 1.2; }
.card-copy .price { margin-bottom: 8px; }
.cover { display: block; width: 100%; object-fit: contain; background: #1a2430; aspect-ratio: 4/3; }
.typographic-cover { display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding: 35px; color: #fff; background: #1a2430; border-bottom: 4px solid var(--red); }
.typographic-cover span { font-size: 12px; text-transform: uppercase; letter-spacing: .13em; }
.books .typographic-cover strong { font-weight: 400; font-size: 35px; line-height: 1.15; overflow-wrap: anywhere; }
.typographic-cover small { color: #d1d9e2; letter-spacing: .16em; }
.book-detail { display: grid; grid-template-columns: minmax(260px,350px) minmax(0,1fr); gap: 50px; margin: 30px 0 60px; }
.detail-cover { aspect-ratio: 3/4; border: 1px solid var(--line); border-radius: 4px; }
.books .detail-cover strong { font-size: 44px; }
.price { font-size: 30px; }
.price small { font-size: 16px; }
.terms { padding: 18px 20px; background: var(--wash); border-left: 3px solid var(--accent); margin: 20px 0; }
.books .notice { background: var(--wash); border-left-color: var(--accent); }
.contents-list { padding: 0; list-style: none; }
.contents-list li { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.preserve { white-space: pre-wrap; overflow-wrap: anywhere; }
.books input, .books textarea, .books select { background: var(--paper); color: var(--ink); min-width: 0; }
.books textarea { line-height: 1.6; }
.books .check { align-items: center; }
.inline-form { display: flex; align-items: flex-end; gap: 15px; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: min(220px,100%); margin: 0; }
.form-grid, .account-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.wide { grid-column: 1/-1; }
.books th { background: var(--wash); }
.books caption { text-align: left; font-weight: 600; margin-bottom: 12px; }
.table-scroll { max-width: 100%; overflow: auto; }
.books .panel:has(> table) { overflow-x: auto; }
.editor-layout { display: grid; grid-template-columns: 265px minmax(0,1fr); gap: 24px; align-items: start; }
.editor-outline { position: sticky; top: 20px; max-height: 85vh; overflow: auto; }
.editor-outline ol { list-style: none; padding: 0; }
.editor-outline li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.editor-outline small { margin: 6px 0; }
.editor-document { min-height: 650px; }
.block-editor { border: 1px solid var(--line); border-radius: 4px; padding: 18px; margin: 20px 0; background: var(--ground); }
.block-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.block-heading strong { text-transform: capitalize; font-size: 14px; }
.add-block-row { display: flex; align-items: end; gap: 12px; margin: 24px 0; flex-wrap: wrap; }
.add-block-row label { margin: 0; flex: 1; min-width: 130px; }
.sticky-save { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); padding: 18px 0; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(170px,100%),1fr)); gap: 18px; margin-top: 25px; }
.asset-grid article { display: flex; flex-direction: column; gap: 9px; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.asset-grid img { width: 100%; height: 130px; object-fit: contain; background: var(--ground); border-radius: 4px; }
.import-summary { max-height: 300px; overflow: auto; }
#reader-status, #editor-status { font: 14px/1.5 var(--reading-font); }
.error { color: #aa182b; }
#editor-status:not(:empty) { position: sticky; top: 0; z-index: 5; background: var(--wash); border-left: 3px solid var(--accent); padding: 15px 20px; margin-bottom: 20px; }

/* Book typography: Abel throughout, white pages, and red chapter markers. */
.reader-page .book-wrap { max-width: 1800px; margin-top: 20px; padding: 0 2% 70px; }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 0 22px; border-bottom: 1px solid var(--line); }
.reader-toolbar > span { font-size: 20px; }
.compact { display: flex; gap: 8px; align-items: center; margin: 0; }
.compact select { width: auto; padding: 7px; margin: 0; }
#toggle-contents { display: none; }
.reader-layout { --contents-width: 310px; display: grid; grid-template-columns: var(--contents-width) 12px minmax(0,820px) 245px; gap: 18px; justify-content: center; align-items: start; margin-top: 28px; }
.reader-contents { grid-column: 1; }
.reading-paper { grid-column: 3; }
.reader-notes { grid-column: 4; }
.reader-contents, .reader-notes { position: sticky; top: 20px; max-height: 90vh; overflow: auto; min-width: 0; font: 17px/1.6 var(--reading-font); }
.contents-resizer { grid-column: 2; position: sticky; top: 20px; height: 80vh; cursor: col-resize; touch-action: none; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.contents-resizer::before { content: ''; position: absolute; width: 1px; height: 100%; background: var(--line); }
.contents-resizer span { position: relative; width: 4px; height: 48px; border-radius: 4px; background: var(--muted); }
.contents-resizer:hover, .contents-resizer:focus-visible { background: var(--wash); outline: 2px solid var(--accent); outline-offset: 2px; }
.contents-resizer:focus-visible span, .contents-resizer:hover span { background: var(--accent); }
.reader-resizing { cursor: col-resize; user-select: none; }
.reader-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.books [hidden] { display: none !important; }
.reader-contents h3, .reader-contents h4, .reader-notes h3 { font-family: Abel,'Arial Narrow',sans-serif; }
.reader-contents h3 { font-size: 20px; margin-top: 25px; }
.reader-contents h4 { font-size: 17px; color: var(--muted); margin: 18px 0 8px; }
.books .toc-item { display: block; padding: 10px 12px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; margin: 3px 0; overflow-wrap: anywhere; }
.books .toc-item.selected { background: var(--paper); border-left-color: var(--accent); color: var(--accent); }
.reading-paper { min-width: 0; background: var(--paper); padding: 48px clamp(24px,4vw,62px); border: 1px solid var(--line); }
.reading-paper h1 { font-size: clamp(30px,3vw,43px); line-height: 1.12; }
.section-rule { width: 65px; height: 3px; background: var(--accent); margin: 30px 0; }
#reading-content { font-family: var(--reading-font); font-size: var(--reading-size); line-height: 1.75; }
.content-block { margin: 24px 0; overflow-wrap: anywhere; }
.content-block h2, .content-block h3, .content-block h4 { font-family: Abel,'Arial Narrow',sans-serif; }
.content-block h2 { font-size: 30px; margin-top: 34px; color: var(--accent); }
.content-block figure { margin: 35px 0; }
.books .figure-button, .books .figure-button:hover { padding: 0; background: none; border: 0; border-radius: 0; width: 100%; min-height: 0; cursor: zoom-in; }
.figure-button img { max-width: 100%; max-height: 700px; object-fit: contain; }
.content-block figcaption { font: 16px/1.6 var(--reading-font); color: var(--muted); padding-top: 13px; border-top: 1px solid var(--line); margin-top: 12px; }
.content-block details { font: 16px/1.65 var(--reading-font); margin: 16px 0; }
.books .callout { border-left-color: var(--accent); background: var(--wash); font: 17px/1.75 var(--reading-font); }
.callout p { margin-bottom: 0; }
.example { padding: 26px; background: var(--ground); border: 1px solid var(--line); border-radius: 4px; }
.equation { padding: 20px; text-align: center; background: var(--ground); overflow: auto; }
.equation code { white-space: pre-wrap; font-size: 16px; }
.source-list { margin-top: 50px; border-top: 1px solid var(--line); padding-top: 20px; font: 14px/1.6 var(--reading-font); overflow-wrap: anywhere; }
.source-list h2 { font-family: Abel,'Arial Narrow',sans-serif; font-size: 23px; }
.section-navigation { display: flex; justify-content: space-between; gap: 20px; margin-top: 40px; font: 14px/1.6 var(--reading-font); }
.reader-notes textarea { font-size: 16px; }
.reader-notes hr { border: 0; border-top: 1px solid var(--line); margin: 25px 0; }
.highlight-item { border-left: 3px solid var(--accent); padding: 10px; margin: 18px 0; overflow-wrap: anywhere; }
.highlight-item blockquote { margin: 0 0 8px; font-size: 15px; }
mark { background: #f5e8a3; color: #253748; }
.books dialog { max-width: 94vw; max-height: 94vh; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); padding: 22px; }
.books dialog::backdrop { background: #15202dcc; }
.books dialog img { display: block; max-width: 85vw; max-height: 76vh; object-fit: contain; margin-top: 16px; }
#search-results a { display: block; padding: 8px 0; }
.reader-layout.without-notes { grid-template-columns: var(--contents-width) 12px minmax(0,820px); }

body.books.night { --ink: #e8ecf1; --muted: #b5bfca; --paper: #1e2835; --ground: #151c25; --line: #3d4a5a; --accent: #ff8797; --wash: #283444; color-scheme: dark; }
.night .mast { background: var(--paper); }
.night .academy-brand em { color: var(--accent); }
.night .danger, .night .error { color: #ff8797; }
.night .figure-button img { background: white; }
.night mark { background: #786b35; color: white; }

@media (max-width:1400px) {
  .reader-layout, .reader-layout.without-notes { grid-template-columns: var(--contents-width) 12px minmax(0,1fr); }
  .reader-notes { grid-column: 3; position: static; max-height: none; padding: 25px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
  .book-detail { gap: 30px; }
}
@media (max-width:800px) {
  .page-heading { display: block; }
  .page-heading .actions { margin: 20px 0; }
  .book-detail { grid-template-columns: minmax(0,1fr); }
  .detail-cover { max-width: 280px; margin: auto; }
  .account-grid, .form-grid, .editor-layout { grid-template-columns: minmax(0,1fr); }
  .editor-outline { position: static; max-height: 300px; }
  .reader-layout, .reader-layout.without-notes { grid-template-columns: minmax(0,1fr); gap: 18px; }
  .contents-resizer { display: none; }
  .reading-paper, .reader-contents, .reader-notes { grid-column: 1; }
  .reader-contents { display: none; position: static; max-height: 65vh; padding: 18px; background: var(--paper); border: 1px solid var(--line); }
  .reader-contents.open { display: block; }
  .reader-notes { grid-column: 1; }
  .reading-paper { padding: 30px 22px; }
  .reader-toolbar { flex-wrap: wrap; }
  .reader-toolbar > span { display: none; }
  #toggle-contents { display: inline-block; }
  .reader-toolbar .actions { gap: 8px; flex-wrap: wrap; }
  .reader-toolbar button { font-size: 16px; padding: 9px; }
  .compact { font-size: 16px; }
  .contents-list li { align-items: center; }
  .section-navigation { flex-direction: column; }
  .inline-form { align-items: stretch; }
  .books table { font-size: 14px; }
  .reader-page .book-wrap { margin-top: 15px; padding: 0 3% 50px; }
}
@media print {
  .book-mast, .reader-toolbar, .reader-contents, .reader-notes, .contents-resizer, .notice, .section-navigation { display: none !important; }
  .book-wrap, .reader-page .book-wrap { margin: 0; padding: 0; }
  .reader-layout { display: block !important; }
  .reading-paper { border: 0; padding: 0; }
  .content-block { break-inside: avoid; }
  body.books, body.books.night { --ink: #000; --muted: #333; --paper: #fff; --ground: #fff; --accent: #000; --wash: #fff; color-scheme: light; }
}
