/* Manga mobile: safeguards for readable controls and a non-obstructing quick menu.
   Keep the shared Anime/Manga square-left Details card presentation unchanged.
   The previous oversized review label came from a 17px !important override. */
@media (max-width:690px) {
  #app #mangaGrid[data-layout="details"] .media-card > .sk-detail-foot {
    min-width:0!important;
    max-width:100%!important;
    overflow:visible!important;
    padding-inline:clamp(9px,2.6vw,13px)!important;
  }
  #app #mangaGrid[data-layout="details"] .media-card .card-actions {
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    align-items:stretch!important;
    gap:7px!important;
    margin:0!important;
    padding:0!important;
    min-width:0!important;
    max-width:100%!important;
    width:100%!important;
  }
  #app #mangaGrid[data-layout="details"] .media-card .card-actions > :is(button,a) {
    box-sizing:border-box!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    flex:initial!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:42px!important;
    height:auto!important;
    margin:0!important;
    padding:8px 5px!important;
    font-family:inherit!important;
    font-size:clamp(10.5px,2.85vw,12px)!important;
    font-weight:780!important;
    line-height:1.35!important;
    letter-spacing:normal!important;
    text-align:center!important;
    white-space:normal!important;
    overflow-wrap:break-word!important;
    word-break:normal!important;
    text-overflow:clip!important;
    overflow:visible!important;
    border-radius:11px!important;
  }
  #app #mangaGrid[data-layout="details"] .media-card .card-actions > button.plus {
    font-size:clamp(10.5px,2.85vw,12px)!important;
    font-weight:820!important;
    letter-spacing:normal!important;
    padding-inline:4px!important;
  }
  #app #mangaGrid[data-layout="details"] .media-card .sk-detail-facts {
    min-width:0!important;
    max-width:100%!important;
  }
  #app #mangaGrid[data-layout="details"] .media-card .sk-detail-facts > * {
    box-sizing:border-box!important;
    max-width:100%!important;
    overflow-wrap:anywhere!important;
  }
  /* The large floating circle formerly covered Finale on Android.
     Place the same menu control in the fifth dock slot on Manga only. */
  #app:has(#page-manga.view.active) > .dock {
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
  }
  #app:has(#page-manga.view.active) > .fab {
    box-sizing:border-box!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    gap:2px!important;
    right:calc(max(8px, (100vw - 535px) / 2) + 5px)!important;
    bottom:calc(19px + env(safe-area-inset-bottom,0px))!important;
    width:min(101px,calc((100vw - 34px) / 5))!important;
    max-width:none!important;
    min-width:0!important;
    height:53px!important;
    min-height:53px!important;
    padding:6px 2px!important;
    border:0!important;
    border-radius:13px!important;
    box-shadow:none!important;
    background:var(--soft,#25334e)!important;
    color:var(--purple,#bca5f7)!important;
    transform:none!important;
  }
  #app:has(#page-manga.view.active) > .fab svg {
    width:19px!important;
    height:19px!important;
    flex-shrink:0!important;
  }
  #app:has(#page-manga.view.active) > .fab::after {
    content:"Menu";
    font-size:10px;
    line-height:1.15;
    font-weight:800;
    color:inherit;
  }
}
@media (max-width:640px) {
  #app:has(#page-manga.view.active) > .fab {
    right:13px!important;
    width:calc((100vw - 34px) / 5)!important;
    bottom:calc(13px + env(safe-area-inset-bottom,0px))!important;
  }
}
@media (max-width:370px) {
  #app #mangaGrid[data-layout="details"] .media-card .card-actions {
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  #app #mangaGrid[data-layout="details"] .media-card .card-actions > :is(button,a) {
    font-size:11px!important;
    padding-inline:5px!important;
  }
  #app #mangaGrid[data-layout="details"] .media-card .card-actions > button.plus {
    font-size:11px!important;
  }
}


/* Manga phone-width: contain quick filters and library mode selector.
   The chip strip scrolls within its own width instead of expanding the page. */
@media (max-width:690px) {
  #app #page-manga {
    min-width:0;
    max-width:100%;
    overflow-x:clip;
  }
  #app #page-manga .studio-theme-row {
    box-sizing:border-box;
    width:100%;
    min-width:0;
    max-width:100%;
    overflow:hidden;
  }
  #app #page-manga #mangaChips {
    box-sizing:border-box;
    display:flex;
    flex-wrap:nowrap;
    width:100%;
    min-width:0;
    max-width:100%;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior-x:contain;
    touch-action:pan-x;
    scroll-padding-inline:8px;
    padding:3px 2px 8px;
  }
  #app #page-manga #mangaChips > .chip {
    flex:0 0 auto;
    max-width:none;
  }
  /* On narrow phones, the mode switch gets its own line instead of
     competing with the heading for horizontal space. */
  #app #page-manga > .section-head h2 {
    flex:1 1 100%;
    min-width:0;
  }
  #app #page-manga > .section-head .sk-library-switch {
    margin-left:0!important;
    min-width:0;
    max-width:100%;
    flex:0 1 auto;
  }
  #app #page-manga > .section-head .sk-library-switch button[data-mode] {
    min-width:0;
    padding-inline:clamp(8px,2.7vw,13px);
  }
  #app #page-manga > .section-head .tiny {
    min-width:0;
    max-width:100%;
    white-space:normal;
  }
}


/* Mobile Manga: the Copertine/Dettagli/Compatta control must occupy the full
   width beneath the heading, never remain half-width or shifted left. */
@media(max-width:690px){
 #app #page-manga > .section-head{box-sizing:border-box;display:grid!important;grid-template-columns:minmax(0,1fr)!important;align-items:stretch;gap:10px;width:100%;max-width:100%;min-width:0}
 #app #page-manga > .section-head > h2{grid-column:1;width:100%;max-width:100%;min-width:0;margin:0}
 #app #page-manga > .section-head > .sk-library-switch{box-sizing:border-box;grid-column:1;display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(44px,.62fr)!important;align-items:stretch;width:100%!important;max-width:100%!important;min-width:0!important;margin:0!important;padding:5px;gap:5px}
 #app #page-manga > .section-head > .sk-library-switch > button[data-mode]{box-sizing:border-box;width:100%!important;min-width:0!important;max-width:100%!important;height:44px!important;min-height:44px!important;padding:6px 5px!important;font-size:clamp(11px,3vw,13px)!important;text-align:center}
 #app #page-manga > .section-head > .sk-library-switch > .sk-layout-compact{width:100%!important;min-width:0!important;padding:6px!important}
 #app #page-manga > .section-head > .sk-library-switch-caption{display:none!important}
 #app #page-manga > .section-head > .tiny{grid-column:1;min-width:0;max-width:100%;margin:0}
}

/* STORYVERSE_MANGA_SWITCH_ALIGNMENT_V2
   Same heading/segmented-selector relationship as the Anime page.
   Reverses earlier manga-only full-width mode bar, without affecting chips,
   square details cards, or the dock/menu safeguards above. */
@media(max-width:690px){
 #app #page-manga > .section-head{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) max-content!important;
  grid-template-rows:auto auto!important;
  column-gap:8px!important;
  row-gap:6px!important;
  align-items:center!important;
  box-sizing:border-box!important;
  width:100%!important;min-width:0!important;max-width:100%!important;
  margin-block:23px 11px!important;
 }
 #app #page-manga > .section-head > h2{
  grid-column:1!important;grid-row:1!important;
  min-width:0!important;width:auto!important;max-width:100%!important;
  flex:none!important;margin:0!important;
  font-size:clamp(16px,4.3vw,22px)!important;line-height:1.2!important;
  overflow-wrap:normal!important;
 }
 #app #page-manga > .section-head > .sk-library-switch{
  grid-column:2!important;grid-row:1!important;
  display:grid!important;
  grid-template-columns:minmax(0,82px) minmax(0,74px) 39px!important;
  column-gap:3px!important;
  justify-self:end!important;align-self:center!important;
  width:max-content!important;max-width:100%!important;min-width:0!important;
  margin:0!important;padding:4px!important;
  border-radius:13px!important;overflow:visible!important;
 }
 #app #page-manga > .section-head > .sk-library-switch > button[data-mode]{
  box-sizing:border-box!important;
  min-width:0!important;max-width:100%!important;width:100%!important;
  min-height:39px!important;height:39px!important;
  padding:5px 6px!important;
  font-size:11px!important;font-weight:800!important;
  white-space:nowrap!important;
 }
 #app #page-manga > .section-head > .sk-library-switch > .sk-layout-compact{
  width:39px!important;min-width:39px!important;max-width:39px!important;
  padding:6px!important;
 }
 #app #page-manga > .section-head > .sk-library-switch-caption{display:none!important}
 #app #page-manga > .section-head > .tiny{
  grid-column:1/-1!important;grid-row:2!important;
  display:block!important;width:100%!important;
  margin:0!important;min-width:0!important;max-width:100%!important;
  order:0!important;line-height:1.45!important;
 }
}
@media(max-width:360px){
 #app #page-manga > .section-head{
  grid-template-columns:minmax(0,1fr) max-content!important;
  column-gap:6px!important;
 }
 #app #page-manga > .section-head > .sk-library-switch{
  grid-template-columns:70px 67px 35px!important;
  gap:2px!important;padding:3px!important;
 }
 #app #page-manga > .section-head > .sk-library-switch > button[data-mode]{
  font-size:10px!important;min-height:37px!important;height:37px!important;
  padding:4px!important;
 }
 #app #page-manga > .section-head > .sk-library-switch > .sk-layout-compact{
  width:35px!important;min-width:35px!important;max-width:35px!important;
 }
}
