/* Mobile header and navigation panel. */

@media (max-width: 991px) {
    :root { --mobile-header-height: calc(57px + env(safe-area-inset-top)); }
    body.is-logged-in .controls-panel { display: none !important; }
    body.is-logged-in #left-panel-toggle { display: none !important; }

    body.is-logged-in .generation-space {
        padding-top: var(--mobile-header-height) !important;
    }

    .mobile-workspace-bar {
        position: fixed !important;
        z-index: 1042;
        top: 0;
        right: 0;
        left: 0;
        display: grid !important;
        grid-template-columns: minmax(0,1fr) 44px minmax(0,1fr) !important;
        align-items: center;
        gap: 6px;
        width: 100%;
        min-height: calc(56px + env(safe-area-inset-top)) !important;
        margin: 0 !important;
        padding: calc(6px + env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 6px max(8px,env(safe-area-inset-left)) !important;
        border: 0 !important;
        border-bottom: 1px solid var(--border-color) !important;
        border-radius: 0 !important;
        background: linear-gradient(180deg,#111 0%,#090909 100%) !important;
        box-shadow: 0 8px 24px rgba(0,0,0,.38) !important;
    }

    .mobile-workspace-brand,
    .mobile-service-action,
    .mobile-header-balance,
    .mobile-profile-avatar {
        display: grid;
        min-width: 44px;
        min-height: 44px;
        place-items: center;
        margin: 0;
        padding: 0;
        border: 1px solid var(--border-color);
        border-radius: 11px;
        background: var(--bg-input);
        color: var(--text-secondary);
        touch-action: manipulation;
    }

    .mobile-workspace-brand { grid-column:2; grid-row:1; justify-self:center; border-color:transparent; background:transparent; }
    .mobile-workspace-brand .shell-brand-mark { position:relative; display: grid; place-items:center; width: 36px; height: 36px; }
    .mobile-workspace-brand .shell-brand-mark img { inset:3px; width:30px; height:30px; }

    .mobile-service-nav {
        grid-column:1;
        grid-row:1;
        justify-self:start;
        position:static;
        display: flex;
        min-width: 0;
        align-items: center;
        justify-content: flex-start;

        gap: 5px;
        overflow: visible;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .mobile-service-nav::-webkit-scrollbar { display: none; }
    .mobile-service-action { flex: 0 0 44px; width: 44px; height: 44px; font: 700 15px/1 'Bowler',sans-serif; }
    #mobile-modes-toggle { border-radius:50%; border-color:color-mix(in srgb,var(--primary) 62%,var(--border-color)); background:var(--bg-input); }
    .mobile-service-action :is(i,svg) { width:20px; height:20px; overflow:visible; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; font-size:15px; }
    .mobile-service-action:is(.active,[aria-expanded="true"]) { border-color: var(--primary); background: var(--primary-glow); color: var(--primary); }

    .mobile-account-actions { grid-column:3; grid-row:1; justify-self:end; display: flex; align-items: center; gap: 5px; }
    .mobile-header-balance {
        grid-auto-flow: column;
        width: auto;
        min-width: 44px;
        padding-inline: 8px;
        color: var(--primary);
        font: 900 15px/1 Manrope,sans-serif;
        border:0;
        background:transparent;
        gap:5px;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }
    .mobile-header-balance svg { width:18px; height:18px; fill:rgba(24,178,255,.08); stroke:#18b2ff; stroke-width:1.8; filter:drop-shadow(0 0 6px rgba(24,178,255,.45)); }
    .mobile-profile-avatar { width: 44px; height: 44px; overflow: visible; border-radius: 50%; padding:2px; border-color:color-mix(in srgb,var(--primary) 62%,var(--border-color)); }
    .mobile-profile-avatar img { width: 100%; height: 100%; max-width: none; object-fit: cover; }

    body.is-logged-in .modes-panel {
        position: fixed !important;
        z-index: 1050;
        top: calc(var(--mobile-header-height) + 6px) !important;
        right: max(8px,env(safe-area-inset-right)) !important;
        bottom: auto !important;
        left: max(8px,env(safe-area-inset-left)) !important;
        display: block !important;
        width: min(360px,calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right))) !important;
        height: fit-content !important;
        max-height: calc(100dvh - var(--mobile-header-height) - 14px - env(safe-area-inset-bottom)) !important;
        margin: 0 auto !important;
        padding: 8px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        border: 1px solid color-mix(in srgb,var(--primary) 34%,var(--border-color)) !important;
        border-radius: var(--radius-panel) !important;
        background: var(--surface-panel) !important;
        box-shadow: var(--shadow-panel) !important;
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px) scale(.98) !important;
        transform-origin: top center;
        pointer-events: none;
        transition: opacity .16s ease,transform .16s ease,visibility .16s ease !important;
    }
    body.is-logged-in .modes-panel.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1) !important;
        pointer-events: auto;
    }

    .mobile-navigation-section-label { padding:8px 10px 5px; color:var(--primary); font-family:'Bowler',sans-serif; font-size:9px; font-weight:500; letter-spacing:.1em; }
    .mobile-navigation-section-label--spaces { margin-top:8px; padding-top:14px; border-top:1px solid var(--border-color); }
    body.is-logged-in #modes-menu.mode-tile-nav {
        display: grid !important;
        flex: 0 0 auto !important;
        grid-template-columns: 1fr !important;
        gap: 3px !important;
        max-height: none !important;
        padding: 0 !important;
        overflow: visible !important;
    }
    .mobile-spaces-menu { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; padding:3px 2px 5px; }
    body.is-logged-in #modes-menu :is(.mode-group,.studio-submenu) { display: contents !important; }
    body.is-logged-in #modes-menu .mode-button,
    body.is-logged-in #modes-menu .studio-submenu .mode-button {
        display: grid !important;
        grid-template-columns: 36px minmax(0,1fr);
        min-width: 0 !important;
        min-height: 54px !important;
        height: auto !important;
        aspect-ratio: auto !important;
        align-items: center;
        gap: 10px;
        margin: 0 !important;
        padding: 8px 10px !important;
        overflow: visible;
        border: 1px solid transparent !important;
        border-radius: var(--radius-control) !important;
        background: transparent !important;
        box-shadow: none !important;
        color: var(--text-secondary) !important;
        text-align:left;
        text-decoration:none;
        cursor:pointer;
    }
    .mobile-spaces-menu .mobile-space-button { display:grid; min-width:0; min-height:52px; aspect-ratio:1; place-items:center; padding:0; border:1px solid var(--border-color); border-radius:var(--radius-control); background:var(--surface-control); color:var(--primary); text-decoration:none; cursor:pointer; touch-action:manipulation; }
    .mobile-spaces-menu .mobile-space-button > :first-child { display:grid; width:22px !important; height:22px !important; place-items:center; justify-self:center; color:inherit; font-size:20px !important; }
    body.is-logged-in #modes-menu .mode-button > img { width:34px; height:34px; justify-self:center; border-radius:50%; object-fit:cover; }
    body.is-logged-in #modes-menu .mode-button > span { display:flex !important; min-width:0; align-items:center; gap:8px; color:inherit; font-family:'Bowler',sans-serif !important; font-size:10px !important; font-weight:500; line-height:1.2; letter-spacing:.035em; }
    body.is-logged-in #modes-menu .mode-maintenance-tag { margin-left:0; }
    .mobile-spaces-menu__mark { font-family:'Bowler',sans-serif; font-size:17px !important; }
    body.is-logged-in #modes-menu .mode-button:is(:hover,.active),
    .mobile-spaces-menu .mobile-space-button:is(:hover,.active) { border-color:color-mix(in srgb,var(--primary) 60%,var(--border-color)) !important; background:var(--primary-glow) !important; color:var(--primary) !important; }
    body.is-logged-in .modes-panel :is(.modes-panel-footer,#radio-player-container,#photoshoot-sidebar-warning,#collective-menu-promo) { display: none !important; }

    #menu-overlay { inset:0 !important; width:auto !important; height:auto !important; background:rgba(0,0,0,.18) !important; pointer-events:none; backdrop-filter:none !important; -webkit-backdrop-filter:none !important; }
    #menu-overlay:not(.is-open) { display:none !important; }
    #menu-overlay.is-open { pointer-events:auto; }
    .mobile-workspace-bar button:focus-visible,#modes-menu button:focus-visible,.mobile-spaces-menu .mobile-space-button:focus-visible { outline:0; box-shadow:var(--focus-ring) !important; }
    .creative-drawer { top: var(--mobile-header-height); }
    body.app-mode-text #text-mode-container > #text-chat-sidebar-view { height: auto !important; max-height: 45dvh; flex: 0 0 auto; margin: 6px 8px; }
    body.app-mode-text #text-chat-sidebar-view .chat-sidebar-header { min-height: 44px; }
    body.app-mode-text #text-chat-sidebar-view .chat-sidebar-header:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
}

@media (max-width: 430px) {
    .mobile-header-balance { padding-inline: 6px; }

}

@media (max-width: 370px) {
    .mobile-workspace-bar { grid-template-columns: minmax(0,1fr) 44px minmax(0,1fr) !important; gap: 4px; padding-inline: 5px !important; }
    .mobile-workspace-brand,.mobile-service-action,.mobile-profile-avatar { min-width: 44px; width: 44px; min-height: 44px; height: 44px; }
    .mobile-workspace-brand .shell-brand-mark { width:32px; height:32px; }
    .mobile-workspace-brand .shell-brand-mark img { inset:2px; width:28px; height:28px; }
    .mobile-service-action { flex-basis: 44px; }
    .mobile-header-balance { min-width: 44px; min-height: 44px; padding-inline: 5px; font-size: 12px; }
    .mobile-spaces-menu { gap:6px; }
}

@media (max-width: 991px) and (orientation: landscape) and (max-height: 560px) {
    :root { --mobile-header-height: calc(53px + env(safe-area-inset-top)); }
    .mobile-workspace-bar { min-height: calc(48px + env(safe-area-inset-top)) !important; padding-block: calc(4px + env(safe-area-inset-top)) 4px !important; }
    .mobile-workspace-brand,.mobile-service-action,.mobile-header-balance,.mobile-profile-avatar { min-height: 44px; height: 44px; }
    .mobile-service-action { min-width: 44px; width: 44px; flex-basis: 44px; }
    .mobile-profile-avatar { width: 44px; }
    .mobile-workspace-brand .shell-brand-mark { width:32px; height:32px; }
    .mobile-workspace-brand .shell-brand-mark img { inset:2px; width:28px; height:28px; }
    body.is-logged-in .modes-panel { top: calc(var(--mobile-header-height) + 6px) !important; max-height: calc(100dvh - 65px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important; }
    body.is-logged-in #modes-menu .mode-button,body.is-logged-in #modes-menu .studio-submenu .mode-button { min-height: 52px !important; }
}
@media (prefers-reduced-motion: reduce) {
    body.is-logged-in .modes-panel { transition: none !important; }
}

@media (max-width: 991px) {
    :root:has(.site-system-strip:not([hidden])) { --mobile-header-height: calc(101px + env(safe-area-inset-top)); }
    .generation-space > .site-system-strip {
        position: fixed;
        z-index: 1041;
        top: 0;
        right: 0;
        left: 0;
        height: calc(44px + env(safe-area-inset-top));
        max-height: none;
        margin: 0;
        grid-template-columns: max(44px,env(safe-area-inset-left)) minmax(0,1fr) max(44px,env(safe-area-inset-right));
        padding: env(safe-area-inset-top) 0 0;
    }
    .site-system-strip__close { width:44px; height:44px; }
    .generation-space:has(> .site-system-strip:not([hidden])) > .mobile-workspace-bar {
        top: calc(44px + env(safe-area-inset-top));
        min-height: 56px !important;
        padding-top: 6px !important;
    }
}

@media (max-width: 991px) and (orientation: landscape) and (max-height: 560px) {
    :root:has(.site-system-strip:not([hidden])) { --mobile-header-height: calc(97px + env(safe-area-inset-top)); }
    .generation-space:has(> .site-system-strip:not([hidden])) > .mobile-workspace-bar {
        min-height: 48px !important;
        padding-top: 4px !important;
    }
}
@media (max-width:600px) {
    :root:has(.site-system-strip:not([hidden]):has(.site-system-strip__action:not([hidden]))) { --mobile-header-height: calc(121px + env(safe-area-inset-top)); }
    .generation-space > .site-system-strip:has(.site-system-strip__action:not([hidden])) { height:calc(64px + env(safe-area-inset-top)); }
    .generation-space:has(> .site-system-strip:not([hidden]):has(.site-system-strip__action:not([hidden]))) > .mobile-workspace-bar { top:calc(64px + env(safe-area-inset-top)); }
}
