/* remove-bg.css - Modern, Colorful & Professional */

:root {
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    --primary-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.08);
    --border-color: #e2e8f0;
}

body.dark-mode {
    --bg-page: #0f172a;
    --bg-surface: #1e293b;
    --glass-bg: rgba(30, 41, 59, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.3);
}

/* --- Vivid Hero Section --- */
.rm-hero {
    text-align: center;
    padding: 1.5rem 1rem 0.5rem; /* Tighter padding */
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
    z-index: 1;
}

/* Abstract Background Blobs - Global */
body::before, body::after {
    content: '';
    position: fixed; /* Fixed to viewport for full page effect */
    width: 500px;
    height: 500px;
    background: var(--primary-gradient);
    filter: blur(100px);
    opacity: 0.15;
    z-index: -1; /* Behind everything */
    border-radius: 50%;
    animation: floatBlob 15s infinite alternate;
    pointer-events: none; /* Ensure clicks pass through */
}

body::before { top: -100px; left: -150px; }
body::after { bottom: -100px; right: -150px; animation-delay: -5s; }

/* Keep animation definition */
@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

.rm-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 50px;
    color: #6366f1;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.rm-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.rm-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 3rem;
    line-height: 1.6;
}

/* --- Tool Section Wrapper --- */
/* --- Tool Section Wrapper --- */
.tool-section {
    position: relative;
    padding: 0.5rem 1rem 2rem; /* Reduced top/bottom padding */
    z-index: 10;
    background: transparent;
}

/* --- Content Sections (SEO & FAQ) --- */
.content-section {
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 1rem;
    position: relative;
    z-index: 10;
    background: transparent;
}

/* --- Container Wrappers --- */
.container {
    position: relative;
    z-index: 10;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* --- 1. Upload View --- */
#uploadView {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 20;
}

.upload-box {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-surface);
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

.upload-box:hover {
    border-color: #ec4899;
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.upload-icon {
    font-size: 4rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.btn-upload-trigger {
    margin-top: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 2rem;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    border: none;
    transition: transform 0.2s;
    cursor: pointer;
}
.btn-upload-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
}

/* --- 2. Loading View --- */
.loading-view {
    display: none; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3.5rem 2.5rem;
    background: var(--bg-surface);
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
    max-width: min(550px, 90vw); /* Responsive from start */
    min-width: min(320px, 90vw); /* Minimum for mobile */
    width: 90%; /* Responsive width */
    margin: 1rem auto;
    border: 1px solid var(--border-color);
    position: relative;
    z-index: 20;
    box-sizing: border-box; /* Include padding in width */
}

.ai-loader-core {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    flex-shrink: 0; /* Prevent collapse */
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem; /* Optimized spacing */
}

.ai-core-icon {
    font-size: 2.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    z-index: 2;
    filter: drop-shadow(0 4px 6px rgba(99, 102, 241, 0.3));
    animation: pulseBrain 2s infinite ease-in-out;
}

.ai-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid rgba(99, 102, 241, 0.3);
    animation: rippleEffect 3s infinite cubic-bezier(0, 0, 0.2, 1);
    z-index: 1;
}
.ai-ripple:nth-child(2) { animation-delay: 0.5s; border-color: rgba(236, 72, 153, 0.3); }
.ai-ripple:nth-child(3) { animation-delay: 1s; }

@keyframes pulseBrain {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes rippleEffect {
    0% { transform: scale(0.8); opacity: 1; border-width: 2px; }
    100% { transform: scale(1.6); opacity: 0; border-width: 0px; } /* Reduced to prevent overflow */
}

.loading-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 1rem 0 0.5rem; /* Optimized for proper spacing */
    position: relative; /* Z-Index context */
    z-index: 50; /* Sit ABOVE ripples */
    white-space: nowrap; /* Prevent text wrapping */
}
.loading-subtitle {
    color: var(--text-muted);
    position: relative;
    z-index: 50;
}

/* --- 3. Editor Wrapper (Result) --- */
.editor-wrapper {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    background: var(--bg-surface);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    border: var(--glass-border);
    position: relative;
    /* Remove restrictive overflow and height to prevent clipping buttons */
    overflow: visible; 
    height: auto;
    display: flex; 
    flex-direction: column;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    position: relative;
    background-color: #f1f5f9;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto; /* Allow scrolling within canvas if needed */
    min-height: 300px;
    height: 500px; /* Default height */
    max-height: 60vh; /* Responsive max height */
}
body.dark-mode .canvas-container {
    background-color: #0f172a;
    background-image: radial-gradient(#334155 1px, transparent 1px);
}

#workCanvas {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border-radius: 8px; 
    max-width: 100%; /* Scale to fit container width */
    max-height: 100%; /* Scale to fit container height */
    width: auto;
    height: auto;
    object-fit: contain; /* Maintain aspect ratio */
}

/* --- Toolbar --- */
.editor-toolbar {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    gap: 0; /* Removing gap to use borders for separation */
    align-items: stretch;
    justify-content: space-between;
    background: linear-gradient(to bottom, rgba(255,255,255,0.95), rgba(255,255,255,0.8));
    overflow-x: auto;
}

/* Groups within toolbar - Strict Areas */
.tool-group {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0 1.5rem; /* More padding for visual separation */
    position: relative;
    flex: 1; /* Assign equal available space or separate areas */
    min-width: 180px; /* Increased minimum width */
    border-right: 1px solid var(--border-color); /* Strict physical divider */
}

/* Remove default separator since we use border-right */
.tool-group::after {
    display: none;
}

.tool-group:last-of-type {
    border-right: none; /* No border for the last tool group before actions */
}

/* Group Titles */
.group-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    text-align: center; /* Center titles in their assigned areas */
    white-space: nowrap;
    opacity: 0.8;
}

/* Control Rows - Vertical Stacking Logic */
.control-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center; /* Center content in the area */
    width: 100%;
}

/* Background Group Specific - Grid Layout */
.bg-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns */
    gap: 0.5rem;
    width: 100%;
}

.bg-grid button {
    width: 100%;
    justify-content: center;
}

/* Specific adjustments for rows that need horizontal alignment */
.control-row > div:not(.bg-grid) {
     display: flex;
     gap: 0.4rem;
     width: 100%;
     align-items: center;
     justify-content: center;
}

/* Input Constraints */
.control-row input[type="number"],
.control-row select {
    width: 100%;
    min-width: 0;
    text-align: center;
}

/* Action Group - Vertical Stack (Mobile Style on Desktop) */
.action-group {
    display: flex;
    flex-direction: column; /* Stack vertically! */
    gap: 0.75rem;
    align-items: stretch; /* Full width buttons */
    margin-left: 0;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
    min-width: 160px; /* Ensure explicit width for the stack */
    justify-content: center;
    background: transparent !important;
}

/* Desktop Action Buttons - Full Width in Stack */
.action-group .btn-primary,
.action-group .btn-secondary,
.action-group .btn-tool {
    width: 100%;
    justify-content: center;
    padding: 0.6rem;
}

/* Tool Buttons */
/* Tool Buttons */
.btn-tool {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    color: var(--text-main);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    min-height: 38px;
}
.btn-tool:hover {
    color: #fff;
    border-color: #6366f1;
    background: #6366f1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
    font-weight: 600;
    white-space: nowrap;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    font-weight: 600;
    white-space: nowrap;
    padding: 0.75rem 1.75rem;
    border-radius: 12px;
    font-size: 0.95rem;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    filter: brightness(1.05); /* Brighter gradient on hover */
}

/* Color Dots */
.color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1), 0 0 0 3px transparent;
    transition: box-shadow 0.2s;
}
.btn-tool:hover .color-dot {
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1), 0 0 0 3px #6366f1;
}

/* Checkerboard Pattern */
.color-dot.transparent-pattern {
    background-color: #ffffff;
    background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), 
                      linear-gradient(-45deg, #ccc 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #ccc 75%), 
                      linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

/* --- SEO Content --- */
.content-section {
    max-width: 900px;
    margin: 4rem auto;
    padding: 0 1.5rem;
}
.section-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2.5rem;
    color: var(--text-main);
}
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}
.feature-card {
    background: transparent;
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}
.step-list {
    display: grid;
    gap: 1.5rem;
    counter-reset: steps;
}
.editor-toolbar .action-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.unit-toggle {
    min-width: 80px; /* Wider click area */
    justify-content: center;
}

.btn-unit {
    flex: 1;
    text-align: center;
    transition: all 0.2s ease;
    font-weight: 600 !important;
}
.step-item {
    display: flex;
    gap: 1rem;
    background: transparent;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}
.step-item::before {
    counter-increment: steps;
    content: counter(steps);
    background: var(--primary-gradient);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

/* Mobile/Desktop visibility helpers - Base styles */
.mobile-only-btn {
    display: none !important; /* Hidden by default on desktop */
}

.desktop-only-btn {
    display: inline-flex !important; /* Visible by default on desktop */
}

/* --- SEO Content Sections --- */
.features-section {
    padding: 4rem 2rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(168, 85, 247, 0.05));
}

.features-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 3rem;
}

.features-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.features-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto 3rem;
}

.feature-card {
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.feature-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.feature-icon i {
    font-size: 1.75rem;
    color: white;
}

.feature-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

.feature-card p {
    color: var(--text-muted);
    line-height: 1.6;
}

.use-cases {
    max-width: 1000px;
    margin: 3rem auto;
    text-align: center;
}

.use-cases h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

.use-case-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.tag {
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.how-it-works {
    max-width: 900px;
    margin: 3rem auto 0;
}

.how-it-works h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2rem;
    text-align: center;
}

.steps {
    display: grid;
    gap: 1.5rem;
}

.step {
    display: flex;
    gap: 1.5rem;
    align-items: start;
}

.step-number {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.step-content p {
    color: var(--text-muted);
    line-height: 1.6;
}

.rm-footer {
    background: var(--bg-surface);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.rm-footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.rm-footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.rm-footer a:hover {
    color: var(--secondary-color);
}

/* --- Mobile / Responsive --- */
@media (max-width: 768px) {
    /* Hero Section */
    .rm-hero { 
        padding: 2rem 1rem; 
    }
    .rm-title { 
        font-size: 2rem; 
        line-height: 1.2;
    }
    .rm-subtitle { 
        font-size: 0.95rem; 
    }

    /* Show mobile buttons, hide desktop - CRITICAL for mobile */
    .mobile-only-btn {
        display: inline-flex !important;
    }

    .desktop-only-btn {
        display: none !important;
    }

    /* Ensure all action group buttons are visible */
    .action-group button {
        display: inline-flex !important;
    }

    /* But still hide desktop-only ones */
    .action-group .desktop-only-btn {
        display: none !important;
    }

    /* Upload Box */
    .upload-box {
        padding: 2rem 1.5rem;
        min-height: 300px;
    }

    /* Canvas Container */
    .canvas-container {
        height: 300px; /* Reduced for mobile to make room for toolbar */
        min-height: 250px;
        padding: 0.5rem;
        max-height: 35vh; /* Ensure toolbar has space */
    }

    /* Loading View - Critical Mobile Fix */
    .loading-view {
        min-width: 280px;
        max-width: 90vw;
        width: auto;
        padding: 2rem 1.5rem;
        margin: 0.5rem auto;
    }

    .loading-title {
        font-size: 1.25rem;
        white-space: normal;
        line-height: 1.3;
    }

    .loading-subtitle {
        font-size: 0.9rem;
    }

    .ai-loader-core {
        width: 80px;
        height: 80px;
        margin-bottom: 1rem;
    }

    /* Editor Wrapper */
    .editor-wrapper {
        max-height: none; /* Remove height constraint on mobile */
        border-radius: 16px;
        display: flex;
        flex-direction: column;
    }

    /* Ensure toolbar is scrollable with visible scrollbar */
    .editor-toolbar::-webkit-scrollbar {
        width: 6px;
    }

    .editor-toolbar::-webkit-scrollbar-track {
        background: var(--bg-page);
        border-radius: 3px;
    }

    .editor-toolbar::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }

    .editor-toolbar::-webkit-scrollbar-thumb:hover {
        background: var(--primary-color);
    }

    /* Toolbar - Optimized for Mobile */
    /* Toolbar - Optimized for Mobile */
    .editor-toolbar {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem;
        padding: 1rem;
        position: relative;
        max-height: none; 
        overflow: visible;
    }
    
    /* Hide complex controls on mobile */
    .tool-group:has(#dimensionPresets),
    .tool-group:has(#exportFormat) {
        display: none !important;
    }

    /* Editing Tools Group - Keep visible */
    .tool-group:has(.btn-tool[onclick*="setTool"]) {
        display: flex;
    }

    /* Background Group - Horizontal Layout (Mobile) */
    .tool-group:has(#bgColorPicker) {
        display: flex;
        padding: 1rem;
    }

    /* The main control row wrapper */
    .tool-group:has(#bgColorPicker) .control-row {
        display: flex;
        flex-direction: column !important;
        gap: 0.75rem;
        width: 100%;
        overflow: visible;
    }

    /* Target the grid container and turn it into a horizontal scroll strip on mobile */
    .bg-grid {
        display: flex !important;
        grid-template-columns: none !important;
        flex-wrap: nowrap !important;
        gap: 0.5rem !important;
        justify-content: flex-start !important;
        width: 100% !important;
        overflow-x: auto !important;
        padding-bottom: 0.5rem !important;
    }

    /* Restore button sizing for horizontal scroll */
    .bg-grid .btn-tool {
        flex: 0 0 auto !important;
        width: 50px !important;
        min-width: 50px !important;
    }
    
    /* Scrollbar for the grid row */
    .bg-grid::-webkit-scrollbar {
        height: 4px;
    }
    .bg-grid::-webkit-scrollbar-track {
        background: var(--bg-page);
    }
    .bg-grid::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 2px;
    }


    .tool-group:has(#bgColorPicker) .group-title {
        text-align: center;
        margin-bottom: 0.75rem;
    }
    
    /* Tool Groups - Mobile Reset */
    .tool-group {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.03); 
        border: 1px solid var(--border-color) !important; /* Restore full border */
        border-radius: 12px;
        margin-bottom: 0.5rem; 
        flex: none !important; /* Remove flex: 1 */
    }

    .tool-group:last-of-type {
        border-right: 1px solid var(--border-color) !important; /* Restore right border */
    }

    .group-title {
        text-align: center !important;
        margin-bottom: 0.5rem;
    }
    
    .action-group {
        border-left: none; 
        margin-left: 0 !important;
        padding-left: 0 !important;
        gap: 0.75rem !important;
    }

    .group-title {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    /* Control Rows - Better Mobile Layout */
    .control-row {
        width: 100%;
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Buttons - Larger Touch Targets */
    .btn-tool {
        min-width: 44px;
        min-height: 44px;
        padding: 0.7rem 0.9rem;
        font-size: 0.85rem;
        flex: 0 0 auto;
    }

    /* Background color buttons - horizontal on mobile */
    .control-row .btn-tool {
        flex: 0 0 auto;
        min-width: 50px;
        min-height: 50px;
        border-radius: 12px;
    }

    /* Keep custom background button inline */
    .tool-group:has(#bgColorPicker) .btn-tool {
        flex-shrink: 0;
    }

    /* Custom background file input button */
    #customBgInput + .btn-tool {
        white-space: nowrap;
    }

    /* Input Fields */
    input[type="number"],
    input[type="color"],
    select {
        min-height: 44px;
        font-size: 16px;
        padding: 0.6rem 0.8rem !important;
        border-radius: 8px;
    }

    /* Action Group - Mobile Layout */
    .action-group {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.75rem !important;
        margin-top: 1rem !important;
        margin-left: 0 !important; /* Reset auto margin */
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }
    
    /* Child buttons */
    .action-group button,
    .action-group .btn-primary,
    .action-group .btn-secondary,
    .action-group .btn-tool {
        width: 100% !important;
        min-height: 52px !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Visibility Toggles for Mobile */
    .mobile-only-btn {
        display: flex !important;
    }

    .desktop-only-btn {
        display: none !important;
    }
}

/* Extra Small Devices */
@media (max-width: 480px) {
    .rm-title {
        font-size: 1.75rem;
    }

    .upload-box {
        padding: 1.5rem 1rem;
    }

    .editor-toolbar {
        padding: 0.75rem;
    }

    .tool-group {
        padding: 0.75rem;
    }

    .btn-tool {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        min-width: 40px;
    }

    #canvasWidth,
    #canvasHeight {
        width: 70px !important;
    }
}
