/* The only owner of viewport height and device safe areas. See FULLSCREEN.md. */
:root{
  --app-canvas:#0b0b0c;
  --app-safe-top:env(safe-area-inset-top,0px);
  --app-safe-bottom:env(safe-area-inset-bottom,0px);
  --app-bottom-shortfall:0px;
  --app-dock-clearance:0px;
  --app-chat-clearance:0px;
}
html,body{height:100%;min-height:0;margin:0;padding:0;background:var(--app-canvas)!important}
html[data-app-physical-portrait=true],html[data-app-physical-portrait=true] body{height:var(--app-height);min-height:0;max-height:none}
#app{
  position:fixed;inset:0;width:100%;height:var(--app-height,100%);height:100dvh;height:var(--app-height,100dvh);
  min-height:0;max-height:none;margin:0;padding:0;box-sizing:border-box;background:var(--app-canvas);transform:none!important;
}
/* Viewer chrome and the installed status bar sample the same black canvas in
   either theme. The normal install canvas remains owned by --app-canvas. */
html[data-app-immersive=true],html[data-app-immersive=true] body,html[data-app-immersive=true] #app{background:#000!important}
/* The installed fixed frame stays opaque; preference changes must not replay its auth intro. */
html[data-app-standalone=true] #app{animation:none!important}
html[data-app-keyboard=true] #app{top:var(--app-offset-top,0px)}
#app>.app-shell{height:100%!important;min-height:0;max-height:none!important;overflow:hidden}
#app .workspace{min-height:0;overflow:hidden}
#app .workspace-body{position:relative;inset:auto;flex:1;min-height:0;max-height:none;margin:0;box-sizing:border-box;padding-bottom:0}
#app #adstudioh-cold-wall{position:absolute;inset:0;height:100%;min-height:0;max-height:none;margin:0;padding:0;box-sizing:border-box}
@media(max-width:768px),(display-mode:standalone){
  html,body{overflow:hidden;overscroll-behavior:none}
  #app:has(#adstudioh-cold-wall:not([hidden])) .workspace-bar{display:none!important}
  #app .workspace-body:has(#adstudioh-cold-wall:not([hidden])){overflow:hidden}
  /* Exactly one active header receives the top device inset. The approved row
     retains it while a native modal owns it outside the app subtree. */
  :is(#app .workspace>.workspace-bar,.browse-studio-head,#app .inspo-focus-nav,#app .inspo-focus-page-head,
      #app .inspo-viewer-bar,.brand-authority-dialog>header,.sidebar.open .sidebar-head,
      #app .inspo-cosmos-band-inner,.browse-studio-launch-head,.app-modal-header){
    padding-top:calc(var(--app-header-gap,8px) + var(--app-safe-top))!important;
    box-sizing:border-box;
  }
  #app .workspace>.workspace-bar{--app-header-gap:2px;min-height:calc(48px + var(--app-safe-top));max-height:none}
  #app .inspo-focus-nav{--app-header-gap:0px;min-height:calc(48px + var(--app-safe-top));max-height:none}
  #app #inspiration .inspo-focus-page-head{--app-header-gap:6px;min-height:calc(62px + var(--app-safe-top))}
  .brand-authority-dialog>header{--app-header-gap:12px}
  .sidebar.open .sidebar-head{--app-header-gap:18px}
  .app-modal-header{--app-header-gap:0px}
  html[data-app-keyboard=true] .browse-studio-launch-head{--app-header-gap:0px}
  #app #inspiration .inspo-cosmos-band-inner{--app-header-gap:0px;height:max(92px,calc(44px + var(--app-safe-top)))}
  :is(#app .inspo-cosmos-detail:not(:has(.inspo-cosmos-approved-head)) .inspo-cosmos-head,
      #app .inspo-topic-wall:not(:has(.inspo-topic-approved-head)) .inspo-topic-head){
    --app-header-gap:16px;padding-top:calc(var(--app-header-gap) + var(--app-safe-top));
  }
  /* Fixed controls use the layout viewport even when the app paints farther.
     Subtract only its shortfall, so the glass still ends one device inset
     above the physical display edge. The child pill/up controls move with it. */
  body :is(.browse-studio-dock,.browse-studio-detail-dock,.mobile-studio-dock),#inspiration>.inspo-dock{bottom:calc(var(--app-safe-bottom) - var(--app-bottom-shortfall))!important}
  .inspo-brands-az-scrubber{bottom:calc(var(--app-dock-clearance) + 10px - var(--app-bottom-shortfall))!important}
  body.browse-studio .inspo-brands-az-scrubber{bottom:calc(var(--app-dock-clearance) + 12px - var(--app-bottom-shortfall))!important}
  .skeleton-result-alert{bottom:calc(var(--app-offset-bottom,0px) + var(--app-dock-clearance) + 16px - var(--app-bottom-shortfall))!important}
  [data-skeleton-result-error]:not(.skeleton-result-alert){bottom:calc(100px - var(--app-bottom-shortfall))!important}
  :is(.toast,.adstudioh-action-toast){bottom:calc(22px - var(--app-bottom-shortfall))!important}
  :is(.recon-qa-panel,.vsm-panel,.typo-panel,.vc-panel){bottom:calc(16px - var(--app-bottom-shortfall))!important}
  /* These sheets are in the top layer, outside the inherited app frame.
     Keyboard positioning below remains their sole keyboard-frame anchor. */
  html:not([data-app-keyboard=true]) :is(#inspiration .inspo-dialog.inspo-action-sheet,#inspiration dialog.inspo-cosmos-extras,dialog.skeleton-result-sheet){bottom:calc(0px - var(--app-bottom-shortfall))!important}
  html[data-app-keyboard=true] :is(.browse-studio-dock,.browse-studio-detail-dock,.mobile-studio-dock,#inspiration>.inspo-dock){display:none!important;pointer-events:none}
  /* Top-layer dialogs do not inherit the fixed app root's keyboard frame. */
  html[data-app-keyboard=true] dialog[open],
  html[data-app-keyboard=true] #app .inspo-focus-page{
    top:var(--app-offset-top,0px)!important;bottom:var(--app-offset-bottom,0px)!important;
    max-height:var(--app-height,100%)!important;
  }
  html[data-app-keyboard=true] :is(dialog.inspo-action-sheet,dialog.inspo-cosmos-extras){top:auto!important;max-height:calc(var(--app-height,100%) - 12px)!important}
  #app #inspiration{padding-bottom:0!important;min-height:100%;box-sizing:border-box}
  #app .workspace-body{padding-bottom:0!important;scroll-padding-bottom:var(--app-dock-clearance)}
  /* One final content container reserves the measured overlap, including the
     safe inset. Nested shelf grids and the full-height scrollport do not. */
  #app #inspiration #inspo-results{padding-bottom:var(--app-dock-clearance)!important;scroll-padding-bottom:var(--app-dock-clearance)}
  #app #inspiration #inspo-results :is(.inspo-shelf-grid,.inspo-brands-az-list){padding-bottom:0!important}
  #app #inspiration :is(.inspo-cosmos-related,.inspo-topic-body){padding-bottom:var(--app-dock-clearance)}
  /* Chat is another full-height content surface; its composer floats above the dock. */
  #app #talk.talk-view{position:relative;height:100%;min-height:0;max-height:100%;overflow:hidden}
  #app #talk .talk-scroll{padding-bottom:var(--app-chat-clearance);scroll-padding-bottom:var(--app-chat-clearance)}
  #app #talk .talk-dock{position:absolute;inset:auto 0 var(--app-dock-clearance);margin:0;background:transparent;padding-bottom:10px}
  #app #talk .talk-dock::after{content:none;display:none}
  #app #talk.talk-keyboard-open .talk-dock{bottom:0}
  .browse-studio-launch[open]:not([hidden]){height:var(--app-height,100%)!important;min-height:0;max-height:var(--app-height,100%)!important}
  /* Launch already inherits the full physical frame. Give only its controls
     a bounded inner gutter; do not inset the frame or move other docks. */
  html[data-app-standalone=true]:not([data-app-keyboard=true]) .browse-studio-launch[open]:not([hidden]) .browse-studio-launch-composer{
    padding-bottom:calc(22px + clamp(12px,calc(var(--app-safe-bottom) - var(--app-bottom-shortfall)),16px))!important;
  }
}
/* Immersive media inherits the physical shell frame. Source pixels and overlay
   controls fit inside its insets; their outer presentation stays full frame. */
#inspiration .inspo-cosmos-detail[data-content-mode=fullscreen] .inspo-content-stage.inspo-video-stage,
#inspiration .inspo-cosmos-detail .inspo-content-overlay,
#inspiration .inspo-cosmos-detail[data-video-mode=fullscreen] .inspo-video-stage,
#inspiration .inspo-cosmos-detail .inspo-video-shade{
  position:fixed;inset:0;width:100%;height:var(--app-height,100%);
}
#inspiration .inspo-cosmos-detail .inspo-video-overlay :is([data-video-back],[data-video-mute]){top:calc(16px + var(--app-safe-top))}
#inspiration .inspo-cosmos-detail .inspo-content-overlay{box-sizing:border-box;padding-top:calc(16px + var(--app-safe-top))}
/* The scrubber flows inside the physical-height stage, rather than anchoring
   a fixed control to the potentially shorter layout viewport. */
#inspiration .inspo-cosmos-detail .inspo-video-overlay{padding-bottom:calc(16px + var(--app-safe-bottom))}
/* Fit source pixels and their solid placeholder into the same safe content
   box without resizing carousel pages, poster wrappers or the gesture stage. */
#inspiration .inspo-cosmos-detail[data-content-mode=fullscreen] .inspo-content-stage :is(img,video,[data-content-image-colour],[data-detail-video-colour]){
  box-sizing:border-box;padding-top:var(--app-safe-top);padding-bottom:var(--app-safe-bottom);
}
/* Back the inset regions with black even during source transitions. These
   masks sit outside the fitted source pixels and do not intercept gestures. */
#inspiration .inspo-cosmos-detail[data-content-mode=fullscreen]:not(.is-content-closing):not(.is-content-dragging)::before,
#inspiration .inspo-cosmos-detail[data-content-mode=fullscreen]:not(.is-content-closing):not(.is-content-dragging)::after{
  content:"";position:fixed;left:0;width:100%;z-index:41;background:#000;pointer-events:none;
}
#inspiration .inspo-cosmos-detail[data-content-mode=fullscreen]:not(.is-content-closing):not(.is-content-dragging)::before{top:0;height:var(--app-safe-top)}
#inspiration .inspo-cosmos-detail[data-content-mode=fullscreen]:not(.is-content-closing):not(.is-content-dragging)::after{bottom:calc(0px - var(--app-bottom-shortfall))!important;height:var(--app-safe-bottom)}

/* A retained top row already consumes the inset; its scrolled detail row does not. */
#app #inspiration .inspo-cosmos-detail:has(.inspo-persistent-head) .inspo-cosmos-band-inner{padding-top:0!important;height:48px}
