/* small_phone_patch.css
   Ultra-small phones (≈300px wide) — prevent overlaps and clipped UI.
   Load LAST on every page.
*/

body, .wrap, .panel, .card, .item, .rowItem, .sub, .hint, .msg{
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ---------- Shell header/footer ---------- */
@media (max-width: 360px){
  .bxTop{
    padding: 10px 10px;
    gap: 8px;
  }

  .bxIconBtn{
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .bxLogo{
    width: 34px;
    height: 34px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 34px;
  }

  .bxLeft{ gap: 8px; }
  .bxRight{ gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

  .bxPill{
    padding: 6px 10px;
    font-size: 11px;
    max-width: 52vw;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  .bxMeta .bxT2{
    font-size: 12px;
    max-width: 42vw;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  .bxDrawerPanel{
    width: min(92vw, 340px);
    left: 6px;
    top: 6px;
    bottom: 6px;
  }

  .bxFoot{
    padding: 8px 10px;
    gap: 8px;
  }
}

/* ---------- Global tightening ---------- */
@media (max-width: 360px){
  .wrap{ padding: 10px; }
  .panel{ padding: 10px; border-radius: 16px; }
  .card{ padding: 10px; border-radius: 16px; }

  h1{ font-size: 16px; }
  h2{ font-size: 14px; }

  .sub, .hint, .small, .lbl, .t2{ font-size: 12px; }
}

/* ---------- Buttons/rows stack instead of overlap ---------- */
@media (max-width: 360px){
  .row, .row2, .actions, .filters, .actionsRow, .heroActions, .remRow, .deckActions{
    flex-direction: column;
    align-items: stretch;
  }

  .btn, .pill, .qa{
    width: 100%;
    text-align: center;
  }

  .input, select, textarea{
    width: 100%;
  }
}

/* ---------- Grids collapse to one column ---------- */
@media (max-width: 360px){
  .grid4{ grid-template-columns: 1fr !important; }
  .qaGrid{ grid-template-columns: 1fr !important; }
  .summaryGrid{ grid-template-columns: 1fr !important; }
  .grid2{ grid-template-columns: 1fr !important; }
}

/* ---------- Sheets / modals ---------- */
@media (max-width: 360px){
  .sheetInner{
    width: 94vw !important;
    max-height: 70vh !important;
    padding: 10px !important;
    border-radius: 16px !important;
  }

  .sheetTitle{
    font-size: 14px !important;
  }

  .iconBtn{
    width: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
  }
}

/* ---------- Review card readability ---------- */
@media (max-width: 360px){
  .cardArea .card{
    width: 94vw !important;
    min-height: 62vh !important;
    padding: 14px !important;
  }
  .cardArea .content{
    font-size: 17px !important;
    line-height: 1.6 !important;
  }
}

/* ---------- Extra tiny (≤320px) ---------- */
@media (max-width: 320px){
  .bxPill{ max-width: 48vw; }
  .bxMeta .bxT2{ max-width: 38vw; }
  .btn, .pill{ padding: 9px 10px; }
}

/* =========================================================
   FIX: ViewerSheet compact + still closable (modal safe)
   ========================================================= */

/* Ensure modal takes the full viewport and respects aria-hidden */
#viewerSheet.sheet{
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  padding: 10px !important;
  align-items: center !important;
  justify-content: center !important;
}

#viewerSheet.sheet[aria-hidden="true"]{
  display: none !important;           /* ✅ fully gone when hidden */
  pointer-events: none !important;
}

#viewerSheet.sheet[aria-hidden="false"]{
  display: flex !important;           /* ✅ visible when open */
  pointer-events: auto !important;
}

/* Backdrop must cover screen and be clickable */
#viewerSheet .sheetBackdrop{
  position: absolute !important;
  inset: 0 !important;
  z-index: 1 !important;
  pointer-events: auto !important;
}

/* Inner panel above backdrop */
#viewerSheet .sheetInner{
  position: relative !important;
  z-index: 2 !important;
  pointer-events: auto !important;

  width: min(520px, 94vw) !important;
  max-height: min(320px, 45vh) !important;   /* ✅ shorter */
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;

  padding: 10px !important;
  border-radius: 16px !important;
}

/* Tight header */
#viewerSheet .sheetTop{
  padding: 4px 0 8px !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 3 !important;
  background: inherit !important;
}

/* Dense button grid */
#viewerSheet .grid2{
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 6px !important;
  margin-top: 6px !important;
}

@media (max-width: 520px){
  #viewerSheet .grid2{
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* Compact buttons */
#viewerSheet .pill{
  padding: 7px 8px !important;
  font-size: 12px !important;
  line-height: 1.05 !important;
  border-radius: 12px !important;
  min-height: 34px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Page jump row: compact, wraps safely */
#viewerSheet #pageJumpForm{
  display:flex !important;
  align-items:center !important;
  gap: 8px !important;
  margin-top: 8px !important;
  flex-wrap: wrap !important;
}

#viewerSheet #pageJump{
  width: 84px !important;
  min-width: 74px !important;
}

#viewerSheet .smallLbl{
  min-width: 74px !important;
  font-size: 12px !important;
}

#viewerSheet .tiny{
  margin-top: 6px !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
}
