/* 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;
}
/* 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. Inner content does not. */
  :is(#app .workspace>.workspace-bar,#app .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 video is a top-layer presentation of the shared shell, including
   its black safe-area canvas. Device inset ownership stays in this file. */
#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))}
/* 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))}
