/* Shared popup chrome: the rounded frame clips an independently scrolling body. */
html body .ui-popup-frame {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  isolation: isolate;
}
html body dialog.ui-popup-frame:not([open]):not([data-fallback-open="true"]),
html body .ui-popup-frame[hidden] { display: none; }
html body .ui-popup-bounded { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
html body .ui-popup-scroll {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px;
}
html body .ui-popup-frame > .ui-popup-scroll { margin: 4px; border-radius: inherit; }
html body .ui-popup-pad { padding: 1.5rem; }
html body .ui-popup-layout {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  max-height: inherit;
  overflow: hidden;
}
html body .ui-popup-layout > header,
html body .ui-popup-layout > footer { flex: 0 0 auto; position: relative; }
html body .calendar-export-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
html body .application-document-dialog { overflow: hidden; }
html body .pwa-install__scroll { padding: 1.35rem; }
.album-lightbox, .gallery-lightbox__dialog { --popup-scroll-thumb: #75aba8; }
html body .website-editor-dialog-actions { display: flex; justify-content: center; gap: .6rem; margin-top: 1.35rem; }
html body .website-editor-dialog section > .ui-popup-scroll { display: block; }
html body .ui-popup-actions { display: flex; justify-content: flex-end; gap: .75rem; }

/* Scope also covers nested lists, textareas, dynamic datepickers and future dialogs. */
html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll),
html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) * {
  scrollbar-width: thin;
  scrollbar-color: var(--popup-scroll-thumb, #508d80) transparent;
  scrollbar-gutter: auto;
}

/* Non-auto standard properties override WebKit thumb styling in Chromium. */
@supports selector(::-webkit-scrollbar) {
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll),
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) * {
    scrollbar-width: auto;
    scrollbar-color: auto;
  }
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll)::-webkit-scrollbar,
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) *::-webkit-scrollbar {
    width: 7px; height: 7px; background: transparent;
  }
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll)::-webkit-scrollbar-track,
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) *::-webkit-scrollbar-track {
    background: transparent; margin-block: 10px; margin-inline: 10px;
  }
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll)::-webkit-scrollbar-thumb,
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) *::-webkit-scrollbar-thumb {
    min-height: 30px; min-width: 30px;
    border: 1px solid transparent; border-radius: 999px;
    background: var(--popup-scroll-thumb, #508d80); background-clip: padding-box;
  }
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll)::-webkit-scrollbar-thumb:hover,
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) *::-webkit-scrollbar-thumb:hover { background-color: #177665; }
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll)::-webkit-scrollbar-button,
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) *::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll)::-webkit-scrollbar-corner,
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) *::-webkit-scrollbar-corner { background: transparent; }
}
@media (max-width: 640px) {
  html body .ui-popup-pad { padding: 1rem; }
  html body .pwa-install__scroll { padding: 1.1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
}
@media (max-height: 500px) {
  html body .calendar-export-header { padding: .65rem 1rem; }
  html body .calendar-export-header p { display: none; }
  html body .calendar-export-footer { padding: .6rem .8rem; }
}
@media (forced-colors: active) {
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll),
  html :is(dialog, [role="dialog"], [role="alertdialog"], [role="tooltip"], [role="listbox"], .ui-popup-scroll) * {
    --popup-scroll-thumb: CanvasText;
    scrollbar-color: auto;
  }
}
