:root {
    --bg-dark: #1f2937;
    /* Tailwind gray-800 */
    --bg-panel: #2d3748;
    /* Tailwind gray-700 */
    --bg-tool: #4a5568;
    /* Tailwind gray-600 */
    --text-main: #e2e8f0;
    --accent: #3b82f6;
    /* Blue-500 */
    --border: #4b5563;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: #111827;
    /* Very dark */
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: none;
    transition: background-color 0.2s;
}

body.drag-active {
    background-color: #1a365d !important;
    /* Slight blue tint when dragging */
}

body.drag-active::after {
    content: "Drop Image or Project Here";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #ffffff;
    pointer-events: none;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px 40px;
    border-radius: 12px;
    border: 2px dashed #3b82f6;
}

/* Force high contrast text on inputs and bars */
.options-bar,
.options-bar span,
.options-bar label,
.options-bar input,
.options-bar select,
.modal-content,
.modal-content h5,
.modal-content label,
.modal-content span,
.modal-content input,
.modal-content select,
.form-control,
.form-select {
    color: #ffffff !important;
}

/* Fix Form Inputs Background in Modals */
.form-control,
.form-select {
    background-color: #2d3748;
    border: 1px solid #4a5568;
    color: #ffffff;
}

.form-control:focus,
.form-select:focus {
    background-color: #2d3748;
    color: #ffffff;
    border-color: #63b3ed;
    box-shadow: 0 0 0 0.2rem rgba(99, 179, 237, 0.25);
}

/* Placeholder color fixing */
::placeholder {
    color: #a0aec0 !important;
    opacity: 1;
}

/* Top Bar */
.top-bar {
    min-height: 40px;
    height: auto;
    background-color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Fix 1: Ensure Logo Left, Button Right */
    padding: 0 15px;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 4000;
    /* Fix 3: Massive Z-index to dominate Home Screen */
    flex-wrap: wrap;
}

.logo {
    font-weight: 600;
    margin-right: 20px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(14px, 2vw, 18px);
    max-width: 80%;
    /* Limit width so it doesn't push button */
}

.mobile-menu-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    padding: 0 10px;
    cursor: pointer;
    display: none;
    /* margin-left: auto; Removed, justify-content handles this */
}

@media (max-width: 768px) {

    /* Force horizontal layout for top bar */
    .top-bar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        height: 50px !important;
        min-height: 50px !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0 10px !important;
        gap: 10px !important;
    }

    /* Hamburger button FIRST (on LEFT) */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(59, 130, 246, 0.1) !important;
        border: 1px solid rgba(59, 130, 246, 0.3) !important;
        border-radius: 8px !important;
        padding: 8px 10px !important;
        flex: 0 0 auto !important;
        order: -1 !important;
        /* Move before logo */
        color: #60a5fa !important;
        transition: all 0.2s ease !important;
    }

    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:active {
        background: rgba(59, 130, 246, 0.2) !important;
        border-color: rgba(59, 130, 246, 0.5) !important;
    }

    .logo {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        margin-right: auto !important;
        font-size: 14px !important;
        white-space: nowrap !important;
        flex: 1 1 auto !important;
        max-width: 70% !important;
        overflow: hidden !important;
    }

    /* Hide Desktop Menu Items completely - ALWAYS */
    .menu-items {
        display: none !important;
    }

    /* Professional Drawer-style Menu */
    .menu-items.show {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        max-width: 85vw !important;
        flex-direction: column !important;
        background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
        padding: 0 !important;
        z-index: 6000 !important;
        overflow-y: auto !important;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5) !important;
        border-right: 1px solid rgba(59, 130, 246, 0.2) !important;
        animation: slideInLeft 0.3s ease !important;
    }

    /* Menu Header */
    .menu-items.show::before {
        content: 'Menu';
        display: block !important;
        padding: 20px !important;
        font-size: 18px !important;
        font-weight: 600 !important;
        color: #60a5fa !important;
        border-bottom: 1px solid rgba(59, 130, 246, 0.2) !important;
        background: rgba(59, 130, 246, 0.05) !important;
    }

    .menu-items.show .menu-item {
        padding: 15px 20px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        font-size: 15px !important;
        color: #e2e8f0 !important;
        transition: all 0.2s ease !important;
    }

    .menu-items.show .menu-item:hover {
        background: rgba(59, 130, 246, 0.1) !important;
        color: #60a5fa !important;
        padding-left: 25px !important;
    }

    .user-profile {
        display: none !important;
    }

    /* Hide duplicate mobile menu overlay */
    /* Removed display: none !important because it breaks the menu from opening */
    /* Toolbar positioning fix */
    .toolbar {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        height: 100% !important;
        z-index: 200 !important;
    }

    /* Slide-in animation */
    @keyframes slideInLeft {
        from {
            transform: translateX(-100%);
            opacity: 0;
        }

        to {
            transform: translateX(0);
            opacity: 1;
        }
    }
}

/* Desktop Override - Reset mobile drawer styles when > 768px */
@media (min-width: 769px) {

    .menu-items,
    .menu-items.show {
        display: flex !important;
        position: static !important;
        width: auto !important;
        max-width: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-right: none !important;
        animation: none !important;
        padding: 0 !important;
        overflow: visible !important;
        flex-direction: row !important;
    }

    .menu-items.show::before {
        display: none !important;
    }

    .menu-items .menu-item,
    .menu-items.show .menu-item {
        padding: 8px 12px !important;
        border-bottom: none !important;
        width: auto !important;
    }

    .mobile-menu-toggle {
        display: none !important;
    }
}

.text-blue {
    color: var(--accent);
}

.menu-items {
    display: flex;
    font-size: 13px;
    flex-wrap: wrap;
}

.menu-item {
    padding: 8px 12px;
    /* Increased padding relative to previous */
    cursor: pointer;
    border-radius: 3px;
    white-space: nowrap;
    width: 100%;
    /* Full width on mobile if wrapped */
    text-align: left;
}

@media (min-width: 769px) {
    .menu-item {
        width: auto;
        /* Auto width on desktop */
    }
}

.menu-item:hover {
    background-color: var(--bg-tool);
}

.user-profile {
    margin-left: auto;
    font-size: 13px;
}

/* Options Bar */
.options-bar {
    height: 35px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 13px;
}

.separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 10px;
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.toolbar {
    width: 72px;
    /* Two columns by default */
    flex-shrink: 0;
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    /* Support two columns */
    flex-direction: row;
    /* Row-based wrapping */
    align-content: flex-start;
    padding: 3px;
    gap: 2px;
    position: relative;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.2s ease;
}

.toolbar.narrow {
    width: 38px !important;
    flex-direction: column !important;
    /* Force column stack */
    flex-wrap: nowrap !important;
    align-items: center !important;
    padding: 0 !important;
    gap: 2px !important;
}

.toolbar.narrow .tool-group-container {
    width: 30px !important;
    height: 30px !important;
    margin: 0 auto !important;
}

.toolbar.narrow .toolbar-header {
    justify-content: center !important;
    padding: 0 !important;
}

.toolbar.narrow .toolbar-header span {
    display: none !important;
    /* Hide text in single column */
}

/* Ensure toggle button fits in narrow mode */
.toolbar.narrow #btn-toggle-columns {
    width: 30px !important;
    margin: 5px auto !important;
}

/* Toolbar Header — aligns with project tabs bar */
.toolbar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 30px;
    min-height: 30px;
    background: #1f2937;
    margin: 0 -3px;
    border-bottom: 1px solid var(--border);
    color: #9ca3af;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
    width: 100% !important;
}

.toolbar-header i {
    font-size: 10px;
    color: var(--accent);
}

.toolbar-header span {
    display: none;
}

.tool-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d1d5db;
    cursor: pointer;
    border-radius: 0 !important;
    font-size: 13px;
}

.toolbar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 5px;
    width: calc(100% - 10px);
}

.toolbar.narrow .toolbar-divider {
    margin: 8px 3px;
    width: calc(100% - 6px);
}

.swatch-container {
    position: relative;
    width: 34px;
    height: 34px;
}

.color-swatch {
    width: 22px;
    height: 22px;
    border: 2px solid #fff;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    position: absolute;
    transition: all 0.2s ease;
}

.color-swatch:hover {
    z-index: 10;
    border-color: var(--accent);
}

.color-swatch.primary {
    top: 0;
    left: 0;
    z-index: 5;
    background-color: #000;
}

.color-swatch.secondary {
    bottom: 0;
    right: 0;
    z-index: 4;
    background-color: #fff;
}

.color-swatch.none {
    background-color: #fff !important;
}

.none-indicator {
    display: none;
    position: absolute;
    top: 50%;
    left: -20%;
    width: 140%;
    height: 2px;
    background: #ff4d4d;
    transform: rotate(45deg);
    pointer-events: none;
}

.color-swatch.none .none-indicator,
.prop-color-swatch.none .none-indicator {
    display: block;
}

/* Property Panel Swatches */
.prop-color-swatch {
    width: 45px;
    height: 31px;
    border: 1px solid #4a5568;
    background-color: #000;
    cursor: pointer;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}

.prop-color-swatch:hover {
    border-color: var(--accent);
}

.prop-color-swatch.none {
    background-color: #fff !important;
}

.prop-color-swatch .none-indicator {
    width: 200%;
    left: -50%;
}

.color-picker-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}

.color-controls-mini {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
}


.color-btn {
    font-size: 11px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.color-btn.reset .reset-icon {
    width: 8px;
    height: 8px;
    border: 1px solid currentColor;
    position: relative;
    background: #000;
}

.color-btn.reset .reset-icon::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    border: 1px solid currentColor;
    background: #fff;
    z-index: 10;
}

/* Custom Scrollbar for Toolbar */
.toolbar::-webkit-scrollbar {
    width: 4px;
}

.toolbar::-webkit-scrollbar-track {
    background: transparent;
}

.toolbar::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 2px;
}

.toolbar::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Tool Group Container */
.tool-group-container {
    position: relative;
    margin-bottom: 0;
}

.tool-btn {
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 0 !important;
    color: #9ca3af;
    position: relative;
    margin: 0;
    font-size: 13px;
}

/* Tiny arrow for groupable tools */
.tool-btn.has-dropdown::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 3px solid #9ca3af;
}

.tool-btn:hover {
    background-color: var(--bg-tool);
    color: white;
}

.tool-btn.active {
    background-color: var(--bg-tool);
    color: var(--accent);
    box-shadow: inset 2px 0 0 var(--accent);
    border-radius: 0 !important;
}

.tool-btn.active::after {
    border-top-color: var(--accent);
}


/* Dropdown Menu */
.tool-dropdown {
    display: none;
    position: absolute;
    left: 40px;
    /* To the right of the sidebar */
    top: 0;
    background-color: #2d3748 !important;
    /* Force solid background */
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    flex-direction: column;
    min-width: 150px;
    padding: 6px;
    white-space: nowrap;
    opacity: 1 !important;
    visibility: visible !important;
    height: auto !important;
    /* Force expansion for children */
    min-height: min-content;
    /* Prevent text wrapping */
}

/* Keep dropdown visible when hovered */
.tool-dropdown.show {
    display: flex;
}

.tool-dropdown.show {
    display: flex;
}

.tool-dropdown-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 3px;
    color: #e2e8f0;
    font-size: 13px;
    background-color: #2d3748;
    /* Solid background on items for safety */
    flex-shrink: 0;
}

.tool-dropdown-item:hover {
    background-color: var(--bg-tool);
}

.tool-dropdown-item i {
    width: 20px;
    font-size: 14px;
    margin-right: 8px;
    text-align: center;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    min-width: 0;
    min-height: 0;
    background-color: #1f2937;
    position: relative;
    overflow: hidden;
    /* Changed from auto to hidden to prevent scrollbars on home screen */
    display: flex !important;
    flex-direction: column;
    /* Ensure column so we can center */
    align-items: center;
    justify-content: center;
    /* padding-top creates space for the absolute positioned tabs bar (30px + buffer) */
    padding-top: 40px;
    padding-bottom: 40px;
    padding-left: 20px;
    padding-right: 20px;

}

/* Apply checkerboard to the wrapper of the canvas */
.canvas-container {
    background-image:
        linear-gradient(45deg, #2d3748 25%, transparent 25%),
        /* Slightly lighter checks */
        linear-gradient(-45deg, #2d3748 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2d3748 75%),
        linear-gradient(-45deg, transparent 75%, #2d3748 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    /* Shadow to separate form bg */
    /* margin: auto; removed in favor of grid placement */
}

.canvas-container-centered {
    /* Flexbox 'magic' centering: margin: auto centers item in flex container vertically & horizontally */
    margin: auto;
    /* Ensure it shrinks to fit content */
    width: max-content;
    height: max-content;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    /* Prevent crushing when window is small */
}

/* Panels */
.panels {
    width: 280px;
    flex-shrink: 0;
    background-color: #1a202c;
    /* Deeper dark for sidebar */
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 40;
    height: 100%;
    overflow: visible;
}

.panel {
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex: 1;
    /* Both panels take equal space by default */
    min-height: 0;
    max-height: 100%;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px;
    height: 30px;
    min-height: 30px;
    max-height: 30px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-panel);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-header span {
    color: #ffffff;
    display: flex;
    align-items: center;
}

.panel-header span i {
    margin-right: 8px;
    /* Ensure spacing if icon exists */
    color: #ffffff;
}

/* Professional Properties UI */
/* Compact Property Bar (Bottom) */
.prop-section-compact {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    padding: 0 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    max-width: none;
}

#object-properties-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 2px;
}

/* === Text Options Flyout Panel === */
.flyout-panel {
    display: none;
    position: absolute;
    bottom: 26px; /* just above status bar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    width: clamp(280px, 50vw, 480px);
    background: rgba(17, 24, 39, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: flyoutSlideUp 0.2s ease-out;
    overflow: hidden;
}

.flyout-panel.open {
    display: block;
}

@keyframes flyoutSlideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.flyout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

.flyout-close-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}
.flyout-close-btn:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.flyout-body {
    padding: 10px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flyout-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.flyout-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.flyout-item-wide {
    flex: 2;
}

.flyout-label {
    font-size: 10px;
    color: #64748b;
    font-weight: 500;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.flyout-select {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.6);
    color: #e2e8f0;
    font-size: 12px;
    height: 30px;
    padding: 0 8px;
    border-radius: 6px;
    width: 100%;
    cursor: pointer;
    transition: border-color 0.15s;
}
.flyout-select:focus {
    border-color: #3b82f6;
    outline: none;
}

.flyout-input {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.6);
    color: #e2e8f0;
    font-size: 12px;
    height: 30px;
    padding: 0 8px;
    border-radius: 6px;
    width: 100%;
    text-align: center;
    transition: border-color 0.15s;
}
.flyout-input:focus {
    border-color: #3b82f6;
    outline: none;
}

.flyout-btn-group {
    display: flex;
    gap: 2px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 6px;
    padding: 2px;
}

.flyout-btn {
    background: none;
    border: 1px solid transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 13px;
    padding: 5px 9px;
    border-radius: 4px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.flyout-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.08);
}
.flyout-btn.active {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

/* Toggle button in status bar */
.text-flyout-toggle {
    background: rgba(59, 130, 246, 0.15) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    color: #60a5fa !important;
    border-radius: 4px;
    padding: 2px 8px !important;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.text-flyout-toggle:hover {
    background: rgba(59, 130, 246, 0.25) !important;
}
.text-flyout-toggle.active {
    background: rgba(59, 130, 246, 0.3) !important;
    color: #93c5fd !important;
}

/* Responsive: smaller screens */
@media (max-width: 768px) {
    .flyout-panel {
        width: clamp(260px, 85vw, 400px);
        bottom: 26px;
    }
    .flyout-btn {
        font-size: 12px;
        padding: 4px 7px;
    }
    .flyout-select, .flyout-input {
        height: 28px;
        font-size: 11px;
    }
    .flyout-label {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .flyout-panel {
        width: calc(100vw - 20px);
        left: 10px;
        transform: none;
        border-radius: 10px 10px 0 0;
    }
    @keyframes flyoutSlideUp {
        from { opacity: 0; transform: translateY(12px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .flyout-row {
        flex-wrap: wrap;
    }
    .flyout-item {
        min-width: 80px;
    }
}

/* === Inline Gradient Bar (Photoshop-style) === */
.gradient-editor-inline {
    padding: 8px 0 4px;
}
.gradient-bar-wrapper {
    position: relative;
    margin-bottom: 2px;
}
.gradient-bar {
    width: 100%;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    cursor: crosshair;
    background: linear-gradient(to right, #ff0000, #0000ff);
}
.gradient-stops-track {
    position: relative;
    height: 18px;
    margin-top: 2px;
}
.gradient-stop-marker {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid #ccc;
    border-radius: 2px;
    cursor: pointer;
    transform: translateX(-50%);
    top: -2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    transition: border-color 0.1s;
}
.gradient-stop-marker::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #ccc;
}
.gradient-stop-marker.selected {
    border-color: #3b82f6;
    z-index: 2;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.4);
}
.gradient-stop-marker.selected::before {
    border-bottom-color: #3b82f6;
}
.gradient-stop-marker .stop-delete {
    display: none;
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: #f87171;
    cursor: pointer;
    background: rgba(0,0,0,0.7);
    border-radius: 2px;
    padding: 0 3px;
    line-height: 14px;
}
.gradient-stop-marker.selected .stop-delete {
    display: block;
}

/* === Corner Radius Professional Grid === */
.corner-radius-grid {
    display: flex;
    align-items: center;
    gap: 12px;
}
.corner-radius-preview {
    flex-shrink: 0;
}
.corner-preview-svg {
    opacity: 0.6;
}
.corner-inputs-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex: 1;
}
.corner-input-pair {
    display: flex;
    align-items: center;
    gap: 4px;
}
.corner-label {
    font-size: 9px;
    color: #64748b;
    white-space: nowrap;
    min-width: 28px;
}
.corner-label i {
    font-size: 8px;
}
.corner-input {
    background: rgba(30,41,59,0.9);
    border: 1px solid rgba(71,85,105,0.6);
    color: #e2e8f0;
    font-size: 11px;
    height: 26px;
    width: 50px;
    padding: 0 6px;
    border-radius: 4px;
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}
.corner-input:focus {
    border-color: #3b82f6;
}

.compact-group {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.compact-select, .compact-select-xs {
    background: #1f2937;
    border: 1px solid #374151;
    color: #e2e8f0;
    font-size: 11px;
    height: 22px;
    padding: 0 4px;
    border-radius: 3px;
    outline: none;
}

.compact-select {
    width: 100px;
}

.compact-input {
    background: #1f2937;
    border: 1px solid #374151;
    color: #e2e8f0;
    font-size: 11px;
    height: 22px;
    width: 45px;
    padding: 0 4px;
    border-radius: 3px;
    outline: none;
    -moz-appearance: textfield;
}

.compact-input::-webkit-outer-spin-button,
.compact-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.compact-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #9ca3af;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.compact-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.compact-btn.active {
    background: #3b82f6;
    color: #ffffff;
}

.compact-swatch {
    width: 22px;
    height: 22px;
    border: 1px solid #374151;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.compact-unit {
    font-size: 10px;
    color: #9ca3af;
    margin-left: -2px;
}

.compact-checkbox {
    width: 12px;
    height: 12px;
    cursor: pointer;
}

#tool-options-bar {
    flex: 1;
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 10px;
}

/* Hide scrollbar but keep functionality */
#tool-options-bar::-webkit-scrollbar {
    display: none;
}
#tool-options-bar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Sidebar Layers Adjustment */
#panel-layers {
    flex: 1 !important;
    height: 100% !important;
}

.section-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #60a5fa;
    /* Professional blue */
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 10px;
}

.section-title i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

/* Typography Specific Buttons */
.btn-text-align,
.btn-text-style {
    background: #1a202c;
    border-color: #4a5568 !important;
    color: #9ca3af !important;
    transition: all 0.2s;
}

.btn-text-align:hover,
.btn-text-style:hover {
    background: #4a5568;
    color: white !important;
}

.btn-text-align.active,
.btn-text-style.active {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
}

/* Tiny Button fix */
.btn-xs {
    padding: 1px 5px;
    font-size: 10px;
    border-radius: 3px;
}

.prop-section input[type="number"] {
    height: 31px;
    font-size: 12px;
}

.panel-header i,
.panel-actions i {
    color: #ffffff;
}

.panel-actions i:hover {
    color: var(--accent);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    color: #ffffff;
}

.panel-content label,
.panel-content span,
.panel-content small {
    color: #e5e7eb !important;
}

/* Premium Prop Sections */
.prop-section {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.prop-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #ffffff;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    letter-spacing: 0.8px;
}

/* CMYK Grid Styling */
/* CMYK Grid Styling */
.cmyk-grid {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.cmyk-input-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    /* Distribute space evenly */
}

.cmyk-input-box label {
    font-size: 9px !important;
    font-weight: 800;
    margin-bottom: 4px;
    color: #9ca3af !important;
}

.cmyk-input-box input {
    width: 100%;
    background: #1a202c;
    border: 1px solid #4a5568;
    color: white;
    font-size: 11px;
    text-align: center;
    padding: 2px;
    border-radius: 4px;
    height: 24px;
}

/* Ensure layer icons are white */
.layer-item i {
    color: #ffffff !important;
}

.cmyk-input-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Custom Sliders */
.form-range::-webkit-slider-runnable-track {
    background: #4a5568;
    height: 4px;
    border-radius: 2px;
}

.form-range::-webkit-slider-thumb {
    background: var(--accent);
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border: 2px solid #ffffff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.form-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

/* Color Picker Tuning */
.form-control-color {
    padding: 2px !important;
    background: #1a202c !important;
    border: 1px solid #4a5568 !important;
    cursor: pointer;
    transition: all 0.2s;
}

.form-control-color:hover {
    border-color: var(--accent) !important;
}

/* Switch Customization */
.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-check-input {
    background-color: #4a5568;
    border-color: #4a5568;
}

/* Layer Items */
.layer-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: var(--bg-panel);
    cursor: pointer;
    font-size: 13px;
    color: #ffffff;
}

.layer-item:hover {
    background-color: var(--bg-tool);
}

.layer-item.active {
    background-color: #4a5568 !important;
}

.layer-vis {
    margin-right: 10px;
    color: #ffffff;
    width: 14px;
    text-align: center;
}

.layer-thumb {
    width: 30px;
    height: 20px;
    background: white;
    margin-right: 10px;
    border: 1px solid #999;
}

.layer-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status Bar */
.status-bar {
    height: 25px;
    background-color: var(--bg-dark);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 15px;
    font-size: 11px;
    color: #9ca3af;
    gap: 8px; /* Standardize gap */
}

.status-bar > *:not(script):not(style) {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

.status-bar .status-item-dims {
    margin-right: 0 !important;
}
.status-bar .status-divider {
    margin-right: 0 !important;
    opacity: 0.5;
}
#active-tool-container {
    margin: 0 !important;
}
#status-color-mode {
    margin: 0 !important;
}
.status-bar {
    display: flex !important;
    align-items: center;
    gap: 12px !important; /* Single global gap for status bar items */
    padding: 0 10px;
}
.status-bar > * {
    margin: 0 !important; /* Remove all individual margins to let gap control layout */
}


/* === Bottom Toolbar Bars === */
#permanent-properties-bar,
#tool-options-bar {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px !important; /* Unified gap for elements inside these bars */
    min-width: 0;
}
#permanent-properties-bar::-webkit-scrollbar,
#tool-options-bar::-webkit-scrollbar { display: none; }

#tool-options-bar {
    flex: 1; /* Dynamic part takes remaining space */
}
#permanent-properties-bar {
    flex-shrink: 0; /* Permanent part keeps its size */
}

#tool-options-bar .tob-sep {
    width: 1px;
    height: 14px;
    background: #4b5563;
    margin: 0 4px !important; /* Tighter separator spacing */
    flex-shrink: 0;
}

#tool-options-bar .tob-label {
    font-size: 10px;
    color: #9ca3af;
    white-space: nowrap;
    margin-right: 3px;
    flex-shrink: 0;
    user-select: none;
}

#tool-options-bar .tob-group {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

#tool-options-bar input[type="number"] {
    width: 42px;
    height: 18px;
    background: #1a202c;
    border: 1px solid #4b5563;
    border-radius: 3px;
    color: #e2e8f0;
    font-size: 10px;
    padding: 0 3px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}
#tool-options-bar input[type="number"]::-webkit-inner-spin-button,
#tool-options-bar input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#tool-options-bar input[type="range"] {
    width: 60px;
    height: 12px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

#tool-options-bar select {
    height: 18px;
    background: #1a202c;
    border: 1px solid #4b5563;
    border-radius: 3px;
    color: #e2e8f0;
    font-size: 10px;
    padding: 0 4px;
    outline: none;
    cursor: pointer;
    max-width: 90px;
}

#tool-options-bar input[type="checkbox"] {
    transform: scale(0.75);
    accent-color: #3b82f6;
    cursor: pointer;
    margin: 0;
}

#tool-options-bar .tob-chk-label {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: #ccc;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

#tool-options-bar .tob-btn-group {
    display: flex;
    gap: 1px;
    background: #1a202c;
    padding: 1px;
    border-radius: 3px;
    border: 1px solid #4b5563;
}

#tool-options-bar .tob-btn {
    width: 20px;
    height: 18px;
    border: none;
    background: transparent;
    color: #9ca3af;
    border-radius: 2px;
    cursor: pointer;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s;
}
#tool-options-bar .tob-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #e2e8f0;
}
#tool-options-bar .tob-btn.active {
    background: #3b82f6;
    color: white;
}

#tool-options-bar .tob-val {
    font-size: 10px;
    color: #9ca3af;
    min-width: 18px;
    text-align: center;
    white-space: nowrap;
}

/* Status Bar Color Swatch Global */
.tob-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    flex-shrink: 0;
    margin: 0 !important; /* Rely on gap */
    position: relative;
    background-color: #3b82f6; /* Default visible color */
}
.tob-color-swatch.none::after {
    content: "";
    position: absolute;
    width: 130%;
    height: 1px;
    background: red;
    transform: rotate(-45deg);
    top: 50%;
    left: -15%;
}

@media (max-width: 768px) {
    #tool-options-bar {
        display: flex !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100vw - 120px); /* Leave room for tool name and zoom */
        margin-left: 5px;
        padding-right: 15px;
    }
    
    #tool-options-bar::-webkit-scrollbar {
        display: none;
    }
    
    #tool-options-bar .tob-label {
        font-size: 10px;
        margin-right: 3px;
    }
    
    #tool-options-bar input[type="number"] {
        width: 35px !important;
        height: 18px;
        font-size: 10px;
        padding: 0 2px;
    }
    
    #tool-options-bar input[type="range"] {
        width: 40px !important;
    }
    
    #tool-options-bar select {
        height: 18px;
        font-size: 10px;
        padding: 0 12px 0 2px;
    }
    
    #tool-options-bar .tob-group {
        margin-right: 10px;
    }
    
    #tool-options-bar .tob-btn {
        width: 20px;
        height: 20px;
    }
    
    #tool-options-bar .tob-btn i {
        font-size: 10px;
    }
}


/* RTL Support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .toolbar {
    border-right: none;
    border-left: 1px solid var(--border);
}

[dir="rtl"] .panels {
    border-left: none;
    border-right: 1px solid var(--border);
}

[dir="rtl"] .logo {
    margin-right: 0;
    margin-left: 20px;
}

[dir="rtl"] .user-profile {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .panel-actions i {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] .layer-vis {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .layer-thumb {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .status-bar span {
    margin-right: 0;
    margin-left: 20px;
}

/* Fix modal RTL */
[dir="rtl"] .modal-header .btn-close {
    margin-left: 0;
    margin-right: auto;
}

/* ===== RESPONSIVE & FULLSCREEN ===== */

html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: #111827 !important;
}

/* Tablet (< 1024px) */
@media (max-width: 1024px) {
    .panels {
        width: 200px;
    }

    #history-toggler {
        display: none !important;
    }

    .panels.open #history-toggler {
        display: flex !important;
    }

    .toolbar {
        width: 45px;
    }

    .tool-btn {
        width: 32px;
        height: 32px;
    }
}

/* Mobile Landscape / Small Tablet (<768px) */
/* NOTE: Toolbar & panels overlay behavior is handled by the @media(max-width:1024px) block.
   These rules are kept only for non-sidebar elements. */
@media (max-width: 768px) {
    .workspace {
        flex-direction: column;
    }

    .options-bar {
        display: none;
    }
}

/* Mobile Portrait (< 480px) */
@media (max-width: 480px) {
    .top-bar {
        padding: 0 8px;
    }

    .menu-items {
        display: none;
    }

    .logo span {
        display: block;
        /* Show on mobile */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        /* Take remaining space */
        min-width: 0;
        /* Allow shrinking below content size */
    }

    /* panels height override removed — handled by 1024px block */

    .panel-header {
        padding: 6px 8px;
        font-size: 11px;
    }
}

/* Drag and Drop */
.layer-item.dragging {
    opacity: 0.5;
}

.layer-item.drag-over {
    border-top: 2px solid #3b82f6;
}

/* Home Screen Styling - Centered within Canvas Overlay */
#home-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #111827 !important;
    z-index: 200;
    /* Below top-bar (4000) and toolbars */
    display: flex;
    flex-direction: column;
    justify-content: center !important;
    align-items: center !important;
    color: white !important;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#home-screen .logo {
    height: auto !important;
    /* Prevent stretching */
    flex: none !important;
    /* Don't take up extra space */
    font-size: 2.2rem;
    margin: 0 0 20px 0 !important;
    color: white;
    white-space: normal !important;
    word-break: break-word !important;
    text-align: center;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    width: auto !important;
    max-width: 90% !important;
}

#home-screen .actions {
    height: auto !important;
    /* Prevent stretching */
    flex: none !important;
    /* Don't take up extra space */
    display: flex !important;
    gap: 20px !important;
    justify-content: center !important;
    align-items: center !important;
    margin-top: 0 !important;
    width: 100% !important;
}

/* Base Action Button Styles */
#home-screen .action-btn {
    width: 120px;
    height: 120px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #e5e7eb;
}

#home-screen .action-btn:hover {
    background: #374151;
    transform: translateY(-2px);
    border-color: #3b82f6;
    color: white;
}

#home-screen .action-btn i {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #60a5fa;
}

/* Explore Templates Button */
#home-screen .explore-tpl-btn {
    position: relative;
    background: #1f2937;
    border: 2px solid transparent;
    background-image: linear-gradient(#1f2937, #1f2937), linear-gradient(135deg, #8b5cf6, #6366f1, #3b82f6);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}
#home-screen .explore-tpl-btn i {
    color: #8b5cf6;
    background: -webkit-linear-gradient(135deg, #8b5cf6, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
#home-screen .explore-tpl-btn:hover {
    background-image: linear-gradient(#283347, #283347), linear-gradient(135deg, #a78bfa, #818cf8, #60a5fa);
}

/* AI Background Remover Button */
#home-screen .ai-bg-btn {
    position: relative;
    background: #1f2937;
    border: 2px solid transparent;
    background-image: linear-gradient(#1f2937, #1f2937), linear-gradient(45deg, #ff00cc, #3333ff, #00ffff);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    animation: ai-border-glow 3s linear infinite;
}
#home-screen .ai-bg-btn:hover {
    background-image: linear-gradient(#283347, #283347), linear-gradient(45deg, #ff00cc, #3333ff, #00ffff);
}
#home-screen .ai-bg-btn i {
    color: #ff00cc;
    background: -webkit-linear-gradient(45deg, #ff00cc, #00ffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
@keyframes ai-border-glow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

/* Device Specific Adjustments */
@media (max-width: 1024px) {
    #home-screen .logo {
        font-size: 1.8rem !important;
        margin-bottom: 20px !important;
    }

    #home-screen .action-btn {
        width: 125px !important;
        height: 125px !important;
    }
}

@media (max-width: 768px) {
    #home-screen {
        padding: 20px !important;
        box-sizing: border-box !important;
        justify-content: center !important;
        /* Forces vertical center */
    }

    #home-screen .logo {
        font-size: 1.5rem !important;
        margin-bottom: 25px !important;
        /* Space between logo and buttons */
        flex-direction: row !important;
        gap: 10px !important;
    }

    #home-screen .actions {
        flex-direction: row !important;
        gap: 15px !important;
        margin-top: 0 !important;
    }

    #home-screen .action-btn {
        width: 110px !important;
        height: 110px !important;
        flex: 0 0 auto !important;
    }

    #home-screen .action-btn i {
        font-size: 2rem !important;
    }
}


.tool-dropdown {
    position: absolute;
    left: 45px;
    top: 0;
    background: #1f2937;
    border: 1px solid #4b5563;
    border-radius: 4px;
    padding: 5px 0;
    display: none;
    z-index: 1000;
    width: max-content;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    /* Prevent wrapping */
}

.tool-dropdown-item {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 13px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    white-space: nowrap;
    /* Prevent wrapping */
}


/* ===== MOBILE BOTTOM BAR ===== */
/* ===== MOBILE FAB (Floating Action Bar) ===== */
.mobile-fab-container {
    position: fixed;
    bottom: 130px; /* Above status bar (32px) + ads (90px) + margin */
    left: -22px; /* 50% outside (22px of 44px circle) for a more tucked look */
    z-index: 1100;
    display: none;
    flex-direction: row; /* Expand to the right */
    align-items: center;
    gap: 12px;
}

.mobile-fab-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    padding-left: 18px; /* Shift icon further right so it stays visible in the semi-circle */
    z-index: 2;
}

.mobile-fab-items {
    display: flex;
    flex-direction: row; /* Horizontal icons */
    gap: 10px;
    opacity: 0;
    transform: translateX(-20px) scale(0.5);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-fab-container.expanded .mobile-fab-items {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.mobile-fab-container.expanded .mobile-fab-toggle {
    background: rgba(239, 68, 68, 0.7);
    /* Removed button rotation to keep padding/icon position stable */
}

.mobile-fab-container.expanded .mobile-fab-toggle i {
    transform: rotate(180deg); /* Rotate only the icon */
}

.mobile-fab-container .mobile-nav-item {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transition: all 0.2s;
    padding: 0;
}

.mobile-fab-container .mobile-nav-item i {
    font-size: 13px;
    margin: 0;
}

.mobile-fab-container .mobile-nav-item span {
    display: none;
}

.mobile-fab-container .mobile-nav-item.active {
    background: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.5);
}

/* Ads Sidebar (Desktop) */
.ads-sidebar.ads-desktop {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    background-color: var(--bg-dark);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 0;
    z-index: 40;
    flex-shrink: 0;
    height: 100%;
}

/* Hide Mobile Ad on Desktop */
.ads-mobile {
    display: none;
}

.ads-placeholder {
    width: 100%;
    max-width: 160px;
    height: 600px;
    max-height: 100%;
    background: #2d3748;
    border: 1px dashed #4b5563;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-size: 14px;
    border-radius: 8px;
}

/* ===== RESPONSIVE OVERRIDES ===== */

@media (max-width: 1024px) {

    /* Show Bottom Bar */
    .mobile-bottom-bar {
        display: flex;
    }

    /* Show Hamburger on Tablet/Mobile */
    .mobile-menu-toggle {
        display: block !important;
    }

    /* Show Status Bar above Ads on Mobile */
    .status-bar {
        display: flex !important;
        position: fixed;
        bottom: 90px; /* Right above ads */
        left: 0;
        width: 100%;
        z-index: 1040;
        background: rgba(17, 24, 39, 0.98);
        backdrop-filter: blur(12px);
        height: 32px; /* Increased to fit compact inputs */
        padding: 0 8px;
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        gap: 6px !important; /* Reduced from 12px to fix spacing defects */
        white-space: nowrap;
        scrollbar-width: none;
    }
    .status-bar::-webkit-scrollbar { display: none; }

    .status-bar .status-item-dims {
        white-space: nowrap !important;
        font-size: 9px !important;
        overflow: hidden;
        display: inline-block;
        max-width: 85px !important;
        color: #9ca3af;
    }

    .status-bar .status-divider {
    }

    #active-tool-container {
        display: flex !important;
        align-items: center !important;
    }

    #active-tool-icon {
        display: inline-block !important;
        font-size: 18px !important;
        color: #60a5fa !important;
        min-width: 20px;
        text-align: center;
        line-height: 1;
    }

    #status-color-mode,
    .status-bar span#active-tool-name,
    .status-bar .status-tool-suffix {
        display: none !important;
    }

    #tool-options-bar {
        flex: 0 1 auto !important; /* Changed from flex:1 to prevent empty space expand */
        max-width: none !important;
        margin-left: 0 !important;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* Color Swatch moved outside media query so it paints correctly everywhere */

    /* Hide redundant status elements on very small screens */
    @media (max-width: 600px) {

        #status-color-mode,
        #status-msg,
        .status-bar .zoom-controls,
        #tool-settings {
            display: none !important;
        }

        .status-bar {
            justify-content: space-between;
        }
    }

    /* Adjust Tool Size Slider in Status Bar for Mobile */
    #tool-size-control {
        margin-left: auto;
        /* Push to right */
        border-left: none;
        padding-left: 5px;
    }

    /* Hide Top Header on Mobile - Replaced by Mini Header in Tabs */
    .top-bar {
        display: none !important;
    }

    /* Adjust Layout */
    .main-layout {
        padding-bottom: 60px;
        /* Space for bottom bar */
    }

    /* Panels becomes an Overlay */
    .panels {
        position: fixed;
        top: 31px;
        right: 0;
        bottom: 122px !important; /* Above status bar (32px) + ads (90px) */
        height: unset !important;
        min-height: 0;
        width: 220px;
        z-index: 150;
        border-left: 1px solid var(--border);
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .panels.open {
        transform: translateX(0);
    }

    /* When one panel is active, make it full height of the container */
    .panels.open .panel {
        flex: 1 !important;
        height: 100% !important;
        display: none;
        /* Default hidden unless JS shows it */
    }

    .panels.open .panel[style*="display: flex"] {
        display: flex !important;
    }

    /* Toolbar becomes an Overlay (Hidden by default or slim) */
    .toolbar {
        position: fixed;
        top: 35px !important; /* Adjusted to sit strictly below the project tabs bar */
        left: 0;
        bottom: 122px !important; /* Above status bar (32px) + ads (90px) */
        height: unset !important;
        z-index: 1005 !important; /* Ensure it stays above project tabs (z-index: 1000) */
        width: 40px !important; /* Single column by default on mobile */
        border-right: 1px solid var(--border);
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        flex-direction: column !important; /* Vertical single column */
        flex-wrap: nowrap !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        background-color: var(--bg-dark);
        padding: 3px;
        padding-top: 0;
        align-items: center;
    }

    .toolbar.two-columns {
        width: 72px !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        padding: 5px;
        padding-top: 0;
        align-content: flex-start;
    }

    .toolbar.narrow {
        width: 38px !important;
    }

    .toolbar.open {
        transform: translateX(0);
    }

    /* Mobile dropdown positioning - appear to the right of toolbar */
    .toolbar .tool-dropdown {
        position: fixed !important;
        left: 50px !important; /* Adjusted for single column (40px toolbar) */
        top: auto !important;
        bottom: auto !important;
        min-width: 180px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .toolbar.two-columns .tool-dropdown {
        left: 85px !important; /* Wider offset for two columns */
    }

    /* Toolbar header — force visible, distinct background, clickable */
    .toolbar .toolbar-header {
        display: flex !important;
        height: 28px !important;
        min-height: 28px !important;
        flex-shrink: 0;
        margin: 0 0 4px 0 !important;
        padding: 0 6px;
        width: 100% !important;
        background: rgba(30, 41, 59, 1) !important;
        border-bottom: 1px solid #374151;
        box-sizing: border-box;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        position: relative;
    }

    .toolbar .toolbar-header span {
        display: none; /* Hide text in single column */
        font-size: 8px;
    }

    .toolbar.two-columns .toolbar-header span {
        display: inline; /* Show text in two columns */
    }

    .toolbar .toolbar-header i {
        font-size: 9px;
    }

    .toolbar .tool-btn {
        width: 28px;
        height: 28px;
        margin: 1px;
        font-size: 12px;
        flex-shrink: 0;
    }

    .toolbar.two-columns .tool-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* Enable scrolling for mobile toolbar */
    .toolbar.open {
        overflow-y: auto !important;
        /* Allow scroll when open */
    }

    /* Ensure Canvas takes full space */
    .canvas-area {
        height: 100%;
        width: 100%;
        padding-bottom: 0;
        /* Remove padding if any */
    }

    /* Adjust Project Tabs Bar to not overlap */
    #project-tabs-bar {
        left: 0 !important;
        right: 0 !important;
    }

    /* Show FAB on mobile */
    .mobile-fab-container {
        display: flex !important;
    }

    .mobile-bottom-bar:not(.mobile-fab-container) {
        display: none !important;
    }

    /* Separate Ad Layouts */
    .ads-desktop {
        display: none !important;
    }

    .ads-mobile {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100% !important;
        height: 90px;
        background-color: var(--bg-dark);
        border-top: 1px solid var(--border);
        z-index: 1000;
        justify-content: center;
        align-items: center;
    }

    .ads-mobile .ads-placeholder {
        width: 100% !important;
        max-width: none !important;
        height: 100% !important;
        border: none;
        background: #1a202c;
    }

    /* Adjust main layout to account for ad banner at very bottom */
    .main-layout {
        padding-bottom: 90px !important;
    }

    /* Mobile Dropdown Fix */
    .app-dropdown {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        z-index: 5000 !important;
        background-color: #0f172a !important;
        padding-top: env(safe-area-inset-top, 0);
    }

    .app-dropdown .list-group-item {
        flex-direction: row !important;
        padding: 16px 20px !important;
        border-bottom: 1px solid rgba(255,255,255,0.05) !important;
        font-size: 15px !important;
    }

    .dropdown-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
        background: #1e293b;
        border-bottom: 1px solid #334155;
        font-weight: bold;
        color: white;
    }

    .mobile-mini-header {
        flex-shrink: 0;
    }
    
    #mobile-menu-toggle-mini:active {
        background: rgba(255,255,255,0.1);
    }

    /* === Compact Mobile Styles for Layers Panel === */
    .panels .panel-tabs-header .panel-tab {
        font-size: 10px !important;
        padding: 4px 6px !important;
    }

    .panels .layer-item {
        padding: 4px 6px !important;
        font-size: 11px !important;
    }

    .panels .layer-thumb {
        width: 22px !important;
        height: 14px !important;
        margin-right: 6px !important;
    }

    .panels .layer-name {
        font-size: 11px !important;
    }

    .panels .layer-vis {
        font-size: 11px !important;
        margin-right: 6px !important;
    }

    .panels .layers-list-header {
        padding: 2px 4px !important;
        gap: 4px !important;
    }

    .panels #layer-blend-mode {
        font-size: 9px !important;
        height: 16px !important;
        width: 80px !important;
    }

    .panels #layer-panel-opacity {
        height: 10px !important;
    }

    .panels #layer-panel-opacity-val {
        font-size: 9px !important;
    }

    .panels .panel-footer .layer-footer-btn {
        padding: 2px 4px !important;
    }

    .panels .panel-footer .layer-footer-btn i,
    .panels .panel-footer .layer-footer-btn svg,
    .panels .panel-footer .layer-footer-btn span {
        font-size: 10px !important;
    }

    /* === Drag-to-Resize Handle on Left Edge of Panels === */
    .panels .panels-resize-handle {
        position: absolute;
        left: -6px;
        top: 0;
        width: 12px;
        height: 100%;
        cursor: ew-resize;
        z-index: 200;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .panels .panels-resize-handle::after {
        content: '';
        width: 3px;
        height: 40px;
        background: #4b5563;
        border-radius: 2px;
        transition: background 0.2s;
    }

    .panels .panels-resize-handle:hover::after,
    .panels .panels-resize-handle:active::after {
        background: #60a5fa;
        width: 4px;
    }
}

/* Mobile Menu Overlay Styles */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 9000;
    display: none;
    /* Controlled by JS */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.open {
    display: flex;
    opacity: 1;
}

.mobile-menu-content {
    background-color: var(--bg-dark);
    width: 80%;
    max-width: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    z-index: 9001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.mobile-menu-overlay.open .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.mobile-menu-header button {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
}

.mobile-menu-list {
    padding: 10px 0;
    overflow-y: auto;
}

.mobile-menu-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
    color: white !important;
    /* Force white text */
}

.mobile-menu-item:hover {
    background-color: var(--bg-tool);
}

/* ===== PANEL RESIZER ===== */
.panel-resizer {
    height: 8px;
    background: linear-gradient(to bottom, #374151 0%, #1f2937 50%, #374151 100%);
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.panel-resizer:hover {
    background: linear-gradient(to bottom, #4b5563 0%, #3b82f6 50%, #4b5563 100%);
}

.panel-resizer::after {
    content: '';
    width: 40px;
    height: 3px;
    background: #6b7280;
    border-radius: 2px;
}

.panel-resizer:hover::after {
    background: #93c5fd;
}

/* ===== LAYER FILTER SYSTEM STYLES ===== */

/* Filter Badge on Layer Item */
.layer-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    margin-left: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

.layer-filter-badge:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #9f7afa 0%, #7c7cf9 100%);
    box-shadow: 0 4px 8px rgba(139, 92, 246, 0.4);
}

/* Filter Dialog Modal */
.filter-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    z-index: 10000;
    padding: 100px 50px;
    /* No backdrop-filter so user can see filter preview on layer */
}

.filter-dialog-content {
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    border: 1px solid #374151;
    border-radius: 12px;
    width: 340px;
    max-width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: filterDialogSlideIn 0.2s ease-out;
}

@keyframes filterDialogSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.filter-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #374151;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.filter-dialog-header i {
    color: #8b5cf6;
}

.filter-dialog-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.filter-dialog-close:hover {
    color: #f87171;
}

.filter-dialog-body {
    padding: 20px;
}

.filter-slider-group {
    margin-bottom: 0;
}

.filter-slider-group label {
    display: block;
    color: #9ca3af;
    font-size: 12px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-slider-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.filter-slider-row input[type="range"] {
    flex: 1;
    height: 6px;
    background: #374151;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.filter-slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
}

.filter-slider-row span {
    min-width: 50px;
    text-align: center;
    color: #e5e7eb;
    font-size: 13px;
    font-weight: 500;
    background: #374151;
    padding: 4px 8px;
    border-radius: 6px;
}

.filter-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #374151;
}

.filter-dialog-footer .btn {
    padding: 8px 18px;
    font-size: 13px;
    border-radius: 6px;
}

/* Layer Filters Dropdown */
.layer-filters-dropdown {
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    border: 1px solid #374151;
    border-radius: 8px;
    min-width: 220px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: dropdownFadeIn 0.15s ease-out;
    overflow: hidden;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Advanced Color Picker Modal Styles */
.modal-side-picker {
    max-width: 480px;
    margin: 0;
    position: absolute;
    top: 80px;
    left: 70px;
    z-index: 5000;
}

/* Remove Bootstrap modal backdrop behavior */
#colorPickerModal {
    pointer-events: none;
}

#colorPickerModal .modal-dialog {
    pointer-events: auto;
}

#colorPickerModal.modal.fade .modal-dialog {
    transform: none;
}

#colorPickerModal.modal.show .modal-dialog {
    transform: none;
}

.advanced-picker-content {
    background-color: rgba(26, 32, 44, 0.78) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 5000;
    position: relative;
}

/* Resize Handles (corners) — invisible, cursor only */
.picker-resize-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    z-index: 10;
}

.picker-resize-tl {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.picker-resize-tr {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.picker-resize-bl {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

.picker-resize-br {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

/* Content scaling when resized */
.picker-body-content {
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.picker-top-row {
    flex-shrink: 1;
    min-height: 0;
}

.color-map {
    min-height: 60px;
}

.picker-inputs-row {
    flex-shrink: 0;
}

.picker-footer {
    flex-shrink: 0;
}

.advanced-picker-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Drag Handle */
.picker-drag-handle {
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    padding: 8px 14px !important;
}

.picker-drag-handle .modal-title {
    font-size: 14px;
    font-weight: 600;
}

/* Body Content */
.picker-body-content {
    padding: 10px 14px !important;
}

/* Top row: color map + preview side by side */
.picker-top-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.picker-map-area {
    flex: 1;
    min-width: 0;
}

.picker-preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 80px;
    flex-shrink: 0;
}

#picker-transparent-btn {
    white-space: nowrap;
    font-size: 10px;
    padding: 3px 6px;
    width: 100%;
    text-align: center;
}

/* Inputs row: full width below */
.picker-inputs-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.picker-hex-group {
    flex: 0 0 auto;
    min-width: 100px;
}

.picker-inputs-row .input-group-custom {
    flex: 1;
    min-width: 0;
}

.picker-inputs-row .input-group-custom .d-flex {
    flex-wrap: nowrap;
}

.picker-inputs-row .input-group-custom .field {
    flex: 1;
    min-width: 0;
}

.picker-inputs-row .input-group-custom input {
    width: 100%;
    min-width: 0;
}

/* Footer */
.picker-footer {
    padding: 6px 14px !important;
}

/* ===== Mobile: compact floating panel in corner ===== */
@media (max-width: 768px) {
    .modal-side-picker {
        max-width: 280px !important;
        width: 280px !important;
        margin: 0 !important;
        position: fixed !important;
        top: auto !important;
        bottom: 90px !important;
        left: 10px !important;
        right: auto !important;
        border-radius: 12px !important;
        z-index: 6000 !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
    }

    .advanced-picker-content {
        background-color: rgba(26, 32, 44, 0.55) !important;
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }

    .picker-body-content {
        padding: 6px 8px !important;
    }

    .picker-drag-handle {
        padding: 5px 8px !important;
    }

    .picker-drag-handle .modal-title {
        font-size: 12px !important;
    }

    .color-map {
        height: 100px !important;
    }

    .picker-top-row {
        gap: 6px;
    }

    .picker-preview-col {
        width: 55px;
    }

    .preview-box-container {
        width: 40px !important;
        height: 40px !important;
    }

    #picker-transparent-btn {
        font-size: 8px !important;
        padding: 2px 3px !important;
    }

    .picker-inputs-row {
        gap: 4px;
        margin-top: 6px;
        flex-direction: column;
    }

    .picker-inputs-row .input-group-custom input {
        height: 28px !important;
        padding: 2px 2px 2px 18px !important;
        font-size: 10px !important;
    }

    .picker-hex-group {
        width: 100%;
    }

    .picker-footer {
        padding: 4px 8px !important;
    }

    .picker-footer .btn {
        font-size: 12px;
        padding: 3px 12px;
    }

    .hue-range {
        height: 8px !important;
    }
}

/* ===== iPad / Tablet ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .modal-side-picker {
        max-width: 340px !important;
        width: 340px !important;
        position: fixed !important;
        top: auto !important;
        bottom: 20px !important;
        left: 20px !important;
        right: auto !important;
        border-radius: 12px !important;
    }

    .advanced-picker-content {
        background-color: rgba(26, 32, 44, 0.65) !important;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .color-map {
        height: 120px !important;
    }
}

.color-map {
    width: 100%;
    height: 180px;
    /* Slightly smaller for compact modal */
    background-color: #ff0000;
    position: relative;
    cursor: crosshair;
    border-radius: 4px;
    overflow: hidden;
}

.color-map-white,
.color-map-black {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.color-map-white {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff);
}

.color-map-black {
    background: linear-gradient(to right, #000, rgba(0, 0, 0, 0));
}

.color-cursor {
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 10;
}

.hue-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
    outline: none;
    cursor: pointer;
}

.hue-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid #2d3748;
    border-radius: 50%;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.preview-box-container {
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    border: 1px solid #4a5568;
    border-radius: 4px;
    overflow: hidden;
}

.preview-box {
    flex: 1;
}

.preview-box.new {
    background-color: #ff0000;
}

.preview-box.current {
    background-color: #000;
}

.input-group-custom .label {
    display: block;
    font-size: 10px;
    font-weight: 800;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.input-group-custom .field {
    position: relative;
}

.input-group-custom input {
    width: 100%;
    background: #1a202c;
    border: 1px solid #4a5568;
    color: #fff;
    padding: 10px 10px 10px 25px;
    border-radius: 6px;
    font-size: 13px;
    height: 38px;
}

.input-group-custom .field label {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #718096;
    pointer-events: none;
}

.input-group-custom input::-webkit-inner-spin-button,
.input-group-custom input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-group-custom input:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.filters-dropdown-header {
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #374151;
}

.filter-dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s;
}

.filter-dropdown-item:last-child {
    border-bottom: none;
}

.filter-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.filter-dropdown-item .filter-toggle {
    color: #60a5fa;
    cursor: pointer;
    width: 16px;
    text-align: center;
    transition: color 0.15s;
}

.filter-dropdown-item .filter-toggle:hover {
    color: #93c5fd;
}

.filter-dropdown-item .filter-name {
    flex: 1;
    color: #e5e7eb;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-dropdown-item .filter-value-badge {
    background: #374151;
    color: #9ca3af;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

.filter-dropdown-item .filter-adjust,
.filter-dropdown-item .filter-delete {
    color: #6b7280;
    cursor: pointer;
    font-size: 11px;
    padding: 4px;
    transition: color 0.15s;
}

.filter-dropdown-item .filter-adjust:hover {
    color: #8b5cf6;
}

@media (max-width: 991px) {
    #panel-toggler {
        display: none !important;
    }
}

/* Custom Menu Divider */
.menu-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.5);
    /* Semi-transparent white for natural look */
    margin: 6px 0;
    width: 100%;
}

.app-dropdown {
    overflow: hidden;
    padding: 0;
    background-color: #1a202c !important;
    /* Ensure solid dark background */
    border: 1px solid #4b5563;
    border-radius: 4px;
}

.app-dropdown .list-group-item {
    border-radius: 0;
    margin: 0;
}

.app-dropdown .menu-divider {
    background-color: #ffffff;
    /* Solid white line */
    opacity: 0.3;
    /* Subtle but clear */
    height: 1px;
    margin: 4px 0;
}

/* --- Tool Column Toggle Override --- */
/* Placing at the end with !important to ensure it works across all media queries */
.toolbar.two-columns {
    width: 80px !important;
    display: grid !important;
    grid-template-columns: repeat(2, 34px) !important;
    justify-content: center !important;
    justify-items: center !important;
    padding: 0 3px 6px 3px !important;
    gap: 4px 2px !important;
    align-content: flex-start !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    overflow-x: hidden !important;
}

.toolbar.two-columns .toolbar-header {
    grid-column: span 2 !important;
    width: calc(100% + 6px) !important;
    margin: 0 -3px !important;
}

.toolbar.two-columns .toolbar-header span {
    display: inline !important;
}

.toolbar.two-columns .tool-group-container {
    width: 34px !important;
    display: flex !important;
    justify-content: center !important;
    margin: 0 !important;
}

.toolbar.two-columns .color-picker-section {
    grid-column: span 2 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 15px !important;
    padding: 10px 0 !important;
}

.toolbar.two-columns .color-controls-mini {
    flex-direction: column !important;
    gap: 8px !important;
}

.toolbar.two-columns .toggle-columns-container {
    grid-column: span 2 !important;
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    margin-top: 5px !important;
}

.toolbar.two-columns .toolbar-divider {
    grid-column: span 2 !important;
    width: calc(100% - 10px) !important;
}


.toolbar.two-columns .tool-btn {
    width: 30px !important;
    height: 30px !important;
    margin: 0 !important;
    font-size: 13px !important;
}

/* Tool Size Control in Status Bar */
#tool-size-control {
    display: none;
    /* Hidden by default */
    align-items: center;
    gap: 8px;
    margin-right: 15px;
    padding-left: 15px;
    border-left: 1px solid #4b5563;
}

#tool-size-number {
    background: #1a202c;
    border: 1px solid #4b5563;
    color: #fff;
    width: 40px;
    text-align: center;
    font-size: 11px;
    border-radius: 3px;
}

#tool-size-slider {
    width: 60px;
    height: 4px;
    cursor: pointer;
    accent-color: var(--accent);
}

@media (max-width: 768px) {
    #tool-size-control {
        gap: 4px;
        margin-right: 5px;
        padding-left: 5px;
    }

    #tool-size-slider {
        width: 40px;
    }
}

#brush-cursor-preview {
    position: fixed !important;
    pointer-events: none !important;
    border: 1.5px solid #ffffff !important;
    mix-blend-mode: difference !important;
    z-index: 2147483647 !important;
    display: none;
    box-sizing: border-box;
    border-radius: 50%;
    /* Circle by default */
}

#brush-cursor-preview.square {
    border-radius: 0;
}

#brush-cursor-preview.circle {
    border-radius: 50%;
}

/* Fix Mobile Toolbar Header & Bottom Spacing */
@media (max-width: 768px) {
    .toolbar {
        padding-bottom: 130px !important;
        /* Prevent overlap with bottom bar */
    }

    /* If toolbar is narrow on mobile (default often is), ensure header is small */
    .toolbar.narrow .toolbar-header {
        height: 30px !important;
    }

    .toolbar.narrow .toolbar-header span {
        display: none !important;
    }
}

/* Fixed Tool Dropdowns */
.tool-dropdown {
    /* Base styles were absolute, override for fixed if JS sets it */
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    background-color: #2d3748;
}

/* Centered & Interactive Toggle Columns Button */
.toggle-columns-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 5px 0;
}

#btn-toggle-columns {
    margin: 0 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 6px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-toggle-columns:hover {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

#btn-toggle-columns:active {
    transform: translateY(0);
}

.toolbar.two-columns #btn-toggle-columns {
    width: 80% !important;
    color: #60a5fa;
}

/* Active State for Screen Mode & Quick Mask */
.tool-btn.active-state {
    color: #60a5fa !important;
    background: rgba(59, 130, 246, 0.15);
}


/* Ensure status bar doesn't wrap content */
.status-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Screen Mode Styles */
body.mode-full-menu .status-bar,
body.mode-full-menu .mobile-bottom-bar,
body.mode-full-menu .ads-mobile {
    display: none !important;
}

body.mode-full-menu .main-layout {
    padding-bottom: 0 !important;
}

body.mode-full-pure .top-bar,
body.mode-full-pure .status-bar,
body.mode-full-pure .panels,
body.mode-full-pure #right-panels,
body.mode-full-pure .mobile-bottom-bar,
body.mode-full-pure .ads-mobile,
body.mode-full-pure .toolbar-header {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

body.mode-full-pure .main-layout {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

body.mode-full-pure .workspace {
    height: 100vh !important;
}

/* Custom Cursors */
.cursor-gradient {
    /* Crosshair with a small plus */
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>') 12 12, crosshair !important;
}

.cursor-bucket {
    /* Paint bucket icon */
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="black" stroke="white" stroke-width="1"><path d="M19 11L14 16L3 5L8 0L19 11ZM17 13L21 17L16 22L12 18"></path><path d="M16 22L12 18L3 27L7 31"></path></svg>') 0 16, cell !important;
}

.cursor-pencil {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>') 0 20, crosshair !important;
}

.cursor-pen {
    cursor: url('../img/cursor-pen.svg') 18 4, crosshair !important;
}

.cursor-penfree {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25z' fill='black' stroke='white' stroke-width='0.5'/><path d='M20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z' fill='black' stroke='white' stroke-width='0.5'/></svg>") 1 23, crosshair !important;
}

/* Gradient Editor Styles */
.gradient-editor-container {
    width: 100%;
    padding: 0 5px;
}

#gradient-track {
    width: 100%;
    height: 20px;
    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: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    border-radius: 4px;
    border: 1px solid #4b5563;
    position: relative;
    cursor: crosshair;
    margin-bottom: 20px;
    /* Space for stops below */
    background-color: #fff;
}

#gradient-preview {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    /* Background gradient set via JS */
}

/* Container directly under track */
.gradient-stops-container {
    position: relative;
    height: 0;
    top: -10px;
    /* Pull stops up to track bottom edge */
    width: 100%;
}

.gradient-stop {
    position: absolute;
    top: 5px;
    width: 12px;
    height: 14px;
    background: #fff;
    border: 1px solid #000;
    transform: translateX(-6px);
    /* Center nicely */
    cursor: grab;
    z-index: 10;
    /* Triangle pointing up */
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.gradient-stop::after {
    /* Intentionally empty - color preview handled by .stop-color-box */
    content: none;
}

/* Better Stop Implementation: Triangle + Color Box */
.gradient-stop {
    all: unset;
    position: absolute;
    top: 0;
    /* relative to container which is just below track */
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid #cbd5e0;
    /* Default handle color */
    transform: translateX(-50%);
    cursor: grab;
    z-index: 10;
}

/* The color box below the triangle */
.gradient-stop .stop-color-box {
    position: absolute;
    top: 8px;
    /* Below triangle */
    left: -6px;
    /* Relative to center */
    width: 12px;
    height: 12px;
    background: currentColor;
    border: 1px solid #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.gradient-stop.selected {
    z-index: 20;
    border-bottom-color: #3b82f6;
    /* Blue selection */
}

.gradient-stop:hover {
    border-bottom-color: #60a5fa;
}

/* History Items */
.history-item {
    padding: 6px 10px;
    cursor: pointer;
    color: #9ca3af;
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    transition: background 0.15s, color 0.15s;
    font-size: 11px;
}

.history-item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #e2e8f0;
}

.history-item.active {
    background: rgba(59, 130, 246, 0.2);
    color: #ffffff;
    border-left: 2px solid #3b82f6;
}

/* Sharp Tool Aesthetics */
.tool-btn i,
.tool-dropdown-item i,
.prop-color-swatch {
    border-radius: 0 !important;
}

.fa-square-full {
    border-radius: 0 !important;
}

#canvas-wrapper {
    overflow: visible !important;
}
/* Panel Tabs Header (Photoshop Style) */
.panel-tabs-header {
    display: flex;
    background: #2d3748;
    border-bottom: 1px solid #1f2937;
    padding-top: 4px;
    padding-left: 6px;
}

.panel-tab {
    padding: 6px 14px;
    color: #9ca3af;
    font-size: 13px;
    cursor: pointer;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    margin-right: 2px;
    background: #374151;
    font-weight: 500;
}

.panel-tab.active {
    background: #4b5563;
    color: #ffffff;
}

.panel-tab:hover:not(.active) {
    background: #4b5563;
    color: #d1d5db;
}

/* Tab contents and Channels */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.channel-item, .path-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid #374151;
    cursor: pointer;
    background: #4b5563;
}

.channel-item.active, .path-item.active {
    background: #60a5fa;
}

.channel-item .channel-name {
    margin-left: 10px;
    font-size: 13px;
    color: #e5e7eb;
    font-style: italic;
}

.channel-item .layer-vis {
    color: #9ca3af;
    margin-right: 10px;
    font-size: 14px;
}

.channel-item .layer-vis:hover {
    color: #ffffff;
}

.channel-item .layer-thumb {
    width: 32px;
    height: 24px;
    background-color: white;
    border: 1px solid #1f2937;
    margin-right: 10px;
}

/* Canvas wrapper filtered state */
.canvas-filtered {
    filter: url(#channel-filter);
}

/* Top Bar Shrinking */
.top-bar {
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 10px !important;
}

.top-bar .menu-item {
    padding: 0 10px !important;
    font-size: 13px !important;
    height: 38px !important;
    line-height: 38px !important;
}

.top-bar .logo img {
    max-height: 18px !important;
}

.top-bar .logo span {
    font-size: 14px !important;
}

.top-bar .btn-sm {
    padding: 2px 8px !important;
    font-size: 12px !important;
}

.top-bar .login-btn, .top-bar .register-btn {
    font-size: 12px !important;
}

/* Tabs Shrinking to match Properties panel */
.panel-tabs-header {
    height: 30px !important;
    min-height: 30px !important;
    padding-top: 4px;
    padding-left: 6px;
    align-items: flex-end;
}

.panel-tab {
    padding: 4px 10px !important;
    font-size: 12px !important;
    height: 26px !important;
    line-height: 18px !important;
}

.channel-item, .path-item {
    padding: 4px 8px !important;
    border-bottom: 1px solid #1f2937 !important;
}

.channel-item .channel-name, .path-item .layer-name {
    font-size: 12px !important;
}

.channel-item .layer-thumb, .path-item .layer-thumb {
    width: 28px !important;
    height: 20px !important;
    margin-right: 8px !important;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The black square/content inside channel thumbnail matching Photoshop */
.channel-item .layer-thumb::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: black;
}

/* ======= LAYER FOOTER BUTTONS (Photoshop-style) ======= */
.layer-footer-btn {
    width: 24px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #9ca3af;
    font-size: 11px;
    border-radius: 2px;
    transition: color 0.15s, background 0.15s;
    position: relative;
    flex-shrink: 0;
}

.layer-footer-btn.has-menu {
    width: 32px;
}

.layer-footer-btn .menu-arrow {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 8px;
    color: #6b7280;
    pointer-events: none;
}

.layer-footer-btn:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,0.08);
}

.layer-footer-btn:active {
    background: rgba(59,130,246,0.2);
    color: #60a5fa;
}

.layer-footer-btn svg {
    pointer-events: none;
}

/* Tooltip on hover */
.layer-footer-btn[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    border: 1px solid #374151;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    margin-bottom: 4px;
}

/* ======= LAYER FOOTER POPUP MENUS ======= */
.layer-popup-menu {
    position: absolute;
    bottom: 100%;
    background: #1e293b;
    border: 1px solid #374151;
    border-radius: 6px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    z-index: 9999;
    min-width: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px 0;
    margin-bottom: 6px;
}

.layer-popup-menu .popup-menu-item {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    cursor: pointer;
    color: #d1d5db;
    font-size: 12px;
    transition: background 0.1s;
    gap: 8px;
    white-space: nowrap;
}

.layer-popup-menu .popup-menu-item:hover {
    background: #334155;
    color: #f1f5f9;
}

.layer-popup-menu .popup-menu-item i,
.layer-popup-menu .popup-menu-item svg {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    font-size: 11px;
    color: #64748b;
}

.layer-popup-menu .popup-menu-item:hover i,
.layer-popup-menu .popup-menu-item:hover svg {
    color: #93c5fd;
}

.layer-popup-menu .popup-divider {
    height: 1px;
    background: #334155;
    margin: 4px 0;
}

/* ======= DUAL THUMBNAIL MASK UI (Photoshop-style) ======= */
.layer-item .layer-thumbnails {
    display: flex;
    align-items: center;
    gap: 0;
    margin-right: 8px;
    flex-shrink: 0;
}

.layer-item .layer-thumb {
    width: 28px;
    height: 28px;
    background: #444;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    border: 1px solid #374151;
    cursor: pointer;
    transition: border 0.15s;
    user-select: none;
}

.layer-item .layer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Link icon between thumbnails */
.layer-item .mask-link-icon {
    font-size: 10px;
    color: #4b5563;
    padding: 0 1px;
}

/* Focus Border - Indicated by a blue selection */
.layer-item .layer-thumb.focus-thumb {
    border: 2px solid #3b82f6 !important;
}

.layer-item .layer-thumb:hover {
    border-color: #60a5fa;
}

/* Mask Thumb specifics (Black & White look) */
.layer-item .layer-thumb.mask-thumb {
    background: #000;
}

.layer-item .layer-thumb.mask-thumb img {
    image-rendering: pixelated;
}


/* Layer Style Dialog */
.layer-style-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1e293b;
    border: 1px solid #374151;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    z-index: 10000;
    min-width: 420px;
    max-width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.layer-style-dialog .dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #0f172a;
    border-bottom: 1px solid #334155;
    cursor: move;
}

.layer-style-dialog .dialog-header span {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}

.layer-style-dialog .dialog-header button {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 16px;
    cursor: pointer;
}

.layer-style-dialog .dialog-body {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
}

.layer-style-dialog .dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #334155;
    background: #0f172a;
}

.style-control-group {
    margin-bottom: 12px;
}

.style-control-group label {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.style-control-group input[type="range"] {
    width: 100%;
    accent-color: #3b82f6;
}

.style-control-group .style-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.style-control-group .style-row input[type="color"] {
    width: 32px;
    height: 24px;
    border: 1px solid #4b5563;
    border-radius: 3px;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.style-control-group .style-row input[type="number"] {
    width: 60px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 11px;
}

.style-control-group select {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 11px;
}

/* Mask thumbnail in layer item */
.layer-mask-thumb {
    width: 24px;
    height: 24px;
    border: 2px solid #4b5563;
    border-radius: 2px;
    margin-left: 4px;
    cursor: pointer;
    flex-shrink: 0;
    background: #fff;
    position: relative;
}

.layer-mask-thumb.active-mask {
    border-color: #3b82f6;
}

.layer-mask-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Clipping mask indicator */
.layer-item.clipped {
    padding-left: 24px !important;
    position: relative;
}

.layer-item.clipped::before {
    content: '↳';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: #60a5fa;
    font-size: 12px;
}

/* Ensure color picker modal is always on top of all flyout panels globally */
#colorPickerModal {
    z-index: 10550 !important;
}
