/* Mobile store surfaces. Specificity keeps lazy-loaded legacy styles from
   turning the five-item navigation back into a clipped scrolling strip. */
@media (max-width: 700px) {
  .mp-app.mp-shop .mp-sidebar {
    height: auto;
    min-height: 0;
    overflow: visible;
    z-index: 40;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  }
  .mp-app.mp-shop .mp-sidebar nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    margin: 0;
    padding: 0;
    gap: 2px;
    overflow: visible;
  }
  .mp-app.mp-shop .mp-sidebar nav button.mp-nav-secondary { display: none; }
  .mp-app.mp-shop .mp-sidebar nav :is(button.mp-nav-frequent, button.mp-nav-more) {
    width: 100%;
    min-width: 0;
    min-height: 60px;
    padding: 6px 2px;
    gap: 5px;
    text-align: center;
    transform: none;
  }
  .mp-app.mp-shop .mp-sidebar nav button > span {
    max-width: 100%;
    white-space: normal;
    font-size: 12px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  .mp-app.mp-shop .mp-mobile-menu {
    z-index: 1;
    max-height: calc(var(--shop-visible-height, 100dvh) - 150px);
    overscroll-behavior: contain;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .mp-app.mp-shop .mp-mobile-menu header > button { min-width: 44px; }
  .mp-app.mp-shop .mp-topbar__right { gap: 8px; min-width: 0; }
  .mp-app.mp-shop .mp-topbar__right > button { min-width: 44px; min-height: 44px; flex-shrink: 0; }
  .mp-app.mp-shop .mp-topbar__right .mp-global-search { min-width: 0; }

  /* 16px prevents Safari's focus zoom without restricting user zoom. */
  .mp-app.mp-shop :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select) {
    font-size: 16px !important;
    max-width: 100%;
    min-width: 0;
    scroll-margin-block: 80px;
  }
  .mp-app.mp-shop :is(button, a, summary) { touch-action: manipulation; }
  .mp-app.mp-shop :is(.mp-toolbar, .mp-module-hero, .mp-section-title) { min-width: 0; }
  .mp-app.mp-shop :is(.mp-filter-select, .mp-tab, .mp-back-link, .mp-inbox-filters button, .sx-tabs button) { min-height: 44px; }
  .mp-app.mp-shop :is(.mp-toolbar, .mp-quick-actions, .mp-dialog__actions) .mp-button {
    max-width: 100%;
    white-space: normal;
  }
  .mp-app.mp-shop .mp-topbar-popover {
    max-width: calc(100vw - 24px);
    max-height: calc(var(--shop-visible-height, 100dvh) - 180px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
@media (max-width: 700px) {
  /* Keep the client, next action and measurements readable on narrow phones. */
  .mp-app.mp-shop .mp-analysis-list > button {
    grid-template-columns: 24px minmax(0, 1fr) 64px 16px;
    gap: 10px 8px;
    align-items: start;
  }
  .mp-app.mp-shop .mp-analysis-list > button > .mp-rank { grid-area: 1 / 1; }
  .mp-app.mp-shop .mp-analysis-list > button > span:nth-of-type(3) { grid-area: 1 / 2 / 2 / 4; }
  .mp-app.mp-shop .mp-analysis-list > button > .mp-analysis-statuses {
    grid-area: 2 / 2 / 3 / 4;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
  }
  .mp-app.mp-shop .mp-analysis-list > button > .mp-analysis-result { grid-area: 3 / 2; }
  .mp-app.mp-shop .mp-analysis-list > button > span:nth-of-type(5) { grid-area: 3 / 3; }
  .mp-app.mp-shop .mp-analysis-list > button > svg { grid-area: 1 / 4 / 4 / 5; align-self: center; }
  .mp-app.mp-shop .mp-analysis-list :is(b, small) { white-space: normal; overflow-wrap: anywhere; }
  .mp-app.mp-shop .mp-dialog-backdrop {
    top: var(--shop-visible-top, 0px);
    bottom: auto;
    height: var(--shop-visible-height, 100dvh);
    padding: 8px;
    backdrop-filter: none;
    background: rgb(10 59 73 / 38%);
  }
  .mp-app.mp-shop .mp-dialog {
    width: 100%;
    max-height: calc(var(--shop-visible-height, 100dvh) - 16px);
    padding: 18px;
    overscroll-behavior: contain;
    scrollbar-gutter: auto;
  }
  .mp-app.mp-shop .mp-dialog__close {
    position: sticky;
    display: grid;
    top: 0;
    right: auto;
    margin: -6px -6px 8px auto;
    width: 44px;
    height: 44px;
    z-index: 5;
  }
  .mp-app.mp-shop dialog:is(.shop-window, .mp-appointment-dialog, .sav-resolution-dialog, .assistant-dialog, .ow-offer-dialog) {
    top: calc(var(--shop-visible-top, 0px) + 8px);
    bottom: auto;
    margin: 0 auto;
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    max-height: calc(var(--shop-visible-height, 100dvh) - 16px);
    overscroll-behavior: contain;
  }
  .mp-app.mp-shop .shop-window-heading { gap: 12px; }
  .mp-app.mp-shop .shop-window-heading > button { width: 44px; height: 44px; }
  .mp-app.mp-shop .shop-window-heading h2 { min-width: 0; overflow-wrap: anywhere; }
  .mp-app.mp-shop .shop-window-body { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .mp-app.mp-shop .mp-appointment-dialog > header {
    position: sticky;
    top: 0;
    z-index: 5;
    padding-block: 8px;
    background: #fff;
  }
  .mp-app.mp-shop :is(.mp-dialog__actions, .sav-create-footer) { gap: 8px; }
  .mp-app.mp-shop .mp-main { padding-bottom: env(safe-area-inset-bottom); }
  .mp-app.mp-shop .mp-messages-workspace .mp-messages-shell {
    height: calc(var(--shop-visible-height, 100dvh) - 275px);
    min-height: 280px;
  }
  .mp-app.mp-shop .mp-conversation > header :is(.mp-inbox-back, .mp-thread-client),
  .mp-app.mp-shop .mp-composer button {
    min-width: 44px;
    min-height: 44px;
  }
  .mp-app.mp-shop.mp-app--assistants {
    height: var(--shop-visible-height, 100dvh);
  }
}
@media (min-width: 701px) and (max-width: 940px) {
  .mp-app.mp-shop :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select) { font-size: 16px !important; }
}
@media (max-width: 940px) and (max-height: 500px) {
  .mp-app.mp-shop:not(.mp-app--assistants) .mp-sidebar { position: static; }
  .mp-app.mp-shop .mp-mobile-menu { max-height: calc(var(--shop-visible-height, 100dvh) - 130px); }
}
