/*
 * TRT Diary mobile experience
 *
 * This file is loaded only for phone-sized viewports or coarse-pointer touch
 * tablets. Every rule is additionally scoped to the pre-paint
 * `.mobile-experience` class so the desktop cascade remains unchanged.
 */

@view-transition {
    navigation: auto;
}

html.mobile-experience {
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-safe-right: env(safe-area-inset-right, 0px);
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-safe-left: env(safe-area-inset-left, 0px);
    --mobile-gutter: clamp(0.75rem, 3.8vw, 1.15rem);
    --mobile-header-height: 4.15rem;
    --mobile-dock-height: 5rem;
    --mobile-radius: 1.1rem;
    --mobile-radius-small: 0.85rem;
    --mobile-shadow: 0 10px 30px rgba(15, 23, 42, 0.09);
    --mobile-tap: 3rem;
    --mobile-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: 16px !important;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

html.mobile-experience,
html.mobile-experience body {
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
}

html.mobile-experience body {
    min-height: 100svh;
    min-height: var(--mobile-viewport-height, 100svh);
    overscroll-behavior-x: none;
    -webkit-tap-highlight-color: transparent;
}

html.mobile-experience :where(button, a, input, select, textarea, summary) {
    touch-action: manipulation;
}

html.mobile-experience :where(input, select, textarea) {
    max-width: 100%;
    font-size: 16px !important;
}

/* Keep text-entry values readable and consistent throughout the admin area. */
html.mobile-experience .admin-page-content :where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
    select,
    textarea,
    option
) {
    text-align: left !important;
}

html.mobile-experience .admin-page-content select {
    text-align-last: left;
}

html.mobile-experience :where(input[type="checkbox"], input[type="radio"]) {
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    accent-color: #1A7A84;
}

html.mobile-experience :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]),
    select,
    textarea
) {
    min-height: var(--mobile-tap);
    border-radius: var(--mobile-radius-small) !important;
}

html.mobile-experience :where(
    button,
    [role="button"],
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    .mobile-touch-btn
) {
    min-height: var(--mobile-tap);
}

html.mobile-experience :where(input, select, textarea, button, a[href], summary):focus-visible {
    outline: 3px solid rgba(26, 122, 132, 0.35) !important;
    outline-offset: 2px;
}

html.mobile-experience :where(button, [role="button"], a[href][class]):active {
    transform: scale(0.98);
    transition: transform 70ms linear;
}

html.mobile-experience :where(img, svg, video, canvas) {
    max-width: 100%;
}

/*
 * Mobile layout contract
 *
 * Grid and flex children default to an intrinsic minimum width. A long nav,
 * table, generated URL or desktop-sized component can therefore widen the
 * whole track even when its parent says width:100%. Let mobile page regions
 * shrink to the viewport and give genuinely wide content its own scroller.
 */
html.mobile-experience :where(
    .app-main,
    .app-content-container,
    .home-shell,
    .home-nav,
    .home-main,
    .public-shell,
    .public-nav,
    .public-main,
    .sample-shell,
    .sample-nav,
    .auth-nav-card,
    main,
    section,
    article,
    aside,
    header,
    footer,
    nav,
    form,
    fieldset,
    div
) {
    min-width: 0;
}

html.mobile-experience :where(.home-shell, .public-shell) {
    grid-template-columns: minmax(0, 1fr) !important;
}

html.mobile-experience :where(fieldset, pre, iframe, embed, object) {
    max-width: 100%;
}

html.mobile-experience :where(pre, .blog-content table, .blog-content iframe, .blog-content embed, .blog-content object) {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

html.mobile-experience :where(
    .blog-content,
    .blog-content p,
    .blog-content li,
    .blog-content a,
    .public-main p,
    .public-main li,
    .public-main a,
    .public-main dd,
    td,
    th
) {
    overflow-wrap: anywhere;
    word-break: normal;
}

html.mobile-experience .guide-citations ul {
    grid-template-columns: minmax(0, 1fr) !important;
}

html.mobile-experience .guide-citations li {
    width: 100%;
    min-width: 0;
}

html.mobile-experience :where(.mobile-table-region, .mobile-scroll-table, .guide-table) {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
}

html.mobile-experience .mobile-table-region > table {
    width: max-content;
    min-width: 100%;
}

html.mobile-experience :where(.mobile-table-region, .mobile-scroll-table):focus-visible {
    border-radius: var(--mobile-radius-small);
    outline: 3px solid rgba(26, 122, 132, 0.3);
    outline-offset: 2px;
}

/* Authenticated application shell --------------------------------------- */

html.mobile-experience.is-mobile-browser .app-header {
    padding-top: var(--mobile-safe-top);
    border-bottom-color: color-mix(in srgb, var(--nav-border) 82%, transparent) !important;
    background: color-mix(in srgb, var(--nav-bg) 97%, transparent) !important;
    /*
     * backdrop-filter makes this fixed header a containing block for its
     * fixed mobile-nav descendant, which pins the "bottom" dock to the
     * header instead of the viewport.
     */
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

html.mobile-experience.is-mobile-browser .app-header-bar {
    height: var(--mobile-header-height) !important;
    min-height: var(--mobile-header-height);
    gap: 0.45rem !important;
    padding: 0 max(var(--mobile-gutter), var(--mobile-safe-right)) 0 max(var(--mobile-gutter), var(--mobile-safe-left)) !important;
}

html.mobile-experience.is-mobile-browser .app-brand-group {
    min-width: 0;
    gap: 0 !important;
}

html.mobile-experience.is-mobile-browser .app-logo {
    width: auto !important;
    height: 2.65rem !important;
    max-width: min(9.25rem, 38vw) !important;
}

html.mobile-experience.is-mobile-browser .app-logo-settings-link {
    display: none !important;
}

html.mobile-experience.is-mobile-browser .app-user {
    gap: 0.25rem !important;
}

html.mobile-experience.is-mobile-browser .app-user-actions {
    gap: 0.12rem !important;
}

html.mobile-experience.is-mobile-browser .app-user-avatar {
    width: 2.75rem !important;
    height: 2.75rem !important;
}

html.mobile-experience.is-mobile-browser :where(.app-user-icon-link, .app-theme-button, .app-logout-button) {
    width: 2.75rem !important;
    height: 2.75rem !important;
    min-width: 2.75rem !important;
    min-height: 2.75rem !important;
    border-radius: 0.85rem !important;
}

html.mobile-experience.is-mobile-browser .app-user-icon-link {
    display: none !important;
}

html.mobile-experience.is-mobile-browser .app-mobile-nav {
    position: fixed !important;
    z-index: 70;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex !important;
    align-items: stretch !important;
    gap: 0.2rem !important;
    width: 100%;
    height: auto !important;
    min-height: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom));
    padding: 0.42rem max(0.55rem, var(--mobile-safe-right)) calc(0.42rem + var(--mobile-safe-bottom)) max(0.55rem, var(--mobile-safe-left)) !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-padding-inline: 0.55rem;
    scroll-snap-type: x proximity;
    background: color-mix(in srgb, var(--nav-bg) 91%, transparent);
    border-top: 1px solid var(--nav-border);
    box-shadow: 0 -12px 34px rgba(15, 23, 42, 0.12);
    -webkit-backdrop-filter: saturate(170%) blur(22px);
    backdrop-filter: saturate(170%) blur(22px);
    transition: transform 180ms var(--mobile-ease), opacity 180ms ease;
}

html.mobile-experience.is-mobile-browser .app-mobile-nav-link {
    flex: 0 0 4.25rem !important;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    width: 4.25rem !important;
    min-width: 4.25rem !important;
    height: 3.85rem !important;
    min-height: 3.85rem !important;
    padding: 0.25rem !important;
    border: 1px solid transparent !important;
    border-radius: 0.95rem !important;
    color: var(--c-muted) !important;
    background: transparent !important;
    box-shadow: none !important;
    scroll-snap-align: center;
}

html.mobile-experience.is-mobile-browser .app-mobile-nav-link svg {
    width: 1.32rem !important;
    height: 1.32rem !important;
    min-width: 1.32rem !important;
    flex-basis: 1.32rem !important;
}

html.mobile-experience.is-mobile-browser .app-mobile-nav-link .sr-only {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
    text-align: center;
    color: inherit;
    font-size: 0.625rem;
    font-weight: 780;
    line-height: 1.05;
    letter-spacing: 0;
}

html.mobile-experience.is-mobile-browser .app-mobile-nav-link.is-active {
    color: #fff !important;
    background: #1A7A84 !important;
    border-color: #1A7A84 !important;
    box-shadow: 0 7px 18px rgba(26, 122, 132, 0.24) !important;
}

html.mobile-experience.is-mobile-browser .app-mobile-nav-link.is-hot:not(.is-active) {
    color: #fff !important;
    background: #C41230 !important;
    border-color: #C41230 !important;
    box-shadow: 0 7px 18px rgba(196, 18, 48, 0.22) !important;
}

html.mobile-experience.is-mobile-browser .app-mobile-nav-link--child::before {
    display: none;
}

html.mobile-experience.is-mobile-browser .app-main {
    min-height: 100svh !important;
    padding-top: calc(var(--mobile-header-height) + var(--mobile-safe-top)) !important;
    padding-bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.75rem) !important;
}

html.mobile-experience.is-mobile-browser .app-content-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: var(--mobile-gutter) max(var(--mobile-gutter), var(--mobile-safe-right)) var(--mobile-gutter) max(var(--mobile-gutter), var(--mobile-safe-left)) !important;
}

html.mobile-experience.is-mobile-browser .mobile-page-head {
    align-items: flex-start;
    gap: 0.75rem;
}

html.mobile-experience.is-mobile-browser .mobile-page-title {
    font-size: clamp(1.55rem, 7vw, 2rem);
    line-height: 1.08;
    text-wrap: balance;
}

html.mobile-experience.is-mobile-browser .mobile-page-head-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    width: 100%;
    gap: 0.55rem;
}

/* Keep the calendar controls compact without changing other mobile pages. */
@media (max-width: 767px) {
    html.mobile-experience.is-mobile-browser .calendar-page > .mobile-page-head .mobile-page-head-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.4rem;
    }

    html.mobile-experience.is-mobile-browser .calendar-page > .mobile-page-head .mobile-page-head-actions .calendar-toolbar-btn {
        min-width: 0;
        min-height: 2.5rem;
        padding: 0.4rem 0.5rem;
        border-radius: 0.65rem;
        font-size: 0.78rem;
    }

    html.mobile-experience.is-mobile-browser .calendar-page > .calendar-action-toolbar {
        width: 100%;
        max-width: 100%;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 0.4rem;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.4rem;
        scroll-padding-inline: 0.4rem;
        scroll-snap-type: x proximity;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    html.mobile-experience.is-mobile-browser .calendar-page > .calendar-action-toolbar::-webkit-scrollbar {
        display: none;
    }

    html.mobile-experience.is-mobile-browser .calendar-page > .calendar-action-toolbar .calendar-compact-action,
    html.mobile-experience.is-mobile-browser .calendar-page > .calendar-action-toolbar .calendar-compact-action:hover,
    html.mobile-experience.is-mobile-browser .calendar-page > .calendar-action-toolbar .calendar-compact-action:focus-visible,
    html.mobile-experience.is-mobile-browser .calendar-page > .calendar-action-toolbar .calendar-compact-action.is-expanded {
        flex: 0 0 2.75rem;
        width: 2.75rem;
        min-width: 2.75rem;
        max-width: 2.75rem;
        min-height: 2.75rem;
        height: 2.75rem;
        gap: 0;
        padding: 0.55rem;
        border-radius: 0.65rem;
        scroll-snap-align: start;
    }

    html.mobile-experience.is-mobile-browser .calendar-page > .calendar-action-toolbar .calendar-compact-label {
        display: none;
    }
}

html.mobile-experience.is-mobile-browser :where(
    .diary-card,
    .food-card,
    .profile-card,
    .measurements-card,
    .morning-card,
    .reports-panel,
    .checkin-panel,
    .admin-panel,
    .forum-side-panel,
    .sample-panel
) {
    border-radius: var(--mobile-radius) !important;
    box-shadow: var(--mobile-shadow) !important;
}

html.mobile-experience.is-mobile-browser :where(.app-flash-stack.app-toast-top-left, .app-flash-stack.app-toast-top-right, .app-flash-stack.app-toast-top-middle) {
    top: calc(var(--mobile-safe-top) + 0.5rem);
}

html.mobile-experience.is-mobile-browser :where(.app-flash-stack.app-toast-bottom-left, .app-flash-stack.app-toast-bottom-right) {
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.55rem);
}

html.mobile-experience.is-mobile-browser .reward-popup-stack {
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.65rem) !important;
}

/*
 * Keep Coach launchers above the navigation dock so they never cover a
 * destination. The button keeps a 44px touch target while the portrait remains
 * visually compact.
 */
html.mobile-experience.is-mobile-browser .nld-widget {
    right: max(0.15rem, var(--mobile-safe-right)) !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.55rem) !important;
}

html.mobile-experience.is-mobile-browser .nld-avatar-button {
    box-sizing: border-box;
    width: 2.75rem !important;
    height: 2.75rem !important;
    min-width: 2.75rem !important;
    min-height: 2.75rem !important;
    padding: 0.45rem !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible;
}

html.mobile-experience.is-mobile-browser .nld-avatar-button img {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    border: 2px solid var(--card-bg);
    border-radius: 999px;
    box-shadow: 0 7px 18px rgba(15, 23, 42, 0.2);
}

html.mobile-experience.is-mobile-browser .nld-avatar-button:is(:hover, :focus-visible, .is-active) {
    border: 0 !important;
    box-shadow: none !important;
}

html.mobile-experience.is-mobile-browser .nld-avatar-button:is(:hover, :focus-visible, .is-active) img {
    border-color: #1A7A84;
    box-shadow: 0 9px 22px rgba(26, 122, 132, 0.28);
}

html.mobile-experience.is-mobile-browser .nld-panel:not([hidden]) {
    margin-bottom: 0.5rem;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble {
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.7rem) !important;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble:not(.is-mobile-open) {
    right: max(0.15rem, var(--mobile-safe-right)) !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.55rem) !important;
    left: auto !important;
    z-index: 71;
    width: 2.75rem !important;
    animation: none;
    pointer-events: auto;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble:not(.is-mobile-open) .trt-coach-bubble__panel {
    display: none !important;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble:not(.is-mobile-open) .trt-coach-bubble__mobile-launcher {
    box-sizing: border-box;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.675rem;
    border: 0;
    border-radius: 999px !important;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble__mobile-avatar {
    display: grid;
    place-items: center;
    width: 1.4rem;
    height: 1.4rem;
    border: 1px solid var(--card-bg);
    border-radius: 999px;
    background: #22384A;
    color: #fff;
    box-shadow: 0 7px 18px rgba(15, 23, 42, 0.2);
    font-size: 0.48rem;
    font-weight: 900;
    line-height: 1;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble.is-female .trt-coach-bubble__mobile-avatar {
    background: #C41230;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble__mobile-launcher:is(:hover, :focus-visible, :active) .trt-coach-bubble__mobile-avatar {
    border-color: #1A7A84;
    box-shadow: 0 9px 22px rgba(26, 122, 132, 0.28);
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble.is-mobile-open {
    right: 0.75rem !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.7rem) !important;
    left: 0.75rem !important;
    z-index: 90;
    width: auto !important;
    animation: none;
}

html.mobile-experience.is-mobile-browser .trt-coach-bubble.is-mobile-open .trt-coach-bubble__mobile-launcher {
    display: none;
}

html.mobile-experience.is-mobile-browser:has(.trt-coach-bubble:not([hidden])) .nld-widget {
    right: max(3rem, calc(var(--mobile-safe-right) + 2.75rem)) !important;
}

html.mobile-experience.is-mobile-browser .nld-widget:has(.nld-panel:not([hidden])) {
    right: max(0.15rem, var(--mobile-safe-right)) !important;
}

html.mobile-experience.is-mobile-browser:has(.nld-panel:not([hidden])) .trt-coach-bubble:not(.is-mobile-open),
html.mobile-experience.is-mobile-browser:has(.trt-coach-bubble.is-mobile-open) .nld-widget {
    opacity: 0;
    pointer-events: none;
}

html.mobile-experience.is-mobile-browser .ai-coach-standalone-launcher {
    right: max(0.15rem, var(--mobile-safe-right)) !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.55rem) !important;
    z-index: 71;
    width: 2.75rem !important;
    height: 2.75rem !important;
    min-width: 2.75rem !important;
    min-height: 2.75rem !important;
}

html.mobile-experience.is-mobile-browser:has(.food-mobile-bar) :where(
    .nld-widget,
    .trt-coach-bubble,
    .ai-coach-standalone-launcher
) {
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 5.4rem) !important;
}

html.mobile-experience.mobile-keyboard-open .app-mobile-nav {
    opacity: 0;
    pointer-events: none;
    transform: translateY(115%);
}

html.mobile-experience.mobile-keyboard-open :where(.reward-popup-stack, .trt-coach-bubble) {
    bottom: calc(var(--mobile-safe-bottom) + 0.5rem) !important;
}

html.mobile-experience.mobile-keyboard-open .trt-coach-bubble.is-mobile-open {
    bottom: calc(var(--mobile-safe-bottom) + 0.5rem) !important;
}

html.mobile-experience.mobile-keyboard-open .nld-widget:not(:has(.nld-panel:not([hidden]))) {
    opacity: 0;
    pointer-events: none;
}

html.mobile-experience.mobile-keyboard-open .nld-panel:not([hidden]) {
    margin-bottom: 0.5rem;
}

html.mobile-experience.mobile-keyboard-open :where(.ai-coach-standalone-launcher, .food-mobile-bar) {
    opacity: 0;
    pointer-events: none;
    transform: translateY(115%);
}

/* Native-feeling bottom sheets for action dialogs. */
html.mobile-experience :where(
    .dashboard-add-modal,
    .quick-workout-modal,
    .profile-modal,
    .download-modal,
    .calendar-body-progress-modal,
    .admin-image-regenerate-modal
) {
    align-items: flex-end !important;
    place-items: end stretch !important;
    padding: 0 !important;
}

html.mobile-experience :where(
    .dashboard-add-panel,
    .quick-workout-panel,
    .profile-modal-panel,
    .download-modal-panel,
    .calendar-body-progress-panel,
    .admin-image-regenerate-modal__panel
) {
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(92dvh, var(--mobile-viewport-height, 92dvh)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin: 0 !important;
    padding-bottom: max(1rem, var(--mobile-safe-bottom)) !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-radius: 1.35rem 1.35rem 0 0 !important;
    box-shadow: 0 -18px 60px rgba(2, 6, 12, 0.28) !important;
}

/* Page-specific mobile layers that share the application shell. */
html.mobile-experience.is-mobile-browser .food-mobile-bar {
    right: max(var(--mobile-gutter), var(--mobile-safe-right)) !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.65rem) !important;
    left: max(var(--mobile-gutter), var(--mobile-safe-left)) !important;
    z-index: 69 !important;
    transition: transform 180ms var(--mobile-ease), opacity 180ms ease;
}

html.mobile-experience.is-mobile-browser .food-shell:has(.food-mobile-bar),
html.mobile-experience.is-mobile-browser .food-shell {
    padding-bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 5.35rem) !important;
}

html.mobile-experience .diary-photo-modal {
    top: var(--mobile-viewport-offset-top, 0px) !important;
    right: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    width: 100% !important;
    height: var(--mobile-viewport-height, 100dvh) !important;
}

html.mobile-experience .diary-photo-modal-content {
    width: 100% !important;
    height: var(--mobile-viewport-height, 100dvh) !important;
}

html.mobile-experience .diary-photo-frame {
    padding:
        calc(3.7rem + var(--mobile-safe-top))
        max(3.25rem, calc(var(--mobile-safe-right) + 2.7rem))
        calc(4.35rem + var(--mobile-safe-bottom))
        max(3.25rem, calc(var(--mobile-safe-left) + 2.7rem)) !important;
}

html.mobile-experience .diary-photo-close {
    position: absolute !important;
    top: calc(0.65rem + var(--mobile-safe-top)) !important;
    right: max(0.65rem, var(--mobile-safe-right)) !important;
}

html.mobile-experience .diary-photo-arrow {
    position: absolute !important;
}

html.mobile-experience .diary-photo-arrow[data-photo-prev] {
    left: max(0.35rem, var(--mobile-safe-left)) !important;
}

html.mobile-experience .diary-photo-arrow[data-photo-next] {
    right: max(0.35rem, var(--mobile-safe-right)) !important;
}

html.mobile-experience .diary-photo-meta {
    position: absolute !important;
    bottom: calc(0.65rem + var(--mobile-safe-bottom)) !important;
    width: auto !important;
    max-width: calc(100% - var(--mobile-safe-left) - var(--mobile-safe-right) - 1rem) !important;
}

html.mobile-experience :where(.diary-info-tip-text, .morning-info-tip-text) {
    position: fixed !important;
    z-index: 100 !important;
    top: auto !important;
    right: max(var(--mobile-gutter), var(--mobile-safe-right)) !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.7rem) !important;
    left: max(var(--mobile-gutter), var(--mobile-safe-left)) !important;
    width: auto !important;
    max-width: none !important;
    transform: translateY(0.3rem) scale(0.98) !important;
    transform-origin: bottom center !important;
}

html.mobile-experience :where(.diary-info-tip, .morning-info-tip):is(:hover, :focus, :focus-within) :where(.diary-info-tip-text, .morning-info-tip-text) {
    transform: none !important;
}

html.mobile-experience .calendar-body-progress-head {
    position: sticky;
    z-index: 2;
    top: 0;
    align-items: center !important;
    padding: 0.85rem var(--mobile-gutter) 0.7rem !important;
    background: #fff;
}

html.mobile-experience .calendar-body-progress-head > div {
    min-width: 0;
}

html.mobile-experience .calendar-body-progress-head h2 {
    font-size: 1.15rem !important;
}

html.mobile-experience .calendar-body-progress-head p {
    font-size: 0.78rem !important;
    line-height: 1.35 !important;
}

html.mobile-experience .calendar-body-progress-close {
    min-width: 2.75rem !important;
    min-height: 2.75rem !important;
    padding-inline: 0.75rem !important;
}

html.mobile-experience .calendar-body-progress-body {
    padding: 0.75rem var(--mobile-gutter) max(1rem, var(--mobile-safe-bottom)) !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    grid-template-areas:
        "viewport viewport"
        "previous next";
    gap: 0.6rem !important;
    max-width: 100% !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-viewport {
    grid-area: viewport;
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-preview {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 3.5rem !important;
    grid-template-columns: 3rem minmax(0, 1fr) !important;
    grid-template-rows: 1fr !important;
    align-items: center !important;
    gap: 0.5rem !important;
    padding: 0.35rem !important;
    border-radius: 0.75rem !important;
    text-align: left !important;
    touch-action: manipulation;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-preview.is-far {
    display: none !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-preview.is-near {
    opacity: 1 !important;
    transform: none !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-preview[data-body-progress-prev] {
    grid-area: previous;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-preview[data-body-progress-next] {
    grid-area: next;
    grid-template-columns: minmax(0, 1fr) 3rem !important;
    text-align: right !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-preview-frame {
    width: 3rem !important;
    height: 3rem !important;
    min-height: 3rem !important;
    border-radius: 0.6rem !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-preview-frame img {
    max-height: 3rem !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-preview[data-body-progress-next] .body-progress-preview-frame {
    order: 2;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-carousel-preview[data-body-progress-next] .body-progress-preview-caption {
    order: 1;
    justify-items: end;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-preview-caption {
    min-width: 0;
    font-size: 0.68rem !important;
    line-height: 1.2 !important;
}

html.mobile-experience .calendar-body-progress-panel .body-progress-photo-item img {
    max-height: min(55svh, 32rem) !important;
}

html.mobile-experience.is-mobile-browser .profile-body-metrics-panel {
    top: calc(var(--mobile-header-height) + var(--mobile-safe-top) + 0.5rem) !important;
    right: max(0.6rem, var(--mobile-safe-right)) !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.6rem) !important;
    left: max(0.6rem, var(--mobile-safe-left)) !important;
    width: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

html.mobile-experience.is-mobile-browser .goal-edit > form {
    right: max(0.75rem, var(--mobile-safe-right)) !important;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-safe-bottom) + 0.65rem) !important;
    left: max(0.75rem, var(--mobile-safe-left)) !important;
    width: auto !important;
    max-height: min(70dvh, calc(var(--mobile-viewport-height, 100dvh) - var(--mobile-header-height) - var(--mobile-dock-height) - 2rem)) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

html.mobile-experience .admin-image-regenerate-modal__actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
}

html.mobile-experience .blog-content :where(img, video, canvas, svg) {
    width: auto;
    height: auto;
    max-width: 100% !important;
}

/* Public, marketing and authentication shells -------------------------- */

html.mobile-experience :where(.home-nav, .public-nav, .sample-nav, .auth-nav-card) {
    top: 0;
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    padding: calc(0.55rem + var(--mobile-safe-top)) max(var(--mobile-gutter), var(--mobile-safe-right)) 0.55rem max(var(--mobile-gutter), var(--mobile-safe-left)) !important;
    background: color-mix(in srgb, #fff 90%, transparent) !important;
    -webkit-backdrop-filter: saturate(160%) blur(18px);
    backdrop-filter: saturate(160%) blur(18px);
}

html.mobile-experience :where(.home-logo, .public-logo, .sample-logo, .auth-nav-card__logo) {
    align-self: center;
}

html.mobile-experience :where(.home-logo, .public-logo, .sample-logo, .auth-nav-card__logo) img {
    width: auto !important;
    height: 2.75rem !important;
}

html.mobile-experience :where(.home-nav-actions, .public-nav-actions, .sample-nav-actions, .auth-nav-card__actions) {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    gap: 0.45rem !important;
    width: 100% !important;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

html.mobile-experience :where(.home-nav-actions, .public-nav-actions, .sample-nav-actions, .auth-nav-card__actions)::-webkit-scrollbar {
    display: none;
}

html.mobile-experience :where(.home-link, .home-button, .public-link, .public-button, .sample-link, .sample-button, .auth-nav-card__link, .auth-nav-card__button) {
    flex: 0 0 auto !important;
    width: auto !important;
    min-height: 2.75rem !important;
    padding-inline: 0.9rem !important;
    border-radius: 999px !important;
    scroll-snap-align: start;
}

html.mobile-experience :where(.home-button, .public-button, .sample-button, .auth-nav-card__button) {
    order: -1;
}

html.mobile-experience :where(.home-main, .public-main, .sample-shell) {
    width: 100%;
    max-width: 100%;
    padding-right: max(var(--mobile-gutter), var(--mobile-safe-right)) !important;
    padding-left: max(var(--mobile-gutter), var(--mobile-safe-left)) !important;
}

html.mobile-experience :where(.home-main, .public-main) {
    padding-top: clamp(1.35rem, 6vw, 2.25rem) !important;
    padding-bottom: calc(2rem + var(--mobile-safe-bottom)) !important;
}

html.mobile-experience :where(.home-title, .public-title, .sample-title) {
    max-width: 100% !important;
    font-size: clamp(2.25rem, 11vw, 3.45rem) !important;
    line-height: 0.98 !important;
    text-wrap: balance;
}

html.mobile-experience :where(.home-copy, .public-copy, .sample-copy) {
    font-size: 1rem !important;
    line-height: 1.62 !important;
}

html.mobile-experience :where(.home-cta-row, .public-cta-row, .sample-cta-row) {
    display: grid !important;
    grid-template-columns: 1fr;
    align-items: stretch !important;
}

html.mobile-experience :where(.home-cta-row, .public-cta-row, .sample-cta-row) > a {
    width: 100% !important;
    min-height: var(--mobile-tap) !important;
}

html.mobile-experience :where(.home-product, .home-lead-form, .home-guide-card, .public-card, .sample-card) {
    border-radius: var(--mobile-radius) !important;
    box-shadow: var(--mobile-shadow) !important;
}

html.mobile-experience .home-guide-card img {
    aspect-ratio: 1200 / 760;
    object-fit: cover;
}

html.mobile-experience :where(.auth-shell, .register-shell, .reset-shell, .magic-shell) {
    min-height: var(--mobile-viewport-height, 100svh) !important;
    align-content: start;
    padding: var(--mobile-gutter) max(var(--mobile-gutter), var(--mobile-safe-right)) calc(var(--mobile-gutter) + var(--mobile-safe-bottom)) max(var(--mobile-gutter), var(--mobile-safe-left)) !important;
}

html.mobile-experience :where(.auth-card, .register-card, .reset-card, .magic-card, .mfa-card) {
    width: 100% !important;
    max-width: 32rem !important;
    padding: clamp(1.15rem, 5vw, 1.65rem) !important;
    border-radius: var(--mobile-radius) !important;
    box-shadow: var(--mobile-shadow) !important;
}

html.mobile-experience :where(.register-logo, .reset-logo, .magic-logo) {
    top: calc(var(--mobile-safe-top) + 0.5rem) !important;
}

html.mobile-experience :where(.auth-btn, .register-button, .reset-button, .magic-button) {
    min-height: var(--mobile-tap) !important;
    border-radius: var(--mobile-radius-small) !important;
}

html.mobile-experience .footer-card {
    padding-right: max(1rem, var(--mobile-safe-right)) !important;
    padding-bottom: calc(0.9rem + var(--mobile-safe-bottom)) !important;
    padding-left: max(1rem, var(--mobile-safe-left)) !important;
}

/* The public shell already has a complete legal/footer region. */
html.mobile-experience body > .public-shell + .footer-card-spacer,
html.mobile-experience body > .public-shell ~ .footer-card {
    display: none !important;
}

/* Shared mobile presentation for legacy admin pages that use admin tokens. */
html.mobile-experience .admin-page-content .admin-shell {
    display: grid;
    gap: 0.85rem;
    width: 100%;
}

html.mobile-experience .admin-page-content .admin-hero {
    display: grid !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
}

html.mobile-experience .admin-page-content .admin-kicker {
    margin: 0 0 0.2rem;
    color: var(--c-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

html.mobile-experience .admin-page-content .admin-hero h1 {
    margin: 0;
    color: var(--c-hi);
    font-size: clamp(1.55rem, 7vw, 2rem);
    line-height: 1.08;
}

html.mobile-experience .admin-page-content .admin-admin-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid var(--card-border);
    border-radius: var(--mobile-radius-small);
    background: var(--card-bg);
    padding: 0.7rem 0.8rem;
}

html.mobile-experience .admin-page-content .admin-admin-badge :where(span, strong) {
    min-width: 0;
    overflow-wrap: anywhere;
}

html.mobile-experience .admin-page-content .admin-stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.65rem !important;
}

html.mobile-experience .admin-page-content .admin-stats article,
html.mobile-experience .admin-page-content .admin-panel {
    border: 1px solid var(--card-border);
    border-radius: var(--mobile-radius) !important;
    background: var(--card-bg);
    box-shadow: var(--mobile-shadow) !important;
}

html.mobile-experience .admin-page-content .admin-stats article {
    padding: 0.8rem;
}

html.mobile-experience .admin-page-content .admin-stats :where(span, strong, p) {
    display: block;
    margin: 0;
    overflow-wrap: anywhere;
}

html.mobile-experience .admin-page-content .admin-stats span {
    color: var(--c-muted);
    font-size: 0.68rem;
    font-weight: 850;
    text-transform: uppercase;
}

html.mobile-experience .admin-page-content .admin-stats strong {
    margin-top: 0.2rem;
    color: var(--c-hi);
    font-size: 1.35rem;
}

html.mobile-experience .admin-page-content .admin-stats p {
    margin-top: 0.25rem;
    color: var(--c-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

html.mobile-experience .admin-page-content .admin-panel {
    padding: 0.8rem;
}

html.mobile-experience .admin-page-content .admin-panel-header {
    display: grid !important;
    gap: 0.65rem !important;
    margin-bottom: 0.75rem;
}

html.mobile-experience .admin-page-content .admin-panel-header :where(h2, p) {
    margin: 0;
}

html.mobile-experience .admin-page-content .admin-row-actions,
html.mobile-experience .admin-page-content .admin-row-actions a {
    width: 100%;
}

html.mobile-experience .admin-page-content .admin-alert {
    border: 1px solid var(--card-border);
    border-radius: var(--mobile-radius-small);
    padding: 0.75rem 0.85rem;
    overflow-wrap: anywhere;
}

html.mobile-experience .admin-page-content .admin-alert.success {
    border-color: rgba(4, 120, 87, 0.35);
    background: rgba(16, 185, 129, 0.1);
}

html.mobile-experience .admin-page-content .admin-alert.error {
    border-color: rgba(196, 18, 48, 0.35);
    background: rgba(196, 18, 48, 0.08);
}

html.mobile-experience .lead-rate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

html.mobile-experience .dashboard-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

html.mobile-experience .dashboard-actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

html.mobile-experience .dashboard-action {
    min-height: var(--mobile-tap) !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    text-align: center;
}

/*
 * Meal selectors use visually hidden native radios. The shared mobile form
 * sizing otherwise expands those absolutely positioned controls to the
 * viewport width, creating invisible horizontal overflow.
 */
html.mobile-experience :where(.food-meal-segments, .meal-builder-meals) input[type="radio"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-width: 1px !important;
    min-height: 1px !important;
    max-width: 1px !important;
    max-height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

html.mobile-experience :where(.food-meal-segments, .meal-builder-meals) input[type="radio"]:focus-visible + span {
    outline: 3px solid rgba(26, 122, 132, 0.35);
    outline-offset: 2px;
}

/* Keep manual lab fields compact while allowing both grid tracks to shrink. */
html.mobile-experience .manual-lab-row {
    width: 100% !important;
    min-width: 0 !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

html.mobile-experience .manual-lab-row :where(input, select, textarea, button) {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

/* Compact phones: show the logo mark without sacrificing account controls. */
@media (max-width: 374px) {
    html.mobile-experience {
        --mobile-gutter: 0.7rem;
    }

    html.mobile-experience.is-mobile-browser .app-logo-link {
        display: block !important;
        width: 3rem;
        overflow: hidden;
    }

    html.mobile-experience.is-mobile-browser .app-logo {
        width: 8rem !important;
        max-width: none !important;
        object-fit: initial;
        object-position: left center;
    }

    html.mobile-experience.is-mobile-browser :where(.app-user-avatar, .app-theme-button, .app-logout-button) {
        width: 2.6rem !important;
        height: 2.6rem !important;
        min-width: 2.6rem !important;
        min-height: 2.6rem !important;
    }

    html.mobile-experience :where(.home-title, .public-title, .sample-title) {
        font-size: clamp(2rem, 11vw, 2.5rem) !important;
    }

    html.mobile-experience .manual-lab-row {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

@media (max-width: 430px) {
    html.mobile-experience :where(.profile-dynamic-grid, .profile-dynamic-results) {
        grid-template-columns: 1fr !important;
    }

    html.mobile-experience .lead-rate-grid {
        grid-template-columns: 1fr !important;
    }

    html.mobile-experience .admin-page-content .admin-stats {
        grid-template-columns: 1fr !important;
    }

    html.mobile-experience .diary-photo-frame {
        padding-right: max(0.75rem, var(--mobile-safe-right)) !important;
        padding-left: max(0.75rem, var(--mobile-safe-left)) !important;
    }

    html.mobile-experience .diary-photo-arrow {
        top: auto !important;
        bottom: calc(0.55rem + var(--mobile-safe-bottom)) !important;
        width: 2.75rem !important;
        height: 2.75rem !important;
        transform: none !important;
    }

    html.mobile-experience .diary-photo-meta {
        bottom: calc(0.55rem + var(--mobile-safe-bottom)) !important;
        max-width: calc(100% - var(--mobile-safe-left) - var(--mobile-safe-right) - 7rem) !important;
        min-height: 2.75rem;
        margin-inline: auto;
    }
}

/* Touch tablets get a wider dock and two-column action layouts. */
@media (min-width: 768px) and (max-width: 1024px) and (any-pointer: coarse) {
    html.mobile-experience {
        --mobile-gutter: 1.25rem;
        --mobile-dock-height: 5.4rem;
    }

    html.mobile-experience.is-mobile-browser .app-mobile-nav {
        justify-content: safe center;
    }

    html.mobile-experience.is-mobile-browser .app-mobile-nav-link {
        flex-basis: 5rem !important;
        width: 5rem !important;
        min-width: 5rem !important;
    }

    html.mobile-experience :where(.home-cta-row, .public-cta-row, .sample-cta-row) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    html.mobile-experience {
        scroll-behavior: auto;
    }

    html.mobile-experience *,
    html.mobile-experience *::before,
    html.mobile-experience *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: more) {
    html.mobile-experience :where(button, input, select, textarea, a[href][class]) {
        border-width: 2px !important;
    }
}
