
        @font-face {
            font-family: 'BBHBartle';
            src: url('assets/BBHBartle-Regular.ttf') format('truetype');
        }

        :root {
            /* Light theme (default) */
            --sidebar-width: 320px;
            --toggle-width: 22px;
            --bg-primary: #f9fafb;
            --bg-secondary: #ffffff;
            --bg-tertiary: #f3f4f6;
            --accent-primary: #6366f1;
            --accent-secondary: #10b981;
            --accent-tertiary: #6366f1;
            --text-primary: #111827;
            --text-secondary: #4b5563;
            --text-tertiary: #9ca3af;
            --border: hwb(220 90% 8% / 0.25);
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
            --shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
            --shadow-lg: 0 4px 28px rgba(0, 0, 0, 0.08);
            --radius-sm: 8px;
            --radius: 12px;
            --radius-lg: 16px;
            --radius-full: 9999px;
            --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);

            /* UI spacing */
            --space-1: 4px;
            --space-2: 8px;
            --space-3: 12px;
            --space-4: 16px;
            --space-5: 20px;
            --space-6: 24px;
            --space-8: 32px;
            --space-10: 40px;
            --space-12: 48px;

            /* Font sizes */
            --text-xs: 0.75rem;
            --text-sm: 0.875rem;
            --text-base: 1rem;
            --text-lg: 1.125rem;
            --text-xl: 1.25rem;
            --text-2xl: 1.5rem;
            --text-3xl: 1.875rem;
        }

        /* Dark theme */
        body.dark-theme {
            --bg-primary: #121212;
            --bg-secondary: #1e1e1e;
            --bg-tertiary: #2d2d2d;
            --accent-primary: #6366f1;
            /* Purple accent */
            --accent-secondary: #10b981;
            /* Teal accent */
            --accent-tertiary: #6366f1;
            /* Orange accent */
            --text-primary: #f5f5f5;
            --text-secondary: #e0e0e0;
            --text-tertiary: #a0a0a0;
            --border: rgba(255, 255, 255, 0.15);
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
            --shadow: 0 2px 14px rgba(0, 0, 0, 0.3);
            --shadow-lg: 0 4px 28px rgba(0, 0, 0, 0.3);
        }

        /* Reset & Base Styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            -webkit-tap-highlight-color: transparent;
            -webkit-user-select: none;
            user-select: none;
            cursor: default;
        }

        input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
        textarea,
        [contenteditable="true"],
        .hex-input,
        .license-input,
        .control-value-input,
        .cp-channel-input,
        .rename-input {
            -webkit-user-select: text;
            user-select: text;
            cursor: text;
        }

        button,
        select,
        label,
        a,
        input[type="checkbox"],
        input[type="radio"],
        input[type="color"],
        .listbox-option,
        .toggle-item label,
        .switch {
            touch-action: manipulation;
        }

        html {
            font-size: 16px;
            height: 100%;
            overflow: hidden;
        }

        body {
            font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.5;
            transition: background-color 0.3s, color 0.3s;
            height: 100%;
            min-height: 100vh;
            overflow: hidden;
        }

        /* App Layout */
        .storage-warning {
            position: fixed;
            top: var(--space-4);
            left: 50%;
            transform: translateX(-50%);
            z-index: 2500;
            width: 480px;
            max-width: calc(100vw - 2 * var(--space-4));
            max-height: 45vh;
            overflow-y: auto;
            padding: var(--space-4);
            border: 1px solid var(--accent-primary);
            border-radius: var(--radius);
            background: var(--bg-secondary);
            color: var(--text-primary);
            box-shadow: var(--shadow-lg);
            font-size: var(--text-sm);
        }
        .storage-warning[hidden], .storage-warning button[hidden] { display: none; }
        .storage-warning p { margin: var(--space-2) 0 var(--space-4); color: var(--text-secondary); }
        .storage-warning-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
        .storage-warning-actions .btn { padding: var(--space-2) var(--space-4); }

        .desktop-update-notice {
            position: fixed;
            right: var(--space-4);
            bottom: var(--space-4);
            z-index: 2500;
            width: 360px;
            max-width: calc(100vw - 2 * var(--space-4));
            padding: var(--space-4);
            border: 1px solid var(--accent-primary);
            border-radius: var(--radius);
            background: var(--bg-secondary);
            color: var(--text-primary);
            box-shadow: var(--shadow-lg);
        }
        .desktop-update-notice[hidden] { display: none; }
        .desktop-update-notice strong { font-size: var(--text-sm); }
        .desktop-update-notice p {
            margin: var(--space-2) 0 var(--space-4);
            font-size: var(--text-sm);
            color: var(--text-secondary);
        }
        .desktop-update-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
        .desktop-update-actions .btn { padding: var(--space-2) var(--space-4); }

        .app-container {
            display: flex;
            width: 100%;
            height: 100vh;
            min-height: 100vh;
            padding: var(--space-4);
            gap: calc(var(--space-8) + var(--toggle-width) - var(--space-4));
            overflow: hidden;
        }

        /* Sidebar and Main Content */
        /* Sidebar wrapper: sticky containing block for the absolute toggle tab */
        .sidebar-wrapper {
            position: sticky;
            top: 0;
            height: 100%;
            flex-shrink: 0;
            width: calc(var(--sidebar-width) + var(--space-4));
            margin-left: calc(-1 * var(--space-4));
            padding-left: var(--space-4);
            transition: width 0.3s cubic-bezier(0.2, 0, 0, 1);
        }

        .sidebar-wrapper.collapsed {
            width: 0 !important;
            padding-left: 0;
            overflow: visible; /* so the toggle tab is visible */
        }

        .brand-fixed {
            position: fixed;
            top: var(--space-8); /* Match app-container padding + app-header padding */
            left: var(--space-4); /* Match sidebar-wrapper inner position */
            display: none;
            align-items: center;
            z-index: 150;
        }

        .app-container:has(.sidebar-wrapper.collapsed) .brand-fixed {
            display: flex;
        }

        /* Sidebar: width-collapsing flex column */
        .sidebar {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            container-type: inline-size;
            transition: opacity 0.18s ease;
        }

        .sidebar.collapsed {
            width: 0;
            opacity: 0;
            overflow: hidden;
            border: none;
        }

        /* Sidebar Footer */
        .sidebar-footer {
            position: sticky;
            bottom: -24px;
            z-index: 10;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 16px;
            min-height: 88px;
            margin: 24px -24px -24px -24px;
            background: color-mix(in srgb, var(--bg-secondary) 85%, transparent);
            border-top: 1px solid var(--border);
            border-bottom-left-radius: var(--radius);
            border-bottom-right-radius: var(--radius);
        }

        @supports (backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px)) {
            .sidebar-footer {
                background: color-mix(in srgb, var(--bg-secondary) 50%, transparent);
                -webkit-backdrop-filter: blur(20px);
                backdrop-filter: blur(20px);
                border-top: none;
                -webkit-mask-image: linear-gradient(to bottom, transparent, black 20px);
                mask-image: linear-gradient(to bottom, transparent, black 20px);
            }
        }

        .copyright-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 8px;
            border-radius: 999px;
            transition: all 0.18s ease;
        }

        .copyright-badge .copyright-mask {
            display: block;
            height: 22px;
            width: 185px;
            background-color: var(--text-muted, var(--text-secondary));
            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: all 0.18s ease;
        }

        body:not(.dark-theme) .copyright-badge .copyright-mask,
        [data-theme="light"] .copyright-badge .copyright-mask {
            opacity: 0.45;
        }

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

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

        .copyright-badge:active .copyright-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;
        }
        
        /* Dock rail styles */
        .dock-rail {
            display: none;
            flex: 1; /* take remaining height just like .card */
            width: 100%; /* take full width of the 60px sidebar */
            flex-direction: column;
            justify-content: space-between;
            background-color: var(--bg-secondary);
            border-radius: var(--radius);
            border: 1px solid var(--border);
            box-shadow: var(--shadow);
            margin-bottom: 0;
            overflow: visible;
        }
        
        .dock-rail-icons {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: var(--space-3);
            overflow-y: auto;
            padding-top: var(--space-2);
            /* Hide scrollbar for dock rail icons */
            scrollbar-width: none;
            -ms-overflow-style: none;
        }
        
        .dock-rail-icons::-webkit-scrollbar {
            display: none;
        }
        
        .dock-rail-bottom {
            display: flex;
            justify-content: center;
            margin-top: auto;
            padding: var(--space-4) 0;
        }
        
        .dock-icon-btn {
            width: 40px;
            height: 40px;
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s ease;
            flex-shrink: 0;
        }
        
        .dock-icon-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

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

        .dock-logo-btn:hover {
            background: color-mix(in srgb, var(--accent-primary) 8%, transparent);
        }
        
        .dock-icon-btn.toggled {
            background-color: color-mix(in srgb, var(--accent-primary) 15%, transparent);
            color: var(--accent-primary);
            border-color: color-mix(in srgb, var(--accent-primary) 30%, transparent);
        }
        
        body.dark-theme .dock-icon-btn.toggled {
            background-color: color-mix(in srgb, var(--accent-primary) 25%, transparent);
        }
        
        body.dock-active .dock-rail {
            display: flex;
        }
        
        body.dock-active .sidebar .card {
            display: none;
        }
        

        .dock-logo-icon {
            display: block;
            width: 22px;
            height: 22px;
            background-color: var(--text-muted, var(--text-secondary));
            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: all 0.18s ease;
        }

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

        .dock-logo-btn:active .dock-logo-icon {
            -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;
        }

        /* Toggle tab: absolute, flush on sidebar's right edge */
        #sidebarToggle {
            position: absolute;
            left: 100%;
            top: 55%;
            transform: translateY(-50%);
            z-index: 20;
            width: var(--toggle-width);
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-left: none;
            border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
            box-shadow: var(--shadow-sm);
            cursor: pointer;
            color: var(--text-secondary);
            padding: 0;
            touch-action: none;
            transition: background-color 0.15s, color 0.15s;
        }

        #sidebarToggle:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        #sidebarToggle svg {
            width: 12px;
            height: 12px;
            flex-shrink: 0;
            transition: transform .22s cubic-bezier(.4,0,.2,1);
        }

        .sidebar-wrapper.collapsed #sidebarToggle { left: 0; }

        /* The arrow points left while a click collapses further (full → dock → hidden). */
        .sidebar-wrapper.collapsed #sidebarToggle svg { transform: rotate(180deg); }

        /* Sidebar Resizer */
        .sidebar-resizer {
            position: absolute;
            top: 86px; /* Match the start of the .card */
            bottom: var(--space-4);
            left: calc(100% - 3px);
            width: 6px;
            cursor: col-resize;
            z-index: 30;
            background: transparent;
            touch-action: none;
        }

        .sidebar-resizer::after {
            content: '';
            position: absolute;
            top: var(--radius); /* Start below the top-right rounded corner */
            bottom: var(--radius); /* End above the bottom-right rounded corner */
            left: 2px;
            width: 1px;
            background-color: var(--accent-primary);
            opacity: 0;
            transition: opacity 0.15s ease, width 0.15s ease, left 0.15s ease;
        }
        
        /* Disable transitions during resize to prevent rubber-banding */
        body.is-resizing-sidebar .sidebar-wrapper,
        body.is-resizing-sidebar .sidebar,
        body.is-resizing-sidebar #sidebarToggle {
            transition: none !important;
        }

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

        .sidebar-resizer.is-resizing::after {
            width: 2px;
            left: 2px;
            opacity: 0.65;
        }

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

        /* Hide when sidebar is collapsed */
        .sidebar-wrapper.collapsed .sidebar {
            opacity: 0 !important;
            visibility: hidden;
            pointer-events: none;
        }
        
        .sidebar-wrapper.collapsed .sidebar-resizer {
            opacity: 0;
            pointer-events: none;
        }

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

        .app-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: var(--space-6);
            padding: var(--space-4) 0;
            flex-shrink: 0;
        }

        .sidebar .card {
            overflow-y: auto;
            margin-bottom: 0;
            /* Remove margin at the bottom */
            flex: 1;
        }

        .main-content {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            padding-top: 88px;
            /* Adjusted to match settings panel position */
            height: 100%;
            /* Make main content fill viewport height */
        }

        /* Cards */
        .card {
            position: relative;
            background-color: var(--bg-secondary);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            border: 1px solid var(--border);
            padding: var(--space-6);
            transition: box-shadow 0.3s, transform 0.3s;
            width: 100%;
            margin-bottom: var(--space-6);
        }

        .card:hover {
            box-shadow: var(--shadow-lg);
        }

        /* Header & Branding */
        .app-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: var(--space-6);
            padding: var(--space-4) 0;
        }

        .app-title {
            font-family: 'BBHBartle', sans-serif;
            font-size: var(--text-lg);
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
            cursor: pointer;
            position: relative;
            transition: transform 0.2s ease;
            white-space: nowrap;
        }

        body.dark-theme .app-title {
            color: var(--text-tertiary);
        }

        .app-title:hover {
            transform: translateY(-1px);
        }

        .app-version {
            position: absolute;
            top: -6px;
            right: -24px;
            font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
            font-size: 10px;
            font-weight: 400;
            background: var(--text-secondary);
            -webkit-background-clip: text;
            background-clip: text;
            color: var(--text-secondary);
            opacity: 0;
            transition: opacity 0.3s ease;
            pointer-events: none;
        }

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

        .app-subtitle {
            font-size: var(--text-sm);
            color: var(--text-secondary);
            margin-top: var(--space-1);
        }

        /* Control Groups */
        .control-group {
            margin-bottom: var(--space-6);
        }

        .control-group-title {
            display: flex;
            align-items: center;
            gap: var(--space-2);
            font-size: var(--text-sm);
            font-weight: 600;
            color: var(--text-secondary);
            margin-bottom: var(--space-3);
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .control-group-title svg {
            width: 16px;
            height: 16px;
            color: var(--accent-primary);
        }

        /* Remove margin when title is inside panel header */
        .panel-header .control-group-title {
            margin-bottom: 0;
            cursor: grab;
        }

        .panel-header .control-group-title:active {
            cursor: grabbing;
        }

        /* Section divider */
        .section-divider {
            height: 1px;
            background-color: var(--border);
            margin: var(--space-6) 0;
            opacity: 0.8;
        }

        .control-item {
            margin-bottom: var(--space-4);
        }

        .control-item label {
            display: block;
            font-size: var(--text-sm);
            font-weight: 500;
            color: var(--text-primary);
            margin-bottom: var(--space-2);
        }

        .parameter-heading {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: var(--space-2);
            margin-bottom: var(--space-2);
        }

        .control-item .parameter-heading label {
            margin-bottom: 0;
        }

        .parameter-lock {
            width: 26px;
            height: 26px;
            flex: 0 0 26px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            border: 1px solid transparent;
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--text-tertiary);
            cursor: pointer;
            opacity: 0.65;
            transition: color 0.18s ease, background-color 0.18s ease,
                        border-color 0.18s ease, opacity 0.18s ease;
        }

        .parameter-lock::before {
            content: '';
            width: 14px;
            height: 14px;
            background-color: currentColor;
            -webkit-mask: url('icons/lock.svg') center / contain no-repeat;
            mask: url('icons/lock.svg') center / contain no-repeat;
        }

        .parameter-lock:hover {
            color: var(--text-primary);
            background-color: var(--bg-tertiary);
            opacity: 1;
        }

        .parameter-lock[aria-pressed="true"] {
            color: var(--accent-primary);
            background-color: color-mix(in srgb, var(--accent-primary) 12%, transparent);
            border-color: color-mix(in srgb, var(--accent-primary) 30%, transparent);
            opacity: 1;
        }

        .parameter-lock:focus-visible {
            outline: 2px solid var(--accent-primary);
            outline-offset: 2px;
        }

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

        .slider-container {
            flex: 1;
            position: relative;
            display: flex;
            align-items: center;
            min-height: 28px;
            touch-action: pan-y;
        }

        input[type="range"] {
            width: 100%;
            height: 4px;
            -webkit-appearance: none;
            appearance: none;
            background: var(--bg-tertiary);
            outline: none;
            border-radius: var(--radius-full);
            margin: var(--space-2) 0;
            cursor: pointer;
            touch-action: pan-y;
            --track-fill: 0%;
            /* Variable to control the filled portion */
            background: linear-gradient(to right,
                    color-mix(in srgb, var(--accent-primary) 20%, transparent) 0%,
                    color-mix(in srgb, var(--accent-primary) 20%, transparent) var(--track-fill),
                    var(--bg-tertiary) var(--track-fill),
                    var(--bg-tertiary) 100%);
        }

        input[type="range"]:hover,
        input[type="range"].slider-active {
            background: linear-gradient(to right,
                    color-mix(in srgb, var(--accent-primary) 30%, transparent) 0%,
                    color-mix(in srgb, var(--accent-primary) 30%, transparent) var(--track-fill),
                    var(--bg-tertiary) var(--track-fill),
                    var(--bg-tertiary) 100%);
        }

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--accent-primary);
            cursor: pointer;
            box-shadow: var(--shadow-sm);
            transition: transform 0.15s ease;
        }

        input[type="range"]::-webkit-slider-thumb:hover,
        input[type="range"].slider-active::-webkit-slider-thumb,
        input[type="range"]:active::-webkit-slider-thumb {
            transform: scale(1.15);
        }

        /* Dropdown Styles */
        .dropdown-container {
            width: 100%;
        }

        .dropdown-row {
            display: flex;
            align-items: center;
            gap: var(--space-2);
        }

        .dropdown-select {
            flex: 1;
            padding: var(--space-2) var(--space-3);
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: var(--text-sm);
            font-family: inherit;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            cursor: pointer;
            transition: var(--transition);
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 8px center;
            background-size: 16px;
            padding-right: 32px;
        }

        .dropdown-select:hover {
            border-color: var(--accent-primary);
        }

        .dropdown-select:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
        }

        /* Light colored triangle for dropdown in dark mode */
        body.dark-theme .dropdown-select {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23e0e0e0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        }

        /* Arrow button for dropdown */
        .dropdown-arrow-btn {
            min-width: 60px;
            max-width: 80px;
            padding: var(--space-2) var(--space-3);
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: var(--text-sm);
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .dropdown-arrow-btn:hover {
            border-color: var(--accent-primary);
            background-color: var(--bg-primary);
        }

        .dropdown-arrow-btn:active {
            background-color: var(--accent-primary);
            color: white;
        }

        .dropdown-arrow-btn svg {
            width: 16px;
            height: 16px;
            transition: var(--transition);
        }

        .listbox-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background-color: color-mix(in srgb, var(--bg-tertiary) 50%, transparent);
            min-height: 0;
        }

        .listbox-search-wrap {
            position: sticky;
            top: 0;
            z-index: 1;
            background-color: var(--bg-tertiary);
            padding: var(--space-2) var(--space-3);
            border-top-left-radius: var(--radius-sm);
            border-top-right-radius: var(--radius-sm);
        }

        .search-glass-icon {
            position: absolute;
            left: 20px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-tertiary);
            pointer-events: none;
            width: 14px;
            height: 14px;
        }

        .listbox-search {
            width: 100%;
            padding: var(--space-2) var(--space-3);
            font-size: var(--text-sm);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background-color: var(--bg-primary);
            color: var(--text-primary);
            padding-left: 32px;
            padding-right: 36px;
            transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
        }

        .listbox-search:hover {
            border-color: var(--accent-primary);
            background-color: var(--bg-secondary);
        }

        .listbox-search:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
        }

        .listbox-search-icon {
            position: absolute;
            right: 16px;
            top: 50%;
            transform: translateY(-50%) scale(0.8);
            width: 20px;
            height: 20px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: 14px;
            border: none;
            outline: none;
            cursor: pointer;
            background-color: transparent;
            opacity: 0;
            pointer-events: none;
            visibility: hidden;
            transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.2s ease;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");
        }

        .listbox-search-wrap.has-value .listbox-search-icon {
            opacity: 0.7;
            pointer-events: auto;
            visibility: visible;
            transform: translateY(-50%) scale(1);
        }

        .listbox-search-wrap.has-value .listbox-search-icon:hover {
            opacity: 1;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");
        }

        .listbox-options {
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            max-height: 256px; /* Default cap, dynamically updated by JS */
            min-height: 0;
        }

        .listbox-options.no-pointer-events {
            pointer-events: none;
        }

        .style-view-toggle { display: flex; gap: 4px; padding: 4px; background: var(--bg-tertiary); border-bottom: 1px solid var(--border); }
        .style-view-toggle button { display: flex; justify-content: center; align-items: center; gap: 6px; flex: 1; min-height: 30px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font: inherit; font-size: var(--text-xs); cursor: pointer; }
        .style-view-toggle button[aria-pressed="true"] { background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm); }
        .style-view-toggle button:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: -2px; }
        #shapeMode-options.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; padding: 6px; align-content: start; }
        #shapeMode-options.style-grid .listbox-option { position: relative; flex-direction: column; justify-content: center; gap: 8px; min-width: 0; min-height: 106px; padding: 12px 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-secondary); }
        .style-mode-thumbnail { width: 54px; height: 54px; flex-shrink: 0; pointer-events: none; }
        .style-mode-thumbnail .home-tile-shape { fill: currentColor; }
        #shapeMode-options.style-grid .style-mode-name { font-size: 11px; line-height: 1.3; text-align: center; overflow-wrap: anywhere; min-height: 28px; display: flex; align-items: center; justify-content: center; }
        #shapeMode-options.style-grid .favorite-btn { position: absolute; right: 2px; top: 2px; margin: 0; padding: 4px; }
        #shapeMode-options.style-grid .favorite-btn.active { opacity: 0.75; }
        #shapeMode-options.style-grid .listbox-empty { grid-column: 1 / -1; }
        .style-favorites-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 190px; text-align: center; padding: 24px !important; }
        .style-empty-heart { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: color-mix(in srgb, var(--accent-primary) 10%, transparent); color: var(--accent-primary); font-size: 34px; line-height: 1; }
        .style-favorites-empty strong { color: var(--text-primary); font-size: var(--text-sm); font-weight: 500; }
        .style-favorites-empty p { max-width: 210px; margin: 0; font-size: var(--text-xs); line-height: 1.5; }
        .style-favorites-empty button { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-tertiary); color: var(--text-primary); font: inherit; font-size: var(--text-xs); cursor: pointer; }

        .listbox-resize-handle {
            height: 12px;
            flex-shrink: 0;
            cursor: ns-resize;
            background-color: var(--bg-tertiary);
            border-top: 1px solid var(--border);
            border-bottom-left-radius: var(--radius-sm);
            border-bottom-right-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            touch-action: none;
            transition: background-color 0.15s ease;
        }

        .listbox-resize-handle::before {
            content: '';
            display: block;
            width: 28px;
            height: 3px;
            border-radius: 2px;
            background-color: var(--border);
            transition: background-color 0.15s ease;
        }

        .listbox-resize-handle:hover {
            background-color: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-tertiary));
        }

        .listbox-resize-handle:hover::before {
            background-color: var(--accent-primary);
        }

        .listbox-resize-handle.is-resizing {
            background-color: color-mix(in srgb, var(--accent-primary) 20%, var(--bg-tertiary));
        }

        .listbox-resize-handle.is-resizing::before {
            background-color: var(--accent-primary);
        }

        .listbox-option {
            padding: var(--space-2) var(--space-3);
            cursor: pointer;
            color: var(--text-primary);
        }

        .listbox-option:nth-child(even) {
            background-color: rgba(0, 0, 0, 0.01);
        }

        body.dark-theme .listbox-option:nth-child(even) {
            background-color: rgba(255, 255, 255, 0.015);
        }

        .listbox-option:hover {
            box-shadow: inset 0 0 0 100px color-mix(in srgb, var(--accent-primary) 8%, transparent);
        }

        .listbox-option[aria-selected="true"] {
            background-color: var(--accent-primary) !important;
            color: white !important;
        }

        .listbox-empty {
            padding: var(--space-2) var(--space-3);
            color: var(--text-tertiary);
        }

        /* Favorite Button Styles */
        .listbox-option {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .favorite-btn {
            background: none;
            border: none;
            cursor: pointer;
            padding: 4px;
            opacity: 0;
            transition: opacity 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: var(--radius-sm);
            margin-left: 8px;
        }

        .favorite-btn img {
            width: 16px;
            height: 16px;
            display: block;
            opacity: 0.6;
        }

        body.dark-theme .favorite-btn img {
            filter: invert(1);
        }

        .listbox-option:hover .favorite-btn,
        .favorite-btn.active {
            opacity: 1;
        }

        .favorite-btn:hover {
            background-color: rgba(0, 0, 0, 0.05);
        }

        body.dark-theme .favorite-btn:hover {
            background-color: rgba(255, 255, 255, 0.1);
        }

        .favorite-btn svg {
            width: 16px;
            height: 16px;
            display: block;
            opacity: 0.6;
            transition: opacity 0.2s ease;
        }

        .listbox-option:hover .favorite-btn svg,
        .favorite-btn:hover svg {
            opacity: 1;
        }

        /* Make heart icon white when option is selected */
        .listbox-option[aria-selected="true"] .favorite-btn img {
            filter: brightness(0) invert(1);
            opacity: 1;
        }

        /* Make SVG delete/action icons white when option is selected */
        .listbox-option[aria-selected="true"] .favorite-btn {
            color: white !important;
        }

        .listbox-option[aria-selected="true"] .favorite-btn svg {
            opacity: 1;
        }

        input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--accent-primary);
            cursor: pointer;
            border: none;
            box-shadow: var(--shadow-sm);
            transition: transform 0.15s ease;
        }

        input[type="range"]::-moz-range-thumb:hover,
        input[type="range"].slider-active::-moz-range-thumb,
        input[type="range"]:active::-moz-range-thumb {
            transform: scale(1.15);
        }

        .control-value {
            min-width: 40px;
            margin-left: var(--space-3);
            font-variant-numeric: tabular-nums;
            font-size: var(--text-sm);
            color: var(--text-secondary);
            text-align: right;
        }

        /* Numeric input for slider values */
        .control-value-input {
            width: 60px;
            margin-left: var(--space-3);
            padding: var(--space-1) var(--space-2);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background-color: var(--bg-tertiary);
            color: var(--text-primary);
            font-size: var(--text-sm);
            font-variant-numeric: tabular-nums;
            text-align: right;
            transition: var(--transition);
        }

        .control-value-input:hover {
            border-color: var(--accent-primary);
        }

        .control-value-input:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
        }

        /* Hide number input spinners */
        .control-value-input::-webkit-outer-spin-button,
        .control-value-input::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        .control-value-input[type=number] {
            -moz-appearance: textfield;
            appearance: textfield;
        }

        /* Color picker */
        .color-picker-container {
            display: flex;
            align-items: center;
        }

        input[type="color"] {
            -webkit-appearance: none;
            appearance: none;
            width: 36px;
            height: 36px;
            border: none;
            border-radius: var(--radius-sm);
            background: none;
            cursor: pointer;
            overflow: hidden;
            transition: transform 0.2s ease;
        }

        input[type="color"]:hover {
            transform: translateY(-2px);
        }

        input[type="color"]::-webkit-color-swatch-wrapper {
            padding: 0;
        }

        input[type="color"]::-webkit-color-swatch {
            border: none;
            border-radius: var(--radius-sm);
            box-shadow: var(--shadow-sm);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        input[type="color"]:hover::-webkit-color-swatch {
            transform: scale(1.05);
            box-shadow: var(--shadow);
        }

        input[type="color"]::-moz-color-swatch {
            border: none;
            border-radius: var(--radius-sm);
            box-shadow: var(--shadow-sm);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        input[type="color"]:hover::-moz-color-swatch {
            transform: scale(1.05);
            box-shadow: var(--shadow);
        }

        /* Drag and drop styles for color swatches */
        input[type="color"].dragging {
            opacity: 0.5;
            transform: scale(0.9);
            cursor: grabbing !important;
        }

        .color-picker-container.drag-over {
            border: 2px dashed var(--accent-primary) !important;
            border-radius: var(--radius-sm);
            background-color: rgba(99, 102, 241, 0.05);
            transition: none;
        }

        input[type="color"] {
            cursor: grab;
            transition: all 0.2s ease;
        }

        input[type="color"]:active {
            cursor: grabbing;
        }

        input[type="color"][draggable="true"] {
            cursor: grab;
        }

        .color-value {
            margin-left: var(--space-3);
            font-size: var(--text-sm);
            color: var(--text-secondary);
        }

        .gradient-stop-editor {
            position: relative;
            height: 38px;
            margin: 0 16px;
            touch-action: none;
        }

        .gradient-stop-track {
            position: absolute;
            top: 9px;
            left: 0;
            right: 0;
            height: 12px;
            border: 1px solid color-mix(in srgb, var(--text-primary) 18%, var(--border));
            border-radius: var(--radius-full);
            box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
        }

        .gradient-stop-handle {
            --stop-color: #ffffff;
            position: absolute;
            top: 3px;
            left: 0;
            width: 24px;
            height: 24px;
            padding: 0;
            border: 2px solid var(--bg-secondary);
            border-radius: 50%;
            background: linear-gradient(var(--stop-color), var(--stop-color)), repeating-conic-gradient(#999 0% 25%, #555 0% 50%) 0 / 8px 8px;
            box-shadow: 0 0 0 1px color-mix(in srgb, var(--text-primary) 35%, transparent), var(--shadow-sm);
            cursor: ew-resize;
            transform: translateX(-50%);
            touch-action: none;
            z-index: 2;
        }

        .gradient-stop-handle::after {
            content: attr(data-position);
            position: absolute;
            top: 29px;
            left: 50%;
            color: var(--text-tertiary);
            font-size: 9px;
            font-variant-numeric: tabular-nums;
            transform: translateX(-50%);
            white-space: nowrap;
        }

        .gradient-stop-handle:hover,
        .gradient-stop-handle:focus-visible,
        .gradient-stop-handle.is-dragging {
            z-index: 3;
            box-shadow: 0 0 0 2px var(--accent-primary), var(--shadow);
        }

        .gradient-stop-handle:focus-visible {
            outline: none;
        }

        .gradient-stop-handle[hidden] {
            display: none;
        }
        .gradient-stop-handle.is-removal-pending { opacity: 0.45; box-shadow: 0 0 0 2px #ef4444; }
        .gradient-stop-handle.is-removal-pending::after { content: 'Remove'; color: #ef4444; }

        .additional-gradient-stops { display: grid; gap: var(--space-3); margin-top: var(--space-3); }
        .additional-gradient-stop { display: grid; grid-template-columns: minmax(0, 1fr) 64px 32px; gap: var(--space-2); align-items: center; }
        .additional-gradient-stop > label { grid-column: 1 / -1; margin-bottom: 0; font-size: var(--text-xs); }
        .additional-gradient-stop .color-picker-container { min-width: 0; gap: var(--space-2); }
        .additional-gradient-stop .hex-input { min-width: 0; width: 76px; }
        .additional-gradient-stop .control-value-input { width: 100%; min-width: 0; margin-left: 0; }
        .gradient-stop-remove { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 50%; background: var(--bg-tertiary); color: var(--text-secondary); cursor: pointer; }
        .gradient-list-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-3); }
        .gradient-canvas-visibility { margin-bottom: var(--space-4); }
        .background-opacity-control { margin-top: var(--space-3); }
        .gradient-list-heading label { margin-bottom: 0; }
        #gradientStopCount { color: var(--text-tertiary); font-size: var(--text-xs); }
        #gradientStopEditor { height: 46px; margin: 0 14px var(--space-3); }
        .gradient-list-columns { display: grid; grid-template-columns: minmax(0, 1fr) 58px 58px; gap: 6px; padding: 0 34px 0 30px; margin-bottom: var(--space-2); color: var(--text-tertiary); font-size: 10px; }
        .gradient-stop-list { display: grid; gap: 6px; container-type: inline-size; }
        .gradient-stop-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 58px 58px 26px; gap: 6px; align-items: center; min-height: 46px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-secondary); transition: border-color 120ms, background-color 120ms; }
        .gradient-stop-row:hover { border-color: color-mix(in srgb, var(--text-primary) 24%, var(--border)); }
        .gradient-stop-row .color-picker-container { min-width: 0; gap: 8px; }
        .gradient-stop-row input[type="color"] { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 7px; cursor: pointer; }
        .gradient-color-swatch { position: relative; display: flex; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 7px; overflow: hidden; background: repeating-conic-gradient(#999 0% 25%, #555 0% 50%) 0 / 8px 8px; cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease; }
        .gradient-color-swatch::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(135deg, rgb(255 255 255 / 30%), transparent 65%); opacity: 0; transition: opacity 160ms ease; }
        .gradient-color-swatch:focus-within { box-shadow: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--accent-primary); }
        @media (hover: hover) {
            .gradient-color-swatch:hover { transform: translateY(-2px) scale(1.07); box-shadow: 0 0 0 2px var(--bg-secondary), 0 0 0 3px color-mix(in srgb, var(--text-primary) 55%, transparent), 0 4px 8px rgb(0 0 0 / 18%); }
            .gradient-color-swatch:hover::after { opacity: 1; }
        }
        .gradient-color-swatch:active { transform: scale(0.96); }
        .gradient-color-swatch input[type="color"]:hover,
        .gradient-color-swatch input[type="color"]:hover::-webkit-color-swatch,
        .gradient-color-swatch input[type="color"]:hover::-moz-color-swatch { transform: none; }
        @media (prefers-reduced-motion: reduce) {
            .gradient-color-swatch, .gradient-color-swatch::after { transition: none; }
            .gradient-color-swatch:hover, .gradient-color-swatch:active { transform: none; }
        }
        #gradientStopEditor .gradient-stop-track { background-color: #555; background-image: repeating-conic-gradient(#999 0% 25%, #555 0% 50%); background-size: 8px 8px; }
        .gradient-stop-row .hex-input { width: 100%; min-width: 0; padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
        .gradient-stop-position, .gradient-stop-opacity { display: flex; align-items: center; padding: 4px 6px; gap: 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-tertiary); }
        .gradient-stop-position input, .gradient-stop-opacity input { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--text-primary); text-align: right; font: inherit; font-size: var(--text-xs); appearance: textfield; }
        .gradient-stop-position input::-webkit-inner-spin-button, .gradient-stop-position input::-webkit-outer-spin-button, .gradient-stop-opacity input::-webkit-inner-spin-button, .gradient-stop-opacity input::-webkit-outer-spin-button { appearance: none; margin: 0; }
        .gradient-stop-position span, .gradient-stop-opacity span { color: var(--text-tertiary); font-size: 10px; }
        .gradient-stop-grip, .gradient-stop-row .gradient-stop-remove { display: flex; align-items: center; justify-content: center; width: 100%; height: 28px; padding: 0; border: 0; border-radius: 6px; color: var(--text-tertiary); background: transparent; }
        .gradient-stop-grip { cursor: grab; touch-action: none; }
        .gradient-stop-grip:active { cursor: grabbing; }
        .gradient-stop-row .gradient-stop-remove { cursor: pointer; }
        .gradient-stop-row .gradient-stop-remove:hover:enabled { color: #ef4444; background: color-mix(in srgb, #ef4444 10%, transparent); }
        .gradient-stop-row .gradient-stop-remove:disabled { opacity: 0.25; cursor: default; }
        .gradient-stop-row.is-dragging { opacity: 0.5; border-color: var(--accent-primary); }
        .gradient-stop-row.is-drop-target { border-color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-secondary)); box-shadow: 0 -2px 0 var(--accent-primary); }
        #addGradientStop { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 36px; margin-top: var(--space-2); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-secondary); background: transparent; font: inherit; font-size: var(--text-xs); cursor: pointer; }
        #addGradientStop span { font-size: 18px; line-height: 1; }
        #addGradientStop:hover { border-color: var(--accent-primary); color: var(--text-primary); background: color-mix(in srgb, var(--accent-primary) 6%, transparent); }
        .gradient-stop-row :focus-visible, #addGradientStop:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
        @container (max-width: 300px) {
            .gradient-stop-row { grid-template-columns: 20px minmax(0, 1fr) minmax(0, 1fr) 26px; }
            .gradient-stop-grip { grid-row: 1 / 3; }
            .gradient-stop-row .color-picker-container { grid-column: 2 / 4; grid-row: 1; }
            .gradient-stop-position { grid-column: 2; grid-row: 2; }
            .gradient-stop-position::before { content: 'Position'; font-size: 10px; color: var(--text-tertiary); }
            .gradient-stop-opacity { grid-column: 3; grid-row: 2; }
            .gradient-stop-opacity::before { content: 'Opacity'; font-size: 10px; color: var(--text-tertiary); }
            .gradient-stop-row .gradient-stop-remove { grid-column: 4; grid-row: 1; }
        }

        .gradient-editor-hint {
            display: block;
            margin-top: var(--space-2);
            color: var(--text-tertiary);
            font-size: var(--text-xs);
            line-height: 1.4;
        }

        .gradient-canvas-editor {
            position: absolute;
            inset: 0;
            z-index: 6;
            pointer-events: none;
        }

        .gradient-canvas-editor[hidden] {
            display: none;
        }

        .gradient-canvas-editor .gradient-handle-lines {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            overflow: visible;
            pointer-events: none;
            filter: none;
        }

        .gradient-direction-line {
            stroke: rgba(255, 255, 255, 0.96);
            stroke-width: 2;
            stroke-dasharray: 5 4;
            vector-effect: non-scaling-stroke;
            filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.75));
        }

        .gradient-canvas-handle {
            --handle-color: #ffffff;
            position: absolute;
            left: 50%;
            top: 50%;
            width: 24px;
            height: 24px;
            padding: 0;
            border: 3px solid #ffffff;
            border-radius: 50%;
            background: linear-gradient(var(--handle-color), var(--handle-color)), repeating-conic-gradient(#999 0% 25%, #555 0% 50%) 0 / 8px 8px;
            box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
            transform: translate(-50%, -50%);
            cursor: move;
            pointer-events: auto;
            touch-action: none;
        }

        .gradient-canvas-handle-center {
            width: 24px;
            height: 24px;
            background: var(--bg-secondary);
            border-color: var(--accent-primary);
            transform: translate(calc(-50% + var(--center-offset-x, 0px)), calc(-50% + var(--center-offset-y, 0px)));
        }

        .gradient-canvas-handle-start,
        .gradient-canvas-handle-end {
            cursor: url('icons/cursor-rotate.svg') 16 16, crosshair;
        }

        .gradient-canvas-handle-stop { cursor: grab; z-index: 1; }
        .gradient-canvas-handle-stop.is-dragging { cursor: grabbing; z-index: 2; }
        .gradient-canvas-handle[hidden] { display: none; }

        .gradient-canvas-handle:hover,
        .gradient-canvas-handle:focus-visible,
        .gradient-canvas-handle.is-dragging {
            outline: none;
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 55%, transparent),
                        0 2px 7px rgba(0, 0, 0, 0.6);
        }

        @media (hover: none), (pointer: coarse) {
            .favorite-btn {
                opacity: 0.75;
                min-width: 32px;
                min-height: 32px;
            }

            .has-multiple-tabs .floating-tab.active .floating-tab-close {
                visibility: visible;
                width: 22px;
                height: 22px;
                flex: 0 0 22px;
            }
        }

        @media (pointer: coarse) {
            :root {
                --toggle-width: 28px;
            }

            #sidebarToggle {
                height: 56px;
            }

            .sidebar-resizer {
                width: 16px;
                left: calc(100% - 8px);
            }

            .sidebar-resizer::after {
                left: 7px;
            }

            .sidebar-resizer.is-resizing::after {
                left: 7px;
            }

            .sidebar-resizer.at-min-max::after {
                left: 6px;
            }

            .slider-container {
                min-height: 36px;
            }

            input[type="range"] {
                height: 6px;
            }

            input[type="range"]::-webkit-slider-thumb {
                width: 22px;
                height: 22px;
            }

            input[type="range"]::-moz-range-thumb {
                width: 22px;
                height: 22px;
            }

            .parameter-lock {
                width: 34px;
                height: 34px;
                flex: 0 0 34px;
            }

            .control-value-input {
                width: 68px;
                min-height: 36px;
                font-size: 16px;
                padding: 4px 8px;
            }

            .hex-input {
                min-height: 36px;
                font-size: 16px;
                width: 90px;
                padding: 4px 8px;
            }

            .listbox-search,
            .png-size-input,
            .dropdown-select {
                min-height: 40px;
                font-size: 16px;
            }

            .listbox-search-icon {
                width: 32px;
                height: 32px;
                right: 10px;
            }

            .listbox-option {
                min-height: 40px;
            }

            .listbox-resize-handle {
                height: 20px;
            }

            .preset-btn {
                min-height: 36px;
                padding: var(--space-2) var(--space-3);
            }

            .toggle-item label {
                min-height: 38px;
            }

            .switch {
                width: 46px;
                height: 28px;
            }

            .switch-slider:before {
                width: 22px;
                height: 22px;
            }

            input:checked + .switch-slider:before {
                transform: translateX(18px);
            }

            .zoom-btn,
            .help-btn,
            .animate-btn {
                width: 40px;
                height: 40px;
            }

            .zoom-btn.zoom-reset {
                width: auto;
                height: 40px;
                padding: 0 var(--space-4);
            }

            .copy-btn {
                min-height: 40px;
                padding: var(--space-2) var(--space-4);
            }

            .floating-panel-header {
                flex: 0 0 40px;
                height: 40px;
            }

            .floating-tab-row,
            .floating-tab,
            .floating-drop-preview,
            .floating-grip {
                height: 40px;
            }

            .floating-tab:not(.active):not(.floating-drop-preview) {
                width: 40px;
            }

            .panelHeaderBtn {
                width: 32px;
                height: 32px;
                flex: 0 0 32px;
            }

            .floating-resize-handle {
                width: 24px;
                height: 24px;
            }

            .gradient-stop-editor {
                height: 44px;
            }

            .gradient-stop-track {
                top: 12px;
                height: 14px;
            }

            .gradient-stop-handle {
                width: 28px;
                height: 32px;
            }

            .gradient-stop-remove {
                width: 36px;
                height: 36px;
            }

            .additional-gradient-stop {
                grid-template-columns: minmax(0, 1fr) 72px 36px;
            }

            .gradient-canvas-handle {
                width: 32px;
                height: 32px;
            }

            .gradient-canvas-handle-center {
                width: 32px;
                height: 32px;
            }
        }

        /* Radio and Checkbox Controls (Segmented Pill) */
        .toggle-group, .segmenter {
            display: flex;
            align-items: stretch;
            gap: 0;
            width: 100%;
            background-color: var(--bg-tertiary);
            border-radius: var(--radius-full);
            padding: 0;
            overflow: hidden;
        }

        /* PNG Size input specifics */
        .png-size-input-container {
            display: flex;
            flex-direction: column;
            width: 100%;
            gap: var(--space-2);
        }

        .png-size-input {
            width: 100%;
            padding: var(--space-2) var(--space-3);
            border-radius: var(--radius);
            border: 1px solid var(--border);
            background-color: var(--bg-tertiary);
            color: var(--text-primary);
            font-size: var(--text-sm);
            transition: all var(--transition);
        }

        .png-size-input:focus {
            border-color: var(--accent-primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
        }

        .png-size-presets {
            display: flex;
            gap: var(--space-2);
        }

        .preset-btn {
            flex: 1;
            padding: var(--space-1) var(--space-2);
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text-secondary);
            font-size: var(--text-xs);
            cursor: pointer;
            transition: all var(--transition);
        }

        .preset-btn:hover {
            background-color: color-mix(in srgb, var(--text-primary) 6%, var(--bg-tertiary));
            color: var(--text-primary);
        }

        .preset-btn:active {
            background-color: var(--accent-primary);
            color: white;
        }

        .toggle-item {
            position: relative;
            flex: 1;
            display: flex;
        }

        .toggle-item input[type="radio"],
        .toggle-item input[type="checkbox"] {
            position: absolute;
            opacity: 0;
            width: 0;
            height: 0;
            margin: 0;
            padding: 0;
        }

        .toggle-item label {
            width: 100%;
            height: 100%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: var(--space-2) var(--space-4);
            font-size: var(--text-sm);
            font-weight: 500;
            color: var(--text-secondary);
            background-color: transparent;
            border-radius: 0;
            cursor: pointer;
            transition: all var(--transition);
            white-space: nowrap;
            margin-bottom: 0;
        }

        .toggle-group-vertical {
            flex-direction: column;
            border-radius: var(--radius-lg);
        }

        #gradientTypeRow .toggle-item label {
            justify-content: flex-start;
            text-align: left;
            gap: var(--space-2);
        }
        .fill-type-icon {
            width: 20px;
            height: 20px;
            flex: 0 0 20px;
            background-color: currentColor;
            -webkit-mask: var(--fill-icon) center/contain no-repeat;
            mask: var(--fill-icon) center/contain no-repeat;
        }
        .fill-type-icon-solid { --fill-icon: url('icons/spectrum/Polygon4.svg'); }
        .fill-type-icon-linear { --fill-icon: url('icons/spectrum/GradientHorizontal.svg'); }
        .fill-type-icon-radial { --fill-icon: url('icons/spectrum/GradientRadial.svg'); }

        @container (min-width: 479px) {
            .toggle-group-vertical {
                flex-direction: row;
                border-radius: var(--radius-full);
            }
        }

        .toggle-item label:hover {
            background-color: color-mix(in srgb, var(--text-primary) 6%, transparent);
            color: var(--text-primary);
        }

        .toggle-item input:checked+label {
            background-color: var(--accent-primary);
            color: white;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }

        .toggle-item input:checked+label:hover {
            filter: brightness(1.1);
        }

        /* Switch control */
        .switch-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .switch {
            position: relative;
            display: inline-block;
            width: 40px;
            height: 24px;
        }

        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .switch-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: var(--bg-tertiary);
            transition: var(--transition);
            border-radius: 34px;
        }

        .switch-slider:before {
            position: absolute;
            content: "";
            height: 18px;
            width: 18px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: var(--transition);
            border-radius: 50%;
        }

        input:checked+.switch-slider {
            background-color: var(--accent-primary);
        }

        input:checked+.switch-slider:before {
            transform: translateX(16px);
        }

        /* Buttons */
        .button-group {
            display: flex;
            flex-direction: column;
            gap: var(--space-3);
        }

        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: var(--space-2);
            padding: var(--space-3) var(--space-5);
            font-size: var(--text-sm);
            font-weight: 600;
            border-radius: var(--radius);
            border: none;
            cursor: pointer;
            transition: all var(--transition);
            white-space: nowrap;
        }

        .btn-primary {
            background-color: var(--accent-primary);
            color: white;
        }

        .btn-primary:hover {
            filter: brightness(1.1);
        }

        .btn-secondary {
            background-color: var(--accent-secondary);
            color: white;
        }

        .btn-secondary:hover {
            filter: brightness(1.1);
        }

        .btn-accent {
            background-color: var(--accent-tertiary);
            color: white;
        }

        .btn-accent:hover {
            filter: brightness(1.1);
        }

        .btn-tertiary {
            background-color: var(--bg-tertiary);
            color: var(--text-primary);
            border: 1px solid var(--border);
        }

        .btn-tertiary:hover {
            background-color: color-mix(in srgb, var(--text-primary) 6%, var(--bg-tertiary));
            border-color: color-mix(in srgb, var(--text-primary) 20%, var(--border));
        }

        .btn-icon {
            /* Margin removed to allow flex gap to perfectly center text and icon */
        }

        @keyframes spin360 {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .regenerate-icon {
            margin-right: 4px; /* Increase spacing from text */
            transform-origin: center;
            position: relative;
            top: 1px; /* Vertically align with text */
        }

        .regenerate-icon.spin-animation {
            animation: spin360 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        }

        /* SVG Preview Area */
        .preview-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            margin-top: 0;
            flex: 1;
            /* Make it fill available space */
        }

        .preview-panel {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: var(--space-10);
            background-color: var(--bg-secondary);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow);
            border: 1px solid var(--border);
            transition: background-color 0.3s;
            margin-top: 0;
            /* Remove margin as we're using margin on the container */
            height: 100%;
            /* Make the panel fill the container height */
            position: relative;
            /* Added to position zoom controls */
            overflow: hidden;
            /* Prevent content from exceeding panel boundaries */
        }

        .svg-container {
            position: relative;
            width: 100%;
            max-width: 460px;
            max-height: 460px;
            aspect-ratio: 1 / 1;
            display: flex;
            align-items: center;
            justify-content: center;
            background-image: linear-gradient(45deg, var(--border) 25%, transparent 25%, transparent 75%, var(--border) 75%, var(--border)),
                linear-gradient(45deg, var(--border) 25%, transparent 25%, transparent 75%, var(--border) 75%, var(--border));
            background-size: 20px 20px;
            background-position: 0 0, 10px 10px;
            border-radius: var(--radius);
            margin: auto;
            /* Center horizontally */
            transform-origin: center;
            transition: transform 0.3s ease;
            transform: scale(1);
            /* Initial scale */
            box-sizing: border-box;
            /* Include borders in size calculations */
            will-change: transform;
            /* Hint browser for better performance */
        }

        /* Wide screen enhancement for preview */
        @media (min-width: 1440px) {
            .svg-container {
                max-width: 600px;
                max-height: 600px;
            }
        }

        @media (min-width: 1800px) {
            .svg-container {
                max-width: 700px;
                max-height: 700px;
            }
        }

        /* Copy controls */
        .copy-controls {
            position: absolute;
            bottom: var(--space-4);
            left: var(--space-4);
            display: flex;
            gap: var(--space-2);
        }

        .copy-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: var(--space-2);
            padding: var(--space-2) var(--space-3);
            border-radius: var(--radius);
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            color: var(--text-primary);
            font-size: var(--text-xs);
            font-weight: 500;
            cursor: pointer;
            transition: all var(--transition);
            white-space: nowrap;
        }

        .copy-btn:hover {
            background-color: var(--accent-primary);
            color: white;
            border-color: var(--accent-primary);
        }

        .copy-btn.success {
            background-color: var(--accent-secondary);
            color: white;
            border-color: var(--accent-secondary);
        }

        .copy-btn svg {
            flex-shrink: 0;
        }

        .canvas-context-menu {
            position: fixed;
            top: 0;
            left: 0;
            min-width: 220px;
            padding: var(--space-2);
            border-radius: calc(var(--radius) + 4px);
            border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
            background:
                linear-gradient(180deg, color-mix(in srgb, var(--bg-secondary) 96%, white 4%), color-mix(in srgb, var(--bg-secondary) 98%, black 2%));
            box-shadow: 0 22px 48px rgba(0, 0, 0, 0.2), 0 6px 18px rgba(0, 0, 0, 0.12);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
            opacity: 0;
            transform: translateY(10px) scale(0.96);
            transform-origin: top left;
            pointer-events: none;
            transition: opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
            z-index: 1000;
        }

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

        .canvas-context-menu[hidden] {
            display: none;
        }

        .context-menu-list {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .context-menu-item + .context-menu-item {
            margin-top: 2px;
        }

        .context-menu-action {
            width: 100%;
            display: flex;
            align-items: center;
            gap: var(--space-3);
            padding: 11px 12px;
            border: 0;
            border-radius: calc(var(--radius-sm) + 2px);
            background: transparent;
            color: var(--text-primary);
            font: inherit;
            font-size: var(--text-sm);
            cursor: pointer;
            text-align: left;
            transition: background-color 140ms ease, color 140ms ease;
        }

        .context-menu-action:hover,
        .context-menu-action:focus-visible {
            background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
            color: var(--text-primary);
            outline: none;
        }

        .context-menu-icon {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
            color: var(--text-secondary);
            transition: color 140ms ease;
        }

        .context-menu-action:hover .context-menu-icon,
        .context-menu-action:focus-visible .context-menu-icon {
            color: var(--accent-primary);
        }

        .context-menu-icon-mask {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
            display: block;
            background-color: currentColor;
            mask-repeat: no-repeat;
            mask-position: center;
            mask-size: contain;
            -webkit-mask-repeat: no-repeat;
            -webkit-mask-position: center;
            -webkit-mask-size: contain;
        }

        .context-menu-action .context-menu-icon-mask {
            color: var(--text-secondary);
            transition: color 140ms ease;
        }

        .context-menu-action:hover .context-menu-icon-mask,
        .context-menu-action:focus-visible .context-menu-icon-mask {
            color: var(--accent-primary);
        }

        .context-menu-icon-undock {
            mask-image: url('icons/square-chevron-right.svg');
            -webkit-mask-image: url('icons/square-chevron-right.svg');
        }

        .context-menu-icon-dock {
            mask-image: url('icons/square-chevron-left.svg');
            -webkit-mask-image: url('icons/square-chevron-left.svg');
        }

        .context-menu-icon-move-up {
            mask-image: url('icons/list-chevrons-up-down.svg');
            -webkit-mask-image: url('icons/list-chevrons-up-down.svg');
        }

        .context-menu-icon-move-down {
            mask-image: url('icons/list-chevrons-down-up.svg');
            -webkit-mask-image: url('icons/list-chevrons-down-up.svg');
        }

        .context-menu-icon-expand {
            mask-image: url('icons/square-chevron-down.svg');
            -webkit-mask-image: url('icons/square-chevron-down.svg');
        }

        .context-menu-icon-collapse {
            mask-image: url('icons/square-chevron-up.svg');
            -webkit-mask-image: url('icons/square-chevron-up.svg');
        }

        body.dark-theme .canvas-context-menu {
            background: linear-gradient(180deg, rgba(34, 34, 34, 0.96), rgba(24, 24, 24, 0.98));
            border-color: rgba(255, 255, 255, 0.08);
            box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42), 0 6px 18px rgba(0, 0, 0, 0.28);
        }

        /* Zoom controls */
        .zoom-controls {
            position: absolute;
            bottom: var(--space-4);
            right: var(--space-4);
            display: flex;
            gap: var(--space-2);
        }

        .zoom-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: var(--radius);
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            color: var(--text-primary);
            font-size: var(--text-base);
            cursor: pointer;
            transition: all var(--transition);
        }

        .zoom-btn:hover {
            background-color: var(--bg-primary);
        }

        .zoom-btn svg {
            width: 16px;
            height: 16px;
        }

        .zoom-btn.zoom-reset {
            width: auto;
            padding: 0 var(--space-3);
            font-size: var(--text-xs);
            font-weight: 500;
        }

        /* Dark mode checkerboard adjustment */
        body.dark-theme .svg-container {
            background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.07) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.07) 75%, rgba(255, 255, 255, 0.07)),
                linear-gradient(45deg, rgba(255, 255, 255, 0.07) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.07) 75%, rgba(255, 255, 255, 0.07));
        }

        .click-hint {
            position: absolute;
            bottom: -25px;
            left: 50%;
            transform: translateX(-50%);
            font-size: var(--text-xs);
            color: var(--text-tertiary);
            opacity: 0.8;
            pointer-events: none;
            white-space: nowrap;
        }

        .svg-container svg {
            width: 100%;
            height: 100%;
            filter: drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.08));
            transition: filter 0.3s;
        }

        /* Theme toggle */
        .theme-toggle {
            position: absolute;
            top: var(--space-6);
            right: var(--space-6);
            width: 40px;
            height: 40px;
            border-radius: var(--radius-full);
            background-color: var(--bg-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--border);
            cursor: pointer;
            box-shadow: var(--shadow);
            z-index: 10;
            transition: all var(--transition);
        }

        .theme-toggle:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-lg);
        }

        .theme-icon {
            width: 20px;
            height: 20px;
            color: var(--text-primary);
        }

        /* SVG animation */
        @keyframes blob-pulse {
            0% {
                transform: scale(1);
                opacity: 1;
            }

            50% {
                transform: scale(0.95);
                opacity: 0.8;
            }

            100% {
                transform: scale(1);
                opacity: 1;
            }
        }

        .svg-container.generating svg {
            animation: blob-pulse 0.5s ease;
        }

        /* Responsive adjustments */
        @media (max-width: 1024px) {
            html {
                height: auto;
                overflow-y: auto;
            }

            body {
                height: auto;
                overflow: visible;
            }

            .app-container {
                flex-direction: column;
                height: auto;
                overflow: visible;
                gap: var(--space-6);
                padding-top: 72px; /* Space for fixed header */
            }

            .sidebar-wrapper {
                width: 100%;
                position: static;
                height: auto;
                margin-left: 0;
                padding-left: 0;
                order: 2; /* Move sidebar below preview */
            }

            .sidebar {
                width: 100%;
                margin-right: 0;
                height: auto;
                overflow: visible;
            }

            /* Restore collapsed sidebar on mobile — never hide controls */
            .sidebar-wrapper.collapsed {
                width: 100% !important;
                padding-left: 0;
            }
            .sidebar-wrapper.collapsed .sidebar {
                visibility: visible;
                opacity: 1 !important;
                pointer-events: auto;
            }
            body.dock-active .sidebar .card { display: block; }
            body.dock-active .dock-rail { display: none; }
            .brand-fixed { display: none !important; }
            .sidebar.collapsed {
                width: 100%;
                opacity: 1;
                overflow: visible;
                margin-right: 0;
            }

            #sidebarToggle {
                display: none;
            }

            /* Move header to fixed position at top */
            .app-header {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                background-color: var(--bg-primary);
                z-index: 150;
                padding: var(--space-4);
                margin: 0;
                border-bottom: 1px solid var(--border);
                box-shadow: var(--shadow-sm);
            }

            .sidebar .card {
                overflow-y: visible;
                max-height: none;
            }

            /* The mobile controls participate in normal page flow. Keeping the
               footer in that same flow prevents it from covering list content. */
            .sidebar-footer {
                position: static;
                bottom: auto;
                z-index: auto;
                background: color-mix(in srgb, var(--bg-secondary) 85%, transparent);
                -webkit-backdrop-filter: none;
                backdrop-filter: none;
                -webkit-mask-image: none;
                mask-image: none;
            }

            .main-content {
                flex: 0 0 auto;
                width: 100%;
                padding-top: 0;
                margin-bottom: 0;
                height: auto;
                order: 1; /* Move preview above sidebar */
            }

            .preview-container {
                flex: 0 0 auto;
                height: 460px;
                min-height: 0;
            }

            .sidebar .listbox-search-wrap { position: relative; }
            .sidebar-resizer { display: none !important; }

            /* Adjust Account and Theme toggle positions for narrow widths */
            .account-toggle {
                position: fixed;
                top: 16px;
                right: auto;
                left: auto;
                /* Position to the left of theme toggle: 16px (right margin) + 40px (theme button width) + 8px (gap) */
                right: calc(16px + 40px + 8px);
                z-index: 200;
            }

            .theme-toggle {
                position: fixed;
                top: 16px;
                right: 16px;
                z-index: 200;
            }
        }

        @media (max-width: 860px) {
            .app-container {
                flex-direction: column;
            }

            .main-content {
                order: 1;
                flex: 0 0 auto;
                min-height: 0;
            }

            .sidebar-wrapper {
                order: 2;
                height: auto;
                max-height: none;
                min-height: 0;
                position: static;
            }
        }

        @media (max-width: 640px) {
            .app-container {
                padding: var(--space-3);
                padding-top: 68px; /* Space for fixed header */
            }

            /* Keep preview and controls in separate rows of the scrolling page. */
            .main-content {
                position: static;
            }

            .card {
                padding: var(--space-4);
                border-radius: var(--radius-sm);
            }

            .sidebar-footer {
                margin: var(--space-6) calc(-1 * var(--space-4)) calc(-1 * var(--space-4));
            }

            .preview-panel {
                padding: var(--space-4);
            }

            .button-group {
                flex-direction: column;
            }

            .preview-container {
                height: 320px;
            }

            /* Adjust button positions for smaller screens */
            .account-toggle {
                position: fixed;
                top: 14px;
                right: auto;
                /* Position to the left of theme toggle: 12px (right margin) + 36px (theme button width) + 8px (gap) */
                right: calc(12px + 36px + 8px);
                z-index: 200;
                height: 36px; /* Slightly smaller on mobile */
                padding: 0 var(--space-3);
            }

            .theme-toggle {
                position: fixed;
                top: 14px;
                right: 12px;
                z-index: 200;
                width: 36px; /* Slightly smaller on mobile */
                height: 36px;
            }

            .app-header {
                padding: var(--space-3);
            }

            /* Make account badge text smaller on mobile */
            .account-badge {
                font-size: 10px;
            }

            .account-icon {
                width: 16px;
                height: 16px;
            }

            .theme-icon {
                width: 18px;
                height: 18px;
            }
        }

        @media (max-width: 400px) {
            .app-header .app-title { font-size: clamp(10px, 3.5vw, 14px); }
            .app-header .app-icon { width: 28px; height: 28px; }
        }

        /* Collapsible panels */
        .panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            user-select: none;
            padding-bottom: var(--space-2);
        }

        .panel-header:hover h3 {
            color: var(--accent-primary);
        }

        .panel-toggle {
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 999px;
            color: var(--text-secondary);
            background: transparent;
            transition: background-color 0.18s ease, color 0.18s ease;
        }

        .panel-toggle svg {
            display: none;
        }

        .panel-toggle::before {
            content: '';
            display: block;
            width: 16px;
            height: 16px;
            background-color: currentColor;
            mask-repeat: no-repeat;
            mask-position: center;
            mask-size: contain;
            mask-image: url('icons/chevron-down.svg');
            -webkit-mask-repeat: no-repeat;
            -webkit-mask-position: center;
            -webkit-mask-size: contain;
            -webkit-mask-image: url('icons/chevron-down.svg');
        }

        .panel-content {
            overflow: hidden;
            transition: max-height 0.3s ease;
        }

        .panel-header:hover .panel-toggle {
            background: color-mix(in srgb, var(--text-primary) 7%, transparent);
            color: var(--text-primary);
        }

        .panel-collapsed .panel-toggle::before {
            mask-image: url('icons/chevron-up.svg');
            -webkit-mask-image: url('icons/chevron-up.svg');
        }

        .panel-collapsed .panel-content {
            max-height: 0;
        }

        /* Copyright text styling */
        .copyright-text {
            font-size: var(--text-xs);
            color: var(--text-tertiary);
            text-align: center;
            margin-top: var(--space-4);
            padding-bottom: 0;
            /* Remove padding at the bottom */
        }

        .copyright-text a {
            color: var(--text-tertiary);
            text-decoration: none;
            transition: color var(--transition);
        }

        .copyright-text a:hover {
            color: var(--accent-primary);
        }

        /* Add styles for the app icon */
        .app-icon {
            width: 32px;
            height: 32px;
            background-image: url('icons/app-icon-2.svg');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            border-radius: var(--radius-sm);
            margin-right: var(--space-2);
            cursor: pointer;
            transition: transform 0.2s ease;
        }

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

        button.app-icon {
            padding: 0;
            border: 0;
            background-color: transparent;
            flex-shrink: 0;
        }

        /* Hex color input field */
        .hex-input {
            margin-left: var(--space-3);
            font-size: var(--text-sm);
            color: var(--text-primary);
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 2px 6px;
            width: 80px;
            transition: all var(--transition);
        }

        .hex-input:focus {
            border-color: var(--accent-primary);
            outline: none;
            box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
        }

        /* Help button styles */
        .help-btn {
            position: absolute;
            top: var(--space-4);
            left: var(--space-4);
            width: 32px;
            height: 32px;
            border-radius: var(--radius-full);
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            color: var(--text-tertiary);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 5;
            transition: all var(--transition);
        }

        .help-btn:hover {
            background-color: var(--accent-primary);
            color: white;
        }

        /* Animate button styles */
        .animate-btn {
            position: absolute;
            top: var(--space-4);
            right: var(--space-4);
            width: 32px;
            height: 32px;
            border-radius: var(--radius-full);
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            color: var(--text-tertiary);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 5;
            transition: all var(--transition);
        }

        .animate-btn:hover {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            border-color: var(--accent-primary);
        }

        .animate-btn.active {
            background-color: var(--bg-tertiary);
            color: var(--text-tertiary);
            border-color: var(--accent-primary);
        }

        body.dark-theme .help-btn,
        body.dark-theme .animate-btn {
            color: var(--text-tertiary);
        }

        body.dark-theme .animate-btn.active {
            color: var(--text-tertiary);
        }

        body.dark-theme .help-btn:hover,
        body.dark-theme .animate-btn:hover {
            color: white;
        }

        /* Modal styles */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 100;
            overflow: auto;
            backdrop-filter: blur(4px);
        }

        .modal-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            max-width: 700px;
            width: 90%;
            background-color: var(--bg-secondary);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            border: 1px solid var(--border);
            animation: modalFadeIn 0.3s ease;
            max-height: 85vh;
            overflow-y: auto;
        }

        @keyframes modalFadeIn {
            from {
                opacity: 0;
                transform: translate(-50%, -50%) scale(0.9);
            }

            to {
                opacity: 1;
                transform: translate(-50%, -50%) scale(1);
            }
        }

        .modal-header {
            position: sticky;
            top: 0;
            z-index: 10;
            background-color: var(--bg-secondary);
            padding: var(--space-6);
            padding-bottom: 0; /* Tabs sit on the bottom border */
            display: flex;
            flex-direction: column;
            gap: var(--space-4);
            border-bottom: 1px solid var(--border);
        }

        .modal-header h2 {
            margin: 0;
            font-size: var(--text-xl);
        }

        .modal-header h2:not(.modal-app-name) {
            background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }

        .modal-app-name {
            font-family: 'BBHBartle', sans-serif;
            font-size: var(--text-xl);
            font-weight: 600;
            color: var(--text-primary);
        }

        body.dark-theme .modal-app-name {
            color: var(--text-tertiary);
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 24px;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 0;
            height: 32px;
            width: 32px;
            border-radius: var(--radius);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition);
        }

        .modal-close:hover {
            background-color: var(--bg-tertiary);
            color: var(--text-primary);
        }

        /* Modal Tabs */
        .modal-tabs {
            display: flex;
            gap: var(--space-2);
            margin-top: var(--space-4);
            margin-bottom: -1px; /* Overlap parent border */
        }

        .tab-btn {
            background: none;
            border: none;
            padding: var(--space-3) var(--space-4);
            cursor: pointer;
            color: var(--text-tertiary);
            border-bottom: 3px solid transparent;
            font-weight: 600;
            font-size: var(--text-base);
            transition: all var(--transition);
            border-radius: var(--radius) var(--radius) 0 0;
            position: relative;
        }

        .tab-btn:hover {
            color: var(--text-primary);
            background-color: var(--bg-tertiary);
        }

        .tab-btn.active {
            color: var(--accent-primary);
            border-bottom-color: var(--accent-primary);
            background-color: transparent;
        }

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

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

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

        .modal-body {
            padding: var(--space-8);
        }

        .modal-body h3 {
            font-size: var(--text-lg);
            font-weight: 700;
            color: var(--text-primary);
            margin: 0 0 var(--space-6) 0;
            line-height: 1.4;
        }

        .modal-body h4 {
            font-size: var(--text-base);
            font-weight: 600;
            color: var(--text-primary);
            margin: var(--space-6) 0 var(--space-3) 0;
            line-height: 1.5;
        }

        .modal-body h4:first-child {
            margin-top: 0;
        }

        .modal-body p {
            margin-bottom: var(--space-4);
            color: var(--text-secondary);
            line-height: 1.7;
            font-size: var(--text-base);
        }

        .modal-body ul,
        .modal-body ol {
            margin-bottom: var(--space-6);
            padding-left: var(--space-6);
            color: var(--text-secondary);
        }

        .modal-body li {
            margin-bottom: var(--space-3);
            line-height: 1.7;
        }

        .modal-body li strong {
            color: var(--text-primary);
            font-weight: 600;
        }

        .modal-body ul ul,
        .modal-body ol ol {
            margin-top: var(--space-2);
            margin-bottom: var(--space-2);
        }

        /* See Also Tab Styles */
        .see-also-list {
            max-height: 500px;
            overflow-y: auto;
            padding: 0;
            margin: 0 0 0 calc(-1 * var(--space-8));
            list-style: none;
        }

        .see-also-item {
            border-bottom: 1px solid var(--border);
            transition: background-color var(--transition);
        }

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

        .see-also-header {
            display: flex;
            align-items: center;
            padding: var(--space-4) var(--space-6) var(--space-4) var(--space-4);
            gap: var(--space-3);
            position: relative;
        }

        .see-also-icon {
            width: 40px;
            height: 40px;
            flex-shrink: 0;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            border: 2px solid transparent;
            transition: border-color var(--transition);
        }

        .see-also-icon img {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        .see-also-info {
            flex: 1;
            min-width: 0;
        }

        .see-also-name {
            font-weight: 600;
            color: var(--text-primary);
            font-size: var(--text-base);
            margin: 0;
            cursor: pointer;
            transition: color var(--transition);
            display: inline-block;
        }

        .see-also-link {
            text-decoration: none;
            color: inherit;
            display: flex;
            align-items: center;
            gap: var(--space-3);
            flex: 1;
            min-width: 0;
        }

        .see-also-link:hover .see-also-icon {
            border-color: #4b5563;
        }

        .see-also-link:hover .see-also-name {
            color: var(--accent-primary);
        }

        body.dark-theme .see-also-link:hover .see-also-icon {
            border-color: #e5e7eb;
        }

        .see-also-chevron {
            width: 32px;
            height: 32px;
            flex-shrink: 0;
            cursor: pointer;
            transition: transform var(--transition), background-color var(--transition);
            color: var(--text-tertiary);
            padding: 8px;
            border-radius: 8px;
            margin: -8px;
            background-color: transparent;
        }

        .see-also-chevron:hover {
            background-color: var(--bg-tertiary);
        }

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

        .see-also-description {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease, padding 0.3s ease;
            padding: 0 var(--space-4);
            color: var(--text-secondary);
            font-size: var(--text-sm);
            line-height: 1.6;
        }

        .see-also-description.expanded {
            max-height: 200px;
            padding: 0 var(--space-4) var(--space-4) var(--space-4);
            padding-left: calc(40px + var(--space-4) + var(--space-3));
        }

        .modal-footer {
            margin-top: var(--space-8);
            padding-top: var(--space-4);
            border-top: 1px solid var(--border);
            font-size: var(--text-xs);
            color: var(--text-tertiary);
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
        }

        .copyright-link {
            color: inherit;
            text-decoration: none;
            position: relative;
            transition: color 0.3s ease;
            cursor: pointer;
            display: inline-flex;
            justify-content: center;
        }

        .copyright-link:hover {
            color: var(--accent-primary);
        }

        /* Animated underline */
        .copyright-link::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 100%;
            height: 1px;
            background-color: var(--accent-primary);
            transform: scaleX(0);
            transform-origin: center;
            transition: transform 0.3s ease;
        }

        .copyright-link:hover::after {
            transform: scaleX(1);
        }

        /* Tooltip */
        .footer-tooltip {
            position: absolute;
            bottom: calc(100% + 10px);
            left: 50%;
            transform: translateX(-50%) translateY(5px);
            background-color: var(--text-primary);
            color: var(--bg-primary);
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 11px;
            white-space: nowrap;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
            transition-delay: 0s;
            box-shadow: var(--shadow);
            z-index: 100;
            font-weight: normal;
        }

        .footer-tooltip::after {
            content: '';
            position: absolute;
            top: 100%;
            left: 50%;
            margin-left: -5px;
            border-width: 5px;
            border-style: solid;
            border-color: var(--text-primary) transparent transparent transparent;
        }

        /* Tooltip show state with delay */
        .copyright-link:hover .footer-tooltip {
            opacity: 0.9;
            visibility: visible;
            transform: translateX(-50%) translateY(0);
            transition-delay: 1.2s;
        }

        .modal-body p,
        .modal-body ul {
            margin-bottom: var(--space-4);
            color: var(--text-primary);
        }

        .modal-body ul {
            padding-left: var(--space-6);
        }

        .modal-body li {
            margin-bottom: var(--space-2);
        }

        /* Modal Action Buttons */
        .modal-actions {
            display: flex;
            gap: var(--space-3);
            justify-content: center;
            margin-top: var(--space-8);
            margin-bottom: var(--space-6);
        }

        .modal-btn {
            display: inline-flex;
            align-items: center;
            gap: var(--space-2);
            padding: 10px 20px;
            font-size: var(--text-sm);
            font-weight: 500;
            border-radius: var(--radius);
            cursor: pointer;
            transition: all var(--transition);
            text-decoration: none;
            border: 1px solid var(--border);
            background: var(--bg-secondary);
            color: var(--text-primary);
            width: 210px;
            justify-content: center;
        }

        .modal-btn:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow);
            border-color: var(--accent-primary);
            color: var(--accent-primary);
        }

        .modal-btn:active {
            transform: translateY(0);
        }

        .modal-btn svg {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
        }

        .modal-btn-primary {
            background-color: var(--accent-tertiary) !important;
            color: white !important;
            border-color: transparent !important;
        }

        .modal-btn-primary:hover {
            background-color: var(--accent-tertiary) !important;
            color: white !important;
            border-color: transparent !important;
            filter: brightness(1.1);
        }

        /* Shortcuts List Styles */
        .shortcuts-list {
            display: flex;
            flex-direction: column;
            gap: var(--space-4);
        }

        .shortcut-category {
            margin-bottom: var(--space-2);
        }

        .shortcut-category-title {
            font-size: var(--text-sm);
            font-weight: 600;
            color: var(--text-secondary);
            margin-bottom: var(--space-2);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            padding-bottom: var(--space-1);
            border-bottom: 1px solid var(--border);
        }

        .shortcut-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--space-2) 0;
            border-bottom: 1px solid var(--border);
        }

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

        .shortcut-description {
            font-size: var(--text-sm);
            color: var(--text-primary);
        }

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

        .kbd {
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: 4px;
            padding: 2px 6px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            font-size: 11px;
            color: var(--text-primary);
            min-width: 20px;
            text-align: center;
            box-shadow: 0 1px 0 var(--border);
            display: inline-block;
            line-height: 1.4;
        }

        .kbd-separator {
            color: var(--text-tertiary);
            font-size: 12px;
        }

        /* Loading Screen */
        #app-loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: var(--bg-primary);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 10000;
            transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
        }

        #app-loading-screen.fade-out {
            opacity: 0;
            visibility: hidden;
        }

        .loading-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: var(--space-6);
        }

        .loading-logo-container {
            position: relative;
            width: 100px;
            height: 100px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .loading-blob {
            display: none;
        }

        @keyframes loading-blob-anim {
            0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; transform: rotate(0deg) scale(1); }
            33% { border-radius: 60% 40% 30% 70% / 50% 60% 50% 40%; transform: rotate(120deg) scale(1.1); }
            66% { border-radius: 40% 60% 50% 50% / 60% 40% 60% 40%; transform: rotate(240deg) scale(0.9); }
            100% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; transform: rotate(360deg) scale(1); }
        }

        .loading-logo-svg {
            width: 52px;
            height: 52px;
            z-index: 1;
            filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
            animation: loading-logo-pulse 2s infinite ease-in-out;
        }

        @keyframes loading-logo-pulse {
            0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1)); }
            50% { transform: scale(1.05); filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.15)); }
        }

        .loading-text {
            font-family: 'BBHBartle', sans-serif;
            font-size: var(--text-2xl);
            font-weight: 600;
            color: var(--text-primary);
            letter-spacing: 0.05em;
            margin: 0;
            text-align: center;
        }

        .loading-subtext {
            font-size: 10px;
            color: var(--text-tertiary);
            text-transform: uppercase;
            letter-spacing: 0.25em;
            margin-top: calc(-1 * var(--space-3));
            font-weight: 500;
        }

        .loading-progress-container {
            width: 120px;
            height: 2px;
            background-color: var(--bg-tertiary);
            border-radius: var(--radius-full);
            overflow: hidden;
            margin-top: var(--space-1);
        }

        .loading-progress-bar {
            width: 30%;
            height: 100%;
            background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
            border-radius: var(--radius-full);
            animation: loading-progress-anim 2s infinite ease-in-out;
        }

        @keyframes loading-progress-anim {
            0% { transform: translateX(-100%); width: 20%; }
            50% { width: 50%; }
            100% { transform: translateX(400%); width: 20%; }
        }

    

/* --- Split Block --- */


        .control-group-title {
            cursor: grab;
        }
        .control-group-title:active {
            cursor: grabbing;
        }
        .control-group-title svg {
            cursor: grab;
        }
        .control-group-title svg:active {
            cursor: grabbing;
        }
        .control-group.dragging {
            opacity: 0.4;
            transform: scale(0.98);
            transition: transform 0.1s;
        }

        /* Highlight the existing section divider AFTER the item */
        .control-group.drag-over-bottom + .section-divider {
            background-color: var(--accent-primary);
            height: 2px;
            opacity: 1;
            transform: scaleY(2);
        }

        /* Highlight the existing section divider BEFORE the item using :has() */
        .section-divider:has(+ .control-group.drag-over-top) {
            background-color: var(--accent-primary);
            height: 2px;
            opacity: 1;
            transform: scaleY(2);
        }

        /* Fallback for the very first item dragging over top */
        .controls-form > .control-group:first-of-type.drag-over-top {
            border-top: 2px solid var(--accent-primary);
            margin-top: -2px;
            border-top-left-radius: var(--radius);
            border-top-right-radius: var(--radius);
        }

        /* Fallback for the very last item dragging over bottom */
        .controls-form > .control-group:last-of-type.drag-over-bottom {
            border-bottom: 2px solid var(--accent-primary);
            margin-bottom: calc(var(--space-6) - 2px);
            border-bottom-left-radius: var(--radius);
            border-bottom-right-radius: var(--radius);
        }

        /* Floating Panels Portal */
        #floatingPanelsPortal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 1000;
        }

        #floatingPanelsPortal.dragging-active {
            pointer-events: auto;
        }

        /* Floating windows share the sidebar's surface and icon-button tokens. */
        .floating-panel {
            position: fixed;
            min-width: 260px;
            min-height: 200px;
            max-height: calc(100vh - 64px);
            display: flex;
            flex-direction: column;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow-lg);
            pointer-events: auto;
            overflow: hidden;
        }

        .floating-panel-header {
            display: flex;
            align-items: center;
            flex: 0 0 34px;
            height: 34px;
            min-width: 0;
            background: var(--bg-primary);
            box-shadow: inset 0 -1px var(--border);
            cursor: grab;
            user-select: none;
        }

        .floating-panel-header.drop-target {
            background: color-mix(in srgb, var(--accent-primary) 6%, var(--bg-primary));
        }

        .floating-grip {
            display: none;
            flex: 0 0 22px;
            height: 34px;
            align-items: center;
            justify-content: center;
            border-right: 1px solid var(--border);
            color: var(--text-secondary);
            cursor: grab;
            transition: color 0.15s ease, background-color 0.15s ease;
        }

        .floating-grip:hover {
            color: var(--accent-primary);
            background: var(--bg-tertiary);
        }

        .has-multiple-tabs .floating-grip { display: flex; }
        .floating-grip svg { width: 16px; height: 16px; }
        .floating-panel-header:active, .floating-grip:active { cursor: grabbing; }

        .floating-tab-row {
            display: flex;
            flex: 1 1 auto;
            min-width: 0;
            height: 34px;
            align-items: stretch;
            flex-wrap: nowrap;
            overflow-x: auto;
            overflow-y: hidden;
            scrollbar-width: none;
            scroll-behavior: auto;
        }

        .floating-tab-row::-webkit-scrollbar { display: none; }
        .floating-tab-row.moreBefore {
            mask-image: linear-gradient(to right, transparent, black 18px);
        }
        .floating-tab-row.moreAfter {
            mask-image: linear-gradient(to left, transparent, black 18px);
        }
        .floating-tab-row.moreBefore.moreAfter {
            mask-image: linear-gradient(to right, transparent, black 18px, black calc(100% - 18px), transparent);
        }

        .floating-tab, .floating-drop-preview {
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            height: 34px;
            flex: 0 0 auto;
            border-right: 1px solid var(--border);
            font-size: var(--text-xs);
            font-weight: 600;
            color: var(--text-secondary);
            cursor: pointer;
        }

        .floating-tab:not(.active):not(.floating-drop-preview) { width: 34px; padding: 0; }
        .floating-tab:not(.active):not(.floating-drop-preview) .floating-tab-label { display: none; }
        .floating-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .floating-tab.active {
            max-width: 180px;
            padding: 0 8px;
            background: var(--bg-secondary);
            color: var(--text-primary);
        }
        .floating-tab-label {
            min-width: 0;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .floating-tab > svg, .floating-drop-preview > svg,
        .floating-drag-chip > svg, .floating-drag-ghost > svg {
            width: 16px;
            height: 16px;
            flex: 0 0 16px;
        }
        .floating-tab.active > svg { color: var(--accent-primary); }
        .floating-tab.drag-source { display: none; }

        .floating-panel-header .panel-actions {
            display: flex;
            align-items: center;
            flex: 0 0 auto;
            gap: 2px;
            padding: 0 4px;
        }

        .panelHeaderBtn {
            width: 26px;
            height: 26px;
            flex: 0 0 26px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            border: 1px solid transparent;
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            transition: color .18s ease, background-color .18s ease;
        }
        .panelHeaderBtn:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }
        .panelHeaderBtn:active {
            background: color-mix(in srgb, var(--text-primary) 10%, var(--bg-tertiary));
        }
        .panelHeaderBtn:focus-visible, .floating-tab:focus-visible,
        .floating-resize-handle:focus-visible {
            outline: 2px solid var(--accent-primary);
            outline-offset: -2px;
        }
        .panelHeaderBtn:focus-visible { outline-offset: 2px; }
        .panelHeaderBtn svg { display: block; width: 16px; height: 16px; }
        .panelHeaderBtn .icon-expand { display: none; }
        .minimized .panelHeaderBtn .icon-collapse { display: none; }
        .minimized .panelHeaderBtn .icon-expand { display: inline-flex; }

        .floating-tab-close {
            display: none;
            width: 16px;
            height: 16px;
            flex: 0 0 16px;
            visibility: hidden;
        }
        .has-multiple-tabs .floating-tab.active .floating-tab-close { display: inline-flex; }
        .floating-tab:hover .floating-tab-close,
        .floating-tab:focus-within .floating-tab-close { visibility: visible; }
        .floating-tab-close svg { width: 12px; height: 12px; }
        .floating-tab-close:hover {
            background: color-mix(in srgb, var(--text-primary) 10%, var(--bg-tertiary));
        }
        .floating-panels-dragging .floating-tab-close { visibility: hidden !important; }

        .floating-panel-content {
            display: flex;
            flex-direction: column;
            flex: 1 1 auto;
            min-height: 0;
            overflow: auto;
            padding: var(--space-4);
        }
        .floating-pane.active {
            display: flex;
            flex-direction: column;
            flex: 1 1 auto;
            min-height: 0;
        }
        .floating-pane > .panel-content {
            display: flex;
            flex-direction: column;
            flex: 1 1 auto;
            overflow: visible;
            max-height: none;
        }
        /* The floating style list sizes with its window; retain the sidebar's saved cap. */
        .floating-panel-content:has(> .floating-pane.active #shapeMode-listbox) {
            overflow: hidden;
        }
        .floating-pane:has(#shapeMode-listbox) > .panel-content,
        .floating-pane #shapeMode-listbox,
        .floating-pane .control-item:has(#shapeMode-listbox),
        .floating-pane .dropdown-container:has(#shapeMode-listbox),
        .floating-pane .dropdown-row:has(#shapeMode-listbox) {
            display: flex;
            flex-direction: column;
            flex: 1 1 0;
            min-height: 0;
        }
        .floating-pane #shapeMode-listbox .listbox-search-wrap { flex: 0 0 auto; }
        .floating-pane .dropdown-row:has(#shapeMode-listbox) { align-items: stretch; }
        .floating-pane .control-item:has(#shapeMode-listbox) { margin-bottom: 0; }
        .floating-pane #shapeMode-options {
            flex: 1 1 0;
            max-height: none !important;
            overflow-y: auto;
        }
        .floating-pane #shapeMode-listbox .listbox-resize-handle { display: none; }
        .floating-pane[hidden], .floating-panel-content[hidden],
        .floating-resize-handle[hidden] { display: none; }
        .floating-panel.minimized { min-height: 0; height: auto !important; }
        .floating-panel-content::-webkit-scrollbar { width: 6px; }
        .floating-panel-content::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: var(--radius-sm);
        }
        .floating-resize-handle {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 16px;
            height: 16px;
            cursor: nwse-resize;
            background: linear-gradient(135deg, transparent 65%, var(--border) 65%, var(--border) 72%, transparent 72%, transparent 80%, var(--border) 80%, var(--border) 87%, transparent 87%);
        }
        .floating-resize-handle:hover {
            background: linear-gradient(135deg, transparent 65%, var(--accent-primary) 65%, var(--accent-primary) 72%, transparent 72%, transparent 80%, var(--accent-primary) 80%, var(--accent-primary) 87%, transparent 87%);
        }

        body.floating-panels-dragging, body.floating-panels-dragging * {
            cursor: grabbing !important;
            user-select: none !important;
        }
        .floating-drag-chip, .floating-drag-ghost {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 10px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: var(--bg-secondary);
            color: var(--text-primary);
            box-shadow: var(--shadow-lg);
            font-size: var(--text-xs);
            white-space: nowrap;
        }
        .floating-drag-chip[hidden], .floating-drag-ghost[hidden],
        .floating-drop-preview[hidden], .floating-dock-indicator[hidden] { display: none; }
        .floating-drop-preview {
            position: relative;
            max-width: 180px;
            padding: 0 8px;
            background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-secondary));
            color: var(--accent-primary);
            box-shadow: inset 0 2px var(--accent-primary);
            animation: floating-preview-enter .16s ease-out;
        }
        .floating-drop-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .floating-drag-count {
            border-radius: var(--radius-sm);
            padding: 1px 4px;
            background: var(--bg-tertiary);
            color: var(--text-secondary);
        }
        .floating-dock-indicator { background: var(--accent-primary); }
        @keyframes floating-preview-enter {
            from { max-width: 0; opacity: 0; }
            to { max-width: 180px; opacity: 1; }
        }
        @media (prefers-reduced-motion: reduce) {
            .floating-drop-preview { animation: none; }
        }

        /* Control Group Detached State */
        .control-group.detached {
            opacity: 0.5;
            pointer-events: none;
        }

        .control-group.detached .panel-content {
            display: none;
        }

        /* Panel header cursor for dragging */
        .control-group .panel-header {
            cursor: pointer;
        }

        .control-group .panel-header.dragging-to-undock {
            cursor: grabbing;
        }

        /* Drag Preview/Placeholder */
        .drag-preview {
            position: fixed;
            pointer-events: none;
            z-index: 1001;
            opacity: 0.9;
            transform: rotate(2deg);
        }

        /* App overlay during drag to suppress hover previews */
        #dragOverlay {
            position: fixed;
            inset: 0;
            z-index: 999;
            pointer-events: none;
            background: transparent;
        }

        #dragOverlay.active {
            pointer-events: auto;
        }

        .sr-only {
            position: absolute !important;
            width: 1px !important;
            height: 1px !important;
            padding: 0 !important;
            margin: -1px !important;
            overflow: hidden !important;
            clip: rect(0, 0, 0, 0) !important;
            white-space: nowrap !important;
            border: 0 !important;
        }

        .favorite-btn:focus-visible {
            opacity: 1;
            outline: 2px solid currentColor;
            outline-offset: 2px;
        }

        .listbox-option.active-descendant:not([aria-selected="true"]) {
            box-shadow: inset 0 0 0 2px var(--accent-primary);
        }

        @media (prefers-reduced-motion: reduce) {
            *,
            *::before,
            *::after {
                scroll-behavior: auto !important;
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
                transition-delay: 0ms !important;
            }
        }
    

        /* ------------------------------------------------------------------
           Startup home screen
           ------------------------------------------------------------------ */
        .home-screen {
            --home-ease: cubic-bezier(0.22, 1, 0.36, 1);
            position: fixed;
            inset: 0;
            z-index: 2000;
            background: var(--bg-primary);
            color: var(--text-primary);
            overflow-x: hidden;
            overflow-y: auto;
            transition: opacity 380ms ease, transform 520ms var(--home-ease), visibility 380ms;
        }

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

        .home-screen.is-leaving {
            opacity: 0;
            transform: scale(1.03);
            visibility: hidden;
            pointer-events: none;
        }

        .home-screen *,
        .home-screen button {
            cursor: default;
        }

        .home-screen button,
        .home-screen label,
        .home-screen input {
            cursor: pointer;
        }

        .home-screen button * {
            cursor: inherit;
        }

        /* Dot grid echoing the editor canvas, faded toward the edges. */
        .home-backdrop {
            position: fixed;
            inset: 0;
            pointer-events: none;
            background:
                radial-gradient(60% 55% at 78% 34%, color-mix(in srgb, var(--accent-primary) 13%, transparent), transparent 70%),
                radial-gradient(45% 40% at 96% 78%, color-mix(in srgb, var(--accent-secondary) 10%, transparent), transparent 70%);
        }

        .home-backdrop::after {
            content: '';
            position: absolute;
            inset: 0;
            background-image: radial-gradient(circle, color-mix(in srgb, var(--text-primary) 22%, transparent) 1px, transparent 1.4px);
            background-size: 22px 22px;
            -webkit-mask-image: radial-gradient(75% 70% at 72% 40%, #000 0%, transparent 78%);
            mask-image: radial-gradient(75% 70% at 72% 40%, #000 0%, transparent 78%);
            opacity: 0.55;
        }

        .home-shell {
            position: relative;
            display: flex;
            flex-direction: column;
            gap: clamp(20px, 3.2vh, 40px);
            width: min(1180px, 100%);
            min-height: 100%;
            margin: 0 auto;
            padding: clamp(20px, 3.5vh, 36px) clamp(24px, 5vw, 56px) clamp(16px, 2.5vh, 28px);
        }

        .home-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: var(--space-4);
        }

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

        .home-brand-icon {
            width: 28px;
            height: 28px;
            background: url('icons/app-icon-2.svg') center / contain no-repeat;
        }

        .home-brand-name {
            font-family: 'BBHBartle', sans-serif;
            font-size: 1.05rem;
            letter-spacing: 0.04em;
        }

        .home-brand-version {
            padding: 2px 8px;
            border: 1px solid var(--border);
            border-radius: var(--radius-full);
            font-size: 11px;
            font-variant-numeric: tabular-nums;
            color: var(--text-tertiary);
        }

        .home-skip,
        .home-link {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 4px;
            border: 0;
            background: none;
            font: inherit;
            font-size: var(--text-sm);
            color: var(--text-secondary);
            border-radius: var(--radius-sm);
            transition: color var(--transition);
            white-space: nowrap;
        }

        .home-skip:hover,
        .home-link:hover {
            color: var(--text-primary);
        }

        .home-skip kbd {
            padding: 1px 6px;
            border: 1px solid var(--border);
            border-bottom-width: 2px;
            border-radius: 6px;
            font: inherit;
            font-size: 11px;
            color: var(--text-tertiary);
            background: var(--bg-secondary);
        }

        .home-link {
            color: var(--accent-primary);
            font-weight: 600;
        }

        body.dark-theme .home-link {
            color: #a5b4fc;
        }

        .home-main {
            flex: 1 1 auto;
            display: grid;
            grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
            align-items: center;
            gap: clamp(16px, 4vw, 56px);
            min-height: 0;
        }

        .home-intro {
            container-type: inline-size;
            min-width: 0;
        }

        .home-eyebrow {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            margin-bottom: clamp(12px, 2vh, 20px);
            font-size: 11px;
            font-weight: 600;
            letter-spacing: 0.22em;
            text-transform: uppercase;
            color: var(--text-secondary);
        }

        .home-eyebrow::before {
            content: '';
            width: 28px;
            height: 2px;
            border-radius: 2px;
            background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
        }

        .home-title {
            font-family: 'BBHBartle', sans-serif;
            font-weight: 400;
            font-size: clamp(2.25rem, min(12cqi, 13vh), 6rem);
            line-height: 0.98;
            letter-spacing: -0.01em;
        }

        .home-lede {
            max-width: 44ch;
            margin-top: clamp(14px, 2.4vh, 24px);
            font-size: clamp(0.95rem, 1.25vw, 1.0625rem);
            line-height: 1.6;
            color: var(--text-secondary);
        }

        .home-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: clamp(20px, 3.4vh, 36px);
        }

        .home-cta {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            min-height: 48px;
            padding: 0 18px;
            border: 1px solid var(--border);
            border-radius: 14px;
            background: color-mix(in srgb, var(--bg-secondary) 82%, transparent);
            -webkit-backdrop-filter: blur(8px);
            backdrop-filter: blur(8px);
            color: var(--text-primary);
            font: inherit;
            font-size: var(--text-sm);
            font-weight: 600;
            white-space: nowrap;
            transition: transform 220ms var(--home-ease), border-color var(--transition), background-color var(--transition), box-shadow var(--transition);
        }

        .home-cta svg {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            color: var(--text-secondary);
        }

        .home-cta:hover {
            transform: translateY(-1px);
            border-color: color-mix(in srgb, var(--text-primary) 28%, var(--border));
            box-shadow: var(--shadow);
        }

        .home-cta:active {
            transform: translateY(0) scale(0.985);
        }

        .home-cta-primary {
            padding: 0 16px 0 20px;
            border-color: transparent;
            background: var(--text-primary);
            color: var(--bg-primary);
            -webkit-backdrop-filter: none;
            backdrop-filter: none;
        }

        .home-cta-primary:hover {
            border-color: transparent;
            box-shadow: 0 10px 28px -10px color-mix(in srgb, var(--accent-primary) 70%, transparent);
        }

        .home-cta-meta {
            padding-left: 10px;
            border-left: 1px solid color-mix(in srgb, currentColor 28%, transparent);
            font-weight: 500;
            opacity: 0.72;
        }

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

        .home-cta-primary .home-cta-arrow {
            color: inherit;
            transition: transform 260ms var(--home-ease);
        }

        .home-cta-primary:hover .home-cta-arrow {
            transform: translateX(3px);
        }

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

        .home-hero {
            position: relative;
            justify-self: center;
            width: min(100%, 52vh, 520px);
            aspect-ratio: 1;
        }

        .home-hero svg {
            display: block;
            width: 100%;
            height: 100%;
            overflow: visible;
            filter: drop-shadow(0 30px 50px color-mix(in srgb, var(--accent-primary) 28%, transparent));
        }

        .home-shelves {
            display: grid;
            gap: clamp(14px, 2.2vh, 22px);
            min-width: 0;
        }

        .home-shelf { min-width: 0; }

        .home-shelf-head {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: var(--space-4);
            margin-bottom: 10px;
        }

        .home-shelf-head h2 {
            font-size: 11px;
            font-weight: 600;
            letter-spacing: 0.18em;
            text-transform: uppercase;
            color: var(--text-tertiary);
        }

        .home-shelf-head .home-link {
            padding: 0 2px;
            font-size: var(--text-xs);
        }

        .home-styles {
            display: flex;
            gap: 10px;
            min-width: 0;
            overflow-x: auto;
            overscroll-behavior-x: contain;
            scroll-snap-type: x proximity;
            scroll-padding-inline: 4px;
            padding: 6px 4px 12px;
            scrollbar-width: thin;
            scrollbar-color: var(--border) transparent;
        }

        .home-carousel-actions { display: flex; align-items: center; gap: 8px; }
        .home-carousel-progress { color: var(--text-tertiary); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .home-carousel-arrow { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer; }
        .home-carousel-arrow:hover:enabled { border-color: var(--accent-primary); color: var(--text-primary); }
        .home-carousel-arrow:disabled { opacity: 0.3; cursor: default; }
        .home-styles::-webkit-scrollbar { height: 5px; }
        .home-styles::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }

        .home-tile {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            min-width: 0;
            flex: 0 0 120px;
            scroll-snap-align: start;
            padding: 14px 8px 10px;
            border: 1px solid var(--border);
            border-radius: 14px;
            background: color-mix(in srgb, var(--bg-secondary) 80%, transparent);
            color: var(--text-secondary);
            font: inherit;
            font-size: var(--text-xs);
            font-weight: 500;
            transition: transform 260ms var(--home-ease), border-color var(--transition), color var(--transition), box-shadow var(--transition), background-color var(--transition);
        }

        .home-tile svg {
            width: clamp(30px, 4.4vh, 44px);
            height: clamp(30px, 4.4vh, 44px);
            overflow: visible;
            opacity: 0.78;
            transition: transform 420ms var(--home-ease), opacity var(--transition);
        }

        .home-tile .home-tile-shape {
            fill: var(--text-primary);
            transition: fill var(--transition);
        }

        .home-tile span {
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .home-tile:hover,
        .home-tile:focus-visible {
            transform: translateY(-3px);
            border-color: color-mix(in srgb, var(--accent-primary) 55%, var(--border));
            background: var(--bg-secondary);
            color: var(--text-primary);
            box-shadow: 0 14px 26px -16px color-mix(in srgb, var(--accent-primary) 80%, transparent);
        }

        .home-tile:hover svg,
        .home-tile:focus-visible svg {
            opacity: 1;
            transform: rotate(18deg) scale(1.08);
        }

        .home-tile:hover .home-tile-shape,
        .home-tile:focus-visible .home-tile-shape {
            fill: url(#homeHeroGradient);
        }

        .home-presets {
            display: flex;
            gap: 10px;
            overflow-x: auto;
            padding-bottom: 2px;
            scrollbar-width: none;
        }

        .home-presets::-webkit-scrollbar {
            display: none;
        }

        .home-preset {
            flex: 0 0 auto;
            display: flex;
            align-items: center;
            gap: 10px;
            max-width: 200px;
            padding: 6px 14px 6px 6px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: color-mix(in srgb, var(--bg-secondary) 80%, transparent);
            color: var(--text-primary);
            font: inherit;
            font-size: var(--text-xs);
            font-weight: 500;
            transition: transform 220ms var(--home-ease), border-color var(--transition), box-shadow var(--transition);
        }

        .home-preset:hover {
            transform: translateY(-2px);
            border-color: color-mix(in srgb, var(--accent-primary) 55%, var(--border));
            box-shadow: var(--shadow);
        }

        .home-preset-thumb {
            flex: 0 0 auto;
            display: grid;
            place-items: center;
            width: 36px;
            height: 36px;
            border-radius: 8px;
            background: var(--bg-tertiary);
            overflow: hidden;
        }

        .home-preset-thumb img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            pointer-events: none;
        }

        .home-preset span:last-child {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .home-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: var(--space-4);
            padding-top: clamp(10px, 1.6vh, 16px);
            border-top: 1px solid var(--border);
            font-size: var(--text-xs);
            color: var(--text-tertiary);
        }

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

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

        /* Entrance: one staggered rise, triggered when the loading screen lifts. */
        .home-screen [data-reveal] {
            opacity: 0;
        }

        .home-screen.is-ready [data-reveal] {
            animation: home-rise 720ms var(--home-ease) both;
            animation-delay: calc(var(--i, 0) * 70ms);
        }

        .home-screen.is-ready .home-hero[data-reveal] {
            animation-name: home-bloom;
            animation-duration: 1100ms;
        }

        @keyframes home-rise {
            from { opacity: 0; transform: translateY(16px); }
            to { opacity: 1; transform: none; }
        }

        @keyframes home-bloom {
            from { opacity: 0; transform: scale(0.82) rotate(-10deg); }
            to { opacity: 1; transform: none; }
        }

        @media (max-width: 860px) {
            .home-main {
                grid-template-columns: 1fr;
            }

            .home-hero {
                position: absolute;
                top: 40px;
                right: -22%;
                width: min(78vw, 420px);
                opacity: 0.32;
                pointer-events: none;
                z-index: -1;
            }

            .home-screen.is-ready .home-hero[data-reveal] {
                animation-name: home-bloom-faint;
                opacity: 0.32;
            }

            .home-styles .home-tile { flex-basis: 108px; }
            .home-carousel-actions .home-link { display: none; }
        }

        @keyframes home-bloom-faint {
            from { opacity: 0; transform: scale(0.82) rotate(-10deg); }
            to { opacity: 0.32; transform: none; }
        }

        @media (max-width: 520px) {
            .home-carousel-progress { display: none; }
            .home-skip kbd {
                display: none;
            }

            .home-cta {
                flex: 1 1 100%;
                justify-content: center;
            }
        }

        @media (max-height: 640px) and (min-width: 861px) {
            .home-lede {
                display: none;
            }
        }

        @media (prefers-reduced-motion: reduce) {
            .home-screen,
            .home-screen * {
                transition-duration: 0.01ms !important;
            }

            .home-screen.is-ready [data-reveal] {
                animation: none;
                opacity: 1;
            }

            .home-screen.is-ready .home-hero[data-reveal] {
                animation: none;
            }
        }

/* About / Help: one fixed shell with a scroll area for each tab. */
#helpModal { background: rgb(9 10 18 / 60%); backdrop-filter: blur(10px); overflow: hidden; }
#helpModal.show { animation: helpOverlayIn 180ms ease; }
#helpModal .modal-content { display: flex; flex-direction: column; width: min(720px, calc(100% - 32px)); height: min(820px, 85dvh); max-height: 85dvh; max-width: 720px; overflow: hidden; border-radius: 22px; box-shadow: 0 24px 100px rgb(0 0 0 / 30%); }
#helpModal .modal-header { position: static; flex: 0 0 auto; padding: 24px 28px 16px; gap: 20px; background: var(--bg-secondary); }
#helpModal .help-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#helpModal .help-brand { display: flex; align-items: center; gap: 12px; }
#helpModal .help-brand-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-secondary)); border: 1px solid color-mix(in srgb, var(--accent-primary) 22%, var(--border)); }
#helpModal .help-brand-icon .app-icon { width: 28px; height: 28px; margin: 0; pointer-events: none; }
#helpModal .modal-app-name { color: var(--text-primary); font-size: 21px; line-height: 1.25; }
#helpModal .help-version { display: block; margin-top: 4px; color: var(--text-tertiary); font-size: 11px; font-variant-numeric: tabular-nums; }
#helpModal .modal-close { width: 36px; height: 36px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 50%; color: var(--text-secondary); transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
#helpModal .modal-close svg { width: 20px; height: 20px; flex-shrink: 0; pointer-events: none; }
@media (hover: hover) {
    #helpModal .modal-close:hover { background: color-mix(in srgb, var(--accent-primary) 14%, var(--bg-secondary)); border-color: color-mix(in srgb, var(--accent-primary) 55%, var(--border)); color: var(--accent-primary); box-shadow: 0 2px 8px rgb(0 0 0 / 12%); transform: translateY(-1px); }
}
#helpModal .modal-close:active { transform: scale(.94); box-shadow: none; }
@media (prefers-reduced-motion: reduce) {
    #helpModal .modal-close { transition: none; }
    #helpModal .modal-close:hover, #helpModal .modal-close:active { transform: none; }
}
#helpModal .modal-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin: 0; padding: 4px; border-radius: 11px; background: var(--bg-tertiary); }
#helpModal .tab-btn { padding: 10px 6px; border: 0; border-radius: 8px; font-size: 12px; font-weight: 500; white-space: nowrap; }
#helpModal .tab-btn.active { color: var(--text-primary); background: var(--bg-secondary); box-shadow: 0 1px 4px rgb(0 0 0 / 9%); }
#helpModal :is(button, a):focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
#helpModal .modal-body { flex: 1; min-height: 0; padding: 0; overflow: hidden; }
#helpModal .tab-pane { height: 100%; min-height: 0; }
#helpModal .tab-pane.active { display: flex; flex-direction: column; }
#helpModal .modal-tab-content-inner { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 28px; scroll-behavior: smooth; }
#helpModal .help-eyebrow { display: block; margin-bottom: 12px; font-size: 10px; font-weight: 600; letter-spacing: .13em; color: var(--accent-primary); }
#helpModal .modal-body h3 { margin: 0 0 14px; font-size: 26px; line-height: 1.2; letter-spacing: -.035em; }
#helpModal .help-intro { padding: 24px; border: 1px solid color-mix(in srgb, var(--accent-primary) 24%, var(--border)); border-radius: 16px; background: radial-gradient(ellipse at top right, color-mix(in srgb, var(--accent-primary) 12%, transparent), transparent 75%); }
#helpModal .help-intro h3 { font-size: 36px; font-weight: 600; }
#helpModal .modal-body h4 { margin: 28px 0 12px; font-size: 15px; letter-spacing: -.01em; }
#helpModal .modal-body h5 { margin: 18px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-primary); }
#helpModal .modal-body :is(p, li) { color: var(--text-secondary); font-size: 13px; line-height: 1.7; }
#helpModal .modal-body p { margin: 0 0 12px; }
#helpModal .modal-body :is(ul, ol) { padding-left: 20px; margin: 0 0 18px; }
#helpModal .modal-body li { margin-bottom: 9px; padding-left: 3px; }
#helpModal .modal-body strong { font-weight: 600; color: var(--text-primary); }
#helpModal .help-format-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
#helpModal .help-format-tags span { padding: 4px 8px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 5px; color: var(--text-secondary); font-size: 10px; font-weight: 500; }
#helpModal .help-features { list-style: none; padding: 0; }
#helpModal .help-features li { padding: 0 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
#helpModal .help-steps li::marker { color: var(--accent-primary); font-weight: 600; }
#helpModal .modal-highlight-box { margin: 20px 0 0; padding: 16px 18px; border-left: 3px solid var(--accent-primary); border-radius: 0 10px 10px 0; background: color-mix(in srgb, var(--accent-primary) 7%, var(--bg-secondary)); font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
#helpModal #tab-license .modal-highlight-box + p { margin-top: 18px; }
#helpModal .help-guide-index { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; }
#helpModal .help-guide-index button { border: 0; cursor: pointer; font-family: inherit; padding: 6px 10px; background: var(--bg-tertiary); border-radius: 7px; font-size: 11px; color: var(--text-secondary); text-decoration: none; }
#helpModal .help-guide-index button:hover { color: var(--accent-primary); }
#helpModal .modal-body section { scroll-margin-top: 20px; }
#helpModal .modal-tip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#helpModal .modal-tip-item { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-tertiary); font-size: 12px; }
#helpModal .modal-tip-item p { margin: 6px 0 0; font-size: 12px; }
#helpModal .help-sticky-footer { flex: 0 0 auto; padding: 16px 28px 18px; background: var(--bg-secondary); border-top: 1px solid var(--border); }
#helpModal .help-sticky-footer[hidden] { display: none; }
#helpModal .modal-actions { margin: 0; gap: 10px; }
#helpModal .modal-btn { flex: 1; width: auto; padding: 11px 12px; font-size: 12px; border-radius: 9px; }
#helpModal .modal-btn-primary { background: var(--accent-primary) !important; }
#helpModal .modal-footer { padding: 12px 0 0; margin: 0; border: 0; text-align: center; }
#helpModal .copyright-badge { width: auto; height: auto; display: inline-block; color: var(--text-tertiary); font-size: 10px; text-decoration: none; }
#helpModal .copyright-badge strong { color: var(--text-secondary); font-weight: 500; }
#helpModal .shortcuts-list { gap: 18px; }
#helpModal .shortcut-category { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-tertiary); }
#helpModal .shortcut-category-title { margin: 0 0 8px; padding: 0 0 8px; font-size: 10px; letter-spacing: .09em; }
#helpModal .shortcut-item { gap: 14px; padding: 9px 0; }
#helpModal .shortcut-description { font-size: 12px; }
#helpModal kbd { font-family: inherit; font-size: 11px; }
#helpModal .shortcut-keys { flex-shrink: 0; }
#helpModal .see-also-list { margin: 20px 0 0; padding: 0; max-height: none; overflow: visible; list-style: none; display: grid; gap: 10px; }
#helpModal .see-also-item { margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
#helpModal .see-also-header { padding: 14px 16px; }
#helpModal .see-also-name { margin: 0; font-size: 13px; }
#helpModal .see-also-chevron { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; padding: 7px; margin: 0; }
#helpModal .see-also-chevron svg { width: 18px; height: 18px; }
#helpModal .see-also-description { max-height: none; padding: 0 16px 16px 68px; font-size: 12px; line-height: 1.7; color: var(--text-secondary); }
#helpModal .see-also-description[hidden] { display: none; }
@keyframes helpOverlayIn { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 600px) {
    #helpModal .modal-content { width: calc(100% - 20px); height: 90dvh; max-height: 90dvh; border-radius: 16px; }
    #helpModal .modal-header { padding: 18px 16px 12px; gap: 16px; }
    #helpModal .modal-tab-content-inner { padding: 20px 16px; }
    #helpModal .tab-btn { padding: 10px 3px; font-size: 10px; }
    #helpModal .help-intro { padding: 18px; }
    #helpModal .help-intro h3 { font-size: 30px; }
    #helpModal .help-sticky-footer { padding: 12px 16px 14px; }
    #helpModal .modal-btn { padding: 10px 8px; font-size: 10px; gap: 6px; }
    #helpModal .modal-tip-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    #helpModal.show, #helpModal .modal-content, #helpModal .tab-pane { animation: none; }
    #helpModal .modal-tab-content-inner { scroll-behavior: auto; }
}

#helpModal .modal-tab-content-inner:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: -3px; }

        .style-mode-thumbnail .home-tile-shape.home-tile-rings,
        .home-tile .home-tile-shape.home-tile-rings { fill: none; stroke: currentColor; }
        .home-tile:hover .home-tile-shape.home-tile-rings,
        .home-tile:focus-visible .home-tile-shape.home-tile-rings { fill: none; stroke: var(--accent-primary); }
