/* Keep Web controls reachable at normal browser zoom. */
html body dialog.post-dialog,html body dialog.workflow-dialog{box-sizing:border-box;max-width:calc(100vw - 24px)!important;max-height:calc(100dvh - 24px)!important;overflow:hidden!important;}
html body dialog.post-dialog>form,html body dialog.workflow-dialog>form{box-sizing:border-box;max-height:calc(100dvh - 28px)!important;overflow:auto!important;min-width:0;}
html body .post-submit-row{position:sticky;bottom:0;z-index:5;flex-wrap:wrap;gap:8px;background:var(--panel,#fff);padding:12px 0;margin-bottom:0;}
html body .post-submit-row button{min-width:0;max-width:100%;flex-shrink:0;}
html body dialog.ai-studio-dialog[open]{display:flex;flex-direction:column;max-height:calc(100dvh - 24px);overflow:hidden;}
html body .ai-studio-dialog .ai-studio-header,html body .ai-studio-dialog .ai-studio-tabs{flex-shrink:0;}
html body .ai-studio-dialog .ai-studio-body{flex:1;min-height:0;max-height:none;overflow:auto;}
#calendar .calendar-head,#calendar .calendar-head>div{min-width:0;flex-wrap:wrap;}
#calendar .calendar-actions{display:flex!important;flex-wrap:wrap!important;gap:8px!important;}
#calendar .calendar-actions>button{width:auto!important;flex:0 1 auto!important;min-width:100px;}
@media(max-width:900px){html body .post-compose-grid,html body .workflow-grid{grid-template-columns:minmax(0,1fr)!important;}html body .post-submit-row{justify-content:flex-end;}}

/* A bounded popup, one scrolling body, and actions outside that scroll area. */
html body dialog.web-popup-fit,html body dialog.ai-studio-dialog{
 width:min(1120px,calc(100vw - 64px))!important;
 height:min(840px,calc(100dvh - 64px))!important;
 max-width:calc(100vw - 64px)!important;max-height:calc(100dvh - 64px)!important;
 min-width:0!important;min-height:0!important;margin:auto!important;padding:0!important;
 border-radius:14px;overflow:hidden!important;box-sizing:border-box;
}
html body dialog.web-popup-fit > form{
 display:flex!important;flex-direction:column!important;height:100%!important;max-height:100%!important;
 min-height:0!important;min-width:0!important;overflow:hidden!important;padding:0!important;margin:0!important;
}
html body dialog.web-popup-fit .web-popup-scroll{
 flex:1 1 0;min-height:0;min-width:0;overflow:auto;padding:18px 22px;
 overscroll-behavior:contain;scrollbar-gutter:stable;scroll-padding:16px;
}
html body dialog.web-popup-fit .post-dialog-head,html body dialog.web-popup-fit .post-submit-row{
 flex:0 0 auto!important;position:relative!important;padding:14px 22px!important;margin:0!important;
 background:var(--panel,#fff);gap:10px;min-width:0;
}
html body dialog.web-popup-fit .post-submit-row{border-top:1px solid var(--line,#c6d9d0);}
html body dialog.web-popup-fit .post-submit-row>div{display:flex;flex-wrap:wrap;gap:8px;}
/* The outer popup body owns review scrolling. The review-mode ID rule in
   post-review.css must not create a second, wheel-trapping scroll container. */
#postDialog.web-popup-fit.post-review-mode .post-review-overview{
 max-height:none;overflow:visible;overscroll-behavior:auto;scrollbar-gutter:auto;
 margin:0;min-width:0;
}
html body dialog.web-popup-fit .post-playback-preview img,html body dialog.web-popup-fit .post-playback-preview video{
 width:auto;max-width:100%;height:auto;max-height:30dvh;object-fit:contain;
}
html body dialog.ai-studio-dialog[open]{display:flex!important;flex-direction:column;}
html body dialog.ai-studio-dialog .ai-studio-header{padding:16px 22px;}
html body dialog.ai-studio-dialog .ai-studio-tabs{padding:10px 22px;flex-wrap:wrap;gap:6px;}
html body dialog.ai-studio-dialog .ai-studio-body{flex:1 1 0;min-height:0;overflow:auto;padding:18px 22px;scrollbar-gutter:stable;overscroll-behavior:contain;}
html body dialog.ai-studio-dialog .ai-template-actions,html body dialog.ai-studio-dialog .ai-create-actions{
 position:sticky;bottom:-18px;z-index:5;background:var(--panel,#fff);padding:12px 0;
 border-top:1px solid var(--border,#c6d9d0);display:flex;gap:12px;align-items:center;flex-wrap:wrap;flex-basis:100%;
}
html body dialog.ai-studio-dialog .ai-create-actions p{flex:1;font-size:13px;}
@media(max-width:760px){
 html body dialog.web-popup-fit,html body dialog.ai-studio-dialog{width:calc(100vw - 32px)!important;max-width:calc(100vw - 32px)!important;height:calc(100dvh - 32px)!important;max-height:calc(100dvh - 32px)!important;}
 html body dialog.web-popup-fit .web-popup-scroll,html body dialog.ai-studio-dialog .ai-studio-body{padding:14px;}
 html body dialog.web-popup-fit .post-dialog-head,html body dialog.web-popup-fit .post-submit-row,html body dialog.ai-studio-dialog .ai-studio-header{padding:12px 14px!important;}
 html body dialog.ai-studio-dialog .ai-studio-tabs{padding:8px 14px;}
 html body dialog.ai-studio-dialog .ai-fields{grid-template-columns:minmax(0,1fr);}
}
@media(max-width:760px){html body dialog.ai-studio-dialog .ai-template-actions,html body dialog.ai-studio-dialog .ai-create-actions{bottom:-14px;}}
