/*
 * Shared mobile interaction and layer contract.
 *
 * This stylesheet is loaded after page/theme styles. Every rule is scoped to
 * small viewports so the established desktop layout remains unchanged.
 */

@media (max-width: 920px), (hover: none) and (pointer: coarse) and (max-width: 1366px) {
    :root {
        --fuuvo-mobile-edge: max(12px, env(safe-area-inset-left));
        --fuuvo-mobile-control: 44px;
        --fuuvo-mobile-sheet-z: 320;
    }

    html {
        max-width: 100%;
        overflow-x: hidden;
        touch-action: pan-y !important;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        max-width: 100%;
        overflow-x: clip;
    }

    /* The legacy creation shell switches to a single column at 900px. Keep
     * the shared 920px mobile breakpoint consistent so 901-920px landscape
     * phones do not leave the workspace trapped in the sidebar grid track. */
    body > .creation-app {
        display: block !important;
        grid-template-columns: none !important;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    :where(main, section, article, aside, form, fieldset, header, footer, nav, div) {
        min-width: 0;
    }

    :where(h1, h2, h3, h4, p, li, label, small, strong, span, a, button) {
        overflow-wrap: break-word;
        word-break: normal;
    }

    /* Compact shared heading scale. Limit page and section headings without
     * enlarging the deliberately small headings used inside tool cards. */
    html body :is(
        .creation-heading,
        .detail-heading,
        .analysis-heading,
        .analysis-home-heading,
        .food-heading,
        .food-results-heading,
        .food-detail-heading,
        .fortune-hero,
        .fortune-result-heading,
        .inspiration-heading,
        .office-heading,
        .office-tool-hero,
        .research-home-heading,
        .research-heading,
        .portal-heading,
        .portal-hero,
        .sr-hero,
        .ss-hero,
        .rr-heading,
        .ac-heading,
        .dc-heading,
        .ai-card-heading,
        .legal-article-hero,
        .community-rules-header,
        .capabilities-content-heading,
        .safety-local-heading,
        .pricing-heading,
        .safety-export-head
    ) h1 {
        font-size: clamp(24px, 7.2vw, 27px) !important;
        line-height: 1.24 !important;
    }

    html body :is(
        .legal-copy section,
        .safety-page-section,
        .community-rule-section,
        .ai-info-section-heading,
        .creation-inspiration,
        .image-form,
        .settings-panel,
        .project-content,
        .brand-panel,
        .team-panel,
        .result-actions,
        .project-ai-brief-card,
        .project-result-brief-card,
        .analysis-spreadsheet-heading,
        .analysis-conclusion,
        .analysis-data-panel,
        .analysis-result-side,
        .fortune-setup,
        .fortune-side-info,
        .fortune-step,
        .fortune-keywords,
        .fortune-continue,
        .fortune-inspiration-side,
        .office-result-content,
        .food-info-panel,
        .food-refine-panel,
        .food-before-panel,
        .food-continue-card,
        .ac-panel,
        .ac-policy-timeline,
        .safety-export-complete
    ) > h2 {
        font-size: clamp(18px, 5.4vw, 20px) !important;
        line-height: 1.32 !important;
    }

    html body :is(
        .legal-copy section,
        .safety-page-section,
        .community-standard-card,
        .creation-visual-card,
        .fortune-setup,
        .fortune-reading-grid,
        .office-result-content,
        .analysis-spreadsheet-preview,
        .safety-choice-panel,
        .ac-export-select
    ) > h3 {
        font-size: clamp(15px, 4.5vw, 17px) !important;
        line-height: 1.4 !important;
    }

    :where(img, video, canvas) {
        max-width: 100%;
    }

    :where(button, [role="button"], input, select, textarea) {
        max-width: 100%;
        font: inherit;
    }

    :where(
        button,
        [role="button"],
        a[class*="-btn"],
        a[class*="-button"],
        .sidebar-nav-btn,
        .outline-link,
        .login-link,
        input[type="button"],
        input[type="submit"],
        input[type="reset"],
        select
    ) {
        min-height: var(--fuuvo-mobile-control);
    }

    :where(
        button,
        [role="button"],
        a[class*="-btn"],
        a[class*="-button"],
        .sidebar-nav-btn,
        .topbar-settings-row,
        .creation-pill,
        .research-outline,
        .outline-link,
        .login-link
    ) {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    :where(
        button,
        [role="button"],
        input[type="button"],
        input[type="submit"],
        input[type="reset"]
    ):not(.auth-mask):not(.topbar-settings-backdrop):not(.image-studio-popover-backdrop):not(.fuuvo-mobile-sidebar-backdrop) {
        min-width: var(--fuuvo-mobile-control);
    }

    :where(button, [role="button"], a, input, select, textarea):focus-visible {
        outline: 2px solid #1677ff;
        outline-offset: 2px;
    }

    :where(input:not([type="checkbox"]):not([type="radio"]), select) {
        min-height: var(--fuuvo-mobile-control);
        font-size: 16px;
    }

    textarea {
        min-height: 96px;
        font-size: 16px;
        resize: vertical;
    }

    /* iOS Safari automatically zooms form controls rendered below 16px.
     * Page-specific styles use stronger selectors, so the shared rule must be
     * important to keep focus from widening, shifting or deforming the page. */
    html body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
    html body select,
    html body textarea {
        font-size: 16px !important;
    }

    html body > [data-fuuvo-app-shell="1"],
    html body [data-fuuvo-app-workspace="1"],
    html body [data-fuuvo-app-scroll="1"] {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    html body [data-fuuvo-app-workspace="1"] {
        overflow-x: clip !important;
    }

    html body[data-mode="chat"] #chat-input {
        min-height: 64px !important;
        max-height: 144px !important;
        resize: none !important;
        overflow-x: hidden !important;
        overflow-y: hidden;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    /* Conversation composer: the tools live on the bottom row, so reserving
     * more than 100px on the right needlessly squeezes both typed text and the
     * hint. Give the editable line the full width and keep a dedicated bottom
     * row for actions. */
    html body[data-mode="chat"]:not(.chat-landing) .chat-input-wrap {
        width: 100% !important;
        min-height: 88px !important;
        height: auto !important;
        overflow: visible !important;
    }

    html body[data-mode="chat"]:not(.chat-landing) .chat-input-wrap textarea,
    html body[data-mode="chat"]:not(.chat-landing) #chat-input {
        width: 100% !important;
        min-height: 88px !important;
        max-height: 168px !important;
        padding: 14px 14px 48px !important;
        font-size: 16px !important;
        line-height: 1.5 !important;
        overflow-x: hidden !important;
        overflow-y: auto;
        scroll-margin: 0 !important;
    }

    html body[data-mode="chat"]:not(.chat-landing) .chat-input-hint {
        top: 14px !important;
        right: 14px !important;
        left: 14px !important;
        width: auto !important;
        height: auto !important;
        max-height: 44px;
        font-size: 14px !important;
        line-height: 1.45 !important;
        white-space: normal !important;
        overflow: hidden !important;
        text-overflow: ellipsis;
    }

    html body[data-mode="chat"]:not(.chat-landing) .chat-input-tools {
        right: 10px !important;
        bottom: 8px !important;
        left: 10px !important;
        width: auto !important;
        justify-content: space-between !important;
    }

    /* Apply the focused layout before the native focus action opens the soft
     * keyboard. This prevents Safari/Chrome from scrolling the textarea to the
     * top of the document and keeps the composer attached to the visible
     * viewport while the keyboard changes its height. */
    html:has(body.mobile-chat-composer-focused:not(.chat-landing)) {
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        height: var(--mobile-viewport-height, 100dvh) !important;
        min-height: 0 !important;
        max-height: var(--mobile-viewport-height, 100dvh) !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
    }

    html body.mobile-chat-composer-focused:not(.chat-landing) {
        position: fixed !important;
        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;
        min-height: 0 !important;
        max-height: var(--mobile-viewport-height, 100dvh) !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
    }

    html body.mobile-chat-composer-focused:not(.chat-landing) .app,
    html body.mobile-chat-composer-focused:not(.chat-landing) .workspace {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }

    html body.mobile-keyboard-open:not(.chat-landing) .workspace-disclaimer {
        display: none !important;
    }

    html body.mobile-keyboard-open:not(.chat-landing) .composer {
        padding-bottom: max(6px, env(safe-area-inset-bottom)) !important;
    }

    /* Keep the two primary mobile chat actions available on the landing page,
     * while typing, and after the first answer opens the conversation detail. */
    html body[data-mode="chat"] .mobile-chat-topbar {
        display: grid !important;
        flex: 0 0 auto !important;
    }

    html body[data-mode="chat"] .mobile-chat-primary-actions {
        display: inline-flex;
        align-items: center;
        align-self: center;
        justify-self: start;
        gap: 2px;
        min-width: 0;
        position: relative;
        z-index: 34;
    }

    html body[data-mode="chat"] .mobile-chat-primary-actions .mobile-nav-trigger,
    html body[data-mode="chat"] .mobile-new-chat-trigger {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: var(--fuuvo-mobile-control) !important;
        min-width: var(--fuuvo-mobile-control) !important;
        height: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
        padding: 0 !important;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: #475569;
        box-shadow: none;
        overflow: visible !important;
    }

    html body[data-mode="chat"] .mobile-chat-primary-actions .mobile-nav-pill {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: var(--fuuvo-mobile-control);
        min-width: var(--fuuvo-mobile-control);
        height: var(--fuuvo-mobile-control);
        min-height: var(--fuuvo-mobile-control);
        padding: 0;
        border: 0;
        border-radius: 12px;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    html body[data-mode="chat"] .mobile-chat-primary-actions .mobile-nav-bars,
    html body[data-mode="chat"] .mobile-new-chat-trigger svg {
        width: 22px;
        height: 22px;
        flex: 0 0 22px;
    }

    html body[data-mode="chat"] .mobile-chat-primary-actions .mobile-nav-title {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }

    html body[data-mode="chat"] .mobile-chat-primary-actions :is(.mobile-nav-trigger, .mobile-new-chat-trigger):active {
        background: rgba(148, 163, 184, .14);
    }

    html body[data-ui-theme="dark"][data-mode="chat"] .mobile-chat-primary-actions :is(.mobile-nav-trigger, .mobile-new-chat-trigger) {
        color: #cbd5e1;
    }

    /* The landing surface intentionally keeps a light header even when the
     * saved theme is dark, so its new-chat glyph must use the light-header
     * foreground instead of the detail view's pale foreground. */
    html body.chat-landing[data-ui-theme="dark"][data-mode="chat"] .mobile-new-chat-trigger {
        color: #121826;
    }

    .chat-conversation-loading,
    .conversation-load-error {
        width: min(100%, 760px);
        min-height: 220px;
        margin: 0 auto;
        padding: 24px max(14px, env(safe-area-inset-right)) 30px max(14px, env(safe-area-inset-left));
    }

    .chat-conversation-loading {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .chat-conversation-loading-copy {
        color: #64748b;
        font-size: 13px;
        line-height: 1.45;
    }

    .chat-conversation-loading-bubble {
        width: 68%;
        height: 74px;
        border-radius: 20px;
        background: linear-gradient(100deg, rgba(148, 163, 184, .12) 8%, rgba(148, 163, 184, .24) 18%, rgba(148, 163, 184, .12) 33%);
        background-size: 220% 100%;
        animation: fuuvo-mobile-skeleton 1.35s linear infinite;
    }

    .chat-conversation-loading-bubble.is-wide {
        width: 88%;
        height: 104px;
    }

    .chat-conversation-loading-bubble.is-user {
        width: 48%;
        height: 62px;
        align-self: flex-end;
    }

    .conversation-load-error {
        display: grid;
        place-content: center;
        justify-items: center;
        gap: 14px;
        color: #475569;
        text-align: center;
    }

    .conversation-load-error p {
        margin: 0;
        line-height: 1.6;
    }

    .conversation-load-error button {
        min-width: 112px !important;
        padding: 0 18px;
        border: 0;
        border-radius: 999px;
        background: #1677ff;
        color: #fff;
        font-weight: 700;
    }

    @keyframes fuuvo-mobile-skeleton {
        to {
            background-position-x: -220%;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .chat-conversation-loading-bubble {
            animation: none;
        }
    }

    body[data-ui-theme="dark"] .chat-conversation-loading-copy,
    body[data-ui-theme="dark"] .conversation-load-error {
        color: #cbd5e1;
    }

    body[data-ui-theme="dark"] .chat-conversation-loading-bubble {
        background: linear-gradient(100deg, rgba(71, 85, 105, .24) 8%, rgba(100, 116, 139, .38) 18%, rgba(71, 85, 105, .24) 33%);
        background-size: 220% 100%;
    }

    /* Keep account and quick settings reachable in the mobile drawer. */
    aside[data-fuuvo-shared-sidebar="1"] .fuuvo-mobile-sidebar-auth {
        display: none !important;
    }

    aside[data-fuuvo-shared-sidebar="1"] .sidebar-account-area {
        display: block !important;
        margin-top: 0 !important;
        padding: 6px 4px calc(8px + env(safe-area-inset-bottom)) !important;
        border-top: 1px solid rgba(148, 163, 184, .24);
    }

    aside[data-fuuvo-shared-sidebar="1"] .sidebar-account-card {
        min-height: 52px;
    }

    aside[data-fuuvo-shared-sidebar="1"] .sidebar-account-toggle {
        min-height: 52px;
    }

    aside[data-fuuvo-shared-sidebar="1"] .sidebar-quick-settings {
        bottom: calc(62px + env(safe-area-inset-bottom));
        max-height: min(66dvh, 520px);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    /* Shared topbar controls: 44px touch targets without enlarging artwork. */
    :where(
        .desktop-history-toggle,
        .creation-sidebar-toggle,
        .portal-sidebar-toggle,
        .mobile-nav-trigger,
        .fuuvo-mobile-sidebar-close,
        .workspace-header-link,
        .desktop-action-icon,
        .password-toggle,
        .modal-close,
        .legal-close,
        .conversation-search-close,
        .topbar-settings-drawer-head button
    ) {
        width: var(--fuuvo-mobile-control) !important;
        min-width: var(--fuuvo-mobile-control) !important;
        height: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Chat styles use higher-specificity !important widths; reassert the
     * touch target contract explicitly for the shared mobile header. */
    body .mobile-nav-trigger,
    body .desktop-history-toggle,
    body .creation-sidebar-toggle,
    body .portal-sidebar-toggle,
    body .fuuvo-mobile-sidebar-close,
    body .workspace-header-link,
    body .desktop-action-icon,
    body .chat-tool-btn {
        width: var(--fuuvo-mobile-control) !important;
        min-width: var(--fuuvo-mobile-control) !important;
        height: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
    }

    body .mobile-chat-toolbar-btn {
        min-height: var(--fuuvo-mobile-control) !important;
    }

    body aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn {
        height: auto !important;
        min-height: var(--fuuvo-mobile-control) !important;
        padding: 0 14px !important;
        justify-content: flex-start !important;
        border: 0 !important;
        border-radius: 8px !important;
        background: transparent !important;
        color: #2f2f2f !important;
        font-size: 14px !important;
        font-weight: 400 !important;
    }

    html body[data-mode] aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn {
        height: auto !important;
        min-height: var(--fuuvo-mobile-control) !important;
    }

    body aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn .rail-icon,
    body aside[data-fuuvo-shared-sidebar="1"] :is(#sidebar-new-chat, .portal-new-chat) .rail-icon {
        width: 100% !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }

    html body aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav .sidebar-nav-btn .rail-text {
        color: inherit !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        line-height: 20px !important;
    }

    body aside[data-fuuvo-shared-sidebar="1"] :is(#sidebar-new-chat, .portal-new-chat) {
        width: 100% !important;
        min-height: var(--fuuvo-mobile-control) !important;
        margin: 0 !important;
        padding: 0 14px !important;
        justify-content: flex-start !important;
        border: 0 !important;
        border-radius: 10px !important;
        background: transparent !important;
        color: #2f2f2f !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        box-shadow: none !important;
    }

    body aside[data-fuuvo-shared-sidebar="1"] :is(#sidebar-new-chat, .portal-new-chat) .rail-icon {
        gap: 12px !important;
    }

    body aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn:hover,
    body aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn.active,
    body aside[data-fuuvo-shared-sidebar="1"] :is(#sidebar-new-chat, .portal-new-chat):hover {
        background: #f3f3f3 !important;
        color: #2f2f2f !important;
        box-shadow: none !important;
    }

    body[data-ui-theme="dark"] aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn,
    body[data-ui-theme="dark"] aside[data-fuuvo-shared-sidebar="1"] :is(#sidebar-new-chat, .portal-new-chat) {
        border-color: transparent !important;
        background: transparent !important;
        color: #ececec !important;
    }

    body[data-ui-theme="dark"] aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn:hover,
    body[data-ui-theme="dark"] aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav-btn.active,
    body[data-ui-theme="dark"] aside[data-fuuvo-shared-sidebar="1"] :is(#sidebar-new-chat, .portal-new-chat):hover {
        background: rgba(255, 255, 255, .09) !important;
        color: #f5f5f5 !important;
    }

    html body[data-ui-theme="dark"] aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav .sidebar-nav-btn.active {
        background: rgba(255, 255, 255, .09) !important;
        color: #f5f5f5 !important;
        box-shadow: none !important;
    }

    html body[data-ui-theme="dark"] aside[data-fuuvo-shared-sidebar="1"] .sidebar-nav :is(#sidebar-new-chat.sidebar-nav-btn.active, .portal-new-chat.active) {
        border-color: transparent !important;
        background: transparent !important;
        color: #ececec !important;
        box-shadow: none !important;
    }

    html body[data-mode] .mobile-nav-trigger,
    html body[data-mode] .ui-language-switch-btn,
    html body[data-mode] .chat-tool-btn,
    html body[data-mode] .mobile-chat-toolbar-btn,
    html body.chat-landing[data-mode] .mobile-nav-trigger,
    html body.chat-landing[data-mode] .ui-language-switch-btn,
    html body.chat-landing[data-mode] .chat-tool-btn,
    html body.chat-landing[data-mode] .mobile-chat-toolbar-btn {
        min-width: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
    }

    html body[data-mode] .mobile-nav-trigger,
    html body[data-mode] .ui-language-switch-btn,
    html body[data-mode] .chat-tool-btn,
    html body.chat-landing[data-mode] .mobile-nav-trigger,
    html body.chat-landing[data-mode] .ui-language-switch-btn,
    html body.chat-landing[data-mode] .chat-tool-btn {
        width: var(--fuuvo-mobile-control) !important;
        height: var(--fuuvo-mobile-control) !important;
    }

    body .composer-title-logo-link {
        min-width: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    :where(.creation-language, .portal-language, .ui-language-switch, .auth-language-switch) a,
    :where(.creation-language, .portal-language, .ui-language-switch) button {
        min-width: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
        padding-inline: 9px !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    body .creation-language a,
    body .portal-language a,
    body .ui-language-switch-btn,
    body .auth-language-switch a {
        min-width: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
    }

    .workspace-chat-header,
    .creation-topbar,
    .portal-topbar {
        min-height: 64px;
        padding-left: max(10px, env(safe-area-inset-left)) !important;
        padding-right: max(10px, env(safe-area-inset-right)) !important;
    }

    /* Sticky mobile headers must fully cover the scrolling content beneath
     * them. A solid surface also avoids text ghosting on iOS Safari. */
    html body > :is(.creation-app, .portal-shell, .feature-shell) header[data-fuuvo-shared-topbar="1"],
    html body[data-mode] .workspace-chat-header,
    html body .mobile-chat-topbar {
        z-index: 90 !important;
        border-bottom: 1px solid #e7ebf1 !important;
        background: #ffffff !important;
        background-image: none !important;
        box-shadow: 0 2px 8px rgba(15, 23, 42, .06) !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
        isolation: isolate;
    }

    html body[data-ui-theme="dark"] > :is(.creation-app, .portal-shell, .feature-shell) header[data-fuuvo-shared-topbar="1"],
    html body[data-ui-theme="dark"][data-mode] .workspace-chat-header,
    html body[data-ui-theme="dark"] .mobile-chat-topbar {
        border-bottom-color: #2d3746 !important;
        background: #101722 !important;
        background-image: none !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, .24) !important;
    }

    .shell-topbar-left,
    .shell-topbar-center,
    .shell-topbar-right {
        min-width: 0;
    }

    .shell-topbar-center strong,
    .creation-topbar-title,
    .portal-topbar-title {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .shell-topbar-back,
    .shell-topbar-middle {
        min-height: var(--fuuvo-mobile-control);
        min-width: 0;
        display: inline-flex;
        align-items: center;
    }

    .shell-topbar-back span,
    .shell-topbar-middle {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body > :where(.creation-app, .portal-shell, .feature-shell) [data-fuuvo-app-scroll="1"] {
        padding-bottom: calc(28px + env(safe-area-inset-bottom)) !important;
    }

    /* Button groups may wrap instead of squeezing labels or icons. */
    :where(
        .creation-pills,
        .result-bottom-actions,
        .auth-dialog-actions,
        .outline-actions,
        .learning-result-actions,
        .project-result-actions,
        .food-detail-actions
    ) {
        flex-wrap: wrap;
        gap: 10px;
    }

    :where(.creation-pill, .result-bottom-actions button, .result-bottom-actions a) {
        min-height: var(--fuuvo-mobile-control) !important;
        white-space: normal;
        line-height: 1.35;
        text-align: center;
    }

    /* Dialogs and modal layers stay inside the visual viewport. */
    :where(
        .auth-overlay,
        .settings-overlay,
        .user-settings-overlay,
        .legal-doc-overlay,
        .legal-overlay,
        .modal-backdrop
    ) {
        padding:
            max(12px, env(safe-area-inset-top))
            max(12px, env(safe-area-inset-right))
            max(12px, env(safe-area-inset-bottom))
            max(12px, env(safe-area-inset-left)) !important;
        overscroll-behavior: none;
    }

    :where(.auth-dialog, .settings-dialog, .legal-doc-dialog, .legal-dialog, .modal) {
        width: min(680px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))) !important;
        max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
        max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
        margin: 0 !important;
        overscroll-behavior: contain;
    }

    :where(.auth-dialog, .modal) {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    :where(.settings-dialog, .legal-doc-dialog, .legal-dialog) {
        overflow: hidden !important;
    }

    :where(.legal-content, .legal-doc-content, .settings-main, .settings-content, .modal-content) {
        min-width: 0;
        max-width: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep all settings tabs inside the mobile dialog. The close control only
       reserves space beside the title; the navigation receives the full row. */
    .settings-dialog .settings-sidebar {
        padding: 18px 18px 12px !important;
        overflow: visible !important;
    }

    .settings-dialog .settings-sidebar h3 {
        padding-right: 48px;
    }

    .settings-dialog .settings-nav {
        width: 100%;
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px !important;
        overflow: visible !important;
    }

    .settings-dialog .settings-nav-btn {
        width: 100%;
        min-width: 0;
        min-height: 46px !important;
        padding: 6px 5px !important;
        justify-content: center;
        text-align: center;
        white-space: normal !important;
        line-height: 1.25;
    }

    .settings-dialog .settings-nav-btn > span {
        min-width: 0;
        max-width: 100%;
    }

    :where(.auth-dialog-head, .modal-head, .legal-head, .settings-header) {
        min-width: 0;
        gap: 10px;
    }

    :where(.auth-dialog-head h3, .modal-head h2, .legal-head h3, .settings-header h2) {
        min-width: 0;
        font-size: clamp(20px, 6vw, 26px) !important;
    }

    /* Open layers lock the document; their own content remains scrollable. */
    body:has(.auth-overlay:not(.hidden)),
    body:has(.settings-overlay:not(.hidden)),
    body:has(.user-settings-overlay:not(.hidden)),
    body:has(.legal-doc-overlay:not(.hidden)),
    body:has(.legal-overlay.active),
    body:has(.modal-backdrop.open),
    body:has(.topbar-settings-drawer:not(.hidden)),
    body:has(.image-studio-popover.is-mobile-sheet:not(.hidden)) {
        height: 100dvh !important;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.mobile-nav-open,
    body.fuuvo-mobile-sidebar-open,
    body.fuuvo-mobile-tools-open {
        height: 100dvh !important;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.mobile-nav-open,
    body.fuuvo-mobile-sidebar-open {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }

    body.fuuvo-mobile-tools-open {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }

    .fuuvo-mobile-tool-sheet-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: calc(var(--fuuvo-mobile-sheet-z) - 1);
        width: 100%;
        min-width: 0 !important;
        height: 100%;
        min-height: 0 !important;
        padding: 0;
        border: 0;
        background: rgba(8, 15, 28, .54);
        backdrop-filter: blur(3px);
        touch-action: none;
    }

    body.fuuvo-mobile-tools-open .fuuvo-mobile-tool-sheet-backdrop:not(.hidden) {
        display: block;
    }

    html body #mobile-chat-more-menu,
    html body #mobile-home-capabilities-menu {
        position: fixed !important;
        left: max(10px, env(safe-area-inset-left)) !important;
        right: max(10px, env(safe-area-inset-right)) !important;
        top: auto !important;
        bottom: 0 !important;
        z-index: var(--fuuvo-mobile-sheet-z) !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: min(72dvh, 620px) !important;
        margin: 0 !important;
        padding: 0 14px calc(14px + env(safe-area-inset-bottom)) !important;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        border: 1px solid rgba(148, 163, 184, .26) !important;
        border-bottom: 0 !important;
        border-radius: 22px 22px 0 0 !important;
        background: #fff !important;
        box-shadow: 0 -18px 48px rgba(15, 23, 42, .22) !important;
        transform: none !important;
        -webkit-overflow-scrolling: touch;
    }

    html body #mobile-chat-more-menu.hidden,
    html body #mobile-home-capabilities-menu.hidden {
        display: none !important;
    }

    .fuuvo-mobile-tool-sheet-head {
        position: sticky;
        top: 0;
        z-index: 2;
        grid-column: 1 / -1;
        min-height: 62px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: 0 -2px;
        padding: 10px 0 8px;
        background: inherit;
    }

    .fuuvo-mobile-tool-sheet-head strong {
        min-width: 0;
        color: #172033;
        font-size: 18px;
        line-height: 1.25;
    }

    body .fuuvo-mobile-tool-sheet-close {
        width: var(--fuuvo-mobile-control) !important;
        min-width: var(--fuuvo-mobile-control) !important;
        height: var(--fuuvo-mobile-control) !important;
        min-height: var(--fuuvo-mobile-control) !important;
        padding: 0 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 0 !important;
        border-radius: 50% !important;
        background: #f1f5f9 !important;
        color: #334155 !important;
    }

    .fuuvo-mobile-tool-sheet-close svg {
        width: 21px;
        height: 21px;
    }

    html body #mobile-chat-more-menu > button:not(.fuuvo-mobile-tool-sheet-close),
    html body #mobile-home-capabilities-menu > button:not(.fuuvo-mobile-tool-sheet-close) {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 62px !important;
        margin: 0 !important;
        padding: 10px 12px !important;
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        border: 1px solid #e2e8f0 !important;
        border-radius: 14px !important;
        background: #f8fafc !important;
        color: #1e293b !important;
        font-size: 14px !important;
        font-weight: 650 !important;
        line-height: 1.3 !important;
        text-align: left;
        white-space: normal;
    }

    html body #mobile-chat-more-menu .mobile-chat-more-icon,
    html body #mobile-home-capabilities-menu button > img {
        width: 30px !important;
        min-width: 30px !important;
        height: 30px !important;
        flex: 0 0 30px !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        color: inherit;
        overflow: visible;
    }

    html body #mobile-chat-more-menu .mobile-chat-more-icon img,
    html body #mobile-home-capabilities-menu button > img {
        width: 30px !important;
        max-width: 30px !important;
        height: 30px !important;
        max-height: 30px !important;
        flex: 0 0 30px !important;
        display: block !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        object-fit: contain !important;
        filter: none !important;
    }

    html body #mobile-chat-more-menu .mobile-chat-more-icon .fuuvo-icon {
        display: none !important;
    }

    html body #mobile-chat-more-menu > button:active,
    html body #mobile-home-capabilities-menu > button:active {
        transform: scale(.98);
        background: #eef4ff !important;
    }

    html body[data-ui-theme="dark"] #mobile-chat-more-menu,
    html body[data-ui-theme="dark"] #mobile-home-capabilities-menu {
        border-color: rgba(148, 163, 184, .22) !important;
        background: #111927 !important;
        box-shadow: 0 -18px 48px rgba(0, 0, 0, .42) !important;
    }

    body[data-ui-theme="dark"] .fuuvo-mobile-tool-sheet-head strong {
        color: #f8fafc;
    }

    body[data-ui-theme="dark"] .fuuvo-mobile-tool-sheet-close {
        background: #202b3d !important;
        color: #e2e8f0 !important;
    }

    html body[data-ui-theme="dark"] #mobile-chat-more-menu > button:not(.fuuvo-mobile-tool-sheet-close),
    html body[data-ui-theme="dark"] #mobile-home-capabilities-menu > button:not(.fuuvo-mobile-tool-sheet-close) {
        border-color: rgba(148, 163, 184, .2) !important;
        background: #172131 !important;
        color: #f1f5f9 !important;
    }

    html body[data-ui-theme="dark"] #mobile-chat-more-menu > button:not(.fuuvo-mobile-tool-sheet-close) > span,
    html body[data-ui-theme="dark"] #mobile-home-capabilities-menu > button:not(.fuuvo-mobile-tool-sheet-close) > span {
        color: #fff !important;
        opacity: 1 !important;
        -webkit-text-fill-color: #fff !important;
    }

    html body[data-ui-theme="dark"] #mobile-chat-more-menu .mobile-chat-more-icon,
    html body[data-ui-theme="dark"] #mobile-chat-more-menu .mobile-chat-more-icon img,
    html body[data-ui-theme="dark"] #mobile-home-capabilities-menu button > img {
        background: transparent !important;
        filter: none !important;
    }

    /* On the landing page the input-toolbar More menu is a contextual popover.
       Conversation-detail pages intentionally retain the full-width sheet. */
    html body.chat-landing[data-mode="chat"] #mobile-chat-more-menu {
        position: absolute !important;
        top: auto !important;
        right: auto !important;
        bottom: calc(100% + 10px) !important;
        left: -68px !important;
        z-index: calc(var(--fuuvo-mobile-sheet-z) + 1) !important;
        width: min(320px, calc(100vw - 40px)) !important;
        min-width: 0 !important;
        max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
        max-height: min(46dvh, 220px) !important;
        margin: 0 !important;
        padding: 8px !important;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        border: 1px solid #d9e1ec !important;
        border-radius: 16px !important;
        background: #fff !important;
        box-shadow: 0 16px 38px rgba(22, 43, 72, .2) !important;
        transform: none !important;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: #b9c5d5 transparent;
        -webkit-overflow-scrolling: touch;
    }

    html body.chat-landing[data-mode="chat"] #mobile-chat-more-menu.hidden {
        display: none !important;
    }

    html body.chat-landing[data-mode="chat"] #mobile-chat-more-menu > button:not(.fuuvo-mobile-tool-sheet-close) {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 48px !important;
        margin: 0 !important;
        padding: 7px 9px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        border: 0 !important;
        border-radius: 10px !important;
        background: transparent !important;
        color: #253858 !important;
        font-size: 13px !important;
        font-weight: 500 !important;
        line-height: 1.25 !important;
        text-align: left !important;
        white-space: normal !important;
    }

    html body.chat-landing[data-mode="chat"] #mobile-chat-more-menu .mobile-chat-more-icon,
    html body.chat-landing[data-mode="chat"] #mobile-chat-more-menu .mobile-chat-more-icon img {
        width: 24px !important;
        min-width: 24px !important;
        max-width: 24px !important;
        height: 24px !important;
        max-height: 24px !important;
        flex: 0 0 24px !important;
    }

    html body.chat-landing[data-mode="chat"] #mobile-chat-more-menu > button:active {
        background: #eef4ff !important;
    }

    html body[data-ui-theme="dark"].chat-landing[data-mode="chat"] #mobile-chat-more-menu {
        border-color: rgba(148, 163, 184, .24) !important;
        background: #111927 !important;
        box-shadow: 0 16px 38px rgba(0, 0, 0, .42) !important;
    }

    html body[data-ui-theme="dark"].chat-landing[data-mode="chat"] #mobile-chat-more-menu > button:not(.fuuvo-mobile-tool-sheet-close) {
        background: transparent !important;
        color: #f1f5f9 !important;
    }

    html body[data-ui-theme="dark"].chat-landing[data-mode="chat"] #mobile-chat-more-menu > button:not(.fuuvo-mobile-tool-sheet-close) > span {
        color: #fff !important;
        opacity: 1 !important;
        -webkit-text-fill-color: #fff !important;
    }

    html body[data-ui-theme="dark"].chat-landing[data-mode="chat"] #mobile-chat-more-menu > button:active {
        background: #202b3d !important;
    }

    @media (max-width: 360px) {
        html body.chat-landing[data-mode="chat"] #mobile-chat-more-menu {
            left: -58px !important;
        }
    }

    /* The legal footer belongs to the document, not to the mobile keyboard
       dock. Hide it only while the chat field is active so the home and
       conversation composers can resize without lifting the footer. */
    html body[data-mode="chat"].mobile-chat-input-focused .workspace > .fuuvo-ai-disclaimer,
    html body[data-mode="chat"].mobile-keyboard-open .workspace > .fuuvo-ai-disclaimer,
    html body[data-mode="chat"].mobile-chat-input-focused .workspace > .workspace-disclaimer,
    html body[data-mode="chat"].mobile-keyboard-open .workspace > .workspace-disclaimer {
        display: none !important;
    }

    /* Drawers, dropdowns and popovers receive safe edges and internal scroll. */
    .topbar-settings-backdrop {
        inset: 64px 0 0 !important;
        background: rgba(15, 23, 42, .22) !important;
        backdrop-filter: blur(2px);
    }

    .topbar-settings-drawer {
        top: 64px !important;
        right: env(safe-area-inset-right) !important;
        bottom: 0 !important;
        width: min(360px, calc(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right))) !important;
        max-width: calc(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
        border-radius: 18px 0 0 0;
        overscroll-behavior: contain;
    }

    .topbar-settings-drawer-body {
        padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .conversation-search-dialog {
        width: min(368px, calc(100vw - 12px - env(safe-area-inset-right))) !important;
        max-width: calc(100vw - 12px - env(safe-area-inset-right)) !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
    }

    :where(
        .chat-upload-popover,
        .image-studio-popover,
        .chat-capability-target-menu,
        .mobile-chat-more-menu,
        .mobile-home-capabilities-menu,
        .workspace-account-dropdown,
        .conversation-menu,
        .food-filter-menu
    ) {
        max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
        max-height: calc(100dvh - 96px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .chat-upload-popover {
        left: max(12px, env(safe-area-inset-left)) !important;
        right: max(12px, env(safe-area-inset-right)) !important;
        width: auto !important;
    }

    .image-studio-popover.is-mobile-sheet {
        left: max(10px, env(safe-area-inset-left)) !important;
        right: max(10px, env(safe-area-inset-right)) !important;
        bottom: max(10px, env(safe-area-inset-bottom)) !important;
        width: auto !important;
    }

    .conversation-menu.conversation-menu-floating {
        left: auto !important;
        right: max(12px, env(safe-area-inset-right)) !important;
    }

    .food-filter-menu {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }

    :where(
        .mobile-home-capabilities-menu button,
        .mobile-chat-more-menu button,
        .conversation-menu-item,
        .food-filter-option,
        .topbar-settings-row,
        .topbar-settings-option,
        .topbar-settings-panel-back,
        .workspace-account-action
    ) {
        min-height: var(--fuuvo-mobile-control) !important;
    }

    /* Page-specific compact grids: 2 columns on phones, more on wide phones. */
    .creation-category-tabs {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: stretch !important;
        gap: 8px !important;
        overflow: visible !important;
    }

    .creation-category-tabs a {
        width: auto !important;
        min-width: 0 !important;
        min-height: 70px !important;
        padding: 7px 6px !important;
        flex: none !important;
        flex-direction: column !important;
        justify-content: center;
        gap: 5px !important;
        white-space: normal;
        text-align: center;
        line-height: 1.25;
    }

    .creation-category-tabs > a > img,
    .creation-category-tabs svg {
        width: 23px !important;
        height: 23px !important;
        flex-basis: 23px !important;
    }

    .creation-app-entry,
    .voice-card,
    .writing-card {
        min-height: 150px !important;
        padding: 10px 6px !important;
    }

    .creation-app-entry-art,
    .voice-card-icon,
    .writing-card-art {
        width: 76px !important;
        height: 76px !important;
        flex-basis: 76px !important;
    }

    body[data-ui-theme="dark"] :where(.creation-app-entry-art, .voice-card-icon, .writing-card-art) {
        filter: brightness(0) invert(1);
        opacity: .9;
    }

    /* Search & research: show the complete capability range without a six-card long scroll. */
    .research-app .research-home-heading h1 {
        font-size: clamp(27px, 8vw, 31px);
    }

    .research-app .research-home-heading p {
        margin-top: 8px;
        font-size: 13px;
        line-height: 1.45;
    }

    .research-app .research-tabs {
        min-width: 0;
        margin-top: 18px;
        gap: 14px;
    }

    .research-tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-top: 18px;
    }

    .research-tool-card {
        min-height: 166px;
        padding: 12px 9px 11px;
        justify-content: flex-start;
        border-radius: 14px;
    }

    .research-tool-card:active {
        transform: scale(.985);
    }

    .research-tool-art {
        width: 100%;
        height: 72px;
        object-fit: contain;
    }

    .research-tool-card h2 {
        margin: 9px 0 4px;
        font-size: 16px;
        line-height: 1.28;
    }

    .research-tool-card p {
        display: -webkit-box;
        margin: 0;
        overflow: hidden;
        font-size: 12.5px;
        line-height: 1.38;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    /* Upload analysis: touch-first wording, compact upload, and primary action before presets. */
    .analysis-upload-desktop-copy {
        display: none;
    }

    .analysis-upload-mobile-copy {
        display: block;
    }

    .analysis-home-layout {
        gap: 16px;
        margin-top: 18px;
    }

    .analysis-home-main {
        display: grid;
    }

    .analysis-upload-drop {
        order: 1;
        min-height: 158px;
        padding: 14px 12px;
        text-align: center;
    }

    .analysis-upload-drop img {
        width: 58px;
        height: 58px;
    }

    .analysis-upload-drop strong {
        margin-top: 10px;
        font-size: 16px;
    }

    .analysis-upload-drop > span {
        margin-top: 5px;
        font-size: 12px;
        line-height: 1.4;
    }

    .analysis-selected-files {
        order: 2;
    }

    .analysis-drop-notes {
        order: 3;
        min-height: 52px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding: 8px 0;
    }

    .analysis-drop-notes span {
        gap: 6px;
        font-size: 12px;
        line-height: 1.35;
        text-align: center;
    }

    .analysis-drop-notes i {
        display: none;
    }

    .analysis-drop-notes .analysis-icon {
        width: 19px;
        height: 19px;
        flex: 0 0 19px;
    }

    .analysis-form-block {
        display: contents;
    }

    .analysis-prompt-title {
        order: 4;
        margin: 14px 0 9px;
        font-size: 14px;
    }

    .analysis-prompt {
        order: 5;
        min-height: 94px;
        padding: 12px 13px;
        font-size: 16px;
        resize: none;
    }

    .analysis-home-footer {
        order: 6;
        min-height: 0;
        margin-top: 12px;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .analysis-start-wrap {
        order: 1;
        width: 100%;
    }

    .analysis-rights {
        order: 2;
        justify-content: center;
        font-size: 12px;
        text-align: center;
    }

    .analysis-primary {
        min-height: 52px;
        font-size: 16px;
    }

    .analysis-quick-pills {
        order: 7;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-top: 4px;
    }

    .analysis-quick-pills button {
        width: 100%;
        min-width: 0 !important;
        min-height: 44px;
        padding: 7px 9px;
        justify-content: flex-start;
        font-size: 12.5px;
        line-height: 1.3;
        text-align: left;
    }

    .analysis-process-panel {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 0 10px 12px;
    }

    .analysis-process-panel > h2,
    .analysis-deeper {
        grid-column: 1 / -1;
    }

    .analysis-process-panel > h2 {
        padding: 16px 4px 8px;
        font-size: 16px;
    }

    .analysis-process-panel article {
        min-height: 142px;
        margin: 0;
        padding: 12px 6px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 7px;
        text-align: center;
    }

    .analysis-process-panel article > .analysis-icon {
        width: 32px;
        height: 32px;
        flex: 0 0 32px;
    }

    .analysis-process-panel article div {
        display: block;
    }

    .analysis-process-panel h3 {
        margin: 0;
        font-size: 13px;
    }

    .analysis-process-panel article strong {
        display: -webkit-box;
        margin-top: 5px;
        overflow: hidden;
        font-size: 11px;
        line-height: 1.35;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
    }

    .analysis-deeper {
        padding: 12px 4px 2px;
        text-align: center;
    }

    /* Local food: compact address selection, responsive option grids, and an early primary action. */
    .food-app[data-page="home"] .food-main {
        width: calc(100% - 24px);
        padding-top: 20px;
        display: flex;
        flex-direction: column;
    }

    .food-app[data-page="home"] .food-heading {
        order: 1;
    }

    .food-app[data-page="home"] .food-location-panel {
        order: 2;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
        margin-top: 18px;
        padding: 14px;
        border-radius: 14px;
    }

    .food-location-panel h2 {
        margin-bottom: 12px;
        font-size: 17px;
    }

    .food-location-panel h2 img {
        width: 24px;
        height: 24px;
    }

    .food-location-controls {
        gap: 6px;
    }

    .food-location-current {
        min-height: 46px;
        font-size: 15px;
    }

    .food-location-current img {
        width: 24px;
        height: 24px;
        flex-basis: 24px;
    }

    .food-address-picker {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-top: 10px;
    }

    .food-address-street {
        grid-column: auto;
    }

    .food-address-picker label {
        gap: 4px;
    }

    .food-address-picker select,
    .food-address-picker input {
        height: 44px;
        padding-inline: 9px;
        font-size: 14px;
    }

    .food-app[data-page="home"] .food-filter-row {
        order: 4;
        margin-top: 14px;
        padding: 0 0 4px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        overflow: visible;
    }

    .food-filter-wrap,
    .food-filter-row > .food-filter {
        min-width: 0;
        width: 100%;
    }

    .food-app[data-page="home"] .food-filter-row > .food-filter-wrap:last-child {
        grid-column: auto;
    }

    .food-filter {
        min-height: 66px;
        padding: 8px 10px;
    }

    .food-filter span {
        gap: 6px;
        font-size: 12px;
    }

    .food-filter span img {
        width: 20px;
        height: 20px;
    }

    .food-filter strong {
        font-size: 14px;
    }

    .food-app[data-page="home"] .food-prompt-box {
        order: 3;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
        min-height: 70px;
        margin-top: 14px;
        padding: 10px 12px;
        flex-wrap: nowrap;
        gap: 9px;
        border-radius: 14px;
    }

    .food-prompt-box > img {
        width: 25px;
        height: 25px;
        flex-basis: 25px;
    }

    .food-prompt-box input {
        min-width: 0;
        font-size: 16px;
    }

    .food-prompt-box button {
        width: auto;
        min-width: 110px;
        height: 46px;
        padding: 0 12px;
        font-size: 13px;
    }

    .food-app[data-page="home"] .food-content-grid {
        order: 5;
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        margin-top: 20px;
    }

    .food-app[data-page="results"] .food-result-layout,
    .food-app[data-page="detail"] .food-detail-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .food-app[data-page="home"] .food-disclaimer {
        order: 6;
    }

    .food-app[data-page="home"] .fuuvo-ai-disclaimer {
        order: 7;
    }

    .food-start-section h2,
    .food-method-panel h2 {
        margin-bottom: 11px;
        font-size: 18px;
    }

    .food-quick-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
        overflow: visible;
    }

    .food-quick-card {
        min-width: 0;
        width: 100%;
        min-height: 100px;
        padding: 11px 7px 9px;
    }

    .food-quick-card img {
        width: 43px;
        height: 43px;
    }

    .food-method-panel {
        padding: 14px 12px 10px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .food-method-panel h2 {
        grid-column: 1 / -1;
    }

    .food-method-panel button {
        min-height: 86px;
        padding: 8px 5px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        border: 1px solid var(--food-line);
        border-radius: 10px;
        font-size: 12px;
        text-align: center;
    }

    .food-method-panel button:first-of-type {
        border-top: 1px solid var(--food-line);
    }

    .food-method-panel button img {
        width: 28px;
        height: 28px;
    }

    .food-method-panel button b {
        display: none;
    }

    html:has(body .food-filter-menu:not([hidden])),
    body:has(.food-filter-menu:not([hidden])) {
        height: 100dvh;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body:has(.food-filter-menu:not([hidden]))::before {
        position: fixed;
        inset: 0;
        z-index: 329;
        background: rgba(8, 15, 28, .52);
        backdrop-filter: blur(2px);
        content: "";
    }

    html body .food-filter-menu:not([hidden]) {
        position: fixed !important;
        left: max(10px, env(safe-area-inset-left)) !important;
        right: max(10px, env(safe-area-inset-right)) !important;
        top: auto !important;
        bottom: 0 !important;
        z-index: 330 !important;
        width: auto !important;
        max-width: none !important;
        max-height: min(64dvh, 520px) !important;
        padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        border-bottom: 0;
        border-radius: 22px 22px 0 0;
        overflow-x: hidden;
        overflow-y: auto;
        box-shadow: 0 -18px 48px rgba(15, 23, 42, .24);
    }

    .food-filter-menu:not([hidden])::before {
        grid-column: 1 / -1;
        margin: 0 2px 8px;
        color: var(--food-ink);
        font-size: 17px;
        font-weight: 750;
        content: attr(aria-label);
    }

    .food-filter-option {
        min-height: 44px;
        border: 1px solid var(--food-line);
        background: #f8fafc;
    }

    body[data-ui-theme="dark"] .food-filter-menu:not([hidden])::before {
        color: #f8fafc;
    }

    body[data-ui-theme="dark"] .food-filter-option {
        border-color: #34445d;
        background: #172338;
        color: #f2f6fc;
    }

    body[data-ui-theme="dark"] .food-filter-option:hover,
    body[data-ui-theme="dark"] .food-filter-option:focus-visible,
    body[data-ui-theme="dark"] .food-filter-option[aria-selected="true"] {
        background: #213957;
        color: #b9dcff;
    }

    /* Creation centre: denser header/categories and balanced touch cards. */
    #creation-app[data-creation-page="home"] .creation-heading h1 {
        font-size: clamp(28px, 8vw, 32px);
    }

    #creation-app[data-creation-page="home"] .creation-heading p {
        margin-top: 7px;
        font-size: 13px;
        line-height: 1.45;
    }

    #creation-app[data-creation-page="home"] .creation-tabs {
        margin-top: 18px;
    }

    #creation-app[data-creation-page="home"] .creation-category-tabs {
        margin-top: 16px;
        gap: 7px !important;
    }

    #creation-app[data-creation-page="home"] .creation-category-tabs a {
        min-height: 68px !important;
        padding: 6px 4px !important;
        font-size: 12.5px;
    }

    #creation-app[data-creation-page="home"] .creation-section-title {
        margin-top: 18px;
        margin-bottom: 10px;
        font-size: 21px;
    }

    #creation-app[data-creation-page="home"] .creation-app-list {
        gap: 9px;
    }

    #creation-app[data-creation-page="home"] .creation-app-entry {
        min-height: 140px !important;
        padding: 9px 5px !important;
    }

    #creation-app[data-creation-page="home"] .creation-app-entry-art {
        width: 68px !important;
        height: 68px !important;
        flex-basis: 68px !important;
    }

    #creation-app[data-creation-page="home"] .creation-app-entry-copy strong {
        font-size: 14px;
    }

    #creation-app[data-creation-page="home"] .creation-app-entry-copy small {
        font-size: 11.5px;
        line-height: 1.35;
    }

    @media (min-width: 360px) {
        .detail-chip-row {
            grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        }

        .detail-chip-row button {
            width: 100% !important;
            min-width: 0 !important;
            padding-inline: 6px !important;
            white-space: normal;
            text-align: center;
        }
    }
}

@media (min-width: 480px) and (max-width: 599px) {
    .food-app[data-page="home"] .food-filter-row,
    .food-address-picker,
    .food-quick-grid,
    .food-method-panel,
    html body .food-filter-menu:not([hidden]) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 600px) and (max-width: 920px), (hover: none) and (pointer: coarse) and (min-width: 600px) and (max-width: 1366px) {
    .food-app[data-page="home"] .food-filter-row,
    .food-quick-grid,
    html body .food-filter-menu:not([hidden]) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .food-method-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .food-address-picker {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .zodiac-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .fortune-topic-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .fortune-panel.fortune-side-info {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    .creation-app-list,
    .voice-grid,
    .writing-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 920px) and (orientation: landscape) and (max-height: 560px) {
    .workspace-chat-header,
    .creation-topbar,
    .portal-topbar {
        min-height: 56px !important;
    }

    .topbar-settings-backdrop {
        inset: 56px 0 0 !important;
    }

    .topbar-settings-drawer {
        top: 56px !important;
    }

    :where(.auth-overlay, .settings-overlay, .user-settings-overlay, .legal-doc-overlay, .legal-overlay, .modal-backdrop) {
        align-items: flex-start !important;
        padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)) !important;
    }

    :where(.auth-dialog, .settings-dialog, .legal-doc-dialog, .legal-dialog, .modal) {
        max-height: calc(100dvh - 16px) !important;
        border-radius: 16px !important;
    }

    .auth-dialog {
        top: 8px !important;
        transform: translateX(-50%) !important;
    }

    .zodiac-grid,
    .fortune-topic-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .research-tool-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .food-address-picker {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 359px) {
    .settings-dialog .settings-nav {
        gap: 4px !important;
    }

    .settings-dialog .settings-nav-btn {
        padding-inline: 3px !important;
        font-size: 12px !important;
    }

    .creation-category-tabs {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    .creation-category-tabs a {
        min-height: 66px !important;
        flex-direction: column !important;
        padding-inline: 3px !important;
        font-size: 11px !important;
    }

    .detail-chip-row {
        grid-template-columns: 1fr !important;
    }

    .research-tool-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .research-tool-card {
        min-height: 112px;
        padding: 11px;
        display: grid;
        grid-template-columns: 82px minmax(0, 1fr);
        grid-template-rows: auto auto;
        column-gap: 12px;
        align-content: center;
        text-align: left;
    }

    .research-tool-art {
        width: 82px;
        height: 76px;
        grid-row: 1 / 3;
    }

    .research-tool-card h2 {
        align-self: end;
        margin: 0 0 4px;
    }

    .research-tool-card p {
        align-self: start;
    }

    .analysis-process-panel article {
        min-height: 150px;
    }

    .analysis-upload-drop {
        min-height: 118px;
        padding-block: 10px;
    }

    .analysis-upload-drop img {
        width: 44px;
        height: 44px;
    }

    .analysis-upload-drop strong {
        margin-top: 6px;
        font-size: 15px;
    }

    .analysis-upload-drop > span {
        margin-top: 3px;
    }

    .analysis-prompt-title {
        margin: 10px 0 6px;
    }

    .analysis-drop-notes {
        min-height: 46px;
        padding-block: 6px;
    }

    .analysis-prompt {
        min-height: 88px;
    }

    .analysis-home-footer {
        margin-top: 8px;
    }

    .food-prompt-box button {
        min-width: 96px;
        padding-inline: 9px;
    }
}
