// MENTESH MT-SAT · Multiband Saturation — styled after FabFilter Saturn as a 3U rack unit
// Top preset strip, large frequency-analyzer display with colored crossover points,
// master Drive/Mix sidebars, and five multiband columns with Drive/Feedback/Mix + effect type.

function SaturationInsert({ enabled = true, onToggleEnabled, variant = {} }) {
  const [preset, setPreset] = React.useState(2);
  const presets = [
    'Warm Tape', 'Aggressive Drums', 'Big Honey', 'Broken Radio', 'Subtle Glue',
    'Tube Bass', 'Bright Air', 'Console Sat', 'Lo-Fi Crush',
  ];
  const bandColors = ['#4aa3ff', '#f0c23a', '#5fd27a', '#b77cff', '#ff7aa8'];
  const bandNames = ['LOW', 'LO-MID', 'MID', 'HI-MID', 'HIGH'];
  const effectList = ['TAPE', 'TUBE', 'AMP', 'DISTORTION', 'SATURATION', 'BIT CRUSH', 'DELAY SM', 'DELAY LG'];

  // per-band state: drive, feedback, mix, type idx, solo
  const [bands, setBands] = React.useState(() =>
    [0.4, 0.55, 0.6, 0.45, 0.35].map((d, i) => ({
      drive: d,
      feedback: 0.3 + i * 0.04,
      mix: 0.7 - i * 0.05,
      type: i % effectList.length,
      solo: false,
    }))
  );
  const [masterDrive, setMasterDrive] = React.useState(0.55);
  const [masterMix, setMasterMix] = React.useState(0.85);
  const [bandwidth, setBandwidth] = React.useState(0.55);
  const [dynamics, setDynamics] = React.useState(0.4);

  const updateBand = (i, patch) =>
    setBands(bs => bs.map((b, j) => j === i ? { ...b, ...patch } : b));

  return (
    <div style={{
      width: 1400,
      // 3U-ish
      background: '#0a0c12',
      position: 'relative',
      fontFamily: "'Inter','Helvetica Neue',sans-serif",
      color: '#d8e0ea',
      filter: enabled ? 'none' : 'brightness(0.55) saturate(0.5)',
      transition: 'filter 220ms',
      userSelect: 'none',
    }}>
      <SatRackEars />

      {/* main panel */}
      <div style={{
        margin: '0 54px',
        background: 'linear-gradient(180deg, #151a22 0%, #0e1218 60%, #0a0c12 100%)',
        border: '1px solid rgba(255,255,255,0.04)',
        borderRadius: 2,
        overflow: 'hidden',
      }}>
        <SatTopStrip preset={preset} setPreset={setPreset} presets={presets} />

        {/* middle: sidebars + display */}
        <div style={{ display: 'grid', gridTemplateColumns: '210px 1fr 210px', gap: 0 }}>
          <SatLeftSidebar drive={masterDrive} setDrive={setMasterDrive} />
          <SatDisplay bandColors={bandColors} bands={bands} />
          <SatRightSidebar mix={masterMix} setMix={setMasterMix}
            bandwidth={bandwidth} setBandwidth={setBandwidth}
            dynamics={dynamics} setDynamics={setDynamics} />
        </div>

        {/* bottom: 5 bands */}
        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)',
          background: 'linear-gradient(180deg, #0c1017 0%, #0a0c12 100%)',
          borderTop: '1px solid rgba(255,255,255,0.05)',
        }}>
          {bands.map((b, i) => (
            <SatBandColumn key={i} color={bandColors[i]} name={bandNames[i]}
              band={b} effectList={effectList}
              onChange={patch => updateBand(i, patch)}
              borderRight={i < 4} />
          ))}
        </div>

        <SatFooter />
      </div>
    </div>
  );
}

// ——— TOP STRIP ———————————————————————————————————————————————
function SatTopStrip({ preset, setPreset, presets }) {
  return (
    <div style={{
      height: 44,
      display: 'flex', alignItems: 'center',
      background: 'linear-gradient(180deg, #1a2230 0%, #131924 100%)',
      borderBottom: '1px solid rgba(0,0,0,0.5)',
      boxShadow: 'inset 0 -1px 0 rgba(255,255,255,0.04)',
      padding: '0 16px',
      gap: 14,
    }}>
      {/* mentesh logo block */}
      <div style={{
        display: 'flex', alignItems: 'center', gap: 10,
      }}>
        <div style={{
          width: 30, height: 30, borderRadius: '50%',
          border: '1.4px solid rgba(255,255,255,0.5)',
          background: 'radial-gradient(circle at 35% 30%, #2a3344 0%, #131924 100%)',
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          fontFamily: "'Playfair Display',serif", fontStyle: 'italic',
          fontSize: 14, fontWeight: 900, color: '#e8eef5',
          boxShadow: 'inset 0 1px 0 rgba(255,255,255,0.15), 0 1px 2px rgba(0,0,0,0.5)',
          lineHeight: 1,
        }}>ME</div>
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1 }}>
          <span style={{
            fontFamily: "'Playfair Display',serif", fontStyle: 'italic',
            fontWeight: 500, fontSize: 22, color: '#e8eef5',
            letterSpacing: '0.01em',
            lineHeight: 1,
          }}>ME.SATURATOR</span>
          <span style={{
            fontFamily: "'Inter',sans-serif", fontWeight: 600,
            fontSize: 8, letterSpacing: '0.18em', color: 'rgba(201,212,227,0.7)',
            lineHeight: 1,
          }}>MENTESH ENGINEERING</span>
        </div>
      </div>

      <div style={{ flex: 1 }} />

      {/* preset navigator */}
      <button onClick={() => setPreset(p => (p - 1 + presets.length) % presets.length)}
        style={navBtn}>‹‹</button>
      <button onClick={() => setPreset(p => (p - 1 + presets.length) % presets.length)}
        style={navBtn}>‹</button>
      <div style={{
        minWidth: 280, padding: '6px 16px', textAlign: 'center',
        background: 'rgba(0,0,0,0.35)',
        border: '1px solid rgba(255,255,255,0.06)',
        borderRadius: 3,
        fontSize: 12, letterSpacing: '0.04em',
        color: '#d8e0ea',
      }}>
        <span style={{ opacity: 0.5, marginRight: 10 }}>NO</span>
        <span style={{ fontWeight: 600 }}>{presets[preset]}</span>
        <span style={{ opacity: 0.4, marginLeft: 10, fontStyle: 'italic', fontSize: 11 }}>— Modulation Preset</span>
      </div>
      <button onClick={() => setPreset(p => (p + 1) % presets.length)}
        style={navBtn}>›</button>
      <button onClick={() => setPreset(p => (p + 1) % presets.length)}
        style={navBtn}>››</button>

      <div style={{ flex: 1 }} />

      {/* LO/HI labels top-right, like Saturn */}
      <div style={{ display: 'flex', gap: 28, fontSize: 10, letterSpacing: '0.2em', opacity: 0.55 }}>
        <span>LOW</span>
        <span>HIGH</span>
      </div>
    </div>
  );
}

const navBtn = {
  width: 26, height: 24,
  background: 'rgba(255,255,255,0.04)',
  border: '1px solid rgba(255,255,255,0.06)',
  borderRadius: 3,
  color: '#a8b4c4', fontSize: 12,
  cursor: 'pointer',
};

// ——— LEFT SIDEBAR ———————————————————————————————————————————————
function SatLeftSidebar({ drive, setDrive }) {
  return (
    <div style={{
      padding: '18px 14px 14px',
      borderRight: '1px solid rgba(255,255,255,0.04)',
      background: 'rgba(255,255,255,0.015)',
    }}>
      <SatGlowKnob value={drive} onChange={setDrive} label="DRIVE"
        size={86} color="#4aa3ff" />
      <div style={{ height: 14 }} />
      <div style={{ display: 'flex', justifyContent: 'space-around' }}>
        <SatSmallKnob value={0.8} label="MIX" color="#4aa3ff" />
        <SatSmallKnob value={0.5} label="BAND" color="#4aa3ff" subtle />
      </div>
      <div style={{ height: 12 }} />
      <SatSmallKnob value={0.4} label="BANDWIDTH" color="#4aa3ff" subtle center />
    </div>
  );
}

function SatRightSidebar({ mix, setMix, bandwidth, setBandwidth, dynamics, setDynamics }) {
  return (
    <div style={{
      padding: '18px 14px 14px',
      borderLeft: '1px solid rgba(255,255,255,0.04)',
      background: 'rgba(255,255,255,0.015)',
    }}>
      <div style={{
        textAlign: 'right',
        fontSize: 10, letterSpacing: '0.2em', color: '#8794a6',
        marginBottom: 8,
      }}>WIDE</div>
      <SatGlowKnob value={mix} onChange={setMix} label="MIX" size={86} color="#a0b4cc" />
      <div style={{ height: 14 }} />
      <div style={{ display: 'flex', justifyContent: 'space-around' }}>
        <SatSmallKnob value={bandwidth} onChange={setBandwidth} label="BANDWIDTH" color="#a0b4cc" subtle />
        <SatSmallKnob value={dynamics} onChange={setDynamics} label="DYNAMICS" color="#a0b4cc" subtle />
      </div>
      <div style={{ height: 12 }} />
      <SatSmallKnob value={0.5} label="MIX" color="#a0b4cc" subtle center />
    </div>
  );
}

// ——— MAIN DISPLAY ———————————————————————————————————————————————
function SatDisplay({ bandColors, bands }) {
  // animated spectrum: bars whose heights wobble, with colored crossover vertical lines
  const [t, setT] = React.useState(0);
  React.useEffect(() => {
    let id; const loop = () => { setT(x => x + 1); id = requestAnimationFrame(loop); };
    id = requestAnimationFrame(loop); return () => cancelAnimationFrame(id);
  }, []);

  const W = 900, H = 260;
  // crossover x positions (log-ish)
  const crossovers = [0.18, 0.36, 0.56, 0.78];

  // generate spectrum bars
  const NUM_BARS = 80;
  const bars = Array.from({ length: NUM_BARS }, (_, i) => {
    const x = i / (NUM_BARS - 1);
    // base shape: louder bass, tapering off
    const base = Math.exp(-Math.pow((x - 0.3) * 2.4, 2)) * 0.85
               + Math.exp(-Math.pow((x - 0.55) * 3.2, 2)) * 0.55
               + Math.exp(-Math.pow((x - 0.82) * 4, 2)) * 0.32;
    const wobble = Math.sin(t * 0.05 + i * 0.6) * 0.08 + Math.sin(t * 0.11 + i * 1.3) * 0.05;
    const h = Math.max(0.04, Math.min(0.95, base + wobble));
    // color per band
    let color = bandColors[0];
    for (let c = 0; c < crossovers.length; c++) {
      if (x >= crossovers[c]) color = bandColors[c + 1];
    }
    return { x, h, color };
  });

  return (
    <div style={{
      position: 'relative',
      background: 'radial-gradient(ellipse at center, #0e1a2a 0%, #060a12 100%)',
      borderLeft: '1px solid rgba(255,255,255,0.03)',
      borderRight: '1px solid rgba(255,255,255,0.03)',
      boxShadow: 'inset 0 2px 12px rgba(0,0,0,0.55)',
      overflow: 'hidden',
    }}>
      <svg viewBox={`0 0 ${W} ${H}`} width="100%" height="260"
        preserveAspectRatio="none" style={{ display: 'block' }}>
        {/* freq gridlines */}
        <defs>
          <linearGradient id="satBarGrad" x1="0" y1="1" x2="0" y2="0">
            <stop offset="0" stopColor="currentColor" stopOpacity="0.15" />
            <stop offset="1" stopColor="currentColor" stopOpacity="0.9" />
          </linearGradient>
        </defs>

        {/* horizontal dB grid */}
        {[0.2, 0.4, 0.6, 0.8].map(y => (
          <line key={y} x1="0" x2={W} y1={y * H} y2={y * H}
            stroke="rgba(255,255,255,0.04)" strokeWidth="1" />
        ))}
        {/* vertical freq grid */}
        {[0.1, 0.25, 0.45, 0.7, 0.9].map(x => (
          <line key={x} x1={x * W} x2={x * W} y1="0" y2={H}
            stroke="rgba(255,255,255,0.04)" strokeWidth="1" />
        ))}

        {/* spectrum bars */}
        {bars.map((b, i) => {
          const bw = W / NUM_BARS - 1.2;
          const bx = b.x * (W - bw);
          const bh = b.h * (H * 0.78);
          return (
            <rect key={i} x={bx} y={H - bh - 16} width={bw} height={bh}
              fill={b.color} opacity="0.75"
              style={{ color: b.color }} />
          );
        })}

        {/* average-line curve overlay */}
        <path d={(() => {
          let d = `M 0 ${H}`;
          bars.forEach(b => { d += ` L ${b.x * W} ${H - b.h * H * 0.78 - 20}`; });
          d += ` L ${W} ${H} Z`;
          return d;
        })()} fill="rgba(180,210,240,0.06)" stroke="rgba(180,210,240,0.35)" strokeWidth="1" />

        {/* crossover dividers — colored vertical lines with diamond handles */}
        {crossovers.map((x, i) => (
          <g key={i}>
            <line x1={x * W} x2={x * W} y1="10" y2={H - 12}
              stroke={bandColors[i + 1]} strokeWidth="1.5" strokeDasharray="3 3" opacity="0.85" />
            <polygon points={`${x * W - 6},12 ${x * W},4 ${x * W + 6},12 ${x * W},20`}
              fill={bandColors[i + 1]} opacity="0.9" />
          </g>
        ))}

        {/* frequency labels at bottom */}
        {[
          { x: 0.08, l: '50' },
          { x: 0.22, l: '100' },
          { x: 0.38, l: '300' },
          { x: 0.55, l: '1k' },
          { x: 0.72, l: '3k' },
          { x: 0.88, l: '10k' },
        ].map(f => (
          <text key={f.l} x={f.x * W} y={H - 3}
            fill="rgba(180,210,240,0.35)" fontSize="10" textAnchor="middle"
            fontFamily="Inter, sans-serif">{f.l}Hz</text>
        ))}
      </svg>

      {/* band label pills above display */}
      <div style={{
        position: 'absolute', top: 6, left: 0, right: 0,
        display: 'flex', justifyContent: 'space-around',
        pointerEvents: 'none',
      }}>
        {['LOW', 'LO-MID', 'MID', 'HI-MID', 'HIGH'].map((lbl, i) => (
          <span key={lbl} style={{
            fontSize: 9, letterSpacing: '0.22em',
            color: bandColors[i], opacity: 0.85,
            textShadow: `0 0 6px ${bandColors[i]}80`,
          }}>{lbl}</span>
        ))}
      </div>
    </div>
  );
}

// ——— BAND COLUMN ———————————————————————————————————————————————
function SatBandColumn({ color, name, band, effectList, onChange, borderRight }) {
  return (
    <div style={{
      padding: '14px 14px 16px',
      borderRight: borderRight ? '1px solid rgba(255,255,255,0.05)' : 'none',
      position: 'relative',
    }}>
      {/* colored LED tab header */}
      <div style={{
        position: 'absolute', left: 14, right: 14, top: 0, height: 3,
        background: color,
        boxShadow: `0 0 10px ${color}90`,
      }}/>

      {/* three knobs row */}
      <div style={{ display: 'flex', justifyContent: 'space-around', marginTop: 10 }}>
        <SatSmallKnob value={band.drive} onChange={v => onChange({ drive: v })}
          label="DRIVE" color={color} size={50} />
        <SatSmallKnob value={band.feedback} onChange={v => onChange({ feedback: v })}
          label="FEEDBACK" color={color} size={50} />
        <SatSmallKnob value={band.mix} onChange={v => onChange({ mix: v })}
          label="MIX" color={color} size={50} />
      </div>

      {/* Band / Modulation / Type heading */}
      <div style={{
        display: 'grid', gridTemplateColumns: '1fr 1fr 1fr',
        marginTop: 14, marginBottom: 6,
        fontSize: 9, letterSpacing: '0.18em',
        color: '#8794a6', textAlign: 'center',
      }}>
        <span>BAND</span>
        <span>MODULATION</span>
        <span>TYPE</span>
      </div>

      {/* effect type list */}
      <div style={{
        background: 'rgba(0,0,0,0.28)',
        border: '1px solid rgba(255,255,255,0.04)',
        borderRadius: 3,
        padding: '6px 8px',
        display: 'flex', flexDirection: 'column', gap: 3,
      }}>
        {effectList.map((eff, i) => {
          const active = i === band.type;
          return (
            <button key={eff} onClick={() => onChange({ type: i })}
              style={{
                display: 'flex', justifyContent: 'space-between', alignItems: 'center',
                fontSize: 9.5, letterSpacing: '0.12em',
                padding: '2px 6px',
                background: active ? `${color}22` : 'transparent',
                border: active ? `1px solid ${color}66` : '1px solid transparent',
                color: active ? color : '#8794a6',
                borderRadius: 2,
                cursor: 'pointer',
                fontFamily: 'inherit',
                textAlign: 'left',
              }}>
              <span>{eff}</span>
              <span style={{
                width: 6, height: 6, borderRadius: '50%',
                background: active ? color : 'rgba(255,255,255,0.08)',
                boxShadow: active ? `0 0 4px ${color}` : 'none',
              }}/>
            </button>
          );
        })}
      </div>

      {/* band + modulation chips bottom */}
      <div style={{
        display: 'flex', justifyContent: 'space-between',
        marginTop: 8,
        fontSize: 8, letterSpacing: '0.18em', color: '#6b7688',
      }}>
        <span>BAND <span style={{ color: color, opacity: 0.75 }}>▼</span></span>
        <span>MOD <span style={{ opacity: 0.5 }}>—</span></span>
        <span style={{ color }}>{name}</span>
      </div>
    </div>
  );
}

// ——— FOOTER ———————————————————————————————————————————————
function SatFooter() {
  return (
    <div style={{
      height: 22,
      borderTop: '1px solid rgba(255,255,255,0.05)',
      background: 'linear-gradient(180deg, #0b0e14 0%, #070910 100%)',
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      padding: '0 14px',
      fontSize: 9, letterSpacing: '0.22em', color: '#4a5466',
    }}>
      <span>ME.SATURATOR · MULTIBAND SATURATION</span>
      <span>MENTESH ENGINEERING · HAND-TUNED</span>
    </div>
  );
}

// ——— RACK EARS ———————————————————————————————————————————————
function SatRackEars() {
  const ear = {
    position: 'absolute', top: 0, bottom: 0, width: 54,
    background: 'linear-gradient(90deg, #1a1a1e 0%, #0a0a0c 100%)',
    borderTop: '1px solid rgba(255,255,255,0.04)',
    borderBottom: '1px solid rgba(0,0,0,0.6)',
    display: 'flex', flexDirection: 'column',
    alignItems: 'center', justifyContent: 'space-between',
    padding: '16px 0',
  };
  const screw = (
    <div style={{
      width: 12, height: 12, borderRadius: '50%',
      background: 'radial-gradient(circle at 30% 30%, #7a7a7e, #2a2a2c 70%)',
      border: '1px solid #0a0a0c',
      position: 'relative',
    }}>
      <div style={{
        position: 'absolute', inset: 2,
        background: 'linear-gradient(45deg, transparent 45%, #0a0a0c 45%, #0a0a0c 55%, transparent 55%)',
      }}/>
    </div>
  );
  return (
    <>
      <div style={{ ...ear, left: 0 }}>{screw}{screw}{screw}{screw}</div>
      <div style={{ ...ear, right: 0 }}>{screw}{screw}{screw}{screw}</div>
    </>
  );
}

// ——— KNOBS ———————————————————————————————————————————————
function SatGlowKnob({ value, onChange, label, size = 80, color = '#4aa3ff' }) {
  const ref = React.useRef(null);
  const drag = React.useRef(null);
  const onDown = e => {
    drag.current = { y: e.clientY, v: value };
    window.addEventListener('mousemove', onMove);
    window.addEventListener('mouseup', onUp);
  };
  const onMove = e => {
    if (!drag.current || !onChange) return;
    const dy = drag.current.y - e.clientY;
    onChange(Math.max(0, Math.min(1, drag.current.v + dy / 180)));
  };
  const onUp = () => {
    drag.current = null;
    window.removeEventListener('mousemove', onMove);
    window.removeEventListener('mouseup', onUp);
  };
  const angle = -135 + value * 270;
  const arcSteps = 48;
  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 6 }}>
      <div ref={ref} onMouseDown={onDown}
        style={{
          width: size, height: size, position: 'relative',
          cursor: 'ns-resize',
        }}>
        {/* glowing outer arc */}
        <svg viewBox="0 0 100 100" style={{ position: 'absolute', inset: -4, width: size + 8, height: size + 8 }}>
          {Array.from({ length: arcSteps }, (_, i) => {
            const a = -135 + (i / (arcSteps - 1)) * 270;
            const lit = (i / (arcSteps - 1)) <= value;
            const r = 46, cx = 50, cy = 50;
            const rad = a * Math.PI / 180;
            const x1 = cx + Math.cos(rad) * (r - 4);
            const y1 = cy + Math.sin(rad) * (r - 4);
            const x2 = cx + Math.cos(rad) * r;
            const y2 = cy + Math.sin(rad) * r;
            return <line key={i} x1={x1} y1={y1} x2={x2} y2={y2}
              stroke={lit ? color : 'rgba(255,255,255,0.08)'}
              strokeWidth="1.5" strokeLinecap="round"
              style={lit ? { filter: `drop-shadow(0 0 3px ${color})` } : undefined} />;
          })}
        </svg>
        {/* knob body */}
        <div style={{
          position: 'absolute', inset: 12,
          borderRadius: '50%',
          background: `radial-gradient(circle at 30% 25%, #3a4556 0%, #1c2230 60%, #0e1320 100%)`,
          boxShadow: `inset 0 2px 4px rgba(255,255,255,0.1), inset 0 -3px 6px rgba(0,0,0,0.6), 0 0 16px ${color}40`,
          transform: `rotate(${angle}deg)`,
        }}>
          {/* tick */}
          <div style={{
            position: 'absolute', left: '50%', top: 6,
            width: 3, height: '28%', transform: 'translateX(-50%)',
            background: color, borderRadius: 2,
            boxShadow: `0 0 6px ${color}`,
          }}/>
          {/* center cap */}
          <div style={{
            position: 'absolute', inset: '30%',
            borderRadius: '50%',
            background: 'radial-gradient(circle at 35% 30%, #4a5668 0%, #1a2130 70%)',
          }}/>
        </div>
      </div>
      <span style={{
        fontSize: 9, letterSpacing: '0.22em', color: '#a8b4c4',
        fontFamily: 'inherit',
      }}>{label}</span>
    </div>
  );
}

function SatSmallKnob({ value, onChange, label, color = '#a0b4cc', size = 44, subtle = false, center = false }) {
  const drag = React.useRef(null);
  const onDown = e => {
    if (!onChange) return;
    drag.current = { y: e.clientY, v: value };
    window.addEventListener('mousemove', onMove);
    window.addEventListener('mouseup', onUp);
  };
  const onMove = e => {
    if (!drag.current || !onChange) return;
    const dy = drag.current.y - e.clientY;
    onChange(Math.max(0, Math.min(1, drag.current.v + dy / 160)));
  };
  const onUp = () => {
    drag.current = null;
    window.removeEventListener('mousemove', onMove);
    window.removeEventListener('mouseup', onUp);
  };
  const angle = -135 + value * 270;
  return (
    <div style={{
      display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4,
      margin: center ? '0 auto' : undefined,
    }}>
      <div onMouseDown={onDown} style={{
        width: size, height: size, position: 'relative',
        cursor: onChange ? 'ns-resize' : 'default',
      }}>
        {/* ring */}
        <svg viewBox="0 0 100 100" style={{ position: 'absolute', inset: 0, width: size, height: size }}>
          <circle cx="50" cy="50" r="46" fill="none"
            stroke="rgba(255,255,255,0.06)" strokeWidth="2" />
          {/* arc fill */}
          <circle cx="50" cy="50" r="46" fill="none"
            stroke={color} strokeWidth="2" strokeLinecap="round"
            strokeDasharray={`${value * 216} 999`}
            transform="rotate(135 50 50)"
            style={{ filter: subtle ? 'none' : `drop-shadow(0 0 3px ${color}80)`, opacity: subtle ? 0.7 : 1 }} />
        </svg>
        {/* body */}
        <div style={{
          position: 'absolute', inset: 8,
          borderRadius: '50%',
          background: 'radial-gradient(circle at 30% 25%, #2e3848 0%, #161c28 65%, #0a0e18 100%)',
          boxShadow: 'inset 0 1px 2px rgba(255,255,255,0.08), inset 0 -2px 3px rgba(0,0,0,0.6)',
          transform: `rotate(${angle}deg)`,
        }}>
          <div style={{
            position: 'absolute', left: '50%', top: 3,
            width: 2, height: '32%', transform: 'translateX(-50%)',
            background: color, borderRadius: 1,
            boxShadow: subtle ? 'none' : `0 0 3px ${color}`,
          }}/>
        </div>
      </div>
      <span style={{
        fontSize: 8.5, letterSpacing: '0.18em', color: '#8794a6',
        fontFamily: 'inherit',
      }}>{label}</span>
    </div>
  );
}

// expose to global scope for other bundles
Object.assign(window, { SaturationInsert });
