/* Mobile usability only; inherit WStyle light colours and RapidSpace dark colours. */
@media screen and (max-width:767.98px) {
 body :is(.client-topbar,.site-header,.topbar) :is(.notif-menu,.account-menu),
 body .client-quickactions .dropdown-menu {
  position:fixed !important; inset:5rem .75rem auto !important;
  transform:none !important; width:auto !important; inline-size:auto !important;
  min-inline-size:0 !important; max-inline-size:none !important;
  max-height:calc(100dvh - 6rem); max-block-size:calc(100dvh - 6rem);
  overflow-y:auto; overscroll-behavior:contain;
 }
 body .notif-list { max-block-size:min(22rem,calc(100dvh - 13rem)); }
 body .notif-item-top { flex-wrap:wrap; gap:.25rem .5rem; }
 body .notif-item-desc { white-space:normal; overflow-wrap:anywhere; }
 body :is(.notif-item-title,.account-menu-name,.account-menu-email) { overflow-wrap:anywhere; white-space:normal; }
 body .notif-menu .notif-head-end { flex-wrap:wrap; }
 body .notif-read-btn { min-inline-size:2.75rem; min-block-size:2.75rem; }
 body .account-menu-head > span { min-inline-size:0; }
 body .wstyle-toast-container {
  inset-inline:.75rem !important; inset-block-end:max(.75rem,env(safe-area-inset-bottom));
  max-inline-size:calc(100vw - 1.5rem);
 }
 body .wstyle-toast-container .toast { width:100%; max-inline-size:100%; }
 body .wstyle-toast-container .toast-body { min-inline-size:0; overflow-wrap:anywhere; }
 body .wstyle-toast-container .toast-action { white-space:normal; }
 body .modal-dialog { margin:.5rem; max-inline-size:calc(100% - 1rem); }
 body .modal-content { max-block-size:calc(100dvh - 1rem); }
 body .modal-body { min-block-size:0; overflow-y:auto; }
 body .offcanvas { max-inline-size:calc(100vw - 1rem); }
 body :is(.dropdown-menu,.ts-dropdown,.popover) { max-inline-size:calc(100vw - 1.5rem); }
}
@media screen and (max-width:767.98px) {
 /* A blurred ancestor would make the fixed dropdown relative to the header. */
 body :is(.site-header,.client-topbar,.topbar):has(:is(.notif-menu,.account-menu,.client-quickactions .dropdown-menu).show) {
  -webkit-backdrop-filter:none !important; backdrop-filter:none !important;
 }
 body .notif-menu .account-menu-head { flex-wrap:wrap; }
 body .notif-menu .notif-head-end { margin-inline-start:auto; }
}

/* 3.1.16: flexible content must be able to shrink before wrapping.
   These rules change geometry only; native light colours remain untouched. */
@media screen and (max-width:991.98px) {
 body :is(.client-topbar,.site-header,.topbar) :is(.notif-menu,.account-menu),
 body .client-quickactions .dropdown-menu {
  position:fixed !important; inset:5rem .75rem auto !important;
  transform:none !important; width:auto !important; inline-size:auto !important;
  min-inline-size:0 !important; max-inline-size:none !important;
  max-block-size:calc(100dvh - 6rem); overflow-y:auto; overscroll-behavior:contain;
 }
 body :is(.site-header,.client-topbar,.topbar):has(:is(.notif-menu,.account-menu,.client-quickactions .dropdown-menu).show) {
  -webkit-backdrop-filter:none !important; backdrop-filter:none !important;
 }
 body .client-topbar-menu-head { flex-wrap:wrap; align-items:flex-start; }
 body .notif-head-end { min-inline-size:0; flex-shrink:1; flex-wrap:wrap; margin-inline-start:auto; }
 body .notif-markall { white-space:normal; text-align:start; min-block-size:2.75rem; }
 body .notif-list { max-block-size:min(22rem,calc(100dvh - 13rem)); }
 body .notif-item-top { flex-wrap:wrap; }
 body .notif-item-desc { white-space:normal; overflow-wrap:anywhere; }
 body :is(.notif-item-title,.account-menu-name,.account-menu-email) { white-space:normal; overflow-wrap:anywhere; }
 body .account-menu-head > span { min-inline-size:0; }
 body .dash :is(.dash-panel,.dash-feed,.dash-feed-item,.dash-feed-text) { min-inline-size:0; }
 body .dash .dash-feed-text { flex:1 1 0; overflow-wrap:anywhere; }
 body .dash .dash-panel-head { flex-wrap:wrap; align-items:center; }
 body .dash .dash-panel-title { min-inline-size:0; overflow-wrap:anywhere; }
 body .dash .dash-panel-link { flex-shrink:0; min-block-size:2.75rem; }
 body .dash :is(.dash-row-title,.dash-row-sub,.dash-stat-label,.dash-stat-value,.dash-balance-value) { overflow-wrap:anywhere; }
 body .dash .dash-balance-card { min-inline-size:0; max-inline-size:100%; flex-wrap:wrap; }
 body #as-activity :is(.as-pane-head,.as-pane-tools,.wcp-table-header,.wcp-table-footer) {
  flex-wrap:wrap; gap:.75rem; min-inline-size:0;
 }
 body #as-activity :is(.as-card,.wcp-table,.table-responsive) { min-inline-size:0; max-inline-size:100%; }
 body #as-activity .table-responsive { overflow-x:auto; overscroll-behavior-inline:contain; }
 body #as-activity .table { min-inline-size:34rem; }
 body #as-activity .table td { overflow-wrap:anywhere; }
 body #as-activity .table td:nth-child(2) { max-inline-size:24rem; white-space:normal; }
 body #as-activity :is(.wcp-table-info,.as-pane-title,.as-pane-sub) { overflow-wrap:anywhere; }
 body #as-activity .pagination { flex-wrap:wrap; gap:.25rem; }
}
@media screen and (max-width:575.98px) {
 body .dash .dash-panel { padding:1rem; }
 body .dash .dash-stats { grid-template-columns:repeat(2,minmax(0,1fr)); grid-auto-rows:1fr; }
 body .dash .dash-stat { padding:1rem .75rem; min-inline-size:0; }
 body .dash .dash-stat-top { flex-wrap:wrap; }
 body .dash .dash-row { flex-wrap:wrap; }
 body .dash .dash-row-main { flex:1 1 8rem; }
 body #as-activity .as-pane-tools { inline-size:100%; }
 body #as-activity .as-activity-filter { flex:1 1 9rem; max-inline-size:100%; }
 body #as-activity .as-table-search { flex:1 1 100%; min-inline-size:0; }
 body .as-notif-row { grid-template-columns:minmax(0,1fr) 3rem 3rem; padding-inline:.75rem; gap:.5rem; }
 body .as-notif-headrow :is(.as-notif-ch,.as-notif-cat) { white-space:normal; overflow-wrap:anywhere; }
 body .as-notif-desc { overflow-wrap:anywhere; }
}

/* 3.1.17: Messages uses a separate table and preview from Activity. */
@media screen and (max-width:991.98px) {
 body #as-messages :is(.as-pane-head,.wcp-table-header,.wcp-table-footer) {
  flex-wrap:wrap; gap:.75rem; min-inline-size:0;
 }
 body #as-messages :is(.as-card,.wcp-table,.table-responsive) { min-inline-size:0; max-inline-size:100%; }
 body #as-messages .table-responsive { overflow-x:auto; overscroll-behavior-inline:contain; }
 body #as-messages .as-messages-table { min-inline-size:32rem; }
 body #as-messages .as-messages-table td:first-child {
  max-inline-size:24rem; white-space:normal; overflow-wrap:anywhere;
 }
 body #as-messages .as-messages-table td:first-child :is(a,span,strong) { white-space:normal; overflow-wrap:anywhere; }
 body #as-messages :is(.wcp-table-info,.as-pane-title,.as-pane-sub) { overflow-wrap:anywhere; }
 body #as-messages .pagination { flex-wrap:wrap; gap:.25rem; }
 body #as-message-modal :is(.modal-titles,.modal-body,.as-msg-frame-wrap) { min-inline-size:0; max-inline-size:100%; }
 body #as-message-modal :is(.modal-title,.modal-subtitle,.as-msg-body) { white-space:normal; overflow-wrap:anywhere; }
 body #as-message-modal .as-msg-body { white-space:pre-wrap; }
 body #as-message-modal .btn-close { flex-shrink:0; }
 body #as-message-modal .modal-body { padding:1rem; overflow:auto; }
 body #as-message-modal .as-msg-frame { block-size:55dvh; min-block-size:min(320px,45dvh); max-inline-size:100%; }
 /* Opaque scrolled header: scrolling content cannot mix with its text.
    No header blur boundary, so fixed notification menus retain viewport positioning. */
 [data-bs-theme="dark"] body.rs-page-scrolled :is(.site-header,.site-header.chrome-dark,.client-topbar,.checkout-shell-header),
 [data-bs-theme="dark"] body.rs-page-scrolled[data-client-nav="sidebar"] .client-topbar {
  background:#081b29 !important;
  -webkit-backdrop-filter:none !important; backdrop-filter:none !important;
 }
}
@media screen and (max-width:575.98px) {
 body #as-messages .as-table-search { flex:1 1 100%; min-inline-size:0; }
 body #as-message-modal .modal-dialog { margin:.5rem; }
 body #as-message-modal .modal-header { padding:1rem; gap:.65rem; align-items:flex-start; }
 body #as-message-modal .modal-titles { flex:1 1 0; }
}

/* 3.1.18: phone Messages rows become compact cards; no sideways list scrolling. */
@media screen and (max-width:575.98px) {
 body #as-messages .as-messages-table { width:100%; min-inline-size:0; table-layout:fixed; }
 body #as-messages .as-messages-table thead {
  position:absolute; inline-size:1px; block-size:1px; overflow:hidden;
  clip-path:inset(50%); white-space:nowrap;
 }
 body #as-messages .as-messages-table tbody { display:block; inline-size:100%; }
 body #as-messages .as-messages-table tr {
  display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  border-block-end:1px solid var(--wstyle-border-color); padding:.75rem;
 }
 body #as-messages .as-messages-table td {
  display:block; min-inline-size:0; max-inline-size:100%; padding:.4rem .25rem;
  border:0; white-space:normal !important; overflow-wrap:anywhere;
 }
 body #as-messages .as-messages-table td:first-child,
 body #as-messages .as-messages-table td[colspan] { grid-column:1/-1; }
 body #as-messages .as-messages-table td:first-child > * { min-inline-size:0; max-inline-size:100%; }
 body #as-messages .as-messages-table td:first-child :is(.text-truncate,.text-nowrap) {
  white-space:normal !important; overflow:visible; text-overflow:clip;
 }
 body #as-messages .as-messages-table td:not(:first-child) :is(span,time) { white-space:normal !important; overflow-wrap:anywhere; }
 body #as-message-modal .modal-body { padding:.75rem; }
}

/* 3.1.29: mobile navigation drawer matches the frosted account menus. */
@media screen and (max-width:991.98px) {
 [data-bs-theme="dark"] body[data-client-nav="sidebar"] #client-menu.client-sidebar {
  background:#051620 !important;
  border-color:var(--rs-border) !important;
  -webkit-backdrop-filter:blur(28px) !important;
  backdrop-filter:blur(28px) !important;
 }
 @supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))) {
  [data-bs-theme="dark"] body[data-client-nav="sidebar"] #client-menu.client-sidebar {
   background:var(--rs-panel) !important;
  }
 }
}

/* 3.1.52: shared header blur is a separate layer, enabled only after scrolling.
   Keeping backdrop-filter off the header itself preserves fixed menu positioning. */
@media screen {
  html[data-bs-theme] body :is(.site-header,.site-header.chrome-dark,.client-topbar,.checkout-shell-header:not(.rs-commerce-progress .checkout-shell-header)) {
    isolation:isolate;
    -webkit-backdrop-filter:none !important;
    backdrop-filter:none !important;
  }
  html[data-bs-theme] body :is(.site-header,.client-topbar,.checkout-shell-header:not(.rs-commerce-progress .checkout-shell-header))::before {
    content:"";
    position:absolute;
    inset:0;
    z-index:-1;
    pointer-events:none;
    background:transparent;
    -webkit-backdrop-filter:none;
    backdrop-filter:none;
  }
  html[data-bs-theme] body.rs-page-scrolled :is(.site-header,.site-header.chrome-dark,.client-topbar,.checkout-shell-header:not(.rs-commerce-progress .checkout-shell-header)) {
    background:transparent !important;
  }
  html[data-bs-theme] body.rs-page-scrolled :is(.site-header,.client-topbar,.checkout-shell-header:not(.rs-commerce-progress .checkout-shell-header))::before {
    background:rgba(4,22,33,.88);
    -webkit-backdrop-filter:blur(20px);
    backdrop-filter:blur(20px);
  }
  html[data-bs-theme="light"] body.rs-page-scrolled :is(.site-header,.client-topbar,.checkout-shell-header:not(.rs-commerce-progress .checkout-shell-header))::before {
    background:color-mix(in srgb,var(--wstyle-chrome-bg) 92%,transparent);
  }
}

@media screen {
  html[data-bs-theme="light"] body.rs-page-scrolled :is(.client-topbar,.checkout-shell-header:not(.rs-commerce-progress .checkout-shell-header))::before {
    background:color-mix(in srgb,var(--wstyle-surface-bg) 92%,transparent);
  }
}

/* 3.1.56: the in-flow checkout step bar must never create a backdrop layer. */
@media screen {
  html[data-bs-theme] body .rs-commerce-progress .checkout-shell-header {
    position:relative;
    isolation:auto;
    -webkit-backdrop-filter:none !important;
    backdrop-filter:none !important;
  }
  html[data-bs-theme] body .rs-commerce-progress .checkout-shell-header::before {
    content:none !important;
    display:none !important;
    -webkit-backdrop-filter:none !important;
    backdrop-filter:none !important;
  }
}
