/* Shared paper tasks inherit the existing worksheet's question/answer visibility. */
.am-paper-task, .am-paper-model { margin: 1rem 0; color: #161616; font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.am-paper-task h3, .am-paper-model h3 { font: 700 17px/1.5 sans-serif; margin: .8rem 0 .4rem; }
.am-paper-space { min-height: 42mm; border-bottom: 1px solid #aaa; background: repeating-linear-gradient(transparent, transparent 9mm, #ddd 9mm, #ddd 9.2mm); }
.am-book { font: 16px/1.7 sans-serif; color: #161616; max-width: 900px; margin: auto; }
.am-book *, .am-book *::before, .am-book *::after { box-sizing: border-box; }
.am-book h1 { font: 700 26px/1.5 sans-serif; }
.am-book h2 { font: 700 20px/1.5 sans-serif; margin: 0 0 1rem; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; overflow-wrap: anywhere; }
.am-book-controls { padding: 1rem; border: 2px solid #1f4e79; border-radius: 8px; margin: 1rem 0; }
.am-book-controls select, .am-book-controls button { font: inherit; max-width: 100%; min-height: 44px; margin: .3rem; }
.am-book [hidden] { display: none !important; }
.am-book-question, .am-book-answer { background: #fff; border: 1px solid #aaa; border-radius: 8px; padding: 1.2rem; margin: 1.5rem 0; }
.am-book-stem { overflow-wrap: anywhere; }
.am-book-stem figure { margin: 1rem 0; }
.am-book-stem svg { display: block; max-width: 100%; width: auto; height: auto; max-height: 75mm; margin: auto; }
.am-book-stem table { border-collapse: collapse; max-width: 100%; margin: 1rem 0; font-size: 16px; }
.am-book-stem th, .am-book-stem td { border: 1px solid #555; padding: .3rem; }
.am-book-stem .wb-print-space { display: none; }
.am-book-source { font-size: 16px; }
.am-book .am-paper-task, .am-book .am-paper-model { margin-bottom: 0; }
@media print {
  @page { size: A4; margin: 14mm; }
  .am-paper-task h3, .am-paper-model h3 { break-after: avoid; }
  .am-paper-task p, .am-paper-model p, .am-paper-model li { orphans: 3; widows: 3; }
  .am-paper-space { break-inside: avoid; background: none; border-top: 1px solid #aaa; border-bottom: 1px solid #aaa; }
  body:has(.am-book) { background: #fff !important; margin: 0 !important; }
  body:has(.am-book) :is(.breadcrumb, .skip-link) { display: none !important; }
  body:has(.am-book) main { width: auto !important; max-width: none !important; padding: 0 !important; margin: 0 !important; }
  .am-book { max-width: none; margin: 0; }
  .am-book-controls, .am-book-source { display: none !important; }
  .am-book-question, .am-book-answer { break-inside: avoid; border: 0; border-radius: 0; padding: 0; margin: 0 0 10mm; box-shadow: none; }
  .am-book-heading { margin-bottom: 8mm; }
  /* Keep the first model with its title in the answer-only booklet. */
  .am-book:has(.am-book-questions[hidden]) .am-book-heading > p { display: none; }
  .am-book:has(.am-book-questions[hidden]) .am-book-heading { margin-bottom: 4mm; }
  .am-book-answers { break-before: page; }
  .am-book-questions[hidden] + .am-book-answers { break-before: auto; }
  .am-book-stem figure, .am-book-stem table { break-inside: avoid; }
  .am-book-stem svg { max-height: 65mm; }
  .am-book-stem .statement { border: 0; box-shadow: none; padding: 0; }
  .am-book[data-reasoning-book="data-bunpu"] .am-book-stem:has(> figure + table) { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4mm; }
  .am-book[data-reasoning-book="data-bunpu"] .am-book-stem:has(> figure + table) > :not(figure, table) { grid-column: 1 / -1; }
  .am-book[data-reasoning-book="data-bunpu"] .am-book-stem > figure, .am-book[data-reasoning-book="data-bunpu"] .am-book-stem > table { min-width: 0; }
  .am-book a { color: #161616; text-decoration: none; }
}
