/* Shared layout constraints. Content wraps instead of escaping or being clipped. */
html body [hidden]:not([hidden="until-found"]),
#tagBrowser[hidden],#uploadTagBrowser[hidden],#maintenanceTagBrowser[hidden],#rqPickerTagBrowser[hidden]{display:none!important}
*,*::before,*::after{box-sizing:border-box}
body :is(main,section,article,aside,form,fieldset,label){min-width:0}
body :is(h1,h2,h3,p,label,.creator-handle,.creator-name-copy,.nav-user strong,.mobile-account-copy strong){overflow-wrap:anywhere}
body :is(button,.btn,.creator-studio-action,.rq-primary-button,.rq-secondary-button,.ca-button){max-width:100%;white-space:normal;overflow-wrap:anywhere}
body :is(input,select,textarea){min-width:0;max-width:100%}
body :is(.auth-form,.admin-form,.settings-card) :is(input:not([type=checkbox]):not([type=radio]):not([type=color]),select,textarea){width:100%}
body :is(.page-header,.section-heading,.creator-name-line,.creator-studio-actions,.creator-module-head-actions,.profile-avatar-actions){flex-wrap:wrap;gap:12px}
body :is(.page-header,.section-heading)>div{min-width:0}
body :is(.auth-error,.registration-notice,.validation-modal-message,.custom-file-name){overflow-wrap:anywhere}
body .settings-card{grid-template-columns:minmax(0,1fr);align-content:start}
body .account-settings-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
body .profile-avatar-settings{display:flex;flex-wrap:wrap;align-items:center;gap:16px;min-width:0}
body .profile-avatar-settings .settings-avatar{display:block;width:88px;height:88px;max-width:88px;flex:0 0 88px;object-fit:cover;border-radius:50%}
body .profile-avatar-settings .creator-avatar-fallback{display:grid;place-items:center;font-size:32px;background:#e8edf8}
body .profile-avatar-actions{display:flex;flex-wrap:wrap;flex:1 1 180px;min-width:0}
body .profile-avatar-actions .custom-file-name{flex:1 1 120px;min-width:0;white-space:normal}
body .creator-name-copy{max-width:100%;min-width:0}
body .creator-name-line{display:flex;align-items:center;min-width:0}
body .creator-name-line h1{min-width:0;flex:1 1 140px}
body .creator-handle{white-space:normal}
body .profile-email{display:block;padding:12px;border:1px solid #d9d8e8;border-radius:14px;background:#fcfcff;line-height:1.5;overflow-wrap:anywhere}
body .creator-tabs{height:auto;min-height:52px;flex-wrap:wrap;gap:4px}
body .creator-tabs button{flex:1 1 80px;min-width:0;line-height:1.4}
body .creator-tabs button.active::after{display:none}
body .creator-stats{flex-wrap:wrap;gap:12px 20px}
body .creator-studio-layout>*{min-width:0}
body .creator-add-card{min-width:0;grid-template-columns:42px minmax(0,1fr) 18px}
body .creator-add-card :is(span,strong,small){min-width:0;white-space:normal;overflow-wrap:anywhere}
body .creator-theme-presets{grid-template-columns:repeat(auto-fit,minmax(min(100%,90px),1fr))}
body .creator-theme-preset{min-width:0;white-space:normal;overflow-wrap:anywhere;height:auto;min-height:64px}
body .creator-phone-frame{max-width:100%}
body :is(.mini-apps-hero,.upload-banner,.personal-page-hero){overflow:hidden}
body :is(.maintenance-modal-card,.validation-modal-card,.ui-dialog-card){max-width:calc(100vw - 24px);max-height:calc(100dvh - 24px);overflow-y:auto;overflow-wrap:anywhere}
body :is(.maintenance-actions,.maintenance-toolbar,.upload-draft-resume-actions,.ui-dialog-actions){display:flex;flex-wrap:wrap;gap:10px}
body :is(.maintenance-actions,.maintenance-toolbar,.upload-draft-resume-actions,.ui-dialog-actions)>*{min-width:0;max-width:100%}
@media(max-width:1200px){
  body[data-page="creator_editor"] .creator-studio-layout{grid-template-columns:minmax(0,1fr)!important}
  body[data-page="creator_editor"] .creator-studio-preview{position:static;max-width:410px;width:100%;justify-self:center}
  body .account-settings-profile-only .account-settings-grid{grid-template-columns:minmax(0,1fr)}
}
@media(max-width:760px){
  body :is(.page-header,.section-card,.account-settings){padding:20px!important}
  body .creator-profile-head{gap:14px;padding:20px!important;align-items:flex-start}
  body .creator-profile-main{flex:1 1 0;min-width:0}
  body .creator-name-line h1{font-size:clamp(22px,5.5vw,28px);flex-basis:100%;margin:0}
  body .creator-handle{font-size:13px;line-height:1.5}
  body .creator-stats{gap:8px 14px}
  body .creator-name-line{gap:8px}
  body .creator-profile-card-entry{margin:0}
  body .page-header-actions{margin-left:0;max-width:100%}
  body #nav .mobile-account-copy{min-width:0}
  body #nav .nav-section{max-width:calc(100vw - 24px)}
  body .creator-studio-actions{width:100%;display:flex}
  body .creator-studio-actions>a{flex:1 1 130px;text-align:center}
  body .creator-theme-grid-compact{grid-template-columns:minmax(0,1fr)!important}
}
@media(max-width:360px){
  body .creator-profile-head{flex-wrap:wrap}
  body .creator-profile-main{flex-basis:100%}
  body .creator-name-line h1{flex-basis:140px}
  body .creator-add-row{grid-template-columns:minmax(0,1fr)!important}
}

/* Container geometry owns spacing; legacy themes must not remove one side. */
html body[data-page] main>.page-header{
  height:auto!important;min-height:108px;max-height:none!important;
  padding:24px 32px!important;align-items:center!important;gap:20px!important;
}
html body[data-page] .page-header>div:first-child{display:flex;flex-direction:column;justify-content:center;gap:8px}
html body[data-page] .page-header :is(h1,.page-subtitle,.page-kicker){margin:0!important;line-height:1.35}
html body[data-page] .page-header-actions{display:flex;align-items:center;justify-content:center;align-self:center;margin:0!important;flex:0 0 auto}
html[data-pt-style] body #lang,html body #lang{
  appearance:none;display:block;min-height:44px;height:44px!important;width:120px!important;
  padding:10px 28px!important;margin:0!important;line-height:24px!important;
  text-align:center;text-align-last:center;font-size:14px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4 3 3 3-3' fill='none' stroke='%23504365' stroke-width='1.5'/%3E%3C/svg%3E")!important;
  background-repeat:no-repeat!important;background-position:right 10px center!important;
}
html body[data-page="profile"] .creator-profile-head{padding:32px!important;margin-bottom:24px!important;height:auto!important;gap:28px;align-items:center}
html body[data-page="profile"] .creator-avatar-wrap{height:auto!important;min-height:0!important;max-height:none!important;justify-content:flex-start!important;align-self:center}
html body[data-page="profile"] .creator-avatar-wrap>.creator-avatar{flex-shrink:0!important}
html body .profile-library-column>.creator-tabs{height:auto!important;min-height:60px!important;padding:8px!important;align-items:stretch}
html body .creator-tabs>button{display:flex;align-items:center;justify-content:center;height:auto!important;min-height:44px!important;padding:10px 16px!important;margin:0!important;line-height:1.4!important;text-align:center}
html body #nav .nav-user{width:auto!important;min-width:0!important;max-width:none!important;overflow:visible!important;height:auto!important}
html body #nav .nav-user>a{min-width:0;max-width:100%;align-items:center;gap:10px!important}
html body #nav .nav-user>a>span:last-child{min-width:0;width:auto!important;max-width:none!important;flex:1 1 auto}
html body #nav .nav-user strong{white-space:normal!important;text-overflow:clip!important;overflow:visible!important;max-width:none!important;line-height:1.4!important;font-size:14px!important}
@media(min-width:1200px){
  html body #nav .nav-footer{flex:0 0 auto!important;width:auto!important;gap:12px}
  html body #nav .nav-user{flex:0 0 auto!important;width:180px!important}
  html body #nav .nav-user>a{width:100%!important}
}

/* Every modal uses one inset for both axes, including native/dynamic dialogs. */
:root{--dialog-inset:24px;--dialog-control:44px}
html body :is(.maintenance-modal-card,.edit-panel-card,.validation-modal-card,.upload-complete-card,.pt-ui-dialog-card,.rq-modal-card,.pt-notification-card){
  position:relative!important;padding:var(--dialog-inset)!important;
  scrollbar-gutter:auto!important;max-width:calc(100vw - 32px)!important;
  max-height:calc(100dvh - 32px)!important;min-width:0;overflow-y:auto;
}
html body :is(.edit-panel-head,.rq-modal-head,.pt-notification-head,.filename-audit-header,.ui-settings-head){
  position:relative!important;inset:auto!important;display:flex!important;align-items:center!important;
  justify-content:space-between!important;gap:16px!important;min-height:var(--dialog-control);
  padding:0!important;margin:0 0 20px!important;flex-shrink:0;
}
html body :is(.edit-panel-head,.rq-modal-head,.pt-notification-head,.filename-audit-header,.ui-settings-head)>:first-child{margin:0!important;min-width:0;flex:1}
html body :is(.edit-panel-head,.rq-modal-head,.pt-notification-head,.filename-audit-header,.ui-settings-head) :is(h2,h3){margin:0!important;line-height:1.35}
html body :is(.update-close,.pt-notification-close,.lightbox-close,.upload-lightbox-close,.rq-lightbox-close,#editClose,#lightingManageClose,#poseResultClose,#aiCharacterSearchClose,#rqSourceClose,#rqEditClose,#rqLightingClose,#videoFrameCropClose,#splitPieceCropClose){
  display:flex!important;align-items:center!important;justify-content:center!important;
  width:var(--dialog-control)!important;height:var(--dialog-control)!important;
  min-width:var(--dialog-control)!important;min-height:var(--dialog-control)!important;
  max-width:var(--dialog-control)!important;flex:0 0 var(--dialog-control)!important;
  padding:0!important;margin:0!important;font-size:24px!important;line-height:1!important;transform:none!important;
}
html body :is(.edit-panel-head,.rq-modal-head,.pt-notification-head,.filename-audit-header,.ui-settings-head)>button{position:static!important;inset:auto!important;float:none!important}
html body :is(.maintenance-modal-card,.edit-panel-card):has(>.update-close){display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:16px!important}
html body :is(.maintenance-modal-card,.edit-panel-card):has(>.update-close)>*{grid-column:1!important;min-width:0}
html body :is(.maintenance-modal-card,.edit-panel-card)>.update-close{position:sticky!important;top:0!important;right:auto!important;bottom:auto!important;left:auto!important;grid-row:1!important;justify-self:end!important;align-self:start!important;float:none!important;z-index:10}
html body :is(.maintenance-modal-card,.edit-panel-card):has(>.update-close)>:is(h2,h3):first-child{grid-row:1!important;min-height:var(--dialog-control);padding:0 60px 0 0!important;margin:0!important;display:flex;align-items:center}
html body :is(.edit-actions,.lighting-manage-actions,.pt-ui-dialog-actions,.rq-modal-actions,.maintenance-modal-card>.maintenance-actions,.validation-modal-card>.maintenance-actions){
  display:flex!important;flex-wrap:wrap!important;justify-content:flex-end;align-items:center;gap:12px!important;
  padding:0!important;margin:20px 0 0!important;flex-shrink:0;
}
html body :is(.edit-actions,.lighting-manage-actions,.pt-ui-dialog-actions,.rq-modal-actions,.maintenance-actions)>:is(button,a){margin:0!important;min-height:44px;display:inline-flex;align-items:center;justify-content:center;text-align:center;line-height:1.4}
html body :is(.maintenance-modal-card,.edit-panel-card,.validation-modal-card,.pt-ui-dialog-card,.rq-modal-card)>:last-child{margin-bottom:0!important}
html body :is(#editStatus,#lightingManageStatus,#poseResultError):empty{display:none}
html body :is(.lightbox-close,.upload-lightbox-close,.rq-lightbox-close){position:fixed!important;top:max(var(--dialog-inset),env(safe-area-inset-top),env(safe-area-inset-right))!important;right:max(var(--dialog-inset),env(safe-area-inset-top),env(safe-area-inset-right))!important;bottom:auto!important;left:auto!important}
@media(max-width:760px){
  :root{--dialog-inset:16px}
  html body[data-page] main>.page-header{padding:20px!important;gap:16px!important}
  html body[data-page="profile"] .creator-profile-head{padding:24px!important;gap:16px;align-items:flex-start}
  html body[data-page] .creator-tabs>button{padding:10px 8px!important}
}

/* Keep scrolling content inside the frame so scrollbars never displace corners. */
html body #imageMaintenanceModal .image-maintenance-card{
  grid-template-rows:auto auto minmax(0,1fr);overflow:hidden!important;
}
html body #imageMaintenanceModal .image-maintenance-options{min-height:0;overflow-y:auto}
html body #uiSettingsModal .ui-settings-card{overflow:hidden!important}
html body #uiSettingsModal .ui-settings-head{align-items:flex-start!important}
html body :is(#filenameAuditModal,#integrityAuditModal,#uiSettingsModal) .update-close{position:static!important;inset:auto!important;align-self:flex-start!important;float:none!important}
html body :is(#filenameAuditModal,#integrityAuditModal) .maintenance-modal-card{display:flex!important;flex-direction:column;overflow:hidden!important}
html body :is(#filenameAuditResults,#integrityAuditResults){min-height:0;overflow-y:auto}
html body #uiSettingsModal .ui-palette-grid{min-height:0;overflow-y:auto}
html body #updateHistoryModal.maintenance-modal:not([hidden]){padding:16px!important;align-items:center!important;justify-content:center!important}
html body #updateHistoryModal .update-history-card{
  display:grid!important;grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:auto auto minmax(0,1fr);gap:16px!important;
  padding:var(--dialog-inset)!important;width:min(820px,100%)!important;
  height:calc(100dvh - 32px)!important;max-height:calc(100dvh - 32px)!important;overflow:hidden!important;
}
html body #updateHistoryModal .update-history-card>h3{grid-row:1!important;margin:0!important}
html body #updateHistoryModal #updateHistoryLoading{grid-row:2}
html body #updateHistoryModal .update-history-list{grid-row:3;height:auto!important;min-height:0!important;overflow-y:auto!important}
html body #updateHistoryModal .update-close{top:0!important;right:auto!important}
html body .video-frames-footer{display:flex!important;flex-wrap:wrap;gap:16px;align-items:center;justify-content:space-between;margin-bottom:0!important;padding:0!important}
html body .video-frames-footer>.maintenance-actions{margin:0 0 0 auto!important;justify-content:flex-end!important}
html body :is(#updateModal,#tagLayoutModal) .maintenance-actions{justify-content:flex-end!important}
html body .rq-modal-head{align-items:flex-start!important}
html body #rqLightingModal .rq-modal-card{display:flex;flex-direction:column;gap:16px}
html body #rqLightingClose{position:static!important;align-self:flex-end!important}
html body .cl-sample-dialog{padding:var(--dialog-inset)!important;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto}
html body .cl-sample-dialog .ca-section-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin:0 0 20px;padding:0}
html body .cl-sample-dialog .ca-section-heading h3{margin:0}
html body .cl-sample-dialog .ca-toolbar{justify-content:flex-end;margin-bottom:0;padding:0}
html body .maintenance-menu-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr))}
html body .maintenance-menu-grid>*{min-width:0;width:100%}
html body #creatorCardOpacity{margin-inline:0;width:100%;max-width:100%}
/* Reserve the gallery scrollbar before JavaScript calculates exact-fit rows. */
html body #grid{scrollbar-gutter:stable}

html body [data-dialog-geometry="true"]{
  display:flex!important;flex-direction:column!important;gap:16px!important;
  height:auto!important;max-height:calc(100dvh - 32px)!important;overflow:hidden!important;
}
html body [data-dialog-geometry]>.dialog-fixed-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex:0 0 auto;min-width:0;margin:0!important}
html body [data-dialog-geometry]>.dialog-fixed-head>:first-child{flex:1;min-width:0;margin:0!important}
html body [data-dialog-geometry] .dialog-fixed-head :is(.edit-panel-head,.pt-notification-head,.split-piece-crop-head,.rq-modal-head,.video-frames-head){width:100%;margin:0!important;align-items:flex-start!important}
html body [data-dialog-geometry] .dialog-fixed-head .update-close{position:static!important;inset:auto!important;align-self:flex-start!important}
html body [data-dialog-geometry]>.dialog-scroll-body{flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;padding:0;margin:0!important}
html body [data-dialog-geometry]>.dialog-scroll-body>:first-child{margin-top:0!important}
html body [data-dialog-geometry]>.dialog-scroll-body>:last-child{margin-bottom:0!important}
html body [data-dialog-geometry]>.dialog-fixed-actions{flex:0 0 auto;display:flex!important;flex-wrap:wrap;align-items:center;justify-content:flex-end!important;gap:12px;margin:0!important;padding:0!important}
html body [data-dialog-geometry] .dialog-fixed-actions .maintenance-actions{margin:0!important}
html body .video-frames-footer.dialog-fixed-actions{flex-direction:row!important}
