/* Biblioteca direta: a navegação do catálogo e os atalhos pessoais têm
   regiões próprias. Mantém os controles e identificadores do aplicativo. */
#app > .hero {
  grid-template-columns: minmax(0, 1fr) minmax(130px, 22%);
  min-height: 0;
  margin: 16px 0 14px;
  background: #fff;
  border-color: #d8e5ed;
  box-shadow: 0 4px 18px #08345c09;
}
#app > .hero > .visual-hero-main { padding: 18px 26px; }
#app > .hero .hero-copy h1 {
  font-size: clamp(25px, 2.6vw, 36px);
  line-height: 1.12;
  margin: 5px 0 5px;
  color: #08345c;
}
#app > .hero .hero-copy p { font-size: 12px; line-height: 1.5; }
#app > .hero .visual-hero-bottom { margin-top: 9px; }
#app > .hero > .visual-hero-art { min-height: 0; max-height: none; }
#app > .hero > .visual-hero-art figcaption { display: none; }
#app .search-panel {
  margin: 0 0 15px;
  padding: 15px 18px;
  border: 1px solid #d8e5ed;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 4px 18px #08345c08;
}
#app .search-panel .field label { color: #526c80; }
.library-header-toggle { display: none; }
.library-bottom-nav { display: none; }
body > .site-header { position: relative; z-index: 50; }
.site-header .header-content { flex-wrap: nowrap; }
.site-header .brand { flex: 0 1 auto; }
.site-header #libraryHeaderActions {
  flex: 0 1 auto;
  flex-wrap: nowrap;
  width: auto;
  min-width: 0;
  gap: 6px;
}
.site-header .header-tools {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.site-header .header-task-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.site-header .header-task-link svg { width: 23px; height: 23px; }
.site-header .library-header-toggle svg { width: 18px; height: 18px; }
.site-header .header-tools > :is(button, a) { flex: 0 0 auto; }
.site-header #libraryHeaderActions .account-badge {
  display: block;
  flex: 0 1 145px;
  min-width: 0;
  max-width: 145px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

/* A prévia fica baixa mesmo quando a conta tem dezenas de favoritos. */
#app > .cl35-favorites-half {
  display: block;
  padding: 15px 20px 16px;
  margin-bottom: 18px;
  border: 1px solid #d4e8d9;
  border-radius: 14px;
  background: #eaf5ec;
  box-shadow: none;
}
#app .cl35-favorites-heading {
  justify-content: flex-start;
  flex-wrap: nowrap;
  margin: 0 0 10px;
  gap: 9px;
}
#app .cl35-favorites-title {
  color: #08345c;
  font-size: 16px;
  line-height: 1.35;
}
#app .cl35-favorites-title::before { color: #00663b; }
#app .cl35-favorites-count {
  display: inline-flex;
  min-width: 23px;
  min-height: 23px;
  align-items: center;
  justify-content: center;
  padding: 3px 7px;
  border-radius: 30px;
  background: #fff;
  color: #00663b;
  font-size: 10px;
}
#app .cl35-favorites-open {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 5px 11px 5px 5px;
  border: 1px solid #005e9d;
  border-radius: 10px;
  color: #fff;
  background: #005e9d;
  font: 400 12px Montserrat, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 12px #005e9d24;
  transition: background .2s cubic-bezier(.2,.7,.2,1), transform .2s cubic-bezier(.2,.7,.2,1);
}
#app .cl35-favorites-open:hover { background: #08345c; transform: translateY(-1px); }
#app .cl35-open-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: none;
  place-items: center;
  border-radius: 7px;
  background: #ffffff24;
}
#app .cl35-open-icon svg { stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#app .cl35-open-arrow { font-size: 18px; line-height: 1; }
#app .cl35-favorites-list {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 10px;
  max-height: none;
  overflow: visible;
  padding: 0;
}
#app #cl35FavoritesList .cl35-favorite-preview {
  min-width: 0;
  min-height: 42px;
  padding: 4px 5px 4px 12px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  border-color: #d7e7dc;
  border-radius: 9px;
  box-shadow: none;
}
#app #cl35FavoritesList .cl35-favorite-preview .cl35-favorite-caption { min-width: 0; flex: 1; }
#app #cl35FavoritesList .cl35-favorite-preview .cl35-favorite-name {
  display: block;
  min-width: 0;
  font-size: 11px;
  color: #08345c;
}
#app #cl35FavoritesList .cl35-favorite-preview .cl35-favorite-remove,
#app #cl35FavoritesList .cl35-favorite-preview .cl35-favorite-action:not(:first-child) { display: none; }
#app #cl35FavoritesList .cl35-favorite-preview .cl35-favorite-actions {
  display: block;
  flex: none;
}
#app #cl35FavoritesList .cl35-favorite-preview .cl35-favorite-action:first-child {
  min-height: 33px;
  min-width: 38px;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  color: #00663b;
  background: #dcefe2;
}
#app #cl35FavoritesList .cl35-favorite-preview .cl35-favorite-action:first-child .material-symbols-rounded { display: none; }
#app #cl35FavoritesList .cl35-favorite-preview .cl35-action-label { color: #00663b; font-size: 11px; font-weight: 800; }
#app .cl35-favorites-note { display: none; }
#app .cl35-favorites-empty { margin: 0; font-size: 12px; color: #456654; }

/* Sidebar única: família no primeiro nível, grupos no segundo. */
#app .workspace.cl33-workspace {
  grid-template-columns: minmax(225px, 252px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
#app .cl33-group-panel {
  padding: 19px 15px 22px;
  top: 18px;
  border: 1px solid #d8e5ed;
  background: #fff;
  box-shadow: none;
}
#app .library-sidebar-title {
  margin: 0 7px 5px;
  color: #08345c;
  font-size: 17px;
  letter-spacing: -.02em;
}
#app .library-sidebar-description {
  margin: 0 7px 14px;
  color: #566f81;
  font-size: 11px;
  line-height: 1.55;
}
#app .cl33-group-panel .cl33-family-bar {
  display: block;
  margin: 0;
  padding: 15px 0 12px;
  border: 0;
  border-top: 1px solid #e1eaf0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#app .cl33-group-panel .cl33-family-heading {
  display: block;
  margin: 0 7px 7px;
}
#app .cl33-group-panel .cl33-family-heading h3,
#app .cl33-group-panel .sidebar-heading h3 {
  margin: 0;
  color: #5a7284;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
#app .cl33-group-panel #categoryNavigation {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
}
#app .cl33-group-panel #categoryNavigation .category-button {
  display: flex !important;
  width: 100% !important;
  min-height: 41px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  color: #08345c;
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  box-shadow: none;
  transform: none;
}
#app .cl33-group-panel #categoryNavigation .category-button:hover,
#app .cl33-group-panel #categoryNavigation .category-button.active {
  color: #005e9d;
  background: #e8f3f9;
}
#app .cl33-group-panel #categoryNavigation .category-button small {
  color: #526f82;
  background: #f2f6f8;
}
#app .cl33-group-panel .sidebar-heading {
  display: block;
  margin: 0 7px 5px;
  padding: 13px 0 0;
  border-top: 1px solid #e1eaf0;
  border-bottom: 0;
}
#app .cl33-group-panel .sidebar-heading span { display: none; }
#app .cl33-group-panel #groupNavigation {
  display: grid;
  gap: 3px;
  margin: 0 0 0 10px;
  padding-left: 9px;
  border-left: 2px solid #bbd6e5;
}
#app .cl33-group-panel #groupNavigation .category-button {
  min-height: 37px;
  border: 0;
  color: #526f81;
  font-size: 11px;
}
#app .cl33-group-panel #groupNavigation .category-button.active {
  color: #005e9d;
  background: #eff7fa;
}
#app .cl33-group-panel .sidebar-note { display: none; }
#app .results-header { margin-bottom: 12px; }
#app .results-header h2 { font-size: 23px; }
#app .library-active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 0 0 13px;
}
#app .library-active-filters[hidden] { display: none; }
#app .library-active-filters span {
  max-width: min(100%, 240px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 9px;
  border-radius: 30px;
  color: #005e9d;
  background: #e8f3f9;
  font-size: 10px;
  font-weight: 750;
}
#app .library-active-filters button {
  min-height: 35px;
  padding: 6px 9px;
  border: 0;
  color: #47677a;
  background: transparent;
  text-decoration: underline;
  font: 700 11px Montserrat, sans-serif;
  cursor: pointer;
}
#app .library-filters-toggle { display: none; }
#app .empty-state .button { margin-top: 12px; }

/* Coleção completa, sem rolagem aninhada na home. */
.cl35-favorites-dialog {
  width: min(480px, calc(100vw - 30px));
  max-height: min(88dvh, 850px);
  padding: 0;
  border: 1px solid #cadde8;
  border-radius: 17px;
  color: #08345c;
  background: #f6f9fb;
  box-shadow: 0 18px 70px #082b4a38;
  font-family: Montserrat, sans-serif;
}
.cl35-favorites-dialog::backdrop { background: #08345c99; }
.cl35-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 21px 22px 14px;
  background: #fff;
}
.cl35-dialog-heading h2 { margin: 4px 0 0; font-size: 21px; }
.cl35-dialog-heading p { margin: 7px 0 0; color: #536f80; font-size: 11px; line-height: 1.4; }
.cl35-dialog-heading .close-button { min-width: 38px; min-height: 38px; }
.cl35-dialog-search-label {
  display: block;
  padding: 15px 22px 6px;
  font-size: 11px;
  font-weight: 800;
}
.cl35-dialog-search {
  display: block;
  width: calc(100% - 44px);
  min-height: 44px;
  margin: 0 22px 15px;
  padding: 10px 12px;
  border: 1px solid #adc9da;
  border-radius: 8px;
  color: #08345c;
  background: #fff;
  font: 12px Montserrat, sans-serif;
}
.cl35-favorites-storage-label {
  display: block;
  margin: 0 22px 6px;
  color: #526c80;
  font-size: 11px;
  font-weight: 700;
}
.cl35-favorites-storage {
  display: block;
  width: calc(100% - 44px);
  min-height: 44px;
  margin: 0 22px 14px;
  padding: 8px 12px;
  border: 1px solid #adc9da;
  border-radius: 8px;
  color: #08345c;
  background: #fff;
  font: 12px Montserrat, sans-serif;
}
.cl35-favorites-full-list {
  display: grid;
  gap: 10px;
  padding: 0 22px 22px;
  overflow-y: auto;
  max-height: max(120px, calc(88dvh - 265px));
}
.cl35-favorites-full-list .cl35-favorite-compact {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 10px;
  padding: 14px;
  border: 1px solid #d6e5ed;
  border-radius: 10px;
  background: #fff;
}
.cl35-favorites-full-list .cl35-favorite-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #08345c;
  font-size: 13px;
  font-weight: 750;
}
.cl35-favorites-full-list .cl35-favorite-remove {
  flex: none;
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  color: #850b11;
  background: #fbecee;
  cursor: pointer;
}
.cl35-favorites-full-list .cl35-favorite-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.cl35-favorites-full-list .cl35-favorite-action {
  min-height: 44px;
  border-color: #d3e3ec;
  gap: 4px;
  padding: 5px;
}
.cl35-favorites-full-list .cl35-action-label { font-size: 11px; font-weight: 700; line-height: 1.2; }
.cl35-favorites-dialog :focus-visible,
#app .library-filters-toggle:focus-visible,
#app .cl35-favorites-open:focus-visible {
  outline: 3px solid #a11217;
  outline-offset: 2px;
}

@media (max-width: 900px) {
  #app .workspace.cl33-workspace { display: block; }
  #app .library-filters-toggle {
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 14px;
    padding: 10px 14px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: #005e9d;
    font: 750 12px Montserrat, sans-serif;
    cursor: pointer;
  }
  #app .library-filters-toggle span { font-size: 20px; line-height: 1; }
  #app .library-filters-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
  #app .cl33-group-panel { display: none; position: static; max-height: none; margin-bottom: 16px; overflow: visible; }
  #app .cl33-group-panel.library-sidebar-open { display: block; max-height: 65dvh; overflow-y: auto; overscroll-behavior: contain; }
  #app .cl33-group-panel #categoryNavigation,
  #app .cl33-group-panel #groupNavigation { display: grid !important; }
  #app .cl33-group-panel #groupNavigation .category-button { width: 100%; }
}
@media (max-width: 650px) {
  .site-header .header-content { position: relative; flex-wrap: nowrap; min-height: 64px; }
  .site-header .brand { flex: 1 1 auto; min-width: 0; }
  .site-header .brand-logo { width: 104px; flex: none; }
  .site-header .brand-text { min-width: 0; padding-left: 9px; }
  .site-header .brand-text strong { font-size: 11px; }
  .site-header .brand-text small { display: none; }
  .site-header .library-header-toggle:not([hidden]) {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 7px 11px;
    border: 1px solid #c8dce8;
    border-radius: 8px;
    color: #08345c;
    background: #edf5f9;
    font: 750 11px Montserrat, sans-serif;
    cursor: pointer;
  }
  .site-header .library-header-toggle span { font-size: 17px; }
  .site-header .library-header-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
  .site-header #libraryHeaderActions { display: none !important; }
  .site-header #libraryHeaderActions.library-header-open {
    position: absolute;
    z-index: 15;
    top: calc(100% - 1px);
    right: 0;
    display: grid !important;
    width: min(360px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 15px;
    border: 1px solid #cbdde8;
    border-radius: 0 0 13px 13px;
    background: #fff;
    box-shadow: 0 16px 30px #08345c25;
    overflow-x: hidden;
  }
  .site-header #libraryHeaderActions .account-badge { grid-column: 1 / -1; }
  .site-header #libraryHeaderActions .button,
  .site-header #libraryHeaderActions .booklet-launch-button { width: 100%; }
  #app > .hero { display: grid; grid-template-columns: minmax(0, 1fr); margin: 8px 0 12px; }
  #app > .hero > .visual-hero-main { padding: 15px 17px; }
  #app > .hero .hero-copy h1 { font-size: clamp(21px, 6vw, 26px); margin: 5px 0 5px; }
  #app > .hero .hero-copy p { display: block; font-size: 11px; }
  #app > .hero .visual-hero-bottom { display: none; }
  #app > .hero > .visual-hero-art { display: none; }
  #app .search-panel { padding: 12px; }
  #app > .cl35-favorites-half { padding: 12px 13px 13px; margin-bottom: 12px; }
  #app .cl35-favorites-heading { margin-bottom: 8px; }
  #app .cl35-favorites-title { font-size: 14px; }
  #app .cl35-favorites-list {
    display: flex !important;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    scroll-snap-type: x mandatory;
  }
  #app #cl35FavoritesList .cl35-favorite-preview {
    flex: 0 0 min(88%, 290px);
    scroll-snap-align: start;
  }
  #app .results-header h2 { font-size: 20px; }
  .cl35-favorites-dialog { width: calc(100vw - 16px); max-height: 94dvh; }
  .cl35-favorites-full-list { max-height: max(120px, calc(94dvh - 265px)); }
  .cl35-favorites-full-list .cl35-favorite-action {
    flex-direction: column;
    min-width: 0;
    min-height: 66px;
    gap: 4px;
    padding: 7px 3px;
    text-align: center;
  }
  .cl35-favorites-full-list .cl35-action-label {
    overflow-wrap: anywhere;
  }
}
@media (max-width: 380px) {
  #app .cl35-favorites-heading { flex-wrap: wrap; }
  #app .cl35-favorites-open { min-height: 40px; }
}
@media (max-width: 380px) {
  #app .search-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #app .search-field { grid-column: 1 / -1; }
}
@media (max-width: 1050px) {
  .site-header .header-content { position: relative; flex-wrap: nowrap; min-height: 64px; }
  .site-header .brand { flex: 1 1 auto; min-width: 0; }
  .site-header .library-header-toggle:not([hidden]) {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 7px 11px;
    border: 1px solid #c8dce8;
    border-radius: 8px;
    color: #08345c;
    background: #edf5f9;
    font: 750 11px Montserrat, sans-serif;
    cursor: pointer;
  }
  .site-header #libraryHeaderActions { display: none !important; }
  .site-header #libraryHeaderActions.library-header-open {
    position: absolute;
    z-index: 50;
    top: calc(100% - 1px);
    right: 0;
    display: grid !important;
    width: min(360px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 15px;
    border: 1px solid #cbdde8;
    border-radius: 0 0 13px 13px;
    background: #fff;
    box-shadow: 0 16px 30px #08345c25;
  }
  .site-header #libraryHeaderActions .header-tools {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
  .site-header #libraryHeaderActions .account-badge {
    grid-column: 1 / -1;
    max-width: none;
    width: 100%;
  }
  .site-header #libraryHeaderActions > .button { width: 100%; }
}
@media (pointer: coarse) {
  /* Evita o zoom automatico do iOS ao focar campos, inclusive manualmente. */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea { font-size: max(1rem, 1em) !important; }
}
@media (max-width: 650px) {
  .site-header .library-header-toggle:not([hidden]) { display: none; }
  .library-bottom-nav:not([hidden]) {
    position: fixed;
    z-index: 70;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: 2px;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1px solid #d8e5ed;
    background: #fff;
    box-shadow: 0 -5px 20px #08345c14;
  }
  .library-bottom-nav button {
    display: grid;
    place-items: center;
    gap: 2px;
    min-width: 0;
    min-height: 48px;
    padding: 5px 2px;
    border: 0;
    border-radius: 10px;
    color: #40596d;
    background: transparent;
    font: 650 10px Montserrat, sans-serif;
    cursor: pointer;
  }
  .library-bottom-nav button:first-child,
  .library-bottom-nav button[aria-expanded="true"] { color: #00663b; background: #eaf5ec; }
  .library-bottom-nav .material-symbols-rounded { font-size: 23px; line-height: 1; }
  .library-bottom-nav svg { width: 23px; height: 23px; }
  .library-bottom-nav button:focus-visible { outline: 2px solid #005e9d; outline-offset: -2px; }
  .site-header .header-content { min-height: 58px; }
  .site-header #libraryHeaderActions.library-header-open {
    position: fixed;
    z-index: 60;
    top: auto;
    right: 8px;
    bottom: calc(68px + env(safe-area-inset-bottom));
    width: min(380px, calc(100vw - 16px));
    max-height: min(70dvh, 480px);
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 15px;
    box-shadow: 0 12px 38px #08345c45;
  }
  .site-header #libraryHeaderActions .header-tools > :is(.button, .booklet-launch-button) { width: 44px; }
  #app { padding-bottom: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  #app .library-filters-toggle span,
  #app .cl35-favorites-open { transition: none !important; }
}
@media print {
  #app .cl33-group-panel { display: block; }
  #app .library-filters-toggle,
  .cl35-favorites-dialog { display: none !important; }
}
