 cfg);
      document.querySelector('canvas').style.background = state.canvasBg;
      const typeName = state.chartType.charAt(0).toUpperCase() + state.chartType.slice(1);
      setShapeNote(`${typeName} chart`);
    }

    
    async function handleText(text) {
      state.rawText = text;
      if (!text || !text.trim()) { setStatus('Empty file'); return; }
      const delim = state.delimiter === 'auto' ? detectDelimiter(text) : state.delimiter;
      const rows = parseCSV(text, delim);
      if (!rows || 