        :root {
            --zoom-scale: 1;
            --primary-accent: #007aff;
            --rail-icon-muted: #777777;
            --dock-icon-color: #cccccc;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            user-select: none;
        }

        /* Pro lock badge — shown on PRO-gated elements for Trial users */
        [data-pro-feature] {
            position: relative;
        }

        .pro-lock-badge {
            position: absolute;
            top: -6px;
            right: -6px;
            width: 16px;
            height: 16px;
            background: #111111;
            border: 1.5px solid rgba(255, 255, 255, 0.18);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            z-index: 10;
        }

        .pro-lock-badge svg {
            display: block;
            stroke: #aaaaaa;
        }

        body.light-theme .pro-lock-badge {
            background: #ffffff;
            border-color: rgba(0, 0, 0, 0.14);
        }

        body.light-theme .pro-lock-badge svg {
            stroke: #777777;
        }

        /* Re-enable text selection for directly editable fields */
        input[type="number"],
        input.numeric-input,
        .hex-input,
        .preset-rename-input,
        #licenseKeyInput,
        #presetSearchInput,
        #layoutPresetSearchInput,
        #dimPresetSearchInput {
            user-select: text;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #1a1a1a;
            color: #ffffff;
            height: 100vh;
            overflow: hidden;
            cursor: default;
        }

        /* Loading Screen */
        .loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #1a1a1a;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
            opacity: 1;
            transition: opacity 0.4s ease;
        }

        .loading-screen.fade-out {
            opacity: 0;
            pointer-events: none;
        }

        .loading-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 24px;
        }

        .loading-icon {
            width: 64px;
            height: 64px;
            animation: pulse 2s ease-in-out infinite;
        }

        .loading-spinner {
            width: 40px;
            height: 40px;
            border: 3px solid rgba(255, 255, 255, 0.1);
            border-top-color: #007aff;
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        .loading-text {
            font-size: 14px;
            color: #888;
            font-weight: 500;
            letter-spacing: 0.5px;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        @keyframes pulse {
            0%, 100% {
                opacity: 1;
                transform: scale(1);
            }
            50% {
                opacity: 0.7;
                transform: scale(0.95);
            }
        }

        .app {
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

        .app-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 20px;
            background: #1e1e1e;
            border-bottom: 1px solid #333;
            height: 56px;
            flex-shrink: 0;
        }

        .app-header-left {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .app-icon {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .app-icon:hover {
            transform: scale(1.05);
        }

        .app-title {
            font-size: 18px;
            font-weight: 600;
            color: #ffffff;
            position: relative;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .app-title:hover {
            color: #007aff;
        }

        .app-title .version {
            position: absolute;
            top: -8px;
            right: -24px;
            font-size: 10px;
            font-weight: 400;
            opacity: 0;
            transition: opacity 0.3s ease;
            color: #888;
            pointer-events: none;
        }

        .app-header-right {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .theme-toggle {
            background: none;
            border: none;
            color: #cccccc;
            padding: 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .theme-toggle:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
        }

        .settings-button {
            background: none;
            border: none;
            color: #cccccc;
            padding: 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .settings-button:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
        }

        .main-content {
            display: flex;
            flex: 1;
            overflow: hidden;
            position: relative;
            transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        .canvas-area {
            flex: 1;
            background: #2a2a2a;
            position: relative;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
            cursor: pointer;
        }

        .canvas-area.space-down, .canvas-area.can-pan {
            cursor: grab !important;
        }

        .canvas-area.panning {
            cursor: grabbing !important;
        }

        .canvas-area.panning * {
            cursor: grabbing !important;
            pointer-events: none !important;
        }

        .grid-container {
            background: #ffffff;
            border-radius: 12px;
            padding: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
            transition: width 0.3s ease, height 0.3s ease, padding 0.3s ease, border-radius 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            position: relative;
        }

        .grid-container.snap-transition {
            transition: transform 380ms cubic-bezier(0.175, 0.885, 0.32, 1.1), width 0.3s ease, height 0.3s ease, padding 0.3s ease, border-radius 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
        }

        /* Zoom changes layout dimensions immediately instead of stretching a
           cached layer. Keep the existing pan snap animation. */
        .grid-container.preview-zooming,
        .preview-zooming .bento-grid,
        .preview-zooming .bento-tile,
        .preview-zooming .pattern-subdivision {
            transition: none;
        }

        .grid-container.preview-zooming.snap-transition {
            transition: transform 380ms cubic-bezier(0.175, 0.885, 0.32, 1.1);
        }

        .bento-grid {
            display: grid;
            gap: 8px;
            transition: all 0.3s ease;
            width: 100%;
            height: 100%;
        }

        .bento-tile {
            border-radius: 8px;
            transition: all 0.3s ease;
            position: relative;
            overflow: visible;
        }

        .bento-tile::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(45deg, rgba(255, 255, 255, 0.1), transparent);
            opacity: 0;
            transition: opacity 0.3s ease;
            z-index: 1;
            pointer-events: none;
            border-radius: 8px;
        }

        .bento-tile:hover::after {
            opacity: 1;
        }

        .bento-tile.tile-selected {
            outline: calc(2px / var(--zoom-scale, 1)) solid #007AFF !important;
            outline-offset: calc(-2px / var(--zoom-scale, 1)) !important;
            z-index: 50 !important;
            position: relative;
        }

        .bento-tile.drag-over {
            outline: calc(3px / var(--zoom-scale, 1)) dashed #007AFF !important;
            outline-offset: calc(-3px / var(--zoom-scale, 1)) !important;
            background-color: rgba(0, 122, 255, 0.1) !important;
            z-index: 51 !important;
        }

        .bento-tile.flyout-open {
            z-index: 2000;
        }

        .bento-tile.hidden-tile,
        .pattern-subdivision.hidden-tile {
            background-color: transparent !important;
            background-image: none !important;
            box-shadow: none !important;
            border: calc(1px / var(--zoom-scale, 1)) dashed rgba(255, 255, 255, 0.15) !important;
        }

        .bento-tile.hidden-tile .tile-resize-handle {
            display: none !important;
        }

        .bento-tile.hidden-tile:hover > .tile-menu-btn,
        .pattern-subdivision.hidden-tile:hover > .tile-menu-btn {
            opacity: 1;
        }

        .tile-menu-btn {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(calc(1 / var(--zoom-scale, 1)));
            width: 18px;
            height: 18px;
            background: rgba(0, 0, 0, 0.75);
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            transition: all 0.2s ease;
            z-index: 250;
            color: white;
            border: none;
            backdrop-filter: blur(8px);
        }

        .tile-menu-btn svg {
            width: 10px;
            height: 10px;
        }

        .tile-menu-btn.has-image {
            background: rgba(0, 122, 255, 0.85);
        }

        .bento-tile:hover > .tile-menu-btn {
            opacity: 1;
        }

        .pattern-subdivision:hover > .tile-menu-btn {
            opacity: 1;
        }

        .tile-menu-btn:hover {
            background: rgba(0, 0, 0, 0.9);
            transform: translate(-50%, -50%) scale(calc(1.15 / var(--zoom-scale, 1)));
        }

        .tile-menu-btn.has-image:hover {
            background: rgba(0, 122, 255, 1);
        }

        .tile-menu-flyout {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(calc(1 / var(--zoom-scale, 1)));
            background: rgba(30, 30, 30, 0.75);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 8px;
            padding: 4px;
            display: none;
            flex-direction: column;
            gap: 2px;
            z-index: 300;
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
            min-width: 120px;
        }

        .tile-menu-flyout.active {
            display: flex;
        }

        .tile-menu-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 10px;
            color: white;
            font-size: 12px;
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.15s ease;
            white-space: nowrap;
            position: relative;
        }

        .tile-menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .tile-menu-item svg {
            width: 13px;
            height: 13px;
            flex-shrink: 0;
        }

        .tile-menu-item input[type="color"],
        .tile-menu-item input[type="file"] {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
        }

        .tile-menu-item.remove {
            color: #ff6b6b;
        }

        .tile-menu-item.remove:hover {
            background: rgba(255, 107, 107, 0.15);
        }

        body.light-theme .tile-menu-btn {
            background: rgba(255, 255, 255, 0.9);
            color: #333;
        }

        body.light-theme .tile-menu-btn:hover {
            background: rgba(255, 255, 255, 1);
        }

        body.light-theme .tile-menu-flyout {
            background: rgba(255, 255, 255, 0.75);
            border: 1px solid rgba(0, 0, 0, 0.15);
        }

        body.light-theme .tile-menu-item {
            color: #333;
        }

        body.light-theme .tile-menu-item:hover {
            background: rgba(0, 0, 0, 0.05);
        }

        body.light-theme .tile-menu-item.remove {
            color: #d63031;
        }

        body.light-theme .tile-menu-item.remove:hover {
            background: rgba(214, 48, 49, 0.1);
        }

        /* Hide menu buttons, hover highlights, and inactive resize handles when resizing */
        .bento-grid.is-resizing .tile-menu-btn {
            display: none !important;
        }

        .bento-grid.is-resizing .bento-tile:hover::after {
            opacity: 0 !important;
        }

        .bento-grid.is-resizing .bento-tile .tile-resize-handle:not(.resizing) {
            opacity: 0 !important;
            pointer-events: none !important;
        }

        .tile-resize-handle {
            position: absolute;
            background: #007AFF;
            opacity: 0;
            transition: opacity 0.2s ease;
            z-index: 200;
            pointer-events: auto;
        }

        .bento-tile:hover .tile-resize-handle {
            opacity: 1;
        }

        .tile-resize-handle:hover {
            background: #0051D5;
        }

        .tile-resize-handle.resizing {
            opacity: 1;
        }

        .tile-resize-handle.resize-right {
            right: calc(-1px / var(--zoom-scale, 1));
            top: 0;
            bottom: 0;
            width: calc(2px / var(--zoom-scale, 1));
            cursor: ew-resize;
        }

        .tile-resize-handle.resize-left {
            left: calc(-1px / var(--zoom-scale, 1));
            top: 0;
            bottom: 0;
            width: calc(2px / var(--zoom-scale, 1));
            cursor: ew-resize;
        }

        .tile-resize-handle.resize-bottom {
            left: 0;
            right: 0;
            bottom: calc(-1px / var(--zoom-scale, 1));
            height: calc(2px / var(--zoom-scale, 1));
            cursor: ns-resize;
        }

        .tile-resize-handle.resize-top {
            left: 0;
            right: 0;
            top: calc(-1px / var(--zoom-scale, 1));
            height: calc(2px / var(--zoom-scale, 1));
            cursor: ns-resize;
        }
        
        .tile-resize-handle.resize-mid-right {
            right: calc(-4px / var(--zoom-scale, 1));
            top: 50%;
            transform: translateY(-50%);
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: ew-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }
        
        .tile-resize-handle.resize-mid-left {
            left: calc(-4px / var(--zoom-scale, 1));
            top: 50%;
            transform: translateY(-50%);
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: ew-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }
        
        .tile-resize-handle.resize-mid-bottom {
            left: 50%;
            transform: translateX(-50%);
            bottom: calc(-4px / var(--zoom-scale, 1));
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: ns-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }
        
        .tile-resize-handle.resize-mid-top {
            left: 50%;
            transform: translateX(-50%);
            top: calc(-4px / var(--zoom-scale, 1));
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: ns-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }

        .tile-resize-handle.resize-corner-br {
            right: calc(-3px / var(--zoom-scale, 1));
            bottom: calc(-3px / var(--zoom-scale, 1));
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: nwse-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }

        .tile-resize-handle.resize-corner-bl {
            left: calc(-3px / var(--zoom-scale, 1));
            bottom: calc(-3px / var(--zoom-scale, 1));
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: nesw-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }

        .tile-resize-handle.resize-corner-tr {
            right: calc(-3px / var(--zoom-scale, 1));
            top: calc(-3px / var(--zoom-scale, 1));
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: nesw-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }

        .tile-resize-handle.resize-corner-tl {
            left: calc(-3px / var(--zoom-scale, 1));
            top: calc(-3px / var(--zoom-scale, 1));
            width: calc(8px / var(--zoom-scale, 1));
            height: calc(8px / var(--zoom-scale, 1));
            cursor: nwse-resize;
            border-radius: calc(1px / var(--zoom-scale, 1));
            z-index: 201;
        }


        .sidebar {
            width: var(--sidebar-width, 360px);
            background: #1e1e1e;
            border-left: 1px solid #333;
            padding: 24px 10px 24px 24px; /* Reduced right padding */
            overflow: hidden;
            transform: translateX(0);
            transition: width 0.3s cubic-bezier(0.2, 0, 0, 1), padding 0.3s cubic-bezier(0.2, 0, 0, 1), transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
            position: relative;
            opacity: 1;
            flex-shrink: 0;
            container-type: inline-size;
            container-name: sidebar;
        }

        body.is-resizing .sidebar {
            transition: none;
        }

        body.dock-active .sidebar:not(.collapsed) {
            width: var(--dock-rail-width, 60px);
            padding: 0;
        }

        body.dock-active .sidebar:not(.collapsed) .sidebar-content {
            display: none;
        }

        .dock-rail {
            display: none;
            height: 100%;
            min-height: 0;
            padding: 12px 8px 10px;
            flex-direction: column;
            align-items: center;
        }

        body.dock-active .sidebar:not(.collapsed) .dock-rail {
            display: flex;
        }

        .dock-rail-panels {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            width: 100%;
            min-height: 0;
            overflow-y: auto;
            scrollbar-width: none;
        }

        .dock-rail-panels::-webkit-scrollbar { display: none; }

        .dock-rail-button,
        .dock-rail-logo {
            width: 42px;
            height: 42px;
            border: 0;
            border-radius: 9px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--dock-icon-color);
            background: transparent;
            cursor: grab;
            transition: color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
        }

        .dock-rail-button:hover,
        .dock-rail-logo:hover {
            color: #c8c8c8;
            background: rgba(255,255,255,0.07);
        }

        .dock-rail-button[aria-pressed="true"] {
            color: #3295ff;
            background: rgba(0,122,255,0.12);
        }

        .dock-rail-button.is-dragging {
            cursor: grabbing;
            transform: scale(0.94);
        }

        .dock-rail-button-icon {
            width: 18px;
            height: 18px;
            display: block;
            background-color: currentColor;
            -webkit-mask-position: center;
            mask-position: center;
            -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
            -webkit-mask-size: contain;
            mask-size: contain;
            opacity: 0.9;
            pointer-events: none;
        }

        .dock-rail-button[aria-pressed="true"] .dock-rail-button-icon {
            opacity: 1;
        }

        .dock-rail-logo {
            margin-top: auto;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            border: 1px solid transparent;
            background: transparent;
            border-radius: 50%;
            cursor: pointer;
            flex-shrink: 0;
            transition: background 0.18s ease;
        }

        .dock-rail-logo-mark {
            width: 22px;
            height: 22px;
            display: block;
            background-color: var(--rail-icon-muted);
            opacity: 0.7;
            -webkit-mask: url("icons/logo/copyright-logo.svg") center / contain no-repeat;
            mask: url("icons/logo/copyright-logo.svg") center / contain no-repeat;
            transition: background-color 0.18s ease, opacity 0.18s ease;
        }

        .dock-rail-logo:hover {
            background: color-mix(in srgb, var(--primary-accent) 8%, transparent);
        }

        .dock-rail-logo:hover .dock-rail-logo-mark {
            background-color: var(--primary-accent);
            opacity: 1;
        }

        .dock-rail-logo:active .dock-rail-logo-mark {
            -webkit-mask: url("icons/logo/copyright-logo-on-click.svg") center / contain no-repeat;
            mask: url("icons/logo/copyright-logo-on-click.svg") center / contain no-repeat;
        }

        .sidebar-content {
            height: 100%;
            overflow-y: auto;
            overflow-x: visible;
            display: flex;
            flex-direction: column;
            padding: 0 14px 24px 0; /* Added right padding inside scroll area and bottom padding for absolute footer */
        }

        .sidebar.dragging {
            transition: none;
        }

        body.is-resizing .segmented-indicator,
        body.is-resizing .segmented-option,
        .floating-section-panel:active .segmented-indicator,
        .floating-section-panel:active .segmented-option,
        .sidebar.dragging .segmented-indicator,
        .sidebar.dragging .segmented-option {
            transition: none !important;
        }

        .sidebar-resizer {
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 6px;
            cursor: col-resize;
            background: transparent;
            z-index: 20;
        }

        .sidebar-resizer::after {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 1px;
            background-color: #007AFF;
            opacity: 0;
            transition: all 0.2s ease;
        }

        .sidebar-resizer:hover::after {
            opacity: 0.35;
        }

        .sidebar.dragging .sidebar-resizer::after {
            width: 2px;
            opacity: 0.65;
        }

        .sidebar-resizer.at-min-max::after {
            width: 3px !important;
            opacity: 1 !important;
        }

        @media (max-width: 600px) {
            .sidebar-resizer {
                display: none !important;
            }
        }

        .sidebar.collapsed {
            transform: translateX(100%);
            width: 0 !important;
            padding: 0;
            border: none;
            opacity: 0;
        }

        .sidebar h2 {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 24px;
            color: #ffffff;
        }

        .settings-header-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 24px;
        }

        .settings-header-row h2 {
            margin: 0;
        }



        .control-group {
            margin-bottom: 24px;
        }

        .control-group label {
            display: block;
            font-size: 14px;
            font-weight: 500;
            color: #cccccc;
            margin-bottom: 8px;
        }

        /* Tooltip styles for control labels */
        .control-label {
            transition: color 0.2s ease;
            cursor: default;
        }

        .control-label:hover {
            color: #ffffff !important;
        }

        .color-label {
            font-size: 12px;
            color: #888;
            width: 100px;
            flex-shrink: 0;
            display: inline-block;
        }

        .collapsible-section {
            margin-bottom: 24px;
        }

        .section-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            padding: 8px 0;
            transition: all 0.2s ease;
            user-select: none;
        }

        .section-header-left {
            display: flex;
            align-items: center;
            flex: 1;
            padding: 2px 12px;
            border-radius: 6px;
            transition: all 0.2s ease;
        }

        .section-drag-handle {
            cursor: grab;
        }

        .section-drag-handle:active {
            cursor: grabbing;
        }

        .collapsible-section.is-dragging-section {
            opacity: 0.45;
        }

        .collapsible-section.drop-before,
        .collapsible-section.drop-after {
            position: relative;
        }

        .collapsible-section.drop-before::before,
        .collapsible-section.drop-after::after {
            content: '';
            position: absolute;
            left: 0;
            right: 0;
            height: 2px;
            background: #007aff;
            border-radius: 999px;
            box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.2), 0 0 10px rgba(0, 122, 255, 0.4);
            pointer-events: none;
            z-index: 5;
        }

        .collapsible-section.drop-before::before {
            top: -10px;
        }

        .collapsible-section.drop-after::after {
            bottom: -10px;
        }

        .section-header-left:hover {
            background: rgba(255, 255, 255, 0.08);
        }

        .section-header:hover {
            color: #007aff;
        }

        .section-chevron {
            width: 16px;
            height: 16px;
            margin-left: 8px;
            cursor: default;
            transition: transform 0.3s ease;
            color: #888;
            flex-shrink: 0;
            order: 4;
        }

        .section-chevron.expanded {
            transform: rotate(90deg);
        }

        .section-title {
            font-size: 14px;
            font-weight: 500;
            color: #cccccc;
            order: 2;
            margin-right: auto;
        }

        .section-title-icon {
            width: 14px;
            height: 14px;
            margin-right: 8px;
            opacity: 1;
            flex-shrink: 0;
            object-fit: contain;
            order: 1;
            filter: brightness(0) saturate(100%) invert(47%) sepia(94%) saturate(2326%) hue-rotate(194deg) brightness(102%) contrast(105%);
            transition: filter 0.2s ease, opacity 0.2s ease;
        }

        .section-header:hover .section-title-icon {
            opacity: 1;
            filter: brightness(0) saturate(100%) invert(47%) sepia(94%) saturate(2326%) hue-rotate(194deg) brightness(102%) contrast(105%);
        }

        .section-content {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
            padding: 0 12px 0 8px;
            margin: 0 -12px 0 -8px;
        }

        .section-content.expanded {
            max-height: 2000px;
            overflow: visible;
        }

        #sidebarSections.dock-target-active,
        .dock-rail.dock-target-active {
            outline: 2px dashed rgba(0, 122, 255, 0.75);
            outline-offset: -3px;
            border-radius: 10px;
        }

        body.sidebar-dock-target-active .sidebar {
            box-shadow: inset 0 0 0 1px rgba(0, 122, 255, 0.35);
        }

        .collapsible-section.is-detached {
            display: none;
        }

        .floating-panels-layer {
            position: fixed;
            inset: 0;
            z-index: 3200;
            pointer-events: none;
        }

        .floating-section-panel {
            position: fixed;
            width: min(360px, calc(100vw - 16px));
            max-height: calc(100vh - 16px);
            overflow: auto;
            background: rgba(28, 28, 28, 0.72);
            border: 1px solid rgba(255, 255, 255, 0.14);
            border-radius: 14px;
            box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            pointer-events: auto;
            user-select: none;
            resize: both;
        }

        .floating-section-panel.is-dragging {
            box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
        }

        .floating-section-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px;
            cursor: grab;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .floating-section-header:active {
            cursor: grabbing;
        }

        .floating-section-header-left {
            display: flex;
            align-items: center;
            gap: 8px;
            flex: 1;
            min-width: 0;
        }

        .floating-section-panel .section-title {
            margin-right: 0;
            min-width: 0;
        }

        .floating-section-panel .section-title-icon {
            margin-right: 0;
        }

        .floating-section-chevron {
            margin-left: 0;
        }

        .floating-section-toggle-btn {
            border: none;
            background: transparent;
            color: inherit;
            padding: 2px;
            margin-left: 6px;
            border-radius: 6px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .floating-section-toggle-btn:hover {
            background: rgba(255, 255, 255, 0.08);
        }

        body.light-theme .floating-section-toggle-btn:hover {
            background: rgba(0, 0, 0, 0.06);
        }

        .floating-section-dock-btn {
            width: 24px;
            height: 24px;
            border: none;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.08);
            color: #8a8a8a;
            cursor: pointer;
            margin-left: 10px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .floating-section-dock-btn:hover {
            background: rgba(0, 122, 255, 0.2);
            color: #60aaff;
        }

        .floating-section-dock-icon {
            width: 12px;
            height: 12px;
            display: block;
            background-color: currentColor;
            -webkit-mask-image: url("icons/x.svg");
            mask-image: url("icons/x.svg");
            -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
            -webkit-mask-position: center;
            mask-position: center;
            -webkit-mask-size: contain;
            mask-size: contain;
            opacity: 0.95;
        }

        .floating-section-panel .section-content {
            padding: 12px 12px;
            margin: 0;
            overflow: hidden;
        }

        .floating-section-panel .section-content:not(.expanded) {
            max-height: 0 !important;
            padding-top: 0;
            padding-bottom: 0;
        }

        body.light-theme .floating-section-panel {
            background: rgba(255, 255, 255, 0.82);
            border-color: rgba(0, 0, 0, 0.12);
            box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
        }

        body.light-theme .floating-section-header {
            border-bottom-color: rgba(0, 0, 0, 0.08);
        }

        body.light-theme .floating-section-dock-btn {
            background: rgba(0, 0, 0, 0.06);
            color: #8f8f8f;
        }

        body.light-theme .floating-section-dock-btn:hover {
            background: rgba(0, 122, 255, 0.14);
            color: #007aff;
        }

        /* Tabbed floating windows; legacy floating panels retain their styles above. */
        .fp-window,
        .fp-ghost,
        .fp-chip {
            --fp-surface: #242424;
            --fp-bar: #1e1e1e;
            --fp-border: rgba(255, 255, 255, 0.14);
            --fp-text: #cccccc;
            --fp-muted: #888888;
            --fp-hover: rgba(255, 255, 255, 0.08);
            --fp-drop: rgba(0, 122, 255, 0.06);
            color: var(--fp-text);
        }

        body.light-theme .fp-window,
        body.light-theme .fp-ghost,
        body.light-theme .fp-chip {
            --fp-surface: #ffffff;
            --fp-bar: #f3f3f3;
            --fp-border: rgba(0, 0, 0, 0.12);
            --fp-text: #666666;
            --fp-muted: #8a8a8a;
            --fp-hover: rgba(0, 0, 0, 0.06);
            --fp-drop: rgba(0, 122, 255, 0.06);
        }

        .floating-section-panel.fp-window {
            display: flex;
            flex-direction: column;
            min-width: 250px;
            min-height: 200px;
            overflow: hidden;
            resize: none;
            background: var(--fp-surface);
            border-color: var(--fp-border);
            --fp-radius: 10px;
            border-radius: var(--fp-radius);
        }

        .floating-section-header.fp-bar {
            position: relative;
            flex: 0 0 34px;
            height: 34px;
            min-width: 0;
            justify-content: flex-start;
            gap: 0;
            padding: 0 4px 0 0;
            border: 0;
            background: var(--fp-bar);
            box-shadow: inset 0 -1px var(--fp-border);
        }

        .floating-section-header.fp-bar.drop-target {
            background: var(--fp-drop);
            box-shadow: inset 0 -1px var(--fp-border);
        }

        .fp-grip {
            display: flex;
            align-items: center;
            justify-content: center;
            flex: 0 0 22px;
            border-right: 1px solid var(--fp-border);
            align-self: stretch;
            color: var(--fp-muted);
            cursor: grab;
            touch-action: none;
        }

        .fp-grip[hidden] { display: none; }

        .fp-grip:active, .fp-tab:active { cursor: grabbing; }

        .fp-grip-icon {
            display: block;
            width: 16px;
            height: 16px;
            background: currentColor;
            -webkit-mask: url("icons/grip-vertical.svg") center / contain no-repeat;
            mask: url("icons/grip-vertical.svg") center / contain no-repeat;
        }

        .fp-tabs {
            display: flex;
            align-items: stretch;
            justify-content: flex-start;
            gap: 0;
            padding: 0;
            margin: 0;
            flex: 1 1 auto;
            min-width: 0;
            height: 34px;
            overflow-x: auto;
            overflow-y: hidden;
            scrollbar-width: none;
            --fp-fade-before: 0px;
            --fp-fade-after: 0px;
            -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fp-fade-before), #000 calc(100% - var(--fp-fade-after)), transparent);
            mask-image: linear-gradient(to right, transparent, #000 var(--fp-fade-before), #000 calc(100% - var(--fp-fade-after)), transparent);
        }

        .fp-tabs::-webkit-scrollbar {
            display: none;
        }

        .fp-tabs.moreBefore {
            --fp-fade-before: 16px;
        }

        .fp-tabs.moreAfter {
            --fp-fade-after: 16px;
        }

        .fp-tab,
        .fp-preview {
            position: relative;
            display: inline-flex;
            align-items: center;
            justify-content: flex-start;
            flex: 0 1 auto;
            gap: 6px;
            min-width: 0;
            max-width: 180px;
            height: 34px;
            padding: 0 8px;
            margin: 0;
            text-align: left;
            border: 1px solid transparent;
            border-radius: 0;
            background: transparent;
            color: var(--fp-muted);
            font: inherit;
            font-size: 12px;
            line-height: 1;
            white-space: nowrap;
            cursor: grab;
            touch-action: none;
        }

        .fp-tab:hover {
            background: var(--fp-hover);
            color: var(--fp-text);
        }

        .fp-tab.active,
        .fp-preview {
            z-index: 1;
            background: var(--fp-surface);
            border-color: var(--fp-border);
            border-bottom-color: var(--fp-surface);
            color: var(--fp-text);
        }

        .fp-tab.active {
            flex: none;
            max-width: none;
        }

        .fp-icon {
            display: block;
            flex: 0 0 16px;
            width: 16px;
            height: 16px;
            margin: 0;
            padding: 0;
            object-fit: contain;
            color: var(--primary-accent);
        }

        img.fp-icon {
            filter: brightness(0) saturate(100%) invert(47%) sepia(94%) saturate(2326%) hue-rotate(194deg) brightness(102%) contrast(105%);
        }

        .fp-label {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .fp-tab.active .fp-label {
            flex: none;
            overflow: visible;
            text-overflow: clip;
        }

        .fp-tab:not(.active) .fp-label {
            display: none;
        }

        .fp-tab:not(.active) {
            flex: 0 0 34px;
            width: 34px;
            height: 34px;
            padding: 0;
            justify-content: center;
            gap: 0;
        }

        .fp-window:not(.has-multiple-tabs) .fp-tab:first-child {
            border-top-left-radius: calc(var(--fp-radius) - 1px);
        }

        .fp-tab-close {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex: 0 0 20px;
            width: 20px;
            height: 20px;
            padding: 0;
            border: 0;
            border-radius: 3px;
            background: transparent;
            color: var(--fp-muted);
            font: inherit;
            transition: background-color 120ms ease, color 120ms ease;
            visibility: hidden;
            pointer-events: none;
            cursor: pointer;
        }

        .fp-tab.active:hover .fp-tab-close {
            visibility: visible;
            pointer-events: auto;
        }

        .fp-minimize:hover {
            background: var(--fp-border);
            color: var(--fp-text);
        }

        .fp-tab-close:hover,
        .fp-close:hover {
            background: rgba(0, 122, 255, 0.16);
            color: var(--primary-accent);
        }

        .fp-minimize:active,
        .fp-close:active,
        .fp-tab-close:active {
            background: rgba(0, 122, 255, 0.22);
        }

        .fp-control-icon {
            display: block;
            width: 14px;
            height: 14px;
            flex: none;
            background: currentColor;
            -webkit-mask: var(--fp-control-image) center / contain no-repeat;
            mask: var(--fp-control-image) center / contain no-repeat;
            pointer-events: none;
        }

        .fp-icon-close { --fp-control-image: url("icons/window-close.svg"); }
        .fp-icon-collapse { --fp-control-image: url("icons/window-collapse.svg"); }
        .fp-icon-expand { --fp-control-image: url("icons/window-expand.svg"); }
        .fp-window:not(.minimized) .fp-icon-expand,
        .fp-window.minimized .fp-icon-collapse { display: none; }

        .fp-tab:focus-visible,
        .fp-tab-close:focus-visible,
        .fp-minimize:focus-visible,
        .fp-close:focus-visible {
            outline: 2px solid var(--primary-accent);
            outline-offset: -3px;
        }



        .fp-preview {
            background: rgba(0, 122, 255, 0.12);
            border: 0;
            border-top: 2px solid var(--primary-accent);
            color: var(--primary-accent);
            flex-shrink: 0;
            overflow: hidden;
            opacity: 1;
            pointer-events: none;
            transition: max-width 160ms ease, opacity 160ms ease;
        }

        @starting-style {
            .fp-preview {
                max-width: 0;
                opacity: 0;
            }
        }

        .fp-body,
        .fp-pane:not([hidden]) {
            display: flex;
            flex-direction: column;
            flex: 1 1 auto;
            min-width: 0;
            min-height: 0;
            overflow: hidden;
        }

        .fp-window .fp-pane[hidden] {
            display: none;
        }

        /* Override the legacy !important collapse rule, even without .expanded. */
        .floating-section-panel.fp-window .fp-pane .section-content {
            display: flex;
            flex-direction: column;
            flex: 1 1 auto;
            min-width: 0;
            min-height: 0;
            max-height: none !important;
            padding: 12px;
            margin: 0;
            overflow: auto;
            transition: none;
        }

        .fp-pane .section-content > * {
            flex-shrink: 0;
        }

        /* A floating Grid Style list fills the window and scrolls instead of using its resize handle. */
        .floating-section-panel.fp-window #gridStyleContainer {
            flex: 1 1 auto;
            min-height: 0;
            margin-top: 0;
        }

        .floating-section-panel.fp-window #gridStyleList {
            flex: 1 1 auto;
            min-height: 0;
            height: auto !important;
            overflow-y: auto;
        }

        .floating-section-panel.fp-window #gridStyleContainer .palette-resize-handle {
            display: none;
        }

        .fp-minimize,
        .fp-close {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex: 0 0 24px;
            width: 24px;
            height: 24px;
            padding: 0;
            margin: 0;
            border: 0;
            border-radius: 6px;
            background: var(--fp-hover);
            color: var(--fp-muted);
            cursor: pointer;
            appearance: none;
            transition: background-color 120ms ease, color 120ms ease;
        }

        .fp-minimize {
            margin-right: 4px;
            margin-left: 6px;
        }

        .fp-resize {
            position: absolute;
            right: 0;
            bottom: 0;
            z-index: 2;
            width: 16px;
            height: 16px;
            cursor: nwse-resize;
            touch-action: none;
            background: repeating-linear-gradient(135deg, transparent 0 3px, var(--fp-muted) 3px 4px);
            clip-path: polygon(100% 25%, 100% 100%, 25% 100%);
            opacity: 0.5;
        }

        .floating-section-panel.fp-window.minimized {
            height: 34px !important;
            min-height: 34px;
            max-height: 34px;
        }

        .fp-window.minimized .fp-body,
        .fp-window.minimized .fp-resize {
            display: none;
        }

        body.fp-dragging,
        body.fp-dragging * {
            cursor: grabbing !important;
            user-select: none !important;
            -webkit-user-select: none !important;
        }

        body.fp-dragging .fp-tab-close {
            visibility: hidden !important;
            pointer-events: none !important;
        }

        .fp-tab.drag-source {
            display: none;
        }

        .fp-ghost,
        .fp-chip {
            position: fixed;
            z-index: 11000;
            pointer-events: none;
            border: 1px solid var(--fp-border);
            border-radius: 6px;
            background: var(--fp-surface);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
        }

        .fp-ghost,
        .fp-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 0 8px;
            height: 34px;
            font-size: 12px;
            white-space: nowrap;
        }

        .fp-dock-line {
            position: fixed;
            z-index: 11001;
            height: 2px;
            background: var(--primary-accent);
            pointer-events: none;
        }

        /* Light theme styles for collapsible sections */
        body.light-theme .section-title {
            color: #666666;
        }

        body.light-theme .section-title-icon {
            filter: brightness(0) saturate(100%) invert(47%) sepia(94%) saturate(2326%) hue-rotate(194deg) brightness(102%) contrast(105%);
        }

        body.light-theme .section-header:hover .section-title-icon {
            filter: brightness(0) saturate(100%) invert(47%) sepia(94%) saturate(2326%) hue-rotate(194deg) brightness(102%) contrast(105%);
        }

        body.light-theme .section-header-left:hover {
            background: rgba(0, 0, 0, 0.05);
        }

        body.light-theme .section-header:hover {
            color: #007aff;
        }

        body.light-theme .section-header:hover .section-title {
            color: #007aff;
        }

        /* Section header context menu */
        .section-context-menu {
            position: fixed;
            background: rgba(40, 40, 40, 0.95);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 8px;
            padding: 4px;
            display: none;
            flex-direction: column;
            gap: 2px;
            z-index: 5000;
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
            min-width: 160px;
        }

        .section-context-menu.active {
            display: flex;
        }

        .section-context-menu-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 12px;
            color: #cccccc;
            font-size: 13px;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.15s ease;
            white-space: nowrap;
        }

        .section-context-menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
        }

        .section-context-menu-item.context-menu-delete-item {
            color: #ff8a8a;
        }

        .section-context-menu-item.context-menu-delete-item:hover {
            background: rgba(255, 80, 80, 0.14);
            color: #ffb0b0;
        }

        .section-context-menu-item.disabled {
            opacity: 0.4;
            cursor: not-allowed;
            pointer-events: none;
        }

        .section-context-menu-item svg {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            opacity: 0.8;
        }

        .section-context-menu-item .context-menu-icon {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            opacity: 0.8;
            filter: invert(85%);
        }

        .section-context-menu-item:hover .context-menu-icon {
            opacity: 1;
            filter: invert(100%);
        }

        .section-context-menu-item.context-menu-delete-item .context-menu-icon {
            filter: invert(65%) sepia(63%) saturate(1077%) hue-rotate(310deg) brightness(104%) contrast(101%);
        }

        .section-context-menu-item.context-menu-delete-item:hover .context-menu-icon {
            filter: invert(82%) sepia(22%) saturate(947%) hue-rotate(306deg) brightness(101%) contrast(102%);
        }

        body.light-theme .section-context-menu {
            background: rgba(255, 255, 255, 0.95);
            border-color: rgba(0, 0, 0, 0.12);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        }

        body.light-theme .section-context-menu-item {
            color: #555555;
        }

        body.light-theme .section-context-menu-item:hover {
            background: rgba(0, 0, 0, 0.06);
            color: #111111;
        }

        body.light-theme .section-context-menu-item .context-menu-icon {
            filter: invert(35%);
        }

        body.light-theme .section-context-menu-item:hover .context-menu-icon {
            filter: invert(7%);
        }

        body.light-theme .section-context-menu-item.context-menu-delete-item {
            color: #b00000;
        }

        body.light-theme .section-context-menu-item.context-menu-delete-item:hover {
            background: rgba(204, 0, 0, 0.09);
            color: #800000;
        }

        body.light-theme .section-context-menu-item.context-menu-delete-item .context-menu-icon {
            filter: invert(14%) sepia(99%) saturate(5241%) hue-rotate(357deg) brightness(76%) contrast(114%);
        }

        body.light-theme .section-context-menu-item.context-menu-delete-item:hover .context-menu-icon {
            filter: invert(10%) sepia(86%) saturate(6116%) hue-rotate(358deg) brightness(64%) contrast(113%);
        }

        .control-row {
            display: flex;
            gap: 12px;
            align-items: center;
        }

        .randomize-seed-button {
            width: 20px;
            height: 20px;
            padding: 0;
            border-radius: 4px;
            border: 1px solid #3a3a3a;
            background: #2a2a2a;
            color: #bdbdbd;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            flex-shrink: 0;
            transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
        }

        .randomize-seed-icon {
            width: 12px;
            height: 12px;
        }

        .randomize-seed-button:hover:not(:disabled) {
            background: #3a3a3a;
            color: #ffffff;
            transform: translateY(-1px);
        }

        .randomize-seed-button:disabled {
            opacity: 0.35;
            cursor: not-allowed;
            transform: none;
        }

        body.light-theme .randomize-seed-button {
            background: rgba(0, 0, 0, 0.06);
            border-color: rgba(0, 0, 0, 0.12);
            color: #666666;
        }

        body.light-theme .randomize-seed-button:hover:not(:disabled) {
            background: rgba(0, 0, 0, 0.12);
            color: #111111;
        }

        input[type="range"] {
            width: 100%;
            height: 16px;
            background: transparent;
            border-radius: 2px;
            outline: none;
            -webkit-appearance: none;
            position: relative;
            z-index: 2;
            margin: 0;
            cursor: pointer;
        }

        input[type="range"]::-webkit-slider-track {
            height: 4px;
            background: transparent;
            border-radius: 2px;
            border: none;
            outline: none;
        }

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            background: #007aff;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            z-index: 3;
            margin-top: 0px;
            box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.3);
        }

        input[type="range"]::-webkit-slider-thumb:hover {
            transform: scale(1.2);
            box-shadow: 0 0 0 8px rgba(0, 122, 255, 0.1);
        }

        /* Firefox slider styling */
        input[type="range"]::-moz-range-track {
            height: 4px;
            background: transparent;
            border-radius: 2px;
            border: none;
        }

        input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            background: #007aff;
            border-radius: 50%;
            cursor: pointer;
            border: none;
            transition: all 0.2s ease;
            box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.3);
            margin: 0;
        }

        input[type="range"]::-moz-range-thumb:hover {
            transform: scale(1.2);
            box-shadow: 0 0 0 8px rgba(0, 122, 255, 0.1);
        }

        /* Progress track styling */
        .slider-container {
            position: relative;
            flex: 1;
            height: 16px;
            display: flex;
            align-items: center;
        }

        .slider-container::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 4px;
            background: #333;
            border-radius: 2px;
            transform: translateY(-50%);
            z-index: 0;
        }

        .slider-progress {
            position: absolute;
            top: 50%;
            left: 0;
            height: 4px;
            background: rgba(0, 122, 255, 0.4);
            border-radius: 2px;
            pointer-events: none;
            z-index: 1;
            transform: translateY(-50%);
        }

        input[type="number"], input.numeric-input {
            width: 60px;
            padding: 6px 8px;
            background: #333;
            border: 1px solid #444;
            border-radius: 6px;
            color: #ffffff;
            font-size: 13px;
        }

        .color-swatch-wrapper {
            position: relative;
            display: inline-block;
            width: 32px;
            height: 32px;
            border-radius: 6px;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.2s ease;
        }

        .color-swatch-wrapper.drag-over {
            border-color: #007aff;
            transform: scale(1.1);
            box-shadow: 0 0 10px rgba(0, 122, 255, 0.3);
        }

        .color-swatch-wrapper.dragging {
            opacity: 0.5;
            transform: scale(0.9);
        }

        .color-input-wrapper {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .hex-input {
            width: 80px;
            padding: 4px 8px;
            background: #333;
            border: 1px solid #444;
            border-radius: 4px;
            color: #ffffff;
            font-size: 12px;
            font-family: monospace;
        }

        .color-swatch-wrapper:hover {
            transform: scale(1.1);
            border-color: #007aff;
        }

        .color-swatch {
            width: 100%;
            height: 100%;
            border-radius: 4px;
            background: #ffffff;
            pointer-events: none;
            border: 1px solid rgba(0, 0, 0, 0.1);
        }

        input[type="color"] {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
            z-index: 1;
        }

        /* ── Background visibility toggle button ── */
        .bg-visibility-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            width: 28px;
            height: 28px;
            padding: 0;
            background: #2a2a2a;
            border: 1px solid #444;
            border-radius: 4px;
            color: #888;
            cursor: pointer;
            transition: color 0.15s, border-color 0.15s, background 0.15s;
        }

        .bg-visibility-btn:hover {
            color: #fff;
            border-color: #666;
            background: #333;
        }

        .bg-visibility-btn.bg-hidden {
            color: #007aff;
            border-color: #007aff;
        }

        .swap-colors-btn:hover {
            color: #007aff !important;
            border-color: #007aff !important;
        }

        body.light-theme .bg-visibility-btn {
            background: #f0f0f0;
            border-color: #d0d0d0;
            color: #888;
        }

        body.light-theme .bg-visibility-btn:hover {
            color: #333;
            border-color: #999;
            background: #e4e4e4;
        }

        body.light-theme .bg-visibility-btn.bg-hidden {
            color: #007aff;
            border-color: #007aff;
        }

        /* ── Disabled background controls when visibility is off ── */
        .bg-color-disabled {
            opacity: 0.4;
            filter: grayscale(1);
            pointer-events: none;
        }

        /* ── Checkerboard transparency pattern for canvas ── */
        .grid-container.bg-transparent {
            background-color: transparent !important;
            background-image:
                linear-gradient(45deg, #3a3a3a 25%, transparent 25%),
                linear-gradient(-45deg, #3a3a3a 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #3a3a3a 75%),
                linear-gradient(-45deg, transparent 75%, #3a3a3a 75%);
            background-size: 16px 16px;
            background-position: 0 0, 0 8px, 8px -8px, -8px 0;
        }

        body.light-theme .grid-container.bg-transparent {
            background-image:
                linear-gradient(45deg, #c8c8c8 25%, transparent 25%),
                linear-gradient(-45deg, #c8c8c8 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #c8c8c8 75%),
                linear-gradient(-45deg, transparent 75%, #c8c8c8 75%);
        }

        .button {
            background: #007aff;
            color: white;
            border: none;
            height: 42px;
            padding: 0 20px;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            width: 100%;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .button:hover {
            background: #0056cc;
            transform: translateY(-1px);
        }

        .button.secondary {
            background: #333;
            color: #cccccc;
        }

        .button.secondary:hover {
            background: #444;
        }

        .button:disabled {
            background: #555;
            color: #888;
            cursor: not-allowed;
            opacity: 0.6;
        }

        .button:disabled:hover {
            background: #555;
            transform: none;
        }

        .link-button {
            background: none;
            border: none;
            color: #666;
            padding: 4px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 20px;
            height: 20px;
            margin-left: 8px;
        }

        .link-button:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #999;
        }

        .link-button.active {
            color: #007aff;
            background: rgba(0, 122, 255, 0.1);
        }

        .link-button.active:hover {
            background: rgba(0, 122, 255, 0.2);
        }

        .section-header .link-button {
            z-index: 10;
            cursor: default;
        }

        .section-header-left .link-button {
            order: 3;
            margin-left: 8px;
            margin-right: 4px;
        }

        .control-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 8px;
        }

        .export-buttons {
            display: flex;
            flex-direction: column;
            gap: 8px;
            padding-top: 8px;
        }

        .export-row {
            display: flex;
            align-items: center;
            gap: 8px;
            padding-top: 2px;
        }

        .export-row .button {
            flex: 1;
            margin-bottom: 0;
        }

        .copy-button {
            background: #007aff;
            border: none;
            color: white;
            padding: 0;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 42px;
            height: 42px;
            flex-shrink: 0;
        }

        .copy-button:hover {
            background: #0056cc;
            color: white;
            transform: translateY(-1px);
        }

        .copy-button.success {
            background: #28a745;
            color: white;
        }

        .copy-button.secondary,
        #copyPngBtn:not(.success) {
            background: #333;
            color: #cccccc;
        }

        .copy-button.secondary:hover,
        #copyPngBtn:not(.success):hover {
            background: #444;
            color: #ffffff;
        }

        body.light-theme .copy-button {
            background: #007aff;
            color: white;
        }

        body.light-theme .copy-button:hover {
            background: #0056cc;
            color: white;
            transform: translateY(-1px);
        }

        body.light-theme .copy-button.success {
            background: #28a745;
            color: white;
        }

        body.light-theme .copy-button.secondary,
        body.light-theme #copyPngBtn:not(.success) {
            background: #f0f0f0;
            color: #666666;
        }

        body.light-theme .copy-button.secondary:hover,
        body.light-theme #copyPngBtn:not(.success):hover {
            background: #e0e0e0;
            color: #333333;
        }

        .color-palette {
            height: 256px;
            overflow-y: auto;
            border-radius: 6px;
            background-color: rgba(30, 30, 30, 0.5);
            margin-top: 8px;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .layout-preset-list {
            height: 180px;
            overflow-y: auto;
            border-radius: 6px;
            background-color: rgba(30, 30, 30, 0.5);
            margin-top: 8px;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        /* Individual margins toggle row */
        .margins-toggle-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 10px;
            padding: 0 2px;
        }

        .margins-toggle-label {
            font-size: 11px;
            color: #666;
            user-select: none;
        }

        /* Toggle switch — use higher specificity to beat .control-group label { display: block } */
        .control-group .toggle-switch,
        .toggle-switch {
            position: relative;
            display: inline-flex !important;
            align-items: center;
            cursor: pointer;
            font-size: unset;
            font-weight: unset;
            color: unset;
        }

        .toggle-switch input {
            position: absolute;
            opacity: 0;
            width: 0;
            height: 0;
            pointer-events: none;
        }

        .toggle-track {
            display: inline-block;
            flex-shrink: 0;
            width: 28px;
            height: 16px;
            background: rgba(255, 255, 255, 0.12);
            border-radius: 8px;
            position: relative;
            transition: background 0.2s ease;
        }

        .toggle-thumb {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 12px;
            height: 12px;
            background: #888;
            border-radius: 50%;
            transition: transform 0.2s ease, background 0.2s ease;
        }

        .toggle-switch input:checked + .toggle-track {
            background: rgba(0, 122, 255, 0.6);
        }

        .toggle-switch input:checked + .toggle-track .toggle-thumb {
            transform: translateX(12px);
            background: #fff;
        }

        /* Gray out the uniform margins row when individual mode is active */
        .margins-uniform-row.dimmed {
            opacity: 0.35;
            pointer-events: none;
        }

        /* Individual margins grid */
        .margins-individual-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 6px;
            padding: 8px 0 2px;
        }

        .margins-individual-cell {
            display: flex;
            flex-direction: column;
            gap: 5px;
            background: rgba(255, 255, 255, 0.04);
            border-radius: 6px;
            padding: 7px 8px 6px;
        }

        .margins-individual-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .margins-individual-label {
            font-size: 10px;
            color: #666;
            user-select: none;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .margins-individual-cell input[type="number"], .margins-individual-cell input.numeric-input {
            width: 48px;
            min-height: 20px;
            text-align: right;
            background: none;
            border: none;
            color: #ddd;
            font-size: 13px;
            font-weight: 500;
            padding: 2px 0;
            outline: none;
        }

        .margins-ind-slider-container {
            flex: unset;
            width: 100%;
        }

        body.light-theme .margins-toggle-label {
            color: #999;
        }

        body.light-theme .toggle-track {
            background: rgba(0, 0, 0, 0.15);
        }

        body.light-theme .toggle-thumb {
            background: #bbb;
        }

        body.light-theme .toggle-switch input:checked + .toggle-track {
            background: rgba(0, 122, 255, 0.7);
        }

        body.light-theme .toggle-switch input:checked + .toggle-track .toggle-thumb {
            background: #fff;
        }

        body.light-theme .margins-individual-cell {
            background: rgba(0, 0, 0, 0.04);
        }

        body.light-theme .margins-individual-label {
            color: #aaa;
        }

        body.light-theme .margins-individual-cell input[type="number"], body.light-theme .margins-individual-cell input.numeric-input {
            color: #333;
        }

        /* Dimension presets */
        #dimPresetContainer.resizable-palette-container {
            margin-top: 0;
        }

        .dim-preset-new-btn {
            display: inline-flex;
            align-items: center;
            gap: 5px;
        }

        .dim-preset-new-btn img,
        .dim-preset-row-action img,
        .dim-orientation-control img {
            width: 13px;
            height: 13px;
            filter: invert(70%);
        }

        .dim-preset-tools {
            display: flex;
            gap: 6px;
            margin-bottom: 8px;
        }

        .dim-preset-search {
            min-width: 0;
            flex: 1 1 130px;
            position: relative;
            margin: 0;
        }

        .dim-preset-search > svg {
            position: absolute;
            z-index: 1;
            left: 8px;
            top: 50%;
            transform: translateY(-50%);
            color: #777;
            pointer-events: none;
        }

        #dimPresetSearchInput {
            width: 100%;
            height: 28px;
            box-sizing: border-box;
            padding: 5px 54px 5px 28px;
            border-radius: 6px;
            outline: none;
        }

        #clearDimSearchBtn {
            position: absolute;
            right: 4px;
            top: 50%;
            transform: translateY(-50%);
            display: none;
            align-items: center;
            justify-content: center;
            width: 20px;
            height: 20px;
            padding: 0;
            border: 0;
            border-radius: 4px;
            color: #888;
            background: transparent;
            cursor: pointer;
        }

        #clearDimSearchBtn:hover { background: rgba(255, 255, 255, 0.08); color: #ddd; }

        .dim-preset-result-count {
            position: absolute;
            right: 27px;
            top: 50%;
            transform: translateY(-50%);
            color: #666;
            font-size: 10px;
            font-variant-numeric: tabular-nums;
            pointer-events: none;
        }

        .dim-orientation-control {
            display: flex;
            flex: 0 0 auto;
            padding: 2px;
            border-radius: 7px;
            background: rgba(20, 20, 20, 0.7);
            border: 1px solid rgba(255, 255, 255, 0.08);
        }

        .dim-orientation-control button {
            height: 22px;
            min-width: 26px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            padding: 0 6px;
            border: 0;
            border-radius: 5px;
            background: transparent;
            color: #777;
            font: 500 10px inherit;
            cursor: pointer;
        }

        .dim-orientation-control button.active { color: #fff; background: #007aff; }
        .dim-orientation-control button.active img { filter: brightness(0) invert(1); }

        .dim-orientation-icon { display: block; border: 1.5px solid currentColor; border-radius: 2px; }
        .dim-orientation-icon.portrait { width: 7px; height: 11px; }
        .dim-orientation-icon.landscape { width: 11px; height: 7px; }

        .dim-preset-browser {
            --dim-tree-width: 132px;
            display: grid;
            grid-template-columns: var(--dim-tree-width) 5px minmax(0, 1fr);
            height: 272px;
            min-height: 150px;
            overflow: hidden;
            border-radius: 7px;
            background: rgba(25, 25, 25, 0.68);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .dim-preset-tree,
        .dim-preset-rows {
            min-width: 0;
            overflow: auto;
            scrollbar-width: thin;
        }

        .dim-preset-tree { padding: 5px 3px; }

        .dim-preset-divider {
            position: relative;
            cursor: ew-resize;
            border-left: 1px solid rgba(255, 255, 255, 0.07);
            border-right: 1px solid rgba(0, 0, 0, 0.22);
        }

        .dim-preset-divider::after {
            content: '';
            position: absolute;
            left: 1px;
            top: 50%;
            width: 2px;
            height: 26px;
            border-radius: 1px;
            background: rgba(255, 255, 255, 0.08);
            transform: translateY(-50%);
            transition: background-color .15s;
        }

        .dim-preset-divider:hover::after,
        .dim-preset-divider.dragging::after { background: #007aff; }

        .dim-tree-item {
            width: 100%;
            height: 25px;
            display: grid;
            grid-template-columns: 13px 15px minmax(0, 1fr) auto;
            align-items: center;
            gap: 4px;
            padding: 0 6px 0 3px;
            border: 0;
            border-radius: 5px;
            background: transparent;
            color: #8b8b8b;
            font: 500 11px inherit;
            text-align: left;
            cursor: pointer;
        }

        .dim-tree-item.depth-1 { padding-left: 16px; grid-template-columns: 7px 14px minmax(0, 1fr) auto; }
        .dim-tree-item:hover { color: #ddd; background: rgba(255, 255, 255, .055); }
        .dim-tree-item.active { color: #fff; background: rgba(0, 122, 255, .82); }
        .dim-tree-chevron { width: 10px; height: 10px; transition: transform .16s ease; }
        .dim-tree-chevron.expanded { transform: rotate(90deg); }
        .dim-tree-icon { width: 14px; height: 14px; opacity: .8; filter: invert(62%); }
        .dim-tree-item.active .dim-tree-icon { filter: brightness(0) invert(1); opacity: 1; }
        .dim-tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .dim-tree-count { font-size: 9px; opacity: .55; font-variant-numeric: tabular-nums; }
        .dim-tree-separator { height: 1px; margin: 5px 7px; background: rgba(255, 255, 255, .07); }

        .dim-preset-results { display: flex; min-width: 0; min-height: 0; flex-direction: column; }
        .dim-preset-list-header {
            flex: 0 0 27px;
            display: grid;
            grid-template-columns: minmax(90px, 1fr) 88px;
            align-items: center;
            padding: 0 5px 0 31px;
            border-bottom: 1px solid rgba(255, 255, 255, .08);
        }

        .dim-preset-list-header button {
            padding: 0;
            border: 0;
            background: none;
            color: #666;
            text-align: left;
            font: 600 9px inherit;
            letter-spacing: .045em;
            text-transform: uppercase;
            cursor: pointer;
        }
        .dim-preset-list-header button:last-child { text-align: right; padding-right: 7px; }
        .dim-preset-list-header button.active { color: #aaa; }

        .dim-preset-rows { flex: 1 1 auto; }
        .dim-preset-item {
            position: relative;
            min-height: 29px;
            display: grid;
            grid-template-columns: 24px minmax(80px, 1fr) auto;
            align-items: center;
            padding: 0 7px 0 5px;
            border-bottom: 1px solid rgba(255, 255, 255, .035);
            color: #c7c7c7;
            cursor: pointer;
            transition: background-color .1s ease;
        }

        .dim-preset-item:hover,
        .dim-preset-item.keyboard-active { background: rgba(255, 255, 255, .06); }
        .dim-preset-item.selected { background: rgba(0, 122, 255, .16); }
        .dim-preset-item:hover .dim-preset-actions,
        .dim-preset-item:focus-within .dim-preset-actions { opacity: 1; }
        .dim-preset-item:hover .dim-preset-size { opacity: 0; }

        .dim-preset-favorite {
            width: 22px;
            height: 22px;
            display: grid;
            place-items: center;
            padding: 0;
            border: 0;
            background: none;
            cursor: pointer;
            color: #5d5d5d;
        }
        .dim-preset-favorite svg { width: 13px; height: 13px; }
        .dim-preset-favorite.active { color: #ffb347; }
        .dim-preset-favorite:hover { color: #ffb347; }

        .dim-preset-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
        .dim-preset-meta { display: block; margin-top: 1px; color: #626262; font-size: 9px; }
        .dim-preset-size { padding-left: 8px; color: #777; font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .dim-preset-actions { position: absolute; right: 4px; display: flex; opacity: 0; background: inherit; }
        .dim-preset-row-action {
            width: 23px;
            height: 23px;
            display: grid;
            place-items: center;
            padding: 0;
            border: 0;
            border-radius: 4px;
            background: rgba(38, 38, 38, .96);
            cursor: pointer;
        }
        .dim-preset-row-action:hover { background: #444; }
        .dim-preset-row-action.danger:hover { background: #b53a3a; }

        .dim-preset-editor-backdrop {
            position: fixed;
            inset: 0;
            z-index: 10020;
            display: grid;
            place-items: center;
            padding: 18px;
            background: rgba(0, 0, 0, .52);
            backdrop-filter: blur(3px);
        }

        .dim-preset-editor {
            width: min(360px, 100%);
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, .13);
            border-radius: 11px;
            color: #ddd;
            background: #252525;
            box-shadow: 0 22px 60px rgba(0, 0, 0, .48);
        }

        .dim-preset-editor-header { padding: 14px 16px 10px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
        .dim-preset-editor-header strong { display: block; font-size: 13px; }
        .dim-preset-editor-header span { display: block; margin-top: 3px; color: #777; font-size: 10px; }
        .dim-preset-editor-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px; }
        .dim-preset-editor-field { display: grid; gap: 5px; min-width: 0; color: #888; font-size: 10px; }
        .dim-preset-editor-field.wide { grid-column: 1 / -1; }
        .dim-preset-editor-field input {
            width: 100%;
            height: 29px;
            box-sizing: border-box;
            padding: 5px 8px;
            border: 1px solid rgba(255, 255, 255, .12);
            border-radius: 6px;
            outline: none;
            color: #ddd;
            background: #1d1d1d;
            font: 11px inherit;
        }
        .dim-preset-editor-field input:focus { border-color: #007aff; box-shadow: 0 0 0 2px rgba(0, 122, 255, .14); }
        .dim-preset-editor-error { min-height: 13px; padding: 0 16px; color: #ff7575; font-size: 10px; }
        .dim-preset-editor-actions { display: flex; justify-content: flex-end; gap: 7px; padding: 10px 16px 14px; }
        .dim-preset-editor-actions button { min-width: 68px; height: 28px; border: 0; border-radius: 6px; color: #bbb; background: #383838; cursor: pointer; font: 500 11px inherit; }
        .dim-preset-editor-actions button:hover { background: #444; }
        .dim-preset-editor-actions .primary { color: #fff; background: #007aff; }
        .dim-preset-editor-actions .primary:hover { background: #1687ff; }

        .dim-preset-name-input {
            width: calc(100% - 6px);
            box-sizing: border-box;
            padding: 3px 5px;
            border: 1px solid #007aff;
            border-radius: 4px;
            outline: 0;
            color: #fff;
            background: #181818;
            font: 11px inherit;
        }

        .dim-preset-group-label {
            height: 24px;
            display: flex;
            align-items: center;
            padding: 0 9px 0 30px;
            color: #666;
            background: rgba(255, 255, 255, .025);
            border-bottom: 1px solid rgba(255, 255, 255, .04);
            font-size: 9px;
            font-weight: 700;
            letter-spacing: .05em;
            text-transform: uppercase;
        }

        .dim-preset-empty { display: grid; min-height: 135px; place-content: center; gap: 7px; padding: 18px; color: #666; text-align: center; font-size: 11px; }
        .dim-preset-empty img { width: 22px; height: 22px; margin: auto; opacity: .45; filter: invert(60%); }

        body.light-theme .dim-preset-browser { background: rgba(247, 247, 247, .82); border-color: rgba(0, 0, 0, .12); }
        body.light-theme .dim-orientation-control { background: rgba(0, 0, 0, .04); border-color: rgba(0, 0, 0, .1); }
        body.light-theme .dim-tree-item { color: #777; }
        body.light-theme .dim-tree-item:hover { color: #222; background: rgba(0, 0, 0, .05); }
        body.light-theme .dim-tree-item.active { color: #fff; background: #007aff; }
        body.light-theme .dim-tree-icon { filter: invert(42%); }
        body.light-theme .dim-tree-item.active .dim-tree-icon { filter: brightness(0) invert(1); }
        body.light-theme .dim-preset-divider { border-color: rgba(0, 0, 0, .08); }
        body.light-theme .dim-preset-divider::after { background: rgba(0, 0, 0, .13); }
        body.light-theme .dim-preset-list-header,
        body.light-theme .dim-preset-item { border-color: rgba(0, 0, 0, .07); }
        body.light-theme .dim-preset-item { color: #333; }
        body.light-theme .dim-preset-item:hover,
        body.light-theme .dim-preset-item.keyboard-active { background: rgba(0, 0, 0, .045); }
        body.light-theme .dim-preset-item.selected { background: rgba(0, 122, 255, .12); }
        body.light-theme .dim-preset-row-action { background: rgba(238, 238, 238, .97); }
        body.light-theme .dim-preset-row-action:hover { background: #ddd; }
        body.light-theme .dim-preset-row-action.danger:hover { background: #d64a4a; }
        body.light-theme .dim-preset-name-input { color: #222; background: #fff; }
        body.light-theme .dim-preset-editor { color: #222; background: #f5f5f5; border-color: rgba(0, 0, 0, .12); }
        body.light-theme .dim-preset-editor-header { border-color: rgba(0, 0, 0, .08); }
        body.light-theme .dim-preset-editor-field input { color: #222; background: #fff; border-color: rgba(0, 0, 0, .15); }
        body.light-theme .dim-preset-editor-actions button { color: #444; background: #e5e5e5; }
        body.light-theme .dim-preset-editor-actions .primary { color: #fff; background: #007aff; }

        /* The sidebar only launches the full preset browser. */
        .dim-preset-launcher {
            width: 100%;
            min-height: 58px;
            display: grid;
            grid-template-columns: 34px minmax(0, 1fr) 14px;
            align-items: center;
            gap: 10px;
            padding: 9px 11px;
            border: 1px solid rgba(255, 255, 255, .1);
            border-radius: 8px;
            color: #d3d3d3;
            background: rgba(30, 30, 30, .55);
            text-align: left;
            cursor: pointer;
            transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
        }
        .dim-preset-launcher:hover { border-color: rgba(0, 122, 255, .65); background: rgba(255, 255, 255, .055); transform: translateY(-1px); }
        .dim-preset-launcher-icon,
        .dim-preset-modal-icon {
            display: grid;
            place-items: center;
            border-radius: 7px;
            color: #fff;
            background: rgba(0, 122, 255, .16);
        }
        .dim-preset-launcher-icon { width: 34px; height: 34px; }
        .dim-preset-launcher-icon img { width: 17px; height: 17px; filter: invert(46%) sepia(93%) saturate(3103%) hue-rotate(199deg) brightness(102%); }
        .dim-preset-launcher-copy { display: grid; min-width: 0; gap: 3px; }
        .dim-preset-launcher-copy strong { font-size: 12px; font-weight: 600; }
        .dim-preset-launcher-copy small { overflow: hidden; color: #777; font-size: 10px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
        .dim-preset-launcher-arrow { width: 14px; height: 14px; opacity: .45; filter: invert(70%); }

        .dim-preset-modal-overlay {
            position: fixed;
            inset: 0;
            z-index: 10010;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 28px;
            visibility: hidden;
            opacity: 0;
            background: rgba(0, 0, 0, .72);
            backdrop-filter: blur(10px);
            transition: opacity .22s ease, visibility .22s ease;
        }
        .dim-preset-modal-overlay.active { visibility: visible; opacity: 1; }
        .dim-preset-modal-shell {
            width: min(920px, 94vw);
            max-height: min(820px, 91vh);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 1px solid #343434;
            border-radius: 16px;
            color: #ccc;
            background: #1e1e1e;
            box-shadow: 0 24px 70px rgba(0, 0, 0, .58);
            transform: translateY(14px) scale(.975);
            transition: transform .25s cubic-bezier(.2, .8, .2, 1);
        }
        .dim-preset-modal-overlay.active .dim-preset-modal-shell { transform: translateY(0) scale(1); }
        .dim-preset-modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            padding: 22px 24px 18px;
            border-bottom: 1px solid rgba(255, 255, 255, .075);
        }
        .dim-preset-modal-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
        .dim-preset-modal-icon { flex: 0 0 38px; width: 38px; height: 38px; }
        .dim-preset-modal-icon img { width: 19px; height: 19px; filter: invert(46%) sepia(93%) saturate(3103%) hue-rotate(199deg) brightness(102%); }
        .dim-preset-modal-heading h2 { margin: 0; color: #f5f5f5; font-size: 18px; line-height: 1.2; }
        .dim-preset-modal-heading p { margin: 4px 0 0; color: #777; font-size: 11px; }
        .dim-preset-modal-close {
            width: 30px;
            height: 30px;
            display: grid;
            flex: 0 0 auto;
            place-items: center;
            padding: 0;
            border: 0;
            border-radius: 6px;
            background: transparent;
            cursor: pointer;
        }
        .dim-preset-modal-close:hover { background: rgba(255, 255, 255, .08); }
        .dim-preset-modal-close img { width: 16px; height: 16px; opacity: .6; filter: invert(80%); }
        .dim-preset-modal-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; }
        .dim-preset-modal-toolbar .dim-preset-search { flex: 1 1 auto; }
        .dim-preset-modal-toolbar #dimPresetSearchInput { height: 34px; padding-left: 32px; font-size: 12px; }
        .dim-preset-modal-toolbar .dim-orientation-control { height: 34px; box-sizing: border-box; }
        .dim-preset-modal-toolbar .dim-orientation-control button { height: 28px; padding: 0 10px; font-size: 11px; }
        .dim-preset-modal-new,
        .dim-preset-modal-footer button {
            height: 34px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 0 12px;
            border: 1px solid rgba(255, 255, 255, .11);
            border-radius: 7px;
            color: #ccc;
            background: #303030;
            font: 600 11px inherit;
            cursor: pointer;
        }
        .dim-preset-modal-new:hover { border-color: rgba(0, 122, 255, .6); background: #383838; }
        .dim-preset-modal-new img { width: 14px; height: 14px; filter: invert(72%); }

        .dim-preset-modal-shell .dim-preset-browser {
            --dim-tree-width: 218px;
            height: clamp(380px, 58vh, 560px);
            min-height: 0;
            margin: 0 18px;
            border-color: rgba(255, 255, 255, .085);
            border-radius: 10px;
            background: #242424;
        }
        .dim-preset-modal-shell .dim-preset-tree { padding: 10px 7px; background: rgba(0, 0, 0, .12); }
        .dim-preset-modal-shell .dim-tree-item { height: 34px; grid-template-columns: 14px 18px minmax(0, 1fr) auto; gap: 7px; padding: 0 9px 0 6px; border-radius: 6px; font-size: 12px; }
        .dim-preset-modal-shell .dim-tree-item.depth-1 { padding-left: 24px; grid-template-columns: 7px 17px minmax(0, 1fr) auto; }
        .dim-preset-modal-shell .dim-tree-icon { width: 16px; height: 16px; }
        .dim-preset-modal-shell .dim-tree-count { font-size: 10px; }
        .dim-preset-modal-shell .dim-preset-list-header { flex-basis: 36px; grid-template-columns: minmax(120px, 1fr) 124px; padding-left: 44px; padding-right: 12px; }
        .dim-preset-modal-shell .dim-preset-list-header button { font-size: 10px; }
        .dim-preset-modal-shell .dim-preset-item { min-height: 43px; grid-template-columns: 33px minmax(120px, 1fr) auto; padding: 0 13px 0 10px; }
        .dim-preset-modal-shell .dim-preset-favorite { width: 28px; height: 28px; }
        .dim-preset-modal-shell .dim-preset-favorite svg { width: 15px; height: 15px; }
        .dim-preset-modal-shell .dim-preset-name { font-size: 12px; }
        .dim-preset-modal-shell .dim-preset-meta { margin-top: 2px; font-size: 10px; }
        .dim-preset-modal-shell .dim-preset-size { font-size: 11px; }
        .dim-preset-modal-shell .dim-preset-group-label { height: 30px; padding-left: 43px; font-size: 10px; }
        .dim-preset-modal-shell .dim-preset-row-action { width: 28px; height: 28px; }
        .dim-preset-modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 18px 16px; color: #696969; font-size: 10px; }
        .dim-preset-modal-footer button { min-width: 72px; color: #fff; border-color: #007aff; background: #007aff; }
        .dim-preset-modal-footer button:hover { background: #1687ff; }

        body.dim-preset-modal-open { overflow: hidden; }
        body.light-theme .dim-preset-launcher { color: #333; border-color: rgba(0, 0, 0, .1); background: rgba(0, 0, 0, .035); }
        body.light-theme .dim-preset-launcher:hover { border-color: rgba(0, 122, 255, .48); background: rgba(0, 122, 255, .035); }
        body.light-theme .dim-preset-launcher-arrow { filter: invert(35%); }
        body.light-theme .dim-preset-modal-overlay { background: rgba(20, 24, 30, .56); }
        body.light-theme .dim-preset-modal-shell { color: #444; border-color: #ddd; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .22); }
        body.light-theme .dim-preset-modal-header { border-color: rgba(0, 0, 0, .08); }
        body.light-theme .dim-preset-modal-heading h2 { color: #222; }
        body.light-theme .dim-preset-modal-close:hover { background: rgba(0, 0, 0, .06); }
        body.light-theme .dim-preset-modal-close img { filter: invert(28%); }
        body.light-theme .dim-preset-modal-new { color: #444; border-color: #d5d5d5; background: #f2f2f2; }
        body.light-theme .dim-preset-modal-new:hover { border-color: rgba(0, 122, 255, .5); background: #eaeaea; }
        body.light-theme .dim-preset-modal-new img { filter: invert(35%); }
        body.light-theme .dim-preset-modal-shell .dim-preset-browser { border-color: #ddd; background: #fafafa; }
        body.light-theme .dim-preset-modal-shell .dim-preset-tree { background: #f5f5f5; }

        @media (max-width: 720px) {
            .dim-preset-modal-overlay { padding: 12px; }
            .dim-preset-modal-shell { width: 100%; max-height: 95vh; }
            .dim-preset-modal-toolbar { flex-wrap: wrap; }
            .dim-preset-modal-toolbar .dim-preset-search { flex-basis: 100%; }
            .dim-preset-modal-shell .dim-preset-browser { --dim-tree-width: 150px; margin: 0 10px; }
            .dim-preset-modal-footer span { display: none; }
            .dim-preset-modal-footer { justify-content: flex-end; }
        }

        @container sidebar (max-width: 410px) {
            .dim-preset-tools { flex-direction: column; }
            .dim-orientation-control { align-self: stretch; }
            .dim-orientation-control button { flex: 1; }
            .dim-preset-browser { --dim-tree-width: 112px; }
        }

        @container sidebar (max-width: 335px) {
            .dim-orientation-control button span:last-child { display: none; }
            .dim-preset-browser { --dim-tree-width: 96px; }
            .dim-preset-meta { display: none; }
        }

        /* Effects section */
        .effects-subsection {
            padding: 8px 0;
        }

        .effects-divider {
            height: 1px;
            background: rgba(255, 255, 255, 0.07);
            margin: 2px 0;
        }

        .toggle-collapsible {
            overflow: hidden;
            max-height: 600px;
            opacity: 1;
            transition: max-height 0.25s ease, opacity 0.2s ease;
        }

        .toggle-collapsible.collapsed {
            max-height: 0;
            opacity: 0;
            pointer-events: none;
        }

        .effect-controls {
            display: flex;
            flex-direction: column;
            gap: 4px;
            overflow: hidden;
            max-height: 0;
            margin-top: 0;
            opacity: 0;
            pointer-events: none;
            transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.25s ease;
        }

        .effect-controls:not(.disabled) {
            max-height: 400px;
            margin-top: 8px;
            opacity: 1;
            pointer-events: auto;
        }

        body.light-theme .effects-divider {
            background: rgba(0, 0, 0, 0.08);
        }

        /* Grid style list */
        .grid-style-list {
            height: 200px;
            overflow-y: auto;
            border-radius: 6px;
            background-color: rgba(30, 30, 30, 0.5);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .grid-style-item {
            display: flex;
            align-items: center;
            padding: 8px 12px;
            cursor: pointer;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
            transition: background-color 0.15s ease;
        }

        .grid-style-item:last-child {
            border-bottom: none;
        }

        .grid-style-item:hover {
            background-color: rgba(255, 255, 255, 0.08);
        }

        .grid-style-item.active {
            background-color: rgba(0, 122, 255, 0.15);
        }

        .grid-style-item.active .grid-style-label {
            color: #60aaff;
            font-weight: 500;
        }

        .grid-style-label {
            flex: 1;
            font-size: 12px;
            color: #ddd;
            text-align: left;
            user-select: none;
        }

        .grid-style-heart {
            display: inline-grid;
            place-items: center;
            background: none;
            border: none;
            padding: 3px;
            cursor: pointer;
            color: #666;
            opacity: 0;
            transition: opacity 0.15s ease, color 0.15s ease;
            border-radius: 3px;
            flex-shrink: 0;
        }

        .grid-style-heart .icon-default,
        .grid-style-heart .icon-hover {
            grid-area: 1 / 1;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: opacity 0.1s;
        }

        .grid-style-item:hover .grid-style-heart {
            opacity: 1;
        }

        .grid-style-heart.favourited {
            opacity: 1;
            color: #007aff;
        }

        .grid-style-heart:hover {
            color: #007aff;
        }

        .grid-style-heart .icon-hover {
            opacity: 0;
            pointer-events: none;
        }

        .grid-style-heart:hover .icon-default {
            opacity: 0;
        }

        .grid-style-heart:hover .icon-hover {
            opacity: 1;
            pointer-events: auto;
        }

        body.light-theme .grid-style-list {
            background-color: rgba(240, 240, 240, 0.8);
            border: 1px solid rgba(0, 0, 0, 0.1);
        }

        body.light-theme .grid-style-item {
            border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        }

        body.light-theme .grid-style-item:hover {
            background-color: rgba(0, 0, 0, 0.05);
        }

        body.light-theme .grid-style-item.active .grid-style-label {
            color: #007aff;
        }

        body.light-theme .grid-style-label {
            color: #333;
        }

        body.light-theme .grid-style-heart {
            color: #bbb;
        }

        /* Collapse list height when no presets are saved */
        #layoutPresetContainer.preset-list-empty .layout-preset-list {
            height: auto;
            min-height: 0;
        }

        #layoutPresetContainer.preset-list-empty .palette-resize-handle {
            display: none;
        }

        /* Resizable palette container */
        .resizable-palette-container {
            position: relative;
            margin-top: 8px;
            display: flex;
            flex-direction: column;
            transition: outline 0.2s ease, background-color 0.2s ease;
        }

        .resizable-palette-container.drag-over {
            outline: 2px dashed #007aff;
            outline-offset: -2px;
            background: rgba(0, 122, 255, 0.05);
            border-radius: 8px;
        }

        .resizable-palette-container.resizing .current-palette,
        .resizable-palette-container.resizing .color-palette {
            pointer-events: none;
            user-select: none;
        }

        .resizable-palette-container > :first-child {
            transition: border-bottom-left-radius 0.2s ease, border-bottom-right-radius 0.2s ease;
        }

        .resizable-palette-container:has(.palette-resize-handle:hover) > :first-child,
        .resizable-palette-container:has(.palette-resize-handle.active) > :first-child {
            border-bottom-left-radius: 0 !important;
            border-bottom-right-radius: 0 !important;
        }

        .palette-resize-handle {
            height: 12px;
            cursor: ns-resize;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            transition: background-color 0.2s ease;
            border-radius: 0 0 6px 6px;
        }

        .palette-resize-handle:hover {
            background-color: rgba(255, 255, 255, 0.05);
        }

        .palette-resize-handle:hover .resize-handle-bar {
            background-color: rgba(255, 255, 255, 0.3);
        }

        .palette-resize-handle.active {
            background-color: rgba(0, 122, 255, 0.1);
        }

        .palette-resize-handle.active .resize-handle-bar {
            background-color: #007aff;
        }

        .resize-handle-bar {
            width: 32px;
            height: 3px;
            background-color: rgba(255, 255, 255, 0.15);
            border-radius: 2px;
            transition: background-color 0.2s ease;
        }

        body.light-theme .palette-resize-handle:hover {
            background-color: rgba(0, 0, 0, 0.05);
        }

        body.light-theme .palette-resize-handle:hover .resize-handle-bar {
            background-color: rgba(0, 0, 0, 0.3);
        }

        body.light-theme .palette-resize-handle.active {
            background-color: rgba(0, 122, 255, 0.1);
        }

        body.light-theme .palette-resize-handle.active .resize-handle-bar {
            background-color: #007aff;
        }

        body.light-theme .resize-handle-bar {
            background-color: rgba(0, 0, 0, 0.15);
        }

        .layout-preset-meta {
            font-size: 11px;
            color: #8a8a8a;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .layout-preset-item {
            gap: 10px;
            min-height: 68px;
        }

        .layout-preset-details {
            display: flex;
            flex: 1;
            min-width: 0;
            flex-direction: column;
            justify-content: center;
            gap: 3px;
        }

        .layout-preset-item .color-preset-name {
            flex: 0 1 auto;
            margin-right: 0;
            padding: 2px 4px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .layout-preset-thumbnail {
            width: 48px;
            height: 48px;
            flex: 0 0 48px;
            display: block;
            padding: 0;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.16);
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.05);
            box-shadow: 0 0 0 0 rgba(0, 122, 255, 0);
            cursor: zoom-in;
            outline: none;
            transition:
                border-color 0.15s ease,
                box-shadow 0.15s ease,
                transform 0.15s ease,
                background-color 0.15s ease;
        }

        .layout-preset-thumbnail canvas {
            display: block;
            width: 100%;
            height: 100%;
        }

        .layout-preset-thumbnail:hover,
        .layout-preset-thumbnail:focus-visible {
            border-color: #007aff;
            background: rgba(0, 122, 255, 0.08);
            box-shadow:
                0 0 0 2px #1e1e1e,
                0 0 0 4px rgba(0, 122, 255, 0.72);
            transform: translateY(-1px);
        }

        .current-palette {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: 256px;
    overflow-y: auto;
}

.palette-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 12px 4px 4px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    transition: background 0.2s ease;
}

.palette-item-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.palette-hex-input {
    flex: 1;
    min-width: 0;
    background: #333;
    border: 1px solid #444;
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    text-transform: uppercase;
}

.palette-hex-input:focus {
    outline: none;
    border-color: #007aff;
    background: #444;
}

.palette-visibility-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    opacity: 0;
    padding: 0;
    pointer-events: none;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
    flex-shrink: 0;
}

.palette-item-row:hover .palette-visibility-btn {
    width: 24px;
    opacity: 1;
    pointer-events: auto;
}

.palette-visibility-btn.is-hidden {
    color: #555;
}

.palette-item-row:hover .palette-visibility-btn.is-hidden {
    opacity: 1;
}

.palette-visibility-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.palette-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    opacity: 0;
    padding: 0;
    margin-left: 0;
    pointer-events: none;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
    flex-shrink: 0;
}

.palette-item-row:hover .palette-remove-btn {
    width: 24px;
    margin-left: 4px;
    opacity: 1;
    pointer-events: auto;
}

.palette-remove-btn:hover {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

/* Light Theme Overrides for Palette */
body.light-theme .current-palette {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .palette-item-row {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid transparent;
}

body.light-theme .palette-item-row:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.light-theme .palette-hex-input {
    background: #ffffff;
    border-color: #e0e0e0;
    color: #333333;
}

body.light-theme .palette-hex-input:focus {
    border-color: #007aff;
    background: #ffffff;
}

body.light-theme .palette-visibility-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #555;
}

body.light-theme .palette-remove-btn:hover {
    background: rgba(214, 48, 49, 0.1);
    color: #d63031;
}

.image-fill-list {
    height: 256px;
}

.image-fill-thumbnail {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 5px;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.image-fill-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #ddd;
}

.empty-state-message {
    color: #888;
}

.empty-state-icon {
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-title {
    color: #ccc;
    margin-bottom: 4px;
    font-weight: 500;
}

.empty-state-desc {
    font-size: 11px;
}

body.light-theme .empty-state-message {
    color: #777;
}

body.light-theme .empty-state-title {
    color: #444;
}

.image-placeholder-tile {
    background-color: #2a2a2a !important;
    background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" opacity="0.2" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 32px 32px;
}

body.light-theme .image-placeholder-tile {
    background-color: #e8e8e8 !important;
    background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" opacity="0.2" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>');
}

.image-fill-list .palette-item-row {
    position: relative;
}

.image-fill-list .palette-visibility-btn,
.image-fill-list .palette-remove-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    width: 24px;
    height: 24px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.image-fill-list .palette-remove-btn {
    right: 8px;
}

.image-fill-list .palette-visibility-btn {
    right: 36px;
}

.image-fill-list .palette-visibility-btn.is-hidden {
    opacity: 1;
    pointer-events: auto;
}

.image-fill-list .palette-item-row:hover .palette-visibility-btn,
.image-fill-list .palette-item-row:hover .palette-remove-btn {
    opacity: 1;
    pointer-events: auto;
}

.image-fill-list .palette-item-row:hover .image-fill-name {
    padding-right: 52px;
}

.image-fill-list .palette-item-row:has(.palette-visibility-btn.is-hidden):not(:hover) .image-fill-name {
    padding-right: 28px;
}

body.light-theme .image-fill-thumbnail {
    border-color: rgba(0, 0, 0, 0.14);
}

body.light-theme .image-fill-name {
    color: #333;
}

.current-color-swatch {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    flex-shrink: 0;
}

        .current-color-swatch:hover {
            transform: scale(1.1);
            border-color: #007aff;
            box-shadow: 0 0 10px rgba(0, 122, 255, 0.3);
        }

        /* Drag & drop state styles for current palette swatches */
        .current-color-swatch.drag-over {
            border-color: #007aff;
            transform: scale(1.1);
            box-shadow: 0 0 10px rgba(0, 122, 255, 0.3);
        }

        .current-color-swatch.dragging {
            opacity: 0.5;
            transform: scale(0.9);
        }

        .current-color-swatch input[type="color"] {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
            z-index: 1;
        }

        .current-color-swatch .color-display {
            width: 100%;
            height: 100%;
            border-radius: 6px;
            pointer-events: none;
        }

        .remove-indicator {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: rgba(0, 0, 0, 0.5);
            color: white;
            font-size: 24px;
            font-weight: bold;
            border-radius: 6px;
            pointer-events: none;
            z-index: 2;
            line-height: 1;
            text-align: center;
            vertical-align: middle;
        }

        .color-preset-item {
            display: flex;
            align-items: center;
            padding: 8px 12px;
            cursor: pointer;
            transition: background-color 0.2s;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .color-preset-item:last-child {
            border-bottom: none;
        }

        .color-preset-item:hover {
            background-color: rgba(255, 255, 255, 0.1);
        }

        .color-preset-item.confirming-delete {
            cursor: default;
            background-color: rgba(255, 80, 80, 0.08);
        }

        .preset-delete-confirmation {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            width: 100%;
        }

        .preset-delete-confirmation-message {
            min-width: 0;
            color: #ddd;
            font-size: 12px;
            line-height: 1.35;
        }

        .preset-delete-confirmation-actions {
            display: flex;
            gap: 6px;
            flex-shrink: 0;
        }

        .preset-delete-confirmation-btn {
            padding: 4px 8px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 5px;
            background: rgba(255, 255, 255, 0.06);
            color: #ddd;
            font-size: 11px;
            cursor: pointer;
        }

        .preset-delete-confirmation-btn:hover {
            background: rgba(255, 255, 255, 0.12);
            color: #fff;
        }

        .preset-delete-confirmation-btn.delete {
            border-color: rgba(255, 80, 80, 0.55);
            background: rgba(255, 80, 80, 0.16);
            color: #ff9a9a;
        }

        .preset-delete-confirmation-btn.delete:hover {
            background: rgba(255, 80, 80, 0.28);
            color: #fff;
        }

        .color-preset-name {
            flex: 1;
            font-size: 12px;
            color: #ddd;
            margin-right: 8px;
            padding: 2px 6px;
            border-radius: 6px;
            border: 1px solid transparent;
            transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
        }

        .color-preset-name:hover {
            color: #ffffff;
            background-color: rgba(255, 255, 255, 0.08);
            border-color: rgba(255, 255, 255, 0.25);
            cursor: text;
        }

        .preset-rename-input {
            flex: 1;
            font-size: 12px;
            color: #fff;
            background: #333;
            border: 1px solid #444;
            border-radius: 4px;
            padding: 4px 6px;
            outline: none;
            min-width: 0;
        }

        .color-preset-swatches {
            display: flex;
            width: 100px;
            height: 14px;
            border-radius: 4px;
            overflow: hidden;
            margin-right: 8px;
            flex-shrink: 0;
        }

        .color-preset-swatch {
            flex: 1;
            height: 100%;
            transition: transform 0.2s ease;
        }

        .color-preset-item:hover .color-preset-swatch {
            transform: scaleY(1.1);
        }


        /* Preset toolbar */
        .preset-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-top: 16px;
            margin-bottom: 8px;
        }

        .preset-toolbar-left {
            font-size: 12px;
            color: #888;
        }

        .preset-toolbar-actions {
            display: flex;
            gap: 6px;
        }

        .preset-action-btn {
            padding: 4px 8px;
            font-size: 11px;
            line-height: 1;
            border-radius: 6px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.06);
            color: #ddd;
            cursor: pointer;
            transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
        }

        .preset-action-btn:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.3);
            color: #fff;
        }

        .preset-item-actions {
            margin-left: auto;
            display: flex;
            align-items: center;
        }

        /* Preset icon buttons */
        .preset-download-icon,
        .preset-delete-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 0;
            height: 24px;
            border-radius: 4px;
            background: transparent;
            border: none;
            color: #888;
            cursor: pointer;
            opacity: 0;
            padding: 0;
            margin-left: 0;
            pointer-events: none;
            overflow: hidden;
            transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
            flex-shrink: 0;
        }

        .color-preset-item:hover .preset-download-icon,
        .color-preset-item:hover .preset-delete-icon {
            width: 24px;
            margin-left: 4px;
            opacity: 1;
            pointer-events: auto;
        }

        .preset-download-icon:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ccc;
        }

        .preset-delete-icon:hover {
            background: rgba(255, 107, 107, 0.2);
            color: #ff6b6b;
        }

        body.light-theme .preset-download-icon,
        body.light-theme .preset-delete-icon {
            color: #888;
        }

        body.light-theme .preset-download-icon:hover {
            background: rgba(0, 0, 0, 0.05);
            color: #333;
        }

        body.light-theme .preset-delete-icon:hover {
            background: rgba(255, 107, 107, 0.15);
            color: #ff4444;
        }

        body.light-theme .preset-action-btn {
            border-color: rgba(0, 0, 0, 0.15);
            background: rgba(0, 0, 0, 0.04);
            color: #333;
        }

        body.light-theme .preset-action-btn:hover {
            background: rgba(0, 0, 0, 0.07);
            border-color: rgba(0, 0, 0, 0.25);
            color: #111;
        }


        body.light-theme .current-palette {
            background: rgba(0, 0, 0, 0.05);
            border: 1px solid rgba(0, 0, 0, 0.1);
        }

        body.light-theme .current-color-swatch {
            border: 1px solid rgba(0, 0, 0, 0.2);
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
        }

        .toolbar {
            position: absolute;
            left: 50%;
            bottom: 20px;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 12px;
            display: flex;
            gap: 8px;
            z-index: 10;
        }

        .tool-button {
            background: rgba(255, 255, 255, 0.1);
            border: none;
            color: white;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s ease;
        }

        .tool-button:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .tool-button.active {
            background: rgba(0, 122, 255, 0.15) !important;
            color: var(--primary-accent, #007aff) !important;
            box-shadow: inset 0 0 0 1px var(--primary-accent, #007aff) !important;
        }

        .zoom-icon-button {
            width: 36px;
            height: 36px;
            padding: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .subtle-icon-button {
            width: 32px;
            height: 32px;
            padding: 5px;
            background: rgba(255, 255, 255, 0.08);
            color: rgba(255, 255, 255, 0.75);
        }

        .subtle-icon-button:hover {
            background: rgba(255, 255, 255, 0.16);
            color: #ffffff;
        }

        .subtle-icon-button:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        body.light-theme .subtle-icon-button {
            background: rgba(0, 0, 0, 0.05);
            color: rgba(0, 0, 0, 0.6);
        }

        body.light-theme .subtle-icon-button:hover {
            background: rgba(0, 0, 0, 0.1);
            color: rgba(0, 0, 0, 0.8);
        }



        .segmented-control {
            display: flex;
            background: #333;
            border-radius: 8px;
            padding: 2px;
            margin-bottom: 24px;
            position: relative;
        }

        .segmented-indicator {
            position: absolute;
            top: 2px;
            left: 2px;
            height: calc(100% - 4px);
            background: #007aff;
            border-radius: 6px;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 0;
        }

        .segmented-option {
            flex: 1;
            background: none;
            border: none;
            color: #888;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 500;
            transition: all 0.2s ease;
            position: relative;
            z-index: 1;
        }

        #fillModeControl .segmented-option {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: center;
            gap: 6px;
        }

        @container sidebar (max-width: 380px) {
            #fillModeControl {
                flex-direction: column;
                gap: 2px;
            }

            #fillModeControl .segmented-option {
                flex: 0 0 auto;
                justify-content: flex-start;
                padding-left: 12px;
                white-space: nowrap;
            }
        }

        .fill-mode-icon {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
            opacity: 0.72;
            filter: invert(60%);
        }

        .segmented-option.active .fill-mode-icon {
            opacity: 1;
            filter: brightness(0) invert(1);
        }

        body.light-theme .segmented-option:not(.active) .fill-mode-icon {
            filter: invert(38%);
        }

        .segmented-option.active {
            color: white;
        }

        .segmented-control.grid-2x2 {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 2px;
            height: auto;
        }

        .segmented-control.grid-2x2 .segmented-indicator {
            height: auto;
        }

        .segmented-control.grid-3x3 {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 2px;
            height: auto;
        }

        .segmented-control.grid-3x3 .segmented-indicator {
            height: auto;
        }

        .segmented-option:hover:not(.active) {
            background: #444;
        }

        /* Light theme styles */
        body.light-theme {
            background: #f5f5f5;
            color: #333333;
            --rail-icon-muted: #8a8a8a;
            --dock-icon-color: #666666;
        }

        body.light-theme .app-header {
            background: #f8f8f8;
            border-bottom: 1px solid #e0e0e0;
        }

        body.light-theme .app-title {
            color: #333333;
        }

        body.light-theme .app-title .version {
            color: #666;
        }

        .app-title:hover .version {
            opacity: 1;
        }

        body.light-theme .theme-toggle,
        body.light-theme .settings-button {
            color: #666666;
        }

        body.light-theme .theme-toggle:hover,
        body.light-theme .settings-button:hover {
            background: rgba(0, 0, 0, 0.1);
            color: #333333;
        }

        body.light-theme .canvas-area {
            background: #e8e8e8;
        }

        body.light-theme .sidebar {
            background: #f8f8f8;
            border-left: 1px solid #e0e0e0;
        }

        body.light-theme .dock-rail-button:hover {
            background: rgba(0,0,0,0.06);
            color: #444;
        }

        body.light-theme .dock-rail-logo:hover {
            background: color-mix(in srgb, var(--primary-accent) 8%, transparent);
        }

        body.light-theme .sidebar h2 {
            color: #333333;
        }

        body.light-theme .control-group label {
            color: #666666;
        }

        /* Light theme tooltip styles for control labels */
        body.light-theme .control-label:hover {
            color: #333333 !important;
        }

        body.light-theme .color-label {
            color: #666666;
        }

        body.light-theme input[type="range"]::-webkit-slider-track {
            background: transparent;
        }

        body.light-theme .slider-container::before {
            background: #e0e0e0;
        }

        body.light-theme .slider-progress {
            background: rgba(0, 122, 255, 0.3);
        }

        body.light-theme input[type="number"],
        body.light-theme input.numeric-input,
        body.light-theme .hex-input {
            background: #f0f0f0;
            border: 1px solid #d0d0d0;
            color: #333333;
        }

        body.light-theme .segmented-control {
            background: #f0f0f0;
        }

        body.light-theme .segmented-option {
            color: #666666;
        }

        body.light-theme .segmented-option:hover:not(.active) {
            background: #e0e0e0;
        }

        body.light-theme .segmented-option.active {
            color: white;
        }

        body.light-theme .button.secondary {
            background: #f0f0f0;
            color: #666666;
        }

        body.light-theme .button.secondary:hover {
            background: #e0e0e0;
        }

        body.light-theme .button:disabled {
            background: #f0f0f0;
            color: #ccc;
            cursor: not-allowed;
            opacity: 0.6;
        }

        body.light-theme .button:disabled:hover {
            background: #f0f0f0;
            transform: none;
        }

        body.light-theme .toolbar {
            background: rgba(248, 248, 248, 0.9);
            backdrop-filter: blur(10px);
        }

        body.light-theme .tool-button {
            background: rgba(0, 0, 0, 0.1);
            color: #333333;
        }

        body.light-theme .tool-button:hover {
            background: rgba(0, 0, 0, 0.2);
        }

        body.light-theme .tool-button.active {
            background: rgba(0, 122, 255, 0.15) !important;
            color: var(--primary-accent, #007aff) !important;
            box-shadow: inset 0 0 0 1px var(--primary-accent, #007aff) !important;
        }

        body.light-theme .link-button {
            color: #999999;
        }

        body.light-theme .link-button:hover {
            background: rgba(0, 0, 0, 0.1);
            color: #666666;
        }

        body.light-theme .link-button.active {
            color: #007aff;
            background: rgba(0, 122, 255, 0.1);
        }

        body.light-theme .color-swatch {
            border: 1px solid rgba(0, 0, 0, 0.2);
        }

        body.light-theme .color-palette,
        body.light-theme .layout-preset-list {
            background-color: rgba(240, 240, 240, 0.8);
            border: 1px solid rgba(0, 0, 0, 0.1);
        }

        /* Preset Search Styles */
        #presetSearchInput,
        #layoutPresetSearchInput,
        #fillImagesSearchInput,
        #dimPresetSearchInput {
            background: #333;
            border: 1px solid #444;
            color: #ffffff;
            font-size: 13px;
        }
        
        #presetSearchInput::placeholder,
        #layoutPresetSearchInput::placeholder,
        #fillImagesSearchInput::placeholder,
        #dimPresetSearchInput::placeholder {
            color: rgba(255, 255, 255, 0.4);
            opacity: 1; /* Firefox */
        }

        #presetSearchInput:focus,
        #layoutPresetSearchInput:focus,
        #fillImagesSearchInput:focus,
        #dimPresetSearchInput:focus {
            border-color: #007aff !important;
            background: #2a2a2a;
        }

        #clearSearchBtn:hover,
        #clearLayoutPresetSearchBtn:hover,
        #clearFillSearchBtn:hover {
            background: rgba(255, 255, 255, 0.1) !important;
            color: #fff !important;
        }

        body.light-theme #presetSearchInput,
        body.light-theme #layoutPresetSearchInput,
        body.light-theme #fillImagesSearchInput,
        body.light-theme #dimPresetSearchInput {
            background: #f0f0f0 !important;
            border-color: #d0d0d0 !important;
            color: #333 !important;
        }

        body.light-theme #presetSearchInput::placeholder,
        body.light-theme #layoutPresetSearchInput::placeholder,
        body.light-theme #fillImagesSearchInput::placeholder,
        body.light-theme #dimPresetSearchInput::placeholder {
            color: rgba(0, 0, 0, 0.4);
            opacity: 1; /* Firefox */
        }

        body.light-theme #presetSearchInput:focus,
        body.light-theme #layoutPresetSearchInput:focus,
        body.light-theme #fillImagesSearchInput:focus,
        body.light-theme #dimPresetSearchInput:focus {
            border-color: #007aff !important;
            background: #fff !important;
        }

        body.light-theme #clearSearchBtn,
        body.light-theme #clearLayoutPresetSearchBtn,
        body.light-theme #clearFillSearchBtn {
            color: #999 !important;
        }

        body.light-theme #clearSearchBtn:hover,
        body.light-theme #clearLayoutPresetSearchBtn:hover,
        body.light-theme #clearFillSearchBtn:hover {
            background: rgba(0, 0, 0, 0.05) !important;
            color: #333 !important;
        }

        .no-results-message {
            animation: fadeIn 0.2s ease;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-4px); }
            to { opacity: 1; transform: translateY(0); }
        }

        body.light-theme .color-preset-item {
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        }

        body.light-theme .color-preset-item:hover {
            background-color: rgba(0, 0, 0, 0.05);
        }

        body.light-theme .color-preset-item.confirming-delete {
            background-color: rgba(204, 0, 0, 0.06);
        }

        body.light-theme .preset-delete-confirmation-message {
            color: #333;
        }

        body.light-theme .preset-delete-confirmation-btn {
            border-color: rgba(0, 0, 0, 0.16);
            background: rgba(0, 0, 0, 0.04);
            color: #555;
        }

        body.light-theme .preset-delete-confirmation-btn:hover {
            background: rgba(0, 0, 0, 0.08);
            color: #222;
        }

        body.light-theme .preset-delete-confirmation-btn.delete {
            border-color: rgba(204, 0, 0, 0.35);
            background: rgba(204, 0, 0, 0.08);
            color: #b00000;
        }

        body.light-theme .preset-delete-confirmation-btn.delete:hover {
            background: rgba(204, 0, 0, 0.16);
            color: #800000;
        }

        body.light-theme .color-preset-name {
            color: #333;
        }

        body.light-theme .color-preset-name:hover {
            color: #007aff;
            background-color: rgba(0, 0, 0, 0.05);
            border-color: rgba(0, 0, 0, 0.2);
        }

        body.light-theme .layout-preset-meta {
            color: #666666;
        }

        body.light-theme .layout-preset-thumbnail {
            border-color: rgba(0, 0, 0, 0.16);
            background: rgba(0, 0, 0, 0.035);
        }

        body.light-theme .layout-preset-thumbnail:hover,
        body.light-theme .layout-preset-thumbnail:focus-visible {
            border-color: #007aff;
            background: rgba(0, 122, 255, 0.06);
            box-shadow:
                0 0 0 2px #ffffff,
                0 0 0 4px rgba(0, 122, 255, 0.55);
        }


        body.light-theme .preset-rename-input {
            background: #f0f0f0;
            border: 1px solid #d0d0d0;
            color: #333;
        }

        .sidebar-footer {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 10;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 1rem 1rem;
            border-top: 1px solid rgba(255, 255, 255, 0.05);
        }
        
        body.dock-active .sidebar:not(.collapsed) .sidebar-footer {
            display: none;
        }
        @supports (backdrop-filter: blur(10px)) {
            .sidebar-footer {
                background: var(--glass-bg, rgba(30, 30, 30, 0.6));
                backdrop-filter: blur(20px);
                -webkit-backdrop-filter: blur(20px);
            }
        }

        .signature-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 8px;
            border-radius: 999px;
            transition: background 0.18s ease;
            text-decoration: none;
            position: relative;
        }

        .signature-mask {
            display: block;
            height: 22px;
            width: 185px;
            background-color: var(--rail-icon-muted);
            opacity: 0.7;
            -webkit-mask: url("icons/logo/copyright-button.svg") center / contain no-repeat;
            mask: url("icons/logo/copyright-button.svg") center / contain no-repeat;
            transition: background-color 0.18s ease, opacity 0.18s ease;
        }

        .signature-badge:hover {
            background: color-mix(in srgb, var(--primary-accent) 8%, transparent);
        }

        .signature-badge:hover .signature-mask {
            background-color: var(--primary-accent);
            opacity: 1;
        }

        .signature-badge:active .signature-mask {
            -webkit-mask: url("icons/logo/copyright-button-on-click.svg") center / contain no-repeat;
            mask: url("icons/logo/copyright-button-on-click.svg") center / contain no-repeat;
        }

        body.light-theme .sidebar-footer {
            border-top: 1px solid rgba(0, 0, 0, 0.05);
        }
        @supports (backdrop-filter: blur(10px)) {
            body.light-theme .sidebar-footer {
                background: rgba(255, 255, 255, 0.6);
            }
        }

        body.light-theme .signature-mask {
            opacity: 0.4;
        }

        body.light-theme .signature-badge:hover .signature-mask {
            opacity: 1;
        }

        .copyright {
            margin-top: auto;
            padding: 24px 16px 16px 16px;
            text-align: center;
            font-size: 11px;
            color: rgba(255, 255, 255, 0.4);
            user-select: none;
            letter-spacing: 0.2px;
        }

        .copyright a {
            color: inherit;
            text-decoration: none;
            position: relative;
            display: inline-block;
            transition: color 0.3s ease;
        }


        /* Modal styles */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(10px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }

        .modal-overlay.active {
            opacity: 1;
            visibility: visible;
        }

        .modal {
            background: #1e1e1e;
            border-radius: 16px;
            display: flex;
            flex-direction: column;
            padding: 0;
            max-width: 600px;
            width: 90%;
            max-height: 80vh;
            overflow: hidden;
            transform: scale(0.9) translateY(20px);
            transition: all 0.3s ease;
            border: 1px solid #333;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
            position: relative;
        }

        .modal-overlay.active .modal {
            transform: scale(1) translateY(0);
        }

        .modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 32px 32px 0 32px;
            margin-bottom: 12px;
            flex-shrink: 0;
        }

        .modal-title {
            font-size: 24px;
            font-weight: 600;
            color: #ffffff;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .modal-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 20px;
        }

        .modal-close {
            background: none;
            border: none;
            color: #888;
            font-size: 24px;
            cursor: pointer;
            padding: 8px;
            border-radius: 6px;
            transition: all 0.2s ease;
            line-height: 1;
        }

        .modal-close:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
        }

        .modal-content {
            color: #cccccc;
            line-height: 1.6;
            padding: 24px 32px 80px 32px;
            overflow-y: auto;
            flex: 1;
            min-height: 0;
        }

        .modal-content h3 {
            color: #ffffff;
            font-size: 18px;
            font-weight: 600;
            margin: 24px 0 12px 0;
        }

        .modal-content h3:first-child {
            margin-top: 0;
        }

        .modal-content p {
            margin-bottom: 16px;
        }

        .modal-content ul {
            margin: 16px 0;
            padding-left: 20px;
        }

        .modal-content li {
            margin-bottom: 8px;
        }

        .modal-version {
            display: inline-block;
            background: rgba(0, 122, 255, 0.2);
            color: #007aff;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
            margin-left: 8px;
        }

        /* Light theme modal styles */
        body.light-theme .modal {
            background: #ffffff;
            border: 1px solid #e0e0e0;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }

        body.light-theme .modal-title {
            color: #333333;
        }

        body.light-theme .modal-close {
            color: #666666;
        }

        body.light-theme .modal-close:hover {
            background: rgba(0, 0, 0, 0.1);
            color: #333333;
        }

        body.light-theme .modal-content {
            color: #666666;
        }

        body.light-theme .modal-content h3 {
            color: #333333;
        }

        body.light-theme .app-title:hover {
            color: #007aff;
        }

        .modal-footer {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 10;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 1rem 1rem;
            border-top: 1px solid rgba(255, 255, 255, 0.05);
        }

        @supports (backdrop-filter: blur(10px)) {
            .modal-footer {
                background: var(--glass-bg, rgba(30, 30, 30, 0.6));
                backdrop-filter: blur(20px);
                -webkit-backdrop-filter: blur(20px);
            }
        }

        .discover-button {
            background: #007aff;
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .discover-button:hover {
            background: #0056cc;
            transform: translateY(-1px);
        }

        .discover-button.secondary {
            background: rgba(255, 255, 255, 0.1);
            color: #cccccc;
        }

        .discover-button.secondary:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        body.light-theme .discover-button.secondary {
            background: rgba(0, 0, 0, 0.05);
            color: #666;
        }

        body.light-theme .discover-button.secondary:hover {
            background: rgba(0, 0, 0, 0.1);
        }

        /* Center helper for Discover button inside modal content */
        .discover-button-row {
            display: flex;
            justify-content: center;
            gap: 12px;
            margin-top: 0;
        }

        .discover-button-row .discover-button {
            flex: 1;
            min-width: 0;
            max-width: 300px;
            white-space: nowrap;
        }

        body.light-theme .modal-footer {
            border-top: 1px solid rgba(0, 0, 0, 0.05);
        }
        @supports (backdrop-filter: blur(10px)) {
            body.light-theme .modal-footer {
                background: rgba(255, 255, 255, 0.6);
            }
        }

        /* Toggle Switch */
        .toggle-switch-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 16px;
        }

        .toggle-label {
            font-size: 14px;
            font-weight: 500;
            color: #cccccc;
        }

        .toggle-checkbox {
            appearance: none;
            width: 36px;
            height: 20px;
            background: #333;
            border-radius: 12px;
            position: relative;
            cursor: pointer;
            outline: none;
            transition: background 0.3s;
            border: 1px solid #444;
        }

        .toggle-checkbox::after {
            content: '';
            position: absolute;
            top: 2px;
            left: 2px;
            width: 14px;
            height: 14px;
            background: #888;
            border-radius: 50%;
            transition: transform 0.3s, background 0.3s;
        }

        .toggle-checkbox:hover {
            background: rgba(0, 122, 255, 0.1);
            border-color: #007aff;
        }

        .toggle-checkbox:hover::after {
            background: #007aff;
        }

        .toggle-checkbox:checked {
            background: #333;
            border-color: #444;
        }

        .toggle-checkbox:checked:hover {
            background: rgba(0, 122, 255, 0.2);
            border-color: #007aff;
        }

        .toggle-checkbox:checked::after {
            transform: translateX(16px);
            background: #007aff;
        }

        body.light-theme .toggle-checkbox {
            background: #e0e0e0;
            border-color: #ccc;
        }

        body.light-theme .toggle-checkbox::after {
            background: #999;
        }

        body.light-theme .toggle-checkbox:hover {
            background: rgba(0, 122, 255, 0.1);
            border-color: #007aff;
        }

        body.light-theme .toggle-checkbox:hover::after {
            background: #007aff;
        }

        body.light-theme .toggle-checkbox:checked {
            background: #e0e0e0;
        }

        /* Modal Tabs */
        .modal-tabs {
            display: flex;
            border-bottom: 1px solid #333;
            margin-bottom: 0;
            background: #1e1e1e;
            padding: 0 24px;
        }

        .modal-tab {
            padding: 16px 24px;
            background: none;
            border: none;
            color: #888;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            border-bottom: 2px solid transparent;
            transition: all 0.2s ease;
        }

        .modal-tab:hover {
            color: #ccc;
        }

        .modal-tab.active {
            color: #007aff;
            border-bottom-color: #007aff;
        }

        .tab-content {
            /* display: flex; */
            /* flex-direction: column; */
            /* height: 100%; */
        }

        .tab-pane {
            display: none;
            animation: fadeIn 0.2s ease;
        }

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

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        /* Light theme adjustments */
        body.light-theme .modal-tabs {
            border-bottom-color: #e0e0e0;
            background: #ffffff;
        }

        body.light-theme .modal-tab {
            color: #666;
        }

        body.light-theme .modal-tab:hover {
            color: #333;
        }

        body.light-theme .modal-tab.active {
            color: #007aff;
        }

        /* Modal Tab Content */
        .modal-tab-content {
            padding: 24px 32px 32px 32px;
        }

        /* Apps List Styles */
        .apps-list {
            max-height: 400px;
            overflow-y: auto;
            padding-right: 8px;
        }

        .app-item {
            border-bottom: 1px solid #333;
            transition: all 0.2s ease;
        }

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

        .app-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            cursor: pointer;
        }

        .app-info {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
            cursor: pointer;
            padding: 4px;
            border-radius: 6px;
            transition: background-color 0.2s ease;
        }

        .app-info:hover {
            background-color: rgba(255, 255, 255, 0.05);
        }

        .app-icon {
            width: 32px;
            height: 32px;
            border-radius: 6px;
            object-fit: cover;
        }

        .app-name {
            font-size: 14px;
            font-weight: 500;
            color: #ffffff;
        }

        .app-chevron {
            background: none;
            border: none;
            color: #888;
            padding: 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .app-chevron:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
        }

        .app-chevron.expanded {
            transform: rotate(90deg);
        }

        .app-description {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
            color: #999;
            font-size: 13px;
            line-height: 1.5;
            padding: 0 48px 0 48px;
        }

        .app-description.expanded {
            max-height: 200px;
            padding: 0 48px 16px 48px;
        }

        /* Light theme apps list styles */
        body.light-theme .app-item {
            border-bottom-color: #e0e0e0;
        }

        body.light-theme .app-info:hover {
            background-color: rgba(0, 0, 0, 0.05);
        }

        body.light-theme .app-name {
            color: #333333;
        }

        body.light-theme .app-chevron {
            color: #666666;
        }

        body.light-theme .app-chevron:hover {
            background: rgba(0, 0, 0, 0.1);
            color: #333333;
        }

        body.light-theme .app-description {
            color: #666666;
        }

        /* Shortcuts styles */
        .shortcuts-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 12px;
            margin-top: 16px;
        }
        
        .shortcut-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .shortcut-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 0;
            border-bottom: 1px solid #333;
        }

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

        .shortcut-keys {
            display: flex;
            gap: 4px;
            align-items: center;
        }

        .shortcut-keys code {
            background: #3a3a3a;
            border: 1px solid #4a4a4a;
            border-radius: 4px;
            padding: 3px 8px;
            font-size: 11px;
            font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
            color: #b0b0b0;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            font-weight: 500;
            letter-spacing: 0.5px;
        }

        .shortcut-keys kbd {
            background: #3a3a3a;
            border: 1px solid #4a4a4a;
            border-radius: 3px;
            padding: 2px 6px;
            font-size: 12px;
            font-family: monospace;
            color: #b0b0b0;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        }

        .shortcut-desc {
            color: #a0a0a0;
            font-size: 14px;
        }

        body.light-theme .shortcut-item {
            border-bottom-color: #e0e0e0;
        }

        body.light-theme .shortcut-desc {
            color: #666666;
        }
        
        body.light-theme .shortcut-keys code {
            background: #e8e8e8;
            border: 1px solid #d0d0d0;
            color: #888888;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        }

        body.light-theme .kbd {
            background: #f5f5f5;
            border-color: #ddd;
            color: #666;
        }

        body.light-theme .shortcut-desc {
            color: #666;
        }

        body.light-theme .toggle-checkbox:checked:hover {
            background: rgba(0, 122, 255, 0.2);
            border-color: #007aff;
        }

        body.light-theme .toggle-checkbox:checked::after {
            background: #007aff;
        }

        /* Custom Windows Scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

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

        ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        body.light-theme ::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.2);
        }

        body.light-theme ::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 0, 0, 0.3);
        }

/* Canvas Context Menu */
.canvas-context-menu {
    transform: none !important;
    top: 0;
    left: 0;
    margin-top: 0;
    margin-left: 0;
}

.canvas-context-menu .tile-menu-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.canvas-context-menu .tile-menu-item.disabled:hover {
    background: transparent;
}

/* Home Screen */
.home-screen {
    --home-bg: #161616;
    --home-surface: #1f1f1f;
    --home-surface-hover: #242424;
    --home-well: #272727;
    --home-border: #2e2e2e;
    --home-text: #f5f5f5;
    --home-text-soft: #c4c4c4;
    --home-muted: #8b8b8b;
    --home-control: rgba(255, 255, 255, 0.06);
    --home-control-hover: rgba(255, 255, 255, 0.1);
    --home-control-border: rgba(255, 255, 255, 0.08);
    --home-accent-text: #4da3ff;
    --home-grid-line: rgba(255, 255, 255, 0.028);
    position: fixed;
    inset: 0;
    z-index: 3500;
    display: flex;
    background: var(--home-bg);
    color: var(--home-text);
    opacity: 1;
    transition: opacity 0.2s ease;
}

.home-screen[hidden] {
    display: none;
}

.home-screen.closing {
    opacity: 0;
    pointer-events: none;
}

body.light-theme .home-screen {
    --home-bg: #f3f3f4;
    --home-surface: #ffffff;
    --home-surface-hover: #ffffff;
    --home-well: #f1f3f6;
    --home-border: #e1e1e3;
    --home-text: #1c1c1e;
    --home-text-soft: #3c3c40;
    --home-muted: #6e6e73;
    --home-control: rgba(0, 0, 0, 0.045);
    --home-control-hover: rgba(0, 0, 0, 0.08);
    --home-control-border: rgba(0, 0, 0, 0.07);
    --home-accent-text: #0066d6;
    --home-grid-line: rgba(0, 0, 0, 0.035);
}

/* Dialogs opened from the home screen must sit above it. */
body.home-open .modal-overlay,
body.home-open .license-modal-overlay {
    z-index: 3600;
}

.home-backdrop {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(720px 480px at 12% 0%, rgba(0, 122, 255, 0.11), transparent 70%),
        linear-gradient(var(--home-grid-line) 1px, transparent 1px) 0 0 / 56px 56px,
        linear-gradient(90deg, var(--home-grid-line) 1px, transparent 1px) 0 0 / 56px 56px;
    -webkit-mask-image: radial-gradient(120% 90% at 30% 20%, #000 35%, transparent 100%);
    mask-image: radial-gradient(120% 90% at 30% 20%, #000 35%, transparent 100%);
}

.home-close {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 2;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--home-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.home-close:hover {
    background: var(--home-control-hover);
    color: var(--home-text);
}

.home-scroll {
    position: relative;
    flex: 1;
    display: flex;
    overflow: auto;
}

.home-shell {
    width: 100%;
    max-width: 1120px;
    margin: auto;
    padding: 56px 48px;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 64px;
    align-items: center;
}

.home-intro {
    animation: home-rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.home-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.home-brand-icon {
    width: 52px;
    height: 52px;
    border-radius: 13px;
    box-shadow: 0 10px 24px rgba(0, 122, 255, 0.28);
}

.home-version {
    padding: 3px 8px;
    border: 1px solid var(--home-control-border);
    border-radius: 999px;
    background: var(--home-control);
    color: var(--home-muted);
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.home-version:empty {
    display: none;
}

.home-title {
    margin-top: 22px;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.022em;
    text-wrap: balance;
}

.home-tagline {
    margin-top: 10px;
    color: var(--home-muted);
    font-size: 14px;
    line-height: 1.55;
    text-wrap: pretty;
}

.home-actions {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.home-continue {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    padding: 10px 14px 10px 10px;
    border: 1px solid var(--home-border);
    border-radius: 12px;
    background: var(--home-surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.home-continue[hidden] {
    display: none;
}

.home-continue:hover {
    border-color: var(--primary-accent);
    background: var(--home-surface-hover);
}

.home-continue-thumb {
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--home-well);
    overflow: hidden;
}

.home-continue-thumb canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.home-continue-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.home-continue-title {
    font-size: 13.5px;
    font-weight: 600;
}

.home-continue-meta {
    color: var(--home-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home-continue-arrow {
    flex: none;
    color: var(--home-muted);
    transition: transform 0.15s ease, color 0.15s ease;
}

.home-continue:hover .home-continue-arrow {
    color: var(--primary-accent);
    transform: translateX(3px);
}

.home-action {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 12px 0 14px;
    border: 1px solid var(--home-control-border);
    border-radius: 10px;
    background: var(--home-control);
    color: var(--home-text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.home-action:hover {
    background: var(--home-control-hover);
}

.home-action svg {
    flex: none;
}

.home-action-primary,
body.light-theme .home-action-primary {
    border-color: transparent;
    background: var(--primary-accent);
    color: #ffffff;
    font-weight: 600;
}

.home-action-primary:hover {
    background: #1a87ff;
}

.home-kbd {
    margin-left: auto;
    color: var(--home-muted);
    font: inherit;
    font-size: 12px;
}

.home-footer {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--home-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--home-muted);
    font-size: 12.5px;
}

.home-startup {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.home-startup input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary-accent);
    cursor: pointer;
}

.home-link {
    border: none;
    background: none;
    color: var(--home-muted);
    font: inherit;
    cursor: pointer;
    transition: color 0.15s ease;
}

.home-link:hover {
    color: var(--home-accent-text);
}

.home-gallery-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 14px;
}

.home-section-title {
    color: var(--home-text-soft);
    font-size: 13px;
    font-weight: 600;
}

.home-sizes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.home-size {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: none;
    color: var(--home-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.home-size:hover {
    background: var(--home-control);
    color: var(--home-text);
}

.home-size.active {
    border-color: rgba(0, 122, 255, 0.4);
    background: rgba(0, 122, 255, 0.14);
    color: var(--home-accent-text);
}

.home-size-glyph {
    border: 1.5px solid currentColor;
    border-radius: 2px;
}

.home-size-readout {
    min-width: 104px;
    margin-left: 8px;
    color: var(--home-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.home-styles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.home-style {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 8px 8px 10px;
    border: 1px solid var(--home-border);
    border-radius: 12px;
    background: var(--home-surface);
    color: var(--home-text-soft);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    animation: home-rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(var(--home-index, 0) * 22ms + 60ms);
}

.home-style:hover {
    transform: translateY(-2px);
    border-color: var(--primary-accent);
    background: var(--home-surface-hover);
    color: var(--home-text);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.home-style-art {
    display: block;
    padding: 9px;
    border-radius: 7px;
    background: var(--home-well);
}

.home-style-art svg {
    display: block;
    width: 100%;
    height: auto;
}

.home-thumb-tile {
    fill: var(--primary-accent);
    transition: fill-opacity 0.18s ease;
}

.home-thumb-tile.tone-1 { fill-opacity: 0.95; }
.home-thumb-tile.tone-2 { fill-opacity: 0.56; }
.home-thumb-tile.tone-3 { fill-opacity: 0.26; }

.home-style:hover .home-thumb-tile.tone-2 { fill-opacity: 0.7; }
.home-style:hover .home-thumb-tile.tone-3 { fill-opacity: 0.4; }

.home-thumb-link {
    stroke: var(--primary-accent);
    stroke-opacity: 0.45;
    stroke-width: 1.5;
}

.home-style-name {
    padding: 0 3px;
    font-size: 12.5px;
    font-weight: 500;
}

.home-screen button:focus-visible,
.home-startup input:focus-visible {
    outline: 2px solid var(--primary-accent);
    outline-offset: 2px;
}

@keyframes home-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

@media (max-width: 1020px) {
    .home-shell {
        grid-template-columns: 264px minmax(0, 1fr);
        gap: 40px;
        padding: 48px 32px;
    }

    .home-title {
        font-size: 26px;
    }

    .home-size-readout {
        display: none;
    }
}

@media (max-width: 760px) {
    .home-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 36px;
        padding: 56px 20px 32px;
    }

    .home-styles {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 440px) {
    .home-styles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-screen,
    .home-style,
    .home-continue-arrow {
        transition: none;
    }

    .home-intro,
    .home-style {
        animation: none;
    }
}

.sidebar-toggle-icon {
    display: block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask: url('icons/panel-right-close.svg') center / contain no-repeat;
    mask: url('icons/panel-right-close.svg') center / contain no-repeat;
}
#settingsButton[data-state="hidden"] .sidebar-toggle-icon {
    -webkit-mask-image: url('icons/panel-right-open.svg');
    mask-image: url('icons/panel-right-open.svg');
}
#settingsButton[data-state="dock"] .sidebar-toggle-icon {
    -webkit-mask-image: url('icons/panel-right.svg');
    mask-image: url('icons/panel-right.svg');
}
