/* Mobile navigation controls never participate in the desktop layout. */
.mobile-menu-toggle, .mobile-nav-backdrop, .mobile-nav-heading, .mobile-nav-shortcuts { display: none; }

@media (max-width: 767px) {
    .layout-shell { --header-height: 104px; height: 100vh; height: 100dvh; }
    .top-header {
        height: auto;
        min-height: var(--header-height);
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: 60px auto;
        padding: env(safe-area-inset-top, 0px) max(.75rem, env(safe-area-inset-right, 0px)) 0 max(.75rem, env(safe-area-inset-left, 0px));
        gap: 0 .5rem;
    }
    .header-left { min-width: 0; gap: .65rem; }
    .header-user { display: none; }
    .header-brand { min-width: 0; }
    .header-brand img { max-width: 100%; height: auto; max-height: 28px; }
    .header-nav .nav-btn { min-height: 44px; padding: .5rem; }
    .header-breadcrumb {
        grid-column: 1 / -1;
        grid-row: 2;
        min-width: 0;
        height: 44px;
        display: flex;
        align-items: center;
        gap: .5rem;
        padding: 0;
        text-align: left;
        font-size: .8rem;
        overflow-x: auto;
        border-top: 1px solid #374151;
        scrollbar-width: thin;
    }
    .header-breadcrumb .follow-chip { flex-shrink: 0; margin-left: auto; }
    .mobile-menu-toggle, .mobile-nav-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        gap: .4rem;
        min-width: 44px;
        min-height: 44px;
        border: 1px solid #64748b;
        border-radius: 8px;
        background: #ffffff0a;
        color: #fff;
        font: inherit;
        font-size: .85rem;
        cursor: pointer;
        padding: .5rem;
    }
    .body-area {
        margin-top: calc(var(--header-height) + env(safe-area-inset-top, 0px));
        height: calc(100% - var(--header-height) - env(safe-area-inset-top, 0px));
        min-height: 0;
    }
    .main-content {
        min-width: 0;
        width: 100%;
        padding: 1rem max(.875rem, env(safe-area-inset-right, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(.875rem, env(safe-area-inset-left, 0px));
        overscroll-behavior-y: contain;
    }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(340px, calc(100vw - 40px));
        height: 100vh;
        height: 100dvh;
        z-index: 251;
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        visibility: hidden;
        transform: translateX(-100%);
        transition: transform .2s ease, visibility 0s linear .2s;
        box-shadow: 8px 0 32px #0004;
    }
    .mobile-nav-open .sidebar { visibility: visible; transform: translateX(0); transition-delay: 0s; }
    .mobile-nav-open .main-content { overflow: hidden; }
    .mobile-nav-open .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 250;
        background: #0f172ab3;
        border: 0;
        cursor: pointer;
        touch-action: none;
    }
    .mobile-nav-heading {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        padding: 1rem;
        color: #fff;
        border-bottom: 1px solid #ffffff26;
    }
    .mobile-nav-heading > div { min-width: 0; }
    .mobile-nav-heading strong { font-size: 1.1rem; }
    .mobile-nav-user { display: block; font-size: .8rem; color: #cbd5e1; overflow-wrap: anywhere; margin-top: .25rem; }
    .sidebar-nav-scroll { min-height: 0; overscroll-behavior: contain; padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px)); }
    .mobile-nav-shortcuts { display: grid; grid-template-columns: 1fr; gap: .35rem; padding: .75rem .75rem .25rem; }
    .mobile-nav-shortcuts a {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: .65rem .75rem;
        border: 1px solid #ffffff26;
        border-radius: 8px;
        background: #ffffff0a;
        color: #e2e8f0;
        text-decoration: none;
        font-size: .9rem;
    }
    .mobile-nav-shortcuts a.active { background: #9a3412; color: white; border-color: #fb923c; }
    .sidebar .section-sub-menu a, .sidebar .nav-standalone > a,
    .sidebar .section-header, .sidebar .nav-subgroup-toggle { min-height: 46px; font-size: .9rem; }
    .sidebar .section-sub-menu a { padding-top: .8rem; padding-bottom: .8rem; overflow-wrap: anywhere; }
    .sidebar .switcher-select { min-height: 44px; font-size: 16px; }
    .sidebar .switcher-collapse { min-width: 44px; min-height: 44px; justify-content: center; }
    .sidebar .nav-group-label { font-size: .72rem; padding-top: 1rem; }
    .sidebar :is(a, button, select, [role="button"]):focus-visible,
    .mobile-menu-toggle:focus-visible { outline: 2px solid #fdba74; outline-offset: -2px; }
    .dropdown-menu { max-width: calc(100vw - 24px); }
    .dropdown-menu a, .dropdown-menu button { min-height: 46px; }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}
