/* PulseBoard V18 — viewport-centered dialogs and modal surfaces. */
:root{
  --pb18-modal-gutter:clamp(10px,2.2vw,24px);
  --pb18-modal-max-height:calc(100dvh - (var(--pb18-modal-gutter) * 2));
}

/* Native admin dialogs fill the top layer, then center their card. */
dialog.bulk-dialog[open]{
  position:fixed!important;
  inset:0!important;
  width:100vw!important;
  max-width:none!important;
  height:100dvh!important;
  max-height:none!important;
  margin:0!important;
  padding:max(var(--pb18-modal-gutter),env(safe-area-inset-top))
          max(var(--pb18-modal-gutter),env(safe-area-inset-right))
          max(var(--pb18-modal-gutter),env(safe-area-inset-bottom))
          max(var(--pb18-modal-gutter),env(safe-area-inset-left))!important;
  border:0!important;
  background:transparent!important;
  overflow:auto!important;
  box-sizing:border-box!important;
  display:grid!important;
  place-items:center!important;
  align-content:center!important;
  justify-content:center!important;
}
dialog.bulk-dialog[open]::backdrop{
  background:rgba(1,8,12,.82)!important;
}
dialog.bulk-dialog[open]>.bulk-card{
  position:relative!important;
  inset:auto!important;
  width:min(760px,calc(100vw - (var(--pb18-modal-gutter) * 2)))!important;
  max-width:100%!important;
  max-height:var(--pb18-modal-max-height)!important;
  margin:auto!important;
  overflow:auto!important;
  overscroll-behavior:contain;
  box-sizing:border-box!important;
  align-self:center!important;
  justify-self:center!important;
}
dialog#socialDialog[open]>.bulk-card.social-dialog-card{
  width:min(980px,calc(100vw - (var(--pb18-modal-gutter) * 2)))!important;
  max-height:var(--pb18-modal-max-height)!important;
  margin:auto!important;
}

/* Custom full-screen modal shells. */
.motion-flow-modal,
.dev-token-modal,
.pulse-trigger-modal,
.pdf-viewer,
.pb-video-modal-shell,
.story-compose-overlay{
  align-items:center!important;
  justify-content:center!important;
  place-items:center!important;
  align-content:center!important;
  justify-items:center!important;
  padding:max(var(--pb18-modal-gutter),env(safe-area-inset-top))
          max(var(--pb18-modal-gutter),env(safe-area-inset-right))
          max(var(--pb18-modal-gutter),env(safe-area-inset-bottom))
          max(var(--pb18-modal-gutter),env(safe-area-inset-left))!important;
  overflow:auto!important;
  box-sizing:border-box!important;
}

.motion-flow-panel,
.dev-token-modal__dialog,
.pulse-trigger-modal__dialog,
.pdf-viewer__dialog,
.pb-video-modal,
.story-compose-sheet{
  margin:auto!important;
  inset:auto!important;
  align-self:center!important;
  justify-self:center!important;
  box-sizing:border-box!important;
}

.motion-flow-panel{
  width:min(960px,calc(100vw - (var(--pb18-modal-gutter) * 2)))!important;
  max-height:var(--pb18-modal-max-height)!important;
  overflow:auto!important;
}
.dev-token-modal__dialog,
.pulse-trigger-modal__dialog{
  max-height:var(--pb18-modal-max-height)!important;
  overflow:auto!important;
}
.pdf-viewer__dialog{
  width:min(1100px,calc(100vw - (var(--pb18-modal-gutter) * 2)))!important;
  height:min(900px,var(--pb18-modal-max-height))!important;
  max-height:var(--pb18-modal-max-height)!important;
}
.pb-video-modal{
  width:min(820px,calc(100vw - (var(--pb18-modal-gutter) * 2)))!important;
  max-height:var(--pb18-modal-max-height)!important;
  border-radius:22px!important;
  overflow:hidden!important;
}
.story-compose-overlay{
  inset:0!important;
  display:grid!important;
}
.story-compose-sheet{
  width:min(1220px,calc(100vw - (var(--pb18-modal-gutter) * 2)))!important;
  height:auto!important;
  max-height:var(--pb18-modal-max-height)!important;
  overflow:auto!important;
  border-radius:30px!important;
}

/* Keep close controls and headings reachable in long forms. */
.bulk-card>.bulk-head,
.social-dialog-card>.bulk-head,
.story-compose-sheet__top,
.pb-video-modal__head{
  top:0;
  z-index:8;
}

@media(max-width:760px){
  :root{--pb18-modal-gutter:10px}

  dialog.bulk-dialog[open]>.bulk-card,
  dialog#socialDialog[open]>.bulk-card.social-dialog-card{
    width:calc(100vw - 20px)!important;
    max-height:calc(100dvh - 20px)!important;
    border-radius:20px!important;
  }

  .pb-video-modal-shell{
    align-items:center!important;
    padding:10px!important;
  }
  .pb-video-modal{
    width:calc(100vw - 20px)!important;
    max-height:calc(100dvh - 20px)!important;
    border-radius:20px!important;
  }

  .story-compose-overlay{
    inset:0!important;
    padding:10px!important;
  }
  .story-compose-sheet{
    width:calc(100vw - 20px)!important;
    height:auto!important;
    max-height:calc(100dvh - 20px)!important;
    margin:auto!important;
    border:1px solid rgba(255,255,255,.1)!important;
    border-radius:22px!important;
    padding:16px!important;
  }

  .pdf-viewer__dialog{
    width:calc(100vw - 20px)!important;
    height:calc(100dvh - 20px)!important;
    max-height:calc(100dvh - 20px)!important;
  }

  .motion-flow-panel,
  .dev-token-modal__dialog,
  .pulse-trigger-modal__dialog{
    width:calc(100vw - 20px)!important;
    max-height:calc(100dvh - 20px)!important;
  }
}

@media(prefers-reduced-motion:reduce){
  .motion-flow-panel,
  .dev-token-modal__dialog,
  .pulse-trigger-modal__dialog,
  .story-compose-sheet{
    transition:none!important;
  }
}
