/* Mobile-only peach bottom bar and contextual search; desktop remains unchanged. */
.app-shell .ym-mobile-context-search,
.app-shell .ym-mobile-bottom-dock { display: none; }
@media (max-width: 760px) {
  .app-shell {
    scroll-padding-bottom: calc(107px + env(safe-area-inset-bottom));
  }

  /* An actual full-width peach block, rather than a blur fading away beside the AI. */
  .app-shell .ym-mobile-bottom-dock {
    display: flex;
    position: fixed;
    inset: auto 0 0;
    z-index: 10000;
    box-sizing: border-box;
    align-items: center;
    width: 100%;
    min-height: calc(85px + env(safe-area-inset-bottom));
    padding: 9px 104px calc(14px + env(safe-area-inset-bottom)) 24px;
    border-top: 1px solid #f3d3c8;
    border-radius: 0;
    background: linear-gradient(105deg, #fff0e6 0%, #ffede2 54%, #ffe6d7 100%);
    box-shadow: 0 -8px 30px rgba(95, 54, 68, .085);
    pointer-events: none;
  }
  .app-shell .ym-mobile-bottom-dock::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 2px;
    background: linear-gradient(90deg, #ef3f78, #ff8d67, #ffbb82);
    opacity: .38;
  }
  .app-shell .ym-mobile-bottom-dock-title {
    display: block;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: Fredoka, Montserrat, sans-serif;
    font-size: clamp(22px, 6vw, 26px);
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -.015em;
    background: linear-gradient(100deg, #e93670, #fb7457 64%, #ffa35c);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }

  /* Free the space previously occupied by the large page title. */
  .app-shell .workspace,
  body[data-app-view="runs"] .app-shell .workspace {
    padding-top: 10px !important;
    padding-bottom: calc(111px + env(safe-area-inset-bottom)) !important;
    scroll-padding-bottom: calc(107px + env(safe-area-inset-bottom));
  }
  .app-shell .topbar,
  body[data-app-view="runs"] .app-shell .topbar {
    display: flex !important;
    position: relative !important;
    z-index: 10001 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0 !important;
    width: 100%;
    min-height: 0 !important;
    margin: 0 0 12px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  .app-shell .topbar::before,
  .app-shell .topbar::after { display: none !important; }

  /* Keep the real page heading in the DOM; show its live text in the bottom dock. */
  .app-shell .topbar .topbar-title-block,
  body[data-app-view="runs"] .app-shell .topbar > .topbar-title-block {
    display: none !important;
  }

  /* Keep the original AI control and chat; only dock the closed bubble visually. */
  #ym-mobile-feedback-widget {
    right: 18px !important;
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }

  /* The old top-right magnifier is redundant now that search is always visible. */
  .app-shell .sidebar .ym-mobile-search-toggle { display: none !important; }
  .app-shell .topbar-actions.ym-unified-client-tools,
  body.ym-mobile-search-open .app-shell .topbar-actions.ym-unified-client-tools {
    display: flex !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    z-index: 20 !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .app-shell .ym-current-client { display: none !important; }
  .app-shell .ym-global-client-search {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .app-shell .ym-global-client-search-field,
  .app-shell .ym-mobile-context-search {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 49px !important;
    margin: 0;
    padding: 0 12px !important;
    border: 1px solid rgba(206, 165, 181, .33) !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, .86) !important;
    box-shadow: 0 6px 20px rgba(70, 42, 63, .045) !important;
  }
  .app-shell .ym-global-client-search-field:focus-within,
  .app-shell .ym-mobile-context-search:focus-within {
    border-color: rgba(239, 63, 120, .55) !important;
    box-shadow: 0 0 0 3px rgba(239, 63, 120, .08) !important;
  }
  .app-shell .ym-global-client-search-icon {
    position: relative;
    flex: 0 0 28px;
    width: 28px;
    height: 22px;
    font-size: 0 !important;
  }
  .app-shell .ym-global-client-search-icon::before {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23818a9d' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.8' cy='10.8' r='6.6'/%3E%3Cpath d='m16 16 4.5 4.5'/%3E%3C/svg%3E");
  }
  .app-shell #ym-global-client-search-input,
  .app-shell #ym-mobile-context-search-input {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 5px !important;
    border: 0 !important;
    outline: none !important;
    background: transparent !important;
    color: #1f2940 !important;
    font: 500 16px/1.3 Montserrat, sans-serif !important;
    box-shadow: none !important;
  }
  .app-shell #ym-global-client-search-input::placeholder,
  .app-shell #ym-mobile-context-search-input::placeholder {
    color: #9b9cab;
    opacity: 1;
  }
  .app-shell .ym-mobile-context-search {
    display: none;
    gap: 10px;
  }
  .app-shell .ym-mobile-context-search svg {
    width: 21px;
    height: 21px;
    flex: 0 0 21px;
    fill: none;
    stroke: #818a9d;
    stroke-width: 2;
    stroke-linecap: round;
  }
  body.ym-mobile-context-search-active .app-shell .ym-global-client-search {
    display: none !important;
  }
  body.ym-mobile-context-search-active .app-shell .ym-mobile-context-search {
    display: flex !important;
  }

  /* Keep page-specific search logic intact but avoid a duplicate field in cards. */
  body.ym-mobile-context-search-active[data-app-view="email"] #email-view .ym-inbox-list-head > .ym-inbox-search,
  body.ym-mobile-context-search-active[data-app-view="crm"] #crm-view .crm-search-field,
  body.ym-mobile-context-search-active[data-app-view="invoice-workspace"] #invoice-workspace-view .ym-workspace-search {
    display: none !important;
  }

  /* Full-screen assistant, dialogs and task-customisation overlays take priority. */
  #auth-screen:not(.hidden) ~ .app-shell .ym-mobile-bottom-dock,
  body.ym-task-customize-open .app-shell .ym-mobile-bottom-dock,
  body:has(#ym-mobile-feedback-widget:not(.ym-ai-expanded-page-mode) .ym-ai-panel.is-open) .app-shell .ym-mobile-bottom-dock,
  body:has(dialog[open]) .app-shell .ym-mobile-bottom-dock {
    display: none !important;
  }
}

@media (prefers-reduced-transparency: reduce) and (max-width: 760px) {
  .app-shell .ym-mobile-bottom-dock {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #fff0e6;
  }
}
