 * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --bg: #F9FAFB;
            --card: white;
            --text: #111827;
            --text-light: #6B7280;
            --border: #E5E7EB;
            --primary: #2563EB;
            --primary-hover: #1D4ED8;
            --success: #059669;
            --success-hover: #047857;
            --danger: #DC2626;
            --danger-hover: #B91C1C;
            --warning: #D97706;
            --radius: 0.75rem;
            --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }

        body.dark {
            --bg: #0F172A;
            --card: #1E293B;
            --text: #F1F5F9;
            --text-light: #94A3B8;
            --border: #334155;
        }

        body {
            background: var(--bg);
            color: var(--text);
            font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            padding: 2rem 1.5rem;
            line-height: 1.5;
        }

        .container { max-width: 1200px; margin: 0 auto; }
        .card {
            background: var(--card);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 1.5rem;
            margin-bottom: 1.25rem;
            border: 1px solid var(--border);
        }
        .header-flex {
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 1rem;
        }
        .upload-area {
            border: 2px dashed var(--border);
            border-radius: var(--radius);
            padding: 3rem 2rem;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .upload-area:hover {
            border-color: var(--primary);
            background: rgba(37, 99, 235, 0.02);
        }
        .grid-controls {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 1rem;
            margin-top: 1rem;
        }
        label {
            display: block;
            font-size: 0.75rem;
            font-weight: 600;
            margin-bottom: 0.25rem;
            color: var(--text-light);
            text-transform: uppercase;
        }
        input, button {
            font-family: inherit;
            font-size: 0.9rem;
            background: var(--bg);
            border: 1px solid var(--border);
            padding: 0.5rem 0.7rem;
            border-radius: 0.5rem;
            color: var(--text);
            width: 100%;
        }
        button {
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            cursor: pointer;
            border: none;
            width: auto;
        }
        .btn-primary { background: var(--primary); color: white; }
        .btn-primary:hover { background: var(--primary-hover); }
        .btn-success { background: var(--success); color: white; }
        .btn-success:hover { background: var(--success-hover); }
        .btn-secondary {
            background: var(--card);
            color: var(--text);
            border: 1px solid var(--border);
        }
        .btn-secondary:hover {
            background: var(--bg);
            border-color: var(--text-light);
        }
        button:disabled {
            background: var(--border) !important;
            cursor: not-allowed;
            opacity: 0.6;
        }
        .action-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 1rem;
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid var(--border);
        }
        .preview-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1.5rem;
            margin-top: 1rem;
        }
        .preview-box {
            background: var(--bg);
            border-radius: var(--radius);
            padding: 1rem;
            border: 1px solid var(--border);
        }
        .preview-wrapper {
            min-height: 260px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #fff;
            border-radius: 0.5rem;
            overflow: hidden;
            padding: 0.5rem;
        }
        .preview-wrapper img, .preview-wrapper svg {
            max-width: 100%;
            max-height: 280px;
            object-fit: contain;
        }
        .badge {
            background: rgba(37, 99, 235, 0.1);
            color: var(--primary);
            padding: 0.2rem 0.7rem;
            border-radius: 2rem;
            font-size: 0.7rem;
            font-weight: 600;
        }
        .palette-preview {
            display: flex;
            flex-wrap: wrap;
            gap: 0.3rem;
            margin-top: 0.5rem;
            padding: 0.5rem;
            background: var(--bg);
            border-radius: 0.5rem;
        }
        .color-swatch {
            width: 32px;
            height: 32px;
            border-radius: 0.3rem;
            border: 1px solid var(--border);
        }
        .toast {
            position: fixed;
            bottom: 1.5rem;
            right: 1.5rem;
            background: #111827;
            color: white;
            padding: 0.6rem 1.2rem;
            border-radius: 0.5rem;
            font-size: 0.85rem;
            opacity: 0;
            transition: 0.2s;
            z-index: 1000;
        }
        .toast.show { opacity: 1; }
        @media (max-width: 768px) {
            body { padding: 1rem; }
            .preview-grid { grid-template-columns: 1fr; }
            .action-bar { flex-direction: column; align-items: stretch; }
            button { width: 100%; }
        }