:root {
  --library-ink: #17352d;
  --library-wine: #7a2e3a;
  --library-paper: #fffdf8;
}

.library-page {
  background: #fff;
}

.library-header {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid rgba(45, 76, 58, .18);
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 12px 34px rgba(17, 39, 29, .12);
  backdrop-filter: blur(14px);
}

.library-page [hidden] {
  display: none !important;
}

.library-header-inner {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.library-header .brand {
  align-items: flex-start;
  text-align: left;
}

.library-hero {
  padding: 74px 0 66px;
  background: linear-gradient(180deg, #3b0714 0%, #5b0f20 35%, #7a2438 70%, #a44a5c 100%);
}

.library-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 760px);
  align-items: center;
  gap: 54px;
}

.library-eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--library-wine);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .17em;
}

.library-hero h1 {
  max-width: 760px;
  margin: 0;
  color: #f1dfd2;
  font-family: "Libre Franklin", sans-serif;
  font-size: clamp(42px, 5.7vw, 76px);
  line-height: 1;
  letter-spacing: -.055em;
}

.library-hero p {
  max-width: 720px;
  margin: 24px 0 0;
  color: #f3e7de;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.6;
}

.library-hero .library-eyebrow {
  color: #efb8c3;
}

.library-hero-highlights {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  vertical-align: baseline;
}

.library-hero-highlights span {
  padding: 3px 9px;
  border: 1px solid rgba(255, 226, 228, .3);
  border-radius: 999px;
  background: rgba(255, 224, 226, .1);
  color: #fff3ed;
  font-size: .78em;
  font-weight: 700;
  line-height: 1.45;
}

.library-hero-highlights i {
  color: rgba(255, 231, 226, .65);
  font-style: normal;
  font-weight: 500;
}

.library-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 28px;
  overflow: visible;
}

.library-choice-card {
  width: 100%;
  min-width: 0;
  min-height: 190px;
  padding: 28px;
  border: 1px solid rgba(45, 76, 58, .24);
  border-radius: 28px;
  background: #fffdf9;
  color: var(--library-ink);
  text-align: left;
  cursor: pointer;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, .18),
    0 6px 14px rgba(0, 0, 0, .12);
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.library-choice-card[data-theme="infantil"] {
  border-color: #e8c8bd;
  background: #f9e6df;
}

.library-choice-card[data-theme="iniciais"] {
  border-color: #bfd7c7;
  background: #e4f1e7;
}

.library-choice-card[data-theme="finais"] {
  border-color: #bfd4df;
  background: #e4f0f5;
}

.library-choice-card[data-theme="medio"] {
  border-color: #d4c7d6;
  background: #eee6ef;
}

.library-choice-card[data-theme="autismo"] {
  position: relative;
  grid-column: 1 / -1;
  min-height: 220px;
  padding-left: 150px;
  overflow: hidden;
  border-color: #087fbd;
  background: linear-gradient(135deg, #064b93 0%, #087fbd 52%, #10a89a 100%);
  color: #fff;
}

.library-choice-card[data-theme="autismo"]::before {
  content: "∞";
  position: absolute;
  left: 35px;
  top: 50%;
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, #ef476f, #ffd166, #06d6a0, #118ab2, #8a4fff) border-box;
  color: #087fbd;
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
}

.library-choice-card[data-theme="autismo"]::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
  background: linear-gradient(90deg, #ef476f 0 20%, #ffd166 20% 40%, #06d6a0 40% 60%, #118ab2 60% 80%, #8a4fff 80% 100%);
}

.library-choice-card[data-theme="autismo"] strong,
.library-choice-card[data-theme="autismo"] span,
.library-choice-card[data-theme="autismo"] small {
  color: #fff;
  text-shadow: 0 2px 7px rgba(2, 42, 83, .32);
}

.autism-category-banner {
  position: relative;
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 24px;
  margin: 0 0 34px;
  padding: 28px 34px;
  overflow: hidden;
  border-radius: 28px;
  background: linear-gradient(135deg, #064b93 0%, #087fbd 52%, #10a89a 100%);
  color: #fff;
  box-shadow: 0 18px 38px rgba(5, 75, 147, .24);
}

.autism-category-banner::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
  background: linear-gradient(90deg, #ef476f 0 20%, #ffd166 20% 40%, #06d6a0 40% 60%, #118ab2 60% 80%, #8a4fff 80% 100%);
}

.autism-category-symbol {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 7px solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, #ef476f, #ffd166, #06d6a0, #118ab2, #8a4fff) border-box;
  color: #087fbd;
  font-size: 66px;
  font-weight: 900;
  line-height: 1;
}

.autism-category-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: #ffe08a;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
}

.autism-category-banner > .autism-category-copy h2 {
  margin: 0;
  color: #fff;
  font-family: "Libre Franklin", sans-serif;
  font-size: clamp(27px, 4vw, 43px);
  line-height: 1.1;
}

.autism-category-banner > .autism-category-copy p {
  max-width: 820px;
  margin: 10px 0 0;
  color: #f3fbff;
  font-size: 17px;
  line-height: 1.5;
}

.autism-featured-section {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  padding: 38px;
  border: 1px solid rgba(8, 127, 189, .2);
  border-radius: 30px;
  background: linear-gradient(180deg, #f2faff 0%, #f7fffd 100%);
  box-shadow: 0 18px 38px rgba(5, 75, 147, .1);
}

.autism-featured-section[hidden] {
  display: none;
}

.autism-featured-header {
  max-width: 820px;
  margin-bottom: 28px;
}

.autism-featured-header h2 {
  margin: 7px 0 10px;
  color: #064b63;
  font-family: "Libre Franklin", sans-serif;
  font-size: clamp(27px, 4vw, 40px);
  line-height: 1.12;
}

.autism-featured-header p {
  margin: 0;
  color: #42615b;
  font-size: 17px;
  line-height: 1.55;
}

.autism-featured-grid {
  margin-top: 0;
}

.autism-featured-card {
  border-top: 6px solid #087fbd;
}

.autism-featured-card .activity-card-actions {
  grid-template-columns: 1fr;
}

.autism-featured-card .preview-button {
  border-color: #087fbd;
  background: #087fbd;
  color: #fff;
}

@media (max-width: 680px) {
  .library-choice-card[data-theme="autismo"] {
    min-height: 210px;
    padding: 118px 24px 24px;
  }

  .library-choice-card[data-theme="autismo"]::before {
    left: 24px;
    top: 24px;
    width: 70px;
    height: 70px;
    transform: none;
    font-size: 52px;
  }

  .autism-category-banner {
    grid-template-columns: 1fr;
    padding: 28px 24px;
  }

  .autism-category-symbol {
    width: 76px;
    height: 76px;
    font-size: 54px;
  }

  .autism-featured-section {
    margin-top: 8px;
    padding: 26px 18px;
    border-radius: 24px;
  }
}

.library-choice-card:hover,
.library-choice-card:focus-visible {
  transform: translateY(-4px);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, .22),
    0 8px 18px rgba(0, 0, 0, .16);
}

.library-choice-card strong,
.library-choice-card span,
.library-choice-card small {
  display: block;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .14);
}

.library-choice-card strong {
  margin: 14px 0 8px;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}

.library-choice-card > span {
  font-size: 1.05rem;
}

.library-choice-card small {
  margin-top: 14px;
  color: #42705e;
  font-weight: 700;
}

.library-breadcrumb {
  min-height: 24px;
  color: #537064;
  font-weight: 700;
}

.library-back {
  margin-top: 18px;
}

.library-pagination {
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 28px;
}

.library-content {
  padding-top: 64px;
  background: #fff;
}

.library-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.library-toolbar h2 {
  margin: 0;
  color: var(--library-ink);
  font-family: "Libre Franklin", sans-serif;
  font-size: clamp(34px, 4vw, 52px);
  letter-spacing: -.045em;
}

.library-toolbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.selection-summary {
  min-width: 180px;
  padding: 15px 18px;
  border-radius: 16px;
  background: var(--green-100);
  color: var(--green-900);
  text-align: right;
}

.selection-summary span,
.selection-summary strong {
  display: block;
}

.selection-summary span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.selection-summary strong {
  margin-top: 3px;
  font-size: 18px;
}

.selection-summary b {
  color: var(--library-wine);
}

.library-filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  padding: 24px;
  border: 1px solid rgba(45, 76, 58, .2);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 20px 46px rgba(17, 39, 29, .13);
}

.library-filters > label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.library-filters label > span,
.library-filters legend {
  color: var(--green-900);
  font-size: 13px;
  font-weight: 800;
}

.library-filters select,
.library-filters input[type="search"] {
  width: 100%;
  min-height: 49px;
  padding: 0 13px;
  border: 1px solid #ced9cc;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
}

.library-filters select:focus,
.library-filters input:focus {
  border-color: var(--library-wine);
  box-shadow: 0 0 0 4px rgba(122, 46, 58, .1);
}

.filter-search {
  grid-column: span 2;
}

.filter-toggles {
  display: flex;
  grid-column: span 3;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  min-width: 0;
  margin: 0;
  padding: 13px 15px;
  border: 1px solid #dbe3d8;
  border-radius: 14px;
}

.filter-toggles legend {
  padding: 0 6px;
}

.filter-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.filter-toggles input {
  width: 18px;
  height: 18px;
  accent-color: var(--library-wine);
}

.filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-actions .btn {
  align-self: end;
  min-height: 49px;
  padding: 10px 11px;
  font-size: 13px;
}

.active-filter-summary {
  min-height: 0;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.active-filter-summary:not(:empty) {
  padding: 10px 14px;
  border-left: 4px solid var(--library-wine);
  background: rgba(255, 255, 255, .72);
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.activity-library-card {
  position: relative;
  display: flex;
  min-height: 430px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(45, 76, 58, .24);
  border-radius: 24px;
  background: #fff;
  box-shadow:
    0 24px 48px rgba(17, 39, 29, .20),
    0 8px 18px rgba(17, 39, 29, .12);
  transition: transform .3s ease, box-shadow .3s ease;
}

.activity-library-card:hover {
  transform: translateY(-8px);
  box-shadow:
    0 34px 68px rgba(17, 39, 29, .28),
    0 12px 24px rgba(17, 39, 29, .16);
}

.activity-card-visual {
  position: relative;
  display: grid;
  min-height: 138px;
  place-items: center;
  overflow: hidden;
  background: var(--visual-gradient, linear-gradient(135deg, #e4f0e1, #fff0cc));
}

.activity-card-visual::before,
.activity-card-visual::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
}

.activity-card-visual::before {
  width: 120px;
  height: 120px;
  top: -42px;
  right: -22px;
}

.activity-card-visual::after {
  width: 78px;
  height: 78px;
  bottom: -32px;
  left: 18px;
}

.activity-card-symbol {
  position: relative;
  z-index: 1;
  font-size: 58px;
  filter: drop-shadow(0 7px 7px rgba(17, 39, 29, .18));
}

.favorite-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(45, 76, 58, .2);
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: var(--library-wine);
  font-size: 21px;
  cursor: pointer;
}

.favorite-button[aria-pressed="true"] {
  background: var(--library-wine);
  color: #fff;
}

.activity-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 22px;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.activity-meta span {
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 11px;
  font-weight: 800;
}

.activity-meta .difficulty {
  background: var(--wine-soft);
  color: var(--library-wine);
}

.activity-library-card h3 {
  margin: 16px 0 9px;
  color: var(--library-ink);
  font-family: "Libre Franklin", sans-serif;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: -.025em;
}

.activity-library-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.activity-features {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 16px 0 20px;
}

.activity-features span {
  color: var(--green-700);
  font-size: 12px;
  font-weight: 800;
}

.activity-features span::before {
  content: "✓";
  margin-right: 4px;
  color: var(--library-wine);
}

.activity-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: auto;
}

.activity-card-actions .btn {
  min-height: 44px;
  padding: 9px 12px;
  font-size: 13px;
}

.activity-card-actions .add-button {
  grid-column: 1 / -1;
}

.activity-card-actions .add-button[aria-pressed="true"] {
  border-color: var(--green-700);
  background: var(--green-700);
  color: #fff;
}

.figure-production-review {
  margin: 18px 0;
  padding: 16px 18px;
  border: 1px solid #e0b95a;
  border-radius: 14px;
  background: #fff8df;
  color: #5d4310;
}

.figure-production-review strong {
  display: block;
  margin-bottom: 6px;
}

.figure-production-review p {
  margin: 4px 0;
  font-weight: 800;
}

.preview-print {
  margin: 0;
}

.collection-export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
}

.collection-student-page,
.collection-answer-key {
  font-family: Arial, sans-serif;
}

.collection-student-page .student-fields {
  grid-template-columns: 2fr 1fr;
  margin: 0 0 10mm;
  color: #111;
  font-size: 15px;
}

.collection-student-page .student-fields span {
  border-bottom: 0;
}

.collection-student-page .student-fields span:last-child {
  grid-column: 1 / -1;
}

.collection-student-page h1 {
  margin: 0 0 18px;
  color: #111;
  font-family: Arial, sans-serif;
  font-size: 24px;
  text-align: center;
}

.collection-instruction {
  font-weight: 700;
}

.support-text {
  margin: 20px 0 24px;
  padding: 18px;
  border: 1px solid #bfc7c1;
  border-radius: 10px;
}

.support-text h2 {
  margin: 0 0 10px;
  color: #111;
  font-family: Arial, sans-serif;
  font-size: 20px;
}

.support-text p,
.collection-question-list > li > p {
  white-space: normal;
}

.collection-question-list > li {
  margin-bottom: 24px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.question-figure {
  display: block;
  width: auto;
  max-width: min(100%, 160mm);
  max-height: 40mm;
  margin: 7px auto 9px;
  object-fit: contain;
  break-inside: avoid;
  page-break-inside: avoid;
}

.collection-student-page-two .collection-question-list {
  margin-top: 0;
}

.question-alternatives {
  margin: 10px 0;
}

.question-alternatives li {
  margin: 7px 0;
}

.student-answer-space {
  margin-top: 10px;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 29px, #b8b8b8 30px);
}

.answer-space-pequeno { min-height: 42px; }
.answer-space-medio { min-height: 82px; }
.answer-space-grande { min-height: 132px; }

.collection-answer-key > ol > li {
  margin-bottom: 18px;
}

.collection-answer-key p {
  margin: 5px 0 0;
}

.empty-state {
  padding: 70px 24px;
  border: 2px dashed rgba(45, 76, 58, .25);
  border-radius: 24px;
  background: rgba(255, 255, 255, .65);
  text-align: center;
}

.empty-state span {
  font-size: 52px;
}

.empty-state h3 {
  margin: 12px 0 7px;
  font-size: 27px;
}

.empty-state p {
  margin: 0 0 20px;
  color: var(--muted);
}

.activity-preview {
  width: min(980px, calc(100% - 30px));
  max-height: calc(100vh - 30px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  box-shadow: none;
}

.activity-preview::backdrop {
  background: rgba(18, 35, 28, .72);
  backdrop-filter: blur(7px);
}

.preview-close {
  position: sticky;
  top: 18px;
  float: right;
  z-index: 5;
  width: 46px;
  height: 46px;
  margin: 18px 18px 0 0;
  border: 0;
  border-radius: 50%;
  background: var(--library-wine);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.preview-shell {
  background: #fff;
  padding: 36px;
}

.preview-topline {
  margin-bottom: 18px;
  color: var(--library-wine);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .15em;
}

.preview-shell > h2 {
  max-width: 780px;
  margin: 0;
  color: var(--library-ink);
  font-family: "Libre Franklin", sans-serif;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.05;
  letter-spacing: -.045em;
}

.preview-summary {
  margin: 12px 0 24px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.worksheet-page {
  margin-top: 24px;
  padding: 34px;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.worksheet-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--green-700);
}

.worksheet-header h3 {
  margin: 0;
  color: var(--library-ink);
  font-size: 26px;
}

.worksheet-header p {
  margin: 5px 0 0;
  color: var(--muted);
}

.worksheet-brand {
  color: var(--library-wine);
  font-weight: 800;
}

.student-fields {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin: 24px 0;
  color: var(--muted);
}

.student-fields span {
  padding-bottom: 7px;
  border-bottom: 1px solid #8ca093;
}

.preview-illustration {
  display: grid;
  min-height: 170px;
  margin: 22px 0;
  place-items: center;
  border-radius: 18px;
  background: var(--visual-gradient, linear-gradient(135deg, #e4f0e1, #fff0cc));
  font-size: 80px;
}

.question-list {
  margin: 0;
  padding-left: 24px;
}

.question-list li {
  margin: 22px 0;
  padding-left: 8px;
  color: #263e36;
  font-size: 17px;
  line-height: 1.6;
}

.answer-line {
  display: block;
  height: 30px;
  margin-top: 8px;
  border-bottom: 1px solid #c9d4ca;
}

.answer-key-page {
  border: 0;
  background: #fff;
  box-shadow: none;
  border-radius: 0;
}

.answer-key-page h3,
.adapted-page h3 {
  margin: 0 0 18px;
  color: var(--library-ink);
  font-size: 27px;
}

.answer-key-page ol {
  padding-left: 24px;
}

.answer-key-page li {
  margin: 14px 0;
  font-size: 16px;
  line-height: 1.5;
}

.adapted-page {
  border: 2px solid rgba(82, 116, 90, .38);
  background: #f7fbf4;
}

.adapted-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.adapted-badges span {
  padding: 7px 10px;
  border-radius: 999px;
  background: #deecda;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 800;
}

.adapted-question {
  margin: 16px 0;
  padding: 18px;
  border-left: 6px solid var(--gold);
  border-radius: 10px;
  background: #fff;
  font-size: 18px;
  line-height: 1.6;
}

.preview-bncc {
  margin-top: 24px;
  padding: 18px;
  border-radius: 14px;
  background: var(--green-100);
  color: var(--green-900);
}

.preview-bncc strong {
  color: var(--library-wine);
}

.library-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: min(360px, calc(100% - 48px));
  padding: 15px 18px;
  border-radius: 14px;
  background: var(--green-900);
  color: #fff;
  box-shadow: 0 18px 48px rgba(17, 39, 29, .32);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: .25s ease;
}

.library-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.library-footer {
  margin-top: 40px;
  background: linear-gradient(
    180deg,
    #5a0f1f 0%,
    #742033 45%,
    #8e3a4d 75%,
    #a44f61 100%
  );
  color: #f7ece8;
}

.library-footer strong,
.library-footer span {
  color: #f7ece8;
}

@media (max-width: 1020px) {
  .library-hero-grid {
    grid-template-columns: 1fr;
  }

  .library-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-search,
  .filter-toggles {
    grid-column: span 2;
  }

  .activity-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .library-choice-grid {
    grid-template-columns: 1fr;
  }

  .library-choice-card {
    min-height: 170px;
  }

  .library-header-inner {
    min-height: 82px;
  }

  .library-header .brand span {
    display: none;
  }

  .library-header .btn {
    padding: 10px 12px;
    font-size: 13px;
  }

  .library-hero {
    padding: 48px 0 44px;
  }

  .library-hero h1 {
    font-size: clamp(40px, 12vw, 56px);
  }

  .library-hero p {
    font-size: 18px;
    line-height: 1.7;
  }

  .library-hero-highlights {
    gap: 5px;
  }

  .library-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .selection-summary {
    text-align: left;
  }

  .library-filters {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .filter-search,
  .filter-toggles {
    grid-column: auto;
  }

  .filter-actions {
    grid-template-columns: 1fr;
  }

  .filter-toggles {
    align-items: flex-start;
    flex-direction: column;
  }

  .activity-grid {
    grid-template-columns: 1fr;
  }

  .activity-library-card {
    min-height: 0;
  }

  .preview-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 26px 18px;
  }

  .worksheet-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 23px 18px;
    overflow: hidden;
    overflow-wrap: anywhere;
  }

  .collection-question-list {
    max-width: 100%;
    padding-left: 26px;
  }

  .collection-question-list > li,
  .collection-question-list > li > p {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .worksheet-header,
  .student-fields {
    grid-template-columns: 1fr;
  }

  .collection-export-actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .collection-export-actions .btn {
    flex: 1 1 170px;
  }

  .collection-student-page .student-fields {
    grid-template-columns: 1fr;
  }

  .collection-student-page .student-fields span:last-child {
    grid-column: auto;
  }

  .collection-student-page,
  .collection-answer-key {
    width: calc(100vw - 72px);
    max-width: 100%;
  }
}

@media print {
  html,
  body {
    margin: 0;
    padding: 0;
    background: #fff !important;
  }

  @page {
    size: A4 portrait;
    margin: 15mm;
  }

  .library-header,
  .library-hero,
  .library-content,
  .library-footer,
  .preview-close,
  .preview-topline,
  .figure-production-review,
  .collection-export-actions {
    display: none !important;
  }

  .activity-preview {
    position: static;
    width: 100%;
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
    border: 0 !important;
    border-radius: 0;
    background: #fff !important;
    box-shadow: none !important;
  }

  .preview-shell {
    padding: 0;
  }

  .worksheet-page,
  .activity-print-page,
  .answer-key-page {
    width: 210mm;
    max-width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    page-break-after: always;
  }

  .collection-student-page,
  .collection-answer-key {
    color: #000;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    line-height: 1.3;
  }

  .collection-student-page h1 {
    font-size: 18pt;
  }

  .collection-instruction,
  .support-text {
    font-size: 11.5pt;
  }

  .collection-question-list > li > p {
    font-size: 12.5pt;
    line-height: 1.3;
  }

  .support-text h2 {
    font-size: 15pt;
  }

  .support-text {
    margin: 0 0 4mm;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .question-alternatives {
    margin: 1mm 0;
    font-size: 12pt;
  }

  .question-alternatives li {
    margin: 0;
    line-height: 1.25;
  }

  .collection-answer-key {
    break-before: page;
    font-size: 11pt;
  }

  .collection-student-page,
  .collection-answer-key {
    break-after: page;
    page-break-after: always;
  }

  .collection-question-list > li {
    margin-bottom: 4mm;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .question-figure {
    max-width: 160mm;
    max-height: 40mm;
    margin: 1.5mm auto 2mm;
  }

  .collection-answer-key h2,
  .collection-answer-key h3 {
    font-family: Arial, sans-serif;
  }

  .collection-student-page::before,
  .collection-student-page::after,
  .collection-answer-key::before,
  .collection-answer-key::after {
    content: none !important;
  }
}

/* =========================================================
   MOLDURA E MARGEM DE IMPRESSÃO — TODAS AS ATIVIDADES
   Mantém o conteúdo afastado da borda física da folha A4.
   ========================================================= */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  .worksheet-page,
  .activity-print-page,
  .answer-key-page {
    width: auto !important;
    max-width: none !important;
    min-height: 281mm;
    margin: 0 !important;
    padding: 9mm 10mm !important;
    box-sizing: border-box !important;
    border: 1.4px solid #222 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    overflow: visible !important;
    page-break-after: always;
  }

  /* Quando a impressão usa diretamente as páginas da coleção. */
  .collection-student-page,
  .collection-answer-key {
    box-sizing: border-box !important;
  }

  /* Evita que a moldura encoste ou seja cortada pela impressora. */
  .preview-shell {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .worksheet-page:last-child,
  .activity-print-page:last-child,
  .answer-key-page:last-child {
    page-break-after: auto;
  }
}
