/* Final mobile chrome layer. Loaded last so legacy navigation rules cannot override it. */
/* The cue is injected by JavaScript before viewport checks run. Keep it
   hidden by default so it can never render as unstyled inline SVG on desktop. */
.sf-mobile-swipe-cue {
  display: none;
}

@media (max-width: 760px) {
  html,
  body.senti {
    max-width: 100%;
    overflow-x: clip;
  }

  .sf-nav-root {
    width: 100%;
    max-width: 100vw;
  }

  .sf-nav-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 60px;
    box-sizing: border-box;
    gap: 10px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .sf-nav-brand {
    min-width: 0 !important;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .sf-nav-brand__img {
    width: min(116px, 32vw) !important;
    max-width: min(116px, 32vw) !important;
  }

  .sf-nav-brand__by {
    display: none !important;
  }

  .sf-nav-mobile-actions {
    display: flex;
    min-width: 0;
    max-width: calc(100% - min(116px, 32vw) - 10px);
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 2px !important;
    margin-left: 0;
  }

  .sf-nav-mobile-actions .sf-nav-icon-btn,
  .sf-nav-mobile-actions .sf-nav-mobile-btn,
  .sf-nav-mobile-actions .sf-nav-burger {
    width: 32px !important;
    height: 36px !important;
    min-width: 32px !important;
    flex: 0 0 32px;
    padding: 0 !important;
    margin: 0 !important;
  }

  .sf-nav-mobile-actions .sf-nav-icon-btn > svg,
  .sf-nav-mobile-actions .sf-nav-mobile-btn > svg {
    width: 17px !important;
    height: 17px !important;
  }

  .sf-nav-mobile-actions .sf-nav-burger span {
    width: 16px;
  }

  body.senti {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .sf-mobile-app-bar {
    right: 0 !important;
    bottom: var(--sf-mobile-viewport-bottom, 0px) !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100vw;
    min-height: calc(72px + env(safe-area-inset-bottom)) !important;
    box-sizing: border-box;
    padding:
      6px
      max(4px, env(safe-area-inset-right))
      max(8px, calc(6px + env(safe-area-inset-bottom)))
      max(4px, env(safe-area-inset-left)) !important;
    overflow: visible;
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: bottom;
  }

  html.sf-mobile-pull-refresh .sf-mobile-app-bar {
    bottom: 0 !important;
    transition: none !important;
  }

  .sf-mobile-app-bar > a,
  .sf-mobile-app-bar > button {
    min-height: 54px !important;
    padding: 2px 0 3px;
  }

  .sf-mobile-app-bar img,
  .sf-mobile-app-bar svg {
    flex: 0 0 auto;
  }

  html.sf-mobile-keyboard-open .sf-mobile-app-bar {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 360px) {
  .sf-nav-shell {
    gap: 6px;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .sf-nav-brand__img {
    width: min(106px, 30vw) !important;
    max-width: min(106px, 30vw) !important;
  }

  .sf-nav-mobile-actions {
    max-width: calc(100% - min(106px, 30vw) - 6px);
    gap: 0 !important;
  }

  .sf-nav-mobile-actions .sf-nav-icon-btn,
  .sf-nav-mobile-actions .sf-nav-mobile-btn,
  .sf-nav-mobile-actions .sf-nav-burger {
    width: 30px !important;
    min-width: 30px !important;
    flex-basis: 30px;
  }
}

/* Dashboard finishing layer: the aura may breathe behind the identity instead of
   ending in a visible rectangle, while the analytical cards keep one alignment. */
.sf-dashboard-page .sf-dashboard-profile-module--collection .sf-family-analysis__heading,
.sf-dashboard-page .sf-dashboard-profile-module--collection .sf-family-analysis__heading > div,
.sf-dashboard-page .sf-dashboard-profile-module--collection .sf-family-analysis__heading h2,
.sf-dashboard-page .sf-dashboard-profile-module--collection .sf-family-analysis__heading p {
  width: 100% !important;
  text-align: center !important;
}

.sf-dashboard-page .sf-dashboard-profile-module--collection .sf-family-analysis__heading {
  align-items: center !important;
  justify-content: flex-start !important;
}

.sf-family-analysis__dashboard-detail {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  order: 2;
  margin: 18px auto 0;
  padding-top: 14px;
  color: #171513;
  font-size: 12px;
  font-weight: 750;
  pointer-events: none;
}

.sf-family-analysis__dashboard-detail > span {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

@media (max-width: 760px) {
  .sf-dashboard-page .sf-dashboard-hero,
  .sf-dashboard-page .sf-dashboard-identity-stage {
    overflow: visible !important;
  }

  .sf-dashboard-page .sf-dashboard-identity-stage {
    z-index: 1 !important;
    min-height: min(110vw, 450px) !important;
    isolation: auto !important;
  }

  .sf-dashboard-page .sf-dashboard-hero__copy {
    z-index: 3 !important;
  }

  .sf-dashboard-page .sf-dashboard-identity {
    position: relative;
    z-index: 2;
  }

  .sf-dashboard-page .sf-dashboard-hero__aura-background {
    top: 50% !important;
    left: 50% !important;
    width: min(138vw, 560px) !important;
    height: min(138vw, 560px) !important;
    overflow: visible !important;
    opacity: .88;
    transform: translate(-50%, -50%) !important;
    -webkit-mask-image: radial-gradient(circle at center, #000 0 52%, rgba(0, 0, 0, .94) 68%, rgba(0, 0, 0, .42) 84%, transparent 100%) !important;
    mask-image: radial-gradient(circle at center, #000 0 52%, rgba(0, 0, 0, .94) 68%, rgba(0, 0, 0, .42) 84%, transparent 100%) !important;
  }

  .sf-dashboard-page .sf-dashboard-hero__aura-background .sfa-aura {
    width: min(104vw, 430px) !important;
    height: min(104vw, 430px) !important;
  }

  .sf-dashboard-page .sf-dashboard-profile-module--collection .sf-family-analysis__heading,
  .sf-dashboard-page .sf-dashboard-profile-module--collection .sf-family-analysis__heading > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  .sf-mobile-swipe-host {
    position: relative !important;
  }

  .sf-mobile-swipe-cue {
    position: absolute;
    z-index: 8;
    inset: 0 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #9d7442;
    opacity: 0;
    transition: opacity .22s ease;
    pointer-events: none;
  }

  .sf-mobile-swipe-cue__arrow {
    display: grid;
    width: 24px;
    height: 34px;
    place-items: center;
    color: currentColor;
    font: 400 29px/1 Georgia, serif;
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
  }

  .sf-mobile-swipe-cue__arrow--previous {
    transform: translateX(3px);
  }

  .sf-mobile-swipe-cue__arrow--next {
    transform: translateX(-3px);
  }

  .sf-mobile-swipe-cue.can-go-previous .sf-mobile-swipe-cue__arrow--previous,
  .sf-mobile-swipe-cue.can-go-next .sf-mobile-swipe-cue__arrow--next {
    opacity: .72;
    transform: translateX(0);
  }

  .sf-mobile-swipe-host.is-swipe-cue-visible:not(.is-swipe-interacting) > .sf-mobile-swipe-cue {
    opacity: 1;
    animation: sf-mobile-swipe-breathe 1.9s ease-in-out infinite;
  }

  [data-sf-carousel] > [data-sf-carousel-dir],
  [data-sf-carousel] > [data-sf-carousel-prev],
  [data-sf-carousel] > [data-sf-carousel-next],
  [data-sf-carousel] > .sf-carousel-arrow,
  .sf-profile-carousel__arrow {
    display: none !important;
  }
}

@keyframes sf-mobile-swipe-breathe {
  0%, 100% { opacity: .42; }
  50% { opacity: .78; }
}

@media (prefers-reduced-motion: reduce) {
  .sf-mobile-swipe-cue { animation: none !important; }
}

/* Messenger conversation picker: desktop keeps the full sidebar, mobile gets
   one compact selected thread and an overlay list on demand. */
.sf-messenger-thread-picker {
  display: none;
}

@media (max-width: 700px) {
  .sf-messenger-list {
    position: relative;
    z-index: 24;
    max-height: none !important;
    overflow: visible !important;
    padding: 12px !important;
  }

  .sf-messenger-new,
  .sf-messenger-new-wrap > .sf-messenger-new,
  .sf-messenger-search {
    height: 54px !important;
    min-height: 54px !important;
  }

  .sf-messenger-search {
    flex: 0 0 54px;
    margin: 11px 0 8px !important;
  }

  .sf-messenger-thread-picker {
    display: grid;
    width: 100%;
    min-height: 64px;
    grid-template-columns: 42px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border: 1px solid rgba(178, 138, 86, .42);
    border-radius: 9px;
    background: linear-gradient(105deg, #fff, #fbf6ef);
    color: #171513;
    text-align: left;
    cursor: pointer;
  }

  .sf-messenger-thread-picker__copy {
    display: grid;
    min-width: 0;
    gap: 3px;
  }

  .sf-messenger-thread-picker__copy small,
  .sf-messenger-thread-picker__copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sf-messenger-thread-picker__copy small {
    color: #a1733d;
    font-size: 8px;
    font-weight: 780;
    letter-spacing: .12em;
    text-transform: uppercase;
  }

  .sf-messenger-thread-picker__copy strong {
    font-size: 14px;
  }

  .sf-messenger-thread-picker__chevron {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: #111;
    color: #fff;
    transition: transform .18s ease;
  }

  .sf-messenger-thread-picker__chevron svg {
    width: 16px;
    height: 16px;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
  }

  .sf-messenger-list.is-thread-picker-open .sf-messenger-thread-picker__chevron {
    transform: rotate(180deg);
  }

  .sf-messenger-list > .sf-messenger-threads {
    position: absolute;
    z-index: 40;
    top: calc(100% - 5px);
    right: 12px;
    left: 12px;
    display: none;
    max-height: min(48vh, 390px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 7px;
    border: 1px solid rgba(20, 20, 20, .12);
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 22px 55px rgba(24, 20, 16, .18);
  }

  .sf-messenger-list.is-thread-picker-open > .sf-messenger-threads {
    display: block;
  }

  .sf-messenger-list.is-finding-user > .sf-messenger-thread-picker,
  .sf-messenger-list.is-finding-user > .sf-messenger-threads {
    display: none !important;
  }

  .sf-messenger-chat {
    height: min(680px, calc(100dvh - 210px)) !important;
    min-height: 500px !important;
  }
}

/* Final mobile layout corrections shared by the dashboard, profile,
   collection and messenger. This file is loaded after the legacy layers. */
@media (max-width: 760px) {
  /* Keep the complete drawer (including its bottom border and account actions)
     above the persistent application bar. */
  .sf-nav-drawer__panel {
    box-sizing: border-box;
    width: calc(100vw - 12px) !important;
    height: calc(100dvh - 12px) !important;
    margin: 6px !important;
    padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important;
    scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .sf-nav-drawer__bottom {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  /* The general .senti-wrap carries desktop-oriented inner gutters. The
     profile should use the same mobile page gutter as the other main views. */
  .sf-profile-wrap.senti-wrap {
    box-sizing: border-box !important;
    width: calc(100% - 24px) !important;
    max-width: none !important;
    margin-inline: 12px !important;
    padding-inline: 0 !important;
  }

  /* Curated recommendation cards: one deliberate card position per swipe,
     with a small preview of the next card and a clearly visible product. */
  .sf-dashboard-page .sf-dashboard-recommendations--curated .sf-dashboard-recommendations__viewport {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-padding-inline: 0 42px;
    scroll-snap-type: x mandatory !important;
  }

  .sf-dashboard-page .sf-dashboard-recommendations--curated .sf-dashboard-recommendations__grid {
    display: grid !important;
    grid-auto-flow: column !important;
    grid-auto-columns: min(84vw, 315px) !important;
    grid-template-columns: none !important;
    gap: 11px !important;
    width: max-content !important;
    min-width: 100% !important;
    margin: 0 !important;
    padding: 0 38px 0 0 !important;
    overflow: visible !important;
  }

  .sf-dashboard-page .sf-dashboard-recommendations--curated .sf-dashboard-recommendation-card {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 390px !important;
    height: auto !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: always;
  }

  .sf-dashboard-page .sf-dashboard-recommendations--curated .sf-dashboard-recommendation-card__media {
    width: 100% !important;
    height: 220px !important;
    flex: 0 0 220px !important;
    padding: 12px !important;
    box-sizing: border-box !important;
    background: #faf9f7 !important;
  }

  .sf-dashboard-page .sf-dashboard-recommendations--curated .sf-dashboard-recommendation-card__media img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    padding: 0 !important;
    object-fit: contain !important;
    object-position: center !important;
  }

  .sf-dashboard-page .sf-dashboard-recommendations--curated .sf-dashboard-recommendation-card__copy {
    min-height: 168px;
    padding: 16px 15px 15px !important;
  }

  .sf-dashboard-page .sf-dashboard-recommendations--curated .sf-dashboard-recommendation-card__reason {
    min-height: 43px !important;
    font-size: 11px !important;
    line-height: 1.45 !important;
    -webkit-line-clamp: 3;
  }

  .sf-dashboard-page .sf-dashboard-recommendations__swipe-hints {
    top: 48% !important;
    right: 3px !important;
    left: 3px !important;
    display: flex !important;
  }

  .sf-dashboard-page .sf-dashboard-recommendations__swipe-hint {
    width: 24px !important;
    height: 34px !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 29px !important;
  }

  /* The selected conversation is already identified by the mobile picker.
     Preserve only the compact profile action in the chat header. */
  .sf-messenger-chat {
    grid-template-rows: 46px minmax(0, 1fr) auto !important;
  }

  .sf-messenger-chat__header {
    min-height: 46px !important;
    height: 46px !important;
    justify-content: flex-end !important;
    padding-inline: 12px !important;
  }

  .sf-messenger-chat__header .sf-messenger-chat__person {
    display: none !important;
  }

  .sf-messenger-chat__header .sf-messenger-icon-btn {
    width: 32px;
    height: 32px;
  }

  /* Native mobile select controls do not consistently respect min-height. */
  #sentiCollectionPage .sf-collection-toolbar__add,
  #sentiCollectionPage .sf-collection-filter .senti-input,
  #sentiCollectionPage .sf-collection-filter .senti-select {
    box-sizing: border-box !important;
    height: 44px !important;
    min-height: 44px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* Note editors are true viewport modals, not bottom sheets. They sit above
     the persistent app bar and remain fully scrollable on short screens. */
  .sf-note-modal {
    z-index: 10150 !important;
    display: grid !important;
    align-items: center !important;
    justify-items: center !important;
    padding:
      max(14px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left)) !important;
  }

  .sf-note-modal[hidden] {
    display: none !important;
  }

  .sf-note-modal__panel {
    width: min(100%, 620px) !important;
    max-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 20px 16px 16px !important;
  }

  .sf-note-modal__textarea {
    min-height: clamp(170px, 38dvh, 280px) !important;
  }
}
