/* HTNS Songbook r36 — deterministic bottom toolbar fix.
   Do not rely on vh/svh/dvh or nested fixed positioning on iOS.
   The Songbook viewer itself owns the viewport and the toolbar is absolutely
   anchored to the viewer's bottom edge. */

@media (max-width:719px){
  html.htns-theme-v234 body #modal:has(.modal.htns-songbook-modal),
  html.htns-theme-v234 body #modal .modal.htns-songbook-modal,
  html.htns-theme-v234 body #modal .modal.htns-songbook-modal .sheet.htns-songbook-sheet{
    position:fixed!important;
    top:0!important;
    right:0!important;
    bottom:0!important;
    left:0!important;
    inset:0!important;
    width:auto!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    padding:0!important;
    transform:none!important;
    translate:none!important;
    scale:none!important;
    rotate:none!important;
    filter:none!important;
    perspective:none!important;
    contain:none!important;
    will-change:auto!important;
    overflow:hidden!important;
  }

  html.htns-theme-v234 body #modal .modal.htns-songbook-modal{
    display:block!important;
    align-items:initial!important;
    justify-content:initial!important;
  }

  html.htns-theme-v234 body #modal .modal.htns-songbook-modal .sheet.htns-songbook-sheet{
    border-radius:0!important;
    border:0!important;
  }

  html.htns-theme-v234 body #modal .modal.htns-songbook-modal .htns-songbook-screen,
  html.htns-theme-v234 body #modal .modal.htns-songbook-modal .htns-songbook-viewer{
    position:absolute!important;
    top:0!important;
    right:0!important;
    bottom:0!important;
    left:0!important;
    inset:0!important;
    width:auto!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    transform:none!important;
    contain:none!important;
    overflow:hidden!important;
  }

  /* The scrolling stage remains the only scrolling surface. */
  html.htns-theme-v234 body #modal .htns-songbook-viewer .htns-songbook-viewer-stage{
    min-height:0!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
  }

  /* Critical fix: absolute, not fixed. This makes the viewer the single
     containing block and guarantees bottom:0 is the actual Songbook viewport
     bottom instead of an iOS nested-fixed/layout-viewport bottom. */
  html.htns-theme-v234 body #modal .htns-songbook-viewer .htns-songbook-viewer-controls{
    position:absolute!important;
    left:0!important;
    right:0!important;
    bottom:0!important;
    top:auto!important;
    width:100%!important;
    max-width:none!important;
    margin:0!important;
    transform:none!important;
    box-sizing:border-box!important;
    padding:6px 7px calc(7px + env(safe-area-inset-bottom))!important;
    border-left:0!important;
    border-right:0!important;
    border-bottom:0!important;
    border-radius:20px 20px 0 0!important;
    z-index:1000!important;
  }

  /* Lyrics/chords must always be able to clear the dock. */
  html.htns-theme-v234 body #modal .htns-songbook-viewer .htns-songbook-viewer-stage-inner{
    padding-bottom:calc(148px + env(safe-area-inset-bottom))!important;
  }
}

/* Landscape/short iPhones use the same deterministic bottom anchor. */
@media (max-width:719px) and (max-height:520px){
  html.htns-theme-v234 body #modal .htns-songbook-viewer .htns-songbook-viewer-controls{
    padding-top:4px!important;
    padding-bottom:calc(4px + env(safe-area-inset-bottom))!important;
  }
  html.htns-theme-v234 body #modal .htns-songbook-viewer .htns-songbook-viewer-stage-inner{
    padding-bottom:calc(118px + env(safe-area-inset-bottom))!important;
  }
}
