/* Geometry owner: platform_insets.js. Visual themes must not override these rules.
   Only Android Telegram changes. Browser, iOS and MAX keep their accepted layout. */
html[data-inset-policy="telegram-android"] body #app-container {
  padding-top: var(--platform-safe-top, 0px) !important;
  padding-bottom: var(--platform-safe-bottom, 0px) !important;
  transition-property: background-color, color !important;
}

/* The root reserves navigation/keyboard space, so the composer adds only its visual gutter. */
html[data-inset-policy="telegram-android"] body #app-container .input-area-container {
  padding-bottom: var(--input-gutter-y, 6px) !important;
}

/* Fixed sidebar is outside the app's padding box; reserve the band once here. */
html[data-inset-policy="telegram-android"] body #app-container #sidebar {
  padding-top: var(--platform-safe-top, 0px) !important;
  transition-property: transform, background-color, border-color !important;
}

/* Projects inherit the app inset, including when their own app bar is hidden. */
html[data-inset-policy="telegram-android"] body #documents-container {
  padding-top: 0 !important;
}

/* Body-mounted dialogs reserve native bars once, independently of the app box. */
html[data-inset-policy="telegram-android"] body :is(.docs-folder-modal, .docs-actions-modal, .acc-confirm, .acc-modal, .guest-auth-modal, #ai-consent-modal) {
  padding-top: calc(var(--platform-safe-top, 0px) + 14px) !important;
  padding-bottom: calc(var(--platform-overlay-bottom, 0px) + 14px) !important;
  box-sizing: border-box;
}
html[data-inset-policy="telegram-android"] body :is(.docs-folder-modal__card, .docs-actions-modal__dialog, .acc-confirm-card, .acc-modal-card, .acc-drawer-card, .guest-auth-modal__card, .ai-consent-dialog) {
  max-height: 100% !important;
  overflow-y: auto;
}
html[data-inset-policy="telegram-android"] body :is(dialog.docs-subscription-modal, .docs-subscription-confirm) {
  --subscription-top: calc(var(--platform-safe-top, 0px) + 16px);
  --subscription-bottom: calc(var(--platform-overlay-bottom, 0px) + 16px);
}
html[data-inset-policy="telegram-android"] body .balance-modal.balance-workspace {
  --balance-top: calc(var(--platform-safe-top, 0px) + 16px);
  --balance-bottom: calc(var(--platform-overlay-bottom, 0px) + 16px);
}

/* Fullscreen surfaces are independent viewport roots, not children of app padding. */
html[data-inset-policy="telegram-android"] body :is(#account-overlay, #image-editor-modal, #panorama-container, .imglb) {
  top: var(--platform-safe-top, 0px) !important;
  bottom: var(--platform-overlay-bottom, 0px) !important;
  height: auto !important;
}
html[data-inset-policy="telegram-android"] body #account-overlay {
  padding-top: 0 !important;
}
html[data-inset-policy="telegram-android"] body #account-overlay .acc-header {
  position: absolute;
  padding-top: 8px !important;
  height: var(--acc-header-h);
}
html[data-inset-policy="telegram-android"] body #account-overlay .acc-body {
  padding-top: calc(var(--acc-header-h) + 24px) !important;
  padding-bottom: var(--acc-pad) !important;
}
html[data-inset-policy="telegram-android"] body #image-editor-modal :is(.image-editor-content, .glass-layout) {
  height: 100% !important;
}
html[data-inset-policy="telegram-android"] body #image-editor-modal .glass-bottom-bar {
  --safe-bottom: 0px;
  bottom: var(--platform-overlay-bottom, 0px) !important;
}
html[data-inset-policy="telegram-android"] body #image-editor-modal .close-btn-fixed {
  top: calc(var(--platform-safe-top, 0px) + 16px) !important;
}
