/* The tinted footer reaches the frame edge and stays above scrolling content. */
@layer remembrand-buttons {
 [data-rb-dialog].ui-mobile-palette-shell .ui-mobile-palette-footer {
  position: sticky !important;
  bottom: calc(0px - var(--overlay-padding-bottom));
  z-index: 2;
  box-sizing: border-box;
  width: calc(100% + 2 * var(--overlay-padding-x)) !important;
  max-width: none !important;
  margin-inline: calc(0px - var(--overlay-padding-x)) !important;
  margin-bottom: calc(0px - var(--overlay-padding-bottom)) !important;
  padding: var(--overlay-footer-gap) var(--overlay-padding-x) var(--overlay-padding-bottom) !important;
  margin-top: 0 !important;
  background: color-mix(in srgb, var(--color-paper) 72%, transparent) !important;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
 }
}

/* Mobile spacing is half the desktop padding. Keep a scroll reserve equal
   to the overlap so the last field can still clear the footer. */
@media(max-width:600px) {
 :root {--overlay-padding-x:14px;--overlay-padding-top:14px;--overlay-padding-bottom:14px;--ui-mobile-palette-gutter:14px;--ui-mobile-footer-padding:14px;--overlay-title-bottom-gap:32px;--overlay-intro-bottom:32px;}
 @layer remembrand-buttons {
  [data-rb-dialog] {padding:var(--overlay-padding-top) var(--overlay-padding-x) var(--overlay-padding-bottom)!important;max-width:calc(100vw - 2 * var(--ui-mobile-palette-gutter))!important;max-height:calc(var(--ui-mobile-viewport-height,100dvh) - 2 * var(--ui-mobile-palette-gutter))!important;}
  .ui-mobile-palette-backdrop {box-sizing:border-box!important;height:var(--ui-mobile-viewport-height,100dvh)!important;top:var(--ui-mobile-viewport-offset,0px)!important;bottom:auto!important;padding:var(--ui-mobile-palette-gutter)!important;overflow:hidden!important;}
  [data-rb-dialog].ui-mobile-palette-shell {display:flex!important;flex-direction:column!important;overflow:hidden!important;min-height:0!important;}
  [data-rb-dialog].ui-mobile-palette-shell>.ui-mobile-palette-flow {display:flex!important;flex-direction:column!important;flex:1 1 auto!important;min-height:0!important;overflow:hidden!important;height:auto!important;}
  .memory-layouts-dialog.is-memory-settings > .memory-settings-tabs {
   padding-bottom: 14px !important;
  }
  .ui-mobile-palette-shell>:not(.ui-mobile-palette-scroll):not(.ui-mobile-palette-flow),.ui-mobile-palette-flow>:not(.ui-mobile-palette-scroll) {flex-shrink:0!important;}
  .ui-mobile-palette-shell .ui-mobile-palette-scroll {flex:1 1 auto!important;min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior:contain;scrollbar-gutter:auto!important;margin-bottom:0!important;}
  [data-rb-dialog].ui-mobile-palette-shell .ui-mobile-palette-footer {flex:0 0 auto!important;position:relative!important;bottom:auto; padding-top:var(--ui-mobile-footer-padding)!important;}
  [data-rb-dialog].ui-mobile-palette-shell:not(.is-palette-writing) {--ui-palette-footer-overlap:40px;}
  [data-rb-dialog].ui-mobile-palette-shell .ui-mobile-palette-footer {
   background: color-mix(in srgb, var(--color-paper) 56%, transparent) !important;
  }
  .ui-mobile-palette-shell:not(.is-palette-writing) .ui-mobile-palette-scroll:has(~ .ui-mobile-palette-footer:not([hidden])) {
   padding-bottom: var(--ui-palette-footer-overlap) !important;
   scroll-padding-bottom: var(--ui-palette-footer-overlap);
  }
  [data-rb-dialog].ui-mobile-palette-shell:not(.is-palette-writing) .ui-mobile-palette-scroll ~ .ui-mobile-palette-footer:not([hidden]) {
   margin-top: calc(0px - var(--ui-palette-footer-overlap)) !important;
  }
  .ui-mobile-palette-flow {display:flex!important;flex-direction:column!important;min-height:0!important;}
  [data-rb-dialog].ui-mobile-palette-shell .ui-mobile-palette-flow[hidden] {display:none!important;}
  #authModal .ui-mobile-palette-flow {flex:1 1 auto!important;overflow:hidden!important;}
  #authModal .ui-mobile-palette-footer>#authSendButton {margin:0 auto!important;}
  [data-rb-dialog].ui-mobile-palette-shell.ui-tabbed-palette {height:min(var(--ui-tabbed-height),calc(var(--ui-mobile-viewport-height,100dvh) - 2 * var(--ui-mobile-palette-gutter)))!important;}
  [data-rb-dialog].ui-mobile-palette-shell[data-ui-palette=contacts] {height:calc(var(--ui-mobile-viewport-height,100dvh) - 2 * var(--ui-mobile-palette-gutter))!important;}
  dialog[data-rb-dialog].ui-mobile-palette-shell {inset-block-start:var(--ui-mobile-viewport-offset,0px)!important;inset-block-end:calc(100% - var(--ui-mobile-viewport-offset,0px) - var(--ui-mobile-viewport-height,100dvh))!important;}
 }
}

/* A keyboard gives the active field the full scrollable height, including the
   header. Native forms and controls stay in place throughout the transition. */
@media (max-width: 600px) {
 @layer remembrand-buttons {
  [data-rb-dialog][data-rb-dialog].is-palette-writing:not(dialog:not([open])) {
   display: block !important;
   height: calc(var(--ui-mobile-viewport-height, 100dvh) - 2 * var(--ui-mobile-palette-gutter)) !important;
   overflow-y: auto !important;
   overflow-x: hidden !important;
   overscroll-behavior: contain;
   scroll-behavior: auto !important;
   overflow-anchor: none;
  }
  [data-rb-dialog].is-palette-writing .ui-mobile-palette-flow:not([hidden]) {
   display: contents !important;
  }
  [data-rb-dialog].is-palette-writing .ui-mobile-palette-scroll {
   flex: none !important;
   height: auto !important;
   max-height: none !important;
   overflow: visible !important;
  }
  [data-rb-dialog].ui-mobile-palette-shell.is-palette-writing .ui-mobile-palette-footer {
   position: sticky !important;
   bottom: calc(0px - var(--overlay-padding-bottom)) !important;
  }
 }
}

@media (max-width: 600px) {
 @layer remembrand-buttons {
  .ai-sticker-modal:is([data-ai-sticker-mode="cutout"], [data-ai-sticker-mode="upload"]) .ui-palette-body[data-rb-header-divider] {
   --overlay-divider-after: 8px;
   --overlay-divided-gap: 9px;
  }
  .ai-sticker-modal:is([data-ai-sticker-mode="cutout"], [data-ai-sticker-mode="upload"]) .ai-sticker-source-section {
   margin-top: 18px !important;
   margin-bottom: 14px !important;
   gap: 14px !important;
  }
 }
}
