/* ----- MOBILE (<1024px) ----- */
        @media (max-width: 1023px) {
            html,
            body {
                width: 100%;
                max-width: 100%;
                overflow-x: hidden;
            }

            body.app-page {
                height: 100dvh;
                width: 100%;
                max-width: 100vw;
                box-sizing: border-box;
                display: flex;
                flex-direction: column;
                overflow: hidden;
                overscroll-behavior: none;
                padding-top: env(safe-area-inset-top, 0px);
            }

            #editor-nav {
                height: 3rem;
                min-height: 3rem;
                max-height: 3rem;
                padding: 0 max(0.75rem, env(safe-area-inset-right, 0px)) 0 max(0.75rem, env(safe-area-inset-left, 0px));
                gap: 0.5rem;
                flex-shrink: 0;
            }

            .editor-body-layout {
                flex: 1;
                height: auto;
                min-height: 0;
                max-height: 100%;
                overflow: hidden;
                display: flex;
                padding: 0;
                gap: 0;
                flex-direction: column;
                width: 100%;
                max-width: 100vw;
            }

            .drawer-grip {
                display: block;
            }

            .editor-sidebar-left {
                position: fixed;
                bottom: 0;
                left: 0;
                width: 100%;
                max-width: 100vw;
                max-height: min(72dvh, calc(100dvh - 6.25rem - env(safe-area-inset-bottom, 0px)));
                z-index: var(--z-mobile-sheet);
                padding: 0;
                margin: 0;
                background: rgba(255, 255, 255, 0.98);
                border-radius: 24px 24px 0 0;
                box-shadow: none;
                border-top: 1px solid var(--panel-border);
                transform: translateY(100%);
                transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
                will-change: transform;
                display: flex;
                flex-direction: column;
                overflow: hidden;
                pointer-events: none;
            }

            .editor-sidebar-left.panel-open {
                transform: translateY(0);
                pointer-events: auto;
            }

            .editor-sidebar-right {
                position: fixed;
                bottom: 0;
                left: 0;
                width: 100%;
                max-width: 100vw;
                max-height: min(72dvh, calc(100dvh - 6.25rem - env(safe-area-inset-bottom, 0px)));
                z-index: var(--z-mobile-sheet);
                padding: 0;
                margin: 0;
                background: rgba(255, 255, 255, 0.98);
                border-radius: 24px 24px 0 0;
                box-shadow: none;
                border-top: 1px solid var(--panel-border);
                transform: translateY(100%);
                transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
                will-change: transform;
                display: flex;
                flex-direction: column;
                overflow: hidden;
                pointer-events: none;
            }

            .editor-sidebar-right.panel-open {
                transform: translateY(0);
                pointer-events: auto;
            }

            .editor-sidebar-left .sidebar-shell,
            .editor-sidebar-right .sidebar-shell {
                flex: 1;
                overflow: hidden;
                -webkit-overflow-scrolling: touch;
                border: none;
                border-radius: 0;
                height: auto;
                padding-bottom: env(safe-area-inset-bottom, 0px);
                background: transparent;
                pointer-events: auto !important;
            }

            .editor-main {
                flex: 1;
                min-height: 0;
                display: flex;
                flex-direction: column;
                padding: 0;
                overflow: hidden;
                width: 100%;
                max-width: 100vw;
            }

            .editor-main {
                display: grid !important;
                grid-template-rows: minmax(0, 1fr) auto;
            }

            #canvas-stage {
                flex: 1 1 100%;
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 0;
                width: 100%;
                height: 100%;
                min-height: 100%;
                overflow: hidden;
                border: none;
                box-shadow: none;
                max-width: 100%;
            }

            #canvas-stage {
                min-height: 0 !important;
                height: auto !important;
                flex: 1 1 auto !important;
            }

            #add-to-cart-btn {
                padding: 0.4rem 0.7rem;
            }

            .editor-undo-redo {
                display: none;
            }

            #editor-info-bar {
                padding: 0 max(0.75rem, env(safe-area-inset-left, 0px));
            }

            .editor-bottom-bar {
                display: flex !important;
                flex-direction: column;
                justify-content: center;
                gap: 0.35rem;
                padding: 0.55rem 0.65rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
                background: #ffffff;
                border-top: 1px solid #e5e7eb;
                margin-top: 0.5rem;
                overflow: visible;
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
            }

            .editor-zoom-controls {
                display: none !important;
                align-items: center;
                justify-content: center;
                gap: 0.25rem;
            }

            .editor-context-toolbar {
                display: grid;
                grid-auto-flow: column;
                grid-auto-columns: minmax(0, 1fr);
                align-items: center;
                justify-items: stretch;
                gap: 0.35rem;
                overflow: visible;
                padding-bottom: 0.1rem;
                touch-action: manipulation;
                width: 100%;
            }

            .editor-context-toolbar.hidden {
                display: none !important;
            }

            .context-action {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                gap: 0;
                width: 100%;
                min-width: 0;
                height: 2.55rem;
                padding: 0;
                border-radius: 16px;
                border: 1px solid var(--panel-border);
                background: #ffffff;
                color: #334155;
                font-size: 0.75rem;
                font-weight: 700;
                line-height: 1;
                box-shadow: none;
                white-space: nowrap;
                flex: 0 0 auto;
            }

            .context-action.active {
                background: #eff6ff;
                border-color: #bfdbfe;
                color: #1d4ed8;
            }

            .context-action--danger {
                color: #dc2626;
            }

            .context-action:disabled,
            .context-action.is-disabled {
                opacity: 0.42;
                color: #94a3b8;
                border-color: #e2e8f0;
                background: #f8fafc;
                box-shadow: none;
                cursor: not-allowed;
                transform: none;
            }

            .context-action:disabled svg,
            .context-action.is-disabled svg {
                opacity: 0.78;
            }

            .context-popover-anchor {
                position: relative;
                width: 100%;
                min-width: 0;
            }

            .context-popover-anchor.hidden {
                display: none !important;
            }

            .context-popover {
                position: absolute;
                right: 50%;
                bottom: calc(100% + 0.6rem);
                transform: translate(50%, 0.75rem) scale(0.96);
                transform-origin: bottom center;
                opacity: 0;
                pointer-events: none;
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 0.45rem;
                padding: 0.7rem 0.55rem 0.55rem;
                border: 1px solid rgba(148, 163, 184, 0.28);
                border-radius: 18px;
                background: rgba(255, 255, 255, 0.98);
                box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
                backdrop-filter: blur(16px);
                -webkit-backdrop-filter: blur(16px);
                transition: opacity 180ms ease, transform 180ms ease;
                z-index: var(--z-mobile-popover);
                touch-action: none;
            }

            .context-popover--font {
                left: -0.65rem;
                right: -0.65rem;
                width: auto;
                max-width: none;
                bottom: calc(100% - 1px);
                transform: translateY(0.85rem) scale(0.98);
                transform-origin: bottom center;
                align-items: stretch;
                justify-content: flex-start;
                gap: 0.65rem;
                overflow: hidden;
                padding: 0.85rem 0.9rem 0.9rem;
                border-radius: 0;
                border-bottom: 0;
                box-shadow: none;
                backdrop-filter: none;
                -webkit-backdrop-filter: none;
            }

            .quick-font-label {
                font-size: 0.68rem;
                font-weight: 800;
                letter-spacing: 0.14em;
                text-transform: uppercase;
                color: #64748b;
                margin-top: 0.05rem;
            }

            .quick-font-textarea {
                width: 100%;
                min-height: 3.25rem;
                max-height: 9rem;
                resize: vertical;
                border-radius: 14px;
                border: 1px solid #dbe4f0;
                background: #ffffff;
                color: #0f172a;
                font-size: 0.92rem;
                font-weight: 600;
                line-height: 1.35;
                padding: 0.6rem 0.8rem;
                outline: none;
                box-shadow: none;
            }

            .quick-font-textarea:focus {
                border-color: #93c5fd;
                box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
            }

            .quick-font-select {
                width: 100%;
                min-height: 2.65rem;
                border-radius: 14px;
                border: 1px solid #dbe4f0;
                background: #ffffff;
                color: #0f172a;
                font-size: 0.88rem;
                font-weight: 700;
                padding: 0.5rem 0.8rem;
                outline: none;
                box-shadow: none;
            }

            .quick-font-select:focus {
                border-color: #93c5fd;
                box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
            }

            .quick-font-actions {
                display: grid;
                grid-template-columns: repeat(4, minmax(0, 1fr));
                gap: 0.35rem;
                width: 100%;
            }

            .quick-font-action {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                width: 100%;
                min-width: 0;
                height: 2.35rem;
                border-radius: 14px;
                border: 1px solid #dbe4f0;
                background: #ffffff;
                color: #334155;
                box-shadow: none;
                transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease, color 160ms ease;
            }

            .quick-font-action:hover {
                background: #f8fbff;
                border-color: #c7d8f6;
                color: #1d4ed8;
            }

            .quick-font-action.active {
                background: #eff6ff;
                border-color: #bfdbfe;
                color: #1d4ed8;
            }

            .quick-font-letter {
                font-size: 0.95rem;
                line-height: 1;
                font-weight: 900;
            }

            .context-popover::after {
                content: none;
            }

            .context-popover.is-open {
                opacity: 1;
                pointer-events: auto;
                transform: translateY(0) scale(1);
            }

            .context-popover-anchor,
            .context-popover,
            .context-popover * {
                -webkit-tap-highlight-color: transparent;
            }

            .context-popover-value {
                font-size: 0.7rem;
                font-weight: 800;
                color: #0f172a;
                letter-spacing: 0.08em;
            }

            .context-range-vertical {
                -webkit-appearance: none;
                appearance: none;
                width: 9.5rem;
                height: 2rem;
                margin: 0;
                padding: 0;
                background: transparent;
                accent-color: #2563eb;
                touch-action: none;
                user-select: none;
                -webkit-user-select: none;
                cursor: ns-resize;
                position: absolute;
                left: 50%;
                top: 50%;
                transform: translate(-50%, -50%) rotate(-90deg);
                transform-origin: center center;
            }

            .context-range-shell {
                position: relative;
                width: 2rem;
                height: 9.5rem;
                display: flex;
                align-items: center;
                justify-content: center;
                touch-action: none;
            }

            .context-range-vertical::-webkit-slider-runnable-track {
                height: 5px;
                background: linear-gradient(90deg, #dbe4f0 0%, #bfdbfe 100%);
                border-radius: 999px;
            }

            .context-range-vertical::-moz-range-track {
                height: 5px;
                background: linear-gradient(90deg, #dbe4f0 0%, #bfdbfe 100%);
                border-radius: 999px;
            }

            .context-range-vertical::-webkit-slider-thumb {
                -webkit-appearance: none;
                appearance: none;
                width: 18px;
                height: 18px;
                border-radius: 999px;
                border: 2px solid #ffffff;
                background: linear-gradient(180deg, #3b82f6, #2563eb);
                box-shadow: 0 3px 8px rgba(37, 99, 235, 0.32);
                margin-top: -6px;
            }

            .context-range-vertical::-moz-range-thumb {
                width: 18px;
                height: 18px;
                border-radius: 999px;
                border: 2px solid #ffffff;
                background: linear-gradient(180deg, #3b82f6, #2563eb);
                box-shadow: 0 3px 8px rgba(37, 99, 235, 0.32);
            }

            .context-range-vertical:focus {
                outline: none;
            }

            .context-range-vertical::-ms-thumb {
                width: 18px;
                height: 18px;
                border-radius: 999px;
                border: 2px solid #ffffff;
                background: linear-gradient(180deg, #3b82f6, #2563eb);
            }

            .editor-context-toolbar .context-action span {
                display: none;
            }

            .editor-context-toolbar .context-action svg {
                width: 1rem;
                height: 1rem;
                flex: 0 0 auto;
            }

            .editor-mobile-tabs {
                display: grid;
                grid-template-columns: repeat(2, minmax(0, 1fr));
                gap: 0.4rem;
                background: #ffffff;
                border-top: 1px solid #e5e7eb;
                flex-shrink: 0;
                padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
            }

            .editor-mobile-tabs {
                display: grid !important;
                grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
                z-index: var(--z-mobile-tabs);
            }

            /* Compact Mobile Panels */
            .sidebar-section {
                padding: 0.85rem 0.85rem 1rem;
            }

            #elements-panel {
                justify-content: flex-start;
            }

            #properties-panel {
                display: flex;
                flex-direction: column;
                align-items: stretch;
                gap: 0.6rem;
                padding: 0.78rem 0.78rem 0.92rem;
                overflow-y: auto;
                overflow-x: hidden;
                scrollbar-gutter: stable both-edges;
                min-height: 0;
            }

            #elements-panel,
            #layers-panel {
                display: flex;
                flex-direction: column;
                gap: 0.85rem;
                overflow-y: auto;
                overflow-x: hidden;
                min-height: 0;
                scrollbar-gutter: stable both-edges;
                -webkit-overflow-scrolling: touch;
            }

            body:not(.has-layers-panel-open) #layers-panel {
                display: none !important;
            }

            body.has-layers-panel-open #elements-panel {
                display: none !important;
            }

            body.has-layers-panel-open #layers-panel {
                display: flex !important;
            }

            #properties-panel .hidden {
                display: none !important;
            }

            /* Garantir inputs funcionem no mobile */
            .sidebar-shell input,
            .sidebar-shell select,
            .sidebar-shell button,
            .sidebar-shell textarea {
                pointer-events: auto !important;
                position: relative;
                z-index: 1;
            }

            .section-title {
                font-size: 0.7rem;
                margin-bottom: 0.5rem;
            }

            .elements-panel-note {
                font-size: 0.75rem;
            }

            .elements-grid {
                gap: 0.65rem;
            }

            .elements-grid--compact {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .shape-grid {
                grid-template-columns: repeat(3, minmax(0, 1fr));
                gap: 0.55rem;
            }

            .tool-tile {
                justify-content: flex-start;
                gap: 0.7rem;
                padding: 0.76rem 0.8rem;
            }

            .tool-tile__label {
                display: block;
            }

            .shape-tile {
                aspect-ratio: 1 / 1;
                min-height: 0;
                padding: 0.4rem;
            }

            .action-btn {
                padding: 0.5rem 0.65rem;
                font-size: 0.75rem;
                min-height: 2.6rem;
                border-radius: 14px;
            }

            .grid-cols-2 {
                gap: 0.5rem !important;
                grid-template-columns: repeat(2, 1fr) !important;
            }

            /* ForÃ§ar 2 colunas nos botoes de acoes */
            .grid.grid-cols-2 {
                display: grid !important;
                grid-template-columns: 1fr 1fr !important;
            }

            /* ForÃ§ar 3 colunas nas formas */
            .grid.grid-cols-3 {
                display: grid !important;
                grid-template-columns: repeat(3, 1fr) !important;
            }

            #mobile-tab-layers {
                display: flex !important;
            }

            #properties-panel > .mb-4 {
                display: none !important;
            }

            #properties-panel .properties-toolbar-row {
                display: flex !important;
                align-items: center !important;
                justify-content: center !important;
                flex-wrap: nowrap !important;
                overflow-x: auto !important;
            }

            #properties-panel #no-selection,
            #properties-panel #text-properties,
            #properties-panel #image-properties,
            #properties-panel #shape-properties {
                position: static;
                top: auto;
                left: auto;
                right: auto;
                width: 100%;
                max-height: none;
                margin: 0;
                padding: 0.85rem;
                box-shadow: none;
                border: 1px solid rgba(226, 232, 240, 0.95);
                border-radius: 16px;
                background: #ffffff;
            }

            #properties-panel #no-selection,
            #properties-panel #text-properties,
            #properties-panel #image-properties,
            #properties-panel #shape-properties {
                display: none;
            }

            #properties-panel #no-selection:not(.hidden) {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                gap: 0.35rem;
                min-height: 128px;
                padding: 0.95rem 0.85rem;
                text-align: center;
            }

            #properties-panel #text-properties:not(.hidden),
            #properties-panel #image-properties:not(.hidden),
            #properties-panel #shape-properties:not(.hidden) {
                display: flex;
                flex-direction: column;
                gap: 0.55rem;
            }

            body.has-element-selected #properties-panel > .grid.grid-cols-2 {
                display: grid !important;
            }

            body:not(.has-element-selected) #properties-panel > .grid.grid-cols-2,
            body:not(.has-element-selected) #properties-panel #text-properties,
            body:not(.has-element-selected) #properties-panel #image-properties,
            body:not(.has-element-selected) #properties-panel #shape-properties {
                display: none !important;
            }

            #properties-panel > .grid.grid-cols-2 {
                display: grid !important;
                grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
                gap: 0.5rem !important;
                align-items: stretch;
            }

            #properties-panel > .grid.grid-cols-2 > .action-btn {
                min-width: 0;
                width: 100%;
                justify-content: center;
                text-align: center;
                padding-inline: 0.5rem;
                line-height: 1.15;
            }

            #text-properties div,
            #image-properties div,
            #shape-properties div {
                margin-bottom: 0.5rem !important;
            }

            #text-properties label,
            #image-properties label,
            #shape-properties label {
                font-size: 0.75rem;
                margin-bottom: 0.25rem;
            }

            #text-properties input:not([type="color"]),
            #text-properties select,
            #image-properties input:not([type="color"]),
            #shape-properties input:not([type="color"]) {
                padding: 0.35rem 0.5rem;
                font-size: 0.75rem;
            }

            #text-properties input[type="color"],
            #image-properties input[type="color"],
            #shape-properties input[type="color"] {
                min-height: 2.5rem;
                border-radius: 12px;
            }

            #text-properties input[type="range"],
            #image-properties input[type="range"],
            #shape-properties input[type="range"] {
                -webkit-appearance: none;
                appearance: none;
                width: 100%;
                height: 28px;
                padding: 0;
                margin: 4px 0 2px;
                touch-action: manipulation;
                pointer-events: auto !important;
                position: relative;
                z-index: 1;
                background: transparent;
            }

            /* Melhorar thumb do range no mobile */
            #text-properties input[type="range"]::-webkit-slider-thumb,
            #image-properties input[type="range"]::-webkit-slider-thumb,
            #shape-properties input[type="range"]::-webkit-slider-thumb {
                -webkit-appearance: none;
                appearance: none;
                width: 18px;
                height: 18px;
                background: #2563eb;
                cursor: pointer;
                border-radius: 50%;
                border: 2px solid white;
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
                margin-top: -7px;
            }

            #text-properties input[type="range"]::-moz-range-thumb,
            #image-properties input[type="range"]::-moz-range-thumb,
            #shape-properties input[type="range"]::-moz-range-thumb {
                width: 18px;
                height: 18px;
                background: #2563eb;
                cursor: pointer;
                border-radius: 50%;
                border: 2px solid white;
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            }

            /* Estilizar track do range */
            #text-properties input[type="range"]::-webkit-slider-runnable-track,
            #image-properties input[type="range"]::-webkit-slider-runnable-track,
            #shape-properties input[type="range"]::-webkit-slider-runnable-track {
                width: 100%;
                height: 4px;
                background: #dbe4f0;
                border-radius: 9999px;
            }

            #text-properties input[type="range"]::-moz-range-track,
            #image-properties input[type="range"]::-moz-range-track,
            #shape-properties input[type="range"]::-moz-range-track {
                width: 100%;
                height: 4px;
                background: #dbe4f0;
                border-radius: 9999px;
            }

            #text-properties,
            #image-properties,
            #shape-properties {
                display: flex;
                flex-direction: column;
                gap: 0.55rem;
                overflow: visible;
            }

            #text-properties > div,
            #image-properties > div,
            #shape-properties > div {
                margin-bottom: 0 !important;
            }

            #text-properties h3,
            #image-properties h3,
            #shape-properties h3 {
                font-size: 0.95rem;
                margin-bottom: 0.25rem;
            }

            #add-text-btn,
            .upload-image-btn-mobile {
                width: 100%;
                padding: 0.5rem !important;
                font-size: 0.8rem;
            }

            #properties-panel #text-properties h3,
            #properties-panel #image-properties h3,
            #properties-panel #shape-properties h3 {
                margin-bottom: 0.1rem;
            }

            #properties-panel #text-properties input,
            #properties-panel #text-properties select,
            #properties-panel #image-properties input,
            #properties-panel #image-properties select,
            #properties-panel #shape-properties input,
            #properties-panel #shape-properties select {
                width: 100%;
                min-width: 0;
            }

            #properties-panel .grid.grid-cols-2 .action-btn svg,
            #properties-panel .grid.grid-cols-2 .action-btn i {
                flex-shrink: 0;
            }
        }
