/* Owner workspaces only. These rules do not style an editor canvas, a saved
   website snapshot, a template, or a member-facing preview. */
@media (max-width: 1023px) {
  .operator-theme-shell[data-personal-os-polish] #account-dashboard-main-content,
  [data-site-workspace-surface] main.operator-workspace {
    min-inline-size: 0;
    scroll-padding-block: calc(76px + env(safe-area-inset-top, 0px)) 28px;
    padding-bottom: max(24px, calc(20px + env(safe-area-inset-bottom, 0px)));
    overscroll-behavior-y: contain;
  }

  .operator-theme-shell[data-personal-os-polish] [data-personal-os-mobile-menu],
  [data-site-workspace-surface] [data-site-workspace-mobile-menu] {
    position: sticky;
    top: 0;
    z-index: 20;
    min-block-size: 60px;
    gap: 12px;
    padding-block: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--background);
  }

  .operator-theme-shell[data-personal-os-polish] [data-personal-os-mobile-menu] {
    border-color: var(--poe-line);
    background: var(--poe-canvas);
  }

  :is([data-personal-os-mobile-menu], [data-site-workspace-mobile-menu]) > span {
    min-inline-size: 0;
    overflow-wrap: anywhere;
    line-height: 1.5;
  }

  .operator-theme-shell[data-personal-os-polish] .personal-os-sidebar,
  [data-site-workspace-surface] .operator-shell-sidebar:has(#site-os-pages) {
    max-inline-size: calc(100vw - 16px - env(safe-area-inset-right, 0px));
    padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
    padding-inline-start: env(safe-area-inset-left, 0px);
  }

  .operator-theme-shell[data-personal-os-polish] #personal-os-pages,
  [data-site-workspace-surface] #site-os-pages {
    min-block-size: 0;
    min-inline-size: 0;
    overscroll-behavior-y: contain;
    scroll-padding-block: 12px;
  }

  .operator-theme-shell[data-personal-os-polish] #personal-os-pages button,
  [data-site-workspace-surface] #site-os-pages button,
  [data-site-workspace-surface] button[aria-label="Close Site OS menu"],
  [data-site-workspace-surface] button[aria-label="All Sites"],
  [data-site-workspace-surface] [data-site-workspace-mobile-menu] > button {
    min-block-size: 44px;
    touch-action: manipulation;
  }

  [data-site-workspace-surface] button[aria-label="Close Site OS menu"] {
    min-inline-size: 44px;
    flex-shrink: 0;
  }
}

/* Keep navigation and account actions independently reachable in landscape
   and when a small browser window leaves little vertical space. */
@media (max-width: 1023px) and (max-height: 560px) {
  .operator-theme-shell[data-personal-os-polish] .personal-os-sidebar-footer,
  [data-site-workspace-surface] .operator-shell-sidebar-footer {
    flex: 0 1 auto;
    min-block-size: 0;
    max-block-size: 42dvh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .operator-theme-shell[data-personal-os-polish] #personal-os-pages,
  [data-site-workspace-surface] #site-os-pages {
    flex: 1 1 0;
    min-block-size: 88px;
  }
}

@media (max-width: 767px) {
  /* Sixteen-pixel editable fields avoid iOS's small-input focus zoom. The
     scoped text tokens also cover the held native Tailwind text utilities. */
  .operator-theme-shell[data-personal-os-polish] #account-dashboard-main-content :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"]), textarea, select):not(:where([data-published-site] *, [data-public-site-page] *, [data-history-snapshot] *, .personal-site-preview-canvas *, .template-preview-canvas *, [data-site-editor-root] *, .member-dashboard-preview *, .sa-dashboard-preview-body *)),
  [data-site-workspace-surface] main.operator-workspace :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"]), textarea, select):not(:where([data-published-site] *, [data-public-site-page] *, [data-history-snapshot] *, .personal-site-preview-canvas *, .template-preview-canvas *, [data-site-editor-root] *, .member-dashboard-preview *, .sa-dashboard-preview-body *)) {
    --text-sm: 1rem;
    --text-xs: 1rem;
    min-block-size: 44px;
    min-inline-size: 0;
    max-inline-size: 100%;
    font-size: 16px !important;
    line-height: 1.5;
    scroll-margin-block: 80px 24px;
  }

  :is([data-personal-os-polish], [data-site-workspace-surface]) .operator-workspace :is([data-slot="button"], [data-slot="select-trigger"], [data-slot="tabs-trigger"]):not(:where([data-published-site] *, [data-public-site-page] *, [data-history-snapshot] *, .personal-site-preview-canvas *, .template-preview-canvas *, [data-site-editor-root] *, .member-dashboard-preview *, .sa-dashboard-preview-body *, [data-slot="calendar"] *, .rdp *)):not([role="checkbox"], [role="switch"]) {
    min-block-size: 44px;
    min-inline-size: 44px;
    touch-action: manipulation;
  }

  :is([data-personal-os-polish], [data-site-workspace-surface]) .operator-workspace [data-slot="select-trigger"] > [data-slot="select-value"]:not(:where([data-published-site] *, [data-public-site-page] *, [data-history-snapshot] *, .personal-site-preview-canvas *, .template-preview-canvas *, [data-site-editor-root] *, .member-dashboard-preview *, .sa-dashboard-preview-body *)) {
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  :is([data-personal-os-polish], [data-site-workspace-surface]) .operator-workspace :is(.billing-workspace-content, .personal-settings-content, .site-settings-content, [data-site-workspace-panel], .sa-main, .sa-panel, .sa-panel-body, [data-forms-inbox]) {
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  :is([data-personal-os-polish], [data-site-workspace-surface]) .operator-workspace :is([data-slot="table-container"], .sa-table-wrap):not(:where([data-published-site] *, [data-public-site-page] *, [data-history-snapshot] *, .personal-site-preview-canvas *, .template-preview-canvas *, [data-site-editor-root] *, .member-dashboard-preview *, .sa-dashboard-preview-body *)) {
    min-inline-size: 0;
    max-inline-size: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  :is([data-personal-os-polish], [data-site-workspace-surface]) .operator-workspace :is([role="alert"], [role="status"]):not(:where([data-published-site] *, [data-public-site-page] *, .personal-site-preview-canvas *, .template-preview-canvas *, [data-site-editor-root] *)) {
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }

  [data-site-workspace-surface] .site-access-workspace .sa-app-identity,
  [data-site-workspace-surface] .site-access-workspace .sa-app-identity > div {
    min-inline-size: 0;
  }

  [data-site-workspace-surface] main .site-access-workspace .sa-app-identity h1 {
    font-size: clamp(20px, 6vw, 24px);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  [data-site-workspace-surface] :is(.sa-heading-actions, .sa-app-tools, .site-media-type-filters) {
    min-inline-size: 0;
    flex-wrap: wrap;
  }

  [data-site-workspace-surface] .site-media-type-filters button,
  [data-personal-os-polish] [data-account-domains-root] nav[aria-label="Domain status filters"] button {
    min-block-size: 44px;
    touch-action: manipulation;
  }

  /* Preserve the short public-site label as one action. At smaller widths,
     wrap the whole action onto the next line instead of wrapping its words. */
  [data-site-workspace-surface] [data-site-overview] :is(.overview-hero-actions, .sov-hero-actions) > a[data-slot="button"]:not([aria-label]) {
    flex: 1 0 max-content;
    min-inline-size: max-content;
    max-inline-size: 100%;
    white-space: nowrap;
  }

  /* Radix portals live outside the workspace element. Scope them to a mounted
     owner shell and exclude editor sessions and authored preview dialogs. */
  body:has(:is([data-personal-os-polish], [data-site-workspace-surface])):not(:has([data-site-editor-root])) :is([data-slot="dialog-content"], [data-slot="alert-dialog-content"], [role="dialog"][data-state="open"]:not(.personal-os-sidebar, .operator-shell-sidebar)):not(:has([data-published-site], [data-public-site-page], [data-history-snapshot], .template-preview-canvas, .personal-site-preview-canvas)) {
    max-inline-size: calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    max-block-size: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-padding-block: 20px;
  }

  body:has(:is([data-personal-os-polish], [data-site-workspace-surface])):not(:has([data-site-editor-root])) :is([data-slot="dialog-content"], [data-slot="alert-dialog-content"], [role="dialog"][data-state="open"]:not(.personal-os-sidebar, .operator-shell-sidebar)) :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"]), textarea, select):not(:where([data-published-site] *, [data-public-site-page] *, [data-history-snapshot] *, .personal-site-preview-canvas *, .template-preview-canvas *, .member-dashboard-preview *, .sa-dashboard-preview-body *)) {
    --text-sm: 1rem;
    --text-xs: 1rem;
    min-block-size: 44px;
    min-inline-size: 0;
    max-inline-size: 100%;
    font-size: 16px !important;
  }

  body:has(:is([data-personal-os-polish], [data-site-workspace-surface])):not(:has([data-site-editor-root])) :is([data-slot="dropdown-menu-content"], [data-slot="select-content"], [data-slot="popover-content"]) {
    max-inline-size: calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    max-block-size: min(28rem, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  body:has(:is([data-personal-os-polish], [data-site-workspace-surface])):not(:has([data-site-editor-root])) :is([data-slot="dropdown-menu-item"], [data-slot="dropdown-menu-checkbox-item"], [data-slot="dropdown-menu-radio-item"], [data-slot="dropdown-menu-sub-trigger"], [data-slot="select-item"]) {
    min-block-size: 44px;
    padding-block: 10px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  [data-personal-beta-feedback-dialog] {
    max-block-size: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overscroll-behavior-y: contain;
  }
}

@media (max-width: 479px) {
  [data-personal-os-polish] [data-account-notifications-root] > section > div:first-child > div:has(#account-notifications-search),
  [data-personal-os-polish] [data-account-domains-root] > section > div:has(#account-domains-search) {
    grid-template-columns: minmax(0, 1fr);
  }

  [data-personal-os-polish] [data-account-notifications-root] > section > div:first-child > div:has(#account-notifications-search) > *,
  [data-personal-os-polish] [data-account-domains-root] > section > div:has(#account-domains-search) > * {
    min-inline-size: 0;
    grid-column: 1 / -1;
  }

  [data-personal-os-polish] [data-account-domains-root] > header > div {
    inline-size: 100%;
  }

  [data-personal-os-polish] [data-account-domains-root] > header > div > button {
    flex: 1 1 auto;
  }

  [data-account-activity-details] dl {
    grid-template-columns: minmax(0, 1fr);
  }
}
