/* Mobile presentation reuses the retained shell and content owners. */
.mobile-header, .mobile-tabs { display: none; }
@media (max-width: 760px) {
    body#app.mobile-layout {
        --rail-width: 20vw;
        --nav-width: 80vw;
        --scroll-width: 0px;
        --shell-header-height: calc(152px + env(safe-area-inset-top, 0px));
        --mobile-tab-height: calc(64px + env(safe-area-inset-bottom, 0px));
        --mobile-content-bottom: var(--mobile-tab-height);
        position: fixed; inset: auto 0 auto; top: var(--mobile-viewport-top, 0px);
        width: 100%; height: var(--mobile-viewport-height, 100dvh); min-height: 0;
        overflow: hidden; font-size: 16px;
    }
    body#app.mobile-layout[data-mobile-view="search"] { --shell-header-height: calc(168px + env(safe-area-inset-top, 0px)); }
    body#app.mobile-layout.mobile-keyboard { --mobile-tab-height: 0px; }
    body#app.mobile-layout[data-mobile-view="chats"]:not([data-mobile-panel]) {
        --mobile-content-bottom: calc(var(--composer-height, 48px) + env(safe-area-inset-bottom, 0px));
    }
    body#app.mobile-layout #site-header { position: absolute; inset: 0 0 auto; height: var(--shell-header-height); }
    body#app.mobile-layout #community-header-artwork { opacity: 1; }
    body#app.mobile-layout #topbar,
    body#app.mobile-layout #menu,
    body#app.mobile-layout #top-chrome-layer,
    body#app.mobile-layout #bottom-chrome-layer,
    body#app.mobile-layout #scroll-column,
    body#app.mobile-layout #board-scroll-column { display: none !important; }
    .mobile-header {
        display: flex; align-items: center; gap: 8px; height: 44px;
        padding: 0 8px; margin-top: calc(56px + env(safe-area-inset-top, 0px));
        position: relative; z-index: 4; background: color-mix(in srgb, var(--surface) 86%, transparent);
    }
    .mobile-header button { min-width: 44px; min-height: 44px; border: 0; box-shadow: none; color: var(--ink); }
    .mobile-header button svg { width: 24px; height: 24px; flex: 0 0 24px; }
    .mobile-community-trigger { display: flex; align-items: center; gap: 4px; max-width: 55%; padding: 0 4px; background: transparent; }
    .mobile-community-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 650; }
    .mobile-community-trigger svg { width: 16px !important; }
    body[data-mobile-view="communities"]:not([data-mobile-panel]) .mobile-header-title { display: none; }
    body[data-mobile-view="communities"]:not([data-mobile-panel]) .mobile-community-trigger { flex: 1; max-width: none; }
    body#app.mobile-layout #protected-header-row {
        position: absolute; inset: env(safe-area-inset-top,0px) 0 auto; height: 56px;
        display: flex !important; width: 100%; margin: 0; padding: 0;
        background: color-mix(in srgb, var(--toolbar) 78%, transparent); z-index: 6;
    }
    body#app.mobile-layout #world-corner { position: static; width: 20%; height: 56px; min-width: 0; margin: 0; border: 0; }
    body#app.mobile-layout #nav-tools-bar { position: static; display: block !important; flex: 1; width: 80%; height: 56px; min-width: 0; }
    body#app.mobile-layout #nav-tools-bar .nav-tools { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); height: 56px; width: 100%; }
    body#app.mobile-layout #protected-header-row button { padding: 0; min-width: 0; height: 56px; border: 0; background: transparent; box-shadow: none; }
    body#app.mobile-layout #close-nav { display: none !important; }
    body#app.mobile-layout #protected-header-row button svg { width: 27px; height: 27px; }

    .mobile-header-title { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
    .mobile-profile-button { flex: 0 0 40px; border-radius: 50%; background: var(--inset); font-size: 13px; font-weight: 650; }
    .mobile-back { flex: 0 0 44px; padding: 10px; background: transparent; }
    .mobile-back[hidden] { display: none; }
    body[data-mobile-view="chats"]:not([data-mobile-panel]) .mobile-community-trigger,
    body[data-mobile-panel] .mobile-community-trigger { display: none; }
    body#app.mobile-layout #header-search-slot {
        display: none; top: calc(112px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px;
        height: 48px; transform: none; z-index: 5;
    }
    body#app.mobile-layout[data-mobile-view="search"] #header-search-slot { display: flex; }
    body#app.mobile-layout #header-search-slot #search-form { max-width: none; height: 44px; border-radius: 22px; }
    body#app.mobile-layout :is(input,textarea,select) { font-size: 16px; }
    body#app.mobile-layout #workspace {
        position: absolute; inset: var(--shell-header-height) 0 var(--mobile-content-bottom);
        width: auto; min-width: 0; height: auto; margin: 0; padding: 0; overflow: visible;
    }
    body#app.mobile-layout #main { position: absolute; inset: 0; min-width: 0; min-height: 0; padding: 0; margin: 0; }
    body#app.mobile-layout :is(#discover-view,#community-view) {
        position: absolute; inset: 0; min-width: 0; width: 100%; height: 100%;
        padding: 8px; margin: 0; overflow: auto; scrollbar-width: none; overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }
    body#app.mobile-layout #community-view { padding: 0; }
    body#app.mobile-layout :is(.discovery-masonry,.inventory-masonry) { --masonry-width: 150; --masonry-columns: 2; --masonry-gap: 8; --masonry-row-gap: 10; }
    body#app.mobile-layout .pin-caption { min-height: 36px; padding-inline: 4px; gap: 4px; font-size: 12px; }
    body#app.mobile-layout .pin-caption > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    body#app.mobile-layout .pin-open { border-radius: 16px; touch-action: pan-y; -webkit-touch-callout: none; }
    body#app.mobile-layout .discover-pin-info { padding: 12px; border-radius: 0; border: 0; box-shadow: none; background: transparent; }
    body#app.mobile-layout .discover-pin-info h1 { font-size: 18px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    body#app.mobile-layout .discover-preview-group { border-radius: 0; box-shadow: none; }
    body#app.mobile-layout .discover-preview-media { border-radius: 16px; overflow: hidden; }
    body#app.mobile-layout .discover-preview-search { display: none !important; }
    body#app.mobile-layout .discover-preview-actions { min-height: 52px; gap: 8px; }
    body#app.mobile-layout .discover-pin-layout { min-width: 0; }
    body#app.mobile-layout .mobile-tabs {
        position: absolute; inset: auto 0 0; z-index: 105;
        display: grid; grid-template-columns: repeat(5,minmax(0,1fr));
        height: var(--mobile-tab-height); padding: 2px 4px env(safe-area-inset-bottom,0px);
        border-top: 1px solid var(--line); background: var(--surface); color: var(--ink);
    }
    .mobile-tab { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; min-width: 0; min-height: 48px; padding: 6px 0; border-radius: 12px; background: transparent; box-shadow: none; font-size: 10px; color: var(--muted); }
    .mobile-tab svg { width: 24px; height: 24px; }
    .mobile-tab[aria-current="page"] { color: var(--ink); background: var(--inset); font-weight: 650; }
    body#app.mobile-layout:is(.mobile-keyboard,[data-mobile-view="communities"]) .mobile-tabs,
    body#app.mobile-layout[data-mobile-view="chats"]:not([data-mobile-panel]) .mobile-tabs { display: none; }
    body#app.mobile-layout #bottom-bar { display: none !important; }
    body#app.mobile-layout[data-mobile-view="chats"]:not([data-mobile-panel]) #bottom-bar {
        position: fixed; display: flex !important; inset: auto 0 var(--mobile-viewport-bottom,0px);
        height: calc(var(--composer-height,48px) + env(safe-area-inset-bottom,0px));
        min-height: 48px; padding: 4px 8px calc(4px + env(safe-area-inset-bottom,0px)); margin: 0;
        background: var(--toolbar); z-index: 106;
    }
    body#app.mobile-layout #bottom-bar > .chat-composer { padding: 0; width: 100%; }
    body#app.mobile-layout .composer-pull { display: none !important; }
    body#app.mobile-layout .chat-composer :is(.icon-button,button) { min-width: 40px; min-height: 40px; }
    body#app.mobile-layout .composer-context { left: 8px !important; right: 8px !important; }
    body#app.mobile-layout :is(#rail,#navigator) { display: none !important; }
    body#app.mobile-layout.nav-open :is(#rail,#navigator) {
        position: absolute; display: flex !important; top: var(--shell-header-height); bottom: calc(64px + env(safe-area-inset-bottom,0px));
        margin: 0; height: auto; transform: none; z-index: 90; box-shadow: none;
    }
    body#app.mobile-layout.nav-open #rail { left: 0; width: var(--rail-width); }
    body#app.mobile-layout.nav-open #navigator { left: var(--rail-width); width: var(--nav-width); border-left: 1px solid var(--line); }
    body#app.mobile-layout #community-icons { padding: 12px 0; align-items: center; max-height: none; gap: 12px; }
    body#app.mobile-layout .community-icon, body#app.mobile-layout #add-community { width: 52px; height: 52px; flex: 0 0 52px; }
    body#app.mobile-layout #nav-scroll { width: 100%; min-width: 0; padding-bottom: 12px; }
    body#app.mobile-layout :is(.channel-row,.category-heading,.nav-row) { min-height: 44px; font-size: 15px; }
    body#app.mobile-layout :is(#profile,#nav-profile-bar) { display: none !important; }
    body#app.mobile-layout.nav-open #profile { display: flex !important; position: absolute; inset: auto auto 0 0; width: var(--rail-width); height: calc(64px + env(safe-area-inset-bottom,0px)); }
    body#app.mobile-layout.nav-open #nav-profile-bar { display: flex !important; position: absolute; left: var(--rail-width); bottom: 0; width: var(--nav-width); height: calc(64px + env(safe-area-inset-bottom,0px)); padding: 8px 12px calc(8px + env(safe-area-inset-bottom,0px)); }
    body#app.mobile-layout.nav-open #nav-profile-bar > span:not(.avatar) { display: block !important; }
    body#app.mobile-layout #nav-overlay-dismiss { display: none !important; }
    body#app.mobile-layout:is([data-mobile-panel="chats"],[data-mobile-panel="profile"],[data-mobile-panel="people"]) #navigator {
        display: flex !important; position: absolute; inset: var(--shell-header-height) 0 var(--mobile-tab-height);
        width: 100%; height: auto; margin: 0; transform: none; z-index: 85;
    }
    body#app.mobile-layout[data-mobile-panel] #workspace { visibility: hidden; pointer-events: none; }
    body#app.mobile-layout[data-mobile-panel="saved"] #lower-drawer {
        visibility: visible; pointer-events: auto; position: fixed; top: calc(var(--mobile-viewport-top,0px) + var(--shell-header-height));
        bottom: calc(var(--mobile-viewport-bottom,0px) + var(--mobile-tab-height)); left: 0; right: 0;
        height: auto; width: 100%; border-radius: 0; box-shadow: none; transform: none;
        display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: 56px minmax(0,1fr); z-index: 84;
    }
    body#app.mobile-layout #lower-drawer > .board-browser-rail,
    body#app.mobile-layout #lower-drawer > .board-browser-nav { display: none; }
    body#app.mobile-layout #lower-drawer > .shelf-toolbar { grid-column: 1; grid-row: 1; width: 100%; min-width: 0; height: 56px; padding: 4px 8px; }
    body#app.mobile-layout #lower-drawer > .board-browser-view { grid-column: 1; grid-row: 2; min-width: 0; min-height: 0; }
    body#app.mobile-layout #lower-drawer .board-nav-search { min-width: 0; flex: 1; }
    body#app.mobile-layout #lower-drawer .board-nav-search input { width: 100%; min-width: 0; }
    body#app.mobile-layout #shelf-path { display: none; }
    body#app.mobile-layout #board-browser-scroll { padding: 10px; }
    body#app.mobile-layout.board-nav-open #lower-drawer > .board-browser-nav { display: flex; position: absolute; inset: 56px 0 0; width: 100%; height: auto; z-index: 3; }
    body#app.mobile-layout #board-nav-overlay-dismiss { display: none !important; }
    body#app.mobile-layout .post { padding: 8px 12px; max-width: 100%; }
    body#app.mobile-layout .post-body { min-width: 0; }
    body#app.mobile-layout .post-actions { position: static; opacity: 1; pointer-events: auto; background: transparent; box-shadow: none; border: 0; }
    body#app.mobile-layout .post-actions .icon-button { min-width: 40px; min-height: 40px; }
    body#app.mobile-layout #toast { bottom: calc(var(--mobile-tab-height) + 12px); left: 12px; right: 12px; max-width: none; }
    body#app.mobile-layout dialog { max-width: calc(100vw - 16px); max-height: calc(var(--mobile-viewport-height,100dvh) - 24px); }
}
