/* Mobile Optimizations for SLED-Box */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
    }

    /* Top Workspace Bar (Horizontal Scroll) */
    #workspace-sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        padding: 0 15px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        background: var(--bg-deep);
        z-index: 1000;
        -webkit-overflow-scrolling: touch;
    }

    #workspace-sidebar::-webkit-scrollbar { display: none; }

    .ws-icon {
        min-width: 40px;
        min-height: 40px;
        margin-top: 0 !important;
        flex-shrink: 0;
    }

    /* Snippet List Section */
    #snippet-sidebar {
        width: 100%;
        height: 45vh; /* Balanced height for list vs editor visibility */
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        background: var(--bg-sidebar);
    }

    #snippet-list {
        height: calc(100% - 110px);
        overflow-y: auto;
    }

    .snippet-item h4 {
        max-width: 200px;
        font-size: 14px;
    }

    /* Editor Section */
    #editor-container {
        width: 100%;
        min-height: 600px;
    }

    #editor-header {
        padding: 15px;
        display: grid;
        grid-template-columns: repeat(4, 1fr); /* 4 buttons across for tools */
        gap: 8px;
        background: #111;
    }

    #editor-title {
        grid-column: span 4;
        font-size: 16px; /* Prevents iOS auto-zoom */
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border);
    }

    #workspace-selector {
        grid-column: span 4;
        height: 40px;
        font-size: 14px;
    }

    .toolbar-group {
        grid-column: span 4;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .toolbar-btn {
        width: 100%;
        padding: 12px 0;
        font-size: 12px;
        display: flex;
        justify-content: center;
    }

    .btn-save {
        grid-column: span 4; /* Make Save button full width on mobile */
        margin-top: 5px;
    }

    #main-textarea {
        padding: 20px;
        font-size: 16px; /* Prevents iOS auto-zoom */
        line-height: 1.5;
        min-height: 450px;
    }

    /* System Modal Mobile Overrides */
    .modal-content.system-settings {
        width: 95%;
        padding: 20px 15px;
        max-height: 90vh;
    }

    .modal-tabs {
        gap: 10px;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
    }

    .ws-form-row {
        grid-template-columns: 1fr; /* Stack color/emoji/upload on mobile */
        gap: 10px;
    }

    /* Sidebar Footer / Logout */
    .sidebar-footer {
        padding: 15px;
        text-align: center;
    }

    /* Asset Tray Mobile */
    #asset-tray {
        padding: 15px;
        min-height: 120px;
    }

    .asset-card {
        min-width: 110px;
    }

    /* Toast */
    #toast {
        width: calc(100% - 30px);
        left: 15px;
        bottom: 15px;
        text-align: center;
    }
}